message = "iDQ calibration sanity check figure for %s at %s within [%.3f, %.3f]" % (
        opts.classifier, ifo, opts.start, opts.end)
    if opts.verbose:
        print "    " + message
    gracedb.writeLog(opts.gracedb_id,
                     message=message,
                     filename=figname,
                     tagname=['data_quality'])

### discover KW triggers, compute efficiencies, plot ROC curves
if opts.verbose:
    print "retrieving gw triggers"
gwtrgs = event.include(idq.retrieve_kwtrigs(GWgdsdir,
                                            GWkwbasename,
                                            opts.start,
                                            opts.end - opts.start,
                                            kwstride,
                                            sleep=0,
                                            ntrials=1,
                                            verbose=False)[gwchannel],
                       idqsegs,
                       tcent=event.col_kw['tcent'])

fig = isp.plt.figure()
ax = fig.add_axes(isp.default_axpos)

jsonD = {}
for signif in opts.KWsignifThr:
    trgs = [trg for trg in gwtrgs if trg[event.col_kw['signif']] >= signif]
    N = len(trgs) * 1.0
    if N:
        eff = []
            ### build auxmvc_vectors by hand!
            ### get sciseg info
            if not opts.ignore_science_segments:
                (scisegs,
                 coveredseg) = idq.extract_dq_segments(seg_file, dq_name)
            else:
                scisegs = None

            ### get triggers
            logger.info('looking for triggers')
            trigger_dict = idq.retrieve_kwtrigs(
                GWgdsdir,
                GWkwbasename,
                gpsstart - lookback,
                lookback + stride,
                GWkwstride,
                sleep=0,
                ntrials=1,
                logger=logger,
                segments=scisegs)  ### go find GW kwtrgs
            if gwchannel not in trigger_dict:
                trigger_dict[gwchannel] = []

            ### keep only relevant gchs
            if len(trigger_dict[gwchannel]) > max_gch_samples:
                trgdict.resort()  ### make sure they're in the correct order
                trigger_dict[gwchannel] = trigger_dict[gwchannel][
                    -max_gch_samples:]

            if not identical_trgfile:  ### add AUX triggers
                logger.info('looking for additional AUX triggers')
                    f = open(sciseg_path, 'w')
                    for line in scisegs:
                        print >> f, line[0], line[1]
                    f.close()
                    ovlsegs = sciseg_path

            ### build auxmvc_vectors by hand!
            ### get sciseg info
            if not opts.ignore_science_segments:
                (scisegs, coveredseg) = idq.extract_dq_segments(seg_file, dq_name)
            else:
                scisegs = None

            ### get triggers
            logger.info('looking for triggers')
            trigger_dict = idq.retrieve_kwtrigs(GWgdsdir, GWkwbasename, gpsstart-lookback, lookback+stride, GWkwstride, sleep=0, ntrials=1, logger=logger, segments=scisegs) ### go find GW kwtrgs
            if gwchannel not in trigger_dict:
                trigger_dict[gwchannel] = []

            ### keep only relevant gchs
            if len(trigger_dict[gwchannel]) > max_gch_samples:
                trgdict.resort() ### make sure they're in the correct order
                trigger_dict[gwchannel] = trigger_dict[gwchannel][-max_gch_samples:]

            if not identical_trgfile: ### add AUX triggers
                logger.info('looking for additional AUX triggers')
                aux_trgdict = idq.retrieve_kwtrigs(AUXgdsdir, AUXkwbasename, gpsstart-lookback-padding, lookback+stride+padding, AUXkwstride, sleep=0, ntrials=1, logger=logger, segments=scisegs) ### find AUX kwtrgs
                if aux_trgdict == None:
                    logger.warning('  no auxiliary triggers were found')
                    ### we do not skip, although we might want to?
                else:
Example #4
0
proc = sp.Popen(["ligolw_print", "-c" "start_time", "-c" "end_time", "-t" "segment", "sample_segments.xml"], stdout=output_file)
ans = proc.communicate()[0]
output_file.close()

### get start and end seg times formatted as list of lists
scisegs = tl.parse_segments("segment_times.txt")
print("Segs: " + str(scisegs))
newsegs = []
print(opts.min_seg_length)
for i in range(len(scisegs)):
    if ((scisegs[i][1] - scisegs[i][0]) >= opts.min_seg_length):
        newsegs.append(scisegs[i])
scisegs = newsegs
print("Segs: " + str(scisegs))

trigger_dict = idq.retrieve_kwtrigs(GWgdsdir, GWkwbasename, opts.gpsstart, opts.gpsstop-opts.gpsstart, GWkwstride, sleep=0, ntrials=1, logger=logger, segments=scisegs) ### go find GW kwtrgs
if gwchannel not in trigger_dict:
    trigger_dict[gwchannel] = []
print(len(trigger_dict[gwchannel]))
# apply significance threshold to the triggers from the main channel
trigger_dict.apply_signif_threshold(channels=[gwchannel], threshold=gwthreshold)
file = open("output.txt", 'w')
tag = opts.tag
print(len(trigger_dict[gwchannel]))
total_glitches = []
for seg in scisegs:
    ratio_glitches = []
    absolute_glitches=[]
    for trig in trigger_dict[gwchannel]:
        time = trig[col['tcent']]
        if (seg[0] <= time) and (time <= seg[1]):
Example #5
0
for gps in args:
    if opts.verbose:
        print "gps : %.9f" % (gps)

    #=============================================
    # KW triggers
    #=============================================
    if kwchannels:
        ### go find triggers
        if opts.verbose:
            print "\tdiscoverying KW triggers within [%.9f, %.9f]" % (
                gps - maxwindow, gps + maxwindow)
        kwtrgdict = idq.retrieve_kwtrigs(kwgdsdir,
                                         kwbasename,
                                         int(np.floor(gps - maxwindow)),
                                         2 * maxwindow + 1,
                                         kwstride,
                                         verbose=opts.kwverbose)

        ### keep only the relevant channels
        if opts.verbose:
            print "\tdownselecting to only the following channels:"
            for chan in kwchannels:
                print "\t\t%s" % chan
        kwtrgdict.keep_channels(kwchannels)

        ### trim the edges
        kwtrgdict.include([[gps - maxwindow, gps + maxwindow]],
                          tcent=event.col_kw['tcent'])

        ### ensure we have entries for all requested channels and downselect as needed
figname = isp.calibfig( gdbdir, ifo, opts.classifier, filetag, opts.start, opts.end-opts.start )
if opts.verbose:
    print "  %s"%figname
fig.savefig(figname)
isp.plt.close(fig)

if not opts.skip_gracedb_upload:
    message = "iDQ calibration sanity check figure for %s at %s within [%.3f, %.3f]"%(opts.classifier, ifo, opts.start, opts.end)
    if opts.verbose:
        print "    "+message
    gracedb.writeLog( opts.gracedb_id, message=message, filename=figname, tagname=['data_quality'] )

### discover KW triggers, compute efficiencies, plot ROC curves
if opts.verbose:
    print "retrieving gw triggers"
gwtrgs = event.include( idq.retrieve_kwtrigs(GWgdsdir, GWkwbasename, opts.start, opts.end-opts.start, kwstride, sleep=0, ntrials=1, verbose=False)[gwchannel], idqsegs, tcent=event.col_kw['tcent'] )

fig = isp.plt.figure()
ax = fig.add_axes( isp.default_axpos )

jsonD = {}
for signif in opts.KWsignifThr:
    trgs = [trg for trg in gwtrgs if trg[event.col_kw['signif']] >= signif]
    N = len(trgs)*1.0
    if N:
        eff = []
        for fapThr in opts.FAPthr:
            s = segs[fapThr][0]
            eff.append( len(event.include( trgs, s, tcent=event.col_kw['tcent'] ))/N )
    else:
        eff = [0.0 for fapThr in opts.FAPthr]
        scisegs = tl.parse_segments("segment_times.txt")
        print("Segs: " + str(scisegs))
        if opts.ignore_science_segments:
            scisegs=None

        ### remove segments that are too short
        if opts.min_seg_length:
            newsegs=[]
            for i in range(len(scisegs)):
                if (scisegs[i][1]-scisegs[i][0] >= opts.min_seg_length):
                    newsegs.append(scisegs[i])
            scisegs = newsegs
            print("New Segs: " + str(scisegs))
        #==================================================================
        print(GWgdsdir, GWkwbasename, gpsstart, gpsstop-gpsstart, GWkwstride)
        trigger_dict = idq.retrieve_kwtrigs(GWgdsdir, GWkwbasename, gpsstart, gpsstop-gpsstart, GWkwstride, sleep=0, ntrials=1, logger=logger, segments=scisegs) ### go find GW kwtrgs
        if gwchannel not in trigger_dict:
            trigger_dict[gwchannel] = []
        print("Number trigs before theshholding: " +  str(len(trigger_dict[gwchannel])))
        ### keep only relevant gchs
        if len(trigger_dict[gwchannel]) > max_gch_samples:
            trigger_dict.resort() ### make sure they're in the correct order
            trigger_dict[gwchannel] = trigger_dict[gwchannel][-max_gch_samples:]
        print("Number of trigs after max cap: " + str(len(trigger_dict[gwchannel])))


        if not identical_trgfile: ### add AUX triggers
            logger.info('looking for additional AUX triggers')
            aux_trgdict = idq.retrieve_kwtrigs(AUXgdsdir, AUXkwbasename, gpsstart, gpsstop-gpsstart, AUXkwstride, sleep=0, ntrials=1, logger=logger, segments=scisegs) ### find AUX kwtrgs
            if aux_trgdict == None:
                logger.warning('  no auxiliary triggers were found')
Example #8
0
# =================================================

for gps in args:
    print "gps : %.9f" % (gps)

    # =============================================
    # KW triggers
    # =============================================
    if kwchannels:
        ### go find triggers
        if opts.verbose:
            print "\tdiscoverying KW triggers within [%.9f, %.9f]" % (gps - opts.window, gps + opts.window)
        kwtrgdict = idq.retrieve_kwtrigs(
            kwgdsdir,
            kwbasename,
            int(np.floor(gps - opts.window)),
            2 * opts.window + 1,
            kwstride,
            verbose=opts.kwverbose,
        )

        ### keep only the relevant channels
        if opts.verbose:
            print "\tdownselecting to only the following channels:"
            for chan in kwchannels:
                print "\t\t%s" % chan
        kwtrgdict.keep_channels(kwchannels)

        ### trim the edges
        kwtrgdict.include([[gps - opts.window, gps + opts.window]], tcent=event.col_kw["tcent"])

        ### ensure we have entries for all requested channels and downselect as needed