Skip to content

Instantly share code, notes, and snippets.

@PM2Ring
Created January 21, 2022 03:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PM2Ring/b1fec75e78cc08f6fc28c6f6c43529c3 to your computer and use it in GitHub Desktop.
Save PM2Ring/b1fec75e78cc08f6fc28c6f6c43529c3 to your computer and use it in GitHub Desktop.
Run Horizons batch file in Sage
""" Retrieve data from Horizons using a batch-file
Written by PM 2Ring 2021.12.27
"""
import re, requests
url = "https://ssd.jpl.nasa.gov/api/horizons_file.api"
pat = re.compile(r"(?:[^'\s]|'[^']*')+")
@interact
def go(batch=InputBox(width=40, height=24)):
if not batch: return
# Make sure each command is on a separate line
batch = "\n".join(pat.findall(batch))
#print(batch)
req = requests.post(url, data={'format': 'text'}, files={'input': ('cmd', batch)})
print(req.text)
@PM2Ring
Copy link
Author

PM2Ring commented Mar 23, 2024

Halley's comet, 1910, 3D orbit plot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment