Recently, I've changed office in my building. Now, every afternoon, I get a sunray right through my window, making me close the blinds everyday. However, I've noticed that in recent weeks, the sunray appears earlier and earlier in the day. Knowing that astropy exists, this notebook is an exploration of the sun's trajectory as seen from my window.
Reference: this 2015 tutorial on Astropy http://nbviewer.jupyter.org/url/uwescience.github.io/python-seminar-2015/notebooks/intro_to_astropy.ipynb
Hey #AstroPy... how far away is the sun right...... NOW? pic.twitter.com/knff8Epw2W
— Jake VanderPlas (@jakevdp) September 27, 2016
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
Let's define my position in the universe.
import astropy.units as u
from astropy.coordinates import EarthLocation, AltAz
# Define Earth location:
# 48.727585, 2.156112
longitude, latitude, elevation = (2.156112*u.deg, 48.727585*u.deg, 0*u.m)
saclay = EarthLocation.from_geodetic(longitude, latitude, elevation)
from astropy.time import Time
# Define alt/az frame:
alt_az_frame = AltAz(obstime=Time('2017-03-27 16:50:00'), location=saclay)
Let's now define the sun.
from astropy.coordinates import SkyCoord, get_sun
sun = get_sun(Time.now())
Finally, let's compute the angles to the sun:
# Transform the coordinate to the new reference frame, and print
sun_altaz = sun.transform_to(alt_az_frame)
sun_altaz.to_string(style='hmsdms', sep=':')
'17:17:17.8456 +12:53:23.9322'
from astropy.utils.data import download_file
from astropy.utils import iers
iers.IERS.iers_table = iers.IERS_A.open(download_file(iers.IERS_A_URL, cache=True))
Downloading http://maia.usno.navy.mil/ser7/finals2000A.all [Done]