From e75bf335c499f7c45a6db96b1a9fd96e81037906 Mon Sep 17 00:00:00 2001 From: Don Cross Date: Tue, 28 May 2024 17:25:02 -0400 Subject: [PATCH] Python problem might be in trig functions --- demo/python/astronomy.py | 10 +++++++--- generate/template/astronomy.py | 10 +++++++--- source/python/README.md | 9 --------- source/python/astronomy/astronomy.py | 10 +++++++--- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/demo/python/astronomy.py b/demo/python/astronomy.py index ef5b859f..cd14b81d 100644 --- a/demo/python/astronomy.py +++ b/demo/python/astronomy.py @@ -36,9 +36,11 @@ import datetime import enum import re import abc -from os import getenv +import os from typing import Any, List, Tuple, Optional, Union, Callable, Dict +_ProblemDebug:bool = ('1' == os.getenv('ASTRONOMY_ENGINE_PYTHON_PROBLEM')) + def _cbrt(x: float) -> float: '''Returns the cube root of x.''' y = (x ** (1.0 / 3.0)) if (x >= 0.0) else -((-x) ** (1.0 / 3.0)) @@ -3181,8 +3183,6 @@ def _VsopSphereToRect(lon: float, lat: float, rad: float) -> _TerseVector: rad * math.sin(lat) ) -_ProblemDebug:bool = ('1' == getenv('ASTRONOMY_ENGINE_PYTHON_PROBLEM')) - def _CalcVsop(model: _vsop_model_t, time: Time) -> Vector: t = time.tt / _DAYS_PER_MILLENNIUM lon = _VsopFormula(model.lon, t, True) @@ -3191,6 +3191,10 @@ def _CalcVsop(model: _vsop_model_t, time: Time) -> Vector: eclip = _VsopSphereToRect(lon, lat, rad) if _ProblemDebug: print('_CalcVsop: lon={:0.16g}, lat={:0.16g}, rad={:0.16g}, eclip=({:0.16g}, {:0.16g}, {:0.16g})'.format(lon, lat, rad, eclip.x, eclip.y, eclip.z)) + print('_CalcVsop: cos(lon) = {:0.16g}'.format(math.cos(lon))) + print('_CalcVsop: sin(lon) = {:0.16g}'.format(math.sin(lon))) + print('_CalcVsop: cos(lat) = {:0.16g}'.format(math.cos(lat))) + print('_CalcVsop: sin(lat) = {:0.16g}'.format(math.sin(lat))) return _VsopRotate(eclip).ToAstroVector(time) class _body_state_t: diff --git a/generate/template/astronomy.py b/generate/template/astronomy.py index 27d4a656..8a3cade6 100644 --- a/generate/template/astronomy.py +++ b/generate/template/astronomy.py @@ -36,9 +36,11 @@ import datetime import enum import re import abc -from os import getenv +import os from typing import Any, List, Tuple, Optional, Union, Callable, Dict +_ProblemDebug:bool = ('1' == os.getenv('ASTRONOMY_ENGINE_PYTHON_PROBLEM')) + def _cbrt(x: float) -> float: '''Returns the cube root of x.''' y = (x ** (1.0 / 3.0)) if (x >= 0.0) else -((-x) ** (1.0 / 3.0)) @@ -1866,8 +1868,6 @@ def _VsopSphereToRect(lon: float, lat: float, rad: float) -> _TerseVector: rad * math.sin(lat) ) -_ProblemDebug:bool = ('1' == getenv('ASTRONOMY_ENGINE_PYTHON_PROBLEM')) - def _CalcVsop(model: _vsop_model_t, time: Time) -> Vector: t = time.tt / _DAYS_PER_MILLENNIUM lon = _VsopFormula(model.lon, t, True) @@ -1876,6 +1876,10 @@ def _CalcVsop(model: _vsop_model_t, time: Time) -> Vector: eclip = _VsopSphereToRect(lon, lat, rad) if _ProblemDebug: print('_CalcVsop: lon={:0.16g}, lat={:0.16g}, rad={:0.16g}, eclip=({:0.16g}, {:0.16g}, {:0.16g})'.format(lon, lat, rad, eclip.x, eclip.y, eclip.z)) + print('_CalcVsop: cos(lon) = {:0.16g}'.format(math.cos(lon))) + print('_CalcVsop: sin(lon) = {:0.16g}'.format(math.sin(lon))) + print('_CalcVsop: cos(lat) = {:0.16g}'.format(math.cos(lat))) + print('_CalcVsop: sin(lat) = {:0.16g}'.format(math.sin(lat))) return _VsopRotate(eclip).ToAstroVector(time) class _body_state_t: diff --git a/source/python/README.md b/source/python/README.md index 5a7e928c..277cfdd4 100644 --- a/source/python/README.md +++ b/source/python/README.md @@ -3567,12 +3567,3 @@ latitude, longitude, and elevation for that vector. The geographic latitude, longitude, and elevation above sea level that corresponds to the given equatorial vector. ---- - - -### getenv(key, default=None) - -Get an environment variable, return None if it doesn't exist. -The optional second argument can specify an alternate default. -key, default and the result are str. - diff --git a/source/python/astronomy/astronomy.py b/source/python/astronomy/astronomy.py index ef5b859f..cd14b81d 100644 --- a/source/python/astronomy/astronomy.py +++ b/source/python/astronomy/astronomy.py @@ -36,9 +36,11 @@ import datetime import enum import re import abc -from os import getenv +import os from typing import Any, List, Tuple, Optional, Union, Callable, Dict +_ProblemDebug:bool = ('1' == os.getenv('ASTRONOMY_ENGINE_PYTHON_PROBLEM')) + def _cbrt(x: float) -> float: '''Returns the cube root of x.''' y = (x ** (1.0 / 3.0)) if (x >= 0.0) else -((-x) ** (1.0 / 3.0)) @@ -3181,8 +3183,6 @@ def _VsopSphereToRect(lon: float, lat: float, rad: float) -> _TerseVector: rad * math.sin(lat) ) -_ProblemDebug:bool = ('1' == getenv('ASTRONOMY_ENGINE_PYTHON_PROBLEM')) - def _CalcVsop(model: _vsop_model_t, time: Time) -> Vector: t = time.tt / _DAYS_PER_MILLENNIUM lon = _VsopFormula(model.lon, t, True) @@ -3191,6 +3191,10 @@ def _CalcVsop(model: _vsop_model_t, time: Time) -> Vector: eclip = _VsopSphereToRect(lon, lat, rad) if _ProblemDebug: print('_CalcVsop: lon={:0.16g}, lat={:0.16g}, rad={:0.16g}, eclip=({:0.16g}, {:0.16g}, {:0.16g})'.format(lon, lat, rad, eclip.x, eclip.y, eclip.z)) + print('_CalcVsop: cos(lon) = {:0.16g}'.format(math.cos(lon))) + print('_CalcVsop: sin(lon) = {:0.16g}'.format(math.sin(lon))) + print('_CalcVsop: cos(lat) = {:0.16g}'.format(math.cos(lat))) + print('_CalcVsop: sin(lat) = {:0.16g}'.format(math.sin(lat))) return _VsopRotate(eclip).ToAstroVector(time) class _body_state_t: