ExtractFFTSpectrum v1

../_images/ExtractFFTSpectrum-v1_dlg.png

ExtractFFTSpectrum dialog.

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.

Properties

Name Direction Type Default Description
InputWorkspace Input MatrixWorkspace Mandatory The input workspace.
InputImagWorkspace Input MatrixWorkspace   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 MatrixWorkspace Mandatory The output workspace.

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.

from __future__ import print_function
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++ source: ExtractFFTSpectrum.cpp (last modified: 2019-07-17)

C++ header: ExtractFFTSpectrum.h (last modified: 2018-10-05)