Batched simulation
gwmock_signal.jax_batch
¶
Batched, on-device CBC simulation for catalogue-scale generation.
Generates a whole catalogue of compact-binary signals on device: ripple
frequency-domain waveforms under jax.vmap (one shared, worst-case grid), then
the JAX antenna pattern + geocenter delay + inverse FFT per event and detector.
The result is raw strain arrays plus timing metadata; injecting those signals into
fixed-duration data-segment files (including signals spanning several segments) is
a separate assembly step.
Requires the optional [jax] extra (via :class:RippleBackend). JAX is imported
lazily so the package still imports without it.
BatchedDetectorStrain
dataclass
¶
Catalogue-scale detector strain as raw arrays plus timing metadata.
strain has shape (n_events, n_detectors, n_samples) and is a JAX array
(on device). Each event/detector row is a time series with sample spacing
1 / sampling_frequency whose first sample is at GPS time
epoch + coa_time[event] (coalescence sits -epoch seconds from the start,
near the segment end). The signals are not yet placed on a shared timeline or
segmented into files — that assembly step injects them into fixed-duration data
segments and is handled separately.
Source code in src/gwmock_signal/jax_batch.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
assemble_segments(batch, *, segment_duration, segment_start_times, backgrounds=None, interpolate_if_offset=True)
¶
Scatter the batched signals into fixed-duration data segments (in memory).
Each output segment spans [start, start + segment_duration). Every signal
that overlaps a segment is injected into it with
:func:~gwmock_signal.injection.inject_strains_sequential, which crops the
signal to the segment span — so a signal longer than segment_duration
contributes its overlapping part to each of the consecutive segments it spans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
BatchedDetectorStrain
|
Batched per-event/detector strain from :func: |
required |
segment_duration
|
float
|
Duration of every output segment, in seconds. |
required |
segment_start_times
|
Sequence[float]
|
GPS start time of each output segment (typically a
contiguous tiling, e.g. |
required |
backgrounds
|
Sequence[Mapping[str, TimeSeries]] | None
|
Optional per-segment backgrounds, aligned with
|
None
|
interpolate_if_offset
|
bool
|
Forwarded to |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
One |
list[DetectorStrainStack]
|
class: |
list[DetectorStrainStack]
|
entry in |
|
list[DetectorStrainStack]
|
|
Source code in src/gwmock_signal/jax_batch.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
simulate_cbc_batch(approximant, detector_names, *, sampling_frequency, minimum_frequency, parameters, backend=None)
¶
Simulate a catalogue of CBC signals on device, one strain per event and detector.
Evaluates ripple frequency-domain waveforms for the whole catalogue under
jax.vmap (a single grid sized worst-case for the longest inspiral), then
projects each event onto each detector with the JAX antenna pattern and
geocenter delay and inverse-FFTs to strain. The antenna pattern and delay are
evaluated once per event at the segment midpoint (earth_rotation=False),
matching :func:gwmock_signal.projection.network.project_polarizations_to_network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
approximant
|
str
|
A supported ripple approximant name. |
required |
detector_names
|
Sequence[str]
|
Detector codes (e.g. |
required |
sampling_frequency
|
float
|
Sample rate in Hz. |
required |
minimum_frequency
|
float
|
Low-frequency cutoff in Hz. |
required |
parameters
|
Mapping[str, object]
|
Mapping of canonical gwmock-pop parameter names (no aliases)
to equal-length 1-D arrays. In addition to the waveform parameters
(masses, spins, distance, inclination, coa_phase) this must include
|
required |
backend
|
RippleBackend | None
|
Optional configured :class: |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
BatchedDetectorStrain
|
class: |
BatchedDetectorStrain
|
n_samples)`` strain and per-event timing metadata. |
Source code in src/gwmock_signal/jax_batch.py
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 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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
simulate_cbc_catalogue(approximant, detector_names, *, sampling_frequency, minimum_frequency, parameters, segment_duration, start_time, end_time, backend=None, n_chirp_mass_bins=1, chunk_size=None, interpolate_if_offset=True)
¶
Generate a catalogue on device and assemble it into fixed-duration segments.
Convenience wrapper that runs :func:simulate_cbc_batch and then
:func:assemble_segments, tiling [start_time, end_time) into contiguous
zero-noise segments of segment_duration. Signals are placed at their
coa_time and split across the segments they span; signals outside the span
simply do not appear. For non-zero backgrounds use the two-step API
(:func:simulate_cbc_batch then :func:assemble_segments) so you can supply a
background per segment.
Two independent memory controls (composable):
chunk_sizebounds the peak generation memory by processing at most that many events per batched call. All chunks of a bin share that bin's grid, so chunking is output-identical to processing the whole bin at once.n_chirp_mass_binsbounds the buffer length by generating heavier events on shorter grids. Because each bin uses a different frequency resolution, binning is not bit-identical to a single grid (see below).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
approximant
|
str
|
A supported ripple approximant name. |
required |
detector_names
|
Sequence[str]
|
Detector codes (e.g. |
required |
sampling_frequency
|
float
|
Sample rate in Hz. |
required |
minimum_frequency
|
float
|
Low-frequency cutoff in Hz. |
required |
parameters
|
Mapping[str, object]
|
Canonical catalogue parameters as struct-of-arrays (see
:func: |
required |
segment_duration
|
float
|
Duration of every output segment, in seconds. |
required |
start_time
|
float
|
GPS start of the first segment. |
required |
end_time
|
float
|
GPS time the tiling must cover up to; the final segment is the
first one whose span reaches or passes |
required |
backend
|
RippleBackend | None
|
Optional configured :class: |
None
|
n_chirp_mass_bins
|
int
|
Number of chirp-mass groups generated separately, each on
its own worst-case grid (lightest first), injected on top of the
earlier bins. |
1
|
chunk_size
|
int | None
|
If set, generate at most this many events per batched call
(within each bin). Output-identical to |
None
|
interpolate_if_offset
|
bool
|
Forwarded to :func: |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
One |
list[DetectorStrainStack]
|
class: |
list[DetectorStrainStack]
|
segment, in time order. |
Source code in src/gwmock_signal/jax_batch.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
For the narrative guide and examples, see Batched GPU simulation. For the single-event CPU path, see Pipeline and Simulator.