Skip to content

Instantly share code, notes, and snippets.

@translunar
Created April 25, 2019 17:47
Show Gist options
  • Save translunar/0ce54bd9eef6c73780b8ab104d760515 to your computer and use it in GitHub Desktop.
Save translunar/0ce54bd9eef6c73780b8ab104d760515 to your computer and use it in GitHub Desktop.
import numpy as np
from spiceypy import spiceypy as spice
r_lclf = spice.georec(lon, lat, 0.0, r_eq, f)
normal = spice.latrec(1.0, lon, lat)
topo_xform = spice.twovec(normal, 3, np.array([0.0, 0.0, 1.0]), 1)
# Get sun state relative to topo frame
x_sun, lt = spice.spkcpo('SUN', et, 'MOON_ME', 'OBSERVER', 'NONE', r_lclf, 'MOON', 'MOON_ME')
r_sun_topo = spice.mxv(topo_xform, x_sun[0:3])
rho, lon, el = spice.reclat(r_sun_topo)
az = -lon
import spice_helpers as sh
az, el = sh.sun_az_el( et )
# returns azimuth and elevation at epoch time 'et', in radians
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment