1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/fire/23.table+tseries.ncl Mon Jan 26 22:08:20 2009 -0500
1.3 @@ -0,0 +1,692 @@
1.4 +;********************************************************
1.5 +;using model biome vlass
1.6 +;
1.7 +; required command line input parameters:
1.8 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
1.9 +;
1.10 +; histogram normalized by rain and compute correleration
1.11 +;**************************************************************
1.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
1.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
1.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
1.15 +;**************************************************************
1.16 +procedure set_line(lines:string,nline:integer,newlines:string)
1.17 +begin
1.18 +; add line to ascci/html file
1.19 +
1.20 + nnewlines = dimsizes(newlines)
1.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
1.22 + print("set_line: bad index, not setting anything.")
1.23 + return
1.24 + end if
1.25 + lines(nline:nline+nnewlines-1) = newlines
1.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
1.27 + nline = nline + nnewlines
1.28 + return
1.29 +end
1.30 +;**************************************************************
1.31 +; Main code.
1.32 +begin
1.33 +
1.34 + plot_type = "ps"
1.35 + plot_type_new = "png"
1.36 +
1.37 +;---------------------------------------------------
1.38 +; model name and grid
1.39 +
1.40 + model_grid = "T42"
1.41 +
1.42 + model_name = "cn"
1.43 + model_name1 = "i01.06cn"
1.44 + model_name2 = "i01.10cn"
1.45 +
1.46 +;---------------------------------------------------
1.47 +; get biome data: model
1.48 +
1.49 + biome_name_mod = "Model PFT Class"
1.50 +
1.51 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
1.52 + film = "class_pft_"+model_grid+".nc"
1.53 + fm = addfile(dirm+film,"r")
1.54 +
1.55 + classmod = fm->CLASS_PFT
1.56 +
1.57 + delete (fm)
1.58 +
1.59 +; model data has 17 land-type classes
1.60 +
1.61 + nclass_mod = 17
1.62 +
1.63 +;--------------------------------------------------
1.64 +; get model data: landmask, landfrac and area
1.65 +
1.66 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
1.67 + film = "lnd_T42.nc"
1.68 + fm = addfile (dirm+film,"r")
1.69 +
1.70 + landmask = fm->landmask
1.71 + landfrac = fm->landfrac
1.72 + area = fm->area
1.73 +
1.74 + delete (fm)
1.75 +
1.76 +; change area from km**2 to m**2
1.77 + area = area * 1.e6
1.78 +
1.79 +;----------------------------------------------------
1.80 +; read data: time series, model
1.81 +
1.82 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
1.83 + film = model_name2 + "_Fire_C_1979-2004_monthly.nc"
1.84 + fm = addfile (dirm+film,"r")
1.85 +
1.86 + data_mod = fm->COL_FIRE_CLOSS(18:25,:,:,:)
1.87 +
1.88 + delete (fm)
1.89 +
1.90 +; Units for these variables are:
1.91 +; g C/m^2/s
1.92 +
1.93 +; change unit to g C/m^2/month
1.94 +
1.95 + nsec_per_month = 60*60*24*30
1.96 +
1.97 + data_mod = data_mod * nsec_per_month
1.98 +
1.99 + data_mod@unit = "gC/m2/month"
1.100 +;----------------------------------------------------
1.101 +; read data: time series, observed
1.102 +
1.103 + dirm = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
1.104 + film = "Fire_C_1997-2006_monthly_"+ model_grid+".nc"
1.105 + fm = addfile (dirm+film,"r")
1.106 +
1.107 + data_ob = fm->FIRE_C(0:7,:,:,:)
1.108 +
1.109 + delete (fm)
1.110 +
1.111 + ob_name = "GFEDv2"
1.112 +
1.113 +; Units for these variables are:
1.114 +; g C/m^2/month
1.115 +
1.116 +;---------------------------------------------------
1.117 +; take into account landfrac
1.118 +
1.119 + area = area * landfrac
1.120 + data_mod = data_mod * conform(data_mod, landfrac, (/2,3/))
1.121 + data_ob = data_ob * conform(data_ob, landfrac, (/2,3/))
1.122 +
1.123 + delete (landfrac)
1.124 +
1.125 +;-------------------------------------------------------------
1.126 +; html table1 data
1.127 +
1.128 +; column (not including header column)
1.129 +
1.130 + col_head = (/"Observed Fire_Flux (PgC/yr)" \
1.131 + ,"Model Fire_Flux (PgC/yr)" \
1.132 + ,"Correlation Coefficient" \
1.133 + ,"Ratio model/observed" \
1.134 + ,"M_score" \
1.135 + ,"Timeseries plot" \
1.136 + /)
1.137 +
1.138 + ncol = dimsizes(col_head)
1.139 +
1.140 +; row (not including header row)
1.141 +
1.142 +; using model biome class:
1.143 + row_head = (/"Not Vegetated" \
1.144 + ,"Needleleaf Evergreen Temperate Tree" \
1.145 + ,"Needleleaf Evergreen Boreal Tree" \
1.146 +; ,"Needleleaf Deciduous Boreal Tree" \
1.147 + ,"Broadleaf Evergreen Tropical Tree" \
1.148 + ,"Broadleaf Evergreen Temperate Tree" \
1.149 + ,"Broadleaf Deciduous Tropical Tree" \
1.150 + ,"Broadleaf Deciduous Temperate Tree" \
1.151 +; ,"Broadleaf Deciduous Boreal Tree" \
1.152 +; ,"Broadleaf Evergreen Shrub" \
1.153 + ,"Broadleaf Deciduous Temperate Shrub" \
1.154 + ,"Broadleaf Deciduous Boreal Shrub" \
1.155 + ,"C3 Arctic Grass" \
1.156 + ,"C3 Non-Arctic Grass" \
1.157 + ,"C4 Grass" \
1.158 + ,"Corn" \
1.159 +; ,"Wheat" \
1.160 + ,"All Biome" \
1.161 + /)
1.162 + nrow = dimsizes(row_head)
1.163 +
1.164 +; arrays to be passed to table.
1.165 + text = new ((/nrow, ncol/),string )
1.166 +
1.167 +;*****************************************************************
1.168 +; (A) get time-mean
1.169 +;*****************************************************************
1.170 +
1.171 + x = dim_avg_Wrap(data_mod(lat|:,lon|:,month|:,year|:))
1.172 + data_mod_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
1.173 + delete (x)
1.174 +
1.175 + x = dim_avg_Wrap( data_ob(lat|:,lon|:,month|:,year|:))
1.176 + data_ob_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
1.177 + delete (x)
1.178 +
1.179 +;----------------------------------------------------
1.180 +; compute correlation coef
1.181 +
1.182 + landmask_1d = ndtooned(landmask)
1.183 + data_mod_1d = ndtooned(data_mod_m)
1.184 + data_ob_1d = ndtooned(data_ob_m)
1.185 +
1.186 + good = ind(landmask_1d .gt. 0.)
1.187 +
1.188 + cc = esccr(data_mod_1d(good),data_ob_1d(good),0)
1.189 +
1.190 + delete (landmask_1d)
1.191 + delete (data_mod_1d)
1.192 + delete (data_ob_1d)
1.193 + delete (good)
1.194 +
1.195 +;----------------------------------------------------
1.196 +; compute M_global
1.197 +
1.198 + score_max = 1.
1.199 +
1.200 + Mscore1 = cc * cc * score_max
1.201 +
1.202 + M_global = sprintf("%.2f", Mscore1)
1.203 +
1.204 +;----------------------------------------------------
1.205 +; global res
1.206 +
1.207 + resg = True ; Use plot options
1.208 + resg@cnFillOn = True ; Turn on color fill
1.209 + resg@gsnSpreadColors = True ; use full colormap
1.210 + resg@cnLinesOn = False ; Turn off contourn lines
1.211 + resg@mpFillOn = False ; Turn off map fill
1.212 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
1.213 +
1.214 +;----------------------------------------------------
1.215 +; global contour: model vs ob
1.216 +
1.217 + plot_name = "global_model_vs_ob"
1.218 +
1.219 + wks = gsn_open_wks (plot_type,plot_name)
1.220 + gsn_define_colormap(wks,"gui_default")
1.221 +
1.222 + plot=new(3,graphic) ; create graphic array
1.223 +
1.224 + resg@gsnFrame = False ; Do not draw plot
1.225 + resg@gsnDraw = False ; Do not advance frame
1.226 +
1.227 +;----------------------
1.228 +; plot correlation coef
1.229 +
1.230 + gRes = True
1.231 + gRes@txFontHeightF = 0.02
1.232 + gRes@txAngleF = 90
1.233 +
1.234 + correlation_text = "(correlation coef = "+sprintf("%.2f", cc)+")"
1.235 +
1.236 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
1.237 +
1.238 +;-----------------------
1.239 +; plot ob
1.240 +
1.241 + data_ob_m = where(landmask .gt. 0., data_ob_m, data_ob_m@_FillValue)
1.242 +
1.243 + title = ob_name
1.244 + resg@tiMainString = title
1.245 +
1.246 + resg@cnMinLevelValF = 1.
1.247 + resg@cnMaxLevelValF = 10.
1.248 + resg@cnLevelSpacingF = 1.
1.249 +
1.250 + plot(0) = gsn_csm_contour_map_ce(wks,data_ob_m,resg)
1.251 +
1.252 +;-----------------------
1.253 +; plot model
1.254 +
1.255 + data_mod_m = where(landmask .gt. 0., data_mod_m, data_mod_m@_FillValue)
1.256 +
1.257 + title = "Model "+ model_name
1.258 + resg@tiMainString = title
1.259 +
1.260 + resg@cnMinLevelValF = 1.
1.261 + resg@cnMaxLevelValF = 10.
1.262 + resg@cnLevelSpacingF = 1.
1.263 +
1.264 + plot(1) = gsn_csm_contour_map_ce(wks,data_mod_m,resg)
1.265 +
1.266 +;-----------------------
1.267 +; plot model-ob
1.268 +
1.269 + resg@cnMinLevelValF = -8.
1.270 + resg@cnMaxLevelValF = 2.
1.271 + resg@cnLevelSpacingF = 1.
1.272 +
1.273 + zz = data_ob_m
1.274 + zz = data_mod_m - data_ob_m
1.275 + title = "Model_"+model_name+" - Observed"
1.276 + resg@tiMainString = title
1.277 +
1.278 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
1.279 +
1.280 +; plot panel
1.281 +
1.282 + pres = True ; panel plot mods desired
1.283 + pres@gsnMaximize = True ; fill the page
1.284 +
1.285 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
1.286 +
1.287 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
1.288 + "rm "+plot_name+"."+plot_type)
1.289 +
1.290 + clear (wks)
1.291 + delete (plot)
1.292 +
1.293 + delete (data_ob_m)
1.294 + delete (data_mod_m)
1.295 + delete (zz)
1.296 +
1.297 + resg@gsnFrame = True ; Do advance frame
1.298 + resg@gsnDraw = True ; Do draw plot
1.299 +
1.300 +;*******************************************************************
1.301 +; (B) Time series : per biome
1.302 +;*******************************************************************
1.303 +
1.304 + data_n = 2
1.305 +
1.306 + dsizes = dimsizes(data_mod)
1.307 + nyear = dsizes(0)
1.308 + nmonth = dsizes(1)
1.309 + ntime = nyear * nmonth
1.310 +
1.311 + year_start = 1997
1.312 + year_end = 2004
1.313 +
1.314 +;-------------------------------------------
1.315 +; Calculate "nice" bins for binning the data
1.316 +
1.317 +; using model biome class
1.318 + nclass = nclass_mod
1.319 +
1.320 + range = fspan(0,nclass,nclass+1)
1.321 +
1.322 +; Use this range information to grab all the values in a
1.323 +; particular range, and then take an average.
1.324 +
1.325 + nx = dimsizes(range) - 1
1.326 +
1.327 +;-------------------------------------------
1.328 +; put data into bins
1.329 +
1.330 +; using observed biome class
1.331 +; base = ndtooned(classob)
1.332 +; using model biome class
1.333 + base = ndtooned(classmod)
1.334 +
1.335 +; output
1.336 +
1.337 + area_bin = new((/nx/),float)
1.338 + yvalues = new((/ntime,data_n,nx/),float)
1.339 +
1.340 +; Loop through each range, using base.
1.341 +
1.342 + do i=0,nx-1
1.343 +
1.344 + if (i.ne.(nx-1)) then
1.345 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
1.346 + else
1.347 + idx = ind(base.ge.range(i))
1.348 + end if
1.349 +;---------------------
1.350 +; for area
1.351 +
1.352 + data = ndtooned(area)
1.353 +
1.354 + if (.not.any(ismissing(idx))) then
1.355 + area_bin(i) = sum(data(idx))
1.356 + else
1.357 + area_bin(i) = area_bin@_FillValue
1.358 + end if
1.359 +
1.360 +;#############################################################
1.361 +; using model biome class:
1.362 +; set the following 4 classes to _FillValue:
1.363 +; (3)Needleleaf Deciduous Boreal Tree,
1.364 +; (8)Broadleaf Deciduous Boreal Tree,
1.365 +; (9)Broadleaf Evergreen Shrub,
1.366 +; (16)Wheat
1.367 +
1.368 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
1.369 + area_bin(i) = area_bin@_FillValue
1.370 + end if
1.371 +;#############################################################
1.372 +
1.373 + delete (data)
1.374 +
1.375 +;---------------------
1.376 +; for data_mod and data_ob
1.377 +
1.378 + do n = 0,data_n-1
1.379 +
1.380 + t = -1
1.381 + do m = 0,nyear-1
1.382 + do k = 0,nmonth-1
1.383 +
1.384 + t = t + 1
1.385 +
1.386 + if (n.eq.0) then
1.387 + data = ndtooned(data_ob(m,k,:,:))
1.388 + end if
1.389 +
1.390 + if (n.eq.1) then
1.391 + data = ndtooned(data_mod(m,k,:,:))
1.392 + end if
1.393 +
1.394 +; Calculate average
1.395 +
1.396 + if (.not.any(ismissing(idx))) then
1.397 + yvalues(t,n,i) = avg(data(idx))
1.398 + else
1.399 + yvalues(t,n,i) = yvalues@_FillValue
1.400 + end if
1.401 +
1.402 +;#############################################################
1.403 +; using model biome class:
1.404 +; set the following 4 classes to _FillValue:
1.405 +; (3)Needleleaf Deciduous Boreal Tree,
1.406 +; (8)Broadleaf Deciduous Boreal Tree,
1.407 +; (9)Broadleaf Evergreen Shrub,
1.408 +; (16)Wheat
1.409 +
1.410 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
1.411 + yvalues(t,n,i) = yvalues@_FillValue
1.412 + end if
1.413 +;#############################################################
1.414 +
1.415 + end do
1.416 + end do
1.417 +
1.418 + delete(data)
1.419 + end do
1.420 +
1.421 + delete(idx)
1.422 + end do
1.423 +
1.424 + delete (base)
1.425 + delete (data_mod)
1.426 + delete (data_ob)
1.427 +
1.428 +;----------------------------------------------------------------
1.429 +; get area_good
1.430 +
1.431 + good = ind(.not.ismissing(area_bin))
1.432 +
1.433 + area_g = area_bin(good)
1.434 +
1.435 + n_biome = dimsizes(good)
1.436 +
1.437 +;----------------------------------------------------------------
1.438 +; data for tseries plot
1.439 +
1.440 + yvalues_g = new((/ntime,data_n,n_biome/),float)
1.441 +
1.442 + yvalues_g@units = "TgC/month"
1.443 +
1.444 +; change unit to Tg C/month
1.445 +; change unit from g to Tg (Tera gram)
1.446 + factor_unit = 1.e-12
1.447 +
1.448 + yvalues_g = yvalues(:,:,good) * conform(yvalues_g,area_g,2) * factor_unit
1.449 +
1.450 + delete (good)
1.451 +
1.452 +;-------------------------------------------------------------------
1.453 +; general settings for line plot
1.454 +
1.455 + res = True
1.456 + res@xyDashPatterns = (/0,0/) ; make lines solid
1.457 + res@xyLineThicknesses = (/2.0,2.0/) ; make lines thicker
1.458 + res@xyLineColors = (/"blue","red"/) ; line color
1.459 +
1.460 + res@trXMinF = year_start
1.461 + res@trXMaxF = year_end + 1
1.462 +
1.463 + res@vpHeightF = 0.4 ; change aspect ratio of plot
1.464 +; res@vpWidthF = 0.8
1.465 + res@vpWidthF = 0.75
1.466 +
1.467 + res@tiMainFontHeightF = 0.025 ; size of title
1.468 +
1.469 + res@tmXBFormat = "f" ; not to add trailing zeros
1.470 +
1.471 +; res@gsnMaximize = True
1.472 +
1.473 +;----------------------------------------------
1.474 +; Add a boxed legend using the simple method
1.475 +
1.476 + res@pmLegendDisplayMode = "Always"
1.477 +; res@pmLegendWidthF = 0.1
1.478 + res@pmLegendWidthF = 0.08
1.479 + res@pmLegendHeightF = 0.06
1.480 + res@pmLegendOrthogonalPosF = -1.17
1.481 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
1.482 +; res@pmLegendOrthogonalPosF = -0.30 ;(downward)
1.483 +
1.484 +; res@pmLegendParallelPosF = 0.18
1.485 + res@pmLegendParallelPosF = 0.23 ;(rightward)
1.486 + res@pmLegendParallelPosF = 0.73 ;(rightward)
1.487 + res@pmLegendParallelPosF = 0.83 ;(rightward)
1.488 +
1.489 +; res@lgPerimOn = False
1.490 + res@lgLabelFontHeightF = 0.015
1.491 + res@xyExplicitLegendLabels = (/"observed",model_name/)
1.492 +
1.493 +;*******************************************************************
1.494 +; (A) time series plot: monthly ( 2 lines per plot)
1.495 +;*******************************************************************
1.496 +
1.497 +; x-axis in time series plot
1.498 +
1.499 + timeI = new((/ntime/),integer)
1.500 + timeF = new((/ntime/),float)
1.501 + timeI = ispan(1,ntime,1)
1.502 + timeF = year_start + (timeI-1)/12.
1.503 + timeF@long_name = "year"
1.504 +
1.505 + plot_data = new((/2,ntime/),float)
1.506 + plot_data@long_name = "TgC/month"
1.507 +
1.508 +;----------------------------------------------
1.509 +; time series plot : per biome
1.510 +
1.511 + do m = 0, n_biome-1
1.512 +
1.513 + plot_name = "monthly_biome_"+ m
1.514 +
1.515 + wks = gsn_open_wks (plot_type,plot_name)
1.516 +
1.517 + title = "Fire : "+ row_head(m)
1.518 + res@tiMainString = title
1.519 +
1.520 + plot_data(0,:) = yvalues_g(:,0,m)
1.521 + plot_data(1,:) = yvalues_g(:,1,m)
1.522 +
1.523 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
1.524 +
1.525 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
1.526 + "rm "+plot_name+"."+plot_type)
1.527 +
1.528 + clear (wks)
1.529 + delete (plot)
1.530 +
1.531 + end do
1.532 +
1.533 +;------------------------------------------
1.534 +; data for table : per biome
1.535 +
1.536 +; unit change from TgC/month to PgC/month
1.537 + unit_factor = 1.e-3
1.538 +
1.539 + score_max = 1.
1.540 +
1.541 + tmp_ob = new((/ntime/),float)
1.542 + tmp_mod = new((/ntime/),float)
1.543 +
1.544 + total_ob = new((/n_biome/),float)
1.545 + total_mod = new((/n_biome/),float)
1.546 + Mscore2 = new((/n_biome/),float)
1.547 +
1.548 + do m = 0, n_biome-1
1.549 +
1.550 + tmp_ob = yvalues_g(:,0,m)
1.551 + tmp_mod = yvalues_g(:,1,m)
1.552 +
1.553 + total_ob(m) = avg(month_to_annual(tmp_ob, 0)) * unit_factor
1.554 + total_mod(m) = avg(month_to_annual(tmp_mod,0)) * unit_factor
1.555 +
1.556 + cc = esccr(tmp_mod,tmp_ob,0)
1.557 +
1.558 + ratio = total_mod(m)/total_ob(m)
1.559 +
1.560 + good = ind(tmp_ob .ne. 0. .and. tmp_mod .ne. 0.)
1.561 +
1.562 + bias = sum( abs( tmp_mod(good)-tmp_ob(good) )/( abs(tmp_mod(good))+abs(tmp_ob(good)) ) )
1.563 + Mscore2(m) = (1.- (bias/dimsizes(good)))*score_max
1.564 +
1.565 + delete (good)
1.566 +
1.567 + text(m,0) = sprintf("%.2f",total_ob(m))
1.568 + text(m,1) = sprintf("%.2f",total_mod(m))
1.569 + text(m,2) = sprintf("%.2f",cc)
1.570 + text(m,3) = sprintf("%.2f",ratio)
1.571 + text(m,4) = sprintf("%.2f",Mscore2(m))
1.572 + text(m,5) = "<a href=./monthly_biome_"+m+".png>model_vs_ob</a>"
1.573 + end do
1.574 +
1.575 + delete (tmp_ob)
1.576 + delete (tmp_mod)
1.577 +
1.578 +;--------------------------------------------
1.579 +; time series plot: all biome
1.580 +
1.581 + plot_name = "monthly_global"
1.582 +
1.583 + wks = gsn_open_wks (plot_type,plot_name)
1.584 +
1.585 + title = "Fire : "+ row_head(n_biome)
1.586 + res@tiMainString = title
1.587 +
1.588 + do k = 0,ntime-1
1.589 + plot_data(0,k) = sum(yvalues_g(k,0,:))
1.590 + plot_data(1,k) = sum(yvalues_g(k,1,:))
1.591 + end do
1.592 +
1.593 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
1.594 +
1.595 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
1.596 + "rm "+plot_name+"."+plot_type)
1.597 +
1.598 + clear (wks)
1.599 + delete (plot)
1.600 +
1.601 +;------------------------------------------
1.602 +; data for table : global
1.603 +
1.604 + tmp_ob = ndtooned(yvalues_g(:,0,:))
1.605 + tmp_mod = ndtooned(yvalues_g(:,1,:))
1.606 +
1.607 + cc = esccr(tmp_mod,tmp_ob,0)
1.608 +
1.609 + ratio = sum(total_mod)/sum(total_ob)
1.610 +
1.611 + text(nrow-1,0) = sprintf("%.2f",sum(total_ob))
1.612 + text(nrow-1,1) = sprintf("%.2f",sum(total_mod))
1.613 + text(nrow-1,2) = sprintf("%.2f",cc)
1.614 + text(nrow-1,3) = sprintf("%.2f",ratio)
1.615 + text(nrow-1,4) = sprintf("%.2f",avg(Mscore2))
1.616 + text(nrow-1,5) = "<a href=./monthly_global.png>model_vs_ob</a>"
1.617 +
1.618 +;**************************************************
1.619 +; create html table
1.620 +;**************************************************
1.621 +
1.622 + header_text = "<H1>Fire Emission (1997-2004): Model "+model_name+"</H1>"
1.623 +
1.624 + header = (/"<HTML>" \
1.625 + ,"<HEAD>" \
1.626 + ,"<TITLE>CLAMP metrics</TITLE>" \
1.627 + ,"</HEAD>" \
1.628 + ,header_text \
1.629 + /)
1.630 + footer = "</HTML>"
1.631 +
1.632 + table_header = (/ \
1.633 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
1.634 + ,"<tr>" \
1.635 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
1.636 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
1.637 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
1.638 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
1.639 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
1.640 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
1.641 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
1.642 + ,"</tr>" \
1.643 + /)
1.644 + table_footer = "</table>"
1.645 + row_header = "<tr>"
1.646 + row_footer = "</tr>"
1.647 +
1.648 + lines = new(50000,string)
1.649 + nline = 0
1.650 +
1.651 + set_line(lines,nline,header)
1.652 + set_line(lines,nline,table_header)
1.653 +;-----------------------------------------------
1.654 +;row of table
1.655 +
1.656 + do n = 0,nrow-1
1.657 + set_line(lines,nline,row_header)
1.658 +
1.659 + txt0 = row_head(n)
1.660 + txt1 = text(n,0)
1.661 + txt2 = text(n,1)
1.662 + txt3 = text(n,2)
1.663 + txt4 = text(n,3)
1.664 + txt5 = text(n,4)
1.665 + txt6 = text(n,5)
1.666 +
1.667 + set_line(lines,nline,"<th>"+txt0+"</th>")
1.668 + set_line(lines,nline,"<th>"+txt1+"</th>")
1.669 + set_line(lines,nline,"<th>"+txt2+"</th>")
1.670 + set_line(lines,nline,"<th>"+txt3+"</th>")
1.671 + set_line(lines,nline,"<th>"+txt4+"</th>")
1.672 + set_line(lines,nline,"<th>"+txt5+"</th>")
1.673 + set_line(lines,nline,"<th>"+txt6+"</th>")
1.674 +
1.675 + set_line(lines,nline,row_footer)
1.676 + end do
1.677 +;-----------------------------------------------
1.678 + set_line(lines,nline,table_footer)
1.679 + set_line(lines,nline,footer)
1.680 +
1.681 +; Now write to an HTML file.
1.682 +
1.683 + output_html = "table_fire.html"
1.684 +
1.685 + idx = ind(.not.ismissing(lines))
1.686 + if(.not.any(ismissing(idx))) then
1.687 + asciiwrite(output_html,lines(idx))
1.688 + else
1.689 + print ("error?")
1.690 + end if
1.691 +
1.692 + delete (idx)
1.693 +
1.694 +end
1.695 +