summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-06-05 02:25:34 +0200
committerMattias Andrée <maandree@operamail.com>2014-06-05 02:25:34 +0200
commit2dfb4fbbcb4251a3329c1ad46da4b39a30e059c7 (patch)
tree294e7d2e8cf20dfe9385b105e226c6a277390d08 /src
parentm (diff)
downloadblueshift-2dfb4fbbcb4251a3329c1ad46da4b39a30e059c7.tar.gz
blueshift-2dfb4fbbcb4251a3329c1ad46da4b39a30e059c7.tar.bz2
blueshift-2dfb4fbbcb4251a3329c1ad46da4b39a30e059c7.tar.xz
fix have_sunrise_and_sunset
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/solar.py9
1 files 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):