Table of Contents
The algorithm fits an expected diffraction pattern to a workpace spectrum by performing single peak fits.
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | Input | MatrixWorkspace | Mandatory | Workspace to fit peaks in. ToF is expected X unit. |
WorkspaceIndex | Input | number | 0 | Index of the spectra to fit peaks in |
ExpectedPeaks | Input | dbl list | 3.1243,2.7057,1.9132,1.6316,1.5621,1.3529,1.2415,1.21,1.1046,1.0414,0.9566,0.9147,0.9019,0.8556,0.8252,0.8158,0.7811 | A list of dSpacing values to be translated into TOF to find expected peaks. |
ExpectedPeaksFromFile | Input | string | Load from file a list of dSpacing values to be translated into TOF to find expected peaks. This takes precedence over ‘ExpectedPeaks’ if both options are given. Allowed extensions: [‘.csv’] | |
OutParametersTable | Input | string | Name for a table workspace with the fitted values calculated by this algorithm (Difc and Zero parameters) for GSAS. These two parameters are added as two columns in a single row. If not given, the table workspace is not created. | |
OutFittedPeaksTable | Input | string | Name for a table workspace with the parameters of the peaks found and fitted. If not given, the table workspace is not created. | |
Difc | Output | number | Fitted Difc value | |
Zero | Output | number | Fitted Zero value |
Warning
This algorithm is being developed for a specific instrument. It might get changed or even removed without a notification, should instrument scientists decide to do so.
The pattern is specified by providing a list of dSpacing values where Bragg peaks are expected. The algorithm then fits peaks in those areas using a peak fitting function. The dSpacing values for ExpectedPeaks are then converted to time-of-flight (TOF) (as in the Mantid ConvertUnits algorithm).
These values are used as start peak position in fit. It is these adjusted peak TOF value positions that are fitted against ExpectedPeaks dSpacing values according to:
ZERO and Difc can then be used within the GSAS program. The parameters DIFC and ZERO are returned and can be retrieved as output properties as well.
If a name is given in OutParametersTable this algorithm also produces a table workspace with that name, containing the two fitted (DIFC, ZERO) parameters. Also, if a name is given in OutFittedPeaksTable, the algorithm produces a table workspace with information about the peaks fitted. The table has one row per peak and several columns for the different fitted parameters (and the errors of these parameters).
Example - Fitting two peaks:
# Two B2B peaks
peak1 = "name=BackToBackExponential,I=4000,A=1,B=0.5,X0=12000,S=350"
peak2 = "name=BackToBackExponential,I=5000,A=1,B=0.7,X0=35000,S=300"
# Create workpsace with the above peaks and a single detector pixel
ws = CreateSampleWorkspace(Function="User Defined",
UserDefinedFunction=peak1 + ";" + peak2,
NumBanks=1,
BankPixelWidth=1,
XMin=6000,
XMax=45000,
BinWidth=10)
# Update instrument geometry to something that would allow converting to some sane dSpacing values
EditInstrumentGeometry(Workspace = ws, L2 = [1.5], Polar = [90], PrimaryFlightPath = 50)
# Run the algorithm. Defaults are shown below. Files entered must be in .csv format and if both ExpectedPeaks and ExpectedPeaksFromFile are entered, the latter will be used.
# difc, zero = EnggXFitPeaks(InputWorkspace = No default, WorkspaceIndex = None, ExpectedPeaks=[0.6, 1.9], ExpectedPeaksFromFile=None)
out_tbl_name = 'out_params'
difc, zero = EnggFitPeaks(ws, 0, [0.65, 1.9], OutParametersTable=out_tbl_name)
# Print the results
print "Difc: %.1f" % difc
print "Zero: %.1f" % zero
tbl = mtd[out_tbl_name]
print "The output table has %d row(s)" % tbl.rowCount()
print "Parameters from the table, Difc: %.1f, Zero: %.1f" % (tbl.cell(0,0), tbl.cell(0,1))
Output:
Difc: 18400.0
Zero: 46.0
The output table has 1 row(s)
Parameters from the table, Difc: 18400.0, Zero: 46.0
Categories: Algorithms | Diffraction | Engineering | PythonAlgorithms
Python: EnggFitPeaks.py