Injection
gwmock_signal.injection
¶
Time-domain strain injection into segments.
See docs/user_guide/strain-injection.md (examples) and docs/api/injection/index.md (API).
inject_strain(target, injection, *, interpolate_if_offset=True, tapered=False, on_grid=False)
¶
Return a new series equal to target plus injection on overlapping samples.
The two must share a sample rate and a unit. Only the samples of injection that fall
within target are added. An injection off the target's sample lattice is resampled onto
it with the band-limited windowed-sinc kernel the projection uses (see
interpolate_if_offset), reading the whole injection, so a target sample near either end
of target takes its kernel taps from injection samples beyond that end where there are
any.
The injection is placed at the time it carries. It is added sample for sample only when
rounding its offset to whole samples moves it by no more than LAL's no-op shift of 1e-4
samples (gwmock_data.injection.places_whole_samples), as LALSimulation's
XLALSimAddInjectionREAL8TimeSeries places an injection, or when the caller declares it
built on the target's lattice (on_grid). A few float64 steps off the lattice is a genuine
offset for a signal placed at its coalescence time: two steps are 0.24 µs at GPS 1e9.
The target samples filled are those whose position in the injection's own sample index lies in
[0, injection.n_samples - 1]; a single off-lattice injection sample therefore fills none. If
nothing is added (no overlap, or offset skipped), returns a copy of target so the result
is never the same object as target. Both series must be one-dimensional. The samples are
combined on the host, so a JAX-backed input is copied there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
TimeSeries | TimeSeries
|
Background segment (e.g. zeros or noise): a
:class: |
required |
injection
|
TimeSeries | TimeSeries
|
Strain to add (e.g. a projected waveform), of either kind. |
required |
interpolate_if_offset
|
bool
|
If |
True
|
tapered
|
bool
|
Whether |
False
|
on_grid
|
bool
|
Whether |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
New |
TimeSeries
|
class: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If either series is not one-dimensional, the sample rates or units differ, or
|
Source code in src/gwmock_signal/injection/core.py
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 | |
inject_strains_sequential(target, injections, *, interpolate_if_offset=True, tapered=False, on_grid=False)
¶
Apply inject_strain to each series in order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
TimeSeries | TimeSeries
|
Initial segment, a :class: |
required |
injections
|
Sequence[TimeSeries | TimeSeries]
|
Strain series applied in list order, of either kind. |
required |
interpolate_if_offset
|
bool
|
Forwarded to each |
True
|
tapered
|
bool
|
Forwarded to each |
False
|
on_grid
|
bool
|
Forwarded to each |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Final |
TimeSeries
|
class: |
TimeSeries
|
If |
Source code in src/gwmock_signal/injection/core.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
For usage examples, see the User guide — Strain injection examples.