From e375fbe34995777e0d2831ef089a64da7b05b476 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 28 Nov 2015 05:30:22 +0100 Subject: fix solstice and derivative MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/solar_python.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') 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) -- cgit v1.2.3-70-g09d2