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
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 | |
get_end_gps(ifo)
¶
Get the GPS end time for a specific IFO.
Source code in sgnligo/sources/sim_inspiral_source.py
505 506 507 508 509 510 | |
get_max_end_gps()
¶
Get the latest end GPS time across all IFOs.
Source code in sgnligo/sources/sim_inspiral_source.py
512 513 514 | |
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 LAL dictionaries, which allows 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
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 | |
__post_init__()
¶
Initialize the source.
Source code in sgnligo/sources/sim_inspiral_source.py
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | |
internal()
¶
Internal processing - cleanup expired waveforms.
Source code in sgnligo/sources/sim_inspiral_source.py
893 894 895 896 897 898 899 900 901 902 | |
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
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 | |
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
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 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |
__init__(injections, ifos, sample_rate, f_min, approximant_override=None, test_mode=None)
¶
Initialize the waveform cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
injections
|
List[Dict]
|
List of LAL dicts 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
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 | |
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
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | |
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
700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |
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
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | |
calculate_overhead_ra(gps_time, longitude_rad)
¶
Calculate the right ascension for a source directly overhead at a location.
For a source to be at zenith (directly overhead), its right ascension must equal the local sidereal time (LST) at the observer's location.
LST = GMST + longitude (where longitude is positive east, negative west)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gps_time
|
float
|
GPS time of observation (e.g., coalescence time) |
required |
longitude_rad
|
float
|
Observer longitude in radians (negative for west) |
required |
Returns:
| Type | Description |
|---|---|
float
|
Right ascension in radians, normalized to [0, 2π) |
Source code in sgnligo/sources/sim_inspiral_source.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
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
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 | |
generate_test_injection(test_mode, t_co_gps, latitude_rad=STATE_COLLEGE_LAT_RAD, longitude_rad=STATE_COLLEGE_LON_RAD)
¶
Generate a test injection for the given GPS coalescence time.
Creates a LAL dictionary with injection parameters for a test signal positioned directly overhead of the specified location at coalescence time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_mode
|
str
|
Type of injection ("bns", "nsbh", or "bbh") |
required |
t_co_gps
|
float
|
GPS coalescence time |
required |
latitude_rad
|
float
|
Observer latitude in radians (default: State College, PA) |
STATE_COLLEGE_LAT_RAD
|
longitude_rad
|
float
|
Observer longitude in radians (default: State College, PA) |
STATE_COLLEGE_LON_RAD
|
Returns:
| Type | Description |
|---|---|
Dict
|
LAL dictionary with injection parameters in SI units |
Source code in sgnligo/sources/sim_inspiral_source.py
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 | |
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
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 443 | |
load_injections(filepath)
¶
Load injections from XML or LAL H5 file with auto-detection.
Supports LIGOLW XML (.xml, .xml.gz) and LAL HDF5 (.h5, .hdf5, .hdf) formats. The HDF5 format must be the official LAL format with 'cbc_waveform_params' group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Path to injection file |
required |
Returns:
| Type | Description |
|---|---|
List[Dict]
|
List of LAL dictionaries containing injection parameters in SI units |
Source code in sgnligo/sources/sim_inspiral_source.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
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
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 | |