\(\renewcommand\AA{\unicode{x212B}}\)
Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | InOut | MatrixWorkspace | Mandatory | Input signal workspace |
TofBinning | Input | dbl list | Mandatory | Min, Step, and Max of time-of-flight bins. Logarithmic binning is used if Step is negative. |
PreviousCalibrationFile | Input | string | Previous calibration file. Allowed extensions: [‘.h5’, ‘.cal’] | |
PreviousCalibrationTable | Input | TableWorkspace | Previous calibration table. This overrides results from previous file. | |
PeakFunction | Input | string | Gaussian | Allowed values: [‘BackToBackExponential’, ‘Gaussian’, ‘Lorentzian’, ‘PseudoVoigt’, ‘IkedaCarpenterPV’] |
BackgroundType | Input | string | Linear | Type of Background. Allowed values: [‘Flat’, ‘Linear’, ‘Quadratic’] |
PeakPositions | Input | dbl list | Mandatory | Comma delimited d-space positions of reference peaks. |
PeakWindow | Input | number | 0.1 | The maximum window (in d -pace) to the left and right of the nominal peak center to look for the peak |
PeakWidthPercent | Input | number | Optional | The estimated peak width as a percent of the peakcenter value, in d-spacing or TOF units. |
MinimumPeakHeight | Input | number | 2 | Minimum peak height such that all the fitted peaks with height under this value will be excluded. |
MaxChiSq | Input | number | 100 | Maximum chisq value for individual peak fit allowed. (Default: 100) |
ConstrainPeakPositions | Input | boolean | False | If true, peak centers will be constrained by estimated positions (highest Y value position) and the peak width will either be estimated by observation or calculated. |
CalibrationParameters | Input | string | DIFC | Select calibration parameters to fit. Allowed values: [‘DIFC’, ‘DIFC+TZERO’, ‘DIFC+TZERO+DIFA’] |
TZEROrange | Input | dbl list | Range for allowable TZERO from calibration (default is all) | |
DIFArange | Input | dbl list | Range for allowable DIFA from calibration (default is all) | |
UseChiSq | Input | boolean | False | By default the square of the peak height is used as weights in the least-squares fit to find the diffractometer constants, if UseChiSq is true then the inverse square of the error on the fitted peak centres will be used instead. |
OutputCalibrationTable | Output | TableWorkspace | Mandatory | Output table workspace containing the calibration |
DiagnosticWorkspaces | Output | WorkspaceGroup | Mandatory | Workspaces to promote understanding of calibration results |
This algorithm calibrates the detector pixels and creates a
diffraction calibration workspace. Unlike
CalibrateRectangularDetectors v1 the peak fitting and
calibration is done in TOF not d spacing. The peak d values are
converted to TOF based on either the old calibration or the instrument
geometry. The InputWorkspace
contains the data from a standard
sample. The results are then fitted with up to (in order) difc
,
t_zero
, and difa
. These values are described in detail
in AlignDetectors v1.
The peak fitting properties are explained in more detail in FitPeaks v1. This is used to perform a refinement of peaks using as much information as is provided as possible. Each input spectrum is calibrated separately following the same basic steps:
PeakPositions
are used to determine fit windows in combination with PeakWindow
. The windows are half the distance between the provided peak positions, with a maximum size of PeakWindow
.PeakWidthPercent
or by calculating the second moment of the data in the window.If more than one constant is requested, the result that has the lowest reduced chi-squared value is returned. This favors using less parameters.
A mask workspace is created, named “OutputCalibrationTable” + ‘_mask’, with uncalibrated pixels masked.
The resulting calibration table can be saved with
SaveDiffCal v1, loaded with LoadDiffCal v1 and
applied to a workspace with AlignDetectors v1. There are also
three workspaces placed in the DiagnosticWorkspace
group. They are:
_fitted
)_fitparam
)_dspacing
)_width
)_height
)_resolution
)Since multiple peak shapes can be used,
see the documentation for the individual fit functions to see how they relate to the effective
values displayed in the diagnostic tables. For Gaussian
and
Lorentzian
, the widths and resolution are converted to values that
can be directly compared with the results of
EstimateResolutionDiffraction v1.
Example - PDCalibration
# If you have an old calibration it can be used as the starting point
oldCal = 'NOM_calibrate_d72460_2016_05_23.h5'
# list of d values for diamond
dvalues = (0.3117,0.3257,0.3499,0.4205,0.4645,0.4768,0.4996,0.5150,0.5441,0.5642,0.5947,0.6307,.6866,.7283,.8185,.8920,1.0758,1.2615,2.0599)
LoadEventNexus(Filename='NOM_72460', OutputWorkspace='NOM_72460')
PDCalibration(InputWorkspace='NOM_72460',
TofBinning=[300,-.001,16666.7],
PreviousCalibrationFile=oldCal,
PeakPositions=dvalues,
PeakWidthPercent=.008,
OutputCalibrationTable='cal',
DiagnosticWorkspaces='diag')
# Print the result
print("The calibrated difc at detid {detid} is {difc}".format(**mtd['cal'].row(40000)))
Output:
The calibrated difc at detid 40896 is 5523.060327692842
Example - PDCalibration with BackToBackExponential fit function
The following example shows how to use PDCalibration with the BackToBackExponential fit function. The fit works best if sensible initial values for the parameters are specified in an instrument definition or parameter file (for more details, see the fitting parameters documentation):
Load(Filename=r'ENGINX00193749.nxs', OutputWorkspace='193749')
dpks = (1.913220892, 1.631600313,
1.562138267, 1.352851554, 1.104598643)
# initial values for GSAS parameters A, B, S are in ENGINX parameters .xml
# use log binning
PDCalibration(InputWorkspace='193749',
TofBinning=[10000,-0.0005,46000],
PeakPositions=dpks,
PeakWindow = 0.03,
MinimumPeakHeight = 0.5,
PeakFunction = 'BackToBackExponential',
CalibrationParameters = 'DIFC',
OutputCalibrationTable='cal_B2B_DIFC_chisqTrue',
DiagnosticWorkspaces = 'diag_B2B_DIFC_chisqTrue',
UseChiSq = True)
# Print the result
print("The calibrated difc at detid {detid} is {difc}".format(**mtd['cal_B2B_DIFC_chisqTrue'].row(1000)))
Output:
The calibrated difc at detid 108041 is 16834.952770921267
Categories: AlgorithmIndex | Diffraction\Calibration
C++ header: PDCalibration.h (last modified: 2021-05-06)
C++ source: PDCalibration.cpp (last modified: 2021-06-17)