sage.data.noise.coloured_noise
Filename : coloured_noise.py Description : Short description of the file
Created on 2026-01-19 16:18:07
__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
Legacy PyCBC-based coloured Gaussian noise generator. |
Module Contents
- class ColouredNoiseGenerator(psds_dir='')[source]
Legacy PyCBC-based coloured Gaussian noise generator.
Generates noise coloured by real measured PSDs from HDF files (one per detector), matching the “Dataset 3” protocol from MLGWSC-1. For each noise realisation a random PSD is chosen from the precomputed ASD pool for each detector and the corresponding coloured noise is generated via PyCBC’s inverse-spectrum-truncation whitening filter.
Note
This class depends on
pycbcand is used only in legacy CPU-based DataLoader pipelines. The GPU-native real-noise path (MemmapNoiseSampler) is preferred for on-the-fly training.- Parameters:
psds_dir (str) – Path to the parent directory containing
H1/andL1/subdirectories of.hdfPSD files.
- precompute_common_params()[source]
Load all configured PSDs from disk and convert each to a complex ASD.
Must be called once after construction before calling
generate()orapply(). Results are stored incomplex_asds.
- psd_to_asd(psd, start_time, end_time, sample_rate=2048.0, low_frequency_cutoff=15.0, filter_duration=128)[source]
Convert a PyCBC FrequencySeries PSD to a complex ASD suitable for colouring white Gaussian noise.
- Parameters:
psd (pycbc.types.FrequencySeries) – Power spectral density in
Hz^-1.start_time (float) – GPS start/end (seconds) used only for sizing the intermediate time-series.
end_time (float) – GPS start/end (seconds) used only for sizing the intermediate time-series.
sample_rate (float) – Target sample rate (Hz; default
2048.0).low_frequency_cutoff (float) – Below this frequency the PSD is zeroed (Hz; default
15.0).filter_duration (float) – Duration (seconds) of the coloring filter (default
128).
- Returns:
Complex ASD (fourth root of the squared-norm PSD).
- Return type:
pycbc.types.FrequencySeries
- colored_noise(asd, start_time, end_time, seed=42, sample_rate=2048.0, filter_duration=128, det=None)[source]
Create noise from a PSD
Return noise from the chosen PSD. Note that if unique noise is desired a unique seed should be provided.
- Parameters:
asd (pycbc.types.FrequencySeries) – ASD to color the noise
start_time (int) – Start time in GPS seconds to generate noise
end_time (int) – End time in GPS seconds to generate noise
seed ({None, int}) – The seed to generate the noise.
sample_rate ({16384, float}) – The sample rate of the output data. Keep constant if you want to ensure continuity between disjoint time spans.
filter_duration ({128, float}) – The duration in seconds of the coloring filter
- Returns:
noise – A TimeSeries containing gaussian noise colored by the given psd.
- Return type:
TimeSeries
- normal(start, end, sample_rate=2048.0, seed=0)[source]
Generate data with a white Gaussian (normal) distribution
- Parameters:
start_time (int) – Start time in GPS seconds to generate noise
end_time (int) – End time in GPS seconds to generate noise
sample-rate (float) – Sample rate to generate the data at. Keep constant if you want to ensure continuity between disjoint time spans.
seed ({None, int}) – The seed to generate the noise.
- Returns:
noise – A TimeSeries containing gaussian noise
- Return type:
TimeSeries
- generate(asd, seed, det)[source]
Generate a single coloured-noise time-series of length
sample_lengthseconds.- Parameters:
- Returns:
Coloured noise array of shape
(sample_length * sample_rate,).- Return type: