Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase Data Seems Odd #2

Open
skipgraham opened this issue Apr 16, 2019 · 2 comments
Open

Phase Data Seems Odd #2

skipgraham opened this issue Apr 16, 2019 · 2 comments

Comments

@skipgraham
Copy link

I've not quite figured this one out, but I have not dug into the algorithm. If I pass 15 consecutive dates into the moon illumination function, i would expect the return value for "phase" to progress through multiple phases. What I am getting is quite different.

// basic pseudo-code of call interation
var sunMoon: SwiftySuncalc! = SwiftySuncalc()
for date in dates {     // 15 consecutive days of Dates in dates
   let dict = sunMoon.getMoonIllumination(date: date)
   print(dict["phase"])
}

What I am getting is something like this:

0.3497411806334137
0.37585891141293126
0.3758589140085576
0.37585891487953565
0.37585891703961904
0.375858919217154
0.37585892094173023
0.3758589222482511
0.3758589244083345
... and similar through the remaining

I found it odd that the first iteration produced a difference of ~.03 but the next series of iterations barely moved the needle. In theory, the moon phase should progress through a little over half a full cycle in 15 days. Any thoughts? It's certainly possible that I did not interpret the usage of the phase correctly - i.e. does it need to be used in combination with the angle to get the phase values 0.0 - 1.0

@BurgerZ
Copy link

BurgerZ commented Apr 28, 2020

I think this is because of this part of code:

        if date < Date() {
            d = toDays(date: date)
        } else {
            d = toDays(date: Date())
        }

So, if you want to get the moon illumination for tomorrow or later, you'll always get today's data.

Fix: just remove these lines from the getMoonIllumination function.

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

No branches or pull requests

3 participants
@BurgerZ @skipgraham and others