radarx.retrieve.shear.llsd#
- radarx.retrieve.shear.llsd(obj, field=None, window=(750.0, 2500.0), *, weights='uniform', min_valid_fraction=0.5, mask=None, exclude=None, nodata='auto', median_filter=None, n_threads=None, engine='auto')[source]#
Azimuthal shear and radial divergence by linear least-squares derivatives.
- Parameters:
obj (
xarray.Datasetorxarray.DataTree) – A PPI sweep withazimuthandrangecoordinates (e.g. from xradar), a single sweep node of a volume (dtree["sweep_0"]), or a volume whosesweep_*nodes are processed one by one.field (
str, optional) – Radial velocity field in m s⁻¹. Default: the first ofVRADH,VRAD,VRADV,VEL,VELOCITY,velocitythat the sweep holds. Velocities must be dealiased (or free of aliasing); folds produce spurious shear.window (
tupleoffloat, optional) – Window size(range_m, azimuth_m)in metres: its length along the beam and its arc length across it. Default(750, 2500). The window covers at least one neighbouring gate and ray on each side and at most ±90° in azimuth.weights (
{"uniform", "gaussian"}, optional) – Uniform weights (default) or a Gaussian with a standard deviation of a quarter of the window in each direction.min_valid_fraction (
float, optional) – Minimum fraction of the gates in the window that must hold valid data. Default 0.5. The centre gate must always be valid.mask (
strorxarray.DataArray, optional) – Gates to use (True= keep, as inradarx.retrieve.hid(),radarx.retrieve.dsd()andradarx.retrieve.echo_mask()), e.g. the output ofecho_mask, or the name of such a variable. Other gates are left out of the fit. Before this versionTruemeant excluded; useexcludefor that.exclude (
strorxarray.DataArray, optional) – Gates to leave out of the fit (True= excluded). Can be combined withmask.nodata (
{"auto", "nexrad", None}, optional) – Flag values that are not data."auto"(default) treats the NEXRAD Level II codes decoded by xradar (velocity at or below -63.9 m/s, the floorecho_maskandapply_maskuse) as missing for NEXRAD volumes;"nexrad"does it for any input, None never.median_filter (
None,Trueorint, optional) – Median filter of the velocities before the fit, as in Smith and Elmore (2004) [1] (a 3 x 3 filter).None(default) orFalseapplies none,Truea 3 x 3 window and an odd integer a square window of that edge, in rays and gates (rays wrap around north). A gate keeps a value only if it is valid itself and the window holds more than half of its gates; the value is the median of the valid ones. The treatment of missing gates is a radarx choice: the preprint does not describe it. A median filter smooths the isolated velocity spikes that give spurious shear, and also lowers the peak shear of small vortices.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–azimuthal_shearandradial_divergencein s⁻¹ (float32) on the sweep’s dimensions and coordinates; a DataTree with one such node per sweep that hasfieldand the root of the input if a DataTree was given. Merge them into the input with.radarx.assign(products).
Notes
The plane \(v = a + b\,s + c\,\Delta r\) with \(s = r\,\Delta\theta\) is fitted to the window around every gate. Its slopes are the azimuthal shear \(b\) and radial divergence \(c\). The window holds the rays with \(r_0 |\Delta\theta| \le\)
azimuth_m / 2and the gates with \(|r - r_0| \le\)range_m / 2, so the number of rays changes with range. Measured ray azimuths are used and the window wraps around north. With uniform weights the kernel uses cumulative sums along range, so each gate costs one lookup per ray in its window.For solid-body rotation the azimuthal shear is half the vertical vorticity; for axisymmetric convergence the radial divergence is half the horizontal divergence. Smith and Elmore (2004) [1] state this as an approximation that holds for a symmetric wind field (mesocyclone, symmetric downburst) and breaks down for asymmetric features such as gust fronts. For solid-body rotation \(v_\theta = \Omega r\) one gets \(\partial v / \partial s = \Omega = \zeta / 2\), which follows from elementary geometry.
What is taken from the literature. The fitted plane, the arc coordinate \(s = r\,\Delta\theta\), the weighted least-squares fit and the fixed-width window whose number of rays shrinks with range are those of Smith and Elmore (2004) [1]. Their kernel is 3 range gates deep and about 2500 m wide (also 5000 and 8000 m), with at least 3 radials; the radarx defaults
window = (750, 2500)are 3 gates of 250 m and 2500 m, the smallest kernel of that paper. The window was set in metres, so for other gate spacings the depth is not 3 gates. Miller et al. (2013) [2] and Mahalik et al. (2019) [3] apply and evaluate the LLSD derivatives; their window sizes and weights are not used here. The Gaussian weights (a standard deviation of a quarter of the window),min_valid_fraction(0.5) and the requirement of at least 3 valid gates are radarx choices.Dask and extra dimensions. The fields may have extra leading dimensions (for example
timeorvolume): each sweep is processed on its own and the result has the same extra dimensions. Dask arrays stay lazy: the result is a dask array and nothing is computed until it is (the sweep dimensions are rechunked into one chunk). The sweeps of a stack must have the same azimuths.Examples
>>> out = radarx.retrieve.llsd(sweep, "VRADH") >>> out["azimuthal_shear"].plot()