forrest@0
|
1 |
;********************************************************
|
forrest@0
|
2 |
; hardwired: co2_i = 283.1878
|
forrest@0
|
3 |
; co2_f = 364.1252
|
forrest@0
|
4 |
;
|
forrest@0
|
5 |
; beta_4_ob = 0.6
|
forrest@0
|
6 |
;**************************************************************
|
forrest@0
|
7 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
|
forrest@0
|
8 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
|
forrest@0
|
9 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
|
forrest@0
|
10 |
;**************************************************************
|
forrest@0
|
11 |
procedure set_line(lines:string,nline:integer,newlines:string)
|
forrest@0
|
12 |
begin
|
forrest@0
|
13 |
; add line to ascci/html file
|
forrest@0
|
14 |
|
forrest@0
|
15 |
nnewlines = dimsizes(newlines)
|
forrest@0
|
16 |
if(nline+nnewlines-1.ge.dimsizes(lines))
|
forrest@0
|
17 |
print("set_line: bad index, not setting anything.")
|
forrest@0
|
18 |
return
|
forrest@0
|
19 |
end if
|
forrest@0
|
20 |
lines(nline:nline+nnewlines-1) = newlines
|
forrest@0
|
21 |
; print ("lines = " + lines(nline:nline+nnewlines-1))
|
forrest@0
|
22 |
nline = nline + nnewlines
|
forrest@0
|
23 |
return
|
forrest@0
|
24 |
end
|
forrest@0
|
25 |
;**************************************************************
|
forrest@0
|
26 |
; Main code.
|
forrest@0
|
27 |
begin
|
forrest@0
|
28 |
|
forrest@0
|
29 |
plot_type = "ps"
|
forrest@0
|
30 |
plot_type_new = "png"
|
forrest@0
|
31 |
|
forrest@0
|
32 |
;------------------------------------------------------
|
forrest@0
|
33 |
; edit table.html of current model for movel1_vs_model2
|
forrest@0
|
34 |
|
forrest@0
|
35 |
if (isvar("compare")) then
|
forrest@0
|
36 |
html_name2 = compare+"/table.html"
|
forrest@0
|
37 |
html_new2 = html_name2 +".new"
|
forrest@0
|
38 |
end if
|
forrest@0
|
39 |
|
forrest@0
|
40 |
;-------------------------------------------------------
|
forrest@0
|
41 |
; edit table.html for current model
|
forrest@0
|
42 |
|
forrest@0
|
43 |
html_name = model_name+"/table.html"
|
forrest@0
|
44 |
html_new = html_name +".new"
|
forrest@0
|
45 |
|
forrest@0
|
46 |
;-------------------------------------------------------
|
forrest@0
|
47 |
; read model data
|
forrest@0
|
48 |
|
forrest@0
|
49 |
;###############################################################
|
forrest@0
|
50 |
; hardwired for model data
|
forrest@0
|
51 |
|
forrest@0
|
52 |
; these values correspond to the start and the end of model data
|
forrest@0
|
53 |
co2_i = 283.1878
|
forrest@0
|
54 |
co2_f = 364.1252
|
forrest@0
|
55 |
|
forrest@0
|
56 |
film_i = film6
|
forrest@0
|
57 |
film_f = film5
|
forrest@0
|
58 |
;###############################################################
|
forrest@0
|
59 |
|
forrest@0
|
60 |
fm_i = addfile (dirm+film_i,"r")
|
forrest@0
|
61 |
fm_f = addfile (dirm+film_f,"r")
|
forrest@0
|
62 |
|
forrest@0
|
63 |
xm = fm_f->lon
|
forrest@0
|
64 |
ym = fm_f->lat
|
forrest@0
|
65 |
|
forrest@0
|
66 |
npp_i = fm_i->NPP
|
forrest@0
|
67 |
npp_f = fm_f->NPP
|
forrest@0
|
68 |
|
forrest@0
|
69 |
delete (fm_i)
|
forrest@0
|
70 |
delete (fm_f)
|
forrest@0
|
71 |
|
forrest@0
|
72 |
;Units for these variables are:
|
forrest@0
|
73 |
;npp_i: g C/m^2/s
|
forrest@0
|
74 |
|
forrest@0
|
75 |
nsec_per_year = 60*60*24*365
|
forrest@0
|
76 |
|
forrest@0
|
77 |
npp_i = npp_i * nsec_per_year
|
forrest@0
|
78 |
npp_f = npp_f * nsec_per_year
|
forrest@0
|
79 |
|
forrest@0
|
80 |
unit = "gC/m2/year"
|
forrest@0
|
81 |
|
forrest@0
|
82 |
;------------------------------
|
forrest@0
|
83 |
; get landfrac data
|
forrest@0
|
84 |
|
forrest@0
|
85 |
film_l = "lnd_" + model_grid + ".nc"
|
forrest@0
|
86 |
fm_l = addfile (dirs+film_l,"r")
|
forrest@0
|
87 |
landfrac = fm_l->landfrac
|
forrest@0
|
88 |
|
forrest@0
|
89 |
npp_i(0,:,:) = npp_i(0,:,:) * landfrac(:,:)
|
forrest@0
|
90 |
npp_f(0,:,:) = npp_f(0,:,:) * landfrac(:,:)
|
forrest@0
|
91 |
|
forrest@0
|
92 |
delete (fm_l)
|
forrest@0
|
93 |
delete (landfrac)
|
forrest@0
|
94 |
|
forrest@0
|
95 |
;-----------------------------
|
forrest@0
|
96 |
; read biome data: model
|
forrest@0
|
97 |
|
forrest@0
|
98 |
biome_name_mod = "Model PFT Class"
|
forrest@0
|
99 |
|
forrest@0
|
100 |
film_c = "class_pft_"+model_grid+".nc"
|
forrest@0
|
101 |
fm_c = addfile (dirs+film_c,"r")
|
forrest@0
|
102 |
classmod = fm_c->CLASS_PFT
|
forrest@0
|
103 |
|
forrest@0
|
104 |
delete (fm_c)
|
forrest@0
|
105 |
|
forrest@0
|
106 |
; model data has 17 land-type classes
|
forrest@0
|
107 |
nclass_mod = 17
|
forrest@0
|
108 |
|
forrest@0
|
109 |
;---------------------------------------------------
|
forrest@0
|
110 |
; read data: observed at stations
|
forrest@0
|
111 |
|
forrest@0
|
112 |
station = (/"DukeFACE" \
|
forrest@0
|
113 |
,"AspenFACE" \
|
forrest@0
|
114 |
,"ORNL-FACE" \
|
forrest@0
|
115 |
,"POP-EUROFACE" \
|
forrest@0
|
116 |
/)
|
forrest@0
|
117 |
|
forrest@0
|
118 |
lat_ob = (/ 35.58, 45.40, 35.54, 42.22/)
|
forrest@0
|
119 |
lon_ob = (/-79.05, -89.37, -84.20, 11.48/)
|
forrest@0
|
120 |
lon_obx = where(lon_ob.lt.0.,lon_ob+360.,lon_ob)
|
forrest@0
|
121 |
|
forrest@0
|
122 |
n_sta = dimsizes(station)
|
forrest@0
|
123 |
beta_4_ob = new((/n_sta/),float)
|
forrest@0
|
124 |
|
forrest@0
|
125 |
;###################################################
|
forrest@0
|
126 |
; this is a hardwired value
|
forrest@0
|
127 |
beta_4_ob = 0.60
|
forrest@0
|
128 |
;###################################################
|
forrest@0
|
129 |
;---------------------------------------------------
|
forrest@0
|
130 |
; get model data at station
|
forrest@0
|
131 |
|
forrest@0
|
132 |
npp_i_4 =linint2_points(xm,ym,npp_i,True,lon_obx,lat_ob,0)
|
forrest@0
|
133 |
|
forrest@0
|
134 |
npp_f_4 =linint2_points(xm,ym,npp_f,True,lon_obx,lat_ob,0)
|
forrest@0
|
135 |
|
forrest@0
|
136 |
;---------------------------------------------------
|
forrest@0
|
137 |
;compute beta_4
|
forrest@0
|
138 |
|
forrest@1
|
139 |
score_max = 10.
|
forrest@0
|
140 |
|
forrest@0
|
141 |
beta_4 = new((/n_sta/),float)
|
forrest@0
|
142 |
|
forrest@0
|
143 |
beta_4 = ((npp_f_4/npp_i_4) - 1.)/log(co2_f/co2_i)
|
forrest@0
|
144 |
|
forrest@0
|
145 |
beta_4_avg = avg(beta_4)
|
forrest@0
|
146 |
|
forrest@0
|
147 |
bias = sum(abs(beta_4-beta_4_ob)/(abs(beta_4)+abs(beta_4_ob)))
|
forrest@0
|
148 |
Mbeta = (1. - (bias/n_sta))*score_max
|
forrest@0
|
149 |
M_beta = sprintf("%.2f", Mbeta)
|
forrest@0
|
150 |
|
forrest@0
|
151 |
;=========================
|
forrest@0
|
152 |
; for html table - station
|
forrest@0
|
153 |
;=========================
|
forrest@0
|
154 |
|
forrest@0
|
155 |
output_html = "table_station.html"
|
forrest@0
|
156 |
|
forrest@0
|
157 |
; column (not including header column)
|
forrest@0
|
158 |
|
forrest@0
|
159 |
col_head = (/"Latitude","Longitude","CO2_i","CO2_f","NPP_i","NPP_f","Beta_model","Beta_ob"/)
|
forrest@0
|
160 |
|
forrest@0
|
161 |
ncol = dimsizes(col_head)
|
forrest@0
|
162 |
|
forrest@0
|
163 |
; row (not including header row)
|
forrest@0
|
164 |
row_head = (/"DukeFACE" \
|
forrest@0
|
165 |
,"AspenFACE" \
|
forrest@0
|
166 |
,"ORNL-FACE" \
|
forrest@0
|
167 |
,"POP-EUROFACE" \
|
forrest@0
|
168 |
,"All Station" \
|
forrest@0
|
169 |
/)
|
forrest@0
|
170 |
nrow = dimsizes(row_head)
|
forrest@0
|
171 |
|
forrest@0
|
172 |
; arrays to be passed to table.
|
forrest@0
|
173 |
text = new ((/nrow, ncol/),string )
|
forrest@0
|
174 |
|
forrest@0
|
175 |
do i=0,nrow-2
|
forrest@0
|
176 |
text(i,0) = sprintf("%.1f",lat_ob(i))
|
forrest@0
|
177 |
text(i,1) = sprintf("%.1f",lon_ob(i))
|
forrest@0
|
178 |
text(i,2) = sprintf("%.1f",co2_i)
|
forrest@0
|
179 |
text(i,3) = sprintf("%.1f",co2_f)
|
forrest@0
|
180 |
text(i,4) = sprintf("%.1f",npp_i_4(0,i))
|
forrest@0
|
181 |
text(i,5) = sprintf("%.1f",npp_f_4(0,i))
|
forrest@0
|
182 |
text(i,6) = sprintf("%.2f",beta_4(i))
|
forrest@0
|
183 |
text(i,7) = "-"
|
forrest@0
|
184 |
end do
|
forrest@0
|
185 |
text(nrow-1,0) = "-"
|
forrest@0
|
186 |
text(nrow-1,1) = "-"
|
forrest@0
|
187 |
text(nrow-1,2) = "-"
|
forrest@0
|
188 |
text(nrow-1,3) = "-"
|
forrest@0
|
189 |
text(nrow-1,4) = "-"
|
forrest@0
|
190 |
text(nrow-1,5) = "-"
|
forrest@0
|
191 |
text(nrow-1,6) = sprintf("%.2f",beta_4_avg)
|
forrest@0
|
192 |
text(nrow-1,7) = sprintf("%.2f",avg(beta_4_ob))
|
forrest@0
|
193 |
|
forrest@0
|
194 |
;-----------
|
forrest@0
|
195 |
; html table
|
forrest@0
|
196 |
;-----------
|
forrest@0
|
197 |
|
forrest@0
|
198 |
header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
|
forrest@0
|
199 |
|
forrest@0
|
200 |
header = (/"<HTML>" \
|
forrest@0
|
201 |
,"<HEAD>" \
|
forrest@0
|
202 |
,"<TITLE>CLAMP metrics</TITLE>" \
|
forrest@0
|
203 |
,"</HEAD>" \
|
forrest@0
|
204 |
,header_text \
|
forrest@0
|
205 |
/)
|
forrest@0
|
206 |
footer = "</HTML>"
|
forrest@0
|
207 |
|
forrest@0
|
208 |
table_header = (/ \
|
forrest@0
|
209 |
"<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
|
forrest@0
|
210 |
,"<tr>" \
|
forrest@0
|
211 |
," <th bgcolor=DDDDDD >Station</th>" \
|
forrest@0
|
212 |
," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
|
forrest@0
|
213 |
," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
|
forrest@0
|
214 |
," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
|
forrest@0
|
215 |
," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
|
forrest@0
|
216 |
," <th bgcolor=DDDDDD >"+col_head(4)+"<br>("+unit+")</th>" \
|
forrest@0
|
217 |
," <th bgcolor=DDDDDD >"+col_head(5)+"<br>("+unit+")</th>" \
|
forrest@0
|
218 |
," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
|
forrest@0
|
219 |
," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
|
forrest@0
|
220 |
,"</tr>" \
|
forrest@0
|
221 |
/)
|
forrest@0
|
222 |
table_footer = "</table>"
|
forrest@0
|
223 |
row_header = "<tr>"
|
forrest@0
|
224 |
row_footer = "</tr>"
|
forrest@0
|
225 |
|
forrest@0
|
226 |
lines = new(50000,string)
|
forrest@0
|
227 |
nline = 0
|
forrest@0
|
228 |
|
forrest@0
|
229 |
set_line(lines,nline,header)
|
forrest@0
|
230 |
set_line(lines,nline,table_header)
|
forrest@0
|
231 |
;-----------------------------------------------
|
forrest@0
|
232 |
;row of table
|
forrest@0
|
233 |
|
forrest@0
|
234 |
do n = 0,nrow-1
|
forrest@0
|
235 |
set_line(lines,nline,row_header)
|
forrest@0
|
236 |
|
forrest@0
|
237 |
txt1 = row_head(n)
|
forrest@0
|
238 |
txt2 = text(n,0)
|
forrest@0
|
239 |
txt3 = text(n,1)
|
forrest@0
|
240 |
txt4 = text(n,2)
|
forrest@0
|
241 |
txt5 = text(n,3)
|
forrest@0
|
242 |
txt6 = text(n,4)
|
forrest@0
|
243 |
txt7 = text(n,5)
|
forrest@0
|
244 |
txt8 = text(n,6)
|
forrest@0
|
245 |
txt9 = text(n,7)
|
forrest@0
|
246 |
|
forrest@0
|
247 |
set_line(lines,nline,"<th>"+txt1+"</th>")
|
forrest@0
|
248 |
set_line(lines,nline,"<th>"+txt2+"</th>")
|
forrest@0
|
249 |
set_line(lines,nline,"<th>"+txt3+"</th>")
|
forrest@0
|
250 |
set_line(lines,nline,"<th>"+txt4+"</th>")
|
forrest@0
|
251 |
set_line(lines,nline,"<th>"+txt5+"</th>")
|
forrest@0
|
252 |
set_line(lines,nline,"<th>"+txt6+"</th>")
|
forrest@0
|
253 |
set_line(lines,nline,"<th>"+txt7+"</th>")
|
forrest@0
|
254 |
set_line(lines,nline,"<th>"+txt8+"</th>")
|
forrest@0
|
255 |
set_line(lines,nline,"<th>"+txt9+"</th>")
|
forrest@0
|
256 |
|
forrest@0
|
257 |
set_line(lines,nline,row_footer)
|
forrest@0
|
258 |
end do
|
forrest@0
|
259 |
;-----------------------------------------------
|
forrest@0
|
260 |
set_line(lines,nline,table_footer)
|
forrest@0
|
261 |
set_line(lines,nline,footer)
|
forrest@0
|
262 |
|
forrest@0
|
263 |
; Now write to an HTML file.
|
forrest@0
|
264 |
idx = ind(.not.ismissing(lines))
|
forrest@0
|
265 |
if(.not.any(ismissing(idx))) then
|
forrest@0
|
266 |
asciiwrite(output_html,lines(idx))
|
forrest@0
|
267 |
else
|
forrest@0
|
268 |
print ("error?")
|
forrest@0
|
269 |
end if
|
forrest@0
|
270 |
|
forrest@0
|
271 |
delete (col_head)
|
forrest@0
|
272 |
delete (row_head)
|
forrest@0
|
273 |
delete (text)
|
forrest@0
|
274 |
delete (table_header)
|
forrest@0
|
275 |
delete (idx)
|
forrest@0
|
276 |
|
forrest@0
|
277 |
;********************************************************************
|
forrest@0
|
278 |
; use land-type class to bin the data in equally spaced ranges
|
forrest@0
|
279 |
;********************************************************************
|
forrest@0
|
280 |
|
forrest@0
|
281 |
; using model biome class
|
forrest@0
|
282 |
nclass = nclass_mod
|
forrest@0
|
283 |
|
forrest@0
|
284 |
range = fspan(0,nclass,nclass+1)
|
forrest@0
|
285 |
|
forrest@0
|
286 |
; Use this range information to grab all the values in a
|
forrest@0
|
287 |
; particular range, and then take an average.
|
forrest@0
|
288 |
|
forrest@0
|
289 |
nx = dimsizes(range) - 1
|
forrest@0
|
290 |
|
forrest@0
|
291 |
;==============================
|
forrest@0
|
292 |
; put data into bins
|
forrest@0
|
293 |
;==============================
|
forrest@0
|
294 |
|
forrest@0
|
295 |
; for model data and observed
|
forrest@0
|
296 |
data_n = 2
|
forrest@0
|
297 |
|
forrest@0
|
298 |
; using model biome class
|
forrest@0
|
299 |
|
forrest@0
|
300 |
base = ndtooned(classmod)
|
forrest@0
|
301 |
|
forrest@0
|
302 |
; output
|
forrest@0
|
303 |
|
forrest@0
|
304 |
yvalues = new((/data_n,nx/),float)
|
forrest@0
|
305 |
count = new((/data_n,nx/),float)
|
forrest@0
|
306 |
|
forrest@0
|
307 |
; Loop through each range, using base
|
forrest@0
|
308 |
|
forrest@0
|
309 |
do i=0,nx-1
|
forrest@0
|
310 |
|
forrest@0
|
311 |
if (i.ne.(nx-1)) then
|
forrest@0
|
312 |
idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
|
forrest@0
|
313 |
else
|
forrest@0
|
314 |
idx = ind(base.ge.range(i))
|
forrest@0
|
315 |
end if
|
forrest@0
|
316 |
|
forrest@0
|
317 |
; loop through each dataset
|
forrest@0
|
318 |
|
forrest@0
|
319 |
do n = 0,data_n-1
|
forrest@0
|
320 |
|
forrest@0
|
321 |
if (n .eq. 0) then
|
forrest@0
|
322 |
data = ndtooned(npp_i)
|
forrest@0
|
323 |
end if
|
forrest@0
|
324 |
|
forrest@0
|
325 |
if (n .eq. 1) then
|
forrest@0
|
326 |
data = ndtooned(npp_f)
|
forrest@0
|
327 |
end if
|
forrest@0
|
328 |
|
forrest@0
|
329 |
; Calculate average
|
forrest@0
|
330 |
|
forrest@0
|
331 |
if (.not.any(ismissing(idx))) then
|
forrest@0
|
332 |
yvalues(n,i) = avg(data(idx))
|
forrest@0
|
333 |
count(n,i) = dimsizes(idx)
|
forrest@0
|
334 |
else
|
forrest@0
|
335 |
yvalues(n,i) = yvalues@_FillValue
|
forrest@0
|
336 |
count(n,i) = 0
|
forrest@0
|
337 |
end if
|
forrest@0
|
338 |
|
forrest@0
|
339 |
;#############################################################
|
forrest@0
|
340 |
; using model biome class:
|
forrest@0
|
341 |
;
|
forrest@0
|
342 |
; set the following 4 classes to _FillValue:
|
forrest@0
|
343 |
; (3)Needleleaf Deciduous Boreal Tree,
|
forrest@0
|
344 |
; (8)Broadleaf Deciduous Boreal Tree,
|
forrest@0
|
345 |
; (9)Broadleaf Evergreen Shrub,
|
forrest@0
|
346 |
; (16)Wheat
|
forrest@0
|
347 |
|
forrest@0
|
348 |
if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
|
forrest@0
|
349 |
yvalues(n,i) = yvalues@_FillValue
|
forrest@0
|
350 |
count(n,i) = 0
|
forrest@0
|
351 |
end if
|
forrest@0
|
352 |
;#############################################################
|
forrest@0
|
353 |
|
forrest@0
|
354 |
delete(data)
|
forrest@0
|
355 |
end do ; n-loop
|
forrest@0
|
356 |
|
forrest@0
|
357 |
delete(idx)
|
forrest@0
|
358 |
end do ; i-loop
|
forrest@0
|
359 |
|
forrest@0
|
360 |
delete (base)
|
forrest@0
|
361 |
delete (npp_i)
|
forrest@0
|
362 |
delete (npp_f)
|
forrest@0
|
363 |
|
forrest@0
|
364 |
;============================
|
forrest@0
|
365 |
;compute beta
|
forrest@0
|
366 |
;============================
|
forrest@0
|
367 |
|
forrest@0
|
368 |
u = yvalues(0,:)
|
forrest@0
|
369 |
v = yvalues(1,:)
|
forrest@0
|
370 |
u_count = count(0,:)
|
forrest@0
|
371 |
v_count = count(1,:)
|
forrest@0
|
372 |
|
forrest@0
|
373 |
good = ind(.not.ismissing(u) .and. .not.ismissing(v))
|
forrest@0
|
374 |
|
forrest@0
|
375 |
uu = u(good)
|
forrest@0
|
376 |
vv = v(good)
|
forrest@0
|
377 |
uu_count = u_count(good)
|
forrest@0
|
378 |
vv_count = v_count(good)
|
forrest@0
|
379 |
|
forrest@0
|
380 |
n_biome = dimsizes(uu)
|
forrest@0
|
381 |
beta_biome = new((/n_biome/),float)
|
forrest@0
|
382 |
|
forrest@0
|
383 |
beta_biome = ((vv/uu) - 1.)/log(co2_f/co2_i)
|
forrest@0
|
384 |
|
forrest@0
|
385 |
beta_biome_avg = (sum(vv*vv_count)/sum(uu*uu_count) - 1.)/log(co2_f/co2_i)
|
forrest@0
|
386 |
|
forrest@0
|
387 |
;===========================
|
forrest@0
|
388 |
; for html table - biome
|
forrest@0
|
389 |
;===========================
|
forrest@0
|
390 |
|
forrest@0
|
391 |
output_html = "table_biome.html"
|
forrest@0
|
392 |
|
forrest@0
|
393 |
; column (not including header column)
|
forrest@0
|
394 |
|
forrest@0
|
395 |
col_head = (/"CO2_i","CO2_f","NPP_i","NPP_f","Beta_model"/)
|
forrest@0
|
396 |
|
forrest@0
|
397 |
ncol = dimsizes(col_head)
|
forrest@0
|
398 |
|
forrest@0
|
399 |
; row (not including header row)
|
forrest@0
|
400 |
|
forrest@0
|
401 |
;----------------------------------------------------
|
forrest@0
|
402 |
; using model biome class:
|
forrest@0
|
403 |
;
|
forrest@0
|
404 |
row_head = (/"Not Vegetated" \
|
forrest@0
|
405 |
,"Needleleaf Evergreen Temperate Tree" \
|
forrest@0
|
406 |
,"Needleleaf Evergreen Boreal Tree" \
|
forrest@0
|
407 |
; ,"Needleleaf Deciduous Boreal Tree" \
|
forrest@0
|
408 |
,"Broadleaf Evergreen Tropical Tree" \
|
forrest@0
|
409 |
,"Broadleaf Evergreen Temperate Tree" \
|
forrest@0
|
410 |
,"Broadleaf Deciduous Tropical Tree" \
|
forrest@0
|
411 |
,"Broadleaf Deciduous Temperate Tree" \
|
forrest@0
|
412 |
; ,"Broadleaf Deciduous Boreal Tree" \
|
forrest@0
|
413 |
; ,"Broadleaf Evergreen Shrub" \
|
forrest@0
|
414 |
,"Broadleaf Deciduous Temperate Shrub" \
|
forrest@0
|
415 |
,"Broadleaf Deciduous Boreal Shrub" \
|
forrest@0
|
416 |
,"C3 Arctic Grass" \
|
forrest@0
|
417 |
,"C3 Non-Arctic Grass" \
|
forrest@0
|
418 |
,"C4 Grass" \
|
forrest@0
|
419 |
,"Corn" \
|
forrest@0
|
420 |
; ,"Wheat" \
|
forrest@0
|
421 |
,"All Biome" \
|
forrest@0
|
422 |
/)
|
forrest@0
|
423 |
|
forrest@0
|
424 |
nrow = dimsizes(row_head)
|
forrest@0
|
425 |
|
forrest@0
|
426 |
; arrays to be passed to table.
|
forrest@0
|
427 |
text = new ((/nrow, ncol/),string )
|
forrest@0
|
428 |
|
forrest@0
|
429 |
do i=0,nrow-2
|
forrest@0
|
430 |
text(i,0) = sprintf("%.1f",co2_i)
|
forrest@0
|
431 |
text(i,1) = sprintf("%.1f",co2_f)
|
forrest@0
|
432 |
text(i,2) = sprintf("%.1f",uu(i))
|
forrest@0
|
433 |
text(i,3) = sprintf("%.1f",vv(i))
|
forrest@0
|
434 |
text(i,4) = sprintf("%.2f",beta_biome(i))
|
forrest@0
|
435 |
end do
|
forrest@0
|
436 |
text(nrow-1,0) = "-"
|
forrest@0
|
437 |
text(nrow-1,1) = "-"
|
forrest@0
|
438 |
text(nrow-1,2) = "-"
|
forrest@0
|
439 |
text(nrow-1,3) = "-"
|
forrest@0
|
440 |
text(nrow-1,4) = sprintf("%.2f",beta_biome_avg)
|
forrest@0
|
441 |
|
forrest@0
|
442 |
;**************************************************
|
forrest@0
|
443 |
; html table
|
forrest@0
|
444 |
;**************************************************
|
forrest@0
|
445 |
|
forrest@0
|
446 |
header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
|
forrest@0
|
447 |
|
forrest@0
|
448 |
header = (/"<HTML>" \
|
forrest@0
|
449 |
,"<HEAD>" \
|
forrest@0
|
450 |
,"<TITLE>CLAMP metrics</TITLE>" \
|
forrest@0
|
451 |
,"</HEAD>" \
|
forrest@0
|
452 |
,header_text \
|
forrest@0
|
453 |
/)
|
forrest@0
|
454 |
footer = "</HTML>"
|
forrest@0
|
455 |
|
forrest@0
|
456 |
table_header = (/ \
|
forrest@0
|
457 |
"<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
|
forrest@0
|
458 |
,"<tr>" \
|
forrest@0
|
459 |
," <th bgcolor=DDDDDD >Biome Class</th>" \
|
forrest@0
|
460 |
," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
|
forrest@0
|
461 |
," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
|
forrest@0
|
462 |
," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
|
forrest@0
|
463 |
," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
|
forrest@0
|
464 |
," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
|
forrest@0
|
465 |
,"</tr>" \
|
forrest@0
|
466 |
/)
|
forrest@0
|
467 |
table_footer = "</table>"
|
forrest@0
|
468 |
row_header = "<tr>"
|
forrest@0
|
469 |
row_footer = "</tr>"
|
forrest@0
|
470 |
|
forrest@0
|
471 |
lines = new(50000,string)
|
forrest@0
|
472 |
nline = 0
|
forrest@0
|
473 |
|
forrest@0
|
474 |
set_line(lines,nline,header)
|
forrest@0
|
475 |
set_line(lines,nline,table_header)
|
forrest@0
|
476 |
;-----------------------------------------------
|
forrest@0
|
477 |
;row of table
|
forrest@0
|
478 |
|
forrest@0
|
479 |
do n = 0,nrow-1
|
forrest@0
|
480 |
set_line(lines,nline,row_header)
|
forrest@0
|
481 |
|
forrest@0
|
482 |
txt1 = row_head(n)
|
forrest@0
|
483 |
txt2 = text(n,0)
|
forrest@0
|
484 |
txt3 = text(n,1)
|
forrest@0
|
485 |
txt4 = text(n,2)
|
forrest@0
|
486 |
txt5 = text(n,3)
|
forrest@0
|
487 |
txt6 = text(n,4)
|
forrest@0
|
488 |
|
forrest@0
|
489 |
set_line(lines,nline,"<th>"+txt1+"</th>")
|
forrest@0
|
490 |
set_line(lines,nline,"<th>"+txt2+"</th>")
|
forrest@0
|
491 |
set_line(lines,nline,"<th>"+txt3+"</th>")
|
forrest@0
|
492 |
set_line(lines,nline,"<th>"+txt4+"</th>")
|
forrest@0
|
493 |
set_line(lines,nline,"<th>"+txt5+"</th>")
|
forrest@0
|
494 |
set_line(lines,nline,"<th>"+txt6+"</th>")
|
forrest@0
|
495 |
|
forrest@0
|
496 |
set_line(lines,nline,row_footer)
|
forrest@0
|
497 |
end do
|
forrest@0
|
498 |
;-----------------------------------------------
|
forrest@0
|
499 |
set_line(lines,nline,table_footer)
|
forrest@0
|
500 |
set_line(lines,nline,footer)
|
forrest@0
|
501 |
|
forrest@0
|
502 |
; Now write to an HTML file
|
forrest@0
|
503 |
|
forrest@0
|
504 |
idx = ind(.not.ismissing(lines))
|
forrest@0
|
505 |
if(.not.any(ismissing(idx))) then
|
forrest@0
|
506 |
asciiwrite(output_html,lines(idx))
|
forrest@0
|
507 |
else
|
forrest@0
|
508 |
print ("error?")
|
forrest@0
|
509 |
end if
|
forrest@0
|
510 |
delete (idx)
|
forrest@0
|
511 |
|
forrest@0
|
512 |
;**************************************************************************************
|
forrest@0
|
513 |
; update score
|
forrest@0
|
514 |
;**************************************************************************************
|
forrest@0
|
515 |
if (isvar("compare")) then
|
forrest@0
|
516 |
system("sed -e '1,/M_beta/s/M_beta/"+M_beta+"/' "+html_name2+" > "+html_new2+";"+ \
|
forrest@0
|
517 |
"mv -f "+html_new2+" "+html_name2)
|
forrest@0
|
518 |
end if
|
forrest@0
|
519 |
|
forrest@0
|
520 |
system("sed s#M_beta#"+M_beta+"# "+html_name+" > "+html_new+";"+ \
|
forrest@0
|
521 |
"mv -f "+html_new+" "+html_name)
|
forrest@0
|
522 |
|
forrest@0
|
523 |
;***************************************************************************
|
forrest@0
|
524 |
; get total score and write to file
|
forrest@0
|
525 |
;***************************************************************************
|
forrest@0
|
526 |
M_total = Mbeta
|
forrest@0
|
527 |
|
forrest@0
|
528 |
asciiwrite("M_save.beta", M_total)
|
forrest@0
|
529 |
|
forrest@0
|
530 |
delete (M_total)
|
forrest@0
|
531 |
|
forrest@0
|
532 |
;***************************************************************************
|
forrest@0
|
533 |
; output plot and html
|
forrest@0
|
534 |
;***************************************************************************
|
forrest@0
|
535 |
output_dir = model_name+"/beta"
|
forrest@0
|
536 |
|
forrest@0
|
537 |
system("mv *.html " + output_dir)
|
forrest@0
|
538 |
;***************************************************************************
|
forrest@0
|
539 |
|
forrest@0
|
540 |
end
|
forrest@0
|
541 |
|