DataQualityFlag¶
- class gwpy.segments.DataQualityFlag(name: str | None = None, active: SegmentListLike | None = None, known: SegmentListLike | None = None, *, label: str | None = None, category: int | None = None, description: str | None = None, isgood: bool = True, padding: tuple[float | None, float | None] | None = None)[source]¶
A representation of a named set of segments.
- Parameters:
- namestr, optional
The name of this flag. This should be of the form {ifo}:{tag}:{version}, e.g. ‘H1:DMT-SCIENCE:1’. Use
labelfor human-readable names.- active
SegmentList, optional A list of active segments for this flag
- known
SegmentList, optional A list of known segments for this flag
- label
str, optional Human-readable name for this flag, e.g.
'Science-mode'- category
int, optional Veto category for this flag.
- description
str, optional Human-readable description of why this flag was created.
- isgood
bool, optional Do active segments mean the IFO was in a good state?
Attributes Summary
The set of segments during which this flag was active.
Veto category for this flag.
Description of why/how this flag was generated.
The GPS
[start, stop)enclosing segment of thisDataQualityFlag.The interferometer associated with this flag.
Whether
activesegments mean the instrument was in a good state.The segments during which this flag was known.
A human-readable label for this flag.
Amount of time this flag was
active.The name associated with this flag.
(start, end) padding for this flag's active segments.
Read segments from file into a
DataQualityFlag.Trueif theactivesegments are a proper subset of theknown.The tag (name) associated with this flag.
Name of this flag in LaTeX printable format.
The version number of this flag.
Write this
DataQualityFlagto file.Methods Summary
coalesce()Coalesce the segments for this flag.
contract(x)Contract each of the
activesegments byxseconds.copy()Build an exact copy of this flag.
fetch_open_data(flag, start, end, **kwargs)Fetch Open Data timeline segments into a flag.
from_veto_def(veto)Define a
DataQualityFlagfrom aVetoDef.pad(*args[, inplace])Apply a padding to each segment in this
DataQualityFlag.plot([figsize, xscale])Plot this flag on a segments projection.
populate([source, segments, pad])Query the segment database for this flag's active segments.
protract(x)Protract each of the
activesegments byxseconds.query(flag, *args[, host])Query a DQSegDB server for a flag.
query_dqsegdb(flag, *args[, host])Query a DQSegDB server for a flag.
round(*[, contract])Round this flag to integer segments.
Attributes Documentation
- extent[source]¶
The GPS
[start, stop)enclosing segment of thisDataQualityFlag.
- ifo[source]¶
The interferometer associated with this flag.
This should be a single uppercase letter and a single number, e.g.
'H1'.
- name[source]¶
The name associated with this flag.
This normally takes the form {ifo}:{tag}:{version}. If found, each component is stored separately the associated attributes.
- Type:
- read¶
Read segments from file into a
DataQualityFlag.- Parameters:
- filename
str Path of file to read.
- name
str, optional Name of flag to read from file, otherwise read all segments.
- format
str, optional Source format identifier. If not given, the format will be detected if possible. See below for list of acceptable formats.
- coltype
type, optional, default:float Datatype to force for segment times, only valid for
format='segwizard'.- strict
bool, optional, default:True Require segment start and stop times match printed duration, only valid for
format='segwizard'.- coalesce
bool, optional If
Truecoalesce the all segment lists before returning, otherwise return exactly as contained in file(s).- parallel
int, optional, default: 1 Number of threads to use for parallel reading of multiple files.
- verbose
bool, optional, default:False Print a progress bar showing read status.
- filename
- Returns:
- dqflag
DataQualityFlag formatted
DataQualityFlagcontaining the active and known segments read from file.
- dqflag
- Raises:
- IndexError
If
sourceis an empty list.
- tag[source]¶
The tag (name) associated with this flag.
This should take the form
'AAA-BBB_CCC_DDD', i.e. where each component is an uppercase acronym of alphanumeric characters only, e.g.'DCH-IMC_BAD_CALIBRATION'or'DMT-SCIENCE'.
- version[source]¶
The version number of this flag.
Each flag in the segment database is stored with a version integer, with each successive version representing a more accurate dataset for its known segments than any previous.
- write¶
Write this
DataQualityFlagto file.
Methods Documentation
- coalesce() Self[source]¶
Coalesce the segments for this flag.
This method does two things:
Note
This operation is performed in-place.
- Returns:
- self
A view of this flag, not a copy.
- contract(x: float) SegmentList[source]¶
Contract each of the
activesegments byxseconds.This method adds
xto each segment’s lower bound, and subtractsxfrom the upper bound.The
activeSegmentListis modified in place.
- copy() Self[source]¶
Build an exact copy of this flag.
- Returns:
- flag
DataQualityFlag A deepcopy of the original flag.
- flag
- classmethod fetch_open_data(flag: str, start: GpsLike, end: GpsLike, **kwargs) Self[source]¶
Fetch Open Data timeline segments into a flag.
- flag
str The name of the flag to query
- start
LIGOTimeGPS,float,str GPS start time of required data, any input parseable by
to_gpsis fine- end
LIGOTimeGPS,float,str GPS end time of required data, any input parseable by
to_gpsis fine- timeout
int, optional Timeout for download (seconds).
- host
str, optional URL of GWOSC host, default:
'https://gwosc.org'.
- Returns:
- flag
DataQualityFlag a new flag with
activesegments filled from Open Data
- flag
Examples
>>> from gwpy.segments import DataQualityFlag >>> print(DataQualityFlag.fetch_open_data( ... "H1_DATA", ... "Sep 14 2015", ... "Sep 15 2015", ... )) <DataQualityFlag('H1:DATA', known=[[1126224017 ... 1126310417)] active=[[1126251604 ... 1126252133) [1126252291 ... 1126274322) [1126276234 ... 1126281754) ... [1126308670 ... 1126309577) [1126309637 ... 1126309817) [1126309877 ... 1126310417)] description=None)>
- flag
- classmethod from_veto_def(veto: igwn_ligolw.lsctables.VetoDef | astropy.table.Row) Self[source]¶
Define a
DataQualityFlagfrom aVetoDef.
- pad(*args: float, inplace: bool = False) Self[source]¶
Apply a padding to each segment in this
DataQualityFlag.This method either takes no arguments, in which case the value of the
paddingattribute will be used, or two values representing the padding for the start and end of each segment.For both the
startandendpaddings, a positive value means pad forward in time, so that a positivestartpad or negativeendpadding will contract a segment at one or both ends, and vice-versa.This method will apply the same padding to both the
knownandactivelists, but will notcoalesce()the result.- Parameters:
- Returns:
- paddedflag
DataQualityFlag A view of the modified flag.
- paddedflag
- plot(figsize: tuple[float, float] = (12, 4), xscale: str = 'auto-gps', **kwargs) Plot[source]¶
Plot this flag on a segments projection.
- Parameters:
- figsize
tupleoffloat The size (width, height) of the figure to create.
- xscale: `str`
The scaling to use for the X-axis (time axis). Default is
"auto-gps"to dynamically choose the right scaling based on how much time is covered by the visible span.- kwargs
Other keyword arguments are passed to the
Plotconstructor.
- figsize
- Returns:
- figure
Figure The newly created figure, with populated Axes.
- figure
See also
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.
- populate(source: str | None = 'http://segments.ldas.cit', segments: SegmentList | None = None, *, pad: bool = True, **kwargs) Self[source]¶
Query the segment database for this 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.This
DataQualityFlagwill be modified in-place.- Parameters:
- 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 segments during which to query, if not given, existing known segments for this flag will be used.
- pad
bool, optional, default:True - **kwargs
any other keyword arguments to be passed to
DataQualityFlag.query()orDataQualityFlag.read().
- source
- Returns:
- self
DataQualityFlag a reference to this flag
- self
- protract(x: float) SegmentList[source]¶
Protract each of the
activesegments byxseconds.This method subtracts
xfrom each segment’s lower bound, and addsxto the upper bound, while maintaining that eachSegmentstays within theknownbounds.The
activeSegmentListis modified in place.
- classmethod query(flag: str, *args: GpsLike | Segment | SegmentList, host: str | None = 'http://segments.ldas.cit', **kwargs) Self[source]¶
Query a DQSegDB server for a flag.
- Parameters:
- flag
str The name of the flag for which to query
- args
Either, two
float-like numbers indicating the GPS [start, stop) interval, or aSegmentListdefining 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().- kwargs
All other keyword arguments are passed to
dqsegdb2.query.query_segments().
- flag
- Returns:
- flag
DataQualityFlag A new
DataQualityFlag, with theknownandactivelists filled appropriately.
- flag
Examples
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
SegmentListspecifying multiple intervals.>>> DataQualityDict.query_dqsegdb(["X1:OBSERVING:1", "Y1:OBSERVING:1"], intervals)
- classmethod query_dqsegdb(flag: str, *args: GpsLike | Segment | SegmentList, host: str | None = 'http://segments.ldas.cit', **kwargs) Self[source]¶
Query a DQSegDB server for a flag.
- Parameters:
- flag
str The name of the flag for which to query
- args
Either, two
float-like numbers indicating the GPS [start, stop) interval, or aSegmentListdefining 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().- kwargs
All other keyword arguments are passed to
dqsegdb2.query.query_segments().
- flag
- Returns:
- flag
DataQualityFlag A new
DataQualityFlag, with theknownandactivelists filled appropriately.
- flag
Examples
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
SegmentListspecifying multiple intervals.>>> DataQualityDict.query_dqsegdb(["X1:OBSERVING:1", "Y1:OBSERVING:1"], intervals)