Utils
This module offers various utility functions. It can be imported as:
>>> from patsemb import utils
- patsemb.utils.timedelta_to_nb_observations(timedelta_value: timedelta64, time_stamps: array) int[source]
A utility method to convert time delta values to a number of observations. This method will search for the minimal number of observations such that they cover at least the time period given by
timedelta_valuein the providedtime_stamps. This method assumes that the providedtime_stampsare sorted, with the earliest time stamp at the first position and the latest time stamp at the last position. The given time stamps should be regularly sampled.- Parameters:
timedelta_value (np.timedelta64) – The time interval that must be covered by the computed number of observations.
time_stamps (np.array of np.datetime64) – The time stamps corresponding to the observation times of a time series.
- Returns:
nb_observations – The minimal number of consecutive observations that cover the given timedelta value within the given time stamps.
- Return type:
int