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+1frequency bins, the output array hasnffttime samples. No scaling is applied to the output, i.e., it has the same normalization asnumpy.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 fromuwacan.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:
If
time_datais aTimeData, returns aFrequencyDataobject.If
time_datais anxarray.DataArray, returns anxarray.DataArraywith a ‘frequency’ dimension.If
time_datais anumpy.ndarray, returns a NumPy array containing the fft data.
Notes
For a real-valued time signal with
Nsamples, there areN//2 + 1independent values in the spectrum. IfNis 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. IfNis odd the last bin is not the Nyquist bin, but one half bin below, and is not necessarily real-valued. Thus, given a spectrum withKfrequency bins, we assume that the original signal has an even number of samplesN = 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 samplesN = 2*(K-1) + 1.