radarx.retrieve.ensemble.ensemble_statistics#

radarx.retrieve.ensemble.ensemble_statistics(obj, *, dim='member', percentiles=(5, 95), categorical=(), min_fraction=0.5, n_threads=None, engine='auto')[source]#

Mean, spread and percentiles over the members of an ensemble.

Parameters:
  • obj (xarray.DataArray, xarray.Dataset or xarray.DataTree) – Members along dim, for example the output of perturb_radar(), or <name>_members of ensemble_retrieval() (a DataArray needs a name). For a volume the sweeps that have the dimension are used. Dask arrays are loaded.

  • dim (str, optional) – Name of the member dimension. Default "member".

  • percentiles (sequence of float, optional) – Percentiles (0-100, exclusive) in addition to the median. Default (5, 95).

  • categorical (sequence of str, optional) – Names of variables that hold class codes (integers from 0): they get the mode and the agreement instead of the statistics.

  • min_fraction (float, optional) – Gates where fewer than this fraction of the members is finite are NaN. Default 0.5.

  • n_threads (int, optional) – Threads for the compiled kernel. Default: all cores.

  • engine ({"auto", "compiled", "numpy"}, optional) – Implementation to use. Default "auto".

Returns:

xarray.Dataset or xarray.DataTree – For each variable X with the dimension: X_mean, X_median, X_std (standard deviation with n - 1) and X_p05, X_p95 for the default percentiles (see radarx.retrieve.ensemble), or X_mode and X_agreement for class codes, as float32 on the coordinates of X without dim. The percentiles interpolate linearly between the members (the default of numpy.percentile()). The input is not changed.

Raises:
  • KeyError – If no variable has the dimension.

  • ValueError – For percentiles outside (0, 100), min_fraction outside [0, 1] or an unknown engine.

  • ImportError – If engine="compiled" and the compiled kernel is not available.

Examples

>>> ens = radarx.retrieve.perturb_radar(sweep, members=16)
>>> stats = radarx.retrieve.ensemble_statistics(ens)