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

Issue with sunrise and sunset calculations #202

Open
tjryankeogh opened this issue Apr 23, 2024 · 4 comments · May be fixed by #204
Open

Issue with sunrise and sunset calculations #202

tjryankeogh opened this issue Apr 23, 2024 · 4 comments · May be fixed by #204

Comments

@tjryankeogh
Copy link
Member

There is an issue in the calculation of sunrise and sunset.

For some longitudes >~70E the sunrise is later than sunset.

Example data:

'2021-03-06'
lat = 20.2
lon = 154.7

sunrise = '2021-03-06T19:56:00.000000'
sunset = '2021-03-06T07:47:00.000000'

If we change lon to 65E then there is no issue:

sunrise = '2021-03-06T01:57:00.000000'
sunset = '2021-03-06T13:47:00.000000'

@MartinMohrmann
Copy link
Member

MartinMohrmann commented Apr 24, 2024

Welcome and thank you for reporting the issue!
I just had a quick look at the sunset_sunrise function used in GliderTools, and I can see that it returns the results in "Coordinated universal time" (UTC). Your coordinates lie in a time zone that is UTC+10, which means to get the local time you would have to add 10 h to the result (or use some inbuild python time zone conversion magic possibly).
I have not (yet) checked if the time zones are handled correctly in related functions such as the quenching correction. So feel free to report back if you suspect a bug somewhere else.
It could be a good idea to above information to the function documentation.

@tjryankeogh
Copy link
Member Author

But if you add in the timezone hours, +10h, you would still need to add to both sunrise and sunset and therefore sunrise would still technically be after sunset. I have checked this with the Astral package as well (the original package used in GliderTools for sunrise/sunset calculations) and the issue persists there as well.
I believe it is an issue with the almanacs used by both Skyfield and Astral. But perhaps we need a fix that says if sunrise is greater sunset that the date should be adjusted.
The day and night batches in the quenching correction rely on the sunrise being less than sunset to correctly group the profiles.

@MartinMohrmann
Copy link
Member

Ah, I see. This means we will need a patch to make GliderTools quenching correction work at your longitudes, preferably directly in our sunset_sunrise function or even upstream in the skyfield/astral packages if a bug exists there. In case your find a good universal solution, please share it. Either here or as a pull request. :)
(Contribution Guide).

@MartinMohrmann MartinMohrmann linked a pull request May 16, 2024 that will close this issue
4 tasks
@MartinMohrmann
Copy link
Member

I addressed this issue in pull request #204, branch fix_#202. Feel free to use and comment/test.

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

Successfully merging a pull request may close this issue.

2 participants