DatetimeConverter

class ccsdspy.converters.DatetimeConverter(since, units)[source]

Bases: Converter

Post-processing conversion for converting timestamp fields to datetime instances, computed using offset(s) from a reference time.

This class supports the offsets stored in multiple input fields, for example where one field is a coarse time (e.g. seconds) and a second field is a fine time (e.g. nanoseconds). To use multiple input fields, pass a tuple of input field names when this converter is added to the packet.

Initialize a DatetimeConverter

Parameters:
sincedatetime

Reference datetime. The time stored in the field(s) is considered an offset to this reference. If this has timezone information attached to it, so will the converted datetimes.

unitsstr or tuple of str

Units string of tuples of units strings for the offset of each input field. Valid units are “days”, “hours”, “minutes”, “seconds”, “milliseconds”, “microseconds”, and “nanoseconds”.

Raises:
TypeError

One of the input arguments is not of the correct type

ValueError

One or more of the units are invalid

Methods Summary

convert(*field_arrays)

Apply the datetime conversion.

Methods Documentation

convert(*field_arrays)[source]

Apply the datetime conversion.

Parameters:
field_arrayslist of NumPy array

list of decoded packet field values, each must have at least one dimension

Returns:
convertedNumPy array of object (holding datetimes)

converted form of the decoded packet field values

Raises:
ValueError

Too many or too few units were provided, as compared to the input field arrays sent.