Table of Contents
Calibrates one or more detector banks (or group(s) of detectors) by performing single peak fitting.
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | Input | MatrixWorkspace | Mandatory | Workspace with the calibration run to use. |
ExpectedPeaks | Input | dbl list | 3.12428,2.7057,1.91322,1.6316,1.56214,1.35285,1.24146,1.21003,1.1046,1.04143,0.95661,0.914694,0.901901,0.855618,0.825232,0.8158,0.781069,0.757748,0.750427,0.72313,0.704505,0.676426,0.661108,0.656229,0.63774,0.624855,0.620731,0.605014 | A list of dSpacing values where peaks are expected. |
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’] | |
VanadiumWorkspace | Input | MatrixWorkspace | Workspace with the Vanadium (correction and calibration) run. Alternatively, when the Vanadium run has been already processed, the properties can be used | |
VanIntegrationWorkspace | Input | TableWorkspace | Results of integrating the spectra of a Vanadium run, with one column (integration result) and one row per spectrum. This can be used in combination with OutVanadiumCurveFits from a previous execution and VanadiumWorkspace to provide pre-calculated values for Vanadium correction. | |
VanCurvesWorkspace | Input | MatrixWorkspace | A workspace2D with the fitting workspaces corresponding to the instrument banks. This workspace has three spectra per bank, as produced by the algorithm Fit. This is meant to be used as an alternative input VanadiumWorkspace for testing and performance reasons. If not given, no workspace is generated. | |
Bank | Input | string | Which bank to calibrate. It can be specified as 1 or 2, or equivalently, North or South. See also SpectrumNumbers for a more flexible alternative to select specific detectors. Allowed values: [‘’, ‘North’, ‘South’, ‘Both: North, South’, ‘1’, ‘2’] | |
SpectrumNumbers | Input | string | Sets the spectrum numbers for the detectors that should be considered in the calibration (all others will be ignored). This option cannot be used together with Bank, as they overlap. You can give multiple ranges, for example: “0-99”, or “0-9, 50-59, 100-109”. | |
DetectorPositions | Input | TableWorkspace | Calibrated detector positions. If not specified, default ones (from the current instrument definition) are used. | |
OutputParametersTableName | Input | string | Name for a table workspace with the calibration parameters calculated from this algorithm: difc and zero parameters for GSAS. these two parameters are added as two columns in a single row. If not given, no table is generated. | |
DIFA | Output | number | Calibration parameter DIFA for the bank or range of pixels/detectors given | |
DIFC | Output | number | Calibration parameter DIFC for the bank or range of pixels/detectors given | |
TZERO | Output | number | Calibration parameter TZERO for the bank or range of pixels/detectors given | |
FittedPeaks | Output | TableWorkspace | Mandatory | Information on fitted peaks as produced by the (child) algorithm EnggFitPeaks. |
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.
Utilises EnggFocus v1 which performs a TOF to dSpacing conversion using calibrated pixel positions, focuses the values in dSpacing and then converts them back to TOF. EnggFocus v1 also perform corrections with Vanadium data.
Then this algorithm calls EnggFitPeaks v1 (as a child algorithm) which through a sequence of peak fits determines a linear relationship between dSpacing and measured TOF values in terms of DIFA, DIFC and TZERO values and provides the these parameters to the Calibrate algorithm.
This algorithm provides an indirect calibration of the sample position, that is, a calibration returned in terms of DIFA, DIFC and ZERO rather than an actual new sample position (hence the reason for ‘indirect’).
The parameters DIFA, DIFC and ZERO are returned and can be retrieved as output properties as well. If a name is given in OutputParametersTableName the algorithm also produces a table workspace with that name, containing the two output parameters. Presently the DIFA parameter is always set to zero (see EnggFitDIFCFromPeaks v1).
The script EnggUtils included with Mantid can produce a GSAS parameters file for the ENGIN-X instrument, given the DIFC and ZERO parameters for the instrument banks as produced by EnggCalibrate. This can be done with the write_ENGINX_GSAS_iparam_file() function as shown in the usage example below.
See the algorithm EnggFocus v1 for details on the Vanadium corrections.
Categories: Algorithm Index | Diffraction\Engineering
Python: EnggCalibrate.py (last modified: 2018-10-05)
Note
To run these usage examples please first download the usage data, and add these to your path. In MantidPlot this is done using Manage User Directories.
Example - Calculate Difc and Zero for EnginX:
out_tbl_name = 'out_params'
ws_name = 'test_engg_data'
Load('ENGINX00213855.nxs', OutputWorkspace=ws_name)
# Using precalculated Vanadium corrections. To calculate from scrach see EnggVanadiumCorrections
van_integ_ws = Load('ENGINX_precalculated_vanadium_run000236516_integration.nxs')
van_curves_ws = Load('ENGINX_precalculated_vanadium_run000236516_bank_curves.nxs')
difa1, difc1, tzero1, peaks1 = EnggCalibrate(InputWorkspace=ws_name,
VanIntegrationWorkspace=van_integ_ws,
VanCurvesWorkspace=van_curves_ws,
ExpectedPeaks=[1.28, 2.1], Bank='1',
OutputParametersTableName=out_tbl_name)
difa1, difc2, tzero2, peaks2 = EnggCalibrate(InputWorkspace=ws_name,
VanIntegrationWorkspace=van_integ_ws,
VanCurvesWorkspace=van_curves_ws,
ExpectedPeaks=[1.28, 2.1], Bank='2')
# You can produce an instrument parameters (iparam) file for GSAS.
# Note that this is very specific to ENGIN-X
GSAS_iparm_fname = 'ENGIN_X_banks.prm'
import EnggUtils
EnggUtils.write_ENGINX_GSAS_iparam_file(GSAS_iparm_fname, bank_names=['North', 'South'],
difc=[difc1, difc2], tzero=[tzero1, tzero2])
import math
print("DIFA1: {0}".format(difa1))
delta = 2
approx_difc1 = 18267
difc1_ok = abs(difc1 - approx_difc1) <= delta
print("DIFC1 is approximately (+/- {0}) {1}: {2}".format(delta, approx_difc1, difc1_ok))
approx_tzero1 = 277
tzero1_ok = abs(tzero1 - approx_tzero1) <= delta
print("TZERO1 is approximately (+/- {0}) {1}: {2}".format(delta, approx_tzero1, tzero1_ok))
tbl = mtd[out_tbl_name]
tbl_values_ok = (abs(tbl.cell(0,1) - approx_difc1) <= delta) and (abs(tbl.cell(0,2) - approx_tzero1) <= delta)
print("The output table has {0} row(s) and its values are as expected: {1}".format(tbl.rowCount(),
tbl_values_ok))
import os
print("Output GSAS iparam file was written? {0}".format(os.path.exists(GSAS_iparm_fname)))
print("Number of lines of the GSAS iparam file: {0}".format(sum(1 for line in open(GSAS_iparm_fname))))
Output:
DIFA1: 0.0
DIFC1 is approximately (+/- 2) 18267: True
TZERO1 is approximately (+/- 2) 277: True
The output table has 1 row(s) and its values are as expected: True
Output GSAS iparam file was written? True
Number of lines of the GSAS iparam file: 36