scipp.datetimes

scipp.datetimes

scipp.datetimes(*, dims, values, unit=None)

Constructs an array Variable with a dtype of datetime64.

Seealso

scipp.datetime() scipp.epoch() ‘Dates and Times’ section in Data Types

Parameters
  • dims – Dimension labels

  • values (array_like) – Numpy array or something that can be converted to a Numpy array of datetimes.

  • unit (Optional[Union[scipp._scipp.core.Unit, str]]) – Unit for the resulting Variable. Can be deduced if values contains strings or np.datetime64’s.

Return type

scipp._scipp.core.Variable

Examples:

>>> sc.datetimes(dims=['t'], values=['2021-01-10T01:23:45', '2021-01-11T01:23:45'])
<scipp.Variable> (t: 2)  datetime64              [s]  [2021-01-10T01:23:45, 2021-01-11T01:23:45]
>>> sc.datetimes(dims=['t'], values=['2021-01-10T01:23:45', '2021-01-11T01:23:45'], unit='h')
<scipp.Variable> (t: 2)  datetime64              [h]  [2021-01-10T01:00:00, 2021-01-11T01:00:00]
>>> sc.datetimes(dims=['t'], values=[0, 1610288175], unit='s')
<scipp.Variable> (t: 2)  datetime64              [s]  [1970-01-01T00:00:00, 2021-01-10T14:16:15]