Skip to content

Commit 51c201b

Browse files
committed
Revert "strip gravitational_wave module"
This reverts commit a457b5e.
1 parent 2fb6364 commit 51c201b

File tree

7 files changed

+132
-0
lines changed

7 files changed

+132
-0
lines changed

docs/gravitational_waves/index.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*************************************************
2+
Gravitational Waves (`skypy.gravitational_waves`)
3+
*************************************************
4+
5+
.. automodule:: skypy.gravitational_waves

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Packages
3333
:maxdepth: 1
3434

3535
galaxies
36+
gravitational_waves/index
3637
utils/index
3738

3839
Pipeline

skypy/gravitational_waves/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
This module contains methods that model the properties of gravitational wave
3+
populations.
4+
5+
Merger Rates
6+
================
7+
8+
.. autosummary::
9+
:nosignatures:
10+
:toctree: ../api/
11+
12+
b_band_merger_rate
13+
14+
"""
15+
16+
from .merger_rate import * # noqa F401,F403
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
2+
r"""Binary merger rate module.
3+
This module provides functions to calculate compact binary merger rates
4+
for individual galaxies.
5+
6+
"""
7+
8+
from astropy import constants, units
9+
10+
11+
__all__ = [
12+
'b_band_merger_rate',
13+
]
14+
15+
16+
abadie_table_III = {
17+
'NS-NS': {
18+
'low': 0.6,
19+
'realistic': 60,
20+
'high': 600,
21+
'max': 2000},
22+
'NS-BH': {
23+
'low': 0.03,
24+
'realistic': 2,
25+
'high': 60},
26+
'BH-BH': {
27+
'low': 0.006,
28+
'realistic': 0.2,
29+
'high': 20}
30+
}
31+
32+
33+
def b_band_merger_rate(luminosity,
34+
population='NS-NS',
35+
optimism='low'):
36+
37+
r"""Model of Abadie et al (2010), Table III
38+
39+
Compact binary merger rates as a linear function of a galaxies
40+
B-band luminosity.
41+
42+
Parameters
43+
----------
44+
luminosity : (ngal,) array-like
45+
The B-band luminosity of the galaxies to generate merger
46+
rates for, in units of solar luminosity.
47+
population : {'NS-NS', 'NS-BH', 'BH-BH'}
48+
Compact binary population to get rate for.
49+
'NS-NS' is neutron star - neutron star
50+
'NS-BH' is neutron star - black hole
51+
'BH-BH' is black hole - black hole
52+
optimism : {'low', 'realistic', 'high'}
53+
Optimism of predicted merger rates.
54+
For 'NS-NS' there is an extra option 'max'.
55+
56+
Returns
57+
-------
58+
merger_rate : array_like
59+
Merger rates for the galaxies in units of year^-1
60+
61+
Notes
62+
-----
63+
64+
References
65+
----------
66+
.. Abadie et al. 2010, Classical and Quantum Gravity,
67+
Volume 27, Issue 17, article id. 173001 (2010)
68+
https://arxiv.org/abs/1003.2480
69+
70+
Examples
71+
--------
72+
>>> import numpy as np
73+
>>> from skypy.gravitational_waves import b_band_merger_rate
74+
75+
Sample 100 luminosity values near absolute magnitude -20.5.
76+
77+
>>> luminosities = 10.**(-0.4*(-20.5 + np.random.randn(100)))
78+
79+
Generate merger rates for these luminosities.
80+
81+
>>> rates = b_band_merger_rate(luminosities,
82+
... population='NS-NS',
83+
... optimism='low')
84+
85+
"""
86+
87+
# Convert luminosity to units of L_10 defined in Abadie et. al. 2010
88+
L_10 = luminosity * constants.L_sun.to_value('erg/s') / (1e10 * 2.16e33)
89+
return abadie_table_III[population][optimism] * L_10 / units.year

skypy/gravitational_waves/tests/__init__.py

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test_import():
2+
import skypy.gravitational_waves
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import numpy as np
2+
from astropy import constants, units
3+
from skypy.gravitational_waves import b_band_merger_rate
4+
from skypy.gravitational_waves.merger_rate import abadie_table_III
5+
6+
7+
def test_abadie_rates():
8+
9+
# Check the number of merger rates returned
10+
luminosity = 10.**(-0.4*(-20.5 + np.random.randn(1000)))
11+
rates = b_band_merger_rate(luminosity, population='NS-NS', optimism='low')
12+
assert len(rates) == len(luminosity)
13+
14+
# Test that a luminosity of L_10 (in units of solar luminosity) returns a
15+
# rate that matches the value in Abadie Table III
16+
L_10 = 1e10 * 2.16e33 / constants.L_sun.to_value('erg/s')
17+
L_B_rate = b_band_merger_rate(L_10, population='NS-NS', optimism='low')
18+
table_value = abadie_table_III['NS-NS']['low']
19+
assert np.isclose(L_B_rate.to_value(1/units.year), table_value, rtol=1e-5)

0 commit comments

Comments
 (0)