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,
)[source]#

Bases: TimeSeriesBase

Boolean array representing a good/bad state determination.

Parameters:
valuearray_like

Input data array.

t0LIGOTimeGPS, float, str, optional

GPS epoch associated with these data, any input parsable by to_gps is fine.

dtfloat, Quantity, optional

Time between successive samples (seconds), can also be given inversely via sample_rate.

sample_ratefloat, Quantity, optional

The rate of samples per second (Hertz), can also be given inversely via dt.

timesarray-like

The complete array of GPS times accompanying the data for this series. This argument takes precedence over t0 and dt so should be given in place of these if relevant, not alongside.

namestr, optional

Descriptive title for this array.

channelChannel, str, optional

Source data stream for these data.

dtypedtype, optional

Input data type.

copybool, optional

Choose to copy the input data to new memory.

subokbool, 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

unit

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 StateTimeSeries from 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=<no value>,
where=<no value>,
)#

Returns True if all elements evaluate to True.

Refer to numpy.all for full documentation.

See also

numpy.all

equivalent 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:
nint, optional

Number of times to apply the difference operation, defaults to 1, i.e. the first difference.

axisint, optional

Axis along which to compute the difference, defaults to the last axis, i.e. the time axis.

Returns:
newStateTimeSeries

A new StateTimeSeries containing the difference of the current series, with the same metadata as the original.

classmethod from_nds2_buffer(buffer: nds2.buffer, **metadata) Self[source]#

Create a StateTimeSeries from an NDS2 buffer.

override_unit(
unit: UnitLike,
parse_strict: str = 'raise',
) NoReturn[source]#

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,
) DataQualityFlag[source]#

Convert this series into a DataQualityFlag.

Each contiguous set of True values are grouped as a Segment running from the GPS time the first found True, to the GPS time of the next False (or the end of the series)

Parameters:
name: `str`, optional

Name of the segment.

minlenint, optional

Minimum number of consecutive True values to identify as a Segment. This is useful to ignore single bit flips, for example.

dtypetype, 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 dtype of the time index.

roundbool, optional

Choose to round each Segment to its inclusive integer boundaries.

labelstr, optional

The label for the output flag.

descriptionstr, optional

The description for the output flag.

Returns:
dqflagDataQualityFlag

A segment representation of this StateTimeSeries, the span defines the known segments, while the contiguous True sets defined each of the active segments.

to_lal() NoReturn[source]#

Bogus function inherited from superclass, do not use.

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 item method.

If a.ndim is 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:
yobject, or list of object, or list of list of object, or …

The possibly nested list of array elements.

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 as list(a), except that tolist changes 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, tolist applies 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