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

Bases: pyinterp.core.AxisInt64

Time axis


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


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


>>> 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
  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
  min_value: 0 microseconds
  max_value: 311036400000000 microseconds
  step     : 3600000000 microseconds

Public Methods


Get the last value of this axis.


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.


Get the first value of this axis.


Get increment value if is_regular().


Test if the data is sorted in ascending order.


Check if this axis values are spaced regularly.


Get the maximum coordinate value.


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.

Special Methods


Implements the shallow copy operation.

__eq__(self, other)

Overrides the default behavior of the == operator.

__getitem__(*args, **kwargs)

Overloaded function.



Called to implement the built-in function len()

__ne__(self, other)

Overrides the default behavior of the != operator.


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

__setstate__(self, arg0)