From 2dfb4fbbcb4251a3329c1ad46da4b39a30e059c7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 5 Jun 2014 02:25:34 +0200 Subject: fix have_sunrise_and_sunset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/solar.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/solar.py b/src/solar.py index 47fd5be..03cb7ce 100644 --- a/src/solar.py +++ b/src/solar.py @@ -437,12 +437,15 @@ def solar_elevation(latitude, longitude, t = None): return degrees(rc) -# TODO test, document and demo +# TODO document and demo def have_sunrise_and_sunset(latitude, t = None): t = julian_centuries() if t is None else t d = degrees(solar_declination(t)) - latitude = abs(latitude) - return (-90 + d < latitude < 90 - d) or (-90 - d < latitude < 90 + d) + latitude = abs(latitude) ## Covert everything to the Northern hemisphere + if d >= 0: + return -90 + d < latitude < 90 - d ## Northern summer + else: + return -90 - d < latitude < 90 + d ## Northern winter def future_past_elevation(delta, latitude, longitude, elevation, t = None): -- cgit v1.2.3-70-g09d2