I happened upon a polar sun path chart a while back and really thought it was a great graphic. It shows where the sun goes each day as a function of the seasons. Behold:
For Seattle, you can see at the top that the sun rises in the SE, peaks at 20° above the horizon, and then sets at 4:30pm on the winter solstice. Ugh. But in the summer, it’s up from before 4am to after 8pm, and peaks above 60° . You can make one of these plots for your area over at the University of Oregon’s Solar Radiation Monitoring Lab.
I liked this plot so much that I wanted to take it to the next level and see where the sun is live. In my experience with Python, I’ve grown to expect there to be sweet libraries that can compute stuff like that. Sure enough, there are a few. First, I found pysolar, which is really straightforward, fast, and simple. A few lines of code and I was up and running.
The code for this is nearly trivial:
import matplotlib.pyplot as plt
from pysolar import solar
LOC = (47.607,-122.33)
start = datetime.datetime(2019,1,1,0,0,0,0)
delta = datetime.timedelta(hours=HOURS)
for interval in range(DAYS*24//HOURS):
now = start + delta*interval
alt = 90 - solar.get_altitude(*LOC, now)
azi = solar.get_azimuth(*LOC, now)/180.0*math.pi
print(now, alt, azi)
fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')
alts, azis = zip(*data)
c = ax.scatter(azis, alts, s=10, alpha=0.5)
But then as I fiddled with it, I realized I really wanted something that was going to show the Moon as well. And while I was at it, maybe a few more planets. I found the skyfield library, which looked perfect.
Since I want it to be live, I figure the best place to put it is in my self-hosted home automation setup based on Home Assistant (which I’ve written about a lot), right in the weather section. This is basically just local weather information.
As I watched it one day, during the sunset, it looked like some planets were supposed to be out. In the figure above, Jupiter, Saturn, and Venus are closely following the sun into the sunset. The moon was right there to the south but I didn’t see the planets readily. I eventually noticed Venus in the sunset, and then scanned around with my binoculars and, sure enough, I found Jupiter and Saturn too! How about that!
(I realize I could pull up Google Sky Map or similar and do the same thing, but it’s somehow more fun to have a live local version alongside my weather sensors)
A few days later, I’ve gotten used to where the sun rises and sets at this time of year. Out on a jog, I noticed where the sun was. Since I have been paying attention to this plot, it was easy for me to intuit where on the path it is at that time. From this, I was able to immediately orient myself in terms of the cardinal directions. It felt like a revelation.
(I also realize anyone can do this just by thinking about it, but having the polar plot really helped drill it in somehow)
So, this thing is a pretty solid clock, calendar, planet map, and compass! Tons of fun.