Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #170

Merged
merged 2 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 19 additions & 6 deletions paseos/actors/base_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ def discharge(self, consumption_rate_in_W: float, duration_in_s: float):
"""
pass

@property
def altitude(
def get_altitude(
self,
t0: pk.epoch = None,
) -> float:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions paseos/thermal/thermal_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
18 changes: 8 additions & 10 deletions paseos/utils/operations_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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)

Expand Down