radarx.retrieve.multidoppler.multi_doppler#
- radarx.retrieve.multidoppler.multi_doppler(grids, background=None, *, field='VRADH', dbz='DBZH', weights=None, fall_speed_correction=True, freezing_level='auto', melting_depth=500.0, w_boundary='bottom', w_bottom=0.0, terrain=None, storm_motion=(0.0, 0.0), shift_winds=False, analysis_time=None, first_guess=None, levels=3, max_iterations=500, tolerance=None, solver='auto', n_threads=None, engine='auto', obs_error=None, crossing_angle_weight=False, obrien_error='linear', error=False, error_samples=32, error_seed=0)[source]#
Retrieve the three-dimensional wind from two or more Doppler radars.
The wind
(u, v, w)on the grid minimises the cost function \(J = J_o + J_m + J_s + J_b + J_v\) (the structure of Gao et al. 1999 [1], see the Notes for what is and is not taken from it):\[\begin{split}J_o &= C_o \sum_k \sum_i \left(u \cos\phi_k \sin\alpha_k + v \cos\phi_k \cos\alpha_k + (w - V_t) \sin\phi_k - v_{r,k}\right)^2 \\ J_m &= C_m \sum_i \left(\frac{h}{\rho}\left[ \frac{\partial \rho u}{\partial x} + \frac{\partial \rho v}{\partial y} + \frac{\partial \rho w}{\partial z}\right]\right)^2 \\ J_s &= C_s \sum_i \sum_{f=u,v,w} (\delta_{xx} f)^2 + (\delta_{yy} f)^2 + \frac{C_{sz}}{C_s} (\delta_{zz} f)^2 \\ J_b &= C_b \sum_i (u - u_b)^2 + (v - v_b)^2 \\ J_v &= C_v \sum_i \left(\frac{h^2}{U} R_\zeta\right)^2\end{split}\]over the grid cells \(i\) and radars \(k\), where \(\alpha_k\), \(\phi_k\) are the beam azimuth and local elevation, \(V_t\) the fall speed (
fall_speed()), \(\rho\) the air density, \(h = \sqrt{\Delta x \Delta y}\), \(\delta\) second differences in grid units and \(U = 10\) m s-1. The scaling makes every term a squared velocity, so the weights are dimensionless and per grid cell. \(R_\zeta\) is the residual of the vertical vorticity equation (Shapiro et al. 2009 [2]; Potvin et al. 2012 [3]), taken as steady in a frame moving withstorm_motion,\[R_\zeta = (u - U_s) \zeta_x + (v - V_s) \zeta_y + w \zeta_z + (\zeta + f)(u_x + v_y) + w_x v_z - w_y u_z ,\]applied where at least two radars observe. Derivatives are centred differences (one-sided at the edges); the smoothness penalty is applied to the second derivatives in each direction (a radarx choice of discretisation; Potvin et al. 2012 [3] also use smoothness constraints).
The cost and its exact gradient are computed in one fused, multithreaded pass of a compiled kernel. Without the vorticity term the cost is quadratic and is minimised by conjugate gradients (exact steps, no line search), preconditioned with the inverse of the smoothness operator (plus a constant) in the basis of the discrete cosine transform; with the vorticity term SciPy’s L-BFGS-B is used. The minimisation runs first on grids coarsened by two horizontally (
levels), each solution starting the next finer one. The first guess is the background wind withw = 0.wis held at zero at the boundaries named inw_boundaryby removing those cells from the control vector.- Parameters:
grids (
xarray.Datasetor sequence ofxarray.Dataset) – Gridded, dealiased and advection-corrected radial velocities on a common grid with aradardimension (seemulti_doppler_input()):fieldon(radar, z, y, x)and eitherazimuthandelevationon(radar, z, y, x)orradar_x,radar_yandradar_altitudeonradar. A sequence of per-radar Datasets is concatenated alongradar.background (
xarray.Dataset, optional) – Background on the grid, fromradarx.io.sounding.era5_column()orradarx.io.sounding.profile_to_grid():u,v(along the grid axes), optionallyw,air_densityandfreezing_level. Without it there is no background term and a standard density profile is used.field, dbz (
str, optional) – Field names. Default"VRADH"and"DBZH".weights (
dict, optional) – Overrides of the dimensionless weightsobservation(\(C_o\), default 1),mass_continuity(\(C_m\), default 10),smoothness(\(C_s\), 0.5),smoothness_vertical(\(C_{sz}\), default the same assmoothness),background(\(C_b\), 0.001),background_w(weight ofw - w_b, 0) andvorticity(\(C_v\), 0, i.e. off). The defaults areDEFAULT_WEIGHTSinradarx.retrieve.multidoppler. They are radarx choices: the weights of Gao et al. (1999), Shapiro et al. (2009) and Potvin et al. (2012) belong to differently scaled terms and are not transferable, and results depend strongly on them. Without abackground,backgroundis set to 0.fall_speed_correction (
bool, optional) – Correct for the precipitation fall speed. Default True.freezing_level (
{"auto", "rain"},floatorxarray.DataArray, optional) – Height of the 0 degC level (m above sea level, or on(y, x)) that separates the rain and the snow fall speed relation offall_speed()."auto"(default) takes thefreezing_levelof thebackground(as returned byradarx.io.sounding.era5_column()), or the 0 degC crossing of itstemperature; with neither, aRuntimeWarningis issued and the rain relation is used at all heights."rain"is that old behaviour without the warning.melting_depth (
float, optional) – Depth (m) below the freezing level over which the fall speed changes from the rain to the snow relation (fall_speed()). Default 500.w_boundary (
stror sequence ofstr, optional) – Wherew = 0: any of"bottom"(lowest level, default),"top"(highest level),"echo_top"(from one level above the highest echo in each column) and"obrien"(the O’Brien adjustment of the solution so thatw = 0at the highest level, seeobrien_errorand the Notes).Nonefor no boundary condition."bottom"setswtow_bottomat the lowest grid levelz[0]whatever its height; aRuntimeWarningis issued whenz[0]is more thanW_BOTTOM_WARN_HEIGHT(200 m) above the highest radar andw_bottomis 0; see the Notes.w_bottom (
floatorxarray.DataArray, optional) – Value ofw(m s-1, or on(y, x)) held at the lowest level forw_boundary="bottom". Default 0. With a grid that starts above the ground, give the vertical velocity atz[0]implied by the flow below, for example from the low-level divergence.terrain (
xarray.DataArrayorarray, optional) – Terrain height (m above sea level) on(y, x)of the grid, for example from a digital elevation model. The analysis then runs on levels that follow the terrain: levelkof every column is at the heightterrain + z[k] - z[0]above sea level, soz[0]is the ground;z[0]is typically 0 and the grid must reach the highest terrain and the top of the analysis. The radial velocities, reflectivity and background are interpolated linearly in height to these levels and the beam elevation is recomputed. The vertical velocity of the control vector is then the one relative to the levels, \(W = w - u\, \partial h/\partial x - v\, \partial h/\partial y\), sow_boundary="bottom"(W = w_bottom, default 0) is flow along the ground, andwis returned; see the Notes. The result haszas the height above the terrain, the coordinateheight(above sea level, on(z, y, x)) and the variableterrain. Not available with the vorticity term. Default None: levels at constant height above sea level.storm_motion (
tupleoffloat, optional) –(u, v)of the frame in which the vorticity is steady, m s-1; also the velocity of the wind pattern forshift_winds.shift_winds (
bool, optional) – Evaluate the analysis winds, valid atanalysis_time, at the position they had when each radar observed (x - c (t_k - t_a)withc = storm_motion) instead of advecting the radial velocities to a common time. Radial velocity is a projection on the beam direction, which changes when the pattern moves byc (t_k - t_a); advecting it as a scalar leaves an error of about|u| |c| |t_k - t_a| / r(1.4 m s-1 for 20 m s-1 wind, a 15 m s-1 pattern speed, 180 s and 40 km range). Use it with grids that were not advected (multi_doppler_inputwithouttime/motion), whosetimecoordinate holds the observation time of every radar. The shift is made on the observations together with their beam direction (see Notes). Default False.analysis_time (
datetime-like, optional) – Valid time of the analysis forshift_winds.first_guess (
xarray.Dataset, optional) – Start from theseu,v,winstead of the background (e.g. the previous analysis of a time series); thenlevelsis 1.levels (
int, optional) – Number of grid levels of the coarse-to-fine minimisation; each coarser level halves the horizontal resolution (only while the grid keeps at least 12 points). Default 3.max_iterations (
int, optional) – Maximum iterations per level. Default 500.tolerance (
float, optional) – Stopping tolerance. For"cg": the preconditioned gradient norm relative to that of the cost at zero wind (default 3e-4); for"lbfgsb": the relative reduction of the cost (ftol, default 1e-7).solver (
{"auto", "cg", "lbfgsb"}, optional) – Minimiser."auto"(default) uses conjugate gradients when the vorticity term is off and L-BFGS-B otherwise.n_threads (
int, optional) – Threads for the compiled kernel. Default: all cores.engine (
{"auto", "compiled", "numpy"}, optional) – Cost function implementation."auto"prefers the compiled kernel.obs_error (
float, sequence offloat,xarray.DataArrayorarray, optional) – Standard deviation (m s-1) of the error of the radial velocity: one number, one number per radar, or an array or DataArray that broadcasts to(radar, z, y, x)(for examplevelocity_error()of the signal to noise ratio and the spectrum width of the gate, see the Notes). The weight of an observation in \(J_o\) is multiplied by \(1 / \sigma^2\) (m-2 s2), so a radar with twice the error counts a quarter as much. A NaN error removes the observation. Default None: every observation has the weightweights['observation']alone, as if \(\sigma = 1\) m s-1 (the earlier behaviour). The default weights of the other terms are tuned for errors of about 1 m s-1: if all radars have a much larger error the smoothness and mass terms win over the observations (on the test flow, errors of[0.2, 1.0]m s-1 give up to 30 % smaller errors than equal weights, while[1.0, 3.0]give larger ones), so give the relative quality of the radars unless the absolute values are what you want.crossing_angle_weight (
bool, optional) – Multiply the weight of every observation by \(\sin^2\beta\), where \(\beta\) isbeam_crossing_angle(at least1e-3; cells seen by one radar keep the factor 1). The error of the horizontal wind of two radars grows as \(1/\sin\beta\) (Notes), and this factor lowers the trust in observations where the geometry makes any error in them, noise or not, count most. The normal equations of \(J_o\) already contain the geometry, so this is an extra down-weighting beyond the noise model, a radarx choice that is not from a paper. Default False.obrien_error (
{"linear", "constant"}, optional) – Shape of the O’Brien adjustment forw_boundary="obrien": the error of the divergence grows linearly with height ("linear", default; the mass flux correction is quadratic in height) or is constant ("constant"; linear correction).error (
bool, optional) – Returnu_error,v_errorandw_error, the standard deviation of the retrieval error from the covariance of the cost function (see the Notes). Needs the quadratic cost (weights['vorticity'] = 0). Costs abouterror_samplestimes the conjugate-gradient solution on the finest grid. Default False.error_samples (
int, optional) – Number of random draws of the error estimate; the relative uncertainty of the standard deviation is1 / sqrt(2 * error_samples). Default 32.error_seed (
int, optional) – Seed of the random draws. Default 0.
- Returns:
xarray.Dataset– On(z, y, x):u,v(along the grid axes),w,fall_speed,mass_residual(anelastic mass divergence, s-1),n_radars(radars observing each cell) and, with two or more radars,beam_crossing_angle; witherror=Truealsou_error,v_errorandw_error(m s-1);vr_residual(model minus observed radial velocity) on(radar, z, y, x);costonterm(final value of every term) andcost_historyon(iteration, term).attrsrecord the weights, iterations, convergence message and run time.
Notes
What is taken from the literature. Gao et al. (1999) [1] pose the retrieval of the three-dimensional wind from the radial velocities of Doppler radars as a variational (weak-constraint) problem; Shapiro et al. (2009) [2] and Potvin et al. (2012) [3] describe a cost function of the discrepancies between observed and analysed radial winds, errors in the anelastic mass conservation equation, errors in the anelastic vertical vorticity equation and spatial smoothness constraints, as used here. Their equations are not checked term by term. The forms of \(J_o\), \(J_m\), \(J_s\), \(J_b\) and \(J_v\) above, the scaling by \(h\), \(h^2/U\) and the grid spacing (so that the weights are dimensionless), the choice of second differences for the smoothness term, the background term \(J_b\) and all default weights are radarx’s own formulation. Unlike Shapiro et al. (2009), who use Taylor’s frozen-turbulence hypothesis to shift the analysis winds to the observation times, radarx by default advects the data to a common time beforehand (
radarx.retrieve.advect()) and treats the vorticity equation as steady in the frame moving withstorm_motion. Withshift_winds=Truethe analysis winds are shifted to the observation times by-c (t_k - t_a)in the observation operator (the idea of Shapiro et al. 2009; their equations are not checked here). It is done by the equivalent move of each observation with its direction cosines in the opposite direction, so the cost function and the solvers are unchanged; the same bilinear interpolation as inradarx.retrieve.advect()is used, and observations whose shifted position lies outside the grid are dropped. The fall speed correction is described infall_speed().Gridding artifacts. The radial velocities enter on a Cartesian grid. Linear interpolation from the polar grid can create periodic artifacts that produce spurious vertical velocities (Collis et al. 2010 [4]); radarx’s cone gridding (
radarx.grid.grid_cones()) is of that kind, so retrievedwcan contain such artifacts. Their mixed-order interpolation is available asmulti_doppler_input(..., velocity_interpolation="mixed")andradarx.grid.grid_cones_mixed().Solvers. The conjugate-gradient iteration is that of Hestenes and Stiefel (1952) [5] with a preconditioner built on the discrete cosine transform (Strang 1999 [6]; the second-difference operator is diagonal in that basis except at the edge cells, so the preconditioner is approximate and only changes the speed of convergence, not the minimiser). The vorticity case uses SciPy’s L-BFGS-B, an implementation of Byrd et al. (1995) [7] and Zhu et al. (1997) [8]. The coarse-to-fine sequence (
levels, a factor of two in x and y) and the stopping tolerances (3e-4 and 1e-7) are radarx choices.Lower boundary.
w_boundary="bottom"imposesw = w_bottom(default 0) at the lowest grid levelz[0], whatever its height. The physical condition of a wind analysis is impermeability,w = 0at the ground (terrain), and only a grid whose lowest level is the surface satisfies it. Ifz[0]lies above the ground, for example at 500 m above sea level over flat terrain near sea level as in grids built withz = np.arange(500, 12e3, 500), the truewthere is generally not zero and the anelastic integration carries the error up the whole column as a column-wide offset of the order of the truewatz[0]. In a test (two radars, analytic anelastic flowu = 5 + a x,v = 2 + a y,w = -2 a H (exp(z/H) - 1),a = 2e-4 s-1,H = 10 km, no noise) the root-mean-square error ofwwas 0.05 m s-1 for levels 0, 500, …, 10000 m but 0.37 m s-1 (mean error 0.35 m s-1) for levels 500, 1000, …, 10500 m, where the truewat 500 m is -0.20 m s-1. Choosez[0]at the terrain height, pass thewatz[0]asw_bottom(giving the true -0.20 m s-1 in that test brings the rms error ofwback to the level of the first case), or usew_boundary=Noneor"top"/"echo_top"and judgewaccordingly. The statement that the condition belongs at the ground is the standard one for dual-Doppler analyses; it is not checked against the text of Gao et al. (1999) or Potvin et al. (2012).Terrain-following lower boundary. With
terrainthe levels follow the ground, \(z = h(x, y) + z^*\), where \(z^* = z - z[0]\) is the height above the terrain (the simplest terrain-following coordinate, with the spacing of the levels the same in every column; Gal-Chen and Somerville 1975 [10] introduced the family of such transformations, whose equations are not checked here and which usually also scale the coordinate to a flat top). For a function \(f(x, y, z) = F(x, y, z^*)\), \(\partial_x f = \partial_x F - h_x\, \partial_{z^*} F\), so with the density \(\rho\) as a field of the grid the anelastic continuity equation becomes\[\partial_x(\rho u) + \partial_y(\rho v) + \partial_{z^*}(\rho W) = 0, \qquad W = w - u\, h_x - v\, h_y ,\]the same equation as on flat levels for the vertical velocity
Wrelative to the levels, and the impermeability condition at the ground, \(w = u\, h_x + v\, h_y\), is \(W = 0\) at \(z^* = 0\). radarx therefore keeps the cost function, its kernel and the solvers and changes the observation operator, which becomes \((a + c\, h_x) u + (b + c\, h_y) v + c W\) for the direction cosines \((a, b, c)\) of the beam;wis returned. The derivation is elementary calculus (chain rule) and is not taken from a paper. Smoothness and background act onu,vandWin the new coordinates. The slopes \(h_x, h_y\) are centred differences of the terrain on the horizontal grid (one-sided at the edges); the terrain is not smoothed, so a terrain much rougher than the grid gives noisy slopes and a noisyw. The data are interpolated linearly in height from the original levels to the terrain-following ones (a vertical resampling of gridded velocities, with the interpolation error that has), levels above the top of the grid are missing, and over a mountain of height \(h\) the analysis reaches only \(z_{top} - h\) above the ground. The beam is not blocked by terrain: cells hidden behind a ridge have to be masked in the input (seeradarx.retrieve.beam_blockage()). The vorticity term is not available withterrain.Observation weights. With
obs_errorthe weight of the observation of radar \(k\) in \(J_o\) is \(C_o / \sigma_k^2\).velocity_error()gives \(\sigma_k\) of the pulse-pair velocity estimate from the signal to noise ratio and the spectrum width (Doviak and Zrnic 1993, Eq. 6.22); it is the noise of the estimate of one gate, not the error of the gridded velocity, so a radar’s own noise model may be better. The error of the horizontal wind from two radars depends on the crossing angle of the beams (derived indual_doppler_analytic()): the minimiser of \(J_o\) already weights the observations through this geometry, andcrossing_angle_weightis an optional extra.Error estimate. With all weights read as inverse variances, so that \(J\) is a chi-square (\(-2 \ln p\) of independent Gaussian errors), the covariance of the minimiser is the inverse of one half of the Hessian of \(J\) (the Gauss-Markov covariance), which does not depend on the solution because \(J\) is quadratic. radarx draws
error_samplesperturbationsb = 2 B^T xiof all terms (observations, mass continuity, smoothness, background; the cost is \(\sum_j |B_j x - y_j|^2\)), solves \(H x = b\) by preconditioned conjugate gradients and takes the mean of \(x^2\) as the variance, the randomised solution of a linear-Gaussian posterior (not taken from a paper). It is the standard deviation of the error if the radial velocity errors have the standard deviationobs_errorand the weak constraints (mass continuity, smoothness, background) are as accurate as their weights say. The weights of those terms are radarx choices, not error statistics, sou_error,v_errorandw_errordescribe the analysis system with these weights; they do not include errors of the fall speed, the gridding, the advection, or a wrong lower boundary condition. On the synthetic flow of the tests (Beltrami flow, two radars, 0.5 m s-1 noise,obs_error=0.5, 32 draws) they are 1.44 (u), 1.27 (v) and 1.04 (w) times the root-mean-square error of the retrieval where the beams cross at more than 30 degrees. They are 1.5 to 2.1 times the standard deviation of the retrievals over 16 noise realisations, because they include the freedom that the weak constraints leave. On a 4 km grid the truncation error of the discretisation, which they do not contain, dominates the actual error and the ratio forwfalls to 0.35. The Hessian of the vorticity term is not constant, soerror=Trueneedsweights['vorticity'] = 0.O’Brien adjustment.
w_boundary="obrien"(usually with"bottom") applies the adjustment of O’Brien (1970) [9] to the retrievedwafter the minimisation, as described indual_doppler_analytic(): the mass flux \(\rho w\) is reduced by the fraction \(((z - z_0)/(z_{top} - z_0))^2\) of its value at the highest grid level (obrien_error="constant": the first power), so thatw = 0there. The result is no longer the minimiser of \(J\) (the cost terms of the output are those of the adjusted state), and the one-dimensional adjustment does not changeuandv. Use it when the truewis zero at the top of the grid and the retrievedwis not ("top"fixesw = 0inside the minimisation instead). The paper was not read; seedual_doppler_analytic()for what the implementation follows.Dask. This function computes the dask array: the wind is solved for all grid cells at once. The input is loaded into memory and the result is held in memory.
References
Examples
>>> grids = radarx.retrieve.multi_doppler_input([kgwx, kcbm], x, y, z) >>> bg = radarx.io.sounding.era5_column(grids) >>> wind = radarx.retrieve.multi_doppler(grids, bg)