grid_process.time_utils#
Module to wrap some time utility functions
Attributes#
Classes#
Xarray accessors class for time utility methods |
Functions#
|
Converts an array of numpy.datetime64 objects to a timezone-aware |
|
Sets timestamps of daily aggregations at the start of the day (i.e. 00:00). |
Module Contents#
- logger#
- dataset_accessor#
- to_datetime_tzaware(timestamps: numpy.ndarray) pandas.DatetimeIndex[source]#
Converts an array of numpy.datetime64 objects to a timezone-aware pandas.DatetimeIndex representing time in UTC.
- Parameters:
timestamps (array of naive numpy.datetime64) – assumed to be in UTC time
- Returns:
out – UTC timezone aware
- Return type:
pandas.DatetimeIndex
- set_daily(ds: xarray.Dataset, lt_duplicates: bool = True, lt_hr: int = 0) xarray.Dataset[source]#
Sets timestamps of daily aggregations at the start of the day (i.e. 00:00). Daily parameters are stored in the DWH following this convention. If
lt_duplicates=True, selects correct validtimes between summer and winter local time duplicates first, otherwise assume daily aggregation are for UTC periods.- Parameters:
ds (xarray.Dataset) – with a valid time dimension (numpy.datetime64). When
lt_duplicates=True, duplicated timestamps corresponding to summer (UTC+2) and winter (UTC+1) localtime periods are expected as for a dataset returned byinterval_stat()with arglt_duplicatesset to Truelt_duplicates (bool) – whether the dataset contains duplicated timestamps corresponding to summer (UTC+2) and winter (UTC+1) localtime periods. Default is True
lt_hr (int) – hour of the day representing the end of the daily period in localtime. Only used when
lt_duplicates=True. Default is 0, meaning the end of the period is 00:00 J+1 LT
- Returns:
ds_out – dataset where daily timestamps are set to 00:00 of the respective day. Optionally, selection of correct timestamps between summer/winter duplicates based on day of year is done
- Return type:
xarray.Dataset
See also