Source code for irfpy.cy1orb.subsolar
''' Module to calculate the subsolar point.
'''
import irfpy.util.utc as utc
from irfpy.cy1orb import lseme
import numpy as np
[docs]def subsolar(jd):
''' Return a subsolar point position in ME frame.
>>> import datetime
>>> print(subsolar(datetime.datetime(2010, 1, 1))) # doctest: +ELLIPSIS,+NORMALIZE_WHITESPACE
[1732.257648 -140.8436964 -9.504253 ]
'''
Rm = 1738.
vec = (Rm, 0., 0.)
return lseme.lse2me(jd, vec)
[docs]def subsolar_asdegrees(jd):
''' Return a subsolar point position as (longitude, latitude) in ME.
>>> import datetime
>>> subsol = subsolar(datetime.datetime(2010, 1, 11))
>>> print('{0[0]:.3f} {0[1]:.3f} {0[2]:.3f}'.format(subsol)) # doctest: +ELLIPSIS,+NORMALIZE_WHITESPACE
-1024.471 -1403.960 0.533
>>> print(subsolar_asdegrees(datetime.datetime(2010, 1, 10))) # doctest: +ELLIPSIS,+NORMALIZE_WHITESPACE
(-113.94..., -0.00889...)
'''
pos = subsolar(jd)
dist = np.sqrt((pos * pos).sum())
lons = np.rad2deg(np.arctan2(pos[1], pos[0]))
lats = np.rad2deg(np.arcsin(pos[2] / dist))
return (lons, lats)