pyinterp.TemporalAxis

class pyinterp.TemporalAxis(values: numpy.ndarray)[source]

Bases: pyinterp.core.TemporalAxis

Time axis.

__init__(values: numpy.ndarray)[source]

Create a coordinate axis from values.

Parameters
  • values (numpy.ndarray) – Items representing the datetimes or

  • axis. (timedeltas of the) –

Raises

TypeError – if the array data type is not a datetime64 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
TemporalAxis(array(['2000-01-01T00:00:00.000000',
                    '2000-01-01T01:00:00.000000',
                    '2000-01-01T02:00:00.000000',
                    ...,
                    '2009-11-08T21:00:00.000000',
                    '2009-11-08T22:00:00.000000',
                    '2009-11-08T23:00:00.000000'],
                dtype='datetime64[us]'))
>>> values = np.array([
...     datetime.timedelta(hours=index)
...     for index in range(86400)
... ],
...                   dtype="timedelta64[us]")
>>> axis = pyinterp.TemporalAxis(values)
>>> axis
TemporalAxis(array([0,
                    3600000000,
                    7200000000,
                    ...,
                    311029200000000,
                    311032800000000,
                    311036400000000],
             dtype='timedelta64[us]'))

Methods

TemporalAxis.PATTERN([pos, endpos])

Scan through string looking for a match, and return a corresponding match object instance.

TemporalAxis.back()

Get the last value of this axis.

TemporalAxis.find_index(coordinates[, bounded])

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

TemporalAxis.find_indexes(coordinates)

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

TemporalAxis.flip(self[, inplace])

Reverse the order of elements in this axis.

TemporalAxis.front()

Get the first value of this axis.

TemporalAxis.increment()

Get increment value if is_regular().

TemporalAxis.is_ascending(self)

Test if the data is sorted in ascending order.

TemporalAxis.is_regular(self)

Check if this axis values are spaced regularly.

TemporalAxis.max_value()

Get the maximum value of this axis.

TemporalAxis.min_value()

Get the minimum value of this axis.

TemporalAxis.safe_cast(values)

Convert the dates of the vector in the same unit as the time axis defined in this instance.

TemporalAxis.__getitem__(*args)

Get the values of this axis.

TemporalAxis.__getstate__()

Returns the state of this object.

TemporalAxis.__repr__(self)

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

TemporalAxis.__setstate__(state)

Restore the state of this object.

TemporalAxis._assert_issubdtype(dtype)

TemporalAxis._npdate_resolution(dtype)

Gets the numpy date time resolution.

TemporalAxis._object(dtype)

Get the object type handled by this class.

Attributes

TemporalAxis.RESOLUTION

Numpy time units

TemporalAxis.UNITS

Numpy time unit meanings

TemporalAxis.is_circle

Test if this axis represents a circle.