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

earth.twilights(forSunAltitude, coordinates) - Skips over SunSet Time for 10/17/2024 #124

Open
johnnyturpin-aow opened this issue Oct 17, 2024 · 0 comments

Comments

@johnnyturpin-aow
Copy link

johnnyturpin-aow commented Oct 17, 2024

Not able to find the sunSet time for 10/17/2024 - with a sunAltitude of .astronomical

To verify this, I created a loop where I called earth.twilights() repeatedly incrementing the JulianTime by 1 hour each iteration - and it never returns a sunSet time for 10/17/2024.

This only seems to occur with a sunAltitude of .astronomical. Weird.

Here are the results where it transitions from returning valid riset/set times for 10/16 - and then immediately jumps to 10/18

setRiseTransitTimes for: 10/17 at: 6:00 PM
sunRise = 10/17 at: 5:56 AM
sunSet = 10/16 at: 8:00 PM
transitTime = 10/17 at: 12:58 PM
transitError = None

setRiseTransitTimes for: 10/17 at: 7:00 PM
sunRise = 10/17 at: 5:56 AM
sunSet = 10/16 at: 8:00 PM
transitTime = 10/17 at: 12:58 PM
transitError = None

setRiseTransitTimes for: 10/17 at: 8:00 PM
sunRise = 10/18 at: 5:57 AM
sunSet = 10/18 at: 7:58 PM
transitTime = 10/18 at: 12:58 PM
transitError = None

setRiseTransitTimes for: 10/17 at: 9:00 PM
sunRise = 10/18 at: 5:57 AM
sunSet = 10/18 at: 7:58 PM
transitTime = 10/18 at: 12:58 PM
transitError = None

And here is the code snippit I am using to test this - nothing too complicated:

Note: computedTargetDay is set to 12:00 PM UTC-4 (Noon EST) on 10/17/2024

stepTime = computedTargetDay.addingTimeInterval(TimeConstants.secsInDay * -2)
endTime = stepTime.addingTimeInterval(TimeConstants.secsInDay * 4)
			
print("===== \(computedTargetDay.astroTime)")
while stepTime < endTime {
    let earth = Earth(julianDay: JulianDay(stepTime))
    let twilights = earth.twilights(forSunAltitude: twilightAltitude.rawValue, coordinates: geographic)

    print("setRiseTransitTimes for: \(stepTime.astroTime)")
    print("sunRise = \(twilights.riseTime?.date.astroTime ?? "")")
    print("sunSet = \(twilights.setTime?.date.astroTime ?? "")")
    print("transitTime = \(twilights.transitTime?.date.astroTime ?? "")")
    print("transitError = \(twilights.transitError?.localizedDescription ?? "None")")

    sunTimes.append(twilights)
    stepTime = stepTime.addingTimeInterval(TimeConstants.secsInHour * 1)
}
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

1 participant