galactics / beyond

Flight Dynamic Library
MIT License
49 stars 8 forks source link

Cannot parse CCSDS Example OEM due to no support for MARS BARYCENTER #40

Closed seedship closed 2 years ago

seedship commented 2 years ago

I'm trying to parse the example OEM in the official CCSDS guidebook: https://public.ccsds.org/Pubs/502x0b2c1e2.pdf , but having difficulty because MarsBarycenter is not supported. I'm wondering if there is support planned?

oem_utils.py:33: in oem_to_odet_products
    ephemerides = ccsds.loads(oem)
../../../../../../../venv/lib/python3.8/site-packages/beyond/io/ccsds/ccsds.py:60: in loads
    return func(text, fmt=fmt)
../../../../../../../venv/lib/python3.8/site-packages/beyond/io/ccsds/oem.py:32: in loads
    ephem = _loads_kvn(string)
../../../../../../../venv/lib/python3.8/site-packages/beyond/io/ccsds/oem.py:100: in _loads_kvn
    orb = StateVector(
../../../../../../../venv/lib/python3.8/site-packages/beyond/orbits/statevector.py:38: in __new__
    frame = get_frame(frame)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

frame = 'MarsBarycenter'

    def get_frame(frame):
        """Frame factory

        Args:
            frame (str): name of the desired frame
        Return:
            Frame: the object representing the frame demanded
        Raise:
            ~beyond.frames.frames.UnknownFrameError
        """

        if frame not in dynamic.keys() and config.get(
            "env", "jpl", "dynamic_frames", fallback=False
        ):
            from ..env.jpl import create_frames, JplConfigError

            try:
                create_frames()
            except (JplConfigError, UnknownBodyError) as e:
                raise UnknownFrameError(frame) from e

        try:
            return dynamic[frame]
        except KeyError:
>           raise UnknownFrameError(frame)
E           beyond.errors.UnknownFrameError: Unknown frame 'MarsBarycenter'

../../../../../../../venv/lib/python3.8/site-packages/beyond/frames/frames.py:73: UnknownFrameError
galactics commented 2 years ago

Hello !

Interplanetary bodies are already supported, but need a little bit of configuration first. I encourage you to read everything in this section of the documentation. You should have everything you need for it to work.

In short, you have to download the .bsp file containing the ephemerides of the bodies you need (mind the time span of each file), set the configuration to tell beyond where these files are located, and don't forget to call beyond.env.jpl.create_frames(). I didn't include these files into the library because they are really heavy, so I had to make their use optional.

If something is not clear with this, don't hesitate to propose improvements to the documentation.

Cheers

galactics commented 2 years ago

Hey @seedship, did you find a solution to your problem ?

seedship commented 2 years ago

Ahhhh sorry forgot to respond. I didn't really need to do interplanetary analysis, I just wanted a random OEM file to verify a conversion file. I ended up changing the barrycentrt to Earth.

Thanks for the help!