Multichannel strain examples¶
project_polarizations_to_network returns a mapping
from detector name to one GWpy
TimeSeries
each. Many workflows (frame writers, array-oriented numerics, neural nets, or
legacy code that expects an \((N*\mathrm{det}, N*\mathrm{samples})\) array) need
the same data in a fixed channel order as a single object.
This page is examples only. DetectorStrainStack fields, validation
rules, and method contracts are documented only under
API → Multichannel.
API reference
Use API → Multichannel as the single source of truth for stacking semantics; the snippets below show typical call patterns.
Example 1 — From projection dict to NumPy array¶
import numpy as np
from gwmock_signal.waveform import pycbc_waveform_wrapper
from gwmock_signal.projection import project_polarizations_to_network
from gwmock_signal.multichannel import DetectorStrainStack
names = ["H1", "L1", "V1"]
pol = pycbc_waveform_wrapper(
tc=1_400_000_000.0,
sampling_frequency=4096.0,
minimum_frequency=20.0,
waveform_model="IMRPhenomD",
mass1=30.0,
mass2=24.0,
spin1z=0.0,
spin2z=0.0,
)
strains = project_polarizations_to_network(
pol,
names,
right_ascension=1.1,
declination=-0.2,
polarization_angle=0.4,
earth_rotation=False,
)
stack = DetectorStrainStack.from_mapping(names, strains)
arr = stack.data
assert arr.shape == (len(names), len(strains["H1"]))
print(np.max(np.abs(arr)))
Example 2 — Index by name, export one channel¶
h1_series = stack["H1"]
assert h1_series is stack[0] # same order as names
Example 3 — Round-trip to dict¶
again = stack.to_dict()
assert set(again) == set(names)
Pitfalls¶
- Aligned grid: Every channel must share one compatible GWpy time grid; see the API page for what is validated and which errors are raised.
- Order: Do not assume iteration order of Python dicts; always pass an
explicit
detector_namessequence when stacking. - Copy vs. view:
datamay be a copy for contiguity; do not rely on mutatingdatato change internal GWpy series unless documented. - Units: All channels should use compatible strain units (typically dimensionless).
Scientific notes¶
- Row-stacked strains match how many multi-IFO pipelines treat network data before optional whitening or PSD weighting (those steps stay downstream).