Data Conditioning¶
This guide explains what pycWB does to each detector’s strain inside a job segment before the time-frequency analysis: resampling, line regression, whitening, and the noise RMS (nRMS) estimate that later stages reuse.
Why this matters¶
Pixel selection sums pixel energies over detectors and applies one threshold
at every frequency of a WDM resolution, so all data need a common noise scale.
Whitening provides it, after regression has removed narrow spectral lines. The
nRMS map is reused later: the likelihood weights detectors with it, and
reconstruction uses it to return whitened amplitudes to strain. If one band
dominates the background, or hrss values look wrong, check this stage.
How it works¶
Conditioning runs once per job segment and injection trial, before the lag
loop; every lag reuses its output. The input is each detector’s strain at
inRate over the padded job window, with injections added
(Data Ingestion). The native segment processor then runs, in order:
Resampling to the analysis rate
rateANA.Regression of predictable narrow-band components, for all detectors before any whitening.
Whitening, which also produces the nRMS map.
Conditioning hooks, if configured.
Injection whitening: signal-only injection strains are whitened with the same nRMS map, for comparison with the reconstruction.
The cWB-2G products are HoT (whitened strain) and nRMS; pycWB returns
a conditioned TimeSeries and a NoiseRMSMap per detector.
Resampling¶
check_and_resample_py() rejects
data with NaNs or not at inRate, and multiplies by dcCal[i] if that is
positive and not 1. It resamples to fResample if positive, then by a
further \(2^{\text{levelR}}\), and multiplies the samples by
\(2^{\text{levelR}/2}\) (the Meyer-downsampling gain, \(\sqrt{2}\) per
level).
The defaults give 16384 / 22 = 4096 Hz. Both steps use the FFT
resampler cwb_resampling() (cWB
wavearray::Resample), which needs an even whole number of output samples.
target_snr injections are
resampled separately by
resample_snr_injection()
(FFT to fResample if set, then Meyer(1024) downsampling) and added
afterwards, so dcCal does not scale them. In this mode, trials mixing
target-SNR and fixed-hrss injections are rejected. See
Step by Step Injection Search.
Regression¶
apply_regression() follows
cWB’s LPE (linear-prediction error) regression, with the strain as its own
witness:
Transform the strain with a WDM of
rateANA / 8layers (4 Hz resolution). A mean-subtracted copy is transformed as the witness.For each layer from 1 Hz to
fHigh, correlate at lags \(-K \dots K\) (\(K\) =REGRESSION_FILTER_LENGTH) in both quadratures. Lag 0 is excluded, so each coefficient is predicted from its neighbours. Averages skipsegEdgeat both ends and keep only theREGRESSION_MATRIX_FRACTIONof samples with the smallest magnitude.Solve by eigen-decomposition, keeping at most
REGRESSION_SOLVE_EIGEN_NUMcomponents aboveREGRESSION_SOLVE_EIGEN_THR.Subtract a layer’s prediction only if its RMS, relative to the layer’s trimmed RMS, is at least
REGRESSION_APPLY_THR. The subtraction is done in the time domain, averaging the 00 and 90 phase inversions.
Persistent lines are predictable and are removed; broadband noise is not.
Nothing is subtracted if REGRESSION_FILTER_LENGTH ≤ 0, the segment is too
short, or no layer passes the threshold.
Witness amplitudes are capped during filter application using
REGRESSION_MATRIX_FRACTION, as in the built-in cWB 2G pipeline. Full-sample
percentile statistics are always used; subsampling and the uncapped historical
method are no longer selectable. A fraction of one is the full-sample,
unclipped mathematical limit. PycWB YAML does not accept cWB’s
--regression OLD command syntax in Search.
At zero edge padding, or when padding leaves too few interior samples, the percentile helper follows cWB’s ordinary-mean fallback. At a valid percentile boundary, it selects the exact requested number of samples, including ties. Both backends are checked against the captured witness statistics and fitted filters; JAX no longer uses a fused threshold comparison that could count a sample differently from the corresponding sum. An unavailable selected Numba backend raises an error rather than silently changing implementations.
Whitening¶
whiteMethod is wavelet (default; alias python) or mesa.
Wavelet
(whiten_wavelet(), cWB
WSeries::white mode 0) uses a WDM of \(2^{\text{l\_white}}\) layers, or
\(2^{\text{l\_high}}\) if l_white is 0 (256 layers at 8 Hz by
default). Pixel power is \(P_f(t) = a_{00}^2 + a_{90}^2\). A segment of
duration \(T\) (margins included) is split into
\(K = \lfloor (T - 2\,\text{segEdge}) / \text{whiteStride} \rfloor\) equal
intervals, giving \(K+1\) noise anchors. At each anchor \(\tau_j\):
\(W_j\) is whiteWindow long, centred on the anchor and kept
segEdge away from the ends. For Gaussian noise the median of \(P\) is
\(2\ln 2\,\sigma^2\), and 0.7191 is close to \(1/(2\ln 2)\), so
\(\sigma_f\) is the per-quadrature RMS. whiteWindow: 0 uses the whole
span. If whiteStride is not positive or exceeds whiteWindow, it is set
to whiteWindow. Rows outside (16 Hz, fHigh) get \(\sigma_f = 1\)
(cWB bandpass(16, 0, 1)) and are not rescaled; this 16 Hz edge ignores
fLow. Coefficients are divided by \(\sigma_f\), interpolated between
anchors, and transformed back as the mean of the 00 and 90 inversions. The
defaults give 31 anchors per 600 s job, each from 60 s of data.
MESA
(whiten_mesa(),
optional memspectrum and scikit-learn) removes the mean and applies an
8th-order zero-phase Butterworth high-pass at fLow. It fits maximum-entropy
PSDs (mesaOrder, mesaSolver) to mesaWindow-second windows every
mesaStride = mesaWindow / 3 seconds (enforced). If mesaHalfSeg > 0,
a running median over 2 × mesaHalfSeg + 1 estimates smooths the PSDs. If
mesaReindex is set, PSDs flagged by an IsolationForest are replaced by the
nearest inlier. Each window is Planck-tapered, divided by
\(\sqrt{\text{PSD}}\) in the Fourier domain, and stitched by thirds. The
anchors come from the ratio of high-passed to whitened WDM magnitudes, on the
same lattice and band.
The noise RMS map¶
A NoiseRMSMap holds only the anchors,
shape (n_frequency, K+1), timed by noise_start and noise_rate.
After pixel selection,
lookup_pixel_noise_rms() (cWB
detector::setrms) takes, for each pixel, the anchor interval containing
its lag-shifted time (no interpolation) and the \(N_f\) rows covering its
band:
The likelihood weights each detector by \(1/\sigma_\text{pix}\), normalised over the network. Reconstruction multiplies whitened amplitudes by \(\sigma_\text{pix}\) to return to strain units.
Data conditioning¶
prepare_conditioned_data()
runs noise_variability followed by gating when enabled, once per trial
before coherence and lag caches. Neither step changes detector count or the
strain timeline.
noise_variabilitycalls the generic single-band numerical engine innoise_variabilityand attaches a noise-variation map (cWBnVAR) to the nRMS. Frequencies use Hz; durations use seconds. Its defaults reproduce the O3a 16–48 Hz recipe. Omitted detector selection includes all active detectors; templates specify L1/H1 explicitly.cwb_gating: excludes padded times of high whitened-strain energy; the strain is kept.
Excluded intervals are removed from the CAT2 keep windows (or the whole
analysis span), so no pixels are selected there. The recorded livetime excludes
them, but the segTHR check uses the livetime before gating. Preparation is
recorded in conditioning/job_<index>/trial_<trial>/diagnostics.json
(Inspect Conditioning and Time Vetoes).
Implementation¶
pycwb.modules.data_conditioningentry points:condition_strains(all detectors) andcondition_strain(one detector, called per detector by the online search and by the CUDA workflow’sgpu.condition_workers).Regression kernels:
regression_numba(default) orregression_jax, set byexecution_profile.regression_engine(numba). An unavailable selected Numba backend raises an error; no automatic substitution occurs. Both backends use the same full-sample capped regression contract.pycwb.modules.data_conditioning_rootis the legacy ROOT-backed variant, which calls cWB’s C++ regression and whitening.
Configuration¶
Defaults are from pycwb.constants.user_parameters_schema (full
list: User Parameters).
Parameter |
Default |
Meaning |
|---|---|---|
|
16384 / 0 / 2 |
Input rate [Hz] / intermediate rate (0 = none) / downsampling level |
|
|
Per-detector amplitude factor / margin [s] kept out of noise statistics |
|
64.0 / 2048.0 |
MESA high-pass corner / top of regression layers and nRMS band [Hz] |
|
8 / 0.95 / 0.8 |
Filter half-length \(K\) (≤ 0 disables) / trimmed-average fraction / minimum relative prediction RMS to subtract a layer |
|
0.0 / 10 / |
Eigenvalue threshold (< 0: relative) / maximum components / |
|
|
|
|
60.0 / 20.0 |
Anchor window (0 = whole span) / nominal anchor spacing [s] |
|
15 / 5 / 800 |
MESA PSD window / stride [s] (forced to window / 3) / maximum AR order |
|
|
Levinson solver ( |
|
disabled |
Separate scientific setting blocks with explicit |
Output¶
For each detector, the WDM stage receives the conditioned strain (cWB
HoT), a TimeSeries at rateANA with the same start and length as the
padded input, and the NoiseRMSMap (with any variation map). Injection
trials add whitened injection strains (rows from fLow to fHigh only)
and unwhitened WDM round-trip copies. Coherence setup transforms the
conditioned strains at each level from l_low to l_high
(WDM Time-Frequency Transform).
Inspect conditioned data¶
Analysis rate: the
Resampling data from … to …log lines should end atrateANA.Sample rate is not consistentmeans the input is not atinRate.Whitened level: in stationary Gaussian noise, in-band whitened WDM coefficients have roughly unit RMS per quadrature. Residual lines or a sloped spectrum point to regression or
whiteWindowproblems.Regression effect: compare with a
REGRESSION_FILTER_LENGTH: 0run on the same data. Lines should shrink while the broadband level stays the same. Also compare background and recovered injections.MESA reproducibility:
mesaReindexuses an unseeded IsolationForest, so results are not bit-for-bit repeatable. Disable it for exact comparisons.
See also: Pipeline Lifecycle · Data Ingestion · Inspect Conditioning and Time Vetoes
Next: WDM Time-Frequency Transform — the multi-resolution time-frequency transform