scipp.datetimes#

scipp.datetimes(*, dims, values, unit=<scipp._scipp.core.DefaultUnit object>)#

Constructs an array Variable with a dtype of datetime64.

Parameters
  • dims – Dimension labels

  • values (Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) – Numpy array or something that can be converted to a Numpy array of datetimes.

  • unit (Union[Unit, str, None], default: <scipp._scipp.core.DefaultUnit object at 0x7f4add16b330>) – Unit for the resulting Variable. Can be deduced if values contains strings or np.datetime64’s.

Seealso

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

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]
Return type

Variable