Skip to content

Instantly share code, notes, and snippets.

@StuartLittlefair
Created January 24, 2018 17:10
Show Gist options
  • Save StuartLittlefair/907f3c8fb068bbc1eb22a1924725e90e to your computer and use it in GitHub Desktop.
Save StuartLittlefair/907f3c8fb068bbc1eb22a1924725e90e to your computer and use it in GitHub Desktop.
quick-ish calculation of sun and moon location
from astropy import coordinates as coord
from astropy.time import Time
from astropy import units as u
lapalma = coord.EarthLocation.of_site('lapalma')
times = Time.now() + u.minute*np.linspace(-720, 720, 1440)
altaz_frame = coord.AltAz(location=lapalma, obstime=times)
sun = coord.get_body('sun', location=lapalma, time=times)
moon = coord.get_body('moon', location=lapalma, time=times)
sun_altaz = sun.transform_to(altaz_frame)
moon_altaz = moon.transform_to(altaz_frame)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment