Skip to content

Cache Greenwich sidereal times and document the cache - #320

Merged
rhannequin merged 2 commits into
mainfrom
claude/issue-315-fix-cb72ee
Oct 31, 2026
Merged

rhannequin merged 2 commits into
mainfrom
claude/issue-315-fix-cb72ee

Conversation

@rhannequin

@rhannequin rhannequin commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Fixes #315

GreenwichMeanSiderealTime.from_utc and GreenwichApparentSiderealTime.from_utc now go through the cache when it is enabled. LocalApparentSiderealTime.from_utc benefits too, since it only adds the longitude to the GAST.

Unlike nutation and precession, the key is the exact UTC time, with no rounding. Sidereal time moves about 15 arcseconds per second, so sharing an entry between close instants would cost real precision. The cache pays off when the same instant is reused, like converting many points for one observer.

On my machine LocalApparentSiderealTime.from_utc goes from about 72 µs to 2 µs per call with the cache on, and nothing changes with it off.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The GMST and GAST tests need fractional-second cases because their one-second separation would not detect cache keys that incorrectly merge subsecond instants.

1 open issue
What changed in this PR

This PR addresses #315 by extending Astronoby’s optional cache to Greenwich sidereal times, also benefiting local apparent sidereal-time calculations.

Changes:

  • Cache mean and apparent Greenwich sidereal times using exact UTC keys without rounding.
  • Add tests for cache reuse, disabled behavior, and result consistency.
  • Document that caching is disabled by default and helps repeated calculations at the same instant.
File Description
spec/​astronoby/​time/​greenwich_sidereal_time_spec.rb Adds sidereal-time caching tests.
README.md Introduces caching benefits and enablement instructions.
lib/​astronoby/​time/​greenwich_mean_sidereal_time.rb Caches mean sidereal-time results.
lib/​astronoby/​time/​greenwich_apparent_sidereal_time.rb Caches apparent sidereal-time results.
lib/​astronoby/​cache.rb Adds exact UTC cache-key generation.
docs/​configuration.md Documents sidereal-time caching and precision.
CHANGELOG.md Records caching support and documentation updates.

Review effort: Balanced

@rhannequin
rhannequin merged commit 35ef02b into main Oct 31, 2026
44 checks passed
@rhannequin
rhannequin deleted the claude/issue-315-fix-cb72ee branch October 31, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache the sidereal time and document that the cache is off by default

2 participants