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

Create readme #71

Merged
merged 52 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
290b61d
First version of ground station implementation
gomezzz Dec 1, 2022
826c429
Merge branch 'main' into ground-station-implementation
gomezzz Dec 1, 2022
d63db93
Restructured things, small bugfixes
gomezzz Dec 1, 2022
4cbbe41
Adding skyfield requirement
gomezzz Dec 1, 2022
f57cf40
Flaking
gomezzz Dec 1, 2022
a43925e
Added first instance of README.
Dec 9, 2022
486e676
Improving README.
Dec 9, 2022
4bbe0d6
Applying changes suggested in review
gomezzz Dec 12, 2022
b3d8be1
Fixed trailing white space. Flake be my guide
gomezzz Dec 12, 2022
017e38d
WIP Improving README.
Dec 12, 2022
6316ca7
Merge branch 'ground-station-implementation' into create_README
Dec 12, 2022
d671614
Added missing GIF.
Dec 12, 2022
578b9ea
Fixing small name bug.
Dec 12, 2022
46cc5a6
Update README.md
GabrieleMeoni Dec 13, 2022
e925e93
Update README.md
GabrieleMeoni Dec 13, 2022
dc73034
Update README.md
GabrieleMeoni Dec 13, 2022
b67aa32
Update README.md
GabrieleMeoni Dec 13, 2022
be4babb
Update README.md
GabrieleMeoni Dec 13, 2022
62d2a7c
Update README.md
GabrieleMeoni Dec 13, 2022
c3b4ef3
Update README.md
GabrieleMeoni Dec 13, 2022
c42bfe6
Updated README.
Dec 13, 2022
9040491
Updating README.
Dec 13, 2022
2f7b840
Added OperationsMonitor
gomezzz Dec 14, 2022
80badd4
Added test for operations monitor
gomezzz Dec 14, 2022
44d62bf
Added readme entry of status monitoring
gomezzz Dec 14, 2022
c956a7b
Update README.md
gomezzz Dec 15, 2022
a8063b8
Upadting readme to support single examples.
Dec 16, 2022
9e802ed
Corrected example of add other actors.
Dec 17, 2022
7daa15b
Merge branch 'create_README' into monitoring
gomezzz Dec 19, 2022
6b5ace5
Renamed variables
gomezzz Dec 19, 2022
7e45fca
Update README.md
GabrieleMeoni Dec 20, 2022
09a2ad7
Update README.md
GabrieleMeoni Dec 20, 2022
6444605
Update README.md
GabrieleMeoni Dec 20, 2022
6568971
Update README.md
GabrieleMeoni Dec 20, 2022
627e693
Update README.md
GabrieleMeoni Dec 20, 2022
16b6bce
Update README.md
GabrieleMeoni Dec 20, 2022
2aa197d
Update README.md
GabrieleMeoni Dec 20, 2022
03de28d
Added suggestions.
Dec 20, 2022
36b7d4d
Moving images to resources.
Dec 20, 2022
fb25ec3
Fixing small error.
Dec 20, 2022
5f1548f
Improved constraints image.
Dec 20, 2022
65ce98b
Removed missing `PASEOS` and converted into PASEOS.
Dec 20, 2022
428710a
Update README.md
GabrieleMeoni Dec 20, 2022
bd04a24
Update README.md
GabrieleMeoni Dec 20, 2022
e1a3e41
Update README.md
GabrieleMeoni Dec 20, 2022
f7ad578
Adding first corrections and first round of examples structure.
Dec 20, 2022
6ff8a86
Restructuring examples.
Dec 20, 2022
ee85021
Changing image format.
Dec 20, 2022
5657e75
Merge branch 'monitoring' into create_README
Dec 20, 2022
1b34f43
Fixing wrong merge.
Dec 20, 2022
8b29b4c
Fixing wrong links to output files.
Dec 20, 2022
50135f2
Fixing visualisation image position.
Dec 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,4 @@ my_notebooks
examples/Sentinel_2_example_notebook/Etna_00.tif
GabrieleMeoni marked this conversation as resolved.
Show resolved Hide resolved
examples/Sentinel_2_example_notebook/Mayon_02.tif
examples/Sentinel_2_example_notebook/La_Palma_02.tif
paseos/tests/de421.bsp
Binary file added PASEOS_constraints.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
416 changes: 398 additions & 18 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies:
- pytest-asyncio
- python
- scikit-spatial
- skyfield
- sphinx
- sphinx_rtd_theme
- toml
Expand Down
37 changes: 35 additions & 2 deletions paseos/actors/actor_builder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from loguru import logger
from dotmap import DotMap
import pykep as pk
from skyfield.api import wgs84

from .base_actor import BaseActor
from .spacecraft_actor import SpacecraftActor
Expand Down Expand Up @@ -44,8 +45,32 @@ def get_actor_scaffold(name: str, actor_type: object, epoch: pk.epoch):

return actor_type(name, epoch)

def set_ground_station_location(
actor: GroundstationActor,
latitude: float,
longitude: float,
elevation: float = 0,
):
"""Define the position of a ground station actor.

Args:
actor (GroundstationActor): Actor to update.
latitude (float): Latitude of the ground station in degrees.
longitude (float): Longitude of the ground station in degrees.
elevation (float): A distance specifying elevation above (positive)
or below (negative) the surface of the Earth
ellipsoid specified by the WSG84 model in meters. Defaults to 0.
"""
assert latitude >= -90 and latitude <= 90, "Latitude is -90 <= lat <= 90"
assert longitude >= -180 and longitude <= 180, "Longitude is -180 <= lat <= 180"
actor._skyfield_position = wgs84.latlon(
latitude_degrees=latitude,
longitude_degrees=longitude,
elevation_m=elevation,
)

def set_orbit(
actor: BaseActor,
actor: SpacecraftActor,
position,
velocity,
epoch: pk.epoch,
Expand All @@ -62,6 +87,10 @@ def set_orbit(
"""
# TODO Add checks for sensibility of orbit

assert isinstance(
actor, SpacecraftActor
), "Orbit only supported for SpacecraftActors"

actor._central_body = central_body
actor._orbital_parameters = pk.planet.keplerian(
epoch,
Expand All @@ -81,8 +110,12 @@ def set_position(actor: BaseActor, position: list):

Args:
actor (BaseActor): Actor set the position on.
position (list): [x,y,z] position.
position (list): [x,y,z] position for SpacecraftActor.
"""
assert not isinstance(
actor, GroundstationActor
), "Position changing not supported for GroundstationActors"

assert len(position) == 3, "Position has to be list of 3 floats."
assert all(
[isinstance(val, float) for val in position]
Expand Down
37 changes: 33 additions & 4 deletions paseos/actors/base_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class BaseActor(ABC):
# Orbital parameters of the actor, stored in a pykep planet object
_orbital_parameters = None

# Position if not defined by orbital parameters
_position = None

# Earth as a sphere (for now)
# TODO replace this in the future depending on central body
# Note that this needs to be specified in solar reference frame for now
Expand Down Expand Up @@ -88,7 +91,7 @@ def _check_init_value_sensibility(
assert len(velocity) == 3, "Velocity has to have 3 elements (vx,vy,vz)"

def __str__(self):
return self._orbital_parameters.name
return self.name

def set_time(self, t: pk.epoch):
"""Updates the local time of the actor.
Expand Down Expand Up @@ -118,6 +121,14 @@ def discharge(self, consumption_rate_in_W: float, duration_in_s: float):
pass

def get_position(self, epoch: pk.epoch):
"""Compute the position of this actor at a specific time. Requires orbital parameters or position set.

Args:
epoch (pk.epoch): Time as pykep epoch

Returns:
np.array: [x,y,z] in meters
"""
logger.trace(
"Computing "
+ self._orbital_parameters.name
Expand All @@ -136,13 +147,21 @@ def get_position(self, epoch: pk.epoch):
if self._position is not None:
return self._position
else:
return self._orbital_parameters.eph(epoch)
return self._orbital_parameters.eph(epoch)[0]

raise NotImplementedError(
"No suitable way added to determine actor position. Either set an orbit or position with ActorBuilder."
)

def get_position_velocity(self, epoch: pk.epoch):
"""Compute the position / velocity of this actor at a specific time. Requires orbital parameters set.

Args:
epoch (pk.epoch): Time as pykep epoch.

Returns:
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."
Expand All @@ -158,19 +177,29 @@ def get_position_velocity(self, epoch: pk.epoch):
return self._orbital_parameters.eph(epoch)

def is_in_line_of_sight(
self, other_actor: "BaseActor", epoch: pk.epoch, plot=False
self,
other_actor: "BaseActor",
epoch: pk.epoch,
minimum_altitude_angle: float = None,
plot=False,
):
"""Determines whether a position is in line of sight of this actor

Args:
other_actor (BaseActor): The actor to check line of sight with
epoch (pk,.epoch): Epoch at which to check the line of sight
minimum_altitude_angle(float): The altitude angle (in degree) at which the actor
has to be in relation to the surface, has to be between 0 and 90.
to be visible from this ground station. Has to be > 0 and < 90.
Only relevant if one of the actors is a ground station.
plot (bool): Whether to plot a diagram illustrating the positions.

Returns:
bool: true if in line-of-sight.
"""
return is_in_line_of_sight(self, other_actor, epoch, plot)
return is_in_line_of_sight(
self, other_actor, epoch, minimum_altitude_angle, plot
)

def is_in_eclipse(self, t: pk.epoch = None):
"""Checks if the actors is in eclipse at the specified time.
Expand Down
34 changes: 33 additions & 1 deletion paseos/actors/ground_station_actor.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
from loguru import logger
import pykep as pk
from skyfield.api import load

from paseos.actors.base_actor import BaseActor


class GroundstationActor(BaseActor):
"""This class models a groundstation actor."""

def __init__(self, name: str, epoch: pk.epoch) -> None:
# Ground station latitude / longitude
_skyfield_position = None

# Timescale object to convert from pykep epoch to skyfield time
_skyfield_timescale = load.timescale()

def __init__(
self,
name: str,
epoch: pk.epoch,
) -> None:
"""Constructor for a groundstation actor.

Args:
Expand All @@ -16,3 +27,24 @@ def __init__(self, name: str, epoch: pk.epoch) -> None:
"""
logger.trace("Instantiating GroundstationActor.")
super().__init__(name, epoch)

def get_position(self, epoch: pk.epoch):
"""Compute the position of this ground station at a specific time.
Positions are in J2000 geocentric reference frame, same reference frame as
for the spacecraft actors. Since the Earth is rotating, ground stations have
a non-constant position depending on time.

Args:
epoch (pk.epoch): Time as pykep epoch

Returns:
np.array: [x,y,z] in meters
"""
# Converting time to skyfield to use its API
t_skyfield = self._skyfield_timescale.tt_jd(epoch.jd)

# Getting ground station position, skyfield operates in GCRF frame
# which is technically more precise than the J2000 we use but we neglect this here
gcrf_position = self._skyfield_position.at(t_skyfield).position.m

return gcrf_position
Loading