uwacan.spectral.ifft#

ifft(freq_data, nfft=None)[source]#

Compute the inverst fft of a single-sided spectrum.

This computes the single-sided inverse fft of the input data, intended to go from frequency data to real time data. With an input array with nfft//2+1 frequency bins, the output array has nfft time samples. No scaling is applied to the output, i.e., it has the same normalization as numpy.fft.irfft.

Parameters:
freq_data_core.FrequencyData or xr.DataArray or numpy.ndarray

Single-sided fft of some time data. The data can be one of the following:

  • FrequencyData: Wrapped frequency data from uwacan.

  • xarray.DataArray: An xarray DataArray with a ‘frequency’ dimension.

  • numpy.ndarray: A NumPy array containing a single-sided fft spectrum. The ifft will be over the last axis.

nfftint, optional

The number of bins to use for the ifft (= number of samples in the output). See notes for info on how this is computed from the input.

Returns:
_core.FrequencyData or xr.DataArray or numpy.ndarray

The computed single-sided fft of the input data. The return type matches the input type:

Notes

For a real-valued time signal with N samples, there are N//2 + 1 independent values in the spectrum. If N is even, the last bin is the Nyquist bin, which always has a real value. The first bin (index 0) corresponds to 0 Hz (DC), and is also always real-valued. If N is odd the last bin is not the Nyquist bin, but one half bin below, and is not necessarily real-valued. Thus, given a spectrum with K frequency bins, we assume that the original signal has an even number of samples N = 2*(K-1) if all values at the highest bin are real. If there are any non-zero imaginary parts at the highest frequency bin, we assume an odd number of samples N = 2*(K-1) + 1.