-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Trajectory constructor based on a ground strip (#441)
* feat: Trajectory constructor based on a ground strip * Apply suggestions from code review Co-authored-by: Pau Hebrero <65550121+phc1990@users.noreply.github.com> * feat: address feedback --------- Co-authored-by: Pau Hebrero <65550121+phc1990@users.noreply.github.com>
- Loading branch information
1 parent
96fc4a0
commit 57f7d7c
Showing
11 changed files
with
564 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,118 @@ | ||
# Apache License 2.0 | ||
|
||
import ostk.mathematics as mathematics | ||
|
||
import ostk.physics as physics | ||
|
||
import ostk.astrodynamics as astrodynamics | ||
|
||
RealInterval = mathematics.object.RealInterval | ||
Quaternion = mathematics.geometry.d3.transformation.rotation.Quaternion | ||
Length = physics.unit.Length | ||
Angle = physics.unit.Angle | ||
DateTime = physics.time.DateTime | ||
Scale = physics.time.Scale | ||
Duration = physics.time.Duration | ||
Instant = physics.time.Instant | ||
Transform = physics.coordinate.Transform | ||
Frame = physics.coordinate.Frame | ||
Axes = physics.coordinate.Axes | ||
DynamicProvider = physics.coordinate.frame.provider.Dynamic | ||
Environment = physics.Environment | ||
Earth = physics.environment.object.celestial.Earth | ||
Trajectory = astrodynamics.Trajectory | ||
Profile = astrodynamics.flight.Profile | ||
SatelliteSystem = astrodynamics.flight.system.SatelliteSystem | ||
Orbit = astrodynamics.trajectory.Orbit | ||
State = astrodynamics.trajectory.State | ||
Pass = astrodynamics.trajectory.orbit.Pass | ||
Kepler = astrodynamics.trajectory.orbit.model.Kepler | ||
COE = astrodynamics.trajectory.orbit.model.kepler.COE | ||
SGP4 = astrodynamics.trajectory.orbit.model.sgp4 | ||
Access = astrodynamics.Access | ||
|
||
|
||
def test_trajectory_undefined(): | ||
trajectory: Trajectory = Trajectory.undefined() | ||
|
||
assert trajectory is not None | ||
assert isinstance(trajectory, Trajectory) | ||
assert trajectory.is_defined() is False | ||
import pytest | ||
|
||
from ostk.physics.environment.object.celestial import Earth | ||
from ostk.physics.coordinate.spherical import LLA | ||
from ostk.physics.coordinate import Position | ||
from ostk.physics.coordinate import Frame | ||
from ostk.physics.time import Instant | ||
from ostk.physics.time import Duration | ||
from ostk.physics.unit import Derived | ||
|
||
from ostk.astrodynamics import Trajectory | ||
from ostk.astrodynamics.trajectory import State | ||
|
||
|
||
@pytest.fixture | ||
def start_lla() -> LLA: | ||
return LLA.vector([0.0, 0.0, 0.0]) | ||
|
||
|
||
@pytest.fixture | ||
def end_lla() -> LLA: | ||
return LLA.vector([1.0, 0.0, 0.0]) | ||
|
||
|
||
@pytest.fixture | ||
def start_instant() -> Instant: | ||
return Instant.J2000() | ||
|
||
|
||
@pytest.fixture | ||
def ground_speed() -> Derived: | ||
return Derived(7000.0, Derived.Unit.meter_per_second()) | ||
|
||
|
||
@pytest.fixture | ||
def earth() -> Earth: | ||
return Earth.WGS84() | ||
|
||
|
||
@pytest.fixture | ||
def instants() -> list[Instant]: | ||
return [Instant.J2000(), Instant.J2000() + Duration.seconds(10.0)] | ||
|
||
|
||
@pytest.fixture | ||
def position() -> Position: | ||
return Position.meters([0.0, 0.0, 0.0], Frame.ITRF()) | ||
|
||
|
||
@pytest.fixture | ||
def trajectory(position: Position) -> Trajectory: | ||
return Trajectory.position(position) | ||
|
||
|
||
@pytest.fixture | ||
def states(trajectory: Trajectory) -> list[State]: | ||
return trajectory.get_states_at( | ||
[Instant.J2000(), Instant.J2000() + Duration.seconds(10.0)] | ||
) | ||
|
||
|
||
class TestTrajectory: | ||
def test_trajectory(self, states: list[State]): | ||
assert Trajectory(states) is not None | ||
|
||
def test_is_defined(self, trajectory: Trajectory): | ||
assert trajectory.is_defined() | ||
|
||
def test_access_model(self, trajectory: Trajectory): | ||
assert trajectory.access_model() is not None | ||
|
||
def test_get_state_at(self, trajectory: Trajectory): | ||
assert trajectory.get_state_at(Instant.J2000()) is not None | ||
|
||
def test_get_states_at(self, trajectory: Trajectory): | ||
assert ( | ||
trajectory.get_states_at( | ||
[Instant.J2000(), Instant.J2000() + Duration.seconds(10.0)] | ||
) | ||
is not None | ||
) | ||
|
||
def test_trajectory_undefined(self): | ||
trajectory: Trajectory = Trajectory.undefined() | ||
|
||
assert trajectory is not None | ||
assert isinstance(trajectory, Trajectory) | ||
assert trajectory.is_defined() is False | ||
|
||
def test_trajectory_position(self, position: Position): | ||
trajectory: Trajectory = Trajectory.position(position) | ||
|
||
assert trajectory is not None | ||
|
||
def test_ground_strip( | ||
self, | ||
start_lla: LLA, | ||
end_lla: LLA, | ||
ground_speed: Derived, | ||
start_instant: Instant, | ||
earth: Earth, | ||
instants: list[Instant], | ||
): | ||
assert ( | ||
Trajectory.ground_strip( | ||
start_lla, end_lla, ground_speed, start_instant, earth | ||
) | ||
is not None | ||
) | ||
assert ( | ||
Trajectory.ground_strip(start_lla, end_lla, ground_speed, start_instant) | ||
is not None | ||
) | ||
|
||
assert Trajectory.ground_strip(start_lla, end_lla, instants, earth) is not None | ||
assert Trajectory.ground_strip(start_lla, end_lla, instants) is not None |
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
Oops, something went wrong.