1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| import math
def yearToYear(year, month, day, hour): JD0 = int(365.25*(year-1))+int(30.6001*(1+13))+1+hour/24+1720981.5 if month <= 2: JD2 = int(365.25*(year-1))+int(30.6001 * (month+13))+day+hour/24+1720981.5 else: JD2 = int(365.25*year)+int(30.6001*(month+1))+day+hour/24+1720981.5 DOY = JD2-JD0+1 return DOY
def EDCompute(DOY, year): N0 = 79.6764 + 0.2422*(year-1985) - int((year-1985)/4.0) sitar = 2*math.pi*(DOY-N0)/365.2422 ED1 = 0.3723 + 23.2567*math.sin(sitar) + 0.1149*math.sin(2*sitar) - 0.1712*math.sin( 3*sitar) - 0.758*math.cos(sitar) + 0.3656*math.cos(2*sitar) + 0.0201*math.cos(3*sitar) ED = ED1*math.pi/180 return ED
def latCompute(lat): latitudeArc = lat*math.pi/180 return latitudeArc
def dTimeCompute(lon, TimeZone, DOY, year): N0 = 79.6764 + 0.2422*(year-1985) - int((year-1985)/4.0) sitar = 2*math.pi*(DOY-N0)/365.2422 if lon >= 0: if TimeZone == -13: dLon = lon - (math.floor((lon*10-75)/150)+1)*15.0 else: dLon = lon - TimeZone*15.0 else: if TimeZone == -13: dLon = (math.floor((lon*10-75)/150)+1)*15.0 - lon else: dLon = TimeZone*15.0 - lon Et = 0.0028 - 1.9857*math.sin(sitar) + 9.9059*math.sin(2*sitar) - \ 7.0924*math.cos(sitar) - 0.6882*math.cos(2*sitar) gtdt1 = hour + min/60.0 + sec/3600.0 + dLon/15 gtdt = gtdt1 + Et/60.0 dTimeAngle1 = 15.0*(gtdt-12) dTimeAngle = dTimeAngle1*math.pi/180 return dTimeAngle
def heightAngle(latitudeArc, ED, dTimeAngle): HeightAngleArc = math.asin(math.sin( latitudeArc)*math.sin(ED)+math.cos(latitudeArc)*math.cos(ED)*math.cos(dTimeAngle)) return HeightAngleArc
def azimuthAngle(HeightAngleArc, latitudeArc, ED): CosAzimuthAngle = (math.sin(HeightAngleArc)*math.sin(latitudeArc) - math.sin(ED))/math.cos(HeightAngleArc)/math.cos(latitudeArc) AzimuthAngleArc = math.acos(CosAzimuthAngle) AzimuthAngle1 = AzimuthAngleArc * 180/math.pi if dTimeAngle < 0: AzimuthAngle = 180 - AzimuthAngle1 else: AzimuthAngle = 180 + AzimuthAngle1 return AzimuthAngle
if __name__ == '__main__': year = 2022 month = 7 day = 31 hour = 9 min = 00 sec = 00 lon = 120 lat = 30 TimeZone = 8 DOY = yearToYear(year, month, day, hour) ED = EDCompute(DOY, year) latitudeArc = latCompute(lat) dTimeAngle = dTimeCompute(lon, TimeZone, DOY, year) HeightAngle = heightAngle(latitudeArc, ED, dTimeAngle)*180/math.pi AzimuthAngle = azimuthAngle(heightAngle( latitudeArc, ED, dTimeAngle), latitudeArc, ED) print('%s年%s月%s日%s时%s分%s秒,地理位置位于经度%s,纬度%s的高度角(deg)为:%f,方位角(deg)为:%f ' % (year, month, day, hour, min, sec, lon, lat, HeightAngle, AzimuthAngle))
|