diff --git a/bin/hdfcoinc/pycbc_page_segtable b/bin/hdfcoinc/pycbc_page_segtable index ec4c85f642d..7ef37900ccd 100644 --- a/bin/hdfcoinc/pycbc_page_segtable +++ b/bin/hdfcoinc/pycbc_page_segtable @@ -31,22 +31,12 @@ from pycbc.events.veto import get_segment_definer_comments from pycbc.results import save_fig_with_metadata from pycbc.workflow import SegFile import pycbc.version - -def ifo_combinations(ifo_list, n_ifos): - if n_ifos == 0: - return [[]] - list_combo = [] - for i in range(0,len(ifo_list)): - removed = ifo_list[i] - post_removed = ifo_list[i+1:] - for subset in ifo_combinations(post_removed, n_ifos-1): - list_combo.append([removed] + subset) - return list_combo +import itertools def powerset_ifos(ifo_set): combo_set = [] for n_ifos in range(1,len(ifo_set)+1): - combo_set += ifo_combinations(ifo_set, n_ifos) + combo_set += itertools.combinations(ifo_set, n_ifos) return combo_set # parse command line @@ -63,20 +53,16 @@ parser.add_argument('--title-text', type=str, required=False, help='Additional text to append to title.') parser.add_argument('--output-file', type=str, help='Path of the output HTML file.') -parser.add_argument('--ifos', nargs='+', - help=' List of IFOs.') +parser.add_argument('--ifos', nargs='+',default=['H1','L1'], + help='(Optional) List of IFOs, default is H1, L1.') opts = parser.parse_args() # setup log logging.basicConfig(format='%(asctime)s:%(levelname)s : %(message)s', level=logging.INFO,datefmt='%I:%M:%S') -if opts.ifos: - ifos = opts.ifos -else: - ifos = ['H1', 'L1'] # create list of combinations of detectors -ifo_combinations = powerset_ifos(ifos) +ifo_combinations = powerset_ifos(opts.ifos) # set column names columns = (('Name', []),) @@ -115,7 +101,7 @@ for segment_name in opts.segment_names: comp_segs = segments.segmentlistdict({}) # loop over IFOs - for ifo in ifos: + for ifo in opts.ifos: # make an empty list for each IFO base_segs[ifo] = segments.segmentlist([]) @@ -156,20 +142,12 @@ for segment_name in opts.segment_names: # set up dictionary of length of time of single-ifo segments in seconds ifo_len = {} - for ifo in ifos: + for ifo in opts.ifos: if len(names) > 1: ifo_len[ifo] = abs( ( base_segs[ifo].coalesce() & comp_segs[ifo].coalesce() ).coalesce() ) else: ifo_len[ifo] = abs( base_segs[ifo].coalesce() ) - # get length of time of single-IFO segments in seconds -# if len(names) > 1: -# h1_len = abs( ( base_segs['H1'].coalesce() & comp_segs["H1"].coalesce() ).coalesce() ) -# l1_len = abs( ( base_segs['L1'].coalesce() & comp_segs["L1"].coalesce() ).coalesce() ) -# else: -# h1_len = abs( base_segs['H1'].coalesce() ) -# l1_len = abs( base_segs['L1'].coalesce() ) - columns[0][1].append(segment_name) counter = 1 for combo in ifo_combinations: @@ -213,8 +191,6 @@ for segment_name in opts.segment_names: # columns[2][1].append(float(l1_len)) # columns[3][1].append(float(h1l1_len)) -print(columns) - # cast columns into arrays keys = [numpy.array(key, dtype=type(key[0])) for key,_ in columns] vals = [numpy.array(val, dtype=type(val[0])) for _,val in columns]