Beispiel #1
0
            job_segs.append(segments.segment(seg_end - length, seg_end))
            analysis_segs.append(
                segments.segment(seg_start + overlap / 2, seg_end))

    for seg, analysis_seg in zip(job_segs, analysis_segs):
        # create the template bank job
        bank = inspiral.TmpltBankNode(tmplt_job)
        bank.set_start(seg[0])
        bank.set_end(seg[1])
        bank.set_ifo(ifo)
        bank.set_cache(df.get_output())
        bank.add_parent(df)
        dag.add_node(bank)

        # split the template bank up into smaller banks
        split = inspiral.SplitBankNode(split_job)
        split.set_bank(bank.get_output())
        split.set_num_banks(cp.get('splitbank', 'number-of-banks'))
        split.add_parent(bank)
        dag.add_node(split)

        # create the inspiral jobs to do the analysis
        sub_insp = []

        for i, subbank in enumerate(split.get_output()):
            if doCohPTF:
                insp = inspiral.PTFInspiralNode(insp_job)
            else:
                insp = inspiral.InspiralNode(insp_job)
            insp.set_start(seg[0])
            insp.set_end(seg[1])
Beispiel #2
0
def analyze_coh(ifo_list,ifo_data,ifo_to_do,tmplt_job,insp_job,df_job,\
  prev_df,dag, exttrigInjections, usertag=None, inspinjNode = None,\
  runSplitBank=False,sb_job = None,sbBankFile=None,sbNumBanks = None,\
  runSpinChecker=False,sc_job=None):
    """
  Analyze the data from a single IFO.  Since the way we treat all this data is
  the same, this function is the same for all interferometers. Returns the last
  LSCdataFind job that was executed and the chunks analyzed.
  
  ifo_name = the name of the IFO
  ifo_data = the master science segs 
  ifo_to_do = the science segments we need to analyze
  tmplt_job = if not GeoBank: template bank job we should use 
  insp_job = the condor job that we should use to analyze data
  df_job = the condor job to find the data
  prev_df = the previous LSCdataFind job that was executed
  dag = the DAG to attach the nodes to
  exttrigInjections = a two-element list specifying the range 
                      of injections for the external trigger case.
  usertag = the usertag to add to the job names
  inspinjNode = the inspinj node to be added as a parent to inspirals
  """

    data_opts = {}
    type = {}
    channel = {}
    ifo_char = ''

    for ifo_name in ifo_list:
        ifo_char += ifo_name
        if ifo_name == 'G1':
            data_opts['G1'] = 'geo-data'
            try:
                type['G1'] = cp.get('input', 'geo-type')
            except:
                type['G1'] = None
            channel['G1'] = cp.get('input', 'geo-channel')
        elif ifo_name == 'V1':
            data_opts['V1'] = 'virgo-data'
            try:
                type['V1'] = cp.get('input', 'virgo-type')
            except:
                type['V1'] = None
            channel['V1'] = cp.get('input', 'virgo-channel')
        else:
            data_opts[ifo_name] = 'ligo-data'
            try:
                type[ifo_name] = cp.get('input', 'ligo-type')
                if (type[ifo_name] == 'RDS_R_L4') or ('RDS_C' in type[ifo_name]) or \
                    ('DMT_C' in type[ifo_name]) or ('LDAS_C' in type[ifo_name]):
                    type[ifo_name] = ifo_name + '_' + type[ifo_name]
            except:
                type[ifo_name] = None
            channel[ifo_name] = cp.get('input', 'ligo-channel')

    # see if we are using calibrated data
    if cp.has_section(data_opts[ifo_name]) and \
        cp.has_option(data_opts[ifo_name],'calibrated-data'):
        calibrated = True
    else:
        calibrated = False

    if ifo_data:
        exttrigStart = ifo_data[ifo_name][0].start()
        exttrigDuration = ifo_data[ifo_name][-1].end() - exttrigStart
        injectionFileTemplate = "HL-INJECTION_%%s-%d-%d.xml" % \
          (exttrigStart, exttrigDuration)

    # loop over the master science segments
    for seg in ifo_data[ifo_name]:

        # loop over the master analysis chunks in the science segment
        for chunk in seg:
            done_this_chunk = False

            # now loop over all the data that we need to filter
            for seg_to_do in ifo_to_do[ifo_name]:

                # if the current chunk is in one of the segments we need to filter
                if not done_this_chunk and inspiral.overlap_test(
                        chunk, seg_to_do):

                    # make sure we only filter the master chunk once
                    done_this_chunk = True

                    if not sbBankFile:
                        # Determine template bank file name
                        ifo_name = cp.get('templatebank-meta', 'bank-ifo')
                        tb_node = inspiral.TmpltBankNode(tmplt_job)
                        tb_node.set_start(chunk.start())
                        tb_node.set_end(chunk.end())
                        tb_node.set_ifo(ifo_name)
                        tb_node.set_vds_group(ifo_name[0] + str(chunk.start()))
                        tb_node.set_user_tag((usertag.split('_')[0]) +
                                             '_DATAFIND')
                        os.symlink("../datafind/" + tb_node.get_output(),\
                                   tb_node.get_output())
                        sbBankFile = tb_node.get_output()

                    # Set up the bank splitting
                    if runSplitBank:
                        sb_node = inspiral.SplitBankNode(sb_job)
                        sb_node.set_bank(sbBankFile)
                        sb_node.set_num_banks(sbNumBanks)
                        sbOutBanks = sb_node.get_output()
                        dag.add_node(sb_node)
                    else:
                        sbNumBanks = 1

                    scSpinBank = []
                    scNoSpinBank = []
                    scNodes = []
                    if runSpinChecker:
                        for bank in range(sbNumBanks):
                            sc_node = inspiral.PTFSpinCheckerNode(sc_job)
                            scNodes.append(sc_node)
                            sc_node.set_start(chunk.start())
                            sc_node.set_end(chunk.end())
                            sc_node.set_ifo(ifo_char)
                            if runSplitBank:
                                sc_node.set_bank(sbOutBanks[bank])
                                sc_node.add_parent(sb_node)
                                scSpinBank.append(sbOutBanks[bank].replace(
                                    '.xml', '_spin.xml'))
                                scNoSpinBank.append(sbOutBanks[bank].replace('.xml',\
                                                                             '_nospin.xml'))
                                sc_node.set_ifo_tag("FIRST_" + str(bank))
                            else:
                                sc_node.set_ifo_tag("FIRST")
                                scSpinBank.append(sc_node.get_output_base +
                                                  '_spin.xml.gz')
                                scNoSpinBank.append(sc_node.get_output_base +
                                                    '_nospin.xml.gz')
                            sc_node.set_spin_output(scSpinBank[bank])
                            sc_node.set_nospin_output(scNoSpinBank[bank])
                            dag.add_node(sc_node)

                    if doExtTrig:
                        for inj in range(exttrigInjections[0],
                                         exttrigInjections[1] + 1):
                            #XXX: ensure output is added to list of output files
                            exttrigUserTag = usertag + "_" + str(inj)
                            injectionFile = injectionFileTemplate % exttrigUserTag
                            for bank in range(sbNumBanks):
                                insp = setup_coh_inspiral(ifo_name,ifo_char,insp_job,\
                                    runSplitBank,calibrated,runSpinChecker,chunk,dag,bank,\
                                    scSpinBank,scNoSpinBank,sbOutBanks,scNodes,sb_node,\
                                    exttrigUserTag)
                                insp.set_injections(injectionFile)
                    elif doSlides:
                        slide_vector = setup_timeslides(ifo_analyze)
                        num_slides = len(slide_vector)
                        for slide in range(int(num_slides)):
                            vector = slide_vector[slide]
                            slidesUserTag = usertag + "_" + "slide" + "_" + \
                                str('_'.join(map(str,[str(key) + "_" + str(vector[key])\
                                                      for key in vector.keys()])))
                            for bank in range(sbNumBanks):
                                insp = setup_coh_inspiral(ifo_name,ifo_char,insp_job,\
                                    runSplitBank,calibrated,runSpinChecker,chunk,dag,bank,\
                                    scSpinBank,scNoSpinBank,sbOutBanks,scNodes,sb_node,\
                                    slidesUserTag)
                                for key in vector.keys():
                                    insp.add_var_opt(key.lower() + '-slide',
                                                     vector[key])
                    else:
                        for bank in range(sbNumBanks):
                            insp = setup_coh_inspiral(ifo_name,ifo_char,insp_job,\
                                runSplitBank,calibrated,runSpinChecker,chunk,dag,bank,\
                                scSpinBank,scNoSpinBank,sbOutBanks,scNodes,sb_node,usertag)

                    # store this chunk in the list of filtered data
                    for ifo_name in ifo_list:
                        chunks_analyzed[ifo_name] = []
                        chunks_analyzed[ifo_name].append(
                            AnalyzedIFOData(chunk, insp, 0))

    return chunks_analyzed