\(\renewcommand\AA{\unicode{x212B}}\)
IntegratePeaks1DProfile v1¶
Summary¶
Integrate singlecrystal Bragg peaks in MatrixWorkspaces by fitting peaks TOF in adjacent pixels unitl I/sigma of the peak in a pixel is below a threshold. Algorithm is adapted and extendedfrom an algorithm in Gutmann, M. J. (2005). SXD2001. ISIS Facility, RAL
See Also¶
Properties¶
Name 
Direction 
Type 
Default 
Description 

InputWorkspace 
Input 
Mandatory 
A MatrixWorkspace to integrate (xaxis must be TOF). 

PeaksWorkspace 
Input 
IPeaksWorkspace 
Mandatory 
A PeaksWorkspace containing the peaks to integrate. 
OutputWorkspace 
Output 
IPeaksWorkspace 
Mandatory 
The output PeaksWorkspace will be a copy of the input PeaksWorkspace with the integrated intensities. 
NRows 
Input 
number 
11 
Number of row components in the detector to use in the convolution kernel. For WISH row components correspond to pixels along a single tube. 
NCols 
Input 
number 
11 
Number of column components in the detector to use in the convolution kernel. For WISH column components correspond to tubes. 
NBins 
Input 
number 
11 
Number of TOF bins to use in the convolution kernel. 
GetNBinsFromBackToBackParams 
Input 
boolean 
False 
If true the number of TOF bins used in the convolution kernel will be calculated from the FWHM of the BackToBackExponential peak using parameters defined in the instrument parameters.xml file. 
NFWHM 
Input 
number 
10 
If GetNBinsFromBackToBackParams=True then the number of TOF bins will be NFWHM x FWHM of the BackToBackExponential at the peak detector and TOF. 
CostFunction 
Input 
string 
Mandatory 
Cost funtion to minimise. Allowed values: [‘RSq’, ‘ChiSq’, ‘Poisson’] 
PeakFunction 
Input 
string 
BackToBackExponential 
Peak profile funtion to fit. Allowed values: [‘BackToBackExponential’, ‘Gaussian’] 
FixPeakParameters 
Input 
str list 
Peak parameters to fix in the fits (recommend fixing A for backtoback exponential based functions). 

BackgroundFunction 
Input 
string 
FlatBackground 
Background function to fit. Allowed values: [‘FlatBackground’, ‘LinearBackground’] 
ErrorStrategy 
Input 
string 
Summation 
If Hessian then error on the integrated intensity will be determined from the partial derivatives of the costfunction wrt the parameters (this is only supported for BackToBackExponential function for which the integrated intensity is a parameter. If Summation then the error will be the quadrature sum of the individual errors. Allowed values: [‘Hessian’, ‘Summation’] 
IOverSigmaThreshold 
Input 
number 
2.5 
Criterion to stop fitting. 
FractionalChangeDSpacing 
Input 
number 
0.02 
Fractional change in peak centre allowed  this is a constraint in the fit. 
IntegrateIfOnEdge 
Input 
boolean 
False 
If IntegrateIfOnEdge=False then peaks on the detector edge will not be integrated. 
NRowsEdge 
Input 
number 
1 
Shoeboxes containing detectors NRowsEdge from the detector edge are defined as on the edge. 
NColsEdge 
Input 
number 
1 
Shoeboxes containing detectors NColsEdge from the detector edge are defined as on the edge. 
LorentzCorrection 
Input 
boolean 
True 
Correct the integrated intensity by multiplying by the Lorentz factor sin(theta)^2 / lambda^4  do not do this if the data have already been corrected. 
OutputFile 
Input 
string 
Optional file path in which to write diagnostic plots (note this will slow the execution of algorithm). Allowed extensions: [‘.pdf’] 
Description¶
This is an algorithm to integrate singlecrystal Bragg peaks in a MatrixWorkspace with xunits of TimeofFlight (TOF). It is adapted and extended from an algorithm in SXD2001 [1].
The algorithm proceeds by fitting a PeakFunction
and BackgroundFunction
to the TOF spectrum of individual
pixels. If the fit is successful (fit converged and the ratio of intensity/sigma > IOverSigmaThreshold
), then the
fit is attempted on a pixel that is adjacent to a previously successfully fit pixel. The algorithm stops
when no adjacent pixels can be successfully fitted.
The algorithm requires the user to define the number of pixels in the vicinity of a peak using the input NRows
and NCols
and the TOF extent of the data to fit, which can be specified in one of two ways:
Provide
NBins
directly  number of TOF bins in the kernelSetting
GetNBinsFromBackToBackParams=True
and providingNFWHM
 in which caseNBins
will be NFWHM x FWHM of a BackToBackExponential peak at the center of each detector panel/bank at the middle of the spectrum.
Note to use method 2, backtoback exponential coefficients must be defined in the Parameters.xml file for the instrument.
Optionally if OutputFile
is provided a pdf can be output that shows the shoebox kernel and the data integrated along
each dimension like so
Usage¶
Example  IntegratePeaks1DProfile
from mantid.simpleapi import *
Load(Filename="SXD23767.raw", OutputWorkspace="SXD23767")
CreatePeaksWorkspace(InstrumentWorkspace="SXD23767", NumberOfPeaks=0, OutputWorkspace="peaks")
AddPeak(PeaksWorkspace="peaks", RunWorkspace="SXD23767", TOF=8303.3735339704781, DetectorID=7646)
peaks_out = IntegratePeaks1DProfile(InputWorkspace="SXD23767", PeaksWorkspace="peaks", OutputWorkspace="peaks_int",
GetNBinsFromBackToBackParams=True, NFWHM=6, CostFunction="Poisson",
PeakFunction="BackToBackExponential", FixPeakParameters='A',
FractionalChangeDSpacing=0.01, IntegrateIfOnEdge=True)
print(f"I/sigma = {peaks_out.getPeak(0).getIntensityOverSigma():.2f}")
Output:
I/sigma = 92.97
References¶
Categories: AlgorithmIndex  Diffraction\Reduction
Source¶
Python: IntegratePeaks1DProfile.py