Skyfield: HomeTable of ContentsAPI Reference

API Reference — Almanac

See Almanac Computation for a guide to using these routines to search for the times of sunrise, sunset, and the phases of the moon.

skyfield.almanac.phase_angle(ephemeris, body, t)

Compute the phase angle of a body viewed from Earth.

The body should be an integer or string that can be looked up in the given ephemeris, which will also be asked to provide positions for the Earth and Sun. The return value will be an Angle object.

skyfield.almanac.fraction_illuminated(ephemeris, body, t)

Compute the illuminated fraction of a body viewed from Earth.

The body should be an integer or string that can be looked up in the given ephemeris, which will also be asked to provide positions for the Earth and Sun. The return value will be a floating point number between zero and one. This simple routine assumes that the body is a perfectly uniform sphere.

skyfield.almanac.find_discrete(start_time, end_time, f, epsilon=1.1574074074074074e-08, num=12)

Find the times at which a discrete function of time changes value.

This routine is used to find instantaneous events like sunrise, transits, and the seasons. See Searching for the dates of astronomical events for how to use it yourself.

skyfield.almanac.seasons(ephemeris)

Build a function of time that returns the quarter of the year.

The function that this returns will expect a single argument that is a Time and will return 0 through 3 for the seasons Spring, Summer, Autumn, and Winter.

skyfield.almanac.moon_phases(ephemeris)

Build a function of time that returns the moon phase 0 through 3.

The function that this returns will expect a single argument that is a Time and will return the phase of the moon as an integer. See the accompanying array MOON_PHASES if you want to give string names to each phase.

skyfield.almanac.moon_nodes(ephemeris)

Build a function of time that identifies lunar nodes.

This returns a function taking a Time and returning True if the Moon is above the ecliptic else False. See Lunar Nodes for how to use this routine.

skyfield.almanac.oppositions_conjunctions(ephemeris, target)

Build a function to find oppositions and conjunctions with the Sun.

See Opposition and Conjunction for how to call this routine and interpret the results.

skyfield.almanac.sunrise_sunset(ephemeris, topos)

Build a function of time that returns whether the sun is up.

The function that is returned will expect a single argument that is a Time, and will return True if the sun is up, else False.

Skyfield uses the same definition as the United States Naval Observatory: the Sun is up when its center is 0.8333 degrees below the horizon, which accounts for both its apparent radius of around 16 arcminutes and also for the 34 arcminutes by which atmospheric refraction on average lifts the image of the Sun.

If you need to provide a custom value for refraction, adjust the estimate of the Sun’s radius, or account for a vantage point above the Earth’s surface, see Risings and Settings to learn about the more versatile risings_and_settings() routine.

skyfield.almanac.dark_twilight_day(ephemeris, topos)

Build a function of time returning whether it is dark, twilight, or day.

The function that this returns will expect a single argument that is a Time and will return:

0 — Dark of night.
1 — Astronomical twilight.
2 — Nautical twilight.
3 — Civil twilight.
4 — Sun is up.
skyfield.almanac.risings_and_settings(ephemeris, target, topos, horizon_degrees=-0.5666666666666667, radius_degrees=0)

Build a function of time that returns whether a body is up.

This returns a function taking a Time argument returning True if the body’s altazimuth altitude angle plus radius_degrees is greater than horizon_degrees, else False. See Risings and Settings to learn about how to search for risings and settings, and to see more about using the parameters horizon_degrees and radius_degrees.