Skip to content

Commit

Permalink
feat: add more pass computation methods (#414)
Browse files Browse the repository at this point in the history
* feat: provide initial revolution number for Propagated model

* feat: fix tests

* feat: address feedback

* feat: all the things

* feat: fix from rebase

* feat: small fixes

* feat: clean up tests

* feat: address feedback

* feat: clean up the model method

* fix: tests

* feat: add support for backward propagation

* feat: propagate last step

* feat: re-order

* Apply suggestions from code review

Co-authored-by: Antoine Paletta <98616558+apaletta3@users.noreply.github.com>

* fix: typo

* feat: fix tests

* feat: fix tests

* feat: Antoines suggestions

---------

Co-authored-by: Antoine Paletta <98616558+apaletta3@users.noreply.github.com>
  • Loading branch information
vishwa2710 and apaletta3 authored Jun 26, 2024
1 parent 6a2e303 commit 6687920
Show file tree
Hide file tree
Showing 20 changed files with 937 additions and 302 deletions.
1 change: 1 addition & 0 deletions bindings/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ open-space-toolkit-core~=3.0
open-space-toolkit-io~=3.0
open-space-toolkit-mathematics~=3.0
open-space-toolkit-physics~=7.0
numpy~=1.26
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit(pybind11::module& a
arg("revolution_number"),
arg_v("step_duration", Duration::Minutes(10.0), "Duration.minutes(10.0)")
)
.def(
"get_passes_within_interval",
&Orbit::getPassesWithinInterval,
R"doc(
Get the passes within a given interval.
Args:
interval (Interval): The interval.
Returns:
list[Pass]: The passes.
)doc",
arg("interval")
)
.def(
"get_orbital_frame",
&Orbit::getOrbitalFrame,
Expand Down Expand Up @@ -374,7 +388,28 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit(pybind11::module& a
initial_revolution_number (Integer): The initial revolution number.
Returns:
list[tuple[int, Pass]]: List of index-pass pairs
list[tuple[int, Pass]]: List of index-pass pairs.
)doc"
)

.def_static(
"compute_passes_with_model",
&Orbit::ComputePassesWithModel,
arg("model"),
arg("start_instant"),
arg("end_instant"),
arg("initial_revolution_number"),
R"doc(
Compute passes with the given model for the provided interval.
Args:
model (orbit.Model): The model.
start_instant (Instant): The start instant.
end_instant (Instant): The end instant.
initial_revolution_number (int): The initial revolution number.
Returns:
list[Pass]: List of passes.
)doc"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,6 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Model_SGP4(pybind11
)doc"
)

.def(
"calculate_revolution_number_at",
&SGP4::calculateRevolutionNumberAt,
arg("instant"),
R"doc(
Calculate the revolution number of the `SGP4` model at a given instant.
Args:
instant (Instant): The instant.
Returns:
int: The revolution number.
)doc"
)

;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,5 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Model_Tabulated(pyb
arg("instants")
)

.def(
"calculate_revolution_number_at",
&Tabulated::calculateRevolutionNumberAt,
R"doc(
Calculate the revolution number of the `Tabulated` model at a given instant.
Args:
instant (Instant): The instant.
Returns:
int: The revolution number.
)doc",
arg("instant")
)

;
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Pass(pybind11::modu
)doc"
)
.def(
"get_interval",
&Pass::getInterval,
R"doc(
Get the interval of the pass. Undefined if the pass is not complete.
Returns:
Interval: The interval of the pass.
)doc"
)
.def(
"get_instant_at_ascending_node",
&Pass::accessInstantAtAscendingNode,
Expand Down
3 changes: 3 additions & 0 deletions bindings/python/test/trajectory/orbit/test_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def test_get_start_instant(self, pass_: Pass):
def test_get_end_instant(self, pass_: Pass):
assert pass_.get_end_instant() is not None

def test_get_interval(self, pass_: Pass):
assert pass_.get_interval() is not None

def test_get_instant_at_ascending_node(self, pass_: Pass):
assert pass_.get_instant_at_ascending_node() is not None

Expand Down
28 changes: 25 additions & 3 deletions bindings/python/test/trajectory/test_orbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,19 @@ def test_get_pass_with_revolution_number(self, orbit: Orbit):
assert isinstance(pass_, Pass)
assert pass_.is_defined()

assert orbit.get_pass_with_revolution_number(2, Duration.minutes(10.0)) is not None
assert (
orbit.get_pass_with_revolution_number(2, Duration.minutes(10.0)) is not None
)

def test_get_passes_within_interval(self, orbit: Orbit):
passes: list[Pass] = orbit.get_passes_within_interval(
Interval.closed(
Instant.date_time(DateTime(2018, 1, 1, 0, 0, 0), Scale.UTC),
Instant.date_time(DateTime(2018, 1, 1, 0, 10, 0), Scale.UTC),
)
)

assert len(passes) > 0

def test_undefined(self):
assert Orbit.undefined().is_defined() is False
Expand Down Expand Up @@ -169,6 +181,16 @@ def test_sun_synchronous(self, earth):
argument_of_latitude=Angle.degrees(50.0),
).is_defined()

def test_compute_passes(self, orbit: Orbit, states: list[State]):
passes: list[tuple[int, Pass]] = orbit.compute_passes(states, 1)
def test_compute_passes(self, states: list[State]):
passes: list[tuple[int, Pass]] = Orbit.compute_passes(states, 1)
assert passes is not None

def test_compute_passes_with_model(self, orbit: Orbit):
passes: list[tuple[int, Pass]] = Orbit.compute_passes_with_model(
model=orbit.access_kepler_model(),
start_instant=Instant.date_time(DateTime(2018, 1, 1, 0, 0, 0), Scale.UTC),
end_instant=Instant.date_time(DateTime(2018, 1, 1, 0, 10, 0), Scale.UTC),
initial_revolution_number=1,
)

assert len(passes) > 0
Loading

0 comments on commit 6687920

Please sign in to comment.