def toSegmentXml(self): """ Write the segment list in self.segmentList to the url in self.url. """ from pycbc.events import segments_to_file segments_to_file(self.segmentList, self.storage_path, self.tagged_description, ifo=self.ifo_string)
def setup_psd_calculate(workflow, frame_files, ifo, segments, segment_name, out_dir, gate_files=None, tags=None): make_analysis_dir(out_dir) tags = [] if not tags else tags if workflow.cp.has_option_tags('workflow-psd', 'parallelization-factor', tags=tags): num_parts = int(workflow.cp.get_opt_tags('workflow-psd', 'parallelization-factor', tags=tags)) else: num_parts = 1 segment_lists = list(chunks(segments, num_parts)) psd_files = FileList([]) for i, segs in enumerate(segment_lists): seg_file = segments_to_file(segmentlist(segs), out_dir + '/%s-INSPIRAL_DATA-%s.xml' % (ifo, i), 'INSPIRAL_DATA', ifo=ifo) psd_files += [make_psd_file(workflow, frame_files, seg_file, segment_name, out_dir, gate_files=gate_files, tags=tags + ['PART%s' % i])] if num_parts > 1: return merge_psds(workflow, psd_files, ifo, out_dir, tags=tags) else: return psd_files[0]
def setup_psd_calculate(workflow, frame_files, ifo, segments, segment_name, out_dir, gate_files=None, tags=None): make_analysis_dir(out_dir) tags = [] if not tags else tags if workflow.cp.has_option_tags('workflow-psd', 'parallelization-factor', tags=tags): num_parts = int(workflow.cp.get_opt_tags('workflow-psd', 'parallelization-factor', tags=tags)) else: num_parts = 1 # get rid of duplicate segments which happen when splitting the bank segments = segmentlist(frozenset(segments)) segment_lists = list(chunks(segments, num_parts)) psd_files = FileList([]) for i, segs in enumerate(segment_lists): seg_file = segments_to_file(segmentlist(segs), out_dir + '/%s-INSPIRAL_DATA-%s.xml' % (ifo, i), 'INSPIRAL_DATA', ifo=ifo) psd_files += [make_psd_file(workflow, frame_files, seg_file, segment_name, out_dir, gate_files=gate_files, tags=tags + ['PART%s' % i])] if num_parts > 1: return merge_psds(workflow, psd_files, ifo, out_dir, tags=tags) else: return psd_files[0]
def get_analyzable_segments(workflow, out_dir, tags=[]): """ Get the analyzable segments after applying ini specified vetoes. Parameters ----------- workflow : Workflow object Instance of the workflow object out_dir : path Location to store output files tags : list of strings Used to retrieve subsections of the ini file for configuration options. Returns -------- segs : glue.segments.segmentlist instance The segment list specifying the times to analyze data_segs : glue.segments.segmentlist The segment list specifying the time where data exists seg_files : workflow.core.FileList instance The cumulative segment files from each ifo that determined the analyzable time. """ from pycbc.events import segments_to_file logging.info('Entering generation of science segments') make_analysis_dir(out_dir) start_time = workflow.analysis_time[0] end_time = workflow.analysis_time[1] save_veto_definer(workflow.cp, out_dir, tags) cat_sets = parse_cat_ini_opt(workflow.cp.get_opt_tags('workflow-segments', 'segments-science-veto', tags)) if len(cat_sets) > 1: raise ValueError('Provide only 1 category group to determine' ' analyzable segments') cat_set = cat_sets[0] veto_gen_job = create_segs_from_cats_job(workflow.cp, out_dir, workflow.ifo_string) sci_segs, data_segs = {}, {} seg_files = FileList() for ifo in workflow.ifos: sci_segs[ifo], sci_xml = get_science_segments(ifo, workflow.cp, start_time, end_time, out_dir) seg_files += [sci_xml] data_segs[ifo] = sci_segs[ifo] for category in cat_set: curr_veto_file = get_veto_segs(workflow, ifo, cat_to_pipedown_cat(category), start_time, end_time, out_dir, veto_gen_job, execute_now=True) f = open(curr_veto_file.storage_path, 'r') cat_segs = fromsegmentxml(f) f.close() sci_segs[ifo] -= cat_segs sci_segs[ifo].coalesce() seg_ok_path = os.path.abspath(os.path.join(out_dir, '%s-SCIENCE-OK.xml' % ifo)) seg_files += [segments_to_file(sci_segs[ifo], seg_ok_path, "SCIENCE_OK", ifo=ifo)] logging.info('Leaving generation of science segments') return sci_segs, data_segs, seg_files