import math as m def Declination(n): """ 計算太陽赤緯 :param n: 月份天數 :return: 赤緯角度 """ a = 23.45*m.sin(m.radians(360*(284+n)/365)) return a a = Declination(31) print("{:.3f}".format(a)) def Sunrise_hour_angle(d): """ 計算太陽日落時角 :param d: 太陽赤緯 :return: 太陽日落時角w_s """ # 蘇州地區緯度31.3° a = m.radians(d) b = m.tan(m.radians(-31.3)) c = m.tan(a) w = m.acos(b*c) w_s = m.degrees(w) return w_s w_s = Sunrise_hour_angle(-17.78) print("{:.3f}".format(w_s))