Skip to content

Commit

Permalink
Test on sky distance magnitude
Browse files Browse the repository at this point in the history
  • Loading branch information
akoumjian committed Aug 1, 2024
1 parent 6947b95 commit e8f5292
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/test_ephemeris.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_ephemeris():
observers = Observers.from_code("500", delta_times)

on_sky_rtol = 1e-7
on_sky_atol = 2.77e-7 # 1 milliarcsecond
one_milliarcsecond = 2.77778e-7 # 1 milliarcsecond
millisecond_in_days = 1.1574074074074073e-8

light_time_rtol = 1e-8
Expand All @@ -80,9 +80,6 @@ def test_ephemeris():
err_msg=f"Horizons returned significantly different epochs than were requested.",
)

# Horizons appears to give us times that are not exactly what we asked for? try
# propagating to the times horizons returns
modified_observers = Observers.from_code("500", horizons_ephem.coordinates.time)
assist_ephem = prop.generate_ephemeris(
horizons_start_vector, observers, covariance=True
)
Expand All @@ -108,14 +105,27 @@ def test_ephemeris():
assist_ephem.coordinates.lon.to_numpy(zero_copy_only=False),
horizons_ephem.coordinates.lon.to_numpy(zero_copy_only=False),
rtol=on_sky_rtol,
atol=on_sky_atol,
atol=one_milliarcsecond,
err_msg=f"Failed RA for {object_id}",
)

assert_allclose(
assist_ephem.coordinates.lat.to_numpy(zero_copy_only=False),
horizons_ephem.coordinates.lat.to_numpy(zero_copy_only=False),
rtol=on_sky_rtol,
atol=on_sky_atol,
atol=one_milliarcsecond,
err_msg=f"Failed Dec for {object_id}",
)

# Get the difference in magnitude for the lon/lats
on_sky_difference = np.linalg.norm(
assist_ephem.coordinates.values[:, 1:3]
- horizons_ephem.coordinates.values[:, 1:3],
axis=1,
)

np.testing.assert_array_less(
on_sky_difference,
2 * one_milliarcsecond,
err_msg=f"Failed on sky for {object_id}",
)
9 changes: 9 additions & 0 deletions tests/test_propagate.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def test_propagate():
"""
download_jpl_ephemeris_files()
prop = ASSISTPropagator()
millisecond_in_days = 1.1574074074074073e-8

start_time_mjd = Timestamp.from_mjd([60000])
delta_times = Timestamp.from_mjd(
Expand All @@ -154,6 +155,14 @@ def test_propagate():
horizons_start, horizons_propagated_orbits.coordinates.time, covariance=True
)

ephem_times_difference = pc.subtract(
assist_propagated_orbits.coordinates.time.mjd(), horizons_propagated_orbits.coordinates.time.mjd()
)
np.testing.assert_array_less(
np.abs(ephem_times_difference.to_numpy(zero_copy_only=False)),
millisecond_in_days,
err_msg=f"ASSIST produced significantly different epochs than Horizons for {object_id}",
)
# Calculate the absolute magnitude of position and velocity vectors
absolute_position = np.linalg.norm(
assist_propagated_orbits.coordinates.values[:, :3]
Expand Down

0 comments on commit e8f5292

Please sign in to comment.