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:
Broadcasts predictors to target
Pools the DataTrees along the sample dimension
- Parameters:
predictors (DataTree) – A
DataTreeofxr.Datasetobjects used as predictors. TheDataTreemust have nodes for each scenario, each of which holds a Dataset where the predictor(s) are contained as data variables. Thexr.Datasetmust containtime_dimand at least one data variable.target (DataTree) – A
DataTreeholding the targets. Must be isomorphic to the predictor tree, i.e. have the same scenarios. Each leaf must hold axr.Datasetwhich must containtime_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
DataTreeshould 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.