Skip to content

Commit

Permalink
Addressed more comments from Tom
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtrevor committed Jan 22, 2024
1 parent 635360c commit 0a03a9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
2 changes: 2 additions & 0 deletions bin/all_sky_search/pycbc_bin_templates
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,7 @@ with h5.File(args.output_file, 'w') as f:
bin_tids = bin_dict[bin_name]
grp = ifo_grp.create_group(bin_name)
grp['tids'] = bin_tids
f.attrs['f_lower'] = args.f_lower
f.attrs['background_bins'] = args.background_bins

logging.info('Finished')
19 changes: 5 additions & 14 deletions bin/all_sky_search/pycbc_bin_trigger_rates_dq
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ with HFile(args.trig_file, 'r') as trig_file:
if args.gating_windows:
logging.info('Getting gated times')
try:
gating_key = f'{ifo}/gating'
gating_types = trig_file[gating_key].keys()
gating_types = trig_file[f'{ifo}/gating'].keys()
for gt in gating_types:
gate_times += list(trig_file[f'{gating_key}/{gt}/time'][:])
gate_times += list(trig_file[f'{ifo}/gating/{gt}/time'][:])
gate_times = np.unique(gate_times)
except KeyError:
logging.warning('No gating found in trigger file')
Expand Down Expand Up @@ -126,15 +125,7 @@ analysis_segs = select_segments_by_definer(
segment_name=args.analysis_segment_name,
ifo=ifo)


# utility function to compute segment list durations
def segs_duration(segs):
starts, ends = segments_to_start_end(segs)
durs = ends - starts
return np.sum(durs)


livetime = segs_duration(analysis_segs)
livetime = analysis_segs.abs()

# get flag segments
flag_segs = select_segments_by_definer(args.flag_file,
Expand Down Expand Up @@ -192,9 +183,9 @@ with h5.File(args.output_file, 'w') as f:

# calculate the dq rates in this bin
dq_rates = np.zeros(3, dtype=np.float64)
for state in [0, 1, 2]:
for state, segs in dq_state_segs_dict.items():
frac_eff = np.mean(trig_states == state)
frac_dt = segs_duration(dq_state_segs_dict[state]) / livetime
frac_dt = segs.abs() / livetime
dq_rates[state] = frac_eff / frac_dt
bin_grp['dq_rates'] = dq_rates

Expand Down

0 comments on commit 0a03a9e

Please sign in to comment.