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

Feature request: report whether we have midnight sun or polar night #32

Open
rfjakob opened this issue Jul 10, 2024 · 1 comment · May be fixed by #33
Open

Feature request: report whether we have midnight sun or polar night #32

rfjakob opened this issue Jul 10, 2024 · 1 comment · May be fixed by #33

Comments

@rfjakob
Copy link

rfjakob commented Jul 10, 2024

In the polar regions, the sun may stay up the whole day (midnight sun) or may stay down the whole day (polar night). In both cases, we raise the same exception:

raise SunTimeException('The sun never rises on this location (on the specified date)')

It would be useful to know whether we have sunlight the whole day or night the whole day.

Looking at

suntime/suntime/suntime.py

Lines 104 to 107 in 8053379

if cosH > 1:
return None # The sun never rises on this location (on the specified date)
if cosH < -1:
return None # The sun never sets on this location (on the specified date)

it seems that the algorithm knows whether we have midnight sun or polar night.

Could you raise a different exception depending on whether we have midnight sun or polar night?

If you agree that this is a useful feature I can try to make a PR.

@rfjakob rfjakob changed the title Feature request: report whether sun is always up or always down Feature request: report whether we have midnight sun or polar night Jul 10, 2024
rfjakob added a commit to rfjakob/suntime that referenced this issue Jul 11, 2024
Instead of just raising SunTimeException, report
whether we have midnight sun or polar night.

Implemented in a backwards-compatible way by
subclassing SunTimeException.

That catching SunTimeException still works as before
is verified by extending the tests.

Fixes SatAgro#32
@rfjakob rfjakob linked a pull request Jul 11, 2024 that will close this issue
rfjakob added a commit to rfjakob/ntpstrip that referenced this issue Jul 22, 2024
Instead of just raising SunTimeException, report
whether we have midnight sun or polar night.

Implemented in a backwards-compatible way by
subclassing SunTimeException.

That catching SunTimeException still works as before
is verified by extending the tests.

Fixes SatAgro/suntime#32

Upstream PR:
SatAgro/suntime@0b59d7b
@bendeaton
Copy link

+1 this request, came here looking for this. My use case is computing hours of daylight at a location, so a more specific exception would help me distinguish 0 vs 24 hours.

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