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

RiseTransitSetTimes returns a setTime prior to rise time? #117

Closed johnnyturpin-aow closed 1 year ago

johnnyturpin-aow commented 1 year ago

I am a bit confused about the riseTransitSetTimes methods for CelestialBody. I am getting results for some objects calculated at a specific time where the setTime is prior to the riseTime.

Are my expectations incorrect that the times should be in the sequence of rise -> transit -> set?

Should I add 24hr to the setTime result when a setTime is prior to riseTime or should make two riseSetTransitTimes calls and merge the results so that I get a setTime value that is after the transit?

Here is a use-case where it resulted in rise -> transit -> set times in correct chronological order:

building displayable data for object = NGC6405 (Butterfly Cluster)
object viewing time: 3/5 at: 4:03 PM
sunRise: 3/5 at: 6:38 AM
sunSet: 3/4 at: 6:10 PM
object riseTime(Jd) = JD 2460008.82
object transitTime(Jd) = JD 2460009.00
object setTime(Jd) = JD 2460009.18
object riseTime(local) = 3/5 at: 2:47 AM
object transitTime(local) = 3/5 at: 7:01 AM
object setTime(local) = 3/5 at: 11:15 AM

And here is a use-case where it resulted in rise -> transit -> set times where the setTime is prior to the riseTime:

building displayable data for object = NGC1952 (Crab Nebula)
object viewing time: 3/5 at: 4:10 PM
sunRise: 3/5 at: 6:38 AM
sunSet: 3/4 at: 6:10 PM
object riseTime(Jd) = JD 2460009.20
object transitTime(Jd) = JD 2460009.50
object setTime(Jd) = JD 2460008.80
object riseTime(local) = 3/5 at: 11:43 AM
object transitTime(local) = 3/5 at: 6:53 PM
object setTime(local) = 3/5 at: 2:07 AM
onekiloparsec commented 1 year ago

It's a good question, for which I don't see necessarily a definitive answer.

From my memory, these times require a small iterative process to minimise a distance. And depending on where the min distance is found (after or before the provided starting time), you end up with rise, transit & set times not exactly in the "night" you want.

It thought it was better to leave to the client to verify, and apply possible corrections, rather than imposing one myself.

johnnyturpin-aow commented 1 year ago

Thanks for the response... that is what I kinda figured.