Class FFT
java.lang.Object
org.eclipse.dawnsci.analysis.dataset.impl.FFT
Class to hold methods to compute discrete Fourier transforms
Emulates numpy.fft
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.january.dataset.DatasetextendWithPad(org.eclipse.january.dataset.Dataset input, int[] newShape, Object padValue) Pad out dataset to new shape with the provided padValue.static org.eclipse.january.dataset.Datasetfft(org.eclipse.january.dataset.Dataset a) forward 1D fast Fourier transformstatic org.eclipse.january.dataset.Datasetfft(org.eclipse.january.dataset.Dataset a, int n, int axis) forward 1D fast Fourier transformstatic org.eclipse.january.dataset.Datasetfft2(org.eclipse.january.dataset.Dataset a, int[] s, int[] axes) forward 2D fast Fourier transformstatic org.eclipse.january.dataset.Datasetfftn(org.eclipse.january.dataset.Dataset a, int[] s, int[] axes) forward nD fast Fourier transformstatic org.eclipse.january.dataset.Datasetfftshift(org.eclipse.january.dataset.Dataset a, int[] axes) Shift zero-frequency component to centre of datasetstatic org.eclipse.january.dataset.Datasetifft(org.eclipse.january.dataset.Dataset a) inverse 1D fast Fourier transformstatic org.eclipse.january.dataset.Datasetifft(org.eclipse.january.dataset.Dataset a, int n, int axis) inverse 1D fast Fourier transformstatic org.eclipse.january.dataset.Datasetifft2(org.eclipse.january.dataset.Dataset a, int[] s, int[] axes) inverse 2D fast Fourier transformstatic org.eclipse.january.dataset.Datasetifftn(org.eclipse.january.dataset.Dataset a, int[] s, int[] axes) inverse nD fast Fourier transformstatic org.eclipse.january.dataset.Datasetifftshift(org.eclipse.january.dataset.Dataset a, int[] axes) Reverse shift of zero-frequency component to centre of datasetstatic org.eclipse.january.dataset.DatasetsampleFrequencies(int n, double d) Discrete FFT sample frequenciesstatic org.eclipse.january.dataset.Datasetshift(org.eclipse.january.dataset.Dataset input, boolean forward) Shift frequency componentsstatic org.eclipse.january.dataset.DatasetzeroPad(org.eclipse.january.dataset.Dataset input, int[] newShape, boolean inFreqSpace) Pad out dataset to new shape with zeros.
-
Constructor Details
-
FFT
public FFT()
-
-
Method Details
-
fft
public static org.eclipse.january.dataset.Dataset fft(org.eclipse.january.dataset.Dataset a) forward 1D fast Fourier transform- Parameters:
a- dataset- Returns:
- new dataset holding transform
-
fft
public static org.eclipse.january.dataset.Dataset fft(org.eclipse.january.dataset.Dataset a, int n, int axis) forward 1D fast Fourier transform- Parameters:
a- datasetn- number of pointsaxis- (negative numbers refer to axes from end, eg. -1 is last axis)- Returns:
- new dataset holding transform
-
fft2
public static org.eclipse.january.dataset.Dataset fft2(org.eclipse.january.dataset.Dataset a, int[] s, int[] axes) forward 2D fast Fourier transform- Parameters:
a- datasets- shape of FFT dataset (if null, use whole dataset)axes- for FFT (if null, default as [-2,-1])- Returns:
- new dataset holding transform
-
fftn
public static org.eclipse.january.dataset.Dataset fftn(org.eclipse.january.dataset.Dataset a, int[] s, int[] axes) forward nD fast Fourier transform- Parameters:
a- datasets- shape of FFT dataset (if null, use whole dataset)axes- for FFT (if null, default as [..., -1])- Returns:
- new dataset holding transform
-
ifft
public static org.eclipse.january.dataset.Dataset ifft(org.eclipse.january.dataset.Dataset a) inverse 1D fast Fourier transform- Parameters:
a- dataset- Returns:
- new dataset holding transform
-
ifft
public static org.eclipse.january.dataset.Dataset ifft(org.eclipse.january.dataset.Dataset a, int n, int axis) inverse 1D fast Fourier transform- Parameters:
a- datasetn- number of pointsaxis- (negative numbers refer to axes from end, eg. -1 is last axis)- Returns:
- new dataset holding transform
-
ifft2
public static org.eclipse.january.dataset.Dataset ifft2(org.eclipse.january.dataset.Dataset a, int[] s, int[] axes) inverse 2D fast Fourier transform- Parameters:
a- datasets- shape of FFT dataset (if null, use whole dataset)axes- for FFT (default as [-2,-1])- Returns:
- new dataset holding transform
-
ifftn
public static org.eclipse.january.dataset.Dataset ifftn(org.eclipse.january.dataset.Dataset a, int[] s, int[] axes) inverse nD fast Fourier transform- Parameters:
a- datasets- shape of FFT dataset (if null, use whole dataset)axes- for FFT (if null, default as [..., -1])- Returns:
- new dataset holding transform
-
fftshift
public static org.eclipse.january.dataset.Dataset fftshift(org.eclipse.january.dataset.Dataset a, int[] axes) Shift zero-frequency component to centre of dataset- Parameters:
a-axes- (if null, then shift all axes)- Returns:
- shifted dataset
-
ifftshift
public static org.eclipse.january.dataset.Dataset ifftshift(org.eclipse.january.dataset.Dataset a, int[] axes) Reverse shift of zero-frequency component to centre of dataset- Parameters:
a-axes- (if null, then shift all axes)- Returns:
- shifted dataset
-
sampleFrequencies
public static org.eclipse.january.dataset.Dataset sampleFrequencies(int n, double d) Discrete FFT sample frequencies- Parameters:
n- number of samplesd- sample spacing- Returns:
- frequencies
-
zeroPad
public static org.eclipse.january.dataset.Dataset zeroPad(org.eclipse.january.dataset.Dataset input, int[] newShape, boolean inFreqSpace) Pad out dataset to new shape with zeros. There are two ways to zero-pad:- set data in volume starting at origin
- split data in 2^N volumes and scatter to corners of larger volume
- Parameters:
input-newShape-inFreqSpace- if true, then pad higher frequencies as zero- Returns:
- zero-padded dataset
-
extendWithPad
public static org.eclipse.january.dataset.Dataset extendWithPad(org.eclipse.january.dataset.Dataset input, int[] newShape, Object padValue) Pad out dataset to new shape with the provided padValue.- Parameters:
input-newShape-padValue-- Returns:
- padded dataset
-
shift
public static org.eclipse.january.dataset.Dataset shift(org.eclipse.january.dataset.Dataset input, boolean forward) Shift frequency componentsA forward shift moves the zero-frequency from the origin position to the centre of the dataset. A backward shift reverts a forward shift
- Parameters:
input-forward- if true, shift forward, else shift back- Returns:
- shifted dataset
-