Created
December 3, 2017 21:15
-
-
Save th0ma5w/e04a1486697de140f04aec40a3b37170 to your computer and use it in GitHub Desktop.
Is the sun up in Columbus? Using PyEphem to figure it out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ephem | |
def is_the_sun_up(): | |
columbus = ephem.city('Columbus') | |
sun = ephem.Sun() | |
columbus.pressure = 0 | |
sun.compute(columbus) | |
twilight = -6 * ephem.degree | |
return sun.alt > twilight | |
# Civil Twilight is defined as ending / beginning when the sun is 6 degrees below the horizon. | |
# Setting the pressure to 0 is to turn off atmospheric scattering calculations | |
# | |
# http://rhodesmill.org/pyephem/ | |
# http://rhodesmill.org/pyephem/rise-set.html | |
# https://stackoverflow.com/questions/2637293/calculating-dawn-and-sunset-times-using-pyephem | |
# https://stackoverflow.com/questions/26501745/how-to-determine-if-it-is-daytime-light-outside-in-python-using-ephem-library |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment