Clutter detection using the Gabella approach

Clutter detection using the Gabella approach#

import warnings

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

warnings.filterwarnings("ignore")

Read the data#

filename = wradlib_data.DATASETS.fetch("misc/polar_dBZ_fbg.gz")
data = np.loadtxt(filename)
data = wrl.georef.create_xarray_dataarray(data, rf=0.001).wrl.georef.georeference()
data
Downloading file 'misc/polar_dBZ_fbg.gz' from 'https://github.com/wradlib/wradlib-data/raw/main/data/misc/polar_dBZ_fbg.gz' to '/home/docs/.cache/wradlib-data'.
<xarray.DataArray (azimuth: 360, range: 128)> Size: 369kB
array([[  7.01,   8.28,   5.46, ..., -10.  , -10.  , -10.  ],
       [  7.01,   7.01,   7.01, ..., -10.  , -10.  , -10.  ],
       [  7.01,   7.67,   5.46, ..., -10.  , -10.  , -10.  ],
       ...,
       [  7.01,   8.28,   5.46, ...,  14.87,  17.76,  15.51],
       [  7.67,   7.67,   5.46, ...,   0.64,   8.83,   4.53],
       [  8.83,   7.67,   4.53, ...,  -8.99,  -4.17,  -8.99]],
      shape=(360, 128))
Coordinates: (12/14)
  * azimuth     (azimuth) float64 3kB 0.5 1.5 2.5 3.5 ... 357.5 358.5 359.5
    elevation   (azimuth) float64 3kB 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0
  * range       (range) float64 1kB 500.0 1.5e+03 ... 1.265e+05 1.275e+05
    x           (azimuth, range) float64 369kB 4.363 13.09 ... -1.113e+03
    y           (azimuth, range) float64 369kB 500.0 1.5e+03 ... 1.275e+05
    z           (azimuth, range) float64 369kB 0.0147 0.1323 ... 940.8 955.7
    ...          ...
    bins        (azimuth, range) float64 369kB 500.0 1.5e+03 ... 1.275e+05
    longitude   float64 8B 0.0
    latitude    float64 8B 0.0
    altitude    float64 8B 0.0
    sweep_mode  <U20 80B 'azimuth_surveillance'
    crs_wkt     int64 8B 0

Apply filter#

clmap = data.wrl.classify.filter_gabella(
    wsize=5, thrsnorain=0.0, tr1=6.0, n_p=8, tr2=1.3
)
clmap
<xarray.DataArray 'filter_gabella' (azimuth: 360, range: 128)> Size: 46kB
array([[False, False, False, ..., False, False, False],
       [False, False, False, ..., False, False, False],
       [False, False, False, ..., False, False, False],
       ...,
       [False, False, False, ...,  True,  True,  True],
       [False, False, False, ...,  True,  True,  True],
       [False, False, False, ..., False, False, False]], shape=(360, 128))
Coordinates: (12/14)
  * azimuth     (azimuth) float64 3kB 0.5 1.5 2.5 3.5 ... 357.5 358.5 359.5
    elevation   (azimuth) float64 3kB 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0
  * range       (range) float64 1kB 500.0 1.5e+03 ... 1.265e+05 1.275e+05
    x           (azimuth, range) float64 369kB 4.363 13.09 ... -1.113e+03
    y           (azimuth, range) float64 369kB 500.0 1.5e+03 ... 1.275e+05
    z           (azimuth, range) float64 369kB 0.0147 0.1323 ... 940.8 955.7
    ...          ...
    bins        (azimuth, range) float64 369kB 500.0 1.5e+03 ... 1.275e+05
    longitude   float64 8B 0.0
    latitude    float64 8B 0.0
    altitude    float64 8B 0.0
    sweep_mode  <U20 80B 'azimuth_surveillance'
    crs_wkt     int64 8B 0
Attributes:
    standard_name:  clutter_map
    long_name:      Clutter Map
    short_name:     CMAP
    units:          unitless

Plot results#

fig = plt.figure(figsize=(12, 8))
ax1 = fig.add_subplot(121)
pm = data.wrl.vis.plot(ax=ax1)
ax1.set_title("Reflectivity")
ax2 = fig.add_subplot(122)
pm = clmap.wrl.vis.plot(ax=ax2)
ax2.set_title("Cluttermap")
Text(0.5, 1.0, 'Cluttermap')
../../_images/e7854d5177adcd691f0c38ad5b820cc1faa540d2106013c0dcb91601884667d8.png