-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path01a_OperWeather.txt
279 lines (131 loc) · 5.22 KB
/
01a_OperWeather.txt
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/* 1) DEGREE DAYS */
/* t-boundaries for Growing Degree Days > 10°C */
%macro Temperature_Hours (start=, end=);
%do i=&start. %to &end.;
data work.temperature&i.;
set work.temperature&i.;
array Tmin{*} Tmin1--Tmin365;
array Tmax{*} Tmax1--Tmax365;
array t_boundary{*} t_bound10_1--t_bound10_365;
do j = 1 to 365 ;
if ((tmin(j) < 10) and (tmax(j) > 10))
then t_boundary(j) = arcos((2 * 10 - tmax(j) - tmin(j))/(tmax(j) - tmin(j))) ;
else if (tmin(j) > 10)
then t_boundary(j) = '.' ;
else if (tmax(j) < 10)
then t_boundary(j) = '.' ;
end;
run;
%end;
%mend Temperature_Hours ;
%Temperature_Hours (start=&YEAR_S, end=&YEAR_E);
-------------------------------------------------------------------------------------------
/* calculation of Cooling Degree Days > 10°C*/
%macro Temperature_10 (start=, end=);
%do i=&start. %to &end.;
data work.temperature&i.;
set work.temperature&i.;
array Tmin{*} Tmin1-Tmin365;
array Tmax{*} Tmax1-Tmax365;
array t_bound{*} t_bound10_1 - t_bound10_365;
ggd_MarAug_10 = 0 ;
do j = 1 to 365 ;
if ((tmax(j) <= 10) and (j >= 60) and (j <= 243))
then ggd_MarAug_10 = ggd_MarAug_10 + 0;
else if ((tmin(j) >= 10) and (j >= 60) and (j <= 243))
then ggd_MarAug_10 = ggd_MarAug_10 + ((0.5 *(tmax(j)+tmin(j))) - 10) ;
else if ((tmin(j) < 10) and (tmax(j) > 10) and (j >= 60) and (j <= 243) and t_bound(j) ne '.')
then ggd_MarAug_10 = ggd_MarAug_10 + (t_bound(j)/ pi ) * (((tmax(j) + tmin(j))/2) - 10)
+ ((tmax(j) - tmin(j))/(2*pi))*sin(t_bound(j));
end;
run;
%end;
%mend Temperature_10 ;
%Temperature_10 (start=&YEAR_S, end=&YEAR_E);
----------------------------------------------------------------------------------------------------------
/* t-boundaries for Growing Degree Days > 30°C */
%macro Temperature_Hours (start=, end=);
%do i=&start. %to &end.;
data work.temperature&i.;
set work.temperature&i.;
array Tmin{*} Tmin1--Tmin365;
array Tmax{*} Tmax1--Tmax365;
array t_boundary{*} t_bound30_1--t_bound30_365;
do j = 1 to 365 ;
if ((tmin(j) < 30) and (tmax(j) > 30))
then t_boundary(j) = arcos((2 * 30 - tmax(j) - tmin(j))/(tmax(j) - tmin(j))) ;
else if (tmin(j) > 30)
then t_boundary(j) = '.' ;
else if (tmax(j) < 30)
then t_boundary(j) = '.' ;
end;
run;
%end;
%mend Temperature_Hours ;
%Temperature_Hours (start=&YEAR_S, end=&YEAR_E);
------------------------------------------------------------------------------------------
/* calculation of Cooling Degree Days > 30°C*/
%macro Temperature_30 (start=, end=);
%do i=&start. %to &end.; /* Beginn DO-Schleife Zeitreihe */
data work.temperature&i.;
set work.temperature&i.;
array Tmin{*} Tmin1-Tmin365;
array Tmax{*} Tmax1-Tmax365;
array t_bound{*} t_bound30_1 - t_bound30_365;
ggd_MarAug_30 = 0 ;
do j = 1 to 365 ;
if ((tmax(j) <= 30) and (j >= 60) and (j <= 243))
then ggd_MarAug_30 = ggd_MarAug_30 + 0;
else if ((tmin(j) >= 30) and (j >= 60) and (j <= 243))
then ggd_MarAug_30 = ggd_MarAug_30 + ((0.5 *(tmax(j)+tmin(j))) - 30) ;
else if ((tmin(j) < 30) and (tmax(j) > 30) and (j >= 60) and (j <= 243) and t_bound(j) ne '.')
then ggd_MarAug_30 = ggd_MarAug_30 + (t_bound(j)/ pi ) * (((tmax(j) + tmin(j))/2) - 30)
+ ((tmax(j) - tmin(j))/(2*pi))*sin(t_bound(j));
end;
run;
%end; /* Ende DO-Schleife Zeitreihe */
%mend Temperature_30 ;
%Temperature_30 (start=&YEAR_S, end=&YEAR_E);
--------------------------------------------------------------------------------------------------------
/* Calculation of final variable */
%macro Temperature_calculation (start=, end=);
%do i=&start. %to &end.;
data work.temperature&i.;
set work.temperature&i.;
ggd_MarAug_1030 = ggd_MarAug_10 - ggd_MarAug_30 ;
run;
%end;
%mend Temperature_calculation ;
%Temperature_calculation (start=&YEAR_S, end=&YEAR_E);
/* 2) PRECIPITATION AND DRY DAYS */
/*Calculation of overall Precipitation (prec) between March 1st and August 31th */
%macro precipitation (start=, end=);
%do i=&start. %to &end.;
data work.rain_new&i.;
set work.rain_new&i.;
array rain{*} rain1-rain365;
prec_MarAug = 0 ;
do j = 1 to 365 ;
if ((j >= 60) and (j <= 243))
then prec_MarAug = prec_MarAug + rain(j) ;
end;
run;
%end;
%mend precipitation ;
%precipitation(start=&YEAR_S, end=&YEAR_E);
---------------------------------------------------------------------------------------------------
/* Dry days (dd) between March 1st and August 31th with precipitation <1 mm*/
%macro drydays (start=, end=);
%do i=&start. %to &end.;
data work.rain_new&i.;
set work.rain_new&i.;
array rain{*} rain1-rain365;
dd_MarAug = 0 ;
do j = 1 to 365 ;
if ((j >= 60) and (j <= 243) and rain(j) <1)
then dd_MarAug = dd_MarAug + 1 ;
end;
run;
%end;
%mend drydays ;
%drydays(start=&YEAR_S, end=&YEAR_E);