Exemplo n.º 1
0
 def process_state(self, state, *args, **kwargs):
     config = kwargs.get('config', None)
     # first get all of the segments
     if self.segmentfile:
         get_segments(self.flags, state, config=config,
                      cache=self.segmentfile, return_=False)
         segs = get_segments(self.metaflag, state, padding=self.padding,
                             config=config, query=False)
         kwargs['segmentcache'] = Cache()
     else:
         segs = get_segments(self.metaflag, state, config=config,
                             segdb_error=kwargs.get('segdb_error', 'raise'),
                             padding=self.padding)
     # then get all of the triggers
     if self.channel:
         cache = kwargs.pop('trigcache', None)
         before = get_triggers(str(self.channel), self.etg, state,
                               config=config, cache=cache,
                               format=self.etgformat)
     else:
         before = None
     # then apply all of the metrics
     self.results[state] = evaluate_flag(
         segs, triggers=before, metrics=self.metrics, injections=None,
         minduration=self.minseglength, vetotag=str(state),
         channel=str(self.channel), etg=self.etg)[0]
     vprint("    Veto evaluation results:\n")
     for metric, val in self.results[state].iteritems():
         vprint('        %s: %s\n' % (metric, val))
     # then pass to super to make the plots
     kwargs['trigcache'] = Cache()
     return super(FlagTab, self).process_state(state, *args, **kwargs)
Exemplo n.º 2
0
def veto(table, flag, tag=''):
    """Apply a veto to a set of event table and return survivors
    """
    alabel = veto_tag(table.channel, flag, tag)
    vlabel = veto_tag(table.channel, flag, tag, mode='#')
    akey = '%s,%s' % (alabel, table.etg.lower())
    vkey = '%s,%s' % (vlabel, table.etg.lower())
    if alabel in globalv.TRIGGERS:
        return get_triggers(alabel, table.etg, flag.known, query=False)
    else:
        after = table.copy()
        vetoed = table.copy()
        segs = flag.active
        get = get_row_value
        for row in table:
            if float(get(row, 'time')) in segs:
                vetoed.append(row)
            else:
                after.append(row)
        vetoed.segments = flag.active
        after.segments = flag.known - flag.active
        for t, key in zip([after, vetoed], [akey, vkey]):
            t.channel = table.channel
            t.etg = table.etg
            globalv.TRIGGERS[key] = t
        return after
Exemplo n.º 3
0
def veto(table, flag, tag=''):
    """Apply a veto to a set of event table and return survivors
    """
    alabel = veto_tag(table.channel, flag, tag)
    vlabel = veto_tag(table.channel, flag, tag, mode='#')
    akey = '%s,%s' % (alabel, table.etg.lower())
    vkey = '%s,%s' % (vlabel, table.etg.lower())
    if alabel in globalv.TRIGGERS:
        return get_triggers(alabel, table.etg, flag.known, query=False)
    else:
        after = table.copy()
        vetoed = table.copy()
        segs = flag.active
        get = get_row_value
        for row in table:
            if float(get(row, 'time')) in segs:
                vetoed.append(row)
            else:
                after.append(row)
        vetoed.segments = flag.active
        after.segments = flag.known - flag.active
        for t, key in zip([after, vetoed], [akey, vkey]):
            t.channel = table.channel
            t.etg = table.etg
            globalv.TRIGGERS[key] = t
        return after
Exemplo n.º 4
0
def veto(table, flag, tag='', channel='unknown-channel', etg='unknown-etg'):
    """Apply a veto to a set of event table and return survivors
    """
    alabel = veto_tag(channel, flag, tag)
    vlabel = veto_tag(channel, flag, tag, mode='#')
    akey = '%s,%s' % (alabel, etg.lower())
    vkey = '%s,%s' % (vlabel, etg.lower())
    if alabel in globalv.TRIGGERS:
        return get_triggers(alabel, etg, flag.known, query=False)
    else:
        times = get_times(table, etg=etg)
        in_segs = in_segmentlist(times, flag.active)
        vetoed = table[in_segs]
        vetoed.segments = flag.active
        after = table[~in_segs]
        after.segments = flag.known - flag.active
        for t, key in zip([after, vetoed], [akey, vkey]):
            globalv.TRIGGERS[key] = t
        return after
Exemplo n.º 5
0
def veto(table, flag, tag='', channel='unknown-channel', etg='unknown-etg'):
    """Apply a veto to a set of event table and return survivors
    """
    alabel = veto_tag(channel, flag, tag)
    vlabel = veto_tag(channel, flag, tag, mode='#')
    akey = '%s,%s' % (alabel, etg.lower())
    vkey = '%s,%s' % (vlabel, etg.lower())
    if alabel in globalv.TRIGGERS:
        return get_triggers(alabel, etg, flag.known, query=False)
    else:
        times = get_times(table, etg)
        in_segs = time_in_segments(times, flag.active)
        vetoed = table[in_segs]
        vetoed.segments = flag.active
        after = table[~in_segs]
        after.segments = flag.known - flag.active
        for t, key in zip([after, vetoed], [akey, vkey]):
            globalv.TRIGGERS[key] = t
        return after
Exemplo n.º 6
0
def test_read_archive():
    fname = test_write_archive(delete=False)
    empty_globalv()
    try:
        archive.read_data_archive(fname)
    finally:
        os.remove(fname)
    # check timeseries
    ts = data.get_timeseries('X1:TEST-CHANNEL',
                             [(100, 110)], query=False).join()
    nptest.assert_array_equal(ts.value, TEST_DATA.value)
    for attr in ['epoch', 'unit', 'sample_rate', 'channel', 'name']:
        assert getattr(ts, attr) == getattr(TEST_DATA, attr)
    # check trend series
    ts = data.get_timeseries('X1:TEST-TREND.mean,m-trend', [(0, 300)],
                             query=False).join()
    assert ts.channel.type == 'm-trend'
    assert ts.span == (0, 300)
    # check triggers
    t = triggers.get_triggers('X1:TEST-TABLE', 'testing', [(0, 100)])
    assert len(t) == 100
Exemplo n.º 7
0
def test_read_archive():
    fname = test_write_archive(delete=False)
    empty_globalv()
    try:
        archive.read_data_archive(fname)
    finally:
        os.remove(fname)
    # check timeseries
    ts = data.get_timeseries('X1:TEST-CHANNEL', [(100, 110)],
                             query=False).join()
    nptest.assert_array_equal(ts.value, TEST_DATA.value)
    for attr in ['epoch', 'unit', 'sample_rate', 'channel', 'name']:
        assert getattr(ts, attr) == getattr(TEST_DATA, attr)
    # check trend series
    ts = data.get_timeseries('X1:TEST-TREND.mean,m-trend', [(0, 300)],
                             query=False).join()
    assert ts.channel.type == 'm-trend'
    assert ts.span == (0, 300)
    # check triggers
    t = triggers.get_triggers('X1:TEST-TABLE', 'testing', [(0, 100)])
    assert len(t) == 100