# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://skaha-labs.gitbook.io/documentation/online-processing/sanity-check-and-filtering.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
