Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve accuracy and speed of planet functions #162

Merged
merged 12 commits into from
Dec 7, 2023

Conversation

taldcroft
Copy link
Member

@taldcroft taldcroft commented Nov 28, 2023

Description

This includes a few improvements / fixes:

  • Factor out the key method in jplephem.spk that actually computes planet positions, then wrap this in numba for about 25 times speedup (for that method only).
  • Use a specialized version of convert_time_format for time format conversions that is much faster. It sacrifices about a msec of accuracy which is fine here.
  • Fix a bug where the input JD time for SPK was in the UTC scale instead of the required TDB scale. This ~69 sec difference reduced the accuracy of planet positions.
  • Fix an issue in get_planet_chandra where the orbit ephemeris values were being interpolated to the nearest neighbor instead of linearly. Given the 5 minute sampling this makes a big difference.

Overall the get_planet_barycentric function is about 10-12 times faster for scalar or small-array valued inputs.

The accuracy of Venus planet predictions was improved from about 3-4 arcsec to under 0.2 arcsec relative to JPL Horizons.

Interface impacts

Planet positions will change slightly for the better.

Testing

Unit tests

  • Mac
(ska3-perf) ➜  chandra_aca git:(fast-scalar-planet-barycentric) git rev-parse HEAD                
bc34a28fc9a57272e2e745ec5bca25da69910504
(ska3-perf) ➜  chandra_aca git:(fast-scalar-planet-barycentric) pytest chandra_aca
================================================== test session starts ===================================================
platform darwin -- Python 3.10.8, pytest-7.2.1, pluggy-1.0.0
rootdir: /Users/aldcroft/git, configfile: pytest.ini
plugins: timeout-2.1.0, anyio-3.6.2
collected 197 items                                                                                                      

chandra_aca/tests/test_aca_image.py ..............                                                                 [  7%]
chandra_aca/tests/test_all.py ........................                                                             [ 19%]
chandra_aca/tests/test_attitude.py .............................................................                   [ 50%]
chandra_aca/tests/test_dark_model.py ....                                                                          [ 52%]
chandra_aca/tests/test_drift.py ..........................                                                         [ 65%]
chandra_aca/tests/test_maude_decom.py ...............                                                              [ 73%]
chandra_aca/tests/test_planets.py .............                                                                    [ 79%]
chandra_aca/tests/test_psf.py ...                                                                                  [ 81%]
chandra_aca/tests/test_residuals.py ss...                                                                          [ 83%]
chandra_aca/tests/test_star_probs.py ................................                                              [100%]

============================================ 195 passed, 2 skipped in 31.86s =============================================

Independent check of unit tests by Javier

  • OSX:

Functional tests

See the two new validation notebooks.

@taldcroft taldcroft changed the title WIP: Fast planet barycentric Improve get_planet_barycentric speed and get_planet_chandra accuracy Nov 29, 2023
@taldcroft taldcroft changed the title Improve get_planet_barycentric speed and get_planet_chandra accuracy Improve accuracy and speed of planet functions Nov 29, 2023
@taldcroft taldcroft removed the request for review from jeanconn November 30, 2023 17:53
Copy link
Contributor

@javierggt javierggt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went over the changes and they make sense to me. I verified the test outputs and the validation notebooks.

It looks good to me.

@taldcroft taldcroft merged commit 87d5d60 into master Dec 7, 2023
2 checks passed
@taldcroft taldcroft deleted the fast-scalar-planet-barycentric branch December 7, 2023 15:03
@javierggt javierggt mentioned this pull request Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants