radarx.retrieve.qpe_ml.rain_rate_ml#

radarx.retrieve.qpe_ml.rain_rate_ml(obj, *, model=None, band='S', dbz=None, zdr=None, kdp=None, rhohv=None, height=None, temperature=None, mask=None, min_dbz=None, wavelength=None, n_threads=None, engine='auto')[source]#

Rain rate from a machine-learning model.

Parameters:
  • obj (xarray.Dataset or xarray.DataTree) – A sweep or grid with the fields the model needs (by default DBZH, ZDR, KDP, RHOHV and, for height, the coordinates z and altitude), or a volume with sweep_* groups (sweeps without the fields are skipped).

  • model (str or radarx.ml.Model, optional) – The name of a model of the registry of radarx.ml or a loaded model. Default "radarx-qpe-v1", which is not distributed yet: train one with ml/models/qpe of the radarx repository and register it with radarx.ml.register_model().

  • band ({"S", "C", "X"}, optional) – Radar band, which gives the wavelength feature of models that use it. Default "S".

  • dbz, zdr, kdp, rhohv (str or xarray.DataArray, optional) – Names of the fields, or the fields. By default DBZH, ZDR, KDP and RHOHV (and the other names of radarx.retrieve.rain_rate_z()).

  • height (str, xarray.DataArray or float, optional) – Height of the gates above the radar (m, a number or a field; km if the units attribute of the field says so), for models that use it. Default: the coordinate z minus the radar altitude, if there is one.

  • temperature (str, xarray.DataArray or float, optional) – Air temperature (degrees Celsius; Kelvin is detected from the units or the values) for models that use it, for example the field TEMPERATURE of the sounding accessor.

  • mask (xarray.DataArray, optional) – Boolean field on the grid of the fields: only gates where it is True are estimated. Use the rain classes of radarx.retrieve.hid() or the result of radarx.retrieve.echo_mask(). Default: all gates.

  • min_dbz (float, optional) – Gates with a lower reflectivity are not estimated (NaN). Default: none. The training range of the model is in its registry entry.

  • wavelength (float, optional) – Radar wavelength (cm) instead of the one of band.

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

  • engine ({"auto", "compiled", "numpy"}, optional) – Implementation to use. "auto" (default) prefers the compiled kernel and falls back to NumPy.

Returns:

xarray.Dataset or xarray.DataTree – RAIN_RATE_ML (mm h-1, float32), and RAIN_RATE_ML_LOWER and RAIN_RATE_ML_UPPER (one standard deviation below and above in the logarithm of the rain rate) if the model gives them, on the coordinates of the fields, NaN where a gate is not estimated; for a DataTree one node per sweep. The attributes ml_model, ml_model_version, ml_model_licence and ml_model_citation record the model. The input is not changed.

Raises:
  • KeyError – If a field the model needs, or a sweep that has all of them, is not found, or the model returns no rain_rate.

  • ValueError – For an unknown band or engine, a model without features or with unknown ones, or a model name that is not registered.

  • TypeError – If obj is not a Dataset or DataTree, or model is neither a name nor an object with a run method.

  • ImportError – For a model name when ONNX Runtime is not installed (pip install     radarx[ml]), or engine="compiled" without the kernel.

Notes

The network and what it was trained on are described by the model, not by this function. A model trained on simulated drop size distributions (ml/models/qpe) is a multivariate rain-rate relation that weights \(Z_H\), \(Z_{DR}\) and \(K_{DP}\) by their noise and gives an uncertainty from the natural variability of the drop size distribution; it does not correct for attenuation, calibration or the vertical profile of reflectivity. A model trained on gauges (in the way of RainForest) learns these effects for the radar and the region it was trained on. The gauge adjustment of radarx.retrieve.gauge_adjust() applies to either.

Dask. This function computes the dask array: the network runs on all gates of a sweep at once. The input is loaded into memory and the result is held in memory.

References

Wolfensberger, D., M. Gabella, M. Boscacci, U. Germann, and A. Berne, 2021: RainForest: a random forest algorithm for quantitative precipitation estimation over Switzerland. Atmos. Meas. Tech., 14 (4), 3169-3193, https://doi.org/10.5194/amt-14-3169-2021

Vulpiani, G., S. Giangrande, and F. S. Marzano, 2009: Rainfall estimation from polarimetric S-band radar measurements: Validation of a neural network approach. J. Appl. Meteor. Climatol., 48 (10), 2022-2036, https://doi.org/10.1175/2009JAMC2172.1

Examples

>>> ml.register_model("my-qpe", "qpe.onnx", None, "MIT", "citation",
...                   features=["dbz", "zdr", "kdp", "rhohv"])
>>> rr = radarx.retrieve.rain_rate_ml(sweep, model="my-qpe")
>>> rr.RAIN_RATE_ML.attrs["ml_model"]
'my-qpe'