Created
January 21, 2022 03:45
-
-
Save PM2Ring/b1fec75e78cc08f6fc28c6f6c43529c3 to your computer and use it in GitHub Desktop.
Run Horizons batch file in Sage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" 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) |
Here's an updated SageCell version, with easier copy & paste of output data.
A demo with a batch-file for the Moon.
Minimal version
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
Live version on the SageMathCell server.