From f260660f6787021f109329797074e01320ec9ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20G=C3=B3mez?= Date: Mon, 26 Jun 2023 11:55:12 +0200 Subject: [PATCH 1/2] - Fixed altitude being a property - Changed custom quantity to info instead of warning --- paseos/actors/base_actor.py | 23 ++++++++++++++++++----- paseos/thermal/thermal_model.py | 4 ++-- paseos/utils/operations_monitor.py | 18 ++++++++---------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/paseos/actors/base_actor.py b/paseos/actors/base_actor.py index 705ac35d..5543cd67 100644 --- a/paseos/actors/base_actor.py +++ b/paseos/actors/base_actor.py @@ -232,7 +232,6 @@ def discharge(self, consumption_rate_in_W: float, duration_in_s: float): """ pass - @property def altitude( self, t0: pk.epoch = None, @@ -262,10 +261,18 @@ def get_position(self, epoch: pk.epoch): Returns: np.array: [x,y,z] in meters """ - logger.trace("Computing " + self._orbital_parameters.name + " position at time " + str(epoch.mjd2000) + " (mjd2000).") + logger.trace( + "Computing " + + self._orbital_parameters.name + + " position at time " + + str(epoch.mjd2000) + + " (mjd2000)." + ) if self._orbital_parameters is not None and self._position is not None: - raise ValueError("Ambiguous position definition. Either set an orbit OR position with ActorBuilder.") + raise ValueError( + "Ambiguous position definition. Either set an orbit OR position with ActorBuilder." + ) # If the actor has no orbit, return position if self._orbital_parameters is None: @@ -290,10 +297,16 @@ def get_position_velocity(self, epoch: pk.epoch): np.array: [x,y,z] in meters """ if self._orbital_parameters is None: - raise NotImplementedError("No suitable way added to determine actor velocity. Set an orbit with ActorBuilder.") + raise NotImplementedError( + "No suitable way added to determine actor velocity. Set an orbit with ActorBuilder." + ) logger.trace( - "Computing " + self._orbital_parameters.name + " position / velocity at time " + str(epoch.mjd2000) + " (mjd2000)." + "Computing " + + self._orbital_parameters.name + + " position / velocity at time " + + str(epoch.mjd2000) + + " (mjd2000)." ) pos, vel = self._orbital_parameters.eph(epoch) self._previous_position = pos diff --git a/paseos/thermal/thermal_model.py b/paseos/thermal/thermal_model.py index c9c59aba..dcb66749 100644 --- a/paseos/thermal/thermal_model.py +++ b/paseos/thermal/thermal_model.py @@ -139,7 +139,7 @@ def _compute_body_view_from_actor(self) -> None: Returns: float: constant from above defined EQs. """ - h = self._actor.altitude / self._body_radius + h = self._actor.altitude() / self._body_radius return 1.0 / (h * h) def _compute_solar_input(self): @@ -205,7 +205,7 @@ def update_temperature(self, dt: float, current_power_consumption: float = 0): logger.debug(f"Actor's old temperature was {self._actor_temperature_in_K}.") logger.trace(f"Actor in eclipse: {self._actor.is_in_eclipse()}") - logger.trace(f"Actor altitude: {self._actor.altitude}") + logger.trace(f"Actor altitude: {self._actor.altitude()}") self._actor_temperature_in_K = self._actor_temperature_in_K + ( dt * total_change_in_W diff --git a/paseos/utils/operations_monitor.py b/paseos/utils/operations_monitor.py index 02875d48..51850e47 100644 --- a/paseos/utils/operations_monitor.py +++ b/paseos/utils/operations_monitor.py @@ -37,17 +37,17 @@ def __getitem__(self, item): item (str): Name of item. Available are "timesteps","current_activity","state_of_charge", "is_in_eclipse","known_actors","position","velocity","temperature" """ - assert item in (list(self._log.keys()) + list(self._log.custom_properties.keys())), ( - f'Untracked quantity. Available are {self._log.keys() + self._log.custom_properties.keys()}' - ) + assert item in ( + list(self._log.keys()) + list(self._log.custom_properties.keys()) + ), f"Untracked quantity. Available are {self._log.keys() + self._log.custom_properties.keys()}" if item in self._log.custom_properties.keys(): return self._log.custom_properties[item] return self._log[item] def plot(self, item): - assert item in (list(self._log.keys()) + list(self._log.custom_properties.keys())), ( - f'Untracked quantity. Available are {self._log.keys() + self._log.custom_properties.keys()}' - ) + assert item in ( + list(self._log.keys()) + list(self._log.custom_properties.keys()) + ), f"Untracked quantity. Available are {self._log.keys() + self._log.custom_properties.keys()}" if item in self._log.custom_properties.keys(): values = self._log.custom_properties[item] else: @@ -70,9 +70,7 @@ def log( known_actors (list): List of names of the known actors. """ logger.trace("Logging iteration") - assert local_actor.name == self._actor_name, ( - "Expected actor's name was" + self._actor_name - ) + assert local_actor.name == self._actor_name, "Expected actor's name was" + self._actor_name self._log.timesteps.append(local_actor.local_time.mjd2000 * pk.DAY2SEC) self._log.current_activity.append(local_actor.current_activity) self._log.position.append(local_actor._previous_position) @@ -95,7 +93,7 @@ def log( # Track all custom properties for key, value in local_actor.custom_properties.items(): if key not in self._log.custom_properties.keys(): - logger.warning(f"Property {key} was not tracked beforem, adding now.") + logger.info(f"Property {key} was not tracked beforem, adding now.") self._log.custom_properties[key] = [] self._log.custom_properties[key].append(value) From 03a7a999ce0701990edcf5ba357bd9e3eec55de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20G=C3=B3mez?= Date: Tue, 27 Jun 2023 11:53:10 +0200 Subject: [PATCH 2/2] renamed altitude --- paseos/actors/base_actor.py | 2 +- paseos/thermal/thermal_model.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/paseos/actors/base_actor.py b/paseos/actors/base_actor.py index 5543cd67..d72d0fd7 100644 --- a/paseos/actors/base_actor.py +++ b/paseos/actors/base_actor.py @@ -232,7 +232,7 @@ def discharge(self, consumption_rate_in_W: float, duration_in_s: float): """ pass - def altitude( + def get_altitude( self, t0: pk.epoch = None, ) -> float: diff --git a/paseos/thermal/thermal_model.py b/paseos/thermal/thermal_model.py index dcb66749..804556e8 100644 --- a/paseos/thermal/thermal_model.py +++ b/paseos/thermal/thermal_model.py @@ -139,7 +139,7 @@ def _compute_body_view_from_actor(self) -> None: Returns: float: constant from above defined EQs. """ - h = self._actor.altitude() / self._body_radius + h = self._actor.get_altitude() / self._body_radius return 1.0 / (h * h) def _compute_solar_input(self): @@ -205,7 +205,7 @@ def update_temperature(self, dt: float, current_power_consumption: float = 0): logger.debug(f"Actor's old temperature was {self._actor_temperature_in_K}.") logger.trace(f"Actor in eclipse: {self._actor.is_in_eclipse()}") - logger.trace(f"Actor altitude: {self._actor.altitude()}") + logger.trace(f"Actor altitude: {self._actor.get_altitude()}") self._actor_temperature_in_K = self._actor_temperature_in_K + ( dt * total_change_in_W