xarray.DataArray.pr.add_aggregates_coordinates#
- DataArray.pr.add_aggregates_coordinates(agg_info: dict[str, dict[str, list[str] | dict[str, float | str | list[str] | dict[str, str | list[str]]]]], tolerance: float | None = 0.01, skipna: bool | None = True, min_count: int | None = 1) DataArray #
Manually aggregate data for coordinates
There are no sanity checks regarding what you aggregate, so you could combine IPCC2006 categories 2 and 3 to 1.
If an aggregated time-series is present the aggregate data are merged to check if aggregated and existing data agree within the given tolerance.
- Parameters:
- agg_info:
dict of the following form:
agg_info = { <coord1>: { <new_value>: { 'sources': [source_values], <add_coord_name>: <value for additional coordinate> (optional), 'tolerance': <non-default tolerance> (optional), 'filter': <filter in pr.loc style> (optional), }, }, <coord2>: { # simplified format for coord2 <new_value>: [source_values] ... }, ... }
All values in
filter
must be lists to keep the dimensions in the data returned byda.pr.loc
The normal format and the simplified list format can be mixed also within a coordinate- tolerance:
non-default tolerance for merging (default = 0.01 (1%))
- skipna: bool, optional
If
True
(default), skip missing values (as marked by NaN). By default, only skips missing values forfloat
dtypes; other dtypes either do not have a sentinel missing value (int) orskipna=True
has not been implemented (object
,datetime64
ortimedelta64
).- min_count: int (default None, but set to 1 if skipna=True)
The minimal number of non-NA values in a sum that is necessary for a non-NA result. This only has an effect if
skipna=True
. As an example: you sum data for a region for a certain sector, gas and year. Ifskipna=False
, all countries in the region need to have non-NA data for that sector, gas, year combination. Ifskipna=True
andmin_count=1
then one country with non-NA data is enough for a non-NA result. All NA values will be treated as zero. Ifmin_count=0
all NA values will be treated as zero also if there is no single non-NA value in the data that is to be summed.
- Returns:
- xr.DataArray
Input array, but with aggregated values for coordinates / dimensions as specified in the agg_info dict