load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "./taylor_diagram_jat.ncl" ; this is modified to handle legends for specific purposes for these graphs load "./taylor_diagram_jat_ppt.ncl" ; diff axis limits to temp plots etc.. load "./taylor_diagram_jat_tmax.ncl" ;--------- Special procudure which will be required for later on for bias plots ---------- ; This procedure adds markers to a plot, making sure that each ; set is returned to a unique variable name, and that this ; variable is retained even outside this procedure call. ; ;procedure add_markers(wks,plot,x,y,color,type) ;local pmres, str ;begin ; pmres = True ; pmres@gsMarkerColor = color ; pmres@gsMarkerIndex = type ; pmres@gsMarkerSizeF = 0.011 ; ; str = unique_string("polymarker") ; "unique_string" will return a unique ; ; string every time it is called from ; ; within a single NCL session. ; ; You can then use this unique string as an attribute variable name ; that gets attached to the plot variable. This ensures that this ; value will live for the duration of the script. ; ; plot@$str$ = gsn_add_polymarker(wks, plot, x, y, pmres) ;end ;----------------------------------------------------------------------------------------- begin ;------------- define some global plotting resources ----------------------------------------------------------- type = "pdf" resTaylor = True ; use for labels later on resTaylor@caseLabels = (/"REF","N_SST","FNL","ERA","RUC","BMJ","RTG","CAM","AC2","AC2_P","3C","5C_D","FNL_RTG","ERA_RTG"/) resTaylor@centerDiffRMS = True ; put RMS 'circles' on Taylor plots ; don't draw or advance frame since panel plotting resTaylor@taylorDraw = False resTaylor@taylorFrame = False resTaylor@caseLabelsFontHeightF = 0.14 ; caseLabels size [default=0.12 ] resTaylor@varLabelsFontHeightF = 0.015 ; varLabels size [default=0.013 ] resTaylor@gsMarkerSizeF = 0.011 ; marker size [default=0.0085] resTaylor@txFontHeightF = 0.03 ; panelres pres = True pres@gsnPanelRight = 0.89 ;pres@gsnPanelXWhiteSpacePercent = 20.0 ;pres@gsnPanelYWhiteSpacePercent = 0.0 ;bias plot resources ;create dummy x values, ie., 1,1,1,2,2,2,3,3,3,.....,13,13,13 x1 = new((/dimsizes(resTaylor@caseLabels)*3/),"integer") cc = 0; do i = 1,dimsizes(resTaylor@caseLabels),1 do j = 1,3,1 x1(cc) = i cc = cc +1 end do end do delete(cc) ;define index of coast, wheatbelt, and bush points for use later on for xy plot coast_ind = ispan(0,39,3) wb_ind = ispan(1,40,3) bu_ind = ispan(2,41,3) resBias = True resBias@xyLineColor = "white" ; do not want line, but just labels ; define x labels resBias@tmXBMode = "Explicit" ; explicit labels ;resBias@tmXBValues = (/1,2,3,4,5,6,7,8,9,10,11,12,13/) ; location of labels resBias@tmXBValues = ispan(1,14,1) ;resBias@tmXBLabels = (/"REF","SST","FNL","ERA","BMJ","RTG","CAM","AC2","AC2-P","3C","5C-D","FNL-RTG","ERA-RTG"/); resBias@tmXBLabelFontHeightF = 0.025 resBias@tmYLLabelFontHeightF = 0.025 resBias@tmXBLabelAngleF = 90 resBias@gsnDraw = False resBias@gsnFrame = False resBias@gsnYRefLine = 0. ; set reference line to zero ;set axis limits for bias plots resBias@trXMinF = 0 resBias@trXMaxF = 15 resBias@tiYAxisFontHeightF = 0.035 Colors = (/"red","red","red", \ "blue","blue","blue", \ "black","black","black", \ "green","green","green", \ "pink", "pink", "pink", \ "brown","brown","brown", \ "purple","purple","purple", \ "yellow","yellow","yellow", \ "red","red","red", \ "blue","blue","blue", \ "yellow","yellow","yellow", \ "purple","purple","purple", \ "black","black","black", \ "green","green","green" /) ;for adding y=0 line to bias plot for reference later on x2 = ispan(0,15,1) y2 = x2 - x2 lnres = True lnres@xyLineThicknesses = 3.0 all_seas_title = (/"(a) DJF","(b) MAM","(c) JJA","(d) SON"/) ;---------------------------------------------------------------------------------------------------------------- ; open file with all stats f1 = addfile("REG_BOM_NORELAX_add_RUC.nc","r") ; define vars and seasons to loop through and do taylor and bias plots var_field = (/"tmax","tmin","ppt"/) var_season = (/"DJF","MAM","JJA","SON"/) ; define some panel figure titles for later on t_ppt = (/"DJF PPT","MAM PPT","JJA PPT","SON PPT"/) t_tmax = (/"DJF TMAX","MAM TMAX","JJA TMAX","SON TMAX"/) t_tmin = (/"DJF TMIN","MAM TMIN","JJA TMIN","SON TMIN"/) ; loop through vars and seasons do i = 0,dimsizes(var_field)-1,1 ; define x-label for bias plot here, and also conc circles for taylor plots if (i .eq. 2) ; if plotting ppt resBias@tiYAxisString = "Bias (mm/month)" resTaylor@stnRad = (/2.0,3.0,4.0,5.0,6.0,7.0/) else if (i .eq. 0) resBias@tiYAxisString = "Bias (~S~o~N~C)" resTaylor@stnRad = (/ 0.5, 1.5, 2.0, 2.5, 3.0/) else resBias@tiYAxisString = "Bias (~S~o~N~C)" resTaylor@stnRad = (/ 0.5, 1.5, 2.0/) end if end if wks = gsn_open_wks(type,(var_field(i) + "-bom-norelax-allseas_tay_with_ruc")) plot = new(4,graphic) do j = 0,dimsizes(var_season)-1,1 if j .eq. 1 ;resTaylor@caseLabels = (/"REF","SST","FNL","ERA","BMJ","RTG","CAM","AC2","AC2-P","3C","5C-D","FNL-RTG","ERA-RTG"/) resTaylor@caseLabels = (/"REF","N_SST","FNL","ERA","RUC","BMJ","RTG","CAM","AC2","AC2_P","3C","5C_D","FNL_RTG","ERA_RTG"/) else delete(resTaylor@caseLabels) end if ; define wks ; wks = gsn_open_wks(type,(var_field(i) + "-bom-norelax-" + var_season(j) + "_tay-bias")) ; plot = new((/2/),graphic) ; also need to define two new markers here since they need wks ;This example adds a filled square to the marker table and keeps all of its default settings: mstring = "y" fontnum = 35 xoffset = 0.0 yoffset = 0.0 ratio = 1.0 size = 1.0 angle = 0.0 new_index1 = NhlNewMarker(wks, mstring, fontnum, xoffset, yoffset, ratio, size, angle) ;This example adds a filled triangle to the marker table mstring = "u" fontnum = 34 xoffset = 0.0 yoffset = 0.0 ratio = 1.0 size = 1.8 angle = 0.0 new_index2 = NhlNewMarker(wks, mstring, fontnum, xoffset, yoffset, ratio, size, angle) delete(mstring) delete(fontnum) delete(xoffset) delete(yoffset) delete(ratio) delete(size) delete(angle) ; define markers for plots here since these call the 2 new markers markers = (/new_index1,new_index2,16, \ new_index1,new_index2,16, \ new_index1,new_index2,16, \ new_index1,new_index2,16, \ new_index1,new_index2,16, \ new_index1,new_index2,16, \ new_index1,new_index2,16, \ new_index1,new_index2,16, \ 6,7,4, \ 6,7,4, \ 6,7,4, \ 6,7,4, \ 6,7,4, \ 6,7,4/) ; pre-define some arrays to put ratios and corr pats in ratio_var = new((/14,3/),"float") cc = new((/14,3/),"float") ; define a 1d array to put biases y1 = new((/42/),"float") coast_ratio = f1->$("var_rat_" + var_season(j) + "_" + var_field(i) + "_" + "coast")$ coast_pat = f1->$("corr_pat_" + var_season(j) + "_" + var_field(i) + "_" + "coast")$ coast_bias = f1->$("bias_" + var_season(j) + "_" + var_field(i) + "_" + "coast")$ wb_ratio = f1->$("var_rat_" + var_season(j) + "_" + var_field(i) + "_" + "wb")$ wb_pat = f1->$("corr_pat_" + var_season(j) + "_" + var_field(i) + "_" + "wb")$ wb_bias = f1->$("bias_" + var_season(j) + "_" + var_field(i) + "_" + "wb")$ bu_ratio = f1->$("var_rat_" + var_season(j) + "_" + var_field(i) + "_" + "bu")$ bu_pat = f1->$("corr_pat_" + var_season(j) + "_" + var_field(i) + "_" + "bu")$ bu_bias = f1->$("bias_" + var_season(j) + "_" + var_field(i) + "_" + "bu")$ ; now put in ratio and cc arrays for input into taylor_diagram function ratio_var(:,0) = (/coast_ratio/) ratio_var(:,1) = (/wb_ratio/) ratio_var(:,2) = (/bu_ratio/) if (i .eq. 2 .and. j .eq. 0) print(max(ratio_var)) end if cc(:,0) = (/coast_pat/) cc(:,1) = (/wb_pat/) cc(:,2) = (/bu_pat/) ; put biases in y1 for bias plot do k = 0,dimsizes(coast_bias)-1,1 y1(coast_ind(k)) = (/coast_bias(k)/) y1(wb_ind(k)) = (/wb_bias(k)/) y1(bu_ind(k)) = (/bu_bias(k)/) end do resTaylor@tiMainString = all_seas_title(j) resTaylor@tiMainFontHeightF = 0.035 ;do taylor plot if (i .eq. 2) ; if ppt plot plot(j) = taylor_diagram_jat_ppt(wks,ratio_var,cc,resTaylor) else if (i .eq. 0) plot(j) = taylor_diagram_jat_tmax(wks,ratio_var,cc,resTaylor) else plot(j) = taylor_diagram_jat(wks,ratio_var,cc,resTaylor) end if end if delete(resTaylor@tiMainString) ; do bias plot ; plot(0) = gsn_csm_xy(wks,x1,y1,resBias) ; add markers to bias plot ; do kk = 0,dimsizes(markers)-1,1 ; add_markers(wks,plot(0),x1(kk),y1(kk),Colors(kk),markers(kk)) ; end do ; panel the plots ; panel title ; if (i .eq. 0) ; pres@txString = t_tmax(j) ; end if ; if (i .eq. 1) ; pres@txString = t_tmin(j) ; end if ; if (i .eq. 2) ; pres@txString = t_ppt(j) ; end if ; pres@txString = var_season(j) ; gsn_panel(wks,plot,(/1,2/),pres) ; delete(pres@txString) delete(coast_ratio) delete(coast_pat) delete(coast_bias) delete(wb_ratio) delete(wb_pat) delete(wb_bias) delete(bu_ratio) delete(bu_pat) delete(bu_bias) delete(ratio_var) delete(cc) ;delete(wks) delete(y1) end do gsn_panel(wks,plot,(/2,2/),pres) delete(plot) delete(wks) system("pdfcrop " + var_field(i) + "-bom-norelax-allseas_tay_with_ruc.pdf " + var_field(i) + "-bom-norelax-allseas_tay_with_ruc.pdf") delete(resBias@tiYAxisString) delete(resTaylor@stnRad) end do end