gwexpy.segments.DataQualityDict#
- class gwexpy.segments.DataQualityDict#
ベースクラス:
dictAn dict of (key, DataQualityFlag) pairs.
- __init__(*args, **kwargs)#
Methods
__init__(*args, **kwargs)clear()coalesce()Coalesce all segments lists in this DataQualityDict.
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(source[, start, end, ifo])Read a DataQualityDict from a LIGO_LW XML VetoDefinerTable.
fromkeys(iterable[, value])Create a new dictionary with keys from iterable and values set to value.
get(key[, default])Return the value for key if key is in the dictionary, else default.
Return the intersection of all flags in this dict.
items()keys()plot([label])Plot this dict on a segments projection.
pop(k[,d])If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem()Remove and return a (key, value) pair as a 2-tuple.
populate([source, segments, pad, on_error])Query the segment database for each flag's active segments.
query(flags, *args[, host, on_error, parallel])Query the advanced LIGO DQSegDB for a list of flags.
query_dqsegdb(flags, *args[, host, ...])Query the advanced LIGO DQSegDB for a list of flags.
setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
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, ]**F)If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()Attributes
- read = <gwpy.segments.connect.DataQualityDictRead object>#
- write = <gwpy.segments.connect.DataQualityDictWrite object>#
- classmethod query_dqsegdb(flags: list[str], *args: SupportsToGps | Segment | SegmentList, host: str | None = 'https://segments.ligo.org', on_error: str = 'raise', parallel: int = 10, **kwargs) Self#
Query the advanced LIGO DQSegDB for a list of flags.
- パラメータ:
flags (iterable) -- A list of flag names for which to query.
args -- Either, two float-like numbers indicating the GPS [start, stop) interval, or a SegmentList defining a number of summary segments.
host (str, optional) -- Name or URL of the DQSegDB instance to talk to. Defaults to
dqsegdb2.utils.get_default_host().on_error (str, optional) --
how to handle an error querying for one flag, one of
'raise' (default): raise the Exception
'warn': print a warning
'ignore': move onto the next flag as if nothing happened
parallel (int, optional) -- Maximum number of threads to use for parallel connections to the DQSegDB host.
kwargs -- All other keyword arguments are passed to
dqsegdb2.query.query_segments().
- 戻り値:
flagdict -- An ordered DataQualityDict of (name, DataQualityFlag) pairs.
- 戻り値の型:
DataQualityDict
サンプル
The GPS interval(s) of interest can be passed as two arguments specifing the start and end of a single interval:
>>> DataQualityDict.query_dqsegdb(["X1:OBSERVING:1", "Y1:OBSERVING:1"], start, end)
Or, as a single Segment:
>>> DataQualityDict.query_dqsegdb(["X1:OBSERVING:1", "Y1:OBSERVING:1"], interval)
Or, as a SegmentList specifying multiple intervals.
>>> DataQualityDict.query_dqsegdb(["X1:OBSERVING:1", "Y1:OBSERVING:1"], intervals)
- classmethod query(flags: list[str], *args: SupportsToGps | Segment | SegmentList, host: str | None = 'https://segments.ligo.org', on_error: str = 'raise', parallel: int = 10, **kwargs) Self#
Query the advanced LIGO DQSegDB for a list of flags.
- パラメータ:
flags (iterable) -- A list of flag names for which to query.
args -- Either, two float-like numbers indicating the GPS [start, stop) interval, or a SegmentList defining a number of summary segments.
host (str, optional) -- Name or URL of the DQSegDB instance to talk to. Defaults to
dqsegdb2.utils.get_default_host().on_error (str, optional) --
how to handle an error querying for one flag, one of
'raise' (default): raise the Exception
'warn': print a warning
'ignore': move onto the next flag as if nothing happened
parallel (int, optional) -- Maximum number of threads to use for parallel connections to the DQSegDB host.
kwargs -- All other keyword arguments are passed to
dqsegdb2.query.query_segments().
- 戻り値:
flagdict -- An ordered DataQualityDict of (name, DataQualityFlag) pairs.
- 戻り値の型:
DataQualityDict
サンプル
The GPS interval(s) of interest can be passed as two arguments specifing the start and end of a single interval:
>>> DataQualityDict.query_dqsegdb(["X1:OBSERVING:1", "Y1:OBSERVING:1"], start, end)
Or, as a single Segment:
>>> DataQualityDict.query_dqsegdb(["X1:OBSERVING:1", "Y1:OBSERVING:1"], interval)
Or, as a SegmentList specifying multiple intervals.
>>> DataQualityDict.query_dqsegdb(["X1:OBSERVING:1", "Y1:OBSERVING:1"], intervals)
- classmethod from_veto_definer_file(source: str, start: SupportsToGps | None = None, end: SupportsToGps | None = None, ifo: str | None = None, **read_kw) Self#
Read a DataQualityDict from a LIGO_LW XML VetoDefinerTable.
- パラメータ:
source (str, Path, file) -- Path or URL of veto definer file to read, or open file.
start (~gwpy.time.LIGOTimeGPS, float, str) -- GPS start time of required data, any input parseable by ~gwpy.time.to_gps is fine
end (~gwpy.time.LIGOTimeGPS, float, str) -- GPS end time of required data, any input parseable by ~gwpy.time.to_gps is fine
ifo (str, optional) -- Interferometer prefix whose flags you want to read. Default is None (read all flags).
read_kw -- Other keyword arguments are passed to ~astropy.table.Table.read when reading the veto definer file.
- 戻り値:
flags -- A DataQualityDict of flags parsed from the veto_def_table of the input file.
- 戻り値の型:
DataQualityDict
メモ
This method does not automatically ~DataQualityDict.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()
- classmethod from_ligolw_tables(segmentdeftable: igwn_ligolw.lsctables.SegmentDefTable, segmentsumtable: igwn_ligolw.lsctables.SegmentSumTable, segmenttable: igwn_ligolw.lsctables.SegmentTable, names: list[str] | None = None, gpstype: type[SupportsFloat] | Callable[[float], SupportsFloat] = <class 'lal.LIGOTimeGPS'>, on_missing: str = 'error') Self#
Build a DataQualityDict from a set of LIGO_LW segment tables.
- パラメータ:
segmentdeftable (
SegmentDefTable) -- Thesegment_definertable to read.segmentsumtable (
SegmentSumTable) -- Thesegment_summarytable to read.segmenttable (
SegmentTable) -- Thesegmenttable to read.names (list of str, optional) -- A list of flag names to read. Default is to read all names.
gpstype (type, callable, optional) -- Class to use for GPS times in returned objects, can be a function to convert GPS time to something else. Default is ~gwpy.time.LIGOTimeGPS.
on_missing (str, optional) --
Action to take when a one or more
namesare not found in thesegment_definertable, one of'ignore': do nothing'warn': print a warningerror': raise a ValueError
- 戻り値:
dqdict -- A dict of DataQualityFlag objects populated from the LIGO_LW tables.
- 戻り値の型:
DataQualityDict
- to_ligolw_tables(**attrs) tuple[igwn_ligolw.lsctables.SegmentDefTable, igwn_ligolw.lsctables.SegmentSumTable, igwn_ligolw.lsctables.SegmentTable]#
Convert this DataQualityDict into a trio of LIGO_LW segment tables.
- パラメータ:
attrs -- Other attributes to add to all rows in all tables (e.g.
'process_id').- 戻り値:
segmentdeftable (
SegmentDefTable) -- Thesegment_definertable.segmentsumtable (
SegmentSumTable) -- Thesegment_summarytable.segmenttable (
SegmentTable) -- Thesegmenttable.
- coalesce() Self#
Coalesce all segments lists in this DataQualityDict.
This method modifies this object in-place.
- 戻り値:
A view of this flag, not a copy.
- 戻り値の型:
self
- populate(source: str | None = 'https://segments.ligo.org', segments: SegmentList | None = None, *, pad: bool = True, on_error: str = 'raise', **kwargs) Self#
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
Segments will be fetched from the database, with any
paddingadded on-the-fly.Entries in this dict will be modified in-place.
- パラメータ:
source (str) -- Source of segments for this flag. This must be either a URL for a segment database or a path to a file on disk.
segments (SegmentList, optional) -- A list of known segments during which to query, if not given, existing known segments for flags will be used.
pad (bool, optional, default: True) -- Apply the ~DataQualityFlag.padding associated with each flag, default: True.
on_error (str) --
How to handle an error querying for one flag, one of
'raise' (default): raise the Exception
'warn': print a warning
'ignore': move onto the next flag as if nothing happened
kwargs -- Any other keyword arguments to be passed to
DataQualityFlag.query()orDataQualityFlag.read().
- 戻り値:
self -- A reference to the modified DataQualityDict
- 戻り値の型:
DataQualityDict
- copy(*, deep: bool = False) Self#
Build a copy of this dictionary.
- パラメータ:
deep (bool, optional, default: False) -- perform a deep copy of the original dictionary with a fresh memory address
- 戻り値:
flag2 -- a copy of the original dictionary
- 戻り値の型:
DataQualityFlag
- union() DataQualityFlag#
Return the union of all flags in this dict.
- 戻り値:
union -- a new DataQualityFlag who's active and known segments are the union of those of the values of this dict
- 戻り値の型:
DataQualityFlag
- intersection() DataQualityFlag#
Return the intersection of all flags in this dict.
- 戻り値:
intersection -- a new DataQualityFlag who's active and known segments are the intersection of those of the values of this dict
- 戻り値の型:
DataQualityFlag
- plot(label: str = 'key', **kwargs) Plot#
Plot this dict on a segments projection.
- パラメータ:
label (str, optional) --
Labelling system to use, or fixed label for all flags, special values include
'key': use the key of the DataQualityDict,'name': use thenameof the flag
If anything else, that fixed label will be used for all lines.
kwargs -- All keyword arguments are passed to the
Plotconstructor.
- 戻り値:
figure -- the newly created figure, with populated Axes.
- 戻り値の型:
~matplotlib.figure.Figure
参考
matplotlib.pyplot.figureFor documentation of keyword arguments used to create the figure.
matplotlib.figure.Figure.add_subplotFor documentation of keyword arguments used to create the axes.
gwpy.plot.SegmentAxes.plot_segmentlistFor documentation of keyword arguments used in rendering the data.