\(\renewcommand\AA{\unicode{x212B}}\)
IntegratePeaksProfileFitting v1¶
Summary¶
Fits a series of peaks using 3D profile fitting as an Ikeda-Carpenter function by a bivariate gaussian.
Properties¶
Name |
Direction |
Type |
Default |
Description |
---|---|---|---|---|
OutputPeaksWorkspace |
Output |
Mandatory |
PeaksWorkspace with integrated peaks |
|
OutputParamsWorkspace |
Output |
Mandatory |
MatrixWorkspace with fit parameters |
|
InputWorkspace |
Input |
Mandatory |
An input Sample MDHistoWorkspace or MDEventWorkspace in HKL. |
|
PeaksWorkspace |
Input |
Mandatory |
PeaksWorkspace with peaks to be integrated. |
|
UBFile |
Input |
string |
File containing the UB Matrix in ISAW format. Leave blank to use loaded UB Matrix. Allowed extensions: [‘.mat’] |
|
ModeratorCoefficientsFile |
Input |
string |
File containing the Pade coefficients describing moderator emission versus energy. Allowed extensions: [‘.dat’] |
|
StrongPeakParamsFile |
Input |
string |
File containing strong peaks profiles. If left blank, strong peaks will be fit first. Allowed extensions: [‘.pkl’] |
|
IntensityCutoff |
Input |
number |
0 |
Minimum number of counts to force a profile |
EdgeCutoff |
Input |
number |
0 |
Pixels within EdgeCutoff from a detector edge will be have a profile forced. |
FracStop |
Input |
number |
0.05 |
Fraction of max counts to include in peak selection. |
MinpplFrac |
Input |
number |
0.9 |
Min fraction of predicted background level to check |
MaxpplFrac |
Input |
number |
1.1 |
Max fraction of predicted background level to check |
DQMax |
Input |
number |
0.15 |
Largest total side length (in Angstrom) to consider for profile fitting. |
PeakNumber |
Input |
number |
-1 |
Which Peak to fit. Leave negative for all. |
Description¶
This algorithm performs integration of single crystal Bragg peaks by fitting the intensity distribution as a 3D distribution made of an Ikeda-Carpenter function (TOF coordinate) and a bivariate Normal distribution.
Similar algorithms¶
See IntegratePeaksMD v2 or IntegrateEllipsoids v3 for peak-minus-background integration algorithms in reciprocal space.
Inputs¶
The algorithms takes two input workspaces:
A MDEventWorkspace containing the events in multi-dimensional space. This would be the output of ConvertToMD v1.
As well as a PeaksWorkspace containing single-crystal peak locations. This could be the output of FindPeaksMD v1 or PredictPeaks v1. All peaks should be from the same run.
The OutputPeaksWorkspace will contain a copy of the input PeaksWorkspace, with the integrated intensities and errors changed.
The OutputParamsWorkspace is a TableWorkspace containing the fit parameters. Peaks which could not be fit are omitted.
Instrument-Defined Parameters¶
In addition to the input parameters defined above, there are several other parameters to be aware of which are pre-defined for each instrument. The instrument is determined from the instrument that is loaded into PeaksWorkspace. If the instrument parameters file does not contain parameters, the algorithm defaults to MaNDi parameters. Default values are below:
Parameter |
Description |
MaNDi |
TOPAZ |
CORELLI |
---|---|---|---|---|
DQPixel |
The side length for each voxel used for fitting. Units: 1/Angstrom |
0.003 |
0.006 |
0.007 |
FracHKL |
The distance between peaks (in fraction of hkl) that is used for fitting. |
0.25 |
0.25 |
0.25 |
MinDtBinWidth |
The smallest time bin used for fitting the TOF profile Units: microseconds |
15 |
2 |
2 |
MaxDtBinWidth |
The largest time bin used for fitting the TOF profile Units: microseconds |
50 |
15 |
60 |
NTheta |
The number of bins along the scattering direction used for BVG fitting. |
50 |
50 |
50 |
NPhi |
The number of bins along the azimuthal direction used for BVG fitting. |
50 |
50 |
50 |
Calculations¶
This algorithm will fit a set of peaks in a PeaksWorkspace. The intensity profile is fit to an MDHisto workspace formed around the peak location.
Constructing the Measured Intensity Distribution¶
To construct the measured distribution to be fit, a histogram of events is made around the peak. This histogram is in (qx, qy, qz) and composed of voxels of side length DQPixel. To minimize the effect of neighboring peaks on profile fitting, the variable qMask is used to only consider a region around the peak in (h,k,l) space. It will filter voxels outside of (h ± FracHKL, k ± FracHKL, l ± FracHKL) from calculations used for profile fitting. In practice, values of 0.25 < fracHKL < 0.5 seem to work best.
Fitting the Time-of-Flight Coordinate¶
The time-of-flight (TOF), t, of each voxel is determined as:
The events are histogrammed by their t values to create a TOF profile. This profile can then be fit to the Ikeda Carpenter function. To separate the peak and background, different levels of intensity are filtered out. The predicted background level is determined as the average background not near the peak or off the edge and values within Minppl_frac and Maxppl_frac times the predicted value are tried. The best fit to the expected moderator emission (determined by the moderator coefficients defined in ModeratorCoefficientsFile) is taken and these voxels are considered to be signal.
Fitting the Non-TOF Coordinate¶
TOF goes as \(1/|\vec{q}|\) and so it is natural to use spherical coordinate. In that sense, the other two coordinates are \((q_{\theta} , q_{\phi_az})\) - along the scattering angle and azimuthal angle, respectively. From the MDHisto Workspace (filtered by qMask and using only the signal voxels from the TOF fight), a 2D histogram is constructed which is fit to a bivariate normal distribution. The histogram has NTheta \(\times\) NPhi bins.
For weak peaks or peaks near detector edges, the 2D histogram likely does not reflect the full profile. To address this, the profile of the nearest strong peaks is forced when doing the BVG fit. The profile is fit (allowed to vary 10% in \(\sigma_x, \sigma_y, \rho\) ) and location and amplitude are not fixed. Weak peaks are defined as peaks with fewer than IntensityCutoff counts from peak-minus-background integration or within EdgeCutoff pixels of the detector edge.
The strong peaks library can be generated in two ways. First, it can be provided as an input file through StrongPeakParamsFile. The StrongPeakParamsFile should be a .pkl file which contains a Numpy array containing the parameters used for strong peaks. Alternatively, if no file is provided, the algorithm will go through and fit strong peaks first, building the strong peaks library as it goes. After fitting all of the strong peaks, defined as peaks with spherical intensities above IntensityCutoff and further than EdgeCutoff pixels from the edge, it will fit weak peaks using those profiles. For initial guesses, the algorithm will fit the first 30 peaks using the instrument default parameters. After that, it will use already fit peaks to determine initial guesses.
Integrating the Model¶
The final intensity profile is given by
where \(A\) and \(B\) are scaling constants. Here the background is assumed to be constant \(B\) over the volume of the peak, so the model of the peak itself is \(Y_{model}(\vec{q}) = A \times Y_{TOF}(\vec{q}) \times Y_{BVG}(\vec{q})\). The peak intensity \(I\), is given by summing \(Y_{model}(\vec{q})\) over voxels which are greater than FracStop of the maximum.
\(\sigma(I)\) is given as
where the first two terms come from Poissionian statistics and the final term is the variance of the fit. Those sums are over the same voxels used to calculate intensity.
Usage¶
Example - IntegratePeaksProfileFitting
1Load(Filename='/SNS/MANDI/IPTS-8776/0/5921/NeXus/MANDI_5921_event.nxs', OutputWorkspace='MANDI_5921_event')
2MANDI_5921_md = ConvertToMD(InputWorkspace='MANDI_5921_event', QDimensions='Q3D', dEAnalysisMode='Elastic',
3 Q3DFrames='Q_lab', QConversionScales='Q in A^-1',
4 MinValues='-5, -5, -5', Maxvalues='5, 5, 5', MaxRecursionDepth=10,
5 LorentzCorrection=False)
6LoadIsawPeaks(Filename='/SNS/MANDI/shared/ProfileFitting/demo_5921.integrate', OutputWorkspace='peaks_ws')
7
8IntegratePeaksProfileFitting(OutputPeaksWorkspace='peaks_ws_out', OutputParamsWorkspace='params_ws',
9 InputWorkspace='MANDI_5921_md', PeaksWorkspace='peaks_ws',
10 UBFile='/SNS/MANDI/shared/ProfileFitting/demo_5921.mat', MinpplFrac=0.9, MaxpplFrac=1.1,
11 ModeratorCoefficientsFile='/SNS/MANDI/shared/ProfileFitting/franz_coefficients_2017.dat',
12 StrongPeakParamsFile='/SNS/MANDI/shared/ProfileFitting/strongPeakParams_beta_lac_mut_mbvg.pkl',
13 peakNumber=30)
Categories: AlgorithmIndex | Crystal\Integration
Source¶
Python: IntegratePeaksProfileFitting.py