Skip to content

Commit

Permalink
Python problem might be in trig functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinekitty committed May 28, 2024
1 parent 5dbede1 commit e75bf33
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
10 changes: 7 additions & 3 deletions demo/python/astronomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
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))
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
10 changes: 7 additions & 3 deletions generate/template/astronomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
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))
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
9 changes: 0 additions & 9 deletions source/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

<a name="getenv"></a>
### 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.

10 changes: 7 additions & 3 deletions source/python/astronomy/astronomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
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))
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit e75bf33

Please sign in to comment.