date2num

typhon.utils.date2num(dates, units, calendar=None)[source]

Convert an array of integer into datetime objects.

This function optimizes the date2num function of python-netCDF4 if the standard calendar is used.

Parameters:
  • dates – Either an array of numpy.datetime64 objects (if standard gregorian calendar is used), otherwise an array of python datetime objects.

  • units – A string with the format “{unit} since {epoch}”, e.g. “seconds since 1970-01-01T00:00:00”.

  • calendar – (optional) Standard is gregorian. If others are used, netCDF4.num2date will be called.

Returns:

An array of integers.