Repository navigation
Compute the sky orientation once per chart - #22
Merged
Merged
Conversation
Every point of the sky went through Astronoby's whole pipeline, which builds the precession and nutation matrices and the sidereal time again each time, about 325 microseconds per point. Sky computes them once for the observer and the instant, so a point costs about 5 microseconds and a full chart renders in 0.1 s instead of 2.3 s. Astronoby multiplies the precession and nutation matrices in the other order when it has no ephemeris. Sky uses the order of its ephemeris path, so positions move by less than 0.1 arcsecond.
# Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the chart-rendering optimization.
No open issues 🎉
What changed in this PR
Optimizes chart rendering by computing sky orientation once per chart rather than repeating it for every point, while keeping the layer interfaces unchanged.
Changes:
- Adds
Skymap::Skyto cache precession, nutation, and sidereal time, and routesContextcoordinate conversion through it. - Adds tests comparing horizontal coordinates with Astronoby and checking azimuth bounds.
- Documents the reported roughly 20× rendering speedup and small positional differences.
| File | Description |
|---|---|
spec/skymap/sky_spec.rb |
Tests coordinate agreement and azimuth bounds. |
lib/skymap/sky.rb |
Implements horizontal conversion using cached sky orientation. |
lib/skymap/context.rb |
Creates one Sky instance and delegates coordinate conversion. |
lib/skymap.rb |
Loads the new Sky class. |
CHANGELOG.md |
Records rendering performance and positional changes. |
Review effort: Balanced
Astronoby 0.11 computes the rotation and the sidereal time once per observer and instant, which is what Skymap::Sky did. Context uses it directly and Sky is removed, and the dependency moves to ~> 0.11.
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.
Rendering a full chart took 2.3 s, mostly in the conversion of each point of the sky to horizontal coordinates. Astronoby's pipeline builds the precession and nutation matrices and the sidereal time again for every point, about 325 µs each, although they only depend on the observer and the instant.
Astronoby::HorizontalTransformation, added in Astronoby 0.11 after rhannequin/astronoby#314, computes them once.Contextbuilds one when it is created andContext#horizontal_coordinatesuses it, so the layers don't change. Each point then costs about 4 µs.~> 0.11.Skymap::Sky. On Astronoby'smainit gave the same positions asHorizontalTransformationfor 5,200 stars at four observers and times, so it is removed.