source: configs/dcmip2016/PLOTS/testcase/BAROCLINIC_WAVE/dcmip1-lat-lon-TPLSPS.ncl @ 437

Last change on this file since 437 was 437, checked in by dubos, 8 years ago

Plots for DCMIP2016

File size: 7.9 KB
Line 
1;================================================;
2;       Example ncl script to produce the set of
3;       lat-lon plots for DCMIP-2016 test case 1
4; Created by James Kent, Christiane Jablonowski
5;       and Paul Ullrich (University of Michigan) for DCMIP-2012
6;
7; Modified by Colin Zarzycki for DCMIP-2016
8;
9; v1.01 - 6/7/16
10; v1.02 - 6/8/16 - Typo in var_choice options
11;================================================;
12load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"   
13load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
14load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"   
15load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"   
16; ================================================;
17
18; NOTE, if your model does not output T850 OR P at level
19; midpoints OR you cannot calculate P from hybrid levels, you
20; will need to make model specific additions denoted by
21; CALCPHERE below
22
23; PRECL needs to be in m/s for contours to plot correctly
24
25begin
26
27;=================================================;
28; open file and read in data
29; GIVEN AS (time,lev,lat,lon) from 0 to n-1
30;=================================================;
31
32  ; NOTE, that this file needs to be a catted file including all times at daily interval
33  ; if you are outputting 1 file per time, you can run "ncrcat dcmip1.files.*.nc cat.nc"
34  ; for one file
35
36; TD    f = addfile("/home/zarzycki/dcmip/results/dcmip1/newcat.nc","r")
37   f = addfile("output_dcmip2016_regular.nc","r")
38                ; Input useful parameters
39
40        lat  = f->lat
41  lon  = f->lon
42        lev  = f->lev
43        nlat   = getfilevardimsizes(f, "lat" )
44        nlon   = getfilevardimsizes(f, "lon" )
45        nlev   = getfilevardimsizes(f, "lev" )
46
47  ; We want plots of temperature, vertical velocity and relative vorticity
48  ; at the 850 hPa level. We also want surface pressure.
49
50  ; Select var_choice   1 - Temperature at 850 hPa
51  ;                     2 - Large-scale precipitation
52  ;                     3 - Surface Pressure
53
54        var_choice = 3
55       
56        if (var_choice .eq. 1) then                             ; Select T
57
58                if (isfilevar(f,"T850")) then
59
60                        varload = f->T850
61
62                else   
63
64                        ; we interp T to the 850 hPa level
65                        varload0 = f->T                         ; T is a 4D var
66                        varload  = f->T(:,0,:,:)
67                        ; Calculate P using hybrid coefficients
68                        ; If you have pressure as a variable just do
69                        ; P = f->P
70      ; CALCPHERE
71                        hyam = f->hyam
72                hybm = f->hybm
73                P0   = f->P0
74                        PS   = f->PS
75                        P    = 0.0*varload0
76                        P = pres_hybrid_ccm(PS,P0,hyam,hybm)
77                        P!0 = "time"
78                        P!1 = "lev"
79                        P!2 = "lat"
80                        P!3 = "lon"
81                        ; interp to 850 hPa level
82                        plevel = 85000.0
83                        varload = int2p_n(P,varload0,plevel,2,1)
84
85                end if
86
87        else if (var_choice .eq. 2) then                        ; Select Large-scale precipitation
88
89                varload = f->PRECL
90    varload=varload*8.64e7             
91
92        else if (var_choice .eq. 3) then                        ; Select PS
93
94                varload = f->PS
95
96        end if
97        end if 
98        end if
99
100                ; We want the output at days 6, 9, 12 and 15. If your model
101                ; output is in 6 hourly intervals this becomes indices 24, 36, 48 and 60
102
103        output_per_day=8
104        day6  = 6*output_per_day
105        day9  = 9*output_per_day
106        day12 = 12*output_per_day
107        day15 = 15*output_per_day
108
109        var1 = varload(day6,:,:)
110        var2 = varload(day9,:,:)
111        var3 = varload(day12,:,:)
112        var4 = varload(day15,:,:)
113
114                ; We don't want long-name in the plots
115
116        var1@long_name = " "
117        var2@long_name = " "
118        var3@long_name = " "
119        var4@long_name = " "
120
121                ; Delete loaded data
122
123        delete(varload)
124
125                ; We now produce the plot
126
127        plot  = new (4, graphic)                                ; define plot - need 4 panels
128
129        res1                      = True
130        res1@gsnDraw              = False                       ; panel plot
131        res1@gsnFrame             = False                       ; don't draw yet
132        res1@cnFillOn             = True
133        res1@cnLinesOn            = True
134        res1@gsnSpreadColors      = True
135        res1@lbLabelAutoStride    = True
136        res1@gsnCenterString      = ""
137        res1@tiMainString         = ""
138        res1@vpWidthF             = 0.38
139        res1@vpHeightF            = 0.19
140        res1@cnLevelSelectionMode = "ManualLevels"
141        res1@cnInfoLabelOn        = False                       ; don't give each
142        res1@cnLineLabelsOn       = False                       ; panel its own
143        res1@lbLabelBarOn         = False                       ; label bar
144
145        pres                          = True
146        pres@gsnMaximize              = True 
147        pres@gsnPanelLabelBar         = True                    ; Communal label bar
148        pres@gsnPanelLeft             = 0.1
149        pres@gsnPanelRight            = 0.9
150        pres@pmLabelBarOrthogonalPosF = -0.03
151        pres@gsnFrame                 = False
152        pres@lbLabelStride            = 1
153
154        res1@sfXArray        = lon                              ; uses lon as plot x-axis
155        res1@sfYArray        = lat                              ; uses lat for y axis
156        res1@trYReverse      = False                            ; reverses y-axis, false
157        res1@tiYAxisString   = ""                               ; y-axis title
158        res1@tiXAxisString   = ""                               ; x-axis title
159
160        if (var_choice .eq. 1) then     ;================ Temperature plot ====================
161 
162        pltTitle="DYNAMICO Test DCMIP-2016-1, T850 hPa"                         ; Plot title if required
163        pres@txString = pltTitle
164
165                ; Change the output type and name
166
167        ;wks  = gsn_open_wks("X11","cam-fv-test42latlonT850")           ; output using X11
168        ;wks  = gsn_open_wks("eps","cam-fv-test42latlonT850")           ; output using eps
169        wks  = gsn_open_wks("png","DYNAMICO-test42latlonT850")          ; output using png
170        gsn_define_colormap(wks,"gui_default") 
171
172        res1@cnMaxLevelValF  = 300.0                            ; max contour color label
173        res1@cnMinLevelValF  = 230.0                            ; min contour color label
174        res1@cnLevelSpacingF = 10.0                             ; contour color spacing                 ; choose a colormap
175 
176        else if (var_choice .eq. 2) then        ;================ Large-scale precipitation plot ====================
177 
178        pltTitle="DYNAMIXO Test 42, Large-scale precipitation"  ; Plot title if required
179        pres@txString = pltTitle
180
181        var1@units = " "
182        var2@units = " "
183        var3@units = " "
184        var4@units = " "
185
186        res1@cnLinesOn            = False                               ; Turn lines off for clearer plot
187
188                ; Change the output type and name
189
190        ;wks  = gsn_open_wks("X11","cam-fv-test42latlonPRECL")          ; output using X11
191        ;wks  = gsn_open_wks("eps","cam-fv-test42latlonPRECL")          ; output using eps
192        wks  = gsn_open_wks("png","test42latlonPRECL")          ; output using png
193        gsn_define_colormap(wks,"gui_default") 
194
195                ; Note that the maximum might be larger than these contour spacing values
196
197        res1@cnMaxLevelValF  = 50.0                             ; max contour color label
198        res1@cnMinLevelValF  = 0.0                              ; min contour color label
199        res1@cnLevelSpacingF = 4.0                              ; contour color spacing                 ; choose a colormap
200 
201        else if (var_choice .eq. 3) then        ;================ Surface Pressure plot ====================
202 
203        pltTitle="DYNAMICO Test 42, PS"                         ; Plot title if required
204        pres@txString = pltTitle
205
206                ; Convert to hPa
207
208        var1=var1/100.0
209        var2=var2/100.0
210        var3=var3/100.0
211        var4=var4/100.0
212
213        var1@units = "hPa "
214        var2@units = "hPa "
215        var3@units = "hPa "
216        var4@units = "hPa "
217
218                ; Change the output type and name
219
220        ;wks  = gsn_open_wks("X11","cam-fv-test42latlonPS")     ; output using X11
221        ;wks  = gsn_open_wks("eps","cam-fv-test42latlonPS")     ; output using eps
222        wks  = gsn_open_wks("png","test42latlonPS")     ; output using png
223        gsn_define_colormap(wks,"gui_default") 
224
225        res1@cnMaxLevelValF  = 1020.0                           ; max contour color label
226        res1@cnMinLevelValF  = 920.0                            ; min contour color label
227        res1@cnLevelSpacingF = 10.0                             ; contour color spacing                 ; choose a colormap
228
229        end if                          ;============== end plot choice ===============
230        end if                          ;============== end plot choice ===============
231        end if                          ;============== end plot choice ===============
232
233        res1@gsnCenterString = "t = 6"
234        plot(0) = gsn_csm_contour(wks,var1(:,:),res1)           ; plot var1
235
236        res1@gsnCenterString = "t = 9"
237        plot(1) = gsn_csm_contour(wks,var2(:,:),res1)           ; plot var2
238
239        res1@gsnCenterString = "t = 12"
240        plot(2) = gsn_csm_contour(wks,var3(:,:),res1)           ; plot var3
241
242        res1@gsnCenterString = "t = 15"
243        plot(3) = gsn_csm_contour(wks,var4(:,:),res1)           ; plot var4
244
245        gsn_panel(wks,plot,(/2,2/),pres)                        ; 2x2 plot
246
247                ; Add latitude and longitude labels
248
249        txres3                = True
250        txres3@txAngleF       = 90.
251        txres3@txFontHeightF  = 0.02
252        gsn_text_ndc(wks,"Latitude",0.08,0.49,txres3)
253
254        txres3@txAngleF       = 0.
255        gsn_text_ndc(wks,"Longitude",0.5,0.22,txres3)
256
257        frame(wks)
258
259end
260
261
262
263
264
265
Note: See TracBrowser for help on using the repository browser.