Skip to content

Commit 7bdda97

Browse files
lmuccillotitodalcanton
authored andcommitted
Add Effective precession spin chi_p to pycbc_pygrb_plot_injs_results (#5203)
* added chi_p to the variables available for PyGRB plots * fix: applied reviewer’s requested changes * Simplify logic --------- Co-authored-by: Tito Dal Canton <[email protected]>
1 parent 6cb2602 commit 7bdda97

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

bin/pygrb/pycbc_pygrb_plot_injs_results

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def process_var_strings(qty):
5656
qty = qty.replace('endtime', 'end_time')
5757
qty = qty.replace('spin1a', 'spin1_a')
5858
qty = qty.replace('spin2a', 'spin2_a')
59+
qty = qty.replace('chip', 'chi_p')
5960

6061
return qty
6162

@@ -105,6 +106,20 @@ def complete_mass_data(injs, key, tag):
105106
return data
106107

107108

109+
def complete_spin_data(injs, tag):
110+
"""Extract data related to effective precession spin from raw injection data"""
111+
112+
mass1 = injs[tag+'/mass1']
113+
mass2 = injs[tag+'/mass2']
114+
spin1x = injs[tag+'/spin1x']
115+
spin1y = injs[tag+'/spin1y']
116+
spin2x = injs[tag+'/spin2x']
117+
spin2y = injs[tag+'/spin2y']
118+
119+
data = pycbc.conversions.chi_p(mass1, mass2, spin1x, spin1y, spin2x, spin2y)
120+
return data
121+
122+
108123
def complete_sky_error_data(injs, tag):
109124
"""Extract data related to sky_error from raw injection and trigger data"""
110125

@@ -148,6 +163,8 @@ def complete_inj_data(injs, keys, tag, ifos=[]):
148163
# data_dict[key] -= grb_time
149164
elif key in ['mchirp', 'mtotal', 'q']:
150165
data_dict[key] = complete_mass_data(injs, key, tag)
166+
elif key == 'chi_p':
167+
data_dict[key] = complete_spin_data(injs, tag)
151168
elif 'incl' in key:
152169
data_dict[key] = complete_incl_data(injs, key, tag)
153170
elif key == 'sky_error':
@@ -196,7 +213,7 @@ admitted_vars = easy_keys + ['mtotal', 'q', 'mchirp',
196213
'sky_error', 'skyerror', 'end_time', 'endtime',
197214
'dec', 'ra', 'coaphase', 'coa_phase',
198215
'eff_site_dist', 'eff_dist',
199-
'effsitedist', 'effdist']
216+
'effsitedist', 'effdist', 'chip', 'chi_p']
200217
admitted_vars = sorted(set(admitted_vars))
201218

202219
parser = ppu.pygrb_initialize_plot_parser(description=__doc__)
@@ -429,7 +446,8 @@ axis_labels_dict = {'mchirp': "Chirp Mass (solar masses)",
429446
'spin2_a': "Spin on 2nd binary component",
430447
'spin2x': "Spin x-component of 2nd binary component",
431448
'spin2y': "Spin y-component of 2nd binary component",
432-
'spin2z': "Spin z-component of 2nd binary component"}
449+
'spin2z': "Spin z-component of 2nd binary component",
450+
'chi_p': "Effective precession spin"}
433451

434452
fig = plt.figure()
435453
ax = fig.gca()
@@ -521,6 +539,12 @@ if "spin" in y_qty and missed_inj['spin2_a'].size:
521539
ax.set_ylim([0, np.ceil(10 * max(max_missed_inj,
522540
found_inj[y_qty].max())) / 10])
523541

542+
# Handle axis limits when plotting chi_p
543+
if x_qty == 'chi_p':
544+
ax.set_xlim(0, 1)
545+
if y_qty == 'chi_p':
546+
ax.set_ylim(0, 1)
547+
524548
# Handle axis limits when plotting inclination
525549
if "incl" in x_qty or "incl" in y_qty:
526550
max_inc = np.pi
@@ -601,7 +625,8 @@ if plot_title is None:
601625
'spin2_a': "spin",
602626
'spin2x': "spin x-component",
603627
'spin2y': "spin y-component",
604-
'spin2z': "spin z-component"}
628+
'spin2z': "spin z-component",
629+
'chi_p': "Effective precession spin"}
605630

606631
if "sky_error" in [x_qty, y_qty]:
607632
plot_title = "Sky error of recovered injections"

0 commit comments

Comments
 (0)