|
1 ;************************************************************** |
|
2 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" |
|
3 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" |
|
4 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" |
|
5 ;************************************************************** |
|
6 procedure set_line(lines:string,nline:integer,newlines:string) |
|
7 begin |
|
8 ; add line to ascci/html file |
|
9 |
|
10 nnewlines = dimsizes(newlines) |
|
11 if(nline+nnewlines-1.ge.dimsizes(lines)) |
|
12 print("set_line: bad index, not setting anything.") |
|
13 return |
|
14 end if |
|
15 lines(nline:nline+nnewlines-1) = newlines |
|
16 ; print ("lines = " + lines(nline:nline+nnewlines-1)) |
|
17 nline = nline + nnewlines |
|
18 return |
|
19 end |
|
20 ;************************************************************** |
|
21 ; Main code. |
|
22 begin |
|
23 |
|
24 plot_type = "ps" |
|
25 plot_type_new = "png" |
|
26 |
|
27 ;------------------------------------------------------ |
|
28 ; edit table.html of current model for movel1_vs_model2 |
|
29 |
|
30 if (isvar("compare")) then |
|
31 html_name2 = compare+"/table.html" |
|
32 html_new2 = html_name2 +".new" |
|
33 end if |
|
34 |
|
35 ;------------------------------------------------------ |
|
36 ; edit table.html for current model |
|
37 |
|
38 html_name = model_name+"/table.html" |
|
39 html_new = html_name +".new" |
|
40 |
|
41 ;------------------------------------------------------ |
|
42 ; get biome data: model |
|
43 |
|
44 biome_name_mod = "Model PFT Class" |
|
45 |
|
46 film_c = "class_pft_"+ model_grid +".nc" |
|
47 fm_c = addfile (dirs+film_c,"r") |
|
48 classmod = fm_c->CLASS_PFT |
|
49 |
|
50 delete (fm_c) |
|
51 |
|
52 ; model data has 17 land-type classes |
|
53 nclass_mod = 17 |
|
54 |
|
55 ;-------------------------------- |
|
56 ; get model data: landmask, landfrac and area |
|
57 |
|
58 film_l = "lnd_"+ model_grid +".nc" |
|
59 fm_l = addfile (dirs+film_l,"r") |
|
60 landmask = fm_l->landmask |
|
61 landfrac = fm_l->landfrac |
|
62 area = fm_l->area |
|
63 |
|
64 delete (fm_l) |
|
65 |
|
66 ; change area from km**2 to m**2 |
|
67 area = area * 1.e6 |
|
68 |
|
69 ; take into account landfrac |
|
70 area = area * landfrac |
|
71 |
|
72 ;-------------------------------- |
|
73 ; read data: time series, model |
|
74 |
|
75 fm = addfile (dirm+film7,"r") |
|
76 |
|
77 data_mod = fm->COL_FIRE_CLOSS(18:25,:,:,:) |
|
78 |
|
79 delete (fm) |
|
80 |
|
81 ; Units for these variables are: |
|
82 ; g C/m^2/s |
|
83 |
|
84 ; change unit to gC/m2/month |
|
85 |
|
86 nsec_per_month = 60*60*24*30 |
|
87 |
|
88 data_mod = data_mod * nsec_per_month |
|
89 |
|
90 data_mod@units = "gC/m2/month" |
|
91 |
|
92 ;---------------------------------------------------- |
|
93 ; read data: time series, observed |
|
94 |
|
95 dir_f = diro + "fire/" |
|
96 fil_f = "Fire_C_1997-2006_monthly_"+ model_grid+".nc" |
|
97 fm = addfile (dir_f+fil_f,"r") |
|
98 data_ob = fm->FIRE_C(0:7,:,:,:) |
|
99 |
|
100 delete (fm) |
|
101 |
|
102 ob_name = "GFEDv2" |
|
103 |
|
104 ; Units for these variables are: gC/m2/month |
|
105 |
|
106 data_ob@units = "gC/m2/month" |
|
107 |
|
108 ;------------------------------------------------------------- |
|
109 ; html table1 data |
|
110 |
|
111 ; column (not including header column) |
|
112 |
|
113 col_head = (/"Observed Fire_Flux (PgC/yr)" \ |
|
114 ,"Model Fire_Flux (PgC/yr)" \ |
|
115 ,"Correlation Coefficient" \ |
|
116 ,"Ratio model/observed" \ |
|
117 ,"M_score" \ |
|
118 ,"Timeseries plot" \ |
|
119 /) |
|
120 |
|
121 ncol = dimsizes(col_head) |
|
122 |
|
123 ; row (not including header row) |
|
124 |
|
125 ; using model biome class: |
|
126 row_head = (/"Not Vegetated" \ |
|
127 ,"Needleleaf Evergreen Temperate Tree" \ |
|
128 ,"Needleleaf Evergreen Boreal Tree" \ |
|
129 ; ,"Needleleaf Deciduous Boreal Tree" \ |
|
130 ,"Broadleaf Evergreen Tropical Tree" \ |
|
131 ,"Broadleaf Evergreen Temperate Tree" \ |
|
132 ,"Broadleaf Deciduous Tropical Tree" \ |
|
133 ,"Broadleaf Deciduous Temperate Tree" \ |
|
134 ; ,"Broadleaf Deciduous Boreal Tree" \ |
|
135 ; ,"Broadleaf Evergreen Shrub" \ |
|
136 ,"Broadleaf Deciduous Temperate Shrub" \ |
|
137 ,"Broadleaf Deciduous Boreal Shrub" \ |
|
138 ,"C3 Arctic Grass" \ |
|
139 ,"C3 Non-Arctic Grass" \ |
|
140 ,"C4 Grass" \ |
|
141 ,"Corn" \ |
|
142 ; ,"Wheat" \ |
|
143 ,"All Biomes" \ |
|
144 /) |
|
145 nrow = dimsizes(row_head) |
|
146 |
|
147 ; arrays to be passed to table. |
|
148 text = new ((/nrow, ncol/),string ) |
|
149 |
|
150 ;***************************************************************** |
|
151 ; (A) get time-mean |
|
152 ;***************************************************************** |
|
153 |
|
154 x = dim_avg_Wrap(data_mod(lat|:,lon|:,month|:,year|:)) |
|
155 data_mod_m = dim_avg_Wrap( x(lat|:,lon|:,month|:)) |
|
156 delete (x) |
|
157 |
|
158 x = dim_avg_Wrap( data_ob(lat|:,lon|:,month|:,year|:)) |
|
159 data_ob_m = dim_avg_Wrap( x(lat|:,lon|:,month|:)) |
|
160 delete (x) |
|
161 |
|
162 ;---------------------------------------------------- |
|
163 ; compute correlation coef: space |
|
164 |
|
165 landmask_1d = ndtooned(landmask) |
|
166 data_mod_1d = ndtooned(data_mod_m) |
|
167 data_ob_1d = ndtooned(data_ob_m ) |
|
168 area_1d = ndtooned(area) |
|
169 landfrac_1d = ndtooned(landfrac) |
|
170 |
|
171 good = ind(landmask_1d .gt. 0.) |
|
172 |
|
173 global_mod = sum(data_mod_1d(good)*area_1d(good)) * 1.e-15 * 12. |
|
174 global_ob = sum(data_ob_1d(good) *area_1d(good)) * 1.e-15 * 12. |
|
175 ; print (global_mod) |
|
176 ; print (global_ob) |
|
177 |
|
178 global_area= sum(area_1d) |
|
179 global_land= sum(area_1d(good)) |
|
180 ; print (global_area) |
|
181 ; print (global_land) |
|
182 |
|
183 cc_space = esccr(data_mod_1d(good)*landfrac_1d(good),data_ob_1d(good)*landfrac_1d(good),0) |
|
184 |
|
185 delete (landmask_1d) |
|
186 delete (landfrac_1d) |
|
187 ; delete (area_1d) |
|
188 delete (data_mod_1d) |
|
189 delete (data_ob_1d) |
|
190 delete (good) |
|
191 |
|
192 ;---------------------------------------------------- |
|
193 ; compute M_global |
|
194 |
|
195 score_max = 1. |
|
196 |
|
197 Mscore1 = cc_space * cc_space * score_max |
|
198 |
|
199 M_global = sprintf("%.2f", Mscore1) |
|
200 |
|
201 ;---------------------------------------------------- |
|
202 ; global res |
|
203 |
|
204 resg = True ; Use plot options |
|
205 resg@cnFillOn = True ; Turn on color fill |
|
206 resg@gsnSpreadColors = True ; use full colormap |
|
207 resg@cnLinesOn = False ; Turn off contourn lines |
|
208 resg@mpFillOn = False ; Turn off map fill |
|
209 resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals |
|
210 |
|
211 ;---------------------------------------------------- |
|
212 ; global contour: model vs ob |
|
213 |
|
214 plot_name = "global_model_vs_ob" |
|
215 |
|
216 wks = gsn_open_wks (plot_type,plot_name) |
|
217 gsn_define_colormap(wks,"gui_default") |
|
218 |
|
219 plot=new(3,graphic) ; create graphic array |
|
220 |
|
221 resg@gsnFrame = False ; Do not draw plot |
|
222 resg@gsnDraw = False ; Do not advance frame |
|
223 |
|
224 ;---------------------- |
|
225 ; plot correlation coef |
|
226 |
|
227 gRes = True |
|
228 gRes@txFontHeightF = 0.02 |
|
229 gRes@txAngleF = 90 |
|
230 |
|
231 correlation_text = "(correlation coef = "+sprintf("%.2f", cc_space)+")" |
|
232 |
|
233 gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes) |
|
234 |
|
235 ;----------------------- |
|
236 ; plot ob |
|
237 ; change from gC/m2/month to gC/m2/yr |
|
238 month_to_year = 12. |
|
239 |
|
240 data_ob_m@units = "gC/m2/yr" |
|
241 data_mod_m@units = "gC/m2/yr" |
|
242 |
|
243 data_ob_m = data_ob_m * month_to_year |
|
244 data_ob_m = where(landmask .gt. 0., data_ob_m, data_ob_m@_FillValue) |
|
245 |
|
246 title = ob_name |
|
247 resg@tiMainString = title |
|
248 |
|
249 resg@cnMinLevelValF = 10. |
|
250 resg@cnMaxLevelValF = 100. |
|
251 resg@cnLevelSpacingF = 10. |
|
252 |
|
253 plot(0) = gsn_csm_contour_map_ce(wks,data_ob_m,resg) |
|
254 |
|
255 ;----------------------- |
|
256 ; plot model |
|
257 |
|
258 data_mod_m = data_mod_m * month_to_year |
|
259 |
|
260 data_mod_m = where(landmask .gt. 0., data_mod_m, data_mod_m@_FillValue) |
|
261 |
|
262 title = "Model "+ model_name |
|
263 resg@tiMainString = title |
|
264 |
|
265 resg@cnMinLevelValF = 10. |
|
266 resg@cnMaxLevelValF = 100. |
|
267 resg@cnLevelSpacingF = 10. |
|
268 |
|
269 plot(1) = gsn_csm_contour_map_ce(wks,data_mod_m,resg) |
|
270 |
|
271 ;----------------------- |
|
272 ; plot model-ob |
|
273 |
|
274 resg@cnMinLevelValF = -80. |
|
275 resg@cnMaxLevelValF = 20. |
|
276 resg@cnLevelSpacingF = 10. |
|
277 |
|
278 zz = data_ob_m |
|
279 zz = data_mod_m - data_ob_m |
|
280 title = "Model_"+model_name+" - Observed" |
|
281 resg@tiMainString = title |
|
282 |
|
283 plot(2) = gsn_csm_contour_map_ce(wks,zz,resg) |
|
284 |
|
285 ; plot panel |
|
286 |
|
287 pres = True ; panel plot mods desired |
|
288 pres@gsnMaximize = True ; fill the page |
|
289 |
|
290 gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot |
|
291 |
|
292 delete (wks) |
|
293 delete (plot) |
|
294 |
|
295 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \ |
|
296 "rm "+plot_name+"."+plot_type) |
|
297 |
|
298 delete (data_ob_m) |
|
299 delete (data_mod_m) |
|
300 delete (zz) |
|
301 |
|
302 resg@gsnFrame = True ; Do advance frame |
|
303 resg@gsnDraw = True ; Do draw plot |
|
304 |
|
305 ;******************************************************************* |
|
306 ; (B) Time series : per biome |
|
307 ;******************************************************************* |
|
308 |
|
309 data_n = 2 |
|
310 |
|
311 dsizes = dimsizes(data_mod) |
|
312 nyear = dsizes(0) |
|
313 nmonth = dsizes(1) |
|
314 ntime = nyear * nmonth |
|
315 |
|
316 year_start = 1997 |
|
317 year_end = 2004 |
|
318 |
|
319 ;------------------------------------------- |
|
320 ; Calculate "nice" bins for binning the data |
|
321 |
|
322 ; using model biome class |
|
323 nclass = nclass_mod |
|
324 |
|
325 range = fspan(0,nclass,nclass+1) |
|
326 |
|
327 ; Use this range information to grab all the values in a |
|
328 ; particular range, and then take an average. |
|
329 |
|
330 nx = dimsizes(range) - 1 |
|
331 |
|
332 ;------------------------------------------- |
|
333 ; put data into bins |
|
334 |
|
335 ; using observed biome class |
|
336 ; base = ndtooned(classob) |
|
337 ; using model biome class |
|
338 base = ndtooned(classmod) |
|
339 |
|
340 ; output |
|
341 |
|
342 area_bin = new((/nx/),float) |
|
343 yvalues = new((/ntime,data_n,nx/),float) |
|
344 |
|
345 ; Loop through each range, using base. |
|
346 |
|
347 do i=0,nx-1 |
|
348 |
|
349 if (i.ne.(nx-1)) then |
|
350 idx = ind((base.ge.range(i)).and.(base.lt.range(i+1))) |
|
351 else |
|
352 idx = ind(base.ge.range(i)) |
|
353 end if |
|
354 ;--------------------- |
|
355 ; for area |
|
356 |
|
357 if (.not.any(ismissing(idx))) then |
|
358 area_bin(i) = sum(area_1d(idx)) |
|
359 else |
|
360 area_bin(i) = area_bin@_FillValue |
|
361 end if |
|
362 |
|
363 ;############################################################# |
|
364 ; using model biome class: |
|
365 ; set the following 4 classes to _FillValue: |
|
366 ; (3)Needleleaf Deciduous Boreal Tree, |
|
367 ; (8)Broadleaf Deciduous Boreal Tree, |
|
368 ; (9)Broadleaf Evergreen Shrub, |
|
369 ; (16)Wheat |
|
370 |
|
371 if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then |
|
372 area_bin(i) = area_bin@_FillValue |
|
373 end if |
|
374 ;############################################################# |
|
375 |
|
376 ;--------------------- |
|
377 ; for data_mod and data_ob |
|
378 |
|
379 do n = 0,data_n-1 |
|
380 |
|
381 t = -1 |
|
382 do m = 0,nyear-1 |
|
383 do k = 0,nmonth-1 |
|
384 |
|
385 t = t + 1 |
|
386 |
|
387 if (n.eq.0) then |
|
388 data = ndtooned(data_ob(m,k,:,:)) |
|
389 end if |
|
390 |
|
391 if (n.eq.1) then |
|
392 data = ndtooned(data_mod(m,k,:,:)) |
|
393 end if |
|
394 |
|
395 ; Calculate average |
|
396 |
|
397 if (.not.any(ismissing(idx))) then |
|
398 yvalues(t,n,i) = sum(data(idx)*area_1d(idx)) |
|
399 else |
|
400 yvalues(t,n,i) = yvalues@_FillValue |
|
401 end if |
|
402 |
|
403 ;############################################################# |
|
404 ; using model biome class: |
|
405 ; set the following 4 classes to _FillValue: |
|
406 ; (3)Needleleaf Deciduous Boreal Tree, |
|
407 ; (8)Broadleaf Deciduous Boreal Tree, |
|
408 ; (9)Broadleaf Evergreen Shrub, |
|
409 ; (16)Wheat |
|
410 |
|
411 if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then |
|
412 yvalues(t,n,i) = yvalues@_FillValue |
|
413 end if |
|
414 ;############################################################# |
|
415 |
|
416 end do |
|
417 end do |
|
418 |
|
419 delete(data) |
|
420 end do |
|
421 |
|
422 delete(idx) |
|
423 end do |
|
424 |
|
425 delete (base) |
|
426 delete (data_mod) |
|
427 delete (data_ob) |
|
428 |
|
429 global_bin = sum(area_bin) |
|
430 ; print (global_bin) |
|
431 |
|
432 ;---------------------------------------------------------------- |
|
433 ; get area_good |
|
434 |
|
435 good = ind(.not.ismissing(area_bin)) |
|
436 |
|
437 area_g = area_bin(good) |
|
438 |
|
439 n_biome = dimsizes(good) |
|
440 |
|
441 global_good = sum(area_g) |
|
442 ; print (global_good) |
|
443 |
|
444 ;---------------------------------------------------------------- |
|
445 ; data for tseries plot |
|
446 |
|
447 yvalues_g = new((/ntime,data_n,n_biome/),float) |
|
448 |
|
449 yvalues_g@units = "TgC/month" |
|
450 |
|
451 ; change unit to Tg C/month |
|
452 ; change unit from g to Tg (Tera gram) |
|
453 factor_unit = 1.e-12 |
|
454 |
|
455 yvalues_g = yvalues(:,:,good) * factor_unit |
|
456 |
|
457 delete (good) |
|
458 |
|
459 ;------------------------------------------------------------------- |
|
460 ; general settings for line plot |
|
461 |
|
462 res = True |
|
463 res@xyDashPatterns = (/0,0/) ; make lines solid |
|
464 res@xyLineThicknesses = (/2.0,2.0/) ; make lines thicker |
|
465 res@xyLineColors = (/"blue","red"/) ; line color |
|
466 |
|
467 res@trXMinF = year_start |
|
468 res@trXMaxF = year_end + 1 |
|
469 |
|
470 res@vpHeightF = 0.4 ; change aspect ratio of plot |
|
471 ; res@vpWidthF = 0.8 |
|
472 res@vpWidthF = 0.75 |
|
473 |
|
474 res@tiMainFontHeightF = 0.025 ; size of title |
|
475 |
|
476 res@tmXBFormat = "f" ; not to add trailing zeros |
|
477 |
|
478 ; res@gsnMaximize = True |
|
479 |
|
480 ;---------------------------------------------- |
|
481 ; Add a boxed legend using the simple method |
|
482 |
|
483 res@pmLegendDisplayMode = "Always" |
|
484 ; res@pmLegendWidthF = 0.1 |
|
485 res@pmLegendWidthF = 0.08 |
|
486 res@pmLegendHeightF = 0.06 |
|
487 res@pmLegendOrthogonalPosF = -1.17 |
|
488 ; res@pmLegendOrthogonalPosF = -1.00 ;(downward) |
|
489 ; res@pmLegendOrthogonalPosF = -0.30 ;(downward) |
|
490 |
|
491 ; res@pmLegendParallelPosF = 0.18 |
|
492 res@pmLegendParallelPosF = 0.23 ;(rightward) |
|
493 res@pmLegendParallelPosF = 0.73 ;(rightward) |
|
494 res@pmLegendParallelPosF = 0.83 ;(rightward) |
|
495 |
|
496 ; res@lgPerimOn = False |
|
497 res@lgLabelFontHeightF = 0.015 |
|
498 res@xyExplicitLegendLabels = (/"observed",model_name/) |
|
499 |
|
500 ;******************************************************************* |
|
501 ; (A) time series plot: monthly ( 2 lines per plot) |
|
502 ;******************************************************************* |
|
503 |
|
504 ; x-axis in time series plot |
|
505 |
|
506 timeI = new((/ntime/),integer) |
|
507 timeF = new((/ntime/),float) |
|
508 timeI = ispan(1,ntime,1) |
|
509 timeF = year_start + (timeI-1)/12. |
|
510 timeF@long_name = "year" |
|
511 |
|
512 plot_data = new((/2,ntime/),float) |
|
513 plot_data@long_name = "TgC/month" |
|
514 |
|
515 ;---------------------------------------------- |
|
516 ; time series plot : per biome |
|
517 |
|
518 do m = 0, n_biome-1 |
|
519 |
|
520 plot_name = "monthly_biome_"+ m |
|
521 |
|
522 wks = gsn_open_wks (plot_type,plot_name) |
|
523 |
|
524 title = "Fire : "+ row_head(m) |
|
525 res@tiMainString = title |
|
526 |
|
527 plot_data(0,:) = yvalues_g(:,0,m) |
|
528 plot_data(1,:) = yvalues_g(:,1,m) |
|
529 |
|
530 plot = gsn_csm_xy(wks,timeF,plot_data,res) |
|
531 |
|
532 delete (wks) |
|
533 delete (plot) |
|
534 |
|
535 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \ |
|
536 "rm "+plot_name+"."+plot_type) |
|
537 end do |
|
538 |
|
539 ;------------------------------------------ |
|
540 ; data for table : per biome |
|
541 |
|
542 ; unit change from TgC/month to PgC/month |
|
543 unit_factor = 1.e-3 |
|
544 |
|
545 score_max = 1. |
|
546 |
|
547 tmp_ob = new((/ntime/),float) |
|
548 tmp_mod = new((/ntime/),float) |
|
549 |
|
550 total_ob = new((/n_biome/),float) |
|
551 total_mod = new((/n_biome/),float) |
|
552 Mscore2 = new((/n_biome/),float) |
|
553 |
|
554 do m = 0, n_biome-1 |
|
555 |
|
556 tmp_ob = yvalues_g(:,0,m) |
|
557 tmp_mod = yvalues_g(:,1,m) |
|
558 |
|
559 total_ob(m) = avg(month_to_annual(tmp_ob, 0)) * unit_factor |
|
560 total_mod(m) = avg(month_to_annual(tmp_mod,0)) * unit_factor |
|
561 |
|
562 cc_time = esccr(tmp_mod,tmp_ob,0) |
|
563 |
|
564 ratio = total_mod(m)/total_ob(m) |
|
565 |
|
566 good = ind(tmp_ob .ne. 0. .and. tmp_mod .ne. 0.) |
|
567 |
|
568 bias = sum( abs( tmp_mod(good)-tmp_ob(good) )/( abs(tmp_mod(good))+abs(tmp_ob(good)) ) ) |
|
569 Mscore2(m) = (1.- (bias/dimsizes(good)))*score_max |
|
570 |
|
571 delete (good) |
|
572 |
|
573 text(m,0) = sprintf("%.2f",total_ob(m)) |
|
574 text(m,1) = sprintf("%.2f",total_mod(m)) |
|
575 text(m,2) = sprintf("%.2f",cc_time) |
|
576 text(m,3) = sprintf("%.2f",ratio) |
|
577 text(m,4) = sprintf("%.2f",Mscore2(m)) |
|
578 text(m,5) = "<a href=./monthly_biome_"+m+".png>model_vs_ob</a>" |
|
579 end do |
|
580 |
|
581 delete (tmp_ob) |
|
582 delete (tmp_mod) |
|
583 |
|
584 ;-------------------------------------------- |
|
585 ; time series plot: all biome |
|
586 |
|
587 plot_name = "monthly_global" |
|
588 |
|
589 wks = gsn_open_wks (plot_type,plot_name) |
|
590 |
|
591 title = "Fire : "+ row_head(n_biome) |
|
592 res@tiMainString = title |
|
593 |
|
594 do k = 0,ntime-1 |
|
595 plot_data(0,k) = sum(yvalues_g(k,0,:)) |
|
596 plot_data(1,k) = sum(yvalues_g(k,1,:)) |
|
597 end do |
|
598 |
|
599 plot = gsn_csm_xy(wks,timeF,plot_data,res) |
|
600 |
|
601 delete (wks) |
|
602 delete (plot) |
|
603 |
|
604 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \ |
|
605 "rm "+plot_name+"."+plot_type) |
|
606 |
|
607 ;------------------------------------------ |
|
608 ; data for table : global |
|
609 |
|
610 score_max = 1. |
|
611 |
|
612 tmp_ob = ndtooned(yvalues_g(:,0,:)) |
|
613 tmp_mod = ndtooned(yvalues_g(:,1,:)) |
|
614 |
|
615 cc_time = esccr(tmp_mod,tmp_ob,0) |
|
616 |
|
617 ratio = sum(total_mod)/sum(total_ob) |
|
618 |
|
619 good = ind(tmp_ob .ne. 0. .and. tmp_mod .ne. 0.) |
|
620 |
|
621 bias = sum( abs( tmp_mod(good)-tmp_ob(good) )/( abs(tmp_mod(good))+abs(tmp_ob(good)) ) ) |
|
622 Mscore3 = (1.- (bias/dimsizes(good)))*score_max |
|
623 |
|
624 ; print (Mscore3) |
|
625 |
|
626 delete (good) |
|
627 |
|
628 text(nrow-1,0) = sprintf("%.2f",sum(total_ob)) |
|
629 text(nrow-1,1) = sprintf("%.2f",sum(total_mod)) |
|
630 text(nrow-1,2) = sprintf("%.2f",cc_time) |
|
631 text(nrow-1,3) = sprintf("%.2f",ratio) |
|
632 ; text(nrow-1,4) = sprintf("%.2f",avg(Mscore2)) |
|
633 text(nrow-1,4) = sprintf("%.2f", Mscore3) |
|
634 text(nrow-1,5) = "<a href=./monthly_global.png>model_vs_ob</a>" |
|
635 |
|
636 ;************************************************** |
|
637 ; create html table |
|
638 ;************************************************** |
|
639 |
|
640 header_text = "<H1>Fire Emissions from GFEDv2 (1997-2004) vs "+model_name+"</H1>" |
|
641 |
|
642 header = (/"<HTML>" \ |
|
643 ,"<HEAD>" \ |
|
644 ,"<TITLE>CLAMP metrics</TITLE>" \ |
|
645 ,"</HEAD>" \ |
|
646 ,header_text \ |
|
647 /) |
|
648 footer = "</HTML>" |
|
649 |
|
650 table_header = (/ \ |
|
651 "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \ |
|
652 ,"<tr>" \ |
|
653 ," <th bgcolor=DDDDDD >Biome Type</th>" \ |
|
654 ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \ |
|
655 ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \ |
|
656 ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \ |
|
657 ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \ |
|
658 ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \ |
|
659 ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \ |
|
660 ,"</tr>" \ |
|
661 /) |
|
662 table_footer = "</table>" |
|
663 row_header = "<tr>" |
|
664 row_footer = "</tr>" |
|
665 |
|
666 lines = new(50000,string) |
|
667 nline = 0 |
|
668 |
|
669 set_line(lines,nline,header) |
|
670 set_line(lines,nline,table_header) |
|
671 ;----------------------------------------------- |
|
672 ;row of table |
|
673 |
|
674 do n = 0,nrow-1 |
|
675 set_line(lines,nline,row_header) |
|
676 |
|
677 txt0 = row_head(n) |
|
678 txt1 = text(n,0) |
|
679 txt2 = text(n,1) |
|
680 txt3 = text(n,2) |
|
681 txt4 = text(n,3) |
|
682 txt5 = text(n,4) |
|
683 txt6 = text(n,5) |
|
684 |
|
685 set_line(lines,nline,"<th>"+txt0+"</th>") |
|
686 set_line(lines,nline,"<th>"+txt1+"</th>") |
|
687 set_line(lines,nline,"<th>"+txt2+"</th>") |
|
688 set_line(lines,nline,"<th>"+txt3+"</th>") |
|
689 set_line(lines,nline,"<th>"+txt4+"</th>") |
|
690 set_line(lines,nline,"<th>"+txt5+"</th>") |
|
691 set_line(lines,nline,"<th>"+txt6+"</th>") |
|
692 |
|
693 set_line(lines,nline,row_footer) |
|
694 end do |
|
695 ;----------------------------------------------- |
|
696 set_line(lines,nline,table_footer) |
|
697 set_line(lines,nline,footer) |
|
698 |
|
699 ; Now write to an HTML file. |
|
700 |
|
701 output_html = "table_fire.html" |
|
702 |
|
703 idx = ind(.not.ismissing(lines)) |
|
704 if(.not.any(ismissing(idx))) then |
|
705 asciiwrite(output_html,lines(idx)) |
|
706 else |
|
707 print ("error?") |
|
708 end if |
|
709 |
|
710 delete (idx) |
|
711 |
|
712 ;************************************************************************************** |
|
713 ; update score |
|
714 ;************************************************************************************** |
|
715 |
|
716 M_all = Mscore1 + Mscore3 |
|
717 M_fire = sprintf("%.2f", M_all) |
|
718 |
|
719 if (isvar("compare")) then |
|
720 system("sed -e '1,/M_fire/s/M_fire/"+M_fire+"/' "+html_name2+" > "+html_new2+";"+ \ |
|
721 "mv -f "+html_new2+" "+html_name2) |
|
722 end if |
|
723 |
|
724 system("sed s#M_fire#"+M_fire+"# "+html_name+" > "+html_new+";"+ \ |
|
725 "mv -f "+html_new+" "+html_name) |
|
726 |
|
727 ;*************************************************************************** |
|
728 ; get total score and write to file |
|
729 ;*************************************************************************** |
|
730 |
|
731 asciiwrite("M_save.fire", M_fire) |
|
732 |
|
733 delete (M_fire) |
|
734 |
|
735 ;*************************************************************************** |
|
736 ; output plot and html |
|
737 ;*************************************************************************** |
|
738 output_dir = model_name+"/fire" |
|
739 |
|
740 system("mv *.png *.html " + output_dir) |
|
741 ;*************************************************************************** |
|
742 |
|
743 end |
|
744 |