Skip to content

Epoch refactoring into JulianDate#197

Merged
rhannequin merged 6 commits intomainfrom
epoch-refactoring
Aug 7, 2025
Merged

Epoch refactoring into JulianDate#197
rhannequin merged 6 commits intomainfrom
epoch-refactoring

Conversation

@rhannequin
Copy link
Owner

Terms were confusing when dealing with an epoch. An epoch is a reference point, but it depends on a system used. In Astronoby, the system used is the Julian Day, so it wasn't precise enough to call it Epoch.

Also, specs where mentioning "Julian Day Number", which is the integer part of a Julian Date, which was not accurate.

This refactors Epoch into JulianDate for accuracy.

This also drops #to_utc method, which ambiguously expected the Julian date to be in UTC, which is almost never the case in Astronoby (Instant used Julian dates, but stores the value in TT). The code using it has been adapted to use Instant.from_terrestrial_time instead, which has increased precision by a couple seconds in the equinox/solstice calculation.

It was also the opportunity to add #from_julian_year and #from_besselian_year to compute Julian dates from reference points like J2050 or B1875. This will help introduce constellations, which boundaries are defined based on the B1875 epoch.

@rhannequin rhannequin self-assigned this Aug 6, 2025
@rhannequin rhannequin requested a review from Copilot August 6, 2025 23:24
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 refactors the Epoch class into JulianDate to improve accuracy and clarity in astronomical computations. The term "epoch" was ambiguous as it represents a reference point that depends on the system used, while Julian Date is more precise for the Julian Day system used in Astronoby.

  • Renamed Epoch class to JulianDate with more precise naming and constants
  • Removed ambiguous #to_utc method and updated callers to use Instant.from_terrestrial_time
  • Added new methods #from_julian_year and #from_besselian_year for epoch calculations

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/astronoby/julian_date.rb New JulianDate class with improved constants and new epoch calculation methods
lib/astronoby/epoch.rb Removed old Epoch class
spec/astronoby/julian_date_spec.rb New comprehensive test suite for JulianDate functionality
spec/astronoby/epoch_spec.rb Removed old Epoch test suite
lib/astronoby/equinox_solstice.rb Updated to use JulianDate and Instant.from_terrestrial_time for improved precision
lib/astronoby/events/moon_phases.rb Updated to use Instant.from_terrestrial_time instead of Epoch.to_utc
Various spec files Updated references from Epoch to JulianDate
Various lib files Updated constant references and class usage

@rhannequin rhannequin merged commit ab37cdd into main Aug 7, 2025
42 checks passed
@rhannequin rhannequin deleted the epoch-refactoring branch August 7, 2025 16:35
@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