sage.data.waveform.approximants.sinusoid
Filename : sinusoid.py Description : Short description of the file
Created on 2026-01-19 16:06:34
__author__ = Narenraju Nagarajan __copyright__ = Copyright 2026, Sage __license__ = MIT Licence __version__ = 0.0.1 __maintainer__ = Narenraju Nagarajan __email__ = N/A __status__ = [‘inProgress’, ‘Archived’, ‘inUsage’, ‘Debugging’]
GitHub Repository: NULL
Documentation: NULL
Classes
Synthetic sinusoidal waveform generator for bias probing. |
Module Contents
- class SinusoidGenerator(A, phi, inject_lower=2.0, inject_upper=3.0, spectral_bias=False, fixed_duration=5.0, lower_freq=20.0, upper_freq=1024.0, duration_bias=False, fixed_frequency=100.0, lower_tau=0.1, upper_tau=5.0, no_whitening=False)[source]
Synthetic sinusoidal waveform generator for bias probing.
Generates simple sine waves to test for spectral bias (varying frequency, fixed duration) and duration bias (varying duration, fixed frequency). Used to diagnose whether the network learns spurious correlations between signal properties and the detection score.
- Parameters:
A (float) – Amplitude of the sinusoid.
phi (float) – Initial phase (radians).
inject_lower (float) – Lower bound for the random injection time within the segment (s).
inject_upper (float) – Upper bound for the random injection time within the segment (s).
spectral_bias (bool) – If
True, generate samples with varying frequency but fixed duration.fixed_duration (float) – Duration used when
spectral_bias=True(s).lower_freq (float) – Lower frequency bound for spectral-bias sampling (Hz).
upper_freq (float) – Upper frequency bound for spectral-bias sampling (Hz).
duration_bias (bool) – If
True, generate samples with varying duration but fixed frequency.fixed_frequency (float) – Frequency used when
duration_bias=True(Hz).lower_tau (float) – Lower duration bound for duration-bias sampling (s).
upper_tau (float) – Upper duration bound for duration-bias sampling (s).
no_whitening (bool) – Skip whitening-edge padding if
True(defaultFalse).
- get_time_shift(detectors)[source]
Return the light-travel-time offset (seconds) between the two detectors.
- add_zero_padding(signal, start_time, sample_length, sample_rate)[source]
Zero-pad signal to sample_length × sample_rate samples, placing the signal at start_time.
- add_whiten_padding(signal, special)[source]
Append symmetric whitening-corruption padding to signal.
- testing_spectral_bias(special)[source]
Generate two-detector sinusoid injections at random frequencies (fixed duration).
Used to probe whether the model exhibits a spectral bias — i.e. favours certain frequency ranges.
- Returns:
Per-detector time-series.
- Return type:
numpy.ndarray, shape
(2, N)
- testing_duration_bias(special)[source]
Generate two-detector sinusoid injections at random durations (fixed frequency).
Used to probe whether the model exhibits a duration bias — i.e. favours signals of certain in-band durations.
- Returns:
Per-detector time-series.
- Return type:
numpy.ndarray, shape
(2, N)
- apply(params, special)[source]
Generate sinusoidal test signals for bias probing.
Dispatches to
testing_spectral_bias()ortesting_duration_bias()depending on the instance flags.