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

Endless computation of previous_rising/previous_setting for Sun at elevation #253

Open
MADZEROPIE opened this issue Feb 3, 2023 · 3 comments

Comments

@MADZEROPIE
Copy link

MADZEROPIE commented Feb 3, 2023

Parametrs: 2015/6/27 22:57:57.947291 65.7959 -123.7879

def nightMask(day, time, lat, lon):
    sun_height = 90000
    observer = ephem.Observer()
    observer.lat, observer.lon, observer.elevation = str(lat), str(lon), sun_height
    observer.date = day + ' ' + time
    # print(day, time, lat, lon)
    try:
        if observer.previous_rising(ephem.Sun()).datetime() > observer.previous_setting(ephem.Sun()).datetime():
            return False
        else:
            return True
    except:
        return None

Ephem version: 4.1.3.
UPD: Updated to 4.1.4, still not working.

@drbitboy
Copy link
Contributor

drbitboy commented Feb 3, 2023

  • northern hemisphere
  • 0.8° latitude from the land of the midnight sun,
  • 90km(?) elevation,
  • six days after the summer solstice.

Although it will not fix the library problem, simpler logic would be return observer.<sun below horizon>()

@MADZEROPIE
Copy link
Author

Yeah. I've used something like this before

    sun = ephem.Sun()
    sun.compute(observer) 
    return sun.alt < 0 

But I'm intrested in time after sunset. So I have to use observer.previous_rising() anyway...

@drbitboy
Copy link
Contributor

drbitboy commented Feb 4, 2023

that function nightMask(...) returns True if the time arguments represent a time between the previous sunset, and that previous sunset's subsequent rising, which is essentially the same information that sun.alt < 0 returns. there is no difference unless there is an issue with the sun not being a point; even if that is an issue, sun.alt could be compared to a small negative number, e.g. half the angular width of the sun, to get the same information.

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

2 participants