cfdm.Data.datetime_array¶

Data.
datetime_array
¶ Returns an independent numpy array of datetimes.
Specifically, returns an independent numpy array containing the datetime 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
See also
 Returns
numpy.ndarray
An independent numpy array of the datetime objects.
Examples:
>>> d = cfdm.Data([31, 62, 90], units='days since 20181201') >>> 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]) 20190201 00:00:00
>>> d = cfdm.Data( ... [31, 62, 90], units='days since 20181201', 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]) 20190203 00:00:00