Skip to content

Compute the constellation a body is in#199

Merged
rhannequin merged 1 commit intomainfrom
current-constellation
Aug 7, 2025
Merged

Compute the constellation a body is in#199
rhannequin merged 1 commit intomainfrom
current-constellation

Conversation

@rhannequin
Copy link
Owner

@rhannequin rhannequin commented Aug 6, 2025

This implements all 88 IAU designated constellations and the algorithm to find which one holds a set of equatorial coordinates.

The boundaries have been defined based on the B1875 epoch, which means we need to use astrometric (mean J2000) equatorial coordinates and convert them to the B1875 epoch to match how the constellations have been designed.

For now, a constellation is only made of an abbreviation and a name. In the future, I would like to add information for each of them, but also support other cultures.

How it works

The data comes from the VizieR archive and have been pre-processed to allow fast an easy computation by Astronoby.

The different values of right ascension, declinations and abbreviations have been sorted in sorted_right_ascensions.dat, sorted_declinations.dat and indexed_abbreviations.dat. The combinations are pre-processed in radec_to_index.dat, where each row represents a specific right ascension, each column represents a specific declination, and each cell contains an index that points to a constellation abbreviation.

This allows for applying a lookup process with binary search for both right ascension and declination in order to compute the index of the cell in radec_to_index.dat, which itself will provide the constellation abbreviation.

From this abbreviation, the last step is to get the associated constellation object from the constellations repository.

The files are not large, it is acceptable to load them only once and keep them in memory, so that only the first calculation may take a little bit more time and the next ones are fast.

This implementation is heavily inspired by Skyfield.

@rhannequin rhannequin self-assigned this Aug 6, 2025
@rhannequin rhannequin force-pushed the current-constellation branch from 24cab93 to 0202b57 Compare August 7, 2025 08:14
@rhannequin rhannequin requested a review from Copilot August 7, 2025 09:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements constellation finding functionality for all 88 IAU designated constellations. It provides the ability to determine which constellation contains a given set of equatorial coordinates by using pre-processed boundary data from the VizieR archive.

Key changes:

  • Added constellation boundary data and lookup algorithms using binary search
  • Implemented constellation objects with names and abbreviations
  • Added support for B1875 epoch coordinates required for constellation boundaries

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/astronoby/constellation.rb Defines the basic Constellation class with name and abbreviation
lib/astronoby/constellations/repository.rb Repository for retrieving constellation objects by abbreviation
lib/astronoby/constellations/data.rb Data access layer for constellation boundary files
lib/astronoby/constellations/finder.rb Core algorithm to find constellation from coordinates using binary search
lib/astronoby/julian_date.rb Adds B1875 epoch constant
lib/astronoby/bodies/solar_system_body.rb Adds constellation method to solar system bodies
Data files Pre-processed constellation boundary data for fast lookup
Spec files Comprehensive tests for repository and finder functionality

@rhannequin rhannequin force-pushed the current-constellation branch from 0202b57 to 4870cc8 Compare August 7, 2025 10:02
@rhannequin rhannequin marked this pull request as ready for review August 7, 2025 10:03
@rhannequin rhannequin force-pushed the current-constellation branch from 4870cc8 to ae2a37b Compare August 7, 2025 10:34
Base automatically changed from epoch-refactoring to main August 7, 2025 16:35
@rhannequin rhannequin force-pushed the current-constellation branch from ae2a37b to fd946e4 Compare August 7, 2025 16:39
@rhannequin rhannequin merged commit 9943688 into main Aug 7, 2025
42 checks passed
@rhannequin rhannequin deleted the current-constellation branch August 7, 2025 16:48
@rhannequin rhannequin mentioned this pull request Aug 12, 2025
rhannequin added a commit that referenced this pull request Sep 1, 2025
## 0.8.0 - 2025-09-01

_If you are upgrading: please see [UPGRADING.md]._

### Bug fixes

* Fix UPGRADING documentation ([#178])
* Fix possible division by zero in RTS ([#185])

### Features

* Introduce performance benchmark ([#183])
* Cache positions in RTS calculator ([#182])
* Internal global LRU cache ([#186])
* Global configuration ([#187])
* Compute the constellation a body is in ([#199])
* Add `#phase_angle` and `#illuminated_fraction` to planets ([#200])
* Apparent magnitude ([#201])
* Add #events_between to TwilightCalculator with better accuracy ([#204])
* `#angular_diameter` on Solar System bodies ([#207])
* Fix constellation boundaries near 24h right ascension ([#209])

### Improvements

* Bump standard from 1.49.0 to 1.50.0 by @dependabot ([#177])
* Bump ephem from 0.3.0 to 0.4.1 by @dependabot ([#181], [#191])
* Bump irb from 1.14.3 to 1.15.2 by @dependabot ([#184])
* Bump rspec from 3.13.0 to 3.13.1 by @dependabot ([#188])
* Bump benchmark from 0.4.0 to 0.4.1 by @dependabot ([#189])
* Bump rake from 13.2.1 to 13.3.0 by @dependabot ([#190])
* Bump matrix from 0.4.2 to 0.4.3 by @dependabot ([#193])
* Update rubyzip requirement from ~> 2.3 to ~> 3.0 by @dependabot ([#194])
* Bump rubyzip from 3.0.0 to 3.0.2 by @dependabot ([#202], [#206])
* Exclude benchmarks from release ([#196])
* `Epoch` refactoring into `JulianDate` ([#197])
* Support Ruby 3.4.4 ([#198])
* Bump actions/checkout from 4 to 5 ([#203])
* Internal documentation ([#205])

### Backward-incompatible changes

* `Epoch` refactoring into `JulianDate` ([#197])
* `#angular_diameter` on Solar System bodies ([#207])
* Rename "epoch" ([#208])

### Closed issues

* Consider adding typical usage/deployment info ([#179])
* Performance degradation in v0.7 ([#180])

**Full Changelog**: v0.7.0...v0.8.0

[#177]: #177
[#178]: #178
[#179]: #179
[#180]: #180
[#181]: #181
[#182]: #182
[#183]: #183
[#184]: #184
[#185]: #185
[#186]: #186
[#187]: #187
[#188]: #188
[#189]: #189
[#190]: #190
[#191]: #191
[#193]: #193
[#194]: #194
[#196]: #196
[#197]: #197
[#198]: #198
[#199]: #199
[#200]: #200
[#201]: #201
[#202]: #202
[#203]: #203
[#204]: #204
[#205]: #205
[#206]: #206
[#207]: #207
[#208]: #208
[#209]: #209
[UPGRADING.md]: https://github.com/rhannequin/astronoby/blob/main/UPGRADING.md
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.

2 participants