I have UTC time (hours, minutes, seconds), longitude(deg E), latitude (deg N) and date. Can anyone provide me with a code to calculate solar zenith angle in Python 2.7?
It is an interesting problem and I think I have a good answer - well, at least starting points.
Check out the awesome astropy
package. I believe you need to use the coordinates
module.
Something along these lines:
import astropy.coordinates as coord
from astropy.time import Time
import astropy.units as u
loc = coord.EarthLocation(lon=0.1 * u.deg,
lat=51.5 * u.deg)
now = Time.now()
altaz = coord.AltAz(location=loc, obstime=now)
sun = coord.get_sun(now)
print(sun.transform_to(altaz).alt)
Here, we are getting the angle of the sun above the horizon for the 0.1
degrees longitude and 51.5
latitude location at the current time.
FYI, .zen
would give you the zenith angle.