Skip to content

Apparent magnitude#201

Merged
rhannequin merged 3 commits intomainfrom
apparent-magnitude
Aug 12, 2025
Merged

Apparent magnitude#201
rhannequin merged 3 commits intomainfrom
apparent-magnitude

Conversation

@rhannequin
Copy link
Owner

Magnitude is a measure of the luminosity. The more luminous an object, the lower its magnitude number.

The apparent magnitude represents the brightness of the object seen from Earth. Note that is doesn't account the atmospheric effect.

Most planets have many different coefficients. It is because there is no single formula for describing the brightness of all the variety of the planets.
Note that some cases are ignored and fall back to a default (less accurate) formula:

  • Saturn's rings add significant brightness but taking them into account means calculating their inclination, which is a complex one I don't want to deal with right now
  • Uranus uses the default formula as the accurate one depends on a complex correction term called "Uranus' sub-Earth and sub-solar latitudes", which again is just too much burden for now

Values have been tested against the IMCCE, JPL Horizons, Stellarium and Skyfield library. They match these sources most of the time, otherwise the difference is too small to be noticed in any amateur purpose.

Since phase_angle has been added to planets, the position of the Sun in different reference frames is necessary for multiple planetary calculations. Therefore, the whole sun object is now saved on the planet for computing different data.

@rhannequin rhannequin self-assigned this Aug 9, 2025
@rhannequin rhannequin requested a review from Copilot August 12, 2025 14:11
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 apparent magnitude calculations for celestial bodies in the Astronoby library. Apparent magnitude represents the brightness of astronomical objects as observed from Earth.

  • Adds apparent magnitude calculation functionality to all solar system bodies
  • Implements planet-specific magnitude correction formulas for accurate calculations
  • Refactors phase angle computation to support magnitude calculations

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/astronoby/bodies/solar_system_body.rb Adds base apparent magnitude implementation and refactors phase angle computation
lib/astronoby/bodies/sun.rb Implements Sun-specific apparent magnitude calculation
lib/astronoby/bodies/earth.rb Updates Earth to exclude magnitude calculations
lib/astronoby/bodies/mercury.rb Adds Mercury's absolute magnitude and correction formula
lib/astronoby/bodies/venus.rb Adds Venus's absolute magnitude and correction formula
lib/astronoby/bodies/mars.rb Adds Mars's absolute magnitude and correction formula
lib/astronoby/bodies/jupiter.rb Adds Jupiter's absolute magnitude and correction formula
lib/astronoby/bodies/saturn.rb Adds Saturn's absolute magnitude and correction formula
lib/astronoby/bodies/uranus.rb Adds Uranus's absolute magnitude
lib/astronoby/bodies/neptune.rb Adds Neptune's absolute magnitude and correction formula
lib/astronoby/bodies/moon.rb Adds Moon's absolute magnitude and correction formula
spec/astronoby/bodies/*.rb Adds comprehensive test coverage for apparent magnitude calculations

@rhannequin rhannequin merged commit 4ea44aa into main Aug 12, 2025
43 checks passed
@rhannequin rhannequin deleted the apparent-magnitude branch August 12, 2025 20:13
@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