[Python-modules-commits] [python-pysolar] 15/18: solar.py: increased execution speed of GetAltitude() and GetAzimuth by ~2.2x by precalculating polynomial estimations of nutation aberrations, rather than recalculating them for every entry in nutation coefficient table.

Wolfgang Borgert debacle at moszumanska.debian.org
Fri Oct 3 23:36:11 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to annotated tag 0.3.0
in repository python-pysolar.

commit 36f7d48a45789e8e5d5e47525808db4332530f6b
Author: Brandon Stafford <brandon at pingswept.org>
Date:   Sun Aug 31 22:31:38 2008 -0400

    solar.py: increased execution speed of GetAltitude() and GetAzimuth by ~2.2x by precalculating polynomial estimations of nutation aberrations, rather than recalculating them for every entry in nutation coefficient table.
---
 solar.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/solar.py b/solar.py
index 0320f03..0abca13 100644
--- a/solar.py
+++ b/solar.py
@@ -237,16 +237,8 @@ def GetMeanSiderealTime(julian_day):
 	sidereal_time =  280.46061837 + (360.98564736629 * (julian_day - 2451545.0)) + (0.000387933 * jc ** 2) - (jc ** 3 / 38710000)
 	return sidereal_time % 360
 
-def GetNutationAberrationXY(jce, i):
+def GetNutationAberrationXY(jce, i, x):
 	y = constants.aberration_sin_terms
-	x = []
-	p = poly.buildPolyDict()
-	# order of 5 x.append lines below is important
-	x.append(p['MeanElongationOfMoon'](jce))
-	x.append(p['MeanAnomalyOfSun'](jce))
-	x.append(p['MeanAnomalyOfMoon'](jce))
-	x.append(p['ArgumentOfLatitudeOfMoon'](jce))
-	x.append(p['LongitudeOfAscendingNode'](jce))
 	sigmaxy = 0.0
 	for j in range(len(x)):
 		sigmaxy += x[j] * y[i][j]
@@ -257,9 +249,10 @@ def GetNutation(jde):
 	jce = julian.GetJulianEphemerisCentury(jde)
 	nutation_long = []
 	nutation_oblique = []
+	x = PrecalculateAberrations(poly.buildPolyDict(), jce)
 
 	for i in range(len(abcd)):
-		sigmaxy = GetNutationAberrationXY(jce, i)
+		sigmaxy = GetNutationAberrationXY(jce, i, x)
 		nutation_long.append((abcd[i][0] + (abcd[i][1] * jce)) * math.sin(math.radians(sigmaxy)))
 		nutation_oblique.append((abcd[i][2] + (abcd[i][3] * jce)) * math.cos(math.radians(sigmaxy)))
 
@@ -355,3 +348,12 @@ def GetTrueEclipticObliquity(jme, nutation):
 	+ (27.87 * u ** 8) + (5.79 * u ** 9) + (2.45 * u ** 10)
 	return (mean_obliquity / 3600.0) + nutation['obliquity']
 
+def PrecalculateAberrations(p, jce):
+	x = []
+	# order of 5 x.append lines below is important
+	x.append(p['MeanElongationOfMoon'](jce))
+	x.append(p['MeanAnomalyOfSun'](jce))
+	x.append(p['MeanAnomalyOfMoon'](jce))
+	x.append(p['ArgumentOfLatitudeOfMoon'](jce))
+	x.append(p['LongitudeOfAscendingNode'](jce))
+	return x

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pysolar.git



More information about the Python-modules-commits mailing list