Пример #1
0
def get_all_vco_triggers(ifo,
                         seg,
                         frames=False,
                         fit=True,
                         channel='GDS-CALIB_STRAIN',
                         file=None):
    st = int(seg[0])
    et = int(seg[1])
    st2 = st
    First = 1
    # break into 1000s, run into memory issues otherwise
    amps = []
    while (et > st2):
        dur = min(et - st2, 1000)
        if file:
            vco = TimeSeries.read(file)
            vco = vco + 76e6
        else:
            vco = generate_fast_vco(ifo,
                                    Segment(st2, st2 + dur),
                                    frames=frames,
                                    fit=fit)

        trigs = SnglBurstTable.fetch(
            "%s:%s" % (ifo, channel),
            'omicron',
            st2,
            st2 + dur,
            filt=lambda x: st2 <= x.get_peak() < st2 + dur)
        if First:
            trigs2 = table.new_from_template(trigs)
            First = 0
        trigs2.extend(trigs)
        vtrigs = get_vco_trigs(vco, trigs, channel=channel)
        for vtrig in vtrigs:
            amps.append(vtrig)
        st2 += 1000

    central_freqs = trigs2.get_column('peak_frequency')
    snrs = trigs2.get_column('snr')
    sts = trigs2.get_column('time_peak')

    amps = np.asarray(amps)
    amps = amps[~(np.isnan(amps))]
    central_freqs = central_freqs[~(np.isnan(amps))]
    snrs = snrs[~(np.isnan(amps))]
    return amps, central_freqs, snrs, sts
def get_all_vco_triggers(ifo, seg, frames=False, fit=True, channel="GDS-CALIB_STRAIN", file=None):
    st = int(seg[0])
    et = int(seg[1])
    st2 = st
    First = 1
    # break into 1000s, run into memory issues otherwise
    amps = []
    while et > st2:
        dur = min(et - st2, 1000)
        if file:
            vco = TimeSeries.read(file)
            vco = vco + 76e6
        else:
            vco = generate_fast_vco(ifo, Segment(st2, st2 + dur), frames=frames, fit=fit)

        trigs = SnglBurstTable.fetch(
            "%s:%s" % (ifo, channel), "omicron", st2, st2 + dur, filt=lambda x: st2 <= x.get_peak() < st2 + dur
        )
        if First:
            trigs2 = table.new_from_template(trigs)
            First = 0
        trigs2.extend(trigs)
        vtrigs = get_vco_trigs(vco, trigs, channel=channel)
        for vtrig in vtrigs:
            amps.append(vtrig)
        st2 += 1000

    central_freqs = trigs2.get_column("peak_frequency")
    snrs = trigs2.get_column("snr")
    sts = trigs2.get_column("time_peak")

    amps = np.asarray(amps)
    amps = amps[~(np.isnan(amps))]
    central_freqs = central_freqs[~(np.isnan(amps))]
    snrs = snrs[~(np.isnan(amps))]
    return amps, central_freqs, snrs, sts
    trig_template = template_ids[highestSNR]
elif args.ranking_statistic == 'newsnr':
    trig_time = end_times[highestnewSNR]
    trig_template = template_ids[highestnewSNR]

mass1vec = template_file['mass1'][:]
mass2vec = template_file['mass2'][:]
mass1 = mass1vec[trig_template]
mass2 = mass2vec[trig_template]

hoft_chan = str(ifo) + ":GDS-CALIB_STRAIN"
start_time = trig_time - 40
end_time = trig_time + 40

logging.info('Fetching omicron triggers')
omicron_trigs = SnglBurstTable.fetch(hoft_chan, 'omicron', start_time,
                                     end_time)
omicron_times = np.add(omicron_trigs.get_column('peak_time'),
                       omicron_trigs.get_column('peak_time_ns') * 10**-9)
omicron_snr = omicron_trigs.get_column('snr')
omicron_freq = omicron_trigs.get_column('peak_frequency')

from pycbc.workflow.segment import fromsegmentxml
import pycbc.pnutils

f_low = 30
f_high = pycbc.pnutils.f_SchwarzISCO(mass1 + mass2)

inspiral_t, inspiral_f = pycbc.pnutils.get_inspiral_tf(trig_time, mass1, mass2,
                                                       f_low, f_high)

logging.info('Plotting')
Пример #4
0
def get_triggers():

    # Obtain segments that are analysis ready
    analysis_ready = DataQualityFlag.query('{0}:DMT-ANALYSIS_READY:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)

    # Display segments for which this flag is true
    print "Segments for which the ANALYSIS READY Flag is active: {0}".format(analysis_ready.active)

    if opts.applyallDQ:
        print("We are finding all previously created DQ cuts")
        # Obtain segments of all DQ cuts if requested DQ list can be found
        # https://code.pycbc.phy.syr.edu/detchar/veto-definitions/blob/master/burst/O1/H1L1-HOFT_C02_O1_BURST.xml
        # First obtain those flags that are for both H1 and L1
        O1_MISSING_HOFT_C02 = DataQualityFlag.query('{0}:DCS-MISSING_{0}_HOFT_C02:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
        O1_ETMY_ESD_DAC_OVERFLOW = DataQualityFlag.query('{0}:DMT-ETMY_ESD_DAC_OVERFLOW:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
        O1_OMC_DCPD_A_SATURATION = DataQualityFlag.query('{0}:DCH-OMC_DCPD_A_SATURATION:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
        O1_OMC_DCPD_ADC_OVERFLOW = DataQualityFlag.query('{0}:DMT-OMC_DCPD_ADC_OVERFLOW:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
        O1_ETMY_SATURATION_SNR200 = DataQualityFlag.query('{0}:DCH-ETMY_SATURATION_SNR200:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
        O1_CW_INJECTION_TRANSITION = DataQualityFlag.query('{0}:DCH-CW_INJECTION_TRANSITION:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
        O1_BAD_KAPPA_BASIC_CUT_HOFT_C02 = DataQualityFlag.query('{0}:DCS-BAD_KAPPA_BASIC_CUT_{0}_HOFT_C02:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
        O1_PARTIAL_FRAME_LOSS_HOFT_C02 = DataQualityFlag.query('{0}:DCS-PARTIAL_FRAME_LOSS_{0}_HOFT_C02:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)

        # Obtain detector specific flags
        if opts.detector == "H1":
            O1_RF45_AM_STABILIZATION = DataQualityFlag.query('{0}:DCH-RF45_AM_STABILIZATION:4'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_ETMY_SATURATION = DataQualityFlag.query('{0}:DCH-ETMY_SATURATION:2'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_BAD_DATA_BEFORE_LOCKLOSS = DataQualityFlag.query('{0}:DCH-BAD_DATA_BEFORE_LOCKLOSS:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_ETMY_VIOLIN_MODE_2NDHARMONIC_RINGING = DataQualityFlag.query('{0}:DCH-ETMY_VIOLIN_MODE_2NDHARMONIC_RINGING:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_RF45_SEVERE_GLITCHING = DataQualityFlag.query('{0}:DCH-RF45_SEVERE_GLITCHING:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_EY_BECKHOFF_CHASSIS_PROBLEM = DataQualityFlag.query('{0}:DCH-EY_BECKHOFF_CHASSIS_PROBLEM:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_ASC_AS_B_RF36_GLITCHING = DataQualityFlag.query('{0}:DCH-ASC_AS_B_RF36_GLITCHING:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_BAD_STRAIN_HOFT_C02 = DataQualityFlag.query('{0}:DCS-BAD_STRAIN_{0}_HOFT_C02:2'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_TOGGLING_BAD_KAPPA_HOFT_C02= DataQualityFlag.query('{0}:DCS-TOGGLING_BAD_KAPPA_{0}_HOFT_C02:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
        else:
            O1_ETMY_SATURATION = DataQualityFlag.query('{0}:DCH-ETMY_SATURATION:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_BAD_DATA_BEFORE_LOCKLOSS = DataQualityFlag.query('{0}:DCH-BAD_DATA_BEFORE_LOCKLOSS:2'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_PCAL_GLITCHES_GT_20P = DataQualityFlag.query('{0}:DCH-PCAL_GLITCHES_GT_20P:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_SUDDEN_PSD_CHANGE = DataQualityFlag.query('{0}:DCH-SUDDEN_PSD_CHANGE:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_BAD_VCO_OFFSET = DataQualityFlag.query('{0}:DCH-BAD_VCO_OFFSET:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)
            O1_SEVERE_60_200_HZ_NOISE = DataQualityFlag.query('{0}:DCH-SEVERE_60_200_HZ_NOISE:1'.format(opts.detector),opts.gpsStart,opts.gpsEnd)

    # Fetch raw omicron triggers and apply filter which is defined in a function above.
    omicrontriggers = SnglBurstTable.fetch(detchannelname,'Omicron',\
    opts.gpsStart,opts.gpsEnd,filt=threshold)

    print "List of available metadata information for a given glitch provided by omicron: {0}".format(omicrontriggers.columnnames)

    print "Number of triggers after SNR and Freq cuts but before ANALYSIS READY flag filtering: {0}".format(len(omicrontriggers))

    # Filter the raw omicron triggers against the ANALYSIS READY flag.
    omicrontriggers = omicrontriggers.vetoed(analysis_ready.active)
    # If requested filter out DQ flags
    if opts.applyallDQ:
        print("We are applying all previously created DQ cuts")
        # Obtain segments of all DQ cuts if requested DQ list can be found
        # https://code.pycbc.phy.syr.edu/detchar/veto-definitions/blob/master/burst/O1/H1L1-HOFT_C02_O1_BURST.xml
        # First obtain those flags that are for both H1 and L1
        omicrontriggers = omicrontriggers.veto(O1_MISSING_HOFT_C02.active)
        omicrontriggers = omicrontriggers.veto(O1_ETMY_ESD_DAC_OVERFLOW.active)
        omicrontriggers = omicrontriggers.veto(O1_OMC_DCPD_A_SATURATION.active)
        omicrontriggers = omicrontriggers.veto(O1_OMC_DCPD_ADC_OVERFLOW.active)
        omicrontriggers = omicrontriggers.veto(O1_ETMY_SATURATION_SNR200.active)
        omicrontriggers = omicrontriggers.veto(O1_CW_INJECTION_TRANSITION.active)
        omicrontriggers = omicrontriggers.veto(O1_BAD_KAPPA_BASIC_CUT_HOFT_C02.active)
        omicrontriggers = omicrontriggers.veto(O1_PARTIAL_FRAME_LOSS_HOFT_C02.active)

        # Obtain detector specific flags
        if opts.detector == "H1":
            omicrontriggers = omicrontriggers.veto(O1_RF45_AM_STABILIZATION.active)
            omicrontriggers = omicrontriggers.veto(O1_ETMY_SATURATION.active)
            omicrontriggers = omicrontriggers.veto(O1_BAD_DATA_BEFORE_LOCKLOSS.active)
            omicrontriggers = omicrontriggers.veto(O1_ETMY_VIOLIN_MODE_2NDHARMONIC_RINGING.active)
            omicrontriggers = omicrontriggers.veto(O1_RF45_SEVERE_GLITCHING.active)
            omicrontriggers = omicrontriggers.veto(O1_EY_BECKHOFF_CHASSIS_PROBLEM.active)
            omicrontriggers = omicrontriggers.veto(O1_ASC_AS_B_RF36_GLITCHING.active)
            omicrontriggers = omicrontriggers.veto(O1_BAD_STRAIN_HOFT_C02.active)
            omicrontriggers = omicrontriggers.veto(O1_TOGGLING_BAD_KAPPA_HOFT_C02.active)
        else:
            omicrontriggers = omicrontriggers.veto(O1_ETMY_SATURATION.active)
            omicrontriggers = omicrontriggers.veto(O1_BAD_DATA_BEFORE_LOCKLOSS.active)
            omicrontriggers = omicrontriggers.veto(O1_PCAL_GLITCHES_GT_20P.active)
            omicrontriggers = omicrontriggers.veto(O1_SUDDEN_PSD_CHANGE.active)
            omicrontriggers = omicrontriggers.veto(O1_BAD_VCO_OFFSET.active)
            omicrontriggers = omicrontriggers.veto(O1_SEVERE_60_200_HZ_NOISE.active)
        


    print "Final trigger length: {0}".format(len(omicrontriggers))

    return omicrontriggers
Пример #5
0
ifo = sys.argv[1]
chan = sys.argv[2]
st = int(sys.argv[3])
dur = int(sys.argv[4])
et = st + dur

primary_channel = '%s:%s' % (ifo, chan)
vco_channel = ifo + ":SYS-TIMING_C_FO_A_PORT_11_SLAVE_CFC_FREQUENCY_5"

# VCO is sampled in the middle of the second, reported one second later
conn = datafind.GWDataFindHTTPConnection()
cache = conn.find_frame_urls(ifo[0], '%s_R' % ifo, st, et, urltype='file')
vco = TimeSeries.read(cache, vco_channel, st, et + 2)
vco = vco[8::16].value
vco_major_MHz = int(median(vco) / 1.e6)
vco -= 1e6 * vco_major_MHz
vco_interp = UnivariateSpline(arange(len(vco)) - 0.5, vco)

trigs = SnglBurstTable.fetch(primary_channel,
                             'omicron',
                             st,
                             et,
                             filt=lambda x: st <= x.get_peak() < et)

result = []
for trg in trigs:
    f_vco = vco_interp(float(trg.get_peak()) - st)
    result.append((f_vco, trg.peak_frequency, trg.snr))
save('%s-%s_versus_vco-%u-%u.npy' % (ifo, chan, st, dur), result)
if args.ranking_statistic == 'snr':
    trig_time = window_times[highestSNR]
    trig_template = template_ids[highestSNR]
elif args.ranking_statistic == 'newsnr':
    trig_time = window_times[highestnewSNR]
    trig_template = template_ids[highestnewSNR]

mass1vec = template_file['mass1'][:]
mass2vec = template_file['mass2'][:]
mass1 = mass1vec[trig_template]
mass2 = mass2vec[trig_template]


logging.info('Fetching omicron triggers')
omicron_trigs = SnglBurstTable.fetch(hoft_chan,'omicron',start_time,end_time)
omicron_times = np.add(omicron_trigs.get_column('peak_time'),omicron_trigs.get_column('peak_time_ns')*10**-9)
omicron_snr = omicron_trigs.get_column('snr')
omicron_freq = omicron_trigs.get_column('peak_frequency')

from pycbc.workflow.segment import fromsegmentxml
import pycbc.pnutils

f_low = 30
f_high = pycbc.pnutils.f_SchwarzISCO(mass1+mass2)

inspiral_t, inspiral_f = pycbc.pnutils.get_inspiral_tf(trig_time, mass1, mass2, f_low, f_high)

logging.info('Plotting')

cm = plt.cm.get_cmap('Reds')
Пример #7
0
                                             end=end,
                                             ifo=ifo)
vdf.populate()
print('Read %d flags from veto definer' % len(vdf.keys()))

categories = [1, 2, 3, 4]
vdfCats = dict((c, DataQualityDict()) for c in categories)
for name, flag in vdf.iteritems():
    try:
        vdfCats[flag.category][name] = flag
    except KeyError:
        pass

#generate the triggers needed to run vet
if analysis == 'omicron':
    triggers = SnglBurstTable.fetch('%s:GDS-CALIB_STRAIN' % ifo, 'omicron',
                                    start, end)
else:
    triggers = SnglBurstTable.read(trigPath, ifo=ifo, format='cwb-ascii')

#convert the metrics to a standard notation
newMetric = []
for metric in metrics:
    newMetric.append(get_metric(metric))

order = ['1', '1+4', '1+2+4', '1+2+3+4']
for categories in order:
    category = categories.split('+')
    activeVdf = DataQualityFlag('VDFs')
    for cat in category:
        for flag in vdfCats[int(cat)]:
            activeVdf.known += vdf[flag].known