radarx.retrieve.ensemble.ensemble_retrieval#

radarx.retrieve.ensemble.ensemble_retrieval(obj, retrieval, *, dbz=None, zdr=None, phidp=None, rhohv=None, field=None, members=32, seed=0, calibration=(1.0, 0.1), noise=True, prior=True, percentiles=(5, 95), variables=None, categorical=None, keep_members=False, min_fraction=0.5, band=None, attenuation=None, options=None, n_threads=None, engine='auto')[source]#

Run a retrieval on an ensemble of perturbed radar data.

Every member is a copy of the radar fields with random calibration offsets and measurement noise (perturb_radar()) and, if prior is set, with a random change of the DSD prior of the retrieval. The retrievals of radarx run on each member, and the result holds the statistics of the products over the members, see radarx.retrieve.ensemble.

Parameters:
  • obj (xarray.DataArray, xarray.Dataset or xarray.DataTree) – A sweep, a grid or a volume with sweep_* groups (sweeps without a radar field are skipped), or a named field (DataArray). The fields are the raw measurements: the reflectivity and differential reflectivity as measured (they are corrected for attenuation inside the ensemble if attenuation is set), the differential phase before any processing and the correlation coefficient.

  • retrieval (str or callable()) – What runs on each member. One of "kdp" (estimate_kdp() from the perturbed phase, product KDP), "attenuation" (correct_attenuation(): DBZH_corrected, ZDR_corrected, AH), "rain_rate_z", "rain_rate_kdp" (with KDP estimated from the member’s phase), "rain_rate_z_zdr", "rain_rate_a" (with AH from the attenuation correction), "dsd" (dsd(): DM, LOG10_NW, MU, RAIN_RATE, LWC), "dsd_bayesian" (the posterior means of dsd_bayesian()) and "hid" (hid(): class codes HID). Or a function f(dataset, **options) that takes a sweep with the perturbed fields under the names DBZH, ZDR, PHIDP, RHOHV and VRADH and returns a Dataset or DataArray.

  • dbz, zdr, phidp, rhohv, field (str, optional) – Names of the fields, as for perturb_radar().

  • members (int, optional) – Number of members. Default 32.

  • seed (int, optional) – Seed of the random numbers. Default 0.

  • calibration ((float, float) or None, optional) – Standard deviations (dB) of the calibration offsets of the reflectivity and the differential reflectivity. Default (1.0, 0.1).

  • noise (bool or dict, optional) – Add the measurement noise. A dict sets n_samples, snr, spectrum_width and nyquist as for perturb_radar(). Default True.

  • prior (bool or dict, optional) – Change the DSD prior of the retrieval for each member. True uses the defaults, a dict overrides the standard deviations relation (the log of the rain rate prefactor, from relation_scatter()), alpha (the log of the attenuation coefficients, from relation_scatter()), mu (shape of the "dsd" retrieval; the standard deviation of \(\mu\) under the generic prior), tilt (0.5; tilt of the prior of "dsd_bayesian" in standard deviations of \(D_m\) and \(\mu\)) and log10_nw (0.3; shift of the prior mean of \(\log_{10} N_w\)); the last two are radarx choices. False or None for no change. Only the entries that belong to the retrieval act. The draws are common to all gates of a sweep. Not used by "kdp", "hid" or a function.

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

  • variables (sequence of str, optional) – Variables of the retrieval to keep. Default: those listed for retrieval (the data variables of the result for a function).

  • categorical (sequence of str, optional) – Variables that hold class codes (integers from 0): they get the mode and the agreement. Default: ("HID",) for "hid", none otherwise.

  • keep_members (bool, optional) – Also return every member of every product as <name>_members with the dimension member. Default False.

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

  • band ({"S", "C", "X"}, optional) – Radar band for the retrieval and for the attenuation correction. By default as the retrieval finds it ("S" for the rain rates).

  • attenuation (str or dict, optional) – Correct the reflectivity and differential reflectivity of each member for attenuation before the retrieval, with the method ("zphi" or "linear") or a dict of options of correct_attenuation(). Always on for "attenuation" and "rain_rate_a" ("zphi").

  • options (dict, optional) – Options of the retrieval function (for "kdp" those of estimate_kdp(); kdp_options for the phase processing of the others; for "dsd", "dsd_bayesian" and "hid" kdp="estimate" uses the phase of each member). Do not give the names of the fields.

  • n_threads (int, optional) – Threads of the kernels. Default: all cores.

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

Returns:

xarray.Dataset or xarray.DataTree – For each product X: X_mean, X_median, X_std, X_p05 and X_p95 (or X_mode and X_agreement), float32 on the coordinates of the product, and X_members with keep_members. The attributes ensemble_members, ensemble_seed and ensemble_method describe the ensemble. For a volume, a DataTree with one such node per sweep and the root of the input. The input is not changed.

Raises:
  • KeyError – If no sweep has a radar field, or a requested variable is not returned by the retrieval.

  • ValueError – For an unknown retrieval, option or engine, or members below 2.

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

Notes

The members run one after the other; each runs threaded in C++ over its gates or rays. The error model, the draws and their limits are in radarx.retrieve.ensemble. "dsd_bayesian" models errors of its own (errors) inside the posterior: the spread of its posterior means over the ensemble comes on top of the posterior standard deviation and is not a replacement for it.

References

Melnikov, V. M., and D. S. Zrnic, 2004: Simultaneous transmission mode for the polarimetric WSR-88D: Statistical biases and standard deviations of polarimetric variables. NOAA/NSSL report, 84 pp., https://www.nssl.noaa.gov/publications/wsr88d_reports/SHV_statistics.pdf

Giangrande, S. E., A. V. Ryzhkov, V. M. Melnikov, and J. Krause, 2004: Calibration of the polarimetric NEXRAD radar using meteorological signals. Preprints, 11th Conf. on Aviation, Range, and Aerospace Meteorology, paper P5.15, https://ams.confex.com/ams/11aram22sls/techprogram/paper_81811.htm

Ryzhkov, A., M. Diederich, P. Zhang, and C. Simmer, 2014: Potential utilization of specific attenuation for rainfall estimation, mitigation of partial beam blockage, and radar networking. J. Atmos. Oceanic Technol., 31 (3), 599-619, https://doi.org/10.1175/JTECH-D-13-00038.1

Salmon, J. K., M. A. Moraes, R. O. Dror, and D. E. Shaw, 2011: Parallel random numbers: as easy as 1, 2, 3. Proc. 2011 Int. Conf. for High Performance Computing, Networking, Storage and Analysis, 1-12, https://doi.org/10.1145/2063384.2063405

Examples

>>> ens = radarx.retrieve.ensemble_retrieval(
...     sweep, "rain_rate_kdp", members=32, seed=1
... )
>>> ens.RAIN_RATE_KDP_std