sage.data.waveform.snr
Filename : snr.py Description : Short description of the file
Created on 2026-02-16 11:14:49
__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:
- snr = OptimalSNREstimator(
psds=fiducial_psds, # (D, F) delta_f=delta_f, f_low=20.0, f_high=1024.0, device=”cuda”
)
rho_net, rho_det = snr(h_batch)
Classes
Fast batched optimal matched-filter SNR estimator (equivalent to PyCBC |
|
Rescales a batch of signals to match target SNRs. |
Module Contents
- class OptimalSNREstimator[source]
Bases:
torch.nn.ModuleFast batched optimal matched-filter SNR estimator (equivalent to PyCBC
sigmasq).Computes the optimal (whitened) SNR for a batch of frequency-domain detector-projected waveforms using fiducial PSDs loaded from disk. The integration is performed as:
\[\rho^2 = 4 \Delta f \sum_f \frac{|h(f)|^2}{S_n(f)}\]for each detector, summed over detectors for the network SNR.
- asds[source]
Amplitude spectral densities (sqrt of PSDs) per detector.
- Type:
torch.Tensor, shape
(1, D, F)
- mask[source]
Pre-computed frequency mask for
[f_low, f_high]integration band.- Type:
torch.Tensor or None, shape
(1, 1, F)
- Expected input shapes
- ---------------------
- h
- Type:
(B, D, F)complex tensor — detector-projected FD waveforms.
- class OptimalSNRRescaler(target_snr_sampler)[source]
Bases:
torch.nn.ModuleRescales a batch of signals to match target SNRs.
- Parameters:
snr_estimator – instance of OptimalSNREstimator
target_snr_sampler (Callable[[int], torch.Tensor]) – callable(batch_size) -> Tensor of target SNRs
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(signal_batch)[source]
Rescale signals to target SNR.
- Parameters:
signal_batch (torch.Tensor) – shape [B, L] or [B, C, L]
- Returns:
same shape as input, shape (B, …) scale: (B,) float tensor — per-sample amplitude scale factors
(hf_new = hf_old * scale, so distance_new = distance_old / scale)
- Return type:
rescaled_signal_batch