Significant performance boost to Python code: eliminate _ter2cel().

There were 3 calls to _ter2cel(), each of which redundantly
called _sidereal_time, which results in 3 calculations of _e_tilt().
Reworked so there is only one call to _e_tilt().

Minor changes to support using cProfile, which is how I found this.
This commit is contained in:
Don Cross
2019-06-27 14:22:59 -04:00
parent f85025da31
commit c611b50d3f
4 changed files with 22 additions and 22 deletions

View File

@@ -693,10 +693,6 @@ def _spin(angle, pos1):
pos1[2]
]
def _ter2cel(time, vec1):
gast = _sidereal_time(time)
return _spin(-15.0 * gast, vec1)
#----------------------------------------------------------------------------
# BEGIN CalcMoon
@@ -2024,9 +2020,10 @@ def Horizon(time, observer, ra, dec, refraction):
une = [-sinlat*coslon, -sinlat*sinlon, coslat]
uwe = [sinlon, -coslon, 0.0]
uz = _ter2cel(time, uze)
un = _ter2cel(time, une)
uw = _ter2cel(time, uwe)
angle = -15.0 * _sidereal_time(time)
uz = _spin(angle, uze)
un = _spin(angle, une)
uw = _spin(angle, uwe)
p = [cosdc*cosra, cosdc*sinra, sindc]