Noise-variability correction and gating

The supplied native and GPU processors execute two distinct optional steps after resampling and regression/whitening: noise-variability correction, then cWB pixel-selection gating. The two steps run once per injection trial (once per job for background), before signal-only injection whitening, coherence or waveform caches are built. Serial and shared-input process execution use the same preparation path. An omitted step or enabled: false preserves the strain and noise objects.

Separate top-level blocks enable each step and set its parameters:

noise_variability:
  enabled: true
  detectors: [L1, H1]
  frequency_hz: 32
  bandwidth_hz: 32
  filter_seconds: 4
  correlation_seconds: 0.6
  correlation_delay_seconds: 0.125
gating:
  enabled: true
  energy_threshold: 1000000
  integration_seconds: 0.5
  padding_seconds: 1.5

Both steps default to disabled. A nonempty block must include an explicit enabled switch; options alone are rejected. When the detector list is omitted, correction selects all active detectors in configured order. An explicit list must contain unique active detector names. Gating defaults to the three values shown above; its threshold and integration duration must be positive, its padding nonnegative, and all numerical options finite. Unknown keys fail validation, including for disabled steps.

Processors declare versioned conditioning_capabilities. The native and GPU processors support version 2 of noise_variability and version 1 of gating. Every enabled correction requires the noise_variability version 2 contract. Other correction names or versions do not satisfy this contract. The ROOT processor does not execute these Python steps: enabling either step with ROOT fails before submission or data processing. An independent processor must declare the capabilities it actually implements. Changing processor cannot silently disable noise-variability correction or gating.

Online currently supports neither step and rejects enabled settings at startup and at its direct processing entry point. Configuration and catalog loading validate scientific settings without importing processors. Execution checks the actual callable. Custom replacements for native coherence preparation must declare the enabled noise-variability contract, and replacement lag processors must declare every enabled correction/gating contract they preserve.

The explicit preparation sequence calls preparation.apply_noise_variability() followed by preparation.apply_gating() in pycwb.modules.data_conditioning. The correction calls the parameterized numerical function in data_conditioning/noise_variability.py through conditioning_plugins/noise_variability.py. Gating uses conditioning_plugins/cwb_gating.py. The default correction reproduces the existing O3a numerical recipe.

The runtime retains HookContext and ConditioningResult as internal data contracts. Both steps preserve detector count and strain sample count, start time, and cadence. The segment detector order must match the configuration. Variability correction can replace amplitudes and noise-variation models. Gating must preserve strain samples and noise maps. It returns excluded GPS intervals; the processor subtracts them from CAT2 accepted intervals and then applies existing injection-window and circular-lag semantics. An empty accepted list means no live data.

Search configuration

Set noise_variability and gating directly in each search template’s user_parameters.yaml. Their enabled switches are independent: a search can enable either step, both, or neither. Background, simulation, MDC, and XGB configurations retain their own explicit preparation settings. Compare these settings when defining a common search; matching them does not require enabling both steps for every search family.

config-setup renders the template, loads it with strict YAML validation, adds operational machine defaults, and checks processor support before writing config/user_parameters.yaml. Template values take precedence over machine defaults. Machine profiles cannot define the correction/gating blocks, their legacy declarations, or pipeline schema through pycwb_schema. Setup preserves template comments, reloads the generated YAML, and checks that it matches the composed configuration. Duplicate keys and recursive aliases fail validation. Processing consumes the generated configuration without reopening the configuration repository. See Job Control for preparation and submission.

Catalog settings records retain the resolved scientific fields. Resume compares those fields, so changed correction/gating settings block it. Newly enabled operations cannot be silently introduced into a resumed run. Per-trial diagnostics retain the implementation source hashes described below.

Configuration declarations

noise_variability is the sole correction block. The former o3a_correction name and nested conditioning declarations are rejected rather than aliased. The old correction module and its correct_strain/correct_layer wrappers are removed. Call correct_noise_variability or correct_variability_layer from pycwb.modules.data_conditioning.noise_variability for direct numerical use. External steps require a processor that implements and declares their conditioning contract. The supplied workflow calls the preparation runner directly. Existing gating aliases and the separate deprecated custom-hook API do not provide aliases for noise-variability correction.

Noise-variability correction and the O3a recipe

noise_variability exposes a generic single-band correction. Its defaults reproduce the production cWB O3a 16–48 Hz recipe: a 32 Hz WDM band, symmetric four-second LPR filter with right-tail rejection, reference order-statistic medians, magnitude and multiplicity corrections, and both inverse phases. Detector selection defaults to all active detectors. The supplied production templates explicitly select L1/H1 to reproduce the reference recipe. The former O3a hook selected L1/H1 by default; include that detector list explicitly when translating its settings.

The numerical API exposes the band and durations separately:

from pycwb.modules.data_conditioning.noise_variability import correct_noise_variability

corrected, variation = correct_noise_variability(
    whitened_strain, edge_seconds=10.,
    frequency_hz=32., bandwidth_hz=32., filter_seconds=4.,
    correlation_seconds=.6, correlation_delay_seconds=.125,
)

The five values are also optional fields in noise_variability; omitting them preserves the recipe above. For example, an explicitly configured 48–80 Hz band uses frequency_hz: 64 and bandwidth_hz: 32. Altered values define a different scientific correction and require independent validation; the O3a source audit applies to the default recipe. Resolved values are recorded and changing them blocks resume.

Frequencies and filter/correlation durations must be finite and positive. The correlation delay must be finite, nonnegative, and shorter than its window. The correction supports one exact interior WDM band: frequency_hz / bandwidth_hz must be an integer and the lower edge must be positive. At execution, the actual sample rate must be an integer multiple of 2 * bandwidth_hz, and the band must lie inside Nyquist. The numerical function also checks segment length and edge support before transforming the strain. On the coefficient lattice, filter duration and initial delay round to the nearest sample; the correlation-window sample count truncates toward zero, preserving the reference convention. Grid checks allow 1e-12 absolute roundoff in the dimensionless layer/decimation ratios. Durations that leave no usable correlation sample or too little filter/edge support are rejected.

The correction returns an ordinary pycwb.types.time_frequency_map.TimeFrequencyMap on the band’s 2 * bandwidth_hz time lattice (64 Hz by default), matching cWB’s use of WSeries<float> nVAR rather than a dedicated variability type. Its data has shape (1, n_samples) and float32 storage; dt and start describe sampling, while f_low and f_high give frequency_hz ± bandwidth_hz / 2 (16–48 Hz by default). The map contains correction factors, so wavelet is None. NoiseRMSMap.variation carries this map through coherence and likelihood pixel-noise lookups in modules/data_conditioning/noise.py, which delegates optional variation to conditioning_plugins/noise_variation.py, including partial overlap with the affected band and lagged detector sample indices. Physical waveform reconstruction consumes the resulting per-pixel noise RMS. Applying another variability correction to an already corrected noise map is rejected until an explicit composition rule exists. Saved diagnostic arrays are one-dimensional per detector.

Zero-energy/constant envelopes receive identity behavior; zero correction autocorrelation skips the multiplicity adjustment. These safeguards avoid reference divisions by zero and do not change the tested ordinary-data reference result. This correction is different from data_conditioning/psd_correction.py.

Gate semantics

gating computes a rolling sum of squared whitened samples, without division by the sample rate, over 0.5 seconds. It applies the reference threshold and sample padding, scratch-edge clipping, interval rounding, and union across detectors. The strain is not zeroed. The combined exclusions affect pixel selection and reported livetime through the shared keep-window machinery, including circular lags. The CAT2/job-duration eligibility check uses the pre-gate windows; gating does not reapply that cut. Pixel selection and reported livetime use the post-gate windows, matching the reference stage ordering.

The gate is recomputed after injections and conditioning for every trial, as in the reference: a sufficiently loud injection can itself trigger a gate. Count gated injections explicitly in efficiency studies rather than silently removing them from the injected denominator.

Outputs and validation

conditioning/job_<index>/trial_<index>/diagnostics.json records the two distinct steps under steps and numerical detector/gating diagnostics under diagnostics. Each step entry includes fully resolved settings, an applied/skipped status, implementation SHA256, and source hashes of the numerical implementation, resolver, and explicit runner. An enabled correction with no selected detectors records status: skipped and reason: no eligible detectors. Unchanged source hashes are cached between trials; editing a source file invalidates its cached hash. Excluded intervals and variation-lattice metadata remain recorded, and noise_variation.npz retains the correction arrays by detector index. Saved configuration records materialize exact defaults, enabled switches, and detector selection for both steps, including disabled ones.

Validate three distinct levels:

  1. Identical-input correction, variation-map, pixel-noise, and active-gate comparisons against the cWB release.

  2. End-to-end runs for each search family with its explicit preparation settings, plus regression coverage with both steps disabled.

  3. Independent-source population campaigns using final settings, many noise segments/banks, and predeclared equivalence tolerances.

Direct numerical-step comparisons verify the workflow wiring, but do not independently establish cWB production equivalence. In particular, common conditioning/gating settings do not establish native Lveto computation or full QLveto equivalence. Population validation remains a separate scientific check.