Skip to content

Commit

Permalink
Remove the need for template_duration from plot_singles_timefreq
Browse files Browse the repository at this point in the history
  • Loading branch information
titodalcanton committed Feb 19, 2024
1 parent 6eb28d0 commit 0a5edb9
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions bin/plotting/pycbc_plot_singles_timefreq
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,31 @@ pc = ax.pcolormesh(t + opts.gps_start_time - center_time, freq, Pxx,
norm=norm, cmap='afmhot_r', shading='gouraud')
del freq, Pxx

logging.info('Loading bank')
bank = pycbc.waveform.bank.TemplateBank(
opts.bank_file,
approximant=opts.approximant,
parameters=[
'mass1',
'mass2',
'spin1z',
'spin2z',
'approximant',
'template_duration'
],
load_compressed=False
)
tmplts = bank.table

logging.info('Loading trigs')
trig_f = HFile(opts.trig_file, 'r')
trigs = trig_f[opts.detector]

def rough_filter(snr, chisq, chisq_dof, end_time, tmp_id, tmp_dur):
return np.logical_and(end_time > opts.gps_start_time,
end_time < opts.gps_end_time + tmp_dur)
def rough_filter(snr, chisq, chisq_dof, end_time, tmp_id):
return np.logical_and(
end_time > opts.gps_start_time,
end_time < opts.gps_end_time + tmplts.template_duration[tmp_id]
)

indices, data_tuple = trig_f.select(
rough_filter,
Expand All @@ -112,10 +130,10 @@ indices, data_tuple = trig_f.select(
'chisq_dof',
'end_time',
'template_id',
'template_duration',
group=opts.detector
)
snr, chisq, chisq_dof, end_time, template_ids, template_duration = data_tuple
snr, chisq, chisq_dof, end_time, template_ids = data_tuple
del data_tuple

if len(indices) > 0:
if opts.veto_file:
Expand Down Expand Up @@ -151,13 +169,6 @@ if len(indices) > 0:
except ValueError:
max_rank = None

logging.info('Loading bank')
bank = pycbc.waveform.bank.TemplateBank(opts.bank_file,
approximant=opts.approximant,
parameters=['mass1', 'mass2', 'spin1z', 'spin2z', 'approximant'],
load_compressed=False)
tmplts = bank.table

logging.info('Plotting %d trigs', len(sorted_end_time))
for tc, rho, tid in zip(sorted_end_time, sorted_rank, sorted_template_ids):
track_t, track_f = pycbc.pnutils.get_inspiral_tf(
Expand Down

0 comments on commit 0a5edb9

Please sign in to comment.