cfdm.Data.datetime_array

Data.datetime_array

Returns an independent numpy array of datetimes.

Specifically, returns an independent numpy array containing the date-time objects corresponding to times since a reference date.

Only applicable for reference time units.

If the calendar has not been set then the CF default calendar of ‘standard’ (i.e. the mixed Gregorian/Julian calendar as defined by Udunits) will be used.

Conversions are carried out with the netCDF4.num2date function.

New in version (cfdm): 1.7.0

Returns
numpy.ndarray

An independent numpy array of the date-time objects.

Examples:

>>> d = cfdm.Data([31, 62, 90], units='days since 2018-12-01')
>>> a = d.datetime_array
>>> print(a)
[cftime.DatetimeGregorian(2019, 1, 1, 0, 0, 0, 0)
 cftime.DatetimeGregorian(2019, 2, 1, 0, 0, 0, 0)
 cftime.DatetimeGregorian(2019, 3, 1, 0, 0, 0, 0)]
>>> print(a[1])
2019-02-01 00:00:00
>>> d = cfdm.Data(
...     [31, 62, 90], units='days since 2018-12-01', calendar='360_day')
>>> a = d.datetime_array
>>> print(a)
[cftime.Datetime360Day(2019, 1, 2, 0, 0, 0, 0)
 cftime.Datetime360Day(2019, 2, 3, 0, 0, 0, 0)
 cftime.Datetime360Day(2019, 3, 1, 0, 0, 0, 0)]
>>> print(a[1])
2019-02-03 00:00:00