gwpy.segments.
DataQualityDict
(*args, **kwds)[source]¶Bases: collections.OrderedDict
An OrderedDict
of (key, DataQualityFlag
) pairs.
Since the DataQualityDict
is an OrderedDict
, all iterations over
its elements retain the order in which they were inserted.
Methods Summary
clear (() -> None. Remove all items from od.) |
|
copy ([deep]) |
Build a copy of this dictionary. |
from_ligolw_tables (segmentdeftable, …[, …]) |
Build a DataQualityDict from a set of LIGO_LW segment tables |
from_veto_definer_file (fp[, start, end, …]) |
Read a DataQualityDict from a LIGO_LW XML VetoDefinerTable. |
fromkeys ((S[, …) |
If not specified, the value defaults to None. |
get ((k[,d]) -> D[k] if k in D, …) |
|
has_key ((k) -> True if D has a key k, else False) |
|
intersection () |
Return the intersection of all flags in this dict |
items (() -> list of (key, value) pairs in od) |
|
iteritems () |
od.iteritems -> an iterator over the (key, value) pairs in od |
iterkeys (() -> an iterator over the keys in od) |
|
itervalues () |
od.itervalues -> an iterator over the values in od |
keys (() -> list of keys in od) |
|
plot ([label]) |
Plot the data for this dict. |
pop ((k[,d]) -> v, …) |
value. If key is not found, d is returned if given, otherwise KeyError |
popitem (() -> (k, v), …) |
Pairs are returned in LIFO order if last is true or FIFO order if false. |
populate ([source, segments, pad, on_error]) |
Query the segment database for each flag’s active segments. |
query (flags, *args, **kwargs) |
Query for segments of a set of flags. |
query_dqsegdb (flags, *args, **kwargs) |
Query the advanced LIGO DQSegDB for a list of flags. |
query_segdb (flags, *args, **kwargs) |
Query the inital LIGO segment database for a list of flags. |
read (source[, flags, format]) |
Read segments from file into a DataQualityDict |
setdefault ((k[,d]) -> od.get(k,d), …) |
|
to_ligolw_tables (**attrs) |
Convert this DataQualityDict into a trio of LIGO_LW segment tables |
union () |
Return the union of all flags in this dict |
update (([E, …) |
If E present and has a .keys() method, does: for k in E: D[k] = E[k] |
values (() -> list of values in od) |
|
viewitems (…) |
|
viewkeys (…) |
|
viewvalues (…) |
|
write (target, *args, **kwargs) |
Write this DataQualityDict to file |
Methods Documentation
clear
() → None. Remove all items from od.¶copy
(deep=False)[source]¶Build a copy of this dictionary.
Parameters: | deep :
|
---|---|
Returns: | flag2 :
|
from_ligolw_tables
(segmentdeftable, segmentsumtable, segmenttable, names=None, gpstype=<type 'lal.LIGOTimeGPS'>)[source]¶Build a DataQualityDict
from a set of LIGO_LW segment tables
Parameters: | segmentdeftable :
segmentsumtable :
segmenttable :
gpstype :
|
---|---|
Returns: | dqdict :
|
from_veto_definer_file
(fp, start=None, end=None, ifo=None, format='ligolw')[source]¶Read a DataQualityDict
from a LIGO_LW XML VetoDefinerTable.
Parameters: | fp :
start :
end :
ifo :
format :
|
---|---|
Returns: | flags :
|
Notes
This method does not automatically populate
the active
segment list of any flags, a separate call should
be made for that as follows
>>> flags = DataQualityDict.from_veto_definer_file('/path/to/file.xml')
>>> flags.populate()
fromkeys
(S[, v]) → New ordered dictionary with keys from S.¶If not specified, the value defaults to None.
get
(k[, d]) → D[k] if k in D, else d. d defaults to None.¶has_key
(k) → True if D has a key k, else False¶intersection
()[source]¶Return the intersection of all flags in this dict
Returns: | intersection :
|
---|
items
() → list of (key, value) pairs in od¶iteritems
()¶od.iteritems -> an iterator over the (key, value) pairs in od
iterkeys
() → an iterator over the keys in od¶itervalues
()¶od.itervalues -> an iterator over the values in od
keys
() → list of keys in od¶plot
(label='key', **kwargs)[source]¶Plot the data for this dict.
Parameters: | label :
**kwargs
|
---|
pop
(k[, d]) → v, remove specified key and return the corresponding¶value. If key is not found, d is returned if given, otherwise KeyError is raised.
popitem
() → (k, v), return and remove a (key, value) pair.¶Pairs are returned in LIFO order if last is true or FIFO order if false.
populate
(source='http://segments.ldas.cit', segments=None, pad=True, on_error='raise', **kwargs)[source]¶Query the segment database for each flag’s active segments.
This method assumes all of the metadata for each flag have been filled. Minimally, the following attributes must be filled
name |
The name associated with this flag. |
known |
The set of segments during which this flag was known, and its state was well defined. |
Segments will be fetched from the database, with any
padding
added on-the-fly.
Entries in this dict will be modified in-place.
Parameters: | source :
segments :
pad : on_error :
**kwargs
|
---|---|
Returns: | self :
|
query
(flags, *args, **kwargs)[source]¶Query for segments of a set of flags.
This method intelligently selects the query_segdb
or the query_dqsegdb
methods based on the
url
kwarg given.
Parameters: | flags :
*args
url :
|
---|---|
Returns: | flagdict :
|
See also
DataQualityDict.query_dqsegdb
query_dqsegdb
(flags, *args, **kwargs)[source]¶Query the advanced LIGO DQSegDB for a list of flags.
Parameters: | flags :
*args
on_error :
url :
|
---|---|
Returns: | flagdict :
|
query_segdb
(flags, *args, **kwargs)[source]¶Query the inital LIGO segment database for a list of flags.
Parameters: | flags :
*args
url :
|
---|---|
Returns: | flagdict :
|
read
(source, flags=None, format=None, **kwargs)[source]¶Read segments from file into a DataQualityDict
Parameters: | source :
format :
flags :
coalesce :
nproc :
verbose :
|
---|---|
Returns: | flagdict :
|
Notes
The available built-in formats are:
Format | Read | Write | Auto-identify |
---|---|---|---|
hdf5 | Yes | No | No |
ligolw | Yes | Yes | Yes |
setdefault
(k[, d]) → od.get(k,d), also set od[k]=d if k not in od¶to_ligolw_tables
(**attrs)[source]¶Convert this DataQualityDict
into a trio of LIGO_LW segment tables
Parameters: | **attrs
|
---|---|
Returns: | segmentdeftable :
segmentsumtable :
segmenttable :
|
union
()[source]¶Return the union of all flags in this dict
Returns: | union :
|
---|
update
([E, ]**F) → None. Update D from mapping/iterable E and F.¶If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
values
() → list of values in od¶viewitems
() → a set-like object providing a view on od's items¶viewkeys
() → a set-like object providing a view on od's keys¶viewvalues
() → an object providing a view on od's values¶write
(target, *args, **kwargs)[source]¶Write this DataQualityDict
to file
Notes
The available built-in formats are:
Format | Read | Write | Auto-identify |
---|---|---|---|
hdf5 | Yes | Yes | No |
ligolw | Yes | Yes | Yes |
copy
(deep=False)[source]Build a copy of this dictionary.
Parameters: | deep :
|
---|---|
Returns: | flag2 :
|
from_ligolw_tables
(segmentdeftable, segmentsumtable, segmenttable, names=None, gpstype=<type 'lal.LIGOTimeGPS'>)[source]Build a DataQualityDict
from a set of LIGO_LW segment tables
Parameters: | segmentdeftable :
segmentsumtable :
segmenttable :
gpstype :
|
---|---|
Returns: | dqdict :
|
from_veto_definer_file
(fp, start=None, end=None, ifo=None, format='ligolw')[source]Read a DataQualityDict
from a LIGO_LW XML VetoDefinerTable.
Parameters: | fp :
start :
end :
ifo :
format :
|
---|---|
Returns: | flags :
|
Notes
This method does not automatically populate
the active
segment list of any flags, a separate call should
be made for that as follows
>>> flags = DataQualityDict.from_veto_definer_file('/path/to/file.xml')
>>> flags.populate()
intersection
()[source]Return the intersection of all flags in this dict
Returns: | intersection :
|
---|
plot
(label='key', **kwargs)[source]Plot the data for this dict.
Parameters: | label :
**kwargs
|
---|
populate
(source='http://segments.ldas.cit', segments=None, pad=True, on_error='raise', **kwargs)[source]Query the segment database for each flag’s active segments.
This method assumes all of the metadata for each flag have been filled. Minimally, the following attributes must be filled
name |
The name associated with this flag. |
known |
The set of segments during which this flag was known, and its state was well defined. |
Segments will be fetched from the database, with any
padding
added on-the-fly.
Entries in this dict will be modified in-place.
Parameters: | source :
segments :
pad : on_error :
**kwargs
|
---|---|
Returns: | self :
|
query
(flags, *args, **kwargs)[source]Query for segments of a set of flags.
This method intelligently selects the query_segdb
or the query_dqsegdb
methods based on the
url
kwarg given.
Parameters: | flags :
*args
url :
|
---|---|
Returns: | flagdict :
|
See also
DataQualityDict.query_dqsegdb
query_dqsegdb
(flags, *args, **kwargs)[source]Query the advanced LIGO DQSegDB for a list of flags.
Parameters: | flags :
*args
on_error :
url :
|
---|---|
Returns: | flagdict :
|
query_segdb
(flags, *args, **kwargs)[source]Query the inital LIGO segment database for a list of flags.
Parameters: | flags :
*args
url :
|
---|---|
Returns: | flagdict :
|
read
(source, flags=None, format=None, **kwargs)[source]Read segments from file into a DataQualityDict
Parameters: | source :
format :
flags :
coalesce :
nproc :
verbose :
|
---|---|
Returns: | flagdict :
|
Notes
The available built-in formats are:
Format | Read | Write | Auto-identify |
---|---|---|---|
hdf5 | Yes | No | No |
ligolw | Yes | Yes | Yes |
to_ligolw_tables
(**attrs)[source]Convert this DataQualityDict
into a trio of LIGO_LW segment tables
Parameters: | **attrs
|
---|---|
Returns: | segmentdeftable :
segmentsumtable :
segmenttable :
|
union
()[source]Return the union of all flags in this dict
Returns: | union :
|
---|
write
(target, *args, **kwargs)[source]Write this DataQualityDict
to file
Notes
The available built-in formats are:
Format | Read | Write | Auto-identify |
---|---|---|---|
hdf5 | Yes | Yes | No |
ligolw | Yes | Yes | Yes |