To compute the Andromeda Galaxy Risings and Settings I essentially use this code (in a more colplex code, but this serves the purpose):

from skyfield import api, almanac
from skyfield.api import N,S,E,W, wgs84, load, Star

ts = api.load.timescale()
eph = api.load('de421.bsp')
t0 = ts.utc(2021, 11, 1)
t1 = ts.utc(2021, 11, 13)

#The object
andromeda = Star(ra_hours=(00, 42, 44.330), dec_degrees=(41, 16, 7.50), parallax_mas=6.0, radial_km_per_s=-300, names=("Andromeda"))

#The Location
location = api.wgs84.latlon(46.1927800 * N, 9.0170300 * E, elevation_m=200 )

rise_set = almanac.risings_and_settings(eph, andromeda, location)
riseset_time, isrise = almanac.find_discrete(t0, t1, rise_set)
for riseset_time_u, isrise_u in zip(riseset_time, isrise):
    print(riseset_time_u.utc_iso(), 'Rise' if isrise_u else 'Set')

I do optain this results

2021-11-04T07:51:31Z Set
2021-11-04T10:33:33Z Rise
2021-11-05T07:47:35Z Set
2021-11-05T10:29:37Z Rise
2021-11-06T07:43:39Z Set
2021-11-06T10:25:41Z Rise
2021-11-07T07:39:43Z Set
2021-11-07T10:21:45Z Rise
2021-11-08T07:35:47Z Set
2021-11-08T10:17:49Z Rise
2021-11-09T07:31:51Z Set
2021-11-09T10:13:53Z Rise

Now the problem is that t0 is set on November the 1st, but the rises_and_settings function does not return any result before the Novembre 4th. Why is that?

  • 1
    $\begingroup$ For this question I recommend you also post it in the "issues" section of Skyfield's github page. It's very active and I think you'll get a response faster than you will here. $\endgroup$
    – uhoh
    Nov 14, 2021 at 0:49

1 Answer 1


The rising-setting search routine is currently optimized for objects near the celestial equator, like the Sun, Moon, and planets, that spent about half the day in the sky. This assumption lets it search in ¼-day increments, making it more efficient for such objects.

But the Andromeda galaxy and your observer position are both far to the north of the ecliptic, such that the galaxy spends only (if I'm doing the math in my head correctly, given the output you posted) about 4 hours below the horizon each day. It's easy for Skyfield to miss that 4 hour window when it’s stepping forward in ¼-day = 6 hour steps looking for the galaxy to be below the horizon.

Maybe Skyfield should someday have more intelligence around risings and settings! For now, you can tell it to search a tighter collection of points:

rise_set.step_days = 0.1

If you put that before your call to almanac.find_discrete(), I believe you will find that it computes all of the galaxy’s risings and settings!

  • 1
    $\begingroup$ And this actually did the trick, thank you! $\endgroup$
    – Luca Berti
    Nov 14, 2021 at 21:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .