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

calculation of 2023 spring equinox is off by over 1:30 #110

Closed thosmos closed 2 years ago

thosmos commented 2 years ago

Thank you for this great library. It's been super helpful.

I'm calculating equinoxes and solstices with SwiftAA and noticing over a minute and a half difference from various sources on the internet. For example, most sources say it will be at 21:24, but SwiftAA calculates it as 21:25:34. Is this degree of inaccuracy normal for this library? I'm curious if this is due to being out of date with the AA+ library which is up to v2.43 in 2022, whereas we're still using a the 2.0.9 version from 2019? Would it be much work to update AA+ to the newest version? I noticed in the change logs that various renames happened. Does this affect ObjCAA?

thosmos commented 2 years ago

After doing some more research I found that the underlying AA+ library has a comprehensive test suite and I discovered that to get an accurate UTC value, we need to use the TT2UTC function. This raises questions of the very convenient JulianDay(_ date:Date) constructor. Does this convert from UTC2TT before returning the JD value? When calling JulianDay(Date()).date does it convert from TT2UTC? Should it?

onekiloparsec commented 2 years ago

Thanks for your message @thosmos No, 1.5 minute off is not a normal accuracy for this library!

The constructor of the JulianDay from the Date isn't doing any conversion so far, but it seems we might need to reconsider the question.

The update of to a new version of AA+ library isn't too much work. Replacing the files, running the tests, correcting the calls that may have change. Would you mind making a PR?