From 835d6e524bff9afb324fc422bb3bf7535edacd6a Mon Sep 17 00:00:00 2001 From: Don Cross Date: Wed, 3 Jul 2019 21:34:26 -0400 Subject: [PATCH] fixaddsol: Eliminate Term and AddSol functions completely. 44.4 seconds. --- generate/template/astronomy.py | 39 +++++++++------------------------- generate/template/old.py | 39 +++++++++------------------------- source/python/astronomy.py | 39 +++++++++------------------------- 3 files changed, 30 insertions(+), 87 deletions(-) diff --git a/generate/template/astronomy.py b/generate/template/astronomy.py index 98c9daa0..0c7f47e6 100644 --- a/generate/template/astronomy.py +++ b/generate/template/astronomy.py @@ -721,34 +721,6 @@ def _CalcMoon(time): I += 1 - def Term(p, q, r, s): - (a, b) = (1, 0) - if p != 0: - (a, b) = AddThe(a, b, co[p][1], si[p][1]) - if q != 0: - (a, b) = AddThe(a, b, co[q][2], si[q][2]) - if r != 0: - (a, b) = AddThe(a, b, co[r][3], si[r][3]) - if s != 0: - (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 - (a, b) = (1, 0) - if p != 0: - (a, b) = AddThe(a, b, co[p][1], si[p][1]) - if q != 0: - (a, b) = AddThe(a, b, co[q][2], si[q][2]) - if r != 0: - (a, b) = AddThe(a, b, co[r][3], si[r][3]) - if s != 0: - (a, b) = AddThe(a, b, co[s][4], si[s][4]) - 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) (a, b) = (co[4][4], si[4][4]) @@ -1575,7 +1547,16 @@ def _CalcMoon(time): DS += -0.04 * b def ADDN(coeffn, p, q, r, s): - return coeffn * Term(p, q, r, s)[1] + (a, b) = (1, 0) + if p != 0: + (a, b) = AddThe(a, b, co[p][1], si[p][1]) + if q != 0: + (a, b) = AddThe(a, b, co[q][2], si[q][2]) + if r != 0: + (a, b) = AddThe(a, b, co[r][3], si[r][3]) + if s != 0: + (a, b) = AddThe(a, b, co[s][4], si[s][4]) + return coeffn * b N = 0 N += ADDN(-526.069, 0, 0,1,-2) diff --git a/generate/template/old.py b/generate/template/old.py index 99caf667..513af27f 100644 --- a/generate/template/old.py +++ b/generate/template/old.py @@ -721,34 +721,6 @@ def _CalcMoon(time): I += 1 - def Term(p, q, r, s): - (a, b) = (1, 0) - if p != 0: - (a, b) = AddThe(a, b, co[p][1], si[p][1]) - if q != 0: - (a, b) = AddThe(a, b, co[q][2], si[q][2]) - if r != 0: - (a, b) = AddThe(a, b, co[r][3], si[r][3]) - if s != 0: - (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 - (a, b) = (1, 0) - if p != 0: - (a, b) = AddThe(a, b, co[p][1], si[p][1]) - if q != 0: - (a, b) = AddThe(a, b, co[q][2], si[q][2]) - if r != 0: - (a, b) = AddThe(a, b, co[r][3], si[r][3]) - if s != 0: - (a, b) = AddThe(a, b, co[s][4], si[s][4]) - 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) AddSol( 2369.912, 2373.36,+0.601, 28.2333,0, 0, 0, 2) @@ -857,7 +829,16 @@ def _CalcMoon(time): AddSol( -0.330, -0.04, 0.0 , 0.0 ,3, 0, 2, 0) def ADDN(coeffn, p, q, r, s): - return coeffn * Term(p, q, r, s)[1] + (a, b) = (1, 0) + if p != 0: + (a, b) = AddThe(a, b, co[p][1], si[p][1]) + if q != 0: + (a, b) = AddThe(a, b, co[q][2], si[q][2]) + if r != 0: + (a, b) = AddThe(a, b, co[r][3], si[r][3]) + if s != 0: + (a, b) = AddThe(a, b, co[s][4], si[s][4]) + return coeffn * b N = 0 N += ADDN(-526.069, 0, 0,1,-2) diff --git a/source/python/astronomy.py b/source/python/astronomy.py index 666cac97..ac69f31e 100644 --- a/source/python/astronomy.py +++ b/source/python/astronomy.py @@ -812,34 +812,6 @@ def _CalcMoon(time): I += 1 - def Term(p, q, r, s): - (a, b) = (1, 0) - if p != 0: - (a, b) = AddThe(a, b, co[p][1], si[p][1]) - if q != 0: - (a, b) = AddThe(a, b, co[q][2], si[q][2]) - if r != 0: - (a, b) = AddThe(a, b, co[r][3], si[r][3]) - if s != 0: - (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 - (a, b) = (1, 0) - if p != 0: - (a, b) = AddThe(a, b, co[p][1], si[p][1]) - if q != 0: - (a, b) = AddThe(a, b, co[q][2], si[q][2]) - if r != 0: - (a, b) = AddThe(a, b, co[r][3], si[r][3]) - if s != 0: - (a, b) = AddThe(a, b, co[s][4], si[s][4]) - 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) (a, b) = (co[4][4], si[4][4]) @@ -1666,7 +1638,16 @@ def _CalcMoon(time): DS += -0.04 * b def ADDN(coeffn, p, q, r, s): - return coeffn * Term(p, q, r, s)[1] + (a, b) = (1, 0) + if p != 0: + (a, b) = AddThe(a, b, co[p][1], si[p][1]) + if q != 0: + (a, b) = AddThe(a, b, co[q][2], si[q][2]) + if r != 0: + (a, b) = AddThe(a, b, co[r][3], si[r][3]) + if s != 0: + (a, b) = AddThe(a, b, co[s][4], si[s][4]) + return coeffn * b N = 0 N += ADDN(-526.069, 0, 0,1,-2)