pyinterp.core.TemporalAxis

class pyinterp.core.TemporalAxis(self, values: numpy.ndarray)

Bases: AxisInt64

Time axis

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)

Data-type of the axis's elements.

find_index(self, coordinates[, bounded])

Given coordinate positions, find what grid elements contains them, or is closest to them.

find_indexes(self, coordinates)

For all coordinate positions, search for the axis elements around them.

flip(self[, inplace])

Reverse the order of elements in this axis.

front(self)

Get the first value of this axis.

increment(self)

Get increment value if 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 the values of the vector in the same unit as the time axis handled by this instance.

Protected Methods

Special Methods

__copy__(self)

Implements the shallow copy operation.

__eq__(self, other)

Overrides the default behavior of the == operator.

__getitem__(*args, **kwargs)

Overloaded function.

__getstate__(self)

__len__(self)

Called to implement the built-in function len()

__ne__(self, other)

Overrides the default behavior of the != operator.

__repr__(self)

Called by the repr() built-in function to compute the string representation of an Axis.

__setstate__(self, arg0)