Skip to content

[BUG] EphemerisRangeError and RuntimeWarning on Linux when using naive datetime objects #1128

@barraRRR

Description

@barraRRR

When attempting to generate simulation frames on a Linux environment, skyfield fails to calculate planetary positions using the de421.bsp kernel.

The error first manifests as a RuntimeWarning in the jplephem library (related to OS type casting) and ultimately triggers a skyfield.errors.EphemerisRangeError, stating that the requested date is outside the supported range (1899-2053), even though the input date is in 2026.

Interestingly, the exact same code runs flawlessly and generates the GIF correctly on macOS (Apple Silicon).

Environment

  • OS: Linux / macOS (Works on Mac, fails on Linux)
  • Python: 3.10+
  • Libraries involved: skyfield, jplephem, numpy
/home/jbarreir/github/nightwindow/venv/lib/python3.10/site-packages/jplephem/spk.py:226: RuntimeWarning: invalid value encountered in cast
  index = (index1 + index2 + index3).astype(int)
Traceback (most recent call last):
  File "/home/jbarreir/github/nightwindow/project.py", line 127, in <module>
    main()
  File "/home/jbarreir/github/nightwindow/project.py", line 19, in main
    create_gallery(start_time=start_time,
  File "/home/jbarreir/github/nightwindow/project.py", line 33, in create_gallery
    sim.generate_sky_frame(current_time=current_time, frame_num=i)
  File "/home/jbarreir/github/nightwindow/starmap.py", line 41, in generate_sky_frame
    alt_s, az_s, _ = astrometric_stars.apparent().altaz()
  File "/home/jbarreir/github/nightwindow/venv/lib/python3.10/site-packages/skyfield/positionlib.py", line 784, in apparent
    deflector_au = _compute_deflector_position(
  File "/home/jbarreir/github/nightwindow/venv/lib/python3.10/site-packages/skyfield/relativity.py", line 100, in _compute_deflector_position
    bposition = deflector.at(tclose).xyz.au
  File "/home/jbarreir/github/nightwindow/venv/lib/python3.10/site-packages/skyfield/vectorlib.py", line 90, in at
    p, v, gcrs_position, message = self._at(t)
  File "/home/jbarreir/github/nightwindow/venv/lib/python3.10/site-packages/skyfield/jpllib.py", line 237, in _at
    raise e
skyfield.errors.EphemerisRangeError: ephemeris segment only covers dates 1899-07-29 through 2053-10-09

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions