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

# Gain Calibration

A gain calibration, as described [here](../technical-description/internal-calibration), is performed. First, the internal calibration load is applied, with t\_kelvin being the physical temperature of the calibration load:

```python
data_hh = t_kelvin * statistics.median(np.array(data[2][ind]) / np.array(data[0][ind]))
data_vv = t_kelvin * statistics.median(np.array(data[3][ind]) / np.array(data[1][ind]))
data_u = t_kelvin * statistics.median(np.array(data[4][ind]) / (np.sqrt(np.array(data[0][ind])) * np.sqrt(np.array(data[1][ind]))))
data_v = t_kelvin * statistics.median(np.array(data[5][ind]) / (np.sqrt(np.array(data[0][ind])) * np.sqrt(np.array(data[1][ind]))))
```

And then gain drifts due to variations in the receiver temperature are removed, with t being the physical temperature of the PCB (we use the physical temperature of the calibration load as it is measured on the PCB) in degrees Celsius:

```python
LNA_fact_hh = -0.0004132 * data_hh + 0.4057
LNA_fact_vv = -0.0004132 * data_vv + 0.4057
offset_hh = LNA_fact_hh * t
offset_vv = LNA_fact_vv * t
data_hh -= offset_hh
data_vv -= offset_vv

data_hh2 = 1.778 * data_hh - 175.9
data_vv2 = 1.778 * data_vv - 175.9
```
