Skip to content

Commit 4d7ff86

Browse files
committed
Generalize fit plotting
1 parent 6f69268 commit 4d7ff86

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

Diff for: bin/plotting/pycbc_page_ifar_vs_stat

+17-17
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,28 @@ ax = fig.add_subplot(111)
5454

5555
ifar_calc_points = np.linspace(-10, 30, 200)
5656

57-
singles = []
57+
fitted = [] # List of combos for which a fit is used
5858
for f in opts.trigger_files:
5959
logging.info(f"Opening {f}")
6060
with h5py.File(f, 'r') as exc_zlag_f:
61-
event_ifos = exc_zlag_f.attrs['ifos'].split()
62-
coinc_key = ''.join(event_ifos).replace('1', '')
61+
logging.info(f"Ifos {exc_zlag_f.attrs['ifos']}") # eg 'H1 L1'
62+
sig_key = exc_zlag_f.attrs['ifos'].replace(' ', '') # eg 'H1L1'
63+
coinc_key = sig_key.replace('1', '') # eg 'HL'
6364
stat_exc = exc_zlag_f['background_exc']['stat'][:]
6465
dec_fac_exc = exc_zlag_f['background_exc']['decimation_factor'][:]
6566
bg_time = convert_s_to_y(exc_zlag_f.attrs['background_time_exc'])
6667
ifar_file = exc_zlag_f['background_exc']['ifar'][:]
67-
68-
logging.info(f"Min {coinc_key} IFAR: {min(ifar_file)}")
6968
logging.info(f"{coinc_key} background time (y): {bg_time}")
70-
if len(event_ifos) == 1:
71-
ifo = event_ifos[0]
72-
singles.append(ifo)
73-
fit_thresh = sig_dict[ifo]['fit_threshold']
69+
70+
# If fitting / extrapolation is done
71+
if sig_dict[sig_key]['method'] == 'trigger_fit':
72+
fitted.append(sig_key)
73+
fit_thresh = sig_dict[sig_key]['fit_threshold']
7474
far_tuple = significance.get_far(stat_exc,
7575
ifar_calc_points,
7676
dec_fac_exc,
7777
bg_time,
78-
**sig_dict[ifo])
78+
**sig_dict[sig_key])
7979
far = far_tuple[1] # Version-proof: get_far returns 2 or 3 values
8080

8181
# Plot n-louder points with a solid line and sngl fits with dashed
@@ -86,7 +86,7 @@ for f in opts.trigger_files:
8686
far[ifar_calc_points > fit_thresh],
8787
coinc_line_map[coinc_key],
8888
c=coinc_color_map[coinc_key], label=coinc_key, zorder=-5)
89-
del ifo, fit_thresh, far # avoid variables hanging around
89+
del fit_thresh # avoid variable hanging around
9090

9191
else:
9292
far_tuple = significance.get_far(stat_exc,
@@ -98,12 +98,12 @@ for f in opts.trigger_files:
9898
ax.plot(ifar_calc_points, far_tuple[1], '-',
9999
c=coinc_color_map[coinc_key], label=coinc_key, zorder=-5)
100100

101-
del far_tuple # avoid variable hanging around
101+
del sig_key, coinc_key, far_tuple # avoid variables hanging around
102102

103103
# Plot the thresholds
104-
for ifo in singles:
105-
ax.axvline(sig_dict[ifo]['fit_threshold'], ls='--', zorder=-10,
106-
c=coinc_color_map[ifo.rstrip('1')])
104+
for combo in fitted:
105+
ax.axvline(sig_dict[combo]['fit_threshold'], ls='-.', zorder=-10,
106+
c=coinc_color_map[combo.replace('1', '')])
107107

108108
ax.semilogy()
109109
ax.legend(ncol=2, fontsize=12)
@@ -120,8 +120,8 @@ ax.set_ylabel('Cumulative Event Rate [y$^{-1}$]', fontsize=16)
120120
# Save
121121
caption = 'Cumulative rates of noise events for separate event types. Solid ' \
122122
'lines represent estimates from counts of louder (zerolag or time ' \
123-
'shifted) events. Dashed lines represent estimates from fit ' \
124-
'extrapolation for single-detector events.'
123+
'shifted) events. Dashed lines represent estimates from fitting / ' \
124+
'extrapolation.'
125125

126126
results.save_fig_with_metadata(fig, opts.output_file,
127127
fig_kwds={'bbox_inches': 'tight'},

0 commit comments

Comments
 (0)