forrest@0: ;******************************************************************* forrest@0: ; procedure to draw the Taylor Diagram Metrics Table forrest@0: ; forrest@0: ; AWWG METRICS 0.3 ;;; forrest@0: ; 27 Jun 06 ASP forrest@0: ; 5 Jul 06 DJS forrest@0: ; forrest@0: ; Arguments: forrest@0: ; mfname : name of the output table forrest@0: ; varNames : variable names [metrics] forrest@0: ; cases : case (model) names forrest@0: ; seasons : season names forrest@0: ; values : array containing the values to be plotted forrest@0: ; opt : used to pass optional arguments forrest@0: forrest@0: procedure taylor_metrics_table(mfname[1]:string \ ; plot name forrest@0: ,varNames[*]:string \ ; variables forrest@0: ,cases[*]:string \ forrest@0: ,seasons[*]:string \ forrest@0: ,values[*][*][*]:numeric \ forrest@0: ,opt:logical ) forrest@0: forrest@0: forrest@0: ;;; forrest@0: ;;; Output of metrics to a table [grid] forrest@0: forrest@0: begin forrest@0: if (.not.isatt(opt,"pltType") .or. \ forrest@0: (opt@pltType.eq."eps" .or. opt@pltType.eq."png" .or. opt@pltType.eq."gif")) then forrest@0: wks = gsn_open_wks("eps",mfname) ; default forrest@0: else forrest@0: wks = gsn_open_wks(opt@pltType,mfname) forrest@0: end if forrest@0: forrest@0: xbox0 = (/0.0,1.0,1.0,0.0,0.0/) ; Box template. forrest@0: ybox0 = (/0.0,0.0,1.0,1.0,0.0/) forrest@0: forrest@0: nvar = dimsizes(varNames) forrest@0: ncases = dimsizes(cases) forrest@0: nseas = dimsizes(seasons) forrest@0: forrest@0: dimt = dimsizes(values) ; table dimensions forrest@0: forrest@0: if (ncases.ne.dimt(0)) then forrest@0: print("taylor_metrics_table fatal error: Number of case names ("+ncases+ \ forrest@0: ") does not match the number of cases passed in ("+dimt(0)+")") forrest@0: exit forrest@0: end if forrest@0: if (nseas.ne.dimt(1)) then forrest@0: print("taylor_metrics_table fatal error: Number of season names ("+nseas+ \ forrest@0: ") does not match the number of seasons passed in ("+dimt(1)+")") forrest@0: exit forrest@0: end if forrest@0: if (dimsizes(varNames).ne.dimt(2)) then forrest@0: print("taylor_metrics_table fatal error: Number of metric variables names ("+dimsizes(varNames)+ \ forrest@0: ") does not match the number of metric variables passed in ("+dimt(2)+")") forrest@0: exit forrest@0: end if forrest@0: forrest@0: ncolm1 = dimt(0)*dimt(1) forrest@0: if (ncolm1.le.12) then forrest@0: if (ncolm1.le.6) then forrest@0: tt_width = .4 forrest@0: end if forrest@0: if (ncolm1.ge.7.and.ncolm1.le.12) then forrest@0: tt_width = .2 forrest@0: end if forrest@0: tt_height = 0.1 forrest@0: tt_theight = 0.02 forrest@0: mn_height = 0.03 forrest@0: mn_theight = 0.012 forrest@0: else forrest@0: if (ncolm1.le.20) then forrest@0: tt_width = .15 forrest@0: tt_height = 0.06 forrest@0: tt_theight = 0.012 forrest@0: mn_height = 0.018 forrest@0: mn_theight = 0.0072 forrest@0: else forrest@0: tt_width = .1 forrest@0: tt_height = 0.05 forrest@0: tt_theight = 0.01 forrest@0: mn_height = 0.015 forrest@0: mn_theight = 0.006 forrest@0: end if forrest@0: end if forrest@0: if (ncolm1.gt.26.or.dimt(2).gt.63) then forrest@0: print("Warning: Recommended maximium size of array passed into taylor_metrics_table is "+ \ forrest@0: "26 columns (#cases * #seasons) by 63 rows (#variables), continuing") forrest@0: end if forrest@0: forrest@0: mn_width = tt_width forrest@0: mv_height = mn_height forrest@0: mv_width = 0.1 forrest@0: mv_theight = mn_theight forrest@0: forrest@0: tt_pRes = True forrest@0: tt_pRes@gsFillColor = "CornflowerBlue" ; background color for + values forrest@0: forrest@0: tt_tRes = True forrest@0: tt_tRes@txFontHeightF = tt_theight forrest@0: forrest@0: mn_pRes = True forrest@0: mn_pRes@gsFillColor = "Gray70" ; background color for variable names forrest@0: forrest@0: mn_tRes = True forrest@0: mn_tRes@txFontHeightF = mn_theight forrest@0: forrest@0: mv_pRes = True forrest@0: mv_pRes@gsFillColor = "White" ; background color for reference values forrest@0: forrest@0: mv_tRes = True forrest@0: mv_tRes@txFontHeightF = mn_theight forrest@0: forrest@0: ; Title forrest@0: forrest@0: xbox = tt_width*xbox0 forrest@0: ybox = 1.-tt_height*ybox0 forrest@0: forrest@0: ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0)) forrest@0: iytbox = ybox(0)+0.5*(ybox(2)-ybox(0)) forrest@0: forrest@0: gsn_polygon_ndc(wks,xbox,ybox,tt_pRes) forrest@0: if (isatt(opt,"tableTitle") ) then forrest@0: gsn_text_ndc(wks, opt@tableTitle ,ixtbox,iytbox, tt_tRes) forrest@0: else forrest@0: gsn_text_ndc(wks,"CAM METRICS",ixtbox,iytbox, tt_tRes) forrest@0: end if forrest@0: gsn_polyline_ndc(wks,xbox,ybox,False) forrest@0: forrest@0: do im = 0,nvar-1 forrest@0: ybox = min(ybox)-(ybox0*mn_height) forrest@0: ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0)) forrest@0: iytbox = ybox(0)+0.5*(ybox(2)-ybox(0)) forrest@0: forrest@0: gsn_polygon_ndc(wks,xbox,ybox,mn_pRes) forrest@0: gsn_polyline_ndc(wks,xbox,ybox,False) forrest@0: gsn_text_ndc(wks,varNames(im),ixtbox,iytbox, mn_tRes) forrest@0: end do forrest@0: forrest@0: do icase = 0, ncases-1 forrest@0: ybox = 1.-0.5*tt_height*ybox0 forrest@0: xbox = ((1.-tt_width)/ncases)*(xbox0+icase)+tt_width forrest@0: xboxi = min(xbox) forrest@0: ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0)) forrest@0: iytbox = ybox(0)+0.5*(ybox(2)-ybox(0)) forrest@0: gsn_polygon_ndc(wks,xbox,ybox,mn_pRes) forrest@0: gsn_polyline_ndc(wks,xbox,ybox,False) forrest@0: gsn_text_ndc(wks,cases(icase),ixtbox,iytbox, mn_tRes) forrest@0: forrest@0: do iseas = 0, nseas-1 forrest@0: ybox = 1.-0.5*tt_height-0.5*tt_height*ybox0 forrest@0: xbox = xboxi + ((1.-tt_width)/(ncases*nseas))*(xbox0+iseas) forrest@0: ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0)) forrest@0: iytbox = ybox(0)+0.5*(ybox(2)-ybox(0)) forrest@0: gsn_polygon_ndc(wks,xbox,ybox,mn_pRes) forrest@0: gsn_polyline_ndc(wks,xbox,ybox,False) forrest@0: gsn_text_ndc(wks,seasons(iseas),ixtbox,iytbox, mn_tRes) forrest@0: forrest@0: do im=0,nvar-1 forrest@0: if (im .eq. 0) then forrest@0: ybox = 1.-tt_height-mv_height*ybox0 forrest@0: else forrest@0: ybox = ybox - mv_height forrest@0: end if forrest@0: iytbox = ybox(0)+0.5*(ybox(2)-ybox(0)) forrest@0: mv_pRes@gsFillColor = "White" forrest@0: if (icase .gt. 0) then forrest@0: if (ismissing(values(icase,iseas,im)) .or. \ ; ??? forrest@0: ismissing(values(icase,iseas,im)))then forrest@0: ; print ("Missing values skipped") forrest@0: else forrest@0: if (values(icase,iseas,im).le.values(0,iseas,im)) then forrest@0: if (isatt(opt,"color0")) then forrest@0: mv_pRes@gsFillColor = opt@color0 forrest@0: else forrest@0: mv_pRes@gsFillColor = "DarkOliveGreen3" forrest@0: end if forrest@0: else forrest@0: if (isatt(opt,"color1")) then forrest@0: mv_pRes@gsFillColor = opt@color1 forrest@0: else forrest@0: mv_pRes@gsFillColor = "IndianRed1" forrest@0: end if forrest@0: end if forrest@0: end if forrest@0: end if forrest@0: gsn_polygon_ndc(wks,xbox,ybox,mv_pRes) forrest@0: gsn_polyline_ndc(wks,xbox,ybox,False) forrest@0: gsn_text_ndc(wks,sprintf("%4.3f",values(icase,iseas,im)),ixtbox,iytbox, mv_tRes) forrest@0: end do forrest@0: end do forrest@0: end do forrest@0: forrest@0: draw(wks) forrest@0: ;; activate the ;; lines if this is made a function forrest@0: ;;if (.not.isatt(opt,"gsnFrame") .or. opt@gsnFrame) then forrest@0: frame(wks) forrest@0: ; if png or gif then use convert forrest@0: if (isatt(opt,"pltType") .and. \ forrest@0: (opt@pltType.eq."png" .or. opt@pltType.eq."gif")) then forrest@0: system("convert -trim +repage "+mfname+".eps "+mfname+"."+opt@pltType) forrest@0: end if forrest@0: ;;end if forrest@0: forrest@0: end