calc_mean_amplitudes¶
- sofia_redux.scan.filters.filters_numba_functions.calc_mean_amplitudes(amplitudes, amplitude_weights, spectrum, windows, channel_indices)[source]¶
Calculate the mean amplitudes and weights of a Fourier spectrum.
The
amplitudes
andamplitude_weights
are updated in-place.The amplitude of the spectrum at a single frequency channel (f) is calculated as:
amplitude = sqrt(2 * sum_{i=0}^{window-1}(a[f+i]^2 + b[f+i]^2) / w)
where
w = sum_{i=0}^{window-1}((a[f+i] != 0) + (b[f+i] != 0))
(a, b) are the (real, imaginary) components of
spectrum
and w are theamplitude_weights
. Thus, ifwindows
> 1 then this effectively downsamples the spectrum using a box average. Typically,windows
is set to 1. Note that the Nyquist value is purely real, and stored in the last element of the spectrum a[-1] (b[-1] = 0). It’s amplitude and weight will likewise be stored in the last elements ofamplitudes
andamplitude_weights
. The number of frequencies to calculate (nf/2) is determined from the input amplitude.shape[1]- Parameters:
- amplitudesnumpy.ndarray (float)
The empty amplitudes array to fill with the calculated amplitudes of shape (n_channels, >=nf/2). Updated in-place.
- amplitude_weightsnumpy.ndarray (float)
The empty amplitude weights array to fill with the calculated amplitude weights of shape (n_channels, >=nf/2). Updated in-place.
- spectrumnumpy.ndarray (complex)
The spectrum from which to derive amplitudes. An array of shape (n_channels, >=windows * nf/2).
- windowsint
The size of the averaging window in frequency bins.
- channel_indicesnumpy.ndarray (int)
The channel indices for which to calculate amplitudes.
- Returns:
- None