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

Horizons SCOUT support #157

Open
dahlend opened this issue Nov 20, 2024 · 0 comments
Open

Horizons SCOUT support #157

dahlend opened this issue Nov 20, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@dahlend
Copy link
Collaborator

dahlend commented Nov 20, 2024

Add support for querying the SCOUT service.
Here is a bit of code which allows for fetching the monte-carlo states from NEOCP.

    import requests
    import numpy as np
    
    def fetch_neocp_states(obj_identifier):
    
        res = requests.get(f"https://ssd-api.jpl.nasa.gov/scout.api?tdes={obj_identifier}&eph-start&orbits=true")
        res.raise_for_status()
        orbit = res.json()['orbits']
        columns = orbit['fields']
        data = [[float(x) if x != 'NULL' else np.nan for x in y] for y in orbit['data']]
        
        column_ind = {c: idx for idx, c in enumerate(columns)}
        
        lookup = {
            "desig":"idx",
            "epoch": "epoch",
            "eccentricity": "ec",
            "inclination": "inc",
            "lon_of_ascending": "om",
            "peri_arg": "w",
            "peri_dist": "qr",
            "peri_time": "tp",
        }
        lookup_rev = dict(x[::-1] for x in lookup.items())
        
        states = []
        for row in data:
            kwargs = {k: row[column_ind[v]] for k, v in lookup.items()}
            kwargs['desig'] = obj_identifier + str(int(kwargs['desig']))
            states.append(kete.CometElements(**kwargs).state)
        return states
@dahlend dahlend added the enhancement New feature or request label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant