Python: Another _CalcMoon performance improvement.

Reworked Term() to use less array indexing; pack and unpack tuples instead.
Execution time for riseset is just below 51 seconds now.
This commit is contained in:
Don Cross
2019-07-03 19:54:10 -04:00
parent adc424106c
commit 810724a7da
2 changed files with 22 additions and 22 deletions

View File

@@ -813,24 +813,24 @@ def _CalcMoon(time):
I += 1
def Term(p, q, r, s):
result = (1, 0)
(a, b) = (1, 0)
if p != 0:
result = AddThe(result[0], result[1], co[p][1], si[p][1])
(a, b) = AddThe(a, b, co[p][1], si[p][1])
if q != 0:
result = AddThe(result[0], result[1], co[q][2], si[q][2])
(a, b) = AddThe(a, b, co[q][2], si[q][2])
if r != 0:
result = AddThe(result[0], result[1], co[r][3], si[r][3])
(a, b) = AddThe(a, b, co[r][3], si[r][3])
if s != 0:
result = AddThe(result[0], result[1], co[s][4], si[s][4])
return result
(a, b) = AddThe(a, b, co[s][4], si[s][4])
return (a, b)
def AddSol(coeffl, coeffs, coeffg, coeffp, p, q, r, s):
nonlocal DLAM, DS, GAM1C, SINPI
result = Term(p, q, r, s)
DLAM += coeffl * result[1]
DS += coeffs * result[1]
GAM1C += coeffg * result[0]
SINPI += coeffp * result[0]
(a, b) = Term(p, q, r, s)
DLAM += coeffl * b
DS += coeffs * b
GAM1C += coeffg * a
SINPI += coeffp * a
AddSol( 13.902, 14.06,-0.001, 0.2607,0, 0, 0, 4)
AddSol( 0.403, -4.01,+0.394, 0.0023,0, 0, 0, 3)