Skip to content

Pipeline

gwmock_signal.pipeline

High-level CBC injection pipeline.

See docs/user_guide/cli.md (CLI) and docs/api/pipeline/index.md (API reference).

inject_cbc_signal(waveform_model, params, detector_names, background, *, sampling_frequency, minimum_frequency, waveform_backend=None, effects=None, interpolate_if_offset=True, earth_rotation=None, finite_arm_length=None)

Inject a CBC signal into background strain for a network of detectors.

Orchestrates waveform generation, detector projection, and strain injection for compact binary coalescence (CBC) sources. Returns a DetectorStrainStack containing the injected strain for each detector.

Parameters:

Name Type Description Default
waveform_model str

Time-domain approximant name (e.g. 'IMRPhenomD').

required
params dict[str, Any]

CBC injection parameters; must include detector_frame_mass_1, detector_frame_mass_2, coa_time, distance, inclination, right_ascension, declination, and polarization_angle.

required
detector_names Sequence[str | CustomDetector]

IFO codes for the target network (e.g. ['H1', 'L1', 'V1']).

required
background Mapping[str, TimeSeries | TimeSeries]

Mapping of detector name to background TimeSeries (e.g. noise or zeros segment).

required
sampling_frequency float

Sample rate in Hz.

required
minimum_frequency float

Low-frequency cutoff in Hz, passed to the waveform generator.

required
waveform_backend WaveformBackend | None

Optional waveform backend instance used to generate polarizations. Defaults, via CBCSimulator, to :func:~gwmock_signal.waveform.factory.default_waveform_backend: LAL where lalsuite is installed, ripple where it is not and the jax extra is, and an ImportError naming both when neither is.

None
effects ProjectionEffects | None

Which physical effects the projection includes; see :class:~gwmock_signal.projection.effects.ProjectionEffects. None, the default, means all of them.

None
interpolate_if_offset bool

If True, resample with a windowed-sinc kernel when the injection start is not on a target sample boundary. If False and the injection is off-grid, the background is returned unchanged (target.copy()) rather than resampled.

True
earth_rotation bool | None

Deprecated; effects=ProjectionEffects(earth_rotation=...).

None
finite_arm_length bool | None

Deprecated; effects=ProjectionEffects(finite_arm_length=...).

None

Returns:

Type Description
DetectorStrainStack

DetectorStrainStack with one injected strain channel per detector in

DetectorStrainStack

detector_names order.

Raises:

Type Description
ValueError

If any required parameter key is missing from params.

ValueError

If a detector name is not recognized by the detector registry.

KeyError

If a detector name is missing from background.

Source code in src/gwmock_signal/pipeline.py
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
def inject_cbc_signal(  # noqa: PLR0913
    waveform_model: str,
    params: dict[str, Any],
    detector_names: Sequence[str | CustomDetector],
    background: Mapping[str, TimeSeries | gwpy.timeseries.TimeSeries],
    *,
    sampling_frequency: float,
    minimum_frequency: float,
    waveform_backend: WaveformBackend | None = None,
    effects: ProjectionEffects | None = None,
    interpolate_if_offset: bool = True,
    earth_rotation: bool | None = None,
    finite_arm_length: bool | None = None,
) -> DetectorStrainStack:
    """Inject a CBC signal into background strain for a network of detectors.

    Orchestrates waveform generation, detector projection, and strain injection
    for compact binary coalescence (CBC) sources. Returns a
    ``DetectorStrainStack`` containing the injected strain for each detector.

    Args:
        waveform_model: Time-domain approximant name (e.g. ``'IMRPhenomD'``).
        params: CBC injection parameters; must include ``detector_frame_mass_1``,
            ``detector_frame_mass_2``, ``coa_time``, ``distance``, ``inclination``,
            ``right_ascension``, ``declination``, and ``polarization_angle``.
        detector_names: IFO codes for the target network
            (e.g. ``['H1', 'L1', 'V1']``).
        background: Mapping of detector name to background ``TimeSeries``
            (e.g. noise or zeros segment).
        sampling_frequency: Sample rate in Hz.
        minimum_frequency: Low-frequency cutoff in Hz, passed to the waveform
            generator.
        waveform_backend: Optional waveform backend instance used to generate
            polarizations. Defaults, via ``CBCSimulator``, to
            :func:`~gwmock_signal.waveform.factory.default_waveform_backend`: LAL where lalsuite is
            installed, ripple where it is not and the ``jax`` extra is, and an ``ImportError`` naming
            both when neither is.
        effects: Which physical effects the projection includes; see
            :class:`~gwmock_signal.projection.effects.ProjectionEffects`. ``None``, the default, means
            all of them.
        interpolate_if_offset: If ``True``, resample with a windowed-sinc kernel when the
            injection start is not on a target sample boundary. If ``False``
            and the injection is off-grid, the background is returned
            unchanged (``target.copy()``) rather than resampled.
        earth_rotation: Deprecated; ``effects=ProjectionEffects(earth_rotation=...)``.
        finite_arm_length: Deprecated; ``effects=ProjectionEffects(finite_arm_length=...)``.

    Returns:
        ``DetectorStrainStack`` with one injected strain channel per detector in
        ``detector_names`` order.

    Raises:
        ValueError: If any required parameter key is missing from ``params``.
        ValueError: If a detector name is not recognized by the detector registry.
        KeyError: If a detector name is missing from ``background``.
    """
    return CBCSimulator(waveform_model=waveform_model, waveform_backend=waveform_backend).simulate(
        params,
        detector_names,
        background,
        sampling_frequency=sampling_frequency,
        minimum_frequency=minimum_frequency,
        effects=effects,
        interpolate_if_offset=interpolate_if_offset,
        earth_rotation=earth_rotation,
        finite_arm_length=finite_arm_length,
    )

For CLI usage that wraps this workflow, see Command-line interface. For the underlying simulator class, see Simulator (CBCSimulator).