-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpbl_d02.ncl
351 lines (222 loc) · 10.2 KB
/
pbl_d02.ncl
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; NCL Libraries
;
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
begin
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Identify Output File/Device
;
; pdf = PDF file (recommended) ps = Postscript File
; ncgm = NCAR Graphics File x11 = X11 Graphics Image
; eps = Encapsulated Postcript File
;
output_format = "png" ; pdf file
output_format@wkWidth = 800
output_format@wkHeight = 800
hours_in_a_forecast = 36
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; File Control (default directory location of netCDF file)
;
dir_local = "/home/wjc/WRF_REALTIME_KUNR-3DOM/"
dir_wrf = "/cyclone1/WRF_REALTIME/OUTPUT/"
dir_png = "/projects/WRF_REALTIME/OUTPUT_PNG/"
dir_url = "wjc@kyrill:/var/www/html/firemet/wrf_rap/"
dir_local = "./"
; dir_wrf = "./"
; dir_png = "./"
time = ispan(0,hours_in_a_forecast ,1)
; ens_dir = (/ "WRF32_KUNR_3DOM_WSM6_NOAH_MYNN2_KF2_DUDHIA_NARRFNL-09km_150x150/" /)
; ens_dir = (/ "./" /)
ens_dir = (/ "WRF36_KUNR_3DOM_WSM6_NOAH_MYNN2_KF2_DUDHIA_NAM218-09km_150x150/" /)
domains = (/ "d02", "d01" /)
do dd = 0,0
d0n = domains(dd)
domain = d0n
nt = dimsizes(time)
deltat = time(1)-time(0)
; print("cat " + dir_local + "current_day.txt")
run_date = systemfunc("cat " + dir_local + "current_day.txt")
print(run_date)
full_png_dir = dir_png +"/"+run_date+"/"+domain
system("mkdir -v "+dir_png +"/"+run_date)
system("mkdir -v "+ full_png_dir )
wrf_file = new( (/ nt/), string)
wks = gsn_open_wks(output_format ,full_png_dir + "/wrf_plot_PBL_" +domain + "_" + run_date )
gsn_define_colormap(wks,"WhViBlGrYeOrRe")
minpbl = 99999999999.
maxpbl = -minpbl
do t = 0, nt-1
wrf_file(t) = dir_wrf + ens_dir + "/wrfout_" + d0n + "_" + run_date + "_F" + sprinti("%0.2i",time(t)) + ".nc"
result = systemfunc("gunzip -frv "+wrf_file(t)+".gz")
f = addfile(wrf_file(t), "r")
pbl = wrf_user_getvar(f,"PBLH",0)
maxpbl = max( (/ maxpbl, max(pbl) /) )
minpbl = min( (/ minpbl, min(pbl) /) )
end do
maxpbl=round(maxpbl/10,0)*10
print(maxpbl)
print(minpbl)
do t = 0, nt-1
wrf_file(t) = dir_wrf + ens_dir + "/wrfout_" + d0n + "_" + run_date + "_F" + sprinti("%0.2i",time(t)) + ".nc"
f = addfile(wrf_file(t), "r")
time_zero_string = chartostring(f->Times )
;time_zero_string)
time_unit = "hours since "+time_zero_string +"z"
time@units = time_unit
time!0 = "time"
time&time = time
time@long_name = "time"
; print(time)
time_chars = f->Times
time_valid = chartostring(time_chars(:,0:12)) + " UTC"
time_valid_string = sprinti("SDSMT WRF %0.2i-hr Fx Valid @ ",time(t)) + time_valid
; print(time_valid_string)
lon2d = wrf_user_getvar(f,"lon",0)
lat2d = wrf_user_getvar(f,"lat",0)
terrain = wrf_user_getvar(f,"ter",0)
landuse = wrf_user_getvar(f,"LU_INDEX",0)
waterindex = f@ISWATER
iceindex = f@ISICE
terrain@lon2d = lon2d
terrain@lat2d = lat2d
nynx = dimsizes(terrain)
; print(nynx)
ny = nynx(0)
nx = nynx(1)
res = True
wrf_mapres_c(f, res, 0)
res@mpProjection = "LambertConformal"
res@mpLambertParallel1F = f@TRUELAT1
res@mpLambertParallel2F = f@TRUELAT2
res@mpLambertMeridianF = f@CEN_LON
res@mpLimitMode = "Corners"
res@mpLeftCornerLatF = lat2d(0,0)
res@mpLeftCornerLonF = lon2d(0,0)
res@mpRightCornerLatF = lat2d(ny-1,nx-1)
res@mpRightCornerLonF = lon2d(ny-1,nx-1)
res@mpOutlineBoundarySets = "AllBoundaries"
res@mpOutlineBoundarySets = "AllBoundaries" ; all boundaries
res@mpDataBaseVersion = "Ncarg4_1"
res@mpDataSetName = "Earth..4"
res@mpGeophysicalLineColor = "white"
res@mpUSStateLineColor = "white"
res@mpNationalLineColor = "white"
res@mpGeophysicalLineColor = "white"
res@mpGeophysicalLineColor = "white"
res@pmLabelBarOrthogonalPosF = -0.05 ; Move labelbar closer to plo
res@lbLabelFontHeightF =0.02
res@mpOutlineBoundarySets = "AllBoundaries" ; all boundaries
res@pmLabelBarOrthogonalPosF = -0.05 ; Move labelbar closer to plo
res@mpNationalLineThicknessF = 2.0
res@mpGeophysicalLineThicknessF = 4.0
res@mpUSStateLineThicknessF = 4.0
res@cnInfoLabelOn=False
; print(res)
print(time_zero_string+ " " )
time_unit = "hours since "+time_zero_string +"z"
time@units = time_unit
time!0 = "time"
time&time = time
time@long_name = "time"
; print(time)
Times = f->Times ; Times(Time, DateStrLen) (type character)
Time_s = chartostring( Times ) ; string
;printVarSummary(landuse)
;printVarSummary(terrain)
; print(iceindex)
; print(waterindex)
; print(max(landuse))
temparray = ind((ndtooned(landuse) .eq. waterindex) .or. (ndtooned(landuse) .eq. iceindex) )
; print(temparray)
wherewet = ind_resolve(temparray , nynx)
minterrain = min(terrain)
if (.not.all(ismissing(wherewet(0,0))))
; print(waterindex)
; print(wherewet)
dim_ida = dimsizes(wherewet)
npts = dim_ida(0) ; number of elements > 5 (here 9)
ndim = dim_ida(1) ; rank of "a" (here 3)
do n=0,npts-1
terrain(wherewet(n,0),wherewet(n,1)) = minterrain-150
end do
else
delete(wherewet)
delete(dim_ida)
delete(npts)
delete(ndim)
wherewet = ind_resolve(ind(ndtooned(terrain) .eq. minterrain), nynx)
dim_ida = dimsizes(wherewet)
npts = dim_ida(0) ; number of elements > 5 (here 9)
ndim = dim_ida(1) ; rank of "a" (here 3)
;print(waterindex)
;print(wherewet)
do n=0,npts-1
terrain(wherewet(n,0),wherewet(n,1)) = minterrain+100
end do
end if
delete(temparray)
res@cnFillOn = True ; turn on color for contours
res@cnLinesOn = False ; turn off contour lines
res@cnLineLabelsOn = False ; turn off contour line labels
res@cnFillMode = "RasterFill"
res@gsnSpreadColors = True ; use full color map
res@lbTitleOn = False
res@lbTitleString = " "
Times = f->Times ; Times(Time, DateStrLen) (type character)
Time_s = chartostring( Times ) ; string
pbl = wrf_user_getvar(f,"PBLH",0)
pbl@lon2d = lon2d
pbl@lat2d = lat2d
res@gsnMaximize = True ; maximize size
res@gsnBoxMargin = 0 ; no box margin
; res@tiMainFont = "helvetica" ; set default font
res@lbLabelAutoStride = False
res@lbLabelStride = 2
res@tiMainString = time_valid_string
print(domain+ " " + time_valid_string)
res@gsnLeftString = "Model-Estimated PBL Height"
res@gsnRightString ="m"
res@cnLevelSelectionMode = "ManualLevels" ; manual contour levels
res@cnLevelSpacingF = (5000-250)/19 ; contour interval
res@cnMinLevelValF = 250; minpbl ; min level
res@cnMaxLevelValF = 5000; maxpbl ; max level
res@pmLabelBarOrthogonalPosF = -0.05 ; Move labelbar closer to plo
res@lbLabelAngleF = 315.
res@lbLabelJust = "centerLeft"
res@cnHighLabelsOn = False ; mark your highs
res@cnLowLabelsOn = False ; same for lows
plot = gsn_csm_contour_map(wks,pbl, \
res)
delete(res)
delete(terrain)
delete(landuse)
delete(pbl)
delete(lon2d)
delete(lat2d)
delete(wherewet)
end do ; t-loop
system("convert -verbose -delay 100 " + full_png_dir + "/wrf_plot_PBL_"+domain + "_" + run_date +"*.png "+ full_png_dir + "/wrf_plot_PBL_"+domain + "_" + run_date+".gif")
system("rm -frv "+ dir_png + "/currentRAP/wrf_plot_PBL_"+domain+ ".gif")
system ("ln -sv " + full_png_dir + "/wrf_plot_PBL_"+domain + "_" + run_date+".gif "+ dir_png + "/currentRAP/wrf_plot_PBL_"+domain+ ".gif")
system ("scp " + full_png_dir + "/wrf_plot_PBL_"+domain + "_" + run_date+".gif "+ dir_url + "/wrf_plot_PBL_"+domain+ ".gif")
; system(" rm -fr " + full_png_dir + "/wrf_plot_PBL_"+domain + "_" + run_date +"*.png ")
do t = 1, nt
sixnum = sprinti("%0.6i", t)
system ("cp -frv "+ full_png_dir + "/wrf_plot_PBL_"+domain + "_" + run_date +"."+sixnum+ ".png "+ dir_png + "/currentRAP/wrf_plot_PBL_"+domain+"."+sixnum+ ".png")
system ("scp "+ full_png_dir + "/wrf_plot_PBL_"+domain + "_" + run_date +"."+sixnum+ ".png "+ dir_url + "/wrf_plot_PBL_"+domain+"."+sixnum+ ".png")
end do
print(maxpbl)
print(minpbl)
end do
end