-
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: finish tests, docstrings and bindings
- Loading branch information
1 parent
8e2f4fd
commit b0d0586
Showing
17 changed files
with
513 additions
and
110 deletions.
There are no files selected for viewing
52 changes: 30 additions & 22 deletions
52
...src/OpenSpaceToolkitAstrodynamicsPy/Trajectory/Orbit/Models/Kepler/BrouwerLyddaneMean.cpp
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,59 +1,67 @@ | ||
/// Apache License 2.0 | ||
|
||
#include <OpenSpaceToolkit/Physics/Units/Derived/Angle.hpp> | ||
|
||
#include <OpenSpaceToolkit/Astrodynamics/Trajectory/Orbit/Models/Kepler/BrouwerLyddaneMean.hpp> | ||
|
||
using namespace pybind11; | ||
|
||
using ostk::core::types::Real; | ||
using ostk::physics::units::Length; | ||
using ostk::physics::units::Angle; | ||
|
||
using ostk::astro::trajectory::orbit::models::kepler::COE; | ||
using ostk::astro::trajectory::orbit::models::kepler::BrouwerLyddaneMean; | ||
|
||
// Trampoline class for virtual member functions | ||
class PyBrouwerLyddaneMean : public BrouwerLyddaneMean | ||
{ | ||
public: | ||
using BrouwerLyddaneMean::BrouwerLyddaneMean; | ||
|
||
// Trampoline (need one for each virtual function) | ||
|
||
Angle getMeanAnomaly() const | ||
{ | ||
PYBIND11_OVERRIDE_PURE_NAME( | ||
Angle, BrouwerLyddaneMean, "get_mean_anomaly", getMeanAnomaly | ||
); | ||
PYBIND11_OVERRIDE_NAME(Angle, BrouwerLyddaneMean, "get_mean_anomaly", getMeanAnomaly); | ||
} | ||
|
||
Angle getTrueAnomaly() const | ||
{ | ||
PYBIND11_OVERRIDE_PURE_NAME( | ||
Angle, BrouwerLyddaneMean, "get_true_anomaly", getTrueAnomaly | ||
); | ||
PYBIND11_OVERRIDE_NAME(Angle, BrouwerLyddaneMean, "get_true_anomaly", getTrueAnomaly); | ||
} | ||
|
||
Angle getEccentricAnomaly() const | ||
{ | ||
PYBIND11_OVERRIDE_PURE_NAME( | ||
Angle, BrouwerLyddaneMean, "get_eccentric_anomaly", getEccentricAnomaly | ||
); | ||
PYBIND11_OVERRIDE_NAME(Angle, BrouwerLyddaneMean, "get_eccentric_anomaly", getEccentricAnomaly); | ||
} | ||
|
||
COE toCOE() const | ||
{ | ||
PYBIND11_OVERRIDE_PURE_NAME( | ||
COE, BrouwerLyddaneMean, "to_coe", toCOE | ||
); | ||
PYBIND11_OVERRIDE_PURE_NAME(COE, BrouwerLyddaneMean, "to_coe", toCOE); | ||
} | ||
} ; | ||
|
||
}; | ||
|
||
inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_BrouwerLyddaneMean(pybind11::module& aModule) | ||
{ | ||
using namespace pybind11; | ||
|
||
using ostk::core::types::Real; | ||
using ostk::core::types::Shared; | ||
using ostk::physics::units::Length; | ||
|
||
class_<BrouwerLyddaneMean, PyBrouwerLyddaneMean, COE, Shared<BrouwerLyddaneMean>> brouwerLyddaneMean(aModule, "BrouwerLyddaneMean"); | ||
class_<BrouwerLyddaneMean, PyBrouwerLyddaneMean, COE> brouwerLyddaneMean(aModule, "BrouwerLyddaneMean"); | ||
|
||
brouwerLyddaneMean | ||
|
||
.def("get_cartesian_state", &BrouwerLyddaneMean::getCartesianState, arg("gravitational_parameter"), arg("frame")); | ||
.def( | ||
init<const Length&, const Real&, const Angle&, const Angle&, const Angle&, const Angle&>(), | ||
arg("semi_major_axis"), | ||
arg("eccentricity"), | ||
arg("inclination"), | ||
arg("raan"), | ||
arg("aop"), | ||
arg("mean_anomaly") | ||
) | ||
|
||
.def("get_mean_anomaly", &BrouwerLyddaneMean::getMeanAnomaly) | ||
.def("get_true_anomaly", &BrouwerLyddaneMean::getTrueAnomaly) | ||
.def("get_eccentric_anomaly", &BrouwerLyddaneMean::getEccentricAnomaly) | ||
.def( | ||
"get_cartesian_state", &BrouwerLyddaneMean::getCartesianState, arg("gravitational_parameter"), arg("frame") | ||
); | ||
} |
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
65 changes: 65 additions & 0 deletions
65
bindings/python/test/trajectory/orbit/models/kepler/test_brouwer_lyddane_mean.py
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,65 @@ | ||
# Apache License 2.0 | ||
|
||
import pytest | ||
|
||
from ostk.physics.units import Length | ||
from ostk.physics.units import Angle | ||
|
||
from ostk.astrodynamics.trajectory.orbit.models.kepler import BrouwerLyddaneMean | ||
|
||
|
||
@pytest.fixture | ||
def semi_major_axis() -> Length: | ||
return Length.kilometers(7000.0) | ||
|
||
|
||
@pytest.fixture | ||
def eccentricity() -> float: | ||
return 1e-3 | ||
|
||
|
||
@pytest.fixture | ||
def inclination() -> Angle: | ||
return Angle.degrees(35.0) | ||
|
||
|
||
@pytest.fixture | ||
def raan() -> Angle: | ||
return Angle.degrees(40.0) | ||
|
||
|
||
@pytest.fixture | ||
def aop() -> Angle: | ||
return Angle.degrees(50.0) | ||
|
||
|
||
@pytest.fixture | ||
def mean_anomaly() -> Angle: | ||
return Angle.degrees(60.0) | ||
|
||
|
||
@pytest.fixture | ||
def brouwer_lyddane_mean( | ||
semi_major_axis, eccentricity, inclination, raan, aop, mean_anomaly | ||
): | ||
class BrouwerLyddaneMeanMock(BrouwerLyddaneMean): | ||
def __init__( | ||
self, semi_major_axis, eccentricity, inclination, raan, aop, mean_anomaly | ||
): | ||
super().__init__( | ||
semi_major_axis, eccentricity, inclination, raan, aop, mean_anomaly | ||
) | ||
|
||
def to_coe(): | ||
return 0.0 | ||
|
||
return BrouwerLyddaneMeanMock( | ||
semi_major_axis, eccentricity, inclination, raan, aop, mean_anomaly | ||
) | ||
|
||
|
||
class TestBrouwerLyddaneMean: | ||
def test_getters(self, brouwer_lyddane_mean: BrouwerLyddaneMean): | ||
assert isinstance(brouwer_lyddane_mean.get_mean_anomaly(), Angle) | ||
assert isinstance(brouwer_lyddane_mean.get_true_anomaly(), Angle) | ||
assert isinstance(brouwer_lyddane_mean.get_eccentric_anomaly(), Angle) |
84 changes: 84 additions & 0 deletions
84
bindings/python/test/trajectory/orbit/models/kepler/test_brouwer_lyddane_mean_long.py
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,84 @@ | ||
# Apache License 2.0 | ||
|
||
import pytest | ||
|
||
from ostk.physics.units import Length | ||
from ostk.physics.units import Angle | ||
from ostk.physics.environment.gravitational import Earth | ||
|
||
from ostk.physics.coordinate import Frame | ||
from ostk.physics.coordinate import Position | ||
from ostk.physics.coordinate import Velocity | ||
|
||
from ostk.astrodynamics.trajectory.orbit.models.kepler import BrouwerLyddaneMeanLong | ||
|
||
|
||
@pytest.fixture | ||
def semi_major_axis() -> Length: | ||
return Length.kilometers(7000.0) | ||
|
||
|
||
@pytest.fixture | ||
def eccentricity() -> float: | ||
return 1e-3 | ||
|
||
|
||
@pytest.fixture | ||
def inclination() -> Angle: | ||
return Angle.degrees(35.0) | ||
|
||
|
||
@pytest.fixture | ||
def raan() -> Angle: | ||
return Angle.degrees(40.0) | ||
|
||
|
||
@pytest.fixture | ||
def aop() -> Angle: | ||
return Angle.degrees(50.0) | ||
|
||
|
||
@pytest.fixture | ||
def mean_anomaly() -> Angle: | ||
return Angle.degrees(60.0) | ||
|
||
|
||
@pytest.fixture | ||
def cartesian_state() -> tuple[Position, Velocity]: | ||
return ( | ||
Position.meters( | ||
[6596407.223662058, 2281266.582975321, -10540.61521486086], Frame.GCRF() | ||
), | ||
Velocity.meters_per_second( | ||
[337.7269674273224, -969.7192552349448, 7488.702816619139], Frame.GCRF() | ||
), | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def gravitational_parameter(): | ||
return Earth.EGM2008.gravitational_parameter | ||
|
||
|
||
@pytest.fixture | ||
def brouwer_lyddane_mean_long( | ||
semi_major_axis, eccentricity, inclination, raan, aop, mean_anomaly | ||
): | ||
return BrouwerLyddaneMeanLong( | ||
semi_major_axis, eccentricity, inclination, raan, aop, mean_anomaly | ||
) | ||
|
||
|
||
class TestBrouwerLyddaneMeanLong: | ||
def test_to_coe(self, brouwer_lyddane_mean_long: BrouwerLyddaneMeanLong): | ||
assert brouwer_lyddane_mean_long.to_coe().is_defined() | ||
|
||
def test_cartesian( | ||
self, cartesian_state: tuple[Position, Velocity], gravitational_parameter | ||
): | ||
assert BrouwerLyddaneMeanLong.cartesian( | ||
cartesian_state, gravitational_parameter | ||
).is_defined() | ||
|
||
def test_undefined(self): | ||
assert BrouwerLyddaneMeanLong.undefined().is_defined() is False |
Oops, something went wrong.