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
modelthis is the variational single-Doppler retrieval: the cost function ofradarx.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
modela 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; seeml/models/single_doppler/README.mdin the radarx repository. Withrefine=Truethe 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,dzin 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.Datasetorxarray.DataTree) – A gridded radar (field, optionallydbz, on(z, y, x)or(radar, z, y, x), withradar_x,radar_yandradar_altitude, e.g. fromradarx.retrieve.multi_doppler_input()), or a radar volume, which is then gridded ontox,y,zwithradarx.retrieve.multi_doppler_input(). Radial velocities must be dealiased.background (
xarray.Dataset, optional) – Background on the grid fromradarx.io.sounding.era5_column()orradarx.io.sounding.profile_to_grid()(u,valong the grid axes, optionallyair_densityandfreezing_level). Both methods need it to say anything about the cross-beam wind.model (
str,pathorobject, optional) – The network: a model name of theradarx.mlregistry, a local ONNX file, or an object with arun(dict) -> dictmethod (such asradarx.ml.load_model(...)). The network takes the inputfeatures(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 withoutmodel.x, y, z (array-like, optional) – Grid coordinates (m) when
grid_or_volumeis 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 ofradarx.retrieve.multi_doppler().fall_speed_correction (
bool, optional) – Correct for the precipitation fall speed. Default True.w_boundary (
stror sequence ofstr, optional) – Wherew = 0(seeradarx.retrieve.multi_doppler()). Default"bottom".providers (
listofstr, optional) – ONNX Runtime execution providers. Default: CPU.uncertainty (
bool, optional) – Also returnu_uncertainty,v_uncertaintyandw_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. Costsmembersmore 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 backgrounduandv, added as a random field with thecorrelationlengths. Zero or nobackgroundleaves the background as it is. Default 3.0 (a radarx choice).correlation (
tupleoffloat, 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) andwon(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_networkandw_networkhold its raw prediction and the attributesml_model,ml_model_versionandml_model_licencename it, andfall_speed_correctionsays how the fall speed was handled. Withuncertainty=Truethere are alsou_uncertainty,v_uncertaintyandw_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, therefineweights{"background": 0.05, "background_w": 0.05}and the one-radar lower boundaryw_boundary="bottom"are radarx’s own and are not taken from that or any other paper. As inradarx.retrieve.multi_doppler(),w_boundary="bottom"imposesw = 0at the lowest grid level whatever its height; for a grid whose lowest level is above the ground this gives a column-wide bias inw(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 withmodel=Noneand withrefine=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, andu_network,v_network,w_network) therefore carries no explicit correction,fall_speed_correctionhas no effect on it, and the attributefall_speed_correctionof 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=Truethe uncertainty of each wind component is the standard deviation, overmembersretrievals, of the wind retrieved from inputs with random errors: Gaussian noise of standard deviationvr_erroradded independently to every gate of the gridded radial velocity, and, with abackground, a random field of standard deviationbackground_erroradded to itsuandv(white noise smoothed by a Gaussian filter ofcorrelationmetres 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")