radarx.grid.gates.grid_gates#

radarx.grid.gates.grid_gates(obj, data_vars=None, x=None, y=None, z=None, *, weighting='cressman', roi=1000.0, roi_range_factor=0.0, roi_height_factor=0.0, beamwidth=None, min_gates=1, k_e=1.3333333333333333, motion=None, time=None, range_resolution=None, n_threads=None, engine='auto')[source]#

Grid radar gates onto a Cartesian grid with a radius of influence.

Every output point is the weighted mean of the gates within the radius of influence \(R\) of it (Cressman 1959 [1] or Barnes 1964 [2] weights, or the nearest gate). All sweeps of the volume take part, whatever the scan (PPI, sector, RHI, repeated tilts); see radarx.grid.gates.

Parameters:
  • obj (xarray.DataTree) – Radar volume with sweep_* groups and the radar site latitude, longitude and altitude, e.g. from xradar.

  • data_vars (str or list of str, optional) – Fields to grid. By default every field present in the lowest sweep on (azimuth, range).

  • x, y (array-like) – Target coordinates east and north of the radar, in metres.

  • z (array-like) – Target heights above sea level, in metres.

  • weighting ({"cressman", "barnes", "nearest", "beam"}, optional) – Weight of a gate at the distance \(d < R\): Cressman, \((R^2-d^2)/(R^2+d^2)\) (default); Barnes, \(\exp(-4d^2/R^2)\); the value of the nearest gate; or "beam", the Gaussian pulse volume of the gate (needs beamwidth). The beam weight follows the beams instead of the distance: gates of the beams that pass the point dominate, and a velocity, which is a projection on the beam, is mixed less with gates of other directions.

  • roi (float, optional) – Radius of influence in metres, and the smallest one when it grows with the distance from the radar. Default 1000.

  • roi_range_factor, roi_height_factor (float, optional) – Increase of the radius in metres per metre of horizontal distance of the output point from the radar, and per metre of height above the radar (Py-ART’s xy_factor and z_factor). Default 0: a constant radius.

  • beamwidth (float, optional) – Half-power beamwidth in degrees. When given, tan(beamwidth) is added to roi_range_factor: the radius is the width of the beam at the distance of the output point (the dist_beam term of Py-ART), so that the weights reach as far as the gates of the beam do, at any range. Also sets the width of the pulse volume of weighting="beam", which needs it. Default None.

  • min_gates (int, optional) – Fewest gates within the radius for a value. Default 1.

  • k_e (float, optional) – Effective Earth radius factor of the beam, see grid_cones().

  • motion (tuple of float, optional) – Storm motion (u, v) in m/s. Every sweep is moved from its mean time to the analysis time before the gates are averaged, which matters for repeated low tilts minutes apart. See grid_cones(). Default None.

  • time (datetime-like, optional) – Analysis time for motion. Default: the mean time of the volume.

  • range_resolution (float, optional) – With weighting="beam", the half-power width in metres of the Gaussian weight along the beam. Default: the gate spacing of each sweep.

  • 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 and SciPy.

Returns:

xarray.Dataset – Gridded fields on (z, y, x) as float32, georeferenced like the result of grid_cones(). Points without a gate within the radius are NaN.

Raises:
  • ValueError – If no sweep contains a requested variable, the grid is missing or a parameter is out of range.

  • ImportError – If engine="compiled" and the compiled kernel is not available.

See also

grid_cones, grid_rhi

Notes

Cressman’s (1959) weight and the Gaussian weight of Barnes (1964) are the ones of the objective analysis schemes of these papers, with the analysis radius \(R\) as the cut-off. The Gaussian is \(\exp(-d^2/\kappa)\) with \(\kappa = R^2/4\), so the weight is 0.018 at the radius. A radius that grows with the range and height is the dist function of Py-ART [3], and beamwidth its dist_beam term; the formulas were read from the Py-ART source and are implemented here, not copied. The distance is Euclidean between the gate and the output point in metres, in the frame of the radar (beam height with the effective Earth radius model, Doviak and Zrnić 1993, Eqs. 2.28), and the radius is evaluated at the output point. The default radius, min_gates and the rule that a point without a gate is empty are radarx choices.

The mean of the gates in the radius is not the cone interpolation of grid_cones(): it smooths over \(R\), does not reproduce the gate values, and a velocity gridded this way mixes gates of different beams (see the note on velocity in grid_cones()). A radius that follows the beam width, or at most a gate spacing, limits that, and so does weighting="beam".

Beam weighting. The weight of a gate at the point is the pulse volume of the gate evaluated there: a Gaussian whose standard deviation is \(\sigma_\theta r\) across the beam, with \(\sigma_\theta^2 = \theta_1^2 / (16 \ln 2)\) the second central moment of the two-way power pattern of a circularly symmetric Gaussian beam of half-power width \(\theta_1\) (Doviak and Zrnic 1993 [4], Eq. 5.75; the one-way power pattern is \(\exp(-4 \ln 2\,\phi^2/\theta_1^2)\), Eq. C.18), so the weight is 0.25 at half the beamwidth off the axis. Along the beam it is a Gaussian whose half-power width is range_resolution, a radarx choice (the range weighting of the book depends on the pulse and the receiver filter). The beam direction at a gate is taken from the path of the beam in the effective Earth radius model, and the weights of the gates in the radius are taken relative to the largest one, so that they do not vanish at a point between two beams. The radius \(R\) still decides which gates take part. Averaging with these weights is a radarx construction, not a published gridding scheme; only the beam pattern is taken from the book.

Dask. This function computes the dask array: the result is interpolated from the gates of all sweeps. The input is loaded into memory and the result is held in memory.

References

Examples

>>> x = y = np.arange(-100e3, 100e3 + 1, 1000.0)
>>> z = np.arange(500.0, 10e3 + 1, 500.0)
>>> grid = radarx.grid.grid_gates(
...     dtree, "DBZH", x, y, z, weighting="barnes", roi=1500.0, beamwidth=1.0
... )