Class ShortTimeFourierTransform


  • public class ShortTimeFourierTransform
    extends java.lang.Object
    Static utility class providing magnitude spectrograms from complex and real valued input data. Contains high-level functions, which transform whole DataSets and also add metadata/axis descriptions, but also low level array based functions. For complex input values, the data can be provided as two separate arrays as well as in the "interleaved" layout used by JTransforms.
    Author:
    Alexander Krimm
    • Constructor Detail

      • ShortTimeFourierTransform

        public ShortTimeFourierTransform()
    • Method Detail

      • apodizeComplex

        protected static void apodizeComplex​(double[] data,
                                             Apodization apodization)
        Applies the apodization function to data in "interleaved" complex array.
        Parameters:
        data - an array containing [re1, im1, re2, im2 ... ]
        apodization - the apodization window function to use
      • complex

        public static de.gsi.dataset.DataSet complex​(de.gsi.dataset.DataSet input,
                                                     de.gsi.dataset.DataSet output,
                                                     int nFFT,
                                                     int step,
                                                     Apodization apodization,
                                                     ShortTimeFourierTransform.Padding padding,
                                                     boolean dbScale,
                                                     boolean truncateDCNy)
        Perform a Short term fourier transform on complex input data. The complex data is expected to be supplied as a DataSet with dim() = 3 with time axis data in DIM_X, real part in DIM_Y and imaginary part in DIM_Z. All dimensions should have the same number of samples.
        Parameters:
        input - a dataset with equidistantly spaced y(t) = Re(c(t)) and z(t) = data
        output - optional output dataset, if not Null and compatible, data will be modified in place
        nFFT - the number of frequency bins
        step - The timestep size in samples
        apodization - function, by default Hann window is used
        padding - how to pad the slices at the start and end of the time axis: ZERO(default), ZOH or MIRROR
        dbScale - true to convert the spectrum to dB scale
        truncateDCNy - true to interpolate the DC- and Nyquist-bins to their respective nearest neighbours
        Returns:
        the spectrogram, a DataSet3D with dimensions [nf = nQuantx x nY = nQuantt]
      • complex

        public static double[] complex​(double[] real,
                                       double[] imag,
                                       double[] output,
                                       int nFFT,
                                       int step,
                                       Apodization apodization,
                                       ShortTimeFourierTransform.Padding padding,
                                       boolean dbScale,
                                       boolean truncateDCNy)
      • complex

        public static double[] complex​(double[] complexInput,
                                       double[] output,
                                       int nFFT,
                                       int step,
                                       Apodization apodization,
                                       ShortTimeFourierTransform.Padding padding,
                                       boolean dbScale,
                                       boolean truncateDCNy)
      • getFrequencyAxisComplex

        public static double[] getFrequencyAxisComplex​(double dt,
                                                       int nFFT,
                                                       double[] output)
      • getFrequencyAxisReal

        public static double[] getFrequencyAxisReal​(double dt,
                                                    int nFFT,
                                                    double[] output)
      • getTimeAxis

        public static double[] getTimeAxis​(double dt,
                                           int nSamples,
                                           int step,
                                           double[] output)
      • real

        public static de.gsi.dataset.DataSet real​(de.gsi.dataset.DataSet input,
                                                  de.gsi.dataset.DataSet output,
                                                  int nFFT,
                                                  int step,
                                                  Apodization apodization,
                                                  ShortTimeFourierTransform.Padding padding,
                                                  boolean dbScale,
                                                  boolean truncateDCNy)