radarx.retrieve.qc.apply_mask#

radarx.retrieve.qc.apply_mask(obj, mask=None, data_vars=None, *, nodata='auto', **kwargs)[source]#

Set non-meteorological gates to NaN.

Parameters:
  • obj (xarray.Dataset or xarray.DataTree) – A sweep, a single sweep node (dtree["sweep_0"]) or a volume with sweep_* groups.

  • mask (xarray.Dataset, xarray.DataTree or xarray.DataArray, optional) – The output of echo_mask() for obj (or its boolean METEO_MASK, True for gates to keep). By default it is computed with echo_mask() and **kwargs.

  • data_vars (str or list of str, optional) – Fields to mask. Default: all floating point fields on (azimuth, range) (or (elevation, range)). In a volume, sweeps without a field or without a mask are left unchanged.

  • nodata ({"auto", "nexrad"} or None, optional) – "auto" (default) also masks the no-data codes of NEXRAD Level II fields decoded by xradar in NEXRAD data (DBZH <= -32, ZDR <= -12.9, RHOHV <= 0.21, PHIDP < 0, VRADH <= -63.9), so that every masked field holds NaN at gates without data; "nexrad" always does, None never does. Also passed to echo_mask().

  • **kwargs – Options of echo_mask() when mask is not given.

Returns:

xarray.Dataset or xarray.DataTree – A copy of obj with the masked fields (attributes kept).

Notes

Dask and extra dimensions. The fields may have extra leading dimensions (for example time or volume): 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).

References

No published method is implemented here: the function applies the mask of echo_mask(), whose Notes and References state how that classification relates to Gourley et al. (2007), Krause (2016), Park et al. (2009) and Steiner and Smith (2002). The NEXRAD no-data codes it masks are those decoded by xradar, not values from a paper.

Examples

>>> clean = radarx.retrieve.apply_mask(dtree, data_vars=["DBZH", "ZDR"])
>>> clean = dtree.radarx.apply_mask()