Last active
June 30, 2020 08:28
-
-
Save mlubej/62a8684260260f623cf720ed0be221ca to your computer and use it in GitHub Desktop.
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 | |
import numpy as np | |
from datetime import datetime | |
def get_shadow_length(long, lat, datetime, height): | |
""" | |
Accepts longitude and latitude in the WGS84 CRS, along with the | |
datetime in the UTC time zone. Returns the length of a shadow of an object | |
with a specified height at the specified time and location. | |
""" | |
o = ephem.Observer() | |
o.long, o.lat = str(long), str(lat) | |
o.date = ephem.Date(datetime) | |
sun = ephem.Sun(o) | |
az = sun.az * 180/np.pi | |
zen = 90 - sun.alt*180/np.pi | |
shadow = 1 / np.tan(sun.alt) | |
return shadow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment