Coverage for pesummary/gw/conversions/mass.py: 83.1%
59 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
1# Licensed under an MIT style license -- see LICENSE.md
3from pesummary.utils.decorators import array_input
5__author__ = ["Charlie Hoy <charlie.hoy@ligo.org>"]
8@array_input()
9def mass2_from_m1_q(mass1, q):
10 """Return the secondary mass given samples for mass1 and mass ratio
11 """
12 return mass1 * q
15@array_input()
16def m_total_from_m1_m2(mass1, mass2):
17 """Return the total mass given the samples for mass1 and mass2
18 """
19 return mass1 + mass2
22@array_input()
23def component_mass_product(mass1, mass2):
24 """Return the product of mass1 and mass2
25 """
26 return mass1 * mass2
29@array_input()
30def mchirp_from_m1_m2(mass1, mass2):
31 """Return the chirp mass given the samples for mass1 and mass2
33 Parameters
34 ----------
35 """
36 total_mass = m_total_from_m1_m2(mass1, mass2)
37 return component_mass_product(mass1, mass2)**0.6 / total_mass**0.2
40@array_input()
41def component_masses_from_mtotal_q(mtotal, q):
42 """Return the primary and secondary masses given samples for the total mass
43 and mass ratio
44 """
45 m1 = mtotal / (1. + q)
46 return m1, mass2_from_m1_q(m1, q)
49@array_input()
50def component_masses_from_mchirp_q(mchirp, q):
51 """Return the primary and secondary masses given samples for the chirp mass
52 and mass ratio
53 """
54 m1 = ((1. / q)**(2. / 5.)) * ((1.0 + (1. / q))**(1. / 5.)) * mchirp
55 return m1, mass2_from_m1_q(m1, q)
58@array_input()
59def m1_from_mchirp_q(mchirp, q):
60 """Return the mass of the larger component given the chirp mass and
61 mass ratio
62 """
63 return component_masses_from_mchirp_q(mchirp, q)[0]
66@array_input()
67def m2_from_mchirp_q(mchirp, q):
68 """Return the mass of the smaller component given the chirp mass and
69 mass ratio
70 """
71 return component_masses_from_mchirp_q(mchirp, q)[1]
74@array_input()
75def m1_from_mtotal_q(mtotal, q):
76 """Return the mass of the larger component given the total mass and
77 mass ratio
78 """
79 return component_masses_from_mtotal_q(mtotal, q)[0]
82@array_input()
83def m2_from_mtotal_q(mtotal, q):
84 """Return the mass of the smaller component given the total mass and
85 mass ratio
86 """
87 return component_masses_from_mtotal_q(mtotal, q)[1]
90@array_input()
91def eta_from_m1_m2(mass1, mass2):
92 """Return the symmetric mass ratio given the samples for mass1 and mass2
93 """
94 total_mass = m_total_from_m1_m2(mass1, mass2)
95 return component_mass_product(mass1, mass2) / total_mass**2
98@array_input()
99def eta_from_mtotal_q(total_mass, mass_ratio):
100 """Return the symmetric mass ratio given samples for the total mass and
101 mass ratio
102 """
103 mass1, mass2 = component_masses_from_mtotal_q(total_mass, mass_ratio)
104 return eta_from_m1_m2(mass1, mass2)
107@array_input()
108def q_from_m1_m2(mass1, mass2):
109 """Return the mass ratio given the samples for mass1 and mass2
110 """
111 return mass2 / mass1
114@array_input()
115def invq_from_m1_m2(mass1, mass2):
116 """Return the inverted mass ratio (mass1/mass2 for mass1 > mass2)
117 given the samples for mass1 and mass2
118 """
119 return 1. / q_from_m1_m2(mass1, mass2)
122@array_input()
123def invq_from_q(mass_ratio):
124 """Return the inverted mass ratio (mass1/mass2 for mass1 > mass2)
125 given the samples for mass ratio (mass2/mass1)
126 """
127 return 1. / mass_ratio
130@array_input()
131def q_from_eta(symmetric_mass_ratio):
132 """Return the mass ratio given samples for symmetric mass ratio
133 """
134 temp = (1 / symmetric_mass_ratio / 2 - 1)
135 return (temp - (temp ** 2 - 1) ** 0.5)
138@array_input()
139def mchirp_from_mtotal_q(total_mass, mass_ratio):
140 """Return the chirp mass given samples for total mass and mass ratio
141 """
142 return eta_from_mtotal_q(total_mass, mass_ratio)**(3. / 5) * total_mass