gwpy.segments.DataQualityFlag(name=None, active=None, known=None, label=None, category=None, description=None, isgood=True, padding=None)[source]¶Bases: object
A representation of a named set of segments.
name : str, 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 single GPS |
|
The interferometer associated with this flag. |
|
Whether |
|
The set of segments during which this flag was known, and its state was well defined. |
|
A human-readable label for this flag. |
|
Amount of time this flag was |
|
The name associated with this flag. |
|
[start, end) padding for this flag’s active segments. |
|
|
|
The tag (name) associated with this flag. |
|
Name of this flag in LaTeX printable format. |
|
The version number of this flag. |
Methods Summary
|
Coalesce the segments for this flag. |
|
Contract each of the |
|
Build an exact copy of this flag. |
|
Fetch Open Data timeline segments into a flag. |
|
Define a |
|
Apply a padding to each segment in this |
|
Plot this flag on a segments projection. |
|
Query the segment database for this flag’s active segments. |
|
Protract each of the |
|
Query for segments of a given flag |
|
Query the advanced LIGO DQSegDB for the given flag |
|
Query the initial LIGO segment database for the given flag |
|
Read segments from file into a |
|
Round this flag to integer segments. |
|
Write this |
Attributes Documentation
active¶The set of segments during which this flag was active.
extent¶The single GPS [start, stop) enclosing segment of this
DataQualityFlag.
ifo¶The interferometer associated with this flag.
This should be a single uppercase letter and a single number,
e.g. 'H1'.
known¶The set of segments during which this flag was known, and its state was well defined.
name¶The name associated with this flag.
This normally takes the form {ifo}:{tag}:{version}. If found, each component is stored separately the associated attributes.
padding¶[start, end) padding for this flag’s active segments.
tag¶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'.
texname¶Name of this flag in LaTeX printable format.
version¶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.
Methods Documentation
coalesce(self)[source]¶Coalesce the segments for this flag.
This method does two things:
Note
this operations is performed in-place.
self
a view of this flag, not a copy.
contract(self, x)[source]¶Contract each of the active Segments by x seconds.
This method adds x to each segment’s lower bound, and subtracts
x from the upper bound.
The active SegmentList is modified
in place.
copy(self)[source]¶Build an exact copy of this flag.
flag2 : DataQualityFlag
a copy of the original flag, but with a fresh memory address.
fetch_open_data(flag, start, end, **kwargs)[source]¶Fetch Open Data timeline segments into a flag.
strthe name of the flag to query
int, strthe GPS start time (or parseable date string) to query
int, strthe GPS end time (or parseable date string) to query
bool, optionalshow verbose download progress, default: False
int, optionaltimeout for download (seconds)
str, optionalURL of LOSC host, default: 'losc.ligo.org'
flag : DataQualityFlag
a new flag with
activesegments filled from Open Data
Examples
>>> from gwpy.segments import DataQualityFlag
>>> print(DataQualityFlag.fetch_open_data('H1_DATA', 'Jan 1 2010',
... 'Jan 2 2010'))
<DataQualityFlag('H1:DATA',
known=[[946339215 ... 946425615)],
active=[[946340946 ... 946351800)
[946356479 ... 946360620)
[946362652 ... 946369150)
[946372854 ... 946382630)
[946395595 ... 946396751)
[946400173 ... 946404977)
[946412312 ... 946413577)
[946415770 ... 946422986)],
description=None)>
from_veto_def(veto)[source]¶Define a DataQualityFlag from a VetoDef
veto : VetoDef
veto definition to convert from
pad(self, *args, **kwargs)[source]¶Apply a padding to each segment in this DataQualityFlag
This method either takes no arguments, in which case the value of
the padding attribute will be used,
or two values representing the padding for the start and end of
each segment.
For both the start and end paddings, a positive value means
pad forward in time, so that a positive start pad or negative
end padding will contract a segment at one or both ends,
and vice-versa.
This method will apply the same padding to both the
known and active lists,
but will not coalesce() the result.
start : float
padding to apply to the start of the each segment
end : float
padding to apply to the end of each segment
inplace : bool, optional, default: False
modify this object in-place, default is
False, i.e. return a copy of the original object with padded segments
paddedflag : DataQualityFlag
a view of the modified flag
plot(self, figsize=(12, 4), xscale='auto-gps', **kwargs)[source]¶Plot this flag on a segments projection.
**kwargs
all keyword arguments are passed to the
Plotconstructor.
figure : Figure
the newly created figure, with populated Axes.
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(self, source='http://segments.ldas.cit', segments=None, pad=True, **kwargs)[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
The name associated with this flag. |
|
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.
This DataQualityFlag 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 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().
self : DataQualityFlag
a reference to this flag
protract(self, x)[source]¶Protract each of the active Segments by x seconds.
This method subtracts x from each segment’s lower bound,
and adds x to the upper bound, while maintaining that each
Segment stays within the known bounds.
The active SegmentList is modified
in place.
query(flag, *args, **kwargs)[source]¶Query for segments of a given flag
This method intelligently selects the query_segdb
or the query_dqsegdb methods based on the
url kwarg given.
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
url : str, optional
URL of the segment database, defaults to
$DEFAULT_SEGMENT_SERVERenvironment variable, or'https://segments.ligo.org'
flag : DataQualityFlag
A new
DataQualityFlag, with theknownandactivelists filled appropriately.
See also
DataQualityFlag.query_segdbDataQualityFlag.query_dqsegdbfor details on the actual query engine, and documentation of other keyword arguments appropriate for each query
query_dqsegdb(flag, *args, **kwargs)[source]¶Query the advanced LIGO DQSegDB for the given flag
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
url : str, optional
URL of the segment database, defaults to
$DEFAULT_SEGMENT_SERVERenvironment variable, or'https://segments.ligo.org'
flag : DataQualityFlag
A new
DataQualityFlag, with theknownandactivelists filled appropriately.
query_segdb(flag, *args, **kwargs)[source]¶Query the initial LIGO segment database for the given flag
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
url : str, optional
URL of the segment database, defaults to
$DEFAULT_SEGMENT_SERVERenvironment variable, or'https://segments.ligo.org'
flag : DataQualityFlag
A new
DataQualityFlag, with theknownandactivelists filled appropriately.
read(source, *args, **kwargs)[source]¶Read segments from file into a DataQualityFlag.
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).
nproc : int, optional, default: 1
number of CPUs to use for parallel reading of multiple files
verbose : bool, optional, default: False
print a progress bar showing read status
dqflag : DataQualityFlag
formatted
DataQualityFlagcontaining the active and known segments read from file.
IndexError
if
sourceis an empty list
Notes
The available built-in formats are:
Format |
Read |
Write |
Auto-identify |
|---|---|---|---|
hdf5 |
Yes |
Yes |
Yes |
json |
Yes |
No |
No |
ligolw |
Yes |
Yes |
Yes |
round(self, contract=False)[source]¶Round this flag to integer segments.
contract : bool, optional
if
False(default) expand each segment to the containing integer boundaries, otherwise contract each segment to the contained boundaries
roundedflag : DataQualityFlag
write(self, target, *args, **kwargs)[source]¶Write this DataQualityFlag to file
Notes
The available built-in formats are:
Format |
Read |
Write |
Auto-identify |
|---|---|---|---|
hdf5 |
Yes |
Yes |
Yes |
json |
Yes |
Yes |
No |
ligolw |
Yes |
Yes |
Yes |
activeThe set of segments during which this flag was active.
categoryVeto category for this flag.
coalesce(self)[source]Coalesce the segments for this flag.
This method does two things:
Note
this operations is performed in-place.
self
a view of this flag, not a copy.
contract(self, x)[source]Contract each of the active Segments by x seconds.
This method adds x to each segment’s lower bound, and subtracts
x from the upper bound.
The active SegmentList is modified
in place.
copy(self)[source]Build an exact copy of this flag.
flag2 : DataQualityFlag
a copy of the original flag, but with a fresh memory address.
descriptionDescription of why/how this flag was generated.
extentThe single GPS [start, stop) enclosing segment of this
DataQualityFlag.
fetch_open_data(flag, start, end, **kwargs)[source]Fetch Open Data timeline segments into a flag.
strthe name of the flag to query
int, strthe GPS start time (or parseable date string) to query
int, strthe GPS end time (or parseable date string) to query
bool, optionalshow verbose download progress, default: False
int, optionaltimeout for download (seconds)
str, optionalURL of LOSC host, default: 'losc.ligo.org'
flag : DataQualityFlag
a new flag with
activesegments filled from Open Data
Examples
>>> from gwpy.segments import DataQualityFlag
>>> print(DataQualityFlag.fetch_open_data('H1_DATA', 'Jan 1 2010',
... 'Jan 2 2010'))
<DataQualityFlag('H1:DATA',
known=[[946339215 ... 946425615)],
active=[[946340946 ... 946351800)
[946356479 ... 946360620)
[946362652 ... 946369150)
[946372854 ... 946382630)
[946395595 ... 946396751)
[946400173 ... 946404977)
[946412312 ... 946413577)
[946415770 ... 946422986)],
description=None)>
from_veto_def(veto)[source]Define a DataQualityFlag from a VetoDef
veto : VetoDef
veto definition to convert from
ifoThe interferometer associated with this flag.
This should be a single uppercase letter and a single number,
e.g. 'H1'.
knownThe set of segments during which this flag was known, and its state was well defined.
labelA human-readable label for this flag.
For example: 'Science-mode'.
nameThe name associated with this flag.
This normally takes the form {ifo}:{tag}:{version}. If found, each component is stored separately the associated attributes.
pad(self, *args, **kwargs)[source]Apply a padding to each segment in this DataQualityFlag
This method either takes no arguments, in which case the value of
the padding attribute will be used,
or two values representing the padding for the start and end of
each segment.
For both the start and end paddings, a positive value means
pad forward in time, so that a positive start pad or negative
end padding will contract a segment at one or both ends,
and vice-versa.
This method will apply the same padding to both the
known and active lists,
but will not coalesce() the result.
start : float
padding to apply to the start of the each segment
end : float
padding to apply to the end of each segment
inplace : bool, optional, default: False
modify this object in-place, default is
False, i.e. return a copy of the original object with padded segments
paddedflag : DataQualityFlag
a view of the modified flag
padding[start, end) padding for this flag’s active segments.
plot(self, figsize=(12, 4), xscale='auto-gps', **kwargs)[source]Plot this flag on a segments projection.
**kwargs
all keyword arguments are passed to the
Plotconstructor.
figure : Figure
the newly created figure, with populated Axes.
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(self, source='http://segments.ldas.cit', segments=None, pad=True, **kwargs)[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
The name associated with this flag. |
|
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.
This DataQualityFlag 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 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().
self : DataQualityFlag
a reference to this flag
protract(self, x)[source]Protract each of the active Segments by x seconds.
This method subtracts x from each segment’s lower bound,
and adds x to the upper bound, while maintaining that each
Segment stays within the known bounds.
The active SegmentList is modified
in place.
query(flag, *args, **kwargs)[source]Query for segments of a given flag
This method intelligently selects the query_segdb
or the query_dqsegdb methods based on the
url kwarg given.
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
url : str, optional
URL of the segment database, defaults to
$DEFAULT_SEGMENT_SERVERenvironment variable, or'https://segments.ligo.org'
flag : DataQualityFlag
A new
DataQualityFlag, with theknownandactivelists filled appropriately.
See also
DataQualityFlag.query_segdbDataQualityFlag.query_dqsegdbfor details on the actual query engine, and documentation of other keyword arguments appropriate for each query
query_dqsegdb(flag, *args, **kwargs)[source]Query the advanced LIGO DQSegDB for the given flag
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
url : str, optional
URL of the segment database, defaults to
$DEFAULT_SEGMENT_SERVERenvironment variable, or'https://segments.ligo.org'
flag : DataQualityFlag
A new
DataQualityFlag, with theknownandactivelists filled appropriately.
query_segdb(flag, *args, **kwargs)[source]Query the initial LIGO segment database for the given flag
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
url : str, optional
URL of the segment database, defaults to
$DEFAULT_SEGMENT_SERVERenvironment variable, or'https://segments.ligo.org'
flag : DataQualityFlag
A new
DataQualityFlag, with theknownandactivelists filled appropriately.
read(source, *args, **kwargs)[source]Read segments from file into a DataQualityFlag.
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).
nproc : int, optional, default: 1
number of CPUs to use for parallel reading of multiple files
verbose : bool, optional, default: False
print a progress bar showing read status
dqflag : DataQualityFlag
formatted
DataQualityFlagcontaining the active and known segments read from file.
IndexError
if
sourceis an empty list
Notes
The available built-in formats are:
Format |
Read |
Write |
Auto-identify |
|---|---|---|---|
hdf5 |
Yes |
Yes |
Yes |
json |
Yes |
No |
No |
ligolw |
Yes |
Yes |
Yes |
round(self, contract=False)[source]Round this flag to integer segments.
contract : bool, optional
if
False(default) expand each segment to the containing integer boundaries, otherwise contract each segment to the contained boundaries
roundedflag : DataQualityFlag
tagThe 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'.
texnameName of this flag in LaTeX printable format.
versionThe 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(self, target, *args, **kwargs)[source]Write this DataQualityFlag to file
Notes
The available built-in formats are:
Format |
Read |
Write |
Auto-identify |
|---|---|---|---|
hdf5 |
Yes |
Yes |
Yes |
json |
Yes |
Yes |
No |
ligolw |
Yes |
Yes |
Yes |