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, earth_rotation=True, interpolate_if_offset=True)

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]

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 to LALSimulationBackend via CBCSimulator.

None
earth_rotation bool

If True, evaluate antenna patterns at time-dependent GPS times (recommended for longer signals). If False, use a single reference time at the segment midpoint.

True
interpolate_if_offset bool

If True, use cubic interpolation 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

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
33
34
35
36
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
def inject_cbc_signal(  # noqa: PLR0913
    waveform_model: str,
    params: dict[str, Any],
    detector_names: Sequence[str | CustomDetector],
    background: Mapping[str, TimeSeries],
    *,
    sampling_frequency: float,
    minimum_frequency: float,
    waveform_backend: WaveformBackend | None = None,
    earth_rotation: bool = True,
    interpolate_if_offset: bool = True,
) -> 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 to ``LALSimulationBackend`` via
            ``CBCSimulator``.
        earth_rotation: If ``True``, evaluate antenna patterns at
            time-dependent GPS times (recommended for longer signals). If
            ``False``, use a single reference time at the segment midpoint.
        interpolate_if_offset: If ``True``, use cubic interpolation 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.

    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,
        earth_rotation=earth_rotation,
        interpolate_if_offset=interpolate_if_offset,
    )

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