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.Datasetorxarray.DataTree) – A sweep or grid with the fields the model needs (by defaultDBZH,ZDR,KDP,RHOHVand, forheight, the coordinateszandaltitude), or a volume withsweep_*groups (sweeps without the fields are skipped).model (
strorradarx.ml.Model, optional) – The name of a model of the registry ofradarx.mlor a loaded model. Default"radarx-qpe-v1", which is not distributed yet: train one withml/models/qpeof the radarx repository and register it withradarx.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 (
strorxarray.DataArray, optional) – Names of the fields, or the fields. By defaultDBZH,ZDR,KDPandRHOHV(and the other names ofradarx.retrieve.rain_rate_z()).height (
str,xarray.DataArrayorfloat, 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 coordinatezminus the radaraltitude, if there is one.temperature (
str,xarray.DataArrayorfloat, optional) – Air temperature (degrees Celsius; Kelvin is detected from the units or the values) for models that use it, for example the fieldTEMPERATUREof 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 ofradarx.retrieve.hid()or the result ofradarx.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 ofband.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.Datasetorxarray.DataTree–RAIN_RATE_ML(mm h-1, float32), andRAIN_RATE_ML_LOWERandRAIN_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 attributesml_model,ml_model_version,ml_model_licenceandml_model_citationrecord 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
bandorengine, a model withoutfeaturesor with unknown ones, or a model name that is not registered.TypeError – If
objis not a Dataset or DataTree, ormodelis neither a name nor an object with arunmethod.ImportError – For a model name when ONNX Runtime is not installed (
pip install radarx[ml]), orengine="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 ofradarx.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'