Skip to content

Twilight events dedicated class#61

Merged
rhannequin merged 1 commit intomainfrom
twilight-events
Apr 15, 2024
Merged

Twilight events dedicated class#61
rhannequin merged 1 commit intomainfrom
twilight-events

Conversation

@rhannequin
Copy link
Owner

In the same way Astronoby::Events::ObservationEvents represent observation events for any body on the celestial sphere, twilight events exist but are related only to the Sun. For example, it doesn't make sense to talk about twilight related to a planet or a distant star.

In a goal of making events more centralized, twilight times are now extract from Astronoby::Sun into their own dedicated Astronoby::Events::TwilightEvents class.

The same methods are exposed. This adds natural memoization as all the times are calculated when the object initialized, which is when the Astronoby::Sun#twilight_events is called.

epoch = Astronoby::Epoch.from_time(Date.new(2024, 1, 1))
sun = Astronoby::Sun.new(epoch: epoch)
observer = Astronoby::Observer.new(
  latitude: Astronoby::Angle.from_degrees(48.8566),
  longitude: Astronoby::Angle.from_degrees(2.3522)
)
twilight_events = sun.twilight_events(observer: observer)

twilight_events.morning_astronomical_twilight_time
# => 2024-01-01 05:47:24 UTC

twilight_events.morning_nautical_twilight_time
# => 2024-01-01 06:25:41 UTC

twilight_events.morning_civil_twilight_time
# => 2024-01-01 07:05:51 UTC

twilight_events.evening_civil_twilight_time
# => 2024-01-01 16:37:37 UTC

twilight_events.evening_nautical_twilight_time
# => 2024-01-01 17:17:46 UTC

twilight_events.evening_astronomical_twilight_time
# => 2024-01-01 17:56:03 UTC

@rhannequin rhannequin self-assigned this Apr 14, 2024
@rhannequin rhannequin marked this pull request as ready for review April 14, 2024 13:56
Base automatically changed from observation_events to main April 15, 2024 19:48
In the same way `Astronoby::Events::ObservationEvents` represent
observation events for any body on the celestial sphere, twilight events
exist but are related only to the Sun. For example, it doesn't make
sense to talk about twilight related to a planet or a distant star.

In a goal of making events more centralized, twilight times are now
extract from `Astronoby::Sun` into their own dedicated
`Astronoby::Events::TwilightEvents` class.

The same methods are exposed. This adds natural memoization as all the
times are calculated when the object initialized, which is when the
`Astronoby::Sun#twilight_events` is called.
@rhannequin rhannequin merged commit c5eb2b8 into main Apr 15, 2024
@rhannequin rhannequin deleted the twilight-events branch April 15, 2024 19:54
rhannequin added a commit that referenced this pull request Apr 29, 2024
 ## What's Changed

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

[UPGRADING.md]: https://github.com/rhannequin/astronoby/blob/main/UPGRADING.md

 ### Bug fixes

* Fix ecliptic to equatorial epoch ([#56])

[#56]: #56

 ### Features

* Add twilight times ([#49])
* Add interpolation method ([#52])
* Add decimal_hour_to_time util ([#53])
* Calculate leap seconds for an instant ([#54])
* Add `Angle#-@` ([#55])
* Enable equivalence and hash equality to `Observer` ([#57])
* Twilight events dedicated class ([#61])

[#49]: #49
[#52]: #52
[#53]: #53
[#54]: #54
[#55]: #55
[#57]: #57
[#61]: #61

 ### Improvements

* Upgrade bundler from 2.3.11 to 2.5.7 by @dorianmariecom ([#45])
* Drop `BigDecimal` ([#46])
* Bump rake from 13.1.0 to 13.2.0 ([#47])
* Increase Ruby versions support ([#48])
* Bump rake from 13.2.0 to 13.2.1 ([#51])
* Dedicated constants class ([#62])
* Improve accuracy of equation of time ([#63])
* Twilight times better accuracy ([#65])
* Update UPGRADING.md ([#66])
* release: Bump version to 0.4.0 ([#67])

[#45]: #45
[#46]: #46
[#47]: #47
[#48]: #48
[#51]: #51
[#62]: #62
[#63]: #63
[#65]: #65
[#66]: #66
[#67]: #67

 ### Backward-incompatible changes

* More accurate rising, transit and setting times ([#50])
* Observation events dedicated and centralized class ([#60])
* Change `Astronoby::Sun` constructor ([#64])

[#50]: #50
[#60]: #60
[#64]: #64

 ## New Contributors

* @dorianmariecom made their first contribution in [#45]

[#45]: #45

**Full Changelog**: v0.3.0...v0.4.0
rhannequin added a commit that referenced this pull request Apr 29, 2024
## What's Changed

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

[UPGRADING.md]: https://github.com/rhannequin/astronoby/blob/main/UPGRADING.md

 ### Bug fixes

* Fix ecliptic to equatorial epoch ([#56])

[#56]: #56

 ### Features

* Add twilight times ([#49])
* Add interpolation method ([#52])
* Add decimal_hour_to_time util ([#53])
* Calculate leap seconds for an instant ([#54])
* Add `Angle#-@` ([#55])
* Enable equivalence and hash equality to `Observer` ([#57])
* Twilight events dedicated class ([#61])

[#49]: #49
[#52]: #52
[#53]: #53
[#54]: #54
[#55]: #55
[#57]: #57
[#61]: #61

 ### Improvements

* Upgrade bundler from 2.3.11 to 2.5.7 by @dorianmariecom ([#45])
* Drop `BigDecimal` ([#46])
* Bump rake from 13.1.0 to 13.2.0 ([#47])
* Increase Ruby versions support ([#48])
* Bump rake from 13.2.0 to 13.2.1 ([#51])
* Dedicated constants class ([#62])
* Improve accuracy of equation of time ([#63])
* Twilight times better accuracy ([#65])
* Update UPGRADING.md ([#66])
* release: Bump version to 0.4.0 ([#67])

[#45]: #45
[#46]: #46
[#47]: #47
[#48]: #48
[#51]: #51
[#62]: #62
[#63]: #63
[#65]: #65
[#66]: #66
[#67]: #67

 ### Backward-incompatible changes

* More accurate rising, transit and setting times ([#50])
* Observation events dedicated and centralized class ([#60])
* Change `Astronoby::Sun` constructor ([#64])

[#50]: #50
[#60]: #60
[#64]: #64

 ## New Contributors

* @dorianmariecom made their first contribution in [#45]

[#45]: #45

**Full Changelog**: v0.3.0...v0.4.0
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.

1 participant