radarx.retrieve.single_doppler.single_doppler_winds#

radarx.retrieve.single_doppler.single_doppler_winds(grid_or_volume, background=None, *, model=None, refine=True, x=None, y=None, z=None, radar=None, field='VRADH', dbz='DBZH', weights=None, fall_speed_correction=True, w_boundary='bottom', providers=None, uncertainty=False, members=20, vr_error=1.0, background_error=3.0, correlation=(25000.0, 1000.0), seed=0, n_threads=None, engine='auto', **input_kwargs)[source]#

Retrieve the three-dimensional wind from one Doppler radar.

Without model this is the variational single-Doppler retrieval: the cost function of radarx.retrieve.multi_doppler() (the structure of Gao et al. 1999 [1], which treats two radars) with the observation term of the one radar, the anelastic mass continuity equation, smoothness and the background. Along the beams the wind follows the observations; across them it comes from the background and from mass continuity.

With model a physics-informed network predicts the wind from the radial velocity, the reflectivity, the beam geometry and the background wind. It was trained against multi-Doppler retrievals of NEXRAD radar pairs and analytic flows, with the variational cost above (observation, mass continuity, smoothness and background terms of the one radar) as a physics loss; see ml/models/single_doppler/README.md in the radarx repository. With refine=True the prediction then serves as the background of the variational retrieval (weights {"background": 0.05, "background_w": 0.05} unless overridden), so that the final wind fits the observed radial velocities and the continuity equation while taking its cross-beam structure from the network. The network runs on its own grid spacing (dx, dy, dz in the model’s metadata, by default 1 km, 1 km, 500 m); other grids are interpolated to it and back.

Parameters:
  • grid_or_volume (xarray.Dataset or xarray.DataTree) – A gridded radar (field, optionally dbz, on (z, y, x) or (radar, z, y, x), with radar_x, radar_y and radar_altitude, e.g. from radarx.retrieve.multi_doppler_input()), or a radar volume, which is then gridded onto x, y, z with radarx.retrieve.multi_doppler_input(). Radial velocities must be dealiased.

  • background (xarray.Dataset, optional) – Background on the grid from radarx.io.sounding.era5_column() or radarx.io.sounding.profile_to_grid() (u, v along the grid axes, optionally air_density and freezing_level). Both methods need it to say anything about the cross-beam wind.

  • model (str, path or object, optional) – The network: a model name of the radarx.ml registry, a local ONNX file, or an object with a run(dict) -> dict method (such as radarx.ml.load_model(...)). The network takes the input features (float32[N, C, Z, Y, X]) and returns the wind (float32[N, 3, Z, Y, X], m s-1). Default: no network (variational retrieval).

  • refine (bool, optional) – Use the network’s wind as the background of a variational retrieval. Default True. Ignored without model.

  • x, y, z (array-like, optional) – Grid coordinates (m) when grid_or_volume is a volume.

  • radar (int, optional) – Index of the radar to use when the grid holds several.

  • field, dbz (str, optional) – Field names. Default "VRADH" and "DBZH".

  • weights (dict, optional) – Overrides of the weights of radarx.retrieve.multi_doppler().

  • fall_speed_correction (bool, optional) – Correct for the precipitation fall speed. Default True.

  • w_boundary (str or sequence of str, optional) – Where w = 0 (see radarx.retrieve.multi_doppler()). Default "bottom".

  • providers (list of str, optional) – ONNX Runtime execution providers. Default: CPU.

  • uncertainty (bool, optional) – Also return u_uncertainty, v_uncertainty and w_uncertainty, the standard deviation of the retrieved wind over an ensemble of retrievals from perturbed inputs (see Notes). The retrieval itself is the unperturbed one and does not change. Costs members more retrievals (network predictions included). Default False.

  • members (int, optional) – Number of perturbed retrievals, at least 2. Default 20.

  • vr_error (float, optional) – Standard deviation (m s-1) of the error of the gridded radial velocity, added as spatially uncorrelated noise to every gate with a velocity. Default 1.0 (a radarx choice).

  • background_error (float, optional) – Standard deviation (m s-1) of the error of the background u and v, added as a random field with the correlation lengths. Zero or no background leaves the background as it is. Default 3.0 (a radarx choice).

  • correlation (tuple of float, optional) – Horizontal and vertical correlation scales (m) of the background error, the standard deviations of the Gaussian smoothing of the random field. Default (25000.0, 1000.0) (a radarx choice).

  • seed (int, optional) – Seed of the random number generator of the ensemble. Default 0.

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

  • engine ({"auto", "compiled", "numpy"}, optional) – Implementation of the variational cost (and of the gridding).

  • **input_kwargs – Further options of radarx.retrieve.multi_doppler_input() when gridding a volume (origin, time, motion, …).

Returns:

xarray.Dataset – u, v (along the grid axes) and w on (z, y, x) with the grid’s coordinates. The variational retrieval adds its diagnostics (fall_speed, mass_residual, n_radars, vr_residual, cost, cost_history). With a network, u_network, v_network and w_network hold its raw prediction and the attributes ml_model, ml_model_version and ml_model_licence name it, and fall_speed_correction says how the fall speed was handled. With uncertainty=True there are also u_uncertainty, v_uncertainty and w_uncertainty (m s-1).

Notes

What is taken from the literature. Only the variational cost structure of Gao et al. (1999) [1] (and, through radarx.retrieve.multi_doppler(), its scaling and weights, which are radarx’s own). Gao et al. (1999) analyse two radars; the single-radar use here, the physics-informed network, its training, the refine weights {"background": 0.05, "background_w": 0.05} and the one-radar lower boundary w_boundary="bottom" are radarx’s own and are not taken from that or any other paper. As in radarx.retrieve.multi_doppler(), w_boundary="bottom" imposes w = 0 at the lowest grid level whatever its height; for a grid whose lowest level is above the ground this gives a column-wide bias in w (see the Notes there). A single Doppler radar determines only the wind component along its beams; the cross-beam wind comes from the background and the prior, so the retrieved cross-beam wind is not an observation.

Fall speed. The variational cost corrects the radial velocity for the fall speed (radarx.retrieve.fall_speed()), so with model=None and with refine=True (fall_speed_correction=True) the correction is applied explicitly. The network takes the uncorrected radial velocity and the reflectivity; it was trained with a physics loss on fall-speed corrected radial velocities, so it can only have learned the correction from the reflectivity. The raw prediction (refine=False, and u_network, v_network, w_network) therefore carries no explicit correction, fall_speed_correction has no effect on it, and the attribute fall_speed_correction of the result says which case applies. The correction in the refinement does not change the network prediction that serves as its background.

Uncertainty. With uncertainty=True the uncertainty of each wind component is the standard deviation, over members retrievals, of the wind retrieved from inputs with random errors: Gaussian noise of standard deviation vr_error added independently to every gate of the gridded radial velocity, and, with a background, a random field of standard deviation background_error added to its u and v (white noise smoothed by a Gaussian filter of correlation metres horizontally and vertically, periodic at the edges, scaled to the stated standard deviation). With a network, the whole pipeline (network prediction and refinement) is run for every member. This is a Monte Carlo propagation of the stated input errors through the retrieval, which is a linear least-squares problem without the vorticity term; it is radarx’s own definition and is not taken from a paper. It is not the posterior covariance of the cost function: the ensemble does not perturb the mass continuity and smoothness terms, so the spread does not contain the error that comes from the truth not satisfying those weak constraints, or from errors of the fall speed, the beam geometry or the advection correction, and the default errors are radarx choices that should be set to the errors of the data at hand. Where no velocity is observed the spread comes from the background error only.

Dask. This function computes the dask array: the wind is fitted to the whole grid or volume. The input is loaded into memory and the result is held in memory.

References

Examples

>>> grid = radarx.retrieve.multi_doppler_input([kgwx], x, y, z)
>>> bg = radarx.io.sounding.era5_column(grid)
>>> wind = radarx.retrieve.single_doppler_winds(grid, bg)
>>> wind = radarx.retrieve.single_doppler_winds(
...     grid, bg, model="single_doppler.onnx")