SPATZ/spatz/sensors/antenna/tx_gain.py
2024-01-31 17:58:12 +01:00

63 lines
1.5 KiB
Python

from numpy.typing import ArrayLike
from typing import List, AnyStr
from numpy import matrix
from typing import List
import pandas as pd
from spatz.sensors import Sensor
from spatz.transforms import Transform
from spatz.dataset import Dataset
from spatz.logger import Logger
'''
Sensor to simulate TX antenna gain in direction of ground station
You will need to supply a gain pattern in the form of a R^3 matrix in the following form:
Returns the gain in dBi per timestep.
gain_pattern: matrix, groundstation_offset_vector
'''
class GainPattern():
def __init__(self, pattern_file):
self._df = pd.read_csv(pattern_file,delimiter='\t')
print(self._df)
def get_gain(self, phi, theta):
phi_left = round(phi,-1)
phi_right = round(phi ,-1)
theta_left = theta
theta_right = theta
class AntennaTxGain(Sensor):
def __init__(self, dataset: Dataset, logger: Logger, transforms: List[Transform] = []):
super().__init__(dataset, logger, transforms)
def _get_data(self) -> ArrayLike | float:
# Get current position of rocket
[x,y,z] = self._dataset.fetch_values(['x', 'y', 'z'])
# Get current rotation of rocket
[pitch,roll,yaw] = self._dataset.fetch_values(['pitch','roll','yaw'])
# Calculate angle between the vectors
# Fetch gain in this direction
return 0
def _sensor_specific_effects(self, x: ArrayLike) -> ArrayLike:
return x
def _get_name(self) -> AnyStr:
return 'Generic Antenna TX'