Skip to content

Commit

Permalink
Try ifo/search group
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeb245 committed Jul 21, 2023
1 parent e72de45 commit 90d99a2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bin/pygrb/pycbc_grb_trig_cluster
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def slice_hdf5(inputfile, outfile, include, verbose=False):
nevents = include.size

with h5py.File(inputfile, "r") as h5in:
ifos = [k for k in h5in.keys() if k not in ("network", "search")]
ifos = [k for k in h5in.keys() if k != "network"]

# find which single-ifo events to keep
ifo_index = {
Expand Down
4 changes: 2 additions & 2 deletions bin/pygrb/pycbc_grb_trig_combiner
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def merge_hdf5_files(inputfiles, outputfile, verbose=False, **compression_kw):

# handle search datasets as a special case
# (they will the same in all files)
search_datasets = set(filter(lambda x: "search/" in x, dataset_names))
search_datasets = set(filter(lambda x: "/search/" in x, dataset_names))

# record where we are in the global dataset
position = defaultdict(int)
Expand Down Expand Up @@ -230,7 +230,7 @@ def bin_events(inputfile, bins, outdir, filetag,
ifotag, _, seg = filename_metadata(inputfile)

with h5py.File(inputfile, "r") as h5in:
ifos = [k for k in h5in.keys() if k not in ("network", "search")]
ifos = [k for k in h5in.keys() if k != "network"]
times = h5in[column][()]

for bin_, segl in bins.items():
Expand Down
5 changes: 1 addition & 4 deletions pycbc/events/eventmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,6 @@ def __setitem__(self, name, data):
th = numpy.array(
[p['tmplt'].template_hash for p in self.template_params])
f = fw(outname)
# Write timeslides to search group
f.prefix = 'search'
for ifo in self.ifos:
f['time_slides_'+ifo] = self.time_slides[ifo]
# Output network stuff
f.prefix = 'network'
network_events = numpy.array(
Expand Down Expand Up @@ -776,6 +772,7 @@ def __setitem__(self, name, data):
f['chisq_dof'] = numpy.zeros(len(ifo_events))

f['template_hash'] = th[tid]
f['search/time_slides'] = numpy.array(self.time_slides[ifo])
if self.opt.trig_start_time:
f['search/start_time'] = numpy.array([
self.opt.trig_start_time[ifo]], dtype=numpy.int32)
Expand Down
4 changes: 2 additions & 2 deletions pycbc/results/pygrb_postprocessing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,10 @@ def load_time_slides(hdf_file_path):
"""Loads timeslides from PyGRB output file as a dictionary"""
hdf_file = h5py.File(hdf_file_path, 'r')
ifos = extract_ifos(hdf_file_path)
ids = numpy.arange(len(hdf_file[f'search/time_slides_{ifos[0]}']))
ids = numpy.arange(len(hdf_file[f'{ifos[0]}/search/time_slides']))
time_slide_dict = {
slide_id: {
ifo: hdf_file[f'search/time_slides_{ifo}'][slide_id]
ifo: hdf_file[f'{ifo}/search/time_slides'][slide_id]
for ifo in ifos}
for slide_id in ids}

Expand Down

0 comments on commit 90d99a2

Please sign in to comment.