-
Notifications
You must be signed in to change notification settings - Fork 0
/
solweig_k_rads.py
202 lines (159 loc) · 9.8 KB
/
solweig_k_rads.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
##############################################################################################################################################
# Fucntions to estimate all shortwave radiations for Solweig #
# source :https://github.com/UMEP-dev/UMEP/tree/SuPy-QGIS3/SOLWEIG/SOLWEIGpython #
# Goteborg Urban Climate Group #
# Gothenburg University #
# #
# #
# #
##############################################################################################################################################
import numpy as np
def Kvikt_veg(svf, svfveg, vikttot):
# Least
viktwall = (vikttot - (
63.227 * svf ** 6 - 161.51 * svf ** 5 + 156.91 * svf ** 4 - 70.424 * svf ** 3 + 16.773 * svf ** 2 - 0.4863 * svf)) / vikttot
svfvegbu = (svfveg + svf - 1) # Vegetation plus buildings
viktveg = (vikttot - (
63.227 * svfvegbu ** 6 - 161.51 * svfvegbu ** 5 + 156.91 * svfvegbu ** 4 - 70.424 * svfvegbu ** 3 + 16.773 * svfvegbu ** 2 - 0.4863 * svfvegbu)) / vikttot
viktveg = viktveg - viktwall
return viktveg, viktwall
def Kup_veg_2015a(radI, radD, radG, altitude, svfbuveg, albedo_b, F_sh, gvfalb, gvfalbE, gvfalbS, gvfalbW, gvfalbN,
gvfalbnosh, gvfalbnoshE, gvfalbnoshS, gvfalbnoshW, gvfalbnoshN):
Kup = (gvfalb * radI * np.sin(altitude * (np.pi / 180.))) + (
radD * svfbuveg + albedo_b * (1 - svfbuveg) * (radG * (1 - F_sh) + radD * F_sh)) * gvfalbnosh
KupE = (gvfalbE * radI * np.sin(altitude * (np.pi / 180.))) + (
radD * svfbuveg + albedo_b * (1 - svfbuveg) * (radG * (1 - F_sh) + radD * F_sh)) * gvfalbnoshE
KupS = (gvfalbS * radI * np.sin(altitude * (np.pi / 180.))) + (
radD * svfbuveg + albedo_b * (1 - svfbuveg) * (radG * (1 - F_sh) + radD * F_sh)) * gvfalbnoshS
KupW = (gvfalbW * radI * np.sin(altitude * (np.pi / 180.))) + (
radD * svfbuveg + albedo_b * (1 - svfbuveg) * (radG * (1 - F_sh) + radD * F_sh)) * gvfalbnoshW
KupN = (gvfalbN * radI * np.sin(altitude * (np.pi / 180.))) + (
radD * svfbuveg + albedo_b * (1 - svfbuveg) * (radG * (1 - F_sh) + radD * F_sh)) * gvfalbnoshN
return Kup, KupE, KupS, KupW, KupN
def Kside_veg_v2019a(radI, radD, radG, shadow, svfS, svfW, svfN, svfE, svfEveg, svfSveg, svfWveg, svfNveg, azimuth,
altitude, psi, t, albedo, F_sh, KupE, KupS, KupW, KupN, cyl, lv, ani, diffsh, rows, cols):
# New reflection equation 2012-05-25
vikttot = 4.4897
aziE = azimuth + t
aziS = azimuth - 90 + t
aziW = azimuth - 180 + t
aziN = azimuth - 270 + t
deg2rad = np.pi / 180
KsideD = np.zeros((rows, cols))
### Direct radiation ###
if cyl == 1: ### Kside with cylinder ###
KsideI = shadow * radI * np.cos(altitude * deg2rad)
KeastI = 0;
KsouthI = 0;
KwestI = 0;
KnorthI = 0
else: ### Kside with weights ###
if azimuth > (360 - t) or azimuth <= (180 - t):
KeastI = radI * shadow * np.cos(altitude * deg2rad) * np.sin(aziE * deg2rad)
else:
KeastI = 0
if azimuth > (90 - t) and azimuth <= (270 - t):
KsouthI = radI * shadow * np.cos(altitude * deg2rad) * np.sin(aziS * deg2rad)
else:
KsouthI = 0
if azimuth > (180 - t) and azimuth <= (360 - t):
KwestI = radI * shadow * np.cos(altitude * deg2rad) * np.sin(aziW * deg2rad)
else:
KwestI = 0
if azimuth <= (90 - t) or azimuth > (270 - t):
KnorthI = radI * shadow * np.cos(altitude * deg2rad) * np.sin(aziN * deg2rad)
else:
KnorthI = 0
KsideI = shadow * 0
### Diffuse and reflected radiation ###
[viktveg, viktwall] = Kvikt_veg(svfE, svfEveg, vikttot)
svfviktbuvegE = (viktwall + (viktveg) * (1 - psi))
[viktveg, viktwall] = Kvikt_veg(svfS, svfSveg, vikttot)
svfviktbuvegS = (viktwall + (viktveg) * (1 - psi))
[viktveg, viktwall] = Kvikt_veg(svfW, svfWveg, vikttot)
svfviktbuvegW = (viktwall + (viktveg) * (1 - psi))
[viktveg, viktwall] = Kvikt_veg(svfN, svfNveg, vikttot)
svfviktbuvegN = (viktwall + (viktveg) * (1 - psi))
### Anisotropic Diffuse Radiation after Perez et al. 1993 ###
if ani == 1:
aniAlt = lv[0][:, 0]
aniAzi = lv[0][:, 1]
aniLum = lv[0][:, 2]
phiVar = np.zeros((145, 1))
radTot = np.zeros(1)
for ix in range(0, 145): # Azimuth delta
if ix < 60:
aziDel = 12
elif ix >= 60 and ix < 108:
aziDel = 15
elif ix >= 108 and ix < 126:
aziDel = 20
elif ix >= 126 and ix < 138:
aziDel = 30
elif ix >= 138 and ix < 144:
aziDel = 60
elif ix == 144:
aziDel = 360
phiVar[ix] = (aziDel * deg2rad) * (np.sin((aniAlt[ix] + 6) * deg2rad) - np.sin(
(aniAlt[ix] - 6) * deg2rad)) # Solid angle / Steradian
radTot = radTot + (
aniLum[ix] * phiVar[ix] * np.sin(aniAlt[ix] * deg2rad)) # Radiance fraction normalization
lumChi = (aniLum * radD) / radTot # Radiance fraction normalization
if cyl == 1:
for idx in range(0, 145):
anglIncC = np.cos(aniAlt[idx] * deg2rad) * np.cos(0) * np.sin(np.pi / 2) + np.sin(
aniAlt[idx] * deg2rad) * np.cos(
np.pi / 2) # Angle of incidence, np.cos(0) because cylinder - always perpendicular
KsideD = KsideD + diffsh[:, :, idx] * lumChi[idx] * anglIncC * phiVar[idx] # Diffuse vertical radiation
Keast = (albedo * (svfviktbuvegE * (radG * (1 - F_sh) + radD * F_sh)) + KupE) * 0.5
Ksouth = (albedo * (svfviktbuvegS * (radG * (1 - F_sh) + radD * F_sh)) + KupS) * 0.5
Kwest = (albedo * (svfviktbuvegW * (radG * (1 - F_sh) + radD * F_sh)) + KupW) * 0.5
Knorth = (albedo * (svfviktbuvegN * (radG * (1 - F_sh) + radD * F_sh)) + KupN) * 0.5
else: # Box
diffRadE = np.zeros((rows, cols));
diffRadS = np.zeros((rows, cols));
diffRadW = np.zeros((rows, cols));
diffRadN = np.zeros((rows, cols))
for idx in range(0, 145):
if aniAzi[idx] <= (180):
anglIncE = np.cos(aniAlt[idx] * deg2rad) * np.cos((90 - aniAzi[idx]) * deg2rad) * np.sin(
np.pi / 2) + np.sin(
aniAlt[idx] * deg2rad) * np.cos(np.pi / 2)
diffRadE = diffRadE + diffsh[:, :, idx] * lumChi[idx] * anglIncE * phiVar[idx] # * 0.5
if aniAzi[idx] > (90) and aniAzi[idx] <= (270):
anglIncS = np.cos(aniAlt[idx] * deg2rad) * np.cos((180 - aniAzi[idx]) * deg2rad) * np.sin(
np.pi / 2) + np.sin(
aniAlt[idx] * deg2rad) * np.cos(np.pi / 2)
diffRadS = diffRadS + diffsh[:, :, idx] * lumChi[idx] * anglIncS * phiVar[idx] # * 0.5
if aniAzi[idx] > (180) and aniAzi[idx] <= (360):
anglIncW = np.cos(aniAlt[idx] * deg2rad) * np.cos((270 - aniAzi[idx]) * deg2rad) * np.sin(
np.pi / 2) + np.sin(
aniAlt[idx] * deg2rad) * np.cos(np.pi / 2)
diffRadW = diffRadW + diffsh[:, :, idx] * lumChi[idx] * anglIncW * phiVar[idx] # * 0.5
if aniAzi[idx] > (270) or aniAzi[idx] <= (90):
anglIncN = np.cos(aniAlt[idx] * deg2rad) * np.cos((0 - aniAzi[idx]) * deg2rad) * np.sin(
np.pi / 2) + np.sin(
aniAlt[idx] * deg2rad) * np.cos(np.pi / 2)
diffRadN = diffRadN + diffsh[:, :, idx] * lumChi[idx] * anglIncN * phiVar[idx] # * 0.5
KeastDG = diffRadE + (albedo * (svfviktbuvegE * (radG * (1 - F_sh) + radD * F_sh)) + KupE) * 0.5
Keast = KeastI + KeastDG
KsouthDG = diffRadS + (albedo * (svfviktbuvegS * (radG * (1 - F_sh) + radD * F_sh)) + KupS) * 0.5
Ksouth = KsouthI + KsouthDG
KwestDG = diffRadW + (albedo * (svfviktbuvegW * (radG * (1 - F_sh) + radD * F_sh)) + KupW) * 0.5
Kwest = KwestI + KwestDG
KnorthDG = diffRadN + (albedo * (svfviktbuvegN * (radG * (1 - F_sh) + radD * F_sh)) + KupN) * 0.5
Knorth = KnorthI + KnorthDG
else:
KeastDG = (radD * (1 - svfviktbuvegE) + albedo * (
svfviktbuvegE * (radG * (1 - F_sh) + radD * F_sh)) + KupE) * 0.5
Keast = KeastI + KeastDG
KsouthDG = (radD * (1 - svfviktbuvegS) + albedo * (
svfviktbuvegS * (radG * (1 - F_sh) + radD * F_sh)) + KupS) * 0.5
Ksouth = KsouthI + KsouthDG
KwestDG = (radD * (1 - svfviktbuvegW) + albedo * (
svfviktbuvegW * (radG * (1 - F_sh) + radD * F_sh)) + KupW) * 0.5
Kwest = KwestI + KwestDG
KnorthDG = (radD * (1 - svfviktbuvegN) + albedo * (
svfviktbuvegN * (radG * (1 - F_sh) + radD * F_sh)) + KupN) * 0.5
Knorth = KnorthI + KnorthDG
return Keast, Ksouth, Kwest, Knorth, KsideI, KsideD