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