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

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

Plots for DCMIP2016

File size: 7.3 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; Modified by Kevin Viner for terminator ouput
10; Further modified by Maximo Menchaca for creating gifs
11;
12; v1.01 - 6/7/16
13; v1.02 - 6/8/16 - Typo in var_choice options
14;================================================;
15load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"   
16load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
17load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"   
18load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"   
19; ================================================;
20
21begin
22
23;=================================================;
24; open file and read in data
25; GIVEN AS (time,lev,lat,lon) from 0 to n-1
26;=================================================;
27
28  ; NOTE, that this file needs to be a catted file including all times at daily interval
29  ; if you are outputting 1 file per time, you can run "ncrcat dcmip1.files.*.nc cat.nc"
30  ; for one file
31
32        f = addfile("output_dcmip2016_regular.nc","r")
33
34use_pdf = False
35
36                ; Input useful parameters
37
38        lat  = f->lat
39        lon  = f->lon
40        lev  = f->lev
41        nlat   = getfilevardimsizes(f, "lat" )
42        nlon   = getfilevardimsizes(f, "lon" )
43        nlev   = getfilevardimsizes(f, "lev" )
44
45  ; We want plots of temperature, vertical velocity and relative vorticity
46  ; at the 850 hPa level. We also want surface pressure.
47
48  ; Select var_choice   1 - average integrated atomic Cl
49  ;                     2 - average integrated diatomic Cl
50  ;                     3 - average integrated Cly
51        do var_choice = 1,3
52
53        if (var_choice .eq. 1) then                             ; Select Cl
54                filename_string = "DYNAMICO-case161latlonQ1int"         ; output using X11
55        else if (var_choice .eq. 2) then                        ; Select Cl2
56                filename_string = "DYNAMICO-case161latlonQ2int"         ; output using png
57        else if (var_choice .eq. 3) then                        ; Select Cly
58                filename_string = "DYNAMICO-case161latlonQtot_int"
59        end if
60        end if
61        end if
62       
63if(use_pdf) then
64        wks  = gsn_open_wks("pdf",filename_string)      ; output using X11
65else
66        wks  = gsn_open_wks("png",filename_string)      ; output using png
67end if
68
69                ; We want the output at days 6, 9, 12 and 15. If your model
70                ; output is in 6 hourly intervals this becomes indices 24, 36, 48 and 60
71
72        output_per_day=8 ; 3-hourly outputs
73        do d = 1,30*output_per_day, (output_per_day/4)
74        day_curr = d/output_per_day
75
76        varload1 = f->Q1_col_int
77        varload2 = f->Q2_col_int
78        if (var_choice .eq. 1) then                             ; Select Cl
79                var1 = varload1(d,:,:)/4e-6
80                filename_string = "DYNAMICO-case161latlonQ1int"         ; output using X11
81        else if (var_choice .eq. 2) then                        ; Select Cl2
82                var1 = varload2(d,:,:)/4e-6
83                filename_string = "DYNAMICO-case161latlonQ2int"         ; output using png
84        else if (var_choice .eq. 3) then                                ; Select Cly
85                var1 = (varload1(d,:,:)+2*varload2(d,:,:))/4e-6 ; should equal 1.
86                print("Max Cly error :")
87                print(max(abs(var1-1.)))
88                var1 = 1e5*abs(var1-1.)
89                filename_string = "DYNAMICO-case161latlonQtot_int"
90        end if
91        end if
92        end if
93
94
95        var1@long_name = " "
96;       var2@long_name = " "
97;       var3@long_name = " "
98;       var4@long_name = " "
99
100                ; Delete loaded data
101
102;       delete(varload)
103
104                ; We now produce the plot
105
106;       plot  = new (4, graphic)                                ; define plot - need 4 panels
107
108        res1                      = True
109        res1@gsnDraw              = False                       ; panel plot
110        res1@gsnFrame             = False                       ; don't draw yet
111        res1@cnFillOn             = True
112        res1@cnLinesOn            = True
113        res1@gsnSpreadColors      = True
114        res1@lbLabelAutoStride    = True
115        res1@gsnCenterString      = ""
116        res1@tiMainString         = ""
117        res1@vpWidthF             = 0.38
118        res1@vpHeightF            = 0.19
119        res1@cnLevelSelectionMode = "ManualLevels"
120        res1@cnInfoLabelOn        = False                       ; don't give each
121        res1@cnLineLabelsOn       = False                       ; panel its own
122        res1@lbLabelBarOn         = False                       ; label bar
123
124        pres                          = True
125        pres@gsnMaximize              = True 
126        pres@gsnPanelLabelBar         = True                    ; Communal label bar
127        pres@gsnPanelLeft             = 0.1
128        pres@gsnPanelRight            = 0.9
129        pres@pmLabelBarOrthogonalPosF = -0.03
130        pres@gsnFrame                 = False
131        pres@lbLabelStride            = 1
132
133        res1@sfXArray        = lon                              ; uses lon as plot x-axis
134        res1@sfYArray        = lat                              ; uses lat for y axis
135        res1@trYReverse      = False                            ; reverses y-axis, false
136        res1@tiYAxisString   = ""                               ; y-axis title
137        res1@tiXAxisString   = ""                               ; x-axis title
138
139        if (var_choice .eq. 1) then     ;================ Temperature plot ====================
140 
141        pltTitle="DYNAMICO Case 161, Integrated Average Cl"                     ; Plot title if required
142        pres@txString = pltTitle
143
144                ; Change the output type and name
145
146        gsn_define_colormap(wks,"gui_default") 
147
148        res1@cnMaxLevelValF  = 1.2                              ; max contour color label
149        res1@cnMinLevelValF  = -0.1                             ; min contour color label
150        res1@cnLevelSpacingF = 0.1                              ; contour color spacing                 ; choose a colormap
151 
152        else if (var_choice .eq. 2) then        ;================ Large-scale precipitation plot ====================
153 
154        pltTitle="DYNAMICO Case 161, Integrated Average Cl2"    ; Plot title if required
155        pres@txString = pltTitle
156
157        var1@units = " "
158;       var2@units = " "
159;       var3@units = " "
160;       var4@units = " "
161
162        res1@cnLinesOn            = False                               ; Turn lines off for clearer plot
163
164                ; Change the output type and name
165
166        gsn_define_colormap(wks,"gui_default") 
167
168                ; Note that the maximum might be larger than these contour spacing values
169
170        res1@cnMaxLevelValF  = 0.48                     ; max contour color label
171        res1@cnMinLevelValF  = -0.04                            ; min contour color label
172        res1@cnLevelSpacingF = 0.04                             ; contour color spacing                 ; choose a colormap
173 
174        else if (var_choice .eq. 3) then        ;================ Surface Pressure plot ====================
175 
176        pltTitle="DYNAMICO Case 161, Integrated Average Cly"                    ; Plot title if required
177        pres@txString = pltTitle
178
179
180        var1@units = " "
181;       var2@units = " "
182;       var3@units = " "
183;       var4@units = " "
184                ; Change the output type and name
185
186        gsn_define_colormap(wks,"gui_default") 
187
188        res1@cnMaxLevelValF  = 1.24                             ; max contour color label
189        res1@cnMinLevelValF  = 0.78                             ; min contour color label
190        res1@cnLevelSpacingF = 0.04                             ; contour color spacing                 ; choose a colormap
191
192        end if                          ;============== end plot choice ===============
193        end if                          ;============== end plot choice ===============
194        end if                          ;============== end plot choice ===============
195
196        res1@gsnCenterString = "t = " + day_curr + " days"
197        plot = gsn_csm_contour(wks,var1(:,:),res1)              ; plot var1
198;
199;       res1@gsnCenterString = "t = 9"
200;       plot(1) = gsn_csm_contour(wks,var2(:,:),res1)           ; plot var2
201;
202;       res1@gsnCenterString = "t = 12"
203;       plot(2) = gsn_csm_contour(wks,var3(:,:),res1)           ; plot var3
204;
205;       res1@gsnCenterString = "t = 15"
206;       plot(3) = gsn_csm_contour(wks,var4(:,:),res1)           ; plot var4
207
208        gsn_panel(wks,plot,(/1,1/),pres)                        ; 2x2 plot
209
210                ; Add latitude and longitude labels
211
212        txres3                = True
213        txres3@txAngleF       = 90.
214        txres3@txFontHeightF  = 0.02
215        gsn_text_ndc(wks,"Latitude",0.08,0.52,txres3)
216
217        txres3@txAngleF       = 0.
218        gsn_text_ndc(wks,"Longitude",0.54,0.28,txres3)
219
220;       draw(plot)
221        frame(wks)
222
223        end do
224;       delete(varload)
225 cmd = "convert -delay 25 "+ filename_string+"*.png "+filename_string+".gif"
226 system(cmd)
227  cmd = "rm "+filename_string+"*.png"
228 system(cmd)
229        end do
230
231end
Note: See TracBrowser for help on using the repository browser.