Offline Sun and Moon astronomy for TypeScript and Swift

Almanac 0.1.0

Release Sky

Almanac 0.1.0 is the first release: offline Sun and Moon astronomy for TypeScript and Swift, with one behavior in both ports and no network access or runtime data files.

  • sunPosition and moonPosition give geocentric apparent right ascension, declination, and distance. sunAltAz and moonAltAz give refracted topocentric altitude and azimuth.
  • sunEvents finds sunrise, sunset, civil, nautical, and astronomical twilight, and transit within a window. moonEvents finds moonrise and moonset from the Moon's upper limb.
  • moonIllumination reports the illuminated fraction, phase angle, phase, and waxing state, and searchMoonPhases finds new, first-quarter, full, and last-quarter moons.
  • nextLunarEclipse returns the kind, peak, magnitudes, and contact times of the next lunar eclipse, and lunarEclipseVisibility reports which contacts an observer can see.
  • Every function covers 1950 through 2100 and raises a typed out-of-range error outside that interval. The functions share names across both ports, with Swift argument labels. The algorithms are translated from Astronomy Engine by Don Cross.

Both ports are tested against the same external fixtures and a cross-port parity corpus, with these tolerances:

Quantity Tolerance Evidence
Sun and Moon position 1′ JPL Horizons, 1,839 samples each across 1950–2100
Sun distance 1e-4 AU JPL Horizons
Moon distance 70 km JPL Horizons
Rise, set, twilight, and phase times 60 s USNO rise and set grid, 693 USNO moon phases
Lunar eclipse peaks and magnitudes 60 s, 0.03 All 344 eclipses in the Espenak catalog, 1950–2100
Lunar eclipse contacts 60 s NASA contact tables for four eclipses

Event searches scale with window length: a full 151-year window takes about 68 s in TypeScript and 44 s in a Swift release build, so run long searches off the main thread. Validation includes 80 TypeScript tests, 84 Swift release tests, and the shared fixture and parity checks.

npm install @openwaters/almanac@0.1.0
.package(url: "https://github.com/openwatersio/almanac.git", exact: "0.1.0")

Changes: #1.

Full history.