StateVector#
- class gwpy.timeseries.StateVector(
- data: ArrayLike1D,
- bits: BitsInput | None = None,
- t0: SupportsToGps | None = None,
- dt: float | Quantity | None = None,
- sample_rate: float | Quantity | None = None,
- times: ArrayLike1D | None = None,
- channel: Channel | str | None = None,
- name: str | None = None,
- **kwargs,
Bases:
TimeSeriesBaseBinary array representing good/bad state determinations of some data.
Each binary bit represents a single boolean condition, with the definitions of all the bits stored in the
StateVector.bitsattribute.- Parameters:
- valuearray_like
Input data array.
- bits
Bits,list, optional List of bits defining this
StateVector.- t0
LIGOTimeGPS,float,str, optional GPS epoch associated with these data, any input parsable by
to_gpsis fine.- dt
float,Quantity, optional Time between successive samples (seconds), can also be given inversely via
sample_rate.- sample_rate
float,Quantity, optional The rate of samples per second (Hertz), can also be given inversely via
dt.- times
array-like The complete array of GPS times accompanying the data for this series. This argument takes precedence over
t0anddtso should be given in place of these if relevant, not alongside.- name
str, optional Descriptive title for this array.
- channel
Channel,str, optional Source data stream for these data.
- dtype
dtype, optional Input data type.
- copy
bool, optional Choose to copy the input data to new memory.
- subok
bool, optional Allow passing of sub-classes by the array generator.
Notes
Key methods:
fetch(channel, start, end, *[, bits, host, ...])Fetch data from NDS into a
StateVector.Read data into a
StateVector.Write this
StateVectorto a file.to_dqflags(bits, minlen, dtype, *, round)Convert this
StateVectorinto aDataQualityDict.plot([format, bits])Plot the data for this
StateVector.Attributes Summary
List of
Bitsfor thisStateVector.A 2-D boolean array representation of this
StateVector.Retrieve
StateVectordata for a channel.Read data into a
StateVector.Write this
StateVectorto a file.Methods Summary
fetch(channel, start, end, *[, bits, host, ...])Fetch data from NDS into a
StateVector.get_bit_series([bits])Get the
StateTimeSeriesfor each bit of thisStateVector.plot([format, bits])Plot the data for this
StateVector.resample(rate)Resample this
StateVectorto a new rate.to_dqflags(bits, minlen, dtype, *, round)Convert this
StateVectorinto aDataQualityDict.Attributes Documentation
- bits[source]#
List of
Bitsfor thisStateVector.- Type:
- boolean[source]#
A 2-D boolean array representation of this
StateVector.
- get#
Retrieve
StateVectordata for a channel.This method attemps to get data any way it can, potentially iterating over multiple available data sources.
- Parameters:
- name
str,Channel The name of the channel to read, or a
Channelobject.- 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.- bits
Bits,list, optional Definition of bits for this
StateVector- source
str,list,listofdict. The data source to use. One of the following formats:
str- the name of a single source to use,list- a list of source names to try in order,listofdict- a list of source specifications to try in order; eachdictmust contain a"source"key giving the name of the source to use, and may contain other keys giving options to pass to the data access function for that source.
See ‘Notes’ section below for valid source names.
- nproc
int, optional Number of parallel processes to use, serial process by default.
- verbose
bool, optional This argument is deprecated and will be removed in a future release. Use DEBUG-level logging instead, see Logging with GWpy.
- kwargs
Other keyword arguments to pass to the data access function for each data source.
- name
- read#
Read data into a
StateVector.Arguments and keywords depend on the output format, see the online documentation for full details for each format, the parameters below are common to most formats.
- Parameters:
- source
str,os.PathLike,file, orlistofthese Source of data, any of the following:
Path of a single data file
List of data file paths
Path of LAL-format cache file
- name
str, optional The name of the data object to read, or a
Channelobject. This argument is required ifsourcecontains (or may contain) multiple datasets.When reading from GWF, this argument should specify the name of the channel to read.
When reading from HDF5, this argument should specify the path or dataset name within the file.
- start
LIGOTimeGPS,float,str, optional GPS start time of required data, defaults to start of data found; any input parseable by
to_gpsis fine.- end
LIGOTimeGPS,float,str, optional GPS end time of required data, defaults to end of data found; any input parseable by
to_gpsis fine.- bits
list, optional List of bits names for this
StateVector, giveNoneat any point in the list to mask that bit.- format
str, optional Source format identifier. If not given, the format will be detected if possible. See below for list of acceptable formats.
- parallel
int, optional Number of parallel processes to use, serial process by default.
- pad
float, optional Value with which to fill gaps in the source data, by default gaps will result in a
ValueError.
- source
- Raises:
IndexErrorIf
sourceis an empty list.
- write#
Write this
StateVectorto a file.Arguments and keywords depend on the output format, see the online documentation for full details for each format, the parameters below are common to most formats.
Methods Documentation
- classmethod fetch(
- channel: str | Channel,
- start: SupportsToGps,
- end: SupportsToGps,
- *,
- bits: Bits | BitsInput | None = None,
- host: str | None = None,
- port: int | None = None,
- verbose: bool | str = False,
- connection: nds2.connection | None = None,
- verify: bool = False,
- pad: float | None = None,
- allow_tape: bool | None = None,
- scaled: bool | None = None,
- type: int | str | None = None,
- dtype: int | str | None = None,
Fetch data from NDS into a
StateVector.- Parameters:
- channel
str,Channel The name (or representation) of the data channel to fetch.
- start
LIGOTimeGPS,float,str GPS start time of required data, any input parseable by
to_gpsis fine- end
LIGOTimeGPS,float,str, optional GPS end time of required data, defaults to end of data found; any input parseable by
to_gpsis fine- bits
Bits,list, optional Definition of bits for this
StateVector.- host
str, optional URL of NDS server to use, if blank will try any server (in a relatively sensible order) to get the data
One of
connectionorhostmust be given.- port
int, optional Port number for NDS server query, must be given with
host.- verify
bool, optional Check channels exist in database before asking for data. Default is
True.- pad
float, optional Value with which to fill gaps in the source data. By default gaps will result in a
ValueError.- verbose
bool, optional This argument is deprecated and will be removed in a future release. Use DEBUG-level logging instead, see Logging with GWpy.
- connection
nds2.connection, optional Open NDS connection to use. Default is to open a new connection using
hostandportarguments.One of
connectionorhostmust be given.- scaled
bool, optional Apply slope and bias calibration to ADC data, for non-ADC data this option has no effect.
- allow_tape
bool, optional Allow data access from slow tapes. If
hostorconnectionis given, the default is to do whatever the server default is, otherwise servers will be searched withallow_tape=Falsefirst, thenallow_tape=Trueif that fails.- type
int,str, optional NDS2 channel type integer or string name to match. Default is to search for any channel type.
- dtype
numpy.dtype,str,type, ordict, optional NDS2 data type to match. Default is to search for any data type.
- channel
- get_bit_series( ) StateTimeSeriesDict[source]#
Get the
StateTimeSeriesfor each bit of thisStateVector.- Parameters:
- bits
list, optional A list of bit indices or bit names, defaults to all bits.
- bits
- Returns:
- bitseries
StateTimeSeriesDict A
dictofStateTimeSeries, one for each given bit.
- bitseries
- plot(
- format: Literal['timeseries', 'segments'] = 'segments',
- bits: Iterable[int | str] | None = None,
- **kwargs,
Plot the data for this
StateVector.- Parameters:
- format
str, optional The type of plot to make, either ‘segments’ to plot the SegmentList for each bit, or ‘timeseries’ to plot the raw data for this
StateVector.- bits
list, optional A list of bit indices or bit names, defaults to
bits. This argument is ignored ifformatis not'segments'.- kwargs
Other keyword arguments to be passed to either
plotorplot, depending onformat.
- format
- Returns:
- plot
Plot Output plot object.
- plot
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_flagFor documentation of keyword arguments used in rendering each statevector flag.
- resample(rate: float | Quantity) StateVector[source]#
Resample this
StateVectorto a new rate.Because of the nature of a state-vector, downsampling is done by taking the logical ‘and’ of all original samples in each new sampling interval, while upsampling is achieved by repeating samples.
- Parameters:
- rate
float Rate to which to resample this
StateVector, must be a divisor of the original sample rate (when downsampling) or a multiple of the original (when upsampling).
- rate
- Returns:
- vector
StateVector Resampled version of the input
StateVector.
- vector
- to_dqflags(
- bits: Iterable[int | str] | None = None,
- minlen: int = 1,
- dtype: type = <class 'float'>,
- *,
- round: bool = False,
Convert this
StateVectorinto aDataQualityDict.The
StateTimeSeriesfor each bit is converted into aDataQualityFlagwith the bits combined into a dict.- Parameters:
- bits
list, optional A list of bit indices or bit names to select, defaults to
bits.- minlen
int, optional Minimum number of consecutive
Truevalues to identify as aSegment. This is useful to ignore single bit flips, for example.- dtype
type, optional Output segment entry type, can pass either a type for simple casting, or a callable function that accepts a float and returns another numeric type, defaults to
float.- round
bool, optional Choose to round each
Segmentto its inclusive integer boundaries.
- bits
- Returns:
- DataQualityFlag list
list A list of
DataQualityFlagrepresentations for each bit in thisStateVector.
- DataQualityFlag list
See also
StateTimeSeries.to_dqflagFor details on the segment representation method for
StateVectorbits.