Modifications to scoring and graphics production for the final version of code for the C-LAMP paper in GCB.
1 ;************************************************************
2 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
3 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
4 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
5 ;************************************************************
6 procedure set_line(lines:string,nline:integer,newlines:string)
8 ; add line to ascci/html file
10 nnewlines = dimsizes(newlines)
11 if(nline+nnewlines-1.ge.dimsizes(lines))
12 print("set_line: bad index, not setting anything.")
15 lines(nline:nline+nnewlines-1) = newlines
16 ; print ("lines = " + lines(nline:nline+nnewlines-1))
17 nline = nline + nnewlines
20 ;*************************************************************
26 ;------------------------------------------------------
27 ; edit table.html of current model for movel1_vs_model2
29 if (isvar("compare")) then
30 html_name2 = compare+"/table.html"
31 html_new2 = html_name2 +".new"
34 ;------------------------------------------------------
35 ; edit table.html for current model
37 html_name = model_name+"/table.html"
38 html_new = html_name +".new"
40 ;------------------------------------------------------
44 ; for nee, gpp, and ar
45 ; observed unit is gC/m2/day
46 ; model unit is gC/m2/s
47 ; to change to observed unit,
51 ; for incident solar radiation,
52 ; observed Rg_f unit is MJ/m2/day
53 ; model (FSDS) unit is W/m2
54 ; to change to model unit,
56 factor_rad = 1.e6/86400.
58 ;************************************************
60 ;************************************************
62 station = (/"ARM_Oklahoma" \
63 ,"ARM_Oklahoma_burn" \
64 ,"ARM_Oklahoma_control" \
72 ,"Duke_Forest_Hardwoods" \
73 ,"Duke_Forest_Open_Field" \
77 ,"Flagstaff_Managed" \
78 ,"Flagstaff_Unmanaged" \
79 ,"Flagstaff_Wildfire" \
81 ,"FreemanRanch_mesquite" \
84 ,"HarvardForestHemlock" \
85 ,"HowlandForestMain" \
86 ,"HowlandForestWest" \
88 ,"KendallGrasslands" \
89 ,"KennedySpaceCenterPine" \
90 ,"KennedySpaceCenterScrub" \
94 ,"Mead-irrigated-rotation" \
96 ,"Metolius_2nd_YoungPonderosaPine" \
98 ,"MetoliusIntermediatePine" \
99 ,"MetoliusOldPonderosaPine" \
104 ,"NorthCarolina_cc" \
105 ,"NorthCarolina_lp" \
110 ,"SkyOaks_PostFire" \
112 ,"SylvaniaWilderness" \
138 field = (/"NEE Flux" \
139 ,"Shortwave Incoming" \
146 field_unit = (/"gC/m2/day" \
154 nstation = dimsizes(station)
155 nfield = dimsizes(field)
157 ;========================================================================
158 ; get observed info: number of year, first/last year, lat, lon
161 dir_root = diro + "ameriflux/"
163 year_station = new ((/nstation/),integer) ; number of year
164 year_ob = new ((/nstation/),string) ; observed year
165 year_ob_i = new ((/nstation/),integer) ; first year
166 year_ob_f = new ((/nstation/),integer) ; last year
167 lat_ob = new ((/nstation/),float) ; latitude
168 lon_ob = new ((/nstation/),float) ; longitude
170 data_ob_ann = new ((/nfield, nmonth, nstation/),float)
174 dir_f = dir_root + station(n)+"/"
175 fil_f = "timeseries_L4_m.nc"
176 fo = addfile (dir_f+fil_f,"r")
183 year_station(n) = dimsizes(year)
184 year_ob_i(n) = year(0)
185 year_ob_f(n) = year(year_station(n)-1)
186 year_ob(n) = year_ob_i(n) + "-" + year_ob_f(n)
190 data = fo->NEE_or_fMDS
191 data_ob_ann(0,:,n) = dim_avg(data(month|:,year|:))
194 data_ob_ann(1,:,n) = dim_avg(data(month|:,year|:)) * factor_rad
197 data_ob_ann(2,:,n) = dim_avg(data(month|:,year|:))
200 data_ob_ann(3,:,n) = dim_avg(data(month|:,year|:))
202 data = fo->GPP_or_MDS
203 data_ob_ann(4,:,n) = dim_avg(data(month|:,year|:))
206 data_ob_ann(5,:,n) = dim_avg(data(month|:,year|:))
212 ;--------------------------------------------------------------
213 ; find (# of year observed) >=4 and year_ob_i <= 2001
215 i_long_ob = ind(year_station .ge. 4 .and. year_ob_i .le. 2001)
217 station_long = station(i_long_ob)
218 lat_ob_long = lat_ob(i_long_ob)
219 lon_ob_long = lat_ob(i_long_ob)
220 year_ob_long = year_ob(i_long_ob)
221 year_ob_i_long = year_ob_i(i_long_ob)
222 year_ob_f_long = year_ob_f(i_long_ob)
223 year_station_long = year_station(i_long_ob)
225 nstation_long = dimsizes(station_long)
227 ;=========================================================
228 ; get model data at observed lat-lon
230 fm = addfile (dirm+film8,"r")
236 date_dim = dimsizes(date)
239 data_mod = new ((/nfield,nyear,nmonth,nstation/),float)
240 data_mod_ann = new ((/nfield,nmonth,nstation/),float)
241 data_mod_long = new ((/nfield,nyear,nmonth,nstation_long/),float)
243 ; change to unit of observed (u mol/m2/s)
244 ; Model_units [=] gC/m2/s
245 ; 12. = molecular weight of C
250 ;------------------------------------------------------------
251 ; interpolate model data into observed station
252 ; note: model is 0-360E, 90S-90N
254 ; to be able to handle observation at (-89.98,-24.80)
256 ;------------------------------------------------------------
258 if (ENERGY .eq. "old") then
261 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
262 data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
263 data_mod(0,:,:,:) = yy(:,:,:) * factor_flux
268 ; data = data - data1
272 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
273 data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:))
274 data_mod(1,:,:,:) = yy(:,:,:)
281 data = data + data1 + data2
282 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
283 data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:))
284 data_mod(2,:,:,:) = yy(:,:,:)
288 ; data = fm->SENSIBLE
290 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
291 data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:))
292 data_mod(3,:,:,:) = yy(:,:,:)
297 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
298 data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
299 data_mod(0,:,:,:) = yy(:,:,:) * factor_flux
303 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
304 data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:))
305 data_mod(1,:,:,:) = yy(:,:,:)
308 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
309 data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:))
310 data_mod(2,:,:,:) = yy(:,:,:)
312 ; data = fm->SENSIBLE
314 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
315 data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:))
316 data_mod(3,:,:,:) = yy(:,:,:)
321 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
322 data_mod_ann(4,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
323 data_mod(4,:,:,:) = yy(:,:,:) * factor_flux
326 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
327 data_mod_ann(5,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
328 data_mod(5,:,:,:) = yy(:,:,:) * factor_flux
330 data_mod_long(:,:,:,:) = data_mod(:,:,:,i_long_ob)
337 asciiwrite(station(0)+"_ob.txt", data_ob_ann(:,:,0))
338 asciiwrite(station(0)+"_"+model_name+".txt", data_mod_ann(:,:,0))
340 asciiwrite(station(7)+"_ob.txt", data_ob_ann(:,:,7))
341 asciiwrite(station(7)+"_"+model_name+".txt", data_mod_ann(:,:,7))
343 asciiwrite(station(21)+"_ob.txt", data_ob_ann(:,:,21))
344 asciiwrite(station(21)+"_"+model_name+".txt", data_mod_ann(:,:,21))
346 asciiwrite(station(44)+"_ob.txt", data_ob_ann(:,:,44))
347 asciiwrite(station(44)+"_"+model_name+".txt", data_mod_ann(:,:,44))
349 asciiwrite(station(50)+"_ob.txt", data_ob_ann(:,:,50))
350 asciiwrite(station(50)+"_"+model_name+".txt", data_mod_ann(:,:,50))
352 asciiwrite(station(54)+"_ob.txt", data_ob_ann(:,:,54))
353 asciiwrite(station(54)+"_"+model_name+".txt", data_mod_ann(:,:,54))
355 asciiwrite(station(62)+"_ob.txt", data_ob_ann(:,:,62))
356 asciiwrite(station(62)+"_"+model_name+".txt", data_mod_ann(:,:,62))
359 ;*******************************************************************
360 ; for station line plot
361 ;*******************************************************************
363 ; for x-axis in xyplot
365 mon@long_name = "month"
367 res = True ; plot mods desired
368 res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
369 res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
371 res@tmXBFormat = "f" ; not to add trailing zeros
373 ;-------------------------------------------------------------------------
374 ; Add a boxed legend using the more simple method
376 res@pmLegendDisplayMode = "Always"
377 ; res@pmLegendWidthF = 0.1
378 res@pmLegendWidthF = 0.08
379 res@pmLegendHeightF = 0.06
380 ; res@pmLegendOrthogonalPosF = -1.17
381 ; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
382 res@pmLegendOrthogonalPosF = -0.30 ;(downward)
384 ; res@pmLegendParallelPosF = 0.18
385 res@pmLegendParallelPosF = 0.23 ;(rightward)
387 ; res@lgPerimOn = False
388 res@lgLabelFontHeightF = 0.015
389 res@xyExplicitLegendLabels = (/"observed",model_name/)
390 ;-------------------------------------------------------------------
392 res@gsnFrame = False ; Do not draw plot
393 res@gsnDraw = False ; Do not advance frame
395 pres = True ; panel plot mods desired
396 pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
397 ; indiv. plots in panel
398 pres@gsnMaximize = True ; fill the page
399 ;-------------------------------------------------------------------
401 ;==============================================================
402 ; get ob data at each site with long observation
404 do n = 0,nstation_long-1
406 ;##################################################################
407 ; hardwired: model up to year 2004
408 ; observed up to year 2006
412 nyear = year_station_long(n)
414 if (year_ob_f_long(n).eq. 2006) then
415 year_setback = 2006 -2004
417 if (year_ob_f_long(n).eq. 2005) then
418 year_setback = 2005 -2004
420 ;##################################################################
422 ntime = (nyear - year_setback) * nmonth
424 data_ob = new ((/nfield, nyear, nmonth/),float)
426 dir_f = dir_root + station_long(n)+"/"
427 fil_f = "timeseries_L4_m.nc"
428 fo = addfile (dir_f+fil_f,"r")
430 data_ob(0,:,:) = fo->NEE_or_fMDS
431 data_ob(1,:,:) = fo->Rg_f
432 data_ob(2,:,:) = fo->LE_f
433 data_ob(3,:,:) = fo->H_f
434 data_ob(4,:,:) = fo->GPP_or_MDS
435 data_ob(5,:,:) = fo->Reco_or
437 data_ob(1,:,:) = data_ob(1,:,:) * factor_rad
441 timeI = new((/ntime/),integer)
442 timeF = new((/ntime/),float)
443 timeI = ispan(1,ntime,1)
444 timeF = year_ob_i_long(n) + (timeI-1)/12.
445 timeF@long_name = "year"
447 plot_data = new((/2,ntime/),float)
449 ;----------------------------
452 plot_name = station_long(n)+"_tseries_vs_ob"
453 title = station_long(n)+"("+sprintf("%5.2f",lat_ob_long(n))+","+sprintf("%5.2f",lon_ob_long(n))+")"
454 res@tiMainString = title
456 wks = gsn_open_wks (plot_type,plot_name)
457 plot=new(nfield,graphic) ; create graphic array
459 i_year_mod_i = year_ob_i_long(n) - 1990
460 i_year_mod_f = i_year_mod_i + nyear - 1 - year_setback
462 i_year_ob_f = nyear - year_setback - 1
465 ; print (i_year_ob_f)
466 ; print (i_year_mod_i)
467 ; print (i_year_mod_f)
470 plot_data(0,:) = ndtooned(data_ob (i,0:i_year_ob_f,:))
471 plot_data(1,:) = ndtooned(data_mod_long(i,i_year_mod_i:i_year_mod_f,:,n))
472 plot_data@long_name = field(i)+" ("+field_unit(i)+")"
473 plot(i)=gsn_csm_xy(wks,timeF,plot_data,res) ; create plot
476 gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
478 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
479 "rm "+plot_name+"."+plot_type)
491 ;###################################################################
492 ; for the following tables,
493 ; sort by latitude in decending order (N->S)
495 isort = dim_pqsort(lat_ob_long,-1)
497 station_sort = station_long(isort)
498 year_ob_sort = year_ob_long(isort)
499 lat_ob_sort = lat_ob_long(isort)
500 lon_ob_sort = lon_ob_long(isort)
505 ;*******************************************************************
506 ; html table of site: observed
507 ;*******************************************************************
508 output_html = "tseries_vs_ob.html"
510 header = (/"<HTML>" \
512 ,"<TITLE>CLAMP metrics</TITLE>" \
514 ,"<H1>Timeseries at Site: "+model_name+" vs Observation</H1>" \
519 "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
521 ," <th bgcolor=DDDDDD >Site Name</th>" \
522 ," <th bgcolor=DDDDDD >Latitude</th>" \
523 ," <th bgcolor=DDDDDD >Longitude</th>" \
524 ," <th bgcolor=DDDDDD >Observed</th>" \
527 table_footer = "</table>"
531 lines = new(50000,string)
534 set_line(lines,nline,header)
535 set_line(lines,nline,table_header)
536 ;-----------------------------------------------
539 do n = 0,nstation_long-1
541 set_line(lines,nline,row_header)
543 txt0 = station_sort(n)
544 txt1 = sprintf("%5.2f", lat_ob_sort(n))
545 txt2 = sprintf("%5.2f", lon_ob_sort(n))
546 txt3 = year_ob_sort(n)
548 set_line(lines,nline,"<th><a href="+txt0+"_tseries_vs_ob.png>"+txt0+"</a></th>")
549 set_line(lines,nline,"<th>"+txt1+"</th>")
550 set_line(lines,nline,"<th>"+txt2+"</th>")
551 set_line(lines,nline,"<th>"+txt3+"</th>")
553 set_line(lines,nline,row_footer)
555 ;-----------------------------------------------
556 set_line(lines,nline,table_footer)
557 set_line(lines,nline,footer)
559 ; Now write to an HTML file.
560 idx = ind(.not.ismissing(lines))
561 if(.not.any(ismissing(idx))) then
562 asciiwrite(output_html,lines(idx))
569 delete (station_sort)
570 delete (year_ob_sort)
574 ;************************************************************
575 ; compute annual cycle correlation coef and M score
576 ;************************************************************
580 ccr = new ((/nstation, nfield/),float)
581 M_score = new ((/nstation, nfield/),float)
585 ccr(n,m) = esccr(data_ob_ann(m,:,n),data_mod_ann(m,:,n),0)
586 bias = sum(abs(data_mod_ann(m,:,n)-data_ob_ann(m,:,n))/(abs(data_mod_ann(m,:,n))+abs(data_ob_ann(m,:,n))))
587 M_score(n,m) = (1. -(bias/nmonth)) * score_max
591 M_nee = avg(M_score(:,0))
592 M_rad = avg(M_score(:,1))
593 M_lh = avg(M_score(:,2))
594 M_sh = avg(M_score(:,3))
595 M_gpp = avg(M_score(:,4))
596 M_er = avg(M_score(:,5))
597 M_all = M_nee+ M_rad +M_lh + M_sh + M_gpp + M_er
599 M_ameriflux_nee = sprintf("%.2f", M_nee)
600 M_ameriflux_rad = sprintf("%.2f", M_rad)
601 M_ameriflux_lh = sprintf("%.2f", M_lh )
602 M_ameriflux_sh = sprintf("%.2f", M_sh )
603 M_ameriflux_gpp = sprintf("%.2f", M_gpp)
604 M_ameriflux_er = sprintf("%.2f", M_er )
605 M_ameriflux_all = sprintf("%.2f", M_all)
607 ;*******************************************************************
608 ; for station line plot
609 ;*******************************************************************
611 ; for x-axis in xyplot
613 mon@long_name = "month"
615 ;-------------------------------------------------------------------
617 plot_data = new((/2,nmonth/),float)
619 plot_data!1 = "month"
622 ;----------------------------
625 plot_name = station(n)+"_ob"
626 title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
627 res@tiMainString = title
629 wks = gsn_open_wks (plot_type,plot_name)
630 plot=new(nfield,graphic) ; create graphic array
633 plot_data(0,:) = (/data_ob_ann(i,:,n)/)
634 plot_data@long_name = field(i)+" ("+field_unit(i)+")"
635 plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
638 gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
640 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
641 "rm "+plot_name+"."+plot_type)
645 ;----------------------------
648 plot_name = station(n)+"_model_vs_ob"
649 title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
650 res@tiMainString = title
652 wks = gsn_open_wks (plot_type,plot_name)
653 plot=new(nfield,graphic) ; create graphic array
656 plot_data(0,:) = (/data_ob_ann(i,:,n)/)
657 plot_data(1,:) = (/data_mod_ann(i,:,n)/)
658 plot_data@long_name = field(i)+" ("+field_unit(i)+")"
659 plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
662 gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
664 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
665 "rm "+plot_name+"."+plot_type)
671 ;###################################################################
672 ; for the following tables,
673 ; sort by latitude in decending order (N->S)
674 ; sort by lat in decending order (N->S)
676 isort = dim_pqsort(lat_ob,-1)
678 station_sort = station(isort)
679 year_ob_sort = year_ob(isort)
680 lat_ob_sort = lat_ob(isort)
681 lon_ob_sort = lon_ob(isort)
682 M_score_sort = M_score(isort,:)
686 ;###################################################################
687 ;*******************************************************************
688 ; html table of site: observed
689 ;*******************************************************************
690 output_html = "line_ob.html"
692 header = (/"<HTML>" \
694 ,"<TITLE>CLAMP metrics</TITLE>" \
696 ,"<H1>Energy at Site: Observation</H1>" \
701 "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
703 ," <th bgcolor=DDDDDD >Site Name</th>" \
704 ," <th bgcolor=DDDDDD >Latitude</th>" \
705 ," <th bgcolor=DDDDDD >Longitude</th>" \
706 ," <th bgcolor=DDDDDD >Observed</th>" \
709 table_footer = "</table>"
713 lines = new(50000,string)
716 set_line(lines,nline,header)
717 set_line(lines,nline,table_header)
718 ;-----------------------------------------------
722 set_line(lines,nline,row_header)
724 txt0 = station_sort(n)
725 txt1 = sprintf("%5.2f", lat_ob_sort(n))
726 txt2 = sprintf("%5.2f", lon_ob_sort(n))
727 txt3 = year_ob_sort(n)
729 set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
730 set_line(lines,nline,"<th>"+txt1+"</th>")
731 set_line(lines,nline,"<th>"+txt2+"</th>")
732 set_line(lines,nline,"<th>"+txt3+"</th>")
734 set_line(lines,nline,row_footer)
736 ;-----------------------------------------------
737 set_line(lines,nline,table_footer)
738 set_line(lines,nline,footer)
740 ; Now write to an HTML file.
741 idx = ind(.not.ismissing(lines))
742 if(.not.any(ismissing(idx))) then
743 asciiwrite(output_html,lines(idx))
749 ;*******************************************************************
750 ; score and line table : model vs observed
751 ;*******************************************************************
752 output_html = "score+line_vs_ob.html"
754 header = (/"<HTML>" \
756 ,"<TITLE>CLAMP metrics</TITLE>" \
758 ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
762 delete (table_header)
764 "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
766 ," <th bgcolor=DDDDDD >Site Name</th>" \
767 ," <th bgcolor=DDDDDD >Latitude</th>" \
768 ," <th bgcolor=DDDDDD >Longitude</th>" \
769 ," <th bgcolor=DDDDDD >Observed</th>" \
770 ," <th bgcolor=DDDDDD >NEE Flux</th>" \
771 ," <th bgcolor=DDDDDD >Shortwave <br> Incoming</th>" \
772 ," <th bgcolor=DDDDDD >Latent Heat</th>" \
773 ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
774 ," <th bgcolor=DDDDDD >GPP Flux</th>" \
775 ," <th bgcolor=DDDDDD >Respiration</th>" \
776 ," <th bgcolor=DDDDDD >Average</th>" \
779 table_footer = "</table>"
783 lines = new(50000,string)
786 set_line(lines,nline,header)
787 set_line(lines,nline,table_header)
788 ;-----------------------------------------------
792 set_line(lines,nline,row_header)
794 txt0 = station_sort(n)
795 txt1 = sprintf("%5.2f", lat_ob_sort(n))
796 txt2 = sprintf("%5.2f", lon_ob_sort(n))
797 txt3 = year_ob_sort(n)
798 txt4 = sprintf("%5.2f", M_score_sort(n,0))
799 txt5 = sprintf("%5.2f", M_score_sort(n,1))
800 txt6 = sprintf("%5.2f", M_score_sort(n,2))
801 txt7 = sprintf("%5.2f", M_score_sort(n,3))
802 txt8 = sprintf("%5.2f", M_score_sort(n,4))
803 txt9 = sprintf("%5.2f", M_score_sort(n,5))
804 txt10 = sprintf("%5.2f", avg(M_score_sort(n,:)))
806 set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
807 set_line(lines,nline,"<th>"+txt1+"</th>")
808 set_line(lines,nline,"<th>"+txt2+"</th>")
809 set_line(lines,nline,"<th>"+txt3+"</th>")
810 set_line(lines,nline,"<th>"+txt4+"</th>")
811 set_line(lines,nline,"<th>"+txt5+"</th>")
812 set_line(lines,nline,"<th>"+txt6+"</th>")
813 set_line(lines,nline,"<th>"+txt7+"</th>")
814 set_line(lines,nline,"<th>"+txt8+"</th>")
815 set_line(lines,nline,"<th>"+txt9+"</th>")
816 set_line(lines,nline,"<th>"+txt10+"</th>")
818 set_line(lines,nline,row_footer)
822 set_line(lines,nline,row_header)
824 txt0 = "All_"+sprintf("%.0f", nstation)
828 txt4 = M_ameriflux_nee
829 txt5 = M_ameriflux_rad
830 txt6 = M_ameriflux_lh
831 txt7 = M_ameriflux_sh
832 txt8 = M_ameriflux_gpp
833 txt9 = M_ameriflux_er
834 txt10 = M_ameriflux_all
836 set_line(lines,nline,"<th>"+txt0+"</th>")
837 set_line(lines,nline,"<th>"+txt1+"</th>")
838 set_line(lines,nline,"<th>"+txt2+"</th>")
839 set_line(lines,nline,"<th>"+txt3+"</th>")
840 set_line(lines,nline,"<th>"+txt4+"</th>")
841 set_line(lines,nline,"<th>"+txt5+"</th>")
842 set_line(lines,nline,"<th>"+txt6+"</th>")
843 set_line(lines,nline,"<th>"+txt7+"</th>")
844 set_line(lines,nline,"<th>"+txt8+"</th>")
845 set_line(lines,nline,"<th>"+txt9+"</th>")
846 set_line(lines,nline,"<th>"+txt10+"</th>")
848 set_line(lines,nline,row_footer)
849 ;-----------------------------------------------
850 set_line(lines,nline,table_footer)
851 set_line(lines,nline,footer)
853 ; Now write to an HTML file.
854 idx = ind(.not.ismissing(lines))
855 if(.not.any(ismissing(idx))) then
856 asciiwrite(output_html,lines(idx))
862 ;**************************************************************************************
864 ;**************************************************************************************
866 if (isvar("compare")) then
867 system("sed 1,/M_ameriflux_nee/s//"+M_ameriflux_nee+"/ "+html_name2+" > "+html_new2+";"+ \
868 "mv -f "+html_new2+" "+html_name2+";"+ \
869 "sed 1,/M_ameriflux_rad/s//"+M_ameriflux_rad+"/ "+html_name2+" > "+html_new2+";"+ \
870 "mv -f "+html_new2+" "+html_name2+";"+ \
871 "sed 1,/M_ameriflux_lh/s//"+M_ameriflux_lh+"/ "+html_name2+" > "+html_new2+";"+ \
872 "mv -f "+html_new2+" "+html_name2+";"+ \
873 "sed 1,/M_ameriflux_sh/s//"+M_ameriflux_sh+"/ "+html_name2+" > "+html_new2+";"+ \
874 "mv -f "+html_new2+" "+html_name2+";"+ \
875 "sed 1,/M_ameriflux_gpp/s//"+M_ameriflux_gpp+"/ "+html_name2+" > "+html_new2+";"+ \
876 "mv -f "+html_new2+" "+html_name2+";"+ \
877 "sed 1,/M_ameriflux_er/s//"+M_ameriflux_er+"/ "+html_name2+" > "+html_new2+";"+ \
878 "mv -f "+html_new2+" "+html_name2)
881 system("sed s#M_ameriflux_nee#"+M_ameriflux_nee+"# "+html_name+" > "+html_new+";"+ \
882 "mv -f "+html_new+" "+html_name+";"+ \
883 "sed s#M_ameriflux_rad#"+M_ameriflux_rad+"# "+html_name+" > "+html_new+";"+ \
884 "mv -f "+html_new+" "+html_name+";"+ \
885 "sed s#M_ameriflux_lh#"+M_ameriflux_lh+"# "+html_name+" > "+html_new+";"+ \
886 "mv -f "+html_new+" "+html_name+";"+ \
887 "sed s#M_ameriflux_sh#"+M_ameriflux_sh+"# "+html_name+" > "+html_new+";"+ \
888 "mv -f "+html_new+" "+html_name+";"+ \
889 "sed s#M_ameriflux_gpp#"+M_ameriflux_gpp+"# "+html_name+" > "+html_new+";"+ \
890 "mv -f "+html_new+" "+html_name+";"+ \
891 "sed s#M_ameriflux_er#"+M_ameriflux_er+"# "+html_name+" > "+html_new+";"+ \
892 "mv -f "+html_new+" "+html_name)
894 ;***************************************************************************
895 ; add total score and write to file
896 ;***************************************************************************
897 M_total = M_ameriflux_all
899 asciiwrite("M_save.ameriflux", M_total)
901 ;***************************************************************************
902 ; output plot and html
903 ;***************************************************************************
904 output_dir = model_name+"/ameriflux"
906 system("mv *.png *.html " + output_dir)
907 ;***************************************************************************