Example #1
0
    from lalinference.tiger import make_injtimes
    print 'TIGER: Generating science and veto segment files for real data'
    if not (cp.has_option('input', 'gps-start-time')
            and cp.has_option('input', 'gps-end-time')):
        print "make_injtimes needs both gps start and end time"
        sys.exit(1)

    segfolder = os.path.join(basefolder, 'segments')
    ensure_dir(segfolder)
    curdir = os.getcwd()
    os.chdir(segfolder)

    vetoCats = ast.literal_eval(cp.get('segments', 'veto-categories'))

    vetoDefFile = inspiralutils.downloadVetoDefFile(cp, True)
    inspiralutils.generate_veto_cat_files(cp, vetoDefFile, True)

    # Populate dictionary with veto filenames for each IFO and generate the veto segment files
    veto_dic = {}
    seg_dic = {}

    # Download science segment files for each IFO
    for IFO in ifos:
        (seg_dic[IFO], veto_dic[IFO]) = inspiralutils.findSegmentsToAnalyze(
            cp,
            IFO,
            vetoCats,
            generate_segments=True,
            use_available_data=False,
            data_quality_vetoes=True)
os.chdir("segments")

# Determine which veto categories to filter
veto_categories = [int(cat) for cat in \
    cp.get("segments", "veto-categories").split(",")]
if 1 not in veto_categories: 
  raise ValueError("The list of veto categories must include 1!")
veto_categories.sort()
# separate out non-CAT1 categories for some purposes
vetocats_without1 = [cat for cat in veto_categories if cat!=1]

# Download the veto definer xml file
vetoDefFile = inspiralutils.downloadVetoDefFile(cp, opts.generate_segments)

# Generate veto xml files for each ifo and for each category
inspiralutils.generate_veto_cat_files(cp, vetoDefFile, \
    opts.generate_veto_segments)

# Generate a combined veto file for each ifo for use by pipedown
gps_start = int(opts.gps_start_time)
gps_end = int(opts.gps_end_time)
duration = gps_end - gps_start

dqVetoes = {}
dqVetoes["combined-veto-file"] = {}
for category in veto_categories:
  ifos_string = ""
  veto_cat_files = []
  veto_cat_filename = str(gps_start) + "-" + str(duration) + ".xml"
  for ifo in ifos:
    veto_cat_files.append("-".join([ifo, "VETOTIME_CAT" + str(category), veto_cat_filename]))
    ifos_string += ifo
if injfile is None and gpstimefile is None and gid is None and not cp.has_option('lalinference', 'fake-cache'):
  from lalinference.tiger import make_injtimes
  print 'TIGER: Generating science and veto segment files for real data'
  if not (cp.has_option('input','gps-start-time') and cp.has_option('input','gps-end-time')):
    print "make_injtimes needs both gps start and end time"
    sys.exit(1)
    
  segfolder = os.path.join(basefolder, 'segments')
  ensure_dir(segfolder)
  curdir = os.getcwd()
  os.chdir(segfolder)

  vetoCats = ast.literal_eval(cp.get('segments', 'veto-categories'))

  vetoDefFile = inspiralutils.downloadVetoDefFile(cp, True)
  inspiralutils.generate_veto_cat_files(cp, vetoDefFile, True)

  # Populate dictionary with veto filenames for each IFO and generate the veto segment files
  veto_dic = {}
  seg_dic = {}


  # Download science segment files for each IFO
  for IFO in ifos:
    (seg_dic[IFO], veto_dic[IFO]) = inspiralutils.findSegmentsToAnalyze(cp, IFO, vetoCats, generate_segments=True, use_available_data=False, data_quality_vetoes=True)


  # Feed science and veto segment files to make_injtimes and generate injection times and timeslides
  print 'TIGER: Generating GPS times for unvetoed injections'
  ensure_dir(os.path.join(basefolder, 'injtimes'))
  IFOdict={}