impactlab_tools.acp package

Submodules

impactlab_tools.acp.aggregate module

impactlab_tools.acp.aggregate.population_weighted_mean(ds, level='state', dim='fips', year=2012, pop=None)[source]

Find the population-weighted mean of a county-level xarray DataArray

Parameters:
  • ds (array) – DataArray to be aggregated. May contain any number of dimensions >= 1.

  • level (str (optional)) – Level of resolution to aggregate to. May be one of 'fips', 'state', 'state_names', 'state_abbrevs', 'census', or 'national' (default 'state')

  • dim (str (optional)) – dimension to aggregate along (default 'fips')

  • year (int (optional)) – population year (or column in the pop dataset) to use for the weights. If not provided, 2012 population is used.

  • pop (array (optional)) – DataArray to use for weights. If not provided, US Census Bureau 2014 vintage CO-EST2014-alldata.csv estimates from the ACP are used

Returns:

mean – weighted average aggregated DataArray

Return type:

array

impactlab_tools.acp.dist module

impactlab_tools.acp.dist.acp_quantiles(data, rcp, quantiles=[0.05, 0.17, 0.5, 0.83, 0.95], values_sorted=False, dim='model')[source]

Compute quantiles of an xarray distribution using ACP weights

Note

This function does not control for the number of samples of each model. If they are not constant across models provide a correctly weighted weights array to utils.weighting.weighted_quantile_xr(). We would like to fix this. If you have a good fix we’d love a PR :)

Parameters:
  • data (DataArray or Dataset) – xarray.DataArray or xarray.Dataset with data indexed by ACP model along the dimension dim. If a Dataset is passed, acp_quantiles computes the weighted quantile for each variable in the Dataset that is indexed by dim.

  • rcp (str) – RCP weights/models to use (‘rcp45’, ‘rcp85’)

  • quantiles (list-like, optional) – quantiles of distribution to return. quantiles should be in [0, 1]. Default [0.05, 0.17, 0.5, 0.83, 0.95].

  • values_sorted (bool, optional) – if True, then will avoid sorting of initial array. default False.

  • dim (str, optional) – dimension along which to retrieve quantiles. The indices of this dimension should be valid (case insensitive) ACP climate models. Default: ‘model’.

Returns:

returns a new DataArray or Dataset with quantiles computed from weighted distribution along a new dimension quantile and dimension dim dropped.

Return type:

DataArray or Dataset

See also

Module contents