pcmdi_metrics.utils.check_daily_time_axis
- pcmdi_metrics.utils.check_daily_time_axis(ds, time_key='time')[source]
Check if the time axis in an xarray dataset follows a correct daily sequence, considering all CFTime calendars.
- Parameters:
ds (
xarray.Dataset
orxarray.DataArray
) – The dataset or data array containing the time axis to be checked.time_key (
str
, optional) – The key corresponding to the time dimension in the dataset (default is ‘time’).
- Returns:
None
– The function doesn’t return a value if the check passes.- Raises:
ValueError – If the time axis does not use CFTime objects or does not follow a correct daily sequence.
Example
>>> from pcmdi_metrics.utils import check_daily_time_axis >>> # generate a dummy daily dataset to test >>> import xarray as xr >>> ds = xr.Dataset({"time": xr.cftime_range("2000-01-01", periods=400, freq="D", calendar="gregorian")}) >>> # check axis >>> check_daily_time_axis(ds, "time") # No output if check passes