Repository navigation
Add an altitude-crossing calculator and base twilight on it - #311
Merged
Merged
Conversation
rhannequin
force-pushed
the
altitude-crossing-calculator
branch
from
October 26, 2026 22:49
802f576 to
3985d75
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #310
Adds
AltitudeCrossingCalculator, which finds when a body reaches any altitude, with unrounded instants, and rebuildsTwilightCalculatoron top of it.It also has
crossing_on,extremes_betweenandmultiple_crossings_between, plus therefraction:andreference:(:center,:upper_limb,:lower_limb) options.The window is split at the culminations. Where the target is clearly crossed, the instant is found on the real altitude with a safeguarded secant. Where the target is within 0.05° of a culmination, it falls back to sampling and bisection and the crossing is flagged
grazing?.Twilight
TwilightCalculatorkeeps its signatures and still returns times rounded to the second. What changes:time_for_zenith_angleand custom angles. The new values match IMCCE, Horizons and Skyfield.nil.event_onnow covers midnight to the next midnight, so a crossing in the last second of a day isn't dropped.Validation
Compared 22 Sun crossings (-6°, -12°, -18° at Paris, Makkah, 60° N and 75° N) with other tools. The largest difference with Astronoby is 0.6 s for IMCCE, 0.10 s for Horizons and 0.19 s for Skyfield on the same ephemeris. USNO agrees to the minute for civil twilight. The Skyfield gap is the difference between its ΔT prediction and IERS.
Performance
Twilight is slower than before, because each crossing needs a few real position evaluations:
event_onx 30events_betweenover a year