sage.data.noise.recolour
Filename : recolour.py Description : Short description of the file
Created on 2026-02-09 23:39: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
GPU postprocessing step: stochastic PSD recolouring from one noise epoch |
Module Contents
- class RecolourPostprocess(*, p_recolour, recolour_dataset_dir, eps=1e-38)[source]
Bases:
torch.nn.ModuleGPU postprocessing step: stochastic PSD recolouring from one noise epoch to another, operating entirely in the frequency domain.
Motivation
Sage trains on O3b noise but evaluates on O3a noise (different GPS epoch, different spectral shape). Simply whitening with O3b PSDs and testing on O3a produces a distribution shift. With
p_recolourprobability, each training sample is:Whitened using the segment’s own O3b ASD (removing O3b colour).
Recoloured by multiplying with a randomly chosen O3a ASD (adding O3a colour).
The remaining
1 - p_recolourfraction of the batch passes through unchanged (plain FD conversion only).This bridges the spectral gap between training and evaluation epochs without using any actual O3a time-domain data during training. Note that glitch morphology is not altered — only the spectral amplitude envelope changes.
- param p_recolour:
Per-sample probability of applying the whiten + recolour transform. Typical value: 0.37.
- type p_recolour:
float in [0, 1]
- param recolour_dataset_dir:
Root directory of the target noise epoch dataset (e.g. the O3a data release directory). Must contain a
data_dir/recolour_psds/sub-directory with pre-computed per-detector ASD banks.- type recolour_dataset_dir:
str
- param eps:
Small value added to ASDs before division/multiplication to prevent division by zero in very quiet frequency bins.
- type eps:
float
- param Inputs / Outputs:
- param —————-:
- param forward(batch_td:
batch_td:(B, D, T)float32 — time-domain noise windows.segment_ids:(B, D)int64 — index into the segment ASD bank (used to select the correct per-segment whitening ASD).- param segment_ids):
batch_td:(B, D, T)float32 — time-domain noise windows.segment_ids:(B, D)int64 — index into the segment ASD bank (used to select the correct per-segment whitening ASD).- param Returns ``(B:
- param D:
- param F)`` complex64 — frequency-domain (recoloured) strain.:
- param Initialize internal Module state:
- param shared by both nn.Module and ScriptModule.:
- forward(batch_td, segment_ids)[source]
torch.compile-safe FD recolouring
- Parameters:
batch_td (torch.Tensor)
segment_ids (torch.Tensor)
- Return type: