mesmer.datatree.broadcast_and_pool_scen_ens

mesmer.datatree.broadcast_and_pool_scen_ens#

mesmer.datatree.broadcast_and_pool_scen_ens(predictors, target, weights=None, *, time_dim='time', member_dim='member', scenario_dim='scenario', sample_dim='sample')#

prepare predictors, target, and weights for statistical functions

Converts several nD DataTree nodes into a single 2D Dataset with sample dimension. The sample dimension consists of the time, member, and scenario dimensions. This is done in two steps:

  1. Broadcasts predictors to target

  2. Pools the DataTrees along the sample dimension

Parameters:
  • predictors (DataTree) – A DataTree of xr.Dataset objects used as predictors. The DataTree must have nodes for each scenario, each of which holds a Dataset where the predictor(s) are contained as data variables. The xr.Dataset must contain time_dim and at least one data variable.

  • target (DataTree) – A DataTree holding the targets. Must be isomorphic to the predictor tree, i.e. have the same scenarios. Each leaf must hold a xr.Dataset which must contain time_dim.

  • weights (DataTree or None, default: None) – Individual weights for each sample, must be isomorphic to target.

  • time_dim (str, default: “time”) – Name of the time dimension.

  • member_dim (str, default: “member”) – Name of the member dimension.

  • scenario_dim (str, default: “scenario”) – Name of the scenario dimension.

  • sample_dim (str, default: “sample”) – Name of the sample dimension.

Returns:

tuple of pooled predictors, target and weights – Tuple of the prepared predictors, target and weights. The predictors are broadcast against the target. And then predictors, target, and weights are pooled along the sample dimension, by stacking the scenario nodes and ensemble member dimension.

Notes

Dimensions which exist along the target but are not in the stacking_dims will be excluded from the broadcasting of the predictors.

Example for how the predictor DataTree should look like:

├─ hist
|        data_vars: tas, hfds, ...
├─ scen1
|        data_vars: tas, hfds, ...
└─ ...

with ‘hist’ and ‘scen1’ being the scenarios, holding each a dataset with the same dimensions.