radarx.retrieve.attenuation.correct_attenuation#

radarx.retrieve.attenuation.correct_attenuation(obj, dbz=None, zdr=None, phidp=None, rhohv=None, *, method='zphi', band=None, coefficients='bringi1990', alpha=None, beta=None, b=None, min_dphi=3.0, max_pia=None, min_dbz=0.0, min_rhohv=0.9, melting=None, mask=None, kdp_options=None, n_threads=None, engine='auto')[source]#

Correct the reflectivity and the differential reflectivity for rain attenuation.

Uses the path-integrated differential phase, with the constrained ZPHI solution of Testud et al. (2000) or the linear relation of Bringi et al. (1990). The equations, the coefficients for S, C and X band and the choices of radarx are in radarx.retrieve.attenuation.

Parameters:
  • obj (xarray.DataArray, xarray.Dataset or xarray.DataTree) – A sweep on (azimuth, range) (or any dimensions with a range dimension; range in metres, uniformly spaced), a volume with sweep_* groups, or the reflectivity of a sweep as a DataArray (then give phidp, and zdr for the differential reflectivity, as DataArrays). The reflectivity may be a dask array; the result stays lazy.

  • dbz, zdr, phidp, rhohv (str or xarray.DataArray, optional) – The reflectivity (dBZ), the differential reflectivity (dB), the processed differential phase (degrees, increasing with range in rain, offset removed, see below) and the copolar correlation coefficient: a field name or a DataArray. By default the first name found is used: DBZH, DBZ, reflectivity, corrected_reflectivity; ZDR, differential_reflectivity, corrected_differential_reflectivity (the differential reflectivity is corrected only if there is one); RHOHV, cross_correlation_ratio, copol_correlation_coeff (without \(\rho_{hv}\) that gate test is skipped). Without phidp, PHIDP_processed is used if the dataset has it (the output of radarx.retrieve.estimate_kdp(), merged with assign); otherwise radarx.retrieve.estimate_kdp() is run on the raw phase (UPHIDP, PHIDP, uncorrected_differential_phase, differential_phase, PHI) with its defaults, or with kdp_options. Name the uncorrected reflectivity if the file holds several.

  • method ({"zphi", "linear"}, optional) – Default "zphi".

  • band ({"S", "C", "X"}, optional) – Radar band for the coefficients. By default it is read from the radar frequency of the data (S band, with a warning, if there is none); not needed when alpha, beta and b are all given.

  • coefficients ({"bringi1990", "tmatrix"}, optional) – Set of \(\alpha\) and \(\beta\), see attenuation_coefficients(). Default "bringi1990".

  • alpha, beta, b (float, optional) – Override the coefficients: \(A_H = \alpha K_{DP}\) and \(A_{DP} = \beta K_{DP}\) in dB per degree (so that PIA = alpha * delta_phidp) and the exponent of \(A_H = a Z^b\) ("zphi" only).

  • min_dphi (float, optional) – Rays whose phase span is smaller (degrees) get no correction. Default 3.

  • max_pia (float, optional) – Upper limit (dB) of the path attenuation. Default: none.

  • min_dbz (float, optional) – Gates with a lower reflectivity (dBZ) are not rain. Default 0.

  • min_rhohv (float, optional) – Gates with a lower correlation coefficient are not rain. Default 0.9.

  • melting (float or xarray.DataArray, optional) – Height of the melting level (m above sea level, a number or an array that broadcasts to the reflectivity). Gates at or above it are left out of the rain path. The beam height is the z coordinate (e.g. after xradar.accessors.XradarDataTreeAccessor.georeference()) or computed from the elevation and altitude (4/3 Earth radius). Default: no cutoff.

  • mask (str or xarray.DataArray, optional) – Boolean field of the gates that may belong to the rain path (e.g. a classification), True where allowed. A name refers to a variable of the sweep. For a volume, a name.

  • kdp_options (dict, optional) – Options of radarx.retrieve.estimate_kdp() for the case that the phase has to be processed.

  • n_threads (int, optional) – Threads of the compiled kernel (per call; each dask chunk is one call). Default: all cores.

  • engine ({"auto", "compiled", "numpy"}, optional) – Implementation. "auto" (default) prefers the compiled kernel.

Returns:

xarray.Dataset or xarray.DataTree – On the coordinates of the input: DBZH_corrected (dBZ), ZDR_corrected (dB, if the differential reflectivity is given), the specific attenuation AH and differential attenuation ADP (dB km-1, one way; NaN outside the rain path), the two-way path attenuation PIA and differential attenuation PIDA (dB) at each gate, and DELTA_PHIDP, the phase span of the rain path of each ray (degrees). The coefficients used are in the attributes attenuation_alpha, attenuation_beta and attenuation_b. For a volume, a DataTree with one such node per sweep that has the fields, and the root of the input. Merge it into the input with dtree.radarx.assign(products). The input is not changed.

Raises:
  • KeyError – If a field is missing.

  • ValueError – For unknown options, non-uniform range gates, or no band.

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

Notes

Use the uncorrected reflectivity: a field that an earlier chain already corrected would be corrected twice. The differential phase must be free of the system offset: a phase that does not start near zero at the first rain gate is fine, since the span of the rain path is used, but a phase that is folded or noisy is not. The method assumes rain. Hail changes the coefficients, and ZPHI spreads an error of the coefficients over the whole ray (Ryzhkov et al. 2014).

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

Examples

>>> kdp = sweep.radarx.kdp()
>>> out = sweep.radarx.assign(kdp).radarx.correct_attenuation(band="C")
>>> out = correct_attenuation(sweep, method="linear", band="X")