I'd like to set up a Python program to be able to pull sunrise/sunset from various locations to trigger lights in the local location to symbolize the remote sunrise as it would be -- if you were actually there. What I mean by this, is if you live in Berlin, and YOUR sunrise/sunset in the middle of December is 7:45am/4:15pm, you could have a little LED that would light when some tropical sunrise is happening (say Hawaii). But this is happening in reaction to your own local time.
So, using Python's ephem, and pytz, and localtime, pull the information for sunrise/sunset for various locations, and trigger events based on each location.
I've set up a test program using Vancouver, BC and Georgetown, French Guyana as a test case, and it mostly works -- but the sunrise/sunset for Georgetown is completely wrong.
You can cut and paste this entire thing into a Python window to test, and please forgive the extraneous time calls, but I find it interesting to see what each of the time calls pull.
Nonetheless, what you'll see is that the Guyana.date is absolutely correct, but the sunrise/sunset is something like 1:53 AM / 13:57 PM, which is completely whacked. Any ideas on how this could have gone so horribly, horribly wrong?
EDITED TO REMOVE UNNECESSARY CODE
import ephem
from datetime import datetime, timedelta
from pytz import timezone
import pytz
import time
Guyana = ephem.Observer()
Guyana.lat = '5'
Guyana.lon = '58.3'
Guyana.horizon = 0
Guyana.elevation = 80
Guyana.date = datetime.utcnow()
sun = ephem.Sun()
print("Guyana.date is ",Guyana.date)
print("Guyana sunrise is at",Guyana.next_rising(sun))
print("Guyana sunset is going to be at ",Guyana.next_setting(sun))
The results of this are as follows:
Guyana.date is 2014/10/4 16:47:36
Guyana sunrise is at 2014/10/5 01:53:26
Guyana sunset is going to be at 2014/10/5 13:57:05
What is so wrong about this, is that the actual sunrise in Guyana today is 5:40am, so the 1:53:26 is off by not just hours, but in many ways off.