xarray.DataArray.pr.downscale_timeseries

xarray.DataArray.pr.downscale_timeseries#

DataArray.pr.downscale_timeseries(*, dim: Hashable, basket: Hashable, basket_contents: Sequence[Hashable], check_consistency: bool = True, sel: dict[Hashable, Sequence] | None = None, skipna_evaluation_dims: None | Sequence[Hashable] = None, skipna: bool = True, tolerance: float = 0.01) DataArray#

Downscale timeseries along a dimension using a basket defined on a broader timeseries.

This is useful if you have data for many points in time for a total, for example the entire Energy sector, and higher-resolution data (e.g. fossil and non-fossil energies separately) for only a few points in time. In the example, the Energy sector is the basket and fossil and non-fossil energies are the basket contents.

From any time points where all the basket contents are known, the relative shares of the basket contents are determined, and then interpolated linearly and extrapolated constantly to the full timeseries. The shares are then used to downscale the basket to its contents, which is used to fill gaps in the timeseries of the basket contents.

Parameters:
dim: str

The name of the dimension which contains the basket and its contents, has to be one of the dimensions in ds.dims.

basket: str

The name of the super-category for which values are known at higher temporal resolution and/or for a wider range. A value from ds[dimension].

basket_contents: list of str

The name of the sub-categories. The sum of all sub-categories equals the basket. Values from ds[dimension].

check_consistency: bool, default True

If for all points where the basket and all basket_contents are defined, it should be checked if the sum of the basket_contents actually equals the basket. A ValueError is raised if the consistency check fails.

sel: Selection dict, optional

If the downscaling should only be done on a subset of the Dataset while retaining all other values unchanged, give a selection dictionary. The downscaling will be done on ds.loc[sel].

skipna_evaluation_dims: list of str, optional

Dimensions which should be evaluated to determine if NA values should be skipped entirely if missing fully. By default, no NA values are skipped.

skipna: bool, default True

If true it will be passed on to xarray’s ds.sum function with min_count=1 for the calculation of the basket. The effect is that NA values in a sum will be ignored and treated as zero in the sum unless all values are NA which results in NA.

tolerance: float

If given it overrides the default tolerance for deviations of sums of individual timeseries to given aggregate timeseries. Default is 0.01 (1%)

Returns:
downscaled: xr.DataArray