Skip to content

Instantly share code, notes, and snippets.

@void4
Last active May 23, 2023 21:54
Show Gist options
  • Save void4/fdc91f24908ea42f2f0f8cdf85b3a77b to your computer and use it in GitHub Desktop.
Save void4/fdc91f24908ea42f2f0f8cdf85b3a77b to your computer and use it in GitHub Desktop.
Quickly plot impacting asteroid groundtrack
"""
Dependencies:
find_orb (specifically the non-gui 'fo'): https://www.projectpluto.com/find_orb.htm
pip install pandas plotly
$ grab_mpc obs.txt 2023 CX1
# -E 8 includes ground track latlon+alt
# only with -e generates combined.json i think
$ ./fo obs.txt -e astroeph.json -E 8 "EPHEM_START=2023 Feb 13 02:55" EPHEM_STEPS=600 EPHEM_STEP_SIZE=1s
"""
import json
import pandas as pd
import plotly.express as px
with open("/home/test/find_orb/find_orb/combined.json") as f:
j = json.loads(f.read())
ephemerides = list(j["objects"]["2023 CX1"]["ephemeris"]["entries"].values())
lons = []
lats = []
alts = []
ts = []
hover_names = []
for i, eph in enumerate(ephemerides):
t = eph["ISO_time"]
lon = eph["lon"]
lat = eph["lat"]
alt = eph["alt(km)"]
if alt < -10:
break
# ra, dec more accurate?
print(t, lon, lat, alt)
lons.append(lon)
lats.append(lat)
alts.append(alt)
ts.append(t)
hover_names.append(f"{t} {alt}km")
df = pd.DataFrame({"lats":lats, "lons":lons, "alts":alts, "hover_name": hover_names})
fig = px.scatter_mapbox(df, lat="lats", lon="lons", hover_name="hover_name", mapbox_style="carto-positron")
fig.show()
@void4
Copy link
Author

void4 commented May 23, 2023

image

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