AndrewAnnex / SpiceyPy

SpiceyPy: a Pythonic Wrapper for the SPICE Toolkit.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Binary PCK generation tutorial

TommasoPino opened this issue · comments

As suggested by the Spice NAIF team I reported here an issue I encountered and its solution could be useful for others.

For work reasons, I have no access to the internet but I have to use the latest EOP data from IERS Bulletin and automatically and internally update the earth_latest_high_prec.bpc when the bulletin is provided.

Reading the SPICE guide (here) I tried to generate my bpc file but with no useful results.

BPC generation

I attached in the zip file the testgenerationpck.py file where I am trying to build my bpc file starting from the earth_latest_high_prec.bpc used to generate a rotation matrix for each specific time necessary for the Chebyshev polynomials generation.
This script has the only purpose to search the correct way to build a binary PCK file.

I supposed the problem was on the rotation angles order then I tried several combinations with no success.

Precession Nutation Model Adopted

Searching what is wrong I identified something that I am not completely sure about the earth_latest_high_prec.bpc comment. In the Particurals section is explained that the model adopted for precession and nutation are the 1976 IAU model and the 1980 IAU model, respectively. Using the following code I made a comparison between the SPICE EOP data and the IERS IAU SOFA data ( provided by this website https://hpiers.obspm.fr/eop-pc/index.php?index=rotation&lang=en). On the website, it is defined the model used for the computation of the matrix orientation:

Transformation from the international terrestrial reference system (ITRF) to the international celestial reference frame (ICRF): transformation coordinate and associated quaternion. Computation of Celestial Pole coordinates (X, Y), Earth rotation angle, Celestial Intermediate Origin locator, Terrestrial Intermediate Origin locator are performed by FORTRAN programs of the SOFA IAU library, consistent with the IAU 2000/2006 resolutions.

Using another python script (issuePCK_JPL.py) I tested the results between the Sofa website and the spice kernel for three dates:

  Date 2021/11/18
  SPICE - SOFAWEB: 
  [[-8.36408121e-09 -5.26288901e-09 -2.85880329e-08]
   [ 5.30570088e-09 -8.31998515e-09 -6.56178744e-09]
   [-2.08866204e-08  2.05868687e-08  5.99987837e-11]]

  Date 2021/11/19
  SPICE - SOFAWEB:
  [[-7.35634476e-09 -4.44592985e-09 -2.81641371e-08]
   [ 4.48837256e-09 -7.31285243e-09 -6.90231290e-09]
   [-2.06001698e-08  2.04022694e-08  5.91263705e-11]]

  Date 2021/11/20
  SPICE - SOFAWEB:
  [[-8.56023530e-09 -4.98599650e-09 -2.77258759e-08]
   [ 5.02802544e-09 -8.51731463e-09 -7.25655761e-09]
   [-2.03260714e-08  2.01975239e-08  5.82177639e-11]]

The relative difference is so low that I suppose that the model adopted is the same.

The questions are:

The comment is correct? The models for precession and nutation adopted are Precession (1976 IAU model) and Nutation (1980 IAU model)?

The ITRF definition adopted is the latest and the name is maintained only for retro compatibility purposes?

Thanks in advance for the consideration and the help trying to answer all these questions.

BinaryPCKgenerationTutorial.zip

@TommasoPino

At the top, you suggest that the problem is solved, but at the bottom you ask two questions that are out of scope for spiceypy entirely, so it is a little unclear why the issue was posted here, if there actually is an issue at all, or why the naif suggested that you should post it here since it doesn't seem to be specific to SpiceyPy.

If I interpret you correctly, another project independently implemented from SPICE returns slightly different numbers for some state.

SpiceyPy wraps SPICE and cannot return different results than SPICE. Therefore, if there is a numerical issue with the result you are getting, and you know the SPICE results are wrong, not just different, then you need to talk to the NAIF. If you don't know which value is actually correct then you will need to speak to both the NAIF and IERS.

Both the NAIF and the IERS is far better equipped to answer this question, without looking at your attachment it depends on the initial state, what actual computations are performed, and all the various issues involving floating point math.

I will close this issue after a day or two. Issues posted on this website must be specific to SpiceyPy. If you can demonstrate that SpiceyPy returns different results than say CSPICE, SPICE, MICE, or ICY then I would consider it in scope.

@AndrewAnnex thanks for your reply to this issue. I agree to close the issue as it is. NAIF will continue discussing the issue with @TommasoPino via email.