satellogic / orbit-predictor

Python library to propagate satellite orbits.
MIT License
140 stars 43 forks source link

ltan_from_raan util added #106

Closed xrael closed 4 years ago

xrael commented 4 years ago

orbit-predictor has a util to convert from ltan to raan. I happened to need the opposite util and I've decided to propose to add this to repo.

coveralls commented 4 years ago

Coverage Status

Coverage decreased (-10.7%) to 83.482% when pulling 2b116cd4fd9af687b300af2461b045c6c7139380 on xrael:ltan-from-raan into c03e11a8f4ad29088e214e15bf755b839e7d40cd on satellogic:master.

astrojuanlu commented 4 years ago

Thanks a lot @xrael! I see these failures in the CI:

=================================== FAILURES ===================================

_ SunSynchronousTests.test_sun_sync_delta_true_anomaly_has_expected_anomaly_and_epoch _

self = <test_numerical_predictor.SunSynchronousTests testMethod=test_sun_sync_delta_true_anomaly_has_expected_anomaly_and_epoch>

    def test_sun_sync_delta_true_anomaly_has_expected_anomaly_and_epoch(self):

        date = dt.datetime.today().date()

        ltan_h = 12

        expected_ref_epoch = dt.datetime(date.year, date.month, date.day, 12)

        for expected_ta_deg in [-30, 0, 30]:

            pred = J2Predictor.sun_synchronous(

                alt_km=800, ecc=0, date=date, ltan_h=ltan_h, ta_deg=expected_ta_deg

            )

            ta_deg = pred.get_position(expected_ref_epoch).osculating_elements[5]

>           self.assertAlmostEqual(ta_deg, expected_ta_deg % 360, places=12)

E           AssertionError: 360.0 != 0 within 12 places (360.0 difference)

would you like to address them?

xrael commented 4 years ago

ooops. I'm sorry :) Isn't that weird? I did not put my hands on that part of the code. I can try to fix it, definitely

astrojuanlu commented 4 years ago

Oh sorry, I looked quickly and thought it was the test you added. I'll take care of it separately.

xrael commented 4 years ago

I cannot even reproduce the error. When I run that test, it passes smoothly

astrojuanlu commented 4 years ago

Floating point weirdness strikes back.

>>> from math import pi
>>> v = -9.812684231690591e-18
>>> v % (2 * pi)
6.283185307179586
>>> v % (2 * pi) % (2 * pi)
0.0
astrojuanlu commented 4 years ago

@xrael I fixed the rogue test and changed the CI system, would you like to rebase your PR?

astrojuanlu commented 4 years ago

Thanks a lot @xrael ! Merging when the pipelines pass