radarx.retrieve.vertical_profiles.mask_above_melting_layer#

radarx.retrieve.vertical_profiles.mask_above_melting_layer(products, melting_layer, *, bottom='melting_layer_bottom', height=None, margin=0.0, beamwidth=None, variables=None)[source]#

Remove the products of rain-only retrievals above the melting layer.

The rain rates of radarx.retrieve.rain_rate_z(), rain_rate_kdp, rain_rate_z_zdr, rain_rate_a and the drop size distribution parameters of radarx.retrieve.dsd() hold for rain. Above the melting layer the radar sees snow and ice, and in it wet snow, for which the relations do not apply. radarx.retrieve.rain_rate() already leaves the gates of the hydrometeor classes without a relation (including the melting layer, “wet snow”) empty, but depends on the classification; this function makes a cap from a melting-layer height instead, for example from melting_layer() (profiles of a QVP, with the time of the volume) or melting_layer_ppi() (with the azimuth).

A gate is removed where its height is above the bottom of the melting layer plus margin. The bottom is the end of snow melting (Ryzhkov and Krause 2022 [1], p. 533), so below it there are no wet snow and no ice: the rain-only relations apply from there downward. The margin (default 0 m) moves the cap, and beamwidth makes it use the lower edge of the beam instead of its centre, because a beam whose lower half is in rain and upper half in the layer is contaminated. Both are radarx’s definition and are not taken from a paper. Gates are kept where the melting layer is not known (NaN): the function does not assume that there is no melting layer.

Parameters:
  • products (xarray.DataArray, xarray.Dataset or xarray.DataTree) – A rain-only product (DataArray), a sweep with such products (Dataset), or a volume. Datasets need the elevation and range coordinates (and altitude) for the gate heights.

  • melting_layer (xarray.Dataset, xarray.DataArray or float) – The bottom of the melting layer, in m above sea level: the output of melting_layer() or melting_layer_ppi() (variable bottom), a DataArray, or a number. A DataArray or variable on azimuth is matched to the azimuths of the rays (nearest, circular); one without dimensions applies to all gates. Select one time of a time series first (isel(time=...)).

  • bottom (str, optional) – Variable of a Dataset that holds the bottom. Default "melting_layer_bottom".

  • height (xarray.DataArray, optional) – Height of the gates (m above sea level). By default the beam height of qvp() (4/3 Earth model) from the elevation, range and altitude coordinates.

  • margin (float, optional) – Added to the bottom (m); gates above the sum are removed. Default 0.

  • beamwidth (float, optional) – Two-way half-power beam width (degrees). With it the height compared with the cap is the lower edge of the beam, height - 0.5 * width * range * cos(elevation). Default None: the centre of the beam.

  • variables (str or list of str, optional) – The variables of a Dataset to remove. Default: those of RAIN_ONLY_PRODUCTS the Dataset has.

Returns:

xarray.DataArray, xarray.Dataset or xarray.DataTree – The products with NaN above the layer; other variables are unchanged. In a Dataset with RAIN_RATE and RAIN_RATE_FLAG the flag is 4 (above_melting_layer) and RAIN_RATE_RELATION 0 where an estimate was removed.

See also

melting_layer, melting_layer_ppi, radarx.retrieve.rain_rate

Notes

Nothing here estimates the rain rate in the melting layer or above it: the relations scaled for wet snow and dry snow of Giangrande and Ryzhkov (2007) are listed in radarx.retrieve.qpe and are chosen there with class_relations.

Dask. This function computes the dask array: the layer height is found from the data. The input is loaded into memory and the result is held in memory.

References

Examples

>>> ml = radarx.retrieve.melting_layer_ppi(dtree)
>>> rr = radarx.retrieve.rain_rate_z(sweep)
>>> rr = radarx.retrieve.mask_above_melting_layer(rr, ml, margin=-200.0)