weewx-skyfield

Almanac tag reference

Home · Installation · The Sky page · Sky panels in your skin · Translating (i18n) · GitHub project


Bodies

The Skyfield almanac natively computes, for the sun, the moon and all planets (plus Pluto):

PyEphem is not required for any of these, nor for any tag used by WeeWX’s standard skins.

There is no $almanac.earth: Earth is the observer, not a served body (PyEphem, which this almanac replaces, has no Earth body either). Earth’s heliocentric coordinates are available all the same — $almanac.sun.hlongitude and $almanac.sun.hlatitude report them, per the XEphem convention (see Differences from PyEphem).

Constellations and eclipses

Two tag families (new in 1.9) have no PyEphem counterpart at all.

Every body, stars included, reports the constellation it currently stands in — $almanac.saturn.constellation gives “Pisces” — judged from the observer’s topocentric place against the IAU boundaries (the boundary map ships inside the Skyfield library; nothing is downloaded). The value is the Latin name in every language (it is data: templates comparing it and loopdata fields publishing it always see the same string), and as of 1.13 it carries the other views of the answer as attributes: $almanac.saturn.constellation.abbr gives “Psc”, .label the translated display name from the report’s [Almanac] [[Constellations]] section keyed by IAU abbreviation (Psc = Fische) falling back to the Latin, and .name the Latin name again. $almanac.saturn.constellation_abbr remains as a legacy alias for .abbr — see Translating the Sky page.

And the almanac finds eclipses: $almanac.next_lunar_eclipse and $almanac.next_solar_eclipse (with previous_ counterparts) give the time of maximum eclipse of the nearest eclipse visible from the station — the eclipsed body must be above the horizon at maximum — and each has a _type companion: penumbral/partial/total for lunar eclipses, and for solar eclipses the type as seen from your location (partial/annular/total) — a station that catches only the penumbra of a total eclipse reports partial, which is exactly what an observer there sees. Lunar eclipses come from Skyfield’s eclipselib; solar eclipses this extension finds directly, testing each new moon for a topocentric overlap of the solar and lunar discs at the station. When a skin just wants “the next eclipse, whichever kind”, the combined $almanac.next_eclipse (and previous_eclipse) picks the sooner (later) of the two, with _kind (“lunar”/”solar”) and _type companions — the Sky page’s eclipse chip is written with exactly these three tags.

Translated body names

Every body, stars included, carries a display name a skin can translate: $almanac.moon.label (new in 1.12). Add the tag name to the report’s [Almanac] section — the same section that holds moon_phases, so usually in a lang file — for example:

[Almanac]
    moon = Mond
    polaris = Polarstern

and $almanac.moon.label renders “Mond”, $almanac.polaris.label “Polarstern”. Bodies the report does not translate fall back to the English name, so a partial list is fine, and the lookup follows each report’s own language — the entry belongs in the report that uses the tag, in its lang file or skin.conf, or per report in weewx.conf:

[StdReport]
    [[MyReport]]
        [[[Almanac]]]
            polaris = Polarstern

(the weewx.conf form survives skin and extension upgrades; under [[Defaults]] instead of [[MyReport]] it applies to every report at once — see Your own reports and skins and One place for the whole station on the translation page). On live-updating pages, a weewx-loopdata almanac field such as almanac.moon.label renders in the language of loopdata’s target report — one language per loopdata instance.

Stars

Named stars (e.g., $almanac.rigel.rise, $almanac.polaris.circumpolar, $almanac.sirius.mag) are computed natively. The names are the official proper names of the IAU Catalog of Star Names (every entry of the Working Group on Star Names’ IAU-CSN list with a Hipparcos number), plus PyEphem’s 115 star names for backward compatibility (a few of those are legacy spellings of the same stars, e.g. albereo for albireo) — 420 names in all, covering 412 stars. Multi-word names use underscores and diacritics are dropped ($almanac.kaus_australis.rise, $almanac.barnards_star.mag).

Any other Hipparcos star can be addressed by catalog number: $almanac.hip_57939.rise — the bundled catalog excerpt covers the named stars, and a user-installed full hip_main.dat serves all 118,218 (see Serving every Hipparcos star). The star positions, proper motions, parallaxes and magnitudes come from wxskyfield_stars.dat, an excerpt of the Hipparcos Catalogue (The Hipparcos and Tycho Catalogues, ESA SP-1200, 1997; distributed by CDS as VizieR catalog I/239) which is installed along with the extension.

Unlike PyEphem, earth_distance and sun_distance work for stars (in astronomical units, like the planets — e.g., $almanac.proxima_centauri.earth_distance), computed from the star’s Hipparcos parallax.

Star support can be turned off by setting stars = false in the Skyfield section of weewx.conf.

Fallback behavior

Anything this extension does not compute falls through to the next almanac in WeeWX’s list — the built-in PyEphem almanac when PyEphem is installed (e.g., named stars when the star catalog is disabled, or direct PyEphem data attributes such as $almanac.moon.a_epoch). Almanac times outside the span of the bundled DE421 ephemeris (mid-1899 through 2053) fall through the same way. Without PyEphem, such tags simply report per-tag errors rather than breaking report generation.

Differences from PyEphem

Where PyEphem and standard astronomical conventions differ, weewx-skyfield follows the standard definitions rather than PyEphem:

The result cache

Report generation asks the almanac the same expensive questions over and over: every template mention of $almanac.moon.rise runs a fresh rise search, a page rendered in desktop and smartphone variants repeats each other’s work, and the day-window verbs (rise/set/transit, searched from local midnight) return the same instant for every almanac time within the day. Since 1.4, results are cached at the computation layer, transparently — no configuration, no new tags:

Only raw floats are cached, never formatted values, so skins with different formatters cannot leak into each other. The one deliberate tolerance: rise/set cache keys quantize the effective horizon to 0.002 degrees, because the default horizon scales refraction by the almanac’s current temperature and pressure, which drift a few thousandths of a degree between report cycles. Within a day, a cached rise/set may therefore be served under conditions differing by up to that quantum — worth well under a second of event time (worst measured 0.64 s over a 15-hour replay of real sensor data), below the refraction model’s own physical uncertainty; the displayed minute agrees with a fresh computation except when the true time sits within that fraction of a second of the boundary. For perspective, an uncached answer is itself a moving target: because refraction follows the live temperature and pressure, a fresh computation of the same rise or set wanders a few seconds over the course of a day — the cache tracks that wander well within the wander itself. Cache pools are bounded and simply cleared on overflow; correctness never depends on an entry being present. Expect the first report cycle after a WeeWX restart, and the first after local midnight, to run at full uncached cost while the day’s entries repopulate (in practice the midnight cycle is often much cheaper: skins with calendar strips or day-window loops have already cached the new day’s searches).

Measured on the eight-page paloaltoweather.com site (a heavy consumer: ~3,200 almanac tag evaluations per cycle, Raspberry Pi 5): template generation dropped from ~17.7 s per report cycle to ~4.6 s on warm cycles, with ~10 s for the first cycle after a restart.