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

fix so that pycbc_plot_singles_timefreq does not fail when there are no triggers #508

Merged
merged 1 commit into from
Oct 19, 2015
Merged
Changes from all commits
Commits
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
17 changes: 12 additions & 5 deletions bin/hdfcoinc/pycbc_plot_singles_timefreq
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ if mask.any():
sorted_rchisq = rchisq[sorter]
sorted_template_ids = template_ids[sorter]

max_rank = max([sorted_rank[i] for i in xrange(len(sorted_rank)) \
if sorted_end_time[i] <= opts.gps_end_time])
try:
max_rank = max([sorted_rank[i] for i in xrange(len(sorted_rank)) \
if sorted_end_time[i] <= opts.gps_end_time])
except ValueError:
max_rank = None

logging.info('Loading bank')
bank = h5py.File(opts.bank_file, 'r')
Expand All @@ -141,7 +144,7 @@ if mask.any():
sorted_template_ids, f_highs):
track_t, track_f = pycbc.pnutils.get_inspiral_tf(
tc - center_time, mass1s[tid], mass2s[tid], opts.f_low, f_high)
if rho == max_rank:
if max_rank and rho == max_rank:
ax.plot(track_t, track_f, '-', color='#ff0000', zorder=3, lw=2)
else:
ax.plot(track_t, track_f, '-', color='#0000ff', zorder=2, alpha=0.02)
Expand All @@ -159,8 +162,12 @@ if mask.any():
else:
interesting_trig_rank = None

title = '%s - loudest %d triggers by %s - max %s = %.2f (red curve)' \
% (opts.channel_name, opts.num_loudest, opts.rank, opts.rank, max_rank)
if max_rank:
title = '%s - loudest %d triggers by %s - max %s = %.2f (red curve)' \
% (opts.channel_name, opts.num_loudest, opts.rank, opts.rank, max_rank)
else:
title = '%s - loudest %d triggers by %s' \
% (opts.channel_name, opts.num_loudest, opts.rank)
if interesting_trig_rank is not None:
title += ' - selected %s = %.2f (green curve)' \
% (opts.rank, interesting_trig_rank)
Expand Down