aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-11-28 05:30:22 +0100
committerMattias Andrée <maandree@operamail.com>2015-11-28 05:30:22 +0100
commite375fbe34995777e0d2831ef089a64da7b05b476 (patch)
tree15d41bb4a9075befd501f50bf8047d4832a91849
parentadd info manual + fix documentation (diff)
downloadsolar-python-e375fbe34995777e0d2831ef089a64da7b05b476.tar.gz
solar-python-e375fbe34995777e0d2831ef089a64da7b05b476.tar.bz2
solar-python-e375fbe34995777e0d2831ef089a64da7b05b476.tar.xz
fix solstice and derivative
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/solar_python.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/solar_python.py b/src/solar_python.py
index 7233df2..b81baa4 100644
--- a/src/solar_python.py
+++ b/src/solar_python.py
@@ -74,7 +74,7 @@ SOLAR_ELEVATION_RANGE_ASTRONOMICAL_TWILIGHT = (-18.0, -12.0)
# The following functions are used to calculate the result for `sun`
# (most of them) but could be used for anything else. There name is
-# should tell you enough, `t` (and `noon`) is in Julian centuries
+# should tell you enough, `t` (and `noon`) is in Julian Centuries
# except for in the convertion methods.
@@ -529,7 +529,7 @@ def solar_prediction(delta, requested, fun, epsilon = 0.000001, span = 0.01, t =
calculate the time point of occurrence
@param fun:(t:float)→float Function that calculate the data of interest
@param epsilon:float Error tolerance for `requested`
- @param span:float The number of Julian centuries (0,01 for
+ @param span:float The number of Julian Centuries (0,01 for
one year) to restrict the search to
@param t:float? The time in Julian Centuries, `None` for
the current time
@@ -624,7 +624,7 @@ def future_past_solstice(delta, t = None):
'''
e = 0.00001
fun = solar_declination
- dfun = lambda t : (fun(t + e) - fun(t - e)) / 2
+ dfun = lambda t : (fun(t + e) - fun(t - e)) / (2 * e)
return solar_prediction(delta, 0, dfun, t = t)
@@ -726,8 +726,9 @@ def future_past_elevation_derivative(delta, latitude, longitude, derivative, t =
@return :float? The calculated time point, `None` if
none were found within a year
'''
+ e = 0.00001
fun = lambda t : solar_elevation(latitude, longitude, t)
- dfun = lambda t : (fun(t + e) - fun(t - e)) / 2
+ dfun = lambda t : (fun(t + e) - fun(t - e)) / (2 * e)
return solar_prediction(delta, derivative, dfun, t = t)