carpet_concentrations.time
Time handling
MONTHS_PER_YEAR
NonUniqueYearMonths
- class NonUniqueYearMonths(unique_vals, counts)[source]
Bases:
ValueError
Raised when the user tries to convert to year-month with non-unique values
This happens when the datetime values lead to year-month values that are not unique
CftimeConverter
convert_year_month_to_time
- convert_year_month_to_time(inp, day=1, **kwargs)[source]
Convert year and month co-ordinates into a time axis
This is a facade to
convert_to_time()
- Parameters
inp (
xarray.core.dataset.Dataset
) – Data to convertday (
int
) – Day of the month to assume in output**kwargs (
typing.Any
) – Passed to intialiser ofcftime.datetime
- Returns
xarray.core.dataset.Dataset
– Data with time axis
convert_to_time
- convert_to_time(inp, time_coords, cftime_converter)[source]
Convert some co-ordinates representing time into a time axis
- Parameters
inp (
xarray.core.dataset.Dataset
) – Data to converttime_coords (
tuple
[str
,...
]) – Co-ordinates from which to create the time axiscftime_converter (
carpet_concentrations.time.CftimeConverter
) – Callable that converts the stacked time co-ordinates tocftime.datetime
- Returns
xarray.core.dataset.Dataset
– Data with time axis
split_time_to_year_month
- split_time_to_year_month(inp, time_axis='time')[source]
Convert the time dimension to year and month without stacking
This means there is still a single time dimension in the output, but there is now also accompanying year and month information
- Parameters
inp (
xarray.core.dataset.Dataset
) – Data to convert- Returns
xarray.core.dataset.Dataset
– Data with year and month information for the time axis- Raises
NonUniqueYearMonths – The years and months are not unique
convert_time_to_year_month
- convert_time_to_year_month(inp, time_axis='time')[source]
Convert the time dimension to year and month co-ordinates
- Parameters
inp (
xarray.core.dataset.Dataset
) – Data to convert- Returns
xarray.core.dataset.Dataset
– Data with year and month co-ordinates