Heuristic clutter detection based on distribution properties (“histo cut”)#

Detects areas with anomalously low or high average reflectivity or precipitation. It is recommended to use long term average or sums (months to year).

import wradlib as wrl
import numpy as np
import matplotlib.pyplot as plt
import warnings

    get_ipython().run_line_magic("matplotlib inline")
/home/runner/micromamba/envs/wradlib-tests/lib/python3.11/site-packages/h5py/__init__.py:36: UserWarning: h5py is running against HDF5 1.14.3 when it was built against 1.14.2, this may cause problems
  _warn(("h5py is running against HDF5 {0} when it was built against {1}, "

Load annual rainfall acummulation example (from DWD radar Feldberg)#

filename = wrl.util.get_wradlib_data_file("misc/annual_rainfall_fbg.gz")
yearsum = np.loadtxt(filename)
Downloading file 'misc/annual_rainfall_fbg.gz' from 'https://github.com/wradlib/wradlib-data/raw/pooch/data/misc/annual_rainfall_fbg.gz' to '/home/runner/work/wradlib/wradlib/wradlib-data'.

Apply histo-cut filter to retrieve boolean array that highlights clutter as well as beam blockage#

Depending on your data and climate you can parameterize the upper and lower frequency percentage with the kwargs upper_frequency/lower_frequency. For European ODIM_H5 data these values have been found to be in the order of 0.05 in EURADCLIM: The European climatological high-resolution gauge-adjusted radar precipitation dataset. The current default is 0.01 for both values.

mask = wrl.classify.histo_cut(yearsum)

Plot results#

fig = plt.figure(figsize=(14, 14))
ax = fig.add_subplot(221)
yearsum = wrl.georef.create_xarray_dataarray(yearsum).wrl.georef.georeference()
pm = np.log(yearsum).wrl.vis.plot(ax=ax)
plt.title("Logarithm of annual precipitation sum")
plt.colorbar(pm, shrink=0.75)
ax = fig.add_subplot(222)
mask = wrl.georef.create_xarray_dataarray(mask).wrl.georef.georeference()
pm = mask.wrl.vis.plot(ax=ax)
plt.title("Map of execptionally low and high values\n(clutter and beam blockage)")
plt.colorbar(pm, shrink=0.75)
ax = fig.add_subplot(223)
pm = mask.where(mask == 1).wrl.vis.plot(ax=ax)
plt.title("Map of execptionally high values\n(clutter)")
plt.colorbar(pm, shrink=0.75)
ax = fig.add_subplot(224)
pm = mask.where(mask == 2).wrl.vis.plot(ax=ax)
plt.title("Map of execptionally low values\n(beam blockage)")
plt.colorbar(pm, shrink=0.75)
<matplotlib.colorbar.Colorbar at 0x7fc19430bf50>