---
jupytext:
  formats: md:myst
  text_representation:
    extension: .md
    format_name: myst
    format_version: 0.13
    jupytext_version: 1.18.1
kernelspec:
  name: python3
  display_name: Python 3
---

```{include} ../../_includes/license_block.md
```
# Clutter detection using the Gabella approach

```{code-cell} python
import warnings

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

warnings.filterwarnings("ignore")
```

## Read the data

```{code-cell} python
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
```

## Apply filter

```{code-cell} python
clmap = data.wrl.classify.filter_gabella(
    wsize=5, thrsnorain=0.0, tr1=6.0, n_p=8, tr2=1.3
)
clmap
```

## Plot results

```{code-cell} python
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")
```
