From 28ed2616450b956ea5123092e0caf9d46ba0728e Mon Sep 17 00:00:00 2001 From: Tim Smit Date: Thu, 8 Feb 2024 12:48:42 +0100 Subject: [PATCH] Refactoring --- paseos/actors/actor_builder.py | 1 - paseos/communication/link_model.py | 60 ++++++++++--------- paseos/communication/optical_link_model.py | 49 ++++++++------- .../communication/optical_receiver_model.py | 21 ++++--- .../optical_transmitter_model.py | 29 ++++----- paseos/communication/radio_link_model.py | 10 ++-- paseos/communication/radio_receiver_model.py | 26 ++++---- .../communication/radio_transmitter_model.py | 49 ++++++++------- paseos/communication/receiver_model.py | 32 +++++----- paseos/communication/transmitter_model.py | 26 ++++---- paseos/utils/gain_calc.py | 8 ++- paseos/utils/link_budget_calc.py | 15 ++--- 12 files changed, 167 insertions(+), 159 deletions(-) diff --git a/paseos/actors/actor_builder.py b/paseos/actors/actor_builder.py index b9c238b..2f918ee 100644 --- a/paseos/actors/actor_builder.py +++ b/paseos/actors/actor_builder.py @@ -5,7 +5,6 @@ from dotmap import DotMap import pykep as pk from skyfield.api import wgs84 -import math from .base_actor import BaseActor from .spacecraft_actor import SpacecraftActor diff --git a/paseos/communication/link_model.py b/paseos/communication/link_model.py index 30a286a..880561f 100644 --- a/paseos/communication/link_model.py +++ b/paseos/communication/link_model.py @@ -6,6 +6,7 @@ from ..actors.base_actor import BaseActor import math + class LinkModel: """This class defines a link model, containing one transmitter and one receiver.""" @@ -18,27 +19,29 @@ class LinkModel: _current_line_of_sight = False _current_distance = 0 _current_elevation_angle = 0 - + def __init__( - self, - transmitter_actor: BaseActor, - transmitter_model: TransmitterModel, - receiver_actor: BaseActor, - receiver_model: ReceiverModel, - frequency: float + self, + transmitter_actor: BaseActor, + transmitter_model: TransmitterModel, + receiver_actor: BaseActor, + receiver_model: ReceiverModel, + frequency: float ) -> None: """Initializes the model. Args: - transmitter_actor (BaseActor): The transmitter in this link. - receiver (ReceiverModel): The receiver in this link. + transmitter_actor (BaseActor): the transmitter actor in this link. + transmitter_model (TransmitterModel): the transmitter device model in this link. + receiver_actor (BaseActor): the receiver actor in this link. + receiver_model (ReceiverModel): the receiver device model. """ # assert isinstance(transmitter, TransmitterModel), "A transmitter is required for this link." assert isinstance(receiver_model, ReceiverModel), "A receiver is required for this link." logger.debug("Initializing link model.") self.c = 299792458 - self.wavelength = self.c / frequency # in m + self.wavelength = self.c / frequency # in m self.transmitter_actor = transmitter_actor self.transmitter = transmitter_model self.receiver_actor = receiver_actor @@ -47,30 +50,31 @@ def __init__( self._line_of_sight_history = [] self._distance_history = [] self._elevation_angle_history = [] - - def get_path_loss(self, slant_range): + + def get_path_loss(self, slant_range: float) -> float: """Gets the path loss (free space loss) for a link. Args: - slant_range (int): The slant range of the link, in meters + slant_range (float): The slant range of the link, in meters Returns: The path loss (free space loss) in dB """ assert slant_range > 0, "Slant range needs to be higher than 0 meters" - return 20 * math.log10(4 * math.pi * slant_range / self.wavelength) + return 20 * math.log10(4 * math.pi * slant_range / self.wavelength) - def set_bitrate(self, bitrate: float): + def set_bitrate(self, bitrate: float) -> None: """Sets the bitrate of this link for a certain epoch. Args: bitrate (float): The bitrate of this link, in bps """ self._current_bitrate = bitrate - - def set_line_of_sight(self, state: bool): - """Sets the line of sight of this link for a certain epoch, if there is a line of sight, the transmitter is set to active. + + def set_line_of_sight(self, state: bool) -> None: + """Sets the line of sight of this link for a certain epoch, + if there is a line of sight, the transmitter is set to active. Args: state (bool): The current line of sight state @@ -81,41 +85,41 @@ def set_line_of_sight(self, state: bool): else: self.transmitter.set_active(False) - def set_distance(self, distance: float): + def set_distance(self, distance: float) -> None: """Sets the distance of this link for a certain epoch. Args: distance (float): The slant range of the link, in meters """ self._current_distance = distance - - def set_elevation_angle(self, angle: float): + + def set_elevation_angle(self, angle: float) -> None: """Sets the elevation angle of this link for a certain epoch. Args: angle (float): The elevation angle, in degrees """ self._current_elevation_angle = angle - - def save_state(self): + + def save_state(self) -> None: """Saves the state of this link.""" self._bitrate_history.append(self._current_bitrate) self._line_of_sight_history.append(self._current_line_of_sight) self._distance_history.append(self._current_distance) self._elevation_angle_history.append(self._current_elevation_angle) - + @property def bitrate_history(self): return self._bitrate_history - + @property def line_of_sight_history(self): return self._line_of_sight_history - + @property def distance_history(self): return self._distance_history - + @property def elevation_angle_history(self): - return self._elevation_angle_history \ No newline at end of file + return self._elevation_angle_history diff --git a/paseos/communication/optical_link_model.py b/paseos/communication/optical_link_model.py index ecdf34f..1ffbd6a 100644 --- a/paseos/communication/optical_link_model.py +++ b/paseos/communication/optical_link_model.py @@ -7,15 +7,16 @@ from ..actors.base_actor import BaseActor import math + class OpticalLinkModel(LinkModel): - """This class defines an ptical link model, containing one transmitter and one receiver.""" + """This class defines an optical link model, containing one transmitter and one receiver.""" def __init__( - self, - transmitter_actor: BaseActor, - transmitter_device_name: str, - receiver_actor: BaseActor, - receiver_device_name: str + self, + transmitter_actor: BaseActor, + transmitter_device_name: str, + receiver_actor: BaseActor, + receiver_device_name: str ) -> None: """Initializes the model. @@ -25,44 +26,46 @@ def __init__( receiver_actor (BaseActor): the receiver in this link. receiver_device_name (str): the name of the receiver device. """ - self.wavelength = 1550E-9 # in m + self.wavelength = 1550E-9 # in m # Get the transmitter and receiver models from the actor transmitter = transmitter_actor.get_transmitter(transmitter_device_name) receiver = receiver_actor.get_receiver(receiver_device_name) - super().__init__(transmitter_actor, transmitter, receiver_actor, receiver, frequency=299792458/self.wavelength) - - assert isinstance(transmitter, OpticalTransmitterModel), "An optical transmitter is required for this optical link." + super().__init__(transmitter_actor, transmitter, receiver_actor, receiver, + frequency=299792458 / self.wavelength) + + assert isinstance(transmitter, OpticalTransmitterModel), ("An optical transmitter is required " + "for this optical link.") assert isinstance(receiver, OpticalReceiverModel), "An optical receiver is required for this optical link." logger.debug("Initializing optical link model.") self.required_BER = 10E-3 - + self.modulation_scheme = "OOK" - self.required_s_n_margin = 3 # in dB + self.required_s_n_margin = 3 # in dB self.receiver.set_gain(self.wavelength) self.transmitter.set_gain() - - def get_path_loss(self, slant_range): + + def get_path_loss(self, slant_range: float) -> float: """Gets the path loss (free space loss) for a link. Args: - slant_range (int): The slant range of the link, in meters + slant_range (float): The slant range of the link, in meters Returns: The path loss (free space loss) in dB """ assert slant_range > 0, "Slant range needs to be higher than 0 meters" - return 20 * math.log10(4 * math.pi * slant_range / self.wavelength) - - def get_bitrate(self, slant_range, min_elevation_angle): + return 20 * math.log10(4 * math.pi * slant_range / self.wavelength) + + def get_bitrate(self, slant_range: float, min_elevation_angle: float) -> float: """Gets the bitrate for a link based on current slant range and minimum elevation angle. Args: - slant_range (int): The slant range of the link, in meters + slant_range (float): The slant range of the link, in meters min_elevation_angle (float): The minimum elevation angle for this receiver, in degrees Returns: @@ -76,11 +79,11 @@ def get_bitrate(self, slant_range, min_elevation_angle): self.signal_at_receiver = self.transmitter.EIRP - self.total_channel_loss self.received_signal_power_with_gain = self.signal_at_receiver + self.receiver.antenna_gain - self.receiver.line_losses - self.received_signal_power_with_margin = self.received_signal_power_with_gain - self.required_s_n_margin #dBm - self.received_signal_power_with_margin = 10**(self.received_signal_power_with_margin / 10) * 1E-3 #nW + self.received_signal_power_with_margin = self.received_signal_power_with_gain - self.required_s_n_margin # dBm + self.received_signal_power_with_margin = 10 ** (self.received_signal_power_with_margin / 10) * 1E-3 # nW bitrate = self.received_signal_power_with_margin / 250 * 1550E-9 / 6.626E-34 / self.c if bitrate < 0: bitrate = 0 - - return bitrate \ No newline at end of file + + return bitrate diff --git a/paseos/communication/optical_receiver_model.py b/paseos/communication/optical_receiver_model.py index 46e553a..eb9ec46 100644 --- a/paseos/communication/optical_receiver_model.py +++ b/paseos/communication/optical_receiver_model.py @@ -1,32 +1,35 @@ from loguru import logger from .receiver_model import ReceiverModel +from ..utils.gain_calc import calc_optical_gain_from_wavelength_diameter + class OpticalReceiverModel(ReceiverModel): """This class defines an optical receiver model.""" def __init__( - self, - line_losses: int, - antenna_diameter: int = 0, - antenna_gain: int = 0 + self, + line_losses: float, + antenna_diameter: float = 0, + antenna_gain: float = 0 ) -> None: """Initializes the model. Args: - line_losses (int): The line losses of the receiver, in dB. - antenna_diameter (int): The diameter of the antenna, in m. Either this or the gain needs to be given. - antenna_gain (int): The gain of the antenna, either this or the diameter needs to be given so that gain can be determined. + line_losses (float): The line losses of the receiver, in dB. + antenna_diameter (float): The diameter of the antenna, in m. Either this or the gain needs to be given. + antenna_gain (float): The gain of the antenna, either this or the diameter needs to be given so that + gain can be determined. """ super().__init__(line_losses, antenna_diameter, antenna_gain) logger.debug("Initializing optical receiver model.") - def set_gain(self, wavelength): + def set_gain(self, wavelength: float = 0) -> None: """Sets gain for a receiver, based on the given gain, or antenna diameter and wavelength. Args: wavelength (int): The wavelength of the link, in meters """ if self.antenna_gain == 0: - self.antenna_gain = calc_optical_gain_from_wavelength_diameter(wavelength, self.antenna_diameter, 1) \ No newline at end of file + self.antenna_gain = calc_optical_gain_from_wavelength_diameter(wavelength, self.antenna_diameter, 1) diff --git a/paseos/communication/optical_transmitter_model.py b/paseos/communication/optical_transmitter_model.py index 2bff6de..aa9bcec 100644 --- a/paseos/communication/optical_transmitter_model.py +++ b/paseos/communication/optical_transmitter_model.py @@ -9,27 +9,27 @@ class OpticalTransmitterModel(TransmitterModel): def __init__( self, - input_power: int, + input_power: float, power_efficiency: float, antenna_efficiency: float, - line_losses: int, - point_losses: int, - antenna_gain: int = 0, - antenna_diameter: int = 0, - fwhm: int = 0 + line_losses: float, + point_losses: float, + antenna_gain: float = 0, + antenna_diameter: float = 0, + fwhm: float = 0 ) -> None: """Initializes the model. Args: - input_power (int): Input power into the signal amplifier, in W. + input_power (float): Input power into the signal amplifier, in W. power_efficiency (float): The power efficiency of the signal amplifier, determines the output power. antenna_efficiency (float): The efficiency of the antenna. - line_losses (int): The line losses of the transmitter, in dB. - point_losses (int): The pointing losses of the transmitter, in dB. - antenna_gain (int): The gain of the antenna, either this or the diameter needs to be given so that gain + line_losses (float): The line losses of the transmitter, in dB. + point_losses (float): The pointing losses of the transmitter, in dB. + antenna_gain (float): The gain of the antenna, either this or the diameter needs to be given so that gain can be determined. - antenna_diameter (int): The diameter of the antenna, in m. Either this or the gain needs to be given. - fwhm (int): full width at half maximum, in radians. + antenna_diameter (float): The diameter of the antenna, in m. Either this or the gain needs to be given. + fwhm (float): full width at half maximum, in radians. """ logger.debug("Initializing optical transmitter model.") @@ -37,9 +37,6 @@ def __init__( antenna_diameter) assert antenna_gain > 0 or antenna_diameter > 0 or fwhm > 0, ("Antenna gain or antenna diameter or " "FWHM needs to be higher than 0.") - # assert ( - # antenna_diameter > 0 and antenna_gain > 0 and fwhm > 0), ("Only set one of antenna gain, " - # "antenna diameter, and FWHM not multiple.") assert sum(param != 0 for param in (antenna_diameter, antenna_gain, fwhm)) <= 1, ("Only set one of antenna gain, " "antenna diameter, and FWHM not multiple.") @@ -49,7 +46,7 @@ def __init__( self.output_power = 10 * math.log10(input_power * power_efficiency * 1000) # dBm self.FWHM = fwhm - def set_gain(self): + def set_gain(self) -> None: """Sets gain for a transmitter, based on the given gain, or antenna diameter and wavelength. """ if self.antenna_gain == 0: diff --git a/paseos/communication/radio_link_model.py b/paseos/communication/radio_link_model.py index 553978d..68a90b5 100644 --- a/paseos/communication/radio_link_model.py +++ b/paseos/communication/radio_link_model.py @@ -54,11 +54,11 @@ def __init__( self.receiver.set_gain(self.wavelength) self.transmitter.set_gain(self.wavelength) - def get_path_loss(self, slant_range) -> float: + def get_path_loss(self, slant_range: float) -> float: """Gets the path loss (free space loss) for a link. Args: - slant_range (int): The slant range of the link, in meters + slant_range (float): The slant range of the link, in meters Returns: The path loss (free space loss) in dB @@ -67,7 +67,7 @@ def get_path_loss(self, slant_range) -> float: return 20 * math.log10(4 * math.pi * slant_range / self.wavelength) - def get_max_atmospheric_loss(self, min_elevation_angle) -> float: + def get_max_atmospheric_loss(self, min_elevation_angle: float) -> float: """Gets the maximal atmospheric loss for a link. Args: @@ -80,11 +80,11 @@ def get_max_atmospheric_loss(self, min_elevation_angle) -> float: return self.zenith_atmospheric_attenuation / math.sin(min_elevation_angle * math.pi / 180) - def get_bitrate(self, slant_range, min_elevation_angle) -> float: + def get_bitrate(self, slant_range: float, min_elevation_angle: float) -> float: """Gets the bitrate for a link based on current slant range and minimum elevation angle. Args: - slant_range (int): The slant range of the link, in meters + slant_range (float): The slant range of the link, in meters min_elevation_angle (float): The minimum elevation angle for this receiver, in degrees Returns: diff --git a/paseos/communication/radio_receiver_model.py b/paseos/communication/radio_receiver_model.py index b0f45e9..936c54d 100644 --- a/paseos/communication/radio_receiver_model.py +++ b/paseos/communication/radio_receiver_model.py @@ -9,20 +9,20 @@ class RadioReceiverModel(ReceiverModel): def __init__( self, - line_losses: int, - polarization_loss: int , - noise_temperature: int, - antenna_diameter: int = 0, - antenna_gain: int = 0 + line_losses: float, + polarization_loss: float, + noise_temperature: float, + antenna_diameter: float = 0, + antenna_gain: float = 0 ) -> None: """Initializes the model. Args: - line_losses (int): The line losses of the receiver, in dB. - polarization_loss (int): The polarization losses of the receiver, in dB. - noise_temperature (int): The noise temperature of the receiver, in K. - antenna_diameter (int): The diameter of the antenna, in m. Either this or the gain needs to be given. - antenna_gain (int): The gain of the antenna, either this or the diameter needs to be given so that gain can be determined. + line_losses (float): The line losses of the receiver, in dB. + polarization_loss (float): The polarization losses of the receiver, in dB. + noise_temperature (float): The noise temperature of the receiver, in K. + antenna_diameter (float): The diameter of the antenna, in m. Either this or the gain needs to be given. + antenna_gain (float): The gain of the antenna, either this or the diameter needs to be given so that gain can be determined. """ @@ -32,13 +32,13 @@ def __init__( logger.debug("Initializing radio receiver model.") self.polarization_loss = polarization_loss # in dB - self.noise_temperature = 10 * math.log10(noise_temperature) # in dBK + self.noise_temperature = 10 * math.log10(noise_temperature) # in dBK - def set_gain(self, wavelength): + def set_gain(self, wavelength: float = 0) -> None: """Sets gain for a receiver, based on the given gain, or antenna diameter and wavelength. Args: - wavelength (int): The wavelength of the link, in meters + wavelength (float): The wavelength of the link, in meters """ if self.antenna_gain == 0: self.antenna_gain = calc_radio_gain_from_wavelength_diameter(wavelength, self.antenna_diameter, 1) \ No newline at end of file diff --git a/paseos/communication/radio_transmitter_model.py b/paseos/communication/radio_transmitter_model.py index 6730b9e..a201e4e 100644 --- a/paseos/communication/radio_transmitter_model.py +++ b/paseos/communication/radio_transmitter_model.py @@ -3,50 +3,53 @@ from ..utils.gain_calc import calc_radio_gain_from_wavelength_diameter from .transmitter_model import TransmitterModel + class RadioTransmitterModel(TransmitterModel): """This class defines a radio transmitter model.""" def __init__( - self, - input_power: int, - power_efficiency: float, - antenna_efficiency: float, - line_losses: float, - point_losses: float, - antenna_gain: float = 0, - antenna_diameter: float = 0 + self, + input_power: float, + power_efficiency: float, + antenna_efficiency: float, + line_losses: float, + point_losses: float, + antenna_gain: float = 0, + antenna_diameter: float = 0 ) -> None: """Initializes the model. Args: - input_power (int): Input power into the signal amplifier, in W. + input_power (float): Input power into the signal amplifier, in W. power_efficiency (float): The power efficiency of the signal amplifier, determines the output power. antenna_efficiency (float): The efficiency of the antenna. - line_losses (int): The line losses of the transmitter, in dB. - point_losses (int): The pointing losses of the transmitter, in dB. - antenna_gain (int): The gain of the antenna, either this or the diameter needs to be given so that gain can be determined. - antenna_diameter (int): The diameter of the antenna, in m. Either this or the gain needs to be given. - full_angle_divergence (int): the full angle divergence of the transmit beam. For optical systems. - antenna_type (str): Antenna type, currently only parabolic is implemented. + line_losses (float): The line losses of the transmitter, in dB. + point_losses (float): The pointing losses of the transmitter, in dB. + antenna_gain (float): The gain of the antenna, either this or the diameter needs to be given so that gain + can be determined. + antenna_diameter (float): The diameter of the antenna, in m. Either this or the gain needs to be given. """ - super().__init__(input_power, power_efficiency, antenna_efficiency, line_losses, point_losses, antenna_gain, antenna_diameter) + super().__init__(input_power, power_efficiency, antenna_efficiency, line_losses, point_losses, antenna_gain, + antenna_diameter) assert antenna_gain > 0 or antenna_diameter > 0, "Antenna gain or antenna diameter needs to be higher than 0." - assert not (antenna_diameter != 0 and antenna_gain != 0), "Only set one of antenna gain and antenna diameter, not both." + assert not ( + antenna_diameter != 0 and antenna_gain != 0), ("Only set one of antenna gain and " + "antenna diameter, not both.") self.input_power = input_power self.power_efficiency = power_efficiency - self.output_power = 10 * math.log10(input_power * power_efficiency) # dBW + self.output_power = 10 * math.log10(input_power * power_efficiency) # dBW logger.debug("Initializing radio transmitter model.") - - def set_gain(self, wavelength): + def set_gain(self, wavelength: float = 0) -> None: """Sets gain for a transmitter, based on the given gain, or antenna diameter and wavelength. Args: - wavelength (int): The wavelength of the link, in meters + wavelength (float): The wavelength of the link, in meters """ if self.antenna_gain == 0: - self.antenna_gain = calc_radio_gain_from_wavelength_diameter(wavelength, self.antenna_diameter, self.antenna_efficiency) - + self.antenna_gain = calc_radio_gain_from_wavelength_diameter(wavelength, self.antenna_diameter, + self.antenna_efficiency) + self.set_EIRP() diff --git a/paseos/communication/receiver_model.py b/paseos/communication/receiver_model.py index 08edf0b..b7387d1 100644 --- a/paseos/communication/receiver_model.py +++ b/paseos/communication/receiver_model.py @@ -1,30 +1,34 @@ from loguru import logger + class ReceiverModel: """This class defines a receiver model.""" def __init__( - self, - line_losses: int, - antenna_diameter: int = 0, - antenna_gain: int = 0 + self, + line_losses: float, + antenna_diameter: float = 0, + antenna_gain: float = 0 ) -> None: """Initializes the model. Args: - line_losses (int): The line losses of the receiver, in dB. - antenna_diameter (int): The diameter of the antenna, in m. Either this or the gain needs to be given. - antenna_gain (int): The gain of the antenna, either this or the diameter needs to be given so that gain can be determined. + line_losses (float): The line losses of the receiver, in dB. + antenna_diameter (float): The diameter of the antenna, in m. Either this or the gain needs to be given. + antenna_gain (float): The gain of the antenna, either this or the diameter needs to be given so that gain + can be determined. """ assert line_losses >= 0, "Line losses needs to be 0 or higher." assert antenna_gain > 0 or antenna_diameter > 0, "Antenna gain or antenna diameter needs to be higher than 0." - assert not (antenna_diameter != 0 and antenna_gain != 0), "Only set one of antenna gain and antenna diameter, not both." + assert not ( + antenna_diameter != 0 and antenna_gain != 0), ("Only set one of antenna gain and " + "antenna diameter, not both.") logger.debug("Initializing receiver model.") - self.line_losses = line_losses # in dB - self.antenna_diameter = antenna_diameter # in m - self.antenna_gain = antenna_gain # in dB - - def set_gain(self): - pass \ No newline at end of file + self.line_losses = line_losses # in dB + self.antenna_diameter = antenna_diameter # in m + self.antenna_gain = antenna_gain # in dB + + def set_gain(self, wavelength: float = 0) -> None: + pass diff --git a/paseos/communication/transmitter_model.py b/paseos/communication/transmitter_model.py index 21f1251..fd7abfd 100644 --- a/paseos/communication/transmitter_model.py +++ b/paseos/communication/transmitter_model.py @@ -6,25 +6,25 @@ class TransmitterModel: def __init__( self, - input_power: int, + input_power: float, power_efficiency: float, antenna_efficiency: float, - line_losses: int, - point_losses: int, - antenna_gain: int = 0, - antenna_diameter: int = 0 + line_losses: float, + point_losses: float, + antenna_gain: float = 0, + antenna_diameter: float = 0 ) -> None: """Initializes the model. Args: - input_power (int): Input power into the signal amplifier, in W. + input_power (float): Input power into the signal amplifier, in W. power_efficiency (float): The power efficiency of the signal amplifier, determines the output power. antenna_efficiency (float): The efficiency of the antenna. - line_losses (int): The line losses of the transmitter, in dB. - point_losses (int): The pointing losses of the transmitter, in dB. - antenna_gain (int): The gain of the antenna, either this or the diameter needs to be given so that gain + line_losses (float): The line losses of the transmitter, in dB. + point_losses (float): The pointing losses of the transmitter, in dB. + antenna_gain (float): The gain of the antenna, either this or the diameter needs to be given so that gain can be determined. - antenna_diameter (int): The diameter of the antenna, in m. Either this or the gain needs to be given. + antenna_diameter (float): The diameter of the antenna, in m. Either this or the gain needs to be given. """ assert input_power > 0, "Input power needs to be higher than 0." assert 0 < power_efficiency <= 1, "Power efficiency should be between 0 and 1." @@ -41,14 +41,14 @@ def __init__( self.point_losses = point_losses self.active = False - def set_EIRP(self): + def set_EIRP(self) -> None: """Sets the Effective Isotropic Radiated Power (EIRP) for a transmitter.""" self.EIRP = self.output_power - self.line_losses - self.point_losses + self.antenna_gain - def set_gain(self): + def set_gain(self) -> None: pass - def set_active(self, state: bool): + def set_active(self, state: bool) -> None: """Sets the active state of the transmitter. Args: diff --git a/paseos/utils/gain_calc.py b/paseos/utils/gain_calc.py index 1101c8a..3913448 100644 --- a/paseos/utils/gain_calc.py +++ b/paseos/utils/gain_calc.py @@ -3,12 +3,13 @@ from skyfield.api import load -def calc_radio_gain_from_wavelength_diameter(wavelength, antenna_diameter, antenna_efficiency): +def calc_radio_gain_from_wavelength_diameter(wavelength: float, antenna_diameter: float, antenna_efficiency: float) -> float: """Calculates antenna gain (directivity) based on wavelength and diameter, valid for parabolic antennas. Args: wavelength (float): The wavelength of the signal, in meters. antenna_diameter (int): The diameter of the antenna, in meters. + antenna_efficiency (float): The antenna efficiency Returns: The antenna gain (directivity) in dB @@ -19,12 +20,13 @@ def calc_radio_gain_from_wavelength_diameter(wavelength, antenna_diameter, anten return 10 * math.log10(antenna_efficiency * (math.pi * antenna_diameter / wavelength) ** 2) -def calc_optical_gain_from_wavelength_diameter(wavelength, antenna_diameter, antenna_efficiency): +def calc_optical_gain_from_wavelength_diameter(wavelength: float, antenna_diameter: float, antenna_efficiency: float) -> float: """Calculates antenna gain (directivity) based on wavelength and diameter, valid for parabolic antennas. Args: wavelength (float): The wavelength of the signal, in meters. - antenna_diameter (int): The diameter of the antenna, in meters. + antenna_diameter (float): The diameter of the antenna, in meters. + antenna_efficiency (float): The antenna efficiency Returns: The antenna gain (directivity) in dB diff --git a/paseos/utils/link_budget_calc.py b/paseos/utils/link_budget_calc.py index cf79e43..46cce39 100644 --- a/paseos/utils/link_budget_calc.py +++ b/paseos/utils/link_budget_calc.py @@ -1,10 +1,7 @@ -import math import pykep as pk import os import numpy as np -from skyfield.units import AU_M from skyfield.api import load -from skyfield.vectorlib import VectorFunction from .sky_field_sky_coordinate import SkyfieldSkyCoordinate from ..actors.spacecraft_actor import SpacecraftActor from ..actors.ground_station_actor import GroundstationActor @@ -14,11 +11,8 @@ _SKYFIELD_EARTH = load(_SKYFIELD_EARTH_PATH)["earth"] - - - def calc_dist_and_alt_angle_spacecraft_ground(spacecraft_actor, ground_station_actor, epoch: pk.epoch) -> ( -float, float): + float, float): """Calculates distance and elevation angle based on spacecraft and ground station positions. Args: @@ -68,7 +62,7 @@ def calc_dist_and_alt_angle_spacecraft_spacecraft(local_actor, known_actor, epoc distance = np.sqrt( (local_actor_pos[0] - other_actor_pos[0]) ** 2 + (local_actor_pos[1] - other_actor_pos[1]) ** 2 + ( - local_actor_pos[2] - other_actor_pos[2]) ** 2) + local_actor_pos[2] - other_actor_pos[2]) ** 2) altitude_angle = 0 return distance, altitude_angle @@ -86,10 +80,9 @@ def calc_dist_and_alt_angle(local_actor, known_actor, epoch: pk.epoch): distance, elevation (float, float): the distance in m and the elevation angle in degrees. """ - # return None - if (isinstance(local_actor, SpacecraftActor) and isinstance(known_actor, GroundstationActor)): + if isinstance(local_actor, SpacecraftActor) and isinstance(known_actor, GroundstationActor): return calc_dist_and_alt_angle_spacecraft_ground(local_actor, known_actor, epoch) - elif (isinstance(local_actor, SpacecraftActor) and isinstance(known_actor, SpacecraftActor)): + elif isinstance(local_actor, SpacecraftActor) and isinstance(known_actor, SpacecraftActor): return calc_dist_and_alt_angle_spacecraft_spacecraft(local_actor, known_actor, epoch) else: print("No suitable types for distance calculations.")