1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/ameriflux/15.plot.ncl Mon Jan 26 22:08:20 2009 -0500
1.3 @@ -0,0 +1,858 @@
1.4 +;************************************************************
1.5 +; find year_ob >= 4
1.6 +; add year_ob_i and year_ob_f
1.7 +; change long_name
1.8 +;************************************************************
1.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
1.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
1.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
1.12 +;************************************************************
1.13 +procedure set_line(lines:string,nline:integer,newlines:string)
1.14 +begin
1.15 +; add line to ascci/html file
1.16 +
1.17 + nnewlines = dimsizes(newlines)
1.18 + if(nline+nnewlines-1.ge.dimsizes(lines))
1.19 + print("set_line: bad index, not setting anything.")
1.20 + return
1.21 + end if
1.22 + lines(nline:nline+nnewlines-1) = newlines
1.23 +; print ("lines = " + lines(nline:nline+nnewlines-1))
1.24 + nline = nline + nnewlines
1.25 + return
1.26 +end
1.27 +;*************************************************************
1.28 +begin
1.29 +
1.30 + plot_type = "ps"
1.31 + plot_type_new = "png"
1.32 +
1.33 +; for 6 fields, 12-monthly
1.34 + nmon = 12
1.35 + nfield = 6
1.36 +
1.37 +;************************************************
1.38 +; read model data
1.39 +;************************************************
1.40 + model = "cn"
1.41 +; model = "casa"
1.42 +
1.43 + model_name = "i01.10" + model
1.44 +
1.45 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
1.46 + film = "lnd_T42.nc"
1.47 + fm = addfile(dirm+film,"r")
1.48 +
1.49 + xm = fm->lon
1.50 + ym = fm->lat
1.51 +;------------------------------------------------
1.52 + nlat = dimsizes(ym)
1.53 + nlon = dimsizes(xm)
1.54 +
1.55 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
1.56 +
1.57 +; change to unit of observed (u mol/m2/s)
1.58 +; Model_units [=] gC/m2/s
1.59 +; 12. = molecular weight of C
1.60 +; u mol = 1e-6 mol
1.61 + factor = 1e6 /12.
1.62 +
1.63 + ENERGY ="new"
1.64 +
1.65 +;************************************************
1.66 +; read data: observed
1.67 +;************************************************
1.68 +
1.69 + station = (/"ARM_Oklahoma" \
1.70 + ,"ARM_Oklahoma_burn" \
1.71 + ,"ARM_Oklahoma_control" \
1.72 + ,"Atqasuk" \
1.73 + ,"Audubon" \
1.74 + ,"AustinCary" \
1.75 + ,"Bartlett" \
1.76 + ,"Bondville" \
1.77 + ,"Brookings" \
1.78 + ,"Donaldson" \
1.79 + ,"Duke_Forest_Hardwoods" \
1.80 + ,"Duke_Forest_Open_Field" \
1.81 + ,"Duke_Forest_Pine" \
1.82 + ,"Fermi_Ag" \
1.83 + ,"Fermi_Prairie" \
1.84 + ,"Flagstaff_Managed" \
1.85 + ,"Flagstaff_Unmanaged" \
1.86 + ,"Flagstaff_Wildfire" \
1.87 + ,"FortPeck" \
1.88 + ,"FreemanRanch_mesquite" \
1.89 + ,"Goodwin_Creek" \
1.90 + ,"HarvardForest" \
1.91 + ,"HarvardForestHemlock" \
1.92 + ,"HowlandForestMain" \
1.93 + ,"HowlandForestWest" \
1.94 + ,"Ivotuk" \
1.95 + ,"KendallGrasslands" \
1.96 + ,"KennedySpaceCenterPine" \
1.97 + ,"KennedySpaceCenterScrub" \
1.98 + ,"LittleProspect" \
1.99 + ,"LostCreek" \
1.100 + ,"Mead-irrigated" \
1.101 + ,"Mead-irrigated-rotation" \
1.102 + ,"Mead-rainfed" \
1.103 + ,"Metolius_2nd_YoungPonderosaPine" \
1.104 + ,"MetoliusEyerly" \
1.105 + ,"MetoliusIntermediatePine" \
1.106 + ,"MetoliusOldPonderosaPine" \
1.107 + ,"MissouriOzark" \
1.108 + ,"Mize" \
1.109 + ,"MorganMonroe" \
1.110 + ,"NiwotRidge" \
1.111 + ,"NorthCarolina_cc" \
1.112 + ,"NorthCarolina_lp" \
1.113 + ,"ParkFalls" \
1.114 + ,"Rayonier" \
1.115 + ,"SantaRita" \
1.116 + ,"SkyOaks_Old" \
1.117 + ,"SkyOaks_PostFire" \
1.118 + ,"SkyOaks_Young" \
1.119 + ,"SylvaniaWilderness" \
1.120 + ,"Toledo" \
1.121 + ,"Tonzi" \
1.122 + ,"UCI_1850" \
1.123 + ,"UCI_1930" \
1.124 + ,"UCI_1964" \
1.125 + ,"UCI_1964wet" \
1.126 + ,"UCI_1981" \
1.127 + ,"UCI_1989" \
1.128 + ,"UCI_1998" \
1.129 + ,"UMBS" \
1.130 + ,"Vaira" \
1.131 + ,"WalkerBranch" \
1.132 + ,"WillowCreek" \
1.133 + ,"WindRiver" \
1.134 + ,"Wisconsin_ihw" \
1.135 + ,"Wisconsin_irp" \
1.136 + ,"Wisconsin_mrp" \
1.137 + ,"Wisconsin_myjp" \
1.138 + ,"Wisconsin_pb" \
1.139 + ,"Wisconsin_rpcc" \
1.140 + ,"Wisconsin_yhw" \
1.141 + ,"Wisconsin_yjp" \
1.142 + ,"Wisconsin_yrp" \
1.143 + /)
1.144 +
1.145 + year_ob = (/"2003-2006" \
1.146 + ,"2005-2006" \
1.147 + ,"2005-2006" \
1.148 + ,"1999-2006" \
1.149 + ,"2002-2006" \
1.150 + ,"2000-2005" \
1.151 + ,"2004-2005" \
1.152 + ,"1996-2006" \
1.153 + ,"2004-2006" \
1.154 + ,"1999-2004" \
1.155 + ,"2003-2005" \
1.156 + ,"2001-2005" \
1.157 + ,"2001-2005" \
1.158 + ,"2005-2006" \
1.159 + ,"2004-2006" \
1.160 + ,"2005-2006" \
1.161 + ,"2005-2006" \
1.162 + ,"2005-2006" \
1.163 + ,"2000-2006" \
1.164 + ,"2004-2006" \
1.165 + ,"2002-2006" \
1.166 + ,"1991-2004" \
1.167 + ,"2004-2004" \
1.168 + ,"1996-2004" \
1.169 + ,"1999-2004" \
1.170 + ,"2003-2006" \
1.171 + ,"2004-2006" \
1.172 + ,"2002-2002" \
1.173 + ,"2000-2006" \
1.174 + ,"2002-2005" \
1.175 + ,"2001-2005" \
1.176 + ,"2001-2005" \
1.177 + ,"2001-2005" \
1.178 + ,"2001-2005" \
1.179 + ,"2004-2005" \
1.180 + ,"2004-2005" \
1.181 + ,"2003-2005" \
1.182 + ,"1996-2000" \
1.183 + ,"2004-2006" \
1.184 + ,"1998-2004" \
1.185 + ,"1999-2005" \
1.186 + ,"1999-2003" \
1.187 + ,"2005-2006" \
1.188 + ,"2005-2006" \
1.189 + ,"1996-2003" \
1.190 + ,"1998-1998" \
1.191 + ,"2004-2006" \
1.192 + ,"1997-2006" \
1.193 + ,"2004-2006" \
1.194 + ,"1997-2006" \
1.195 + ,"2002-2006" \
1.196 + ,"2004-2005" \
1.197 + ,"2001-2006" \
1.198 + ,"2004-2005" \
1.199 + ,"2001-2005" \
1.200 + ,"2001-2005" \
1.201 + ,"2002-2004" \
1.202 + ,"2001-2005" \
1.203 + ,"2001-2005" \
1.204 + ,"2002-2005" \
1.205 + ,"1999-2003" \
1.206 + ,"2001-2006" \
1.207 + ,"1995-1999" \
1.208 + ,"1999-2005" \
1.209 + ,"1999-2004" \
1.210 + ,"2003-2003" \
1.211 + ,"2003-2003" \
1.212 + ,"2002-2005" \
1.213 + ,"2004-2004" \
1.214 + ,"2002-2002" \
1.215 + ,"2005-2005" \
1.216 + ,"2002-2002" \
1.217 + ,"2004-2005" \
1.218 + ,"2002-2002" \
1.219 + /)
1.220 +
1.221 + year_ob_i = (/2003 \
1.222 + ,2005 \
1.223 + ,2005 \
1.224 + ,1999 \
1.225 + ,2002 \
1.226 + ,2000 \
1.227 + ,2004 \
1.228 + ,1996 \
1.229 + ,2004 \
1.230 + ,1999 \
1.231 + ,2003 \
1.232 + ,2001 \
1.233 + ,2001 \
1.234 + ,2005 \
1.235 + ,2004 \
1.236 + ,2005 \
1.237 + ,2005 \
1.238 + ,2005 \
1.239 + ,2000 \
1.240 + ,2004 \
1.241 + ,2002 \
1.242 + ,1991 \
1.243 + ,2004 \
1.244 + ,1996 \
1.245 + ,1999 \
1.246 + ,2003 \
1.247 + ,2004 \
1.248 + ,2002 \
1.249 + ,2000 \
1.250 + ,2002 \
1.251 + ,2001 \
1.252 + ,2001 \
1.253 + ,2001 \
1.254 + ,2001 \
1.255 + ,2004 \
1.256 + ,2004 \
1.257 + ,2003 \
1.258 + ,1996 \
1.259 + ,2004 \
1.260 + ,1998 \
1.261 + ,1999 \
1.262 + ,1999 \
1.263 + ,2005 \
1.264 + ,2005 \
1.265 + ,1996 \
1.266 + ,1998 \
1.267 + ,2004 \
1.268 + ,1997 \
1.269 + ,2004 \
1.270 + ,1997 \
1.271 + ,2002 \
1.272 + ,2004 \
1.273 + ,2001 \
1.274 + ,2004 \
1.275 + ,2001 \
1.276 + ,2001 \
1.277 + ,2002 \
1.278 + ,2001 \
1.279 + ,2001 \
1.280 + ,2002 \
1.281 + ,1999 \
1.282 + ,2001 \
1.283 + ,1995 \
1.284 + ,1999 \
1.285 + ,1999 \
1.286 + ,2003 \
1.287 + ,2003 \
1.288 + ,2002 \
1.289 + ,2004 \
1.290 + ,2002 \
1.291 + ,2005 \
1.292 + ,2002 \
1.293 + ,2004 \
1.294 + ,2002 \
1.295 + /)
1.296 +
1.297 + year_ob_f = (/2006 \
1.298 + ,2006 \
1.299 + ,2006 \
1.300 + ,2006 \
1.301 + ,2006 \
1.302 + ,2005 \
1.303 + ,2005 \
1.304 + ,2006 \
1.305 + ,2006 \
1.306 + ,2004 \
1.307 + ,2005 \
1.308 + ,2005 \
1.309 + ,2005 \
1.310 + ,2006 \
1.311 + ,2006 \
1.312 + ,2006 \
1.313 + ,2006 \
1.314 + ,2006 \
1.315 + ,2006 \
1.316 + ,2006 \
1.317 + ,2006 \
1.318 + ,2004 \
1.319 + ,2004 \
1.320 + ,2004 \
1.321 + ,2004 \
1.322 + ,2006 \
1.323 + ,2006 \
1.324 + ,2002 \
1.325 + ,2006 \
1.326 + ,2005 \
1.327 + ,2005 \
1.328 + ,2005 \
1.329 + ,2005 \
1.330 + ,2005 \
1.331 + ,2005 \
1.332 + ,2005 \
1.333 + ,2005 \
1.334 + ,2000 \
1.335 + ,2006 \
1.336 + ,2004 \
1.337 + ,2005 \
1.338 + ,2003 \
1.339 + ,2006 \
1.340 + ,2006 \
1.341 + ,2003 \
1.342 + ,1998 \
1.343 + ,2006 \
1.344 + ,2006 \
1.345 + ,2006 \
1.346 + ,2006 \
1.347 + ,2006 \
1.348 + ,2005 \
1.349 + ,2006 \
1.350 + ,2005 \
1.351 + ,2005 \
1.352 + ,2005 \
1.353 + ,2004 \
1.354 + ,2005 \
1.355 + ,2005 \
1.356 + ,2005 \
1.357 + ,2003 \
1.358 + ,2006 \
1.359 + ,1999 \
1.360 + ,2005 \
1.361 + ,2004 \
1.362 + ,2003 \
1.363 + ,2003 \
1.364 + ,2005 \
1.365 + ,2004 \
1.366 + ,2002 \
1.367 + ,2005 \
1.368 + ,2002 \
1.369 + ,2005 \
1.370 + ,2002 \
1.371 + /)
1.372 +
1.373 + year_ob_long = ind((year_ob_f - year_ob_i) .ge. 4 .and. year_ob_i .le. 2001)
1.374 + print (year_ob_long)
1.375 + print (year_ob_i(year_ob_long))
1.376 +
1.377 +
1.378 + field = (/"NEE Flux" \
1.379 + ,"Net Radiation" \
1.380 + ,"Latent Heat" \
1.381 + ,"Sensible Heat" \
1.382 + ,"GPP Flux" \
1.383 + ,"Respiration" \
1.384 + /)
1.385 +
1.386 + field_unit = (/"u mol/m2/s" \
1.387 + ,"W/m2" \
1.388 + ,"W/m2" \
1.389 + ,"W/m2" \
1.390 + ,"u mol/m2/s" \
1.391 + ,"u mol/m2/s" \
1.392 + /)
1.393 +
1.394 +;nstation = dimsizes(station)
1.395 + nstation = dimsizes(year_ob_long)
1.396 +
1.397 + data_mod = new ((/nstation, nfield, nmon/),float)
1.398 + data_ob = new ((/nstation, nfield, nmon/),float)
1.399 + lat_ob = new ((/nstation/),float)
1.400 + lon_ob = new ((/nstation/),float)
1.401 + unit_ob = new ((/nfield/),string)
1.402 +
1.403 + diro_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
1.404 + dirm_root = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
1.405 +
1.406 + do n = 0,nstation-1
1.407 +
1.408 +;-------------------------------------------------
1.409 +; get ob data
1.410 +
1.411 +; nn = n
1.412 + nn = year_ob_long(n)
1.413 +
1.414 + diro = diro_root + station(nn)+"/"
1.415 + filo = year_ob_i(nn)+"-"+year_ob_f(nn)+"_L4_m.nc"
1.416 + fo = addfile (diro+filo,"r")
1.417 +
1.418 + print (filo)
1.419 +
1.420 + lon_ob(n) = fo->lon
1.421 + lat_ob(n) = fo->lat
1.422 +
1.423 + data = fo->NEE_or_fMDS
1.424 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
1.425 + delete (data)
1.426 +
1.427 + data = fo->Rg_f
1.428 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
1.429 + delete (data)
1.430 +
1.431 + data = fo->LE_f
1.432 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
1.433 + delete (data)
1.434 +
1.435 + data = fo->H_f
1.436 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
1.437 + delete (data)
1.438 +
1.439 + data = fo->GPP_or_MDS
1.440 + data_ob(n,4,:) = dim_avg(data(month|:,year|:))
1.441 + delete (data)
1.442 +
1.443 + data = fo->Reco_or
1.444 + data_ob(n,5,:) = dim_avg(data(month|:,year|:))
1.445 + delete (data)
1.446 +
1.447 + delete (fo)
1.448 +;---------------------------------------------------
1.449 +; get model data
1.450 +
1.451 +; film = model_name+"_"+ year_ob(n)+"_MONS_climo.nc"
1.452 + film = model_name+"_"+"1990-2004"+"_MONS_climo.nc"
1.453 + fm = addfile (dirm_root+film,"r")
1.454 +
1.455 +; print (film)
1.456 +
1.457 +if (ENERGY .eq. "old") then
1.458 +
1.459 + data = fm->NEE
1.460 + data_mod0(0,:,:,:) = data(:,:,:) * factor
1.461 + delete (data)
1.462 +
1.463 +; data = fm->LATENT
1.464 + data1 = fm->FCEV
1.465 + data2 = fm->FCTR
1.466 + data3 = fm->FGEV
1.467 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
1.468 + delete (data1)
1.469 + delete (data2)
1.470 + delete (data3)
1.471 +
1.472 +; data = fm->SENSIBLE
1.473 + data = fm->FSH
1.474 + data_mod0(3,:,:,:) = data(:,:,:)
1.475 + delete (data)
1.476 +
1.477 +; data = fm->NETRAD
1.478 + data1 = fm->FSA
1.479 + data2 = fm->FIRA
1.480 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)-data_mod0(2,:,:,:)-data_mod0(3,:,:,:)
1.481 + delete (data1)
1.482 + delete (data2)
1.483 +
1.484 +else
1.485 +
1.486 + data = fm->NEE
1.487 + data_mod0(0,:,:,:) = data(:,:,:) * factor
1.488 + delete (data)
1.489 +
1.490 + data = fm->NETRAD
1.491 + data_mod0(1,:,:,:) = data(:,:,:)
1.492 + delete (data)
1.493 +
1.494 + data = fm->LATENT
1.495 + data_mod0(2,:,:,:) = data(:,:,:)
1.496 + delete (data)
1.497 +
1.498 +; data = fm->SENSIBLE
1.499 + data = fm->FSH
1.500 + data_mod0(3,:,:,:) = data(:,:,:)
1.501 + delete (data)
1.502 +end if
1.503 +
1.504 + data = fm->GPP
1.505 + data_mod0(4,:,:,:) = data(:,:,:) * factor
1.506 + delete (data)
1.507 +
1.508 + if (model .eq. "cn") then
1.509 + data = fm->ER
1.510 + else
1.511 + data1 = fm->AR
1.512 + data2 = fm->HR
1.513 + data = data1 + data2
1.514 +
1.515 + delete (data1)
1.516 + delete (data2)
1.517 + end if
1.518 +
1.519 + data_mod0(5,:,:,:) = data(:,:,:) * factor
1.520 + delete (data)
1.521 +
1.522 + delete (fm)
1.523 +
1.524 +;************************************************************
1.525 +; interpolate model data into observed station
1.526 +; note: model is 0-360E, 90S-90N
1.527 +;************************************************************
1.528 +
1.529 +; to be able to handle observation at (-89.98,-24.80)
1.530 + ym(0) = -90.
1.531 +
1.532 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob(n),lat_ob(n),0)
1.533 +
1.534 +; print (yy)
1.535 +
1.536 + data_mod(n,:,:) = yy(:,:,0)
1.537 +
1.538 + delete (yy)
1.539 +
1.540 + end do
1.541 +;************************************************************
1.542 +; compute correlation coef and M score
1.543 +;************************************************************
1.544 +
1.545 + score_max = 5.
1.546 +
1.547 + ccr = new ((/nstation, nfield/),float)
1.548 + M_score = new ((/nstation, nfield/),float)
1.549 +
1.550 + do n=0,nstation-1
1.551 + do m=0,nfield-1
1.552 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
1.553 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
1.554 + M_score(n,m) = (1. -(bias/nmon)) * score_max
1.555 + end do
1.556 + end do
1.557 +
1.558 + M_co2 = avg(M_score(:,0))
1.559 + M_rad = avg(M_score(:,1))
1.560 + M_lh = avg(M_score(:,2))
1.561 + M_sh = avg(M_score(:,3))
1.562 + M_gpp = avg(M_score(:,4))
1.563 + M_er = avg(M_score(:,5))
1.564 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
1.565 +
1.566 + M_energy_co2 = sprintf("%.2f", M_co2)
1.567 + M_energy_rad = sprintf("%.2f", M_rad)
1.568 + M_energy_lh = sprintf("%.2f", M_lh )
1.569 + M_energy_sh = sprintf("%.2f", M_sh )
1.570 + M_energy_gpp = sprintf("%.2f", M_gpp)
1.571 + M_energy_er = sprintf("%.2f", M_er )
1.572 + M_energy_all = sprintf("%.2f", M_all)
1.573 +
1.574 +;*******************************************************************
1.575 +; for station line plot
1.576 +;*******************************************************************
1.577 +
1.578 +; for x-axis in xyplot
1.579 + mon = ispan(1,12,1)
1.580 + mon@long_name = "month"
1.581 +
1.582 + res = True ; plot mods desired
1.583 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
1.584 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
1.585 +;-------------------------------------------------------------------------
1.586 +; Add a boxed legend using the more simple method
1.587 +
1.588 + res@pmLegendDisplayMode = "Always"
1.589 +; res@pmLegendWidthF = 0.1
1.590 + res@pmLegendWidthF = 0.08
1.591 + res@pmLegendHeightF = 0.06
1.592 +; res@pmLegendOrthogonalPosF = -1.17
1.593 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
1.594 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
1.595 +
1.596 +; res@pmLegendParallelPosF = 0.18
1.597 + res@pmLegendParallelPosF = 0.23 ;(rightward)
1.598 +
1.599 +; res@lgPerimOn = False
1.600 + res@lgLabelFontHeightF = 0.015
1.601 + res@xyExplicitLegendLabels = (/"observed",model_name/)
1.602 +;-------------------------------------------------------------------
1.603 +; for panel plot
1.604 + res@gsnFrame = False ; Do not draw plot
1.605 + res@gsnDraw = False ; Do not advance frame
1.606 +
1.607 + pres = True ; panel plot mods desired
1.608 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
1.609 + ; indiv. plots in panel
1.610 + pres@gsnMaximize = True ; fill the page
1.611 +;-------------------------------------------------------------------
1.612 +
1.613 + plot_data = new((/2,12/),float)
1.614 + plot_data!0 = "case"
1.615 + plot_data!1 = "month"
1.616 +
1.617 + do n = 0,nstation-1
1.618 +
1.619 +; nn = n
1.620 + nn = year_ob_long(n)
1.621 +
1.622 +;----------------------------
1.623 +; for observed
1.624 +
1.625 + plot_name = station(nn)+"_ob"
1.626 + title = station(nn)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
1.627 + res@tiMainString = title
1.628 +
1.629 + wks = gsn_open_wks (plot_type,plot_name)
1.630 + plot=new(nfield,graphic) ; create graphic array
1.631 +
1.632 + do i = 0,nfield-1
1.633 + plot_data(0,:) = (/data_ob (n,i,:)/)
1.634 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
1.635 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
1.636 + end do
1.637 +
1.638 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
1.639 +
1.640 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
1.641 + "rm "+plot_name+"."+plot_type)
1.642 +
1.643 + clear (wks)
1.644 + delete (plot)
1.645 +;----------------------------
1.646 +; for model_vs_ob
1.647 +
1.648 + plot_name = station(nn)+"_model_vs_ob"
1.649 + title = station(nn)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
1.650 + res@tiMainString = title
1.651 +
1.652 + wks = gsn_open_wks (plot_type,plot_name)
1.653 + plot=new(nfield,graphic) ; create graphic array
1.654 +
1.655 + do i = 0,nfield-1
1.656 + plot_data(0,:) = (/data_ob (n,i,:)/)
1.657 + plot_data(1,:) = (/data_mod(n,i,:)/)
1.658 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
1.659 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
1.660 + end do
1.661 +
1.662 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
1.663 +
1.664 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
1.665 + "rm "+plot_name+"."+plot_type)
1.666 +
1.667 + clear (wks)
1.668 + delete (plot)
1.669 + end do
1.670 +
1.671 +;*******************************************************************
1.672 +; html table of site: observed
1.673 +;*******************************************************************
1.674 + output_html = "line_ob.html"
1.675 +
1.676 + header = (/"<HTML>" \
1.677 + ,"<HEAD>" \
1.678 + ,"<TITLE>CLAMP metrics</TITLE>" \
1.679 + ,"</HEAD>" \
1.680 + ,"<H1>Energy at Site: Observation</H1>" \
1.681 + /)
1.682 + footer = "</HTML>"
1.683 +
1.684 + table_header = (/ \
1.685 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
1.686 + ,"<tr>" \
1.687 + ," <th bgcolor=DDDDDD >Site Name</th>" \
1.688 + ," <th bgcolor=DDDDDD >Latitude</th>" \
1.689 + ," <th bgcolor=DDDDDD >Longitude</th>" \
1.690 + ," <th bgcolor=DDDDDD >Observed</th>" \
1.691 + ,"</tr>" \
1.692 + /)
1.693 + table_footer = "</table>"
1.694 + row_header = "<tr>"
1.695 + row_footer = "</tr>"
1.696 +
1.697 + lines = new(50000,string)
1.698 + nline = 0
1.699 +
1.700 + set_line(lines,nline,header)
1.701 + set_line(lines,nline,table_header)
1.702 +;-----------------------------------------------
1.703 +; row of table
1.704 +
1.705 + do n = 0,nstation-1
1.706 +
1.707 +; nn = n
1.708 + nn = year_ob_long(n)
1.709 +
1.710 + set_line(lines,nline,row_header)
1.711 +
1.712 + txt0 = station(nn)
1.713 + txt1 = sprintf("%5.2f", lat_ob(n))
1.714 + txt2 = sprintf("%5.2f", lon_ob(n))
1.715 + txt3 = year_ob(nn)
1.716 +
1.717 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
1.718 + set_line(lines,nline,"<th>"+txt1+"</th>")
1.719 + set_line(lines,nline,"<th>"+txt2+"</th>")
1.720 + set_line(lines,nline,"<th>"+txt3+"</th>")
1.721 +
1.722 + set_line(lines,nline,row_footer)
1.723 + end do
1.724 +;-----------------------------------------------
1.725 + set_line(lines,nline,table_footer)
1.726 + set_line(lines,nline,footer)
1.727 +
1.728 +; Now write to an HTML file.
1.729 + idx = ind(.not.ismissing(lines))
1.730 + if(.not.any(ismissing(idx))) then
1.731 + asciiwrite(output_html,lines(idx))
1.732 + else
1.733 + print ("error?")
1.734 + end if
1.735 + delete (idx)
1.736 +
1.737 +;*******************************************************************
1.738 +; score and line table : model vs observed
1.739 +;*******************************************************************
1.740 + output_html = "score+line_vs_ob.html"
1.741 +
1.742 + header = (/"<HTML>" \
1.743 + ,"<HEAD>" \
1.744 + ,"<TITLE>CLAMP metrics</TITLE>" \
1.745 + ,"</HEAD>" \
1.746 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
1.747 + /)
1.748 + footer = "</HTML>"
1.749 +
1.750 + delete (table_header)
1.751 + table_header = (/ \
1.752 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
1.753 + ,"<tr>" \
1.754 + ," <th bgcolor=DDDDDD >Site Name</th>" \
1.755 + ," <th bgcolor=DDDDDD >Latitude</th>" \
1.756 + ," <th bgcolor=DDDDDD >Longitude</th>" \
1.757 + ," <th bgcolor=DDDDDD >Observed</th>" \
1.758 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
1.759 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
1.760 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
1.761 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
1.762 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
1.763 + ," <th bgcolor=DDDDDD >Respiration</th>" \
1.764 + ," <th bgcolor=DDDDDD >Average</th>" \
1.765 + ,"</tr>" \
1.766 + /)
1.767 + table_footer = "</table>"
1.768 + row_header = "<tr>"
1.769 + row_footer = "</tr>"
1.770 +
1.771 + lines = new(50000,string)
1.772 + nline = 0
1.773 +
1.774 + set_line(lines,nline,header)
1.775 + set_line(lines,nline,table_header)
1.776 +;-----------------------------------------------
1.777 +; row of table
1.778 +
1.779 + do n = 0,nstation-1
1.780 +
1.781 +; nn = n
1.782 + nn = year_ob_long(n)
1.783 +
1.784 + set_line(lines,nline,row_header)
1.785 +
1.786 + txt0 = station(nn)
1.787 + txt1 = sprintf("%5.2f", lat_ob(n))
1.788 + txt2 = sprintf("%5.2f", lon_ob(n))
1.789 + txt3 = year_ob(nn)
1.790 + txt4 = sprintf("%5.2f", M_score(n,0))
1.791 + txt5 = sprintf("%5.2f", M_score(n,1))
1.792 + txt6 = sprintf("%5.2f", M_score(n,2))
1.793 + txt7 = sprintf("%5.2f", M_score(n,3))
1.794 + txt8 = sprintf("%5.2f", M_score(n,4))
1.795 + txt9 = sprintf("%5.2f", M_score(n,5))
1.796 + txt10 = sprintf("%5.2f", avg(M_score(n,:)))
1.797 +
1.798 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
1.799 + set_line(lines,nline,"<th>"+txt1+"</th>")
1.800 + set_line(lines,nline,"<th>"+txt2+"</th>")
1.801 + set_line(lines,nline,"<th>"+txt3+"</th>")
1.802 + set_line(lines,nline,"<th>"+txt4+"</th>")
1.803 + set_line(lines,nline,"<th>"+txt5+"</th>")
1.804 + set_line(lines,nline,"<th>"+txt6+"</th>")
1.805 + set_line(lines,nline,"<th>"+txt7+"</th>")
1.806 + set_line(lines,nline,"<th>"+txt8+"</th>")
1.807 + set_line(lines,nline,"<th>"+txt9+"</th>")
1.808 + set_line(lines,nline,"<th>"+txt10+"</th>")
1.809 +
1.810 + set_line(lines,nline,row_footer)
1.811 + end do
1.812 +
1.813 +; last row, summary
1.814 + set_line(lines,nline,row_header)
1.815 +
1.816 + txt0 = "All_"+sprintf("%.0f", nstation)
1.817 + txt1 = "-"
1.818 + txt2 = "-"
1.819 + txt3 = "-"
1.820 + txt4 = M_energy_co2
1.821 + txt5 = M_energy_rad
1.822 + txt6 = M_energy_lh
1.823 + txt7 = M_energy_sh
1.824 + txt8 = M_energy_gpp
1.825 + txt9 = M_energy_er
1.826 + txt10 = M_energy_all
1.827 +
1.828 + set_line(lines,nline,"<th>"+txt0+"</th>")
1.829 + set_line(lines,nline,"<th>"+txt1+"</th>")
1.830 + set_line(lines,nline,"<th>"+txt2+"</th>")
1.831 + set_line(lines,nline,"<th>"+txt3+"</th>")
1.832 + set_line(lines,nline,"<th>"+txt4+"</th>")
1.833 + set_line(lines,nline,"<th>"+txt5+"</th>")
1.834 + set_line(lines,nline,"<th>"+txt6+"</th>")
1.835 + set_line(lines,nline,"<th>"+txt7+"</th>")
1.836 + set_line(lines,nline,"<th>"+txt8+"</th>")
1.837 + set_line(lines,nline,"<th>"+txt9+"</th>")
1.838 + set_line(lines,nline,"<th>"+txt10+"</th>")
1.839 +
1.840 + set_line(lines,nline,row_footer)
1.841 +;-----------------------------------------------
1.842 + set_line(lines,nline,table_footer)
1.843 + set_line(lines,nline,footer)
1.844 +
1.845 +; Now write to an HTML file.
1.846 + idx = ind(.not.ismissing(lines))
1.847 + if(.not.any(ismissing(idx))) then
1.848 + asciiwrite(output_html,lines(idx))
1.849 + else
1.850 + print ("error?")
1.851 + end if
1.852 + delete (idx)
1.853 +
1.854 +;***************************************************************************
1.855 +; output plots
1.856 +;***************************************************************************
1.857 + output_dir = model_name+"/ameriflux"
1.858 +
1.859 + system("mv *.png *.html " + output_dir)
1.860 +;***************************************************************************
1.861 +end