\(\renewcommand\AA{\unicode{x212B}}\)
ExtractFFTSpectrum v1¶
Summary¶
This algorithm performs a Fast Fourier Transform on each spectrum in a workspace, and from the result takes the indicated spectrum and places it into the OutputWorkspace, so that you end up with one result spectrum for each input spectrum in the same workspace.
See Also¶
Properties¶
Name |
Direction |
Type |
Default |
Description |
---|---|---|---|---|
InputWorkspace |
Input |
Mandatory |
The input workspace. |
|
InputImagWorkspace |
Input |
The optional input workspace for the imaginary part. |
||
FFTPart |
Input |
number |
2 |
Spectrum number, one of the six possible spectra output by the FFT algorithm |
OutputWorkspace |
Output |
Mandatory |
The output workspace. |
|
Shift |
Input |
number |
0 |
Apply an extra phase equal to this quantity times 2*pi to the transform |
AutoShift |
Input |
boolean |
False |
Automatically calculate and apply phase shift. Zero on the X axis is assumed to be in the centre - if it is not, setting this property will automatically correct for this. |
AcceptXRoundingErrors |
Input |
boolean |
False |
Continue to process the data even if X values are not evenly spaced |
Description¶
This algorithm iterates the FFT v1 algorithm on each spectrum of InputWorkspace, computing the Fourier Transform and storing the transformed spectrum in OutputWorkspace. If InputImagWorkspace is also passed, then the pair spectrum i of InputWorkspace (real) and spectrum i of InputImagWorkspace (real) are taken together as spectrum i of a complex workspace, on which FFT v1 is applied.
The FFTPart parameter specifies which transform is selected from the output of the FFT v1 algorithm:
For the case of input containing real and imaginary workspaces:
FFTPart |
Description |
---|---|
0 |
Complete real part |
1 |
Complete imaginary part |
2 |
Complete transform modulus |
For the case of input containing no imaginary workspace:
FFTPart |
Description |
---|---|
0 |
Real part, positive frequencies |
1 |
Imaginary part, positive frequencies |
2 |
Modulus, positive frequencies |
3 |
Complete real part |
4 |
Complete imaginary part |
5 |
Complete transform modulus |
Usage¶
Example - Extract FFT spectrum from an exponential and a gaussian.
import numpy
# Functions x and y defined over the time domain: z(t) = x(t) + i * y(t)
dt=0.001
t=numpy.arange(-1,1,dt)
# Exponential decay in [-1,1] for the real part
tau=0.05
x=numpy.exp(-numpy.abs(t)/tau)
wsx = CreateWorkspace(t,x)
# Gaussian decay in [-1,1] for the imaginary part
sigma=0.05
y=numpy.exp(-t*t/(2*sigma*sigma))
wsy = CreateWorkspace(t,y)
# Extract the FFT spectrum from z(t) = x(t) + i * y(t)
wsfr = ExtractFFTSpectrum(InputWorkspace=wsx, InputImagWorkspace=wsy, FFTPart=0) # real part
wsfi = ExtractFFTSpectrum(InputWorkspace=wsx, InputImagWorkspace=wsy, FFTPart=1) # imaginary
# Test the real part with a fitting to the expected Lorentzian
myFunc = 'name=Lorentzian,Amplitude=0.05,PeakCentre=0,FWHM=6,ties=(PeakCentre=0)'
fit_output = Fit(Function=myFunc, InputWorkspace='wsfr', StartX=-40, EndX=40, CreateOutput=1)
paramTable = fit_output.OutputParameters # table containing the optimal fit parameters
print("Theoretical FWHM = 1/(pi*tau)=6.367 -- Fitted FWHM value is: %.3f" % paramTable.column(1)[2])
# Test the imaginary part with a fitting to the expected Gaussian
myFunc = 'name=Gaussian,Height=0.1,PeakCentre=0,Sigma=3.0, ties=(PeakCentre=0)'
fit_output = Fit(Function=myFunc, InputWorkspace='wsfi', StartX=-15, EndX=15, CreateOutput=1)
paramTable = fit_output.OutputParameters
print("Theoretical Sigma = 1/(2*pi*sigma)=3.183 -- Fitted Sigma value is: %.3f" % paramTable.column(1)[2])
Output:
Theoretical FWHM = 1/(pi*tau)=6.367 -- Fitted FWHM value is: 6.367
Theoretical Sigma = 1/(2*pi*sigma)=3.183 -- Fitted Sigma value is: 3.183
Categories: AlgorithmIndex | Arithmetic\FFT
Source¶
C++ header: ExtractFFTSpectrum.h
C++ source: ExtractFFTSpectrum.cpp