sage.data.waveform.multiband_selector

MultibandSelector: apply the LAL worst-case multibanding grid to any FD tensor.

The multibanding grid (from multiband_grid.py) produces coarse frequency points that are exact integer multiples of the uniform grid spacing DELTA_F. This means multibanding is pure index selection — no interpolation, no approximation.

Mathematical guarantee:

multiband(signal + noise)[i] == multiband(signal)[i] + multiband(noise)[i]

because both sides compute h_fd[idx_i] + n_fd[idx_i] with identical float ops.

Usage

# Build from prior at runtime (recommended — no hardcoded masses): selector = MultibandSelector.from_prior_scan(param_sampler, data_cfg)

# Or specify masses directly: selector = MultibandSelector.from_prior(m1_worst, m2_worst, data_cfg)

hf_coarse = selector(hf_full) # (B, D, F_full) -> (B, D, N_coarse) nf_coarse = selector(nf_full) injected = hf_coarse + nf_coarse

Classes

MultibandSelector

Select the worst-case multibanding indices from a full FD tensor.

Module Contents

class MultibandSelector(coarse_indices, coarse_freqs)[source]

Bases: torch.nn.Module

Select the worst-case multibanding indices from a full FD tensor.

Parameters:
  • coarse_indices (torch.LongTensor, shape (N_coarse,)) – Integer indices into the full FD array [0 .. F_full-1].

  • coarse_freqs (torch.Tensor, shape (N_coarse,)) – Corresponding frequencies in Hz (for diagnostics).

  • state (Initialize internal Module)

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

classmethod from_prior(m1_worst, m2_worst, data_cfg, res_test=0.001, device='cpu')[source]

Build a MultibandSelector for the given worst-case masses.

Parameters:
  • m1_worst (float) – Component masses (solar masses) that produce the most coarse grid points — the “worst case” for the prior.

  • m2_worst (float) – Component masses (solar masses) that produce the most coarse grid points — the “worst case” for the prior.

  • data_cfg (BaseDataConfig) – Sage data configuration (provides padded_delta_f, sample_rate, etc.)

  • res_test (float) – LAL multibanding accuracy threshold (default 1e-3).

  • device (str) – Torch device for the index tensor.

Return type:

MultibandSelector

classmethod from_prior_scan(param_sampler, data_cfg, n_grid=500, res_test=0.001, device='cpu', verbose=True)[source]

Scan the mass prior at runtime and build a selector for the worst-case (m1, m2) — the pair that requires the most coarse grid points.

Parameters:
  • param_sampler (DistributionSampler) – Sage parameter sampler built from a gwconfig YAML. The mass bounds are read from param_sampler.bounds.

  • data_cfg (BaseDataConfig) – Sage data configuration (f_min, f_max, delta_f).

  • n_grid (int) – Number of points per axis for the coarse scan grid. 500×500 (default) covers ~125k valid pairs in a few seconds using the fast counter. Increase for finer resolution.

  • res_test (float) – LAL multibanding accuracy threshold (default 1e-3).

  • device (str) – Torch device for the index tensor.

  • verbose (bool) – Print scan progress and result.

Returns:

Selector built for the worst-case mass pair found in the prior.

Return type:

MultibandSelector

property n_coarse: int[source]
Return type:

int

forward(x)[source]

Select coarse frequency bins from a full FD tensor.

Parameters:

x (torch.Tensor) – Shape (…, F_full). The last dimension is the full FD axis.

Returns:

Shape (…, N_coarse). Identical float values as x at the selected indices — no arithmetic, just index gather.

Return type:

torch.Tensor