Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mchirp_area codes #2951

Merged
merged 31 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
382d200
Add mchirp_area codes
Sep 23, 2019
985c363
Update mchirp_plots.py
veronica-villa Sep 23, 2019
51c3b83
Update mass_area_plot.py
veronica-villa Sep 25, 2019
20be3d1
Update mchirp_plots.py
veronica-villa Sep 25, 2019
13248b3
Update mass_area_plot.py
veronica-villa Sep 25, 2019
2ee0fc0
Update mchirp_area.py
veronica-villa Sep 25, 2019
c489f49
Update mass_area_plot.py
veronica-villa Sep 25, 2019
e4dafca
Update mass_area_plot.py
veronica-villa Sep 25, 2019
e5ab6bc
Update mchirp_plots.py
veronica-villa Sep 25, 2019
9c67e4c
Update mchirp_plots.py
veronica-villa Sep 25, 2019
9f28b2f
Update mchirp_area.py
veronica-villa Sep 25, 2019
224ec18
Update mass_area_plot.py
veronica-villa Sep 25, 2019
3579c00
Update mass_area_plot.py
veronica-villa Sep 25, 2019
e2735de
Update mass_area_plot.py
veronica-villa Sep 25, 2019
b594dae
Update mass_area_plot.py
veronica-villa Sep 25, 2019
394436a
Update mchirp_area.py
veronica-villa Oct 1, 2019
3698eef
Add docstring
veronica-villa Oct 3, 2019
077b7fb
Add docstrings and aliasing some modules
veronica-villa Oct 3, 2019
526459b
Solving codeclimate issues
veronica-villa Oct 3, 2019
2bc2533
Solving codeclimate issue
veronica-villa Oct 3, 2019
a8afe47
Rename mass_area_plot.py to mass_area_plot
veronica-villa Oct 4, 2019
1bdae05
Rename mass_area_plot to pycbc_mass_area_plot
veronica-villa Oct 4, 2019
b049138
Rename mchirp_plots.py as pycbc_mchirp_plots
veronica-villa Oct 4, 2019
072a6d0
Change equations spacing
veronica-villa Oct 4, 2019
7cf8cb1
Edit docstrings
veronica-villa Oct 4, 2019
3ee168d
Fixing Travis issues
veronica-villa Oct 4, 2019
5a9a043
Delete pycbc_mass_area_plot
veronica-villa Oct 4, 2019
43a492b
Add pycbc_mass_area_plot
veronica-villa Oct 4, 2019
016aeaa
Change some imports
veronica-villa Oct 7, 2019
3a151e1
Delete pycbc_mchirp_plots
veronica-villa Oct 7, 2019
3865f82
Add pycbc_mchirp_plots
veronica-villa Oct 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions bin/plotting/pycbc_mass_area_plot
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/usr/bin/env python
#
# Integration of the area laying in the different cbc regions
# By A. Curiel Barroso
# August 2019

"""This script computes the area corresponding to different CBC on
the m1 & m2 plane when given a central mchirp value and uncertainty.
"""

import argparse
from pycbc.mchirp_area import calc_areas
from pycbc.mchirp_area import src_mass_from_z_det_mass
from pycbc.conversions import mass2_from_mchirp_mass1 as m2mcm1
import numpy
from matplotlib import use; use("Agg")
from matplotlib import pyplot

# ARGUMENT PARSER
parser = argparse.ArgumentParser()
parser.add_argument("--central-mc", type=float, help="Central value of mchirp")
parser.add_argument("--delta-mc", type=float, help="Uncertainty for mchirp")
parser.add_argument("--min-m2", type=float, help="Minimum value for m2")
parser.add_argument("--max-m1", type=float, help="Maximum value for m1")
parser.add_argument("--central-z", type=float, help="Central redshift value")
parser.add_argument("--delta-z", type=float, help="Redshift uncertainty")
parser.add_argument("--ns-max", type=float, help="Maximum neutron star mass")
parser.add_argument("--gap-max", type=float, help="Minimum black hole mass")

args = parser.parse_args()

if args.central_mc and args.delta_mc:
central_mc = float(args.central_mc)
delta_mc = float(args.delta_mc)

if args.min_m2 and args.max_m1:
m2_min = float(args.min_m2)
m1_max = float(args.max_m1)

if args.min_m2 and args.max_m1:
ns_max = float(args.ns_max)
gap_max = float(args.gap_max)

if args.central_z and args.delta_z:
central_z = float(args.central_z)
delta_z = float(args.delta_z)
else:
central_z = 0.0
delta_z = 0.0

mass_limits = {"max_m1": m1_max, "min_m2": m2_min}
mass_bdary = {"ns_max": ns_max, "gap_max": gap_max}
z = {"central": central_z, "delta": delta_z}
trig_mc = {"central": central_mc, "delta": delta_mc}

areas = calc_areas(trig_mc, mass_limits, mass_bdary, z)

print("abbh = " + str(areas["bbh"]))
print("abhg = " + str(areas["bhg"]))
print("agg = " + str(areas["gg"]))
print("ansbh = " + str(areas["nsbh"]))
print("agns = " + str(areas["gns"]))
print("abns = " + str(areas["bns"]))

# PLOT GENERATION
src_mchirp = src_mass_from_z_det_mass(central_z, delta_z,
central_mc, delta_mc)

mcb = src_mchirp[0] + src_mchirp[1]
mcs = src_mchirp[0] - src_mchirp[1]

# The points where the equal mass line and a chirp mass
# curve intersect is m1 = m2 = (2**0.2)*mchirp

mib = (2**0.2)*mcb
mis = (2**0.2)*mcs

lim_m1b = min(m1_max, m2mcm1(mcb, m2_min))
m1b = numpy.linspace(mib, lim_m1b, num=100)
m2b = m2mcm1(mcb, m1b)

lim_m1s = min(m1_max, m2mcm1(mcs, m2_min))
m1s = numpy.linspace(mis, lim_m1s, num=100)
m2s = m2mcm1(mcs, m1s)

if mib > m1_max:
pyplot.plot((m1_max, m1_max), (m2mcm1(mcs, lim_m1s), m1_max), "b")
else:
pyplot.plot(m1b, m2b, "b")
pyplot.plot((m1_max, m1_max), (m2mcm1(mcs, lim_m1s),
m2mcm1(mcb, lim_m1b)),"b")

if mis >= m2_min:
pyplot.plot(m1s, m2s, "b")
pyplot.plot((lim_m1s, lim_m1b), (m2_min, m2_min), "b")
else:
pyplot.plot((m2_min, lim_m1b), (m2_min, m2_min), "b")

pyplot.plot((m2_min, m1_max), (m2_min, m1_max), "k--")
pyplot.plot((ns_max, ns_max), (m2_min, ns_max), "k:")
pyplot.plot((gap_max, gap_max), (m2_min, gap_max), "k:")
pyplot.plot((ns_max, m1_max), (ns_max, ns_max), "k:")
pyplot.plot((gap_max, m1_max), (gap_max, gap_max), "k:")

pyplot.xlabel("M1")
pyplot.ylabel("M2")
pyplot.title("MChirp = " + str(0.5 * (mcb + mcs)) + " +/- "
+ str((mcb - mcs) * 0.5))
pyplot.savefig("mass_plot.png")
81 changes: 81 additions & 0 deletions bin/plotting/pycbc_mchirp_plots
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env python
#
# Integration of the area laying in the different cbc regions
# By A. Curiel Barroso
# August 2019

"""This script computes the area corresponding to different CBC on the m1 & m2
plane as a function of central mchirp value.
"""

import argparse
from pycbc.mchirp_area import calc_areas
import numpy
from matplotlib import use; use("Agg")
from matplotlib import pyplot

# ARGUMENT PARSER
parser = argparse.ArgumentParser()
parser.add_argument("--min-m2", type=float, help="Minimum value for m2")
parser.add_argument("--max-m1", type=float, help="Maximum value for m1")
parser.add_argument("--ns-max", type=float, help="Maximum neutron star mass")
parser.add_argument("--gap-max", type=float, help="Minimum black hole mass")
parser.add_argument("--central-z", type=float, help="Central redshift value")
parser.add_argument("--delta-z", type=float, help="Redshift uncertainty")
args = parser.parse_args()

if args.min_m2 and args.max_m1:
m1_max = float(args.max_m1)
m2_min = float(args.min_m2)

if args.min_m2 and args.max_m1:
ns_max = float(args.ns_max)
gap_max = float(args.gap_max)

if args.central_z and args.delta_z:
central_z = float(args.central_z)
delta_z = float(args.delta_z)
else:
central_z = 0.0
delta_z = 0.0

mass_limits = {"max_m1": m1_max, "min_m2": m2_min}
mass_bdary = {"ns_max": ns_max, "gap_max": gap_max}
z = {"central": central_z, "delta": delta_z}
n = 1000

x_mc = numpy.zeros(n, float)
y_abbh = numpy.zeros(n, float)
y_abhg = numpy.zeros(n, float)
y_agg = numpy.zeros(n, float)
y_ansbh = numpy.zeros(n, float)
y_agns = numpy.zeros(n, float)
y_abns = numpy.zeros(n, float)

for i in range(0, n):
central_mc = 0.8 + i*(10.0 - 0.8)/(n - 1)
delta_mc = central_mc * 0.01
trig_mc = {"central": central_mc, "delta": delta_mc}
x_mc[i] = central_mc
areas = calc_areas(trig_mc, mass_limits, mass_bdary, z)
y_abbh[i] = areas["bbh"]
y_abhg[i] = areas["bhg"]
y_agg[i] = areas["gg"]
y_ansbh[i] = areas["nsbh"]
y_agns[i] = areas["gns"]
y_abns[i] = areas["bns"]

pyplot.plot(x_mc, y_abbh, label="Binary Black Hole")
pyplot.plot(x_mc, y_abhg, label="Black Hole + Mass Gap Object")
pyplot.plot(x_mc, y_agg, label="Binary Mass Gap Object")
pyplot.plot(x_mc, y_ansbh, label="Neutron Star + Black Hole")
pyplot.plot(x_mc, y_agns, label="Neutron Star + Mass Gap Object")
pyplot.plot(x_mc, y_abns, label="Binary Neutron Star")

pyplot.legend()
pyplot.xlabel("Central MChirp (Solar Masses)")
pyplot.ylabel("Area (Solar Masses Squared)")
pyplot.yscale("log")
pyplot.title("Area vs MChirp (1% uncertainty)")

pyplot.savefig("mchirp_plot.png")
Loading