forrest@0
|
1 |
;*******************************************************************
|
forrest@0
|
2 |
; procedure to draw the Taylor Diagram Metrics Table
|
forrest@0
|
3 |
;
|
forrest@0
|
4 |
; AWWG METRICS 0.3 ;;;
|
forrest@0
|
5 |
; 27 Jun 06 ASP
|
forrest@0
|
6 |
; 5 Jul 06 DJS
|
forrest@0
|
7 |
;
|
forrest@0
|
8 |
; Arguments:
|
forrest@0
|
9 |
; mfname : name of the output table
|
forrest@0
|
10 |
; varNames : variable names [metrics]
|
forrest@0
|
11 |
; cases : case (model) names
|
forrest@0
|
12 |
; seasons : season names
|
forrest@0
|
13 |
; values : array containing the values to be plotted
|
forrest@0
|
14 |
; opt : used to pass optional arguments
|
forrest@0
|
15 |
|
forrest@0
|
16 |
procedure taylor_metrics_table(mfname[1]:string \ ; plot name
|
forrest@0
|
17 |
,varNames[*]:string \ ; variables
|
forrest@0
|
18 |
,cases[*]:string \
|
forrest@0
|
19 |
,seasons[*]:string \
|
forrest@0
|
20 |
,values[*][*][*]:numeric \
|
forrest@0
|
21 |
,opt:logical )
|
forrest@0
|
22 |
|
forrest@0
|
23 |
|
forrest@0
|
24 |
;;;
|
forrest@0
|
25 |
;;; Output of metrics to a table [grid]
|
forrest@0
|
26 |
|
forrest@0
|
27 |
begin
|
forrest@0
|
28 |
if (.not.isatt(opt,"pltType") .or. \
|
forrest@0
|
29 |
(opt@pltType.eq."eps" .or. opt@pltType.eq."png" .or. opt@pltType.eq."gif")) then
|
forrest@0
|
30 |
wks = gsn_open_wks("eps",mfname) ; default
|
forrest@0
|
31 |
else
|
forrest@0
|
32 |
wks = gsn_open_wks(opt@pltType,mfname)
|
forrest@0
|
33 |
end if
|
forrest@0
|
34 |
|
forrest@0
|
35 |
xbox0 = (/0.0,1.0,1.0,0.0,0.0/) ; Box template.
|
forrest@0
|
36 |
ybox0 = (/0.0,0.0,1.0,1.0,0.0/)
|
forrest@0
|
37 |
|
forrest@0
|
38 |
nvar = dimsizes(varNames)
|
forrest@0
|
39 |
ncases = dimsizes(cases)
|
forrest@0
|
40 |
nseas = dimsizes(seasons)
|
forrest@0
|
41 |
|
forrest@0
|
42 |
dimt = dimsizes(values) ; table dimensions
|
forrest@0
|
43 |
|
forrest@0
|
44 |
if (ncases.ne.dimt(0)) then
|
forrest@0
|
45 |
print("taylor_metrics_table fatal error: Number of case names ("+ncases+ \
|
forrest@0
|
46 |
") does not match the number of cases passed in ("+dimt(0)+")")
|
forrest@0
|
47 |
exit
|
forrest@0
|
48 |
end if
|
forrest@0
|
49 |
if (nseas.ne.dimt(1)) then
|
forrest@0
|
50 |
print("taylor_metrics_table fatal error: Number of season names ("+nseas+ \
|
forrest@0
|
51 |
") does not match the number of seasons passed in ("+dimt(1)+")")
|
forrest@0
|
52 |
exit
|
forrest@0
|
53 |
end if
|
forrest@0
|
54 |
if (dimsizes(varNames).ne.dimt(2)) then
|
forrest@0
|
55 |
print("taylor_metrics_table fatal error: Number of metric variables names ("+dimsizes(varNames)+ \
|
forrest@0
|
56 |
") does not match the number of metric variables passed in ("+dimt(2)+")")
|
forrest@0
|
57 |
exit
|
forrest@0
|
58 |
end if
|
forrest@0
|
59 |
|
forrest@0
|
60 |
ncolm1 = dimt(0)*dimt(1)
|
forrest@0
|
61 |
if (ncolm1.le.12) then
|
forrest@0
|
62 |
if (ncolm1.le.6) then
|
forrest@0
|
63 |
tt_width = .4
|
forrest@0
|
64 |
end if
|
forrest@0
|
65 |
if (ncolm1.ge.7.and.ncolm1.le.12) then
|
forrest@0
|
66 |
tt_width = .2
|
forrest@0
|
67 |
end if
|
forrest@0
|
68 |
tt_height = 0.1
|
forrest@0
|
69 |
tt_theight = 0.02
|
forrest@0
|
70 |
mn_height = 0.03
|
forrest@0
|
71 |
mn_theight = 0.012
|
forrest@0
|
72 |
else
|
forrest@0
|
73 |
if (ncolm1.le.20) then
|
forrest@0
|
74 |
tt_width = .15
|
forrest@0
|
75 |
tt_height = 0.06
|
forrest@0
|
76 |
tt_theight = 0.012
|
forrest@0
|
77 |
mn_height = 0.018
|
forrest@0
|
78 |
mn_theight = 0.0072
|
forrest@0
|
79 |
else
|
forrest@0
|
80 |
tt_width = .1
|
forrest@0
|
81 |
tt_height = 0.05
|
forrest@0
|
82 |
tt_theight = 0.01
|
forrest@0
|
83 |
mn_height = 0.015
|
forrest@0
|
84 |
mn_theight = 0.006
|
forrest@0
|
85 |
end if
|
forrest@0
|
86 |
end if
|
forrest@0
|
87 |
if (ncolm1.gt.26.or.dimt(2).gt.63) then
|
forrest@0
|
88 |
print("Warning: Recommended maximium size of array passed into taylor_metrics_table is "+ \
|
forrest@0
|
89 |
"26 columns (#cases * #seasons) by 63 rows (#variables), continuing")
|
forrest@0
|
90 |
end if
|
forrest@0
|
91 |
|
forrest@0
|
92 |
mn_width = tt_width
|
forrest@0
|
93 |
mv_height = mn_height
|
forrest@0
|
94 |
mv_width = 0.1
|
forrest@0
|
95 |
mv_theight = mn_theight
|
forrest@0
|
96 |
|
forrest@0
|
97 |
tt_pRes = True
|
forrest@0
|
98 |
tt_pRes@gsFillColor = "CornflowerBlue" ; background color for + values
|
forrest@0
|
99 |
|
forrest@0
|
100 |
tt_tRes = True
|
forrest@0
|
101 |
tt_tRes@txFontHeightF = tt_theight
|
forrest@0
|
102 |
|
forrest@0
|
103 |
mn_pRes = True
|
forrest@0
|
104 |
mn_pRes@gsFillColor = "Gray70" ; background color for variable names
|
forrest@0
|
105 |
|
forrest@0
|
106 |
mn_tRes = True
|
forrest@0
|
107 |
mn_tRes@txFontHeightF = mn_theight
|
forrest@0
|
108 |
|
forrest@0
|
109 |
mv_pRes = True
|
forrest@0
|
110 |
mv_pRes@gsFillColor = "White" ; background color for reference values
|
forrest@0
|
111 |
|
forrest@0
|
112 |
mv_tRes = True
|
forrest@0
|
113 |
mv_tRes@txFontHeightF = mn_theight
|
forrest@0
|
114 |
|
forrest@0
|
115 |
; Title
|
forrest@0
|
116 |
|
forrest@0
|
117 |
xbox = tt_width*xbox0
|
forrest@0
|
118 |
ybox = 1.-tt_height*ybox0
|
forrest@0
|
119 |
|
forrest@0
|
120 |
ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
|
forrest@0
|
121 |
iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
|
forrest@0
|
122 |
|
forrest@0
|
123 |
gsn_polygon_ndc(wks,xbox,ybox,tt_pRes)
|
forrest@0
|
124 |
if (isatt(opt,"tableTitle") ) then
|
forrest@0
|
125 |
gsn_text_ndc(wks, opt@tableTitle ,ixtbox,iytbox, tt_tRes)
|
forrest@0
|
126 |
else
|
forrest@0
|
127 |
gsn_text_ndc(wks,"CAM METRICS",ixtbox,iytbox, tt_tRes)
|
forrest@0
|
128 |
end if
|
forrest@0
|
129 |
gsn_polyline_ndc(wks,xbox,ybox,False)
|
forrest@0
|
130 |
|
forrest@0
|
131 |
do im = 0,nvar-1
|
forrest@0
|
132 |
ybox = min(ybox)-(ybox0*mn_height)
|
forrest@0
|
133 |
ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
|
forrest@0
|
134 |
iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
|
forrest@0
|
135 |
|
forrest@0
|
136 |
gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
|
forrest@0
|
137 |
gsn_polyline_ndc(wks,xbox,ybox,False)
|
forrest@0
|
138 |
gsn_text_ndc(wks,varNames(im),ixtbox,iytbox, mn_tRes)
|
forrest@0
|
139 |
end do
|
forrest@0
|
140 |
|
forrest@0
|
141 |
do icase = 0, ncases-1
|
forrest@0
|
142 |
ybox = 1.-0.5*tt_height*ybox0
|
forrest@0
|
143 |
xbox = ((1.-tt_width)/ncases)*(xbox0+icase)+tt_width
|
forrest@0
|
144 |
xboxi = min(xbox)
|
forrest@0
|
145 |
ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
|
forrest@0
|
146 |
iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
|
forrest@0
|
147 |
gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
|
forrest@0
|
148 |
gsn_polyline_ndc(wks,xbox,ybox,False)
|
forrest@0
|
149 |
gsn_text_ndc(wks,cases(icase),ixtbox,iytbox, mn_tRes)
|
forrest@0
|
150 |
|
forrest@0
|
151 |
do iseas = 0, nseas-1
|
forrest@0
|
152 |
ybox = 1.-0.5*tt_height-0.5*tt_height*ybox0
|
forrest@0
|
153 |
xbox = xboxi + ((1.-tt_width)/(ncases*nseas))*(xbox0+iseas)
|
forrest@0
|
154 |
ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
|
forrest@0
|
155 |
iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
|
forrest@0
|
156 |
gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
|
forrest@0
|
157 |
gsn_polyline_ndc(wks,xbox,ybox,False)
|
forrest@0
|
158 |
gsn_text_ndc(wks,seasons(iseas),ixtbox,iytbox, mn_tRes)
|
forrest@0
|
159 |
|
forrest@0
|
160 |
do im=0,nvar-1
|
forrest@0
|
161 |
if (im .eq. 0) then
|
forrest@0
|
162 |
ybox = 1.-tt_height-mv_height*ybox0
|
forrest@0
|
163 |
else
|
forrest@0
|
164 |
ybox = ybox - mv_height
|
forrest@0
|
165 |
end if
|
forrest@0
|
166 |
iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
|
forrest@0
|
167 |
mv_pRes@gsFillColor = "White"
|
forrest@0
|
168 |
if (icase .gt. 0) then
|
forrest@0
|
169 |
if (ismissing(values(icase,iseas,im)) .or. \ ; ???
|
forrest@0
|
170 |
ismissing(values(icase,iseas,im)))then
|
forrest@0
|
171 |
; print ("Missing values skipped")
|
forrest@0
|
172 |
else
|
forrest@0
|
173 |
if (values(icase,iseas,im).le.values(0,iseas,im)) then
|
forrest@0
|
174 |
if (isatt(opt,"color0")) then
|
forrest@0
|
175 |
mv_pRes@gsFillColor = opt@color0
|
forrest@0
|
176 |
else
|
forrest@0
|
177 |
mv_pRes@gsFillColor = "DarkOliveGreen3"
|
forrest@0
|
178 |
end if
|
forrest@0
|
179 |
else
|
forrest@0
|
180 |
if (isatt(opt,"color1")) then
|
forrest@0
|
181 |
mv_pRes@gsFillColor = opt@color1
|
forrest@0
|
182 |
else
|
forrest@0
|
183 |
mv_pRes@gsFillColor = "IndianRed1"
|
forrest@0
|
184 |
end if
|
forrest@0
|
185 |
end if
|
forrest@0
|
186 |
end if
|
forrest@0
|
187 |
end if
|
forrest@0
|
188 |
gsn_polygon_ndc(wks,xbox,ybox,mv_pRes)
|
forrest@0
|
189 |
gsn_polyline_ndc(wks,xbox,ybox,False)
|
forrest@0
|
190 |
gsn_text_ndc(wks,sprintf("%4.3f",values(icase,iseas,im)),ixtbox,iytbox, mv_tRes)
|
forrest@0
|
191 |
end do
|
forrest@0
|
192 |
end do
|
forrest@0
|
193 |
end do
|
forrest@0
|
194 |
|
forrest@0
|
195 |
draw(wks)
|
forrest@0
|
196 |
;; activate the ;; lines if this is made a function
|
forrest@0
|
197 |
;;if (.not.isatt(opt,"gsnFrame") .or. opt@gsnFrame) then
|
forrest@0
|
198 |
frame(wks)
|
forrest@0
|
199 |
; if png or gif then use convert
|
forrest@0
|
200 |
if (isatt(opt,"pltType") .and. \
|
forrest@0
|
201 |
(opt@pltType.eq."png" .or. opt@pltType.eq."gif")) then
|
forrest@0
|
202 |
system("convert -trim +repage "+mfname+".eps "+mfname+"."+opt@pltType)
|
forrest@0
|
203 |
end if
|
forrest@0
|
204 |
;;end if
|
forrest@0
|
205 |
|
forrest@0
|
206 |
end
|