1 ; ***********************************************
3 ; ***********************************************
4 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
5 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
6 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
7 ;************************************************
8 procedure pminmax(data:numeric,name:string)
10 print ("min/max " + name + " = " + min(data) + "/" + max(data))
11 if(isatt(data,"units")) then
12 print (name + " units = " + data@units)
22 ;************************************************
24 ;************************************************
25 dir81 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
27 f81 = addfile (dir81+fil81,"r")
31 rain81 = tofloat(f81->PREC_ANN)
35 id81@long_name = "SITE_ID"
36 npp81@long_name = "NPP (gC/m2/year)"
38 ;change longitude from (-180,180) to (0,360)
39 ;for model data interpolation
41 do i= 0,dimsizes(x81)-1
42 if (x81(i) .lt. 0.) then
47 ;-------------------------------------
48 dir933 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
49 fil933 = "data.933.nc"
50 f933 = addfile (dir933+fil933,"r")
58 id933@long_name = "SITE_ID"
59 npp933@long_name = "NPP (gC/m2/year)"
61 ;change longitude from (-180,180) to (0,360)
62 ;for model data interpolation
64 do i= 0,dimsizes(x933)-1
65 if (x933(i) .lt. 0.) then
66 x933(i) = x933(i)+ 360.
70 ;************************************************
72 ;************************************************
73 model_name = "b30.061n"
75 dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
76 film = "b30.061n_1995-2004_ANN_climo_lnd.nc"
77 fm = addfile (dirm+film,"r")
84 nppmod81 =linint2_points(xm,ym,nppmod(0,:,:),True,x81,y81,0)
86 nppmod933 =linint2_points(xm,ym,nppmod(0,:,:),True,x933,y933,0)
88 rainmod81 =linint2_points(xm,ym,rainmod(0,:,:),True,x81,y81,0)
90 rainmod933=linint2_points(xm,ym,rainmod(0,:,:),True,x933,y933,0)
92 ;************************************************
93 ; Units for these four variables are:
97 ; npp81 : g C/m^2/year
100 ; We want to convert these to "m/year" and "g C/m^2/year".
102 nsec_per_year = 60*60*24*365
104 rain81 = rain81 / 1000.
105 rainmod81 = (rainmod81/ 1000.) * nsec_per_year
106 nppmod81 = nppmod81 * nsec_per_year
108 rain933 = rain933 / 1000.
109 rainmod933 = (rainmod933/ 1000.) * nsec_per_year
110 nppmod933 = nppmod933 * nsec_per_year
112 npp81@units = "gC/m^2/yr"
113 nppmod81@units = "gC/m^2/yr"
114 npp933@units = "gC/m^2/yr"
115 nppmod933@units = "gC/m^2/yr"
116 rain81@units = "m/yr"
117 rainmod81@units = "m/yr"
118 rain933@units = "m/yr"
119 rainmod933@units = "m/yr"
121 npp81@long_name = "NPP (gC/m2/year)"
122 npp933@long_name = "NPP (gC/m2/year)"
123 nppmod81@long_name = "NPP (gC/m2/year)"
124 nppmod933@long_name = "NPP (gC/m2/year)"
125 rain81@long_name = "PREC (m/year)"
126 rain933@long_name = "PREC (m/year)"
127 rainmod81@long_name = "PREC (m/year)"
128 rainmod933@long_name = "PREC (m/year)"
130 ;(A) plot scatter ob 81
132 plot_name = "scatter_ob_81"
133 title = "Observed 81 sites"
135 wks = gsn_open_wks (plot_type,plot_name) ; open workstation
136 res = True ; plot mods desired
137 res@tiMainString = title ; add title
138 res@xyMarkLineModes = "Markers" ; choose which have markers
139 res@xyMarkers = 16 ; choose type of marker
140 res@xyMarkerColor = "red" ; Marker color
141 res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
142 res@tmLabelAutoStride = True ; nice tick mark labels
144 plot = gsn_csm_xy (wks,id81,npp81,res) ; create plot
147 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
148 system("rm "+plot_name+"."+plot_type)
149 system("rm "+plot_name+"-1."+plot_type_new)
150 system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
154 ;(B) plot scatter ob 933
156 plot_name = "scatter_ob_933"
157 title = "Observed 933 sites"
159 wks = gsn_open_wks (plot_type,plot_name) ; open workstation
160 res = True ; plot mods desired
161 res@tiMainString = title ; add title
162 res@xyMarkLineModes = "Markers" ; choose which have markers
163 res@xyMarkers = 16 ; choose type of marker
164 res@xyMarkerColor = "red" ; Marker color
165 res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
166 res@tmLabelAutoStride = True ; nice tick mark labels
168 plot = gsn_csm_xy (wks,id933,npp933,res) ; create plot
171 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
172 system("rm "+plot_name+"."+plot_type)
173 system("rm "+plot_name+"-1."+plot_type_new)
174 system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
178 ;(C) plot scatter model 81
180 plot_name = "scatter_model_81"
181 title = "Model "+ model_name +" 81 sites"
183 wks = gsn_open_wks (plot_type,plot_name) ; open workstation
184 res = True ; plot mods desired
185 res@tiMainString = title ; add title
186 res@xyMarkLineModes = "Markers" ; choose which have markers
187 res@xyMarkers = 16 ; choose type of marker
188 res@xyMarkerColor = "red" ; Marker color
189 res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
190 res@tmLabelAutoStride = True ; nice tick mark labels
192 plot = gsn_csm_xy (wks,id81,nppmod81,res) ; create plot
195 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
196 system("rm "+plot_name+"."+plot_type)
197 system("rm "+plot_name+"-1."+plot_type_new)
198 system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
202 ;(D) plot scatter model 933
204 plot_name = "scatter_model_933"
205 title = "Model "+ model_name +" 933 sites"
207 wks = gsn_open_wks (plot_type,plot_name) ; open workstation
208 res = True ; plot mods desired
209 res@tiMainString = title ; add title
210 res@xyMarkLineModes = "Markers" ; choose which have markers
211 res@xyMarkers = 16 ; choose type of marker
212 res@xyMarkerColor = "red" ; Marker color
213 res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
214 res@tmLabelAutoStride = True ; nice tick mark labels
216 plot = gsn_csm_xy (wks,id933,nppmod933,res) ; create plot
219 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
220 system("rm "+plot_name+"."+plot_type)
221 system("rm "+plot_name+"-1."+plot_type_new)
222 system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
226 ;(E) scatter model vs ob 81
228 plot_name = "scatter_model_vs_ob_81"
229 title = model_name +" vs ob 81 sites"
231 wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232 res = True ; plot mods desired
233 res@tiMainString = title ; add title
234 res@xyMarkLineModes = "Markers" ; choose which have markers
235 res@xyMarkers = 16 ; choose type of marker
236 res@xyMarkerColor = "red" ; Marker color
237 res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
238 res@tmLabelAutoStride = True ; nice tick mark labels
239 ;-------------------------------
240 ;compute correlation coef. and M
241 ccr81 = esccr(nppmod81,npp81,0)
245 bias = sum(abs(nppmod81-npp81)/(nppmod81+npp81))
246 M81 = (1. - (bias/dimsizes(y81)))*5.
250 tRes@txFontHeightF = 0.025
252 correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81)+")"
254 gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
255 ;--------------------------------
256 plot = gsn_csm_xy (wks,npp81,nppmod81,res) ; create plot
259 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
260 system("rm "+plot_name+"."+plot_type)
261 system("rm "+plot_name+"-1."+plot_type_new)
262 system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
266 ;(F) scatter model vs ob 933
268 plot_name = "scatter_model_vs_ob_933"
269 title = model_name +" vs ob 933 sites"
271 wks = gsn_open_wks (plot_type,plot_name) ; open workstation
272 res = True ; plot mods desired
273 res@tiMainString = title ; add title
274 res@xyMarkLineModes = "Markers" ; choose which have markers
275 res@xyMarkers = 16 ; choose type of marker
276 res@xyMarkerColor = "red" ; Marker color
277 res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
278 res@tmLabelAutoStride = True ; nice tick mark labels
279 ;-------------------------------
280 ;compute correlation coef. and M
281 ccr933 = esccr(nppmod933,npp933,0)
285 bias = sum(abs(nppmod933-npp933)/(nppmod933+npp933))
286 M933 = (1. - (bias/dimsizes(y933)))*5.
290 tRes@txFontHeightF = 0.025
292 correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933)+")"
294 gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
295 ;--------------------------------
296 plot = gsn_csm_xy (wks,npp933,nppmod933,res) ; create plot
299 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
300 system("rm "+plot_name+"."+plot_type)
301 system("rm "+plot_name+"-1."+plot_type_new)
302 system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
305 ;**************************************************************************
308 ;--------------------------------------------------------------------
311 RAIN1_1D = ndtooned(rain81)
312 RAIN2_1D = ndtooned(rainmod81)
313 NPP1_1D = ndtooned(npp81)
314 NPP2_1D = ndtooned(nppmod81)
316 ; Calculate some "nice" bins for binning the data in equally spaced
319 nbins = 15 ; Number of bins to use.
321 nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
322 nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
323 range = fspan(nicevals(0),nicevals(1),nvals)
325 ; Use this range information to grab all the values in a
326 ; particular range, and then take an average.
330 xvalues = new((/2,nx/),typeof(RAIN1_1D))
331 xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
332 dx = xvalues(0,1) - xvalues(0,0) ; range width
333 dx4 = dx/4 ; 1/4 of the range
334 xvalues(1,:) = xvalues(0,:) - dx/5.
335 yvalues = new((/2,nx/),typeof(RAIN1_1D))
336 mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
337 mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
341 ; See if we are doing model or observational data.
351 ; Loop through each range and check for values.
354 if (i.ne.(nr-2)) then
356 ; print("In range ["+range(i)+","+range(i+1)+")")
357 idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
360 ; print("In range ["+range(i)+",)")
361 idx = ind(range(i).le.data)
364 ; Calculate average, and get min and max.
366 if(.not.any(ismissing(idx))) then
367 yvalues(nd,i) = avg(npp_data(idx))
368 mn_yvalues(nd,i) = min(npp_data(idx))
369 mx_yvalues(nd,i) = max(npp_data(idx))
370 count = dimsizes(idx)
373 yvalues(nd,i) = yvalues@_FillValue
374 mn_yvalues(nd,i) = yvalues@_FillValue
375 mx_yvalues(nd,i) = yvalues@_FillValue
378 ; Print out information.
380 ; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
381 ; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
384 ; Clean up for next time in loop.
391 ;----------------------------------------
392 ;compute correlation coeff and M score
396 good = ind(.not.ismissing(u) .and. .not.ismissing(v))
400 ccr81h = esccr(uu,vv,0)
404 bias = sum(abs(vv-uu)/(vv+uu))
405 M81h = (1.- (bias/dimsizes(uu)))*5.
412 ;----------------------------------------------------------------------
416 res@gsnMaximize = True
419 res@xyMarkLineMode = "Markers"
420 res@xyMarkerSizeF = 0.014
422 res@xyMarkerColors = (/"Brown","Blue"/)
423 res@trYMinF = min(mn_yvalues) - 10.
424 res@trYMaxF = max(mx_yvalues) + 10.
426 res@tiYAxisString = "NPP (g C/m2/year)"
427 res@tiXAxisString = "Precipitation (m/year)"
429 max_bar = new((/2,nx/),graphic)
430 min_bar = new((/2,nx/),graphic)
431 max_cap = new((/2,nx/),graphic)
432 min_cap = new((/2,nx/),graphic)
435 line_colors = (/"brown","blue"/)
436 ;=================================================================
437 ; histogram ob 81 site only
439 plot_name = "histogram_ob_81"
440 title = "Observed 81 site"
441 res@tiMainString = title
443 wks = gsn_open_wks (plot_type,plot_name)
445 xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),res)
447 ;-------------------------------
448 ;Attach the vertical bar and the horizontal cap line
451 lnres@gsLineColor = line_colors(nd)
454 if(.not.ismissing(mn_yvalues(nd,i)).and. \
455 .not.ismissing(mx_yvalues(nd,i))) then
457 ; Attach the vertical bar, both above and below the marker.
461 y2 = mn_yvalues(nd,i)
462 min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
464 y2 = mx_yvalues(nd,i)
465 max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
467 ; Attach the horizontal cap line, both above and below the marker.
469 x1 = xvalues(nd,i) - dx4
470 x2 = xvalues(nd,i) + dx4
471 y1 = mn_yvalues(nd,i)
472 min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
474 y1 = mx_yvalues(nd,i)
475 max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
483 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
484 ; system("rm "+plot_name+"."+plot_type)
485 ; system("rm "+plot_name+"-1."+plot_type_new)
486 ; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
489 ;===========================================================================
490 ; histogram model vs ob 81 site
492 plot_name = "histogram_mod-ob_81"
493 title = model_name+ " vs Observed 81 site"
494 res@tiMainString = title
496 wks = gsn_open_wks (plot_type,plot_name) ; open workstation
498 ;-----------------------------
499 ; Add a boxed legend using the more simple method, which won't have
500 ; vertical lines going through the markers.
502 res@pmLegendDisplayMode = "Always"
503 ; res@pmLegendWidthF = 0.1
504 res@pmLegendWidthF = 0.08
505 res@pmLegendHeightF = 0.05
506 res@pmLegendOrthogonalPosF = -1.17
507 ; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
508 ; res@pmLegendParallelPosF = 0.18
509 res@pmLegendParallelPosF = 0.23 ;(rightward)
511 ; res@lgPerimOn = False
512 res@lgLabelFontHeightF = 0.015
513 res@xyExplicitLegendLabels = (/"observed",model_name/)
514 ;-----------------------------
516 tRes@txFontHeightF = 0.025
518 correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81h)+")"
520 gsn_text_ndc(wks,correlation_text,0.5,0.8,tRes)
522 xy = gsn_csm_xy(wks,xvalues,yvalues,res)
523 ;-------------------------------
524 ;Attach the vertical bar and the horizontal cap line
527 lnres@gsLineColor = line_colors(nd)
530 if(.not.ismissing(mn_yvalues(nd,i)).and. \
531 .not.ismissing(mx_yvalues(nd,i))) then
533 ; Attach the vertical bar, both above and below the marker.
537 y2 = mn_yvalues(nd,i)
538 min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
540 y2 = mx_yvalues(nd,i)
541 max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
543 ; Attach the horizontal cap line, both above and below the marker.
545 x1 = xvalues(nd,i) - dx4
546 x2 = xvalues(nd,i) + dx4
547 y1 = mn_yvalues(nd,i)
548 min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
550 y1 = mx_yvalues(nd,i)
551 max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
558 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
559 ;system("rm "+plot_name+"."+plot_type)
560 ;system("rm "+plot_name+"-1."+plot_type_new)
561 ;system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
579 ;**************************************************************************
582 ;--------------------------------------------------------------------
585 RAIN1_1D = ndtooned(rain933)
586 RAIN2_1D = ndtooned(rainmod933)
587 NPP1_1D = ndtooned(npp933)
588 NPP2_1D = ndtooned(nppmod933)
590 ; Calculate some "nice" bins for binning the data in equally spaced
593 nbins = 15 ; Number of bins to use.
595 nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
596 nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
597 range = fspan(nicevals(0),nicevals(1),nvals)
599 ; Use this range information to grab all the values in a
600 ; particular range, and then take an average.
604 xvalues = new((/2,nx/),typeof(RAIN1_1D))
605 xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
606 dx = xvalues(0,1) - xvalues(0,0) ; range width
607 dx4 = dx/4 ; 1/4 of the range
608 xvalues(1,:) = xvalues(0,:) - dx/5.
609 yvalues = new((/2,nx/),typeof(RAIN1_1D))
610 mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
611 mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
615 ; See if we are doing model or observational data.
625 ; Loop through each range and check for values.
628 if (i.ne.(nr-2)) then
630 ; print("In range ["+range(i)+","+range(i+1)+")")
631 idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
634 ; print("In range ["+range(i)+",)")
635 idx = ind(range(i).le.data)
638 ; Calculate average, and get min and max.
640 if(.not.any(ismissing(idx))) then
641 yvalues(nd,i) = avg(npp_data(idx))
642 mn_yvalues(nd,i) = min(npp_data(idx))
643 mx_yvalues(nd,i) = max(npp_data(idx))
644 count = dimsizes(idx)
647 yvalues(nd,i) = yvalues@_FillValue
648 mn_yvalues(nd,i) = yvalues@_FillValue
649 mx_yvalues(nd,i) = yvalues@_FillValue
652 ; Print out information.
654 ; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
655 ; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
658 ; Clean up for next time in loop.
665 ;----------------------------------------
666 ;compute correlation coeff and M score
670 good = ind(.not.ismissing(u) .and. .not.ismissing(v))
674 ccr933h = esccr(uu,vv,0)
678 bias = sum(abs(vv-uu)/(vv+uu))
679 M933h = (1.- (bias/dimsizes(uu)))*5.
686 ;----------------------------------------------------------------------
690 res@gsnMaximize = True
693 res@xyMarkLineMode = "Markers"
694 res@xyMarkerSizeF = 0.014
696 res@xyMarkerColors = (/"Brown","Blue"/)
697 res@trYMinF = min(mn_yvalues) - 10.
698 res@trYMaxF = max(mx_yvalues) + 10.
700 res@tiYAxisString = "NPP (g C/m2/year)"
701 res@tiXAxisString = "Precipitation (m/year)"
703 max_bar = new((/2,nx/),graphic)
704 min_bar = new((/2,nx/),graphic)
705 max_cap = new((/2,nx/),graphic)
706 min_cap = new((/2,nx/),graphic)
709 line_colors = (/"brown","blue"/)
710 ;=================================================================
711 ; histogram ob 933 site only
713 plot_name = "histogram_ob_933"
714 title = "Observed 933 site"
715 res@tiMainString = title
717 wks = gsn_open_wks (plot_type,plot_name)
719 xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),res)
721 ;-------------------------------
722 ;Attach the vertical bar and the horizontal cap line
725 lnres@gsLineColor = line_colors(nd)
728 if(.not.ismissing(mn_yvalues(nd,i)).and. \
729 .not.ismissing(mx_yvalues(nd,i))) then
731 ; Attach the vertical bar, both above and below the marker.
735 y2 = mn_yvalues(nd,i)
736 min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
738 y2 = mx_yvalues(nd,i)
739 max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
741 ; Attach the horizontal cap line, both above and below the marker.
743 x1 = xvalues(nd,i) - dx4
744 x2 = xvalues(nd,i) + dx4
745 y1 = mn_yvalues(nd,i)
746 min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
748 y1 = mx_yvalues(nd,i)
749 max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
757 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
758 ; system("rm "+plot_name+"."+plot_type)
759 ; system("rm "+plot_name+"-1."+plot_type_new)
760 ; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
763 ;===========================================================================
764 ; histogram model vs ob 933 site
766 plot_name = "histogram_mod-ob_933"
767 title = model_name+ " vs Observed 933 site"
768 res@tiMainString = title
770 wks = gsn_open_wks (plot_type,plot_name) ; open workstation
772 ;-----------------------------
773 ; Add a boxed legend using the more simple method, which won't have
774 ; vertical lines going through the markers.
776 res@pmLegendDisplayMode = "Always"
777 ; res@pmLegendWidthF = 0.1
778 res@pmLegendWidthF = 0.08
779 res@pmLegendHeightF = 0.05
780 res@pmLegendOrthogonalPosF = -1.17
781 ; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
782 ; res@pmLegendParallelPosF = 0.18
783 res@pmLegendParallelPosF = 0.23 ;(rightward)
785 ; res@lgPerimOn = False
786 res@lgLabelFontHeightF = 0.015
787 res@xyExplicitLegendLabels = (/"observed",model_name/)
788 ;-----------------------------
790 tRes@txFontHeightF = 0.025
792 correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933h)+")"
794 gsn_text_ndc(wks,correlation_text,0.5,0.8,tRes)
796 xy = gsn_csm_xy(wks,xvalues,yvalues,res)
797 ;-------------------------------
798 ;Attach the vertical bar and the horizontal cap line
801 lnres@gsLineColor = line_colors(nd)
804 if(.not.ismissing(mn_yvalues(nd,i)).and. \
805 .not.ismissing(mx_yvalues(nd,i))) then
807 ; Attach the vertical bar, both above and below the marker.
811 y2 = mn_yvalues(nd,i)
812 min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
814 y2 = mx_yvalues(nd,i)
815 max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
817 ; Attach the horizontal cap line, both above and below the marker.
819 x1 = xvalues(nd,i) - dx4
820 x2 = xvalues(nd,i) + dx4
821 y1 = mn_yvalues(nd,i)
822 min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
824 y1 = mx_yvalues(nd,i)
825 max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
832 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
833 ;system("rm "+plot_name+"."+plot_type)
834 ;system("rm "+plot_name+"-1."+plot_type_new)
835 ;system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
838 ;------------------------------------------------------------------------