sage.data.psd.smoothing
Filename : smoothing.py Description : Short description of the file
Created on 2026-02-11 20:48:57
__author__ = Narenraju Nagarajan __copyright__ = Copyright 2026, ProjectName __license__ = MIT Licence __version__ = 0.0.1 __maintainer__ = Narenraju Nagarajan __affiliation__ = N/A __email__ = N/A __status__ = [‘inProgress’, ‘Archived’, ‘inUsage’, ‘Debugging’]
GitHub Repository: NULL
Documentation: NULL
Classes
PSD smoother based on a univariate spline fit in log-log space. |
Module Contents
- class LogSplineSmoothing(smooth_factor=None, upweight_regions=None, return_coeffs=False, noise_low_frequency_cutoff=15.0)[source]
PSD smoother based on a univariate spline fit in log-log space.
Transforms both frequency and PSD to log scale before fitting a
scipy.interpolate.UnivariateSpline, then exponentiates the result back. Log-log fitting is well-suited to PSDs because their broad-band structure follows approximate power laws, so the spline needs fewer knots and produces a more physically plausible smooth curve than a linear-domain fit would.Frequencies below
noise_low_frequency_cutoffare excluded from the spline fit (the seismic wall makes PSD estimates unreliable there); the original values are returned unchanged for those bins.- Parameters:
smooth_factor (float or None) – Smoothing parameter passed to
UnivariateSplineass. Larger values produce smoother output. IfNone, a heuristic0.2 * n_pointsis used on the first call.upweight_regions (list[tuple[float, float]] or None) – Optional list of
(f_low, f_high)frequency bands to upweight (weight 2 vs. default 1) so the spline tracks those regions more closely (e.g. the detector’s most sensitive band).return_coeffs (bool) – Unused placeholder for future coefficient export (default
False).noise_low_frequency_cutoff (float) – Frequency (Hz) below which PSD values are not used for fitting (default
15.0).
- smooth(freqs, psd, smooth_factor=None)[source]
Smooth a noisy PSD estimate using a spline in log-log space.
- Parameters:
freqs ((F,) array) – Frequency array (must be > 0).
psd ((F,) array) – PSD values (must be > 0).
smooth_factor (float or None) – Smoothing strength. Larger = smoother. If None, an automatic heuristic is used.
- Returns:
psd_smooth – Smoothed PSD (same shape as input).
- Return type:
(F,) array