sage.dsp.inverse_spectrum_truncation
Filename : inverse_spectrum_truncation.py Description : Short description of the file
Created on 2026-02-09 12:18:56
__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:
We take inspiration from the PyCBC function for truncation https://pycbc.org/pycbc/latest/html/_modules/pycbc/psd/estimate.html#inverse_spectrum_truncation
Functions
|
GPU-native batched inverse spectrum truncation (IST) for PSD smoothing. |
|
CPU version of inverse spectrum truncation for a single PSD (1D tensor). |
Module Contents
- inverse_spectrum_truncation_batch(psd, max_filter_len, low_frequency_cutoff=None, delta_f=1.0, trunc_method='hann')[source]
GPU-native batched inverse spectrum truncation (IST) for PSD smoothing.
Reproduces the PyCBC
inverse_spectrum_truncationroutine in PyTorch for batched, device-resident PSDs. IST time-limits the inverse-ASD filter so that it cannot introduce correlations beyondmax_filter_lensamples, preventing the whitening filter from growing unboundedly long.Algorithm:
Compute
1 / sqrt(PSD)in the frequency domain (inverse ASD).IFFT to the time domain and zero out samples beyond
max_filter_len/2from each edge (optionally with a Hann window at the truncation point).FFT back and square to recover the truncated PSD.
- Parameters:
psd (torch.Tensor, shape
(B, D, F)) – Real-valued one-sided PSDs.max_filter_len (int) – Maximum whitening filter length in samples. Bins beyond this radius are zeroed in the time-domain inverse ASD.
low_frequency_cutoff (float or None) – Frequency (Hz) below which the inverse ASD is set to zero.
delta_f (float) – Frequency bin spacing in Hz (default
1.0).trunc_method (str or None) – Window applied at the truncation boundary:
"hann"applies a half-Hann taper;Noneuses a hard rectangular truncation.
- Returns:
Truncated PSDs ready for use in whitening.
- Return type:
torch.Tensor, shape
(B, D, F)
- inverse_spectrum_truncation_single(psd, max_filter_len, low_frequency_cutoff=None, delta_f=1.0, trunc_method='hann')[source]
CPU version of inverse spectrum truncation for a single PSD (1D tensor).
- Parameters:
psd (torch.Tensor) – torch.Tensor, shape (F,), real-valued PSD
max_filter_len (int) – int, maximum length of the time-domain filter
low_frequency_cutoff (float) – float or None, zero out PSD below this frequency
delta_f (float) – float, frequency bin spacing of PSD
trunc_method (str) – str or None, truncation method (“hann” or None)
- Returns:
torch.Tensor, shape (F,), truncated PSD
- Return type: