\(\renewcommand\AA{\unicode{x212B}}\)
DeltaPDF3D v1¶
Summary¶
Calculates the 3DdeltaPDF from a HKL workspace
Properties¶
Name 
Direction 
Type 
Default 
Description 

InputWorkspace 
Input 
IMDHistoWorkspace 
Mandatory 
Input Workspace with HKL dimensions centered on zero. 
IntermediateWorkspace 
Output 
The resulting workspace after reflection removal and filters applied. What is the input of the FFT. 

OutputWorkspace 
Output 
Mandatory 
Output Workspace 

Method 
Input 
string 
KAREN 
Bragg peak removal method. Allowed values: [‘None’, ‘Punch and fill’, ‘KAREN’] 
WindowFunction 
Input 
string 
Blackman 
Apply a window function to the data. Allowed values: [‘None’, ‘Gaussian’, ‘Blackman’, ‘Tukey’, ‘Kaiser’] 
WindowParameter 
Input 
number 
0.5 
Parameter for window function, depends on window type, see algorithm docs 
Shape 
Input 
string 
sphere 
Shape to punch out reflections. Allowed values: [‘sphere’, ‘cube’] 
Size 
Input 
dbl list 
0.2 
Width of cube/diameter of sphere used to remove reflections, in (HKL) (one or three values) 
SpaceGroup 
Input 
string 
Space group for reflection removal, either full name or number. If empty all HKL’s will be removed. 

Convolution 
Input 
boolean 
True 
Apply convolution to fill in removed reflections 
ConvolutionWidth 
Input 
number 
2 
Width of gaussian convolution in pixels 
CropSphere 
Input 
boolean 
False 
Limit min/max q values. Can help with edge effects. 
SphereMin 
Input 
dbl list 
Optional 
HKL values below which will be removed (one or three values) 
SphereMax 
Input 
dbl list 
Optional 
HKL values above which will be removed (one or three values) 
FillValue 
Input 
number 
Optional 
Value to replace with outside sphere 
KARENWidth 
Input 
number 
7 
Size of filter window 
Description¶
Calculates the 3DΔPDF [1] from a HKL MDHistoWorkspace. This algorithm can remove the Bragg peaks by either the punchandfill method [2] or the KAREN algorithm.
This algorithm is still in development and features may be added, removed or changed. The scale of the resulting 3DΔPDF is, as yet, not scaled correctly, so while the magnitude is not correct the sign should be.
The input workspace must be a MDHistoWorkspace with dimensions ‘[H,0,0]’, ‘[0,K,0]’ and ‘[0,0,L]’, The dimensions must be centered on zero.
Peak removal¶
Two method are available to remove the Bragg peaks.
Punchandfill¶
The punchandfill method is described in [2]. Basically it will punch out a volume of reciprocal space of shape defined by the property Shape and Size. After punchandfill the removed Bragg peaks are filled back in by applying a Gaussian convolution.
The convolution option requires astropy to be installed as it uses astropy.convolution. The convolution can be very slow for large workspaces, it will attempt to use astropy.convolution.convolve_fft (which is fast but only works for small workspace) but will use astropy.convolution.convolve (which is slow) if the workspace is too large.
KAREN¶
The KAREN (Kspace Algorithmic REconstructioN) method [3], is a more advanced approach that applies a filter over the data removing any points that are outliers in a moving window, with width set by the property KARENWidth. Outliers are defined as values more than 3 sigma away from the median. Sigma is estimated using 1.4826*MAD (median absolute deviation). Outliers are replaced with a value of median+2.2*MAD of window.
Window function¶
A window function can be applied to the volume that will produce a smooth transition to zero and you approach the edge of the data.
Currently implemented functions are Blackman (numpy.blackman()
,
default), Gaussian (scipy.signal.windows.gaussian()
), Tukey
(scipy.signal.windows.tukey()
) and Kaiser (numpy.kaiser()
)
The WindowParameter allows you to define the Gaussian window sigma, the Tukey window alpha and the Kaiser window beta.
References¶
Usage  PunchandFill¶
The example here is MDHistoWorkspace that corresponds to negative substitutional correlation in the [100] direction. If you just run it without any alterations to the workspace the 3DΔPDF will be dominated by the Bragg peaks and will just be a 3DPDF instead.
DeltaPDF3D(InputWorkspace='DeltaPDF3D_MDH',OutputWorkspace='fft',
Method='None', WindowFunction='None')
print("The value at [1,0,0] is {:.4f}".format(mtd['fft'].signalAt(1866)))
print("The value at [0,1,0] is {:.4f}".format(mtd['fft'].signalAt(2226)))
The value at [1,0,0] is 4042.2047
The value at [0,1,0] is 5539.0284
The results 3DΔPDF workspace looks like
Starting workspace 
Resulting 3DPDF 
Removing Reflections
To get a ΔPDF you need to remove the Bragg peaks. If we now remove the reflections you will see that negative value at [±1,0,0].
The IntermediateWorkspace shows the changes to the input workspace.
DeltaPDF3D(InputWorkspace='DeltaPDF3D_MDH',OutputWorkspace='fft2',IntermediateWorkspace='int2',
Method='Punch and fill',Size=0.3,Convolution=False, WindowFunction='None')
print("The value at [1,0,0] is {:.4f}".format(mtd['fft2'].signalAt(1866)))
print("The value at [0,1,0] is {:.4f}".format(mtd['fft2'].signalAt(2226)))
The value at [1,0,0] is 754.4627
The value at [0,1,0] is 742.3611
Intermediate workspace after reflections removed 
Resulting 3DΔPDF 
Removing Reflections and crop to sphere
DeltaPDF3D(InputWorkspace='DeltaPDF3D_MDH',OutputWorkspace='fft3',IntermediateWorkspace='int3',
Method='Punch and fill',Size=0.3,CropSphere=True,SphereMax=3,Convolution=False, WindowFunction='None')
print("The value at [1,0,0] is {:.4f}".format(mtd['fft3'].signalAt(1866)))
print("The value at [0,1,0] is {:.4f}".format(mtd['fft3'].signalAt(2226)))
The value at [1,0,0] is 501.2694
The value at [0,1,0] is 493.9502
Intermediate workspace after reflections removed and crop to sphere 
Resulting 3DΔPDF 
Removing Reflections and crop to sphere with fill value The fill value should be about the background level
DeltaPDF3D(InputWorkspace='DeltaPDF3D_MDH',OutputWorkspace='fft3',IntermediateWorkspace='int3',
Method='Punch and fill',Size=0.3,CropSphere=True,SphereMax=3,Convolution=False, WindowFunction='None')
print("The value at [1,0,0] is {:.4f}".format(mtd['fft3'].signalAt(1866)))
print("The value at [0,1,0] is {:.4f}".format(mtd['fft3'].signalAt(2226)))
The value at [1,0,0] is 501.2694
The value at [0,1,0] is 493.9502
Intermediate workspace after reflections removed and crop to sphere 
Resulting 3DΔPDF 
Applying convolution
DeltaPDF3D(InputWorkspace='DeltaPDF3D_MDH',OutputWorkspace='fft4',IntermediateWorkspace='int4',
Method='Punch and fill',Size=0.3,CropSphere=True,SphereMax=3,Convolution=True, WindowFunction='None')
print("The value at [1,0,0] is {:.4f}".format(mtd['fft4'].signalAt(1866)))
print("The value at [0,1,0] is {:.4f}".format(mtd['fft4'].signalAt(2226)))
The value at [1,0,0] is 47.1984
The value at [0,1,0] is 44.3406
Intermediate workspace after convolution is applied 
Resulting 3DΔPDF 
Usage  KAREN¶
DeltaPDF3D(InputWorkspace='DeltaPDF3D_MDH',OutputWorkspace='fft',IntermediateWorkspace='int',KARENWidth=3)
print("The value at [1,0,0] is {:.4f}".format(mtd['fft'].signalAt(1866)))
print("The value at [0,1,0] is {:.4f}".format(mtd['fft'].signalAt(2226)))
The value at [1,0,0] is 31.3149
The value at [0,1,0] is 31.3080
Intermediate workspace after KAREN and window function applied 
Resulting 3DΔPDF 
Categories: AlgorithmIndex  Diffraction\Utility
Source¶
Python: DeltaPDF3D.py