Skip to content

Commit

Permalink
sanitize eph of jpl_lp
Browse files Browse the repository at this point in the history
  • Loading branch information
darioizzo committed Oct 2, 2024
1 parent bb8ef2e commit 285a825
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions pykep/test_trajopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,15 @@ class gym_cassini1_tests(_ut.TestCase):
def test_fitness(self):
import pykep as pk
udp = pk.trajopt.gym.cassini1
# Three random values. Ground truth provided by a snapshot of the kep3 code validated agains the old pykep code
# (not identical, just validated ... as a the old pykep had a buggy jpl_lp eph method nhere fixed)
# Three random values. Ground truth provided by the old pykep code
x = [-554.5189290104555, 103.27184879471751, 335.41655259663474, 80.50258543604521, 862.0950563689543, 2865.018040480413 ]
f = udp.fitness(x)[0]
self.assertTrue(float_rel_error(f,80747.26667221037) < 1e-14)
self.assertTrue(float_rel_error(f,80400.08898184073) < 1e-14)

x = [-932.0532394941108, 37.534681289972674, 162.5093144821548, 336.970139545233, 1743.2915882004586, 2527.8785180526465 ]
f = udp.fitness(x)[0]
self.assertTrue(float_rel_error(f,216694.84791232392) < 1e-14)
self.assertTrue(float_rel_error(f,217105.875031613573) < 1e-14)

x = [-583.0776694390058, 388.65047998036107, 334.9959782156864, 65.57508619540917, 1520.2982946551908, 2132.7771932619144 ]
f = udp.fitness(x)[0]
self.assertTrue(float_rel_error(f,107787.63141728108) < 1e-14)
self.assertTrue(float_rel_error(f,107218.08496509642) < 1e-14)
4 changes: 2 additions & 2 deletions src/udpla/jpl_lp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ std::array<double, 6> jpl_lp::_f_elements(double mjd2000) const
// algorithm from https://ssd.jpl.nasa.gov/planets/approx_pos.html accessed
// 2023.
std::array<double, 6> elements_updated{}, elements_f{};
double dt = (mjd2000) / 36525.; // Number of centuries passed since J2000.0
double dt = (mjd2000 - 0.5) / 36525.; // Number of centuries passed since J2000. T = (T_eph - 2451545.0)/36525
for (unsigned int i = 0; i < 6; ++i) {
elements_updated[i] = (m_elements[i] + m_elements_dot[i] * dt);
}
Expand Down Expand Up @@ -221,7 +221,7 @@ std::string jpl_lp::get_extra_info() const

std::ostream &operator<<(std::ostream &os, const kep3::udpla::jpl_lp &udpla)
{
os << udpla.get_extra_info() << "/n";
os << udpla.get_extra_info() << "\n";
return os;
}

Expand Down

0 comments on commit 285a825

Please sign in to comment.