Skip to main content

Crate stem_branch

Crate stem_branch 

Source
Expand description

Native Rust port of stem-branch’s solar ephemeris core.

Computes the Sun’s geocentric ecliptic state from the full VSOP87D Earth series plus a JPL DE441-fitted correction polynomial and IAU2000B nutation. Input is a Julian Ephemeris Day in Terrestrial Time (JDE/TT); the UTC<->TT / ΔT boundary is the caller’s responsibility.

This is a faithful translation of the TypeScript solarEclipticState; the VSOP87D and IAU2000B coefficient tables are generated from the same source by scripts/gen-rust-solar-data.mjs.

Structs§

CivilDate
A Gregorian civil date in Beijing time.
LunarMonth
One month of a lunisolar year: its number, leap flag, Gregorian start date (正月初一 etc., Beijing), and length in days (29 or 30).
LunisolarDate
A Chinese lunisolar date.
MoonPhase
Illumination geometry of the Moon at a Julian Ephemeris Day (TT), from the Moon’s and Sun’s geocentric positions (ELP/MPP02 + VSOP87D). Computed per Meeus, Astronomical Algorithms 2e, chapter 48 — using the true geocentric elongation (including the Moon’s ecliptic latitude) and the Sun/Moon distances, not a longitude-only approximation.
MoonState
Apparent geocentric position of the Moon at a Julian Ephemeris Day (TT): ELP/MPP02 geometric place, precessed to the ecliptic of date and corrected for nutation in longitude, then resolved to equatorial coordinates.
SolarState
Geocentric solar ecliptic state at a Julian Ephemeris Day (TT).

Constants§

EARTHLY_BRANCHES
The twelve Earthly Branches (地支), index 0 = 子.
HEAVENLY_STEMS
The ten Heavenly Stems (天干), index 0 = 甲.
SOLAR_TERM_LONGITUDES
Apparent ecliptic longitude (degrees) for each term; index 0 = 小寒 at 285°.
SOLAR_TERM_NAMES
Traditional-Chinese names of the 24 solar terms, index-aligned with SOLAR_TERM_LONGITUDES (index 0 = 小寒 @ 285°). Ported verbatim from the TypeScript SOLAR_TERM_NAMES (src/solar-terms.ts).

Functions§

delta_t_for_year
ΔT in seconds for a decimal year (TT = UT + ΔT).
find_new_moons_in_range
All new-moon JDEs (TT) within the Julian-Day range [start_jd, end_jd].
find_solar_term_moment
Find the JD(UT) of the solar term at target_longitude in year, searching from the first of start_month. Returns None if not found in 120 days.
gregorian_to_lunisolar
Convert a Gregorian (Beijing) civil date to its Chinese lunisolar date.
gregorian_to_lunisolar_with
As gregorian_to_lunisolar, with a caller-supplied ΔT model (decimal year → seconds) — e.g. to match an authority’s calendar at a ΔT-uncertain far-future boundary. Bypasses the per-year cache.
jd_from_ymd
Julian Day at 00:00 UT of the given Gregorian calendar date.
lunar_months_for_year
Lunar months for the lunisolar year whose 正月 falls in lunar_year — 12 months, or 13 in a leap year.
lunar_new_year
The Lunar New Year (正月初一) Gregorian date for gregorian_year.
moon_phase
Compute the Moon’s phase geometry (elongation, phase angle, illuminated fraction) at the given Julian Ephemeris Day in Terrestrial Time.
moon_position
Compute the Moon’s apparent geocentric position at the given Julian Ephemeris Day in Terrestrial Time.
new_moon_jde
JDE (TT) of the true new moon (定朔) for integer lunation k: the Meeus Ch.49 estimate refined to the exact Sun–Moon apparent-longitude conjunction using the ELP/MPP02 Moon and VSOP87D + DE441 Sun. Sub-arcsecond — far tighter than Meeus alone (~1 minute), which is what fixes the rare near-midnight calendar boundary where a coarser instant could land on the wrong day.
solar_ecliptic_state
Compute the Sun’s geocentric ecliptic state at the given Julian Ephemeris Day in Terrestrial Time.
solar_term_for_longitude
The solar term in effect at apparent ecliptic longitude deg — the term whose longitude is the greatest one at or before deg (circular). Terms sit every 15° starting from SOLAR_TERM_LONGITUDES[0] (小寒, 285°). Inputs are normalized, so negative or >360 longitudes are accepted.
ymd_from_jd
Gregorian (year, month, day) of the civil day that contains instant jd, using the midnight (.5) day boundary.