skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.4k stars 211 forks source link

EphemerisRangeError: ephemeris segment only covers dates 1899-07-28 23:59:18Z through 2053-10-08 23:58:51Z UT #720

Closed famc2 closed 2 years ago

famc2 commented 2 years ago

hi I just follow the document https://rhodesmill.org/skyfield/kepler-orbits.html

from skyfield.api import load
from skyfield.data import mpc
with load.open(mpc.COMET_URL) as f:
    comets = mpc.load_comets_dataframe(f)

comets = comets.set_index('designation', drop=False)

row = comets.loc['C/2017 K2 (PANSTARRS)']
from skyfield.constants import GM_SUN_Pitjeva_2005_km3_s2 as GM_SUN

ts = load.timescale(builtin=True)
eph = load('./de421.bsp')
sun, earth = eph['sun'], eph['earth']

comet = sun + mpc.comet_orbit(row, ts, GM_SUN)

from skyfield.api import Topos
add = earth + Topos('10 N', '10 E')

t = ts.utc(2022, 3, 13, 13, 40, 00)
ra, dec, distance = add.at(t).observe(comet).radec()

i got : skyfield.errors.EphemerisRangeError: ephemeris segment only covers dates 1899-07-28 23:59:18Z through 2053-10-08 23:58:51Z UT

tried 3 comets:1P/Halley, C/2020 F3 (NEOWISE), C/2017 K2 (PANSTARRS) only C/2017 K2 (PANSTARRS) raise the error

Thank you!

brandon-rhodes commented 2 years ago

Alas, I don't get that error. Could you temporarily replace your last line of code with print(t.utc_jpl()) so we can double-check the time object you've created?

famc2 commented 2 years ago

I found the reason: python3.8 works fine, but python3.6 raise that error. Thank you for quickly reply

brandon-rhodes commented 2 years ago

I am not sure why the two versions of Python would not work the same. Does this little script display the same thing under both Python 3.6 and 3.8?

import skyfield
print(skyfield.__version__)
famc2 commented 2 years ago

python3.6 with skyfield 1.23 goes error python3.8 with skyfield 1.39 ok I update python3.6 skyfield1.23 to python3.9 skyfield1.41, it raise another error: pandas.errors.ParserError: Error tokenizing data. C error: Expected 12 fields in line 504, saw 13

after google, I edit: /lib/python3.9/site-packages/skyfield/data/mpc.py at this line, add on_bad_lines='skip' df = pd.read_csv(io.BytesIO(text), header=None, names=_COMET_FAST_COLUMNS, on_bad_lines='skip')

it's OK now