pyinterp.TemporalAxis

Contents

pyinterp.TemporalAxis#

class pyinterp.TemporalAxis(self, values: numpy.ndarray[tuple[int], numpy.dtype[numpy.datetime64 | numpy.timedelta64]])#

Bases: AxisInt64

Create a time axis for temporal coordinates.

Parameters:

values – Items representing the datetimes or timedeltas of the axis.

Raises:

TypeError – if the array data type is not a datetime64 or timedelta64 subtype.

Examples

>>> import datetime
>>> import numpy as np
>>> import pyinterp
>>> start = datetime.datetime(2000, 1, 1)
>>> values = np.array([
...     start + datetime.timedelta(hours=index)
...     for index in range(86400)
... ],
...                   dtype="datetime64[us]")
>>> axis = pyinterp.TemporalAxis(values)
>>> axis
<pyinterp.core.TemporalAxis>
  min_value: 2000-01-01T00:00:00.000000
  max_value: 2009-11-08T23:00:00.000000
  step     : 3600000000 microseconds
>>> values = np.array([
...     datetime.timedelta(hours=index)
...     for index in range(86400)
... ],
...                   dtype="timedelta64[us]")
>>> axis = pyinterp.TemporalAxis(values)
>>> axis
<pyinterp.core.TemporalAxis>
  min_value: 0 microseconds
  max_value: 311036400000000 microseconds
  step     : 3600000000 microseconds

Public Methods

back(self)

Get the last value of this axis.

dtype(self)

Get the data-type of the axis's elements.

find_index(self, coordinates[, bounded])

Find grid elements that contain or are closest to coordinate positions.

find_indexes(self, coordinates)

Search for axis elements around all coordinate positions.

flip(self[, inplace])

Reverse the order of elements in this axis.

front(self)

Get the first value of this axis.

increment(self)

Get the increment value if axis is regular.

is_ascending(self)

Test if the data is sorted in ascending order.

is_regular(self)

Check if this axis values are spaced regularly.

max_value(self)

Get the maximum coordinate value.

min_value(self)

Get the minimum coordinate value.

safe_cast(self, values)

Convert values to the same unit as the time axis.

Special Methods

__copy__(self)

Implement the shallow copy operation.

__eq__(self, other)

Override the default behavior of the == operator.

__getitem__(*args, **kwargs)

Overloaded function.

__getstate__(self, /)

__len__(self)

Return the length of the axis.

__ne__(self, other)

Override the default behavior of the != operator.

__repr__(self)

Return the string representation of this Axis.

__setstate__(self, arg0)