all/03.co2.ncl
changeset 0 0c6405ab2ff4
child 1 4be95183fbcd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/all/03.co2.ncl	Mon Jan 26 22:08:20 2009 -0500
     1.3 @@ -0,0 +1,593 @@
     1.4 +; ***********************************************
     1.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
     1.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
     1.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
     1.8 +load dirscript + "taylor_diagram.ncl"
     1.9 +;************************************************
    1.10 +procedure set_line(lines:string,nline:integer,newlines:string) 
    1.11 +begin
    1.12 +; add line to ascci/html file
    1.13 +    
    1.14 +  nnewlines = dimsizes(newlines)
    1.15 +  if(nline+nnewlines-1.ge.dimsizes(lines))
    1.16 +    print("set_line: bad index, not setting anything.") 
    1.17 +    return
    1.18 +  end if 
    1.19 +  lines(nline:nline+nnewlines-1) = newlines
    1.20 +;  print ("lines = " + lines(nline:nline+nnewlines-1))
    1.21 +  nline = nline + nnewlines
    1.22 +  return 
    1.23 +end
    1.24 +;****************************************************************************
    1.25 +
    1.26 +begin
    1.27 +
    1.28 +  plot_type = "ps"
    1.29 +  plot_type_new = "png"
    1.30 +
    1.31 +;-----------------------------------------------------
    1.32 +; edit table.html of current model for movel1_vs_model2
    1.33 +
    1.34 +  if (isvar("compare")) then
    1.35 +     html_name2 = compare+"/table.html"  
    1.36 +     html_new2  = html_name2 +".new"
    1.37 +  end if
    1.38 +
    1.39 +;------------------------------------------------------
    1.40 +; edit table.html for current model
    1.41 +
    1.42 +  html_name = model_name+"/table.html"  
    1.43 +  html_new  = html_name +".new"
    1.44 +
    1.45 +;------------------------------------------------------
    1.46 +; read model data
    1.47 +
    1.48 +  fm    = addfile(dirm+film3,"r")
    1.49 +
    1.50 +  x     = fm->CO2
    1.51 +  xi    = fm->lon
    1.52 +  yi    = fm->lat
    1.53 +
    1.54 +  delete (fm)
    1.55 +
    1.56 +  xdim  = dimsizes(x)
    1.57 +  nlev  = xdim(1)
    1.58 +  y     = x(:,0,:,:)
    1.59 +  
    1.60 +; get co2 at the lowest level
    1.61 +  y     = x(:,nlev-1,:,:)
    1.62 +
    1.63 +; change to unit of observed (u mol/mol)
    1.64 +; Model_units [=] kgCO2 / kgDryAir
    1.65 +; 28.966 = molecular weight of dry air
    1.66 +; 44.       = molecular weight of CO2
    1.67 +; u mol = 1e-6 mol
    1.68 +
    1.69 +  factor = (28.966/44.) * 1e6
    1.70 +  y      = y * factor
    1.71 +
    1.72 +  y@_FillValue = 1.e36
    1.73 +  y@units      = "u mol/mol"
    1.74 +
    1.75 +;************************************************
    1.76 +; read data: observed
    1.77 +;************************************************
    1.78 +  diri  = diro + "co2/"
    1.79 +  fili  = "co2_globalView_98.nc"
    1.80 +  g     = addfile (diri+fili,"r")
    1.81 +
    1.82 +  val   = g->CO2_SEAS  
    1.83 +  lon   = g->LON 
    1.84 +  lat   = g->LAT
    1.85 +  sta   = chartostring(g->STATION)
    1.86 + 
    1.87 +  delete (g)
    1.88 +
    1.89 +  ncase = dimsizes(lat)
    1.90 +;**************************************************************
    1.91 +; get only the lowest level at each station 
    1.92 +;**************************************************************
    1.93 +  lat_tmp = lat
    1.94 +  lat_tmp@_FillValue = 1.e+36
    1.95 + 
    1.96 +  do n = 0,ncase-1
    1.97 +     if (.not. ismissing(lat_tmp(n))) then 
    1.98 +        indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
    1.99 +        if (dimsizes(indexes) .gt. 1) then
   1.100 +           lat_tmp(indexes(1:)) = lat_tmp@_FillValue
   1.101 +        end if
   1.102 +        delete (indexes)
   1.103 +     end if
   1.104 +  end do
   1.105 +
   1.106 +  indexes = ind(.not. ismissing(lat_tmp))
   1.107 + 
   1.108 +  lat_ob = lat(indexes)
   1.109 +  lon_ob = lon(indexes)
   1.110 +  val_ob = val(indexes,:)
   1.111 +;************************************************************
   1.112 +; interpolate model data into observed station
   1.113 +; note: model is 0-360E, 90S-90N
   1.114 +;************************************************************
   1.115 +; to be able to handle observation at (-89.98,-24.80)
   1.116 +  yi(0) = -90.
   1.117 +
   1.118 +  i = ind(lon_ob .lt. 0.)
   1.119 +  lon_ob(i) = lon_ob(i) + 360.  
   1.120 +
   1.121 +  yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
   1.122 +
   1.123 +  val_model = yo(pts|:,time|:)
   1.124 +  val_model_0 = val_model
   1.125 +;************************************************************
   1.126 +; remove annual mean
   1.127 +;************************************************************
   1.128 +  val_model = val_model - conform(val_model,dim_avg(val_model),0)
   1.129 +
   1.130 +;*******************************************************************
   1.131 +; res for station line plot
   1.132 +;*******************************************************************
   1.133 +; for x-axis in xyplot
   1.134 +  mon = ispan(1,12,1)
   1.135 +  mon@long_name = "month"
   1.136 +
   1.137 +  res                   = True                      ; plot mods desired
   1.138 +  res@xyLineThicknesses = (/2.0,2.0,2.0/)           ; make 2nd lines thicker
   1.139 +  res@xyLineColors      = (/"red","blue"/)  ; change line color
   1.140 +
   1.141 +; Add a boxed legend using the more simple method
   1.142 +  res@pmLegendDisplayMode    = "Always"
   1.143 +; res@pmLegendWidthF         = 0.1
   1.144 +  res@pmLegendWidthF         = 0.08
   1.145 +  res@pmLegendHeightF        = 0.06
   1.146 +; res@pmLegendOrthogonalPosF = -1.17
   1.147 +; res@pmLegendOrthogonalPosF = -1.00  ;(downward)
   1.148 +  res@pmLegendOrthogonalPosF = -0.30  ;(downward)
   1.149 +
   1.150 +; res@pmLegendParallelPosF   =  0.18
   1.151 +  res@pmLegendParallelPosF   =  0.23  ;(rightward)
   1.152 +
   1.153 +; res@lgPerimOn             = False
   1.154 +  res@lgLabelFontHeightF     = 0.015
   1.155 +  res@xyExplicitLegendLabels = (/model_name,"observed"/)
   1.156 +;************************************************************
   1.157 +; number of latitude zone
   1.158 +;************************************************************
   1.159 +  nzone = 4
   1.160 +
   1.161 +; saving data for zone
   1.162 +; number of rows for zone table (with data)
   1.163 +  nrow_zone = nzone 
   1.164 +
   1.165 +; number of columns for zone table
   1.166 +  ncol_zone = 7
   1.167 +
   1.168 +  text = new((/nrow_zone,ncol_zone/),string)
   1.169 +
   1.170 +do z = 0,nzone-1
   1.171 +
   1.172 +  if (z .eq. 0) then 
   1.173 +     zone = "60N-90N" 
   1.174 +     score_max = 5.0
   1.175 +     ind_z = ind(lat_ob .ge. 60.)
   1.176 +  end if
   1.177 +
   1.178 +  if (z .eq. 1) then 
   1.179 +     zone = "30N-60N" 
   1.180 +     score_max = 5.0
   1.181 +     ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
   1.182 +  end if
   1.183 +
   1.184 +  if (z .eq. 2) then 
   1.185 +     zone = "EQ-30N"
   1.186 +     score_max = 5.0
   1.187 +     ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
   1.188 +  end if
   1.189 +
   1.190 +  if (z .eq. 3) then 
   1.191 +     zone = "90S-EQ" 
   1.192 +     score_max = 5.0
   1.193 +     ind_z = ind(lat_ob .lt. 0. )
   1.194 +  end if
   1.195 +
   1.196 +  npts = dimsizes(ind_z)
   1.197 +
   1.198 +;------------------------------------------------------
   1.199 +; for metric table computation
   1.200 +  amp_ob        = new((/npts/),float)
   1.201 +  amp_model     = new((/npts/),float)
   1.202 +
   1.203 +  amp_ratio_sta = new((/npts/),float)
   1.204 +  ccr_sta       = new((/npts/),float)
   1.205 +  M_sta         = new((/npts/),float)
   1.206 +  score_sta     = new((/npts/),float)
   1.207 +
   1.208 +  var_sta       = new((/npts/),float)
   1.209 +;-----------------------------------------------------
   1.210 +; for station line plot
   1.211 +  npts_str = ""
   1.212 +  npts_str = npts
   1.213 +
   1.214 +  plot_data   = new((/2,12,npts/),float)
   1.215 +  plot_data_0 = new((/12,npts/),float)
   1.216 +
   1.217 +  plot_data!0 = "case"
   1.218 +  plot_data!1 = "month"
   1.219 +  plot_data!2 = "pts"
   1.220 +  plot_data@long_name   = "CO2 Annual Cycle (ppm)"
   1.221 +
   1.222 +  plot_data_0!0 = "month"
   1.223 +  plot_data_0!1 = "pts"
   1.224 +  plot_data_0@long_name = "CO2 (ppm)"
   1.225 +;--------------------------------------------------------------------------
   1.226 +  do n=0,npts-1
   1.227 +
   1.228 +     amp_ob(n)    = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:)) 
   1.229 +     amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
   1.230 +
   1.231 +     amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
   1.232 +     ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
   1.233 +     M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
   1.234 +     score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
   1.235 + 
   1.236 +     var_model = stddev(val_model(ind_z(n),:))
   1.237 +     var_ob    = stddev(val_ob(ind_z(n),:))
   1.238 +     var_sta(n)= var_model/var_ob 
   1.239 +;----------------------------------------------------------------------
   1.240 +; for station line plot
   1.241 +
   1.242 +     plot_data(0,:,n) = (/val_model(ind_z(n),:)/)
   1.243 +     plot_data(1,:,n) = (/val_ob(ind_z(n),:)/)
   1.244 +
   1.245 +     plot_data_0(:,n) = (/val_model_0(ind_z(n),:)/)
   1.246 +   
   1.247 +     plot_name = sta(ind_z(n))    
   1.248 +     title = plot_name+" ("+lat(ind_z(n))+","+lon(ind_z(n))+")"
   1.249 +
   1.250 +     wks = gsn_open_wks (plot_type,plot_name)   ; open workstation
   1.251 +;------------------------------------------
   1.252 +;    for panel plot
   1.253 +   
   1.254 +     plot=new(2,graphic)                        ; create graphic array
   1.255 +     res@gsnFrame     = False                   ; Do not draw plot 
   1.256 +     res@gsnDraw      = False                   ; Do not advance frame
   1.257 +
   1.258 +     pres                            = True     ; panel plot mods desired
   1.259 +     pres@gsnPanelYWhiteSpacePercent = 5        ; increase white space around
   1.260 +                                               ; indiv. plots in panel
   1.261 +     pres@gsnMaximize                = True     ; fill the page
   1.262 +;------------------------------------------
   1.263 +     res@tiMainString = title                           ; add title
   1.264 +
   1.265 +     plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res)   ; create plot 1
   1.266 +
   1.267 +     plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,n),res) ; create plot 2
   1.268 +
   1.269 +     gsn_panel(wks,plot,(/2,1/),pres)                 ; create panel plot
   1.270 +
   1.271 +     delete (wks)
   1.272 +     delete (plot)
   1.273 +
   1.274 +     system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
   1.275 +            "rm "+plot_name+"."+plot_type)
   1.276 +
   1.277 +;---------------------------------------------------------------------------  
   1.278 +  end do
   1.279 +
   1.280 +;-------------------------------------------------------------------------
   1.281 +; for Taylor plot in a zone
   1.282 +
   1.283 +; Cases [Model]
   1.284 +  case      = (/ model_name /) 
   1.285 +  nCase     = dimsizes(case )                 ; # of Cases [Cases]
   1.286 +
   1.287 +; station compared
   1.288 +  var       = sta(ind_z) 
   1.289 +  nVar      = dimsizes(var)                   ; # of stations
   1.290 +
   1.291 +; arrays to be passed to taylor plot 
   1.292 +  ratio      = new ((/nCase, nVar/),typeof(var_sta) )  
   1.293 +  cc         = new ((/nCase, nVar/),typeof(ccr_sta) ) 
   1.294 +
   1.295 +  ratio(0,:) = var_sta 
   1.296 +  cc(0,:)    = ccr_sta
   1.297 +
   1.298 +;---------------------------------
   1.299 +; create plot
   1.300 +
   1.301 +  rest   = True                           ; default taylor diagram
   1.302 +        
   1.303 +  rest@Markers      = (/16/)               ; make all solid fill
   1.304 +  rest@Colors       = (/"red" /)          
   1.305 +; rest@varLabels    = var
   1.306 +  rest@caseLabels   = case
   1.307 +
   1.308 +  rOpts  = True
   1.309 +  rOpts@caseLabels = True
   1.310 +; rOpts@caseLabelsFontHeightF = 0.05
   1.311 +  rOpts@caseLabelsFontHeightF = 0.15
   1.312 +
   1.313 +  plot_name = "taylor_diagram_"+ zone
   1.314 +  title = "CO2 Annual Cycle:  "+ zone
   1.315 +  rest@tiMainString = title
   1.316 +  
   1.317 +  wks  = gsn_open_wks (plot_type,plot_name)        ; open workstation  
   1.318 +  plot = taylor_diagram(wks,ratio,cc,rest)
   1.319 +
   1.320 +  delete (wks)
   1.321 +  delete (plot)
   1.322 +
   1.323 +  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
   1.324 +         "rm "+plot_name+"."+plot_type)
   1.325 +
   1.326 +  delete (ratio)
   1.327 +  delete (cc)
   1.328 +  delete (var_sta)
   1.329 +  delete (var)
   1.330 +
   1.331 +;-------------------------------------------------------------------------
   1.332 +; for line plot in a zone
   1.333 +
   1.334 +  plot_name = "All_"+npts_str
   1.335 +  title = plot_name + " in "+ zone
   1.336 +
   1.337 +  wks = gsn_open_wks (plot_type,plot_name)        ; open workstation
   1.338 +;-----------------------------------------
   1.339 +; for panel plot
   1.340 +   
   1.341 +  plot=new(2,graphic)                        ; create graphic array
   1.342 +  res@gsnFrame     = False                   ; Do not draw plot 
   1.343 +  res@gsnDraw      = False                   ; Do not advance frame
   1.344 +
   1.345 +  pres                            = True     ; panel plot mods desired
   1.346 +  pres@gsnPanelYWhiteSpacePercent = 5        ; increase white space around
   1.347 +                                               ; indiv. plots in panel
   1.348 +  pres@gsnMaximize                = True     ; fill the page
   1.349 +;-----------------------------------------
   1.350 +  res@tiMainString = title                                     ; add title
   1.351 +
   1.352 +  plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res)   ; create plot 1
   1.353 +    
   1.354 +  plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
   1.355 +
   1.356 +  gsn_panel(wks,plot,(/2,1/),pres)                 ; create panel plot
   1.357 +
   1.358 +  delete (wks)
   1.359 +  delete (plot)
   1.360 +
   1.361 +  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
   1.362 +         "rm "+plot_name+"."+plot_type)
   1.363 +
   1.364 +  delete (plot_data)
   1.365 +  delete (plot_data_0)    
   1.366 +;---------------------------------------------------------------------------
   1.367 +; values saved for zone table 
   1.368 +
   1.369 +  amp_ratio_zone = avg(amp_ratio_sta)
   1.370 +  ccr_zone       = avg(ccr_sta)
   1.371 +  M_zone         = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts) 
   1.372 +  score_zone     = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
   1.373 +
   1.374 +  text(z,0) = zone
   1.375 +  text(z,1) = sprintf("%.0f", npts)
   1.376 +  text(z,2) = sprintf("%.2f", amp_ratio_zone)
   1.377 +  text(z,3) = sprintf("%.2f", ccr_zone)
   1.378 +  text(z,4) = sprintf("%.2f", M_zone)
   1.379 +  text(z,5) = sprintf("%.2f", score_zone)
   1.380 +  text(z,6) = zone  
   1.381 +
   1.382 +;*******************************************************************
   1.383 +; html table -- station
   1.384 +;*******************************************************************
   1.385 +  output_html = "score+line_"+zone+".html"
   1.386 +
   1.387 +  header = (/"<HTML>" \
   1.388 +            ,"<HEAD>" \
   1.389 +            ,"<TITLE>CLAMP metrics</TITLE>" \
   1.390 +            ,"</HEAD>" \
   1.391 +            ,"<H1>Latitude Zone "+zone+": Model "+model_name+"</H1>" \
   1.392 +            /) 
   1.393 +  footer = "</HTML>"
   1.394 +
   1.395 +  table_header = (/ \
   1.396 +        "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
   1.397 +       ,"<tr>" \
   1.398 +       ,"   <th bgcolor=DDDDDD >Site Name</th>" \
   1.399 +       ,"   <th bgcolor=DDDDDD >Latitude</th>" \
   1.400 +       ,"   <th bgcolor=DDDDDD >Longitude</th>" \
   1.401 +       ,"   <th bgcolor=DDDDDD >model vs obs.<br>amplitude ratio</th>" \
   1.402 +       ,"   <th bgcolor=DDDDDD >Correlation Coef.</th>" \
   1.403 +       ,"   <th bgcolor=DDDDDD >M Score</th>" \
   1.404 +       ,"   <th bgcolor=DDDDDD >Combined Score</th>" \
   1.405 +       ,"</tr>" \
   1.406 +       /)
   1.407 +  table_footer = "</table>"
   1.408 +  row_header = "<tr>"
   1.409 +  row_footer = "</tr>"
   1.410 +
   1.411 +  lines = new(50000,string)
   1.412 +  nline = 0
   1.413 +
   1.414 +  set_line(lines,nline,header)
   1.415 +  set_line(lines,nline,table_header)
   1.416 +;-----------------------------------------------
   1.417 +; row of table
   1.418 +  
   1.419 +  do n = 0,npts-1
   1.420 +     set_line(lines,nline,row_header)
   1.421 +
   1.422 +     txt0 = sta(ind_z(n))
   1.423 +     txt1 = sprintf("%5.2f", (/lat(ind_z(n))/))
   1.424 +     txt2 = sprintf("%5.2f", (/lon(ind_z(n))/))
   1.425 +     txt3 = sprintf("%5.2f", (/amp_ratio_sta(n)/))
   1.426 +     txt4 = sprintf("%5.2f", (/ccr_sta(n)/))
   1.427 +     txt5 = sprintf("%5.2f", (/M_sta(n)/))
   1.428 +     txt6 = sprintf("%5.2f", (/score_sta(n)/))
   1.429 +
   1.430 +     set_line(lines,nline,"<th><a href="+txt0+".png>"+txt0+"</a></th>")
   1.431 +     set_line(lines,nline,"<th>"+txt1+"</th>")
   1.432 +     set_line(lines,nline,"<th>"+txt2+"</th>")
   1.433 +     set_line(lines,nline,"<th>"+txt3+"</th>")
   1.434 +     set_line(lines,nline,"<th>"+txt4+"</th>")
   1.435 +     set_line(lines,nline,"<th>"+txt5+"</th>")
   1.436 +     set_line(lines,nline,"<th>"+txt6+"</th>")
   1.437 +
   1.438 +     set_line(lines,nline,row_footer)
   1.439 +  end do
   1.440 +
   1.441 +; last row, summary
   1.442 +  set_line(lines,nline,row_header)
   1.443 +
   1.444 +  txt0 = "All_"+sprintf("%.0f", (/npts/))
   1.445 +  txt1 = "-"
   1.446 +  txt2 = "-"
   1.447 +  txt3 = sprintf("%5.2f", (/amp_ratio_zone/))
   1.448 +  txt4 = sprintf("%5.2f", (/ccr_zone/))
   1.449 +  txt5 = sprintf("%5.2f", (/M_zone/))
   1.450 +  txt6 = sprintf("%5.2f", (/score_zone/))
   1.451 +
   1.452 +  set_line(lines,nline,"<th><a href="+txt0+".png>"+txt0+"</a></th>")
   1.453 +  set_line(lines,nline,"<th>"+txt1+"</th>")
   1.454 +  set_line(lines,nline,"<th>"+txt2+"</th>")
   1.455 +  set_line(lines,nline,"<th>"+txt3+"</th>")
   1.456 +  set_line(lines,nline,"<th>"+txt4+"</th>")
   1.457 +  set_line(lines,nline,"<th>"+txt5+"</th>")
   1.458 +  set_line(lines,nline,"<th>"+txt6+"</th>")
   1.459 +
   1.460 +  set_line(lines,nline,row_footer)
   1.461 +;-----------------------------------------------
   1.462 +  set_line(lines,nline,table_footer)
   1.463 +  set_line(lines,nline,footer) 
   1.464 +
   1.465 +; Now write to an HTML file.
   1.466 +  idx = ind(.not.ismissing(lines))
   1.467 +  if(.not.any(ismissing(idx))) then
   1.468 +    asciiwrite(output_html,lines(idx))
   1.469 +  else
   1.470 +   print ("error?")
   1.471 +  end if
   1.472 +  delete (idx)
   1.473 +;-----------------------------------------------------------------
   1.474 +
   1.475 +  delete (ind_z)
   1.476 +  delete (amp_model)
   1.477 +  delete (amp_ob)
   1.478 +  delete (amp_ratio_sta)
   1.479 +  delete (ccr_sta)
   1.480 +  delete (M_sta)
   1.481 +  delete (score_sta)
   1.482 +end do
   1.483 +
   1.484 +;*******************************************************************
   1.485 +; html table -- zone
   1.486 +;*******************************************************************
   1.487 +  output_html = "score+line_vs_ob.html"
   1.488 +
   1.489 +  header = (/"<HTML>" \
   1.490 +            ,"<HEAD>" \
   1.491 +            ,"<TITLE>CLAMP metrics</TITLE>" \
   1.492 +            ,"</HEAD>" \
   1.493 +            ,"<H1>CO2 Seasonal Cycle Comparisons by Latitude Zone: Model "+model_name+"</H1>" \
   1.494 +            /) 
   1.495 +  footer = "</HTML>"
   1.496 +
   1.497 +  delete (table_header)
   1.498 +  table_header = (/ \
   1.499 +        "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
   1.500 +       ,"<tr>" \
   1.501 +       ,"   <th bgcolor=DDDDDD >Zone</th>" \
   1.502 +       ,"   <th bgcolor=DDDDDD >Number of Site</th>" \
   1.503 +       ,"   <th bgcolor=DDDDDD >model vs obs.<br>amplitide ratio</th>" \
   1.504 +       ,"   <th bgcolor=DDDDDD >Correlation Coef.</th>" \
   1.505 +       ,"   <th bgcolor=DDDDDD >M Score</th>" \
   1.506 +       ,"   <th bgcolor=DDDDDD >Combined Score</th>" \
   1.507 +       ,"   <th bgcolor=DDDDDD >Taylor diagram</th>" \
   1.508 +       ,"</tr>" \
   1.509 +       /)
   1.510 +  table_footer = "</table>"
   1.511 +  row_header = "<tr>"
   1.512 +  row_footer = "</tr>"
   1.513 +
   1.514 +  lines = new(50000,string)
   1.515 +  nline = 0
   1.516 +
   1.517 +  set_line(lines,nline,header)
   1.518 +  set_line(lines,nline,table_header)
   1.519 +;-----------------------------------------------
   1.520 +;row of table
   1.521 + 
   1.522 +  do n = 0,nrow_zone-1
   1.523 +     set_line(lines,nline,row_header)
   1.524 +
   1.525 +     set_line(lines,nline,"<th><a href=score+line_"+text(n,0)+".html>"+text(n,0)+"</th>")
   1.526 +     set_line(lines,nline,"<th>"+text(n,1)+"</th>")
   1.527 +     set_line(lines,nline,"<th>"+text(n,2)+"</th>")
   1.528 +     set_line(lines,nline,"<th>"+text(n,3)+"</th>")
   1.529 +     set_line(lines,nline,"<th>"+text(n,4)+"</th>")
   1.530 +     set_line(lines,nline,"<th>"+text(n,5)+"</th>")
   1.531 +     set_line(lines,nline,"<th><a href=taylor_diagram_"+text(n,6)+".png>Taylor_diagram</th>")
   1.532 +
   1.533 +     set_line(lines,nline,row_footer)
   1.534 +  end do
   1.535 +
   1.536 +; for the last row
   1.537 +
   1.538 +     txt0 = "All"
   1.539 +     txt1 = sum(stringtofloat(text(0:3,1))) 
   1.540 +     txt2 = "-"
   1.541 +     txt3 = "-"
   1.542 +     txt4 = "-"
   1.543 +     txt5 = sum(stringtofloat(text(0:3,5)))
   1.544 +     txt6 = "-"
   1.545 +
   1.546 +     set_line(lines,nline,row_header)
   1.547 +
   1.548 +     set_line(lines,nline,"<th>"+txt0+"</th>")
   1.549 +     set_line(lines,nline,"<th>"+txt1+"</th>")
   1.550 +     set_line(lines,nline,"<th>"+txt2+"</th>")
   1.551 +     set_line(lines,nline,"<th>"+txt3+"</th>")
   1.552 +     set_line(lines,nline,"<th>"+txt4+"</th>")
   1.553 +     set_line(lines,nline,"<th>"+txt5+"</th>")
   1.554 +     set_line(lines,nline,"<th>"+txt6+"</th>")
   1.555 +
   1.556 +     set_line(lines,nline,row_footer)
   1.557 +;-----------------------------------------------
   1.558 +  set_line(lines,nline,table_footer)
   1.559 +  set_line(lines,nline,footer) 
   1.560 +
   1.561 +; Now write to an HTML file.
   1.562 +  idx = ind(.not.ismissing(lines))
   1.563 +  if(.not.any(ismissing(idx))) then
   1.564 +    asciiwrite(output_html,lines(idx))
   1.565 +  else
   1.566 +   print ("error?")
   1.567 +  end if
   1.568 +  delete (idx)
   1.569 +;--------------------------------------------------------------------------
   1.570 + 
   1.571 +  M_co2 = txt5
   1.572 +
   1.573 +  if (isvar("compare")) then
   1.574 +
   1.575 +     system("sed -e '1,/M_co2/s/M_co2/"+M_co2+"/' "+html_name2+" > "+html_new2+";"+ \
   1.576 +            "mv -f "+html_new2+" "+html_name2)
   1.577 +  end if
   1.578 +
   1.579 +  system("sed s#M_co2#"+M_co2+"# "+html_name+" > "+html_new+";"+ \
   1.580 +         "mv -f "+html_new+" "+html_name)
   1.581 +
   1.582 +;***************************************************************************
   1.583 +; add total score and write to file
   1.584 +;***************************************************************************
   1.585 +  M_total = M_co2
   1.586 +
   1.587 +  asciiwrite("M_save.co2", M_total)
   1.588 + 
   1.589 +;***************************************************************************
   1.590 +; output plots
   1.591 +;***************************************************************************
   1.592 +  output_dir = model_name+"/co2"
   1.593 +
   1.594 +  system("mv *.png *.html " + output_dir)
   1.595 +;*************************************************************************** 
   1.596 +end