-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactors environment summary serialization
- Loading branch information
1 parent
68e222e
commit 559bdd0
Showing
5 changed files
with
110 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from typing import Self | ||
from rocketpy.environment.environment import Environment as RocketPyEnvironment | ||
from rocketpy.utilities import get_instance_attributes | ||
from lib.models.environment import Env | ||
from lib.views.environment import EnvSummary | ||
|
||
|
||
class EnvironmentService(RocketPyEnvironment): | ||
|
||
@classmethod | ||
def from_env_model(cls, env: Env) -> Self: | ||
""" | ||
Get the rocketpy env object. | ||
Returns: | ||
RocketPyEnvironment | ||
""" | ||
rocketpy_env = cls( | ||
latitude=env.latitude, | ||
longitude=env.longitude, | ||
elevation=env.elevation, | ||
date=env.date, | ||
) | ||
rocketpy_env.set_atmospheric_model( | ||
type=env.atmospheric_model_type, file=env.atmospheric_model_file | ||
) | ||
return rocketpy_env | ||
|
||
def get_env_summary(self) -> EnvSummary: | ||
""" | ||
Get the summary of the environment. | ||
Returns: | ||
EnvSummary | ||
""" | ||
|
||
attributes = get_instance_attributes(self) | ||
env_summary = EnvSummary(**attributes) | ||
return env_summary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters