aboutsummaryrefslogtreecommitdiffstats
path: root/src/solar_python.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-07-26 12:07:25 +0200
committerMattias Andrée <maandree@operamail.com>2014-07-26 12:07:25 +0200
commit589a45c90f18203a91208996c40e14d9d4f1b7ea (patch)
tree7101440134b312820771a87b7d8f8dd6c549a1e7 /src/solar_python.py
parentadd SOLAR_APPARENT_RADIUS (diff)
downloadsolar-python-589a45c90f18203a91208996c40e14d9d4f1b7ea.tar.gz
solar-python-589a45c90f18203a91208996c40e14d9d4f1b7ea.tar.bz2
solar-python-589a45c90f18203a91208996c40e14d9d4f1b7ea.tar.xz
fix solar_prediction bug2
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/solar_python.py')
-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 19694d5..76923bf 100644
--- a/src/solar_python.py
+++ b/src/solar_python.py
@@ -528,6 +528,7 @@ def solar_prediction(delta, requested, fun, epsilon = 0.000001, span = 0.01, t =
@return :float? The calculated time point, `None` if none
were found within the specified time span
'''
+ fun = lambda t : fun(t) - requested
t = julian_centuries() if t is None else t
t1 = t2 = t
v1 = v0 = fun(t)
@@ -538,9 +539,9 @@ def solar_prediction(delta, requested, fun, epsilon = 0.000001, span = 0.01, t =
return None
t2 += delta
v2 = fun(t2)
- if (v1 <= requested <= v2) or ((requested >= v1 >= v2) and (requested <= v0)):
+ if (v1 <= 0 <= v2) or ((0 >= v1 >= v2) and (0 <= v0)):
break
- if (v1 >= requested >= v2) or ((requested <= v1 <= v2) and (requested >= v0)):
+ if (v1 >= 0 >= v2) or ((0 <= v1 <= v2) and (0 >= v0)):
break
t1 = t2
v2 = v1
@@ -554,12 +555,12 @@ def solar_prediction(delta, requested, fun, epsilon = 0.000001, span = 0.01, t =
if abs(v1 - v2) < epsilon:
return tm if abs(vm) < epsilon else None
if v1 < v2:
- if requested < vm:
+ if 0 < vm:
t2 = tm
else:
t1 = tm
elif v1 > v2:
- if requested > vm:
+ if 0 > vm:
t2 = tm
else:
t1 = tm