EnggCalibrate v1

../_images/EnggCalibrate-v1_dlg.png

EnggCalibrate dialog.

Summary

Calibrates one or more detector banks (or group(s) of detectors) by performing single peak fitting.

Properties

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.

Description

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: Algorithms | Diffraction\Engineering

Usage

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, Zero1, 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, Zero2, 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=[Zero1, Zero2])

import math
Difa1 = int(math.floor(Difa1))
Difc1 = int(math.floor(Difc1))
Zero1 = int(math.floor(Zero1))
print "DIFA1: {0}".format(Difa1)
print "DIFC1: {0}".format(Difc1)
print "TZERO1: {0}".format(Zero1)
tbl = mtd[out_tbl_name]
print "The output table has {0} row(s)".format(tbl.rowCount())
print ("Parameters from the table, DIFC1: {0}, ZERO1: {1}".
       format(int(math.floor(tbl.cell(0,1))), int(math.floor(tbl.cell(0,2)))))
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
DIFC1: 18267
TZERO1: 277
The output table has 1 row(s)
Parameters from the table, DIFC1: 18267, ZERO1: 277
Output GSAS iparam file was written? True
Number of lines of the GSAS iparam file: 36