sgnligo.sources.sim_inspiral_source
¶
A source element to generate gravitational wave waveforms from injection files.
This module provides the SimInspiralSource class which reads injection parameters from XML (LIGOLW) or HDF5 files and generates time-domain waveforms projected onto each detector with proper time delays, antenna patterns, and phase corrections.
All injection parameters are stored internally as LAL dictionaries (lal.Dict) in SI units, which allows pass-through of all LAL-supported parameters including tidal deformability, higher-order modes, and approximant-specific settings.
CachedWaveform
dataclass
¶
Cached waveform data for an injection.
Each detector has its own LAL REAL8TimeSeries which includes: - epoch: GPS time of first sample (accounts for light travel time) - deltaT: Sample spacing (1/sample_rate) - data: The strain values
Using LAL TimeSeries preserves sub-sample timing information needed for proper interpolation when injecting into buffers.
Source code in sgnligo/sources/sim_inspiral_source.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
get_end_gps(ifo)
¶
Get the GPS end time for a specific IFO.
Source code in sgnligo/sources/sim_inspiral_source.py
230 231 232 233 234 235 | |
get_max_end_gps()
¶
Get the latest end GPS time across all IFOs.
Source code in sgnligo/sources/sim_inspiral_source.py
237 238 239 | |
SimInspiralSource
dataclass
¶
Bases: TSSource
flowchart TD
sgnligo.sources.sim_inspiral_source.SimInspiralSource[SimInspiralSource]
click sgnligo.sources.sim_inspiral_source.SimInspiralSource href "" "sgnligo.sources.sim_inspiral_source.SimInspiralSource"
Source element that generates GW waveforms from an injection file or test mode.
Reads injection parameters from XML (LIGOLW SimInspiralTable) or HDF5 files and generates time-domain waveforms projected onto each detector with proper time delays, antenna patterns, and phase corrections using LALSimulation.
Alternatively, test mode can be used to generate periodic test injections (BNS, NSBH, or BBH) every 30 seconds, positioned directly overhead of State College, PA.
All injection parameters are stored as InjectionParams objects, which use LAL dictionaries internally for pass-through of any LAL-supported parameters including tidal deformability, higher-order modes, and approximant-specific settings.
The source outputs zeros + summed injection signals on separate pads for each interferometer. Combine with a noise source using an Adder transform to create realistic data with injections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
injection_file
|
Optional[str]
|
Path to injection file (XML or HDF5). Mutually exclusive with test_mode. |
None
|
test_mode
|
Optional[str]
|
Generate test injections instead of loading from file. Valid values: "bns" (100 Mpc), "nsbh" (200 Mpc), "bbh" (500 Mpc). Mutually exclusive with injection_file. |
None
|
ifos
|
Optional[List[str]]
|
List of interferometer prefixes, e.g., ["H1", "L1", "V1"] |
None
|
sample_rate
|
int
|
Output sample rate in Hz (default: 16384) |
16384
|
f_min
|
float
|
Minimum frequency for waveform generation in Hz (default: 10) |
10.0
|
approximant_override
|
Optional[str]
|
Override approximant for all injections (optional) |
None
|
Example
Using injection file¶
source = SimInspiralSource( ... name="Injections", ... injection_file="injections.xml", ... ifos=["H1", "L1"], ... t0=1234567890, ... end=1234567900, ... )
Using test mode¶
source = SimInspiralSource( ... name="TestInjections", ... test_mode="bbh", ... ifos=["H1", "L1"], ... t0=1234567890, ... end=1234567900, ... )
Source code in sgnligo/sources/sim_inspiral_source.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | |
__post_init__()
¶
Initialize the source.
Source code in sgnligo/sources/sim_inspiral_source.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
internal()
¶
Internal processing - cleanup expired waveforms.
Source code in sgnligo/sources/sim_inspiral_source.py
624 625 626 627 628 629 630 631 632 633 | |
new(pad)
¶
Generate a new frame with injection signals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pad
|
SourcePad
|
Source pad requesting new data |
required |
Returns:
| Type | Description |
|---|---|
TSFrame
|
TSFrame containing injection signals (zeros + waveforms) |
Source code in sgnligo/sources/sim_inspiral_source.py
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | |
WaveformCache
¶
Manages waveform generation and caching.
Waveforms are generated on-demand and cached until they're fully consumed (i.e., the pipeline has moved past the waveform's end time).
Source code in sgnligo/sources/sim_inspiral_source.py
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 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
__init__(injections, ifos, sample_rate, f_min, approximant_override=None, test_mode=None)
¶
Initialize the waveform cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
injections
|
List[InjectionParams]
|
List of InjectionParams with injection parameters |
required |
ifos
|
List[str]
|
List of interferometer prefixes |
required |
sample_rate
|
int
|
Output sample rate in Hz |
required |
f_min
|
float
|
Minimum frequency for waveform generation |
required |
approximant_override
|
Optional[str]
|
Override approximant for all injections |
None
|
test_mode
|
Optional[str]
|
If set, generate test injections ("bns", "nsbh", "bbh") |
None
|
Source code in sgnligo/sources/sim_inspiral_source.py
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 | |
add_injection_to_target(inj_id, ifo, target)
¶
Add an injection waveform to a target buffer using proper interpolation.
Uses SimAddInjectionREAL8TimeSeries which performs sub-sample re-interpolation in the frequency domain to properly align the injection epoch to integer sample boundaries in the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inj_id
|
int
|
Injection index |
required |
ifo
|
str
|
Interferometer prefix |
required |
target
|
REAL8TimeSeries
|
Target LAL REAL8TimeSeries to add injection into (modified in place) |
required |
Source code in sgnligo/sources/sim_inspiral_source.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
cleanup_expired(current_gps)
¶
Remove waveforms that are fully consumed.
A waveform is expired when all IFOs have moved past it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_gps
|
float
|
Current GPS time of the pipeline |
required |
Source code in sgnligo/sources/sim_inspiral_source.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
get_overlapping_injections(buf_start, buf_end)
¶
Find injections that overlap the buffer time window.
For test mode, this also ensures test injections exist for the query range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buf_start
|
float
|
Buffer start GPS time |
required |
buf_end
|
float
|
Buffer end GPS time |
required |
Returns:
| Type | Description |
|---|---|
List[int]
|
List of injection indices that overlap the buffer |
Source code in sgnligo/sources/sim_inspiral_source.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
estimate_waveform_duration(params, f_min)
¶
Estimate the duration of a waveform before and after merger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Dict
|
LAL dict with injection parameters (masses in SI units) |
required |
f_min
|
float
|
Minimum frequency for waveform generation (Hz) |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
Tuple of (pre_merger_duration, post_merger_duration) in seconds |
Source code in sgnligo/sources/sim_inspiral_source.py
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 | |
generate_waveform_td(params, sample_rate, f_min, approximant_override=None)
¶
Generate time-domain h+, hx waveforms from LAL parameter dict.
Uses LALSimulation's unified generator interface which automatically handles both time-domain and frequency-domain approximants. All parameters from the input dict are passed through to the generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Dict
|
LAL dict with injection parameters (masses/distance in SI units) |
required |
sample_rate
|
int
|
Sample rate in Hz |
required |
f_min
|
float
|
Minimum frequency in Hz |
required |
approximant_override
|
Optional[str]
|
Override the approximant from the dict |
None
|
Returns:
| Type | Description |
|---|---|
tuple[REAL8TimeSeries, REAL8TimeSeries]
|
Tuple of (hp, hc) as LAL REAL8TimeSeries objects |
Source code in sgnligo/sources/sim_inspiral_source.py
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 167 168 | |
project_to_detector(hp, hc, params, ifo)
¶
Project h+, hx waveforms onto a detector.
Uses LALSimulation's accurate projection which handles: - Antenna response (F+, Fx) - Light travel time delays - Phase corrections
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hp
|
REAL8TimeSeries
|
Plus polarization time series |
required |
hc
|
REAL8TimeSeries
|
Cross polarization time series |
required |
params
|
Dict
|
LAL dict with sky position and polarization |
required |
ifo
|
str
|
Interferometer prefix (H1, L1, V1, etc.) |
required |
Returns:
| Type | Description |
|---|---|
REAL8TimeSeries
|
Detector strain as REAL8TimeSeries |
Source code in sgnligo/sources/sim_inspiral_source.py
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 | |