logBinSpectrum
Module for logarithmic binning of spectral data.
This module provides functionality for logarithmic binning of spectral data, particularly useful for analyzing eddy covariance spectra and cospectra. It implements:
Logarithmic frequency binning
Special handling of zero frequency
Automatic bin averaging
Flexible bin count control
Based on the InnFlux code for spectral analysis.
Functions
Perform logarithmic binning of spectral data. |
- logBinSpectrum.logBinSpectrum(f, y, N, f_min, f_max)[source]
Perform logarithmic binning of spectral data.
This function bins spectral data using logarithmically spaced frequency intervals. The zero frequency component is handled separately in the first bin.
- Parameters:
f (
numpy.ndarray
) – Frequency array [Hz] Must be monotonically increasing First element should be 0 Hzy (
numpy.ndarray
) – Spectral values array Must be same length as fN (
int
) – Number of logarithmic bins Must be > 1f_min (
float
) – Minimum frequency for binning [Hz] Must be > 0f_max (
float
) – Maximum frequency for binning [Hz] Must be > f_min
- Returns:
[f_out, y_out] where: f_out : numpy.ndarray
Logarithmically binned frequencies [Hz] Length = N f_out[0] = 0 for zero frequency
- y_outnumpy.ndarray
Binned spectral values Length = N y_out[0] = y[0] for zero frequency
- Return type:
Notes
Bin edges are calculated as: exp(linspace(log(f_min), log(f_max), N))
Bin centers are geometric means of edges
Values within each bin are arithmetically averaged
Warnings are suppressed during computation
NaN is used for empty bins
Examples
>>> f = np.linspace(0, 10, 1000) >>> y = np.sin(2*np.pi*f) >>> f_binned, y_binned = logBinSpectrum(f, y, 20, 0.1, 10)