Skip to content

Commit

Permalink
refactor: move some stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwa2710 committed Oct 12, 2023
1 parent 0e1d655 commit 1e47f44
Show file tree
Hide file tree
Showing 22 changed files with 239 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models(pybind11::mo
OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_SGP4(models);
OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Tabulated(models);
OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Propagated(models);
OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_BrouwerLyddaneMean(models);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

#include <OpenSpaceToolkit/Astrodynamics/Trajectory/Orbit/Models/Kepler.hpp>

#include <OpenSpaceToolkitAstrodynamicsPy/Trajectory/Orbit/Models/Kepler/COE.cpp>
#include <OpenSpaceToolkitAstrodynamicsPy/Trajectory/Orbit/Models/Kepler/BrouwerLyddaneMean.cpp>
#include <OpenSpaceToolkitAstrodynamicsPy/Trajectory/Orbit/Models/Kepler/BrouwerLyddaneMeanShort.cpp>
#include <OpenSpaceToolkitAstrodynamicsPy/Trajectory/Orbit/Models/Kepler/BrouwerLyddaneMeanLong.cpp>
#include <OpenSpaceToolkitAstrodynamicsPy/Trajectory/Orbit/Models/Kepler/COE.cpp>

inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler(pybind11::module& aModule)
{
Expand Down Expand Up @@ -92,7 +90,4 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler(pybin
kepler.attr("__path__") = "ostk.astrodynamics.trajectory.orbit.models.kepler";

OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_COE(kepler);
OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_BrouwerLyddaneMean(kepler);
OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_BrouwerLyddaneMeanShort(kepler);
OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_BrouwerLyddaneMeanLong(kepler);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

#include <OpenSpaceToolkit/Physics/Units/Derived/Angle.hpp>

#include <OpenSpaceToolkit/Astrodynamics/Trajectory/Orbit/Models/Kepler/BrouwerLyddaneMean.hpp>
#include <OpenSpaceToolkit/Astrodynamics/Trajectory/Orbit/Models/BrouwerLyddaneMean/BrouwerLyddaneMean.hpp>

#include <OpenSpaceToolkitAstrodynamicsPy/Trajectory/Orbit/Models/Kepler/BrouwerLyddaneMeanLong.cpp>
#include <OpenSpaceToolkitAstrodynamicsPy/Trajectory/Orbit/Models/Kepler/BrouwerLyddaneMeanShort.cpp>

using namespace pybind11;

Expand All @@ -11,7 +14,7 @@ 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;
using ostk::astro::trajectory::orbit::models::blm::BrouwerLyddaneMean;

// Trampoline class for virtual member functions
class PyBrouwerLyddaneMean : public BrouwerLyddaneMean
Expand Down Expand Up @@ -42,26 +45,45 @@ class PyBrouwerLyddaneMean : public BrouwerLyddaneMean
}
};

inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_BrouwerLyddaneMean(pybind11::module& aModule)
inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_BrouwerLyddaneMean(pybind11::module& aModule)
{
class_<BrouwerLyddaneMean, PyBrouwerLyddaneMean, COE> brouwerLyddaneMean(aModule, "BrouwerLyddaneMean");

brouwerLyddaneMean

.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")
);
{
class_<BrouwerLyddaneMean, PyBrouwerLyddaneMean, COE> brouwerLyddaneMean(aModule, "BrouwerLyddaneMean");

brouwerLyddaneMean

.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")
)

;
}

// Create "brouwerLyddaneMean" python submodule
auto brouwerLyddaneMean = aModule.def_submodule("brouwerLyddaneMean");

// Add __path__ attribute for "brouwerLyddaneMean" submodule
brouwerLyddaneMean.attr("__path__") = "ostk.astrodynamics.trajectory.orbit.models.brouwerLyddaneMean";

OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_BrouwerLyddaneMean_BrouwerLyddaneMeanShort(
brouwerLyddaneMean
);
OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_BrouwerLyddaneMean_BrouwerLyddaneMeanLong(brouwerLyddaneMean
);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// Apache License 2.0

#include <OpenSpaceToolkit/Astrodynamics/Trajectory/Orbit/Models/Kepler/BrouwerLyddaneMeanLong.hpp>
#include <OpenSpaceToolkit/Astrodynamics/Trajectory/Orbit/Models/BrouwerLyddaneMean/BrouwerLyddaneMeanLong.hpp>

inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_BrouwerLyddaneMeanLong(
inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_BrouwerLyddaneMean_BrouwerLyddaneMeanLong(
pybind11::module& aModule
)
{
Expand All @@ -13,8 +13,8 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_Brouw
using ostk::physics::units::Angle;
using ostk::physics::units::Length;

using ostk::astro::trajectory::orbit::models::kepler::BrouwerLyddaneMean;
using ostk::astro::trajectory::orbit::models::kepler::BrouwerLyddaneMeanLong;
using ostk::astro::trajectory::orbit::models::blm::BrouwerLyddaneMean;
using ostk::astro::trajectory::orbit::models::blm::BrouwerLyddaneMeanLong;

class_<BrouwerLyddaneMeanLong, BrouwerLyddaneMean> brouwerLyddaneMeanLong(aModule, "BrouwerLyddaneMeanLong");

Expand All @@ -32,6 +32,8 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_Brouw

.def("to_coe", &BrouwerLyddaneMeanLong::toCOE)

.def_static("COE", &BrouwerLyddaneMeanLong::COE, arg("coe"))

.def_static(
"cartesian", &BrouwerLyddaneMeanLong::Cartesian, arg("cartersian_state"), arg("gravitational_parameter")
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// Apache License 2.0

#include <OpenSpaceToolkit/Astrodynamics/Trajectory/Orbit/Models/Kepler/BrouwerLyddaneMeanShort.hpp>
#include <OpenSpaceToolkit/Astrodynamics/Trajectory/Orbit/Models/BrouwerLyddaneMean/BrouwerLyddaneMeanShort.hpp>

inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_BrouwerLyddaneMeanShort(
inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_BrouwerLyddaneMean_BrouwerLyddaneMeanShort(
pybind11::module& aModule
)
{
Expand All @@ -13,7 +13,8 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_Brouw
using ostk::physics::units::Angle;
using ostk::physics::units::Length;

using ostk::astro::trajectory::orbit::models::kepler::BrouwerLyddaneMeanShort;
using ostk::astro::trajectory::orbit::models::blm::BrouwerLyddaneMean;
using ostk::astro::trajectory::orbit::models::blm::BrouwerLyddaneMeanShort;

class_<BrouwerLyddaneMeanShort, BrouwerLyddaneMean> brouwerLyddaneMeanShort(aModule, "BrouwerLyddaneMeanShort");

Expand All @@ -31,6 +32,8 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_Brouw

.def("to_coe", &BrouwerLyddaneMeanShort::toCOE)

.def_static("COE", &BrouwerLyddaneMeanShort::COE, arg("coe"))

.def_static(
"cartesian", &BrouwerLyddaneMeanShort::Cartesian, arg("cartersian_state"), arg("gravitational_parameter")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_COE(p
.def("get_mean_anomaly", &COE::getMeanAnomaly)
.def("get_eccentric_anomaly", &COE::getEccentricAnomaly)
.def("get_periapsis_radius", &COE::getPeriapsisRadius)
.def("get_periapsis_altitude", &COE::getPeriapsisRadius)
.def("get_apoapsis_radius", &COE::getApoapsisRadius)
.def("get_SI_vector", &COE::getSIVector, arg("anomaly_type"))

.def("get_mean_motion", &COE::getMeanMotion, arg("gravitational_parameter"))
Expand All @@ -54,9 +54,6 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Models_Kepler_COE(p

.def("get_cartesian_state", &COE::getCartesianState, arg("gravitational_parameter"), arg("frame"))

.def("to_brouwer_lyddane_mean_long", &COE::toBrouwerLyddaneMeanLong)
.def("to_brouwer_lyddane_mean_short", &COE::toBrouwerLyddaneMeanShort)

.def_static("undefined", &COE::Undefined)

.def_static("cartesian", &COE::Cartesian, arg("cartesian_state"), arg("gravitational_parameter"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ostk.physics.units import Length
from ostk.physics.units import Angle

from ostk.astrodynamics.trajectory.orbit.models.kepler import BrouwerLyddaneMean
from ostk.astrodynamics.trajectory.orbit.models import BrouwerLyddaneMean


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
from ostk.physics.coordinate import Position
from ostk.physics.coordinate import Velocity

from ostk.astrodynamics.trajectory.orbit.models.kepler import BrouwerLyddaneMeanLong
from ostk.astrodynamics.trajectory.orbit.models.kepler import COE
from ostk.astrodynamics.trajectory.orbit.models.brouwerLyddaneMean import (
BrouwerLyddaneMeanLong,
)


@pytest.fixture
Expand Down Expand Up @@ -43,6 +46,18 @@ def mean_anomaly() -> Angle:
return Angle.degrees(60.0)


@pytest.fixture
def coe(
semi_major_axis: Length,
eccentricity: float,
inclination: Angle,
raan: Angle,
aop: Angle,
mean_anomaly: Angle,
) -> COE:
return COE(semi_major_axis, eccentricity, inclination, raan, aop, mean_anomaly)


@pytest.fixture
def cartesian_state() -> tuple[Position, Velocity]:
return (
Expand Down Expand Up @@ -73,6 +88,9 @@ class TestBrouwerLyddaneMeanLong:
def test_to_coe(self, brouwer_lyddane_mean_long: BrouwerLyddaneMeanLong):
assert brouwer_lyddane_mean_long.to_coe().is_defined()

def test_coe(self, coe: COE):
assert BrouwerLyddaneMeanLong.COE(coe).is_defined()

def test_cartesian(
self, cartesian_state: tuple[Position, Velocity], gravitational_parameter
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
from ostk.physics.coordinate import Position
from ostk.physics.coordinate import Velocity

from ostk.astrodynamics.trajectory.orbit.models.kepler import BrouwerLyddaneMeanShort
from ostk.astrodynamics.trajectory.orbit.models.kepler import COE
from ostk.astrodynamics.trajectory.orbit.models.brouwerLyddaneMean import (
BrouwerLyddaneMeanShort,
)


@pytest.fixture
Expand Down Expand Up @@ -43,6 +46,18 @@ def mean_anomaly() -> Angle:
return Angle.degrees(60.0)


@pytest.fixture
def coe(
semi_major_axis: Length,
eccentricity: float,
inclination: Angle,
raan: Angle,
aop: Angle,
mean_anomaly: Angle,
) -> COE:
return COE(semi_major_axis, eccentricity, inclination, raan, aop, mean_anomaly)


@pytest.fixture
def cartesian_state() -> tuple[Position, Velocity]:
return (
Expand Down Expand Up @@ -73,6 +88,9 @@ class TestBrouwerLyddaneMeanShort:
def test_to_coe(self, brouwer_lyddane_mean_short: BrouwerLyddaneMeanShort):
assert brouwer_lyddane_mean_short.to_coe().is_defined()

def test_coe(self, coe: COE) -> COE:
assert BrouwerLyddaneMeanShort.COE(coe).is_defined()

def test_cartesian(
self, cartesian_state: tuple[Position, Velocity], gravitational_parameter
):
Expand Down
28 changes: 12 additions & 16 deletions bindings/python/test/trajectory/orbit/models/kepler/test_coe.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,9 @@ def test_getters(
assert coe.get_orbital_period(Earth.EGM2008.gravitational_parameter) is not None
assert coe.get_periapsis_radius() is not None
assert coe.get_apoapsis_radius() is not None
assert coe.get_si_vector(COE.AnomalyType.TrueAnomaly) is not None
assert coe.get_si_vector(COE.AnomalyType.MeanAnomaly) is not None
assert coe.get_si_vector(COE.AnomalyType.EccentricAnomaly) is not None

def test_to_brouwer_lyddane_mean(
self,
coe: COE,
):
assert coe.to_brouwer_lyddane_mean_long() is not None
assert coe.to_brouwer_lyddane_mean_short() is not None
assert coe.get_SI_vector(COE.AnomalyType.TrueAnomaly) is not None
assert coe.get_SI_vector(COE.AnomalyType.MeanAnomaly) is not None
assert coe.get_SI_vector(COE.AnomalyType.EccentricAnomaly) is not None

def test_anomaly_conversions(self):
assert (
Expand Down Expand Up @@ -138,12 +131,15 @@ def test_from_SI_vector(
true_anomaly: Angle,
):
assert coe == COE.from_SI_vector(
semi_major_axis.inMeters(),
eccentricity,
inclination.inRadians(),
raan.inRadians(),
aop.inRadians(),
true_anomaly.inRadians(),
[
semi_major_axis.in_meters(),
eccentricity,
inclination.in_radians(),
raan.in_radians(),
aop.in_radians(),
true_anomaly.in_radians(),
],
COE.AnomalyType.TrueAnomaly,
)

def test_string_from_element(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// Apache License 2.0

#ifndef __OpenSpaceToolkit_Astrodynamics_Trajectory_Orbit_Models_Kepler_BrouwerLyddaneMean__
#define __OpenSpaceToolkit_Astrodynamics_Trajectory_Orbit_Models_Kepler_BrouwerLyddaneMean__
#ifndef __OpenSpaceToolkit_Astrodynamics_Trajectory_Orbit_Models_BrouwerLyddaneMean_BrouwerLyddaneMean__
#define __OpenSpaceToolkit_Astrodynamics_Trajectory_Orbit_Models_BrouwerLyddaneMean_BrouwerLyddaneMean__

#include <OpenSpaceToolkit/Core/Containers/Pair.hpp>
#include <OpenSpaceToolkit/Core/Types/Real.hpp>
Expand Down Expand Up @@ -30,7 +30,7 @@ namespace orbit
{
namespace models
{
namespace kepler
namespace blm
{

using ostk::core::ctnr::Pair;
Expand Down Expand Up @@ -120,7 +120,7 @@ class BrouwerLyddaneMean : public COE
);
};

} // namespace kepler
} // namespace blm
} // namespace models
} // namespace orbit
} // namespace trajectory
Expand Down
Loading

0 comments on commit 1e47f44

Please sign in to comment.