-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfigure1.py
executable file
·99 lines (86 loc) · 3.56 KB
/
figure1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2023
# Maximiliano Isi <[email protected]>
# Will M. Farr <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
from matplotlib import pyplot as plt
import os
import pickle as pkl
import seaborn as sns
from utils.constants import *
import utils.plots as pu
import paths
sns.set(context='notebook', palette='colorblind', style='ticks')
# ----------------------------------------------------------------------------
# LOAD DATA
keys = [
"pyring_t0-good_timestamps-good_seglen-good",
"ringdown_t0-good_timestamps-good_seglen-good",
"pyring_t0-bad_timestamps-bad_seglen-bad",
"ringdown_t0-bad_timestamps-good_seglen-bad",
"ringdown_t0-bad_timestamps-good_seglen-good",
]
fname = paths.data / 'fig1_samples_dict.pkl'
with open(fname, 'rb') as f:
samples = pkl.load(f)
# ----------------------------------------------------------------------------
# PLOT
plot_scale_exp = -20
def plot_curves(plot_kws, ax):
for k, kws in plot_kws.items():
x = samples[k]
sns.histplot(x/10**plot_scale_exp, element='step', fill=False,
stat='density', ax=ax, **kws)
fig, (ax, axins) = plt.subplots(2, figsize=pu.figsize_column)
plot_kws = {
"pyring_t0-bad_timestamps-bad_seglen-bad":
dict(alpha=0.8, color='k', ls=':',
label='Cotesta+2022 "$-0.72M$"\n'+r'($t_0 = t_{\rm ref} - 0.5M,T=0.1\,{\rm s}$)'),
"ringdown_t0-good_timestamps-good_seglen-good":
dict(lw=2, color=sns.color_palette()[0],
label='ringdown\n'+r'($t_0 = t_{\rm ref},T=0.2\,{\rm s}$)'),
"pyring_t0-good_timestamps-good_seglen-good":
dict(lw=2, color=sns.color_palette()[0], ls='--',
label='PyRing\n'+r'($t_0 = t_{\rm ref},T=0.2\,{\rm s}$)'),
}
plot_curves(plot_kws, ax)
inset_kws = {
"pyring_t0-bad_timestamps-bad_seglen-bad":
dict(alpha=0.8, ls=':', color='k'),
"ringdown_t0-bad_timestamps-good_seglen-bad":
dict(alpha=0.5, lw=1.5, color=sns.color_palette(desat=0.25)[2],
label='fixed time-stamps\n'+r'($t_0 = t_{\rm ref} - 0.5M,T=0.1\,{\rm s}$)'),
"ringdown_t0-bad_timestamps-good_seglen-good":
dict(lw=2, ls='-', color=sns.color_palette(desat=1)[2],
label='fixed time-stamps & duration\n'+r'($t_0 = t_{\rm ref} - 0.5M,T=0.2\,{\rm s}$)'),
}
plot_curves(inset_kws, axins)
plt.subplots_adjust(hspace=0)
fig.canvas.draw()
yl = [tick.get_text() for tick in axins.get_yticklabels()]
axins.set_yticklabels(yl[:-2])
axins.tick_params(direction='in')
ax.tick_params(direction='in', labelbottom=False)
axins.set_xlabel(r'$A_1\, /\, 10^{{{}}}$'.format(plot_scale_exp))
for a in [ax, axins]:
a.legend()
a.set_xlim(-0.02, 1.75)
a.set_ylim(0, 2)
figpath = os.path.join(paths.figures, "a1_posterior_at_reference_time.pdf")
plt.savefig(figpath, bbox_inches='tight')