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