-
Notifications
You must be signed in to change notification settings - Fork 0
/
UPP-PM25-O3-subset_stat-12Z.ksh
285 lines (202 loc) · 6.39 KB
/
UPP-PM25-O3-subset_stat-12Z.ksh
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
280
281
282
283
284
285
#=================================================================================
# ---- Get grib data at certain record # ----------------------
#
# subset $field & ":1 hybrid level" and append all time together
#
#========================================
#=== Day1
#==== FOR 12Z cycle
#---- previous cycles (fill the gap of day1)
#---- ndate -12 ==> "00z"
let istart1=5
let iend1=6
echo $istart1 > meta_time-step.txt
let ix=$istart1
while [ $ix -le $iend1 ]; do
let i2=ix
# typeset -Z2 i2
# file=NATLEV${i2}.tm00
typeset -Z3 i2
file=rrfs.t00z.natlevf${i2}.tm00.grib2
if [ $i2 -eq $istart1 ]; then
wgrib2 $postdirx12/$file -match ":$field1" -match ":$field3" -GRIB $fname1
wgrib2 $postdirx12/$file -match ":$field2" -match ":$field3" -GRIB $fname1s
else
wgrib2 $postdirx12/$file -match ":$field1" -match ":$field3" -append -GRIB $fname1
wgrib2 $postdirx12/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1s
fi
let ix=ix+1
done # while
#---- ndate -6 ==> "06z"
let istart1=1
let iend1=6
let ix=$istart1
while [ $ix -le $iend1 ]; do
let i2=ix
# typeset -Z2 i2
# file=NATLEV${i2}.tm00
typeset -Z3 i2
file=rrfs.t06z.natlevf${i2}.tm00.grib2
if [ $i2 -eq $istart1 ]; then
wgrib2 $postdirx06/$file -match ":$field1" -match ":$field3" -append -GRIB $fname1
wgrib2 $postdirx06/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1s
else
wgrib2 $postdirx06/$file -match ":$field1" -match ":$field3" -append -GRIB $fname1
wgrib2 $postdirx06/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1s
fi
let ix=ix+1
done # while
#===== O3 8hr max
#---- ndate -18 ==> "18z"
let istart2=4 # extra hourly for O3 8 hours max calculation
let iend2=6
let ix=$istart2
while [ $ix -le $iend2 ]; do
let i2=ix
# typeset -Z2 i2
# file=NATLEV${i2}.tm00
typeset -Z3 i2
file=rrfs.t18z.natlevf${i2}.tm00.grib2
if [ $i2 -eq $istart2 ]; then
wgrib2 $postdirx18/$file -match ":$field2" -match ":$field3" -GRIB $fname1x
else
wgrib2 $postdirx18/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1x
fi
let ix=ix+1
done # while
#---- ndate -12 ==> "00z"
let istart2=1 # extra hourly for O3 8 hours max calculation
let iend2=6
let ix=$istart2
while [ $ix -le $iend2 ]; do
let i2=ix
# typeset -Z2 i2
# file=NATLEV${i2}.tm00
typeset -Z3 i2
file=rrfs.t00z.natlevf${i2}.tm00.grib2
if [ $i2 -eq $istart2 ]; then
wgrib2 $postdirx12/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1x
else
wgrib2 $postdirx12/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1x
fi
let ix=ix+1
done # while
#---- ndate -6 ==> "06z"
let istart2=1 # extra hourly for O3 8 hours max calculation
let iend2=6
let ix=$istart2
while [ $ix -le $iend2 ]; do
let i2=ix
# typeset -Z2 i2
# file=NATLEV${i2}.tm00
typeset -Z3 i2
file=rrfs.t06z.natlevf${i2}.tm00.grib2
if [ $i2 -eq $istart2 ]; then
wgrib2 $postdirx06/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1x
else
wgrib2 $postdirx06/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1x
fi
let ix=ix+1
done # while
#---- current cycle (part of day1 & full day2)
#=== Day1 part from current cycle
let istart=1
let iend=16
echo $iend >> meta_time-step.txt
let i=$istart
while [ $i -le $iend ]; do
let i2=i
# typeset -Z2 i2
# file=NATLEV${i2}.tm00
typeset -Z3 i2
file=rrfs.t${CYC}z.natlevf${i2}.tm00.grib2
if [ $i2 -eq $istart ]; then
wgrib2 $postdir/$file -match ":$field1" -match ":$field3" -append -GRIB $fname1
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1s
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1x
else
wgrib2 $postdir/$file -match ":$field1" -match ":$field3" -append -GRIB $fname1
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1s
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -append -GRIB $fname1x
fi
let i=i+1
done # while
#========================================
#=== Day2 full
let istart=17
let iend=40
echo $istart >> meta_time-step.txt
echo $iend >> meta_time-step.txt
let i=$istart
while [ $i -le $iend ]; do
let i2=i
# typeset -Z2 i2
# file=NATLEV${i2}.tm00
typeset -Z3 i2
file=rrfs.t${CYC}z.natlevf${i2}.tm00.grib2
if [ $i2 -eq $istart ]; then
wgrib2 $postdir/$file -match ":$field1" -match ":$field3" -GRIB $fname2
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -GRIB $fname2s
else
wgrib2 $postdir/$file -match ":$field1" -match ":$field3" -append -GRIB $fname2
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -append -GRIB $fname2s
fi
let i=i+1
done # while
#===== O3 8hr max
let istart=10
let iend=40
let i=$istart
while [ $i -le $iend ]; do
let i2=i
# typeset -Z2 i2
# file=NATLEV${i2}.tm00
typeset -Z3 i2
file=rrfs.t${CYC}z.natlevf${i2}.tm00.grib2
if [ $i2 -eq $istart ]; then
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -GRIB $fname2x
else
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -append -GRIB $fname2x
fi
let i=i+1
done # while
#========================================
#=== Day3 full
let istart=41
let iend=64
echo $istart >> meta_time-step.txt
echo $iend >> meta_time-step.txt
let i=$istart
while [ $i -le $iend ]; do
let i2=i
# typeset -Z2 i2
# file=NATLEV${i2}.tm00
typeset -Z3 i2
file=rrfs.t${CYC}z.natlevf${i2}.tm00.grib2
if [ $i2 -eq $istart ]; then
wgrib2 $postdir/$file -match ":$field1" -match ":$field3" -GRIB $fname3
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -GRIB $fname3s
else
wgrib2 $postdir/$file -match ":$field1" -match ":$field3" -append -GRIB $fname3
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -append -GRIB $fname3s
fi
let i=i+1
done # while
#===== O3 8hr max
let istart=34
let iend=64
let i=$istart
while [ $i -le $iend ]; do
let i2=i
# typeset -Z2 i2
# file=NATLEV${i2}.tm00
typeset -Z3 i2
file=rrfs.t${CYC}z.natlevf${i2}.tm00.grib2
if [ $i2 -eq $istart ]; then
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -GRIB $fname3x
else
wgrib2 $postdir/$file -match ":$field2" -match ":$field3" -append -GRIB $fname3x
fi
let i=i+1
done # while
#################################################