Define the function solar_elevation(latitude, day_num,
solar_hour) that returns the angle of the sun to the ground
for an observer at the given latitude, for the given day number and
solar hour.
The formula for calculating this is:
ππππ£ππ‘πππ=ππ ππ_π(π ππ_π(πππ‘)Γπ ππ_π(ππππππππ‘πππ)+πππ _π(πππ‘)Γπππ _π(βππ’π_πππππ)Γπππ _π(ππππππππ‘πππ))elevation=asin_d(sin_d(lat)Γsin_d(declination)+cos_d(lat)Γcos_d(hour_angle)Γcos_d(declination))
Where:
IT ITT HNMON 1 def sin_d(degrees): 2 To save us converting to radians all the time 3 return math.sin(math.radians(degrees)) 4 = def asin_d(n): Returns the degrees such that sin(degrees) The standard asin function returns the value in re This function converts the result to degrees 6 7 8 9 10 11 12 13 14 # We force the cos_value between -1 and 1 so that # This removes rounding errors from values such as # be careful not to use values outside the -1 to if n < -1: n = -1 elif n > 1: n = 1 return math.degrees(math.asin(n)) 16 45919 17 18 20 21 def solar_hour_angle(solar_hour): 22 "" The earth makes a full 360 degree rotation 23 every 24 hours, or 15 degrees per hour. 24 This function returns the angle implied by a 25 given hourly time, relative to the solar noon. For example: 27 An hour of 11 should give -15 28 An hour of 15 (3 hours after midday) should give 29 An hour of 15.5 should give 52.5 30 31 return 15 * (solar_hour 12) 32 def solar_elevation(latitude, day_num, solar_hour) 26 Scratchpad
Define the function solar_elevation(latitude, day_num, solar_hour) that returns the angle of the sun to the ground for a
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am