Simulation classes#
The Simulation classes form the primary interface for accessing
simulation data. They are the top-level objects that contain all the
data for a single simulation. These classes are designed to be
lightweight and to load data only when needed.
Note that the user will not usually need to interact with these
classes (or the factory) automatically; the sxs.load function will
automatically select the appropriate version of the simulation and
return the appropriate object.
sxs.Simulation factory function#
Construct a Simulation object from a location string
The location string should be an SXS ID with an optional version number, and possibly a Lev specification, as in "SXS:BBH:1234v2.0/Lev5". The default version number is "v2.0", and the default Lev number is the highest available. Note that the version number must be in the form "v2.0", not "2.0", and it must exist, or no files will be found to load the data from.
The returned object will be either a Simulation_v1,
Simulation_v2, or Simulation_v3 object, depending on the
version number. Hopefully, most details of the two versions will
be hidden from the user, so that the interface is identical.
Note that some simulations are deprecated and/or superseded by other simulations. By default, this function will raise an error if you try to load a deprecated or superseded simulation. There are several ways to override this behavior:
- Pass
ignore_deprecation=Trueto completely bypass even checking for deprecation or supersession. No warnings or errors will be issued. - Include an explicit version number in the
locationstring, as in "SXS:BBH:0001v2.0". A warning will be issued that the simulation is deprecated, but it will be loaded anyway. - Pass
auto_supersede=Trueto automatically load the superseding simulation, if there is only one. Because no superseding simulation can be precisely the same as the deprecated one, there may be multiple superseding simulations that have very similar parameters, in which case an error will be raised and you must explicitly choose one. If there is only one, a warning will be issued, but the superseding simulation will be loaded.
Otherwise, a ValueError will be raised, with an explanation and
suggestions on what you might want to do.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
str
|
The location string for the simulation. This must include the SXS ID, but can also include the version and Lev number, as described above. |
required |
Keyword Arguments
ignore_deprecation : bool, optional
If True, completely bypass checking for deprecation or
supersession. No warnings or errors will be issued. Default
is False.
auto_supersede : bool or float, optional
If present, automatically load the closest undeprecated
simulation. If this is a float and the distance to the
closest undeprecated simulation (see the following argument)
is larger, a ValueError will be raised. Otherwise, a warning
will be issued with the ID of the new simulation and the
distance. Note that this can also be set in the configuration
file by calling, e.g.,
sxs.write_config(auto_supersede=True).
metadata_metric : MetadataMetric, optional
Metric to use for comparing simulations when automatically
superseding deprecated a simulation. If not provided, the
default metric will be used.
extrapolation : str, optional
The extrapolation order to use for the strain and Psi4 data.
This is only relevant for versions 1 and 2 of the data format,
both of which default to "N2". Other options include "N3",
"N4", and "Outer". "Nx" refers to extrapolation by
polynomials in 1/r with degree x, while "Outer" refers to
data extracted at the outermost extraction radius but
corrected for time-dilation and areal-radius effects.
download_file_info : bool, optional
If True, download the information about the files from the
CaltechDATA record. If False, only use the file information
that is already available (which will raise an error if the
file information has not previously been downloaded). If not
present, use the value from the configuration file, defaulting
to True if it is not configured.
Returns:
| Name | Type | Description |
|---|---|---|
simulation |
SimulationBase
|
A |
Note that all remaining arguments (including keyword arguments)
|
|
|
are passed on to the `SimulationBase`, `Simulation_v1`,
|
|
|
`Simulation_v2`, and/or `Simulation_v3` constructors, though none
|
|
|
currently recognize any arguments other than those listed above.
|
|
Source code in sxs/simulations/simulation.py
38 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 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 167 168 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 231 232 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 | |
SimulationBase class#
Base class for Simulation objects
Note that users almost certainly never need to call this function;
see the Simulation function or sxs.load function instead.
Attributes:
| Name | Type | Description |
|---|---|---|
metadata |
Metadata or None
|
Metadata object for the simulation. If |
series |
Series
|
The metadata, as extracted from the |
version |
str
|
Version number of the simulation |
sxs_id_stem |
str
|
SXS ID without the version number or Lev |
sxs_id |
str
|
SXS ID with the version number |
location |
str
|
Location string for the simulation, including the SXS ID, version number, and Lev number. |
url |
str
|
URL for the DOI of the simulation |
files |
dict
|
Dictionary of file information for the simulation. The keys are of the form "Lev5:Horizons.h5", and the values are dictionaries with keys "checksum", "size", and "link". |
lev_numbers |
list
|
List of available Lev numbers for the simulation. |
lev_number |
int
|
Chosen Lev number for the simulation. |
horizons |
Horizons
|
Horizons object for the simulation |
strain |
Waveform
|
Strain Waveform object for the simulation. Note that |
psi4 |
Waveform
|
Psi4 Waveform object for the simulation. Note that this
attribute is also case insensitive: |
psi3 |
Waveform
|
Psi3 Waveform object for the simulation. Note that this
attribute is also case insensitive: |
psi2 |
Waveform
|
Psi2 Waveform object for the simulation. Note that this
attribute is also case insensitive: |
psi1 |
Waveform
|
Psi1 Waveform object for the simulation. Note that this
attribute is also case insensitive: |
psi0 |
Waveform
|
Psi0 Waveform object for the simulation. Note that this
attribute is also case insensitive: |
Source code in sxs/simulations/simulation.py
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 443 444 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 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 715 716 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 | |
closest_simulation(dataframe=None, metadata_metric=None, warning_threshold=0.01)
#
Return the closest undeprecated simulation to this one
Note that any simulation in dataframe with zero distance
from this one will be ignored; the returned index will not
refer to this simulation, even if it is undeprecated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
DataFrame of simulations to compare to. If not provided,
the full catalog of simulations will be loaded as
|
None
|
metadata_metric
|
MetadataMetric
|
Metric to use for comparing simulations. If not provided, the default metric will be used. |
None
|
warning_threshold
|
float
|
Threshold distance above which a warning will be issued that the closest simulation is fairly distant. Default is 1e-2. |
0.01
|
Returns:
| Name | Type | Description |
|---|---|---|
closest_index |
str
|
Index of the closest undeprecated simulation in the
|
distance |
float
|
|
Source code in sxs/simulations/simulation.py
distances(dataframe=None, metadata_metric=None, drop_deprecated=False)
#
Measure the distance from this simulation to others
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
DataFrame of simulations to compare to. If not provided,
the full catalog of simulations will be loaded as
|
None
|
metadata_metric
|
MetadataMetric
|
Metric to use for comparing simulations. If not provided, the default metric will be used. |
None
|
drop_deprecated
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
distances |
Series
|
Distance from this simulation to each element of the
|
See Also
simulations_sorted_by_distance : Sort dataframe of simulations by "distance" to this one sxs.metadata.metric.MetadataMetric : Metric for comparing metadata
Source code in sxs/simulations/simulation.py
to_lvk(**kwargs)
#
Convert an SXS simulation to LVK convention.
Returns an SXS waveform (modes or polarizations) and dynamics
(including angular velocities, frame quaternions, and spins) in
the inertial frame that coincides with the waveform-defined frame
defined at a reference time t_ref or reference frequency
f_ref.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t_ref
|
float
|
The reference time at which the waveform frame is specified.
This is measured in units of M, and defined relative to the
epoch time (see below). Either |
required |
f_ref
|
float
|
The reference frequency, in units of cycles/M, at which the
waveform frame is specified. Either |
required |
dt
|
float
|
The time step, in units of M, to which to interpolate the waveform. |
required |
f_low
|
float
|
The lower frequency bound, in units of cycles/M, for the waveform. |
required |
ell_max
|
int
|
The maximum ell to include in the waveform. |
required |
phi_ref
|
float
|
The binary's phase in the coprecessing frame, measured at
|
required |
inclination
|
float
|
Angle between the binary's angular momentum and the line of
sight of the observer, measured at |
required |
ell_max_epoch
|
int
|
The maximum ell to include in the epoch time calculation, which sets t=0 at the maximum of the L^2 norm, calculated by including all modes up to and including this ell value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
times |
float array
|
Uniformly spaced 1D array of times, in units of M, at which the waveform and dynamics quantities are returned. Aligned such that peak of waveform modes with ell=2 is at t=0. |
hlm_dict |
dict[optional]
|
Dictionary of waveform modes in the inertial frame that
coincides with the waveform-defined coprecessing frame at
|
hp, hc : float arrays [optional]
|
1D-arrays of real-valued GW polarizations evaluated in the
frame of the observer at each time node. Polarizations are
computed using all modes up to ell=ell_max, with one value at
each time node. These are returned only if either of the
input values of |
|
dynamics_dict |
dict
|
Dictionary of real-valued arrays of dynamics quantities:
* "t_ref": The reference time at which the waveform frame
is specified.
* "f_ref": The waveform's frequency at |
See also
|
|
|
========
|
|
|
sxs.load : General-purpose function to load SXS data in native
|
format |
|
sxs.waveforms.to_lvc_conventions : Inner function that does all
|
the work for this function |
|
Conventions
|
|
|
===========
|
|
|
We assume geometric units for time (units of M) and frequency
|
|
|
(units of cycles/M), with total mass M equal to 1.
|
|
|
Epoch time is defined by the peak of the $L^2$ norm of the modes:
|
\[t_e = \argmax_t \sum_\ell \sum_m |h_{\ell,m}(t)|^2,\]
|
|
where the sum over $\ell$ ranges from 2 to `ell_max_epoch`. All
|
|
|
time axes are then adjusted so that $t_e = 0$.
|
|
|
Frequencies are measured from the waveform, rather than orbital
|
|
|
trajectories, in terms of the angular-velocity vector given by
|
|
|
equation (7) of arXiv:1302.2919. The frequency is defined as the
|
|
|
magnitude of this vector divided by $2\pi$.
|
|
|
Waveforms, spins, dynamics, times, inclination angle and GW
|
|
|
reference phase are all defined in the inertial frame that
|
|
|
coincides with the "waveform-defined frame" at the reference time.
|
|
|
This frame is chosen so that the $z$ axis is aligned with the
|
|
|
dominant principal axis of the matrix given by equation (2a) of
|
|
|
arXiv |
1109.5224, except that the strain is used in place of
|
|
$\psi_4$. That axis is only determined up to a sign, so we choose
|
|
|
the positive $z$ axis to be more parallel than antiparallel to the
|
|
|
angular velocity. Rotation about the $z$ axis is chosen to
|
|
|
approximate the condition that the more massive black hole is
|
|
|
located on the positive $x$ axis at the reference time, but can be
|
|
|
written solely in terms of the waveform modes:
|
|
|
The first two conditions are necessary for cases of symmetric
|
|
|
systems in which $h_{2,\pm 1}=0$; the last condition breaks the
|
|
|
degeneracy of the first two under rotation about the $z$ axis by
|
|
|
$\pi$. For configurations that are symmetric under that rotation,
|
|
|
$h_{2,1}$ will be zero, so this condition will be impossible to
|
|
|
apply, but the symmetry of the system will mean that there is no
|
|
|
difference in the result.
|
|
|
Quaternion conventions are described in Appendix B of
|
|
|
arXiv |
1110.2965. In particular, we use the convention that
|
Q = q_0 + vec(q) -> (q_0, q_1, q_2, q_3) |
where q_0 is the scalar part.
|
|
Source code in sxs/simulations/simulation.py
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 715 716 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 | |
Simulation_v1 class#
Bases: SimulationBase
Simulation object for version 1 of the data format
Note that users almost certainly never need to call this function;
see the Simulation function or sxs.load function instead. See
also SimulationBase for the base class that this class inherits
from.
Source code in sxs/simulations/simulation.py
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 | |
Simulation_v2 class#
Bases: SimulationBase
Simulation object for version 2 of the data format
Note that users almost certainly never need to call this function;
see the Simulation function or sxs.load function instead. See
also SimulationBase for the base class that this class inherits
from.
Source code in sxs/simulations/simulation.py
Simulation_v3 class#
Bases: Simulation_v2
Simulation object for version 3 of the data format
Note that users almost certainly never need to call this function;
see the Simulation function or sxs.load function instead. See
also SimulationBase for the base class that this class inherits
from.