|
1 ;************************************************************ |
|
2 ; merge annual |
|
3 ; add table |
|
4 ; add time series plot |
|
5 ; sort by latitude in decending order (N->S) |
|
6 ; find year_ob >= 4 |
|
7 ; add year_ob_i and year_ob_f |
|
8 ; change long_name |
|
9 ;************************************************************ |
|
10 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" |
|
11 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" |
|
12 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" |
|
13 ;************************************************************ |
|
14 procedure set_line(lines:string,nline:integer,newlines:string) |
|
15 begin |
|
16 ; add line to ascci/html file |
|
17 |
|
18 nnewlines = dimsizes(newlines) |
|
19 if(nline+nnewlines-1.ge.dimsizes(lines)) |
|
20 print("set_line: bad index, not setting anything.") |
|
21 return |
|
22 end if |
|
23 lines(nline:nline+nnewlines-1) = newlines |
|
24 ; print ("lines = " + lines(nline:nline+nnewlines-1)) |
|
25 nline = nline + nnewlines |
|
26 return |
|
27 end |
|
28 ;************************************************************* |
|
29 begin |
|
30 |
|
31 plot_type = "ps" |
|
32 plot_type_new = "png" |
|
33 |
|
34 ;************************************************ |
|
35 ; model data info |
|
36 ;************************************************ |
|
37 model = "cn" |
|
38 ; model = "casa" |
|
39 |
|
40 model_name = "i01.10" + model |
|
41 |
|
42 ENERGY ="new" |
|
43 |
|
44 nmonth = 12 |
|
45 |
|
46 ;************************************************ |
|
47 ; observed data info |
|
48 ;************************************************ |
|
49 |
|
50 station = (/"ARM_Oklahoma" \ |
|
51 ,"ARM_Oklahoma_burn" \ |
|
52 ,"ARM_Oklahoma_control" \ |
|
53 ,"Atqasuk" \ |
|
54 ,"Audubon" \ |
|
55 ,"AustinCary" \ |
|
56 ,"Bartlett" \ |
|
57 ,"Bondville" \ |
|
58 ,"Brookings" \ |
|
59 ,"Donaldson" \ |
|
60 ,"Duke_Forest_Hardwoods" \ |
|
61 ,"Duke_Forest_Open_Field" \ |
|
62 ,"Duke_Forest_Pine" \ |
|
63 ,"Fermi_Ag" \ |
|
64 ,"Fermi_Prairie" \ |
|
65 ,"Flagstaff_Managed" \ |
|
66 ,"Flagstaff_Unmanaged" \ |
|
67 ,"Flagstaff_Wildfire" \ |
|
68 ,"FortPeck" \ |
|
69 ,"FreemanRanch_mesquite" \ |
|
70 ,"Goodwin_Creek" \ |
|
71 ,"HarvardForest" \ |
|
72 ,"HarvardForestHemlock" \ |
|
73 ,"HowlandForestMain" \ |
|
74 ,"HowlandForestWest" \ |
|
75 ,"Ivotuk" \ |
|
76 ,"KendallGrasslands" \ |
|
77 ,"KennedySpaceCenterPine" \ |
|
78 ,"KennedySpaceCenterScrub" \ |
|
79 ,"LittleProspect" \ |
|
80 ,"LostCreek" \ |
|
81 ,"Mead-irrigated" \ |
|
82 ,"Mead-irrigated-rotation" \ |
|
83 ,"Mead-rainfed" \ |
|
84 ,"Metolius_2nd_YoungPonderosaPine" \ |
|
85 ,"MetoliusEyerly" \ |
|
86 ,"MetoliusIntermediatePine" \ |
|
87 ,"MetoliusOldPonderosaPine" \ |
|
88 ,"MissouriOzark" \ |
|
89 ,"Mize" \ |
|
90 ,"MorganMonroe" \ |
|
91 ,"NiwotRidge" \ |
|
92 ,"NorthCarolina_cc" \ |
|
93 ,"NorthCarolina_lp" \ |
|
94 ,"ParkFalls" \ |
|
95 ,"Rayonier" \ |
|
96 ,"SantaRita" \ |
|
97 ,"SkyOaks_Old" \ |
|
98 ,"SkyOaks_PostFire" \ |
|
99 ,"SkyOaks_Young" \ |
|
100 ,"SylvaniaWilderness" \ |
|
101 ,"Toledo" \ |
|
102 ,"Tonzi" \ |
|
103 ,"UCI_1850" \ |
|
104 ,"UCI_1930" \ |
|
105 ,"UCI_1964" \ |
|
106 ,"UCI_1964wet" \ |
|
107 ,"UCI_1981" \ |
|
108 ,"UCI_1989" \ |
|
109 ,"UCI_1998" \ |
|
110 ,"UMBS" \ |
|
111 ,"Vaira" \ |
|
112 ,"WalkerBranch" \ |
|
113 ,"WillowCreek" \ |
|
114 ,"WindRiver" \ |
|
115 ,"Wisconsin_ihw" \ |
|
116 ,"Wisconsin_irp" \ |
|
117 ,"Wisconsin_mrp" \ |
|
118 ,"Wisconsin_myjp" \ |
|
119 ,"Wisconsin_pb" \ |
|
120 ,"Wisconsin_rpcc" \ |
|
121 ,"Wisconsin_yhw" \ |
|
122 ,"Wisconsin_yjp" \ |
|
123 ,"Wisconsin_yrp" \ |
|
124 /) |
|
125 |
|
126 year_ob = (/"2003-2006" \ |
|
127 ,"2005-2006" \ |
|
128 ,"2005-2006" \ |
|
129 ,"1999-2006" \ |
|
130 ,"2002-2006" \ |
|
131 ,"2000-2005" \ |
|
132 ,"2004-2005" \ |
|
133 ,"1996-2006" \ |
|
134 ,"2004-2006" \ |
|
135 ,"1999-2004" \ |
|
136 ,"2003-2005" \ |
|
137 ,"2001-2005" \ |
|
138 ,"2001-2005" \ |
|
139 ,"2005-2006" \ |
|
140 ,"2004-2006" \ |
|
141 ,"2005-2006" \ |
|
142 ,"2005-2006" \ |
|
143 ,"2005-2006" \ |
|
144 ,"2000-2006" \ |
|
145 ,"2004-2006" \ |
|
146 ,"2002-2006" \ |
|
147 ,"1991-2004" \ |
|
148 ,"2004-2004" \ |
|
149 ,"1996-2004" \ |
|
150 ,"1999-2004" \ |
|
151 ,"2003-2006" \ |
|
152 ,"2004-2006" \ |
|
153 ,"2002-2002" \ |
|
154 ,"2000-2006" \ |
|
155 ,"2002-2005" \ |
|
156 ,"2001-2005" \ |
|
157 ,"2001-2005" \ |
|
158 ,"2001-2005" \ |
|
159 ,"2001-2005" \ |
|
160 ,"2004-2005" \ |
|
161 ,"2004-2005" \ |
|
162 ,"2003-2005" \ |
|
163 ,"1996-2000" \ |
|
164 ,"2004-2006" \ |
|
165 ,"1998-2004" \ |
|
166 ,"1999-2005" \ |
|
167 ,"1999-2003" \ |
|
168 ,"2005-2006" \ |
|
169 ,"2005-2006" \ |
|
170 ,"1996-2003" \ |
|
171 ,"1998-1998" \ |
|
172 ,"2004-2006" \ |
|
173 ,"1997-2006" \ |
|
174 ,"2004-2006" \ |
|
175 ,"1997-2006" \ |
|
176 ,"2002-2006" \ |
|
177 ,"2004-2005" \ |
|
178 ,"2001-2006" \ |
|
179 ,"2004-2005" \ |
|
180 ,"2001-2005" \ |
|
181 ,"2001-2005" \ |
|
182 ,"2002-2004" \ |
|
183 ,"2001-2005" \ |
|
184 ,"2001-2005" \ |
|
185 ,"2002-2005" \ |
|
186 ,"1999-2003" \ |
|
187 ,"2001-2006" \ |
|
188 ,"1995-1999" \ |
|
189 ,"1999-2005" \ |
|
190 ,"1999-2004" \ |
|
191 ,"2003-2003" \ |
|
192 ,"2003-2003" \ |
|
193 ,"2002-2005" \ |
|
194 ,"2004-2004" \ |
|
195 ,"2002-2002" \ |
|
196 ,"2005-2005" \ |
|
197 ,"2002-2002" \ |
|
198 ,"2004-2005" \ |
|
199 ,"2002-2002" \ |
|
200 /) |
|
201 |
|
202 field = (/"NEE Flux" \ |
|
203 ,"Net Radiation" \ |
|
204 ,"Latent Heat" \ |
|
205 ,"Sensible Heat" \ |
|
206 ,"GPP Flux" \ |
|
207 ,"Respiration" \ |
|
208 /) |
|
209 |
|
210 field_unit = (/"u mol/m2/s" \ |
|
211 ,"W/m2" \ |
|
212 ,"W/m2" \ |
|
213 ,"W/m2" \ |
|
214 ,"u mol/m2/s" \ |
|
215 ,"u mol/m2/s" \ |
|
216 /) |
|
217 |
|
218 nstation = dimsizes(station) |
|
219 nfield = dimsizes(field) |
|
220 |
|
221 ;======================================================================== |
|
222 ; get observed info: number of year, first/last year, lat, lon |
|
223 ; and annual data |
|
224 |
|
225 dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/" |
|
226 |
|
227 year_station = new ((/nstation/),integer) ; number of year |
|
228 year_ob_i = new ((/nstation/),integer) ; first year |
|
229 year_ob_f = new ((/nstation/),integer) ; last year |
|
230 lat_ob = new ((/nstation/),float) ; latitude |
|
231 lon_ob = new ((/nstation/),float) ; longitude |
|
232 |
|
233 data_ob_ann = new ((/nfield, nmonth, nstation/),float) |
|
234 |
|
235 do n = 0, nstation-1 |
|
236 |
|
237 diro = dir_root + station(n)+"/" |
|
238 filo = year_ob(n)+"_L4_m.nc" |
|
239 fo = addfile (diro+filo,"r") |
|
240 |
|
241 lat_ob(n) = fo->lat |
|
242 lon_ob(n) = fo->lon |
|
243 |
|
244 year = fo->year |
|
245 |
|
246 year_station(n) = dimsizes(year) |
|
247 year_ob_i(n) = year(0) |
|
248 year_ob_f(n) = year(year_station(n)-1) |
|
249 |
|
250 delete (year) |
|
251 |
|
252 data = fo->NEE_or_fMDS |
|
253 data_ob_ann(0,:,n) = dim_avg(data(month|:,year|:)) |
|
254 |
|
255 data = fo->Rg_f |
|
256 data_ob_ann(1,:,n) = dim_avg(data(month|:,year|:)) |
|
257 |
|
258 data = fo->LE_f |
|
259 data_ob_ann(2,:,n) = dim_avg(data(month|:,year|:)) |
|
260 |
|
261 data = fo->H_f |
|
262 data_ob_ann(3,:,n) = dim_avg(data(month|:,year|:)) |
|
263 |
|
264 data = fo->GPP_or_MDS |
|
265 data_ob_ann(4,:,n) = dim_avg(data(month|:,year|:)) |
|
266 |
|
267 data = fo->Reco_or |
|
268 data_ob_ann(5,:,n) = dim_avg(data(month|:,year|:)) |
|
269 |
|
270 delete (data) |
|
271 delete (fo) |
|
272 end do |
|
273 |
|
274 ;print (year_ob_i) |
|
275 ;print (year_ob_f) |
|
276 |
|
277 ;-------------------------------------------------------------- |
|
278 ; find (# of year observed) >=4 and year_ob_i <= 2001 |
|
279 |
|
280 i_long_ob = ind(year_station .ge. 4 .and. year_ob_i .le. 2001) |
|
281 |
|
282 station_long = station(i_long_ob) |
|
283 lat_ob_long = lat_ob(i_long_ob) |
|
284 lon_ob_long = lat_ob(i_long_ob) |
|
285 year_ob_long = year_ob(i_long_ob) |
|
286 year_ob_i_long = year_ob_i(i_long_ob) |
|
287 year_ob_f_long = year_ob_f(i_long_ob) |
|
288 year_station_long = year_station(i_long_ob) |
|
289 |
|
290 nstation_long = dimsizes(station_long) |
|
291 |
|
292 ; print (i_long_ob) |
|
293 ; print (nstation_long) |
|
294 ; print (station_long) |
|
295 ; print (year_ob_i(i_long_ob)) |
|
296 |
|
297 ;========================================================= |
|
298 ; get model data at observed lat-lon |
|
299 |
|
300 dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/" |
|
301 film = model_name+"_ameriflux_1990-2004_monthly.nc" |
|
302 fm = addfile (dirm+film,"r") |
|
303 |
|
304 xm = fm->lon |
|
305 ym = fm->lat |
|
306 date = fm->date |
|
307 |
|
308 date_dim = dimsizes(date) |
|
309 nyear = date_dim(0) |
|
310 |
|
311 data_mod = new ((/nfield,nyear,nmonth,nstation/),float) |
|
312 data_mod_ann = new ((/nfield,nmonth,nstation/),float) |
|
313 data_mod_long = new ((/nfield,nyear,nmonth,nstation_long/),float) |
|
314 |
|
315 ; change to unit of observed (u mol/m2/s) |
|
316 ; Model_units [=] gC/m2/s |
|
317 ; 12. = molecular weight of C |
|
318 ; u mol = 1e-6 mol |
|
319 |
|
320 factor = 1.e6 /12. |
|
321 |
|
322 ;------------------------------------------------------------ |
|
323 ; interpolate model data into observed station |
|
324 ; note: model is 0-360E, 90S-90N |
|
325 |
|
326 ; to be able to handle observation at (-89.98,-24.80) |
|
327 ym(0) = -90. |
|
328 ;------------------------------------------------------------ |
|
329 |
|
330 if (ENERGY .eq. "old") then |
|
331 |
|
332 data = fm->NEE |
|
333 data_mod(0,:,:,:) = data(:,:,:) * factor |
|
334 |
|
335 ; data = fm->LATENT |
|
336 data1 = fm->FCEV |
|
337 data2 = fm->FCTR |
|
338 data3 = fm->FGEV |
|
339 data_mod(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:) |
|
340 delete (data1) |
|
341 delete (data2) |
|
342 delete (data3) |
|
343 |
|
344 ; data = fm->SENSIBLE |
|
345 data = fm->FSH |
|
346 data_mod(3,:,:,:) = data(:,:,:) |
|
347 |
|
348 ; data = fm->NETRAD |
|
349 data1 = fm->FSA |
|
350 data2 = fm->FIRA |
|
351 data_mod(1,:,:,:) = data1(:,:,:)-data2(:,:,:) |
|
352 delete (data1) |
|
353 delete (data2) |
|
354 |
|
355 else |
|
356 |
|
357 data = fm->NEE |
|
358 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0) |
|
359 data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor |
|
360 data_mod(0,:,:,:) = yy(:,:,:) * factor |
|
361 |
|
362 ; printVarSummary(yy) |
|
363 |
|
364 data = fm->NETRAD |
|
365 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0) |
|
366 data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:)) |
|
367 data_mod(1,:,:,:) = yy(:,:,:) |
|
368 |
|
369 data = fm->LATENT |
|
370 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0) |
|
371 data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:)) |
|
372 data_mod(2,:,:,:) = yy(:,:,:) |
|
373 |
|
374 ; data = fm->SENSIBLE |
|
375 data = fm->FSH |
|
376 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0) |
|
377 data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:)) |
|
378 data_mod(3,:,:,:) = yy(:,:,:) |
|
379 |
|
380 end if |
|
381 |
|
382 data = fm->GPP |
|
383 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0) |
|
384 data_mod_ann(4,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor |
|
385 data_mod(4,:,:,:) = yy(:,:,:) * factor |
|
386 |
|
387 if (model .eq. "cn") then |
|
388 data = fm->ER |
|
389 else |
|
390 data1 = fm->AR |
|
391 data2 = fm->HR |
|
392 data = data1 + data2 |
|
393 |
|
394 delete (data1) |
|
395 delete (data2) |
|
396 end if |
|
397 |
|
398 yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0) |
|
399 data_mod_ann(5,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor |
|
400 data_mod(5,:,:,:) = yy(:,:,:) * factor |
|
401 |
|
402 data_mod_long(:,:,:,:) = data_mod(:,:,:,i_long_ob) |
|
403 |
|
404 delete (data_mod) |
|
405 delete (fm) |
|
406 delete (data) |
|
407 delete (yy) |
|
408 |
|
409 ;******************************************************************* |
|
410 ; for station line plot |
|
411 ;******************************************************************* |
|
412 |
|
413 ; for x-axis in xyplot |
|
414 mon = ispan(1,12,1) |
|
415 mon@long_name = "month" |
|
416 |
|
417 res = True ; plot mods desired |
|
418 res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker |
|
419 res@xyLineColors = (/"blue","red"/) ; line color (ob,model) |
|
420 |
|
421 res@tmXBFormat = "f" ; not to add trailing zeros |
|
422 |
|
423 ;------------------------------------------------------------------------- |
|
424 ; Add a boxed legend using the more simple method |
|
425 |
|
426 res@pmLegendDisplayMode = "Always" |
|
427 ; res@pmLegendWidthF = 0.1 |
|
428 res@pmLegendWidthF = 0.08 |
|
429 res@pmLegendHeightF = 0.06 |
|
430 ; res@pmLegendOrthogonalPosF = -1.17 |
|
431 ; res@pmLegendOrthogonalPosF = -1.00 ;(downward) |
|
432 res@pmLegendOrthogonalPosF = -0.30 ;(downward) |
|
433 |
|
434 ; res@pmLegendParallelPosF = 0.18 |
|
435 res@pmLegendParallelPosF = 0.23 ;(rightward) |
|
436 |
|
437 ; res@lgPerimOn = False |
|
438 res@lgLabelFontHeightF = 0.015 |
|
439 res@xyExplicitLegendLabels = (/"observed",model_name/) |
|
440 ;------------------------------------------------------------------- |
|
441 ; for panel plot |
|
442 res@gsnFrame = False ; Do not draw plot |
|
443 res@gsnDraw = False ; Do not advance frame |
|
444 |
|
445 pres = True ; panel plot mods desired |
|
446 pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around |
|
447 ; indiv. plots in panel |
|
448 pres@gsnMaximize = True ; fill the page |
|
449 ;------------------------------------------------------------------- |
|
450 |
|
451 ;============================================================== |
|
452 ; get ob data at each site with long observation |
|
453 |
|
454 dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/" |
|
455 |
|
456 do n = 0,nstation_long-1 |
|
457 ; do n = 0,0 |
|
458 |
|
459 year_setback = 0 |
|
460 |
|
461 nyear = year_station_long(n) |
|
462 |
|
463 if (year_ob_f_long(n).eq. 2006) then |
|
464 year_setback = 2006 -2004 |
|
465 end if |
|
466 if (year_ob_f_long(n).eq. 2005) then |
|
467 year_setback = 2005 -2004 |
|
468 end if |
|
469 |
|
470 ntime = (nyear - year_setback) * nmonth |
|
471 |
|
472 data_ob = new ((/nfield, nyear, nmonth/),float) |
|
473 |
|
474 diro = dir_root + station_long(n)+"/" |
|
475 filo = year_ob_long(n)+"_L4_m.nc" |
|
476 fo = addfile (diro+filo,"r") |
|
477 |
|
478 ; print (diro) |
|
479 ; print (filo) |
|
480 |
|
481 data_ob(0,:,:) = fo->NEE_or_fMDS |
|
482 data_ob(1,:,:) = fo->Rg_f |
|
483 data_ob(2,:,:) = fo->LE_f |
|
484 data_ob(3,:,:) = fo->H_f |
|
485 data_ob(4,:,:) = fo->GPP_or_MDS |
|
486 data_ob(5,:,:) = fo->Reco_or |
|
487 |
|
488 delete (fo) |
|
489 |
|
490 timeI = new((/ntime/),integer) |
|
491 timeF = new((/ntime/),float) |
|
492 timeI = ispan(1,ntime,1) |
|
493 timeF = year_ob_i_long(n) + (timeI-1)/12. |
|
494 timeF@long_name = "year" |
|
495 |
|
496 plot_data = new((/2,ntime/),float) |
|
497 |
|
498 ;---------------------------- |
|
499 ; for model_vs_ob |
|
500 |
|
501 plot_name = station_long(n)+"_tseries_vs_ob" |
|
502 title = station_long(n)+"("+sprintf("%5.2f",lat_ob_long(n))+","+sprintf("%5.2f",lon_ob_long(n))+")" |
|
503 res@tiMainString = title |
|
504 |
|
505 wks = gsn_open_wks (plot_type,plot_name) |
|
506 plot=new(nfield,graphic) ; create graphic array |
|
507 |
|
508 i_year_mod_i = year_ob_i_long(n) - 1990 |
|
509 i_year_mod_f = i_year_mod_i + nyear - 1 - year_setback |
|
510 |
|
511 i_year_ob_f = nyear - year_setback - 1 |
|
512 |
|
513 ; print (nyear) |
|
514 ; print (i_year_ob_f) |
|
515 ; print (i_year_mod_i) |
|
516 ; print (i_year_mod_f) |
|
517 |
|
518 do i = 0,nfield-1 |
|
519 plot_data(0,:) = ndtooned(data_ob (i,0:i_year_ob_f,:)) |
|
520 plot_data(1,:) = ndtooned(data_mod_long(i,i_year_mod_i:i_year_mod_f,:,n)) |
|
521 plot_data@long_name = field(i)+" ("+field_unit(i)+")" |
|
522 plot(i)=gsn_csm_xy(wks,timeF,plot_data,res) ; create plot |
|
523 end do |
|
524 |
|
525 gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot |
|
526 |
|
527 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \ |
|
528 "rm "+plot_name+"."+plot_type) |
|
529 |
|
530 clear (wks) |
|
531 delete (plot) |
|
532 |
|
533 delete (data_ob) |
|
534 delete (timeI) |
|
535 delete (timeF) |
|
536 delete (plot_data) |
|
537 |
|
538 end do |
|
539 |
|
540 ;################################################################### |
|
541 ; for the following tables, |
|
542 ; sort by latitude in decending order (N->S) |
|
543 |
|
544 isort = dim_pqsort(lat_ob_long,-1) |
|
545 |
|
546 station_sort = station_long(isort) |
|
547 year_ob_sort = year_ob_long(isort) |
|
548 lat_ob_sort = lat_ob_long(isort) |
|
549 lon_ob_sort = lon_ob_long(isort) |
|
550 |
|
551 ; print(isort) |
|
552 ; print(lat_ob_sort) |
|
553 |
|
554 ;******************************************************************* |
|
555 ; html table of site: observed |
|
556 ;******************************************************************* |
|
557 output_html = "tseries_vs_ob.html" |
|
558 |
|
559 header = (/"<HTML>" \ |
|
560 ,"<HEAD>" \ |
|
561 ,"<TITLE>CLAMP metrics</TITLE>" \ |
|
562 ,"</HEAD>" \ |
|
563 ,"<H1>Timeseries at Site: "+model_name+" vs Observation</H1>" \ |
|
564 /) |
|
565 footer = "</HTML>" |
|
566 |
|
567 table_header = (/ \ |
|
568 "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \ |
|
569 ,"<tr>" \ |
|
570 ," <th bgcolor=DDDDDD >Site Name</th>" \ |
|
571 ," <th bgcolor=DDDDDD >Latitude</th>" \ |
|
572 ," <th bgcolor=DDDDDD >Longitude</th>" \ |
|
573 ," <th bgcolor=DDDDDD >Observed</th>" \ |
|
574 ,"</tr>" \ |
|
575 /) |
|
576 table_footer = "</table>" |
|
577 row_header = "<tr>" |
|
578 row_footer = "</tr>" |
|
579 |
|
580 lines = new(50000,string) |
|
581 nline = 0 |
|
582 |
|
583 set_line(lines,nline,header) |
|
584 set_line(lines,nline,table_header) |
|
585 ;----------------------------------------------- |
|
586 ; row of table |
|
587 |
|
588 do n = 0,nstation_long-1 |
|
589 |
|
590 set_line(lines,nline,row_header) |
|
591 |
|
592 txt0 = station_sort(n) |
|
593 txt1 = sprintf("%5.2f", lat_ob_sort(n)) |
|
594 txt2 = sprintf("%5.2f", lon_ob_sort(n)) |
|
595 txt3 = year_ob_sort(n) |
|
596 |
|
597 set_line(lines,nline,"<th><a href="+txt0+"_tseries_vs_ob.png>"+txt0+"</a></th>") |
|
598 set_line(lines,nline,"<th>"+txt1+"</th>") |
|
599 set_line(lines,nline,"<th>"+txt2+"</th>") |
|
600 set_line(lines,nline,"<th>"+txt3+"</th>") |
|
601 |
|
602 set_line(lines,nline,row_footer) |
|
603 end do |
|
604 ;----------------------------------------------- |
|
605 set_line(lines,nline,table_footer) |
|
606 set_line(lines,nline,footer) |
|
607 |
|
608 ; Now write to an HTML file. |
|
609 idx = ind(.not.ismissing(lines)) |
|
610 if(.not.any(ismissing(idx))) then |
|
611 asciiwrite(output_html,lines(idx)) |
|
612 else |
|
613 print ("error?") |
|
614 end if |
|
615 delete (idx) |
|
616 |
|
617 delete (isort) |
|
618 delete (station_sort) |
|
619 delete (year_ob_sort) |
|
620 delete (lat_ob_sort) |
|
621 delete (lon_ob_sort) |
|
622 |
|
623 ;************************************************************ |
|
624 ; compute annual cycle correlation coef and M score |
|
625 ;************************************************************ |
|
626 |
|
627 score_max = 5. |
|
628 |
|
629 ccr = new ((/nstation, nfield/),float) |
|
630 M_score = new ((/nstation, nfield/),float) |
|
631 |
|
632 do n=0,nstation-1 |
|
633 do m=0,nfield-1 |
|
634 ccr(n,m) = esccr(data_ob_ann(m,:,n),data_mod_ann(m,:,n),0) |
|
635 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)))) |
|
636 M_score(n,m) = (1. -(bias/nmonth)) * score_max |
|
637 end do |
|
638 end do |
|
639 |
|
640 M_co2 = avg(M_score(:,0)) |
|
641 M_rad = avg(M_score(:,1)) |
|
642 M_lh = avg(M_score(:,2)) |
|
643 M_sh = avg(M_score(:,3)) |
|
644 M_gpp = avg(M_score(:,4)) |
|
645 M_er = avg(M_score(:,5)) |
|
646 M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er |
|
647 |
|
648 M_energy_co2 = sprintf("%.2f", M_co2) |
|
649 M_energy_rad = sprintf("%.2f", M_rad) |
|
650 M_energy_lh = sprintf("%.2f", M_lh ) |
|
651 M_energy_sh = sprintf("%.2f", M_sh ) |
|
652 M_energy_gpp = sprintf("%.2f", M_gpp) |
|
653 M_energy_er = sprintf("%.2f", M_er ) |
|
654 M_energy_all = sprintf("%.2f", M_all) |
|
655 |
|
656 ;******************************************************************* |
|
657 ; for station line plot |
|
658 ;******************************************************************* |
|
659 |
|
660 ; for x-axis in xyplot |
|
661 mon = ispan(1,12,1) |
|
662 mon@long_name = "month" |
|
663 |
|
664 ;------------------------------------------------------------------- |
|
665 |
|
666 plot_data = new((/2,nmonth/),float) |
|
667 plot_data!0 = "case" |
|
668 plot_data!1 = "month" |
|
669 |
|
670 do n = 0,nstation-1 |
|
671 ;---------------------------- |
|
672 ; for observed |
|
673 |
|
674 plot_name = station(n)+"_ob" |
|
675 title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")" |
|
676 res@tiMainString = title |
|
677 |
|
678 wks = gsn_open_wks (plot_type,plot_name) |
|
679 plot=new(nfield,graphic) ; create graphic array |
|
680 |
|
681 do i = 0,nfield-1 |
|
682 plot_data(0,:) = (/data_ob_ann(i,:,n)/) |
|
683 plot_data@long_name = field(i)+" ("+field_unit(i)+")" |
|
684 plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot |
|
685 end do |
|
686 |
|
687 gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot |
|
688 |
|
689 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \ |
|
690 "rm "+plot_name+"."+plot_type) |
|
691 |
|
692 clear (wks) |
|
693 delete (plot) |
|
694 ;---------------------------- |
|
695 ; for model_vs_ob |
|
696 |
|
697 plot_name = station(n)+"_model_vs_ob" |
|
698 title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")" |
|
699 res@tiMainString = title |
|
700 |
|
701 wks = gsn_open_wks (plot_type,plot_name) |
|
702 plot=new(nfield,graphic) ; create graphic array |
|
703 |
|
704 do i = 0,nfield-1 |
|
705 plot_data(0,:) = (/data_ob_ann(i,:,n)/) |
|
706 plot_data(1,:) = (/data_mod_ann(i,:,n)/) |
|
707 plot_data@long_name = field(i)+" ("+field_unit(i)+")" |
|
708 plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot |
|
709 end do |
|
710 |
|
711 gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot |
|
712 |
|
713 system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \ |
|
714 "rm "+plot_name+"."+plot_type) |
|
715 |
|
716 clear (wks) |
|
717 delete (plot) |
|
718 end do |
|
719 |
|
720 ;################################################################### |
|
721 ; for the following tables, |
|
722 ; sort by latitude in decending order (N->S) |
|
723 ; sort by lat in decending order (N->S) |
|
724 |
|
725 isort = dim_pqsort(lat_ob,-1) |
|
726 |
|
727 station_sort = station(isort) |
|
728 year_ob_sort = year_ob(isort) |
|
729 lat_ob_sort = lat_ob(isort) |
|
730 lon_ob_sort = lon_ob(isort) |
|
731 M_score_sort = M_score(isort,:) |
|
732 |
|
733 ; print(isort) |
|
734 ; print(lat_ob_sort) |
|
735 ;################################################################### |
|
736 ;******************************************************************* |
|
737 ; html table of site: observed |
|
738 ;******************************************************************* |
|
739 output_html = "line_ob.html" |
|
740 |
|
741 header = (/"<HTML>" \ |
|
742 ,"<HEAD>" \ |
|
743 ,"<TITLE>CLAMP metrics</TITLE>" \ |
|
744 ,"</HEAD>" \ |
|
745 ,"<H1>Energy at Site: Observation</H1>" \ |
|
746 /) |
|
747 footer = "</HTML>" |
|
748 |
|
749 table_header = (/ \ |
|
750 "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \ |
|
751 ,"<tr>" \ |
|
752 ," <th bgcolor=DDDDDD >Site Name</th>" \ |
|
753 ," <th bgcolor=DDDDDD >Latitude</th>" \ |
|
754 ," <th bgcolor=DDDDDD >Longitude</th>" \ |
|
755 ," <th bgcolor=DDDDDD >Observed</th>" \ |
|
756 ,"</tr>" \ |
|
757 /) |
|
758 table_footer = "</table>" |
|
759 row_header = "<tr>" |
|
760 row_footer = "</tr>" |
|
761 |
|
762 lines = new(50000,string) |
|
763 nline = 0 |
|
764 |
|
765 set_line(lines,nline,header) |
|
766 set_line(lines,nline,table_header) |
|
767 ;----------------------------------------------- |
|
768 ; row of table |
|
769 |
|
770 do n = 0,nstation-1 |
|
771 set_line(lines,nline,row_header) |
|
772 |
|
773 txt0 = station_sort(n) |
|
774 txt1 = sprintf("%5.2f", lat_ob_sort(n)) |
|
775 txt2 = sprintf("%5.2f", lon_ob_sort(n)) |
|
776 txt3 = year_ob_sort(n) |
|
777 |
|
778 set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>") |
|
779 set_line(lines,nline,"<th>"+txt1+"</th>") |
|
780 set_line(lines,nline,"<th>"+txt2+"</th>") |
|
781 set_line(lines,nline,"<th>"+txt3+"</th>") |
|
782 |
|
783 set_line(lines,nline,row_footer) |
|
784 end do |
|
785 ;----------------------------------------------- |
|
786 set_line(lines,nline,table_footer) |
|
787 set_line(lines,nline,footer) |
|
788 |
|
789 ; Now write to an HTML file. |
|
790 idx = ind(.not.ismissing(lines)) |
|
791 if(.not.any(ismissing(idx))) then |
|
792 asciiwrite(output_html,lines(idx)) |
|
793 else |
|
794 print ("error?") |
|
795 end if |
|
796 delete (idx) |
|
797 |
|
798 ;******************************************************************* |
|
799 ; score and line table : model vs observed |
|
800 ;******************************************************************* |
|
801 output_html = "score+line_vs_ob.html" |
|
802 |
|
803 header = (/"<HTML>" \ |
|
804 ,"<HEAD>" \ |
|
805 ,"<TITLE>CLAMP metrics</TITLE>" \ |
|
806 ,"</HEAD>" \ |
|
807 ,"<H1>Energy at Site: Model "+model_name+"</H1>" \ |
|
808 /) |
|
809 footer = "</HTML>" |
|
810 |
|
811 delete (table_header) |
|
812 table_header = (/ \ |
|
813 "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \ |
|
814 ,"<tr>" \ |
|
815 ," <th bgcolor=DDDDDD >Site Name</th>" \ |
|
816 ," <th bgcolor=DDDDDD >Latitude</th>" \ |
|
817 ," <th bgcolor=DDDDDD >Longitude</th>" \ |
|
818 ," <th bgcolor=DDDDDD >Observed</th>" \ |
|
819 ," <th bgcolor=DDDDDD >CO2 Flux</th>" \ |
|
820 ," <th bgcolor=DDDDDD >Net Radiation</th>" \ |
|
821 ," <th bgcolor=DDDDDD >Latent Heat</th>" \ |
|
822 ," <th bgcolor=DDDDDD >Sensible Heat</th>" \ |
|
823 ," <th bgcolor=DDDDDD >GPP Glux</th>" \ |
|
824 ," <th bgcolor=DDDDDD >Respiration</th>" \ |
|
825 ," <th bgcolor=DDDDDD >Average</th>" \ |
|
826 ,"</tr>" \ |
|
827 /) |
|
828 table_footer = "</table>" |
|
829 row_header = "<tr>" |
|
830 row_footer = "</tr>" |
|
831 |
|
832 lines = new(50000,string) |
|
833 nline = 0 |
|
834 |
|
835 set_line(lines,nline,header) |
|
836 set_line(lines,nline,table_header) |
|
837 ;----------------------------------------------- |
|
838 ; row of table |
|
839 |
|
840 do n = 0,nstation-1 |
|
841 set_line(lines,nline,row_header) |
|
842 |
|
843 txt0 = station_sort(n) |
|
844 txt1 = sprintf("%5.2f", lat_ob_sort(n)) |
|
845 txt2 = sprintf("%5.2f", lon_ob_sort(n)) |
|
846 txt3 = year_ob_sort(n) |
|
847 txt4 = sprintf("%5.2f", M_score_sort(n,0)) |
|
848 txt5 = sprintf("%5.2f", M_score_sort(n,1)) |
|
849 txt6 = sprintf("%5.2f", M_score_sort(n,2)) |
|
850 txt7 = sprintf("%5.2f", M_score_sort(n,3)) |
|
851 txt8 = sprintf("%5.2f", M_score_sort(n,4)) |
|
852 txt9 = sprintf("%5.2f", M_score_sort(n,5)) |
|
853 txt10 = sprintf("%5.2f", avg(M_score_sort(n,:))) |
|
854 |
|
855 set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>") |
|
856 set_line(lines,nline,"<th>"+txt1+"</th>") |
|
857 set_line(lines,nline,"<th>"+txt2+"</th>") |
|
858 set_line(lines,nline,"<th>"+txt3+"</th>") |
|
859 set_line(lines,nline,"<th>"+txt4+"</th>") |
|
860 set_line(lines,nline,"<th>"+txt5+"</th>") |
|
861 set_line(lines,nline,"<th>"+txt6+"</th>") |
|
862 set_line(lines,nline,"<th>"+txt7+"</th>") |
|
863 set_line(lines,nline,"<th>"+txt8+"</th>") |
|
864 set_line(lines,nline,"<th>"+txt9+"</th>") |
|
865 set_line(lines,nline,"<th>"+txt10+"</th>") |
|
866 |
|
867 set_line(lines,nline,row_footer) |
|
868 end do |
|
869 |
|
870 ; last row, summary |
|
871 set_line(lines,nline,row_header) |
|
872 |
|
873 txt0 = "All_"+sprintf("%.0f", nstation) |
|
874 txt1 = "-" |
|
875 txt2 = "-" |
|
876 txt3 = "-" |
|
877 txt4 = M_energy_co2 |
|
878 txt5 = M_energy_rad |
|
879 txt6 = M_energy_lh |
|
880 txt7 = M_energy_sh |
|
881 txt8 = M_energy_gpp |
|
882 txt9 = M_energy_er |
|
883 txt10 = M_energy_all |
|
884 |
|
885 set_line(lines,nline,"<th>"+txt0+"</th>") |
|
886 set_line(lines,nline,"<th>"+txt1+"</th>") |
|
887 set_line(lines,nline,"<th>"+txt2+"</th>") |
|
888 set_line(lines,nline,"<th>"+txt3+"</th>") |
|
889 set_line(lines,nline,"<th>"+txt4+"</th>") |
|
890 set_line(lines,nline,"<th>"+txt5+"</th>") |
|
891 set_line(lines,nline,"<th>"+txt6+"</th>") |
|
892 set_line(lines,nline,"<th>"+txt7+"</th>") |
|
893 set_line(lines,nline,"<th>"+txt8+"</th>") |
|
894 set_line(lines,nline,"<th>"+txt9+"</th>") |
|
895 set_line(lines,nline,"<th>"+txt10+"</th>") |
|
896 |
|
897 set_line(lines,nline,row_footer) |
|
898 ;----------------------------------------------- |
|
899 set_line(lines,nline,table_footer) |
|
900 set_line(lines,nline,footer) |
|
901 |
|
902 ; Now write to an HTML file. |
|
903 idx = ind(.not.ismissing(lines)) |
|
904 if(.not.any(ismissing(idx))) then |
|
905 asciiwrite(output_html,lines(idx)) |
|
906 else |
|
907 print ("error?") |
|
908 end if |
|
909 delete (idx) |
|
910 |
|
911 ;*************************************************************************** |
|
912 ; output plots |
|
913 ;*************************************************************************** |
|
914 output_dir = model_name+"/ameriflux" |
|
915 |
|
916 system("mv *.png *.html " + output_dir) |
|
917 ;*************************************************************************** |
|
918 end |
|
919 |