add AGC compensation

This commit is contained in:
Christos Falas 2025-05-14 16:55:54 +01:00
parent d15b82f031
commit 7ff89d2fda
No known key found for this signature in database
2 changed files with 20 additions and 1 deletions

View File

@ -131,7 +131,6 @@ class CSIApplication:
""" """
def decorator(data: CSIMatrix) -> None: def decorator(data: CSIMatrix) -> None:
self.visualise_data(data, visualise.figures.Figure.RAW_CSI)
func(data) func(data)
self.preprocessed_csi_callback = decorator self.preprocessed_csi_callback = decorator

View File

@ -123,9 +123,28 @@ class Preprocessor:
return csi return csi
def normalise_magnitude(
self, csi: CSIMatrix, frames: dict[CSIHost, CSI]
) -> CSIMatrix:
"""
Normalise the magnitude of the CSI data to compensate for the effect of the
Automatic Gain Control (AGC) of the receiver
References:
[1] -
"""
rssi = [
frames[host].header.rssi1 if antenna == 0 else frames[host].header.rssi2
for host, antenna in config.antennas.order
]
rssi_linear = np.reshape(10 ** (np.array(rssi) / 10), (1, -1, 1))
csi_power = np.sum(np.abs(csi) ** 2)
return csi * np.sqrt(rssi_linear / csi_power)
def preprocess( def preprocess(
self, self,
h: CSIMatrix, h: CSIMatrix,
frames: dict[CSIHost, CSI],
visualiser: None visualiser: None
| Callable[[npt.NDArray[Any], visualise.figures.Figure], None] = None, | Callable[[npt.NDArray[Any], visualise.figures.Figure], None] = None,
) -> CSIMatrix: ) -> CSIMatrix:
@ -144,6 +163,7 @@ class Preprocessor:
# h_hat = correlate(h_hat, np.ones((3, 1, 1)) / 3) # h_hat = correlate(h_hat, np.ones((3, 1, 1)) / 3)
# h_hat = correlate(h_hat, [[[1 / 4]], [[1 / 2]], [[1 / 4]]], mode="valid") # h_hat = correlate(h_hat, [[[1 / 4]], [[1 / 2]], [[1 / 4]]], mode="valid")
h_hat = self.normalise_magnitude(h_hat, frames)
h_hat = self.remove_sfo(h_hat, visualiser=visualiser) h_hat = self.remove_sfo(h_hat, visualiser=visualiser)
# Skip subcarrierss per config # Skip subcarrierss per config