onekiloparsec / SwiftAA

The most comprehensive collection of accurate astronomical algorithms in (C++, Objective-C and) Swift.
http://www.onekiloparsec.dev/
MIT License
171 stars 31 forks source link

BUG calculating illuminated fraction and phase angle #92

Closed suyamaha closed 4 years ago

suyamaha commented 4 years ago
let today = Date()
for i in 1...35 {
    let date = Calendar.current.date(byAdding: .day, value: i, to: today)!
    let moon = Moon(julianDay: JulianDay(date))
    print("\ndate: ", date)
    print("illuminated: ", moon.illuminatedFraction())
    print("phase angle: ", moon.phaseAngle().inRadians)
}

... date: 2020-06-20 07:58:09 +0000 illuminated: 0.009716656259011525 phase angle: 2.944 rad

-> BUG calculating illuminated fraction and phase angle date: 2020-06-21 07:58:09 +0000 illuminated: 3.156544325816357e-05 phase angle: 3.130 rad

date: 2020-06-22 07:58:09 +0000 illuminated: 0.012492466021575277 phase angle: 2.918 rad ...

// Use this to reproduce the error
if let date = Calendar.current.date(from: DateComponents(timeZone: TimeZone(secondsFromGMT: 0), year: 2020, month: 06, day: 21, hour: 08, minute: 00, second: 00)) {
    let moon = Moon(julianDay: JulianDay(date))
    print("date: ", date)
    print("illuminated: ", moon.illuminatedFraction())
    print("phase angle: ", moon.phaseAngle().inRadians)
}
tallPete commented 4 years ago

I am not involved with development on this project although I do use these very numbers in some software. Please do describe what the bug you are seeing is and importantly what you expected to see? It isn't obvious from the numbers you have given. Cheers.

HerrAlien commented 4 years ago

Looks correct to me. According to https://the-moon.us/wiki/Phase_angle , it is supposed to be around PI radians at new moon.

On Thu, May 21, 2020 at 4:34 AM Peter Smith notifications@github.com wrote:

I am not involved with development on this project although I do use these very numbers in some software. Please do describe what the bug you are seeing is? It isn't obvious from the numbers you have given. Cheers.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/onekiloparsec/SwiftAA/issues/92#issuecomment-631825820, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI7JWRF3KNIVPIC4GQX2NWLRSSAI5ANCNFSM4NF3QZRA .

suyamaha commented 4 years ago

I am not involved with development on this project although I do use these very numbers in some software. Please do describe what the bug you are seeing is and importantly what you expected to see? It isn't obvious from the numbers you have given. Cheers.

My mistake. I apologize. The calculation is correct. Please delete this issue. Thanks a lot.

suyamaha commented 4 years ago

Looks correct to me. According to https://the-moon.us/wiki/Phase_angle , it is supposed to be around PI radians at new moon.

You're right. Thank you.

onekiloparsec commented 4 years ago

Auto-solving issue ? Thanks a lot everybody. :-) Don't hesitate for any question, even if documentation is here, it is not an easy codebase...