Add Astronoby::Moon#current_phase_fraction
#115
Merged
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.
While
#illuminated_fraction
already provides a valid information on how much the Moon seems illuminated as observed from the Earth, it doesn't help deduce the current phase name. When the Moon is 45% illuminated, it can be either the First Quarter or the Last Quarter, there is no way of knowing without calculating when is was the previous Full Moon and when is the next one.To help with this, we introduce
#current_phase_fraction
, based on the mean elongation, which is a number from 0 to 1 which always increase while we're getting closer to the next New Moon.As it is using
#mean_elongation
, the result is not extremely precise, however it is precise enough to deduce the current phase name for a given day.For a user wanting to get accurate phase times, it is preferred to use
::monthly_phase_events
.Fixes #101