本文整理汇总了Python中gwpy.segments.DataQualityFlag类的典型用法代码示例。如果您正苦于以下问题:Python DataQualityFlag类的具体用法?Python DataQualityFlag怎么用?Python DataQualityFlag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataQualityFlag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: downtime
def downtime(vetosegs, segments, channel):
myflag = DataQualityFlag()
myflag.active = vetosegs
myflag.known = segments
plot = myflag.plot()
plot.set_title(r'Active and vetoed segments for %s' %channel)
plot.savefig(r'%s_downtime.png'%channel)
示例2: test_deprecated
def test_deprecated(self):
with pytest.warns(DeprecationWarning):
flag = DataQualityFlag(FLAG1, active=ACTIVE, valid=KNOWN)
with pytest.warns(DeprecationWarning):
flag.valid
with pytest.warns(DeprecationWarning):
flag.valid = flag.known
with pytest.warns(DeprecationWarning):
del flag.valid
示例3: evaluate_flag
def evaluate_flag(flag, triggers=None, metrics=['deadtime'], injections=None,
minduration=0, vetotag='', channel=None, etg=None):
"""Evaluate the performance of a set of a `~gwpy.segments.DataQualityFlag`
Parameters
----------
flag : `~gwpy.segments.DataQualityFlag`
the data-quality flag to be tested
triggers : `~glue.ligolw.table.Table`, optional
the set of analysis event triggers against which to test
metrics : `list`, optional
the list of `Metrics <~gwvet.Metric>`
injections : `~glue.ligolw.table.Table`, `~gwpy.segments.SegmentList`, optional
a list of injections, or injection segments, against which to test
flag safety
minduration : `float`, optional
the minimum duration of post-veto segments, if applicable, default: 0
Returns
-------
results, after : `OrderedDict`, `~glue.ligolw.table.Table`
the results of each metric test, and the triggers after vetoes have
been applied (or `None` if not given)
"""
# format as flag
if not isinstance(flag, DataQualityFlag):
flag = DataQualityFlag(active=flag)
else:
flag = flag.copy()
# get inverse of veto segments
if minduration:
post = type(flag.known)([s for s in (flag.known - flag.active)
if float(abs(s)) >= minduration])
flag.active = flag.known - post
# apply vetoes to triggers
triggers.etg = etg
if triggers is not None:
after = veto(triggers, flag, tag=vetotag, channel=channel, etg=etg)
else:
after = None
# test each metric
out = OrderedDict()
for metric in metrics:
if isinstance(metric, Metric):
_metric = metric
else:
_metric = get_metric(metric)
if _metric.name.lower() == 'safety':
out[metric] = _metric(flag, injections)
elif _metric.needs_triggers:
out[metric] = _metric(flag, triggers, after=after)
else:
out[metric] = _metric(flag)
return out, after
示例4: test_coalesce
def test_coalesce(self):
flag = DataQualityFlag(FLAG1, active=ACTIVE, known=KNOWN)
self.assertFalse(flag.regular,
'flag.regular test failed (should be False)')
flag.coalesce()
self.assertTrue(flag.known == KNOWN, 'flag.known changed by coalesce')
self.assertTrue(flag.active == KNOWNACTIVE,
'flag.active misset by coalesce')
self.assertTrue(flag.regular,
'flag.regular test failed (should be True)')
示例5: test_pad
def test_pad(self):
flag = DataQualityFlag(FLAG1, active=ACTIVE, known=KNOWN)
# test without arguments (and no padding)
padded = flag.pad()
self.assertListEqual(padded.known, flag.known)
self.assertListEqual(padded.active, flag.active)
# test without arguments (and no padding)
flag.padding = PADDING
padded = flag.pad()
self.assertListEqual(padded.known, KNOWNPAD)
self.assertListEqual(padded.active, ACTIVEPAD)
# test with arguments
flag = DataQualityFlag(FLAG1, active=ACTIVE, known=KNOWN)
padded = flag.pad(*PADDING)
self.assertListEqual(padded.known, KNOWNPAD)
self.assertListEqual(padded.active, ACTIVEPAD)
# test coalesce
padded.coalesce()
self.assertListEqual(padded.active, ACTIVEPADC)
# test in-place
flag = DataQualityFlag(FLAG1, active=ACTIVE, known=KNOWN)
padded = flag.pad(*PADDING)
self.assertIsNot(flag, padded)
padded = flag.pad(*PADDING, inplace=True)
self.assertIs(flag, padded)
# test other kwargs fail
self.assertRaises(TypeError, flag.pad, *PADDING, kwarg='test')
示例6: test_write_hdf5
def test_write_hdf5(self, delete=True):
flag = DataQualityFlag(FLAG1, active=ACTIVE, known=KNOWN)
hdfout = self.tmpfile % 'hdf'
try:
flag.write(hdfout)
except ImportError as e:
self.skipTest(str(e))
else:
if delete:
os.remove(hdfout)
return hdfout
示例7: summary_stats
def summary_stats(statistics, bbh_trigs, omicron_trigs, channel, vetosegs, segments):
# Metrics being considered
eff = get_metric('efficiency')
dt = get_metric('deadtime')
eff_over_dt = get_metric('efficiency/deadtime')
usep = get_metric('my use percentage')
loudbysnr = get_metric('loudest event by snr')
get_percentile= get_metric('percentile')
myflag = DataQualityFlag()
myflag.active = vetosegs
myflag.known = segments
statistics[i] = (channel, eff(myflag, bbh_trigs).value, dt(myflag).value,\
eff_over_dt(myflag, bbh_trigs).value, usep(myflag, omic_trigs).value,\
loudbysnr(myflag, bbh_trigs).value)
示例8: check_flag
def check_flag(flag, gpstime, duration, pad):
"""Check that a state flag is active during an entire analysis segment
Parameters
----------
flag : `str`
state flag to check
gpstime : `float`
GPS time of required data
duration : `float`
duration (in seconds) of required data
pad : `float`
amount of extra data to read in at the start and end for filtering
Returns
-------
check : `bool`
Boolean switch to pass (`True`) or fail (`False`) depending on whether
the given flag is active
"""
# set GPS start and end time
start = gpstime - duration/2. - pad
end = gpstime + duration/2. + pad
seg = Segment(start, end)
# query for state segments
active = DataQualityFlag.query(flag, start, end,
url=DEFAULT_SEGMENT_SERVER).active
# check that state flag is active during the entire analysis
if (not active.intersects_segment(seg)) or (abs(active[0]) < abs(seg)):
return False
return True
示例9: test_read_ligolw
def test_read_ligolw(self):
flag = DataQualityFlag.read(SEGXML, FLAG1, coalesce=False)
self.assertTrue(flag.active == ACTIVE,
'DataQualityFlag.read(ligol) mismatch:\n\n%s\n\n%s'
% (ACTIVE, flag.active))
self.assertTrue(flag.known == KNOWN,
'DataQualityFlag.read(ligol) mismatch:\n\n%s\n\n%s'
% (KNOWN, flag.known))
示例10: query_state_segments
def query_state_segments(flag, start, end, url=DEFAULT_SEGMENT_SERVER,
pad=(0, 0)):
"""Query a segment database for active segments associated with a flag
"""
# NOTE: DQF.pad pads forward in time at end
return DataQualityFlag.query(
flag, start-pad[0], end+pad[1], url=url,
).coalesce().pad(pad[0], -pad[1]).active
示例11: test_query_dqsegdb
def test_query_dqsegdb(self):
try:
flag = DataQualityFlag.query_dqsegdb(
QUERY_FLAG, QUERY_START, QUERY_END, url=QUERY_URL)
except (ImportError, URLError) as e:
self.skipTest(str(e))
else:
self.assertEqual(flag.known, QUERY_KNOWN)
self.assertEqual(flag.active, QUERY_ACTIVE)
示例12: test_query_segdb
def test_query_segdb(self):
flag = QUERY_FLAGS[0]
try:
result = DataQualityFlag.query_segdb(flag, QUERY_START, QUERY_END,
url=QUERY_URL_SEGDB)
except (SystemExit, LDBDClientException) as e:
self.skipTest(str(e))
self.assertEqual(result.known, QUERY_RESULT[flag].known)
self.assertEqual(result.active, QUERY_RESULT[flag].active)
示例13: _read_segments
def _read_segments(self, filename):
segs = DataQualityFlag.read(filename, self.definition)
# XXX HACK around malformed segment files with no segment_summary table
if segs.active and not segs.known:
segs.known = type(segs.active)(segs.active)
if self.known:
self.known = self.known & segs.known
self.active = self.known & segs.active
else:
self.known = segs.known
self.active = segs.active
return self
示例14: test_query_dqsegdb_multi
def test_query_dqsegdb_multi(self):
querymid = int(QUERY_START + (QUERY_END - QUERY_START) /2.)
segs = SegmentList([Segment(QUERY_START, querymid),
Segment(querymid, QUERY_END)])
try:
flag = DataQualityFlag.query_dqsegdb(
QUERY_FLAG, segs, url=QUERY_URL)
except (ImportError, URLError) as e:
self.skipTest(str(e))
else:
self.assertEqual(flag.known, QUERY_KNOWN)
self.assertEqual(flag.active, QUERY_ACTIVE)
示例15: test_read_hdf5
def test_read_hdf5(self):
try:
hdfout = self.test_write_hdf5(delete=False)
except ImportError as e:
self.skipTest(str(e))
else:
flag = DataQualityFlag.read(hdfout)
os.remove(hdfout)
self.assertTrue(flag.active == ACTIVE,
'DataQualityFlag.read(hdf5) mismatch:\n\n%s\n\n%s'
% (ACTIVE, flag.active))
self.assertTrue(flag.known == KNOWN,
'DataQualityFlag.read(hdf5) mismatch:\n\n%s\n\n%s'
% (KNOWN, flag.known))