Repository navigation
Cache Greenwich sidereal times and document the cache - #320
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 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
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.

Fixes #315
GreenwichMeanSiderealTime.from_utcandGreenwichApparentSiderealTime.from_utcnow go through the cache when it is enabled.LocalApparentSiderealTime.from_utcbenefits 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_utcgoes from about 72 µs to 2 µs per call with the cache on, and nothing changes with it off.