cfdm.Data.datetime_array¶
-
Data.
datetime_array
¶ Return 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 1.7.0.
See also
- Returns
numpy.ndarray
An independent numpy array of the date-time objects.
Examples:
>>> d = Data([31, 62, 90], units='days since 2018-12-01') >>> a = d.datetime_array >>> print(a) [cftime.DatetimeGregorian(2019-01-01 00:00:00) cftime.DatetimeGregorian(2019-02-01 00:00:00) cftime.DatetimeGregorian(2019-03-01 00:00:00)] >>> print(a[1]) 2019-02-01 00:00:00
>>> d = Data([31, 62, 90], units='days since 2018-12-01', ... calendar='360_day') >>> a = d.datetime_array >>> print(a) [cftime.Datetime360Day(2019-01-02 00:00:00) cftime.Datetime360Day(2019-02-03 00:00:00) cftime.Datetime360Day(2019-03-01 00:00:00)] >>> print(a[1]) 2019-02-03 00:00:00