StateTimeSeries#
- class gwpy.timeseries.StateTimeSeries(
- data: ArrayLike1D,
- 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:
TimeSeriesBaseBoolean array representing a good/bad state determination.
- Parameters:
- valuearray_like
Input data array.
- 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
to_dqflag([name, minlen, dtype, round, ...])Convert this series into a
DataQualityFlag.Attributes Summary
The unit of this
StateTimeSeries.Methods Summary
all([axis, out, keepdims, where])Returns True if all elements evaluate to True.
diff([n, axis])Return the difference between successive samples.
from_nds2_buffer(buffer, **metadata)Create a
StateTimeSeriesfrom an NDS2 buffer.override_unit(unit[, parse_strict])Override the unit of this
StateTimeSeries.to_dqflag([name, minlen, dtype, round, ...])Convert this series into a
DataQualityFlag.to_lal()Bogus function inherited from superclass, do not use.
tolist()Return the array as an
a.ndim-levels deep nested list of Python scalars.Attributes Documentation
- unit[source]#
The unit of this
StateTimeSeries.
Methods Documentation
- all(axis=None, out=None, keepdims=False, *, where=True)#
Returns True if all elements evaluate to True.
Refer to
numpy.allfor full documentation.See also
numpy.allequivalent function
- diff(n: int = 1, axis: int = -1) Self[source]#
Return the difference between successive samples.
The difference is defined as the exclusive-or of the previous and current samples.
- Parameters:
- Returns:
- new
StateTimeSeries A new
StateTimeSeriescontaining the difference of the current series, with the same metadata as the original.
- new
- classmethod from_nds2_buffer(buffer: nds2.buffer, **metadata) Self[source]#
Create a
StateTimeSeriesfrom an NDS2 buffer.
- override_unit(
- unit: UnitLike,
- parse_strict: str = 'raise',
Override the unit of this
StateTimeSeries. UNSUPPORTED DO NOT USE.
- to_dqflag(
- name: str | None = None,
- minlen: int = 1,
- dtype: type | None = None,
- *,
- round: bool = False,
- label: str | None = None,
- description: str | None = None,
Convert this series into a
DataQualityFlag.Each contiguous set of
Truevalues are grouped as aSegmentrunning from the GPS time the first foundTrue, to the GPS time of the nextFalse(or the end of the series)- Parameters:
- name: `str`, optional
Name of the segment.
- minlen
int, optional Minimum number of consecutive
Truevalues to identify as aSegment. This is useful to ignore single bit flips, for example.- dtype
type,callable 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 the
dtypeof the time index.- round
bool, optional Choose to round each
Segmentto its inclusive integer boundaries.- label
str, optional The
labelfor the output flag.- description
str, optional The
descriptionfor the output flag.
- Returns:
- dqflag
DataQualityFlag A segment representation of this
StateTimeSeries, the span defines theknownsegments, while the contiguousTruesets defined each of theactivesegments.
- dqflag
- tolist()#
Return the array as an
a.ndim-levels deep nested list of Python scalars.Return a copy of the array data as a (nested) Python list. Data items are converted to the nearest compatible builtin Python type, via the
itemfunction.If
a.ndimis 0, then since the depth of the nested list is 0, it will not be a list at all, but a simple Python scalar.- Parameters:
- none
- Returns:
Notes
The array may be recreated via
a = np.array(a.tolist()), although this may sometimes lose precision.Examples
For a 1D array,
a.tolist()is almost the same aslist(a), except thattolistchanges numpy scalars to Python scalars:>>> import numpy as np >>> a = np.uint32([1, 2]) >>> a_list = list(a) >>> a_list [np.uint32(1), np.uint32(2)] >>> type(a_list[0]) <class 'numpy.uint32'> >>> a_tolist = a.tolist() >>> a_tolist [1, 2] >>> type(a_tolist[0]) <class 'int'>
Additionally, for a 2D array,
tolistapplies recursively:>>> a = np.array([[1, 2], [3, 4]]) >>> list(a) [array([1, 2]), array([3, 4])] >>> a.tolist() [[1, 2], [3, 4]]
The base case for this recursion is a 0D array:
>>> a = np.array(1) >>> list(a) Traceback (most recent call last): ... TypeError: iteration over a 0-d array >>> a.tolist() 1