Newer
Older
;================================================;
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

ESCOBAR MUNOZ Juan
committed
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
; ================================================;
;================================================;
begin
;=================================================;
; open file and read in data
;=================================================;
fichier1 = addfile("EXPER.1.HYD2D.002.nc4", "r")
fichier2 = addfile("EXPER.1.HYD2D.003.nc4", "r")
;==================================================;
; Open the workstation
;==================================================;

ESCOBAR MUNOZ Juan
committed
type = "x11"
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
wks = gsn_open_wks(type,"visu_2Drelief")
;=================================================;
; lecture des différents champs
;=================================================;
zs = fichier1->ZS(0,:) ; ZS
zhat = fichier1->ZHAT(:) ; ZHAT
xhat = fichier1->XHAT(:) ; XHAT
lsum1_old = fichier1->LSUM(:,0,:) ; LSUM
lsthm1 = fichier1->LSTHM(:,0,:) ; LSTHM
lsthm1@long_name="LSTHM"
lsthm1@units="K"
wt1_old= fichier1->WT(:,0,:) ; WT
ut1_old= fichier1->UT(:,0,:) ; UT
tht1= fichier1->THT(:,0,:) ; THT
tht1@long_name="Potential Temperature"
tht1@units="K"
rvt1= fichier1->RVT(:,0,:) ; RVT
rvt1@long_name="Vapor mixing ratio"
rvt1@units="g/kg"
cflu1= fichier1->CFLU(:,0,:) ; CFLU
cflu1@long_name="CFLU"
cflu1@units="-"
cflw1= fichier1->CFLW(:,0,:) ; CFLW
cflw1@long_name="CFLW"
cflw1@units=" "
YYYYDDMM1= fichier1->DTCUR__TDATE
SS1=fichier1->DTCUR__TIME
YYYYDDMM2= fichier2->DTCUR__TDATE
SS2=fichier2->DTCUR__TIME
lsum2_old = fichier2->LSUM(:,0,:) ; LSUM
lsthm2 = fichier2->LSTHM(:,0,:) ; LSTHM
lsthm2@long_name="LSTHM"
lsthm2@units="K"
wt2_old= fichier2->WT(:,0,:) ; WT
ut2_old= fichier2->UT(:,0,:) ; UT
tht2= fichier2->THT(:,0,:) ; THT
tht2@long_name="Potential Temperature"
tht2@units="K"
rvt2= fichier2->RVT(:,0,:) ; RVT
rvt2@long_name="Vapor mixing ratio"
rvt2@units="g/kg"
cflu2= fichier2->CFLU(:,0,:) ; CFLU
cflu2@long_name="CFLU"
cflu2@units="-"
cflw2= fichier2->CFLW(:,0,:) ; CFLW
cflw2@long_name="CFLW"
cflw2@units=" "
;=================================================;
; Récupération des dimensions des tableaux
;=================================================;
mdims = dimsizes(tht1)
print (mdims)
nd=dimsizes(mdims)
imax=mdims(nd-1)
kmax=mdims(nd-2)
;=================================================;
; Récupération de la date
;=================================================;
year1=YYYYDDMM1(0)
day1=YYYYDDMM1(1)
min1=YYYYDDMM1(2)
time1=SS1
year2=YYYYDDMM2(0)
day2=YYYYDDMM2(1)
min2=YYYYDDMM2(2)
time2=SS2
;=================================================;
; On mets toutes les variables sur la grille 1
;=================================================;
lsum1 = wrf_user_unstagger(lsum1_old,"X")
lsum1@long_name="LSUM"
lsum1@units="m/s"
ut1 = wrf_user_unstagger(ut1_old,"X")
ut1@long_name="Zonal wind"
ut1@units="m/s"
printVarSummary(ut1_old)
printVarSummary(ut1)
lsum2 = wrf_user_unstagger(lsum1_old,"X")
lsum2@long_name="LSUM"
lsum2@units="m/s"
ut2 = wrf_user_unstagger(ut1_old,"X")
ut2@long_name="Zonal wind"
ut2@units="m/s"
; Unstagger wt (from grid 4 to 1)
wt1=new((/kmax,imax/),double)
wt2=new((/kmax,imax/),double)
do k=0,kmax-2
wt1(k,:)=(wt1_old(k,:)+wt1_old(k+1,:))/2.
wt2(k,:)=(wt2_old(k,:)+wt2_old(k+1,:))/2.
end do
wt1(kmax-1,:)=2*wt1_old(kmax-1,:)-wt1_old(kmax-2,:)
wt2(kmax-1,:)=2*wt2_old(kmax-1,:)-wt2_old(kmax-2,:)
wt1@long_name="Vertical wind"
wt1@units="m/s"
wt2@long_name="Vertical wind"
wt2@units="m/s"
;=================================================;
; Altitude des niveaux modèles
;=================================================;
; Unstagger zhat (from grid 4 to 1)
nzh=new(kmax,double)
do k=0,kmax-2
nzh(k)=(zhat(k)+zhat(k+1))/2.
end do
nzh(kmax-1)=2*zhat(kmax-1)-zhat(kmax-2)
; Create a (altitude des niveaux modèle)
z=new(dimsizes(tht1),double)
zcoef=new(imax,double)
zcoef=1.-zs/nzh(kmax-1)
do i=0,imax-1
z(:,i) = nzh*zcoef(i)+zs(i)
end do
printVarSummary(ut1)
printVarSummary(z)
printVarSummary(xhat)
xconf=conform(tht1,xhat,1)
printVarSummary(xconf)
;=================================================;
; Set some other basic resources
;=================================================;
resmap = True
resmap@gsnFrame = False
resmap@gsnDraw = False
resmap@gsnMaximize = True
resmap@gsnPaperOrientation = "portrait"
resmap@gsnSpreadColors = True ; use full range of colormap
resmap@tiYAxisString =" "
resmap@cnFillOn = True ; turn on color fill
resmap@cnLinesOn = False ; turn off contour lines
;pour prendre en compte l'orographie sur la coupe verticale.
resmap@sfYArray = z ; 2D
resmap@sfXArray = xconf ; 2D
resmap@trGridType = "TriangularMesh"
; resmap@cnInfoLabelOn = False ; turn off contour info label
resmap@tiXAxisPosition="Left"
resmap@tiXAxisFontHeightF=0.015
;=================================================;
; TRACE
;=================================================;
gsn_define_colormap(wks,"rainbow") ; Choose colormap
opts=resmap
opts@cnLevelSelectionMode = "ExplicitLevels"
cnLevels = (/4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12/)
opts@cnLevels = cnLevels
opts@tiXAxisString="time="+time1+"s"
plot_ut1 = gsn_csm_contour(wks,ut1,opts)
draw(plot_ut1)
frame(wks)
opts@tiXAxisString="time="+time2+"s"
plot_ut2 = gsn_csm_contour(wks,ut2,opts)
draw(plot_ut2)
frame(wks)
delete(opts)
delete(cnLevels)
opts=resmap
opts@cnLevelSelectionMode = "ManualLevels"
opts@cnLevelSpacingF = 2.5
opts@cnMinLevelValF = 285
opts@cnMaxLevelValF = 330
opts@tiXAxisString="time="+time1+"s"
plot_tht1 = gsn_csm_contour(wks,tht1,opts)
draw(plot_tht1)
frame(wks)
opts@tiXAxisString="time="+time2+"s"
plot_tht2 = gsn_csm_contour(wks,tht2,opts)
draw(plot_tht2)
frame(wks)
delete(opts)
opts=resmap
opts@cnLevelSelectionMode = "ManualLevels"
opts@cnLevelSpacingF = 0.04
opts@cnMinLevelValF = -0.4
opts@cnMaxLevelValF = 0.28
opts@tiXAxisString="time="+time1+"s"
plot_wt1 = gsn_csm_contour(wks,wt1,opts)
draw(plot_wt1)
frame(wks)
opts@tiXAxisString="time="+time2+"s"
plot_wt2 = gsn_csm_contour(wks,wt2,opts)
draw(plot_wt2)
frame(wks)
delete(opts)
opts=resmap
opts@cnLevelSelectionMode = "ManualLevels"
opts@cnLevelSpacingF = 0.0002
opts@cnMinLevelValF = 0.0002
opts@cnMaxLevelValF = 0.0038
opts@tiXAxisString="time="+time1+"s"
plot_rvt1 = gsn_csm_contour(wks,rvt1,opts)
draw(plot_rvt1)
frame(wks)
opts@tiXAxisString="time="+time2+"s"
plot_rvt2 = gsn_csm_contour(wks,rvt2,opts)
draw(plot_rvt2)
frame(wks)
delete(opts)
opts=resmap
opts@cnLevelSelectionMode = "ManualLevels"
opts@cnLevelSpacingF = 0.003
opts@cnMinLevelValF = 0.028
opts@cnMaxLevelValF = 0.078
opts@tiXAxisString="time="+time1+"s"
plot_cflu1 = gsn_csm_contour(wks,cflu1,opts)
draw(plot_cflu1)
frame(wks)
opts@tiXAxisString="time="+time2+"s"
plot_cflu2 = gsn_csm_contour(wks,cflu2,opts)
draw(plot_cflu2)
frame(wks)
delete(opts)
opts=resmap
opts@cnLevelSelectionMode = "ManualLevels"
opts@cnLevelSpacingF = 0.004
opts@cnMinLevelValF = 0.004
opts@cnMaxLevelValF = 0.072
opts@tiXAxisString="time="+time1+"s"
plot_cflw1 = gsn_csm_contour(wks,cflw1,opts)
draw(plot_cflw1)
frame(wks)
opts@tiXAxisString="time="+time2+"s"
plot_cflw2 = gsn_csm_contour(wks,cflw2,opts)
draw(plot_cflw2)
frame(wks)
delete(opts)
res=resmap
;===================================================
; profils verticaux
;===================================================
;====================================
resmap@pmLegendDisplayMode = "Always"
resmap@pmLegendWidthF = 0.05
resmap@pmLegendHeightF = 0.15
resmap@lgPerimOn = False
resmap@pmLegendSide = "Top"
resmap@pmLegendParallelPosF = .1
resmap@lgLabelFontHeightF = .01
resmap@pmLegendOrthogonalPosF = -0.3
res_w=resmap
res_t=resmap
res_w@gsnRightString="time="+time1+"s"
res_w@trXMinF=-0.3
res_w@trXMaxF=0.3
res_w@xyLineColors = (/"red","green"/) ; change line color
res_w@xyExplicitLegendLabels = (/"WT","THT-LSTHM"/)
res_w@tiXAxisString = "WT" ; title
res_w@tiXAxisFontHeightF = 0.015
res_t@pmLegendOrthogonalPosF = -0.4
res_t@pmLegendParallelPosF = .15
res_t@trXMinF=-0.8
res_t@trXMaxF=0.1
res_t@xyLineColors = (/"green"/) ; change line color
res_t@xyExplicitLegendLabels = (/"THT-LSTHM"/)
res_t@gsnLeftString = "THT-LSTHM" ; title
res_t@gsnLeftStringFontHeightF = 0.015
plot = gsn_csm_x2y (wks,wt1(:,128),tht1(:,128)-lsthm1(:,128),z(:,128),res_w,res_t)
draw(plot)
frame(wks)
res_t@trXMinF=-1
res_t@trXMaxF=0.2
res_w@gsnRightString="time="+time2+"s"
plot = gsn_csm_x2y (wks,wt2(:,128),tht2(:,128)-lsthm2(:,128),z(:,128),res_w,res_t)
draw(plot)
frame(wks)
res_u=resmap
res_lsu=resmap
res_w@xyExplicitLegendLabels = (/"WT","UT-LSUM"/)
res_lsu@pmLegendOrthogonalPosF = -0.4
res_lsu@pmLegendParallelPosF = .15
res_lsu@trXMinF=-0.2
res_lsu@trXMaxF=0.8
res_lsu@xyLineColors = (/"green"/) ; change line color
res_lsu@xyExplicitLegendLabels = (/"UT-LSUM"/)
res_lsu@gsnLeftString = "UT-LSUM" ; title
res_lsu@tiMainFontHeightF = 0.015
res_w@gsnRightString="time="+time1+"s"
plot = gsn_csm_x2y (wks,wt1(:,128),ut1(:,128)-lsum1(:,128),z(:,128),res_w,res_lsu)
draw(plot)
frame(wks)
res_lsu@trXMinF=-2
res_lsu@trXMaxF=2
res_w@gsnRightString="time="+time2+"s"
plot = gsn_csm_x2y (wks,wt2(:,128),ut2(:,128)-lsum2(:,128),z(:,128),res_w,res_lsu)
draw(plot)
frame(wks)
end