sage.data.noise.glitch_sampler

GlitchOversampledNoiseSampler

Subclass of MemmapNoiseSampler that injects known high-SNR glitch windows into a controlled fraction of each training batch.

Motivation

The O3b noise training data is dominated by Scattered_Light glitches (~65 % of H1 triggers), leaving rare-but-dangerous classes like Repeating_Blips underrepresented. When evaluating on O3a test data, these minority classes produce the loudest background triggers.

Solution

Override _sample_starts_batch so that glitch_frac of each batch is drawn from a GPS-aligned pool of high-SNR O3b glitch windows (sourced from the GravitySpy CSV catalogs). All downstream processing — DYN_RANGE_FAC normalisation, TD→FD conversion, and RecolourPostprocess — runs unchanged, so the injected glitch windows receive exactly the same treatment as regular noise windows.

Class-balanced sampling

With class_balanced=True (default), a glitch class is chosen uniformly at random before selecting a specific event. This gives equal weight to each morphological class regardless of how common it is in the catalogue, directly addressing the majority-class dominance problem.

Classes

GlitchOversampledNoiseSampler

MemmapNoiseSampler with class-balanced O3b glitch oversampling.

Module Contents

class GlitchOversampledNoiseSampler(*args, catalog_files, min_snr=15.0, glitch_frac=0.1, class_balanced=True, exclude_classes=None, **kwargs)[source]

Bases: sage.data.noise.real_noise.MemmapNoiseSampler

MemmapNoiseSampler with class-balanced O3b glitch oversampling.

Parameters:
  • catalog_files (list of (det_idx, csv_path)) – GravitySpy CSV files keyed by detector index (0=H1, 1=L1). Example: [(0, ‘/path/H1_O3b.csv’), (1, ‘/path/L1_O3b.csv’)]

  • min_snr (float) – Only glitches with GravitySpy SNR >= min_snr are used.

  • glitch_frac (float) – Fraction of each batch replaced by glitch windows. 0.10 = 10 %.

  • class_balanced (bool) – If True, sample uniformly over glitch classes before sampling an event, giving equal representation to rare classes. If False, sample uniformly over all qualifying events.

  • exclude_classes (set of str, optional) – GravitySpy class labels to exclude (e.g. {‘No_Glitch’}).

  • state (Initialize internal Module)

  • ScriptModule. (shared by both nn.Module and)

glitch_frac = 0.1[source]
class_balanced = True[source]