anise: MetaAlmanac not loading planetary data for 301 (Earth's Moon)

Bug report

Describe the bug

I cannot access lunar planetary constants or frame data through anise.

To Reproduce

Steps to reproduce the behavior:

import pathlib
import anise

def load_kernels() -> anise.MetaAlmanac:
    my_constants_filename = (
        'my_constants.tpc')
    earth_assoc_itrf93_fk_filename = (
        'earth_assoc_itrf93.tf')
    earth_assoc_itrf93_epa_filename = (
        'earth_assoc_itrf93.epa')

    if not pathlib.Path(my_constants_filename).is_file():
        # Make sure the constants file exists (create if not)
        anise.utils.convert_tpc(
                'pck00010.tpc',
                'gm_de440.tpc',
                my_constants_filename)

    if not pathlib.Path(earth_assoc_itrf93_epa_filename).is_file():
        anise.utils.convert_fk(
            earth_assoc_itrf93_fk_filename,
            earth_assoc_itrf93_epa_filename)

    earth_latest_high_prec = anise.MetaFile(
        'earth_latest_high_prec.bpc',
    )
    jpl_moon_rotation = anise.MetaFile(
        'moon_pa_de440_200625.bpc',
    )
    de440 = anise.MetaFile(
        'de440.bsp'
    )
    moon_frames = anise.MetaFile(
        'moon_fk.epa'
    )
    itrf93 = anise.MetaFile(earth_assoc_itrf93_epa_filename)
    my_constants = anise.MetaFile(
        'my_constants.tpc'
    )
    new_meta = anise.MetaAlmanac()
    new_meta.files = [
        earth_latest_high_prec,
        jpl_moon_rotation,
        de440,
        itrf93,
        moon_frames,
        my_constants
    ]
    return almanac

and then almanac.describe(spk=True, bpc=True, planetary=True) does not list 301. I believe this should be in de440.bsp, but maybe I’m missing something. I spent a bunch of time staring at the documentation for MetaAlmanac and Almanac and couldn’t figure this out.

Expected behavior

I would expect loading the planetary constants and BPC files should yield planetary data for 301. I should also be able to get the MOON_J2000 frame, but I get the following error with almanac.frame_info(Frames.MOON_J2000):

Exception: when fetching frame by its UID via ephemeris_id, when fetching by ID, ID 301 not in look up table

Platform

Linux, Anise 0.4.4

Additional context

This comes from the tutorial, which suggests the following should work:

    moon_j2000 = Frames.MOON_J2000
    loaded_moon_j2000 = almanac.frame_info(moon_j2000)

The tutorial may need to be updated, or else this code simply doesn’t work.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (14 by maintainers)

Commits related to this issue

Most upvoted comments

let ctx = Almanac::new(“./almanac/de440s.bsp”).expect(“Could not load bsp”); let loaded_ctx = ctx.load(“./almanac/moon_pa_de440_200625.bpc”).expect(“Could not load bpc”).load(“./almanac/pck11.pca”).expect(“failure pck”);

That worked for me, thanks! In retrospect, I think I had two issues going on:

  • At first, I was loading all of the files but didn’t realize that load returns the loaded instance (I was trying to use ctx instead of loaded_ctx later in the routine)
  • When I attempted to recreate it and stored loaded_ctx, I didn’t load all the files.

Hi Greg,

The planetary data in the almanac refers only to the data you’d typically find the SPICE PCK files, including gravity parameters and shape of the ellipsoid. The ctx.planetary_data.len() returns the length of that dataset. So you need to also load the pck11.pca file.

let ctx = Almanac::new("./almanac/de440s.bsp").expect("Could not load bsp");
let loaded_ctx = ctx.load("./almanac/moon_pa_de440_200625.bpc").expect("Could not load bpc").load("./almanac/pck11.pca").expect("failure pck");

println!("Planetary data length: {}", loaded_ctx.planetary_data.len());

That will print Planetary data length: 54.

The BPC file only contains the data to rotate from one frame to another. In the case of the Moon PA file, it allows the rotation between the 31008 frame ID and the inertial frame:

Image

(This is a screenshot from the ANISE GUI.)