Skip to content

Commit

Permalink
Edited 2 more algorithms' doc. Refs #9573.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Jun 10, 2014
1 parent 83e08b2 commit c573622
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 8 deletions.
76 changes: 76 additions & 0 deletions Code/Mantid/docs/source/algorithms/ExtractMaskToTable-v1.rst
Expand Up @@ -32,4 +32,80 @@ and Xmax) in MaskTableWorkspace has higher priority, i.e., in the output
mask table workspace, the masked detector will be recorded in the row
copied from input MaskTableWrokspace.

Usage
-----

**Example - Extract mask to table without optional input table workspace:**

.. testcode:: ExHistSimple

# load data
dataws = LoadNexusProcessed(Filename="PG3_2538_2k.nxs")

# mask some detectors
for i in xrange(100):
dataws.maskDetectors(100+i)

# Run algorithm
outmaskws = ExtractMaskToTable(InputWorkspace=dataws, Xmin = 12300., Xmax = 24500.)

# Output
print "Number of rows: ", outmaskws.rowCount()
print "Row 0: Xmin = %.5f, Xmax = %.5f, DetectorIDsList = %s." % (outmaskws.cell(0, 0), outmaskws.cell(0, 1), outmaskws.cell(0, 2))

.. testcleanup:: ExHistSimple

DeleteWorkspace(dataws)
DeleteWorkspace(outmaskws)

Output:

.. testoutput:: ExHistSimple

Number of rows: 1
Row 0: Xmin = 12300.00000, Xmax = 24500.00000, DetectorIDsList = 27599-27698.

**Example - Extract mask to table with an optional input table workspace:**

.. testcode:: ExOptTable

# load data
dataws = LoadNexusProcessed(Filename="PG3_2538_2k.nxs")

# mask some detectors
for i in xrange(100):
dataws.maskDetectors(100+i)

# create a mask table workspacetws =
tws = CreateEmptyTableWorkspace()
tws.addColumn("double", "XMin")
tws.addColumn("double", "XMax")
tws.addColumn("str", "DetectorIDsList")
tws.addRow([10000, 20000, "10000"])
tws.addRow([12000, 20000, "20000, 20002-20004"])

# run algorithm
outmaskws = ExtractMaskToTable(InputWorkspace=dataws, MaskTableWorkspace=tws, Xmin = 12300., Xmax = 24500.)

# Write some result
print "Number of rows: ", outmaskws.rowCount()
print "Row 0: Xmin = %.5f, Xmax = %.5f, DetectorIDsList = %s." % (outmaskws.cell(0, 0), outmaskws.cell(0, 1), outmaskws.cell(0, 2))
print "Row 1: Xmin = %.5f, Xmax = %.5f, DetectorIDsList = %s." % (outmaskws.cell(1, 0), outmaskws.cell(1, 1), outmaskws.cell(1, 2))
print "Row 2: Xmin = %.5f, Xmax = %.5f, DetectorIDsList = %s." % (outmaskws.cell(2, 0), outmaskws.cell(2, 1), outmaskws.cell(2, 2))

.. testcleanup:: ExOptTable

DeleteWorkspace(dataws)
DeleteWorkspace(outmaskws)
DeleteWorkspace(tws)

Output:

.. testoutput:: ExOptTable

Number of rows: 3
Row 0: Xmin = 10000.00000, Xmax = 20000.00000, DetectorIDsList = 10000.
Row 1: Xmin = 12000.00000, Xmax = 20000.00000, DetectorIDsList = 20000, 20002-20004.
Row 2: Xmin = 12300.00000, Xmax = 24500.00000, DetectorIDsList = 27599-27698.

.. categories::
57 changes: 49 additions & 8 deletions Code/Mantid/docs/source/algorithms/SaveGSASInstrumentFile-v1.rst
Expand Up @@ -16,7 +16,7 @@ Supported peak profiles
#######################

- Time-of-flight back-to-back exponential convoluted with pseudo-voigt
(planned)
(in future)

- Fullprof: Profile 9;
- GSAS: Type 3 TOF profile.
Expand All @@ -33,7 +33,7 @@ Supported input Fullprof file
There can be several types of Fullprof files as the input file

- resolution file .irf (implemented)
- configuration file .pcr (planned)
- configuration file .pcr (in future)

Set up :math:`2\theta`
######################
Expand All @@ -42,9 +42,9 @@ There are several places in this algorithm that can set the value of
:math:`2\theta`. From the highest priority, here is the list how
:math:`2\theta` is set up.

| ``1. Algorithms' input property ``\ *``2Theta``*\ ``;``
| ``2. Either input TableWorkspace or input Fullprof resolution (.irf) file;``
| ``3. Hard coded default  ``\ :math:`2\theta`\ `` of a certain instrument.``
| ``1. Algorithms' input property ``\ *``2Theta``*\ ``;``
| ``2. Either input TableWorkspace or input Fullprof resolution (.irf) file;``
| ``3. Hard coded default ``\ :math:`2\theta`\ `` of a certain instrument.``
Set up :math:`L_1`
##################
Expand All @@ -53,10 +53,10 @@ There are 2 places in this algorithm that can set the value of
:math:`L_1`. From the highest priority, here is the list how
:math:`2\theta` is set up.

| ``1. Algorithms' input property ``\ *``L1``*\ ``;``
| ``2. Hard coded default  ``\ :math:`2\theta`\ `` of a certain instrument.``
| ``1. Algorithms' input property ``\ *``L1``*\ ``;``
| ``2. Hard coded default ``\ :math:`2\theta`\ `` of a certain instrument.``
Calculation of L2
Calculation of :math:`L_2`
#################

- If 2Theta (:math:`2\theta`) is given, L2 will be calculated from
Expand All @@ -68,4 +68,45 @@ Calculation of L2
- If "2Theta" (:math:`2\theta`) is not given, L2 will be read from user
input.

Usage
-----

**Example - save GSAS instrument file from a Fullprof .irf file:**

.. testcode:: ExHistSimple

# Run the algorithm to save for GSAS instrument file
SaveGSASInstrumentFile(InputFileName = "PG3_Bank1.irf", OutputFileName = "/tmp/PG3_Bank1.iparam",
BankIDs = 1, Instrument = "powgen", ChopperFrequency = "60",
IDLine = "60Hz 2011 Bank 1", Sample = "LaB6", L1 = 60.0, TwoTheta = 90.0)

# Load GSAS parameter files
gfile = open("/tmp/PG3_Bank1.iparam", "r")
lines = gfile.readlines()
gfile.close()

# Print out some result
print "Number of lines in GSAS instrument file: ", len(lines)
print "Line 0: ", lines[0].strip()
print "Line 1: ", lines[1].strip()
print "Line 2: ", lines[2].strip()
print "Line 3: ", lines[3].strip()
print "Line 305: ", lines[305].strip()

.. testcleanup:: ExHistSimple

import os
os.remove("/tmp/PG3_Bank1.iparam")

Output:

.. testoutput:: ExHistSimple

Number of lines in GSAS instrument file: 306
Line 0: 12345678901234567890123456789012345678901234567890123456789012345678
Line 1: ID 60Hz 2011 Bank 1
Line 2: INS BANK 1
Line 3: INS FPATH1 60.000000
Line 305: INS 1PAB590 0.00213 0.46016 1.99061 -3.12296

.. categories::
22 changes: 22 additions & 0 deletions Test/AutoTestData/UsageData/PG3_Bank1.irf
@@ -0,0 +1,22 @@
Instrumental resolution function for POWGEN/SNS J.P. Hodges 2011-09-02 ireso: 6
! To be used with function NPROF=10 in FullProf (Res=6)
! ---------------------------------------------- Bank 1 CWL = 0.5330A
! Type of profile function: back-to-back exponentials * pseudo-Voigt
NPROF 10
! Tof-min(us) step Tof-max(us)
TOFRG 2.2778326 0.005 46.76
! Zero Dtt1
ZD2TOF 0.455858968 22578.91315
! Zerot Dtt1t Dtt2t x-cross Width
ZD2TOT 154.8857664 22580.38612 1.906236992 0.01450292623 2.19006296
! TOF-TWOTH of the bank
TWOTH 90.807
! Sig-2 Sig-1 Sig-0
SIGMA 485.8251351 8.949421512e-05 0.4567565228
! Gam-2 Gam-1 Gam-0
GAMMA 0 0 0
! alph0 beta0 alph1 beta1
ALFBE 0.50235125 -0.35954019 0.0029061805 18.463782
! alph0t beta0t alph1t beta1t
ALFBT 29.805465 0.74465955 -3.5140123e-310 -0.35954019
END

0 comments on commit c573622

Please sign in to comment.