standardise_time¶
- earthkit.transforms.temporal.standardise_time(dataarray: Dataset | DataArray, target_format: str = '%Y-%m-%d %H:%M:%S', time_dim: str | None = None) Dataset | DataArray[source]¶
Convert time coordinates to a standard format using the Gregorian calendar.
This function is helpful when combining data from different sources with different time standards or calendars - for example, when combining data which uses a 360-day calendar with data which uses a Gregorian calendar. All data passed into this function will be converted to a standard Gregorian calendar format.
- Parameters:
dataarray (xarray.Dataset or xarray.DataArray) – Data object with a time coordinate to be standardised.
target_format (str, optional) – Datetime format to use when creating the standardised datetime object. This can be used to change the resolution of the datetime object - for example, “%Y-%m-%d” will reduce to daily resolution - or to fix elements of the datetime object - for example, “%Y-%m-15” would reduce to monthly resolution and fix the date to the 15th of each month.
time_dim (str, optional) – Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to “time”. If you do not want to aggregate along the time dimension use earthkit.transforms.aggregate.reduce
- Returns:
Data object with the time coordinate standardised to the specified format
- Return type: