if opts.verbose: print 'querrying science segments' ### this returns a string seg_xml_file = idq.segment_query(config, opts.start, opts.end, url=segdb_url) ### write seg_xml_file to disk lsctables.use_in(ligolw.LIGOLWContentHandler) xmldoc = ligolw_utils.load_fileobj( seg_xml_file, contenthandler=ligolw.LIGOLWContentHandler)[0] ### science segments xml filename seg_file = idq.segxml(gdbdir, "%s_%s" % (filetag, dq_name), opts.start, opts.end - opts.start) if opts.verbose: print ' writing science segments to file : ' + seg_file ligolw_utils.write_filename(xmldoc, seg_file, gz=seg_file.endswith(".gz")) (scisegs, coveredseg) = idq.extract_dq_segments( seg_file, dq_name) ### read in segments from xml file if opts.verbose: print 'finding idq segments' idqsegs = idq.get_idq_segments(realtimedir, opts.start, opts.end, suffix='.dat') if opts.verbose:
seg_file = None if ovl: ovlsegs = False ### required for OVL input else: logger.info('Begin: querrying science segments') try: ### this returns a string seg_xml_file = idq.segment_query(config, gpsstart - lookback , gpsstart + stride, url=segdb_url) ### load xml document xmldoc = ligolw_utils.load_fileobj(seg_xml_file, contenthandler=ligolw.LIGOLWContentHandler)[0] ### science segments xml filename seg_file = idq.segxml(output_dir, "_%s"%dq_name, gpsstart - lookback , lookback+stride) logger.info('writing science segments to file : '+seg_file) ligolw_utils.write_filename(xmldoc, seg_file, gz=seg_file.endswith(".gz")) except Exception as e: traceback.print_exc() logger.info('ERROR: segment generation failed. Skipping this training period.') if opts.force: ### we are require successful training or else we want errors logger.info(traceback.print_exc()) raise e else: ### we don't care if any particular training job fails gpsstart += stride continue
logger.info('Begin: querrying science segments') try: ### this returns a string seg_xml_file = idq.segment_query(config, gpsstart - lookback, gpsstart + stride, url=segdb_url) ### write seg_xml_file to disk lsctables.use_in(ligolw.LIGOLWContentHandler) xmldoc = ligolw_utils.load_fileobj( seg_xml_file, contenthandler=ligolw.LIGOLWContentHandler)[0] ### science segments xml filename seg_file = idq.segxml(output_dir, "_%s" % dq_name, gpsstart - lookback, lookback + stride) logger.info('writing science segments to file : ' + seg_file) ligolw_utils.write_filename(xmldoc, seg_file, gz=seg_file.endswith(".gz")) (scisegs, coveredseg) = idq.extract_dq_segments( seg_file, dq_name) ### read in segments from xml file except Exception as e: traceback.print_exc() logger.info( 'ERROR: segment generation failed. Skipping this calibration period.' )
### load settings for accessing dmt segment files dq_name = config.get('get_science_segments', 'include') segdb_url = config.get('get_science_segments', 'segdb') if opts.verbose: print 'querrying science segments' ### this returns a string seg_xml_file = idq.segment_query(config, opts.start , opts.end, url=segdb_url) ### write seg_xml_file to disk lsctables.use_in(ligolw.LIGOLWContentHandler) xmldoc = ligolw_utils.load_fileobj(seg_xml_file, contenthandler=ligolw.LIGOLWContentHandler)[0] ### science segments xml filename seg_file = idq.segxml(gdbdir, "%s_%s"%(filetag, dq_name), opts.start , opts.end-opts.start ) if opts.verbose: print ' writing science segments to file : '+seg_file ligolw_utils.write_filename(xmldoc, seg_file, gz=seg_file.endswith(".gz")) (scisegs, coveredseg) = idq.extract_dq_segments(seg_file, dq_name) ### read in segments from xml file if opts.verbose: print 'finding idq segments' idqsegs = idq.get_idq_segments(realtimedir, opts.start, opts.end, suffix='.dat') if opts.verbose: print 'taking intersection between science segments and idq segments' idqsegs = event.andsegments( [scisegs, idqsegs] ) ### write segment file
logger.info('analyzing data regardless of science segements') scisegs = [[startgps, endgps]] ### set segs to be this stride range coveredsegs = [[startgps, endgps]] ### set segs to be this stride range else: logger.info('Begin: querrying science segments') ### this returns a string seg_xml_file = idq.segment_query(config, startgps, endgps, url=segdb_url) ### write seg_xml_file to disk lsctables.use_in(ligolw.LIGOLWContentHandler) xmldoc = ligolw_utils.load_fileobj(seg_xml_file, contenthandler=ligolw.LIGOLWContentHandler)[0] ### science segments xml filename seg_file = idq.segxml(opts.output_dir, "_%s"%dq_name, startgps, stride) logger.info('writing science segments to file : '+seg_file) ligolw_utils.write_filename(xmldoc, seg_file, gz=seg_file.endswith(".gz")) (scisegs, coveredseg) = idq.extract_dq_segments(seg_file, dq_name) ### read in segments from xml file ### modify scisegs to account for shifts logger.info('modifying scisegs to account for shifts') modified_scisegs = [(s-opts.right_padding-opts.t_lag, e+opts.left_padding-opts.t_lag) for s, e in scisegs] ### find idq segments logger.info('finding idq segments') idqsegs = idq.get_idq_segments(realtimedir, lookup_startgps, lookup_endgps, suffix='.dat') logger.info('taking intersection between modified science segments and idq segments') idqsegs = event.andsegments( [modified_scisegs, idqsegs] )
scisegs = [[startgps, endgps]] ### set segs to be this stride range coveredsegs = [[startgps, endgps]] ### set segs to be this stride range else: logger.info('Begin: querrying science segments') ### this returns a string seg_xml_file = idq.segment_query(config, startgps, endgps, url=segdb_url) ### write seg_xml_file to disk lsctables.use_in(ligolw.LIGOLWContentHandler) xmldoc = ligolw_utils.load_fileobj( seg_xml_file, contenthandler=ligolw.LIGOLWContentHandler)[0] ### science segments xml filename seg_file = idq.segxml(opts.output_dir, "_%s" % dq_name, startgps, stride) logger.info('writing science segments to file : ' + seg_file) ligolw_utils.write_filename(xmldoc, seg_file, gz=seg_file.endswith(".gz")) (scisegs, coveredseg) = idq.extract_dq_segments( seg_file, dq_name) ### read in segments from xml file ### modify scisegs to account for shifts logger.info('modifying scisegs to account for shifts') modified_scisegs = [(s - opts.right_padding - opts.t_lag, e + opts.left_padding - opts.t_lag) for s, e in scisegs] ### find idq segments logger.info('finding idq segments') idqsegs = idq.get_idq_segments(realtimedir, lookup_startgps,