import kete
import numpy as np
import pandas as pd
from astropy import units as u
from astropy.time import Time
from IPython.core.interactiveshell import InteractiveShell
from matplotlib import pyplot as plt
import skyloc as sloc
%config InlineBackend.figure_format = 'retina'
# %matplotlib notebook
InteractiveShell.ast_node_interactivity = 'last_expr'
# We need to do it in a separate cell. See:
# https://github.com/jupyter/notebook/issues/3385
plt.style.use('default')
plt.rcParams.update({
'font.family': 'latin modern math', 'font.size':12, 'mathtext.fontset':'stix',
'axes.formatter.use_mathtext': True, 'axes.formatter.limits': (-4, 4),
'axes.grid': True, 'grid.color': 'gray', 'grid.linewidth': 0.5,
'xtick.top': True, 'ytick.right': True,
'xtick.direction': 'inout', 'ytick.direction': 'inout',
'xtick.minor.size': 2.0, 'ytick.minor.size': 2.0, # default 2.0
'xtick.major.size': 4.0, 'ytick.major.size': 4.0, # default 3.5
'xtick.minor.visible': True, 'ytick.minor.visible': True
})
observatory = (37.53660, 128.444790, 0.3) # lat, lon in deg, height in km
VMAG_CUT = 14.5
# print all logs from skyloc
sloc.set_log_level("DEBUG")Plan observations
Use this when planning a multi-day asteroid campaign with a brightness limit and a ground-station observer.
This is a static archive. The source queries SBDB and Horizons and runs kete integrations, but the site build runs none of those cells. Its dates, counts, and plot are historical outputs.
Workflow in the source
The notebook first applies a maximum-brightness screen, computes coarse geometry for 60 days, selects useful objects, and then runs a finer pass. It filters by altitude and magnitude and spot-checks the result against Horizons. Treat the limiting magnitude and sky-coverage assumptions as observatory-specific inputs.
Source and current API
Download the original notebook. The inline view omits stderr log lines, including catalog size and propagation/FOV counts. Read the complete saved run (optional) for those results and timestamps. See the external-data guide and brightness API for current interfaces.
Observation Planning
In case you want to plan future observations, multiple clever strategies can be used. Here, I will demonstrate
- Case of SNU Pyeongchang Campus telescope (60-cm, using limiting mag of V=14.5 for polarimeter)
- Focusing on asteroids, not comets
- Focusing on MBAs, not NEAs.
- First, only ~1% of known asteroids can be “bright enough”
- “maximum possible” brightness can be obtained by assuming r_hel=q, r_obs=MOID, and α=0.
- For the selected 1% of objects (say
usefulobjects), calculate their r_hel, r_obs, and alpha.- This does not have to be accurate. Use simple approximations in N-body.
- Timestep for the calculations is 1 day for the next 60 days.
- Then choose objects that can be bright enough for that time interval (60d)
- “maximum possible” brightness can be obtained by assuming r_hel=min(r_hel), r_obs=min(r_obs), and α=min(α) during that interval.
- Only ~10^3 objects (say
vmag_cutobjects) will be chosen. For them, do “accurate” calculations.- Use Cone FOV with 150° radius, i.e., select solar-elongation > 30° objects only.
# Download the orbit information file from JPL SBDB
# ~ 4-10min for the first time, ~10s for subsequent runs.
orb, m_ng = sloc.fetch_orb(
output="orb_sbdb.parq",
update_output=999, # days - if output's last-modified is older than this, it will be updated
# filters=[
# ("kind", "not in", ("au")),
# ("kind", "in", ("cu", "cn")),
# ("condition_code", "in", ["0", "1"]),
# ]
)# Query MOID - it is not in the fetch_orb by default.
# --- The user may specify this column in fetch_orb in the beginning
if "moid" not in orb.columns:
sq = sloc.SBDBQuery(fields=["pdes", "moid"])
df = sq.query()
# fill moid column based on orb["desig"] and df["pdes"]
orb = orb.merge(df[["pdes", "moid"]], left_on="desig", right_on="pdes", how="left")
# Assume phase angle alpha=0, r_hel=q, r_obs=moid, H=H to get theoretical *BRIGHTEST* V-mag:
vmag = sloc.iau_hg_mag(hmag=orb["H"], rhel=orb["peri_dist"], robs=orb["moid"], alpha__deg=0)
vmask = (vmag < VMAG_CUT) & ~pd.isna(vmag)
orb_useful = orb.loc[vmask].copy().reset_index(drop=True)
print(len(orb_useful), f"objects with V-mag < {VMAG_CUT}")14012 objects with V-mag < 14.5
# === 1. Crude calculation
times = Time("2025-12-01") + np.arange(0, 60, 1) * u.day
fovs_crude = []
for _t in times:
jd_tdb = _t.tdb.jd
name = _t.strftime("%Y-%m-%d %H:%M:%S")
obssta = kete.spice.earth_pos_to_ecliptic(
jd_tdb, *observatory, name=name, center=399 # geocenter will be changed to Sun below
)
fovs_crude.append(sloc.make_omni_fov(
state_desig=name,
jd_tdb=jd_tdb,
pos_au=obssta.pos,
vel_aupd=obssta.vel,
vel_frame=None, # if kete.Vector is provided, frame should be None
pos_frame=None,
center_id=399, # The pos/vel are with respect to geocenter (399)
fov_to_sun=True, # FOV is converted to the helio-centric coordinate
)[1])
fovs_crude = sloc.FOVCollection(fovs_crude)
# Initialize
sl_c = sloc.SSOLocator(fovs=fovs_crude, orb=orb_useful, non_gravs=True)
# ^^^^^^^^^^^^^^^
# Automatically use non-gravitational accelerations if parameters are available
# N-body propagate to mean JD of FOVs
# (later N-body simulations will be done *from* this JD0)
sl_c.propagate_n_body(include_asteroids=False, jd0=times.tdb.jd[0])
# Check which FOVs contain which objects.
sl_c.fov_state_check(include_asteroids=False, dt_limit=5., use_spice_for_loaded=False)
fov_hasobj_c = sl_c.fovc_hasobj
orb_infov_c = sl_c.orb.loc[sl_c.orb_infov_mask].copy()
print(f"Number of FOVs with objects: {fov_hasobj_c.shape[0]} out of {len(fovs_crude)}")
print(f"Number of objects in FOVs : {orb_infov_c.shape[0]}")Number of FOVs with objects: 60 out of 60
Number of objects in FOVs : 13998
# --- Calculate brief geometry, cut by Vmag
eph_c = []
# a low-level function that is behind the "calc_ephems" method - ~100 times faster than the full calc_ephems
for simsta in sl_c.fov_check_simstates:
eph_c.append(pd.DataFrame.from_dict(
sloc.calc_geometries(
simsta, do_hel_ecl=False, do_obs_ecl=False, do_radec=False, do_galactic=False
)
))
eph_c = pd.concat(eph_c)
# Secondary cut based on "theoretical maximum" brightness during the next time interval:
desig_vmag_cut = []
for desig, _eph in eph_c.groupby("desig"):
alpha_min = _eph["alpha"].min()
r_hel_min = _eph["r_hel"].min()
r_obs_min = _eph["r_obs"].min()
hmag = orb_useful.loc[orb_useful["desig"] == desig, "H"].values[0]
vmag_theo = sloc.iau_hg_mag(hmag=hmag, rhel=r_hel_min, robs=r_obs_min, alpha__deg=alpha_min)
if vmag_theo < VMAG_CUT:
desig_vmag_cut.append(desig)
orb_vmag_cut = orb_useful.loc[orb_useful["desig"].isin(desig_vmag_cut)].copy().reset_index(drop=True)Above took ~5-7s on MBP 14” [2024, macOS 15.2, M4Pro(8P+4E/G20c/N16c/48G)].
# === 2. Accurate calculation
times = Time("2025-12-01") + np.arange(0, 60, 0.5) * u.day
fovs_a = []
for _t in times:
jd_tdb = _t.tdb.jd
name = _t.strftime("%Y-%m-%d %H:%M:%S")
obssta = kete.spice.earth_pos_to_ecliptic(
jd_tdb, *observatory, name=name, center=399 # geocenter will be changed to Sun below
)
sunsta = kete.spice.get_state("10", jd_tdb, "399").as_equatorial
# FoV at anti-sun, radius = 150 deg to include objects >~30deg from the sun.
fovs_a.append(sloc.make_cone_fov(
state_desig=name,
jd_tdb=jd_tdb,
pos_au=obssta.pos,
vel_aupd=obssta.vel,
center_ra_deg=(sunsta.pos.ra + 180) % 360,
center_dec_deg=-sunsta.pos.dec,
radius_deg=150, # sufficiently large
vel_frame=None, # if kete.Vector is provided, frame should be None
pos_frame=None,
)[1])
fovs_a = sloc.FOVCollection(fovs_a)
# --- 1.5M objs: ~15s on MBP 14" [2024, macOS 15.2, M4Pro(8P+4E/G20c/N16c/48G)]
# Initialize
sl_a = sloc.SSOLocator(fovs=fovs_a, orb=orb_vmag_cut, non_gravs=True)
# ^^^^^^^^^^^^^^^
# Automatically use non-gravitational accelerations if parameters are available
# N-body propagate to mean JD of FOVs
# (later N-body simulations will be done *from* this JD0)
sl_a.propagate_n_body(include_asteroids=False, jd0=times.tdb.jd[0])
# Check which FOVs contain which objects.
sl_a.fov_state_check(include_asteroids=False, dt_limit=5., use_spice_for_loaded=False)
fov_hasobj_a = sl_a.fovc_hasobj
orb_infov_a = sl_a.orb.loc[sl_a.orb_infov_mask].copy()
sl_a.calc_ephems()
print(f"Number of FOVs with objects: {fov_hasobj_a.shape[0]} out of {len(fovs_a)}")
print(f"Number of objects in FOVs : {orb_infov_a.shape[0]}")Number of FOVs with objects: 120 out of 120
Number of objects in FOVs : 526
Above took ~6.1s on MBP 14” [2024, macOS 15.2, M4Pro(8P+4E/G20c/N16c/48G)].
| desig | alpha | r_hel | r_obs | hel_ecl_lon | hel_ecl_lat | obs_ecl_lon | obs_ecl_lat | glx_lon | glx_lat | ... | racosdec_rate | dec_rate | sky_motion | sky_motion_pa | sun_target_pa | vmag | jd_tdb | jd_utc | obsid | h_cul | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 471 | 11.773261 | 2.239566 | 1.318592 | 54.665623 | -7.435610 | 43.963637 | -12.695952 | 173.203623 | -45.952138 | ... | -0.462482 | 0.313431 | 0.558685 | -55.873935 | 47.807823 | 9.221092 | 2.461011e+06 | 2461010.5 | 2025-12-01 00:00:00 | 56.347838 |
| 1 | 6 | 30.591628 | 1.937699 | 1.668502 | 9.955319 | -11.606290 | -21.345985 | -13.510692 | 41.315410 | -64.395940 | ... | 0.889299 | 0.403307 | 0.976478 | 65.605210 | 66.660232 | 9.335254 | 2.461011e+06 | 2461010.5 | 2025-12-01 00:00:00 | 31.661867 |
| 2 | 16 | 3.662202 | 2.662371 | 1.685582 | 74.189512 | -3.003099 | 77.418098 | -4.745616 | 184.244253 | -13.287181 | ... | -0.531814 | -0.052229 | 0.534373 | -95.609020 | -66.936108 | 9.793522 | 2.461011e+06 | 2461010.5 | 2025-12-01 00:00:00 | 70.582230 |
| 3 | 44 | 24.420442 | 2.065239 | 1.387101 | 104.207628 | -1.702880 | 128.631072 | -2.534611 | 210.427054 | 31.258310 | ... | 0.289460 | -0.052339 | 0.294153 | 100.249182 | -73.590715 | 9.794920 | 2.461011e+06 | 2461010.5 | 2025-12-01 00:00:00 | 68.119257 |
| 4 | 40 | 16.330417 | 2.260206 | 1.414989 | 92.478559 | -0.124846 | 108.808877 | -0.198206 | 196.158620 | 16.122505 | ... | -0.253211 | 0.111352 | 0.276613 | -66.262063 | -81.821217 | 9.955877 | 2.461011e+06 | 2461010.5 | 2025-12-01 00:00:00 | 74.386353 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 56079 | 220839 | 135.767598 | 0.777171 | 0.265528 | 139.901892 | 1.872713 | -83.765837 | 5.496064 | 14.245836 | -2.626509 | ... | -0.735910 | 0.200064 | 0.762620 | -74.791142 | -84.211076 | 20.361835 | 2.461070e+06 | 2461070.0 | 2026-01-29 12:00:00 | 34.661133 |
| 56080 | 2007 VM184 | 90.404115 | 0.563504 | 0.803925 | -179.096514 | 21.263624 | -82.773854 | 14.728882 | 22.700838 | 1.213669 | ... | 1.818938 | -1.468810 | 2.337935 | 128.921204 | -70.761710 | 22.472985 | 2.461070e+06 | 2461070.0 | 2026-01-29 12:00:00 | 43.930063 |
| 56081 | mercury | 18.379759 | 2.661992 | 3.041651 | -127.426108 | 9.211344 | -108.870442 | 8.054047 | 4.071569 | 20.355497 | ... | 0.937697 | -0.166987 | 0.952449 | 100.097485 | -77.393501 | 99.000000 | 2.461070e+06 | 2461070.0 | 2026-01-29 12:00:00 | 38.332436 |
| 56082 | jupiter | 17.945778 | 3.192342 | 3.089234 | -155.762917 | 5.838205 | -137.720649 | 6.034417 | 344.051234 | 43.701738 | ... | 0.418891 | -0.166471 | 0.450758 | 111.673250 | -72.304933 | 99.000000 | 2.461070e+06 | 2461070.0 | 2026-01-29 12:00:00 | 42.694821 |
| 56083 | pluto | 18.568795 | 2.656542 | 2.013690 | 89.259593 | -7.954316 | 70.623236 | -10.517981 | 186.138644 | -21.969532 | ... | 0.051689 | 0.093948 | 0.107229 | 28.819027 | 75.901245 | 99.000000 | 2.461070e+06 | 2461070.0 | 2026-01-29 12:00:00 | 64.085751 |
56084 rows × 22 columns
t0 = times[0].utc.isot
_eph = eph.loc[eph["jd_utc"] == times[0].utc.jd]
fig, axs = plt.subplots(1, 1, figsize=(8, 5), layout="constrained", gridspec_kw=None, sharex=False, sharey=False)
sc = axs.scatter(_eph["ra"], _eph["dec"], c=_eph["vmag"], cmap="RdYlBu", edgecolors="k", vmin=9, vmax=16, s=10, alpha=0.7)
#colorbar:
cbar = plt.colorbar(sc, ax=axs)
cbar.set_label("V-mag")
axs.set(
title=t0,
xlabel="RA[deg]",
ylabel="DEC[deg]"
)
plt.show();
Sanity check against JPL Horizons
The eph table above is your observing plan (save it with e.g. eph.to_parquet(...)). Before trusting it, spot-check the first few rows against JPL Horizons with sloc.horizons_quick. The cell below asserts that alpha, ra/dec, and r_hel/r_obs agree within the listed tolerances.
obs_dict = {
"lat": observatory[0],
"lon": observatory[1],
"elevation": observatory[2],
"body": "399", # geocenter
}
cols_tol = {
("alpha"): (1/3600, 0.01), # 1 arcsec atol & 1% rtol for phase angle
("dec"): (1/3600/1000, 0.001), # 10 mas atol & 0.1% rtol for ra/dec
("r_hel", "r_obs"): (1e-6, 0.001), # 1e-6 au atol & 0.1% rtol for distances
}
for i, row in eph.iterrows():
if i > 10:
break
small_body_id = f"{row['desig']};" # add semicolon
_, _eph = sloc.horizons_quick(
small_body_id, epochs=[row["jd_utc"]], location=obs_dict, in_tdb=False
)
_eph = _eph.iloc[0]
for cols, (atol, rtol) in cols_tol.items():
if isinstance(cols, str):
cols = (cols,)
for col in cols:
assert np.isclose(
row[col],
_eph[col],
atol=atol,
rtol=rtol,
), f"{col} mismatch for {row['desig']}: {row[col]} vs {_eph[col]}"