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