---
description: First step of the data processing chain.
---

# Sanity Check and Filtering

### Field Boundaries

Field boundaries are determined using either the alpha algorithm (alphashape) with the alpha parameter equal to the number of coordinates:

```python
import alphashape
alpha = len(position)
alpha_shape = alphashape.alphashape(points, alpha)
```

or, if the alpha shape algorithm is not successful, the ConvexHull algorithm:

```python
from scipy.spatial import ConvexHull
hull = ConvexHull(points)
indices = hull.vertices
```

The dataset is discarded if the area inside the field boundaries is less than 200 square metres.

### Dataset Size

The dataset is discarded if the total number of usable data points in the data set is less than 100.

### Averaging

The median value in each spectrum (HH, VV, HV, and VH) is calculated.&#x20;

Total power, polarized power, and unpolarized power are calculated:

```python
temp_tot = (0.5 * (data_hh2 + data_vv2))
temp_q = 1.0 * (0.5 * (data_hh2 - data_vv2))
temp_pol = np.sqrt(data_u * data_u + temp_q * temp_q + data_v * data_v)
temp_unpol = temp_tot - temp_pol
```

### Filtering

The data point is discarded if the total power for an integration exceeds 400 Kelvin or is less than 50 Kelvin.
