forrest@0
|
1 |
;************************************************************
|
forrest@0
|
2 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
|
forrest@0
|
3 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
|
forrest@0
|
4 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
|
forrest@0
|
5 |
;************************************************************
|
forrest@0
|
6 |
procedure set_line(lines:string,nline:integer,newlines:string)
|
forrest@0
|
7 |
begin
|
forrest@0
|
8 |
; add line to ascci/html file
|
forrest@0
|
9 |
|
forrest@0
|
10 |
nnewlines = dimsizes(newlines)
|
forrest@0
|
11 |
if(nline+nnewlines-1.ge.dimsizes(lines))
|
forrest@0
|
12 |
print("set_line: bad index, not setting anything.")
|
forrest@0
|
13 |
return
|
forrest@0
|
14 |
end if
|
forrest@0
|
15 |
lines(nline:nline+nnewlines-1) = newlines
|
forrest@0
|
16 |
; print ("lines = " + lines(nline:nline+nnewlines-1))
|
forrest@0
|
17 |
nline = nline + nnewlines
|
forrest@0
|
18 |
return
|
forrest@0
|
19 |
end
|
forrest@0
|
20 |
;*************************************************************
|
forrest@0
|
21 |
begin
|
forrest@0
|
22 |
|
forrest@0
|
23 |
plot_type = "ps"
|
forrest@0
|
24 |
plot_type_new = "png"
|
forrest@0
|
25 |
|
forrest@0
|
26 |
;------------------------------------------------------
|
forrest@0
|
27 |
; edit table.html of current model for movel1_vs_model2
|
forrest@0
|
28 |
|
forrest@0
|
29 |
if (isvar("compare")) then
|
forrest@0
|
30 |
html_name2 = compare+"/table.html"
|
forrest@0
|
31 |
html_new2 = html_name2 +".new"
|
forrest@0
|
32 |
end if
|
forrest@0
|
33 |
|
forrest@0
|
34 |
;------------------------------------------------------
|
forrest@0
|
35 |
; edit table.html for current model
|
forrest@0
|
36 |
|
forrest@0
|
37 |
html_name = model_name+"/table.html"
|
forrest@0
|
38 |
html_new = html_name +".new"
|
forrest@0
|
39 |
|
forrest@0
|
40 |
;------------------------------------------------------
|
forrest@0
|
41 |
; read model data
|
forrest@0
|
42 |
|
forrest@0
|
43 |
fm = addfile(dirm+film2,"r")
|
forrest@0
|
44 |
|
forrest@0
|
45 |
xm = fm->lon
|
forrest@0
|
46 |
ym = fm->lat
|
forrest@0
|
47 |
|
forrest@0
|
48 |
nlat = dimsizes(ym)
|
forrest@0
|
49 |
nlon = dimsizes(xm)
|
forrest@0
|
50 |
|
forrest@0
|
51 |
; for 4 fields, 12-monthly
|
forrest@0
|
52 |
nmon = 12
|
forrest@0
|
53 |
nfield = 4
|
forrest@0
|
54 |
|
forrest@0
|
55 |
data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
|
forrest@0
|
56 |
|
forrest@0
|
57 |
; change to unit of observed (u mol/m2/s)
|
forrest@0
|
58 |
; Model_units [=] gC/m2/s
|
forrest@0
|
59 |
; 12. = molecular weight of C
|
forrest@0
|
60 |
; u mol = 1e-6 mol
|
forrest@0
|
61 |
factor = 1e6 /12.
|
forrest@0
|
62 |
|
forrest@0
|
63 |
if (ENERGY .eq. "old") then
|
forrest@0
|
64 |
|
forrest@0
|
65 |
data = fm->NEE
|
forrest@0
|
66 |
data_mod0(0,:,:,:) = data(:,:,:) * factor
|
forrest@0
|
67 |
delete (data)
|
forrest@0
|
68 |
|
forrest@0
|
69 |
; data = fm->LATENT
|
forrest@0
|
70 |
data1 = fm->FCEV
|
forrest@0
|
71 |
data2 = fm->FCTR
|
forrest@0
|
72 |
data3 = fm->FGEV
|
forrest@0
|
73 |
data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
|
forrest@0
|
74 |
delete (data1)
|
forrest@0
|
75 |
delete (data2)
|
forrest@0
|
76 |
delete (data3)
|
forrest@0
|
77 |
|
forrest@0
|
78 |
; data = fm->SENSIBLE
|
forrest@0
|
79 |
data = fm->FSH
|
forrest@0
|
80 |
data_mod0(3,:,:,:) = data(:,:,:)
|
forrest@0
|
81 |
delete (data)
|
forrest@0
|
82 |
|
forrest@0
|
83 |
; data = fm->NETRAD
|
forrest@0
|
84 |
data1 = fm->FSA
|
forrest@0
|
85 |
data2 = fm->FIRA
|
forrest@0
|
86 |
data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)
|
forrest@0
|
87 |
delete (data1)
|
forrest@0
|
88 |
delete (data2)
|
forrest@0
|
89 |
|
forrest@0
|
90 |
else
|
forrest@0
|
91 |
|
forrest@0
|
92 |
data = fm->NEE
|
forrest@0
|
93 |
data_mod0(0,:,:,:) = data(:,:,:) * factor
|
forrest@0
|
94 |
delete (data)
|
forrest@0
|
95 |
|
forrest@0
|
96 |
data = fm->NETRAD
|
forrest@0
|
97 |
data_mod0(1,:,:,:) = data(:,:,:)
|
forrest@0
|
98 |
delete (data)
|
forrest@0
|
99 |
|
forrest@0
|
100 |
data = fm->LATENT
|
forrest@0
|
101 |
data_mod0(2,:,:,:) = data(:,:,:)
|
forrest@0
|
102 |
delete (data)
|
forrest@0
|
103 |
|
forrest@0
|
104 |
data = fm->FSH
|
forrest@0
|
105 |
data_mod0(3,:,:,:) = data(:,:,:)
|
forrest@0
|
106 |
delete (data)
|
forrest@0
|
107 |
end if
|
forrest@0
|
108 |
|
forrest@0
|
109 |
delete (fm)
|
forrest@0
|
110 |
|
forrest@0
|
111 |
;************************************************
|
forrest@0
|
112 |
; read data: observed
|
forrest@0
|
113 |
;************************************************
|
forrest@0
|
114 |
|
forrest@0
|
115 |
station = (/"BOREAS_NSA_OBS" \
|
forrest@0
|
116 |
,"CastelPorziano" \
|
forrest@0
|
117 |
,"Hyytiala" \
|
forrest@0
|
118 |
,"Kaamanen" \
|
forrest@0
|
119 |
,"LBA_Tapajos_KM67" \
|
forrest@0
|
120 |
,"Lethbridge" \
|
forrest@0
|
121 |
,"Tharandt" \
|
forrest@0
|
122 |
,"Vielsalm" \
|
forrest@0
|
123 |
/)
|
forrest@0
|
124 |
|
forrest@0
|
125 |
year_ob = (/"1994-2004" \
|
forrest@0
|
126 |
,"1997-2003" \
|
forrest@0
|
127 |
,"1996-2003" \
|
forrest@0
|
128 |
,"2000-2003" \
|
forrest@0
|
129 |
,"2002-2005" \
|
forrest@0
|
130 |
,"1999-2004" \
|
forrest@0
|
131 |
,"1996-2003" \
|
forrest@0
|
132 |
,"1998-2003" \
|
forrest@0
|
133 |
/)
|
forrest@0
|
134 |
|
forrest@0
|
135 |
field = (/"NEE" \
|
forrest@0
|
136 |
,"Net Radiation" \
|
forrest@0
|
137 |
,"Latent Heat" \
|
forrest@0
|
138 |
,"Sensible Heat" \
|
forrest@0
|
139 |
/)
|
forrest@0
|
140 |
|
forrest@0
|
141 |
nstation = dimsizes(station)
|
forrest@0
|
142 |
nmon = 12
|
forrest@0
|
143 |
nfield = dimsizes(field)
|
forrest@0
|
144 |
|
forrest@0
|
145 |
data_ob = new ((/nstation, nfield, nmon/),float)
|
forrest@0
|
146 |
lat_ob = new ((/nstation/),float)
|
forrest@0
|
147 |
lon_ob = new ((/nstation/),float)
|
forrest@0
|
148 |
|
forrest@0
|
149 |
diri_root = diro + "fluxnet/"
|
forrest@0
|
150 |
|
forrest@0
|
151 |
do n = 0,nstation-1
|
forrest@0
|
152 |
diri = diri_root + station(n)+"/"
|
forrest@0
|
153 |
fili = station(n)+"_"+year_ob(n)+"_monthly.nc"
|
forrest@0
|
154 |
g = addfile (diri+fili,"r")
|
forrest@0
|
155 |
|
forrest@0
|
156 |
lon_ob(n) = g->lon
|
forrest@0
|
157 |
lat_ob(n) = g->lat
|
forrest@0
|
158 |
|
forrest@0
|
159 |
data = g->CO2_FLUX
|
forrest@0
|
160 |
data_ob(n,0,:) = dim_avg(data(month|:,year|:))
|
forrest@0
|
161 |
delete (data)
|
forrest@0
|
162 |
|
forrest@0
|
163 |
data = g->RAD_FLUX
|
forrest@0
|
164 |
data_ob(n,1,:) = dim_avg(data(month|:,year|:))
|
forrest@0
|
165 |
delete (data)
|
forrest@0
|
166 |
|
forrest@0
|
167 |
data = g->LH_FLUX
|
forrest@0
|
168 |
data_ob(n,2,:) = dim_avg(data(month|:,year|:))
|
forrest@0
|
169 |
delete (data)
|
forrest@0
|
170 |
|
forrest@0
|
171 |
data = g->SH_FLUX
|
forrest@0
|
172 |
data_ob(n,3,:) = dim_avg(data(month|:,year|:))
|
forrest@0
|
173 |
delete (data)
|
forrest@0
|
174 |
|
forrest@0
|
175 |
delete (g)
|
forrest@0
|
176 |
end do
|
forrest@0
|
177 |
|
forrest@0
|
178 |
;************************************************************
|
forrest@0
|
179 |
; interpolate model data into observed station
|
forrest@0
|
180 |
; note: model is 0-360E, 90S-90N
|
forrest@0
|
181 |
;************************************************************
|
forrest@0
|
182 |
|
forrest@0
|
183 |
; to be able to handle observation at (-89.98,-24.80)
|
forrest@0
|
184 |
ym(0) = -90.
|
forrest@0
|
185 |
|
forrest@0
|
186 |
yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob,lat_ob,0)
|
forrest@0
|
187 |
|
forrest@0
|
188 |
delete (data_mod0)
|
forrest@0
|
189 |
yy!0 = "field"
|
forrest@0
|
190 |
data_mod = yy(pts|:,field|:,time|:)
|
forrest@0
|
191 |
|
forrest@0
|
192 |
;************************************************************
|
forrest@0
|
193 |
; compute correlation coef and M score
|
forrest@0
|
194 |
;************************************************************
|
forrest@0
|
195 |
|
forrest@0
|
196 |
score_max = 5.
|
forrest@0
|
197 |
|
forrest@0
|
198 |
ccr = new ((/nstation, nfield/),float)
|
forrest@0
|
199 |
M_score = new ((/nstation, nfield/),float)
|
forrest@0
|
200 |
|
forrest@0
|
201 |
do n=0,nstation-1
|
forrest@0
|
202 |
do m=0,nfield-1
|
forrest@0
|
203 |
ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
|
forrest@0
|
204 |
bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
|
forrest@0
|
205 |
M_score(n,m) = (1. -(bias/nmon)) * score_max
|
forrest@0
|
206 |
end do
|
forrest@0
|
207 |
end do
|
forrest@0
|
208 |
|
forrest@0
|
209 |
M_nee = avg(M_score(:,0))
|
forrest@0
|
210 |
M_rad = avg(M_score(:,1))
|
forrest@0
|
211 |
M_lh = avg(M_score(:,2))
|
forrest@0
|
212 |
M_sh = avg(M_score(:,3))
|
forrest@0
|
213 |
M_all = M_nee+ M_rad +M_lh + M_sh
|
forrest@0
|
214 |
|
forrest@0
|
215 |
M_fluxnet_nee = sprintf("%.2f", M_nee)
|
forrest@0
|
216 |
M_fluxnet_rad = sprintf("%.2f", M_rad)
|
forrest@0
|
217 |
M_fluxnet_lh = sprintf("%.2f", M_lh )
|
forrest@0
|
218 |
M_fluxnet_sh = sprintf("%.2f", M_sh )
|
forrest@0
|
219 |
M_fluxnet_all = sprintf("%.2f", M_all)
|
forrest@0
|
220 |
|
forrest@0
|
221 |
;*******************************************************************
|
forrest@0
|
222 |
; for station line plot
|
forrest@0
|
223 |
;*******************************************************************
|
forrest@0
|
224 |
|
forrest@0
|
225 |
; for x-axis in xyplot
|
forrest@0
|
226 |
mon = ispan(1,12,1)
|
forrest@0
|
227 |
mon@long_name = "month"
|
forrest@0
|
228 |
|
forrest@0
|
229 |
res = True ; plot mods desired
|
forrest@0
|
230 |
res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
|
forrest@0
|
231 |
res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
|
forrest@0
|
232 |
;-------------------------------------------------------------------------
|
forrest@0
|
233 |
; Add a boxed legend using the more simple method
|
forrest@0
|
234 |
|
forrest@0
|
235 |
res@pmLegendDisplayMode = "Always"
|
forrest@0
|
236 |
; res@pmLegendWidthF = 0.1
|
forrest@0
|
237 |
res@pmLegendWidthF = 0.08
|
forrest@0
|
238 |
res@pmLegendHeightF = 0.06
|
forrest@0
|
239 |
; res@pmLegendOrthogonalPosF = -1.17
|
forrest@0
|
240 |
; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
|
forrest@0
|
241 |
res@pmLegendOrthogonalPosF = -0.30 ;(downward)
|
forrest@0
|
242 |
|
forrest@0
|
243 |
; res@pmLegendParallelPosF = 0.18
|
forrest@0
|
244 |
res@pmLegendParallelPosF = 0.23 ;(rightward)
|
forrest@0
|
245 |
|
forrest@0
|
246 |
; res@lgPerimOn = False
|
forrest@0
|
247 |
res@lgLabelFontHeightF = 0.015
|
forrest@0
|
248 |
res@xyExplicitLegendLabels = (/"observed",model_name/)
|
forrest@0
|
249 |
;-------------------------------------------------------------------
|
forrest@0
|
250 |
; for panel plot
|
forrest@0
|
251 |
res@gsnFrame = False ; Do not draw plot
|
forrest@0
|
252 |
res@gsnDraw = False ; Do not advance frame
|
forrest@0
|
253 |
|
forrest@0
|
254 |
pres = True ; panel plot mods desired
|
forrest@0
|
255 |
pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
|
forrest@0
|
256 |
; indiv. plots in panel
|
forrest@0
|
257 |
pres@gsnMaximize = True ; fill the page
|
forrest@0
|
258 |
;-------------------------------------------------------------------
|
forrest@0
|
259 |
|
forrest@0
|
260 |
plot_data = new((/2,12/),float)
|
forrest@0
|
261 |
plot_data!0 = "case"
|
forrest@0
|
262 |
plot_data!1 = "month"
|
forrest@0
|
263 |
|
forrest@0
|
264 |
; change longitude from 0-360 to -180-180
|
forrest@0
|
265 |
lon_ob = where(lon_ob .gt. 180.,lon_ob-360., lon_ob)
|
forrest@0
|
266 |
|
forrest@0
|
267 |
do n = 0,nstation-1
|
forrest@0
|
268 |
;----------------------------
|
forrest@0
|
269 |
; for observed
|
forrest@0
|
270 |
|
forrest@0
|
271 |
plot_name = station(n)+"_ob"
|
forrest@0
|
272 |
title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
|
forrest@0
|
273 |
res@tiMainString = title
|
forrest@0
|
274 |
|
forrest@0
|
275 |
wks = gsn_open_wks (plot_type,plot_name)
|
forrest@0
|
276 |
plot=new(4,graphic) ; create graphic array
|
forrest@0
|
277 |
|
forrest@0
|
278 |
plot_data(0,:) = (/data_ob (n,0,:)/)
|
forrest@0
|
279 |
plot_data@long_name = field(0)
|
forrest@0
|
280 |
plot(0)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 1
|
forrest@0
|
281 |
|
forrest@0
|
282 |
plot_data(0,:) = (/data_ob (n,1,:)/)
|
forrest@0
|
283 |
plot_data@long_name = field(1)
|
forrest@0
|
284 |
plot(1)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 2
|
forrest@0
|
285 |
|
forrest@0
|
286 |
plot_data(0,:) = (/data_ob (n,2,:)/)
|
forrest@0
|
287 |
plot_data@long_name = field(2)
|
forrest@0
|
288 |
plot(2)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 3
|
forrest@0
|
289 |
|
forrest@0
|
290 |
plot_data(0,:) = (/data_ob (n,3,:)/)
|
forrest@0
|
291 |
plot_data@long_name = field(3)
|
forrest@0
|
292 |
plot(3)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 4
|
forrest@0
|
293 |
|
forrest@0
|
294 |
gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
|
forrest@0
|
295 |
|
forrest@0
|
296 |
delete (wks)
|
forrest@0
|
297 |
delete (plot)
|
forrest@0
|
298 |
|
forrest@0
|
299 |
system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
|
forrest@0
|
300 |
"rm "+plot_name+"."+plot_type)
|
forrest@0
|
301 |
|
forrest@0
|
302 |
;----------------------------
|
forrest@0
|
303 |
; for model_vs_ob
|
forrest@0
|
304 |
|
forrest@0
|
305 |
plot_name = station(n)+"_model_vs_ob"
|
forrest@0
|
306 |
title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
|
forrest@0
|
307 |
res@tiMainString = title
|
forrest@0
|
308 |
|
forrest@0
|
309 |
wks = gsn_open_wks (plot_type,plot_name)
|
forrest@0
|
310 |
plot=new(4,graphic) ; create graphic array
|
forrest@0
|
311 |
|
forrest@0
|
312 |
plot_data(0,:) = (/data_ob (n,0,:)/)
|
forrest@0
|
313 |
plot_data(1,:) = (/data_mod(n,0,:)/)
|
forrest@0
|
314 |
plot_data@long_name = field(0)
|
forrest@0
|
315 |
plot(0)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 1
|
forrest@0
|
316 |
|
forrest@0
|
317 |
plot_data(0,:) = (/data_ob (n,1,:)/)
|
forrest@0
|
318 |
plot_data(1,:) = (/data_mod(n,1,:)/)
|
forrest@0
|
319 |
plot_data@long_name = field(1)
|
forrest@0
|
320 |
plot(1)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 2
|
forrest@0
|
321 |
|
forrest@0
|
322 |
plot_data(0,:) = (/data_ob (n,2,:)/)
|
forrest@0
|
323 |
plot_data(1,:) = (/data_mod(n,2,:)/)
|
forrest@0
|
324 |
plot_data@long_name = field(2)
|
forrest@0
|
325 |
plot(2)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 3
|
forrest@0
|
326 |
|
forrest@0
|
327 |
plot_data(0,:) = (/data_ob (n,3,:)/)
|
forrest@0
|
328 |
plot_data(1,:) = (/data_mod(n,3,:)/)
|
forrest@0
|
329 |
plot_data@long_name = field(3)
|
forrest@0
|
330 |
plot(3)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 4
|
forrest@0
|
331 |
|
forrest@0
|
332 |
gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
|
forrest@0
|
333 |
|
forrest@0
|
334 |
delete (wks)
|
forrest@0
|
335 |
delete (plot)
|
forrest@0
|
336 |
|
forrest@0
|
337 |
system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
|
forrest@0
|
338 |
"rm "+plot_name+"."+plot_type)
|
forrest@0
|
339 |
end do
|
forrest@0
|
340 |
|
forrest@0
|
341 |
;*******************************************************************
|
forrest@0
|
342 |
; html table of site: observed
|
forrest@0
|
343 |
;*******************************************************************
|
forrest@0
|
344 |
output_html = "line_ob.html"
|
forrest@0
|
345 |
|
forrest@0
|
346 |
header = (/"<HTML>" \
|
forrest@0
|
347 |
,"<HEAD>" \
|
forrest@0
|
348 |
,"<TITLE>CLAMP metrics</TITLE>" \
|
forrest@0
|
349 |
,"</HEAD>" \
|
forrest@0
|
350 |
,"<H1>Fluxnet at Site: Observation</H1>" \
|
forrest@0
|
351 |
/)
|
forrest@0
|
352 |
footer = "</HTML>"
|
forrest@0
|
353 |
|
forrest@0
|
354 |
table_header = (/ \
|
forrest@0
|
355 |
"<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
|
forrest@0
|
356 |
,"<tr>" \
|
forrest@0
|
357 |
," <th bgcolor=DDDDDD >Site Name</th>" \
|
forrest@0
|
358 |
," <th bgcolor=DDDDDD >Latitude</th>" \
|
forrest@0
|
359 |
," <th bgcolor=DDDDDD >Longitude</th>" \
|
forrest@0
|
360 |
," <th bgcolor=DDDDDD >Observed</th>" \
|
forrest@0
|
361 |
,"</tr>" \
|
forrest@0
|
362 |
/)
|
forrest@0
|
363 |
table_footer = "</table>"
|
forrest@0
|
364 |
row_header = "<tr>"
|
forrest@0
|
365 |
row_footer = "</tr>"
|
forrest@0
|
366 |
|
forrest@0
|
367 |
lines = new(50000,string)
|
forrest@0
|
368 |
nline = 0
|
forrest@0
|
369 |
|
forrest@0
|
370 |
set_line(lines,nline,header)
|
forrest@0
|
371 |
set_line(lines,nline,table_header)
|
forrest@0
|
372 |
;-----------------------------------------------
|
forrest@0
|
373 |
; row of table
|
forrest@0
|
374 |
|
forrest@0
|
375 |
do n = 0,nstation-1
|
forrest@0
|
376 |
set_line(lines,nline,row_header)
|
forrest@0
|
377 |
|
forrest@0
|
378 |
txt0 = station(n)
|
forrest@0
|
379 |
txt1 = sprintf("%5.2f", lat_ob(n))
|
forrest@0
|
380 |
txt2 = sprintf("%5.2f", lon_ob(n))
|
forrest@0
|
381 |
txt3 = year_ob(n)
|
forrest@0
|
382 |
|
forrest@0
|
383 |
set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
|
forrest@0
|
384 |
set_line(lines,nline,"<th>"+txt1+"</th>")
|
forrest@0
|
385 |
set_line(lines,nline,"<th>"+txt2+"</th>")
|
forrest@0
|
386 |
set_line(lines,nline,"<th>"+txt3+"</th>")
|
forrest@0
|
387 |
|
forrest@0
|
388 |
set_line(lines,nline,row_footer)
|
forrest@0
|
389 |
end do
|
forrest@0
|
390 |
;-----------------------------------------------
|
forrest@0
|
391 |
set_line(lines,nline,table_footer)
|
forrest@0
|
392 |
set_line(lines,nline,footer)
|
forrest@0
|
393 |
|
forrest@0
|
394 |
; Now write to an HTML file.
|
forrest@0
|
395 |
idx = ind(.not.ismissing(lines))
|
forrest@0
|
396 |
if(.not.any(ismissing(idx))) then
|
forrest@0
|
397 |
asciiwrite(output_html,lines(idx))
|
forrest@0
|
398 |
else
|
forrest@0
|
399 |
print ("error?")
|
forrest@0
|
400 |
end if
|
forrest@0
|
401 |
delete (idx)
|
forrest@0
|
402 |
|
forrest@0
|
403 |
;*******************************************************************
|
forrest@0
|
404 |
; score and line table : model vs observed
|
forrest@0
|
405 |
;*******************************************************************
|
forrest@0
|
406 |
output_html = "score+line_vs_ob.html"
|
forrest@0
|
407 |
|
forrest@0
|
408 |
header = (/"<HTML>" \
|
forrest@0
|
409 |
,"<HEAD>" \
|
forrest@0
|
410 |
,"<TITLE>CLAMP metrics</TITLE>" \
|
forrest@0
|
411 |
,"</HEAD>" \
|
forrest@0
|
412 |
,"<H1>Fluxnet at Site: Model "+model_name+"</H1>" \
|
forrest@0
|
413 |
/)
|
forrest@0
|
414 |
footer = "</HTML>"
|
forrest@0
|
415 |
|
forrest@0
|
416 |
delete (table_header)
|
forrest@0
|
417 |
table_header = (/ \
|
forrest@0
|
418 |
"<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
|
forrest@0
|
419 |
,"<tr>" \
|
forrest@0
|
420 |
," <th bgcolor=DDDDDD >Site Name</th>" \
|
forrest@0
|
421 |
," <th bgcolor=DDDDDD >Latitude</th>" \
|
forrest@0
|
422 |
," <th bgcolor=DDDDDD >Longitude</th>" \
|
forrest@0
|
423 |
," <th bgcolor=DDDDDD >Observed</th>" \
|
forrest@0
|
424 |
," <th bgcolor=DDDDDD >NEE</th>" \
|
forrest@0
|
425 |
," <th bgcolor=DDDDDD >Net Radiation</th>" \
|
forrest@0
|
426 |
," <th bgcolor=DDDDDD >Latent Heat</th>" \
|
forrest@0
|
427 |
," <th bgcolor=DDDDDD >Sensible Heat</th>" \
|
forrest@0
|
428 |
," <th bgcolor=DDDDDD >Average</th>" \
|
forrest@0
|
429 |
,"</tr>" \
|
forrest@0
|
430 |
/)
|
forrest@0
|
431 |
table_footer = "</table>"
|
forrest@0
|
432 |
row_header = "<tr>"
|
forrest@0
|
433 |
row_footer = "</tr>"
|
forrest@0
|
434 |
|
forrest@0
|
435 |
lines = new(50000,string)
|
forrest@0
|
436 |
nline = 0
|
forrest@0
|
437 |
|
forrest@0
|
438 |
set_line(lines,nline,header)
|
forrest@0
|
439 |
set_line(lines,nline,table_header)
|
forrest@0
|
440 |
;-----------------------------------------------
|
forrest@0
|
441 |
; row of table
|
forrest@0
|
442 |
|
forrest@0
|
443 |
do n = 0,nstation-1
|
forrest@0
|
444 |
set_line(lines,nline,row_header)
|
forrest@0
|
445 |
|
forrest@0
|
446 |
txt0 = station(n)
|
forrest@0
|
447 |
txt1 = sprintf("%5.2f", lat_ob(n))
|
forrest@0
|
448 |
txt2 = sprintf("%5.2f", lon_ob(n))
|
forrest@0
|
449 |
txt3 = year_ob(n)
|
forrest@0
|
450 |
txt4 = sprintf("%5.2f", M_score(n,0))
|
forrest@0
|
451 |
txt5 = sprintf("%5.2f", M_score(n,1))
|
forrest@0
|
452 |
txt6 = sprintf("%5.2f", M_score(n,2))
|
forrest@0
|
453 |
txt7 = sprintf("%5.2f", M_score(n,3))
|
forrest@0
|
454 |
txt8 = sprintf("%5.2f", avg(M_score(n,:)))
|
forrest@0
|
455 |
|
forrest@0
|
456 |
set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
|
forrest@0
|
457 |
set_line(lines,nline,"<th>"+txt1+"</th>")
|
forrest@0
|
458 |
set_line(lines,nline,"<th>"+txt2+"</th>")
|
forrest@0
|
459 |
set_line(lines,nline,"<th>"+txt3+"</th>")
|
forrest@0
|
460 |
set_line(lines,nline,"<th>"+txt4+"</th>")
|
forrest@0
|
461 |
set_line(lines,nline,"<th>"+txt5+"</th>")
|
forrest@0
|
462 |
set_line(lines,nline,"<th>"+txt6+"</th>")
|
forrest@0
|
463 |
set_line(lines,nline,"<th>"+txt7+"</th>")
|
forrest@0
|
464 |
set_line(lines,nline,"<th>"+txt8+"</th>")
|
forrest@0
|
465 |
|
forrest@0
|
466 |
set_line(lines,nline,row_footer)
|
forrest@0
|
467 |
end do
|
forrest@0
|
468 |
|
forrest@0
|
469 |
; last row, summary
|
forrest@0
|
470 |
set_line(lines,nline,row_header)
|
forrest@0
|
471 |
|
forrest@0
|
472 |
txt0 = "All_"+sprintf("%.0f", nstation)
|
forrest@0
|
473 |
txt1 = "-"
|
forrest@0
|
474 |
txt2 = "-"
|
forrest@0
|
475 |
txt3 = "-"
|
forrest@0
|
476 |
txt4 = M_fluxnet_nee
|
forrest@0
|
477 |
txt5 = M_fluxnet_rad
|
forrest@0
|
478 |
txt6 = M_fluxnet_lh
|
forrest@0
|
479 |
txt7 = M_fluxnet_sh
|
forrest@0
|
480 |
txt8 = M_fluxnet_all
|
forrest@0
|
481 |
|
forrest@0
|
482 |
set_line(lines,nline,"<th>"+txt0+"</th>")
|
forrest@0
|
483 |
set_line(lines,nline,"<th>"+txt1+"</th>")
|
forrest@0
|
484 |
set_line(lines,nline,"<th>"+txt2+"</th>")
|
forrest@0
|
485 |
set_line(lines,nline,"<th>"+txt3+"</th>")
|
forrest@0
|
486 |
set_line(lines,nline,"<th>"+txt4+"</th>")
|
forrest@0
|
487 |
set_line(lines,nline,"<th>"+txt5+"</th>")
|
forrest@0
|
488 |
set_line(lines,nline,"<th>"+txt6+"</th>")
|
forrest@0
|
489 |
set_line(lines,nline,"<th>"+txt7+"</th>")
|
forrest@0
|
490 |
set_line(lines,nline,"<th>"+txt8+"</th>")
|
forrest@0
|
491 |
|
forrest@0
|
492 |
set_line(lines,nline,row_footer)
|
forrest@0
|
493 |
;-----------------------------------------------
|
forrest@0
|
494 |
set_line(lines,nline,table_footer)
|
forrest@0
|
495 |
set_line(lines,nline,footer)
|
forrest@0
|
496 |
|
forrest@0
|
497 |
; Now write to an HTML file.
|
forrest@0
|
498 |
idx = ind(.not.ismissing(lines))
|
forrest@0
|
499 |
if(.not.any(ismissing(idx))) then
|
forrest@0
|
500 |
asciiwrite(output_html,lines(idx))
|
forrest@0
|
501 |
else
|
forrest@0
|
502 |
print ("error?")
|
forrest@0
|
503 |
end if
|
forrest@0
|
504 |
delete (idx)
|
forrest@0
|
505 |
|
forrest@0
|
506 |
;**************************************************************************************
|
forrest@0
|
507 |
; update score
|
forrest@0
|
508 |
;**************************************************************************************
|
forrest@0
|
509 |
|
forrest@0
|
510 |
if (isvar("compare")) then
|
forrest@0
|
511 |
system("sed -e '1,/M_fluxnet_nee/s/M_fluxnet_nee/"+M_fluxnet_nee+"/' "+html_name2+" > "+html_new2+";"+ \
|
forrest@0
|
512 |
"mv -f "+html_new2+" "+html_name2+";"+ \
|
forrest@0
|
513 |
"sed -e '1,/M_fluxnet_rad/s/M_fluxnet_rad/"+M_fluxnet_rad+"/' "+html_name2+" > "+html_new2+";"+ \
|
forrest@0
|
514 |
"mv -f "+html_new2+" "+html_name2+";"+ \
|
forrest@0
|
515 |
"sed -e '1,/M_fluxnet_lh/s/M_fluxnet_lh/"+M_fluxnet_lh+"/' "+html_name2+" > "+html_new2+";"+ \
|
forrest@0
|
516 |
"mv -f "+html_new2+" "+html_name2+";"+ \
|
forrest@0
|
517 |
"sed -e '1,/M_fluxnet_sh/s/M_fluxnet_sh/"+M_fluxnet_sh+"/' "+html_name2+" > "+html_new2+";"+ \
|
forrest@0
|
518 |
"mv -f "+html_new2+" "+html_name2)
|
forrest@0
|
519 |
end if
|
forrest@0
|
520 |
|
forrest@0
|
521 |
system("sed s#M_fluxnet_nee#"+M_fluxnet_nee+"# "+html_name+" > "+html_new+";"+ \
|
forrest@0
|
522 |
"mv -f "+html_new+" "+html_name+";"+ \
|
forrest@0
|
523 |
"sed s#M_fluxnet_rad#"+M_fluxnet_rad+"# "+html_name+" > "+html_new+";"+ \
|
forrest@0
|
524 |
"mv -f "+html_new+" "+html_name+";"+ \
|
forrest@0
|
525 |
"sed s#M_fluxnet_lh#"+M_fluxnet_lh+"# "+html_name+" > "+html_new+";"+ \
|
forrest@0
|
526 |
"mv -f "+html_new+" "+html_name+";"+ \
|
forrest@0
|
527 |
"sed s#M_fluxnet_sh#"+M_fluxnet_sh+"# "+html_name+" > "+html_new+";"+ \
|
forrest@0
|
528 |
"mv -f "+html_new+" "+html_name)
|
forrest@0
|
529 |
|
forrest@0
|
530 |
;***************************************************************************
|
forrest@0
|
531 |
; add total score and write to file
|
forrest@0
|
532 |
;***************************************************************************
|
forrest@1
|
533 |
;M_total = M_fluxnet_all
|
forrest@1
|
534 |
M_total = 0.00 ; we don't actually use these scores
|
forrest@0
|
535 |
|
forrest@0
|
536 |
asciiwrite("M_save.fluxnet", M_total)
|
forrest@0
|
537 |
|
forrest@0
|
538 |
;***************************************************************************
|
forrest@0
|
539 |
; output plots
|
forrest@0
|
540 |
;***************************************************************************
|
forrest@0
|
541 |
output_dir = model_name+"/fluxnet"
|
forrest@0
|
542 |
|
forrest@0
|
543 |
system("mv *.png *.html " + output_dir)
|
forrest@0
|
544 |
;***************************************************************************
|
forrest@0
|
545 |
end
|