-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCoverDegreeCal.py
72 lines (69 loc) · 2.5 KB
/
CoverDegreeCal.py
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
# -*- coding: cp936 -*-
import os
import datetime
import math
# from DayTotalRadiance import LevAstRad
# from test import GetCoeffab
# from test import GetCoeffAB
# from test import GetLL
import numpy
#from osgeo import gdal
import arcpy
SunPara = 1366.7
PI = math.pi
PI180 = math.pi / 180.0
SunPara = 1366.7
NDirectAngle = 72
Resolution = 1000.0
CVDatadistance = 1000.0
CVDirect = [0 for i in range(NDirectAngle)]
for k in range(0,NDirectAngle):
CVDirect[k] = k*360.0/NDirectAngle*PI180
def CoverDegree(ix, iy, Altitude, sNumRow, sNumColumn):
CVvalue = 0.0
for i in range(0,NDirectAngle):
CVDirectValue = 0.0
for j in range(1,10):
RDistance = j * CVDatadistance
DataX = RDistance * math.sin(CVDirect[i])
DataX = abs(DataX) - Resolution / 2.0
if math.sin(CVDirect[i]) <= 0.0:
if DataX <= 0.0:
NyStation = iy
else:
NxDirect = int(DataX / Resolution) + 1
NyStation = iy - NxDirect
else:
if DataX <= 0.0:
NyStation = iy
else:
NxDirect = int(DataX / Resolution) + 1
NyStation = iy + NxDirect
DataY = RDistance * math.cos(CVDirect[i])
DataY = abs(DataY) - Resolution / 2.0
if math.cos(CVDirect[i]) <= 0.0:
if DataY <= 0.0:
NxStation = ix
else:
NyDirect = int(DataY/Resolution) + 1
NxStation = ix - NyDirect
else:
if DataY <= 0.0:
NxStation = ix
else:
NyDirect = int(DataY / Resolution) + 1
NxStation = ix + NyDirect
NxStation = max(0, min(NxStation, sNumRow - 1))
NyStation = max(0, min(NyStation, sNumColumn - 1))
#print Altitude[ix][iy], Altitude[NxStation][NyStation]
TanSlope = (int(Altitude[NxStation][NyStation]) - int(Altitude[ix][iy]))/RDistance
if TanSlope > CVDirectValue:
CVDirectValue = TanSlope
Alpha = math.atan(CVDirectValue)
# P点在某方位下的地形开阔度,1-sin(alpha)
CVDirectValue = 1.0 - math.sin(Alpha)
#计算2pi内各方位开阔度,累加求平均
CVvalue = CVvalue + CVDirectValue
CVvalue = CVvalue / NDirectAngle
#print CVvalue
return CVvalue