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 loop in sunrise computation #258

Open
fpinnahub opened this issue Jul 17, 2023 · 0 comments
Open

Endless loop in sunrise computation #258

fpinnahub opened this issue Jul 17, 2023 · 0 comments

Comments

@fpinnahub
Copy link

With version 4.1.4 I think there is an endless loop happening in sunrise calculation for some particular latitude, longitude and elevation.
I share below an example:

# venv/Lib/site-packages/ephem/__init__.py --> line 490, endless loop
#
# overtake by setting: default_newton_precision = minute

import ephem
from datetime import datetime
from timezonefinder import TimezoneFinder
from pytz import timezone

ephem_obj = ephem.Sun()

latitude = 69.043
longitude = 20.851
elevation = 1009

# Create an observer object
observer = ephem.Observer()

# Set the observer's location
observer.lat = str(latitude)
observer.lon = str(longitude)
observer.elev = elevation

tf = TimezoneFinder()
tz_str = tf.timezone_at(lat=latitude, lng=longitude)
tz = timezone(tz_str)

# Set the observer's date and time in local
observer.date = datetime(2023, 5, 21, 0, 0, 0, 0, tz)

sr = observer.next_rising(ephem_obj)	# Here, endless loop! *****************
sunrise = datetime(*map(int, sr.tuple()), 0, timezone('UTC'))
ss = observer.next_setting(ephem_obj)
sunset = datetime(*map(int, ss.tuple()), 0, timezone('UTC'))

Thanks in advance for your support and work.

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