1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/all/00.initial.ncl Mon Jan 26 22:08:20 2009 -0500
1.3 @@ -0,0 +1,31 @@
1.4 +;*****************************************************
1.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
1.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
1.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
1.8 +;****************************************************************************
1.9 +; Main code.
1.10 +;****************************************************************************
1.11 +begin
1.12 +
1.13 +;--------------------------------------------------
1.14 +; edit table.html of current model for movel1_vs_model2
1.15 +
1.16 + if (isvar("compare")) then
1.17 + html_name2 = compare+"/table.html"
1.18 + html_new2 = html_name2 +".new"
1.19 +
1.20 + system("sed -e '/"+modeln+"/s/"+modeln+"/"+model_name+"/' "+html_name2+" > "+html_new2+";"+ \
1.21 + "mv -f "+html_new2+" "+html_name2)
1.22 + end if
1.23 +;-------------------------------------
1.24 +; edit table.html for current model
1.25 +
1.26 + html_name = model_name+"/table.html"
1.27 + html_new = html_name +".new"
1.28 + system("sed s#model_name#"+model_name+"# "+html_name+" > "+html_new+";"+ \
1.29 + "mv -f "+html_new+" "+html_name)
1.30 +
1.31 +;---------------------------------------------------------------------------
1.32 +
1.33 +end
1.34 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/all/01.npp.ncl Mon Jan 26 22:08:20 2009 -0500
2.3 @@ -0,0 +1,1370 @@
2.4 +;*****************************************************
2.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
2.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
2.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
2.8 +;****************************************************************************
2.9 +procedure set_line(lines:string,nline:integer,newlines:string)
2.10 +begin
2.11 +; add line to ascci/html file
2.12 +
2.13 + nnewlines = dimsizes(newlines)
2.14 + if(nline+nnewlines-1.ge.dimsizes(lines))
2.15 + print("set_line: bad index, not setting anything.")
2.16 + return
2.17 + end if
2.18 + lines(nline:nline+nnewlines-1) = newlines
2.19 +; print ("lines = " + lines(nline:nline+nnewlines-1))
2.20 + nline = nline + nnewlines
2.21 + return
2.22 +end
2.23 +;****************************************************************************
2.24 +procedure get_bin(RAIN1_1D[*]:numeric, NPP1_1D[*]:numeric \
2.25 + ,RAIN2_1D[*]:numeric, NPP2_1D[*]:numeric \
2.26 + ,xvalues[*][*]:numeric, yvalues[*][*]:numeric \
2.27 + ,mn_yvalues[*][*]:numeric, mx_yvalues[*][*]:numeric \
2.28 + ,dx4[1]:numeric \
2.29 + )
2.30 +begin
2.31 +; Calculaee "nice" bins for binning the data in equally spaced ranges.
2.32 +; input : RAIN1_1D, RAIN2_1D, NPP1_1D, NPP2_1D
2.33 +; output: xvalues, yvalues, mn_yvalues, mx_yvalues,dx4
2.34 +
2.35 + nbins = 15 ; Number of bins to use.
2.36 +
2.37 + nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
2.38 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
2.39 + range = fspan(nicevals(0),nicevals(1),nvals)
2.40 +
2.41 +; Use this range information to grab all the values in a
2.42 +; particular range, and then take an average.
2.43 +
2.44 + nr = dimsizes(range)
2.45 + nx = nr-1
2.46 +; print (nx)
2.47 +
2.48 +; xvalues = new((/2,nx/),typeof(RAIN1_1D))
2.49 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
2.50 + dx = xvalues(0,1) - xvalues(0,0) ; range width
2.51 + dx4 = dx/4 ; 1/4 of the range
2.52 + xvalues(1,:) = xvalues(0,:) - dx/5.
2.53 +; yvalues = new((/2,nx/),typeof(RAIN1_1D))
2.54 +; mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
2.55 +; mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
2.56 +
2.57 + do nd=0,1
2.58 +
2.59 +; See if we are doing model or observational data.
2.60 +
2.61 + if(nd.eq.0) then
2.62 + data = RAIN1_1D
2.63 + npp_data = NPP1_1D
2.64 + else
2.65 + data = RAIN2_1D
2.66 + npp_data = NPP2_1D
2.67 + end if
2.68 +
2.69 +; Loop through each range and check for values.
2.70 +
2.71 + do i=0,nr-2
2.72 + if (i.ne.(nr-2)) then
2.73 +; print("")
2.74 +; print("In range ["+range(i)+","+range(i+1)+")")
2.75 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
2.76 + else
2.77 +; print("")
2.78 +; print("In range ["+range(i)+",)")
2.79 + idx = ind(range(i).le.data)
2.80 + end if
2.81 +
2.82 +; Calculate average, and get min and max.
2.83 +
2.84 + if(.not.any(ismissing(idx))) then
2.85 + yvalues(nd,i) = avg(npp_data(idx))
2.86 + mn_yvalues(nd,i) = min(npp_data(idx))
2.87 + mx_yvalues(nd,i) = max(npp_data(idx))
2.88 + count = dimsizes(idx)
2.89 + else
2.90 + count = 0
2.91 + yvalues(nd,i) = yvalues@_FillValue
2.92 + mn_yvalues(nd,i) = yvalues@_FillValue
2.93 + mx_yvalues(nd,i) = yvalues@_FillValue
2.94 + end if
2.95 +
2.96 +; Print out information.
2.97 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
2.98 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
2.99 +
2.100 +; Clean up for next time in loop.
2.101 +
2.102 + delete(idx)
2.103 + end do
2.104 + delete(data)
2.105 + delete(npp_data)
2.106 + end do
2.107 +end
2.108 +;****************************************************************************
2.109 +; Main code.
2.110 +;****************************************************************************
2.111 +begin
2.112 +
2.113 + plot_type = "ps"
2.114 + plot_type_new = "png"
2.115 +
2.116 +;-----------------------------------------------------
2.117 +; edit table.html of current model for movel1_vs_model2
2.118 +
2.119 + if (isvar("compare")) then
2.120 + html_name2 = compare+"/table.html"
2.121 + html_new2 = html_name2 +".new"
2.122 + end if
2.123 +;------------------------------------------------------
2.124 +; edit table.html for current model
2.125 +
2.126 + html_name = model_name+"/table.html"
2.127 + html_new = html_name +".new"
2.128 +
2.129 +;------------------------------------------------------
2.130 +; read model data
2.131 +
2.132 + fm = addfile (dirm+film1,"r")
2.133 +
2.134 + nppmod0 = fm->NPP
2.135 + rainmod0 = fm->RAIN
2.136 + xm = fm->lon
2.137 + ym = fm->lat
2.138 +
2.139 + delete (fm)
2.140 +
2.141 +;----------------------------------------------------
2.142 +; read ob data
2.143 +
2.144 +;(1) data at 81 sites
2.145 +
2.146 + dir81 = diro + "npp/"
2.147 + fil81 = "data.81.nc"
2.148 + f81 = addfile (dir81+fil81,"r")
2.149 +
2.150 + id81 = f81->SITE_ID
2.151 + npp81 = f81->TNPP_C
2.152 + rain81 = tofloat(f81->PREC_ANN)
2.153 + x81 = f81->LONG_DD
2.154 + y81 = f81->LAT_DD
2.155 +
2.156 + delete (f81)
2.157 +
2.158 + id81@long_name = "SITE_ID"
2.159 +
2.160 +;change longitude from (-180,180) to (0,360)
2.161 +;for model data interpolation
2.162 +
2.163 + do i= 0,dimsizes(x81)-1
2.164 + if (x81(i) .lt. 0.) then
2.165 + x81(i) = x81(i)+ 360.
2.166 + end if
2.167 + end do
2.168 +
2.169 +;-------------------------------------
2.170 +;(2) data at 933 sites
2.171 +
2.172 + dir933 = diro + "npp/"
2.173 + fil933 = "data.933.nc"
2.174 + f933 = addfile (dir933+fil933,"r")
2.175 +
2.176 + id933 = f933->SITE_ID
2.177 + npp933 = f933->TNPP_C
2.178 + rain933 = f933->PREC
2.179 + x933 = f933->LONG_DD
2.180 + y933 = f933->LAT_DD
2.181 +
2.182 + delete (f933)
2.183 +
2.184 + id933@long_name = "SITE_ID"
2.185 +
2.186 +;change longitude from (-180,180) to (0,360)
2.187 +;for model data interpolation
2.188 +
2.189 + do i= 0,dimsizes(x933)-1
2.190 + if (x933(i) .lt. 0.) then
2.191 + x933(i) = x933(i)+ 360.
2.192 + end if
2.193 + end do
2.194 +
2.195 +;----------------------------------------
2.196 +;(3) global data, interpolated into model grid
2.197 +
2.198 + dirg = diro + "npp/"
2.199 + filg = "Npp_"+model_grid+"_mean.nc"
2.200 + fglobe = addfile (dirg+filg,"r")
2.201 +
2.202 + nppglobe0 = fglobe->NPP
2.203 + nppglobe = nppglobe0
2.204 +
2.205 + delete (fglobe)
2.206 +
2.207 +;***********************************************************************
2.208 +; interpolate model data into ob sites
2.209 +;***********************************************************************
2.210 +
2.211 + nppmod = nppmod0(0,:,:)
2.212 + rainmod = rainmod0(0,:,:)
2.213 + delete (nppmod0)
2.214 + delete (rainmod0)
2.215 +
2.216 + nppmod81 =linint2_points(xm,ym,nppmod,True,x81,y81,0)
2.217 +
2.218 + nppmod933 =linint2_points(xm,ym,nppmod,True,x933,y933,0)
2.219 +
2.220 + rainmod81 =linint2_points(xm,ym,rainmod,True,x81,y81,0)
2.221 +
2.222 + rainmod933=linint2_points(xm,ym,rainmod,True,x933,y933,0)
2.223 +
2.224 +;**********************************************************
2.225 +; unified units
2.226 +;**********************************************************
2.227 +; Units for these variables are:
2.228 +;
2.229 +; rain81 : mm/year
2.230 +; rainmod : mm/s
2.231 +; npp81 : g C/m^2/year
2.232 +; nppmod81: g C/m^2/s
2.233 +; nppglobe: g C/m^2/year
2.234 +;
2.235 +; We want to convert these to "m/year" and "g C/m^2/year".
2.236 +
2.237 + nsec_per_year = 60*60*24*365
2.238 +
2.239 + rain81 = rain81 / 1000.
2.240 + rainmod81 = (rainmod81/ 1000.) * nsec_per_year
2.241 + nppmod81 = nppmod81 * nsec_per_year
2.242 +
2.243 + rain933 = rain933 / 1000.
2.244 + rainmod933 = (rainmod933/ 1000.) * nsec_per_year
2.245 + nppmod933 = nppmod933 * nsec_per_year
2.246 +
2.247 + nppmod = nppmod * nsec_per_year
2.248 +
2.249 + npp81@units = "gC/m^2/yr"
2.250 + nppmod81@units = "gC/m^2/yr"
2.251 + npp933@units = "gC/m^2/yr"
2.252 + nppmod933@units = "gC/m^2/yr"
2.253 + nppmod@units = "gC/m^2/yr"
2.254 + nppglobe@units = "gC/m^2/yr"
2.255 + rain81@units = "m/yr"
2.256 + rainmod81@units = "m/yr"
2.257 + rain933@units = "m/yr"
2.258 + rainmod933@units = "m/yr"
2.259 +
2.260 + npp81@long_name = "Obs. NPP (gC/m2/year)"
2.261 + npp933@long_name = "Obs. NPP (gC/m2/year)"
2.262 + nppmod81@long_name = "Model NPP (gC/m2/year)"
2.263 + nppmod933@long_name = "Model NPP (gC/m2/year)"
2.264 + nppmod@long_name = "Model NPP (gC/m2/year)"
2.265 + nppglobe@long_name = "NPP (gC/m2/year)"
2.266 + rain81@long_name = "PREC (m/year)"
2.267 + rain933@long_name = "PREC (m/year)"
2.268 + rainmod81@long_name = "PREC (m/year)"
2.269 + rainmod933@long_name = "PREC (m/year)"
2.270 +
2.271 +; change longitude from 0-360 to -180-180
2.272 + x81 = where(x81 .gt. 180., x81 -360., x81 )
2.273 + x933 = where(x933 .gt. 180., x933-360., x933)
2.274 +
2.275 +;*******************************************************************
2.276 +;(A)-1 html table of site81 -- observed
2.277 +;*******************************************************************
2.278 +
2.279 + output_html = "table_site81_ob.html"
2.280 +
2.281 + header = (/"<HTML>" \
2.282 + ,"<HEAD>" \
2.283 + ,"<TITLE>CLAMP metrics</TITLE>" \
2.284 + ,"</HEAD>" \
2.285 + ,"<H1>EMDI Observations Class A (81 sites)</H1>" \
2.286 + /)
2.287 + footer = "</HTML>"
2.288 +
2.289 + table_header = (/ \
2.290 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
2.291 + ,"<tr>" \
2.292 + ," <th bgcolor=DDDDDD >Site ID</th>" \
2.293 + ," <th bgcolor=DDDDDD >Latitude</th>" \
2.294 + ," <th bgcolor=DDDDDD >Longitude</th>" \
2.295 + ," <th bgcolor=DDDDDD >NPP(gC/m2/year)</th>" \
2.296 + ," <th bgcolor=DDDDDD >PPT(m/year)</th>" \
2.297 + ,"</tr>" \
2.298 + /)
2.299 + table_footer = "</table>"
2.300 + row_header = "<tr>"
2.301 + row_footer = "</tr>"
2.302 +
2.303 + lines = new(50000,string)
2.304 + nline = 0
2.305 +
2.306 + set_line(lines,nline,header)
2.307 + set_line(lines,nline,table_header)
2.308 +;-----------------------------------------------
2.309 +;row of table
2.310 +
2.311 + nrow = dimsizes(id81)
2.312 + do n = 0,nrow-1
2.313 + set_line(lines,nline,row_header)
2.314 +
2.315 + txt1 = sprintf("%5.0f", id81(n))
2.316 + txt2 = sprintf("%5.2f", y81(n))
2.317 + txt3 = sprintf("%5.2f", x81(n))
2.318 + txt4 = sprintf("%5.2f", npp81(n))
2.319 + txt5 = sprintf("%5.2f", rain81(n))
2.320 +
2.321 + set_line(lines,nline,"<th>"+txt1+"</th>")
2.322 + set_line(lines,nline,"<th>"+txt2+"</th>")
2.323 + set_line(lines,nline,"<th>"+txt3+"</th>")
2.324 + set_line(lines,nline,"<th>"+txt4+"</th>")
2.325 + set_line(lines,nline,"<th>"+txt5+"</th>")
2.326 +
2.327 + set_line(lines,nline,row_footer)
2.328 + end do
2.329 +;-----------------------------------------------
2.330 + set_line(lines,nline,table_footer)
2.331 + set_line(lines,nline,footer)
2.332 +
2.333 +; Now write to an HTML file.
2.334 + idx = ind(.not.ismissing(lines))
2.335 + if(.not.any(ismissing(idx))) then
2.336 + asciiwrite(output_html,lines(idx))
2.337 + else
2.338 + print ("error?")
2.339 + end if
2.340 +
2.341 +;*******************************************************************
2.342 +;(A)-2 html table of site933 -- observed
2.343 +;*******************************************************************
2.344 + output_html = "table_site933_ob.html"
2.345 +
2.346 + header = (/"<HTML>" \
2.347 + ,"<HEAD>" \
2.348 + ,"<TITLE>CLAMP metrics</TITLE>" \
2.349 + ,"</HEAD>" \
2.350 + ,"<H1>EMDI Observations Class B (933 sites)</H1>" \
2.351 + /)
2.352 + footer = "</HTML>"
2.353 +
2.354 + table_header = (/ \
2.355 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
2.356 + ,"<tr>" \
2.357 + ," <th bgcolor=DDDDDD >Site ID</th>" \
2.358 + ," <th bgcolor=DDDDDD >Latitude</th>" \
2.359 + ," <th bgcolor=DDDDDD >Longitude</th>" \
2.360 + ," <th bgcolor=DDDDDD >NPP(gC/m2/year)</th>" \
2.361 + ," <th bgcolor=DDDDDD >PPT(m/year)</th>" \
2.362 + ,"</tr>" \
2.363 + /)
2.364 + table_footer = "</table>"
2.365 + row_header = "<tr>"
2.366 + row_footer = "</tr>"
2.367 +
2.368 + delete (lines)
2.369 + lines = new(50000,string)
2.370 + nline = 0
2.371 +
2.372 + set_line(lines,nline,header)
2.373 + set_line(lines,nline,table_header)
2.374 +;-----------------------------------------------
2.375 +;row of table
2.376 +
2.377 + nrow = dimsizes(id933)
2.378 + do n = 0,nrow-1
2.379 + set_line(lines,nline,row_header)
2.380 +
2.381 + txt1 = sprintf("%5.0f", id933(n))
2.382 + txt2 = sprintf("%5.2f", y933(n))
2.383 + txt3 = sprintf("%5.2f", x933(n))
2.384 + txt4 = sprintf("%5.2f", npp933(n))
2.385 + txt5 = sprintf("%5.2f", rain933(n))
2.386 +
2.387 + set_line(lines,nline,"<th>"+txt1+"</th>")
2.388 + set_line(lines,nline,"<th>"+txt2+"</th>")
2.389 + set_line(lines,nline,"<th>"+txt3+"</th>")
2.390 + set_line(lines,nline,"<th>"+txt4+"</th>")
2.391 + set_line(lines,nline,"<th>"+txt5+"</th>")
2.392 +
2.393 + set_line(lines,nline,row_footer)
2.394 + end do
2.395 +;-----------------------------------------------
2.396 + set_line(lines,nline,table_footer)
2.397 + set_line(lines,nline,footer)
2.398 +
2.399 +; Now write to an HTML file.
2.400 + delete (idx)
2.401 + idx = ind(.not.ismissing(lines))
2.402 + if(.not.any(ismissing(idx))) then
2.403 + asciiwrite(output_html,lines(idx))
2.404 + else
2.405 + print ("error?")
2.406 + end if
2.407 +
2.408 +;*******************************************************************
2.409 +;(A)-3 html table of site81 -- model vs ob
2.410 +;*******************************************************************
2.411 + output_html = "table_site81_model_vs_ob.html"
2.412 +
2.413 + header_text = "<H1>Model "+model_name+" vs Class A Observations (81 sites)</H1>"
2.414 +
2.415 + header = (/"<HTML>" \
2.416 + ,"<HEAD>" \
2.417 + ,"<TITLE>CLAMP metrics</TITLE>" \
2.418 + ,"</HEAD>" \
2.419 + ,header_text \
2.420 + /)
2.421 + footer = "</HTML>"
2.422 +
2.423 + delete (table_header)
2.424 + table_header_text = " <th bgcolor=DDDDDD >"+model_name+"</th>"
2.425 + table_header = (/ \
2.426 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
2.427 + ,"<tr>" \
2.428 + ," <th bgcolor=DDDDDD rowspan=2>Site ID</th>" \
2.429 + ," <th bgcolor=DDDDDD rowspan=2>Latitude</th>" \
2.430 + ," <th bgcolor=DDDDDD rowspan=2>Longitude</th>" \
2.431 + ," <th bgcolor=DDDDDD colspan=2>NPP(gC/m2.year)</th>" \
2.432 + ," <th bgcolor=DDDDDD colspan=2>RAIN(m/year)</th>" \
2.433 + ,"</tr>" \
2.434 + ,"<tr>" \
2.435 + ," <th bgcolor=DDDDDD >observed</th>" \
2.436 + , table_header_text \
2.437 + ," <th bgcolor=DDDDDD >observed</th>" \
2.438 + , table_header_text \
2.439 + ,"</tr>" \
2.440 + /)
2.441 + table_footer = "</table>"
2.442 + row_header = "<tr>"
2.443 + row_footer = "</tr>"
2.444 +
2.445 + delete (lines)
2.446 + lines = new(50000,string)
2.447 + nline = 0
2.448 +
2.449 + set_line(lines,nline,header)
2.450 + set_line(lines,nline,table_header)
2.451 +;-----------------------------------------------
2.452 +;row of table
2.453 +
2.454 + nrow = dimsizes(id81)
2.455 + do n = 0,nrow-1
2.456 + set_line(lines,nline,row_header)
2.457 +
2.458 + txt1 = sprintf("%5.0f", id81(n))
2.459 + txt2 = sprintf("%5.2f", y81(n))
2.460 + txt3 = sprintf("%5.2f", x81(n))
2.461 + txt4 = sprintf("%5.2f", npp81(n))
2.462 + txt5 = sprintf("%5.2f", nppmod81(n))
2.463 + txt6 = sprintf("%5.2f", rain81(n))
2.464 + txt7 = sprintf("%5.2f", rainmod81(n))
2.465 +
2.466 + set_line(lines,nline,"<th>"+txt1+"</th>")
2.467 + set_line(lines,nline,"<th>"+txt2+"</th>")
2.468 + set_line(lines,nline,"<th>"+txt3+"</th>")
2.469 + set_line(lines,nline,"<th>"+txt4+"</th>")
2.470 + set_line(lines,nline,"<th>"+txt5+"</th>")
2.471 + set_line(lines,nline,"<th>"+txt6+"</th>")
2.472 + set_line(lines,nline,"<th>"+txt7+"</th>")
2.473 +
2.474 + set_line(lines,nline,row_footer)
2.475 + end do
2.476 +;-----------------------------------------------
2.477 + set_line(lines,nline,table_footer)
2.478 + set_line(lines,nline,footer)
2.479 +
2.480 +; Now write to an HTML file.
2.481 + delete (idx)
2.482 + idx = ind(.not.ismissing(lines))
2.483 + if(.not.any(ismissing(idx))) then
2.484 + asciiwrite(output_html,lines(idx))
2.485 + else
2.486 + print ("error?")
2.487 + end if
2.488 +
2.489 +;*******************************************************************
2.490 +;(A)-4 html table of site933 -- model vs ob
2.491 +;*******************************************************************
2.492 + output_html = "table_site933_model_vs_ob.html"
2.493 +
2.494 + header_text = "<H1>Model "+model_name+" vs Class B Observations (933 sites)</H1>"
2.495 +
2.496 + header = (/"<HTML>" \
2.497 + ,"<HEAD>" \
2.498 + ,"<TITLE>CLAMP metrics</TITLE>" \
2.499 + ,"</HEAD>" \
2.500 + ,header_text \
2.501 + /)
2.502 + footer = "</HTML>"
2.503 +
2.504 + delete (table_header)
2.505 + table_header_text = " <th bgcolor=DDDDDD >"+model_name+"</th>"
2.506 + table_header = (/ \
2.507 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
2.508 + ,"<tr>" \
2.509 + ," <th bgcolor=DDDDDD rowspan=2>Site ID</th>" \
2.510 + ," <th bgcolor=DDDDDD rowspan=2>Latitude</th>" \
2.511 + ," <th bgcolor=DDDDDD rowspan=2>Longitude</th>" \
2.512 + ," <th bgcolor=DDDDDD colspan=2>NPP(gC/m2.year)</th>" \
2.513 + ," <th bgcolor=DDDDDD colspan=2>RAIN(m/year)</th>" \
2.514 + ,"</tr>" \
2.515 + ,"<tr>" \
2.516 + ," <th bgcolor=DDDDDD >observed</th>" \
2.517 + , table_header_text \
2.518 + ," <th bgcolor=DDDDDD >observed</th>" \
2.519 + , table_header_text \
2.520 + ,"</tr>" \
2.521 + /)
2.522 + table_footer = "</table>"
2.523 + row_header = "<tr>"
2.524 + row_footer = "</tr>"
2.525 +
2.526 + delete (lines)
2.527 + lines = new(50000,string)
2.528 + nline = 0
2.529 +
2.530 + set_line(lines,nline,header)
2.531 + set_line(lines,nline,table_header)
2.532 +;-----------------------------------------------
2.533 +;row of table
2.534 +
2.535 + nrow = dimsizes(id933)
2.536 + do n = 0,nrow-1
2.537 + set_line(lines,nline,row_header)
2.538 +
2.539 + txt1 = sprintf("%5.0f", id933(n))
2.540 + txt2 = sprintf("%5.2f", y933(n))
2.541 + txt3 = sprintf("%5.2f", x933(n))
2.542 + txt4 = sprintf("%5.2f", npp933(n))
2.543 + txt5 = sprintf("%5.2f", nppmod933(n))
2.544 + txt6 = sprintf("%5.2f", rain933(n))
2.545 + txt7 = sprintf("%5.2f", rainmod933(n))
2.546 +
2.547 + set_line(lines,nline,"<th>"+txt1+"</th>")
2.548 + set_line(lines,nline,"<th>"+txt2+"</th>")
2.549 + set_line(lines,nline,"<th>"+txt3+"</th>")
2.550 + set_line(lines,nline,"<th>"+txt4+"</th>")
2.551 + set_line(lines,nline,"<th>"+txt5+"</th>")
2.552 + set_line(lines,nline,"<th>"+txt6+"</th>")
2.553 + set_line(lines,nline,"<th>"+txt7+"</th>")
2.554 +
2.555 + set_line(lines,nline,row_footer)
2.556 + end do
2.557 +;-----------------------------------------------
2.558 + set_line(lines,nline,table_footer)
2.559 + set_line(lines,nline,footer)
2.560 +
2.561 +; Now write to an HTML file.
2.562 + delete (idx)
2.563 + idx = ind(.not.ismissing(lines))
2.564 + if(.not.any(ismissing(idx))) then
2.565 + asciiwrite(output_html,lines(idx))
2.566 + else
2.567 + print ("error?")
2.568 + end if
2.569 +
2.570 +;***************************************************************************
2.571 +;(A)-5 scatter plot, model vs ob 81
2.572 +;***************************************************************************
2.573 +
2.574 + plot_name = "scatter_model_vs_ob_81"
2.575 + title = model_name +" vs Class A observations (81 sites)"
2.576 +
2.577 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
2.578 + res = True ; plot mods desired
2.579 + res@tiMainString = title ; add title
2.580 + res@xyMarkLineModes = "Markers" ; choose which have markers
2.581 + res@xyMarkers = 16 ; choose type of marker
2.582 + res@xyMarkerColor = "red" ; Marker color
2.583 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
2.584 + res@tmLabelAutoStride = True ; nice tick mark labels
2.585 +
2.586 + res@gsnDraw = False
2.587 + res@gsnFrame = False ; don't advance frame yet
2.588 +;-------------------------------
2.589 +;compute correlation coef. and M
2.590 + ccr81 = esccr(nppmod81,npp81,0)
2.591 +;print (ccr81)
2.592 +
2.593 + score_max = 2.5
2.594 +
2.595 + bias = sum(abs(nppmod81-npp81)/(abs(nppmod81)+abs(npp81)))
2.596 + M81s = (1. - (bias/dimsizes(y81)))*score_max
2.597 + M_npp_S81 = sprintf("%.2f", M81s)
2.598 +
2.599 + if (isvar("compare")) then
2.600 + system("sed -e '1,/M_npp_S81/s/M_npp_S81/"+M_npp_S81+"/' "+html_name2+" > "+html_new2+";"+ \
2.601 + "mv -f "+html_new2+" "+html_name2)
2.602 + end if
2.603 +
2.604 + system("sed s#M_npp_S81#"+M_npp_S81+"# "+html_name+" > "+html_new+";"+ \
2.605 + "mv -f "+html_new+" "+html_name)
2.606 +
2.607 + tRes = True
2.608 + tRes@txFontHeightF = 0.025
2.609 +
2.610 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81)+")"
2.611 +
2.612 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
2.613 +;--------------------------------
2.614 + plot = gsn_csm_xy (wks,npp81,nppmod81,res) ; create plot
2.615 +;-------------------------------
2.616 +; add polyline
2.617 +
2.618 + dum=gsn_add_polyline(wks,plot,(/0,1200/),(/0,1200/),False)
2.619 +;-------------------------------
2.620 + draw (plot)
2.621 + delete (wks)
2.622 + delete (dum)
2.623 +
2.624 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
2.625 + "rm "+plot_name+"."+plot_type)
2.626 +
2.627 +;***************************************************************************
2.628 +;(A)-6 scatter plot, model vs ob 933
2.629 +;***************************************************************************
2.630 +
2.631 + plot_name = "scatter_model_vs_ob_933"
2.632 + title = model_name +" vs Class B Observations (933 sites)"
2.633 +
2.634 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
2.635 + res = True ; plot mods desired
2.636 + res@tiMainString = title ; add title
2.637 + res@xyMarkLineModes = "Markers" ; choose which have markers
2.638 + res@xyMarkers = 16 ; choose type of marker
2.639 + res@xyMarkerColor = "red" ; Marker color
2.640 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
2.641 + res@tmLabelAutoStride = True ; nice tick mark labels
2.642 +
2.643 + res@gsnDraw = False
2.644 + res@gsnFrame = False ; don't advance frame yet
2.645 +;-------------------------------
2.646 +;compute correlation coef. and M
2.647 +
2.648 + ccr933 = esccr(nppmod933,npp933,0)
2.649 +
2.650 + score_max = 2.5
2.651 +
2.652 + bias = sum(abs(nppmod933-npp933)/(abs(nppmod933)+abs(npp933)))
2.653 + M933s = (1. - (bias/dimsizes(y933)))*score_max
2.654 + M_npp_S933 = sprintf("%.2f", M933s)
2.655 +
2.656 + if (isvar("compare")) then
2.657 + system("sed -e '1,/M_npp_S933/s/M_npp_S933/"+M_npp_S933+"/' "+html_name2+" > "+html_new2+";"+ \
2.658 + "mv -f "+html_new2+" "+html_name2)
2.659 + end if
2.660 +
2.661 + system("sed s#M_npp_S933#"+M_npp_S933+"# "+html_name+" > "+html_new+";"+ \
2.662 + "mv -f "+html_new+" "+html_name)
2.663 +
2.664 + tRes = True
2.665 + tRes@txFontHeightF = 0.025
2.666 +
2.667 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933)+")"
2.668 +
2.669 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
2.670 +;--------------------------------
2.671 + plot = gsn_csm_xy (wks,npp933,nppmod933,res) ; create plot
2.672 +;-------------------------------
2.673 +; add polyline
2.674 +
2.675 + dum=gsn_add_polyline(wks,plot,(/0,1500/),(/0,1500/),False)
2.676 +;-------------------------------
2.677 + draw (plot)
2.678 + delete (wks)
2.679 + delete (dum)
2.680 +
2.681 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
2.682 + "rm "+plot_name+"."+plot_type)
2.683 +
2.684 +;**************************************************************************
2.685 +;(B) histogram 81
2.686 +;**************************************************************************
2.687 +;get data
2.688 + RAIN1_1D = ndtooned(rain81)
2.689 + RAIN2_1D = ndtooned(rainmod81)
2.690 + NPP1_1D = ndtooned(npp81)
2.691 + NPP2_1D = ndtooned(nppmod81)
2.692 +
2.693 +; number of bin
2.694 + nx = 8
2.695 +
2.696 + xvalues = new((/2,nx/),float)
2.697 + yvalues = new((/2,nx/),float)
2.698 + mn_yvalues = new((/2,nx/),float)
2.699 + mx_yvalues = new((/2,nx/),float)
2.700 + dx4 = new((/1/),float)
2.701 +
2.702 + get_bin(RAIN1_1D, NPP1_1D, RAIN2_1D, NPP2_1D \
2.703 + ,xvalues,yvalues,mn_yvalues,mx_yvalues,dx4)
2.704 +
2.705 +;----------------------------------------
2.706 +;compute correlation coeff and M score
2.707 +
2.708 + u = yvalues(0,:)
2.709 + v = yvalues(1,:)
2.710 +
2.711 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
2.712 + uu = u(good)
2.713 + vv = v(good)
2.714 +
2.715 + ccr81h = esccr(uu,vv,0)
2.716 +
2.717 + score_max = 2.5
2.718 +
2.719 + bias = sum(abs(vv-uu)/(abs(vv)+abs(uu)))
2.720 + M81h = (1.- (bias/dimsizes(uu)))*score_max
2.721 + M_npp_H81 = sprintf("%.2f", M81h)
2.722 +
2.723 + if (isvar("compare")) then
2.724 + system("sed -e '1,/M_npp_H81/s/M_npp_H81/"+M_npp_H81+"/' "+html_name2+" > "+html_new2+";"+ \
2.725 + "mv -f "+html_new2+" "+html_name2)
2.726 + end if
2.727 +
2.728 + system("sed s#M_npp_H81#"+M_npp_H81+"# "+html_name+" > "+html_new+";"+ \
2.729 + "mv -f "+html_new+" "+html_name)
2.730 +
2.731 + delete (u)
2.732 + delete (v)
2.733 + delete (uu)
2.734 + delete (vv)
2.735 +;----------------------------------------------------------------------
2.736 +; histogram res
2.737 + resh = True
2.738 + resh@gsnMaximize = True
2.739 + resh@gsnDraw = False
2.740 + resh@gsnFrame = False
2.741 + resh@xyMarkLineMode = "Markers"
2.742 + resh@xyMarkerSizeF = 0.014
2.743 + resh@xyMarker = 16
2.744 + resh@xyMarkerColors = (/"Brown","Blue"/)
2.745 + resh@trYMinF = min(mn_yvalues) - 10.
2.746 + resh@trYMaxF = max(mx_yvalues) + 10.
2.747 +
2.748 + resh@tiYAxisString = "NPP (g C/m2/year)"
2.749 + resh@tiXAxisString = "Precipitation (m/year)"
2.750 +
2.751 + max_bar = new((/2,nx/),graphic)
2.752 + min_bar = new((/2,nx/),graphic)
2.753 + max_cap = new((/2,nx/),graphic)
2.754 + min_cap = new((/2,nx/),graphic)
2.755 +
2.756 + lnres = True
2.757 + line_colors = (/"brown","blue"/)
2.758 +
2.759 +;**************************************************************************
2.760 +;(B)-1 histogram plot, ob 81 site
2.761 +;**************************************************************************
2.762 +
2.763 + plot_name = "histogram_ob_81"
2.764 + title = "Class A Observations (81 sites)"
2.765 + resh@tiMainString = title
2.766 +
2.767 + wks = gsn_open_wks (plot_type,plot_name)
2.768 +
2.769 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
2.770 +
2.771 +;-------------------------------
2.772 +;Attach the vertical bar and the horizontal cap line
2.773 +
2.774 + do nd=0,0
2.775 + lnres@gsLineColor = line_colors(nd)
2.776 + do i=0,nx-1
2.777 +
2.778 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
2.779 + .not.ismissing(mx_yvalues(nd,i))) then
2.780 +;
2.781 +; Attach the vertical bar, both above and below the marker.
2.782 +;
2.783 + x1 = xvalues(nd,i)
2.784 + y1 = yvalues(nd,i)
2.785 + y2 = mn_yvalues(nd,i)
2.786 + plx = (/x1,x1/)
2.787 + ply = (/y1,y2/)
2.788 + min_bar(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
2.789 +
2.790 + y2 = mx_yvalues(nd,i)
2.791 + plx = (/x1,x1/)
2.792 + ply = (/y1,y2/)
2.793 + max_bar(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
2.794 +;
2.795 +; Attach the horizontal cap line, both above and below the marker.
2.796 +;
2.797 + x1 = xvalues(nd,i) - dx4
2.798 + x2 = xvalues(nd,i) + dx4
2.799 + y1 = mn_yvalues(nd,i)
2.800 + plx = (/x1,x2/)
2.801 + ply = (/y1,y1/)
2.802 + min_cap(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
2.803 +
2.804 + y1 = mx_yvalues(nd,i)
2.805 + plx = (/x1,x2/)
2.806 + ply = (/y1,y1/)
2.807 + max_cap(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
2.808 + end if
2.809 + end do
2.810 + end do
2.811 +
2.812 + draw(xy)
2.813 + delete (wks)
2.814 +
2.815 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
2.816 + "rm "+plot_name+"."+plot_type)
2.817 +
2.818 +;****************************************************************************
2.819 +;(B)-2 histogram plot, model vs ob 81 site
2.820 +;****************************************************************************
2.821 +
2.822 + plot_name = "histogram_model_vs_ob_81"
2.823 + title = model_name+ " vs Class A Observations (81 sites)"
2.824 + resh@tiMainString = title
2.825 +
2.826 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
2.827 +
2.828 +;-----------------------------
2.829 +; Add a boxed legend using the more simple method, which won't have
2.830 +; vertical lines going through the markers.
2.831 +
2.832 + resh@pmLegendDisplayMode = "Always"
2.833 +; resh@pmLegendWidthF = 0.1
2.834 + resh@pmLegendWidthF = 0.08
2.835 + resh@pmLegendHeightF = 0.05
2.836 + resh@pmLegendOrthogonalPosF = -1.17
2.837 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
2.838 +; resh@pmLegendParallelPosF = 0.18
2.839 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
2.840 +
2.841 +; resh@lgPerimOn = False
2.842 + resh@lgLabelFontHeightF = 0.015
2.843 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
2.844 +;-----------------------------
2.845 + tRes = True
2.846 + tRes@txFontHeightF = 0.025
2.847 +
2.848 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81h)+")"
2.849 +
2.850 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
2.851 +
2.852 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
2.853 +;-------------------------------
2.854 +;Attach the vertical bar and the horizontal cap line
2.855 +
2.856 + do nd=0,1
2.857 + lnres@gsLineColor = line_colors(nd)
2.858 + do i=0,nx-1
2.859 +
2.860 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
2.861 + .not.ismissing(mx_yvalues(nd,i))) then
2.862 +;
2.863 +; Attach the vertical bar, both above and below the marker.
2.864 +;
2.865 + x1 = xvalues(nd,i)
2.866 + y1 = yvalues(nd,i)
2.867 + y2 = mn_yvalues(nd,i)
2.868 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
2.869 +
2.870 + y2 = mx_yvalues(nd,i)
2.871 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
2.872 +;
2.873 +; Attach the horizontal cap line, both above and below the marker.
2.874 +;
2.875 + x1 = xvalues(nd,i) - dx4
2.876 + x2 = xvalues(nd,i) + dx4
2.877 + y1 = mn_yvalues(nd,i)
2.878 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
2.879 +
2.880 + y1 = mx_yvalues(nd,i)
2.881 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
2.882 + end if
2.883 + end do
2.884 + end do
2.885 +
2.886 + draw(xy)
2.887 + delete(wks)
2.888 +
2.889 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
2.890 + "rm "+plot_name+"."+plot_type)
2.891 +
2.892 + delete (RAIN1_1D)
2.893 + delete (RAIN2_1D)
2.894 + delete (NPP1_1D)
2.895 + delete (NPP2_1D)
2.896 +;delete (range)
2.897 + delete (xvalues)
2.898 + delete (yvalues)
2.899 + delete (mn_yvalues)
2.900 + delete (mx_yvalues)
2.901 + delete (good)
2.902 + delete (max_bar)
2.903 + delete (min_bar)
2.904 + delete (max_cap)
2.905 + delete (min_cap)
2.906 +
2.907 +;**************************************************************************
2.908 +;(B) histogram 933
2.909 +;**************************************************************************
2.910 +
2.911 +; get data
2.912 + RAIN1_1D = ndtooned(rain933)
2.913 + RAIN2_1D = ndtooned(rainmod933)
2.914 + NPP1_1D = ndtooned(npp933)
2.915 + NPP2_1D = ndtooned(nppmod933)
2.916 +
2.917 +; number of bin
2.918 + nx = 10
2.919 +
2.920 + xvalues = new((/2,nx/),float)
2.921 + yvalues = new((/2,nx/),float)
2.922 + mn_yvalues = new((/2,nx/),float)
2.923 + mx_yvalues = new((/2,nx/),float)
2.924 + dx4 = new((/1/),float)
2.925 +
2.926 + get_bin(RAIN1_1D, NPP1_1D, RAIN2_1D, NPP2_1D \
2.927 + ,xvalues,yvalues,mn_yvalues,mx_yvalues,dx4)
2.928 +
2.929 +;----------------------------------------
2.930 +;compute correlation coeff and M score
2.931 +
2.932 + u = yvalues(0,:)
2.933 + v = yvalues(1,:)
2.934 +
2.935 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
2.936 + uu = u(good)
2.937 + vv = v(good)
2.938 +
2.939 + ccr933h = esccr(uu,vv,0)
2.940 +
2.941 + score_max = 2.5
2.942 +
2.943 + bias = sum(abs(vv-uu)/(abs(vv)+abs(uu)))
2.944 + M933h = (1.- (bias/dimsizes(uu)))*score_max
2.945 + M_npp_H933 = sprintf("%.2f", M933h)
2.946 +
2.947 + if (isvar("compare")) then
2.948 + system("sed -e '1,/M_npp_H933/s/M_npp_H933/"+M_npp_H933+"/' "+html_name2+" > "+html_new2+";"+ \
2.949 + "mv -f "+html_new2+" "+html_name2)
2.950 + end if
2.951 +
2.952 + system("sed s#M_npp_H933#"+M_npp_H933+"# "+html_name+" > "+html_new+";"+ \
2.953 + "mv -f "+html_new+" "+html_name)
2.954 +
2.955 + delete (u)
2.956 + delete (v)
2.957 + delete (uu)
2.958 + delete (vv)
2.959 +;----------------------------------------------------------------------
2.960 +; histogram res
2.961 + delete (resh)
2.962 + resh = True
2.963 + resh@gsnMaximize = True
2.964 + resh@gsnDraw = False
2.965 + resh@gsnFrame = False
2.966 + resh@xyMarkLineMode = "Markers"
2.967 + resh@xyMarkerSizeF = 0.014
2.968 + resh@xyMarker = 16
2.969 + resh@xyMarkerColors = (/"Brown","Blue"/)
2.970 + resh@trYMinF = min(mn_yvalues) - 10.
2.971 + resh@trYMaxF = max(mx_yvalues) + 10.
2.972 +
2.973 + resh@tiYAxisString = "NPP (g C/m2/year)"
2.974 + resh@tiXAxisString = "Precipitation (m/year)"
2.975 +
2.976 + max_bar = new((/2,nx/),graphic)
2.977 + min_bar = new((/2,nx/),graphic)
2.978 + max_cap = new((/2,nx/),graphic)
2.979 + min_cap = new((/2,nx/),graphic)
2.980 +
2.981 + lnres = True
2.982 + line_colors = (/"brown","blue"/)
2.983 +
2.984 +;**************************************************************************
2.985 +;(B)-3 histogram plot, ob 933 site
2.986 +;**************************************************************************
2.987 +
2.988 + plot_name = "histogram_ob_933"
2.989 + title = "Class B Observations (933 sites)"
2.990 + resh@tiMainString = title
2.991 +
2.992 + wks = gsn_open_wks (plot_type,plot_name)
2.993 +
2.994 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
2.995 +
2.996 +;-------------------------------
2.997 +;Attach the vertical bar and the horizontal cap line
2.998 +
2.999 + do nd=0,0
2.1000 + lnres@gsLineColor = line_colors(nd)
2.1001 + do i=0,nx-1
2.1002 +
2.1003 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
2.1004 + .not.ismissing(mx_yvalues(nd,i))) then
2.1005 +
2.1006 +; Attach the vertical bar, both above and below the marker.
2.1007 +
2.1008 + x1 = xvalues(nd,i)
2.1009 + y1 = yvalues(nd,i)
2.1010 + y2 = mn_yvalues(nd,i)
2.1011 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
2.1012 +
2.1013 + y2 = mx_yvalues(nd,i)
2.1014 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
2.1015 +
2.1016 +; Attach the horizontal cap line, both above and below the marker.
2.1017 +
2.1018 + x1 = xvalues(nd,i) - dx4
2.1019 + x2 = xvalues(nd,i) + dx4
2.1020 + y1 = mn_yvalues(nd,i)
2.1021 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
2.1022 +
2.1023 + y1 = mx_yvalues(nd,i)
2.1024 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
2.1025 + end if
2.1026 + end do
2.1027 + end do
2.1028 +
2.1029 + draw(xy)
2.1030 + delete (xy)
2.1031 + delete (wks)
2.1032 +
2.1033 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
2.1034 + "rm "+plot_name+"."+plot_type)
2.1035 +
2.1036 +;****************************************************************************
2.1037 +;(B)-4 histogram plot, model vs ob 933 site
2.1038 +;****************************************************************************
2.1039 +
2.1040 + plot_name = "histogram_model_vs_ob_933"
2.1041 + title = model_name+ " vs Class B Observations (933 sites)"
2.1042 + resh@tiMainString = title
2.1043 +
2.1044 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
2.1045 +
2.1046 +;-----------------------------
2.1047 +; Add a boxed legend using the more simple method, which won't have
2.1048 +; vertical lines going through the markers.
2.1049 +
2.1050 + resh@pmLegendDisplayMode = "Always"
2.1051 +; resh@pmLegendWidthF = 0.1
2.1052 + resh@pmLegendWidthF = 0.08
2.1053 + resh@pmLegendHeightF = 0.05
2.1054 + resh@pmLegendOrthogonalPosF = -1.17
2.1055 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
2.1056 +; resh@pmLegendParallelPosF = 0.18
2.1057 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
2.1058 +
2.1059 +; resh@lgPerimOn = False
2.1060 + resh@lgLabelFontHeightF = 0.015
2.1061 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
2.1062 +;-----------------------------
2.1063 + tRes = True
2.1064 + tRes@txFontHeightF = 0.025
2.1065 +
2.1066 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933h)+")"
2.1067 +
2.1068 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
2.1069 +
2.1070 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
2.1071 +;-------------------------------
2.1072 +;Attach the vertical bar and the horizontal cap line
2.1073 +
2.1074 + do nd=0,1
2.1075 + lnres@gsLineColor = line_colors(nd)
2.1076 + do i=0,nx-1
2.1077 +
2.1078 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
2.1079 + .not.ismissing(mx_yvalues(nd,i))) then
2.1080 +;
2.1081 +; Attach the vertical bar, both above and below the marker.
2.1082 +;
2.1083 + x1 = xvalues(nd,i)
2.1084 + y1 = yvalues(nd,i)
2.1085 + y2 = mn_yvalues(nd,i)
2.1086 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
2.1087 +
2.1088 + y2 = mx_yvalues(nd,i)
2.1089 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
2.1090 +;
2.1091 +; Attach the horizontal cap line, both above and below the marker.
2.1092 +;
2.1093 + x1 = xvalues(nd,i) - dx4
2.1094 + x2 = xvalues(nd,i) + dx4
2.1095 + y1 = mn_yvalues(nd,i)
2.1096 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
2.1097 +
2.1098 + y1 = mx_yvalues(nd,i)
2.1099 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
2.1100 + end if
2.1101 + end do
2.1102 + end do
2.1103 +
2.1104 + draw(xy)
2.1105 + delete(xy)
2.1106 + delete(wks)
2.1107 +
2.1108 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
2.1109 + "rm "+plot_name+"."+plot_type)
2.1110 +
2.1111 +;***************************************************************************
2.1112 +;(C) global contour
2.1113 +;***************************************************************************
2.1114 +
2.1115 +;res
2.1116 + resg = True ; Use plot options
2.1117 + resg@cnFillOn = True ; Turn on color fill
2.1118 + resg@gsnSpreadColors = True ; use full colormap
2.1119 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
2.1120 +; resg@lbLabelAutoStride = True
2.1121 + resg@cnLinesOn = False ; Turn off contourn lines
2.1122 + resg@mpFillOn = False ; Turn off map fill
2.1123 +
2.1124 + resg@gsnSpreadColors = True ; use full colormap
2.1125 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
2.1126 + resg@cnMinLevelValF = 0. ; Min level
2.1127 + resg@cnMaxLevelValF = 2200. ; Max level
2.1128 + resg@cnLevelSpacingF = 200. ; interval
2.1129 +
2.1130 +;****************************************************************************
2.1131 +;(C)-1 global contour plot, ob
2.1132 +;****************************************************************************
2.1133 +
2.1134 + delta = 0.00000000001
2.1135 + nppglobe = where(ismissing(nppglobe).and.(ismissing(nppmod).or.(nppmod.lt.delta)),0.,nppglobe)
2.1136 +
2.1137 + plot_name = "global_ob"
2.1138 + title = "Observed MODIS MOD 17"
2.1139 + resg@tiMainString = title
2.1140 +
2.1141 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
2.1142 + gsn_define_colormap(wks,"gui_default") ; choose colormap
2.1143 +
2.1144 + plot = gsn_csm_contour_map_ce(wks,nppglobe,resg)
2.1145 +
2.1146 + delete (wks)
2.1147 +
2.1148 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
2.1149 + "rm "+plot_name+"."+plot_type)
2.1150 +;****************************************************************************
2.1151 +;(C)-2 global contour plot, model
2.1152 +;****************************************************************************
2.1153 +
2.1154 + plot_name = "global_model"
2.1155 + title = "Model "+ model_name
2.1156 + resg@tiMainString = title
2.1157 +
2.1158 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
2.1159 + gsn_define_colormap(wks,"gui_default") ; choose colormap
2.1160 +
2.1161 + plot = gsn_csm_contour_map_ce(wks,nppmod,resg)
2.1162 +
2.1163 + delete (wks)
2.1164 +
2.1165 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
2.1166 + "rm "+plot_name+"."+plot_type)
2.1167 +
2.1168 +;****************************************************************************
2.1169 +;(C)-3 global contour plot, model vs ob
2.1170 +;****************************************************************************
2.1171 +
2.1172 + plot_name = "global_model_vs_ob"
2.1173 +
2.1174 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
2.1175 + gsn_define_colormap(wks,"gui_default") ; choose colormap
2.1176 +
2.1177 + delete (plot)
2.1178 + plot=new(3,graphic) ; create graphic array
2.1179 +
2.1180 + resg@gsnFrame = False ; Do not draw plot
2.1181 + resg@gsnDraw = False ; Do not advance frame
2.1182 +
2.1183 +; compute correlation coef and M score
2.1184 +
2.1185 + uu1 = ndtooned(nppmod)
2.1186 + vv1 = ndtooned(nppglobe)
2.1187 +
2.1188 + delete (good)
2.1189 + good = ind(.not.ismissing(uu1) .and. .not.ismissing(vv1))
2.1190 +
2.1191 + ug = uu1(good)
2.1192 + vg = vv1(good)
2.1193 +
2.1194 + ccrG = esccr(ug,vg,0)
2.1195 +
2.1196 + score_max = 5.0
2.1197 +
2.1198 + MG = (ccrG*ccrG)* score_max
2.1199 + M_npp_G = sprintf("%.2f", MG)
2.1200 +
2.1201 + if (isvar("compare")) then
2.1202 + system("sed -e '1,/M_npp_G/s/M_npp_G/"+M_npp_G+"/' "+html_name2+" > "+html_new2+";"+ \
2.1203 + "mv -f "+html_new2+" "+html_name2)
2.1204 + end if
2.1205 +
2.1206 + system("sed s#M_npp_G#"+M_npp_G+"# "+html_name+" > "+html_new+";"+ \
2.1207 + "mv -f "+html_new+" "+html_name)
2.1208 +
2.1209 +; plot correlation coef
2.1210 +
2.1211 + gRes = True
2.1212 + gRes@txFontHeightF = 0.02
2.1213 + gRes@txAngleF = 90
2.1214 +
2.1215 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrG)+")"
2.1216 +
2.1217 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
2.1218 +;--------------------------------------------------------------------
2.1219 +;(a) ob
2.1220 +
2.1221 + title = "Observed MODIS MOD 17"
2.1222 + resg@tiMainString = title
2.1223 +
2.1224 + plot(0) = gsn_csm_contour_map_ce(wks,nppglobe,resg)
2.1225 +
2.1226 +;(b) model
2.1227 +
2.1228 + title = "Model "+ model_name
2.1229 + resg@tiMainString = title
2.1230 +
2.1231 + plot(1) = gsn_csm_contour_map_ce(wks,nppmod,resg)
2.1232 +
2.1233 +;(c) model-ob
2.1234 +
2.1235 + zz = nppmod
2.1236 + zz = nppmod - nppglobe
2.1237 + title = "Model_"+model_name+" - Observed"
2.1238 +
2.1239 + resg@cnMinLevelValF = -500 ; Min level
2.1240 + resg@cnMaxLevelValF = 500. ; Max level
2.1241 + resg@cnLevelSpacingF = 50. ; interval
2.1242 + resg@tiMainString = title
2.1243 +
2.1244 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
2.1245 +
2.1246 + pres = True ; panel plot mods desired
2.1247 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
2.1248 + ; indiv. plots in panel
2.1249 + pres@gsnMaximize = True ; fill the page
2.1250 +
2.1251 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
2.1252 +
2.1253 + delete (wks)
2.1254 + delete (plot)
2.1255 +
2.1256 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
2.1257 + "rm "+plot_name+"."+plot_type)
2.1258 +
2.1259 +;***************************************************************************
2.1260 +;(D)-1 zonal line plot, ob
2.1261 +;***************************************************************************
2.1262 +
2.1263 + vv = zonalAve(nppglobe)
2.1264 + vv@long_name = nppglobe@long_name
2.1265 +
2.1266 + plot_name = "zonal_ob"
2.1267 + title = "Observed MODIS MOD 17"
2.1268 +
2.1269 + resz = True
2.1270 + resz@tiMainString = title
2.1271 +
2.1272 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
2.1273 +
2.1274 + plot = gsn_csm_xy (wks,ym,vv,resz)
2.1275 +
2.1276 + delete (wks)
2.1277 +
2.1278 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
2.1279 + "rm "+plot_name+"."+plot_type)
2.1280 +
2.1281 +;****************************************************************************
2.1282 +;(D)-2 zonal line plot, model vs ob
2.1283 +;****************************************************************************
2.1284 +
2.1285 + s = new ((/2,dimsizes(ym)/), float)
2.1286 +
2.1287 + s(0,:) = zonalAve(nppglobe)
2.1288 + s(1,:) = zonalAve(nppmod)
2.1289 +
2.1290 + s@long_name = nppglobe@long_name
2.1291 +;-------------------------------------------
2.1292 +; compute correlation coef and M score
2.1293 +
2.1294 + score_max = 5.0
2.1295 +
2.1296 + ccrZ = esccr(s(1,:), s(0,:),0)
2.1297 + MZ = (ccrZ*ccrZ)* score_max
2.1298 + M_npp_Z = sprintf("%.2f", MZ)
2.1299 +
2.1300 + if (isvar("compare")) then
2.1301 + system("sed -e '1,/M_npp_Z/s/M_npp_Z/"+M_npp_Z+"/' "+html_name2+" > "+html_new2+";"+ \
2.1302 + "mv -f "+html_new2+" "+html_name2)
2.1303 + end if
2.1304 +
2.1305 + system("sed s#M_npp_Z#"+M_npp_Z+"# "+html_name+" > "+html_new+";"+ \
2.1306 + "mv -f "+html_new+" "+html_name)
2.1307 +;-------------------------------------------
2.1308 + plot_name = "zonal_model_vs_ob"
2.1309 + title = "Zonal Average"
2.1310 + resz@tiMainString = title
2.1311 +
2.1312 + wks = gsn_open_wks (plot_type,plot_name)
2.1313 +
2.1314 +; resz@vpHeightF = 0.4 ; change aspect ratio of plot
2.1315 +; resz@vpWidthF = 0.7
2.1316 +
2.1317 + resz@xyMonoLineColor = "False" ; want colored lines
2.1318 + resz@xyLineColors = (/"black","red"/) ; colors chosen
2.1319 +; resz@xyLineThicknesses = (/3.,3./) ; line thicknesses
2.1320 + resz@xyLineThicknesses = (/2.,2./) ; line thicknesses
2.1321 + resz@xyDashPatterns = (/0.,0./) ; make all lines solid
2.1322 +
2.1323 + resz@tiYAxisString = s@long_name ; add a axis title
2.1324 + resz@txFontHeightF = 0.0195 ; change title font heights
2.1325 +
2.1326 +; Legent
2.1327 + resz@pmLegendDisplayMode = "Always" ; turn on legend
2.1328 + resz@pmLegendSide = "Top" ; Change location of
2.1329 +; resz@pmLegendParallelPosF = .45 ; move units right
2.1330 + resz@pmLegendParallelPosF = .82 ; move units right
2.1331 + resz@pmLegendOrthogonalPosF = -0.4 ; move units down
2.1332 +
2.1333 + resz@pmLegendWidthF = 0.10 ; Change width and
2.1334 + resz@pmLegendHeightF = 0.10 ; height of legend.
2.1335 + resz@lgLabelFontHeightF = .02 ; change font height
2.1336 +; resz@lgTitleOn = True ; turn on legend title
2.1337 +; resz@lgTitleString = "Example" ; create legend title
2.1338 +; resz@lgTitleFontHeightF = .025 ; font of legend title
2.1339 + resz@xyExplicitLegendLabels = (/"Observed",model_name/) ; explicit labels
2.1340 +;--------------------------------------------------------------------
2.1341 + zRes = True
2.1342 + zRes@txFontHeightF = 0.025
2.1343 +
2.1344 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrZ)+")"
2.1345 +
2.1346 + gsn_text_ndc(wks,correlation_text,0.50,0.77,zRes)
2.1347 +;--------------------------------------------------------------------
2.1348 +
2.1349 + plot = gsn_csm_xy (wks,ym,s,resz)
2.1350 +
2.1351 + delete (wks)
2.1352 +
2.1353 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
2.1354 + "rm "+plot_name+"."+plot_type)
2.1355 +
2.1356 +;***************************************************************************
2.1357 +; add total score and write to file
2.1358 +;***************************************************************************
2.1359 + M_total = M81s + M81h + M933s + M933h + MG + MZ
2.1360 +
2.1361 + asciiwrite("M_save.npp", M_total)
2.1362 +
2.1363 +;***************************************************************************
2.1364 +; output plots
2.1365 +;***************************************************************************
2.1366 + output_dir = model_name+"/npp"
2.1367 +
2.1368 + system("mv table_*.html " + output_dir +";"+ \
2.1369 + "mv *.png " + output_dir)
2.1370 +
2.1371 +;***************************************************************************
2.1372 +end
2.1373 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/all/02.lai.ncl Mon Jan 26 22:08:20 2009 -0500
3.3 @@ -0,0 +1,879 @@
3.4 +;**************************************************************
3.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
3.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
3.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
3.8 +;**************************************************************
3.9 +procedure set_line(lines:string,nline:integer,newlines:string)
3.10 +begin
3.11 +; add line to ascci/html file
3.12 +
3.13 + nnewlines = dimsizes(newlines)
3.14 + if(nline+nnewlines-1.ge.dimsizes(lines))
3.15 + print("set_line: bad index, not setting anything.")
3.16 + return
3.17 + end if
3.18 + lines(nline:nline+nnewlines-1) = newlines
3.19 +; print ("lines = " + lines(nline:nline+nnewlines-1))
3.20 + nline = nline + nnewlines
3.21 + return
3.22 +end
3.23 +;**************************************************************
3.24 +; Main code.
3.25 +begin
3.26 +
3.27 + plot_type = "ps"
3.28 + plot_type_new = "png"
3.29 +
3.30 +;-----------------------------------------------------
3.31 +; edit table.html of current model for movel1_vs_model2
3.32 +
3.33 + if (isvar("compare")) then
3.34 + html_name2 = compare+"/table.html"
3.35 + html_new2 = html_name2 +".new"
3.36 + end if
3.37 +
3.38 +;------------------------------------------------------
3.39 +; edit table.html for current model
3.40 +
3.41 + html_name = model_name+"/table.html"
3.42 + html_new = html_name +".new"
3.43 +
3.44 +;------------------------------------------------------
3.45 +; read data: model
3.46 +
3.47 + fm = addfile(dirm+film10,"r")
3.48 + laimod = fm->TLAI
3.49 +
3.50 + delete (fm)
3.51 +
3.52 + dsizes = dimsizes(laimod)
3.53 + ntime = dsizes(0)
3.54 + nlat = dsizes(1)
3.55 + nlon = dsizes(2)
3.56 +
3.57 +;-----------------------------------
3.58 +; get landfrac data
3.59 +
3.60 + film_l = "lnd_"+ model_grid + ".nc"
3.61 + fm_l = addfile (dirs+film_l,"r")
3.62 + landfrac = fm_l->landfrac
3.63 +
3.64 + delete (fm_l)
3.65 +;----------------------------------
3.66 +; read biome data: model
3.67 +
3.68 + biome_name_mod = "Model PFT Class"
3.69 +
3.70 + film_c = "class_pft_"+model_grid+".nc"
3.71 + fm_c = addfile(dirs+film_c,"r")
3.72 + classmod = fm_c->CLASS_PFT
3.73 +
3.74 + delete (fm_c)
3.75 +
3.76 +; model data has 17 land-type classes
3.77 + nclass_mod = 17
3.78 +
3.79 +;----------------------------------------------------------
3.80 +; read data: ob
3.81 +
3.82 +;----------------------------------
3.83 +; read biome data: observed
3.84 +
3.85 + biome_name_ob = "MODIS LandCover"
3.86 +
3.87 + dir_c = diro + "lai/"
3.88 + filo_c = "land_class_"+model_grid+".nc"
3.89 + fo = addfile(dir_c+filo_c,"r")
3.90 + classob = tofloat(fo->LAND_CLASS)
3.91 +
3.92 + delete (fo)
3.93 +
3.94 +; input observed data has 20 land-type classes
3.95 + nclass_ob = 20
3.96 +
3.97 +;---------------------------------
3.98 +; read lai data: observed
3.99 +
3.100 + ;ob_name = "MODIS MOD 15A2 2000-2005"
3.101 + ob_name = "MODIS MOD 15A2 2000-2004"
3.102 +
3.103 + dir_l = diro + "lai/"
3.104 + ;filo = "LAI_2000-2005_MONS_"+model_grid+".nc"
3.105 + filo = "LAI_2000-2004_MONS_"+model_grid+".nc"
3.106 + fo = addfile(dir_l+filo,"r")
3.107 + laiob = fo->LAI
3.108 +
3.109 + delete (fo)
3.110 +
3.111 +;-------------------------------------------------
3.112 +; take into account landfrac
3.113 +
3.114 + laimod = laimod * conform(laimod,landfrac,(/1,2/))
3.115 + laiob = laiob * conform(laiob ,landfrac,(/1,2/))
3.116 +
3.117 + delete (landfrac)
3.118 +
3.119 +;************************************************
3.120 +; global res
3.121 +;************************************************
3.122 + resg = True ; Use plot options
3.123 + resg@cnFillOn = True ; Turn on color fill
3.124 + resg@gsnSpreadColors = True ; use full colormap
3.125 + resg@cnLinesOn = False ; Turn off contourn lines
3.126 + resg@mpFillOn = False ; Turn off map fill
3.127 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
3.128 +
3.129 +;************************************************
3.130 +; plot global biome class: (1) observed
3.131 +;************************************************
3.132 +
3.133 + resg@cnMinLevelValF = 1. ; Min level
3.134 + resg@cnMaxLevelValF = 19. ; Max level
3.135 + resg@cnLevelSpacingF = 1. ; interval
3.136 +
3.137 + classob@_FillValue = 1.e+36
3.138 + classob = where(classob.eq.0,classob@_FillValue,classob)
3.139 +
3.140 + plot_name = "global_class_ob"
3.141 + title = biome_name_ob
3.142 + resg@tiMainString = title
3.143 +
3.144 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
3.145 + gsn_define_colormap(wks,"gui_default") ; choose colormap
3.146 +
3.147 + plot = gsn_csm_contour_map_ce(wks,classob,resg)
3.148 +
3.149 + delete (wks)
3.150 +
3.151 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
3.152 + "rm "+plot_name+"."+plot_type)
3.153 +
3.154 +;************************************************
3.155 +; plot global biome class: (2) model
3.156 +;************************************************
3.157 +
3.158 + resg@cnMinLevelValF = 0. ; Min level
3.159 + resg@cnMaxLevelValF = 16. ; Max level
3.160 + resg@cnLevelSpacingF = 1. ; interval
3.161 +
3.162 + plot_name = "global_class_model"
3.163 + title = biome_name_mod
3.164 + resg@tiMainString = title
3.165 +
3.166 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
3.167 + gsn_define_colormap(wks,"gui_default") ; choose colormap
3.168 +
3.169 + plot = gsn_csm_contour_map_ce(wks,classmod,resg)
3.170 +
3.171 + delete (wks)
3.172 +
3.173 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
3.174 + "rm "+plot_name+"."+plot_type)
3.175 +
3.176 +;*******************************************************************
3.177 +; for html table : all 3 components (Mean, Max, Phase)
3.178 +;*******************************************************************
3.179 +
3.180 +; column (not including header column)
3.181 +
3.182 + component = (/"Mean","Max","Phase"/)
3.183 +
3.184 + col_head = (/"observed",model_name,"M_score" \
3.185 + ,"observed",model_name,"M_score" \
3.186 + ,"observed",model_name,"M_score" \
3.187 + /)
3.188 +
3.189 + n_comp = dimsizes(component)
3.190 + ncol = dimsizes(col_head )
3.191 +
3.192 +; row (not including header row)
3.193 +
3.194 +;----------------------------------------------------
3.195 +; using model biome class:
3.196 + row_head = (/"Not Vegetated" \
3.197 + ,"Needleleaf Evergreen Temperate Tree" \
3.198 + ,"Needleleaf Evergreen Boreal Tree" \
3.199 +; ,"Needleleaf Deciduous Boreal Tree" \
3.200 + ,"Broadleaf Evergreen Tropical Tree" \
3.201 + ,"Broadleaf Evergreen Temperate Tree" \
3.202 + ,"Broadleaf Deciduous Tropical Tree" \
3.203 + ,"Broadleaf Deciduous Temperate Tree" \
3.204 +; ,"Broadleaf Deciduous Boreal Tree" \
3.205 +; ,"Broadleaf Evergreen Shrub" \
3.206 + ,"Broadleaf Deciduous Temperate Shrub" \
3.207 + ,"Broadleaf Deciduous Boreal Shrub" \
3.208 + ,"C3 Arctic Grass" \
3.209 + ,"C3 Non-Arctic Grass" \
3.210 + ,"C4 Grass" \
3.211 + ,"Corn" \
3.212 +; ,"Wheat" \
3.213 + ,"All Biomes" \
3.214 + /)
3.215 +
3.216 + nrow = dimsizes(row_head)
3.217 +
3.218 +; arrays to be passed to table.
3.219 + text = new ((/nrow, ncol/),string )
3.220 +
3.221 +; total M_score
3.222 + M_total = 0.
3.223 +
3.224 +;********************************************************************
3.225 +; use land-type class to bin the data in equally spaced ranges
3.226 +;********************************************************************
3.227 +
3.228 +; using model biome class
3.229 + nclass = nclass_mod
3.230 +
3.231 + range = fspan(0,nclass,nclass+1)
3.232 +
3.233 +; Use this range information to grab all the values in a
3.234 +; particular range, and then take an average.
3.235 +
3.236 + nx = dimsizes(range) - 1
3.237 +
3.238 +; for 2 data: model and observed
3.239 + data_n = 2
3.240 +
3.241 +; using model biome class
3.242 +
3.243 + base = ndtooned(classmod)
3.244 +
3.245 +; output
3.246 +
3.247 + yvalues = new((/data_n,nx/),float)
3.248 + count = new((/data_n,nx/),float)
3.249 +
3.250 +;************************************************************************
3.251 +; go through all components
3.252 +;************************************************************************
3.253 +
3.254 + do m = 0,n_comp-1
3.255 +
3.256 +;===================
3.257 +; get data:
3.258 +;===================
3.259 +; (A) Mean
3.260 +
3.261 + if (m .eq. 0) then
3.262 + data_ob = dim_avg_Wrap(laiob (lat|:,lon|:,time|:))
3.263 + data_mod = dim_avg_Wrap(laimod(lat|:,lon|:,time|:))
3.264 + end if
3.265 +
3.266 +; (B) Max
3.267 +
3.268 + if (m .eq. 1) then
3.269 +
3.270 +; observed
3.271 + data_ob = laiob(0,:,:)
3.272 + data_ob@long_name = "Leaf Area Index Max"
3.273 +
3.274 + do j = 0,nlat-1
3.275 + do i = 0,nlon-1
3.276 + data_ob(j,i) = max(laiob(:,j,i))
3.277 + end do
3.278 + end do
3.279 +
3.280 +; model
3.281 + data_mod = laimod(0,:,:)
3.282 + data_mod@long_name = "Leaf Area Index Max"
3.283 +
3.284 + do j = 0,nlat-1
3.285 + do i = 0,nlon-1
3.286 + data_mod(j,i) = max(laimod(:,j,i))
3.287 + end do
3.288 + end do
3.289 +
3.290 + end if
3.291 +
3.292 +; (C) phase
3.293 +
3.294 + if (m .eq. 2) then
3.295 +
3.296 +; observed
3.297 + data_ob = laiob(0,:,:)
3.298 + data_ob@long_name = "Leaf Area Index Max Month"
3.299 +
3.300 + do j = 0,nlat-1
3.301 + do i = 0,nlon-1
3.302 + data_ob(j,i) = maxind(laiob(:,j,i)) + 1
3.303 + end do
3.304 + end do
3.305 +
3.306 +; model
3.307 + data_mod = laimod(0,:,:)
3.308 + data_mod@long_name = "Leaf Area Index Max Month"
3.309 +
3.310 + do j = 0,nlat-1
3.311 + do i = 0,nlon-1
3.312 + data_mod(j,i) = maxind(laimod(:,j,i)) + 1
3.313 + end do
3.314 + end do
3.315 +
3.316 + end if
3.317 +
3.318 +;==============================
3.319 +; put data into bins
3.320 +;==============================
3.321 +
3.322 +; Loop through each range, using base
3.323 +
3.324 + do i=0,nx-1
3.325 +
3.326 + if (i.ne.(nx-1)) then
3.327 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
3.328 + else
3.329 + idx = ind(base.ge.range(i))
3.330 + end if
3.331 +
3.332 +; loop through each dataset
3.333 +
3.334 + do n = 0,data_n-1
3.335 +
3.336 + if (n .eq. 0) then
3.337 + data = ndtooned(data_ob)
3.338 + end if
3.339 +
3.340 + if (n .eq. 1) then
3.341 + data = ndtooned(data_mod)
3.342 + end if
3.343 +
3.344 +; Calculate average
3.345 +
3.346 + if (.not.any(ismissing(idx))) then
3.347 + yvalues(n,i) = avg(data(idx))
3.348 + count(n,i) = dimsizes(idx)
3.349 + else
3.350 + yvalues(n,i) = yvalues@_FillValue
3.351 + count(n,i) = 0
3.352 + end if
3.353 +
3.354 +;#############################################################
3.355 +; using model biome class:
3.356 +;
3.357 +; set the following 4 classes to _FillValue:
3.358 +; (3)Needleleaf Deciduous Boreal Tree,
3.359 +; (8)Broadleaf Deciduous Boreal Tree,
3.360 +; (9)Broadleaf Evergreen Shrub,
3.361 +; (16)Wheat
3.362 +
3.363 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
3.364 + yvalues(n,i) = yvalues@_FillValue
3.365 + count(n,i) = 0
3.366 + end if
3.367 +;#############################################################
3.368 +
3.369 + delete(data)
3.370 + end do ; n-loop
3.371 +
3.372 + delete(idx)
3.373 + end do ; i-loop
3.374 +
3.375 +;=====================================
3.376 +; compute correlation coef and M score
3.377 +;=====================================
3.378 +
3.379 + score_max = 5.0
3.380 +
3.381 + u = yvalues(0,:)
3.382 + v = yvalues(1,:)
3.383 + u_count = count(0,:)
3.384 + v_count = count(1,:)
3.385 +
3.386 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
3.387 +
3.388 + uu = u(good)
3.389 + vv = v(good)
3.390 + uu_count = u_count(good)
3.391 + vv_count = v_count(good)
3.392 +
3.393 +; compute correlation coef
3.394 + cc = esccr(uu,vv,0)
3.395 +
3.396 + if (n .eq. 2) then
3.397 + bias = avg(abs(vv-uu))
3.398 + bias = where((bias.gt. 6.),12.-bias,bias)
3.399 + Mscore = ((6. - bias)/6.)*score_max
3.400 + else
3.401 + bias = sum(abs(vv-uu)/abs(vv+uu))
3.402 + Mscore = (1.- (bias/dimsizes(uu)))*score_max
3.403 + end if
3.404 +
3.405 + M_score = sprintf("%.2f", Mscore)
3.406 +
3.407 +; compute M_total
3.408 +
3.409 + M_total = M_total + Mscore
3.410 +
3.411 +;================================
3.412 +; output M_score to score sheet
3.413 +;===============================
3.414 +
3.415 + if (isvar("compare")) then
3.416 + system("sed -e '1,/M_lai_"+component(m)+"/s/M_lai_"+component(m)+"/"+M_score+"/' "+html_name2+" > "+html_new2+";"+ \
3.417 + "mv -f "+html_new2+" "+html_name2)
3.418 + end if
3.419 +
3.420 + system("sed s#M_lai_"+component(m)+"#"+M_score+"# "+html_name+" > "+html_new+";"+ \
3.421 + "mv -f "+html_new+" "+html_name)
3.422 +
3.423 +;==============================
3.424 +; output M_score to html table
3.425 +;==============================
3.426 +
3.427 + n = m*3
3.428 +
3.429 + do i=0,nrow-2
3.430 + text(i,n) = sprintf("%.1f",uu(i))
3.431 + text(i,n+1) = sprintf("%.1f",vv(i))
3.432 + text(i,n+2) = "-"
3.433 + end do
3.434 + text(nrow-1,n) = sprintf("%.1f",sum(uu*uu_count)/sum(uu_count))
3.435 + text(nrow-1,n+1) = sprintf("%.1f",sum(vv*vv_count)/sum(vv_count))
3.436 + text(nrow-1,n+2) = M_score
3.437 +
3.438 + delete (u)
3.439 + delete (v)
3.440 + delete (uu)
3.441 + delete (vv)
3.442 + delete (u_count)
3.443 + delete (v_count)
3.444 + delete (uu_count)
3.445 + delete (vv_count)
3.446 + delete (good)
3.447 +
3.448 +;========================================
3.449 +; global res changes for each component
3.450 +;========================================
3.451 + delta = 0.00001
3.452 +
3.453 + if (m .eq. 0) then
3.454 + resg@cnMinLevelValF = 0.
3.455 + resg@cnMaxLevelValF = 10.
3.456 + resg@cnLevelSpacingF = 1.
3.457 +
3.458 + data_ob = where(ismissing(data_ob).and.(ismissing(data_mod).or.(data_mod.lt.delta)),0.,data_ob)
3.459 + end if
3.460 +
3.461 + if (m .eq. 1) then
3.462 + resg@cnMinLevelValF = 0.
3.463 + resg@cnMaxLevelValF = 10.
3.464 + resg@cnLevelSpacingF = 1.
3.465 +
3.466 + data_ob = where(ismissing(data_ob).and.(ismissing(data_mod).or.(data_mod.lt.delta)),0.,data_ob)
3.467 + end if
3.468 +
3.469 + if (m .eq. 2) then
3.470 + resg@cnMinLevelValF = 1.
3.471 + resg@cnMaxLevelValF = 12.
3.472 + resg@cnLevelSpacingF = 1.
3.473 +
3.474 + data_mod = where(ismissing(data_ob).or.(data_mod.lt.delta),data_mod@_FillValue,data_mod)
3.475 + data_ob = where(ismissing(data_ob).and.(ismissing(data_mod).or.(data_mod.lt.delta)),0.,data_ob)
3.476 +
3.477 + end if
3.478 +
3.479 +;=========================
3.480 +; global contour : ob
3.481 +;=========================
3.482 +
3.483 + plot_name = "global_"+component(m)+"_ob"
3.484 + title = ob_name
3.485 + resg@tiMainString = title
3.486 +
3.487 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
3.488 + gsn_define_colormap(wks,"gui_default") ; choose colormap
3.489 +
3.490 + plot = gsn_csm_contour_map_ce(wks,data_ob,resg)
3.491 +
3.492 + delete (wks)
3.493 + delete (plot)
3.494 +
3.495 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
3.496 + "rm "+plot_name+"."+plot_type)
3.497 +
3.498 +;============================
3.499 +; global contour : model
3.500 +;============================
3.501 +
3.502 + plot_name = "global_"+component(m)+"_model"
3.503 + title = "Model " + model_name
3.504 + resg@tiMainString = title
3.505 +
3.506 + wks = gsn_open_wks (plot_type,plot_name)
3.507 + gsn_define_colormap(wks,"gui_default")
3.508 +
3.509 + plot = gsn_csm_contour_map_ce(wks,data_mod,resg)
3.510 +
3.511 + delete (wks)
3.512 + delete (plot)
3.513 +
3.514 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
3.515 + "rm "+plot_name+"."+plot_type)
3.516 +
3.517 +;================================
3.518 +; global contour: model vs ob
3.519 +;================================
3.520 +
3.521 + plot_name = "global_"+component(m)+"_model_vs_ob"
3.522 +
3.523 + wks = gsn_open_wks (plot_type,plot_name)
3.524 + gsn_define_colormap(wks,"gui_default")
3.525 +
3.526 + plot=new(3,graphic) ; create graphic array
3.527 +
3.528 + resg@gsnFrame = False ; Do not draw plot
3.529 + resg@gsnDraw = False ; Do not advance frame
3.530 +
3.531 +; plot correlation coef
3.532 +
3.533 + gRes = True
3.534 + gRes@txFontHeightF = 0.02
3.535 + gRes@txAngleF = 90
3.536 +
3.537 + correlation_text = "(correlation coef = "+sprintf("%.2f", cc)+")"
3.538 +
3.539 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
3.540 +
3.541 +; plot ob
3.542 +
3.543 + title = ob_name
3.544 + resg@tiMainString = title
3.545 +
3.546 + plot(0) = gsn_csm_contour_map_ce(wks,data_ob,resg)
3.547 +
3.548 +; plot model
3.549 +
3.550 + title = "Model "+ model_name
3.551 + resg@tiMainString = title
3.552 +
3.553 + plot(1) = gsn_csm_contour_map_ce(wks,data_mod,resg)
3.554 +
3.555 +; plot model-ob
3.556 +
3.557 + if (m .eq. 0) then
3.558 + resg@cnMinLevelValF = -2.
3.559 + resg@cnMaxLevelValF = 2.
3.560 + resg@cnLevelSpacingF = 0.4
3.561 + end if
3.562 +
3.563 + if (m .eq. 1) then
3.564 + resg@cnMinLevelValF = -6.
3.565 + resg@cnMaxLevelValF = 6.
3.566 + resg@cnLevelSpacingF = 1.
3.567 + end if
3.568 +
3.569 + if (m .eq. 2) then
3.570 + resg@cnMinLevelValF = -6.
3.571 + resg@cnMaxLevelValF = 6.
3.572 + resg@cnLevelSpacingF = 1.
3.573 + end if
3.574 +
3.575 + zz = data_mod
3.576 + zz = data_mod - data_ob
3.577 + title = "Model_"+model_name+" - Observed"
3.578 + resg@tiMainString = title
3.579 +
3.580 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
3.581 +
3.582 +; plot panel
3.583 +
3.584 + pres = True ; panel plot mods desired
3.585 + pres@gsnMaximize = True ; fill the page
3.586 +
3.587 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
3.588 +
3.589 + delete (wks)
3.590 + delete (plot)
3.591 +
3.592 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
3.593 + "rm "+plot_name+"."+plot_type)
3.594 +
3.595 + delete (data_ob)
3.596 + delete (data_mod)
3.597 +
3.598 + resg@gsnFrame = True ; Do advance frame
3.599 + resg@gsnDraw = True ; Do draw plot
3.600 +
3.601 + end do ; m-loop
3.602 +
3.603 +;**************************************************
3.604 +; html table
3.605 +;**************************************************
3.606 + output_html = "table_model_vs_ob.html"
3.607 +
3.608 + header_text = "<H1>LAI: Model "+model_name+" vs. MODIS observations</H1>"
3.609 +
3.610 + header = (/"<HTML>" \
3.611 + ,"<HEAD>" \
3.612 + ,"<TITLE>CLAMP metrics</TITLE>" \
3.613 + ,"</HEAD>" \
3.614 + ,header_text \
3.615 + /)
3.616 + footer = "</HTML>"
3.617 +
3.618 + table_header = (/ \
3.619 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
3.620 + ,"<tr>" \
3.621 + ," <th bgcolor=DDDDDD rowspan=2>Biome Class</th>" \
3.622 + ," <th bgcolor=DDDDDD colspan=3>"+component(0)+" (m2/m2)</th>" \
3.623 + ," <th bgcolor=DDDDDD colspan=3>"+component(1)+" (m2/m2)</th>" \
3.624 + ," <th bgcolor=DDDDDD colspan=3>"+component(2)+" (months)</th>" \
3.625 + ," <th bgcolor=DDDDDD rowspan=2>Annual Plot</th>" \
3.626 + ,"</tr>" \
3.627 + ,"<tr>" \
3.628 + ," <th bgcolor=DDDDDD >observed</th>" \
3.629 + ," <th bgcolor=DDDDDD >"+model_name+"</th>" \
3.630 + ," <th bgcolor=DDDDDD >M_score</th>" \
3.631 + ," <th bgcolor=DDDDDD >observed</th>" \
3.632 + ," <th bgcolor=DDDDDD >"+model_name+"</th>" \
3.633 + ," <th bgcolor=DDDDDD >M_score</th>" \
3.634 + ," <th bgcolor=DDDDDD >observed</th>" \
3.635 + ," <th bgcolor=DDDDDD >"+model_name+"</th>" \
3.636 + ," <th bgcolor=DDDDDD >M_score</th>" \
3.637 + ,"</tr>" \
3.638 + /)
3.639 + table_footer = "</table>"
3.640 + row_header = "<tr>"
3.641 + row_footer = "</tr>"
3.642 +
3.643 + lines = new(50000,string)
3.644 + nline = 0
3.645 +
3.646 + set_line(lines,nline,header)
3.647 + set_line(lines,nline,table_header)
3.648 +;-----------------------------------------------
3.649 +;row of table
3.650 +
3.651 + do n = 0,nrow-1
3.652 + set_line(lines,nline,row_header)
3.653 +
3.654 + txt1 = row_head(n)
3.655 + txt2 = text(n,0)
3.656 + txt3 = text(n,1)
3.657 + txt4 = text(n,2)
3.658 + txt5 = text(n,3)
3.659 + txt6 = text(n,4)
3.660 + txt7 = text(n,5)
3.661 + txt8 = text(n,6)
3.662 + txt9 = text(n,7)
3.663 + txt10 = text(n,8)
3.664 + txt11 = "<a href=./annual_biome_"+n+".png>model_vs_ob</a>"
3.665 +
3.666 + set_line(lines,nline,"<th>"+txt1+"</th>")
3.667 + set_line(lines,nline,"<th>"+txt2+"</th>")
3.668 + set_line(lines,nline,"<th>"+txt3+"</th>")
3.669 + set_line(lines,nline,"<th>"+txt4+"</th>")
3.670 + set_line(lines,nline,"<th>"+txt5+"</th>")
3.671 + set_line(lines,nline,"<th>"+txt6+"</th>")
3.672 + set_line(lines,nline,"<th>"+txt7+"</th>")
3.673 + set_line(lines,nline,"<th>"+txt8+"</th>")
3.674 + set_line(lines,nline,"<th>"+txt9+"</th>")
3.675 + set_line(lines,nline,"<th>"+txt10+"</th>")
3.676 + set_line(lines,nline,"<th>"+txt11+"</th>")
3.677 +
3.678 + set_line(lines,nline,row_footer)
3.679 + end do
3.680 +;-----------------------------------------------
3.681 + set_line(lines,nline,table_footer)
3.682 + set_line(lines,nline,footer)
3.683 +
3.684 +; Now write to an HTML file
3.685 +
3.686 + idx = ind(.not.ismissing(lines))
3.687 + if(.not.any(ismissing(idx))) then
3.688 + asciiwrite(output_html,lines(idx))
3.689 + else
3.690 + print ("error?")
3.691 + end if
3.692 +
3.693 + delete (yvalues)
3.694 + delete (count)
3.695 + delete (idx)
3.696 +
3.697 +;************************************************************************
3.698 +; go through all ntime
3.699 +;************************************************************************
3.700 +
3.701 +; for 2 data: model and observed
3.702 + data_n = 2
3.703 +
3.704 +; using model biome class
3.705 +
3.706 + base = ndtooned(classmod)
3.707 +
3.708 +; output
3.709 +
3.710 + yvalues = new((/data_n,nx,ntime/),float)
3.711 +
3.712 +;==============================
3.713 +; put data into bins
3.714 +;==============================
3.715 +
3.716 +; Loop through each range, using base
3.717 +
3.718 + do i=0,nx-1
3.719 +
3.720 + if (i.ne.(nx-1)) then
3.721 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
3.722 + else
3.723 + idx = ind(base.ge.range(i))
3.724 + end if
3.725 +
3.726 +; loop through each dataset
3.727 +
3.728 + do n = 0,data_n-1
3.729 +
3.730 + do m = 0,ntime-1
3.731 +
3.732 + if (n .eq. 0) then
3.733 + data = ndtooned(laiob (m,:,:))
3.734 + end if
3.735 +
3.736 + if (n .eq. 1) then
3.737 + data = ndtooned(laimod(m,:,:))
3.738 + end if
3.739 +
3.740 +; Calculate average
3.741 +
3.742 + if (.not.any(ismissing(idx))) then
3.743 + yvalues(n,i,m) = avg(data(idx))
3.744 + else
3.745 + yvalues(n,i,m) = yvalues@_FillValue
3.746 + end if
3.747 +
3.748 +;#############################################################
3.749 +; using model biome class:
3.750 +;
3.751 +; set the following 4 classes to _FillValue:
3.752 +; (3)Needleleaf Deciduous Boreal Tree,
3.753 +; (8)Broadleaf Deciduous Boreal Tree,
3.754 +; (9)Broadleaf Evergreen Shrub,
3.755 +; (16)Wheat
3.756 +
3.757 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
3.758 + yvalues(n,i,m) = yvalues@_FillValue
3.759 + end if
3.760 +;#############################################################
3.761 +
3.762 + end do ; m-loop
3.763 +
3.764 + delete(data)
3.765 + end do ; n-loop
3.766 +
3.767 + delete(idx)
3.768 + end do ; i-loop
3.769 +
3.770 + good = ind(.not.ismissing(yvalues(0,:,0)))
3.771 +
3.772 + n_biome = dimsizes(good)
3.773 +
3.774 +;----------------------------------------------------------------
3.775 +; data for tseries plot
3.776 +
3.777 + yvalues_g = new((/data_n,n_biome,ntime/),float)
3.778 +
3.779 + yvalues_g@units = ""
3.780 +
3.781 + yvalues_g = yvalues(:,good,:)
3.782 +
3.783 + delete (good)
3.784 +
3.785 +;*******************************************************************
3.786 +; res for line plot
3.787 +;*******************************************************************
3.788 +; for x-axis in xyplot
3.789 + mon = ispan(1,12,1)
3.790 + mon@long_name = "month"
3.791 +
3.792 + res = True ; plot mods desired
3.793 + res@xyLineThicknesses = (/2.0,2.0,2.0/) ; make 2nd lines thicker
3.794 + res@xyLineColors = (/"blue","red"/) ; change line color
3.795 +
3.796 +; res@tiMainFontHeightF = 0.025 ; size of title
3.797 +
3.798 +; Add a boxed legend using the more simple method
3.799 + res@pmLegendDisplayMode = "Always"
3.800 +; res@pmLegendWidthF = 0.1
3.801 + res@pmLegendWidthF = 0.08
3.802 + res@pmLegendHeightF = 0.06
3.803 +; res@pmLegendOrthogonalPosF = -1.17
3.804 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
3.805 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
3.806 +
3.807 +; res@pmLegendParallelPosF = 0.18
3.808 + res@pmLegendParallelPosF = 0.23 ;(rightward)
3.809 +
3.810 +; res@lgPerimOn = False
3.811 + res@lgLabelFontHeightF = 0.015
3.812 + res@xyExplicitLegendLabels = (/"observed",model_name/)
3.813 +
3.814 +;************************************************************
3.815 +
3.816 + plot_data = new((/2,ntime/),float)
3.817 + plot_data@long_name = "Leaf Area Index"
3.818 +
3.819 +;----------------------------------------------
3.820 +; time series plot : per biome
3.821 +
3.822 + do m = 0, n_biome-1
3.823 +
3.824 + plot_name = "annual_biome_"+ m
3.825 +
3.826 + wks = gsn_open_wks (plot_type,plot_name)
3.827 +
3.828 + title = "LAI : "+ row_head(m)
3.829 + res@tiMainString = title
3.830 +
3.831 + plot_data(0,:) = yvalues_g(0,m,:)
3.832 + plot_data(1,:) = yvalues_g(1,m,:)
3.833 +
3.834 + plot = gsn_csm_xy(wks,mon,plot_data,res)
3.835 +
3.836 + delete (wks)
3.837 + delete (plot)
3.838 +
3.839 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
3.840 + "rm "+plot_name+"."+plot_type)
3.841 + end do
3.842 +
3.843 +;--------------------------------------------
3.844 +; time series plot: all biome
3.845 +
3.846 + plot_name = "annual_biome_"+ n_biome
3.847 +
3.848 + wks = gsn_open_wks (plot_type,plot_name)
3.849 +
3.850 + title = "LAI : "+ row_head(n_biome)
3.851 + res@tiMainString = title
3.852 +
3.853 + do k = 0,ntime-1
3.854 + plot_data(0,k) = avg(yvalues_g(0,:,k))
3.855 + plot_data(1,k) = avg(yvalues_g(1,:,k))
3.856 + end do
3.857 +
3.858 + plot = gsn_csm_xy(wks,mon,plot_data,res)
3.859 +
3.860 + delete (wks)
3.861 + delete (plot)
3.862 +
3.863 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
3.864 + "rm "+plot_name+"."+plot_type)
3.865 +
3.866 + delete (plot_data)
3.867 +
3.868 +;***************************************************************************
3.869 +; write total score to file
3.870 +;***************************************************************************
3.871 +
3.872 + asciiwrite("M_save.lai", M_total)
3.873 +
3.874 +;***************************************************************************
3.875 +; output plots
3.876 +;***************************************************************************
3.877 + output_dir = model_name+"/lai"
3.878 +
3.879 + system("mv *.png *.html " + output_dir)
3.880 +;***************************************************************************
3.881 +end
3.882 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/all/03.co2.ncl Mon Jan 26 22:08:20 2009 -0500
4.3 @@ -0,0 +1,593 @@
4.4 +; ***********************************************
4.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
4.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
4.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
4.8 +load dirscript + "taylor_diagram.ncl"
4.9 +;************************************************
4.10 +procedure set_line(lines:string,nline:integer,newlines:string)
4.11 +begin
4.12 +; add line to ascci/html file
4.13 +
4.14 + nnewlines = dimsizes(newlines)
4.15 + if(nline+nnewlines-1.ge.dimsizes(lines))
4.16 + print("set_line: bad index, not setting anything.")
4.17 + return
4.18 + end if
4.19 + lines(nline:nline+nnewlines-1) = newlines
4.20 +; print ("lines = " + lines(nline:nline+nnewlines-1))
4.21 + nline = nline + nnewlines
4.22 + return
4.23 +end
4.24 +;****************************************************************************
4.25 +
4.26 +begin
4.27 +
4.28 + plot_type = "ps"
4.29 + plot_type_new = "png"
4.30 +
4.31 +;-----------------------------------------------------
4.32 +; edit table.html of current model for movel1_vs_model2
4.33 +
4.34 + if (isvar("compare")) then
4.35 + html_name2 = compare+"/table.html"
4.36 + html_new2 = html_name2 +".new"
4.37 + end if
4.38 +
4.39 +;------------------------------------------------------
4.40 +; edit table.html for current model
4.41 +
4.42 + html_name = model_name+"/table.html"
4.43 + html_new = html_name +".new"
4.44 +
4.45 +;------------------------------------------------------
4.46 +; read model data
4.47 +
4.48 + fm = addfile(dirm+film3,"r")
4.49 +
4.50 + x = fm->CO2
4.51 + xi = fm->lon
4.52 + yi = fm->lat
4.53 +
4.54 + delete (fm)
4.55 +
4.56 + xdim = dimsizes(x)
4.57 + nlev = xdim(1)
4.58 + y = x(:,0,:,:)
4.59 +
4.60 +; get co2 at the lowest level
4.61 + y = x(:,nlev-1,:,:)
4.62 +
4.63 +; change to unit of observed (u mol/mol)
4.64 +; Model_units [=] kgCO2 / kgDryAir
4.65 +; 28.966 = molecular weight of dry air
4.66 +; 44. = molecular weight of CO2
4.67 +; u mol = 1e-6 mol
4.68 +
4.69 + factor = (28.966/44.) * 1e6
4.70 + y = y * factor
4.71 +
4.72 + y@_FillValue = 1.e36
4.73 + y@units = "u mol/mol"
4.74 +
4.75 +;************************************************
4.76 +; read data: observed
4.77 +;************************************************
4.78 + diri = diro + "co2/"
4.79 + fili = "co2_globalView_98.nc"
4.80 + g = addfile (diri+fili,"r")
4.81 +
4.82 + val = g->CO2_SEAS
4.83 + lon = g->LON
4.84 + lat = g->LAT
4.85 + sta = chartostring(g->STATION)
4.86 +
4.87 + delete (g)
4.88 +
4.89 + ncase = dimsizes(lat)
4.90 +;**************************************************************
4.91 +; get only the lowest level at each station
4.92 +;**************************************************************
4.93 + lat_tmp = lat
4.94 + lat_tmp@_FillValue = 1.e+36
4.95 +
4.96 + do n = 0,ncase-1
4.97 + if (.not. ismissing(lat_tmp(n))) then
4.98 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
4.99 + if (dimsizes(indexes) .gt. 1) then
4.100 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
4.101 + end if
4.102 + delete (indexes)
4.103 + end if
4.104 + end do
4.105 +
4.106 + indexes = ind(.not. ismissing(lat_tmp))
4.107 +
4.108 + lat_ob = lat(indexes)
4.109 + lon_ob = lon(indexes)
4.110 + val_ob = val(indexes,:)
4.111 +;************************************************************
4.112 +; interpolate model data into observed station
4.113 +; note: model is 0-360E, 90S-90N
4.114 +;************************************************************
4.115 +; to be able to handle observation at (-89.98,-24.80)
4.116 + yi(0) = -90.
4.117 +
4.118 + i = ind(lon_ob .lt. 0.)
4.119 + lon_ob(i) = lon_ob(i) + 360.
4.120 +
4.121 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
4.122 +
4.123 + val_model = yo(pts|:,time|:)
4.124 + val_model_0 = val_model
4.125 +;************************************************************
4.126 +; remove annual mean
4.127 +;************************************************************
4.128 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
4.129 +
4.130 +;*******************************************************************
4.131 +; res for station line plot
4.132 +;*******************************************************************
4.133 +; for x-axis in xyplot
4.134 + mon = ispan(1,12,1)
4.135 + mon@long_name = "month"
4.136 +
4.137 + res = True ; plot mods desired
4.138 + res@xyLineThicknesses = (/2.0,2.0,2.0/) ; make 2nd lines thicker
4.139 + res@xyLineColors = (/"red","blue"/) ; change line color
4.140 +
4.141 +; Add a boxed legend using the more simple method
4.142 + res@pmLegendDisplayMode = "Always"
4.143 +; res@pmLegendWidthF = 0.1
4.144 + res@pmLegendWidthF = 0.08
4.145 + res@pmLegendHeightF = 0.06
4.146 +; res@pmLegendOrthogonalPosF = -1.17
4.147 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
4.148 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
4.149 +
4.150 +; res@pmLegendParallelPosF = 0.18
4.151 + res@pmLegendParallelPosF = 0.23 ;(rightward)
4.152 +
4.153 +; res@lgPerimOn = False
4.154 + res@lgLabelFontHeightF = 0.015
4.155 + res@xyExplicitLegendLabels = (/model_name,"observed"/)
4.156 +;************************************************************
4.157 +; number of latitude zone
4.158 +;************************************************************
4.159 + nzone = 4
4.160 +
4.161 +; saving data for zone
4.162 +; number of rows for zone table (with data)
4.163 + nrow_zone = nzone
4.164 +
4.165 +; number of columns for zone table
4.166 + ncol_zone = 7
4.167 +
4.168 + text = new((/nrow_zone,ncol_zone/),string)
4.169 +
4.170 +do z = 0,nzone-1
4.171 +
4.172 + if (z .eq. 0) then
4.173 + zone = "60N-90N"
4.174 + score_max = 5.0
4.175 + ind_z = ind(lat_ob .ge. 60.)
4.176 + end if
4.177 +
4.178 + if (z .eq. 1) then
4.179 + zone = "30N-60N"
4.180 + score_max = 5.0
4.181 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
4.182 + end if
4.183 +
4.184 + if (z .eq. 2) then
4.185 + zone = "EQ-30N"
4.186 + score_max = 5.0
4.187 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
4.188 + end if
4.189 +
4.190 + if (z .eq. 3) then
4.191 + zone = "90S-EQ"
4.192 + score_max = 5.0
4.193 + ind_z = ind(lat_ob .lt. 0. )
4.194 + end if
4.195 +
4.196 + npts = dimsizes(ind_z)
4.197 +
4.198 +;------------------------------------------------------
4.199 +; for metric table computation
4.200 + amp_ob = new((/npts/),float)
4.201 + amp_model = new((/npts/),float)
4.202 +
4.203 + amp_ratio_sta = new((/npts/),float)
4.204 + ccr_sta = new((/npts/),float)
4.205 + M_sta = new((/npts/),float)
4.206 + score_sta = new((/npts/),float)
4.207 +
4.208 + var_sta = new((/npts/),float)
4.209 +;-----------------------------------------------------
4.210 +; for station line plot
4.211 + npts_str = ""
4.212 + npts_str = npts
4.213 +
4.214 + plot_data = new((/2,12,npts/),float)
4.215 + plot_data_0 = new((/12,npts/),float)
4.216 +
4.217 + plot_data!0 = "case"
4.218 + plot_data!1 = "month"
4.219 + plot_data!2 = "pts"
4.220 + plot_data@long_name = "CO2 Annual Cycle (ppm)"
4.221 +
4.222 + plot_data_0!0 = "month"
4.223 + plot_data_0!1 = "pts"
4.224 + plot_data_0@long_name = "CO2 (ppm)"
4.225 +;--------------------------------------------------------------------------
4.226 + do n=0,npts-1
4.227 +
4.228 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
4.229 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
4.230 +
4.231 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
4.232 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
4.233 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
4.234 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
4.235 +
4.236 + var_model = stddev(val_model(ind_z(n),:))
4.237 + var_ob = stddev(val_ob(ind_z(n),:))
4.238 + var_sta(n)= var_model/var_ob
4.239 +;----------------------------------------------------------------------
4.240 +; for station line plot
4.241 +
4.242 + plot_data(0,:,n) = (/val_model(ind_z(n),:)/)
4.243 + plot_data(1,:,n) = (/val_ob(ind_z(n),:)/)
4.244 +
4.245 + plot_data_0(:,n) = (/val_model_0(ind_z(n),:)/)
4.246 +
4.247 + plot_name = sta(ind_z(n))
4.248 + title = plot_name+" ("+lat(ind_z(n))+","+lon(ind_z(n))+")"
4.249 +
4.250 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
4.251 +;------------------------------------------
4.252 +; for panel plot
4.253 +
4.254 + plot=new(2,graphic) ; create graphic array
4.255 + res@gsnFrame = False ; Do not draw plot
4.256 + res@gsnDraw = False ; Do not advance frame
4.257 +
4.258 + pres = True ; panel plot mods desired
4.259 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
4.260 + ; indiv. plots in panel
4.261 + pres@gsnMaximize = True ; fill the page
4.262 +;------------------------------------------
4.263 + res@tiMainString = title ; add title
4.264 +
4.265 + plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res) ; create plot 1
4.266 +
4.267 + plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,n),res) ; create plot 2
4.268 +
4.269 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
4.270 +
4.271 + delete (wks)
4.272 + delete (plot)
4.273 +
4.274 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
4.275 + "rm "+plot_name+"."+plot_type)
4.276 +
4.277 +;---------------------------------------------------------------------------
4.278 + end do
4.279 +
4.280 +;-------------------------------------------------------------------------
4.281 +; for Taylor plot in a zone
4.282 +
4.283 +; Cases [Model]
4.284 + case = (/ model_name /)
4.285 + nCase = dimsizes(case ) ; # of Cases [Cases]
4.286 +
4.287 +; station compared
4.288 + var = sta(ind_z)
4.289 + nVar = dimsizes(var) ; # of stations
4.290 +
4.291 +; arrays to be passed to taylor plot
4.292 + ratio = new ((/nCase, nVar/),typeof(var_sta) )
4.293 + cc = new ((/nCase, nVar/),typeof(ccr_sta) )
4.294 +
4.295 + ratio(0,:) = var_sta
4.296 + cc(0,:) = ccr_sta
4.297 +
4.298 +;---------------------------------
4.299 +; create plot
4.300 +
4.301 + rest = True ; default taylor diagram
4.302 +
4.303 + rest@Markers = (/16/) ; make all solid fill
4.304 + rest@Colors = (/"red" /)
4.305 +; rest@varLabels = var
4.306 + rest@caseLabels = case
4.307 +
4.308 + rOpts = True
4.309 + rOpts@caseLabels = True
4.310 +; rOpts@caseLabelsFontHeightF = 0.05
4.311 + rOpts@caseLabelsFontHeightF = 0.15
4.312 +
4.313 + plot_name = "taylor_diagram_"+ zone
4.314 + title = "CO2 Annual Cycle: "+ zone
4.315 + rest@tiMainString = title
4.316 +
4.317 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
4.318 + plot = taylor_diagram(wks,ratio,cc,rest)
4.319 +
4.320 + delete (wks)
4.321 + delete (plot)
4.322 +
4.323 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
4.324 + "rm "+plot_name+"."+plot_type)
4.325 +
4.326 + delete (ratio)
4.327 + delete (cc)
4.328 + delete (var_sta)
4.329 + delete (var)
4.330 +
4.331 +;-------------------------------------------------------------------------
4.332 +; for line plot in a zone
4.333 +
4.334 + plot_name = "All_"+npts_str
4.335 + title = plot_name + " in "+ zone
4.336 +
4.337 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
4.338 +;-----------------------------------------
4.339 +; for panel plot
4.340 +
4.341 + plot=new(2,graphic) ; create graphic array
4.342 + res@gsnFrame = False ; Do not draw plot
4.343 + res@gsnDraw = False ; Do not advance frame
4.344 +
4.345 + pres = True ; panel plot mods desired
4.346 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
4.347 + ; indiv. plots in panel
4.348 + pres@gsnMaximize = True ; fill the page
4.349 +;-----------------------------------------
4.350 + res@tiMainString = title ; add title
4.351 +
4.352 + plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res) ; create plot 1
4.353 +
4.354 + plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
4.355 +
4.356 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
4.357 +
4.358 + delete (wks)
4.359 + delete (plot)
4.360 +
4.361 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
4.362 + "rm "+plot_name+"."+plot_type)
4.363 +
4.364 + delete (plot_data)
4.365 + delete (plot_data_0)
4.366 +;---------------------------------------------------------------------------
4.367 +; values saved for zone table
4.368 +
4.369 + amp_ratio_zone = avg(amp_ratio_sta)
4.370 + ccr_zone = avg(ccr_sta)
4.371 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
4.372 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
4.373 +
4.374 + text(z,0) = zone
4.375 + text(z,1) = sprintf("%.0f", npts)
4.376 + text(z,2) = sprintf("%.2f", amp_ratio_zone)
4.377 + text(z,3) = sprintf("%.2f", ccr_zone)
4.378 + text(z,4) = sprintf("%.2f", M_zone)
4.379 + text(z,5) = sprintf("%.2f", score_zone)
4.380 + text(z,6) = zone
4.381 +
4.382 +;*******************************************************************
4.383 +; html table -- station
4.384 +;*******************************************************************
4.385 + output_html = "score+line_"+zone+".html"
4.386 +
4.387 + header = (/"<HTML>" \
4.388 + ,"<HEAD>" \
4.389 + ,"<TITLE>CLAMP metrics</TITLE>" \
4.390 + ,"</HEAD>" \
4.391 + ,"<H1>Latitude Zone "+zone+": Model "+model_name+"</H1>" \
4.392 + /)
4.393 + footer = "</HTML>"
4.394 +
4.395 + table_header = (/ \
4.396 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
4.397 + ,"<tr>" \
4.398 + ," <th bgcolor=DDDDDD >Site Name</th>" \
4.399 + ," <th bgcolor=DDDDDD >Latitude</th>" \
4.400 + ," <th bgcolor=DDDDDD >Longitude</th>" \
4.401 + ," <th bgcolor=DDDDDD >model vs obs.<br>amplitude ratio</th>" \
4.402 + ," <th bgcolor=DDDDDD >Correlation Coef.</th>" \
4.403 + ," <th bgcolor=DDDDDD >M Score</th>" \
4.404 + ," <th bgcolor=DDDDDD >Combined Score</th>" \
4.405 + ,"</tr>" \
4.406 + /)
4.407 + table_footer = "</table>"
4.408 + row_header = "<tr>"
4.409 + row_footer = "</tr>"
4.410 +
4.411 + lines = new(50000,string)
4.412 + nline = 0
4.413 +
4.414 + set_line(lines,nline,header)
4.415 + set_line(lines,nline,table_header)
4.416 +;-----------------------------------------------
4.417 +; row of table
4.418 +
4.419 + do n = 0,npts-1
4.420 + set_line(lines,nline,row_header)
4.421 +
4.422 + txt0 = sta(ind_z(n))
4.423 + txt1 = sprintf("%5.2f", (/lat(ind_z(n))/))
4.424 + txt2 = sprintf("%5.2f", (/lon(ind_z(n))/))
4.425 + txt3 = sprintf("%5.2f", (/amp_ratio_sta(n)/))
4.426 + txt4 = sprintf("%5.2f", (/ccr_sta(n)/))
4.427 + txt5 = sprintf("%5.2f", (/M_sta(n)/))
4.428 + txt6 = sprintf("%5.2f", (/score_sta(n)/))
4.429 +
4.430 + set_line(lines,nline,"<th><a href="+txt0+".png>"+txt0+"</a></th>")
4.431 + set_line(lines,nline,"<th>"+txt1+"</th>")
4.432 + set_line(lines,nline,"<th>"+txt2+"</th>")
4.433 + set_line(lines,nline,"<th>"+txt3+"</th>")
4.434 + set_line(lines,nline,"<th>"+txt4+"</th>")
4.435 + set_line(lines,nline,"<th>"+txt5+"</th>")
4.436 + set_line(lines,nline,"<th>"+txt6+"</th>")
4.437 +
4.438 + set_line(lines,nline,row_footer)
4.439 + end do
4.440 +
4.441 +; last row, summary
4.442 + set_line(lines,nline,row_header)
4.443 +
4.444 + txt0 = "All_"+sprintf("%.0f", (/npts/))
4.445 + txt1 = "-"
4.446 + txt2 = "-"
4.447 + txt3 = sprintf("%5.2f", (/amp_ratio_zone/))
4.448 + txt4 = sprintf("%5.2f", (/ccr_zone/))
4.449 + txt5 = sprintf("%5.2f", (/M_zone/))
4.450 + txt6 = sprintf("%5.2f", (/score_zone/))
4.451 +
4.452 + set_line(lines,nline,"<th><a href="+txt0+".png>"+txt0+"</a></th>")
4.453 + set_line(lines,nline,"<th>"+txt1+"</th>")
4.454 + set_line(lines,nline,"<th>"+txt2+"</th>")
4.455 + set_line(lines,nline,"<th>"+txt3+"</th>")
4.456 + set_line(lines,nline,"<th>"+txt4+"</th>")
4.457 + set_line(lines,nline,"<th>"+txt5+"</th>")
4.458 + set_line(lines,nline,"<th>"+txt6+"</th>")
4.459 +
4.460 + set_line(lines,nline,row_footer)
4.461 +;-----------------------------------------------
4.462 + set_line(lines,nline,table_footer)
4.463 + set_line(lines,nline,footer)
4.464 +
4.465 +; Now write to an HTML file.
4.466 + idx = ind(.not.ismissing(lines))
4.467 + if(.not.any(ismissing(idx))) then
4.468 + asciiwrite(output_html,lines(idx))
4.469 + else
4.470 + print ("error?")
4.471 + end if
4.472 + delete (idx)
4.473 +;-----------------------------------------------------------------
4.474 +
4.475 + delete (ind_z)
4.476 + delete (amp_model)
4.477 + delete (amp_ob)
4.478 + delete (amp_ratio_sta)
4.479 + delete (ccr_sta)
4.480 + delete (M_sta)
4.481 + delete (score_sta)
4.482 +end do
4.483 +
4.484 +;*******************************************************************
4.485 +; html table -- zone
4.486 +;*******************************************************************
4.487 + output_html = "score+line_vs_ob.html"
4.488 +
4.489 + header = (/"<HTML>" \
4.490 + ,"<HEAD>" \
4.491 + ,"<TITLE>CLAMP metrics</TITLE>" \
4.492 + ,"</HEAD>" \
4.493 + ,"<H1>CO2 Seasonal Cycle Comparisons by Latitude Zone: Model "+model_name+"</H1>" \
4.494 + /)
4.495 + footer = "</HTML>"
4.496 +
4.497 + delete (table_header)
4.498 + table_header = (/ \
4.499 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
4.500 + ,"<tr>" \
4.501 + ," <th bgcolor=DDDDDD >Zone</th>" \
4.502 + ," <th bgcolor=DDDDDD >Number of Site</th>" \
4.503 + ," <th bgcolor=DDDDDD >model vs obs.<br>amplitide ratio</th>" \
4.504 + ," <th bgcolor=DDDDDD >Correlation Coef.</th>" \
4.505 + ," <th bgcolor=DDDDDD >M Score</th>" \
4.506 + ," <th bgcolor=DDDDDD >Combined Score</th>" \
4.507 + ," <th bgcolor=DDDDDD >Taylor diagram</th>" \
4.508 + ,"</tr>" \
4.509 + /)
4.510 + table_footer = "</table>"
4.511 + row_header = "<tr>"
4.512 + row_footer = "</tr>"
4.513 +
4.514 + lines = new(50000,string)
4.515 + nline = 0
4.516 +
4.517 + set_line(lines,nline,header)
4.518 + set_line(lines,nline,table_header)
4.519 +;-----------------------------------------------
4.520 +;row of table
4.521 +
4.522 + do n = 0,nrow_zone-1
4.523 + set_line(lines,nline,row_header)
4.524 +
4.525 + set_line(lines,nline,"<th><a href=score+line_"+text(n,0)+".html>"+text(n,0)+"</th>")
4.526 + set_line(lines,nline,"<th>"+text(n,1)+"</th>")
4.527 + set_line(lines,nline,"<th>"+text(n,2)+"</th>")
4.528 + set_line(lines,nline,"<th>"+text(n,3)+"</th>")
4.529 + set_line(lines,nline,"<th>"+text(n,4)+"</th>")
4.530 + set_line(lines,nline,"<th>"+text(n,5)+"</th>")
4.531 + set_line(lines,nline,"<th><a href=taylor_diagram_"+text(n,6)+".png>Taylor_diagram</th>")
4.532 +
4.533 + set_line(lines,nline,row_footer)
4.534 + end do
4.535 +
4.536 +; for the last row
4.537 +
4.538 + txt0 = "All"
4.539 + txt1 = sum(stringtofloat(text(0:3,1)))
4.540 + txt2 = "-"
4.541 + txt3 = "-"
4.542 + txt4 = "-"
4.543 + txt5 = sum(stringtofloat(text(0:3,5)))
4.544 + txt6 = "-"
4.545 +
4.546 + set_line(lines,nline,row_header)
4.547 +
4.548 + set_line(lines,nline,"<th>"+txt0+"</th>")
4.549 + set_line(lines,nline,"<th>"+txt1+"</th>")
4.550 + set_line(lines,nline,"<th>"+txt2+"</th>")
4.551 + set_line(lines,nline,"<th>"+txt3+"</th>")
4.552 + set_line(lines,nline,"<th>"+txt4+"</th>")
4.553 + set_line(lines,nline,"<th>"+txt5+"</th>")
4.554 + set_line(lines,nline,"<th>"+txt6+"</th>")
4.555 +
4.556 + set_line(lines,nline,row_footer)
4.557 +;-----------------------------------------------
4.558 + set_line(lines,nline,table_footer)
4.559 + set_line(lines,nline,footer)
4.560 +
4.561 +; Now write to an HTML file.
4.562 + idx = ind(.not.ismissing(lines))
4.563 + if(.not.any(ismissing(idx))) then
4.564 + asciiwrite(output_html,lines(idx))
4.565 + else
4.566 + print ("error?")
4.567 + end if
4.568 + delete (idx)
4.569 +;--------------------------------------------------------------------------
4.570 +
4.571 + M_co2 = txt5
4.572 +
4.573 + if (isvar("compare")) then
4.574 +
4.575 + system("sed -e '1,/M_co2/s/M_co2/"+M_co2+"/' "+html_name2+" > "+html_new2+";"+ \
4.576 + "mv -f "+html_new2+" "+html_name2)
4.577 + end if
4.578 +
4.579 + system("sed s#M_co2#"+M_co2+"# "+html_name+" > "+html_new+";"+ \
4.580 + "mv -f "+html_new+" "+html_name)
4.581 +
4.582 +;***************************************************************************
4.583 +; add total score and write to file
4.584 +;***************************************************************************
4.585 + M_total = M_co2
4.586 +
4.587 + asciiwrite("M_save.co2", M_total)
4.588 +
4.589 +;***************************************************************************
4.590 +; output plots
4.591 +;***************************************************************************
4.592 + output_dir = model_name+"/co2"
4.593 +
4.594 + system("mv *.png *.html " + output_dir)
4.595 +;***************************************************************************
4.596 +end
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/all/04.biomass.ncl Mon Jan 26 22:08:20 2009 -0500
5.3 @@ -0,0 +1,536 @@
5.4 +; ****************************************************
5.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
5.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
5.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
5.8 +;************************************************
5.9 +begin
5.10 +
5.11 + plot_type = "ps"
5.12 + plot_type_new = "png"
5.13 +
5.14 +;------------------------------------------------------
5.15 +; edit table.html of current model for movel1_vs_model2
5.16 +
5.17 + if (isvar("compare")) then
5.18 + html_name2 = compare+"/table.html"
5.19 + html_new2 = html_name2 +".new"
5.20 + end if
5.21 +
5.22 +;------------------------------------------------------
5.23 +; edit table.html for current model
5.24 +
5.25 + html_name = model_name+"/table.html"
5.26 + html_new = html_name +".new"
5.27 +
5.28 +;---------------------------------
5.29 +; get model data: landfrac and area
5.30 +
5.31 + film_l = "lnd_"+ model_grid + ".nc"
5.32 + fm_l = addfile (dirs+film_l,"r")
5.33 +
5.34 + landfrac = fm_l->landfrac
5.35 + area0 = fm_l->area
5.36 +
5.37 + delete (fm_l)
5.38 +
5.39 +; change area from km**2 to m**2
5.40 + area0 = area0 * 1.e6
5.41 +
5.42 +;-----------------------------
5.43 +; take into account landfrac
5.44 +
5.45 + area0 = area0 * landfrac
5.46 +
5.47 +;--------------------------------------------
5.48 +; read model data
5.49 +
5.50 + fm = addfile (dirm+film1,"r")
5.51 +
5.52 + if (BGC .eq. "cn") then
5.53 + data1 = fm->LIVESTEMC
5.54 + data2 = fm->DEADSTEMC
5.55 + data3 = fm->LEAFC
5.56 + datamod0 = data1(0,:,:)
5.57 + datamod0 = data1(0,:,:) + data2(0,:,:) + data3(0,:,:)
5.58 + end if
5.59 +
5.60 + if (BGC .eq. "casa") then
5.61 + factor_WOODC = 0.7
5.62 + data1 = fm->WOODC
5.63 + data2 = fm->LEAFC
5.64 + datamod0 = data1(0,:,:)
5.65 + datamod0 = data1(0,:,:)*factor_WOODC + data2(0,:,:)
5.66 + end if
5.67 +
5.68 +; unit: gC/m2
5.69 +
5.70 + xm = fm->lon
5.71 + ym = fm->lat
5.72 +
5.73 + delete (fm)
5.74 +
5.75 +;------------------------------------------------
5.76 +; read amazon mask data
5.77 +
5.78 + dir_m = diro + "biomass/"
5.79 + fil_m = "amazon_mask_"+ model_grid + ".nc"
5.80 + fm = addfile (dir_m+fil_m,"r")
5.81 +
5.82 + mask_amazon0 = fm->mask_amazon
5.83 +
5.84 + delete (fm)
5.85 +
5.86 +;------------------------------------------------
5.87 +; read ob data
5.88 +
5.89 + ob_name = "LC15_Amazon_Biomass"
5.90 +
5.91 + dir_b = diro + "biomass/"
5.92 + fil_b = "amazon_biomass_"+model_grid+".nc"
5.93 + fo = addfile (dir_b+fil_b,"r")
5.94 +
5.95 + dataob = fo->BIOMASS
5.96 + xo = fo->lon
5.97 + yo = fo->lat
5.98 +
5.99 + delete (fo)
5.100 +
5.101 +;************************************************
5.102 +; Units for these variables are:
5.103 +; dataob : MgC/ha
5.104 +; datamod0 : gC/m2
5.105 +; We want to convert these to KgC/m2
5.106 +; ha = 100m*100m = 10,000 m2
5.107 +; MgC/ha*1000/10,000 = KgC/m2
5.108 +
5.109 + factor_aboveground = 0.5
5.110 + factor_unit_ob = 0.1
5.111 + factor_unit_mod = 0.001
5.112 +
5.113 + dataob = dataob * factor_aboveground * factor_unit_ob
5.114 + datamod0 = datamod0 * factor_unit_mod
5.115 +
5.116 + dataob@units = "KgC/m2"
5.117 + datamod0@units = "KgC/m2"
5.118 +
5.119 + dataob@long_name = "Amazon Biomass"
5.120 + datamod0@long_name = "Amazon Biomass"
5.121 +;********************************************************
5.122 +; get subset of datamod0 that match dataob
5.123 +
5.124 + nlon = dimsizes(xo)
5.125 + nlat = dimsizes(yo)
5.126 +
5.127 + ind_lonL = ind(xm .eq. xo(0))
5.128 + ind_lonR = ind(xm .eq. xo(nlon-1))
5.129 + ind_latS = ind(ym .eq. yo(0))
5.130 + ind_latN = ind(ym .eq. yo(nlat-1))
5.131 +
5.132 + datamod = dataob
5.133 + datamod(:,:) = datamod0(ind_latS:ind_latN,ind_lonL:ind_lonR)
5.134 +
5.135 + area = dataob
5.136 + area(:,:) = area0(ind_latS:ind_latN,ind_lonL:ind_lonR)
5.137 +
5.138 + mask_amazon = dataob
5.139 + mask_amazon(:,:) = mask_amazon0(ind_latS:ind_latN,ind_lonL:ind_lonR)
5.140 +
5.141 + mask_amazon@units = ""
5.142 +;********************************************************
5.143 +; sum over amazom_mask area:
5.144 +
5.145 +; Peta g = 1.e15 g = 1.e12 Kg
5.146 + factor_unit = 1.e-12
5.147 +
5.148 +; mask_amazon = where(mask_amazon .ge. 0.5, mask_amazon ,0.)
5.149 +
5.150 + Sum_area = sum(area*mask_amazon)*factor_unit
5.151 +
5.152 + Sum_ob = sum(dataob*area*mask_amazon)*factor_unit
5.153 + Sum_mod = sum(datamod*area*mask_amazon)*factor_unit
5.154 +
5.155 + avg_ob = Sum_ob /Sum_area
5.156 + avg_mod = Sum_mod/Sum_area
5.157 +
5.158 + Sum_biomass_ob = sprintf("%.2f",Sum_ob )
5.159 + Sum_biomass_mod = sprintf("%.2f",Sum_mod)
5.160 +
5.161 +;----------------------------------------------------------------------
5.162 +; contour plot res
5.163 +
5.164 + resg = True ; Use plot options
5.165 + resg@cnFillOn = True ; Turn on color fill
5.166 + resg@gsnSpreadColors = True ; use full colormap
5.167 + resg@cnLinesOn = False ; Turn off contourn lines
5.168 + resg@mpFillOn = False ; Turn off map fill
5.169 + resg@gsnAddCyclic = False
5.170 +
5.171 + resg@gsnSpreadColors = True ; use full colormap
5.172 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
5.173 +
5.174 + resg@mpMinLatF = -21.1 ; range to zoom in on
5.175 + resg@mpMaxLatF = 13.8
5.176 + resg@mpMinLonF = 277.28
5.177 + resg@mpMaxLonF = 326.43
5.178 +;------------------------------------------------------------------------
5.179 +; mask plot
5.180 +
5.181 + plot_name = "mask_ob"
5.182 +
5.183 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
5.184 + gsn_define_colormap(wks,"gui_default") ; choose colormap
5.185 +
5.186 +;-----------------------------------------
5.187 +; plot area sum
5.188 +
5.189 + gRes = True
5.190 + gRes@txFontHeightF = 0.02
5.191 +; gRes@txAngleF = 90
5.192 +
5.193 + area_sum_text = "(mask area = "+sprintf("%.2f", Sum_area)+"e12 m2)"
5.194 +
5.195 + gsn_text_ndc(wks,area_sum_text,0.50,0.80,gRes)
5.196 +;-----------------------------------------
5.197 +
5.198 + resg@cnMinLevelValF = 0. ; Min level
5.199 + resg@cnMaxLevelValF = 1. ; Max level
5.200 + resg@cnLevelSpacingF = 0.1 ; interval
5.201 +
5.202 + resg@tiMainString = "Amazon Mask: grid = "+ model_grid
5.203 +
5.204 + plot = gsn_csm_contour_map_ce(wks,mask_amazon,resg)
5.205 +
5.206 + delete (wks)
5.207 +
5.208 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
5.209 + "rm "+plot_name+"."+plot_type)
5.210 +
5.211 +;------------------------------------------------------------------------
5.212 +; contour ob
5.213 +
5.214 + resg@cnMinLevelValF = 0. ; Min level
5.215 + resg@cnMaxLevelValF = 30. ; Max level
5.216 + resg@cnLevelSpacingF = 2. ; interval
5.217 +
5.218 + plot_name = "global_ob"
5.219 + title = ob_name+" "+ model_grid
5.220 + resg@tiMainString = title
5.221 +
5.222 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
5.223 + gsn_define_colormap(wks,"gui_default") ; choose colormap
5.224 +
5.225 + plot = gsn_csm_contour_map_ce(wks,dataob,resg)
5.226 +
5.227 + delete (wks)
5.228 +
5.229 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
5.230 + "rm "+plot_name+"."+plot_type)
5.231 +
5.232 +;------------------------------------------------------------------------
5.233 +; contour model
5.234 +
5.235 + resg@cnMinLevelValF = 0. ; Min level
5.236 + resg@cnMaxLevelValF = 30. ; Max level
5.237 + resg@cnLevelSpacingF = 2. ; interval
5.238 +
5.239 + plot_name = "global_model"
5.240 + title = "Model "+ model_name
5.241 + resg@tiMainString = title
5.242 +
5.243 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
5.244 + gsn_define_colormap(wks,"gui_default") ; choose colormap
5.245 +
5.246 + plot = gsn_csm_contour_map_ce(wks,datamod,resg)
5.247 +
5.248 + delete (wks)
5.249 +
5.250 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
5.251 + "rm "+plot_name+"."+plot_type)
5.252 +
5.253 +;------------------------------------------------------------------------
5.254 +; contour model vs ob
5.255 +
5.256 + plot_name = "global_model_vs_ob"
5.257 +
5.258 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
5.259 + gsn_define_colormap(wks,"gui_default") ; choose colormap
5.260 +
5.261 + delete (plot)
5.262 + plot=new(3,graphic) ; create graphic array
5.263 +
5.264 + resg@gsnFrame = False ; Do not draw plot
5.265 + resg@gsnDraw = False ; Do not advance frame
5.266 +
5.267 +;(d) compute correlation coef and M score
5.268 +
5.269 + uu = ndtooned(datamod)
5.270 + vv = ndtooned(dataob)
5.271 +
5.272 + good = ind(.not.ismissing(uu) .and. .not.ismissing(vv))
5.273 +
5.274 + ug = uu(good)
5.275 + vg = vv(good)
5.276 +
5.277 + ccrG = esccr(ug,vg,0)
5.278 +
5.279 + score_max = 5.0
5.280 +
5.281 +; Miomass = (ccrG*ccrG)* score_max
5.282 +; new eq
5.283 + bias = sum(abs(ug-vg)/(abs(ug)+abs(vg)))
5.284 + Mbiomass = (1. - (bias/dimsizes(ug)))*score_max
5.285 + M_biomass = sprintf("%.2f", Mbiomass)
5.286 +
5.287 + if (isvar("compare")) then
5.288 + system("sed -e '1,/M_biomass/s/M_biomass/"+M_biomass+"/' "+html_name2+" > "+html_new2+";"+ \
5.289 + "mv -f "+html_new2+" "+html_name2)
5.290 + end if
5.291 +
5.292 + system("sed s#M_biomass#"+M_biomass+"# "+html_name+" > "+html_new+";"+ \
5.293 + "mv -f "+html_new+" "+html_name)
5.294 +
5.295 +; plot correlation coef
5.296 +
5.297 + gRes = True
5.298 + gRes@txFontHeightF = 0.02
5.299 + gRes@txAngleF = 90
5.300 +
5.301 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrG)+")"
5.302 +
5.303 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
5.304 +;--------------------------------------------------------------------
5.305 +
5.306 +;(a) ob
5.307 +
5.308 + title = ob_name+" "+ model_grid
5.309 + resg@tiMainString = title
5.310 +
5.311 + plot(0) = gsn_csm_contour_map_ce(wks,dataob,resg)
5.312 +
5.313 +;(b) model
5.314 +
5.315 + title = "Model "+ model_name
5.316 + resg@tiMainString = title
5.317 +
5.318 + plot(1) = gsn_csm_contour_map_ce(wks,datamod,resg)
5.319 +
5.320 +;(c) model-ob
5.321 +
5.322 + zz = datamod
5.323 + zz = datamod - dataob
5.324 + title = "Model_"+model_name+" - Observed"
5.325 +
5.326 + resg@cnMinLevelValF = -10. ; Min level
5.327 + resg@cnMaxLevelValF = 10. ; Max level
5.328 + resg@cnLevelSpacingF = 2. ; interval
5.329 + resg@tiMainString = title
5.330 +
5.331 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
5.332 +
5.333 + pres = True ; panel plot mods desired
5.334 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
5.335 + ; indiv. plots in panel
5.336 + pres@gsnMaximize = True ; fill the page
5.337 +
5.338 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
5.339 +
5.340 + delete (wks)
5.341 + delete (plot)
5.342 + delete (zz)
5.343 +
5.344 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
5.345 + "rm "+plot_name+"."+plot_type)
5.346 +
5.347 + resg@gsnFrame = True ; draw plot
5.348 + resg@gsnDraw = True ; advance frame
5.349 +;------------------------------------------------------------------------
5.350 +; contour ob : masked
5.351 +
5.352 + resg@cnMinLevelValF = 0. ; Min level
5.353 + resg@cnMaxLevelValF = 30. ; Max level
5.354 + resg@cnLevelSpacingF = 2. ; interval
5.355 +
5.356 + plot_name = "global_mask_ob"
5.357 + title = ob_name+" "+ model_grid
5.358 + resg@tiMainString = title
5.359 +
5.360 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
5.361 + gsn_define_colormap(wks,"gui_default") ; choose colormap
5.362 +;-----------------------------------------
5.363 +; plot average over mask region
5.364 +
5.365 + gRes = True
5.366 + gRes@txFontHeightF = 0.02
5.367 + gRes@txAngleF = 0
5.368 +
5.369 + area_avg_text = "(average over mask area = "+sprintf("%.2f", avg_ob)+" Kg C/m2)"
5.370 +
5.371 + gsn_text_ndc(wks,area_avg_text,0.50,0.81,gRes)
5.372 +;-----------------------------------------
5.373 + zo = dataob
5.374 + zo = dataob*mask_amazon
5.375 + zo = where((mask_amazon .le. 0.01), zo@_FillValue, zo)
5.376 + plot = gsn_csm_contour_map_ce(wks,zo,resg)
5.377 +
5.378 + delete (wks)
5.379 + delete (plot)
5.380 +
5.381 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
5.382 + "rm "+plot_name+"."+plot_type)
5.383 +
5.384 +;------------------------------------------------------------------------
5.385 +; contour model: masked
5.386 +
5.387 + resg@cnMinLevelValF = 0. ; Min level
5.388 + resg@cnMaxLevelValF = 30. ; Max level
5.389 + resg@cnLevelSpacingF = 2. ; interval
5.390 +
5.391 + plot_name = "global_mask_model"
5.392 + title = "Model "+ model_name
5.393 + resg@tiMainString = title
5.394 +
5.395 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
5.396 + gsn_define_colormap(wks,"gui_default") ; choose colormap
5.397 +;-----------------------------------------
5.398 +; plot average over mask region
5.399 +
5.400 + gRes = True
5.401 + gRes@txFontHeightF = 0.02
5.402 + gRes@txAngleF = 0
5.403 +
5.404 + area_avg_text = "(average over mask area = "+sprintf("%.2f", avg_mod)+" Kg C/m2)"
5.405 +
5.406 + gsn_text_ndc(wks,area_avg_text,0.50,0.81,gRes)
5.407 +;-----------------------------------------
5.408 + zm = datamod
5.409 + zm = datamod*mask_amazon
5.410 + zm = where((mask_amazon .le. 0.01), zm@_FillValue, zm)
5.411 + plot = gsn_csm_contour_map_ce(wks,zm,resg)
5.412 +
5.413 + delete (wks)
5.414 + delete (plot)
5.415 +
5.416 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
5.417 + "rm "+plot_name+"."+plot_type)
5.418 +
5.419 +;------------------------------------------------------------------------
5.420 +; contour model vs ob: masked
5.421 +
5.422 + plot_name = "global_mask_vs_ob"
5.423 +
5.424 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
5.425 + gsn_define_colormap(wks,"gui_default") ; choose colormap
5.426 +
5.427 + plot=new(3,graphic) ; create graphic array
5.428 +
5.429 + resg@gsnFrame = False ; Do not draw plot
5.430 + resg@gsnDraw = False ; Do not advance frame
5.431 +
5.432 +;(d) compute correlation coef and M score
5.433 +
5.434 + delete (good)
5.435 + delete (uu)
5.436 + delete (vv)
5.437 + delete (ug)
5.438 + delete (vg)
5.439 +
5.440 + score_max = 5.
5.441 +
5.442 + uu = ndtooned(zm)
5.443 + vv = ndtooned(zo)
5.444 +
5.445 + good = ind((uu .gt. 0.) .and. (vv .gt. 0.))
5.446 +
5.447 + ug = uu(good)
5.448 + vg = vv(good)
5.449 +
5.450 + ccrG = esccr(ug,vg,0)
5.451 +
5.452 +; Miomass = (ccrG*ccrG)*score_max
5.453 +; new eq
5.454 + bias = sum(abs(ug-vg)/(abs(ug)+abs(vg)))
5.455 + Mbiomass2 = (1. - (bias/dimsizes(ug)))*score_max
5.456 + M_biomask = sprintf("%.2f", Mbiomass2)
5.457 +
5.458 + if (isvar("compare")) then
5.459 + system("sed -e '1,/M_biomask/s/M_biomask/"+M_biomask+"/' "+html_name2+" > "+html_new2+";"+ \
5.460 + "mv -f "+html_new2+" "+html_name2)
5.461 + system("sed -e '1,/Sum_biomass_ob/s/Sum_biomass_ob/"+Sum_biomass_ob+"/' "+html_name2+" > "+html_new2+";"+ \
5.462 + "mv -f "+html_new2+" "+html_name2)
5.463 + system("sed -e '1,/Sum_biomass_mod/s/Sum_biomass_mod/"+Sum_biomass_mod+"/' "+html_name2+" > "+html_new2+";"+ \
5.464 + "mv -f "+html_new2+" "+html_name2)
5.465 + end if
5.466 +
5.467 + system("sed s#M_biomask#"+M_biomask+"# "+html_name+" > "+html_new+";"+ \
5.468 + "mv -f "+html_new+" "+html_name)
5.469 + system("sed s#Sum_biomass_ob#"+Sum_biomass_ob+"# "+html_name+" > "+html_new+";"+ \
5.470 + "mv -f "+html_new+" "+html_name)
5.471 + system("sed s#Sum_biomass_mod#"+Sum_biomass_mod+"# "+html_name+" > "+html_new+";"+ \
5.472 + "mv -f "+html_new+" "+html_name)
5.473 +;--------------------------------------------------------------------
5.474 +; plot correlation coef
5.475 +
5.476 + gRes = True
5.477 + gRes@txFontHeightF = 0.02
5.478 + gRes@txAngleF = 90
5.479 +
5.480 + correlation_text = "(correlation coef = "+sprintf("%.2f", ccrG)+")"
5.481 +
5.482 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
5.483 +;--------------------------------------------------------------------
5.484 +
5.485 +;(a) ob
5.486 +
5.487 + title = ob_name+" "+ model_grid
5.488 + resg@tiMainString = title
5.489 +
5.490 + plot(0) = gsn_csm_contour_map_ce(wks,zo,resg)
5.491 +
5.492 +;(b) model
5.493 +
5.494 + title = "Model "+ model_name
5.495 + resg@tiMainString = title
5.496 +
5.497 + plot(1) = gsn_csm_contour_map_ce(wks,zm,resg)
5.498 +
5.499 +;(c) model-ob
5.500 +
5.501 + zz = zo
5.502 + zz = zm - zo
5.503 + title = "Model_"+model_name+" - Observed"
5.504 +
5.505 + resg@cnMinLevelValF = -10. ; Min level
5.506 + resg@cnMaxLevelValF = 10. ; Max level
5.507 + resg@cnLevelSpacingF = 2. ; interval
5.508 + resg@tiMainString = title
5.509 +
5.510 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
5.511 +
5.512 + pres = True ; panel plot mods desired
5.513 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
5.514 + ; indiv. plots in panel
5.515 + pres@gsnMaximize = True ; fill the page
5.516 +
5.517 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
5.518 +
5.519 + delete (wks)
5.520 + delete (plot)
5.521 +
5.522 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
5.523 + "rm "+plot_name+"."+plot_type)
5.524 +
5.525 +;***************************************************************************
5.526 +; add total score and write to file
5.527 +;***************************************************************************
5.528 + M_total = Mbiomass + Mbiomass2
5.529 +
5.530 + asciiwrite("M_save.biomass", M_total)
5.531 +
5.532 +;***************************************************************************
5.533 +; output plots
5.534 +;***************************************************************************
5.535 + output_dir = model_name+"/biomass"
5.536 +
5.537 + system("mv *.png " + output_dir)
5.538 +;***************************************************************************
5.539 +end
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/all/06.fluxnet.ncl Mon Jan 26 22:08:20 2009 -0500
6.3 @@ -0,0 +1,544 @@
6.4 +;************************************************************
6.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
6.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
6.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
6.8 +;************************************************************
6.9 +procedure set_line(lines:string,nline:integer,newlines:string)
6.10 +begin
6.11 +; add line to ascci/html file
6.12 +
6.13 + nnewlines = dimsizes(newlines)
6.14 + if(nline+nnewlines-1.ge.dimsizes(lines))
6.15 + print("set_line: bad index, not setting anything.")
6.16 + return
6.17 + end if
6.18 + lines(nline:nline+nnewlines-1) = newlines
6.19 +; print ("lines = " + lines(nline:nline+nnewlines-1))
6.20 + nline = nline + nnewlines
6.21 + return
6.22 +end
6.23 +;*************************************************************
6.24 +begin
6.25 +
6.26 + plot_type = "ps"
6.27 + plot_type_new = "png"
6.28 +
6.29 +;------------------------------------------------------
6.30 +; edit table.html of current model for movel1_vs_model2
6.31 +
6.32 + if (isvar("compare")) then
6.33 + html_name2 = compare+"/table.html"
6.34 + html_new2 = html_name2 +".new"
6.35 + end if
6.36 +
6.37 +;------------------------------------------------------
6.38 +; edit table.html for current model
6.39 +
6.40 + html_name = model_name+"/table.html"
6.41 + html_new = html_name +".new"
6.42 +
6.43 +;------------------------------------------------------
6.44 +; read model data
6.45 +
6.46 + fm = addfile(dirm+film2,"r")
6.47 +
6.48 + xm = fm->lon
6.49 + ym = fm->lat
6.50 +
6.51 + nlat = dimsizes(ym)
6.52 + nlon = dimsizes(xm)
6.53 +
6.54 +; for 4 fields, 12-monthly
6.55 + nmon = 12
6.56 + nfield = 4
6.57 +
6.58 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
6.59 +
6.60 +; change to unit of observed (u mol/m2/s)
6.61 +; Model_units [=] gC/m2/s
6.62 +; 12. = molecular weight of C
6.63 +; u mol = 1e-6 mol
6.64 + factor = 1e6 /12.
6.65 +
6.66 +if (ENERGY .eq. "old") then
6.67 +
6.68 + data = fm->NEE
6.69 + data_mod0(0,:,:,:) = data(:,:,:) * factor
6.70 + delete (data)
6.71 +
6.72 +; data = fm->LATENT
6.73 + data1 = fm->FCEV
6.74 + data2 = fm->FCTR
6.75 + data3 = fm->FGEV
6.76 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
6.77 + delete (data1)
6.78 + delete (data2)
6.79 + delete (data3)
6.80 +
6.81 +; data = fm->SENSIBLE
6.82 + data = fm->FSH
6.83 + data_mod0(3,:,:,:) = data(:,:,:)
6.84 + delete (data)
6.85 +
6.86 +; data = fm->NETRAD
6.87 + data1 = fm->FSA
6.88 + data2 = fm->FIRA
6.89 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)
6.90 + delete (data1)
6.91 + delete (data2)
6.92 +
6.93 +else
6.94 +
6.95 + data = fm->NEE
6.96 + data_mod0(0,:,:,:) = data(:,:,:) * factor
6.97 + delete (data)
6.98 +
6.99 + data = fm->NETRAD
6.100 + data_mod0(1,:,:,:) = data(:,:,:)
6.101 + delete (data)
6.102 +
6.103 + data = fm->LATENT
6.104 + data_mod0(2,:,:,:) = data(:,:,:)
6.105 + delete (data)
6.106 +
6.107 + data = fm->FSH
6.108 + data_mod0(3,:,:,:) = data(:,:,:)
6.109 + delete (data)
6.110 +end if
6.111 +
6.112 + delete (fm)
6.113 +
6.114 +;************************************************
6.115 +; read data: observed
6.116 +;************************************************
6.117 +
6.118 + station = (/"BOREAS_NSA_OBS" \
6.119 + ,"CastelPorziano" \
6.120 + ,"Hyytiala" \
6.121 + ,"Kaamanen" \
6.122 + ,"LBA_Tapajos_KM67" \
6.123 + ,"Lethbridge" \
6.124 + ,"Tharandt" \
6.125 + ,"Vielsalm" \
6.126 + /)
6.127 +
6.128 + year_ob = (/"1994-2004" \
6.129 + ,"1997-2003" \
6.130 + ,"1996-2003" \
6.131 + ,"2000-2003" \
6.132 + ,"2002-2005" \
6.133 + ,"1999-2004" \
6.134 + ,"1996-2003" \
6.135 + ,"1998-2003" \
6.136 + /)
6.137 +
6.138 + field = (/"NEE" \
6.139 + ,"Net Radiation" \
6.140 + ,"Latent Heat" \
6.141 + ,"Sensible Heat" \
6.142 + /)
6.143 +
6.144 + nstation = dimsizes(station)
6.145 + nmon = 12
6.146 + nfield = dimsizes(field)
6.147 +
6.148 + data_ob = new ((/nstation, nfield, nmon/),float)
6.149 + lat_ob = new ((/nstation/),float)
6.150 + lon_ob = new ((/nstation/),float)
6.151 +
6.152 + diri_root = diro + "fluxnet/"
6.153 +
6.154 + do n = 0,nstation-1
6.155 + diri = diri_root + station(n)+"/"
6.156 + fili = station(n)+"_"+year_ob(n)+"_monthly.nc"
6.157 + g = addfile (diri+fili,"r")
6.158 +
6.159 + lon_ob(n) = g->lon
6.160 + lat_ob(n) = g->lat
6.161 +
6.162 + data = g->CO2_FLUX
6.163 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
6.164 + delete (data)
6.165 +
6.166 + data = g->RAD_FLUX
6.167 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
6.168 + delete (data)
6.169 +
6.170 + data = g->LH_FLUX
6.171 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
6.172 + delete (data)
6.173 +
6.174 + data = g->SH_FLUX
6.175 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
6.176 + delete (data)
6.177 +
6.178 + delete (g)
6.179 + end do
6.180 +
6.181 +;************************************************************
6.182 +; interpolate model data into observed station
6.183 +; note: model is 0-360E, 90S-90N
6.184 +;************************************************************
6.185 +
6.186 +; to be able to handle observation at (-89.98,-24.80)
6.187 + ym(0) = -90.
6.188 +
6.189 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob,lat_ob,0)
6.190 +
6.191 + delete (data_mod0)
6.192 + yy!0 = "field"
6.193 + data_mod = yy(pts|:,field|:,time|:)
6.194 +
6.195 +;************************************************************
6.196 +; compute correlation coef and M score
6.197 +;************************************************************
6.198 +
6.199 + score_max = 5.
6.200 +
6.201 + ccr = new ((/nstation, nfield/),float)
6.202 + M_score = new ((/nstation, nfield/),float)
6.203 +
6.204 + do n=0,nstation-1
6.205 + do m=0,nfield-1
6.206 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
6.207 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
6.208 + M_score(n,m) = (1. -(bias/nmon)) * score_max
6.209 + end do
6.210 + end do
6.211 +
6.212 + M_nee = avg(M_score(:,0))
6.213 + M_rad = avg(M_score(:,1))
6.214 + M_lh = avg(M_score(:,2))
6.215 + M_sh = avg(M_score(:,3))
6.216 + M_all = M_nee+ M_rad +M_lh + M_sh
6.217 +
6.218 + M_fluxnet_nee = sprintf("%.2f", M_nee)
6.219 + M_fluxnet_rad = sprintf("%.2f", M_rad)
6.220 + M_fluxnet_lh = sprintf("%.2f", M_lh )
6.221 + M_fluxnet_sh = sprintf("%.2f", M_sh )
6.222 + M_fluxnet_all = sprintf("%.2f", M_all)
6.223 +
6.224 +;*******************************************************************
6.225 +; for station line plot
6.226 +;*******************************************************************
6.227 +
6.228 +; for x-axis in xyplot
6.229 + mon = ispan(1,12,1)
6.230 + mon@long_name = "month"
6.231 +
6.232 + res = True ; plot mods desired
6.233 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
6.234 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
6.235 +;-------------------------------------------------------------------------
6.236 +; Add a boxed legend using the more simple method
6.237 +
6.238 + res@pmLegendDisplayMode = "Always"
6.239 +; res@pmLegendWidthF = 0.1
6.240 + res@pmLegendWidthF = 0.08
6.241 + res@pmLegendHeightF = 0.06
6.242 +; res@pmLegendOrthogonalPosF = -1.17
6.243 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
6.244 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
6.245 +
6.246 +; res@pmLegendParallelPosF = 0.18
6.247 + res@pmLegendParallelPosF = 0.23 ;(rightward)
6.248 +
6.249 +; res@lgPerimOn = False
6.250 + res@lgLabelFontHeightF = 0.015
6.251 + res@xyExplicitLegendLabels = (/"observed",model_name/)
6.252 +;-------------------------------------------------------------------
6.253 +; for panel plot
6.254 + res@gsnFrame = False ; Do not draw plot
6.255 + res@gsnDraw = False ; Do not advance frame
6.256 +
6.257 + pres = True ; panel plot mods desired
6.258 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
6.259 + ; indiv. plots in panel
6.260 + pres@gsnMaximize = True ; fill the page
6.261 +;-------------------------------------------------------------------
6.262 +
6.263 + plot_data = new((/2,12/),float)
6.264 + plot_data!0 = "case"
6.265 + plot_data!1 = "month"
6.266 +
6.267 +; change longitude from 0-360 to -180-180
6.268 + lon_ob = where(lon_ob .gt. 180.,lon_ob-360., lon_ob)
6.269 +
6.270 + do n = 0,nstation-1
6.271 +;----------------------------
6.272 +; for observed
6.273 +
6.274 + plot_name = station(n)+"_ob"
6.275 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
6.276 + res@tiMainString = title
6.277 +
6.278 + wks = gsn_open_wks (plot_type,plot_name)
6.279 + plot=new(4,graphic) ; create graphic array
6.280 +
6.281 + plot_data(0,:) = (/data_ob (n,0,:)/)
6.282 + plot_data@long_name = field(0)
6.283 + plot(0)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 1
6.284 +
6.285 + plot_data(0,:) = (/data_ob (n,1,:)/)
6.286 + plot_data@long_name = field(1)
6.287 + plot(1)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 2
6.288 +
6.289 + plot_data(0,:) = (/data_ob (n,2,:)/)
6.290 + plot_data@long_name = field(2)
6.291 + plot(2)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 3
6.292 +
6.293 + plot_data(0,:) = (/data_ob (n,3,:)/)
6.294 + plot_data@long_name = field(3)
6.295 + plot(3)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 4
6.296 +
6.297 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
6.298 +
6.299 + delete (wks)
6.300 + delete (plot)
6.301 +
6.302 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
6.303 + "rm "+plot_name+"."+plot_type)
6.304 +
6.305 +;----------------------------
6.306 +; for model_vs_ob
6.307 +
6.308 + plot_name = station(n)+"_model_vs_ob"
6.309 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
6.310 + res@tiMainString = title
6.311 +
6.312 + wks = gsn_open_wks (plot_type,plot_name)
6.313 + plot=new(4,graphic) ; create graphic array
6.314 +
6.315 + plot_data(0,:) = (/data_ob (n,0,:)/)
6.316 + plot_data(1,:) = (/data_mod(n,0,:)/)
6.317 + plot_data@long_name = field(0)
6.318 + plot(0)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 1
6.319 +
6.320 + plot_data(0,:) = (/data_ob (n,1,:)/)
6.321 + plot_data(1,:) = (/data_mod(n,1,:)/)
6.322 + plot_data@long_name = field(1)
6.323 + plot(1)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 2
6.324 +
6.325 + plot_data(0,:) = (/data_ob (n,2,:)/)
6.326 + plot_data(1,:) = (/data_mod(n,2,:)/)
6.327 + plot_data@long_name = field(2)
6.328 + plot(2)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 3
6.329 +
6.330 + plot_data(0,:) = (/data_ob (n,3,:)/)
6.331 + plot_data(1,:) = (/data_mod(n,3,:)/)
6.332 + plot_data@long_name = field(3)
6.333 + plot(3)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 4
6.334 +
6.335 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
6.336 +
6.337 + delete (wks)
6.338 + delete (plot)
6.339 +
6.340 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
6.341 + "rm "+plot_name+"."+plot_type)
6.342 + end do
6.343 +
6.344 +;*******************************************************************
6.345 +; html table of site: observed
6.346 +;*******************************************************************
6.347 + output_html = "line_ob.html"
6.348 +
6.349 + header = (/"<HTML>" \
6.350 + ,"<HEAD>" \
6.351 + ,"<TITLE>CLAMP metrics</TITLE>" \
6.352 + ,"</HEAD>" \
6.353 + ,"<H1>Fluxnet at Site: Observation</H1>" \
6.354 + /)
6.355 + footer = "</HTML>"
6.356 +
6.357 + table_header = (/ \
6.358 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
6.359 + ,"<tr>" \
6.360 + ," <th bgcolor=DDDDDD >Site Name</th>" \
6.361 + ," <th bgcolor=DDDDDD >Latitude</th>" \
6.362 + ," <th bgcolor=DDDDDD >Longitude</th>" \
6.363 + ," <th bgcolor=DDDDDD >Observed</th>" \
6.364 + ,"</tr>" \
6.365 + /)
6.366 + table_footer = "</table>"
6.367 + row_header = "<tr>"
6.368 + row_footer = "</tr>"
6.369 +
6.370 + lines = new(50000,string)
6.371 + nline = 0
6.372 +
6.373 + set_line(lines,nline,header)
6.374 + set_line(lines,nline,table_header)
6.375 +;-----------------------------------------------
6.376 +; row of table
6.377 +
6.378 + do n = 0,nstation-1
6.379 + set_line(lines,nline,row_header)
6.380 +
6.381 + txt0 = station(n)
6.382 + txt1 = sprintf("%5.2f", lat_ob(n))
6.383 + txt2 = sprintf("%5.2f", lon_ob(n))
6.384 + txt3 = year_ob(n)
6.385 +
6.386 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
6.387 + set_line(lines,nline,"<th>"+txt1+"</th>")
6.388 + set_line(lines,nline,"<th>"+txt2+"</th>")
6.389 + set_line(lines,nline,"<th>"+txt3+"</th>")
6.390 +
6.391 + set_line(lines,nline,row_footer)
6.392 + end do
6.393 +;-----------------------------------------------
6.394 + set_line(lines,nline,table_footer)
6.395 + set_line(lines,nline,footer)
6.396 +
6.397 +; Now write to an HTML file.
6.398 + idx = ind(.not.ismissing(lines))
6.399 + if(.not.any(ismissing(idx))) then
6.400 + asciiwrite(output_html,lines(idx))
6.401 + else
6.402 + print ("error?")
6.403 + end if
6.404 + delete (idx)
6.405 +
6.406 +;*******************************************************************
6.407 +; score and line table : model vs observed
6.408 +;*******************************************************************
6.409 + output_html = "score+line_vs_ob.html"
6.410 +
6.411 + header = (/"<HTML>" \
6.412 + ,"<HEAD>" \
6.413 + ,"<TITLE>CLAMP metrics</TITLE>" \
6.414 + ,"</HEAD>" \
6.415 + ,"<H1>Fluxnet at Site: Model "+model_name+"</H1>" \
6.416 + /)
6.417 + footer = "</HTML>"
6.418 +
6.419 + delete (table_header)
6.420 + table_header = (/ \
6.421 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
6.422 + ,"<tr>" \
6.423 + ," <th bgcolor=DDDDDD >Site Name</th>" \
6.424 + ," <th bgcolor=DDDDDD >Latitude</th>" \
6.425 + ," <th bgcolor=DDDDDD >Longitude</th>" \
6.426 + ," <th bgcolor=DDDDDD >Observed</th>" \
6.427 + ," <th bgcolor=DDDDDD >NEE</th>" \
6.428 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
6.429 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
6.430 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
6.431 + ," <th bgcolor=DDDDDD >Average</th>" \
6.432 + ,"</tr>" \
6.433 + /)
6.434 + table_footer = "</table>"
6.435 + row_header = "<tr>"
6.436 + row_footer = "</tr>"
6.437 +
6.438 + lines = new(50000,string)
6.439 + nline = 0
6.440 +
6.441 + set_line(lines,nline,header)
6.442 + set_line(lines,nline,table_header)
6.443 +;-----------------------------------------------
6.444 +; row of table
6.445 +
6.446 + do n = 0,nstation-1
6.447 + set_line(lines,nline,row_header)
6.448 +
6.449 + txt0 = station(n)
6.450 + txt1 = sprintf("%5.2f", lat_ob(n))
6.451 + txt2 = sprintf("%5.2f", lon_ob(n))
6.452 + txt3 = year_ob(n)
6.453 + txt4 = sprintf("%5.2f", M_score(n,0))
6.454 + txt5 = sprintf("%5.2f", M_score(n,1))
6.455 + txt6 = sprintf("%5.2f", M_score(n,2))
6.456 + txt7 = sprintf("%5.2f", M_score(n,3))
6.457 + txt8 = sprintf("%5.2f", avg(M_score(n,:)))
6.458 +
6.459 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
6.460 + set_line(lines,nline,"<th>"+txt1+"</th>")
6.461 + set_line(lines,nline,"<th>"+txt2+"</th>")
6.462 + set_line(lines,nline,"<th>"+txt3+"</th>")
6.463 + set_line(lines,nline,"<th>"+txt4+"</th>")
6.464 + set_line(lines,nline,"<th>"+txt5+"</th>")
6.465 + set_line(lines,nline,"<th>"+txt6+"</th>")
6.466 + set_line(lines,nline,"<th>"+txt7+"</th>")
6.467 + set_line(lines,nline,"<th>"+txt8+"</th>")
6.468 +
6.469 + set_line(lines,nline,row_footer)
6.470 + end do
6.471 +
6.472 +; last row, summary
6.473 + set_line(lines,nline,row_header)
6.474 +
6.475 + txt0 = "All_"+sprintf("%.0f", nstation)
6.476 + txt1 = "-"
6.477 + txt2 = "-"
6.478 + txt3 = "-"
6.479 + txt4 = M_fluxnet_nee
6.480 + txt5 = M_fluxnet_rad
6.481 + txt6 = M_fluxnet_lh
6.482 + txt7 = M_fluxnet_sh
6.483 + txt8 = M_fluxnet_all
6.484 +
6.485 + set_line(lines,nline,"<th>"+txt0+"</th>")
6.486 + set_line(lines,nline,"<th>"+txt1+"</th>")
6.487 + set_line(lines,nline,"<th>"+txt2+"</th>")
6.488 + set_line(lines,nline,"<th>"+txt3+"</th>")
6.489 + set_line(lines,nline,"<th>"+txt4+"</th>")
6.490 + set_line(lines,nline,"<th>"+txt5+"</th>")
6.491 + set_line(lines,nline,"<th>"+txt6+"</th>")
6.492 + set_line(lines,nline,"<th>"+txt7+"</th>")
6.493 + set_line(lines,nline,"<th>"+txt8+"</th>")
6.494 +
6.495 + set_line(lines,nline,row_footer)
6.496 +;-----------------------------------------------
6.497 + set_line(lines,nline,table_footer)
6.498 + set_line(lines,nline,footer)
6.499 +
6.500 +; Now write to an HTML file.
6.501 + idx = ind(.not.ismissing(lines))
6.502 + if(.not.any(ismissing(idx))) then
6.503 + asciiwrite(output_html,lines(idx))
6.504 + else
6.505 + print ("error?")
6.506 + end if
6.507 + delete (idx)
6.508 +
6.509 +;**************************************************************************************
6.510 +; update score
6.511 +;**************************************************************************************
6.512 +
6.513 + if (isvar("compare")) then
6.514 + system("sed -e '1,/M_fluxnet_nee/s/M_fluxnet_nee/"+M_fluxnet_nee+"/' "+html_name2+" > "+html_new2+";"+ \
6.515 + "mv -f "+html_new2+" "+html_name2+";"+ \
6.516 + "sed -e '1,/M_fluxnet_rad/s/M_fluxnet_rad/"+M_fluxnet_rad+"/' "+html_name2+" > "+html_new2+";"+ \
6.517 + "mv -f "+html_new2+" "+html_name2+";"+ \
6.518 + "sed -e '1,/M_fluxnet_lh/s/M_fluxnet_lh/"+M_fluxnet_lh+"/' "+html_name2+" > "+html_new2+";"+ \
6.519 + "mv -f "+html_new2+" "+html_name2+";"+ \
6.520 + "sed -e '1,/M_fluxnet_sh/s/M_fluxnet_sh/"+M_fluxnet_sh+"/' "+html_name2+" > "+html_new2+";"+ \
6.521 + "mv -f "+html_new2+" "+html_name2)
6.522 + end if
6.523 +
6.524 + system("sed s#M_fluxnet_nee#"+M_fluxnet_nee+"# "+html_name+" > "+html_new+";"+ \
6.525 + "mv -f "+html_new+" "+html_name+";"+ \
6.526 + "sed s#M_fluxnet_rad#"+M_fluxnet_rad+"# "+html_name+" > "+html_new+";"+ \
6.527 + "mv -f "+html_new+" "+html_name+";"+ \
6.528 + "sed s#M_fluxnet_lh#"+M_fluxnet_lh+"# "+html_name+" > "+html_new+";"+ \
6.529 + "mv -f "+html_new+" "+html_name+";"+ \
6.530 + "sed s#M_fluxnet_sh#"+M_fluxnet_sh+"# "+html_name+" > "+html_new+";"+ \
6.531 + "mv -f "+html_new+" "+html_name)
6.532 +
6.533 +;***************************************************************************
6.534 +; add total score and write to file
6.535 +;***************************************************************************
6.536 + M_total = M_fluxnet_all
6.537 +
6.538 + asciiwrite("M_save.fluxnet", M_total)
6.539 +
6.540 +;***************************************************************************
6.541 +; output plots
6.542 +;***************************************************************************
6.543 + output_dir = model_name+"/fluxnet"
6.544 +
6.545 + system("mv *.png *.html " + output_dir)
6.546 +;***************************************************************************
6.547 +end
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/all/07.beta.ncl Mon Jan 26 22:08:20 2009 -0500
7.3 @@ -0,0 +1,541 @@
7.4 +;********************************************************
7.5 +; hardwired: co2_i = 283.1878
7.6 +; co2_f = 364.1252
7.7 +;
7.8 +; beta_4_ob = 0.6
7.9 +;**************************************************************
7.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
7.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
7.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
7.13 +;**************************************************************
7.14 +procedure set_line(lines:string,nline:integer,newlines:string)
7.15 +begin
7.16 +; add line to ascci/html file
7.17 +
7.18 + nnewlines = dimsizes(newlines)
7.19 + if(nline+nnewlines-1.ge.dimsizes(lines))
7.20 + print("set_line: bad index, not setting anything.")
7.21 + return
7.22 + end if
7.23 + lines(nline:nline+nnewlines-1) = newlines
7.24 +; print ("lines = " + lines(nline:nline+nnewlines-1))
7.25 + nline = nline + nnewlines
7.26 + return
7.27 +end
7.28 +;**************************************************************
7.29 +; Main code.
7.30 +begin
7.31 +
7.32 + plot_type = "ps"
7.33 + plot_type_new = "png"
7.34 +
7.35 +;------------------------------------------------------
7.36 +; edit table.html of current model for movel1_vs_model2
7.37 +
7.38 + if (isvar("compare")) then
7.39 + html_name2 = compare+"/table.html"
7.40 + html_new2 = html_name2 +".new"
7.41 + end if
7.42 +
7.43 +;-------------------------------------------------------
7.44 +; edit table.html for current model
7.45 +
7.46 + html_name = model_name+"/table.html"
7.47 + html_new = html_name +".new"
7.48 +
7.49 +;-------------------------------------------------------
7.50 +; read model data
7.51 +
7.52 +;###############################################################
7.53 +; hardwired for model data
7.54 +
7.55 +; these values correspond to the start and the end of model data
7.56 + co2_i = 283.1878
7.57 + co2_f = 364.1252
7.58 +
7.59 + film_i = film6
7.60 + film_f = film5
7.61 +;###############################################################
7.62 +
7.63 + fm_i = addfile (dirm+film_i,"r")
7.64 + fm_f = addfile (dirm+film_f,"r")
7.65 +
7.66 + xm = fm_f->lon
7.67 + ym = fm_f->lat
7.68 +
7.69 + npp_i = fm_i->NPP
7.70 + npp_f = fm_f->NPP
7.71 +
7.72 + delete (fm_i)
7.73 + delete (fm_f)
7.74 +
7.75 +;Units for these variables are:
7.76 +;npp_i: g C/m^2/s
7.77 +
7.78 + nsec_per_year = 60*60*24*365
7.79 +
7.80 + npp_i = npp_i * nsec_per_year
7.81 + npp_f = npp_f * nsec_per_year
7.82 +
7.83 + unit = "gC/m2/year"
7.84 +
7.85 +;------------------------------
7.86 +; get landfrac data
7.87 +
7.88 + film_l = "lnd_" + model_grid + ".nc"
7.89 + fm_l = addfile (dirs+film_l,"r")
7.90 + landfrac = fm_l->landfrac
7.91 +
7.92 + npp_i(0,:,:) = npp_i(0,:,:) * landfrac(:,:)
7.93 + npp_f(0,:,:) = npp_f(0,:,:) * landfrac(:,:)
7.94 +
7.95 + delete (fm_l)
7.96 + delete (landfrac)
7.97 +
7.98 +;-----------------------------
7.99 +; read biome data: model
7.100 +
7.101 + biome_name_mod = "Model PFT Class"
7.102 +
7.103 + film_c = "class_pft_"+model_grid+".nc"
7.104 + fm_c = addfile (dirs+film_c,"r")
7.105 + classmod = fm_c->CLASS_PFT
7.106 +
7.107 + delete (fm_c)
7.108 +
7.109 +; model data has 17 land-type classes
7.110 + nclass_mod = 17
7.111 +
7.112 +;---------------------------------------------------
7.113 +; read data: observed at stations
7.114 +
7.115 + station = (/"DukeFACE" \
7.116 + ,"AspenFACE" \
7.117 + ,"ORNL-FACE" \
7.118 + ,"POP-EUROFACE" \
7.119 + /)
7.120 +
7.121 + lat_ob = (/ 35.58, 45.40, 35.54, 42.22/)
7.122 + lon_ob = (/-79.05, -89.37, -84.20, 11.48/)
7.123 + lon_obx = where(lon_ob.lt.0.,lon_ob+360.,lon_ob)
7.124 +
7.125 + n_sta = dimsizes(station)
7.126 + beta_4_ob = new((/n_sta/),float)
7.127 +
7.128 +;###################################################
7.129 +; this is a hardwired value
7.130 + beta_4_ob = 0.60
7.131 +;###################################################
7.132 +;---------------------------------------------------
7.133 +; get model data at station
7.134 +
7.135 + npp_i_4 =linint2_points(xm,ym,npp_i,True,lon_obx,lat_ob,0)
7.136 +
7.137 + npp_f_4 =linint2_points(xm,ym,npp_f,True,lon_obx,lat_ob,0)
7.138 +
7.139 +;---------------------------------------------------
7.140 +;compute beta_4
7.141 +
7.142 + score_max = 3.
7.143 +
7.144 + beta_4 = new((/n_sta/),float)
7.145 +
7.146 + beta_4 = ((npp_f_4/npp_i_4) - 1.)/log(co2_f/co2_i)
7.147 +
7.148 + beta_4_avg = avg(beta_4)
7.149 +
7.150 + bias = sum(abs(beta_4-beta_4_ob)/(abs(beta_4)+abs(beta_4_ob)))
7.151 + Mbeta = (1. - (bias/n_sta))*score_max
7.152 + M_beta = sprintf("%.2f", Mbeta)
7.153 +
7.154 +;=========================
7.155 +; for html table - station
7.156 +;=========================
7.157 +
7.158 + output_html = "table_station.html"
7.159 +
7.160 +; column (not including header column)
7.161 +
7.162 + col_head = (/"Latitude","Longitude","CO2_i","CO2_f","NPP_i","NPP_f","Beta_model","Beta_ob"/)
7.163 +
7.164 + ncol = dimsizes(col_head)
7.165 +
7.166 +; row (not including header row)
7.167 + row_head = (/"DukeFACE" \
7.168 + ,"AspenFACE" \
7.169 + ,"ORNL-FACE" \
7.170 + ,"POP-EUROFACE" \
7.171 + ,"All Station" \
7.172 + /)
7.173 + nrow = dimsizes(row_head)
7.174 +
7.175 +; arrays to be passed to table.
7.176 + text = new ((/nrow, ncol/),string )
7.177 +
7.178 + do i=0,nrow-2
7.179 + text(i,0) = sprintf("%.1f",lat_ob(i))
7.180 + text(i,1) = sprintf("%.1f",lon_ob(i))
7.181 + text(i,2) = sprintf("%.1f",co2_i)
7.182 + text(i,3) = sprintf("%.1f",co2_f)
7.183 + text(i,4) = sprintf("%.1f",npp_i_4(0,i))
7.184 + text(i,5) = sprintf("%.1f",npp_f_4(0,i))
7.185 + text(i,6) = sprintf("%.2f",beta_4(i))
7.186 + text(i,7) = "-"
7.187 + end do
7.188 + text(nrow-1,0) = "-"
7.189 + text(nrow-1,1) = "-"
7.190 + text(nrow-1,2) = "-"
7.191 + text(nrow-1,3) = "-"
7.192 + text(nrow-1,4) = "-"
7.193 + text(nrow-1,5) = "-"
7.194 + text(nrow-1,6) = sprintf("%.2f",beta_4_avg)
7.195 + text(nrow-1,7) = sprintf("%.2f",avg(beta_4_ob))
7.196 +
7.197 +;-----------
7.198 +; html table
7.199 +;-----------
7.200 +
7.201 + header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
7.202 +
7.203 + header = (/"<HTML>" \
7.204 + ,"<HEAD>" \
7.205 + ,"<TITLE>CLAMP metrics</TITLE>" \
7.206 + ,"</HEAD>" \
7.207 + ,header_text \
7.208 + /)
7.209 + footer = "</HTML>"
7.210 +
7.211 + table_header = (/ \
7.212 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
7.213 + ,"<tr>" \
7.214 + ," <th bgcolor=DDDDDD >Station</th>" \
7.215 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
7.216 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
7.217 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
7.218 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
7.219 + ," <th bgcolor=DDDDDD >"+col_head(4)+"<br>("+unit+")</th>" \
7.220 + ," <th bgcolor=DDDDDD >"+col_head(5)+"<br>("+unit+")</th>" \
7.221 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
7.222 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
7.223 + ,"</tr>" \
7.224 + /)
7.225 + table_footer = "</table>"
7.226 + row_header = "<tr>"
7.227 + row_footer = "</tr>"
7.228 +
7.229 + lines = new(50000,string)
7.230 + nline = 0
7.231 +
7.232 + set_line(lines,nline,header)
7.233 + set_line(lines,nline,table_header)
7.234 +;-----------------------------------------------
7.235 +;row of table
7.236 +
7.237 + do n = 0,nrow-1
7.238 + set_line(lines,nline,row_header)
7.239 +
7.240 + txt1 = row_head(n)
7.241 + txt2 = text(n,0)
7.242 + txt3 = text(n,1)
7.243 + txt4 = text(n,2)
7.244 + txt5 = text(n,3)
7.245 + txt6 = text(n,4)
7.246 + txt7 = text(n,5)
7.247 + txt8 = text(n,6)
7.248 + txt9 = text(n,7)
7.249 +
7.250 + set_line(lines,nline,"<th>"+txt1+"</th>")
7.251 + set_line(lines,nline,"<th>"+txt2+"</th>")
7.252 + set_line(lines,nline,"<th>"+txt3+"</th>")
7.253 + set_line(lines,nline,"<th>"+txt4+"</th>")
7.254 + set_line(lines,nline,"<th>"+txt5+"</th>")
7.255 + set_line(lines,nline,"<th>"+txt6+"</th>")
7.256 + set_line(lines,nline,"<th>"+txt7+"</th>")
7.257 + set_line(lines,nline,"<th>"+txt8+"</th>")
7.258 + set_line(lines,nline,"<th>"+txt9+"</th>")
7.259 +
7.260 + set_line(lines,nline,row_footer)
7.261 + end do
7.262 +;-----------------------------------------------
7.263 + set_line(lines,nline,table_footer)
7.264 + set_line(lines,nline,footer)
7.265 +
7.266 +; Now write to an HTML file.
7.267 + idx = ind(.not.ismissing(lines))
7.268 + if(.not.any(ismissing(idx))) then
7.269 + asciiwrite(output_html,lines(idx))
7.270 + else
7.271 + print ("error?")
7.272 + end if
7.273 +
7.274 + delete (col_head)
7.275 + delete (row_head)
7.276 + delete (text)
7.277 + delete (table_header)
7.278 + delete (idx)
7.279 +
7.280 +;********************************************************************
7.281 +; use land-type class to bin the data in equally spaced ranges
7.282 +;********************************************************************
7.283 +
7.284 +; using model biome class
7.285 + nclass = nclass_mod
7.286 +
7.287 + range = fspan(0,nclass,nclass+1)
7.288 +
7.289 +; Use this range information to grab all the values in a
7.290 +; particular range, and then take an average.
7.291 +
7.292 + nx = dimsizes(range) - 1
7.293 +
7.294 +;==============================
7.295 +; put data into bins
7.296 +;==============================
7.297 +
7.298 +; for model data and observed
7.299 + data_n = 2
7.300 +
7.301 +; using model biome class
7.302 +
7.303 + base = ndtooned(classmod)
7.304 +
7.305 +; output
7.306 +
7.307 + yvalues = new((/data_n,nx/),float)
7.308 + count = new((/data_n,nx/),float)
7.309 +
7.310 +; Loop through each range, using base
7.311 +
7.312 + do i=0,nx-1
7.313 +
7.314 + if (i.ne.(nx-1)) then
7.315 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
7.316 + else
7.317 + idx = ind(base.ge.range(i))
7.318 + end if
7.319 +
7.320 +; loop through each dataset
7.321 +
7.322 + do n = 0,data_n-1
7.323 +
7.324 + if (n .eq. 0) then
7.325 + data = ndtooned(npp_i)
7.326 + end if
7.327 +
7.328 + if (n .eq. 1) then
7.329 + data = ndtooned(npp_f)
7.330 + end if
7.331 +
7.332 +; Calculate average
7.333 +
7.334 + if (.not.any(ismissing(idx))) then
7.335 + yvalues(n,i) = avg(data(idx))
7.336 + count(n,i) = dimsizes(idx)
7.337 + else
7.338 + yvalues(n,i) = yvalues@_FillValue
7.339 + count(n,i) = 0
7.340 + end if
7.341 +
7.342 +;#############################################################
7.343 +; using model biome class:
7.344 +;
7.345 +; set the following 4 classes to _FillValue:
7.346 +; (3)Needleleaf Deciduous Boreal Tree,
7.347 +; (8)Broadleaf Deciduous Boreal Tree,
7.348 +; (9)Broadleaf Evergreen Shrub,
7.349 +; (16)Wheat
7.350 +
7.351 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
7.352 + yvalues(n,i) = yvalues@_FillValue
7.353 + count(n,i) = 0
7.354 + end if
7.355 +;#############################################################
7.356 +
7.357 + delete(data)
7.358 + end do ; n-loop
7.359 +
7.360 + delete(idx)
7.361 + end do ; i-loop
7.362 +
7.363 + delete (base)
7.364 + delete (npp_i)
7.365 + delete (npp_f)
7.366 +
7.367 +;============================
7.368 +;compute beta
7.369 +;============================
7.370 +
7.371 + u = yvalues(0,:)
7.372 + v = yvalues(1,:)
7.373 + u_count = count(0,:)
7.374 + v_count = count(1,:)
7.375 +
7.376 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
7.377 +
7.378 + uu = u(good)
7.379 + vv = v(good)
7.380 + uu_count = u_count(good)
7.381 + vv_count = v_count(good)
7.382 +
7.383 + n_biome = dimsizes(uu)
7.384 + beta_biome = new((/n_biome/),float)
7.385 +
7.386 + beta_biome = ((vv/uu) - 1.)/log(co2_f/co2_i)
7.387 +
7.388 + beta_biome_avg = (sum(vv*vv_count)/sum(uu*uu_count) - 1.)/log(co2_f/co2_i)
7.389 +
7.390 +;===========================
7.391 +; for html table - biome
7.392 +;===========================
7.393 +
7.394 + output_html = "table_biome.html"
7.395 +
7.396 +; column (not including header column)
7.397 +
7.398 + col_head = (/"CO2_i","CO2_f","NPP_i","NPP_f","Beta_model"/)
7.399 +
7.400 + ncol = dimsizes(col_head)
7.401 +
7.402 +; row (not including header row)
7.403 +
7.404 +;----------------------------------------------------
7.405 +; using model biome class:
7.406 +;
7.407 + row_head = (/"Not Vegetated" \
7.408 + ,"Needleleaf Evergreen Temperate Tree" \
7.409 + ,"Needleleaf Evergreen Boreal Tree" \
7.410 +; ,"Needleleaf Deciduous Boreal Tree" \
7.411 + ,"Broadleaf Evergreen Tropical Tree" \
7.412 + ,"Broadleaf Evergreen Temperate Tree" \
7.413 + ,"Broadleaf Deciduous Tropical Tree" \
7.414 + ,"Broadleaf Deciduous Temperate Tree" \
7.415 +; ,"Broadleaf Deciduous Boreal Tree" \
7.416 +; ,"Broadleaf Evergreen Shrub" \
7.417 + ,"Broadleaf Deciduous Temperate Shrub" \
7.418 + ,"Broadleaf Deciduous Boreal Shrub" \
7.419 + ,"C3 Arctic Grass" \
7.420 + ,"C3 Non-Arctic Grass" \
7.421 + ,"C4 Grass" \
7.422 + ,"Corn" \
7.423 +; ,"Wheat" \
7.424 + ,"All Biome" \
7.425 + /)
7.426 +
7.427 + nrow = dimsizes(row_head)
7.428 +
7.429 +; arrays to be passed to table.
7.430 + text = new ((/nrow, ncol/),string )
7.431 +
7.432 + do i=0,nrow-2
7.433 + text(i,0) = sprintf("%.1f",co2_i)
7.434 + text(i,1) = sprintf("%.1f",co2_f)
7.435 + text(i,2) = sprintf("%.1f",uu(i))
7.436 + text(i,3) = sprintf("%.1f",vv(i))
7.437 + text(i,4) = sprintf("%.2f",beta_biome(i))
7.438 + end do
7.439 + text(nrow-1,0) = "-"
7.440 + text(nrow-1,1) = "-"
7.441 + text(nrow-1,2) = "-"
7.442 + text(nrow-1,3) = "-"
7.443 + text(nrow-1,4) = sprintf("%.2f",beta_biome_avg)
7.444 +
7.445 +;**************************************************
7.446 +; html table
7.447 +;**************************************************
7.448 +
7.449 + header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
7.450 +
7.451 + header = (/"<HTML>" \
7.452 + ,"<HEAD>" \
7.453 + ,"<TITLE>CLAMP metrics</TITLE>" \
7.454 + ,"</HEAD>" \
7.455 + ,header_text \
7.456 + /)
7.457 + footer = "</HTML>"
7.458 +
7.459 + table_header = (/ \
7.460 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
7.461 + ,"<tr>" \
7.462 + ," <th bgcolor=DDDDDD >Biome Class</th>" \
7.463 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
7.464 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
7.465 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
7.466 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
7.467 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
7.468 + ,"</tr>" \
7.469 + /)
7.470 + table_footer = "</table>"
7.471 + row_header = "<tr>"
7.472 + row_footer = "</tr>"
7.473 +
7.474 + lines = new(50000,string)
7.475 + nline = 0
7.476 +
7.477 + set_line(lines,nline,header)
7.478 + set_line(lines,nline,table_header)
7.479 +;-----------------------------------------------
7.480 +;row of table
7.481 +
7.482 + do n = 0,nrow-1
7.483 + set_line(lines,nline,row_header)
7.484 +
7.485 + txt1 = row_head(n)
7.486 + txt2 = text(n,0)
7.487 + txt3 = text(n,1)
7.488 + txt4 = text(n,2)
7.489 + txt5 = text(n,3)
7.490 + txt6 = text(n,4)
7.491 +
7.492 + set_line(lines,nline,"<th>"+txt1+"</th>")
7.493 + set_line(lines,nline,"<th>"+txt2+"</th>")
7.494 + set_line(lines,nline,"<th>"+txt3+"</th>")
7.495 + set_line(lines,nline,"<th>"+txt4+"</th>")
7.496 + set_line(lines,nline,"<th>"+txt5+"</th>")
7.497 + set_line(lines,nline,"<th>"+txt6+"</th>")
7.498 +
7.499 + set_line(lines,nline,row_footer)
7.500 + end do
7.501 +;-----------------------------------------------
7.502 + set_line(lines,nline,table_footer)
7.503 + set_line(lines,nline,footer)
7.504 +
7.505 +; Now write to an HTML file
7.506 +
7.507 + idx = ind(.not.ismissing(lines))
7.508 + if(.not.any(ismissing(idx))) then
7.509 + asciiwrite(output_html,lines(idx))
7.510 + else
7.511 + print ("error?")
7.512 + end if
7.513 + delete (idx)
7.514 +
7.515 +;**************************************************************************************
7.516 +; update score
7.517 +;**************************************************************************************
7.518 + if (isvar("compare")) then
7.519 + system("sed -e '1,/M_beta/s/M_beta/"+M_beta+"/' "+html_name2+" > "+html_new2+";"+ \
7.520 + "mv -f "+html_new2+" "+html_name2)
7.521 + end if
7.522 +
7.523 + system("sed s#M_beta#"+M_beta+"# "+html_name+" > "+html_new+";"+ \
7.524 + "mv -f "+html_new+" "+html_name)
7.525 +
7.526 +;***************************************************************************
7.527 +; get total score and write to file
7.528 +;***************************************************************************
7.529 + M_total = Mbeta
7.530 +
7.531 + asciiwrite("M_save.beta", M_total)
7.532 +
7.533 + delete (M_total)
7.534 +
7.535 +;***************************************************************************
7.536 +; output plot and html
7.537 +;***************************************************************************
7.538 + output_dir = model_name+"/beta"
7.539 +
7.540 + system("mv *.html " + output_dir)
7.541 +;***************************************************************************
7.542 +
7.543 +end
7.544 +
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/all/08.turnover.ncl Mon Jan 26 22:08:20 2009 -0500
8.3 @@ -0,0 +1,351 @@
8.4 +;********************************************************
8.5 +; hardwire: flux = flux/1200. (for casa only)
8.6 +;**************************************************************
8.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
8.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
8.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
8.10 +;**************************************************************
8.11 +procedure set_line(lines:string,nline:integer,newlines:string)
8.12 +begin
8.13 +; add line to ascci/html file
8.14 +
8.15 + nnewlines = dimsizes(newlines)
8.16 + if(nline+nnewlines-1.ge.dimsizes(lines))
8.17 + print("set_line: bad index, not setting anything.")
8.18 + return
8.19 + end if
8.20 + lines(nline:nline+nnewlines-1) = newlines
8.21 +; print ("lines = " + lines(nline:nline+nnewlines-1))
8.22 + nline = nline + nnewlines
8.23 + return
8.24 +end
8.25 +;**************************************************************
8.26 +; Main code.
8.27 +begin
8.28 +
8.29 + plot_type = "ps"
8.30 + plot_type_new = "png"
8.31 +
8.32 +;------------------------------------------------------
8.33 +; edit table.html of current model for movel1_vs_model2
8.34 +
8.35 + if (isvar("compare")) then
8.36 + html_name2 = compare+"/table.html"
8.37 + html_new2 = html_name2 +".new"
8.38 + end if
8.39 +
8.40 +;------------------------------------------------------
8.41 +; edit table.html for current model
8.42 +
8.43 + html_name = model_name+"/table.html"
8.44 + html_new = html_name +".new"
8.45 +
8.46 +;---------------------------------------------------------------
8.47 +;components
8.48 +
8.49 + component = (/"Leaf","Wood","Fine_Root","Litter","Coarse_Woody_Debris","Soil"/)
8.50 + n_comp = dimsizes(component)
8.51 +
8.52 + field_pool = (/"LEAFC","WOODC","FROOTC","LITTERC","CWDC","SOILC"/)
8.53 + field_flux = (/"LEAFC_ALLOC","WOODC_ALLOC","FROOTC_ALLOC","LITTERC_LOSS","CWDC_LOSS","SOILC_HR"/)
8.54 +
8.55 +;--------------------------------------------------
8.56 +; get landfrac data
8.57 +
8.58 + film_l = "lnd_"+ model_grid +".nc"
8.59 + fm_l = addfile (dirs+film_l,"r")
8.60 + landfrac = fm_l->landfrac
8.61 +
8.62 + delete (fm_l)
8.63 +;---------------------------------------------------
8.64 +; read biome data: model
8.65 +
8.66 + biome_name_mod = "Model PFT Class"
8.67 +
8.68 + film_c = "class_pft_"+ model_grid +".nc"
8.69 + fm_c = addfile (dirs+film_c,"r")
8.70 + classmod = fm_c->CLASS_PFT
8.71 +
8.72 + delete (fm_c)
8.73 +
8.74 +; model data has 17 land-type classes
8.75 + nclass_mod = 17
8.76 +
8.77 +;********************************************************************
8.78 +; use land-type class to bin the data in equally spaced ranges
8.79 +;********************************************************************
8.80 +
8.81 +; using model biome class
8.82 + nclass = nclass_mod
8.83 +
8.84 + range = fspan(0,nclass,nclass+1)
8.85 +
8.86 +; Use this range information to grab all the values in a
8.87 +; particular range, and then take an average.
8.88 +
8.89 + nx = dimsizes(range) - 1
8.90 +
8.91 +; for 2 data: pool and flux
8.92 + data_n = 2
8.93 +
8.94 +; using model biome class
8.95 +
8.96 + base = ndtooned(classmod)
8.97 +
8.98 +; output
8.99 +
8.100 + yvalues = new((/data_n,nx/),float)
8.101 + count = new((/data_n,nx/),float)
8.102 +
8.103 +;--------------------------------------------------
8.104 +; read model data, each component:
8.105 +
8.106 + fm = addfile (dirm+film4,"r")
8.107 +
8.108 + do k = 0,n_comp-1
8.109 +
8.110 + pool = fm->$field_pool(k)$
8.111 + flux = fm->$field_flux(k)$
8.112 +
8.113 +; Units for these variables are:
8.114 +; pool: g C/m^2
8.115 +; flux: g C/m^2/s
8.116 +
8.117 + nsec_per_year = 60*60*24*365
8.118 +
8.119 + flux = flux * nsec_per_year
8.120 +
8.121 + unit_p = "gC/m2"
8.122 + unit_f = "gC/m2/year"
8.123 + unit_t = "year"
8.124 +
8.125 +;#############################################################
8.126 +; casa only
8.127 +; all the plant pools (leaf, wood, and fine root) and
8.128 +; coarse woody debris (cwd) and litter pools for
8.129 +; CASA need to be divided by 1200. The soil flux
8.130 +; and turnover time are fine and do not need to be adjusted.
8.131 +
8.132 + if (BGC .eq. "casa") then
8.133 + if (k .ne. n_comp-1) then
8.134 + flux = flux/1200.
8.135 + end if
8.136 + end if
8.137 +;##############################################################
8.138 +
8.139 +; take into account landfrac
8.140 +
8.141 + pool = pool * conform(pool,landfrac,(/1,2/))
8.142 + flux = flux * conform(flux,landfrac,(/1,2/))
8.143 +
8.144 +; Loop through each range, using base
8.145 +
8.146 + do i=0,nx-1
8.147 +
8.148 + if (i.ne.(nx-1)) then
8.149 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
8.150 + else
8.151 + idx = ind(base.ge.range(i))
8.152 + end if
8.153 +
8.154 +; loop through each dataset
8.155 +
8.156 + do n = 0,data_n-1
8.157 +
8.158 + if (n .eq. 0) then
8.159 + data = ndtooned(pool)
8.160 + end if
8.161 +
8.162 + if (n .eq. 1) then
8.163 + data = ndtooned(flux)
8.164 + end if
8.165 +
8.166 +; Calculate average
8.167 +
8.168 + if (.not.any(ismissing(idx))) then
8.169 + yvalues(n,i) = avg(data(idx))
8.170 + count(n,i) = dimsizes(idx)
8.171 + else
8.172 + yvalues(n,i) = yvalues@_FillValue
8.173 + count(n,i) = 0
8.174 + end if
8.175 +
8.176 +;#############################################################
8.177 +; using model biome class:
8.178 +;
8.179 +; set the following 4 classes to _FillValue:
8.180 +; (3)Needleleaf Deciduous Boreal Tree,
8.181 +; (8)Broadleaf Deciduous Boreal Tree,
8.182 +; (9)Broadleaf Evergreen Shrub,
8.183 +; (16)Wheat
8.184 +
8.185 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
8.186 + yvalues(n,i) = yvalues@_FillValue
8.187 + count(n,i) = 0
8.188 + end if
8.189 +;#############################################################
8.190 +
8.191 + delete(data)
8.192 + end do ; n-loop
8.193 +
8.194 + delete(idx)
8.195 + end do ; i-loop
8.196 +
8.197 + delete (pool)
8.198 + delete (flux)
8.199 +
8.200 +;============================
8.201 +;compute turnover time
8.202 +;============================
8.203 +
8.204 + u = yvalues(0,:)
8.205 + v = yvalues(1,:)
8.206 + u_count = count(0,:)
8.207 + v_count = count(1,:)
8.208 +
8.209 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
8.210 +
8.211 + uu = u(good)
8.212 + vv = v(good)
8.213 + uu_count = u_count(good)
8.214 + vv_count = v_count(good)
8.215 +
8.216 + n_biome = dimsizes(uu)
8.217 + t_biome = new((/n_biome/),float)
8.218 +
8.219 + t_biome = uu/vv
8.220 +
8.221 + t_biome_avg = sum(uu*uu_count)/sum(vv*vv_count)
8.222 +
8.223 +;===========================
8.224 +; for html table - biome
8.225 +;===========================
8.226 +
8.227 + output_html = "table_"+component(k)+".html"
8.228 +
8.229 +; column (not including header column)
8.230 +
8.231 + col_head = (/component(k)+" Flux",component(k)+" Pool",component(k)+" Turnover Time"/)
8.232 +
8.233 + ncol = dimsizes(col_head)
8.234 +
8.235 +; row (not including header row)
8.236 +
8.237 +;----------------------------------------------------
8.238 +; using model biome class:
8.239 + row_head = (/"Not Vegetated" \
8.240 + ,"Needleleaf Evergreen Temperate Tree" \
8.241 + ,"Needleleaf Evergreen Boreal Tree" \
8.242 +; ,"Needleleaf Deciduous Boreal Tree" \
8.243 + ,"Broadleaf Evergreen Tropical Tree" \
8.244 + ,"Broadleaf Evergreen Temperate Tree" \
8.245 + ,"Broadleaf Deciduous Tropical Tree" \
8.246 + ,"Broadleaf Deciduous Temperate Tree" \
8.247 +; ,"Broadleaf Deciduous Boreal Tree" \
8.248 +; ,"Broadleaf Evergreen Shrub" \
8.249 + ,"Broadleaf Deciduous Temperate Shrub" \
8.250 + ,"Broadleaf Deciduous Boreal Shrub" \
8.251 + ,"C3 Arctic Grass" \
8.252 + ,"C3 Non-Arctic Grass" \
8.253 + ,"C4 Grass" \
8.254 + ,"Corn" \
8.255 +; ,"Wheat" \
8.256 + ,"All Biome" \
8.257 + /)
8.258 + nrow = dimsizes(row_head)
8.259 +
8.260 +; arrays to be passed to table.
8.261 + text = new ((/nrow, ncol/),string )
8.262 +
8.263 + do i=0,nrow-2
8.264 + text(i,0) = sprintf("%.1f",vv(i))
8.265 + text(i,1) = sprintf("%.1f",uu(i))
8.266 + text(i,2) = sprintf("%.2f",t_biome(i))
8.267 + end do
8.268 + text(nrow-1,0) = "-"
8.269 + text(nrow-1,1) = "-"
8.270 + text(nrow-1,2) = sprintf("%.2f",t_biome_avg)
8.271 +
8.272 +;**************************************************
8.273 +; html table
8.274 +;**************************************************
8.275 +
8.276 + header_text = "<H1>"+component(k)+" Turnover Time: Model "+model_name+"</H1>"
8.277 +
8.278 + header = (/"<HTML>" \
8.279 + ,"<HEAD>" \
8.280 + ,"<TITLE>CLAMP metrics</TITLE>" \
8.281 + ,"</HEAD>" \
8.282 + ,header_text \
8.283 + /)
8.284 + footer = "</HTML>"
8.285 +
8.286 + table_header = (/ \
8.287 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
8.288 + ,"<tr>" \
8.289 + ," <th bgcolor=DDDDDD >Biome Class</th>" \
8.290 + ," <th bgcolor=DDDDDD >"+col_head(0)+"<br>("+unit_f+")</th>" \
8.291 + ," <th bgcolor=DDDDDD >"+col_head(1)+"<br>("+unit_p+")</th>" \
8.292 + ," <th bgcolor=DDDDDD >"+col_head(2)+"<br>("+unit_t+")</th>" \
8.293 + ,"</tr>" \
8.294 + /)
8.295 + table_footer = "</table>"
8.296 + row_header = "<tr>"
8.297 + row_footer = "</tr>"
8.298 +
8.299 + lines = new(50000,string)
8.300 + nline = 0
8.301 +
8.302 + set_line(lines,nline,header)
8.303 + set_line(lines,nline,table_header)
8.304 +;-----------------------------------------------
8.305 +; row of table
8.306 +
8.307 + do n = 0,nrow-1
8.308 + set_line(lines,nline,row_header)
8.309 +
8.310 + txt1 = row_head(n)
8.311 + txt2 = text(n,0)
8.312 + txt3 = text(n,1)
8.313 + txt4 = text(n,2)
8.314 +
8.315 + set_line(lines,nline,"<th>"+txt1+"</th>")
8.316 + set_line(lines,nline,"<th>"+txt2+"</th>")
8.317 + set_line(lines,nline,"<th>"+txt3+"</th>")
8.318 + set_line(lines,nline,"<th>"+txt4+"</th>")
8.319 +
8.320 + set_line(lines,nline,row_footer)
8.321 + end do
8.322 +;-----------------------------------------------
8.323 + set_line(lines,nline,table_footer)
8.324 + set_line(lines,nline,footer)
8.325 +
8.326 +; Now write to an HTML file
8.327 +
8.328 + idx = ind(.not.ismissing(lines))
8.329 + if(.not.any(ismissing(idx))) then
8.330 + asciiwrite(output_html,lines(idx))
8.331 + else
8.332 + print ("error?")
8.333 + end if
8.334 +
8.335 + delete (idx)
8.336 +
8.337 + delete (good)
8.338 + delete (t_biome)
8.339 + delete (text)
8.340 +
8.341 + end do ; k-loop
8.342 +
8.343 + delete (fm)
8.344 +
8.345 +;***************************************************************************
8.346 +; output plot and html
8.347 +;***************************************************************************
8.348 + output_dir = model_name+"/turnover"
8.349 +
8.350 + system("mv *.html " + output_dir)
8.351 +;******************************
8.352 +
8.353 +end
8.354 +
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/all/09.carbon_sink.ncl Mon Jan 26 22:08:20 2009 -0500
9.3 @@ -0,0 +1,888 @@
9.4 +;**************************************************************
9.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
9.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
9.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
9.8 +;**************************************************************
9.9 +procedure set_line(lines:string,nline:integer,newlines:string)
9.10 +begin
9.11 +; add line to ascci/html file
9.12 +
9.13 + nnewlines = dimsizes(newlines)
9.14 + if(nline+nnewlines-1.ge.dimsizes(lines))
9.15 + print("set_line: bad index, not setting anything.")
9.16 + return
9.17 + end if
9.18 + lines(nline:nline+nnewlines-1) = newlines
9.19 +; print ("lines = " + lines(nline:nline+nnewlines-1))
9.20 + nline = nline + nnewlines
9.21 + return
9.22 +end
9.23 +;**************************************************************
9.24 +; Main code.
9.25 +begin
9.26 +
9.27 + plot_type = "ps"
9.28 + plot_type_new = "png"
9.29 +
9.30 +;----------------------------------------------------------
9.31 +; edit current model for movel1_vs_model2
9.32 +
9.33 + if (isvar("compare")) then
9.34 + html_name2 = compare+"/table.html"
9.35 + html_new2 = html_name2 +".new"
9.36 + end if
9.37 +
9.38 +;----------------------------------------------------------
9.39 +; edit table.html for current model
9.40 +
9.41 + html_name = model_name+"/table.html"
9.42 + html_new = html_name +".new"
9.43 +
9.44 +;----------------------------------------------------------
9.45 +; get biome data: model
9.46 +
9.47 + biome_name_mod = "Model PFT Class"
9.48 +
9.49 + film_c = "class_pft_"+ model_grid +".nc"
9.50 + fm_c = addfile (dirs+film_c,"r")
9.51 + classmod = fm_c->CLASS_PFT
9.52 +
9.53 + delete (fm_c)
9.54 +
9.55 +; model data has 17 land-type classes
9.56 + nclass_mod = 17
9.57 +
9.58 +;------------------------------------
9.59 +; get model landfrac and area
9.60 +
9.61 + film_l = "lnd_"+ model_grid +".nc"
9.62 + fm_l = addfile (dirs+film_l,"r")
9.63 + landfrac = fm_l->landfrac
9.64 + area = fm_l->area
9.65 +
9.66 + delete (fm_l)
9.67 +
9.68 +; change area from km**2 to m**2
9.69 + area = area * 1.e6
9.70 +
9.71 +;-------------------------------------
9.72 +; take into account landfrac
9.73 +
9.74 +; area = area * landfrac
9.75 +
9.76 +; delete (landfrac)
9.77 +
9.78 +;---------------------------------------------------
9.79 +; read data: model, group 1
9.80 +
9.81 + fm = addfile (dirm+film4,"r")
9.82 +
9.83 + NPP1 = fm->NPP
9.84 +
9.85 + leafc = fm->LEAFC
9.86 + woodc = fm->WOODC
9.87 + frootc = fm->FROOTC
9.88 + VegC = leafc
9.89 + VegC = leafc + woodc + frootc
9.90 +
9.91 + litterc = fm->LITTERC
9.92 + cwdc = fm->CWDC
9.93 + LiCwC = litterc
9.94 + LiCwC = litterc + cwdc
9.95 +
9.96 + SoilC = fm->SOILC
9.97 +
9.98 + delete (fm)
9.99 +;---------------------------------------------------
9.100 +; read data: model, group 2
9.101 +
9.102 + fm = addfile (dirm+film5,"r")
9.103 +
9.104 + NPP2 = fm->NPP
9.105 + NEE2 = fm->NEE
9.106 + GPP2 = fm->GPP
9.107 +
9.108 + delete (fm)
9.109 +;---------------------------------------------------
9.110 +; Units for these variables are:
9.111 +
9.112 +;NPP1: g C/m^2/s
9.113 +;NPP2: g C/m^2/s
9.114 +;NEE2: g C/m^2/s
9.115 +;GPP2: g C/m^2/s
9.116 +
9.117 +;VegC: g C/m^2
9.118 +;LiCwC: g C/m^2
9.119 +;SoilC: g C/m^2
9.120 +
9.121 + nsec_per_year = 60*60*24*365
9.122 +
9.123 +; change unit to g C/m^2/year
9.124 +
9.125 + NPP1 = NPP1 * nsec_per_year * conform(NPP1,landfrac,(/1,2/))
9.126 + NPP2 = NPP2 * nsec_per_year * conform(NPP2,landfrac,(/1,2/))
9.127 + NEE2 = NEE2 * nsec_per_year * conform(NEE2,landfrac,(/1,2/))
9.128 + GPP2 = GPP2 * nsec_per_year * conform(GPP2,landfrac,(/1,2/))
9.129 +
9.130 + VegC = VegC * conform(VegC,landfrac,(/1,2/))
9.131 + LiCwC = LiCwC * conform(LiCwC,landfrac,(/1,2/))
9.132 + SoilC = SoilC * conform(SoilC,landfrac,(/1,2/))
9.133 +
9.134 + data_n = 8
9.135 +
9.136 +;*******************************************************************
9.137 +; Calculate "nice" bins for binning the data in equally spaced ranges
9.138 +;********************************************************************
9.139 +
9.140 +; using model biome class
9.141 + nclass = nclass_mod
9.142 +
9.143 + range = fspan(0,nclass,nclass+1)
9.144 +
9.145 +; print (range)
9.146 +; Use this range information to grab all the values in a
9.147 +; particular range, and then take an average.
9.148 +
9.149 + nx = dimsizes(range) - 1
9.150 +
9.151 +;==============================
9.152 +; put data into bins
9.153 +;==============================
9.154 +
9.155 +; using observed biome class
9.156 +; base = ndtooned(classob)
9.157 +; using model biome class
9.158 + base = ndtooned(classmod)
9.159 +
9.160 + area_1d = ndtooned(area)
9.161 +
9.162 +; output
9.163 +
9.164 + yvalues = new((/data_n,nx/),float) ; (per m2)
9.165 + yvalues_t = new((/data_n,nx/),float) ; (per biome)
9.166 +
9.167 +; Loop through each range, using base.
9.168 +
9.169 + do i=0,nx-1
9.170 +
9.171 + if (i.ne.(nx-1)) then
9.172 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
9.173 + else
9.174 + idx = ind(base.ge.range(i))
9.175 + end if
9.176 +
9.177 + do n = 0,data_n-1
9.178 +
9.179 + if (n.eq.0) then
9.180 + data = ndtooned(area)
9.181 + end if
9.182 +
9.183 + if (n.eq.1) then
9.184 + data = ndtooned(NPP1)
9.185 + end if
9.186 +
9.187 + if (n.eq.2) then
9.188 + data = ndtooned(VegC)
9.189 + end if
9.190 +
9.191 + if (n.eq.3) then
9.192 + data = ndtooned(LiCwC)
9.193 + end if
9.194 +
9.195 + if (n.eq.4) then
9.196 + data = ndtooned(SoilC)
9.197 + end if
9.198 +
9.199 + if (n.eq.5) then
9.200 + data = ndtooned(NPP2)
9.201 + end if
9.202 +
9.203 + if (n.eq.6) then
9.204 + data = ndtooned(NEE2)
9.205 + end if
9.206 +
9.207 + if (n.eq.7) then
9.208 + data = ndtooned(GPP2)
9.209 + end if
9.210 +
9.211 +; Calculate sum and average
9.212 +
9.213 + if (.not.any(ismissing(idx))) then
9.214 + if (n.eq.0) then
9.215 + yvalues(n,i) = sum(data(idx))
9.216 + yvalues_t(n,i) = sum(data(idx))
9.217 + else
9.218 + yvalues(n,i) = avg(data(idx))
9.219 + yvalues_t(n,i) = sum(data(idx)*area_1d(idx))
9.220 + end if
9.221 + else
9.222 + yvalues(n,i) = yvalues@_FillValue
9.223 + yvalues_t(n,i) = yvalues@_FillValue
9.224 + end if
9.225 +
9.226 +;#############################################################
9.227 +; using model biome class:
9.228 +; set the following 4 classes to _FillValue:
9.229 +; (3)Needleleaf Deciduous Boreal Tree,
9.230 +; (8)Broadleaf Deciduous Boreal Tree,
9.231 +; (9)Broadleaf Evergreen Shrub,
9.232 +; (16)Wheat
9.233 +
9.234 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
9.235 + yvalues(n,i) = yvalues@_FillValue
9.236 + yvalues_t(n,i) = yvalues@_FillValue
9.237 + end if
9.238 +;#############################################################
9.239 +
9.240 + delete (data)
9.241 + end do
9.242 +
9.243 + delete (idx)
9.244 + end do
9.245 +
9.246 + delete (base)
9.247 + delete (area)
9.248 + delete (NPP1)
9.249 + delete (VegC)
9.250 + delete (LiCwC)
9.251 + delete (SoilC)
9.252 + delete (NPP2)
9.253 + delete (NEE2)
9.254 + delete (GPP2)
9.255 +
9.256 +;----------------------------------------------------------------
9.257 +; data for table1
9.258 +
9.259 + good = ind(.not.ismissing(yvalues(5,:)) .and. .not.ismissing(yvalues(1,:)))
9.260 +;print (good)
9.261 +
9.262 + area_g = yvalues(0,good)
9.263 + NPP1_g = yvalues(1,good)
9.264 + VegC_g = yvalues(2,good)
9.265 + LiCwC_g = yvalues(3,good)
9.266 + SoilC_g = yvalues(4,good)
9.267 + NPP2_g = yvalues(5,good)
9.268 + NEE2_g = yvalues(6,good)
9.269 + GPP2_g = yvalues(7,good)
9.270 +
9.271 + NPP_ratio = NPP2_g/NPP1_g
9.272 +
9.273 + n_biome = dimsizes(NPP1_g)
9.274 +
9.275 +;-----------------------------------------------------------------
9.276 +; data for table2
9.277 +
9.278 +; change unit from g to Pg (Peta gram)
9.279 + factor_unit = 1.e-15
9.280 +
9.281 + NPP1_t = yvalues_t(1,good) * factor_unit
9.282 + VegC_t = yvalues_t(2,good) * factor_unit
9.283 + LiCwC_t = yvalues_t(3,good) * factor_unit
9.284 + SoilC_t = yvalues_t(4,good) * factor_unit
9.285 + NEE2_t = yvalues_t(6,good) * factor_unit
9.286 + GPP2_t = yvalues_t(7,good) * factor_unit
9.287 +
9.288 + delete (yvalues)
9.289 + delete (yvalues_t)
9.290 +
9.291 +;-------------------------------------------------------------
9.292 +; html table1 data
9.293 +
9.294 +; column (not including header column)
9.295 +
9.296 + col_head = (/"Area (1.e12m2)" \
9.297 + ,"NPP (gC/m2/yr)" \
9.298 + ,"VegC (gC/m2)" \
9.299 + ,"Litter+CWD (gC/m2)" \
9.300 + ,"SoilC (gC/m2)" \
9.301 + ,"NPP_ratio" \
9.302 + ,"NEE (gC/m2/yr)" \
9.303 + ,"GPP (gC/m2/yr)" \
9.304 + /)
9.305 +
9.306 + ncol = dimsizes(col_head)
9.307 +
9.308 +; row (not including header row)
9.309 +
9.310 +; using model biome class:
9.311 + row_head = (/"Not Vegetated" \
9.312 + ,"Needleleaf Evergreen Temperate Tree" \
9.313 + ,"Needleleaf Evergreen Boreal Tree" \
9.314 +; ,"Needleleaf Deciduous Boreal Tree" \
9.315 + ,"Broadleaf Evergreen Tropical Tree" \
9.316 + ,"Broadleaf Evergreen Temperate Tree" \
9.317 + ,"Broadleaf Deciduous Tropical Tree" \
9.318 + ,"Broadleaf Deciduous Temperate Tree" \
9.319 +; ,"Broadleaf Deciduous Boreal Tree" \
9.320 +; ,"Broadleaf Evergreen Shrub" \
9.321 + ,"Broadleaf Deciduous Temperate Shrub" \
9.322 + ,"Broadleaf Deciduous Boreal Shrub" \
9.323 + ,"C3 Arctic Grass" \
9.324 + ,"C3 Non-Arctic Grass" \
9.325 + ,"C4 Grass" \
9.326 + ,"Corn" \
9.327 +; ,"Wheat" \
9.328 + ,"All Biome" \
9.329 + /)
9.330 + nrow = dimsizes(row_head)
9.331 +
9.332 +; arrays to be passed to table.
9.333 + text = new ((/nrow, ncol/),string )
9.334 +
9.335 + do i=0,nrow-2
9.336 + text(i,0) = sprintf("%.1f",area_g(i)*1.e-12)
9.337 + text(i,1) = sprintf("%.1f",NPP1_g(i))
9.338 + text(i,2) = sprintf("%.1f",VegC_g(i))
9.339 + text(i,3) = sprintf("%.1f",LiCwC_g(i))
9.340 + text(i,4) = sprintf("%.1f",SoilC_g(i))
9.341 + text(i,5) = sprintf("%.2f",NPP_ratio(i))
9.342 + text(i,6) = sprintf("%.1f",NEE2_g(i))
9.343 + text(i,7) = sprintf("%.1f",GPP2_g(i))
9.344 + end do
9.345 +
9.346 +;-------------------------------------------------------
9.347 +; create html table1
9.348 +
9.349 + header_text = "<H1>NEE and Carbon Stocks and Fluxes: Model "+model_name+"</H1>"
9.350 +
9.351 + header = (/"<HTML>" \
9.352 + ,"<HEAD>" \
9.353 + ,"<TITLE>CLAMP metrics</TITLE>" \
9.354 + ,"</HEAD>" \
9.355 + ,header_text \
9.356 + /)
9.357 + footer = "</HTML>"
9.358 +
9.359 + table_header = (/ \
9.360 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
9.361 + ,"<tr>" \
9.362 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
9.363 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
9.364 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
9.365 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
9.366 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
9.367 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
9.368 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
9.369 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
9.370 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
9.371 + ,"</tr>" \
9.372 + /)
9.373 + table_footer = "</table>"
9.374 + row_header = "<tr>"
9.375 + row_footer = "</tr>"
9.376 +
9.377 + lines = new(50000,string)
9.378 + nline = 0
9.379 +
9.380 + set_line(lines,nline,header)
9.381 + set_line(lines,nline,table_header)
9.382 +
9.383 +;----------------------------
9.384 +;row of table
9.385 +
9.386 + do n = 0,nrow-2
9.387 + set_line(lines,nline,row_header)
9.388 +
9.389 + txt0 = row_head(n)
9.390 + txt1 = text(n,0)
9.391 + txt2 = text(n,1)
9.392 + txt3 = text(n,2)
9.393 + txt4 = text(n,3)
9.394 + txt5 = text(n,4)
9.395 + txt6 = text(n,5)
9.396 + txt7 = text(n,6)
9.397 + txt8 = text(n,7)
9.398 +
9.399 + set_line(lines,nline,"<th>"+txt0+"</th>")
9.400 + set_line(lines,nline,"<th>"+txt1+"</th>")
9.401 + set_line(lines,nline,"<th>"+txt2+"</th>")
9.402 + set_line(lines,nline,"<th>"+txt3+"</th>")
9.403 + set_line(lines,nline,"<th>"+txt4+"</th>")
9.404 + set_line(lines,nline,"<th>"+txt5+"</th>")
9.405 + set_line(lines,nline,"<th>"+txt6+"</th>")
9.406 + set_line(lines,nline,"<th>"+txt7+"</th>")
9.407 + set_line(lines,nline,"<th>"+txt8+"</th>")
9.408 +
9.409 + set_line(lines,nline,row_footer)
9.410 + end do
9.411 +;----------------------------
9.412 + set_line(lines,nline,table_footer)
9.413 + set_line(lines,nline,footer)
9.414 +
9.415 +; Now write to an HTML file.
9.416 +
9.417 + output_html = "table_per_m2.html"
9.418 +
9.419 + idx = ind(.not.ismissing(lines))
9.420 + if(.not.any(ismissing(idx))) then
9.421 + asciiwrite(output_html,lines(idx))
9.422 + else
9.423 + print ("error?")
9.424 + end if
9.425 +
9.426 + delete (idx)
9.427 +
9.428 + delete (col_head)
9.429 + delete (row_head)
9.430 + delete (text)
9.431 + delete (table_header)
9.432 +
9.433 +;-----------------------------------------------------------------
9.434 +; html table2 data
9.435 +
9.436 +; column (not including header column)
9.437 +
9.438 + col_head = (/"NPP (PgC/yr)" \
9.439 + ,"VegC (PgC)" \
9.440 + ,"Litter+CWD (PgC)" \
9.441 + ,"SoilC (PgC)" \
9.442 + ,"NEE (PgC/yr)" \
9.443 + ,"GPP (PgC/yr)" \
9.444 + ,"NPP timeseries" \
9.445 + ,"NEE timeseries" \
9.446 + ,"Fire timeseries" \
9.447 + /)
9.448 +
9.449 + ncol = dimsizes(col_head)
9.450 +
9.451 +; row (not including header row)
9.452 +
9.453 +; using model biome class:
9.454 + row_head = (/"Not Vegetated" \
9.455 + ,"Needleleaf Evergreen Temperate Tree" \
9.456 + ,"Needleleaf Evergreen Boreal Tree" \
9.457 +; ,"Needleleaf Deciduous Boreal Tree" \
9.458 + ,"Broadleaf Evergreen Tropical Tree" \
9.459 + ,"Broadleaf Evergreen Temperate Tree" \
9.460 + ,"Broadleaf Deciduous Tropical Tree" \
9.461 + ,"Broadleaf Deciduous Temperate Tree" \
9.462 +; ,"Broadleaf Deciduous Boreal Tree" \
9.463 +; ,"Broadleaf Evergreen Shrub" \
9.464 + ,"Broadleaf Deciduous Temperate Shrub" \
9.465 + ,"Broadleaf Deciduous Boreal Shrub" \
9.466 + ,"C3 Arctic Grass" \
9.467 + ,"C3 Non-Arctic Grass" \
9.468 + ,"C4 Grass" \
9.469 + ,"Corn" \
9.470 +; ,"Wheat" \
9.471 + ,"All Biome" \
9.472 + /)
9.473 + nrow = dimsizes(row_head)
9.474 +
9.475 +; arrays to be passed to table.
9.476 + text = new ((/nrow, ncol/),string )
9.477 +
9.478 + do i=0,nrow-2
9.479 + text(i,0) = sprintf("%.1f",NPP1_t(i))
9.480 + text(i,1) = sprintf("%.1f",VegC_t(i))
9.481 + text(i,2) = sprintf("%.1f",LiCwC_t(i))
9.482 + text(i,3) = sprintf("%.1f",SoilC_t(i))
9.483 + text(i,4) = sprintf("%.1f",NEE2_t(i))
9.484 + text(i,5) = sprintf("%.1f",GPP2_t(i))
9.485 + text(i,6) = "<a href=./NPP_monthly_biome_"+i+".png>monthly_plot</a> <br> <a href=./NPP_annual_biome_"+i+".png>annual_plot</a>"
9.486 + text(i,7) = "<a href=./NEE_monthly_biome_"+i+".png>monthly_plot</a> <br> <a href=./NEE_annual_biome_"+i+".png>annual_plot</a>"
9.487 + text(i,8) = "<a href=./Fire_monthly_biome_"+i+".png>monthly_plot</a> <br> <a href=./Fire_annual_biome_"+i+".png>annual_plot</a>"
9.488 + end do
9.489 +
9.490 + text(nrow-1,0) = sprintf("%.1f",sum(NPP1_t))
9.491 + text(nrow-1,1) = sprintf("%.1f",sum(VegC_t))
9.492 + text(nrow-1,2) = sprintf("%.1f",sum(LiCwC_t))
9.493 + text(nrow-1,3) = sprintf("%.1f",sum(SoilC_t))
9.494 + text(nrow-1,4) = sprintf("%.1f",sum(NEE2_t))
9.495 + text(nrow-1,5) = sprintf("%.1f",sum(GPP2_t))
9.496 + text(nrow-1,6) = "<a href=./NPP_monthly_global.png>monthly_plot</a> <br> <a href=./NPP_annual_global.png>annual_plot</a>"
9.497 + text(nrow-1,7) = "<a href=./NEE_monthly_global.png>monthly_plot</a> <br> <a href=./NEE_annual_global.png>annual_plot</a>"
9.498 + text(nrow-1,8) = "<a href=./Fire_monthly_global.png>monthly_plot</a> <br> <a href=./Fire_annual_global.png>annual_plot</a>"
9.499 +
9.500 +;**************************************************
9.501 +; create html table2
9.502 +;**************************************************
9.503 +
9.504 + header_text = "<H1>NEE and Carbon Stocks and Fluxes (per biome): Model "+model_name+"</H1>"
9.505 +
9.506 + header = (/"<HTML>" \
9.507 + ,"<HEAD>" \
9.508 + ,"<TITLE>CLAMP metrics</TITLE>" \
9.509 + ,"</HEAD>" \
9.510 + ,header_text \
9.511 + /)
9.512 + footer = "</HTML>"
9.513 +
9.514 + table_header = (/ \
9.515 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
9.516 + ,"<tr>" \
9.517 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
9.518 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
9.519 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
9.520 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
9.521 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
9.522 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
9.523 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
9.524 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
9.525 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
9.526 + ," <th bgcolor=DDDDDD >"+col_head(8)+"</th>" \
9.527 + ,"</tr>" \
9.528 + /)
9.529 + table_footer = "</table>"
9.530 + row_header = "<tr>"
9.531 + row_footer = "</tr>"
9.532 +
9.533 + lines = new(50000,string)
9.534 + nline = 0
9.535 +
9.536 + set_line(lines,nline,header)
9.537 + set_line(lines,nline,table_header)
9.538 +;-----------------------------------------------
9.539 +;row of table
9.540 +
9.541 + do n = 0,nrow-1
9.542 + set_line(lines,nline,row_header)
9.543 +
9.544 + txt0 = row_head(n)
9.545 + txt1 = text(n,0)
9.546 + txt2 = text(n,1)
9.547 + txt3 = text(n,2)
9.548 + txt4 = text(n,3)
9.549 + txt5 = text(n,4)
9.550 + txt6 = text(n,5)
9.551 + txt7 = text(n,6)
9.552 + txt8 = text(n,7)
9.553 + txt9 = text(n,8)
9.554 +
9.555 + set_line(lines,nline,"<th>"+txt0+"</th>")
9.556 + set_line(lines,nline,"<th>"+txt1+"</th>")
9.557 + set_line(lines,nline,"<th>"+txt2+"</th>")
9.558 + set_line(lines,nline,"<th>"+txt3+"</th>")
9.559 + set_line(lines,nline,"<th>"+txt4+"</th>")
9.560 + set_line(lines,nline,"<th>"+txt5+"</th>")
9.561 + set_line(lines,nline,"<th>"+txt6+"</th>")
9.562 + set_line(lines,nline,"<th>"+txt7+"</th>")
9.563 + set_line(lines,nline,"<th>"+txt8+"</th>")
9.564 + set_line(lines,nline,"<th>"+txt9+"</th>")
9.565 +
9.566 + set_line(lines,nline,row_footer)
9.567 + end do
9.568 +;-----------------------------------------------
9.569 + set_line(lines,nline,table_footer)
9.570 + set_line(lines,nline,footer)
9.571 +
9.572 +; Now write to an HTML file.
9.573 +
9.574 + output_html = "table_per_biome.html"
9.575 +
9.576 + idx = ind(.not.ismissing(lines))
9.577 + if(.not.any(ismissing(idx))) then
9.578 + asciiwrite(output_html,lines(idx))
9.579 + else
9.580 + print ("error?")
9.581 + end if
9.582 +
9.583 + delete (idx)
9.584 +
9.585 +;---------------------------------------------------
9.586 +; read model data, time series:
9.587 +
9.588 + fm = addfile (dirm+film7,"r")
9.589 +
9.590 + NPP3 = fm->NPP
9.591 + NEE3 = fm->NEE
9.592 + Fire = fm->COL_FIRE_CLOSS
9.593 +
9.594 + delete (fm)
9.595 +
9.596 +; Units for these variables are:
9.597 +
9.598 +;NPP3: g C/m^2/s
9.599 +;NEE3: g C/m^2/s
9.600 +;Fire: g C/m^2/s
9.601 +
9.602 + nsec_per_month = 60*60*24*30
9.603 +
9.604 +; change unit to g C/m^2/month
9.605 +
9.606 + NPP3 = NPP3 * nsec_per_month * conform(NPP3,landfrac,(/2,3/))
9.607 + NEE3 = NEE3 * nsec_per_month * conform(NEE3,landfrac,(/2,3/))
9.608 + Fire = Fire * nsec_per_month * conform(Fire,landfrac,(/2,3/))
9.609 +
9.610 + data_n = 3
9.611 +
9.612 + dsizes = dimsizes(NPP3)
9.613 + nyear = dsizes(0)
9.614 + nmonth = dsizes(1)
9.615 + ntime = nyear * nmonth
9.616 +
9.617 + year_start = 1979
9.618 + year_end = 2004
9.619 +
9.620 +;*******************************************************************
9.621 +; Calculate "nice" bins for binning the data in equally spaced ranges
9.622 +;********************************************************************
9.623 +
9.624 +; using model biome class
9.625 + nclass = nclass_mod
9.626 +
9.627 + range = fspan(0,nclass,nclass+1)
9.628 +
9.629 +; print (range)
9.630 +; Use this range information to grab all the values in a
9.631 +; particular range, and then take an average.
9.632 +
9.633 + nx = dimsizes(range) - 1
9.634 +
9.635 +;==============================
9.636 +; put data into bins
9.637 +;==============================
9.638 +
9.639 +; using observed biome class
9.640 +; base = ndtooned(classob)
9.641 +; using model biome class
9.642 + base = ndtooned(classmod)
9.643 +
9.644 +; output
9.645 +
9.646 + yvalues = new((/ntime,data_n,nx/),float)
9.647 +
9.648 +; Loop through each range, using base.
9.649 +
9.650 + do i=0,nx-1
9.651 +
9.652 + if (i.ne.(nx-1)) then
9.653 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
9.654 + else
9.655 + idx = ind(base.ge.range(i))
9.656 + end if
9.657 +
9.658 + do n = 0,data_n-1
9.659 +
9.660 + t = -1
9.661 + do m = 0,nyear-1
9.662 + do k = 0,nmonth-1
9.663 +
9.664 + t = t + 1
9.665 +
9.666 + if (n.eq.0) then
9.667 + data = ndtooned(NPP3(m,k,:,:))
9.668 + end if
9.669 +
9.670 + if (n.eq.1) then
9.671 + data = ndtooned(NEE3(m,k,:,:))
9.672 + end if
9.673 +
9.674 + if (n.eq.2) then
9.675 + data = ndtooned(Fire(m,k,:,:))
9.676 + end if
9.677 +
9.678 +; Calculate average
9.679 +
9.680 + if (.not.any(ismissing(idx))) then
9.681 + yvalues(t,n,i) = sum(data(idx)*area_1d(idx))
9.682 + else
9.683 + yvalues(t,n,i) = yvalues@_FillValue
9.684 + end if
9.685 +
9.686 +;#############################################################
9.687 +; using model biome class:
9.688 +; set the following 4 classes to _FillValue:
9.689 +; (3)Needleleaf Deciduous Boreal Tree,
9.690 +; (8)Broadleaf Deciduous Boreal Tree,
9.691 +; (9)Broadleaf Evergreen Shrub,
9.692 +; (16)Wheat
9.693 +
9.694 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
9.695 + yvalues(t,n,i) = yvalues@_FillValue
9.696 + end if
9.697 +;#############################################################
9.698 +
9.699 + end do
9.700 + end do
9.701 +
9.702 + delete(data)
9.703 + end do
9.704 +
9.705 + delete(idx)
9.706 + end do
9.707 +
9.708 + delete (base)
9.709 + delete (NPP3)
9.710 + delete (NEE3)
9.711 + delete (Fire)
9.712 +
9.713 +;----------------------------------------------------------------
9.714 +; data for tseries plot
9.715 +
9.716 + yvalues_g = new((/ntime,data_n,n_biome/),float)
9.717 +
9.718 + yvalues_g@units = "TgC/month"
9.719 +
9.720 +; change unit to Tg C/month
9.721 +; change unit from g to Tg (Tera gram)
9.722 + factor_unit = 1.e-12
9.723 +
9.724 + yvalues_g = yvalues(:,:,good) * factor_unit
9.725 +
9.726 +;*******************************************************************
9.727 +; general settings for line plot
9.728 +;*******************************************************************
9.729 +
9.730 +; res
9.731 + res = True
9.732 + res@xyDashPatterns = (/0/) ; make lines solid
9.733 + res@xyLineThicknesses = (/2.0/) ; make lines thicker
9.734 + res@xyLineColors = (/"blue"/) ; line color
9.735 +
9.736 + res@trXMinF = year_start
9.737 + res@trXMaxF = year_end + 1
9.738 +
9.739 + res@vpHeightF = 0.4 ; change aspect ratio of plot
9.740 +; res@vpWidthF = 0.8
9.741 + res@vpWidthF = 0.75
9.742 +
9.743 +; res@gsnMaximize = True
9.744 +
9.745 +;*******************************************************************
9.746 +; (A) 1 component in each biome: monthly
9.747 +;*******************************************************************
9.748 +
9.749 + component = (/"NPP","NEE","Fire"/)
9.750 +
9.751 +; for x-axis in xyplot
9.752 +
9.753 + timeI = new((/ntime/),integer)
9.754 + timeF = new((/ntime/),float)
9.755 + timeI = ispan(1,ntime,1)
9.756 + timeF = year_start + (timeI-1)/12.
9.757 + timeF@long_name = "year"
9.758 +
9.759 + plot_data = new((/ntime/),float)
9.760 + plot_data@long_name = "TgC/month"
9.761 +
9.762 + do n = 0, data_n-1
9.763 + do m = 0, n_biome-1
9.764 +
9.765 + plot_name = component(n)+"_monthly_biome_"+ m
9.766 +
9.767 + wks = gsn_open_wks (plot_type,plot_name)
9.768 +
9.769 + title = component(n)+ ": "+ row_head(m)
9.770 + res@tiMainString = title
9.771 + res@tiMainFontHeightF = 0.025
9.772 +
9.773 + plot_data(:) = yvalues_g(:,n,m)
9.774 +
9.775 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
9.776 +
9.777 + delete (wks)
9.778 + delete (plot)
9.779 +
9.780 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
9.781 + "rm "+plot_name+"."+plot_type)
9.782 + end do
9.783 + end do
9.784 +
9.785 + do n = 0, data_n-1
9.786 +
9.787 + plot_name = component(n)+"_monthly_global"
9.788 +
9.789 + wks = gsn_open_wks (plot_type,plot_name)
9.790 +
9.791 + title = component(n)+ ": Global"
9.792 + res@tiMainString = title
9.793 + res@tiMainFontHeightF = 0.025
9.794 +
9.795 + do k = 0,ntime-1
9.796 + plot_data(k) = sum(yvalues_g(k,n,:))
9.797 + end do
9.798 +
9.799 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
9.800 +
9.801 + delete (wks)
9.802 + delete (plot)
9.803 +
9.804 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
9.805 + "rm "+plot_name+"."+plot_type)
9.806 + end do
9.807 +
9.808 + delete (plot_data)
9.809 + delete (timeI)
9.810 + delete (timeF)
9.811 +
9.812 +;*******************************************************************
9.813 +; (B) 1 component in each biome: annually
9.814 +;*******************************************************************
9.815 +
9.816 + yvalues_a = new((/nyear,data_n,n_biome/),float)
9.817 + yvalues_g!0 = "time"
9.818 + yvalues_g!1 = "case"
9.819 + yvalues_g!2 = "record"
9.820 +
9.821 + yvalues_a = month_to_annual(yvalues_g,0)
9.822 +
9.823 + delete (yvalues_g)
9.824 +
9.825 +; for x-axis in xyplot
9.826 +
9.827 + timeI = new((/nyear/),integer)
9.828 + timeF = new((/nyear/),float)
9.829 + timeI = ispan(1,nyear,1)
9.830 + timeF = year_start + (timeI-1)
9.831 + timeF@long_name = "year"
9.832 +
9.833 + plot_data = new((/nyear/),float)
9.834 + plot_data@long_name = "TgC/year"
9.835 +
9.836 + do n = 0, data_n-1
9.837 + do m = 0, n_biome-1
9.838 +
9.839 + plot_name = component(n)+"_annual_biome_"+ m
9.840 +
9.841 + wks = gsn_open_wks (plot_type,plot_name)
9.842 +
9.843 + title = component(n)+ ": "+ row_head(m)
9.844 + res@tiMainString = title
9.845 + res@tiMainFontHeightF = 0.025
9.846 +
9.847 + plot_data(:) = yvalues_a(:,n,m)
9.848 +
9.849 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
9.850 +
9.851 + delete (wks)
9.852 + delete (plot)
9.853 +
9.854 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
9.855 + "rm "+plot_name+"."+plot_type)
9.856 + end do
9.857 + end do
9.858 +
9.859 + do n = 0, data_n-1
9.860 +
9.861 + plot_name = component(n)+"_annual_global"
9.862 +
9.863 + wks = gsn_open_wks (plot_type,plot_name)
9.864 +
9.865 + title = component(n)+ ": Global"
9.866 + res@tiMainString = title
9.867 + res@tiMainFontHeightF = 0.025
9.868 +
9.869 + do k = 0,nyear-1
9.870 + plot_data(k) = sum(yvalues_a(k,n,:))
9.871 + end do
9.872 +
9.873 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
9.874 +
9.875 + delete (wks)
9.876 + delete (plot)
9.877 +
9.878 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
9.879 + "rm "+plot_name+"."+plot_type)
9.880 + end do
9.881 +
9.882 +;****************************************
9.883 +; output plot and html
9.884 +;****************************************
9.885 + output_dir = model_name+"/carbon_sink"
9.886 +
9.887 + system("mv *.png *.html " + output_dir)
9.888 +;****************************************
9.889 +
9.890 +end
9.891 +
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/all/09x.carbon_sink.ncl Mon Jan 26 22:08:20 2009 -0500
10.3 @@ -0,0 +1,890 @@
10.4 +;**************************************************************
10.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
10.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
10.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
10.8 +;**************************************************************
10.9 +procedure set_line(lines:string,nline:integer,newlines:string)
10.10 +begin
10.11 +; add line to ascci/html file
10.12 +
10.13 + nnewlines = dimsizes(newlines)
10.14 + if(nline+nnewlines-1.ge.dimsizes(lines))
10.15 + print("set_line: bad index, not setting anything.")
10.16 + return
10.17 + end if
10.18 + lines(nline:nline+nnewlines-1) = newlines
10.19 +; print ("lines = " + lines(nline:nline+nnewlines-1))
10.20 + nline = nline + nnewlines
10.21 + return
10.22 +end
10.23 +;**************************************************************
10.24 +; Main code.
10.25 +begin
10.26 +
10.27 + plot_type = "ps"
10.28 + plot_type_new = "png"
10.29 +
10.30 +;----------------------------------------------------------
10.31 +; edit current model for movel1_vs_model2
10.32 +
10.33 + if (isvar("compare")) then
10.34 + html_name2 = compare+"/table.html"
10.35 + html_new2 = html_name2 +".new"
10.36 + end if
10.37 +
10.38 +;----------------------------------------------------------
10.39 +; edit table.html for current model
10.40 +
10.41 + html_name = model_name+"/table.html"
10.42 + html_new = html_name +".new"
10.43 +
10.44 +;----------------------------------------------------------
10.45 +; get biome data: model
10.46 +
10.47 + biome_name_mod = "Model PFT Class"
10.48 +
10.49 + film_c = "class_pft_"+ model_grid +".nc"
10.50 + fm_c = addfile (dirs+film_c,"r")
10.51 + classmod = fm_c->CLASS_PFT
10.52 +
10.53 + delete (fm_c)
10.54 +
10.55 +; model data has 17 land-type classes
10.56 + nclass_mod = 17
10.57 +
10.58 +;------------------------------------
10.59 +; get model landfrac and area
10.60 +
10.61 + film_l = "lnd_"+ model_grid +".nc"
10.62 + fm_l = addfile (dirs+film_l,"r")
10.63 + landfrac = fm_l->landfrac
10.64 + area = fm_l->area
10.65 +
10.66 + delete (fm_l)
10.67 +
10.68 +; change area from km**2 to m**2
10.69 + area = area * 1.e6
10.70 +
10.71 +;-------------------------------------
10.72 +; take into account landfrac
10.73 +
10.74 +; area = area * landfrac
10.75 +
10.76 +; delete (landfrac)
10.77 +
10.78 +;---------------------------------------------------
10.79 +; read data: model, group 1
10.80 +
10.81 + fm = addfile (dirm+film4,"r")
10.82 +
10.83 + NPP1 = fm->NPP
10.84 +
10.85 + leafc = fm->LEAFC
10.86 + woodc = fm->WOODC
10.87 + frootc = fm->FROOTC
10.88 + VegC = leafc
10.89 + VegC = leafc + woodc + frootc
10.90 +
10.91 + litterc = fm->LITTERC
10.92 + cwdc = fm->CWDC
10.93 + LiCwC = litterc
10.94 + LiCwC = litterc + cwdc
10.95 +
10.96 + SoilC = fm->SOILC
10.97 +
10.98 + delete (fm)
10.99 +;---------------------------------------------------
10.100 +; read data: model, group 2
10.101 +
10.102 + fm = addfile (dirm+film5,"r")
10.103 +
10.104 + NPP2 = fm->NPP
10.105 + NEE2 = fm->NEE
10.106 + GPP2 = fm->GPP
10.107 +
10.108 + delete (fm)
10.109 +;---------------------------------------------------
10.110 +; Units for these variables are:
10.111 +
10.112 +;NPP1: g C/m^2/s
10.113 +;NPP2: g C/m^2/s
10.114 +;NEE2: g C/m^2/s
10.115 +;GPP2: g C/m^2/s
10.116 +
10.117 +;VegC: g C/m^2
10.118 +;LiCwC: g C/m^2
10.119 +;SoilC: g C/m^2
10.120 +
10.121 + nsec_per_year = 60*60*24*365
10.122 +
10.123 +; change unit to g C/m^2/year
10.124 +
10.125 + NPP1 = NPP1 * nsec_per_year * conform(NPP1,landfrac,(/1,2/))
10.126 + NPP2 = NPP2 * nsec_per_year * conform(NPP2,landfrac,(/1,2/))
10.127 + NEE2 = NEE2 * nsec_per_year * conform(NEE2,landfrac,(/1,2/))
10.128 + GPP2 = GPP2 * nsec_per_year * conform(GPP2,landfrac,(/1,2/))
10.129 +
10.130 + VegC = VegC * conform(VegC,landfrac,(/1,2/))
10.131 + LiCwC = LiCwC * conform(LiCwC,landfrac,(/1,2/))
10.132 + SoilC = SoilC * conform(SoilC,landfrac,(/1,2/))
10.133 +
10.134 + data_n = 8
10.135 +
10.136 +;*******************************************************************
10.137 +; Calculate "nice" bins for binning the data in equally spaced ranges
10.138 +;********************************************************************
10.139 +
10.140 +; using model biome class
10.141 + nclass = nclass_mod
10.142 +
10.143 + range = fspan(0,nclass,nclass+1)
10.144 +
10.145 +; print (range)
10.146 +; Use this range information to grab all the values in a
10.147 +; particular range, and then take an average.
10.148 +
10.149 + nx = dimsizes(range) - 1
10.150 +
10.151 +;==============================
10.152 +; put data into bins
10.153 +;==============================
10.154 +
10.155 +; using observed biome class
10.156 +; base = ndtooned(classob)
10.157 +; using model biome class
10.158 + base = ndtooned(classmod)
10.159 +
10.160 + area_1d = ndtooned(area)
10.161 +
10.162 +; output
10.163 +
10.164 + yvalues = new((/data_n,nx/),float) ; (per m2)
10.165 + yvalues_t = new((/data_n,nx/),float) ; (per biome)
10.166 +
10.167 +; Loop through each range, using base.
10.168 +
10.169 + do i=0,nx-1
10.170 +
10.171 + if (i.ne.(nx-1)) then
10.172 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
10.173 + else
10.174 + idx = ind(base.ge.range(i))
10.175 + end if
10.176 +
10.177 + do n = 0,data_n-1
10.178 +
10.179 + if (n.eq.0) then
10.180 + data = ndtooned(area)
10.181 + end if
10.182 +
10.183 + if (n.eq.1) then
10.184 + data = ndtooned(NPP1)
10.185 + end if
10.186 +
10.187 + if (n.eq.2) then
10.188 + data = ndtooned(VegC)
10.189 + end if
10.190 +
10.191 + if (n.eq.3) then
10.192 + data = ndtooned(LiCwC)
10.193 + end if
10.194 +
10.195 + if (n.eq.4) then
10.196 + data = ndtooned(SoilC)
10.197 + end if
10.198 +
10.199 + if (n.eq.5) then
10.200 + data = ndtooned(NPP2)
10.201 + end if
10.202 +
10.203 + if (n.eq.6) then
10.204 + data = ndtooned(NEE2)
10.205 + end if
10.206 +
10.207 + if (n.eq.7) then
10.208 + data = ndtooned(GPP2)
10.209 + end if
10.210 +
10.211 +; Calculate sum and average
10.212 +
10.213 + if (.not.any(ismissing(idx))) then
10.214 + if (n.eq.0) then
10.215 + yvalues(n,i) = sum(data(idx))
10.216 + yvalues_t(n,i) = sum(data(idx))
10.217 + else
10.218 + yvalues(n,i) = avg(data(idx))
10.219 + yvalues_t(n,i) = sum(data(idx)*area_1d(idx))
10.220 + end if
10.221 + else
10.222 + yvalues(n,i) = yvalues@_FillValue
10.223 + yvalues_t(n,i) = yvalues@_FillValue
10.224 + end if
10.225 +
10.226 +;#############################################################
10.227 +; using model biome class:
10.228 +; set the following 4 classes to _FillValue:
10.229 +; (3)Needleleaf Deciduous Boreal Tree,
10.230 +; (8)Broadleaf Deciduous Boreal Tree,
10.231 +; (9)Broadleaf Evergreen Shrub,
10.232 +; (16)Wheat
10.233 +
10.234 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
10.235 + yvalues(n,i) = yvalues@_FillValue
10.236 + yvalues_t(n,i) = yvalues@_FillValue
10.237 + end if
10.238 +;#############################################################
10.239 +
10.240 + delete (data)
10.241 + end do
10.242 +
10.243 + delete (idx)
10.244 + end do
10.245 +
10.246 + delete (base)
10.247 + delete (area)
10.248 + delete (NPP1)
10.249 + delete (VegC)
10.250 + delete (LiCwC)
10.251 + delete (SoilC)
10.252 + delete (NPP2)
10.253 + delete (NEE2)
10.254 + delete (GPP2)
10.255 +
10.256 +;----------------------------------------------------------------
10.257 +; data for table1
10.258 +
10.259 + good = ind(.not.ismissing(yvalues(5,:)) .and. .not.ismissing(yvalues(1,:)))
10.260 +;print (good)
10.261 +
10.262 + area_g = yvalues(0,good)
10.263 + NPP1_g = yvalues(1,good)
10.264 + VegC_g = yvalues(2,good)
10.265 + LiCwC_g = yvalues(3,good)
10.266 + SoilC_g = yvalues(4,good)
10.267 + NPP2_g = yvalues(5,good)
10.268 + NEE2_g = yvalues(6,good)
10.269 + GPP2_g = yvalues(7,good)
10.270 +
10.271 + NPP_ratio = NPP2_g/NPP1_g
10.272 +
10.273 + n_biome = dimsizes(NPP1_g)
10.274 +
10.275 +;-----------------------------------------------------------------
10.276 +; data for table2
10.277 +
10.278 +; change unit from g to Pg (Peta gram)
10.279 + factor_unit = 1.e-15
10.280 +
10.281 + NPP1_t = yvalues_t(1,good) * factor_unit
10.282 + VegC_t = yvalues_t(2,good) * factor_unit
10.283 + LiCwC_t = yvalues_t(3,good) * factor_unit
10.284 + SoilC_t = yvalues_t(4,good) * factor_unit
10.285 + NEE2_t = yvalues_t(6,good) * factor_unit
10.286 + GPP2_t = yvalues_t(7,good) * factor_unit
10.287 +
10.288 + delete (yvalues)
10.289 + delete (yvalues_t)
10.290 +
10.291 +;-------------------------------------------------------------
10.292 +; html table1 data
10.293 +
10.294 +; column (not including header column)
10.295 +
10.296 + col_head = (/"Area (1.e12m2)" \
10.297 + ,"NPP (gC/m2/yr)" \
10.298 + ,"VegC (gC/m2)" \
10.299 + ,"Litter+CWD (gC/m2)" \
10.300 + ,"SoilC (gC/m2)" \
10.301 + ,"NPP_ratio" \
10.302 + ,"NEE (gC/m2/yr)" \
10.303 + ,"GPP (gC/m2/yr)" \
10.304 + /)
10.305 +
10.306 + ncol = dimsizes(col_head)
10.307 +
10.308 +; row (not including header row)
10.309 +
10.310 +; using model biome class:
10.311 + row_head = (/"Not Vegetated" \
10.312 + ,"Needleleaf Evergreen Temperate Tree" \
10.313 + ,"Needleleaf Evergreen Boreal Tree" \
10.314 +; ,"Needleleaf Deciduous Boreal Tree" \
10.315 + ,"Broadleaf Evergreen Tropical Tree" \
10.316 + ,"Broadleaf Evergreen Temperate Tree" \
10.317 + ,"Broadleaf Deciduous Tropical Tree" \
10.318 + ,"Broadleaf Deciduous Temperate Tree" \
10.319 +; ,"Broadleaf Deciduous Boreal Tree" \
10.320 +; ,"Broadleaf Evergreen Shrub" \
10.321 + ,"Broadleaf Deciduous Temperate Shrub" \
10.322 + ,"Broadleaf Deciduous Boreal Shrub" \
10.323 + ,"C3 Arctic Grass" \
10.324 + ,"C3 Non-Arctic Grass" \
10.325 + ,"C4 Grass" \
10.326 + ,"Corn" \
10.327 +; ,"Wheat" \
10.328 + ,"All Biome" \
10.329 + /)
10.330 + nrow = dimsizes(row_head)
10.331 +
10.332 +; arrays to be passed to table.
10.333 + text = new ((/nrow, ncol/),string )
10.334 +
10.335 + do i=0,nrow-2
10.336 + text(i,0) = sprintf("%.1f",area_g(i)*1.e-12)
10.337 + text(i,1) = sprintf("%.1f",NPP1_g(i))
10.338 + text(i,2) = sprintf("%.1f",VegC_g(i))
10.339 + text(i,3) = sprintf("%.1f",LiCwC_g(i))
10.340 + text(i,4) = sprintf("%.1f",SoilC_g(i))
10.341 + text(i,5) = sprintf("%.2f",NPP_ratio(i))
10.342 + text(i,6) = sprintf("%.1f",NEE2_g(i))
10.343 + text(i,7) = sprintf("%.1f",GPP2_g(i))
10.344 + end do
10.345 +
10.346 +;-------------------------------------------------------
10.347 +; create html table1
10.348 +
10.349 + header_text = "<H1>NEE and Carbon Stocks and Fluxes: Model "+model_name+"</H1>"
10.350 +
10.351 + header = (/"<HTML>" \
10.352 + ,"<HEAD>" \
10.353 + ,"<TITLE>CLAMP metrics</TITLE>" \
10.354 + ,"</HEAD>" \
10.355 + ,header_text \
10.356 + /)
10.357 + footer = "</HTML>"
10.358 +
10.359 + table_header = (/ \
10.360 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
10.361 + ,"<tr>" \
10.362 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
10.363 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
10.364 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
10.365 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
10.366 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
10.367 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
10.368 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
10.369 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
10.370 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
10.371 + ,"</tr>" \
10.372 + /)
10.373 + table_footer = "</table>"
10.374 + row_header = "<tr>"
10.375 + row_footer = "</tr>"
10.376 +
10.377 + lines = new(50000,string)
10.378 + nline = 0
10.379 +
10.380 + set_line(lines,nline,header)
10.381 + set_line(lines,nline,table_header)
10.382 +
10.383 +;----------------------------
10.384 +;row of table
10.385 +
10.386 + do n = 0,nrow-2
10.387 + set_line(lines,nline,row_header)
10.388 +
10.389 + txt0 = row_head(n)
10.390 + txt1 = text(n,0)
10.391 + txt2 = text(n,1)
10.392 + txt3 = text(n,2)
10.393 + txt4 = text(n,3)
10.394 + txt5 = text(n,4)
10.395 + txt6 = text(n,5)
10.396 + txt7 = text(n,6)
10.397 + txt8 = text(n,7)
10.398 +
10.399 + set_line(lines,nline,"<th>"+txt0+"</th>")
10.400 + set_line(lines,nline,"<th>"+txt1+"</th>")
10.401 + set_line(lines,nline,"<th>"+txt2+"</th>")
10.402 + set_line(lines,nline,"<th>"+txt3+"</th>")
10.403 + set_line(lines,nline,"<th>"+txt4+"</th>")
10.404 + set_line(lines,nline,"<th>"+txt5+"</th>")
10.405 + set_line(lines,nline,"<th>"+txt6+"</th>")
10.406 + set_line(lines,nline,"<th>"+txt7+"</th>")
10.407 + set_line(lines,nline,"<th>"+txt8+"</th>")
10.408 +
10.409 + set_line(lines,nline,row_footer)
10.410 + end do
10.411 +;----------------------------
10.412 + set_line(lines,nline,table_footer)
10.413 + set_line(lines,nline,footer)
10.414 +
10.415 +; Now write to an HTML file.
10.416 +
10.417 + output_html = "table_per_m2.html"
10.418 +
10.419 + idx = ind(.not.ismissing(lines))
10.420 + if(.not.any(ismissing(idx))) then
10.421 + asciiwrite(output_html,lines(idx))
10.422 + else
10.423 + print ("error?")
10.424 + end if
10.425 +
10.426 + delete (idx)
10.427 +
10.428 + delete (col_head)
10.429 + delete (row_head)
10.430 + delete (text)
10.431 + delete (table_header)
10.432 +
10.433 +;-----------------------------------------------------------------
10.434 +; html table2 data
10.435 +
10.436 +; column (not including header column)
10.437 +
10.438 + col_head = (/"NPP (PgC/yr)" \
10.439 + ,"VegC (PgC)" \
10.440 + ,"Litter+CWD (PgC)" \
10.441 + ,"SoilC (PgC)" \
10.442 + ,"NEE (PgC/yr)" \
10.443 + ,"GPP (PgC/yr)" \
10.444 + ,"NPP timeseries" \
10.445 + ,"NEE timeseries" \
10.446 + ,"Fire timeseries" \
10.447 + /)
10.448 +
10.449 + ncol = dimsizes(col_head)
10.450 +
10.451 +; row (not including header row)
10.452 +
10.453 +; using model biome class:
10.454 + row_head = (/"Not Vegetated" \
10.455 + ,"Needleleaf Evergreen Temperate Tree" \
10.456 + ,"Needleleaf Evergreen Boreal Tree" \
10.457 +; ,"Needleleaf Deciduous Boreal Tree" \
10.458 + ,"Broadleaf Evergreen Tropical Tree" \
10.459 + ,"Broadleaf Evergreen Temperate Tree" \
10.460 + ,"Broadleaf Deciduous Tropical Tree" \
10.461 + ,"Broadleaf Deciduous Temperate Tree" \
10.462 +; ,"Broadleaf Deciduous Boreal Tree" \
10.463 +; ,"Broadleaf Evergreen Shrub" \
10.464 + ,"Broadleaf Deciduous Temperate Shrub" \
10.465 + ,"Broadleaf Deciduous Boreal Shrub" \
10.466 + ,"C3 Arctic Grass" \
10.467 + ,"C3 Non-Arctic Grass" \
10.468 + ,"C4 Grass" \
10.469 + ,"Corn" \
10.470 +; ,"Wheat" \
10.471 + ,"All Biome" \
10.472 + /)
10.473 + nrow = dimsizes(row_head)
10.474 +
10.475 +; arrays to be passed to table.
10.476 + text = new ((/nrow, ncol/),string )
10.477 +
10.478 + do i=0,nrow-2
10.479 + text(i,0) = sprintf("%.1f",NPP1_t(i))
10.480 + text(i,1) = sprintf("%.1f",VegC_t(i))
10.481 + text(i,2) = sprintf("%.1f",LiCwC_t(i))
10.482 + text(i,3) = sprintf("%.1f",SoilC_t(i))
10.483 + text(i,4) = sprintf("%.1f",NEE2_t(i))
10.484 + text(i,5) = sprintf("%.1f",GPP2_t(i))
10.485 + text(i,6) = "<a href=./NPP_monthly_biome_"+i+".png>monthly_plot</a> <br> <a href=./NPP_annual_biome_"+i+".png>annual_plot</a>"
10.486 + text(i,7) = "<a href=./NEE_monthly_biome_"+i+".png>monthly_plot</a> <br> <a href=./NEE_annual_biome_"+i+".png>annual_plot</a>"
10.487 + text(i,8) = "--"
10.488 + end do
10.489 +
10.490 + text(nrow-1,0) = sprintf("%.1f",sum(NPP1_t))
10.491 + text(nrow-1,1) = sprintf("%.1f",sum(VegC_t))
10.492 + text(nrow-1,2) = sprintf("%.1f",sum(LiCwC_t))
10.493 + text(nrow-1,3) = sprintf("%.1f",sum(SoilC_t))
10.494 + text(nrow-1,4) = sprintf("%.1f",sum(NEE2_t))
10.495 + text(nrow-1,5) = sprintf("%.1f",sum(GPP2_t))
10.496 + text(nrow-1,6) = "<a href=./NPP_monthly_global.png>monthly_plot</a> <br> <a href=./NPP_annual_global.png>annual_plot</a>"
10.497 + text(nrow-1,7) = "<a href=./NEE_monthly_global.png>monthly_plot</a> <br> <a href=./NEE_annual_global.png>annual_plot</a>"
10.498 + text(nrow-1,8) = "--"
10.499 +
10.500 +;**************************************************
10.501 +; create html table2
10.502 +;**************************************************
10.503 +
10.504 + header_text = "<H1>NEE and Carbon Stocks and Fluxes (per biome): Model "+model_name+"</H1>"
10.505 +
10.506 + header = (/"<HTML>" \
10.507 + ,"<HEAD>" \
10.508 + ,"<TITLE>CLAMP metrics</TITLE>" \
10.509 + ,"</HEAD>" \
10.510 + ,header_text \
10.511 + /)
10.512 + footer = "</HTML>"
10.513 +
10.514 + table_header = (/ \
10.515 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
10.516 + ,"<tr>" \
10.517 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
10.518 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
10.519 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
10.520 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
10.521 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
10.522 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
10.523 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
10.524 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
10.525 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
10.526 + ," <th bgcolor=DDDDDD >"+col_head(8)+"</th>" \
10.527 + ,"</tr>" \
10.528 + /)
10.529 + table_footer = "</table>"
10.530 + row_header = "<tr>"
10.531 + row_footer = "</tr>"
10.532 +
10.533 + lines = new(50000,string)
10.534 + nline = 0
10.535 +
10.536 + set_line(lines,nline,header)
10.537 + set_line(lines,nline,table_header)
10.538 +;-----------------------------------------------
10.539 +;row of table
10.540 +
10.541 + do n = 0,nrow-1
10.542 + set_line(lines,nline,row_header)
10.543 +
10.544 + txt0 = row_head(n)
10.545 + txt1 = text(n,0)
10.546 + txt2 = text(n,1)
10.547 + txt3 = text(n,2)
10.548 + txt4 = text(n,3)
10.549 + txt5 = text(n,4)
10.550 + txt6 = text(n,5)
10.551 + txt7 = text(n,6)
10.552 + txt8 = text(n,7)
10.553 + txt9 = text(n,8)
10.554 +
10.555 + set_line(lines,nline,"<th>"+txt0+"</th>")
10.556 + set_line(lines,nline,"<th>"+txt1+"</th>")
10.557 + set_line(lines,nline,"<th>"+txt2+"</th>")
10.558 + set_line(lines,nline,"<th>"+txt3+"</th>")
10.559 + set_line(lines,nline,"<th>"+txt4+"</th>")
10.560 + set_line(lines,nline,"<th>"+txt5+"</th>")
10.561 + set_line(lines,nline,"<th>"+txt6+"</th>")
10.562 + set_line(lines,nline,"<th>"+txt7+"</th>")
10.563 + set_line(lines,nline,"<th>"+txt8+"</th>")
10.564 + set_line(lines,nline,"<th>"+txt9+"</th>")
10.565 +
10.566 + set_line(lines,nline,row_footer)
10.567 + end do
10.568 +;-----------------------------------------------
10.569 + set_line(lines,nline,table_footer)
10.570 + set_line(lines,nline,footer)
10.571 +
10.572 +; Now write to an HTML file.
10.573 +
10.574 + output_html = "table_per_biome.html"
10.575 +
10.576 + idx = ind(.not.ismissing(lines))
10.577 + if(.not.any(ismissing(idx))) then
10.578 + asciiwrite(output_html,lines(idx))
10.579 + else
10.580 + print ("error?")
10.581 + end if
10.582 +
10.583 + delete (idx)
10.584 +
10.585 +;---------------------------------------------------
10.586 +; read model data, time series:
10.587 +
10.588 + fm = addfile (dirm+film7,"r")
10.589 +
10.590 + NPP3 = fm->NPP
10.591 + NEE3 = fm->NEE
10.592 +;Fire = fm->COL_FIRE_CLOSS
10.593 +
10.594 + delete (fm)
10.595 +
10.596 +; Units for these variables are:
10.597 +
10.598 +;NPP3: g C/m^2/s
10.599 +;NEE3: g C/m^2/s
10.600 +;Fire: g C/m^2/s
10.601 +
10.602 + nsec_per_month = 60*60*24*30
10.603 +
10.604 +; change unit to g C/m^2/month
10.605 +
10.606 + NPP3 = NPP3 * nsec_per_month * conform(NPP3,landfrac,(/2,3/))
10.607 + NEE3 = NEE3 * nsec_per_month * conform(NEE3,landfrac,(/2,3/))
10.608 +;Fire = Fire * nsec_per_month * conform(Fire,landfrac,(/2,3/))
10.609 +
10.610 +;data_n = 3
10.611 + data_n = 2
10.612 +
10.613 + dsizes = dimsizes(NPP3)
10.614 + nyear = dsizes(0)
10.615 + nmonth = dsizes(1)
10.616 + ntime = nyear * nmonth
10.617 +
10.618 + year_start = 1979
10.619 + year_end = 2004
10.620 +
10.621 +;*******************************************************************
10.622 +; Calculate "nice" bins for binning the data in equally spaced ranges
10.623 +;********************************************************************
10.624 +
10.625 +; using model biome class
10.626 + nclass = nclass_mod
10.627 +
10.628 + range = fspan(0,nclass,nclass+1)
10.629 +
10.630 +; print (range)
10.631 +; Use this range information to grab all the values in a
10.632 +; particular range, and then take an average.
10.633 +
10.634 + nx = dimsizes(range) - 1
10.635 +
10.636 +;==============================
10.637 +; put data into bins
10.638 +;==============================
10.639 +
10.640 +; using observed biome class
10.641 +; base = ndtooned(classob)
10.642 +; using model biome class
10.643 + base = ndtooned(classmod)
10.644 +
10.645 +; output
10.646 +
10.647 + yvalues = new((/ntime,data_n,nx/),float)
10.648 +
10.649 +; Loop through each range, using base.
10.650 +
10.651 + do i=0,nx-1
10.652 +
10.653 + if (i.ne.(nx-1)) then
10.654 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
10.655 + else
10.656 + idx = ind(base.ge.range(i))
10.657 + end if
10.658 +
10.659 + do n = 0,data_n-1
10.660 +
10.661 + t = -1
10.662 + do m = 0,nyear-1
10.663 + do k = 0,nmonth-1
10.664 +
10.665 + t = t + 1
10.666 +
10.667 + if (n.eq.0) then
10.668 + data = ndtooned(NPP3(m,k,:,:))
10.669 + end if
10.670 +
10.671 + if (n.eq.1) then
10.672 + data = ndtooned(NEE3(m,k,:,:))
10.673 + end if
10.674 +
10.675 +; if (n.eq.2) then
10.676 +; data = ndtooned(Fire(m,k,:,:))
10.677 +; end if
10.678 +
10.679 +; Calculate average
10.680 +
10.681 + if (.not.any(ismissing(idx))) then
10.682 + yvalues(t,n,i) = sum(data(idx)*area_1d(idx))
10.683 + else
10.684 + yvalues(t,n,i) = yvalues@_FillValue
10.685 + end if
10.686 +
10.687 +;#############################################################
10.688 +; using model biome class:
10.689 +; set the following 4 classes to _FillValue:
10.690 +; (3)Needleleaf Deciduous Boreal Tree,
10.691 +; (8)Broadleaf Deciduous Boreal Tree,
10.692 +; (9)Broadleaf Evergreen Shrub,
10.693 +; (16)Wheat
10.694 +
10.695 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
10.696 + yvalues(t,n,i) = yvalues@_FillValue
10.697 + end if
10.698 +;#############################################################
10.699 +
10.700 + end do
10.701 + end do
10.702 +
10.703 + delete(data)
10.704 + end do
10.705 +
10.706 + delete(idx)
10.707 + end do
10.708 +
10.709 + delete (base)
10.710 + delete (NPP3)
10.711 + delete (NEE3)
10.712 +; delete (Fire)
10.713 +
10.714 +;----------------------------------------------------------------
10.715 +; data for tseries plot
10.716 +
10.717 + yvalues_g = new((/ntime,data_n,n_biome/),float)
10.718 +
10.719 + yvalues_g@units = "TgC/month"
10.720 +
10.721 +; change unit to Tg C/month
10.722 +; change unit from g to Tg (Tera gram)
10.723 + factor_unit = 1.e-12
10.724 +
10.725 + yvalues_g = yvalues(:,:,good) * factor_unit
10.726 +
10.727 +;*******************************************************************
10.728 +; general settings for line plot
10.729 +;*******************************************************************
10.730 +
10.731 +; res
10.732 + res = True
10.733 + res@xyDashPatterns = (/0/) ; make lines solid
10.734 + res@xyLineThicknesses = (/2.0/) ; make lines thicker
10.735 + res@xyLineColors = (/"blue"/) ; line color
10.736 +
10.737 + res@trXMinF = year_start
10.738 + res@trXMaxF = year_end + 1
10.739 +
10.740 + res@vpHeightF = 0.4 ; change aspect ratio of plot
10.741 +; res@vpWidthF = 0.8
10.742 + res@vpWidthF = 0.75
10.743 +
10.744 +; res@gsnMaximize = True
10.745 +
10.746 +;*******************************************************************
10.747 +; (A) 1 component in each biome: monthly
10.748 +;*******************************************************************
10.749 +
10.750 +; component = (/"NPP","NEE","Fire"/)
10.751 + component = (/"NPP","NEE"/)
10.752 +
10.753 +; for x-axis in xyplot
10.754 +
10.755 + timeI = new((/ntime/),integer)
10.756 + timeF = new((/ntime/),float)
10.757 + timeI = ispan(1,ntime,1)
10.758 + timeF = year_start + (timeI-1)/12.
10.759 + timeF@long_name = "year"
10.760 +
10.761 + plot_data = new((/ntime/),float)
10.762 + plot_data@long_name = "TgC/month"
10.763 +
10.764 + do n = 0, data_n-1
10.765 + do m = 0, n_biome-1
10.766 +
10.767 + plot_name = component(n)+"_monthly_biome_"+ m
10.768 +
10.769 + wks = gsn_open_wks (plot_type,plot_name)
10.770 +
10.771 + title = component(n)+ ": "+ row_head(m)
10.772 + res@tiMainString = title
10.773 + res@tiMainFontHeightF = 0.025
10.774 +
10.775 + plot_data(:) = yvalues_g(:,n,m)
10.776 +
10.777 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
10.778 +
10.779 + delete (wks)
10.780 + delete (plot)
10.781 +
10.782 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
10.783 + "rm "+plot_name+"."+plot_type)
10.784 + end do
10.785 + end do
10.786 +
10.787 + do n = 0, data_n-1
10.788 +
10.789 + plot_name = component(n)+"_monthly_global"
10.790 +
10.791 + wks = gsn_open_wks (plot_type,plot_name)
10.792 +
10.793 + title = component(n)+ ": Global"
10.794 + res@tiMainString = title
10.795 + res@tiMainFontHeightF = 0.025
10.796 +
10.797 + do k = 0,ntime-1
10.798 + plot_data(k) = sum(yvalues_g(k,n,:))
10.799 + end do
10.800 +
10.801 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
10.802 +
10.803 + delete (wks)
10.804 + delete (plot)
10.805 +
10.806 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
10.807 + "rm "+plot_name+"."+plot_type)
10.808 + end do
10.809 +
10.810 + delete (plot_data)
10.811 + delete (timeI)
10.812 + delete (timeF)
10.813 +
10.814 +;*******************************************************************
10.815 +; (B) 1 component in each biome: annually
10.816 +;*******************************************************************
10.817 +
10.818 + yvalues_a = new((/nyear,data_n,n_biome/),float)
10.819 + yvalues_g!0 = "time"
10.820 + yvalues_g!1 = "case"
10.821 + yvalues_g!2 = "record"
10.822 +
10.823 + yvalues_a = month_to_annual(yvalues_g,0)
10.824 +
10.825 + delete (yvalues_g)
10.826 +
10.827 +; for x-axis in xyplot
10.828 +
10.829 + timeI = new((/nyear/),integer)
10.830 + timeF = new((/nyear/),float)
10.831 + timeI = ispan(1,nyear,1)
10.832 + timeF = year_start + (timeI-1)
10.833 + timeF@long_name = "year"
10.834 +
10.835 + plot_data = new((/nyear/),float)
10.836 + plot_data@long_name = "TgC/year"
10.837 +
10.838 + do n = 0, data_n-1
10.839 + do m = 0, n_biome-1
10.840 +
10.841 + plot_name = component(n)+"_annual_biome_"+ m
10.842 +
10.843 + wks = gsn_open_wks (plot_type,plot_name)
10.844 +
10.845 + title = component(n)+ ": "+ row_head(m)
10.846 + res@tiMainString = title
10.847 + res@tiMainFontHeightF = 0.025
10.848 +
10.849 + plot_data(:) = yvalues_a(:,n,m)
10.850 +
10.851 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
10.852 +
10.853 + delete (wks)
10.854 + delete (plot)
10.855 +
10.856 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
10.857 + "rm "+plot_name+"."+plot_type)
10.858 + end do
10.859 + end do
10.860 +
10.861 + do n = 0, data_n-1
10.862 +
10.863 + plot_name = component(n)+"_annual_global"
10.864 +
10.865 + wks = gsn_open_wks (plot_type,plot_name)
10.866 +
10.867 + title = component(n)+ ": Global"
10.868 + res@tiMainString = title
10.869 + res@tiMainFontHeightF = 0.025
10.870 +
10.871 + do k = 0,nyear-1
10.872 + plot_data(k) = sum(yvalues_a(k,n,:))
10.873 + end do
10.874 +
10.875 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
10.876 +
10.877 + delete (wks)
10.878 + delete (plot)
10.879 +
10.880 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
10.881 + "rm "+plot_name+"."+plot_type)
10.882 + end do
10.883 +
10.884 +;****************************************
10.885 +; output plot and html
10.886 +;****************************************
10.887 + output_dir = model_name+"/carbon_sink"
10.888 +
10.889 + system("mv *.png *.html " + output_dir)
10.890 +;****************************************
10.891 +
10.892 +end
10.893 +
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/all/10.fire.ncl Mon Jan 26 22:08:20 2009 -0500
11.3 @@ -0,0 +1,744 @@
11.4 +;**************************************************************
11.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
11.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
11.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
11.8 +;**************************************************************
11.9 +procedure set_line(lines:string,nline:integer,newlines:string)
11.10 +begin
11.11 +; add line to ascci/html file
11.12 +
11.13 + nnewlines = dimsizes(newlines)
11.14 + if(nline+nnewlines-1.ge.dimsizes(lines))
11.15 + print("set_line: bad index, not setting anything.")
11.16 + return
11.17 + end if
11.18 + lines(nline:nline+nnewlines-1) = newlines
11.19 +; print ("lines = " + lines(nline:nline+nnewlines-1))
11.20 + nline = nline + nnewlines
11.21 + return
11.22 +end
11.23 +;**************************************************************
11.24 +; Main code.
11.25 +begin
11.26 +
11.27 + plot_type = "ps"
11.28 + plot_type_new = "png"
11.29 +
11.30 +;------------------------------------------------------
11.31 +; edit table.html of current model for movel1_vs_model2
11.32 +
11.33 + if (isvar("compare")) then
11.34 + html_name2 = compare+"/table.html"
11.35 + html_new2 = html_name2 +".new"
11.36 + end if
11.37 +
11.38 +;------------------------------------------------------
11.39 +; edit table.html for current model
11.40 +
11.41 + html_name = model_name+"/table.html"
11.42 + html_new = html_name +".new"
11.43 +
11.44 +;------------------------------------------------------
11.45 +; get biome data: model
11.46 +
11.47 + biome_name_mod = "Model PFT Class"
11.48 +
11.49 + film_c = "class_pft_"+ model_grid +".nc"
11.50 + fm_c = addfile (dirs+film_c,"r")
11.51 + classmod = fm_c->CLASS_PFT
11.52 +
11.53 + delete (fm_c)
11.54 +
11.55 +; model data has 17 land-type classes
11.56 + nclass_mod = 17
11.57 +
11.58 +;--------------------------------
11.59 +; get model data: landmask, landfrac and area
11.60 +
11.61 + film_l = "lnd_"+ model_grid +".nc"
11.62 + fm_l = addfile (dirs+film_l,"r")
11.63 + landmask = fm_l->landmask
11.64 + landfrac = fm_l->landfrac
11.65 + area = fm_l->area
11.66 +
11.67 + delete (fm_l)
11.68 +
11.69 +; change area from km**2 to m**2
11.70 + area = area * 1.e6
11.71 +
11.72 +; take into account landfrac
11.73 + area = area * landfrac
11.74 +
11.75 +;--------------------------------
11.76 +; read data: time series, model
11.77 +
11.78 + fm = addfile (dirm+film7,"r")
11.79 +
11.80 + data_mod = fm->COL_FIRE_CLOSS(18:25,:,:,:)
11.81 +
11.82 + delete (fm)
11.83 +
11.84 +; Units for these variables are:
11.85 +; g C/m^2/s
11.86 +
11.87 +; change unit to gC/m2/month
11.88 +
11.89 + nsec_per_month = 60*60*24*30
11.90 +
11.91 + data_mod = data_mod * nsec_per_month
11.92 +
11.93 + data_mod@units = "gC/m2/month"
11.94 +
11.95 +;----------------------------------------------------
11.96 +; read data: time series, observed
11.97 +
11.98 + dir_f = diro + "fire/"
11.99 + fil_f = "Fire_C_1997-2006_monthly_"+ model_grid+".nc"
11.100 + fm = addfile (dir_f+fil_f,"r")
11.101 + data_ob = fm->FIRE_C(0:7,:,:,:)
11.102 +
11.103 + delete (fm)
11.104 +
11.105 + ob_name = "GFEDv2"
11.106 +
11.107 +; Units for these variables are: gC/m2/month
11.108 +
11.109 + data_ob@units = "gC/m2/month"
11.110 +
11.111 +;-------------------------------------------------------------
11.112 +; html table1 data
11.113 +
11.114 +; column (not including header column)
11.115 +
11.116 + col_head = (/"Observed Fire_Flux (PgC/yr)" \
11.117 + ,"Model Fire_Flux (PgC/yr)" \
11.118 + ,"Correlation Coefficient" \
11.119 + ,"Ratio model/observed" \
11.120 + ,"M_score" \
11.121 + ,"Timeseries plot" \
11.122 + /)
11.123 +
11.124 + ncol = dimsizes(col_head)
11.125 +
11.126 +; row (not including header row)
11.127 +
11.128 +; using model biome class:
11.129 + row_head = (/"Not Vegetated" \
11.130 + ,"Needleleaf Evergreen Temperate Tree" \
11.131 + ,"Needleleaf Evergreen Boreal Tree" \
11.132 +; ,"Needleleaf Deciduous Boreal Tree" \
11.133 + ,"Broadleaf Evergreen Tropical Tree" \
11.134 + ,"Broadleaf Evergreen Temperate Tree" \
11.135 + ,"Broadleaf Deciduous Tropical Tree" \
11.136 + ,"Broadleaf Deciduous Temperate Tree" \
11.137 +; ,"Broadleaf Deciduous Boreal Tree" \
11.138 +; ,"Broadleaf Evergreen Shrub" \
11.139 + ,"Broadleaf Deciduous Temperate Shrub" \
11.140 + ,"Broadleaf Deciduous Boreal Shrub" \
11.141 + ,"C3 Arctic Grass" \
11.142 + ,"C3 Non-Arctic Grass" \
11.143 + ,"C4 Grass" \
11.144 + ,"Corn" \
11.145 +; ,"Wheat" \
11.146 + ,"All Biomes" \
11.147 + /)
11.148 + nrow = dimsizes(row_head)
11.149 +
11.150 +; arrays to be passed to table.
11.151 + text = new ((/nrow, ncol/),string )
11.152 +
11.153 +;*****************************************************************
11.154 +; (A) get time-mean
11.155 +;*****************************************************************
11.156 +
11.157 + x = dim_avg_Wrap(data_mod(lat|:,lon|:,month|:,year|:))
11.158 + data_mod_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
11.159 + delete (x)
11.160 +
11.161 + x = dim_avg_Wrap( data_ob(lat|:,lon|:,month|:,year|:))
11.162 + data_ob_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
11.163 + delete (x)
11.164 +
11.165 +;----------------------------------------------------
11.166 +; compute correlation coef: space
11.167 +
11.168 + landmask_1d = ndtooned(landmask)
11.169 + data_mod_1d = ndtooned(data_mod_m)
11.170 + data_ob_1d = ndtooned(data_ob_m )
11.171 + area_1d = ndtooned(area)
11.172 + landfrac_1d = ndtooned(landfrac)
11.173 +
11.174 + good = ind(landmask_1d .gt. 0.)
11.175 +
11.176 + global_mod = sum(data_mod_1d(good)*area_1d(good)) * 1.e-15 * 12.
11.177 + global_ob = sum(data_ob_1d(good) *area_1d(good)) * 1.e-15 * 12.
11.178 +; print (global_mod)
11.179 +; print (global_ob)
11.180 +
11.181 + global_area= sum(area_1d)
11.182 + global_land= sum(area_1d(good))
11.183 +; print (global_area)
11.184 +; print (global_land)
11.185 +
11.186 + cc_space = esccr(data_mod_1d(good)*landfrac_1d(good),data_ob_1d(good)*landfrac_1d(good),0)
11.187 +
11.188 + delete (landmask_1d)
11.189 + delete (landfrac_1d)
11.190 +; delete (area_1d)
11.191 + delete (data_mod_1d)
11.192 + delete (data_ob_1d)
11.193 + delete (good)
11.194 +
11.195 +;----------------------------------------------------
11.196 +; compute M_global
11.197 +
11.198 + score_max = 1.
11.199 +
11.200 + Mscore1 = cc_space * cc_space * score_max
11.201 +
11.202 + M_global = sprintf("%.2f", Mscore1)
11.203 +
11.204 +;----------------------------------------------------
11.205 +; global res
11.206 +
11.207 + resg = True ; Use plot options
11.208 + resg@cnFillOn = True ; Turn on color fill
11.209 + resg@gsnSpreadColors = True ; use full colormap
11.210 + resg@cnLinesOn = False ; Turn off contourn lines
11.211 + resg@mpFillOn = False ; Turn off map fill
11.212 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
11.213 +
11.214 +;----------------------------------------------------
11.215 +; global contour: model vs ob
11.216 +
11.217 + plot_name = "global_model_vs_ob"
11.218 +
11.219 + wks = gsn_open_wks (plot_type,plot_name)
11.220 + gsn_define_colormap(wks,"gui_default")
11.221 +
11.222 + plot=new(3,graphic) ; create graphic array
11.223 +
11.224 + resg@gsnFrame = False ; Do not draw plot
11.225 + resg@gsnDraw = False ; Do not advance frame
11.226 +
11.227 +;----------------------
11.228 +; plot correlation coef
11.229 +
11.230 + gRes = True
11.231 + gRes@txFontHeightF = 0.02
11.232 + gRes@txAngleF = 90
11.233 +
11.234 + correlation_text = "(correlation coef = "+sprintf("%.2f", cc_space)+")"
11.235 +
11.236 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
11.237 +
11.238 +;-----------------------
11.239 +; plot ob
11.240 +; change from gC/m2/month to gC/m2/yr
11.241 + month_to_year = 12.
11.242 +
11.243 + data_ob_m@units = "gC/m2/yr"
11.244 + data_mod_m@units = "gC/m2/yr"
11.245 +
11.246 + data_ob_m = data_ob_m * month_to_year
11.247 + data_ob_m = where(landmask .gt. 0., data_ob_m, data_ob_m@_FillValue)
11.248 +
11.249 + title = ob_name
11.250 + resg@tiMainString = title
11.251 +
11.252 + resg@cnMinLevelValF = 10.
11.253 + resg@cnMaxLevelValF = 100.
11.254 + resg@cnLevelSpacingF = 10.
11.255 +
11.256 + plot(0) = gsn_csm_contour_map_ce(wks,data_ob_m,resg)
11.257 +
11.258 +;-----------------------
11.259 +; plot model
11.260 +
11.261 + data_mod_m = data_mod_m * month_to_year
11.262 +
11.263 + data_mod_m = where(landmask .gt. 0., data_mod_m, data_mod_m@_FillValue)
11.264 +
11.265 + title = "Model "+ model_name
11.266 + resg@tiMainString = title
11.267 +
11.268 + resg@cnMinLevelValF = 10.
11.269 + resg@cnMaxLevelValF = 100.
11.270 + resg@cnLevelSpacingF = 10.
11.271 +
11.272 + plot(1) = gsn_csm_contour_map_ce(wks,data_mod_m,resg)
11.273 +
11.274 +;-----------------------
11.275 +; plot model-ob
11.276 +
11.277 + resg@cnMinLevelValF = -80.
11.278 + resg@cnMaxLevelValF = 20.
11.279 + resg@cnLevelSpacingF = 10.
11.280 +
11.281 + zz = data_ob_m
11.282 + zz = data_mod_m - data_ob_m
11.283 + title = "Model_"+model_name+" - Observed"
11.284 + resg@tiMainString = title
11.285 +
11.286 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
11.287 +
11.288 +; plot panel
11.289 +
11.290 + pres = True ; panel plot mods desired
11.291 + pres@gsnMaximize = True ; fill the page
11.292 +
11.293 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
11.294 +
11.295 + delete (wks)
11.296 + delete (plot)
11.297 +
11.298 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
11.299 + "rm "+plot_name+"."+plot_type)
11.300 +
11.301 + delete (data_ob_m)
11.302 + delete (data_mod_m)
11.303 + delete (zz)
11.304 +
11.305 + resg@gsnFrame = True ; Do advance frame
11.306 + resg@gsnDraw = True ; Do draw plot
11.307 +
11.308 +;*******************************************************************
11.309 +; (B) Time series : per biome
11.310 +;*******************************************************************
11.311 +
11.312 + data_n = 2
11.313 +
11.314 + dsizes = dimsizes(data_mod)
11.315 + nyear = dsizes(0)
11.316 + nmonth = dsizes(1)
11.317 + ntime = nyear * nmonth
11.318 +
11.319 + year_start = 1997
11.320 + year_end = 2004
11.321 +
11.322 +;-------------------------------------------
11.323 +; Calculate "nice" bins for binning the data
11.324 +
11.325 +; using model biome class
11.326 + nclass = nclass_mod
11.327 +
11.328 + range = fspan(0,nclass,nclass+1)
11.329 +
11.330 +; Use this range information to grab all the values in a
11.331 +; particular range, and then take an average.
11.332 +
11.333 + nx = dimsizes(range) - 1
11.334 +
11.335 +;-------------------------------------------
11.336 +; put data into bins
11.337 +
11.338 +; using observed biome class
11.339 +; base = ndtooned(classob)
11.340 +; using model biome class
11.341 + base = ndtooned(classmod)
11.342 +
11.343 +; output
11.344 +
11.345 + area_bin = new((/nx/),float)
11.346 + yvalues = new((/ntime,data_n,nx/),float)
11.347 +
11.348 +; Loop through each range, using base.
11.349 +
11.350 + do i=0,nx-1
11.351 +
11.352 + if (i.ne.(nx-1)) then
11.353 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
11.354 + else
11.355 + idx = ind(base.ge.range(i))
11.356 + end if
11.357 +;---------------------
11.358 +; for area
11.359 +
11.360 + if (.not.any(ismissing(idx))) then
11.361 + area_bin(i) = sum(area_1d(idx))
11.362 + else
11.363 + area_bin(i) = area_bin@_FillValue
11.364 + end if
11.365 +
11.366 +;#############################################################
11.367 +; using model biome class:
11.368 +; set the following 4 classes to _FillValue:
11.369 +; (3)Needleleaf Deciduous Boreal Tree,
11.370 +; (8)Broadleaf Deciduous Boreal Tree,
11.371 +; (9)Broadleaf Evergreen Shrub,
11.372 +; (16)Wheat
11.373 +
11.374 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
11.375 + area_bin(i) = area_bin@_FillValue
11.376 + end if
11.377 +;#############################################################
11.378 +
11.379 +;---------------------
11.380 +; for data_mod and data_ob
11.381 +
11.382 + do n = 0,data_n-1
11.383 +
11.384 + t = -1
11.385 + do m = 0,nyear-1
11.386 + do k = 0,nmonth-1
11.387 +
11.388 + t = t + 1
11.389 +
11.390 + if (n.eq.0) then
11.391 + data = ndtooned(data_ob(m,k,:,:))
11.392 + end if
11.393 +
11.394 + if (n.eq.1) then
11.395 + data = ndtooned(data_mod(m,k,:,:))
11.396 + end if
11.397 +
11.398 +; Calculate average
11.399 +
11.400 + if (.not.any(ismissing(idx))) then
11.401 + yvalues(t,n,i) = sum(data(idx)*area_1d(idx))
11.402 + else
11.403 + yvalues(t,n,i) = yvalues@_FillValue
11.404 + end if
11.405 +
11.406 +;#############################################################
11.407 +; using model biome class:
11.408 +; set the following 4 classes to _FillValue:
11.409 +; (3)Needleleaf Deciduous Boreal Tree,
11.410 +; (8)Broadleaf Deciduous Boreal Tree,
11.411 +; (9)Broadleaf Evergreen Shrub,
11.412 +; (16)Wheat
11.413 +
11.414 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
11.415 + yvalues(t,n,i) = yvalues@_FillValue
11.416 + end if
11.417 +;#############################################################
11.418 +
11.419 + end do
11.420 + end do
11.421 +
11.422 + delete(data)
11.423 + end do
11.424 +
11.425 + delete(idx)
11.426 + end do
11.427 +
11.428 + delete (base)
11.429 + delete (data_mod)
11.430 + delete (data_ob)
11.431 +
11.432 + global_bin = sum(area_bin)
11.433 +; print (global_bin)
11.434 +
11.435 +;----------------------------------------------------------------
11.436 +; get area_good
11.437 +
11.438 + good = ind(.not.ismissing(area_bin))
11.439 +
11.440 + area_g = area_bin(good)
11.441 +
11.442 + n_biome = dimsizes(good)
11.443 +
11.444 + global_good = sum(area_g)
11.445 +; print (global_good)
11.446 +
11.447 +;----------------------------------------------------------------
11.448 +; data for tseries plot
11.449 +
11.450 + yvalues_g = new((/ntime,data_n,n_biome/),float)
11.451 +
11.452 + yvalues_g@units = "TgC/month"
11.453 +
11.454 +; change unit to Tg C/month
11.455 +; change unit from g to Tg (Tera gram)
11.456 + factor_unit = 1.e-12
11.457 +
11.458 + yvalues_g = yvalues(:,:,good) * factor_unit
11.459 +
11.460 + delete (good)
11.461 +
11.462 +;-------------------------------------------------------------------
11.463 +; general settings for line plot
11.464 +
11.465 + res = True
11.466 + res@xyDashPatterns = (/0,0/) ; make lines solid
11.467 + res@xyLineThicknesses = (/2.0,2.0/) ; make lines thicker
11.468 + res@xyLineColors = (/"blue","red"/) ; line color
11.469 +
11.470 + res@trXMinF = year_start
11.471 + res@trXMaxF = year_end + 1
11.472 +
11.473 + res@vpHeightF = 0.4 ; change aspect ratio of plot
11.474 +; res@vpWidthF = 0.8
11.475 + res@vpWidthF = 0.75
11.476 +
11.477 + res@tiMainFontHeightF = 0.025 ; size of title
11.478 +
11.479 + res@tmXBFormat = "f" ; not to add trailing zeros
11.480 +
11.481 +; res@gsnMaximize = True
11.482 +
11.483 +;----------------------------------------------
11.484 +; Add a boxed legend using the simple method
11.485 +
11.486 + res@pmLegendDisplayMode = "Always"
11.487 +; res@pmLegendWidthF = 0.1
11.488 + res@pmLegendWidthF = 0.08
11.489 + res@pmLegendHeightF = 0.06
11.490 + res@pmLegendOrthogonalPosF = -1.17
11.491 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
11.492 +; res@pmLegendOrthogonalPosF = -0.30 ;(downward)
11.493 +
11.494 +; res@pmLegendParallelPosF = 0.18
11.495 + res@pmLegendParallelPosF = 0.23 ;(rightward)
11.496 + res@pmLegendParallelPosF = 0.73 ;(rightward)
11.497 + res@pmLegendParallelPosF = 0.83 ;(rightward)
11.498 +
11.499 +; res@lgPerimOn = False
11.500 + res@lgLabelFontHeightF = 0.015
11.501 + res@xyExplicitLegendLabels = (/"observed",model_name/)
11.502 +
11.503 +;*******************************************************************
11.504 +; (A) time series plot: monthly ( 2 lines per plot)
11.505 +;*******************************************************************
11.506 +
11.507 +; x-axis in time series plot
11.508 +
11.509 + timeI = new((/ntime/),integer)
11.510 + timeF = new((/ntime/),float)
11.511 + timeI = ispan(1,ntime,1)
11.512 + timeF = year_start + (timeI-1)/12.
11.513 + timeF@long_name = "year"
11.514 +
11.515 + plot_data = new((/2,ntime/),float)
11.516 + plot_data@long_name = "TgC/month"
11.517 +
11.518 +;----------------------------------------------
11.519 +; time series plot : per biome
11.520 +
11.521 + do m = 0, n_biome-1
11.522 +
11.523 + plot_name = "monthly_biome_"+ m
11.524 +
11.525 + wks = gsn_open_wks (plot_type,plot_name)
11.526 +
11.527 + title = "Fire : "+ row_head(m)
11.528 + res@tiMainString = title
11.529 +
11.530 + plot_data(0,:) = yvalues_g(:,0,m)
11.531 + plot_data(1,:) = yvalues_g(:,1,m)
11.532 +
11.533 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
11.534 +
11.535 + delete (wks)
11.536 + delete (plot)
11.537 +
11.538 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
11.539 + "rm "+plot_name+"."+plot_type)
11.540 + end do
11.541 +
11.542 +;------------------------------------------
11.543 +; data for table : per biome
11.544 +
11.545 +; unit change from TgC/month to PgC/month
11.546 + unit_factor = 1.e-3
11.547 +
11.548 + score_max = 1.
11.549 +
11.550 + tmp_ob = new((/ntime/),float)
11.551 + tmp_mod = new((/ntime/),float)
11.552 +
11.553 + total_ob = new((/n_biome/),float)
11.554 + total_mod = new((/n_biome/),float)
11.555 + Mscore2 = new((/n_biome/),float)
11.556 +
11.557 + do m = 0, n_biome-1
11.558 +
11.559 + tmp_ob = yvalues_g(:,0,m)
11.560 + tmp_mod = yvalues_g(:,1,m)
11.561 +
11.562 + total_ob(m) = avg(month_to_annual(tmp_ob, 0)) * unit_factor
11.563 + total_mod(m) = avg(month_to_annual(tmp_mod,0)) * unit_factor
11.564 +
11.565 + cc_time = esccr(tmp_mod,tmp_ob,0)
11.566 +
11.567 + ratio = total_mod(m)/total_ob(m)
11.568 +
11.569 + good = ind(tmp_ob .ne. 0. .and. tmp_mod .ne. 0.)
11.570 +
11.571 + bias = sum( abs( tmp_mod(good)-tmp_ob(good) )/( abs(tmp_mod(good))+abs(tmp_ob(good)) ) )
11.572 + Mscore2(m) = (1.- (bias/dimsizes(good)))*score_max
11.573 +
11.574 + delete (good)
11.575 +
11.576 + text(m,0) = sprintf("%.2f",total_ob(m))
11.577 + text(m,1) = sprintf("%.2f",total_mod(m))
11.578 + text(m,2) = sprintf("%.2f",cc_time)
11.579 + text(m,3) = sprintf("%.2f",ratio)
11.580 + text(m,4) = sprintf("%.2f",Mscore2(m))
11.581 + text(m,5) = "<a href=./monthly_biome_"+m+".png>model_vs_ob</a>"
11.582 + end do
11.583 +
11.584 + delete (tmp_ob)
11.585 + delete (tmp_mod)
11.586 +
11.587 +;--------------------------------------------
11.588 +; time series plot: all biome
11.589 +
11.590 + plot_name = "monthly_global"
11.591 +
11.592 + wks = gsn_open_wks (plot_type,plot_name)
11.593 +
11.594 + title = "Fire : "+ row_head(n_biome)
11.595 + res@tiMainString = title
11.596 +
11.597 + do k = 0,ntime-1
11.598 + plot_data(0,k) = sum(yvalues_g(k,0,:))
11.599 + plot_data(1,k) = sum(yvalues_g(k,1,:))
11.600 + end do
11.601 +
11.602 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
11.603 +
11.604 + delete (wks)
11.605 + delete (plot)
11.606 +
11.607 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
11.608 + "rm "+plot_name+"."+plot_type)
11.609 +
11.610 +;------------------------------------------
11.611 +; data for table : global
11.612 +
11.613 + score_max = 1.
11.614 +
11.615 + tmp_ob = ndtooned(yvalues_g(:,0,:))
11.616 + tmp_mod = ndtooned(yvalues_g(:,1,:))
11.617 +
11.618 + cc_time = esccr(tmp_mod,tmp_ob,0)
11.619 +
11.620 + ratio = sum(total_mod)/sum(total_ob)
11.621 +
11.622 + good = ind(tmp_ob .ne. 0. .and. tmp_mod .ne. 0.)
11.623 +
11.624 + bias = sum( abs( tmp_mod(good)-tmp_ob(good) )/( abs(tmp_mod(good))+abs(tmp_ob(good)) ) )
11.625 + Mscore3 = (1.- (bias/dimsizes(good)))*score_max
11.626 +
11.627 +; print (Mscore3)
11.628 +
11.629 + delete (good)
11.630 +
11.631 + text(nrow-1,0) = sprintf("%.2f",sum(total_ob))
11.632 + text(nrow-1,1) = sprintf("%.2f",sum(total_mod))
11.633 + text(nrow-1,2) = sprintf("%.2f",cc_time)
11.634 + text(nrow-1,3) = sprintf("%.2f",ratio)
11.635 +; text(nrow-1,4) = sprintf("%.2f",avg(Mscore2))
11.636 + text(nrow-1,4) = sprintf("%.2f", Mscore3)
11.637 + text(nrow-1,5) = "<a href=./monthly_global.png>model_vs_ob</a>"
11.638 +
11.639 +;**************************************************
11.640 +; create html table
11.641 +;**************************************************
11.642 +
11.643 + header_text = "<H1>Fire Emissions from GFEDv2 (1997-2004) vs "+model_name+"</H1>"
11.644 +
11.645 + header = (/"<HTML>" \
11.646 + ,"<HEAD>" \
11.647 + ,"<TITLE>CLAMP metrics</TITLE>" \
11.648 + ,"</HEAD>" \
11.649 + ,header_text \
11.650 + /)
11.651 + footer = "</HTML>"
11.652 +
11.653 + table_header = (/ \
11.654 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
11.655 + ,"<tr>" \
11.656 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
11.657 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
11.658 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
11.659 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
11.660 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
11.661 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
11.662 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
11.663 + ,"</tr>" \
11.664 + /)
11.665 + table_footer = "</table>"
11.666 + row_header = "<tr>"
11.667 + row_footer = "</tr>"
11.668 +
11.669 + lines = new(50000,string)
11.670 + nline = 0
11.671 +
11.672 + set_line(lines,nline,header)
11.673 + set_line(lines,nline,table_header)
11.674 +;-----------------------------------------------
11.675 +;row of table
11.676 +
11.677 + do n = 0,nrow-1
11.678 + set_line(lines,nline,row_header)
11.679 +
11.680 + txt0 = row_head(n)
11.681 + txt1 = text(n,0)
11.682 + txt2 = text(n,1)
11.683 + txt3 = text(n,2)
11.684 + txt4 = text(n,3)
11.685 + txt5 = text(n,4)
11.686 + txt6 = text(n,5)
11.687 +
11.688 + set_line(lines,nline,"<th>"+txt0+"</th>")
11.689 + set_line(lines,nline,"<th>"+txt1+"</th>")
11.690 + set_line(lines,nline,"<th>"+txt2+"</th>")
11.691 + set_line(lines,nline,"<th>"+txt3+"</th>")
11.692 + set_line(lines,nline,"<th>"+txt4+"</th>")
11.693 + set_line(lines,nline,"<th>"+txt5+"</th>")
11.694 + set_line(lines,nline,"<th>"+txt6+"</th>")
11.695 +
11.696 + set_line(lines,nline,row_footer)
11.697 + end do
11.698 +;-----------------------------------------------
11.699 + set_line(lines,nline,table_footer)
11.700 + set_line(lines,nline,footer)
11.701 +
11.702 +; Now write to an HTML file.
11.703 +
11.704 + output_html = "table_fire.html"
11.705 +
11.706 + idx = ind(.not.ismissing(lines))
11.707 + if(.not.any(ismissing(idx))) then
11.708 + asciiwrite(output_html,lines(idx))
11.709 + else
11.710 + print ("error?")
11.711 + end if
11.712 +
11.713 + delete (idx)
11.714 +
11.715 +;**************************************************************************************
11.716 +; update score
11.717 +;**************************************************************************************
11.718 +
11.719 + M_all = Mscore1 + Mscore3
11.720 + M_fire = sprintf("%.2f", M_all)
11.721 +
11.722 + if (isvar("compare")) then
11.723 + system("sed -e '1,/M_fire/s/M_fire/"+M_fire+"/' "+html_name2+" > "+html_new2+";"+ \
11.724 + "mv -f "+html_new2+" "+html_name2)
11.725 + end if
11.726 +
11.727 + system("sed s#M_fire#"+M_fire+"# "+html_name+" > "+html_new+";"+ \
11.728 + "mv -f "+html_new+" "+html_name)
11.729 +
11.730 +;***************************************************************************
11.731 +; get total score and write to file
11.732 +;***************************************************************************
11.733 +
11.734 + asciiwrite("M_save.fire", M_fire)
11.735 +
11.736 + delete (M_fire)
11.737 +
11.738 +;***************************************************************************
11.739 +; output plot and html
11.740 +;***************************************************************************
11.741 + output_dir = model_name+"/fire"
11.742 +
11.743 + system("mv *.png *.html " + output_dir)
11.744 +;***************************************************************************
11.745 +
11.746 +end
11.747 +
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/all/11.ameriflux.ncl Mon Jan 26 22:08:20 2009 -0500
12.3 @@ -0,0 +1,893 @@
12.4 +;************************************************************
12.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
12.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
12.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
12.8 +;************************************************************
12.9 +procedure set_line(lines:string,nline:integer,newlines:string)
12.10 +begin
12.11 +; add line to ascci/html file
12.12 +
12.13 + nnewlines = dimsizes(newlines)
12.14 + if(nline+nnewlines-1.ge.dimsizes(lines))
12.15 + print("set_line: bad index, not setting anything.")
12.16 + return
12.17 + end if
12.18 + lines(nline:nline+nnewlines-1) = newlines
12.19 +; print ("lines = " + lines(nline:nline+nnewlines-1))
12.20 + nline = nline + nnewlines
12.21 + return
12.22 +end
12.23 +;*************************************************************
12.24 +begin
12.25 +
12.26 + plot_type = "ps"
12.27 + plot_type_new = "png"
12.28 +
12.29 +;------------------------------------------------------
12.30 +; edit table.html of current model for movel1_vs_model2
12.31 +
12.32 + if (isvar("compare")) then
12.33 + html_name2 = compare+"/table.html"
12.34 + html_new2 = html_name2 +".new"
12.35 + end if
12.36 +
12.37 +;------------------------------------------------------
12.38 +; edit table.html for current model
12.39 +
12.40 + html_name = model_name+"/table.html"
12.41 + html_new = html_name +".new"
12.42 +
12.43 +;------------------------------------------------------
12.44 +
12.45 + nmonth = 12
12.46 +
12.47 +; for nee, gpp, and ar
12.48 +; observed unit is gC/m2/day
12.49 +; model unit is gC/m2/s
12.50 +; to change to observed unit,
12.51 +
12.52 + factor_flux = 86400.
12.53 +
12.54 +; for incident solar radiation,
12.55 +; observed Rg_f unit is MJ/m2/day
12.56 +; model (FSDS) unit is W/m2
12.57 +; to change to model unit,
12.58 +
12.59 + factor_rad = 1.e6/86400.
12.60 +
12.61 +;************************************************
12.62 +; observed data info
12.63 +;************************************************
12.64 +
12.65 + station = (/"ARM_Oklahoma" \
12.66 + ,"ARM_Oklahoma_burn" \
12.67 + ,"ARM_Oklahoma_control" \
12.68 + ,"Atqasuk" \
12.69 + ,"Audubon" \
12.70 + ,"AustinCary" \
12.71 + ,"Bartlett" \
12.72 + ,"Bondville" \
12.73 + ,"Brookings" \
12.74 + ,"Donaldson" \
12.75 + ,"Duke_Forest_Hardwoods" \
12.76 + ,"Duke_Forest_Open_Field" \
12.77 + ,"Duke_Forest_Pine" \
12.78 + ,"Fermi_Ag" \
12.79 + ,"Fermi_Prairie" \
12.80 + ,"Flagstaff_Managed" \
12.81 + ,"Flagstaff_Unmanaged" \
12.82 + ,"Flagstaff_Wildfire" \
12.83 + ,"FortPeck" \
12.84 + ,"FreemanRanch_mesquite" \
12.85 + ,"Goodwin_Creek" \
12.86 + ,"HarvardForest" \
12.87 + ,"HarvardForestHemlock" \
12.88 + ,"HowlandForestMain" \
12.89 + ,"HowlandForestWest" \
12.90 + ,"Ivotuk" \
12.91 + ,"KendallGrasslands" \
12.92 + ,"KennedySpaceCenterPine" \
12.93 + ,"KennedySpaceCenterScrub" \
12.94 + ,"LittleProspect" \
12.95 + ,"LostCreek" \
12.96 + ,"Mead-irrigated" \
12.97 + ,"Mead-irrigated-rotation" \
12.98 + ,"Mead-rainfed" \
12.99 + ,"Metolius_2nd_YoungPonderosaPine" \
12.100 + ,"MetoliusEyerly" \
12.101 + ,"MetoliusIntermediatePine" \
12.102 + ,"MetoliusOldPonderosaPine" \
12.103 + ,"MissouriOzark" \
12.104 + ,"Mize" \
12.105 + ,"MorganMonroe" \
12.106 + ,"NiwotRidge" \
12.107 + ,"NorthCarolina_cc" \
12.108 + ,"NorthCarolina_lp" \
12.109 + ,"ParkFalls" \
12.110 + ,"Rayonier" \
12.111 + ,"SantaRita" \
12.112 + ,"SkyOaks_Old" \
12.113 + ,"SkyOaks_PostFire" \
12.114 + ,"SkyOaks_Young" \
12.115 + ,"SylvaniaWilderness" \
12.116 + ,"Toledo" \
12.117 + ,"Tonzi" \
12.118 + ,"UCI_1850" \
12.119 + ,"UCI_1930" \
12.120 + ,"UCI_1964" \
12.121 + ,"UCI_1964wet" \
12.122 + ,"UCI_1981" \
12.123 + ,"UCI_1989" \
12.124 + ,"UCI_1998" \
12.125 + ,"UMBS" \
12.126 + ,"Vaira" \
12.127 + ,"WalkerBranch" \
12.128 + ,"WillowCreek" \
12.129 + ,"WindRiver" \
12.130 + ,"Wisconsin_ihw" \
12.131 + ,"Wisconsin_irp" \
12.132 + ,"Wisconsin_mrp" \
12.133 + ,"Wisconsin_myjp" \
12.134 + ,"Wisconsin_pb" \
12.135 + ,"Wisconsin_rpcc" \
12.136 + ,"Wisconsin_yhw" \
12.137 + ,"Wisconsin_yjp" \
12.138 + ,"Wisconsin_yrp" \
12.139 + /)
12.140 +
12.141 + field = (/"NEE Flux" \
12.142 + ,"Shortwave Incoming" \
12.143 + ,"Latent Heat" \
12.144 + ,"Sensible Heat" \
12.145 + ,"GPP Flux" \
12.146 + ,"Respiration" \
12.147 + /)
12.148 +
12.149 + field_unit = (/"gC/m2/day" \
12.150 + ,"W/m2" \
12.151 + ,"W/m2" \
12.152 + ,"W/m2" \
12.153 + ,"gC/m2/day" \
12.154 + ,"gC/m2/day" \
12.155 + /)
12.156 +
12.157 + nstation = dimsizes(station)
12.158 + nfield = dimsizes(field)
12.159 +
12.160 +;========================================================================
12.161 +; get observed info: number of year, first/last year, lat, lon
12.162 +; and annual data
12.163 +
12.164 + dir_root = diro + "ameriflux/"
12.165 +
12.166 + year_station = new ((/nstation/),integer) ; number of year
12.167 + year_ob = new ((/nstation/),string) ; observed year
12.168 + year_ob_i = new ((/nstation/),integer) ; first year
12.169 + year_ob_f = new ((/nstation/),integer) ; last year
12.170 + lat_ob = new ((/nstation/),float) ; latitude
12.171 + lon_ob = new ((/nstation/),float) ; longitude
12.172 +
12.173 + data_ob_ann = new ((/nfield, nmonth, nstation/),float)
12.174 +
12.175 + do n = 0, nstation-1
12.176 +
12.177 + dir_f = dir_root + station(n)+"/"
12.178 + fil_f = "timeseries_L4_m.nc"
12.179 + fo = addfile (dir_f+fil_f,"r")
12.180 +
12.181 + lat_ob(n) = fo->lat
12.182 + lon_ob(n) = fo->lon
12.183 +
12.184 + year = fo->year
12.185 +
12.186 + year_station(n) = dimsizes(year)
12.187 + year_ob_i(n) = year(0)
12.188 + year_ob_f(n) = year(year_station(n)-1)
12.189 + year_ob(n) = year_ob_i(n) + "-" + year_ob_f(n)
12.190 +
12.191 + delete (year)
12.192 +
12.193 + data = fo->NEE_or_fMDS
12.194 + data_ob_ann(0,:,n) = dim_avg(data(month|:,year|:))
12.195 +
12.196 + data = fo->Rg_f
12.197 + data_ob_ann(1,:,n) = dim_avg(data(month|:,year|:)) * factor_rad
12.198 +
12.199 + data = fo->LE_f
12.200 + data_ob_ann(2,:,n) = dim_avg(data(month|:,year|:))
12.201 +
12.202 + data = fo->H_f
12.203 + data_ob_ann(3,:,n) = dim_avg(data(month|:,year|:))
12.204 +
12.205 + data = fo->GPP_or_MDS
12.206 + data_ob_ann(4,:,n) = dim_avg(data(month|:,year|:))
12.207 +
12.208 + data = fo->Reco_or
12.209 + data_ob_ann(5,:,n) = dim_avg(data(month|:,year|:))
12.210 +
12.211 + delete (data)
12.212 + delete (fo)
12.213 + end do
12.214 +
12.215 +;--------------------------------------------------------------
12.216 +; find (# of year observed) >=4 and year_ob_i <= 2001
12.217 +
12.218 + i_long_ob = ind(year_station .ge. 4 .and. year_ob_i .le. 2001)
12.219 +
12.220 + station_long = station(i_long_ob)
12.221 + lat_ob_long = lat_ob(i_long_ob)
12.222 + lon_ob_long = lat_ob(i_long_ob)
12.223 + year_ob_long = year_ob(i_long_ob)
12.224 + year_ob_i_long = year_ob_i(i_long_ob)
12.225 + year_ob_f_long = year_ob_f(i_long_ob)
12.226 + year_station_long = year_station(i_long_ob)
12.227 +
12.228 + nstation_long = dimsizes(station_long)
12.229 +
12.230 +;=========================================================
12.231 +; get model data at observed lat-lon
12.232 +
12.233 + fm = addfile (dirm+film8,"r")
12.234 +
12.235 + xm = fm->lon
12.236 + ym = fm->lat
12.237 + date = fm->date
12.238 +
12.239 + date_dim = dimsizes(date)
12.240 + nyear = date_dim(0)
12.241 +
12.242 + data_mod = new ((/nfield,nyear,nmonth,nstation/),float)
12.243 + data_mod_ann = new ((/nfield,nmonth,nstation/),float)
12.244 + data_mod_long = new ((/nfield,nyear,nmonth,nstation_long/),float)
12.245 +
12.246 +; change to unit of observed (u mol/m2/s)
12.247 +; Model_units [=] gC/m2/s
12.248 +; 12. = molecular weight of C
12.249 +; u mol = 1e-6 mol
12.250 +
12.251 + factor = 1.e6 /12.
12.252 +
12.253 +;------------------------------------------------------------
12.254 +; interpolate model data into observed station
12.255 +; note: model is 0-360E, 90S-90N
12.256 +
12.257 +; to be able to handle observation at (-89.98,-24.80)
12.258 + ym(0) = -90.
12.259 +;------------------------------------------------------------
12.260 +
12.261 +if (ENERGY .eq. "old") then
12.262 +
12.263 + data = fm->NEE
12.264 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
12.265 + data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
12.266 + data_mod(0,:,:,:) = yy(:,:,:) * factor_flux
12.267 +
12.268 +;;data = fm->NETRAD
12.269 +; data = fm->FSA
12.270 +; data1 = fm->FIRA
12.271 +; data = data - data1
12.272 +; delete (data1)
12.273 +
12.274 + data = fm->FSDS
12.275 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
12.276 + data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:))
12.277 + data_mod(1,:,:,:) = yy(:,:,:)
12.278 +
12.279 +
12.280 +; data = fm->LATENT
12.281 + data = fm->FCEV
12.282 + data1 = fm->FCTR
12.283 + data2 = fm->FGEV
12.284 + data = data + data1 + data2
12.285 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
12.286 + data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:))
12.287 + data_mod(2,:,:,:) = yy(:,:,:)
12.288 + delete (data1)
12.289 + delete (data2)
12.290 +
12.291 +; data = fm->SENSIBLE
12.292 + data = fm->FSH
12.293 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
12.294 + data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:))
12.295 + data_mod(3,:,:,:) = yy(:,:,:)
12.296 +
12.297 +else
12.298 +
12.299 + data = fm->NEE
12.300 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
12.301 + data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
12.302 + data_mod(0,:,:,:) = yy(:,:,:) * factor_flux
12.303 +
12.304 +; data = fm->NETRAD
12.305 + data = fm->FSDS
12.306 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
12.307 + data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:))
12.308 + data_mod(1,:,:,:) = yy(:,:,:)
12.309 +
12.310 + data = fm->LATENT
12.311 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
12.312 + data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:))
12.313 + data_mod(2,:,:,:) = yy(:,:,:)
12.314 +
12.315 +; data = fm->SENSIBLE
12.316 + data = fm->FSH
12.317 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
12.318 + data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:))
12.319 + data_mod(3,:,:,:) = yy(:,:,:)
12.320 +
12.321 +end if
12.322 +
12.323 + data = fm->GPP
12.324 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
12.325 + data_mod_ann(4,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
12.326 + data_mod(4,:,:,:) = yy(:,:,:) * factor_flux
12.327 +
12.328 + data = fm->ER
12.329 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
12.330 + data_mod_ann(5,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
12.331 + data_mod(5,:,:,:) = yy(:,:,:) * factor_flux
12.332 +
12.333 + data_mod_long(:,:,:,:) = data_mod(:,:,:,i_long_ob)
12.334 +
12.335 + delete (data_mod)
12.336 + delete (fm)
12.337 + delete (data)
12.338 + delete (yy)
12.339 +
12.340 +;*******************************************************************
12.341 +; for station line plot
12.342 +;*******************************************************************
12.343 +
12.344 +; for x-axis in xyplot
12.345 + mon = ispan(1,12,1)
12.346 + mon@long_name = "month"
12.347 +
12.348 + res = True ; plot mods desired
12.349 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
12.350 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
12.351 +
12.352 + res@tmXBFormat = "f" ; not to add trailing zeros
12.353 +
12.354 +;-------------------------------------------------------------------------
12.355 +; Add a boxed legend using the more simple method
12.356 +
12.357 + res@pmLegendDisplayMode = "Always"
12.358 +; res@pmLegendWidthF = 0.1
12.359 + res@pmLegendWidthF = 0.08
12.360 + res@pmLegendHeightF = 0.06
12.361 +; res@pmLegendOrthogonalPosF = -1.17
12.362 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
12.363 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
12.364 +
12.365 +; res@pmLegendParallelPosF = 0.18
12.366 + res@pmLegendParallelPosF = 0.23 ;(rightward)
12.367 +
12.368 +; res@lgPerimOn = False
12.369 + res@lgLabelFontHeightF = 0.015
12.370 + res@xyExplicitLegendLabels = (/"observed",model_name/)
12.371 +;-------------------------------------------------------------------
12.372 +; for panel plot
12.373 + res@gsnFrame = False ; Do not draw plot
12.374 + res@gsnDraw = False ; Do not advance frame
12.375 +
12.376 + pres = True ; panel plot mods desired
12.377 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
12.378 + ; indiv. plots in panel
12.379 + pres@gsnMaximize = True ; fill the page
12.380 +;-------------------------------------------------------------------
12.381 +
12.382 +; change longitude from 0-360 to -180-180
12.383 + lon_ob = where(lon_ob .gt. 180.,lon_ob-360., lon_ob)
12.384 + lon_ob_long = where(lon_ob_long .gt. 180.,lon_ob_long-360., lon_ob_long)
12.385 +
12.386 +;==============================================================
12.387 +; get ob data at each site with long observation
12.388 +
12.389 + do n = 0,nstation_long-1
12.390 +
12.391 +;##################################################################
12.392 +; hardwired: model up to year 2004
12.393 +; observed up to year 2006
12.394 +
12.395 + year_setback = 0
12.396 +
12.397 + nyear = year_station_long(n)
12.398 +
12.399 + if (year_ob_f_long(n).eq. 2006) then
12.400 + year_setback = 2006 -2004
12.401 + end if
12.402 + if (year_ob_f_long(n).eq. 2005) then
12.403 + year_setback = 2005 -2004
12.404 + end if
12.405 +;##################################################################
12.406 +
12.407 + ntime = (nyear - year_setback) * nmonth
12.408 +
12.409 + data_ob = new ((/nfield, nyear, nmonth/),float)
12.410 +
12.411 + dir_f = dir_root + station_long(n)+"/"
12.412 + fil_f = "timeseries_L4_m.nc"
12.413 + fo = addfile (dir_f+fil_f,"r")
12.414 +
12.415 + data_ob(0,:,:) = fo->NEE_or_fMDS
12.416 + data_ob(1,:,:) = fo->Rg_f
12.417 + data_ob(2,:,:) = fo->LE_f
12.418 + data_ob(3,:,:) = fo->H_f
12.419 + data_ob(4,:,:) = fo->GPP_or_MDS
12.420 + data_ob(5,:,:) = fo->Reco_or
12.421 +
12.422 + data_ob(1,:,:) = data_ob(1,:,:) * factor_rad
12.423 +
12.424 + delete (fo)
12.425 +
12.426 + timeI = new((/ntime/),integer)
12.427 + timeF = new((/ntime/),float)
12.428 + timeI = ispan(1,ntime,1)
12.429 + timeF = year_ob_i_long(n) + (timeI-1)/12.
12.430 + timeF@long_name = "year"
12.431 +
12.432 + plot_data = new((/2,ntime/),float)
12.433 +
12.434 +;----------------------------
12.435 +; for model_vs_ob
12.436 +
12.437 + plot_name = station_long(n)+"_tseries_vs_ob"
12.438 + title = station_long(n)+"("+sprintf("%5.2f",lat_ob_long(n))+","+sprintf("%5.2f",lon_ob_long(n))+")"
12.439 + res@tiMainString = title
12.440 +
12.441 + wks = gsn_open_wks (plot_type,plot_name)
12.442 + plot=new(nfield,graphic) ; create graphic array
12.443 +
12.444 + i_year_mod_i = year_ob_i_long(n) - 1990
12.445 + i_year_mod_f = i_year_mod_i + nyear - 1 - year_setback
12.446 +
12.447 + i_year_ob_f = nyear - year_setback - 1
12.448 +
12.449 +; print (nyear)
12.450 +; print (i_year_ob_f)
12.451 +; print (i_year_mod_i)
12.452 +; print (i_year_mod_f)
12.453 +
12.454 + do i = 0,nfield-1
12.455 + plot_data(0,:) = ndtooned(data_ob (i,0:i_year_ob_f,:))
12.456 + plot_data(1,:) = ndtooned(data_mod_long(i,i_year_mod_i:i_year_mod_f,:,n))
12.457 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
12.458 + plot(i)=gsn_csm_xy(wks,timeF,plot_data,res) ; create plot
12.459 + end do
12.460 +
12.461 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
12.462 +
12.463 + delete (wks)
12.464 + delete (plot)
12.465 +
12.466 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
12.467 + "rm "+plot_name+"."+plot_type)
12.468 +
12.469 + delete (data_ob)
12.470 + delete (timeI)
12.471 + delete (timeF)
12.472 + delete (plot_data)
12.473 +
12.474 + end do
12.475 +
12.476 +;###################################################################
12.477 +; for the following tables,
12.478 +; sort by latitude in decending order (N->S)
12.479 +
12.480 + isort = dim_pqsort(lat_ob_long,-1)
12.481 +
12.482 + station_sort = station_long(isort)
12.483 + year_ob_sort = year_ob_long(isort)
12.484 + lat_ob_sort = lat_ob_long(isort)
12.485 + lon_ob_sort = lon_ob_long(isort)
12.486 +
12.487 +; print(isort)
12.488 +; print(lat_ob_sort)
12.489 +
12.490 +;*******************************************************************
12.491 +; html table of site: observed
12.492 +;*******************************************************************
12.493 + output_html = "tseries_vs_ob.html"
12.494 +
12.495 + header = (/"<HTML>" \
12.496 + ,"<HEAD>" \
12.497 + ,"<TITLE>CLAMP metrics</TITLE>" \
12.498 + ,"</HEAD>" \
12.499 + ,"<H1>Timeseries at Site: "+model_name+" vs Observation</H1>" \
12.500 + /)
12.501 + footer = "</HTML>"
12.502 +
12.503 + table_header = (/ \
12.504 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
12.505 + ,"<tr>" \
12.506 + ," <th bgcolor=DDDDDD >Site Name</th>" \
12.507 + ," <th bgcolor=DDDDDD >Latitude</th>" \
12.508 + ," <th bgcolor=DDDDDD >Longitude</th>" \
12.509 + ," <th bgcolor=DDDDDD >Observed</th>" \
12.510 + ,"</tr>" \
12.511 + /)
12.512 + table_footer = "</table>"
12.513 + row_header = "<tr>"
12.514 + row_footer = "</tr>"
12.515 +
12.516 + lines = new(50000,string)
12.517 + nline = 0
12.518 +
12.519 + set_line(lines,nline,header)
12.520 + set_line(lines,nline,table_header)
12.521 +;-----------------------------------------------
12.522 +; row of table
12.523 +
12.524 + do n = 0,nstation_long-1
12.525 +
12.526 + set_line(lines,nline,row_header)
12.527 +
12.528 + txt0 = station_sort(n)
12.529 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
12.530 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
12.531 + txt3 = year_ob_sort(n)
12.532 +
12.533 + set_line(lines,nline,"<th><a href="+txt0+"_tseries_vs_ob.png>"+txt0+"</a></th>")
12.534 + set_line(lines,nline,"<th>"+txt1+"</th>")
12.535 + set_line(lines,nline,"<th>"+txt2+"</th>")
12.536 + set_line(lines,nline,"<th>"+txt3+"</th>")
12.537 +
12.538 + set_line(lines,nline,row_footer)
12.539 + end do
12.540 +;-----------------------------------------------
12.541 + set_line(lines,nline,table_footer)
12.542 + set_line(lines,nline,footer)
12.543 +
12.544 +; Now write to an HTML file.
12.545 + idx = ind(.not.ismissing(lines))
12.546 + if(.not.any(ismissing(idx))) then
12.547 + asciiwrite(output_html,lines(idx))
12.548 + else
12.549 + print ("error?")
12.550 + end if
12.551 + delete (idx)
12.552 +
12.553 + delete (isort)
12.554 + delete (station_sort)
12.555 + delete (year_ob_sort)
12.556 + delete (lat_ob_sort)
12.557 + delete (lon_ob_sort)
12.558 +
12.559 +;************************************************************
12.560 +; compute annual cycle correlation coef and M score
12.561 +;************************************************************
12.562 +
12.563 + score_max = 1.
12.564 +
12.565 + ccr = new ((/nstation, nfield/),float)
12.566 + M_score = new ((/nstation, nfield/),float)
12.567 +
12.568 + do n=0,nstation-1
12.569 + do m=0,nfield-1
12.570 + ccr(n,m) = esccr(data_ob_ann(m,:,n),data_mod_ann(m,:,n),0)
12.571 + 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))))
12.572 + M_score(n,m) = (1. -(bias/nmonth)) * score_max
12.573 + end do
12.574 + end do
12.575 +
12.576 + M_nee = avg(M_score(:,0))
12.577 + M_rad = avg(M_score(:,1))
12.578 + M_lh = avg(M_score(:,2))
12.579 + M_sh = avg(M_score(:,3))
12.580 + M_gpp = avg(M_score(:,4))
12.581 + M_er = avg(M_score(:,5))
12.582 + M_all = M_nee+ M_rad +M_lh + M_sh + M_gpp + M_er
12.583 +
12.584 + M_ameriflux_nee = sprintf("%.2f", M_nee)
12.585 + M_ameriflux_rad = sprintf("%.2f", M_rad)
12.586 + M_ameriflux_lh = sprintf("%.2f", M_lh )
12.587 + M_ameriflux_sh = sprintf("%.2f", M_sh )
12.588 + M_ameriflux_gpp = sprintf("%.2f", M_gpp)
12.589 + M_ameriflux_er = sprintf("%.2f", M_er )
12.590 + M_ameriflux_all = sprintf("%.2f", M_all)
12.591 +
12.592 +;*******************************************************************
12.593 +; for station line plot
12.594 +;*******************************************************************
12.595 +
12.596 +; for x-axis in xyplot
12.597 + mon = ispan(1,12,1)
12.598 + mon@long_name = "month"
12.599 +
12.600 +;-------------------------------------------------------------------
12.601 +
12.602 + plot_data = new((/2,nmonth/),float)
12.603 + plot_data!0 = "case"
12.604 + plot_data!1 = "month"
12.605 +
12.606 + do n = 0,nstation-1
12.607 +;----------------------------
12.608 +; for observed
12.609 +
12.610 + plot_name = station(n)+"_ob"
12.611 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
12.612 + res@tiMainString = title
12.613 +
12.614 + wks = gsn_open_wks (plot_type,plot_name)
12.615 + plot=new(nfield,graphic) ; create graphic array
12.616 +
12.617 + do i = 0,nfield-1
12.618 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
12.619 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
12.620 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
12.621 + end do
12.622 +
12.623 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
12.624 +
12.625 + delete (wks)
12.626 + delete (plot)
12.627 +
12.628 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
12.629 + "rm "+plot_name+"."+plot_type)
12.630 +
12.631 +;----------------------------
12.632 +; for model_vs_ob
12.633 +
12.634 + plot_name = station(n)+"_model_vs_ob"
12.635 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
12.636 + res@tiMainString = title
12.637 +
12.638 + wks = gsn_open_wks (plot_type,plot_name)
12.639 + plot=new(nfield,graphic) ; create graphic array
12.640 +
12.641 + do i = 0,nfield-1
12.642 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
12.643 + plot_data(1,:) = (/data_mod_ann(i,:,n)/)
12.644 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
12.645 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
12.646 + end do
12.647 +
12.648 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
12.649 +
12.650 + delete (wks)
12.651 + delete (plot)
12.652 +
12.653 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
12.654 + "rm "+plot_name+"."+plot_type)
12.655 + end do
12.656 +
12.657 +;###################################################################
12.658 +; for the following tables,
12.659 +; sort by latitude in decending order (N->S)
12.660 +; sort by lat in decending order (N->S)
12.661 +
12.662 + isort = dim_pqsort(lat_ob,-1)
12.663 +
12.664 + station_sort = station(isort)
12.665 + year_ob_sort = year_ob(isort)
12.666 + lat_ob_sort = lat_ob(isort)
12.667 + lon_ob_sort = lon_ob(isort)
12.668 + M_score_sort = M_score(isort,:)
12.669 +
12.670 +; print(isort)
12.671 +; print(lat_ob_sort)
12.672 +;###################################################################
12.673 +;*******************************************************************
12.674 +; html table of site: observed
12.675 +;*******************************************************************
12.676 + output_html = "line_ob.html"
12.677 +
12.678 + header = (/"<HTML>" \
12.679 + ,"<HEAD>" \
12.680 + ,"<TITLE>CLAMP metrics</TITLE>" \
12.681 + ,"</HEAD>" \
12.682 + ,"<H1>Energy at Site: Observation</H1>" \
12.683 + /)
12.684 + footer = "</HTML>"
12.685 +
12.686 + table_header = (/ \
12.687 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
12.688 + ,"<tr>" \
12.689 + ," <th bgcolor=DDDDDD >Site Name</th>" \
12.690 + ," <th bgcolor=DDDDDD >Latitude</th>" \
12.691 + ," <th bgcolor=DDDDDD >Longitude</th>" \
12.692 + ," <th bgcolor=DDDDDD >Observed</th>" \
12.693 + ,"</tr>" \
12.694 + /)
12.695 + table_footer = "</table>"
12.696 + row_header = "<tr>"
12.697 + row_footer = "</tr>"
12.698 +
12.699 + lines = new(50000,string)
12.700 + nline = 0
12.701 +
12.702 + set_line(lines,nline,header)
12.703 + set_line(lines,nline,table_header)
12.704 +;-----------------------------------------------
12.705 +; row of table
12.706 +
12.707 + do n = 0,nstation-1
12.708 + set_line(lines,nline,row_header)
12.709 +
12.710 + txt0 = station_sort(n)
12.711 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
12.712 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
12.713 + txt3 = year_ob_sort(n)
12.714 +
12.715 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
12.716 + set_line(lines,nline,"<th>"+txt1+"</th>")
12.717 + set_line(lines,nline,"<th>"+txt2+"</th>")
12.718 + set_line(lines,nline,"<th>"+txt3+"</th>")
12.719 +
12.720 + set_line(lines,nline,row_footer)
12.721 + end do
12.722 +;-----------------------------------------------
12.723 + set_line(lines,nline,table_footer)
12.724 + set_line(lines,nline,footer)
12.725 +
12.726 +; Now write to an HTML file.
12.727 + idx = ind(.not.ismissing(lines))
12.728 + if(.not.any(ismissing(idx))) then
12.729 + asciiwrite(output_html,lines(idx))
12.730 + else
12.731 + print ("error?")
12.732 + end if
12.733 + delete (idx)
12.734 +
12.735 +;*******************************************************************
12.736 +; score and line table : model vs observed
12.737 +;*******************************************************************
12.738 + output_html = "score+line_vs_ob.html"
12.739 +
12.740 + header = (/"<HTML>" \
12.741 + ,"<HEAD>" \
12.742 + ,"<TITLE>CLAMP metrics</TITLE>" \
12.743 + ,"</HEAD>" \
12.744 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
12.745 + /)
12.746 + footer = "</HTML>"
12.747 +
12.748 + delete (table_header)
12.749 + table_header = (/ \
12.750 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
12.751 + ,"<tr>" \
12.752 + ," <th bgcolor=DDDDDD >Site Name</th>" \
12.753 + ," <th bgcolor=DDDDDD >Latitude</th>" \
12.754 + ," <th bgcolor=DDDDDD >Longitude</th>" \
12.755 + ," <th bgcolor=DDDDDD >Observed</th>" \
12.756 + ," <th bgcolor=DDDDDD >NEE Flux</th>" \
12.757 + ," <th bgcolor=DDDDDD >Shortwave <br> Incoming</th>" \
12.758 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
12.759 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
12.760 + ," <th bgcolor=DDDDDD >GPP Flux</th>" \
12.761 + ," <th bgcolor=DDDDDD >Respiration</th>" \
12.762 + ," <th bgcolor=DDDDDD >Average</th>" \
12.763 + ,"</tr>" \
12.764 + /)
12.765 + table_footer = "</table>"
12.766 + row_header = "<tr>"
12.767 + row_footer = "</tr>"
12.768 +
12.769 + lines = new(50000,string)
12.770 + nline = 0
12.771 +
12.772 + set_line(lines,nline,header)
12.773 + set_line(lines,nline,table_header)
12.774 +;-----------------------------------------------
12.775 +; row of table
12.776 +
12.777 + do n = 0,nstation-1
12.778 + set_line(lines,nline,row_header)
12.779 +
12.780 + txt0 = station_sort(n)
12.781 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
12.782 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
12.783 + txt3 = year_ob_sort(n)
12.784 + txt4 = sprintf("%5.2f", M_score_sort(n,0))
12.785 + txt5 = sprintf("%5.2f", M_score_sort(n,1))
12.786 + txt6 = sprintf("%5.2f", M_score_sort(n,2))
12.787 + txt7 = sprintf("%5.2f", M_score_sort(n,3))
12.788 + txt8 = sprintf("%5.2f", M_score_sort(n,4))
12.789 + txt9 = sprintf("%5.2f", M_score_sort(n,5))
12.790 + txt10 = sprintf("%5.2f", avg(M_score_sort(n,:)))
12.791 +
12.792 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
12.793 + set_line(lines,nline,"<th>"+txt1+"</th>")
12.794 + set_line(lines,nline,"<th>"+txt2+"</th>")
12.795 + set_line(lines,nline,"<th>"+txt3+"</th>")
12.796 + set_line(lines,nline,"<th>"+txt4+"</th>")
12.797 + set_line(lines,nline,"<th>"+txt5+"</th>")
12.798 + set_line(lines,nline,"<th>"+txt6+"</th>")
12.799 + set_line(lines,nline,"<th>"+txt7+"</th>")
12.800 + set_line(lines,nline,"<th>"+txt8+"</th>")
12.801 + set_line(lines,nline,"<th>"+txt9+"</th>")
12.802 + set_line(lines,nline,"<th>"+txt10+"</th>")
12.803 +
12.804 + set_line(lines,nline,row_footer)
12.805 + end do
12.806 +
12.807 +; last row, summary
12.808 + set_line(lines,nline,row_header)
12.809 +
12.810 + txt0 = "All_"+sprintf("%.0f", nstation)
12.811 + txt1 = "-"
12.812 + txt2 = "-"
12.813 + txt3 = "-"
12.814 + txt4 = M_ameriflux_nee
12.815 + txt5 = M_ameriflux_rad
12.816 + txt6 = M_ameriflux_lh
12.817 + txt7 = M_ameriflux_sh
12.818 + txt8 = M_ameriflux_gpp
12.819 + txt9 = M_ameriflux_er
12.820 + txt10 = M_ameriflux_all
12.821 +
12.822 + set_line(lines,nline,"<th>"+txt0+"</th>")
12.823 + set_line(lines,nline,"<th>"+txt1+"</th>")
12.824 + set_line(lines,nline,"<th>"+txt2+"</th>")
12.825 + set_line(lines,nline,"<th>"+txt3+"</th>")
12.826 + set_line(lines,nline,"<th>"+txt4+"</th>")
12.827 + set_line(lines,nline,"<th>"+txt5+"</th>")
12.828 + set_line(lines,nline,"<th>"+txt6+"</th>")
12.829 + set_line(lines,nline,"<th>"+txt7+"</th>")
12.830 + set_line(lines,nline,"<th>"+txt8+"</th>")
12.831 + set_line(lines,nline,"<th>"+txt9+"</th>")
12.832 + set_line(lines,nline,"<th>"+txt10+"</th>")
12.833 +
12.834 + set_line(lines,nline,row_footer)
12.835 +;-----------------------------------------------
12.836 + set_line(lines,nline,table_footer)
12.837 + set_line(lines,nline,footer)
12.838 +
12.839 +; Now write to an HTML file.
12.840 + idx = ind(.not.ismissing(lines))
12.841 + if(.not.any(ismissing(idx))) then
12.842 + asciiwrite(output_html,lines(idx))
12.843 + else
12.844 + print ("error?")
12.845 + end if
12.846 + delete (idx)
12.847 +
12.848 +;**************************************************************************************
12.849 +; update score
12.850 +;**************************************************************************************
12.851 +
12.852 + if (isvar("compare")) then
12.853 + system("sed -e '1,/M_ameriflux_nee/s/M_ameriflux_nee/"+M_ameriflux_nee+"/' "+html_name2+" > "+html_new2+";"+ \
12.854 + "mv -f "+html_new2+" "+html_name2+";"+ \
12.855 + "sed -e '1,/M_ameriflux_rad/s/M_ameriflux_rad/"+M_ameriflux_rad+"/' "+html_name2+" > "+html_new2+";"+ \
12.856 + "mv -f "+html_new2+" "+html_name2+";"+ \
12.857 + "sed -e '1,/M_ameriflux_lh/s/M_ameriflux_lh/"+M_ameriflux_lh+"/' "+html_name2+" > "+html_new2+";"+ \
12.858 + "mv -f "+html_new2+" "+html_name2+";"+ \
12.859 + "sed -e '1,/M_ameriflux_sh/s/M_ameriflux_sh/"+M_ameriflux_sh+"/' "+html_name2+" > "+html_new2+";"+ \
12.860 + "mv -f "+html_new2+" "+html_name2+";"+ \
12.861 + "sed -e '1,/M_ameriflux_gpp/s/M_ameriflux_gpp/"+M_ameriflux_gpp+"/' "+html_name2+" > "+html_new2+";"+ \
12.862 + "mv -f "+html_new2+" "+html_name2+";"+ \
12.863 + "sed -e '1,/M_ameriflux_er/s/M_ameriflux_er/"+M_ameriflux_er+"/' "+html_name2+" > "+html_new2+";"+ \
12.864 + "mv -f "+html_new2+" "+html_name2)
12.865 + end if
12.866 +
12.867 + system("sed s#M_ameriflux_nee#"+M_ameriflux_nee+"# "+html_name+" > "+html_new+";"+ \
12.868 + "mv -f "+html_new+" "+html_name+";"+ \
12.869 + "sed s#M_ameriflux_rad#"+M_ameriflux_rad+"# "+html_name+" > "+html_new+";"+ \
12.870 + "mv -f "+html_new+" "+html_name+";"+ \
12.871 + "sed s#M_ameriflux_lh#"+M_ameriflux_lh+"# "+html_name+" > "+html_new+";"+ \
12.872 + "mv -f "+html_new+" "+html_name+";"+ \
12.873 + "sed s#M_ameriflux_sh#"+M_ameriflux_sh+"# "+html_name+" > "+html_new+";"+ \
12.874 + "mv -f "+html_new+" "+html_name+";"+ \
12.875 + "sed s#M_ameriflux_gpp#"+M_ameriflux_gpp+"# "+html_name+" > "+html_new+";"+ \
12.876 + "mv -f "+html_new+" "+html_name+";"+ \
12.877 + "sed s#M_ameriflux_er#"+M_ameriflux_er+"# "+html_name+" > "+html_new+";"+ \
12.878 + "mv -f "+html_new+" "+html_name)
12.879 +
12.880 +;***************************************************************************
12.881 +; add total score and write to file
12.882 +;***************************************************************************
12.883 + M_total = M_ameriflux_all
12.884 +
12.885 + asciiwrite("M_save.ameriflux", M_total)
12.886 +
12.887 +;***************************************************************************
12.888 +; output plot and html
12.889 +;***************************************************************************
12.890 + output_dir = model_name+"/ameriflux"
12.891 +
12.892 + system("mv *.png *.html " + output_dir)
12.893 +;***************************************************************************
12.894 +
12.895 +end
12.896 +
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/all/99.final.ncl Mon Jan 26 22:08:20 2009 -0500
13.3 @@ -0,0 +1,95 @@
13.4 +;********************************************************
13.5 +; landfrac applied to area only.
13.6 +; using model biome class
13.7 +;
13.8 +; required command line input parameters:
13.9 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
13.10 +;
13.11 +; histogram normalized by rain and compute correleration
13.12 +;**************************************************************
13.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
13.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
13.15 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
13.16 +;**************************************************************
13.17 +procedure set_line(lines:string,nline:integer,newlines:string)
13.18 +begin
13.19 +; add line to ascci/html file
13.20 +
13.21 + nnewlines = dimsizes(newlines)
13.22 + if(nline+nnewlines-1.ge.dimsizes(lines))
13.23 + print("set_line: bad index, not setting anything.")
13.24 + return
13.25 + end if
13.26 + lines(nline:nline+nnewlines-1) = newlines
13.27 +; print ("lines = " + lines(nline:nline+nnewlines-1))
13.28 + nline = nline + nnewlines
13.29 + return
13.30 +end
13.31 +;**************************************************************
13.32 +; Main code.
13.33 +begin
13.34 +;--------------------------------------------------
13.35 +; edit table.html of current model for movel1_vs_model2
13.36 +
13.37 + if (isvar("compare")) then
13.38 + html_name2 = compare+"/table.html"
13.39 + html_new2 = html_name2 +".new"
13.40 + end if
13.41 +
13.42 +;-------------------------------------
13.43 +; edit table.html for current model
13.44 +
13.45 + html_name = model_name+"/table.html"
13.46 + html_new = html_name +".new"
13.47 +
13.48 +;---------------------------------------------------
13.49 +; add total score and update metric table
13.50 +
13.51 + M_save = 0.
13.52 +
13.53 + if (isfilepresent("M_save.npp")) then
13.54 + M_save = M_save + asciiread("M_save.npp",(/1/),"float")
13.55 + end if
13.56 +
13.57 + if (isfilepresent("M_save.lai")) then
13.58 + M_save = M_save + asciiread("M_save.lai",(/1/),"float")
13.59 + end if
13.60 +
13.61 + if (film3 .ne. "") then
13.62 + if (isfilepresent("M_save.co2")) then
13.63 + M_save = M_save + asciiread("M_save.co2",(/1/),"float")
13.64 + end if
13.65 + end if
13.66 +
13.67 + if (isfilepresent("M_save.biomass")) then
13.68 + M_save = M_save + asciiread("M_save.biomass",(/1/),"float")
13.69 + end if
13.70 +
13.71 + if (isfilepresent("M_save.fluxnet")) then
13.72 + M_save = M_save + asciiread("M_save.fluxnet",(/1/),"float")
13.73 + end if
13.74 +
13.75 + if (isfilepresent("M_save.beta")) then
13.76 + M_save = M_save + asciiread("M_save.beta",(/1/),"float")
13.77 + end if
13.78 +
13.79 + if (isfilepresent("M_save.fire")) then
13.80 + M_save = M_save + asciiread("M_save.fire",(/1/),"float")
13.81 + end if
13.82 +
13.83 + if (isfilepresent("M_save.ameriflux")) then
13.84 + M_save = M_save + asciiread("M_save.ameriflux",(/1/),"float")
13.85 + end if
13.86 +
13.87 + M_total = sprintf("%.2f", M_save)
13.88 +
13.89 + if (isvar("compare")) then
13.90 + system("sed -e '1,/M_total/s/M_total/"+M_total+"/' "+html_name2+" > "+html_new2+";"+ \
13.91 + "mv -f "+html_new2+" "+html_name2)
13.92 + end if
13.93 +
13.94 + system("sed s#M_total#"+M_total+"# "+html_name+" > "+html_new+";"+ \
13.95 + "mv -f "+html_new+" "+html_name+";"+ \
13.96 + "rm M_save.*")
13.97 +end
13.98 +
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/all/note.data Mon Jan 26 22:08:20 2009 -0500
14.3 @@ -0,0 +1,93 @@
14.4 +model data used :
14.5 +
14.6 + FILE1 = i01.10cn_1948-2004_ANN_climo.nc
14.7 + FILE2 = i01.10cn_1948-2004_MONS_climo.nc
14.8 + FILE3 = f02.03cn_1901-1925_MONS_climo_atm.nc
14.9 + FILE4 = i01.06cn_1980-2004_ANN_climo.nc
14.10 + FILE5 = i01.10cn_1990-2004_ANN_climo.nc
14.11 + FILE6 = i01.07cn_1990-2004_ANN_climo.nc
14.12 + FILE7 = i01.10cn_Fire_C_1979-2004_monthly.nc
14.13 + FILE8 = i01.10cn_ameriflux_1990-2004_monthly.nc
14.14 +
14.15 +model data compared with observed data:
14.16 +
14.17 +1. NPP:
14.18 +
14.19 + model: i01.10cn_1948-2004_ANN_climo.nc : NPP, RAIN
14.20 +
14.21 + ob : data.81.nc : TNPP_C, PREC_ANN
14.22 + data.933.nc : TNPP_C, PREC
14.23 + Npp_T42_mean.nc : NPP
14.24 +
14.25 +2. LAI:
14.26 +
14.27 + model: i01.10cn_1948-2004_MONS_climo.nc : TLAI
14.28 +
14.29 + ob : LAI_2000-2005_MONS_T42.nc : LAI
14.30 +
14.31 +3. CO2 Seasonal Cycle:
14.32 +
14.33 + model: f02.03cn_1901-1925_MONS_climo_atm.nc : CO2
14.34 +
14.35 + ob : co2_globalView_98.nc : CO2_SEAS
14.36 +
14.37 +4. Carbon Stocks:
14.38 +
14.39 + model: i01.10cn_1948-2004_ANN_climo.nc : LIVESTEMC, DEADSTEMC, LEAFC
14.40 + WOODC, LEAFC
14.41 +
14.42 + ob : amazon_biomass_T42.nc : BIOMASS
14.43 +
14.44 +6. Fluxnet:
14.45 +
14.46 + model: i01.10cn_1948-2004_MONS_climo.nc : NEE, NETRAD, LATENT, FSH
14.47 +
14.48 + ob : station_name_year_ob_monthly.nc : CO2_FLUX, RAD_FLUX,
14.49 + LH_FLUX, SH_FLUX
14.50 +7. Ameriflux:
14.51 +
14.52 + model: i01.10cn_ameriflux_1990-2004_monthly.nc : NEE, NETRAD, LATENT, FSH,
14.53 + NPP, ER
14.54 + ob : station_name/timeseries_L4_m.nc : NEE_or_fMDS, Rg_f, LE_f,
14.55 + H_f, GPP_or_MDS, Reco_or
14.56 +
14.57 +8. Beta factor:
14.58 +
14.59 + model: i01.07cn_1990-2004_ANN_climo.nc (initial) : NPP
14.60 + i01.10cn_1990-2004_ANN_climo.nc (final) : NPP
14.61 +
14.62 + ob : beta =0.6
14.63 +
14.64 +9. Turnover time:
14.65 +
14.66 + model: i01.06cn_1980-2004_ANN_climo.nc :
14.67 +
14.68 + pool: LEAFC, WOODC, FROOTC, LITTERC, CWDC, SOILC
14.69 + flux: LEAFC_ALLOC, WOODC_ALLOC, FROOTC_ALLOC,
14.70 + LITTERC_LOSS, CWDC_LOSS, SOILC_HR
14.71 +
14.72 + ob : none
14.73 +
14.74 +10. Carbon sink:
14.75 +
14.76 + model: i01.06cn_1980-2004_ANN_climo.nc :
14.77 +
14.78 + NPP, SOILC
14.79 + VegC = LEAFC + WOODC + FROOTC
14.80 + LiCwC = LITTERC + CWDC
14.81 +
14.82 + i01.10cn_1990-2004_ANN_climo.nc
14.83 +
14.84 + NPP, NEE, GPP
14.85 +
14.86 + i01.10cn_Fire_C_1979-2004_monthly.nc
14.87 +
14.88 + NPP, NEE, COL_FIRE_CLOSS
14.89 +
14.90 + ob : none
14.91 +
14.92 +11. Fire:
14.93 +
14.94 + model: i01.10cn_Fire_C_1979-2004_monthly.nc : COL_FIRE_CLOSS
14.95 +
14.96 + ob : Fire_C_1997-2006_monthly_T42.nc : FIRE_C
14.97 \ No newline at end of file
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/all/note.message Mon Jan 26 22:08:20 2009 -0500
15.3 @@ -0,0 +1,6 @@
15.4 +
15.5 +The following warning types are normal:
15.6 +
15.7 +warning:avg: Entire input array contains missing values, can't compute average
15.8 +warning:esccr: Non-fatal conditions encountered: all missing or constant values
15.9 +warning:["CoordArrays.c":590]:No Valid values in Array, unable to compute Min or Max
15.10 \ No newline at end of file
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/all/readme Mon Jan 26 22:08:20 2009 -0500
16.3 @@ -0,0 +1,29 @@
16.4 +======================================
16.5 +To process CLAMP metric diagnostics:
16.6 +======================================
16.7 +
16.8 +1. get script:
16.9 +
16.10 + ( run_1-model.csh : if comparing 1 model with observation )
16.11 + ( run_2-model.csh : if comparing 2 models with observation )
16.12 +
16.13 + /fis/cgd/cseg/people/jeff/clamp/all/run_1-model.csh
16.14 + or
16.15 + /fis/cgd/cseg/people/jeff/clamp/all/run_2-model.csh
16.16 +
16.17 +2. edit script: (change ONLY the "user modeification" section)
16.18 +
16.19 +3. run script:
16.20 +
16.21 + run_1-model.csh > out.1
16.22 + run_2-model.csh > out.1
16.23 +
16.24 + => final ouptput in 1 directory (if comparing 1 model)
16.25 + or
16.26 + final ouptput in 3 directories (if comparing 2 models)
16.27 +
16.28 + (if need to copy output to a web directory:
16.29 + - copy the (one) file *.tar to a web directory
16.30 + - untar *.tar at the web directory )
16.31 +
16.32 + see note.message for normal messages in out.1
16.33 \ No newline at end of file
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/all/run_1-model.csh Mon Jan 26 22:08:20 2009 -0500
17.3 @@ -0,0 +1,112 @@
17.4 +#!/bin/csh -f
17.5 +#-------------------------------------------------------------------
17.6 +# note: user modifies ONLY the "user modification" section
17.7 +#
17.8 +# MODEL : model name
17.9 +# DIR_M : directory of model data
17.10 +# DIR_O : directory of observed data
17.11 +# DIR_S : directory of model surface data
17.12 +# DIR_SCRIPTS : directory of run scripts
17.13 +# FILE1 : time_mean climatology from CLM diagnostic package
17.14 +# FILE2 : 12-monthly climatology from CLM diagnostic package
17.15 +# FILE3 : 12-monthly climatology from ATM diagnostic package
17.16 +# leave it blank, if no ATM file:
17.17 +# set FILE3 =
17.18 +# FILE7 : timeseries file generated from ....
17.19 +# FILE8 : timeseries file generated from ....
17.20 +# GRID : T31, T42, or 1.9
17.21 +# BGC : cn or casa
17.22 +# ENERGY: new or old (model data fields)
17.23 +#********************************************************************
17.24 +# user modification:
17.25 +
17.26 +# model data (no ATM file)
17.27 +set MODEL = CN
17.28 +set DIR_M = /fis/cgd/cseg/people/jeff/clamp_data/model/
17.29 +set FILE1 = i01.10cn_1948-2004_ANN_climo.nc
17.30 +set FILE2 = i01.10cn_1948-2004_MONS_climo.nc
17.31 +set FILE3 =
17.32 +set FILE4 = i01.06cn_1980-2004_ANN_climo.nc
17.33 +set FILE5 = i01.10cn_1990-2004_ANN_climo.nc
17.34 +set FILE6 = i01.07cn_1990-2004_ANN_climo.nc
17.35 +set FILE7 = i01.10cn_Fire_C_1979-2004_monthly.nc
17.36 +set FILE8 = i01.10cn_ameriflux_1990-2004_monthly.nc
17.37 +set GRID = T42
17.38 +set BGC = cn
17.39 +set ENERGY = new
17.40 +
17.41 +# in the "CLAMP metric processing" section:
17.42 +# only 00.initial.ncl and 99.final.ncl are required,
17.43 +# user can comment out any one or more of the other ncl scripts,
17.44 +# e.g.
17.45 +# #ncl $INPUT_TEXT $DIR_SCRIPTS/10.fire.ncl
17.46 +
17.47 +# model surface data
17.48 +set DIR_S = /fis/cgd/cseg/people/jeff/clamp_data/surface_model/
17.49 +
17.50 +# observed data
17.51 +set DIR_O = /fis/cgd/cseg/people/jeff/clamp_data/observed/
17.52 +
17.53 +# directory for scripts, templates and ncl files
17.54 +set DIR_SCRIPTS = /fis/cgd/cseg/people/jeff/clamp/all/
17.55 +
17.56 +#********************************************************************
17.57 +
17.58 +# create a directory for the model by copying from a template
17.59 +if ($FILE3 != "") then
17.60 + set TEMPLATE = template_1-model
17.61 +else
17.62 + set TEMPLATE = template_1-model_noCO2
17.63 +endif
17.64 +cp -r $DIR_SCRIPTS/$TEMPLATE $MODEL
17.65 +
17.66 +# add quote, to be usesd in INPUT_TEXT
17.67 +set MODELQ = \"$MODEL\"
17.68 +set DIRMQ = \"$DIR_M\"
17.69 +set F1 = \"$FILE1\"
17.70 +set F2 = \"$FILE2\"
17.71 +set F3 = \"$FILE3\"
17.72 +set F4 = \"$FILE4\"
17.73 +set F5 = \"$FILE5\"
17.74 +set F6 = \"$FILE6\"
17.75 +set F7 = \"$FILE7\"
17.76 +set F8 = \"$FILE8\"
17.77 +set GRIDQ = \"$GRID\"
17.78 +set BGCQ = \"$BGC\"
17.79 +set ENERGYQ = \"$ENERGY\"
17.80 +set DIRSQ = \"$DIR_S\"
17.81 +set DIROQ = \"$DIR_O\"
17.82 +
17.83 +set INPUT_TEXT = "model_name=$MODELQ model_grid=$GRIDQ dirm=$DIRMQ film1=$F1 film2=$F2 film3=$F3 film4=$F4 film5=$F5 film6=$F6 film7=$F7 film8=$F8 BGC=$BGCQ ENERGY=$ENERGYQ dirs=$DIRSQ diro=$DIROQ"
17.84 +
17.85 +# CLAMP metric processing
17.86 +ncl $INPUT_TEXT $DIR_SCRIPTS/00.initial.ncl
17.87 +ncl $INPUT_TEXT $DIR_SCRIPTS/01.npp.ncl
17.88 +ncl $INPUT_TEXT $DIR_SCRIPTS/02.lai.ncl
17.89 +
17.90 +if ($FILE3 != "") then
17.91 +ncl $INPUT_TEXT $DIR_SCRIPTS/03.co2.ncl
17.92 +endif
17.93 +
17.94 +ncl $INPUT_TEXT $DIR_SCRIPTS/04.biomass.ncl
17.95 +ncl $INPUT_TEXT $DIR_SCRIPTS/06.fluxnet.ncl
17.96 +ncl $INPUT_TEXT $DIR_SCRIPTS/07.beta.ncl
17.97 +ncl $INPUT_TEXT $DIR_SCRIPTS/08.turnover.ncl
17.98 +
17.99 +if ($BGC != "casa") then
17.100 +ncl $INPUT_TEXT $DIR_SCRIPTS/09.carbon_sink.ncl
17.101 +else
17.102 +ncl $INPUT_TEXT $DIR_SCRIPTS/09x.carbon_sink.ncl
17.103 +endif
17.104 +
17.105 +if ($BGC != "casa") then
17.106 +ncl $INPUT_TEXT $DIR_SCRIPTS/10.fire.ncl
17.107 +endif
17.108 +
17.109 +ncl $INPUT_TEXT $DIR_SCRIPTS/11.ameriflux.ncl
17.110 +ncl $INPUT_TEXT $DIR_SCRIPTS/99.final.ncl
17.111 +
17.112 +# create a tar file from the final output
17.113 +tar cf $MODEL.tar $MODEL
17.114 +
17.115 +
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/all/run_2-model.csh Mon Jan 26 22:08:20 2009 -0500
18.3 @@ -0,0 +1,201 @@
18.4 +#!/bin/csh -f
18.5 +#-------------------------------------------------------------------
18.6 +# note: user modifies ONLY the "user modification" section
18.7 +#
18.8 +# COMPARE: model1 vs model2
18.9 +# MODELn : model name
18.10 +# DIR_M : directory of model data
18.11 +# DIR_O : directory of observed data
18.12 +# DIR_S : directory of model surface data
18.13 +# DIR_SCRIPTS : directory of run scripts
18.14 +# FILE1 : time_mean climatology from CLM diagnostic package
18.15 +# FILE2 : 12-monthly climatology from CLM diagnostic package
18.16 +# FILE3 : 12-monthly climatology from ATM diagnostic package
18.17 +# leave it blank, if no ATM file:
18.18 +# set FILE3 =
18.19 +# FILE7 : timeseries file generated from ....
18.20 +# FILE8 : timeseries file generated from ....
18.21 +# GRID : T31, T42, or 1.9
18.22 +# BGC : cn or casa
18.23 +# ENERGY : new or old (fields in model data)
18.24 +#-------------------------------------------------------------------
18.25 +
18.26 +#*******************************************************
18.27 +# user modification-(1)
18.28 +
18.29 +# directory name of model comparison
18.30 +#et COMPARE = b30.061n_vs_b30.061m
18.31 +set COMPARE = CN_vs_CASA
18.32 +
18.33 +#*******************************************************
18.34 +# user modification-(2)
18.35 +
18.36 +# model1
18.37 +set MODEL1 = CN
18.38 +set DIR_M = /lustre/wolf-ddn/scratch/hof/clamp_data/model/
18.39 +set FILE1 = i01.10cn_1948-2004_ANN_climo.nc
18.40 +set FILE2 = i01.10cn_1948-2004_MONS_climo.nc
18.41 +set FILE3 = f02.03cn_1901-1925_MONS_climo_atm.nc
18.42 +set FILE4 = i01.06cn_1980-2004_ANN_climo.nc
18.43 +set FILE5 = i01.10cn_1990-2004_ANN_climo.nc
18.44 +set FILE6 = i01.07cn_1990-2004_ANN_climo.nc
18.45 +set FILE7 = i01.10cn_Fire_C_1979-2004_monthly.nc
18.46 +set FILE8 = i01.10cn_ameriflux_1990-2004_monthly.nc
18.47 +set GRID = T42
18.48 +set BGC = cn
18.49 +set ENERGY = new
18.50 +
18.51 +# in the "CLAMP metric processing" section:
18.52 +# only 00.initial.ncl and 99.final.ncl are required,
18.53 +# user can comment out any one or more of the other ncl scripts,
18.54 +# e.g.
18.55 +# #ncl $INPUT_TEXT $DIR_SCRIPTS/10.fire.ncl
18.56 +
18.57 +# model surface data
18.58 +set DIR_S = /lustre/wolf-ddn/scratch/hof/clamp_data/surface_model/
18.59 +
18.60 +# observed data
18.61 +set DIR_O = /lustre/wolf-ddn/scratch/hof/clamp_data/observed/
18.62 +
18.63 +# directory for scripts, templates and ncl files
18.64 +set DIR_SCRIPTS = /lustre/wolf-ddn/scratch/hof/clamp/all/
18.65 +
18.66 +#********************************************************
18.67 +
18.68 +# create model1 and model1_vs_model2 directory by copying templates
18.69 +if ($FILE3 != "") then
18.70 + set TEMPLATE1 = template_1-model
18.71 + set TEMPLATE2 = template_2-model
18.72 +else
18.73 + set TEMPLATE1 = template_1-model_noCO2
18.74 + set TEMPLATE2 = template_2-model_noCO2
18.75 +endif
18.76 +cp -r $DIR_SCRIPTS/$TEMPLATE1 $MODEL1
18.77 +cp -r $DIR_SCRIPTS/$TEMPLATE2 $COMPARE
18.78 +
18.79 +# add quote, to be usesd in INPUT_TEXT
18.80 +set MODELQ = \"$MODEL1\"
18.81 +set DIRMQ = \"$DIR_M\"
18.82 +set F1 = \"$FILE1\"
18.83 +set F2 = \"$FILE2\"
18.84 +set F3 = \"$FILE3\"
18.85 +set F4 = \"$FILE4\"
18.86 +set F5 = \"$FILE5\"
18.87 +set F6 = \"$FILE6\"
18.88 +set F7 = \"$FILE7\"
18.89 +set F8 = \"$FILE8\"
18.90 +set GRIDQ = \"$GRID\"
18.91 +set BGCQ = \"$BGC\"
18.92 +set ENERGYQ = \"$ENERGY\"
18.93 +set DIRSQ = \"$DIR_S\"
18.94 +set DIROQ = \"$DIR_O\"
18.95 +set DIRCQ = \"$DIR_SCRIPTS\"
18.96 +
18.97 +set COMPAREQ = \"$COMPARE\"
18.98 +set MODELN = \"model1\"
18.99 +
18.100 +set INPUT_TEXT = "model_name=$MODELQ model_grid=$GRIDQ dirm=$DIRMQ film1=$F1 film2=$F2 film3=$F3 film4=$F4 film5=$F5 film6=$F6 film7=$F7 film8=$F8 BGC=$BGCQ ENERGY=$ENERGYQ dirs=$DIRSQ diro=$DIROQ dirscript=$DIRCQ modeln=$MODELN compare=$COMPAREQ"
18.101 +
18.102 +# CLAMP metric processing of model1
18.103 +ncl $INPUT_TEXT $DIR_SCRIPTS/00.initial.ncl
18.104 +ncl $INPUT_TEXT $DIR_SCRIPTS/01.npp.ncl
18.105 +ncl $INPUT_TEXT $DIR_SCRIPTS/02.lai.ncl
18.106 +
18.107 +if ($FILE3 != "") then
18.108 +ncl $INPUT_TEXT $DIR_SCRIPTS/03.co2.ncl
18.109 +endif
18.110 +
18.111 +ncl $INPUT_TEXT $DIR_SCRIPTS/04.biomass.ncl
18.112 +ncl $INPUT_TEXT $DIR_SCRIPTS/06.fluxnet.ncl
18.113 +ncl $INPUT_TEXT $DIR_SCRIPTS/07.beta.ncl
18.114 +ncl $INPUT_TEXT $DIR_SCRIPTS/08.turnover.ncl
18.115 +
18.116 +if ($BGC != "casa") then
18.117 +ncl $INPUT_TEXT $DIR_SCRIPTS/09.carbon_sink.ncl
18.118 +else
18.119 +ncl $INPUT_TEXT $DIR_SCRIPTS/09x.carbon_sink.ncl
18.120 +endif
18.121 +
18.122 +if ($BGC != "casa") then
18.123 +ncl $INPUT_TEXT $DIR_SCRIPTS/10.fire.ncl
18.124 +endif
18.125 +
18.126 +ncl $INPUT_TEXT $DIR_SCRIPTS/11.ameriflux.ncl
18.127 +ncl $INPUT_TEXT $DIR_SCRIPTS/99.final.ncl
18.128 +
18.129 +#*******************************************************
18.130 +# user modification-(3)
18.131 +
18.132 +# model2
18.133 +set MODEL2 = CASA
18.134 +set DIR_M = /lustre/wolf-ddn/scratch/hof/clamp_data/model/
18.135 +set FILE1 = i01.10casa_1948-2004_ANN_climo.nc
18.136 +set FILE2 = i01.10casa_1948-2004_MONS_climo.nc
18.137 +set FILE3 = f02.03casa_1876-1900_MONS_climo_atm.nc
18.138 +set FILE4 = i01.06casa_1980-2004_ANN_climo.nc
18.139 +set FILE5 = i01.10casa_1990-2004_ANN_climo.nc
18.140 +set FILE6 = i01.07casa_1990-2004_ANN_climo.nc
18.141 +set FILE7 = i01.10casa_Fire_C_1979-2004_monthly.nc
18.142 +set FILE8 = i01.10casa_ameriflux_1990-2004_monthly.nc
18.143 +set GRID = T42
18.144 +set BGC = casa
18.145 +set ENERGY = new
18.146 +#*******************************************************
18.147 +# create model2 directory by copying templates
18.148 +if ($FILE3 != "") then
18.149 + set TEMPLATE1 = template_1-model
18.150 +else
18.151 + set TEMPLATE1 = template_1-model_noCO2
18.152 +endif
18.153 +cp -r $DIR_SCRIPTS/$TEMPLATE1 $MODEL2
18.154 +
18.155 +# add quote, to be usesd in INPUT_TEXT
18.156 +set MODELQ = \"$MODEL2\"
18.157 +set DIRMQ = \"$DIR_M\"
18.158 +set F1 = \"$FILE1\"
18.159 +set F2 = \"$FILE2\"
18.160 +set F3 = \"$FILE3\"
18.161 +set F4 = \"$FILE4\"
18.162 +set F5 = \"$FILE5\"
18.163 +set F6 = \"$FILE6\"
18.164 +set F7 = \"$FILE7\"
18.165 +set F8 = \"$FILE8\"
18.166 +set GRIDQ = \"$GRID\"
18.167 +set BGCQ = \"$BGC\"
18.168 +set ENERGYQ = \"$ENERGY\"
18.169 +
18.170 +set COMPAREQ = \"$COMPARE\"
18.171 +set MODELN = \"model2\"
18.172 +
18.173 +set INPUT_TEXT = "model_name=$MODELQ model_grid=$GRIDQ dirm=$DIRMQ film1=$F1 film2=$F2 film3=$F3 film4=$F4 film5=$F5 film6=$F6 film7=$F7 film8=$F8 BGC=$BGCQ ENERGY=$ENERGYQ dirs=$DIRSQ diro=$DIROQ dirscript=$DIRCQ modeln=$MODELN compare=$COMPAREQ"
18.174 +
18.175 +# CLAMP metric processing of model2
18.176 +ncl $INPUT_TEXT $DIR_SCRIPTS/00.initial.ncl
18.177 +ncl $INPUT_TEXT $DIR_SCRIPTS/01.npp.ncl
18.178 +ncl $INPUT_TEXT $DIR_SCRIPTS/02.lai.ncl
18.179 +
18.180 +if ($FILE3 != "") then
18.181 +ncl $INPUT_TEXT $DIR_SCRIPTS/03.co2.ncl
18.182 +endif
18.183 +
18.184 +ncl $INPUT_TEXT $DIR_SCRIPTS/04.biomass.ncl
18.185 +ncl $INPUT_TEXT $DIR_SCRIPTS/06.fluxnet.ncl
18.186 +ncl $INPUT_TEXT $DIR_SCRIPTS/07.beta.ncl
18.187 +ncl $INPUT_TEXT $DIR_SCRIPTS/08.turnover.ncl
18.188 +
18.189 +if ($BGC != "casa") then
18.190 +ncl $INPUT_TEXT $DIR_SCRIPTS/09.carbon_sink.ncl
18.191 +else
18.192 +ncl $INPUT_TEXT $DIR_SCRIPTS/09x.carbon_sink.ncl
18.193 +endif
18.194 +
18.195 +if ($BGC != "casa") then
18.196 +ncl $INPUT_TEXT $DIR_SCRIPTS/10.fire.ncl
18.197 +endif
18.198 +
18.199 +ncl $INPUT_TEXT $DIR_SCRIPTS/11.ameriflux.ncl
18.200 +ncl $INPUT_TEXT $DIR_SCRIPTS/99.final.ncl
18.201 +
18.202 +# create a tar file from the final output
18.203 +tar cf - $MODEL1 $MODEL2 $COMPARE > all.tar
18.204 +
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/all/taylor_diagram.ncl Mon Jan 26 22:08:20 2009 -0500
19.3 @@ -0,0 +1,479 @@
19.4 +function taylor_diagram (wks:graphic ,RATIO[*][*]:numeric, CC[*][*]:numeric \
19.5 + ,rOpts:logical)
19.6 +;--------------------------------------------------------------------
19.7 +; This version of taylor_diagram supports "paneling"
19.8 +; It requires NCL version 4.2.0.a034 because it uses "gsn_create_legend"
19.9 +;--------------------------------------------------------------------
19.10 +
19.11 +;
19.12 +; Generate a Taylor Diagram:
19.13 +; Generate Multiple Aspects of Model Performance in a Single Diagram
19.14 +; Taylor, K. E., J. Geophys. Res., 106, D7, 7183-7192, 2001
19.15 +;
19.16 +; An example:
19.17 +; http://www.grida.no/climate/ipcc_tar/wg1/fig8-4.htm
19.18 +;
19.19 +; This expects one or more datasets. The left dimension
19.20 +; is the number of datasets. The rightmost is the number of pts.
19.21 +;
19.22 +; Markers are at:
19.23 +; http://www.ncl.ucar.edu/Document/Graphics/Resources/gs.shtml
19.24 +;
19.25 +; By default, the function can handle up to 10 variable comparisons..
19.26 +; To expand ... modify the 'Colors' and 'Markers' attributes.
19.27 +; The user can change / add some default settings.
19.28 +;
19.29 +; The defaults that the user can modify:
19.30 +;
19.31 +; rOpts = True
19.32 +; ; 'made-up' resources
19.33 +; rOpts@Colors = (/ "blue" , "red", "green", "cyan", "black" \
19.34 +; , "torquoise", "brown", "yellow"/)
19.35 +; rOpts@Markers = (/ 2, 3, 6, 14, 9, 12, 7, 4/) ; Marker Indices
19.36 +; rOpts@markerTxOffset = 0.0175 ; offset for text above marker
19.37 +; rOpts@stnRad = (/ 1. /) ; (/ 0.50, 0.75, 1.5 /)
19.38 +; rOpts@centerDiffRMS = False ; True mean draw additional radii from REF
19.39 +; rOpts@caseLabelsFontHeightF = 0.05
19.40 +; rOpts@varLabelsFontHeightF = 0.013
19.41 +; rOpts@varLabelsYloc = 0.65
19.42 +; rOpts@legendWidth = 0.015
19.43 +; rOpts@legendHeight = 0.030*nCase
19.44 +; rOpts@taylorDraw = True
19.45 +; rOpts@taylorFrame = True
19.46 +;
19.47 +; ; standard NCL resources
19.48 +; rOpts@tiMainString = "Taylor" ; not using title makes plot bigger
19.49 +; rOpts@gsMarkerSizeF = 0.0085 ; marker size
19.50 +; rOpts@gsMarkerThicknessF = 1.0
19.51 +; rOpts@txFontHeightF = 0.0125 ; text size
19.52 +; rOpts@tiMainFontHeightF = 0.0225 ; tiMainString size
19.53 +;
19.54 +; It returns to the user a graphic object containing the
19.55 +; Taylor background and plotted x/y pts.
19.56 +; This graphic object contains a simple Taylor background appropriate
19.57 +; for standardized data and the markers for the datasets.
19.58 +; ==================================================================
19.59 +; This version allows paneling:
19.60 +; The 'cumbersome' "dum" variables were added by
19.61 +; Adam Phillips to allow paneling via "gsn_add_?".
19.62 +; ==================================================================
19.63 +begin
19.64 + dimR = dimsizes(RATIO)
19.65 + nCase = dimR(0) ; # of cases [models]
19.66 + nVar = dimR(1) ; # of variables
19.67 +
19.68 + ; x/y coordinates for plotting
19.69 + X = new ( (/nCase,nVar/) , typeof(RATIO) )
19.70 + Y = new ( (/nCase,nVar/) , typeof(RATIO) )
19.71 +
19.72 + do nc=0,nCase-1
19.73 + angle = acos( CC(nc,:) ) ; array operation
19.74 + X(nc,:) = RATIO(nc,:)*cos( angle )
19.75 + Y(nc,:) = RATIO(nc,:)*sin( angle )
19.76 + end do
19.77 +
19.78 + xyMin = 0.
19.79 + xyOne = 1.00
19.80 + xyMax = 1.65
19.81 + xyMax_Panel = xyMax+ 0.10 ; paneling purposes
19.82 +
19.83 + if (rOpts .and. isatt(rOpts,"txFontHeightF")) then
19.84 + FontHeightF = rOpts@txFontHeightF ; user wants to specify size
19.85 + else
19.86 + FontHeightF = 0.0175
19.87 + end if
19.88 +
19.89 +; ----------------------------------------------------------------
19.90 +; Part 1:
19.91 +; base plot: Based upon request of Mark Stevens
19.92 +; basic x-y and draw the 1.0 observed and the outer curve at 1.65
19.93 +; ----------------------------------------------------------------
19.94 +
19.95 + rxy = True
19.96 + rxy@gsnDraw = False
19.97 + rxy@gsnFrame = False
19.98 + rxy@vpHeightF = 0.65
19.99 + rxy@vpWidthF = 0.65
19.100 + rxy@tmYLBorderOn = False
19.101 + rxy@tmXBBorderOn = False
19.102 +
19.103 + rxy@tiYAxisString = "Standardized Deviation (Normalized)"
19.104 + rxy@tiYAxisFontHeightF= FontHeightF ; default=0.025
19.105 +
19.106 + rxy@tmXBMode = "Explicit"
19.107 + rxy@tmXBValues = (/0.0,0.25,0.50,0.75,1.00,1.25,1.5/) ; major tm
19.108 + ; default "OBS" or "REF"
19.109 + ;rxy@tmXBLabels = (/"0.00","0.25","0.50","0.75","REF" ,"1.25","1.50"/)
19.110 + rxy@tmXBLabels = (/" ","0.25","0.50","0.75","REF" ,"1.25","1.50"/)
19.111 + if (rOpts .and. isatt(rOpts,"OneX") ) then ; eg: rOpts@OneX="1.00"
19.112 + ;rxy@tmXBLabels = (/"0.00","0.25","0.50","0.75",rOpts@OneX,"1.25","1.50"/)
19.113 + rxy@tmXBLabels = (/" ","0.25","0.50","0.75",rOpts@OneX,"1.25","1.50"/)
19.114 + end if
19.115 +
19.116 + rxy@tmXBMajorLengthF = 0.015 ; default=0.02 for a vpHeightF=0.6
19.117 + rxy@tmXBLabelFontHeightF = FontHeightF
19.118 + rxy@tmXBMinorOn = False
19.119 + rxy@trXMaxF = xyMax_Panel
19.120 +
19.121 + rxy@tmYLMode = "Manual"
19.122 + rxy@tmYLMinorOn = False
19.123 + rxy@tmYLMajorLengthF = rxy@tmXBMajorLengthF
19.124 + rxy@tmYLLabelFontHeightF = FontHeightF
19.125 + rxy@tmYLMode = "Explicit"
19.126 + rxy@tmYLValues = (/0.0, .25,0.50, 0.75, 1.00, 1.25, 1.5/) ; major tm
19.127 + rxy@tmYLLabels = (/"0.00","0.25","0.50","0.75","1.00","1.25","1.50"/)
19.128 + ;rxy@tmYLLabels = (/" ","0.25","0.50","0.75","1.00","1.25","1.50"/)
19.129 + rxy@trYMaxF = xyMax_Panel
19.130 +
19.131 + rxy@tmYRBorderOn = False
19.132 + rxy@tmYROn = False ; Turn off right tick marks.
19.133 +
19.134 + rxy@tmXTBorderOn = False
19.135 + rxy@tmXTOn = False ; Turn off right tick marks.
19.136 +
19.137 + rxy@xyDashPatterns = (/ 0 /) ; line characteristics (dash,solid)
19.138 + rxy@xyLineThicknesses = (/ 2./) ; choose line thickness
19.139 +
19.140 + rxy@gsnFrame = False ; Don't advance the frame.
19.141 +
19.142 + ; create outer 'correlation axis'
19.143 + npts = 200 ; arbitrary
19.144 + xx = fspan(xyMin,xyMax,npts)
19.145 + yy = sqrt(xyMax^2 - xx^2 ) ; outer correlation line (xyMax)
19.146 +
19.147 + sLabels = (/"0.0","0.1","0.2","0.3","0.4","0.5","0.6" \ ; correlation labels
19.148 + ,"0.7","0.8","0.9","0.95","0.99","1.0" /); also, major tm
19.149 + cLabels = stringtofloat(sLabels)
19.150 + rad = 4.*atan(1.0)/180.
19.151 + angC = acos(cLabels)/rad ; angles: correlation labels
19.152 +
19.153 + if (rOpts .and. isatt(rOpts,"tiMainString")) then
19.154 + rxy@tiMainString = rOpts@tiMainString
19.155 + ;rxy@tiMainOffsetYF = 0.015 ; default 0.0
19.156 + if (isatt(rOpts,"tiMainFontHeightF")) then
19.157 + rxy@tiMainFontHeightF = rOpts@tiMainFontHeightF
19.158 + else
19.159 + rxy@tiMainFontHeightF = 0.0225 ; default 0.025
19.160 + end if
19.161 + end if
19.162 +;;if (rOpts .and. isatt(rOpts,"gsnCenterString")) then
19.163 +;; rxy@gsnCenterString = rOpts@gsnCenterString ; only gsn_csm_xy
19.164 +;;end if
19.165 +
19.166 + taylor = gsn_xy(wks,xx,yy,rxy) ; Create and draw XY plot.
19.167 +
19.168 + rsrRes = True
19.169 + rsrRes@gsLineThicknessF = rxy@xyLineThicknesses(0) ; line thickness
19.170 + rsrRes@gsLineDashPattern = 0 ; solid line pattern
19.171 + ; draw x and y to xyMax
19.172 + dum0 = gsn_add_polyline(wks,taylor,(/0., 0. /),(/0.,xyMax/), rsrRes)
19.173 + dum1 = gsn_add_polyline(wks,taylor,(/0.,xyMax/),(/0., 0. /), rsrRes)
19.174 +
19.175 + xx = fspan(xyMin, xyOne ,npts) ; draw 1.0 standard radius
19.176 + yy = sqrt(xyOne - xx^2)
19.177 + rsrRes@gsLineDashPattern = 1 ; dashed line pattern
19.178 + rsrRes@gsLineThicknessF = rxy@xyLineThicknesses(0) ; line thickness
19.179 + dum2 = gsn_add_polyline(wks,taylor,xx,yy, rsrRes)
19.180 + delete(xx)
19.181 + delete(yy)
19.182 +
19.183 + if (rOpts .and. isatt(rOpts,"stnRad") ) then
19.184 + rsrRes@gsLineThicknessF = 1 ; rxy@xyLineThicknesses(0)
19.185 + nStnRad = dimsizes(rOpts@stnRad)
19.186 +
19.187 + dum3 = new(nStnRad,graphic)
19.188 + do n=0,nStnRad-1
19.189 + rr = rOpts@stnRad(n)
19.190 + xx = fspan(xyMin, rr ,npts)
19.191 + yy = sqrt(rr^2 - xx^2)
19.192 + dum3(n) = gsn_add_polyline(wks,taylor,xx,yy, rsrRes)
19.193 + end do
19.194 + taylor@$unique_string("dum")$ = dum3
19.195 +
19.196 + delete(xx)
19.197 + delete(yy)
19.198 + end if
19.199 +
19.200 + getvalues taylor ; get style info from taylor
19.201 + "tmYLLabelFont" : tmYLLabelFont ; use for correlation axis
19.202 + "tmYLLabelFontHeightF" : tmYLLabelFontHeightF
19.203 + end getvalues
19.204 +
19.205 +; ----------------------------------------------------------------
19.206 +; Part 2:
19.207 +; Correlation labels
19.208 +; ----------------------------------------------------------------
19.209 + radC = xyMax ; for correlation labels
19.210 + xC = radC*cos(angC*rad)
19.211 + yC = radC*sin(angC*rad)
19.212 +; added to get some separation
19.213 + xC = xC + 0.020*cos(rad*angC)
19.214 + yC = yC + 0.060*sin(rad*angC)
19.215 +
19.216 + txRes = True ; text mods desired
19.217 + txRes@txFontHeightF = FontHeightF ; match YL
19.218 + txRes@tmYLLabelFont = tmYLLabelFont ; match YL
19.219 + txRes@txAngleF = -45.
19.220 + if (.not.isatt(rOpts,"drawCorLabel") .or. rOpts@drawCorLabel) then
19.221 + dum4 = gsn_add_text(wks,taylor,"Correlation",1.30,1.30,txRes)
19.222 + taylor@$unique_string("dum")$ = dum4
19.223 + end if
19.224 + txRes@txAngleF = 0.0
19.225 + txRes@txFontHeightF = FontHeightF*0.50 ; bit smaller
19.226 +
19.227 +;;dum0 = gsn_add_text(wks,taylor,"OBSERVED",1.00,0.075,txRes)
19.228 +
19.229 + plRes = True
19.230 + plRes@gsLineThicknessF = 2.
19.231 +
19.232 + txRes@txJust = "CenterLeft" ; Default="CenterCenter".
19.233 + txRes@txFontHeightF = FontHeightF ; match YL
19.234 + ;txRes@txBackgroundFillColor = "white"
19.235 +
19.236 + tmEnd = 0.975
19.237 + radTM = xyMax*tmEnd ; radius end: major TM
19.238 + xTM = new( 2 , "float")
19.239 + yTM = new( 2 , "float")
19.240 +
19.241 + dum5 = new(dimsizes(sLabels),graphic)
19.242 + dum6 = dum5
19.243 +
19.244 + do i=0,dimsizes(sLabels)-1 ; Loop to draw strings
19.245 + txRes@txAngleF = angC(i)
19.246 + dum5(i) = gsn_add_text(wks, taylor, sLabels(i),xC(i),yC(i),txRes) ; cor label
19.247 + xTM(0) = xyMax*cos(angC(i)*rad) ; major tickmarks at
19.248 + yTM(0) = xyMax*sin(angC(i)*rad) ; correlation labels
19.249 + xTM(1) = radTM*cos(angC(i)*rad)
19.250 + yTM(1) = radTM*sin(angC(i)*rad)
19.251 + dum6(i) = gsn_add_polyline(wks,taylor,xTM,yTM,plRes)
19.252 + end do
19.253 + ; minor tm locations
19.254 + mTM = (/0.05,0.15,0.25,0.35,0.45,0.55,0.65 \
19.255 + ,0.75,0.85,0.91,0.92,0.93,0.94,0.96,0.97,0.98 /)
19.256 + angmTM = acos(mTM)/rad ; angles: correlation labels
19.257 + radmTM = xyMax*(1.-(1.-tmEnd)*0.5) ; radius end: minor TM
19.258 +
19.259 + dum7 = new(dimsizes(mTM),graphic)
19.260 +
19.261 + do i=0,dimsizes(mTM)-1 ; manually add tm
19.262 + xTM(0) = xyMax*cos(angmTM(i)*rad) ; minor tickmarks
19.263 + yTM(0) = xyMax*sin(angmTM(i)*rad)
19.264 + xTM(1) = radmTM*cos(angmTM(i)*rad)
19.265 + yTM(1) = radmTM*sin(angmTM(i)*rad)
19.266 + dum7(i) = gsn_add_polyline(wks,taylor,xTM,yTM,plRes)
19.267 + end do
19.268 + ; added for Wanli
19.269 + if (rOpts .and. isatt(rOpts,"ccRays") ) then
19.270 + angRL = acos(rOpts@ccRays)/rad ; angles: radial lines
19.271 +
19.272 + rlRes = True
19.273 + rlRes@xyDashPattern = 4 ; line pattern
19.274 + rlRes@xyLineThicknessF = 1 ; choose line thickness
19.275 +
19.276 + dum8 = new(dimsizes(angRL),graphic)
19.277 + do i=0,dimsizes(angRL)-1
19.278 + xRL = xyMax*cos(angRL(i)*rad)
19.279 + yRL = xyMax*sin(angRL(i)*rad)
19.280 + dum8(i) = gsn_add_polyline(wks,taylor,(/0, xRL /),(/0, yRL /),rlRes)
19.281 + end do
19.282 + taylor@$unique_string("dum")$ = dum8
19.283 + end if
19.284 +
19.285 +; ----------------------------------------------------------------
19.286 +; Part 3:
19.287 +; Concentric about 1.0 on XB axis
19.288 +; I think this is correct. Still test mode.
19.289 +; ----------------------------------------------------------------
19.290 + if (rOpts .and. isatt(rOpts,"centerDiffRMS") \
19.291 + .and. rOpts@centerDiffRMS) then
19.292 + respl = True ; polyline mods desired
19.293 + respl@gsLineThicknessF = 1.0 ; line thickness
19.294 + respl@gsLineColor = "Black" ; line color
19.295 + respl@gsLineDashPattern = 2 ; short dash lines
19.296 +
19.297 + dx = 0.25
19.298 + ncon = 4 ; 0.75, 0.50, 0.25, 0.0
19.299 + npts = 100 ; arbitrary
19.300 + ang = fspan(180,360,npts)*rad
19.301 +
19.302 + dum9 = new(ncon,graphic)
19.303 +
19.304 + do n=1,ncon
19.305 + rr = n*dx ; radius from 1.0 [OBS] abscissa
19.306 + xx = 1. + rr*cos(ang)
19.307 + yy = fabs( rr*sin(ang) )
19.308 + if (n.le.2) then
19.309 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx,yy,respl)
19.310 + end if
19.311 + if (n.eq.3) then
19.312 + n3 = floattointeger( 0.77*npts )
19.313 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx(0:n3),yy(0:n3),respl)
19.314 + end if
19.315 + if (n.eq.4) then
19.316 + n4 = floattointeger( 0.61*npts )
19.317 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx(0:n4),yy(0:n4),respl)
19.318 + end if
19.319 + end do
19.320 + delete(ang)
19.321 + delete(xx)
19.322 + delete(yy)
19.323 + taylor@$unique_string("dum")$ = dum9
19.324 +
19.325 + end if
19.326 +; ---------------------------------------------------------------
19.327 +; Part 4:
19.328 +; generic resources that will be applied to all users data points
19.329 +; of course, these can be changed
19.330 +; http://www.ncl.ucar.edu/Document/Graphics/Resources/gs.shtml
19.331 +; ---------------------------------------------------------------
19.332 + if (rOpts .and. isatt(rOpts,"Markers")) then
19.333 + Markers = rOpts@Markers
19.334 + else
19.335 + Markers = (/ 4, 6, 8, 0, 9, 12, 7, 2, 11, 16/) ; Marker Indices
19.336 + end if
19.337 +
19.338 + if (rOpts .and. isatt(rOpts,"Colors")) then
19.339 + Colors = rOpts@Colors
19.340 + else
19.341 + Colors = (/ "red", "blue", "green", "cyan", "orange" \
19.342 + , "torquoise", "brown", "yellow", "purple", "black"/)
19.343 + end if
19.344 +
19.345 + if (rOpts .and. isatt(rOpts,"gsMarkerThicknessF")) then
19.346 + gsMarkerThicknessF = rOpts@gsMarkerThicknessF
19.347 + else
19.348 + gsMarkerThicknessF = 1.0
19.349 + end if
19.350 +
19.351 + if (rOpts .and. isatt(rOpts,"gsMarkerSizeF")) then
19.352 + gsMarkerSizeF = rOpts@gsMarkerSizeF
19.353 + else
19.354 + gsMarkerSizeF = 0.0085 ; Default: 0.007
19.355 + end if
19.356 +
19.357 + gsRes = True
19.358 + gsRes@gsMarkerThicknessF = gsMarkerThicknessF ; default=1.0
19.359 + gsRes@gsMarkerSizeF = gsMarkerSizeF ; Default: 0.007
19.360 +
19.361 + ptRes = True ; text options for points
19.362 + ptRes@txJust = "BottomCenter"; Default="CenterCenter".
19.363 + ptRes@txFontThicknessF = 1.2 ; default=1.00
19.364 + ptRes@txFontHeightF = 0.0125 ; default=0.05
19.365 + if (rOpts .and. isatt(rOpts,"txFontHeightF")) then
19.366 + ptRes@txFontHeightF = rOpts@txFontHeightF
19.367 + end if
19.368 +
19.369 + markerTxYOffset = 0.0175 ; default
19.370 + if (rOpts .and. isatt(rOpts,"markerTxYOffset")) then
19.371 + markerTxYOffset = rOpts@markerTxYOffset ; user defined offset
19.372 + end if
19.373 +
19.374 + dum10 = new((nCase*nVar),graphic)
19.375 + dum11 = dum10
19.376 +
19.377 + do n=0,nCase-1
19.378 + gsRes@gsMarkerIndex = Markers(n) ; marker style (+)
19.379 + gsRes@gsMarkerColor = Colors(n) ; marker color
19.380 + ptRes@txFontColor = gsRes@gsMarkerColor
19.381 + do i=0,nVar-1
19.382 + dum10(n*nVar+i) = gsn_add_polymarker(wks,taylor,X(n,i),Y(n,i),gsRes)
19.383 +; dum11(n*nVar+i) = gsn_add_text(wks,taylor,(i+1),X(n,i),Y(n,i)+markerTxYOffset,ptRes)
19.384 + end do
19.385 + end do
19.386 +
19.387 +; ---------------------------------------------------------------
19.388 +; Part 5: ; add case legend and variable labels
19.389 +; ---------------------------------------------------------------
19.390 +
19.391 + if (rOpts .and. isatt(rOpts,"caseLabels")) then
19.392 +
19.393 + if (isatt(rOpts,"caseLabelsFontHeightF")) then
19.394 + caseLabelsFontHeightF = rOpts@caseLabelsFontHeightF
19.395 + else
19.396 +; caseLabelsFontHeightF = 0.05
19.397 + caseLabelsFontHeightF = 0.15
19.398 + end if
19.399 +
19.400 + lgres = True
19.401 + lgres@lgMarkerColors = Colors ; colors of markers
19.402 + lgres@lgMarkerIndexes = Markers ; Markers
19.403 + lgres@lgMarkerSizeF = gsMarkerSizeF ; Marker size
19.404 + lgres@lgItemType = "Markers" ; draw markers only
19.405 + lgres@lgLabelFontHeightF = caseLabelsFontHeightF ; font height of legend case labels
19.406 +
19.407 + if (isatt(rOpts,"legendWidth")) then
19.408 + lgres@vpWidthF = rOpts@legendWidth
19.409 + else
19.410 + lgres@vpWidthF = 0.15 ; width of legend (NDC)
19.411 + end if
19.412 +
19.413 + if (isatt(rOpts,"legendHeight")) then
19.414 + lgres@vpHeightF = rOpts@legendHeight
19.415 + else
19.416 + lgres@vpHeightF = 0.030*nCase ; height of legend (NDC)
19.417 + end if
19.418 +
19.419 + lgres@lgPerimOn = False ; turn off perimeter
19.420 + nModel = dimsizes( rOpts@caseLabels )
19.421 + lbid = gsn_create_legend(wks,nModel,rOpts@caseLabels,lgres)
19.422 +
19.423 + amres = True
19.424 + amres@amParallelPosF = 0.35
19.425 + amres@amOrthogonalPosF = -0.35
19.426 + annoid1 = gsn_add_annotation(taylor,lbid,amres) ; add legend to plot
19.427 + end if
19.428 +
19.429 + if (rOpts .and. isatt(rOpts,"varLabels")) then
19.430 + nVar = dimsizes(rOpts@varLabels)
19.431 +
19.432 + if (isatt(rOpts,"varLabelsFontHeightF")) then
19.433 + varLabelsFontHeightF = rOpts@varLabelsFontHeightF
19.434 + else
19.435 + varLabelsFontHeightF = 0.013
19.436 + end if
19.437 +
19.438 + txres = True
19.439 + txres@txFontHeightF = varLabelsFontHeightF
19.440 + txres@txJust = "CenterLeft" ; justify to the center left
19.441 +
19.442 + ;delta_y = 0.02
19.443 + delta_y = 0.06
19.444 + if (rOpts .and. isatt(rOpts,"varLabelsYloc")) then
19.445 + ys = rOpts@varLabelsYloc ; user specified
19.446 + else
19.447 + ys = max( (/nVar*delta_y , 0.30/) )
19.448 + end if
19.449 +
19.450 +
19.451 + do i = 1,nVar
19.452 + if (i.eq.1) then
19.453 + dum12 = new(nVar,graphic)
19.454 + end if
19.455 +
19.456 + dum12(i-1) = gsn_add_text(wks,taylor,i+" - "+rOpts@varLabels(i-1), .125,ys,txres)
19.457 + ys = ys- delta_y
19.458 + end do
19.459 +
19.460 + taylor@$unique_string("dum")$ = dum12
19.461 + end if
19.462 +
19.463 + taylor@$unique_string("dum")$ = dum0 ; x-axis
19.464 + taylor@$unique_string("dum")$ = dum1 ; y-axis
19.465 + taylor@$unique_string("dum")$ = dum2 ; 1.0 std curve
19.466 + taylor@$unique_string("dum")$ = dum5 ; labels [COR]
19.467 + taylor@$unique_string("dum")$ = dum6 ; major tm [COR]
19.468 + taylor@$unique_string("dum")$ = dum7 ; minor tm
19.469 + taylor@$unique_string("dum")$ = dum10 ; markers
19.470 + taylor@$unique_string("dum")$ = dum11 ; text
19.471 +
19.472 + if (.not.isatt(rOpts,"taylorDraw") .or. \
19.473 + (isatt(rOpts,"taylorDraw") .and. rOpts@taylorDraw)) then
19.474 + draw(taylor)
19.475 + end if
19.476 + if (.not.isatt(rOpts,"taylorFrame") .or. \
19.477 + (isatt(rOpts,"taylorFrame") .and. rOpts@taylorFrame)) then
19.478 + frame(wks)
19.479 + end if
19.480 + return(taylor)
19.481 +end
19.482 +
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/all/template_1-model/index.html Mon Jan 26 22:08:20 2009 -0500
20.3 @@ -0,0 +1,16 @@
20.4 +<html>
20.5 +<head>
20.6 +<title> Score Sheet for CLAMP </title>
20.7 +<meta name="description" content="score CLAMP">
20.8 +<meta name="keywords" content="score BGC CLAMP CN CASA">
20.9 +<meta name="Authors" content="Jeff Lee">
20.10 +</head>
20.11 +
20.12 +<!----------------------------------------------------------------------------->
20.13 +<h2> <a href=http://www.climatemodeling.org/c-lamp/metrics4.pdf>CLAMP Score Sheet for Biogeochemical Model Evaluation</h2>
20.14 +<!----------------------------------------------------------------------------->
20.15 +
20.16 +<!--#include virtual="table.html"-->
20.17 +
20.18 +<!----------------------------------------------------------------------------->
20.19 +</html>
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/all/template_1-model/table.html Mon Jan 26 22:08:20 2009 -0500
21.3 @@ -0,0 +1,407 @@
21.4 +
21.5 +<!----------------------------------------------------------------------------->
21.6 +<table border=1 cellspacing=0 cellpadding=3 width=100%>
21.7 +<tr>
21.8 + <th bgcolor=DDDDDD width=8% rowspan=2> Metric </th>
21.9 + <th bgcolor=DDDDDD rowspan=2> Metric <br> components</th>
21.10 + <th bgcolor=DDDDDD rowspan=2> Observations & <br> comparison protocol</th>
21.11 + <th bgcolor=DDDDDD rowspan=2> Model<br> model_name </th>
21.12 + <th bgcolor=DDDDDD colspan=2> Score (points) </th>
21.13 +</tr>
21.14 +<tr>
21.15 + <th width=6% bgcolor=DDDDDD> Full </th>
21.16 + <th width=6% bgcolor=DDDDDD> model_name </th>
21.17 +</tr>
21.18 +
21.19 +<tr>
21.20 + <th rowspan=6>NPP</th>
21.21 +
21.22 + <th rowspan=2>EMDI NPP <br> observations</th>
21.23 +
21.24 + <th>
21.25 + <a href=./npp/table_site81_ob.html>
21.26 + Class_A_table</a>
21.27 + </th>
21.28 +
21.29 + <th>
21.30 + <a href=./npp/table_site81_model_vs_ob.html>
21.31 + table</a> <br>
21.32 + <a href=./npp/scatter_model_vs_ob_81.png>
21.33 + scatter_plot</a>
21.34 + </th>
21.35 +
21.36 + <th>2.5</th>
21.37 + <th>M_npp_S81</th>
21.38 +</tr>
21.39 +
21.40 +<tr>
21.41 + <th>
21.42 + <a href=./npp/table_site933_ob.html>
21.43 + Class_B_table</a>
21.44 + </th>
21.45 +
21.46 + <th>
21.47 + <a href=./npp/table_site933_model_vs_ob.html>
21.48 + table</a> <br>
21.49 + <a href=./npp/scatter_model_vs_ob_933.png>
21.50 + scatter_plot</a>
21.51 + </th>
21.52 +
21.53 + <th>2.5</th>
21.54 + <th>M_npp_S933</th>
21.55 +</tr>
21.56 +
21.57 +<tr>
21.58 + <th rowspan=2>EMDI NPP<br>normalized by PPT</th>
21.59 +
21.60 + <th>
21.61 + <a href=./npp/histogram_ob_81.png>
21.62 + Class_A_histogram</a>
21.63 + </th>
21.64 +
21.65 + <th>
21.66 + <a href=./npp/histogram_model_vs_ob_81.png>
21.67 + Class_A_histogram</a>
21.68 + </th>
21.69 +
21.70 + <th>2.5</th>
21.71 + <th>M_npp_H81</th>
21.72 +</tr>
21.73 +
21.74 +<tr>
21.75 + <th>
21.76 + <a href=./npp/histogram_ob_933.png>
21.77 + Class_B_histogram</a>
21.78 + </th>
21.79 +
21.80 + <th>
21.81 + <a href=./npp/histogram_model_vs_ob_933.png>
21.82 + Class_B_histogram</a>
21.83 + </th>
21.84 +
21.85 + <th>2.5</th>
21.86 + <th>M_npp_H933</th>
21.87 +</tr>
21.88 +
21.89 +<tr>
21.90 + <th>Correlation with MODIS obs.</th>
21.91 +
21.92 + <th>
21.93 + <a href=./npp/global_ob.png>
21.94 + global_map</a>
21.95 + </th>
21.96 +
21.97 + <th>
21.98 + <a href=./npp/global_model.png>
21.99 + model_map</a> <br>
21.100 + <a href=./npp/global_model_vs_ob.png>
21.101 + model_vs_obs</a>
21.102 + </th>
21.103 +
21.104 + <th>5</th>
21.105 + <th>M_npp_G</th>
21.106 +</tr>
21.107 +
21.108 +<tr>
21.109 + <th>Correlation with MODIS-zonal mean</th>
21.110 +
21.111 + <th>
21.112 + <a href=./npp/zonal_ob.png>
21.113 + zonal_mean_obs</a>
21.114 + </th>
21.115 +
21.116 + <th>
21.117 + <a href=./npp/zonal_model_vs_ob.png>
21.118 + zonal_mean <br>model_vs_obs_plot</a>
21.119 + </th>
21.120 +
21.121 + <th>5</th>
21.122 + <th>M_npp_Z</th>
21.123 +</tr>
21.124 +
21.125 +<tr>
21.126 + <th rowspan=3>LAI</th>
21.127 +
21.128 + <th>MODIS Mean</th>
21.129 +
21.130 + <th>
21.131 + <a href=./lai/global_class_ob.png>
21.132 + land_class_obs</a> <br>
21.133 + <a href=./lai/global_class_model.png>
21.134 + land_class_model</a> <br>
21.135 + <a href=./lai/global_Mean_ob.png>
21.136 + global_map</a>
21.137 + </th>
21.138 +
21.139 + <th>
21.140 + <a href=./lai/table_model_vs_ob.html>
21.141 + model_vs_obs_table</a> <br>
21.142 + <a href=./lai/global_Mean_model.png>
21.143 + global_map</a> <br>
21.144 + <a href=./lai/global_Mean_model_vs_ob.png>
21.145 + model_vs_obs</a>
21.146 + </th>
21.147 +
21.148 + <th>5</th>
21.149 + <th>M_lai_Mean</th>
21.150 +</tr>
21.151 +
21.152 +<tr>
21.153 + <th>MODIS Maximum</th>
21.154 +
21.155 + <th>
21.156 + <a href=./lai/global_Max_ob.png>
21.157 + global_map</a>
21.158 + </th>
21.159 +
21.160 + <th>
21.161 + <a href=./lai/global_Max_model.png>
21.162 + global_map</a> <br>
21.163 + <a href=./lai/global_Max_model_vs_ob.png>
21.164 + model_vs_obs</a>
21.165 + </th>
21.166 +
21.167 + <th>5</th>
21.168 + <th>M_lai_Max</th>
21.169 +</tr>
21.170 +<tr>
21.171 + <th>MODIS Phase</th>
21.172 +
21.173 + <th>
21.174 + <a href=./lai/global_Phase_ob.png>
21.175 + global_map</a>
21.176 + </th>
21.177 +
21.178 + <th>
21.179 + <a href=./lai/global_Phase_model.png>
21.180 + global_map</a> <br>
21.181 + <a href=./lai/global_Phase_model_vs_ob.png>
21.182 + model_vs_obs</a>
21.183 + </th>
21.184 +
21.185 + <th>5</th>
21.186 + <th>M_lai_Phase</th>
21.187 +</tr>
21.188 +
21.189 +<tr>
21.190 + <th>CO2 <br> Seasonal <br> Cycle</th>
21.191 + <th>Comparison with NOAA observations <br> phase and amplitude</th>
21.192 +
21.193 + <th>--</th>
21.194 +
21.195 + <th>
21.196 + <a href=./co2/score+line_vs_ob.html>
21.197 + model_vs_obs</a>
21.198 + </th>
21.199 +
21.200 + <th >20</th>
21.201 + <th >M_co2</th>
21.202 +</tr>
21.203 +
21.204 +<tr>
21.205 + <th rowspan=2>Carbon<br> Stocks</th>
21.206 +
21.207 + <th>Aboveground live biomass <br> in South America</th>
21.208 +
21.209 + <th>
21.210 + <a href=./biomass/global_ob.png>
21.211 + obs_amazon</a>
21.212 + </th>
21.213 +
21.214 + <th>
21.215 + <a href=./biomass/global_model.png>
21.216 + model_amazon</a> <br>
21.217 + <a href=./biomass/global_model_vs_ob.png>
21.218 + model_vs_obs</a>
21.219 + </th>
21.220 +
21.221 + <th>5</th>
21.222 + <th>M_biomass</th>
21.223 +</tr>
21.224 +
21.225 +<tr>
21.226 +
21.227 + <th>Aboveground live <br> biomass <br> within Amazon Basin <br>(sum within Legal Amazon)</th>
21.228 +
21.229 + <th>
21.230 + <a href=./biomass/mask_ob.png>
21.231 + mask</a> <br>
21.232 + <a href=./biomass/global_mask_ob.png>
21.233 + obs_masked</a> <br>
21.234 + Sum_biomass_ob (Pg C)
21.235 + </th>
21.236 +
21.237 + <th>
21.238 + <a href=./biomass/global_mask_model.png>
21.239 + model_masked</a> <br>
21.240 + <a href=./biomass/global_mask_vs_ob.png>
21.241 + model_vs_obs</a> <br>
21.242 + Sum_biomass_mod (Pg C)
21.243 + </th>
21.244 +
21.245 + <th>5</th>
21.246 + <th>M_biomask</th>
21.247 +</tr>
21.248 +
21.249 +<tr>
21.250 + <th rowspan=4>Energy and<br>C Fluxes<br>from Fluxnet</th>
21.251 +
21.252 + <th>NEE</th>
21.253 +
21.254 + <th rowspan=4>
21.255 + <a href=./fluxnet/line_ob.html>
21.256 + line_plot</a>
21.257 + </th>
21.258 +
21.259 + <th rowspan=4>
21.260 + <a href=./fluxnet/score+line_vs_ob.html>
21.261 + model_vs_obs</a>
21.262 + </th>
21.263 +
21.264 + <th>5</th>
21.265 + <th>M_fluxnet_nee</th>
21.266 +</tr>
21.267 +
21.268 +<tr>
21.269 + <th>Net radiation</th>
21.270 + <th>5</th>
21.271 + <th>M_fluxnet_rad</th>
21.272 +</tr>
21.273 +
21.274 +<tr>
21.275 + <th>Latent heat</th>
21.276 + <th>5</th>
21.277 + <th>M_fluxnet_lh</th>
21.278 +</tr>
21.279 +
21.280 +<tr>
21.281 + <th>Sensible heat</th>
21.282 + <th>5</th>
21.283 + <th>M_fluxnet_sh</th>
21.284 +</tr>
21.285 +
21.286 +<tr>
21.287 + <th rowspan=6>Energy and<br>C Fluxes<br>from Ameriflux</th>
21.288 +
21.289 + <th>NEE</th>
21.290 +
21.291 + <th rowspan=6>
21.292 + <a href=./ameriflux/line_ob.html>
21.293 + line_plot</a>
21.294 + </th>
21.295 +
21.296 + <th rowspan=6>
21.297 + <a href=./ameriflux/score+line_vs_ob.html>
21.298 + model_vs_obs</a> <br>
21.299 + <a href=./ameriflux/tseries_vs_ob.html>
21.300 + timeseries_plot</a>
21.301 + </th>
21.302 +
21.303 + <th>1</th>
21.304 + <th>M_ameriflux_nee</th>
21.305 +</tr>
21.306 +
21.307 +<tr>
21.308 + <th>Shortwave Incoming</th>
21.309 + <th>1</th>
21.310 + <th>M_ameriflux_rad</th>
21.311 +</tr>
21.312 +
21.313 +<tr>
21.314 + <th>Latent heat</th>
21.315 + <th>1</th>
21.316 + <th>M_ameriflux_lh</th>
21.317 +</tr>
21.318 +
21.319 +<tr>
21.320 + <th>Sensible heat</th>
21.321 + <th>1</th>
21.322 + <th>M_ameriflux_sh</th>
21.323 +</tr>
21.324 +
21.325 +<tr>
21.326 + <th>GPP</th>
21.327 + <th>1</th>
21.328 + <th>M_ameriflux_gpp</th>
21.329 +</tr>
21.330 +
21.331 +<tr>
21.332 + <th>ER</th>
21.333 + <th>1</th>
21.334 + <th>M_ameriflux_er</th>
21.335 +</tr>
21.336 +
21.337 +<tr>
21.338 + <th rowspan=4>Transient Dynamics</th>
21.339 + <th>Beta factor for NPP Stimulation from elevated CO2</th>
21.340 + <th>--</th>
21.341 + <th>
21.342 + <a href=./beta/table_station.html>
21.343 + FACE_Site_comparison</a> <br>
21.344 + <a href=./beta/table_biome.html>
21.345 + biome_table</a>
21.346 + </th>
21.347 + <th>3</th>
21.348 + <th>M_beta</th>
21.349 +</tr>
21.350 +
21.351 +<tr>
21.352 + <th>Turnover times and pool sizes</th>
21.353 + <th>--</th>
21.354 + <th>
21.355 + <a href=./turnover/table_Leaf.html>
21.356 + Leaf</a> <br>
21.357 + <a href=./turnover/table_Wood.html>
21.358 + Wood</a> <br>
21.359 + <a href=./turnover/table_Fine_Root.html>
21.360 + Fine_Root</a> <br>
21.361 + <a href=./turnover/table_Litter.html>
21.362 + Litter</a> <br>
21.363 + <a href=./turnover/table_Coarse_Woody_Debris.html>
21.364 + Coarse_Woody_Debris</a> <br>
21.365 + <a href=./turnover/table_Soil.html>
21.366 + Soil</a>
21.367 + </th>
21.368 + <th>3</th>
21.369 + <th>--</th>
21.370 +</tr>
21.371 +
21.372 +<tr>
21.373 + <th>Carbon Sinks<br>(1990-2004)</th>
21.374 + <th>--</th>
21.375 +
21.376 + <th>
21.377 + <a href=./carbon_sink/table_per_m2.html>
21.378 + biome_mean</a> <br>
21.379 + <a href=./carbon_sink/table_per_biome.html>
21.380 + biome_total</a>
21.381 + </th>
21.382 +
21.383 + <th>2</th>
21.384 + <th>--</th>
21.385 +</tr>
21.386 +
21.387 +<tr>
21.388 + <th>Fire Variability</th>
21.389 + <th>--</th>
21.390 +
21.391 + <th>
21.392 + <a href=./fire/global_model_vs_ob.png>
21.393 + global_spatial_comparison</a> <br>
21.394 + <a href=./fire/table_fire.html>
21.395 + temporal_dynamics_(1997-2004)</a>
21.396 + </th>
21.397 +
21.398 + <th>2</th>
21.399 + <th>M_fire</th>
21.400 +</tr>
21.401 +
21.402 +<tr>
21.403 + <th bgcolor=DDDDDD> Total </th>
21.404 + <th colspan=3> </th>
21.405 + <th bgcolor=DDDDDD>100</th>
21.406 + <th bgcolor=DDDDDD>M_total</th>
21.407 +</tr>
21.408 +
21.409 +</table>
21.410 +<!----------------------------------------------------------------------------->
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/all/template_1-model/tablerows.html Mon Jan 26 22:08:20 2009 -0500
22.3 @@ -0,0 +1,13 @@
22.4 +<!----------------------------------------------------------------------------->
22.5 +<tr>
22.6 +<td align=center rowspan=4 > NPP</td>
22.7 +<td >Site observationn1</td>
22.8 +</tr>
22.9 +<tr>
22.10 +<td test3</td>
22.11 +</tr>
22.12 +<tr>
22.13 +<td >Site observationn2</td>
22.14 +<td >Site observationn3</td>
22.15 +<td >Site observationn4</td>
22.16 +<!----------------------------------------------------------------------------->
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/all/template_1-model_noCO2/index.html Mon Jan 26 22:08:20 2009 -0500
23.3 @@ -0,0 +1,16 @@
23.4 +<html>
23.5 +<head>
23.6 +<title> Score Sheet for CLAMP </title>
23.7 +<meta name="description" content="score CLAMP">
23.8 +<meta name="keywords" content="score BGC CLAMP CN CASA">
23.9 +<meta name="Authors" content="Jeff Lee">
23.10 +</head>
23.11 +
23.12 +<!----------------------------------------------------------------------------->
23.13 +<h2> <a href=http://www.climatemodeling.org/c-lamp/metrics4.pdf>CLAMP Score Sheet for Biogeochemical Model Evaluation</h2>
23.14 +<!----------------------------------------------------------------------------->
23.15 +
23.16 +<!--#include virtual="table.html"-->
23.17 +
23.18 +<!----------------------------------------------------------------------------->
23.19 +</html>
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2 +++ b/all/template_1-model_noCO2/table.html Mon Jan 26 22:08:20 2009 -0500
24.3 @@ -0,0 +1,404 @@
24.4 +
24.5 +<!----------------------------------------------------------------------------->
24.6 +<table border=1 cellspacing=0 cellpadding=3 width=100%>
24.7 +<tr>
24.8 + <th bgcolor=DDDDDD width=8% rowspan=2> Metric </th>
24.9 + <th bgcolor=DDDDDD rowspan=2> Metric <br> components</th>
24.10 + <th bgcolor=DDDDDD rowspan=2> Observations & <br> comparison protocol</th>
24.11 + <th bgcolor=DDDDDD rowspan=2> Model<br> model_name </th>
24.12 + <th bgcolor=DDDDDD colspan=2> Score (points) </th>
24.13 +</tr>
24.14 +<tr>
24.15 + <th width=6% bgcolor=DDDDDD> Full </th>
24.16 + <th width=6% bgcolor=DDDDDD> model_name </th>
24.17 +</tr>
24.18 +
24.19 +<tr>
24.20 + <th rowspan=6>NPP</th>
24.21 +
24.22 + <th rowspan=2>EMDI NPP <br> observations</th>
24.23 +
24.24 + <th>
24.25 + <a href=./npp/table_site81_ob.html>
24.26 + Class_A_table</a>
24.27 + </th>
24.28 +
24.29 + <th>
24.30 + <a href=./npp/table_site81_model_vs_ob.html>
24.31 + table</a> <br>
24.32 + <a href=./npp/scatter_model_vs_ob_81.png>
24.33 + scatter_plot</a>
24.34 + </th>
24.35 +
24.36 + <th>2.5</th>
24.37 + <th>M_npp_S81</th>
24.38 +</tr>
24.39 +
24.40 +<tr>
24.41 + <th>
24.42 + <a href=./npp/table_site933_ob.html>
24.43 + Class_B_table</a>
24.44 + </th>
24.45 +
24.46 + <th>
24.47 + <a href=./npp/table_site933_model_vs_ob.html>
24.48 + table</a> <br>
24.49 + <a href=./npp/scatter_model_vs_ob_933.png>
24.50 + scatter_plot</a>
24.51 + </th>
24.52 +
24.53 + <th>2.5</th>
24.54 + <th>M_npp_S933</th>
24.55 +</tr>
24.56 +
24.57 +<tr>
24.58 + <th rowspan=2>EMDI NPP<br>normalized by PPT</th>
24.59 +
24.60 + <th>
24.61 + <a href=./npp/histogram_ob_81.png>
24.62 + Class_A_histogram</a>
24.63 + </th>
24.64 +
24.65 + <th>
24.66 + <a href=./npp/histogram_model_vs_ob_81.png>
24.67 + Class_A_histogram</a>
24.68 + </th>
24.69 +
24.70 + <th>2.5</th>
24.71 + <th>M_npp_H81</th>
24.72 +</tr>
24.73 +
24.74 +<tr>
24.75 + <th>
24.76 + <a href=./npp/histogram_ob_933.png>
24.77 + Class_B_histogram</a>
24.78 + </th>
24.79 +
24.80 + <th>
24.81 + <a href=./npp/histogram_model_vs_ob_933.png>
24.82 + Class_B_histogram</a>
24.83 + </th>
24.84 +
24.85 + <th>2.5</th>
24.86 + <th>M_npp_H933</th>
24.87 +</tr>
24.88 +
24.89 +<tr>
24.90 + <th>Correlation with MODIS obs.</th>
24.91 +
24.92 + <th>
24.93 + <a href=./npp/global_ob.png>
24.94 + global_map</a>
24.95 + </th>
24.96 +
24.97 + <th>
24.98 + <a href=./npp/global_model.png>
24.99 + model_map</a> <br>
24.100 + <a href=./npp/global_model_vs_ob.png>
24.101 + model_vs_obs</a>
24.102 + </th>
24.103 +
24.104 + <th>5</th>
24.105 + <th>M_npp_G</th>
24.106 +</tr>
24.107 +
24.108 +<tr>
24.109 + <th>Correlation with MODIS-zonal mean</th>
24.110 +
24.111 + <th>
24.112 + <a href=./npp/zonal_ob.png>
24.113 + zonal_mean_obs</a>
24.114 + </th>
24.115 +
24.116 + <th>
24.117 + <a href=./npp/zonal_model_vs_ob.png>
24.118 + zonal_mean <br>model_vs_obs_plot</a>
24.119 + </th>
24.120 +
24.121 + <th>5</th>
24.122 + <th>M_npp_Z</th>
24.123 +</tr>
24.124 +
24.125 +<tr>
24.126 + <th rowspan=3>LAI</th>
24.127 +
24.128 + <th>MODIS Mean</th>
24.129 +
24.130 + <th>
24.131 + <a href=./lai/global_class_ob.png>
24.132 + land_class_obs</a> <br>
24.133 + <a href=./lai/global_class_model.png>
24.134 + land_class_model</a> <br>
24.135 + <a href=./lai/global_Mean_ob.png>
24.136 + global_map</a>
24.137 + </th>
24.138 +
24.139 + <th>
24.140 + <a href=./lai/table_model_vs_ob.html>
24.141 + model_vs_obs_table</a> <br>
24.142 + <a href=./lai/global_Mean_model.png>
24.143 + global_map</a> <br>
24.144 + <a href=./lai/global_Mean_model_vs_ob.png>
24.145 + model_vs_obs</a>
24.146 + </th>
24.147 +
24.148 + <th>5</th>
24.149 + <th>M_lai_Mean</th>
24.150 +</tr>
24.151 +
24.152 +<tr>
24.153 + <th>MODIS Maximum</th>
24.154 +
24.155 + <th>
24.156 + <a href=./lai/global_Max_ob.png>
24.157 + global_map</a>
24.158 + </th>
24.159 +
24.160 + <th>
24.161 + <a href=./lai/global_Max_model.png>
24.162 + global_map</a> <br>
24.163 + <a href=./lai/global_Max_model_vs_ob.png>
24.164 + model_vs_obs</a>
24.165 + </th>
24.166 +
24.167 + <th>5</th>
24.168 + <th>M_lai_Max</th>
24.169 +</tr>
24.170 +<tr>
24.171 + <th>MODIS Phase</th>
24.172 +
24.173 + <th>
24.174 + <a href=./lai/global_Phase_ob.png>
24.175 + global_map</a>
24.176 + </th>
24.177 +
24.178 + <th>
24.179 + <a href=./lai/global_Phase_model.png>
24.180 + global_map</a> <br>
24.181 + <a href=./lai/global_Phase_model_vs_ob.png>
24.182 + model_vs_obs</a>
24.183 + </th>
24.184 +
24.185 + <th>5</th>
24.186 + <th>M_lai_Phase</th>
24.187 +</tr>
24.188 +
24.189 +<tr>
24.190 + <th>CO2 <br> Seasonal <br> Cycle</th>
24.191 + <th>Comparison with NOAA observations <br> phase and amplitude</th>
24.192 +
24.193 + <th>--</th>
24.194 +
24.195 + <th>--</th>
24.196 +
24.197 + <th>20</th>
24.198 + <th>--</th>
24.199 +</tr>
24.200 +
24.201 +<tr>
24.202 + <th rowspan=2>Carbon<br> Stocks</th>
24.203 +
24.204 + <th>Aboveground live biomass <br> in South America</th>
24.205 +
24.206 + <th>
24.207 + <a href=./biomass/global_ob.png>
24.208 + obs_amazon</a>
24.209 + </th>
24.210 +
24.211 + <th>
24.212 + <a href=./biomass/global_model.png>
24.213 + model_amazon</a> <br>
24.214 + <a href=./biomass/global_model_vs_ob.png>
24.215 + model_vs_obs</a>
24.216 + </th>
24.217 +
24.218 + <th>5</th>
24.219 + <th>M_biomass</th>
24.220 +</tr>
24.221 +
24.222 +<tr>
24.223 +
24.224 + <th>Aboveground live <br> biomass <br> within Amazon Basin <br>(sum within Legal Amazon)</th>
24.225 +
24.226 + <th>
24.227 + <a href=./biomass/mask_ob.png>
24.228 + mask</a> <br>
24.229 + <a href=./biomass/global_mask_ob.png>
24.230 + obs_masked</a> <br>
24.231 + Sum_biomass_ob (Pg C)
24.232 + </th>
24.233 +
24.234 + <th>
24.235 + <a href=./biomass/global_mask_model.png>
24.236 + model_masked</a> <br>
24.237 + <a href=./biomass/global_mask_vs_ob.png>
24.238 + model_vs_obs</a> <br>
24.239 + Sum_biomass_mod (Pg C)
24.240 + </th>
24.241 +
24.242 + <th>5</th>
24.243 + <th>M_biomask</th>
24.244 +</tr>
24.245 +
24.246 +<tr>
24.247 + <th rowspan=4>Energy and<br>C Fluxes<br>from Fluxnet</th>
24.248 +
24.249 + <th>NEE</th>
24.250 +
24.251 + <th rowspan=4>
24.252 + <a href=./fluxnet/line_ob.html>
24.253 + line_plot</a>
24.254 + </th>
24.255 +
24.256 + <th rowspan=4>
24.257 + <a href=./fluxnet/score+line_vs_ob.html>
24.258 + model_vs_obs</a>
24.259 + </th>
24.260 +
24.261 + <th>5</th>
24.262 + <th>M_fluxnet_nee</th>
24.263 +</tr>
24.264 +
24.265 +<tr>
24.266 + <th>Net radiation</th>
24.267 + <th>5</th>
24.268 + <th>M_fluxnet_rad</th>
24.269 +</tr>
24.270 +
24.271 +<tr>
24.272 + <th>Latent heat</th>
24.273 + <th>5</th>
24.274 + <th>M_fluxnet_lh</th>
24.275 +</tr>
24.276 +
24.277 +<tr>
24.278 + <th>Sensible heat</th>
24.279 + <th>5</th>
24.280 + <th>M_fluxnet_sh</th>
24.281 +</tr>
24.282 +
24.283 +<tr>
24.284 + <th rowspan=6>Energy and<br>C Fluxes<br>from Ameriflux</th>
24.285 +
24.286 + <th>NEE</th>
24.287 +
24.288 + <th rowspan=6>
24.289 + <a href=./ameriflux/line_ob.html>
24.290 + line_plot</a>
24.291 + </th>
24.292 +
24.293 + <th rowspan=6>
24.294 + <a href=./ameriflux/score+line_vs_ob.html>
24.295 + model_vs_obs</a> <br>
24.296 + <a href=./ameriflux/tseries_vs_ob.html>
24.297 + timeseries_plot</a>
24.298 + </th>
24.299 +
24.300 + <th>1</th>
24.301 + <th>M_ameriflux_nee</th>
24.302 +</tr>
24.303 +
24.304 +<tr>
24.305 + <th>Shortwave Incoming</th>
24.306 + <th>1</th>
24.307 + <th>M_ameriflux_rad</th>
24.308 +</tr>
24.309 +
24.310 +<tr>
24.311 + <th>Latent heat</th>
24.312 + <th>1</th>
24.313 + <th>M_ameriflux_lh</th>
24.314 +</tr>
24.315 +
24.316 +<tr>
24.317 + <th>Sensible heat</th>
24.318 + <th>1</th>
24.319 + <th>M_ameriflux_sh</th>
24.320 +</tr>
24.321 +
24.322 +<tr>
24.323 + <th>GPP</th>
24.324 + <th>1</th>
24.325 + <th>M_ameriflux_gpp</th>
24.326 +</tr>
24.327 +
24.328 +<tr>
24.329 + <th>ER</th>
24.330 + <th>1</th>
24.331 + <th>M_ameriflux_er</th>
24.332 +</tr>
24.333 +
24.334 +<tr>
24.335 + <th rowspan=4>Transient Dynamics</th>
24.336 + <th>Beta factor for NPP Stimulation from elevated CO2</th>
24.337 + <th>--</th>
24.338 + <th>
24.339 + <a href=./beta/table_station.html>
24.340 + FACE_Site_comparison</a> <br>
24.341 + <a href=./beta/table_biome.html>
24.342 + biome_table</a>
24.343 + </th>
24.344 + <th>3</th>
24.345 + <th>M_beta</th>
24.346 +</tr>
24.347 +
24.348 +<tr>
24.349 + <th>Turnover times and pool sizes</th>
24.350 + <th>--</th>
24.351 + <th>
24.352 + <a href=./turnover/table_Leaf.html>
24.353 + Leaf</a> <br>
24.354 + <a href=./turnover/table_Wood.html>
24.355 + Wood</a> <br>
24.356 + <a href=./turnover/table_Fine_Root.html>
24.357 + Fine_Root</a> <br>
24.358 + <a href=./turnover/table_Litter.html>
24.359 + Litter</a> <br>
24.360 + <a href=./turnover/table_Coarse_Woody_Debris.html>
24.361 + Coarse_Woody_Debris</a> <br>
24.362 + <a href=./turnover/table_Soil.html>
24.363 + Soil</a>
24.364 + </th>
24.365 + <th>3</th>
24.366 + <th>--</th>
24.367 +</tr>
24.368 +
24.369 +<tr>
24.370 + <th>Carbon Sinks<br>(1990-2004)</th>
24.371 + <th>--</th>
24.372 +
24.373 + <th>
24.374 + <a href=./carbon_sink/table_per_m2.html>
24.375 + biome_mean</a> <br>
24.376 + <a href=./carbon_sink/table_per_biome.html>
24.377 + biome_total</a>
24.378 + </th>
24.379 +
24.380 + <th>2</th>
24.381 + <th>--</th>
24.382 +</tr>
24.383 +
24.384 +<tr>
24.385 + <th>Fire Variability</th>
24.386 + <th>--</th>
24.387 +
24.388 + <th>
24.389 + <a href=./fire/global_model_vs_ob.png>
24.390 + global_spatial_comparison</a> <br>
24.391 + <a href=./fire/table_fire.html>
24.392 + temporal_dynamics_(1997-2004)</a>
24.393 + </th>
24.394 +
24.395 + <th>2</th>
24.396 + <th>M_fire</th>
24.397 +</tr>
24.398 +
24.399 +<tr>
24.400 + <th bgcolor=DDDDDD> Total </th>
24.401 + <th colspan=3> </th>
24.402 + <th bgcolor=DDDDDD>100</th>
24.403 + <th bgcolor=DDDDDD>M_total</th>
24.404 +</tr>
24.405 +
24.406 +</table>
24.407 +<!----------------------------------------------------------------------------->
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/all/template_1-model_noCO2/tablerows.html Mon Jan 26 22:08:20 2009 -0500
25.3 @@ -0,0 +1,13 @@
25.4 +<!----------------------------------------------------------------------------->
25.5 +<tr>
25.6 +<td align=center rowspan=4 > NPP</td>
25.7 +<td >Site observationn1</td>
25.8 +</tr>
25.9 +<tr>
25.10 +<td test3</td>
25.11 +</tr>
25.12 +<tr>
25.13 +<td >Site observationn2</td>
25.14 +<td >Site observationn3</td>
25.15 +<td >Site observationn4</td>
25.16 +<!----------------------------------------------------------------------------->
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/all/template_2-model/index.html Mon Jan 26 22:08:20 2009 -0500
26.3 @@ -0,0 +1,16 @@
26.4 +<html>
26.5 +<head>
26.6 +<title> Score Sheet for CLAMP </title>
26.7 +<meta name="description" content="score CLAMP">
26.8 +<meta name="keywords" content="score BGC CLAMP CN CASA">
26.9 +<meta name="Authors" content="Jeff Lee">
26.10 +</head>
26.11 +
26.12 +<!----------------------------------------------------------------------------->
26.13 +<h2> <a href=http://www.climatemodeling.org/c-lamp/metrics4.pdf>CLAMP Score Sheet for Biogeochemical Model Evaluation</h2>
26.14 +<!----------------------------------------------------------------------------->
26.15 +
26.16 +<!--#include virtual="table.html"-->
26.17 +
26.18 +<!----------------------------------------------------------------------------->
26.19 +</html>
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
27.2 +++ b/all/template_2-model/table.html Mon Jan 26 22:08:20 2009 -0500
27.3 @@ -0,0 +1,559 @@
27.4 +
27.5 +<!----------------------------------------------------------------------------->
27.6 +<table border=1 cellspacing=0 cellpadding=3 width=100%>
27.7 +<tr>
27.8 + <th bgcolor=DDDDDD width=8% rowspan=2> Metric </th>
27.9 + <th bgcolor=DDDDDD rowspan=2> Metric <br> components</th>
27.10 + <th bgcolor=DDDDDD rowspan=2> Observations & <br> comparison protocol</th>
27.11 + <th bgcolor=DDDDDD rowspan=2> Model<br> model1 </th>
27.12 + <th bgcolor=DDDDDD rowspan=2> Model<br> model2 </th>
27.13 + <th bgcolor=DDDDDD colspan=3> Score (points) </th>
27.14 +</tr>
27.15 +<tr>
27.16 + <th width=6% bgcolor=DDDDDD> Full </th>
27.17 + <th width=6% bgcolor=DDDDDD> model1 </th>
27.18 + <th width=6% bgcolor=DDDDDD> model2 </th>
27.19 +</tr>
27.20 +
27.21 +<tr>
27.22 + <th rowspan=6>NPP</th>
27.23 +
27.24 + <th rowspan=2>EMDI NPP <br> observations</th>
27.25 +
27.26 + <th>
27.27 + <a href=../model1/npp/table_site81_ob.html>
27.28 + Class_A_table</a>
27.29 + </th>
27.30 +
27.31 + <th>
27.32 + <a href=../model1/npp/table_site81_model_vs_ob.html>
27.33 + table</a> <br>
27.34 + <a href=../model1/npp/scatter_model_vs_ob_81.png>
27.35 + scatter_plot</a>
27.36 + </th>
27.37 +
27.38 + <th>
27.39 + <a href=../model2/npp/table_site81_model_vs_ob.html>
27.40 + table</a> <br>
27.41 + <a href=../model2/npp/scatter_model_vs_ob_81.png>
27.42 + scatter_plot</a>
27.43 + </th>
27.44 +
27.45 + <th>2.5</th>
27.46 + <th>M_npp_S81</th>
27.47 + <th>M_npp_S81</th>
27.48 +</tr>
27.49 +
27.50 +<tr>
27.51 + <th>
27.52 + <a href=../model1/npp/table_site933_ob.html>
27.53 + Class_B_table</a>
27.54 + </th>
27.55 +
27.56 + <th>
27.57 + <a href=../model1/npp/table_site933_model_vs_ob.html>
27.58 + table</a> <br>
27.59 + <a href=../model1/npp/scatter_model_vs_ob_933.png>
27.60 + scatter_plot</a>
27.61 + </th>
27.62 +
27.63 + <th>
27.64 + <a href=../model2/npp/table_site933_model_vs_ob.html>
27.65 + table</a> <br>
27.66 + <a href=../model2/npp/scatter_model_vs_ob_933.png>
27.67 + scatter_plot</a>
27.68 + </th>
27.69 +
27.70 + <th>2.5</th>
27.71 + <th>M_npp_S933</th>
27.72 + <th>M_npp_S933</th>
27.73 +</tr>
27.74 +
27.75 +<tr>
27.76 + <th rowspan=2>EMDI NPP <br> normalized by PPT</th>
27.77 +
27.78 + <th>
27.79 + <a href=../model1/npp/histogram_ob_81.png>
27.80 + Class_A_histogram</a>
27.81 + </th>
27.82 +
27.83 + <th>
27.84 + <a href=../model1/npp/histogram_model_vs_ob_81.png>
27.85 + Class_A_histogram</a>
27.86 + </th>
27.87 +
27.88 + <th>
27.89 + <a href=../model2/npp/histogram_model_vs_ob_81.png>
27.90 + Class_A_histogram</a>
27.91 + </th>
27.92 +
27.93 + <th>2.5</th>
27.94 + <th>M_npp_H81</th>
27.95 + <th>M_npp_H81</th>
27.96 +</tr>
27.97 +
27.98 +<tr>
27.99 + <th>
27.100 + <a href=../model1/npp/histogram_ob_933.png>
27.101 + Class_B_histogram</a>
27.102 + </th>
27.103 +
27.104 + <th>
27.105 + <a href=../model1/npp/histogram_model_vs_ob_933.png>
27.106 + Class_B_histogram</a>
27.107 + </th>
27.108 +
27.109 + <th>
27.110 + <a href=../model2/npp/histogram_model_vs_ob_933.png>
27.111 + Class_B_histogram</a>
27.112 + </th>
27.113 +
27.114 + <th>2.5</th>
27.115 + <th>M_npp_H933</th>
27.116 + <th>M_npp_H933</th>
27.117 +</tr>
27.118 +
27.119 +<tr>
27.120 + <th>Correlation with MODIS obs.</th>
27.121 +
27.122 + <th>
27.123 + <a href=../model1/npp/global_ob.png>
27.124 + global_map</a>
27.125 + </th>
27.126 +
27.127 + <th>
27.128 + <a href=../model1/npp/global_model.png>
27.129 + model_map</a> <br>
27.130 + <a href=../model1/npp/global_model_vs_ob.png>
27.131 + model_vs_obs</a>
27.132 + </th>
27.133 +
27.134 + <th>
27.135 + <a href=../model2/npp/global_model.png>
27.136 + model_map</a> <br>
27.137 + <a href=../model2/npp/global_model_vs_ob.png>
27.138 + model_vs_obs</a>
27.139 + </th>
27.140 +
27.141 + <th>5</th>
27.142 + <th>M_npp_G</th>
27.143 + <th>M_npp_G</th>
27.144 +</tr>
27.145 +
27.146 +<tr>
27.147 + <th>Correlation with MODIS-zonal mean</th>
27.148 +
27.149 + <th>
27.150 + <a href=../model1/npp/zonal_ob.png>
27.151 + zonal_mean_obs</a>
27.152 + </th>
27.153 +
27.154 + <th>
27.155 + <a href=../model1/npp/zonal_model_vs_ob.png>
27.156 + zonal_mean <br> model_vs_obs_plot</a>
27.157 + </th>
27.158 +
27.159 + <th>
27.160 + <a href=../model2/npp/zonal_model_vs_ob.png>
27.161 + zonal_mean <br> model_vs_obs_plot</a>
27.162 + </th>
27.163 +
27.164 + <th>5</th>
27.165 + <th>M_npp_Z</th>
27.166 + <th>M_npp_Z</th>
27.167 +</tr>
27.168 +
27.169 +<tr>
27.170 + <th rowspan=3>LAI</th>
27.171 +
27.172 + <th>MODIS Mean</th>
27.173 +
27.174 + <th>
27.175 + <a href=../model1/lai/global_class_ob.png>
27.176 + land_class_obs</a> <br>
27.177 + <a href=../model1/lai/global_class_model.png>
27.178 + land_class_model</a> <br>
27.179 + <a href=../model1/lai/global_Mean_ob.png>
27.180 + global_map</a>
27.181 + </th>
27.182 +
27.183 + <th>
27.184 + <a href=../model1/lai/table_model_vs_ob.html>
27.185 + model_vs_obs_table</a> <br>
27.186 + <a href=../model1/lai/global_Mean_model.png>
27.187 + global_map</a> <br>
27.188 + <a href=../model1/lai/global_Mean_model_vs_ob.png>
27.189 + model_vs_obs</a>
27.190 + </th>
27.191 +
27.192 + <th>
27.193 + <a href=../model2/lai/table_model_vs_ob.html>
27.194 + model_vs_obs_table</a> <br>
27.195 + <a href=../model2/lai/global_Mean_model.png>
27.196 + global_map</a> <br>
27.197 + <a href=../model2/lai/global_Mean_model_vs_ob.png>
27.198 + model_vs_obs</a>
27.199 + </th>
27.200 +
27.201 + <th>5</th>
27.202 + <th>M_lai_Mean</th>
27.203 + <th>M_lai_Mean</th>
27.204 +</tr>
27.205 +
27.206 +<tr>
27.207 + <th>MODIS Maximum</th>
27.208 +
27.209 + <th>
27.210 + <a href=../model1/lai/global_Max_ob.png>
27.211 + global_map</a>
27.212 + </th>
27.213 +
27.214 + <th>
27.215 + <a href=../model1/lai/global_Max_model.png>
27.216 + global_map</a> <br>
27.217 + <a href=../model1/lai/global_Max_model_vs_ob.png>
27.218 + model_vs_obs</a>
27.219 + </th>
27.220 +
27.221 + <th>
27.222 + <a href=../model2/lai/global_Max_model.png>
27.223 + global_map</a> <br>
27.224 + <a href=../model2/lai/global_Max_model_vs_ob.png>
27.225 + model_vs_obs</a>
27.226 + </th>
27.227 +
27.228 + <th>5</th>
27.229 + <th>M_lai_Max</th>
27.230 + <th>M_lai_Max</th>
27.231 +</tr>
27.232 +<tr>
27.233 + <th>MODIS Phase</th>
27.234 +
27.235 + <th>
27.236 + <a href=../model1/lai/global_Phase_ob.png>
27.237 + global_map</a>
27.238 + </th>
27.239 +
27.240 + <th>
27.241 + <a href=../model1/lai/global_Phase_model.png>
27.242 + global_map</a> <br>
27.243 + <a href=../model1/lai/global_Phase_model_vs_ob.png>
27.244 + model_vs_obs</a>
27.245 + </th>
27.246 +
27.247 + <th>
27.248 + <a href=../model2/lai/global_Phase_model.png>
27.249 + global_map</a> <br>
27.250 + <a href=../model2/lai/global_Phase_model_vs_ob.png>
27.251 + model_vs_obs</a>
27.252 + </th>
27.253 +
27.254 + <th>5</th>
27.255 + <th>M_lai_Phase</th>
27.256 + <th>M_lai_Phase</th>
27.257 +</tr>
27.258 +
27.259 +<tr>
27.260 + <th>CO2<br> Seasonal<br> Cycle</th>
27.261 + <th>Comparison with NOAA observations <br> phase and amplitude</th>
27.262 + <th>--</th>
27.263 +
27.264 + <th>
27.265 + <a href=../model1/co2/score+line_vs_ob.html>
27.266 + model_vs_obs</a>
27.267 + </th>
27.268 +
27.269 + <th>
27.270 + <a href=../model2/co2/score+line_vs_ob.html>
27.271 + model_vs_obs</a>
27.272 + </th>
27.273 +
27.274 + <th>20</th>
27.275 + <th>M_co2</th>
27.276 + <th>M_co2</th>
27.277 +</tr>
27.278 +
27.279 +<tr>
27.280 + <th rowspan=2>Carbon<br> Stocks</th>
27.281 +
27.282 + <th>Aboveground live biomass <br> in South America</th>
27.283 +
27.284 + <th>
27.285 + <a href=../model1/biomass/global_ob.png>
27.286 + obs_amazon</a>
27.287 + </th>
27.288 +
27.289 + <th>
27.290 + <a href=../model1/biomass/global_model.png>
27.291 + model_amazon</a> <br>
27.292 + <a href=../model1/biomass/global_model_vs_ob.png>
27.293 + model_vs_obs</a>
27.294 + </th>
27.295 +
27.296 + <th>
27.297 + <a href=../model2/biomass/global_model.png>
27.298 + amazon_map</a> <br>
27.299 + <a href=../model2/biomass/global_model_vs_ob.png>
27.300 + model_vs_obs</a>
27.301 + </th>
27.302 +
27.303 + <th>5</th>
27.304 + <th>M_biomass</th>
27.305 + <th>M_biomass</th>
27.306 +</tr>
27.307 +
27.308 +<tr>
27.309 + <th>Aboveground live <br> biomass <br> within Amazon Basin <br>(sum within Legal Amazon)</th>
27.310 + <th>
27.311 + <a href=../model1/biomass/mask_ob.png>
27.312 + mask</a> <br>
27.313 + <a href=../model1/biomass/global_mask_ob.png>
27.314 + obs_masked</a> <br>
27.315 + Sum_biomass_ob (Pg C)
27.316 + </th>
27.317 +
27.318 + <th>
27.319 + <a href=../model1/biomass/global_mask_model.png>
27.320 + model_masked</a> <br>
27.321 + <a href=../model1/biomass/global_mask_vs_ob.png>
27.322 + model_vs_obs</a> <br>
27.323 + Sum_biomass_mod (Pg C)
27.324 + </th>
27.325 +
27.326 + <th>
27.327 + <a href=../model2/biomass/global_mask_model.png>
27.328 + model_masked</a> <br>
27.329 + <a href=../model2/biomass/global_mask_vs_ob.png>
27.330 + model_vs_obs</a> <br>
27.331 + Sum_biomass_mod (Pg C)
27.332 + </th>
27.333 +
27.334 + <th>5</th>
27.335 + <th>M_biomask</th>
27.336 + <th>M_biomask</th>
27.337 +</tr>
27.338 +
27.339 +<tr>
27.340 + <th rowspan=4>Energy and<br>C Fluxes<br>from Fluxnet</th>
27.341 +
27.342 + <th>NEE</th>
27.343 +
27.344 + <th rowspan=4>
27.345 + <a href=../model1/fluxnet/line_ob.html>
27.346 + line_plot</a>
27.347 + </th>
27.348 +
27.349 + <th rowspan=4>
27.350 + <a href=../model1/fluxnet/score+line_vs_ob.html>
27.351 + model_vs_obs</a>
27.352 + </th>
27.353 +
27.354 + <th rowspan=4>
27.355 + <a href=../model2/fluxnet/score+line_vs_ob.html>
27.356 + model_vs_obs</a>
27.357 + </th>
27.358 +
27.359 + <th>5</th>
27.360 + <th>M_fluxnet_nee</th>
27.361 + <th>M_fluxnet_nee</th>
27.362 +</tr>
27.363 +
27.364 +<tr>
27.365 + <th>Net radiation</th>
27.366 + <th>5</th>
27.367 + <th>M_fluxnet_rad</th>
27.368 + <th>M_fluxnet_rad</th>
27.369 +</tr>
27.370 +
27.371 +<tr>
27.372 + <th>Latent heat</th>
27.373 + <th>5</th>
27.374 + <th>M_fluxnet_lh</th>
27.375 + <th>M_fluxnet_lh</th>
27.376 +</tr>
27.377 +
27.378 +<tr>
27.379 + <th>Sensible heat</th>
27.380 + <th>5</th>
27.381 + <th>M_fluxnet_sh</th>
27.382 + <th>M_fluxnet_sh</th>
27.383 +</tr>
27.384 +
27.385 +<tr>
27.386 + <th rowspan=6>Energy and<br>C Fluxes<br>from Ameriflux</th>
27.387 +
27.388 + <th>NEE</th>
27.389 +
27.390 + <th rowspan=6>
27.391 + <a href=../model1/ameriflux/line_ob.html>
27.392 + line_plot</a>
27.393 + </th>
27.394 +
27.395 + <th rowspan=6>
27.396 + <a href=../model1/ameriflux/score+line_vs_ob.html>
27.397 + model_vs_obs</a> <br>
27.398 + <a href=../model1/ameriflux/tseries_vs_ob.html>
27.399 + timeseries_plot</a>
27.400 + </th>
27.401 +
27.402 + <th rowspan=6>
27.403 + <a href=../model2/ameriflux/score+line_vs_ob.html>
27.404 + model_vs_obs</a> <br>
27.405 + <a href=../model2/ameriflux/tseries_vs_ob.html>
27.406 + timeseries_plot</a>
27.407 + </th>
27.408 +
27.409 + <th>1</th>
27.410 + <th>M_ameriflux_nee</th>
27.411 + <th>M_ameriflux_nee</th>
27.412 +</tr>
27.413 +
27.414 +<tr>
27.415 + <th>Shortwave Incoming</th>
27.416 + <th>1</th>
27.417 + <th>M_ameriflux_rad</th>
27.418 + <th>M_ameriflux_rad</th>
27.419 +</tr>
27.420 +
27.421 +<tr>
27.422 + <th>Latent heat</th>
27.423 + <th>1</th>
27.424 + <th>M_ameriflux_lh</th>
27.425 + <th>M_ameriflux_lh</th>
27.426 +</tr>
27.427 +
27.428 +<tr>
27.429 + <th>Sensible heat</th>
27.430 + <th>1</th>
27.431 + <th>M_ameriflux_sh</th>
27.432 + <th>M_ameriflux_sh</th>
27.433 +</tr>
27.434 +
27.435 +<tr>
27.436 + <th>GPP</th>
27.437 + <th>1</th>
27.438 + <th>M_ameriflux_gpp</th>
27.439 + <th>M_ameriflux_gpp</th>
27.440 +</tr>
27.441 +
27.442 +<tr>
27.443 + <th>ER</th>
27.444 + <th>1</th>
27.445 + <th>M_ameriflux_er</th>
27.446 + <th>M_ameriflux_er</th>
27.447 +</tr>
27.448 +
27.449 +<tr>
27.450 + <th rowspan=4>Transient Dynamics</th>
27.451 + <th>Beta factor for NPP Stimulation from elevated CO2</th>
27.452 + <th>--</th>
27.453 +
27.454 + <th>
27.455 + <a href=../model1/beta/table_station.html>
27.456 + FACE_Site_comparison</a> <br>
27.457 + <a href=../model1/beta/table_biome.html>
27.458 + biome_table</a>
27.459 + </th>
27.460 +
27.461 + <th>
27.462 + <a href=../model2/beta/table_station.html>
27.463 + FACE_Site_comparison</a> <br>
27.464 + <a href=../model2/beta/table_biome.html>
27.465 + biome_table</a>
27.466 + </th>
27.467 +
27.468 + <th>3</th>
27.469 + <th>M_beta</th>
27.470 + <th>M_beta</th>
27.471 +</tr>
27.472 +
27.473 +<tr>
27.474 + <th>Turnover times and pool sizes</th>
27.475 + <th>--</th>
27.476 +
27.477 + <th>
27.478 + <a href=../model1/turnover/table_Leaf.html>
27.479 + Leaf</a> <br>
27.480 + <a href=../model1/turnover/table_Wood.html>
27.481 + Wood</a> <br>
27.482 + <a href=../model1/turnover/table_Fine_Root.html>
27.483 + Fine_Root</a> <br>
27.484 + <a href=../model1/turnover/table_Litter.html>
27.485 + Litter</a> <br>
27.486 + <a href=../model1/turnover/table_Coarse_Woody_Debris.html>
27.487 + Coarse_Woody_Debris</a> <br>
27.488 + <a href=../model1/turnover/table_Soil.html>
27.489 + Soil</a>
27.490 + </th>
27.491 +
27.492 + <th>
27.493 + <a href=../model2/turnover/table_Leaf.html>
27.494 + Leaf</a> <br>
27.495 + <a href=../model2/turnover/table_Wood.html>
27.496 + Wood</a> <br>
27.497 + <a href=../model2/turnover/table_Fine_Root.html>
27.498 + Fine_Root</a> <br>
27.499 + <a href=../model2/turnover/table_Litter.html>
27.500 + Litter</a> <br>
27.501 + <a href=../model2/turnover/table_Coarse_Woody_Debris.html>
27.502 + Coarse_Woody_Debris</a> <br>
27.503 + <a href=../model2/turnover/table_Soil.html>
27.504 + Soil</a>
27.505 + </th>
27.506 +
27.507 + <th>3</th>
27.508 + <th>--</th>
27.509 + <th>--</th>
27.510 +</tr>
27.511 +
27.512 +<tr>
27.513 + <th>Carbon Sinks<br>(1990-2004)</th>
27.514 + <th>--</th>
27.515 +
27.516 + <th>
27.517 + <a href=../model1/carbon_sink/table_per_m2.html>
27.518 + biome_mean</a> <br>
27.519 + <a href=../model1/carbon_sink/table_per_biome.html>
27.520 + biome_total</a>
27.521 + </th>
27.522 +
27.523 + <th>
27.524 + <a href=../model2/carbon_sink/table_per_m2.html>
27.525 + biome_mean</a> <br>
27.526 + <a href=../model2/carbon_sink/table_per_biome.html>
27.527 + biome_total</a>
27.528 + </th>
27.529 +
27.530 + <th>2</th>
27.531 + <th>--</th>
27.532 + <th>--</th>
27.533 +</tr>
27.534 +
27.535 +<tr>
27.536 + <th>Fire Variability</th>
27.537 + <th>--</th>
27.538 +
27.539 + <th>
27.540 + <a href=../model1/fire/global_model_vs_ob.png>
27.541 + global_spatial_comparison</a> <br>
27.542 + <a href=../model1/fire/table_fire.html>
27.543 + temporal_dynamics_(1997-2004)</a>
27.544 + </th>
27.545 +
27.546 + <th>--</th>
27.547 +
27.548 + <th>2</th>
27.549 + <th>M_fire</th>
27.550 + <th>--</th>
27.551 +</tr>
27.552 +
27.553 +<tr>
27.554 + <th bgcolor=DDDDDD> Total </th>
27.555 + <th colspan=4> </th>
27.556 + <th bgcolor=DDDDDD>100</th>
27.557 + <th bgcolor=DDDDDD>M_total</th>
27.558 + <th bgcolor=DDDDDD>M_total</th>
27.559 +</tr>
27.560 +
27.561 +</table>
27.562 +<!----------------------------------------------------------------------------->
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
28.2 +++ b/all/template_2-model/tablerows.html Mon Jan 26 22:08:20 2009 -0500
28.3 @@ -0,0 +1,13 @@
28.4 +<!----------------------------------------------------------------------------->
28.5 +<tr>
28.6 +<td align=center rowspan=4 > NPP</td>
28.7 +<td >Site observationn1</td>
28.8 +</tr>
28.9 +<tr>
28.10 +<td test3</td>
28.11 +</tr>
28.12 +<tr>
28.13 +<td >Site observationn2</td>
28.14 +<td >Site observationn3</td>
28.15 +<td >Site observationn4</td>
28.16 +<!----------------------------------------------------------------------------->
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2 +++ b/all/template_2-model_noCO2/index.html Mon Jan 26 22:08:20 2009 -0500
29.3 @@ -0,0 +1,16 @@
29.4 +<html>
29.5 +<head>
29.6 +<title> Score Sheet for CLAMP </title>
29.7 +<meta name="description" content="score CLAMP">
29.8 +<meta name="keywords" content="score BGC CLAMP CN CASA">
29.9 +<meta name="Authors" content="Jeff Lee">
29.10 +</head>
29.11 +
29.12 +<!----------------------------------------------------------------------------->
29.13 +<h2> <a href=http://www.climatemodeling.org/c-lamp/metrics4.pdf>CLAMP Score Sheet for Biogeochemical Model Evaluation</h2>
29.14 +<!----------------------------------------------------------------------------->
29.15 +
29.16 +<!--#include virtual="table.html"-->
29.17 +
29.18 +<!----------------------------------------------------------------------------->
29.19 +</html>
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/all/template_2-model_noCO2/table.html Mon Jan 26 22:08:20 2009 -0500
30.3 @@ -0,0 +1,552 @@
30.4 +
30.5 +<!----------------------------------------------------------------------------->
30.6 +<table border=1 cellspacing=0 cellpadding=3 width=100%>
30.7 +<tr>
30.8 + <th bgcolor=DDDDDD width=8% rowspan=2> Metric </th>
30.9 + <th bgcolor=DDDDDD rowspan=2> Metric <br> components</th>
30.10 + <th bgcolor=DDDDDD rowspan=2> Observations & <br> comparison protocol</th>
30.11 + <th bgcolor=DDDDDD rowspan=2> Model<br> model1 </th>
30.12 + <th bgcolor=DDDDDD rowspan=2> Model<br> model2 </th>
30.13 + <th bgcolor=DDDDDD colspan=3> Score (points) </th>
30.14 +</tr>
30.15 +<tr>
30.16 + <th width=6% bgcolor=DDDDDD> Full </th>
30.17 + <th width=6% bgcolor=DDDDDD> model1 </th>
30.18 + <th width=6% bgcolor=DDDDDD> model2 </th>
30.19 +</tr>
30.20 +
30.21 +<tr>
30.22 + <th rowspan=6>NPP</th>
30.23 +
30.24 + <th rowspan=2>EMDI NPP <br> observations</th>
30.25 +
30.26 + <th>
30.27 + <a href=../model1/npp/table_site81_ob.html>
30.28 + Class_A_table</a>
30.29 + </th>
30.30 +
30.31 + <th>
30.32 + <a href=../model1/npp/table_site81_model_vs_ob.html>
30.33 + table</a> <br>
30.34 + <a href=../model1/npp/scatter_model_vs_ob_81.png>
30.35 + scatter_plot</a>
30.36 + </th>
30.37 +
30.38 + <th>
30.39 + <a href=../model2/npp/table_site81_model_vs_ob.html>
30.40 + table</a> <br>
30.41 + <a href=../model2/npp/scatter_model_vs_ob_81.png>
30.42 + scatter_plot</a>
30.43 + </th>
30.44 +
30.45 + <th>2.5</th>
30.46 + <th>M_npp_S81</th>
30.47 + <th>M_npp_S81</th>
30.48 +</tr>
30.49 +
30.50 +<tr>
30.51 + <th>
30.52 + <a href=../model1/npp/table_site933_ob.html>
30.53 + Class_B_table</a>
30.54 + </th>
30.55 +
30.56 + <th>
30.57 + <a href=../model1/npp/table_site933_model_vs_ob.html>
30.58 + table</a> <br>
30.59 + <a href=../model1/npp/scatter_model_vs_ob_933.png>
30.60 + scatter_plot</a>
30.61 + </th>
30.62 +
30.63 + <th>
30.64 + <a href=../model2/npp/table_site933_model_vs_ob.html>
30.65 + table</a> <br>
30.66 + <a href=../model2/npp/scatter_model_vs_ob_933.png>
30.67 + scatter_plot</a>
30.68 + </th>
30.69 +
30.70 + <th>2.5</th>
30.71 + <th>M_npp_S933</th>
30.72 + <th>M_npp_S933</th>
30.73 +</tr>
30.74 +
30.75 +<tr>
30.76 + <th rowspan=2>EMDI NPP <br> normalized by PPT</th>
30.77 +
30.78 + <th>
30.79 + <a href=../model1/npp/histogram_ob_81.png>
30.80 + Class_A_histogram</a>
30.81 + </th>
30.82 +
30.83 + <th>
30.84 + <a href=../model1/npp/histogram_model_vs_ob_81.png>
30.85 + Class_A_histogram</a>
30.86 + </th>
30.87 +
30.88 + <th>
30.89 + <a href=../model2/npp/histogram_model_vs_ob_81.png>
30.90 + Class_A_histogram</a>
30.91 + </th>
30.92 +
30.93 + <th>2.5</th>
30.94 + <th>M_npp_H81</th>
30.95 + <th>M_npp_H81</th>
30.96 +</tr>
30.97 +
30.98 +<tr>
30.99 + <th>
30.100 + <a href=../model1/npp/histogram_ob_933.png>
30.101 + Class_B_histogram</a>
30.102 + </th>
30.103 +
30.104 + <th>
30.105 + <a href=../model1/npp/histogram_model_vs_ob_933.png>
30.106 + Class_B_histogram</a>
30.107 + </th>
30.108 +
30.109 + <th>
30.110 + <a href=../model2/npp/histogram_model_vs_ob_933.png>
30.111 + Class_B_histogram</a>
30.112 + </th>
30.113 +
30.114 + <th>2.5</th>
30.115 + <th>M_npp_H933</th>
30.116 + <th>M_npp_H933</th>
30.117 +</tr>
30.118 +
30.119 +<tr>
30.120 + <th>Correlation with MODIS obs.</th>
30.121 +
30.122 + <th>
30.123 + <a href=../model1/npp/global_ob.png>
30.124 + global_map</a>
30.125 + </th>
30.126 +
30.127 + <th>
30.128 + <a href=../model1/npp/global_model.png>
30.129 + model_map</a> <br>
30.130 + <a href=../model1/npp/global_model_vs_ob.png>
30.131 + model_vs_obs</a>
30.132 + </th>
30.133 +
30.134 + <th>
30.135 + <a href=../model2/npp/global_model.png>
30.136 + model_map</a> <br>
30.137 + <a href=../model2/npp/global_model_vs_ob.png>
30.138 + model_vs_obs</a>
30.139 + </th>
30.140 +
30.141 + <th>5</th>
30.142 + <th>M_npp_G</th>
30.143 + <th>M_npp_G</th>
30.144 +</tr>
30.145 +
30.146 +<tr>
30.147 + <th>Correlation with MODIS-zonal mean</th>
30.148 +
30.149 + <th>
30.150 + <a href=../model1/npp/zonal_ob.png>
30.151 + zonal_mean_obs</a>
30.152 + </th>
30.153 +
30.154 + <th>
30.155 + <a href=../model1/npp/zonal_model_vs_ob.png>
30.156 + zonal_mean <br> model_vs_obs_plot</a>
30.157 + </th>
30.158 +
30.159 + <th>
30.160 + <a href=../model2/npp/zonal_model_vs_ob.png>
30.161 + zonal_mean <br> model_vs_obs_plot</a>
30.162 + </th>
30.163 +
30.164 + <th>5</th>
30.165 + <th>M_npp_Z</th>
30.166 + <th>M_npp_Z</th>
30.167 +</tr>
30.168 +
30.169 +<tr>
30.170 + <th rowspan=3>LAI</th>
30.171 +
30.172 + <th>MODIS Mean</th>
30.173 +
30.174 + <th>
30.175 + <a href=../model1/lai/global_class_ob.png>
30.176 + land_class_obs</a> <br>
30.177 + <a href=../model1/lai/global_class_model.png>
30.178 + land_class_model</a> <br>
30.179 + <a href=../model1/lai/global_Mean_ob.png>
30.180 + global_map</a>
30.181 + </th>
30.182 +
30.183 + <th>
30.184 + <a href=../model1/lai/table_model_vs_ob.html>
30.185 + model_vs_obs_table</a> <br>
30.186 + <a href=../model1/lai/global_Mean_model.png>
30.187 + global_map</a> <br>
30.188 + <a href=../model1/lai/global_Mean_model_vs_ob.png>
30.189 + model_vs_obs</a>
30.190 + </th>
30.191 +
30.192 + <th>
30.193 + <a href=../model2/lai/table_model_vs_ob.html>
30.194 + model_vs_obs_table</a> <br>
30.195 + <a href=../model2/lai/global_Mean_model.png>
30.196 + global_map</a> <br>
30.197 + <a href=../model2/lai/global_Mean_model_vs_ob.png>
30.198 + model_vs_obs</a>
30.199 + </th>
30.200 +
30.201 + <th>5</th>
30.202 + <th>M_lai_Mean</th>
30.203 + <th>M_lai_Mean</th>
30.204 +</tr>
30.205 +
30.206 +<tr>
30.207 + <th>MODIS Maximum</th>
30.208 +
30.209 + <th>
30.210 + <a href=../model1/lai/global_Max_ob.png>
30.211 + global_map</a>
30.212 + </th>
30.213 +
30.214 + <th>
30.215 + <a href=../model1/lai/global_Max_model.png>
30.216 + global_map</a> <br>
30.217 + <a href=../model1/lai/global_Max_model_vs_ob.png>
30.218 + model_vs_obs</a>
30.219 + </th>
30.220 +
30.221 + <th>
30.222 + <a href=../model2/lai/global_Max_model.png>
30.223 + global_map</a> <br>
30.224 + <a href=../model2/lai/global_Max_model_vs_ob.png>
30.225 + model_vs_obs</a>
30.226 + </th>
30.227 +
30.228 + <th>5</th>
30.229 + <th>M_lai_Max</th>
30.230 + <th>M_lai_Max</th>
30.231 +</tr>
30.232 +<tr>
30.233 + <th>MODIS Phase</th>
30.234 +
30.235 + <th>
30.236 + <a href=../model1/lai/global_Phase_ob.png>
30.237 + global_map</a>
30.238 + </th>
30.239 +
30.240 + <th>
30.241 + <a href=../model1/lai/global_Phase_model.png>
30.242 + global_map</a> <br>
30.243 + <a href=../model1/lai/global_Phase_model_vs_ob.png>
30.244 + model_vs_obs</a>
30.245 + </th>
30.246 +
30.247 + <th>
30.248 + <a href=../model2/lai/global_Phase_model.png>
30.249 + global_map</a> <br>
30.250 + <a href=../model2/lai/global_Phase_model_vs_ob.png>
30.251 + model_vs_obs</a>
30.252 + </th>
30.253 +
30.254 + <th>5</th>
30.255 + <th>M_lai_Phase</th>
30.256 + <th>M_lai_Phase</th>
30.257 +</tr>
30.258 +
30.259 +<tr>
30.260 + <th>CO2<br> Seasonal<br> Cycle</th>
30.261 + <th>Comparison with NOAA observations <br> phase and amplitude</th>
30.262 + <th>--</th>
30.263 +
30.264 + <th>--</th>
30.265 + <th>--</th>
30.266 +
30.267 + <th>20</th>
30.268 + <th>--</th>
30.269 + <th>--</th>
30.270 +</tr>
30.271 +
30.272 +<tr>
30.273 + <th rowspan=2>Carbon<br> Stocks</th>
30.274 +
30.275 + <th>Aboveground live biomass <br> in South America</th>
30.276 +
30.277 + <th>
30.278 + <a href=../model1/biomass/global_ob.png>
30.279 + obs_amazon</a>
30.280 + </th>
30.281 +
30.282 + <th>
30.283 + <a href=../model1/biomass/global_model.png>
30.284 + model_amazon</a> <br>
30.285 + <a href=../model1/biomass/global_model_vs_ob.png>
30.286 + model_vs_obs</a>
30.287 + </th>
30.288 +
30.289 + <th>
30.290 + <a href=../model2/biomass/global_model.png>
30.291 + amazon_map</a> <br>
30.292 + <a href=../model2/biomass/global_model_vs_ob.png>
30.293 + model_vs_obs</a>
30.294 + </th>
30.295 +
30.296 + <th>5</th>
30.297 + <th>M_biomass</th>
30.298 + <th>M_biomass</th>
30.299 +</tr>
30.300 +
30.301 +<tr>
30.302 + <th>Aboveground live <br> biomass <br> within Amazon Basin <br>(sum within Legal Amazon)</th>
30.303 + <th>
30.304 + <a href=../model1/biomass/mask_ob.png>
30.305 + mask</a> <br>
30.306 + <a href=../model1/biomass/global_mask_ob.png>
30.307 + obs_masked</a> <br>
30.308 + Sum_biomass_ob (Pg C)
30.309 + </th>
30.310 +
30.311 + <th>
30.312 + <a href=../model1/biomass/global_mask_model.png>
30.313 + model_masked</a> <br>
30.314 + <a href=../model1/biomass/global_mask_vs_ob.png>
30.315 + model_vs_obs</a> <br>
30.316 + Sum_biomass_mod (Pg C)
30.317 + </th>
30.318 +
30.319 + <th>
30.320 + <a href=../model2/biomass/global_mask_model.png>
30.321 + model_masked</a> <br>
30.322 + <a href=../model2/biomass/global_mask_vs_ob.png>
30.323 + model_vs_obs</a> <br>
30.324 + Sum_biomass_mod (Pg C)
30.325 + </th>
30.326 +
30.327 + <th>5</th>
30.328 + <th>M_biomask</th>
30.329 + <th>M_biomask</th>
30.330 +</tr>
30.331 +
30.332 +<tr>
30.333 + <th rowspan=4>Energy and<br>C Fluxes<br>from Fluxnet</th>
30.334 +
30.335 + <th>NEE</th>
30.336 +
30.337 + <th rowspan=4>
30.338 + <a href=../model1/fluxnet/line_ob.html>
30.339 + line_plot</a>
30.340 + </th>
30.341 +
30.342 + <th rowspan=4>
30.343 + <a href=../model1/fluxnet/score+line_vs_ob.html>
30.344 + model_vs_obs</a>
30.345 + </th>
30.346 +
30.347 + <th rowspan=4>
30.348 + <a href=../model2/fluxnet/score+line_vs_ob.html>
30.349 + model_vs_obs</a>
30.350 + </th>
30.351 +
30.352 + <th>5</th>
30.353 + <th>M_fluxnet_nee</th>
30.354 + <th>M_fluxnet_nee</th>
30.355 +</tr>
30.356 +
30.357 +<tr>
30.358 + <th>Net radiation</th>
30.359 + <th>5</th>
30.360 + <th>M_fluxnet_rad</th>
30.361 + <th>M_fluxnet_rad</th>
30.362 +</tr>
30.363 +
30.364 +<tr>
30.365 + <th>Latent heat</th>
30.366 + <th>5</th>
30.367 + <th>M_fluxnet_lh</th>
30.368 + <th>M_fluxnet_lh</th>
30.369 +</tr>
30.370 +
30.371 +<tr>
30.372 + <th>Sensible heat</th>
30.373 + <th>5</th>
30.374 + <th>M_fluxnet_sh</th>
30.375 + <th>M_fluxnet_sh</th>
30.376 +</tr>
30.377 +
30.378 +<tr>
30.379 + <th rowspan=6>Energy and<br>C Fluxes<br>from Ameriflux</th>
30.380 +
30.381 + <th>NEE</th>
30.382 +
30.383 + <th rowspan=6>
30.384 + <a href=../model1/ameriflux/line_ob.html>
30.385 + line_plot</a>
30.386 + </th>
30.387 +
30.388 + <th rowspan=6>
30.389 + <a href=../model1/ameriflux/score+line_vs_ob.html>
30.390 + model_vs_obs</a> <br>
30.391 + <a href=../model1/ameriflux/tseries_vs_ob.html>
30.392 + timeseries_plot</a>
30.393 + </th>
30.394 +
30.395 + <th rowspan=6>
30.396 + <a href=../model2/ameriflux/score+line_vs_ob.html>
30.397 + model_vs_obs</a> <br>
30.398 + <a href=../model2/ameriflux/tseries_vs_ob.html>
30.399 + timeseries_plot</a>
30.400 + </th>
30.401 +
30.402 + <th>1</th>
30.403 + <th>M_ameriflux_nee</th>
30.404 + <th>M_ameriflux_nee</th>
30.405 +</tr>
30.406 +
30.407 +<tr>
30.408 + <th>Shortwave Incoming</th>
30.409 + <th>1</th>
30.410 + <th>M_ameriflux_rad</th>
30.411 + <th>M_ameriflux_rad</th>
30.412 +</tr>
30.413 +
30.414 +<tr>
30.415 + <th>Latent heat</th>
30.416 + <th>1</th>
30.417 + <th>M_ameriflux_lh</th>
30.418 + <th>M_ameriflux_lh</th>
30.419 +</tr>
30.420 +
30.421 +<tr>
30.422 + <th>Sensible heat</th>
30.423 + <th>1</th>
30.424 + <th>M_ameriflux_sh</th>
30.425 + <th>M_ameriflux_sh</th>
30.426 +</tr>
30.427 +
30.428 +<tr>
30.429 + <th>GPP</th>
30.430 + <th>1</th>
30.431 + <th>M_ameriflux_gpp</th>
30.432 + <th>M_ameriflux_gpp</th>
30.433 +</tr>
30.434 +
30.435 +<tr>
30.436 + <th>ER</th>
30.437 + <th>1</th>
30.438 + <th>M_ameriflux_er</th>
30.439 + <th>M_ameriflux_er</th>
30.440 +</tr>
30.441 +
30.442 +<tr>
30.443 + <th rowspan=4>Transient Dynamics</th>
30.444 + <th>Beta factor for NPP Stimulation from elevated CO2</th>
30.445 + <th>--</th>
30.446 +
30.447 + <th>
30.448 + <a href=../model1/beta/table_station.html>
30.449 + FACE_Site_comparison</a> <br>
30.450 + <a href=../model1/beta/table_biome.html>
30.451 + biome_table</a>
30.452 + </th>
30.453 +
30.454 + <th>
30.455 + <a href=../model2/beta/table_station.html>
30.456 + FACE_Site_comparison</a> <br>
30.457 + <a href=../model2/beta/table_biome.html>
30.458 + biome_table</a>
30.459 + </th>
30.460 +
30.461 + <th>3</th>
30.462 + <th>M_beta</th>
30.463 + <th>M_beta</th>
30.464 +</tr>
30.465 +
30.466 +<tr>
30.467 + <th>Turnover times and pool sizes</th>
30.468 + <th>--</th>
30.469 +
30.470 + <th>
30.471 + <a href=../model1/turnover/table_Leaf.html>
30.472 + Leaf</a> <br>
30.473 + <a href=../model1/turnover/table_Wood.html>
30.474 + Wood</a> <br>
30.475 + <a href=../model1/turnover/table_Fine_Root.html>
30.476 + Fine_Root</a> <br>
30.477 + <a href=../model1/turnover/table_Litter.html>
30.478 + Litter</a> <br>
30.479 + <a href=../model1/turnover/table_Coarse_Woody_Debris.html>
30.480 + Coarse_Woody_Debris</a> <br>
30.481 + <a href=../model1/turnover/table_Soil.html>
30.482 + Soil</a>
30.483 + </th>
30.484 +
30.485 + <th>
30.486 + <a href=../model2/turnover/table_Leaf.html>
30.487 + Leaf</a> <br>
30.488 + <a href=../model2/turnover/table_Wood.html>
30.489 + Wood</a> <br>
30.490 + <a href=../model2/turnover/table_Fine_Root.html>
30.491 + Fine_Root</a> <br>
30.492 + <a href=../model2/turnover/table_Litter.html>
30.493 + Litter</a> <br>
30.494 + <a href=../model2/turnover/table_Coarse_Woody_Debris.html>
30.495 + Coarse_Woody_Debris</a> <br>
30.496 + <a href=../model2/turnover/table_Soil.html>
30.497 + Soil</a>
30.498 + </th>
30.499 +
30.500 + <th>3</th>
30.501 + <th>--</th>
30.502 + <th>--</th>
30.503 +</tr>
30.504 +
30.505 +<tr>
30.506 + <th>Carbon Sinks<br>(1990-2004)</th>
30.507 + <th>--</th>
30.508 +
30.509 + <th>
30.510 + <a href=../model1/carbon_sink/table_per_m2.html>
30.511 + biome_mean</a> <br>
30.512 + <a href=../model1/carbon_sink/table_per_biome.html>
30.513 + biome_total</a>
30.514 + </th>
30.515 +
30.516 + <th>
30.517 + <a href=../model2/carbon_sink/table_per_m2.html>
30.518 + biome_mean</a> <br>
30.519 + <a href=../model2/carbon_sink/table_per_biome.html>
30.520 + biome_total</a>
30.521 + </th>
30.522 +
30.523 + <th>2</th>
30.524 + <th>--</th>
30.525 + <th>--</th>
30.526 +</tr>
30.527 +
30.528 +<tr>
30.529 + <th>Fire Variability</th>
30.530 + <th>--</th>
30.531 +
30.532 + <th>
30.533 + <a href=../model1/fire/global_model_vs_ob.png>
30.534 + global_spatial_comparison</a> <br>
30.535 + <a href=../model1/fire/table_fire.html>
30.536 + temporal_dynamics_(1997-2004)</a>
30.537 + </th>
30.538 +
30.539 + <th>--</th>
30.540 +
30.541 + <th>2</th>
30.542 + <th>M_fire</th>
30.543 + <th>--</th>
30.544 +</tr>
30.545 +
30.546 +<tr>
30.547 + <th bgcolor=DDDDDD> Total </th>
30.548 + <th colspan=4> </th>
30.549 + <th bgcolor=DDDDDD>100</th>
30.550 + <th bgcolor=DDDDDD>M_total</th>
30.551 + <th bgcolor=DDDDDD>M_total</th>
30.552 +</tr>
30.553 +
30.554 +</table>
30.555 +<!----------------------------------------------------------------------------->
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2 +++ b/all/template_2-model_noCO2/tablerows.html Mon Jan 26 22:08:20 2009 -0500
31.3 @@ -0,0 +1,13 @@
31.4 +<!----------------------------------------------------------------------------->
31.5 +<tr>
31.6 +<td align=center rowspan=4 > NPP</td>
31.7 +<td >Site observationn1</td>
31.8 +</tr>
31.9 +<tr>
31.10 +<td test3</td>
31.11 +</tr>
31.12 +<tr>
31.13 +<td >Site observationn2</td>
31.14 +<td >Site observationn3</td>
31.15 +<td >Site observationn4</td>
31.16 +<!----------------------------------------------------------------------------->
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
32.2 +++ b/ameriflux/01.read_ascii.ncl Mon Jan 26 22:08:20 2009 -0500
32.3 @@ -0,0 +1,371 @@
32.4 +;----------------------------------------------------------------------
32.5 +; This example reads an ASCII file that is formatted a specific way, and
32.6 +; writes out the results to a netCDF file.
32.7 +;
32.8 +; The first line in the ASCII file must be a header, with each field
32.9 +; separated by a single character delimiter (like a ","). The rest of
32.10 +; the file must be such that each row contains all fields, each
32.11 +; separated by the designated delimiter.
32.12 +;
32.13 +; The fields can be integer, float, double, character, or string.
32.14 +; String fields cannot be written to a netCDF file. They have to
32.15 +; be read in as character arrays and written out that way.
32.16 +;----------------------------------------------------------------------
32.17 +
32.18 +;----------------------------------------------------------------------
32.19 +; This function returns the index locations of the given delimiter
32.20 +; in a row or several rows of strings.
32.21 +;----------------------------------------------------------------------
32.22 +function delim_indices(strings,nfields,delimiter)
32.23 +local cstrings, cdelim
32.24 +begin
32.25 + nrows = dimsizes(strings)
32.26 +;
32.27 +; Handle special case if we only have one string. Make sure it
32.28 +; is put into a 2D array.
32.29 +;
32.30 + if(nrows.eq.1) then
32.31 + cstrings = new((/1,strlen(strings)+1/),character)
32.32 + end if
32.33 +
32.34 + cstrings = stringtochar(strings) ; Convert to characters.
32.35 + cdelim = stringtochar(delimiter) ; Convert delimiter to character.
32.36 +;
32.37 +; Som error checking here. Make sure delimiter is one character.
32.38 +;
32.39 + nc = dimsizes(cdelim)
32.40 + rank = dimsizes(nc)
32.41 + if(rank.ne.1.or.(rank.eq.1.and.nc.ne.2)) then
32.42 + print("delim_indices: fatal: the delimiter you've selected")
32.43 + print("must be a single character. Can't continue.")
32.44 + exit
32.45 + end if
32.46 +
32.47 +;
32.48 +; Create array to hold indices of delimiter locations, and then loop
32.49 +; through each row and find all the delimiters. Make sure each row has
32.50 +; the correct number of delimiters.
32.51 +;
32.52 + ndelims = nfields-1
32.53 + cindices = new((/nrows,ndelims/),integer)
32.54 + do i = 0, nrows-1
32.55 + ii = ind(cstrings(i,:).eq.cdelim(0))
32.56 +;
32.57 +; Make sure there were delimiters on this row. If not, we just quit.
32.58 +; This could probably be modified to do this more gracefully.
32.59 +;
32.60 + if(any(ismissing(ii))) then
32.61 + print("delim_indices: fatal: I didn't find any delimiters")
32.62 + print("('" + delimiter + "') on row " + i + ". Can't continue.")
32.63 + exit
32.64 + end if
32.65 + if(dimsizes(ii).ne.ndelims) then
32.66 + print("delim_indices: fatal: I expected to find " + ndelims)
32.67 + print("delimiters on row " + i + ". Instead, I found " + dimsizes(ii) + ".")
32.68 + print("Can't continue.")
32.69 + exit
32.70 + end if
32.71 +
32.72 + cindices(i,:) = ii
32.73 +
32.74 + delete(ii) ; For next time through loop
32.75 + end do
32.76 +
32.77 + return(cindices)
32.78 +end
32.79 +
32.80 +;----------------------------------------------------------------------
32.81 +; This function reads in a particular field from a string array,
32.82 +; given the field number to read (fields start at #1 and go to #nfield),
32.83 +; and the indices of the delimiters.
32.84 +;
32.85 +; It returns either an integer, float, double, character, or a string,
32.86 +; depending on the input flag "return_type".
32.87 +;----------------------------------------------------------------------
32.88 +function read_field(strings,ifield,indices,return_type)
32.89 +local nstring, cstrings, nf, tmp_str
32.90 +begin
32.91 + nrows = dimsizes(strings)
32.92 +;
32.93 +; Handle special case if we only have one string. Make sure it
32.94 +; is put into a 2D array.
32.95 +;
32.96 + if(nrows.eq.1) then
32.97 + cstrings = new((/1,strlen(strings)+1/),character)
32.98 + end if
32.99 +
32.100 + cstrings = stringtochar(strings)
32.101 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
32.102 +
32.103 +;
32.104 +; Error checking. Make sure user has entered a valid field.
32.105 +;
32.106 + if(ifield.le.0.or.ifield.gt.nf) then
32.107 + print("read_field: fatal: you've selected a field that is")
32.108 + print("out-of-range of the number of fields that you have (" + nf + ").")
32.109 + exit
32.110 + end if
32.111 +
32.112 +;
32.113 +; Set up array to return. For string, int, float, or double arrays,
32.114 +; we don't have to do anything special. For character arrays,
32.115 +; however, we do.
32.116 +;
32.117 + if(return_type.ne."character") then
32.118 + return_array = new(nrows,return_type)
32.119 + else
32.120 +;
32.121 +; We don't know what the biggest character array is at this point, so
32.122 +; make it bigger than necessary, and then resize later as necessary.
32.123 +;
32.124 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
32.125 +
32.126 + max_len = 0 ; Use to keep track of max lengths of strings.
32.127 + end if
32.128 +
32.129 + do i = 0,nrows-1
32.130 +;
32.131 +; Special case of first field in row.
32.132 +;
32.133 + if(ifield.eq.1) then
32.134 + ibeg = 0
32.135 + iend = indices(i,ifield-1)-1
32.136 + else
32.137 +;
32.138 +; Special case of first field in row.
32.139 +;
32.140 + if(ifield.eq.nf) then
32.141 + ibeg = indices(i,ifield-2)+1
32.142 + iend = dimsizes(cstrings(i,:))-1
32.143 +;
32.144 +; Any field between first and last field.
32.145 +;
32.146 + else
32.147 + ibeg = indices(i,ifield-2)+1
32.148 + iend = indices(i,ifield-1)-1
32.149 + end if
32.150 + end if
32.151 +;
32.152 +; Here's the code that pulls off the correct string, and converts it
32.153 +; to float if desired.
32.154 +;
32.155 + if(return_type.eq."integer") then
32.156 + return_array(i) = stringtointeger(chartostring(cstrings(i,ibeg:iend)))
32.157 + end if
32.158 + if(return_type.eq."float") then
32.159 + return_array(i) = stringtofloat(chartostring(cstrings(i,ibeg:iend)))
32.160 + end if
32.161 + if(return_type.eq."double") then
32.162 + return_array(i) = stringtodouble(chartostring(cstrings(i,ibeg:iend)))
32.163 + end if
32.164 + if(return_type.eq."string") then
32.165 + return_array(i) = chartostring(cstrings(i,ibeg:iend))
32.166 + end if
32.167 + if(return_type.eq."character") then
32.168 + if( (iend-ibeg+1) .gt. max_len) then
32.169 + max_len = iend-ibeg+1
32.170 + end if
32.171 + tmp_return_array(i,0:iend-ibeg) = cstrings(i,ibeg:iend)
32.172 + end if
32.173 + end do
32.174 +
32.175 + if(return_type.eq."character") then
32.176 + return_array = new((/nrows,max_len/),"character")
32.177 + return_array = tmp_return_array(:,0:max_len-1)
32.178 + end if
32.179 +
32.180 + return(return_array)
32.181 +end
32.182 +
32.183 +
32.184 +;----------------------------------------------------------------------
32.185 +; This function reads in string fields only to get the maximum string
32.186 +; length.
32.187 +;----------------------------------------------------------------------
32.188 +function get_maxlen(strings,ifield,indices)
32.189 +local nstring, cstrings, nf, tmp_str
32.190 +begin
32.191 + nrows = dimsizes(strings)
32.192 +;
32.193 +; Handle special case if we only have one string. Make sure it
32.194 +; is put into a 2D array.
32.195 +;
32.196 + if(nrows.eq.1) then
32.197 + cstrings = new((/1,strlen(strings)+1/),character)
32.198 + end if
32.199 +
32.200 + cstrings = stringtochar(strings)
32.201 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
32.202 +
32.203 +;
32.204 +; Error checking. Make sure user has entered a valid field.
32.205 +;
32.206 + if(ifield.le.0.or.ifield.gt.nf) then
32.207 + print("read_field: fatal: you've selected a field that is")
32.208 + print("out-of-range of the number of fields that you have (" + nf + ").")
32.209 + exit
32.210 + end if
32.211 +;
32.212 +; We don't know what the biggest character array is at this point, so
32.213 +; make it bigger than necessary, and then resize later as necessary.
32.214 +;
32.215 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
32.216 +
32.217 + max_len = 0 ; Use to keep track of max lengths of strings.
32.218 +
32.219 + do i = 0,nrows-1
32.220 +;
32.221 +; Special case of first field in row.
32.222 +;
32.223 + if(ifield.eq.1) then
32.224 + ibeg = 0
32.225 + iend = indices(i,ifield-1)-1
32.226 + else
32.227 +;
32.228 +; Special case of first field in row.
32.229 +;
32.230 + if(ifield.eq.nf) then
32.231 + ibeg = indices(i,ifield-2)+1
32.232 + iend = dimsizes(cstrings(i,:))-1
32.233 +;
32.234 +; Any field between first and last field.
32.235 +;
32.236 + else
32.237 + ibeg = indices(i,ifield-2)+1
32.238 + iend = indices(i,ifield-1)-1
32.239 + end if
32.240 + end if
32.241 + if( (iend-ibeg+1) .gt. max_len) then
32.242 + max_len = iend-ibeg+1
32.243 + end if
32.244 + end do
32.245 +
32.246 + return(max_len)
32.247 +end
32.248 +
32.249 +;----------------------------------------------------------------------
32.250 +; Main code.
32.251 +;----------------------------------------------------------------------
32.252 +begin
32.253 +
32.254 +; Set up defaults here. We are hard-coding the field types here.
32.255 +; You can set up this script to try to determine the field types
32.256 +; automatically, but this is a bit tedious. Maybe later.
32.257 +
32.258 + station = "USHa1"
32.259 + year = 1991
32.260 + nfields = 30 ; # of fields
32.261 + delimiter = "," ; field delimiter
32.262 +
32.263 + filename = station+year+"_L4_m.txt" ; ASCII" file to read.
32.264 + cdf_file = station+year+"_L4_m.nc" ; netCDF file to write.
32.265 +
32.266 +; In this case, fields #2-#2 are integers,
32.267 +; and the rest of the fields are floats.
32.268 +
32.269 + var_types = new(nfields,string)
32.270 + var_strlens = new(nfields,integer) ; var to hold strlens, just in case.
32.271 +
32.272 + var_types = "float" ; Most are floats.
32.273 + var_types(0:1) = "integer"
32.274 +
32.275 + if(isfilepresent(cdf_file))
32.276 + print("Warning: '" + cdf_file + "' exists. Will remove it.")
32.277 + system("/bin/rm " + cdf_file)
32.278 + end if
32.279 +
32.280 +; Read in data as strings. This will create a string array that has the
32.281 +; same number of strings as there are rows in the file. We will then need
32.282 +; to parse each string later.
32.283 +
32.284 + read_data = asciiread(filename,-1,"string")
32.285 + header = read_data(0) ; Header. Use for variable names.
32.286 + data = read_data(1:) ; Get rid of first line which is a header.
32.287 + nrows = dimsizes(data) ; Number of rows.
32.288 +
32.289 +; Read in locations of delimiters in each string row.
32.290 +
32.291 + hindices = delim_indices(header,nfields,delimiter) ; header row
32.292 + dindices = delim_indices(data,nfields,delimiter) ; rest of file
32.293 +
32.294 + print (hindices)
32.295 + print (dindices)
32.296 +
32.297 +; Read in the field names which will become variable names on
32.298 +; the netCDF file.
32.299 +
32.300 + var_names = new(nfields,string)
32.301 +
32.302 + do i=0,nfields-1
32.303 + var_names(i) = read_field(header,i+1,hindices,"string")
32.304 + end do
32.305 +
32.306 +; Write out this netCDF file efficiently so it will be faster.
32.307 +; Try to predefine everything before you write to it.
32.308 +
32.309 + f = addfile(cdf_file,"c")
32.310 + setfileoption(f,"DefineMode",True) ; Enter predefine phase.
32.311 +
32.312 +; Write global attributes to file. It's okay to do this before
32.313 +; predefining the file's variables. We are still in "define" mode.
32.314 +
32.315 + fAtt = True
32.316 + fAtt@description = "Data read in from " + filename + " ASCII file."
32.317 + fAtt@creation_date = systemfunc ("date")
32.318 + fileattdef( f, fAtt )
32.319 +
32.320 +; Write dimension names to file. If there are no character variables,
32.321 +; then there's only one dimension name ("nvalues").
32.322 +
32.323 + nyear = -1
32.324 + nmonth = 12
32.325 +
32.326 + dim_names = (/ "year", "month" /)
32.327 + dim_sizes = (/ nyear , nmonth /)
32.328 + dimUnlim = (/ True , False /)
32.329 +
32.330 + filedimdef( f, dim_names, dim_sizes, dimUnlim )
32.331 +
32.332 +; Define each variable on the file.
32.333 +;
32.334 +; Don't deal with variable Month (i=0).
32.335 +
32.336 + do i=1,nfields-1
32.337 + filevardef(f, var_names(i), var_types(i), dim_names)
32.338 + end do
32.339 +
32.340 +; Loop through each field, read the values for that field, print
32.341 +; information about the variable, and then write it to the netCDF
32.342 +; file.
32.343 +
32.344 + do i=1,nfields-1
32.345 + ifield = i+1 ; Fields start at #1, not #0.
32.346 +
32.347 +; Note: you can't write strings to a netCDF file, so these have
32.348 +; to be written out as character arrays.
32.349 +
32.350 + tmp_data = new((/1,nmonth/),var_types(i))
32.351 +
32.352 + out_data = read_field(data,ifield,dindices,var_types(i))
32.353 +
32.354 + tmp_data(0,:) = out_data(:)
32.355 +
32.356 +; Print some info about the variable.
32.357 +
32.358 + print("")
32.359 + print("Writing variable '" + var_names(i) + "' (field #" + ifield + ").")
32.360 + print("Type is " + var_types(i) + ".")
32.361 + print("min/max = " + min(tmp_data) + "/" + max(tmp_data))
32.362 +
32.363 + if(any(ismissing(tmp_data))) then
32.364 + print("This variable does contain missing values.")
32.365 + else
32.366 + print("This variable doesn't contain missing values.")
32.367 + end if
32.368 +
32.369 + f->$var_names(i)$ = tmp_data ; Write to netCDF file.
32.370 +
32.371 + delete(tmp_data) ; Delete for next round.
32.372 + delete(out_data)
32.373 + end do
32.374 +end
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
33.2 +++ b/ameriflux/02.read_ascii.ncl Mon Jan 26 22:08:20 2009 -0500
33.3 @@ -0,0 +1,377 @@
33.4 +;----------------------------------------------------------------------
33.5 +; add year to output
33.6 +;
33.7 +; This example reads an ASCII file that is formatted a specific way, and
33.8 +; writes out the results to a netCDF file.
33.9 +;
33.10 +; The first line in the ASCII file must be a header, with each field
33.11 +; separated by a single character delimiter (like a ","). The rest of
33.12 +; the file must be such that each row contains all fields, each
33.13 +; separated by the designated delimiter.
33.14 +;
33.15 +; The fields can be integer, float, double, character, or string.
33.16 +; String fields cannot be written to a netCDF file. They have to
33.17 +; be read in as character arrays and written out that way.
33.18 +;----------------------------------------------------------------------
33.19 +
33.20 +;----------------------------------------------------------------------
33.21 +; This function returns the index locations of the given delimiter
33.22 +; in a row or several rows of strings.
33.23 +;----------------------------------------------------------------------
33.24 +function delim_indices(strings,nfields,delimiter)
33.25 +local cstrings, cdelim
33.26 +begin
33.27 + nrows = dimsizes(strings)
33.28 +;
33.29 +; Handle special case if we only have one string. Make sure it
33.30 +; is put into a 2D array.
33.31 +;
33.32 + if(nrows.eq.1) then
33.33 + cstrings = new((/1,strlen(strings)+1/),character)
33.34 + end if
33.35 +
33.36 + cstrings = stringtochar(strings) ; Convert to characters.
33.37 + cdelim = stringtochar(delimiter) ; Convert delimiter to character.
33.38 +;
33.39 +; Som error checking here. Make sure delimiter is one character.
33.40 +;
33.41 + nc = dimsizes(cdelim)
33.42 + rank = dimsizes(nc)
33.43 + if(rank.ne.1.or.(rank.eq.1.and.nc.ne.2)) then
33.44 + print("delim_indices: fatal: the delimiter you've selected")
33.45 + print("must be a single character. Can't continue.")
33.46 + exit
33.47 + end if
33.48 +
33.49 +;
33.50 +; Create array to hold indices of delimiter locations, and then loop
33.51 +; through each row and find all the delimiters. Make sure each row has
33.52 +; the correct number of delimiters.
33.53 +;
33.54 + ndelims = nfields-1
33.55 + cindices = new((/nrows,ndelims/),integer)
33.56 + do i = 0, nrows-1
33.57 + ii = ind(cstrings(i,:).eq.cdelim(0))
33.58 +;
33.59 +; Make sure there were delimiters on this row. If not, we just quit.
33.60 +; This could probably be modified to do this more gracefully.
33.61 +;
33.62 + if(any(ismissing(ii))) then
33.63 + print("delim_indices: fatal: I didn't find any delimiters")
33.64 + print("('" + delimiter + "') on row " + i + ". Can't continue.")
33.65 + exit
33.66 + end if
33.67 + if(dimsizes(ii).ne.ndelims) then
33.68 + print("delim_indices: fatal: I expected to find " + ndelims)
33.69 + print("delimiters on row " + i + ". Instead, I found " + dimsizes(ii) + ".")
33.70 + print("Can't continue.")
33.71 + exit
33.72 + end if
33.73 +
33.74 + cindices(i,:) = ii
33.75 +
33.76 + delete(ii) ; For next time through loop
33.77 + end do
33.78 +
33.79 + return(cindices)
33.80 +end
33.81 +
33.82 +;----------------------------------------------------------------------
33.83 +; This function reads in a particular field from a string array,
33.84 +; given the field number to read (fields start at #1 and go to #nfield),
33.85 +; and the indices of the delimiters.
33.86 +;
33.87 +; It returns either an integer, float, double, character, or a string,
33.88 +; depending on the input flag "return_type".
33.89 +;----------------------------------------------------------------------
33.90 +function read_field(strings,ifield,indices,return_type)
33.91 +local nstring, cstrings, nf, tmp_str
33.92 +begin
33.93 + nrows = dimsizes(strings)
33.94 +;
33.95 +; Handle special case if we only have one string. Make sure it
33.96 +; is put into a 2D array.
33.97 +;
33.98 + if(nrows.eq.1) then
33.99 + cstrings = new((/1,strlen(strings)+1/),character)
33.100 + end if
33.101 +
33.102 + cstrings = stringtochar(strings)
33.103 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
33.104 +
33.105 +;
33.106 +; Error checking. Make sure user has entered a valid field.
33.107 +;
33.108 + if(ifield.le.0.or.ifield.gt.nf) then
33.109 + print("read_field: fatal: you've selected a field that is")
33.110 + print("out-of-range of the number of fields that you have (" + nf + ").")
33.111 + exit
33.112 + end if
33.113 +
33.114 +;
33.115 +; Set up array to return. For string, int, float, or double arrays,
33.116 +; we don't have to do anything special. For character arrays,
33.117 +; however, we do.
33.118 +;
33.119 + if(return_type.ne."character") then
33.120 + return_array = new(nrows,return_type)
33.121 + else
33.122 +;
33.123 +; We don't know what the biggest character array is at this point, so
33.124 +; make it bigger than necessary, and then resize later as necessary.
33.125 +;
33.126 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
33.127 +
33.128 + max_len = 0 ; Use to keep track of max lengths of strings.
33.129 + end if
33.130 +
33.131 + do i = 0,nrows-1
33.132 +;
33.133 +; Special case of first field in row.
33.134 +;
33.135 + if(ifield.eq.1) then
33.136 + ibeg = 0
33.137 + iend = indices(i,ifield-1)-1
33.138 + else
33.139 +;
33.140 +; Special case of first field in row.
33.141 +;
33.142 + if(ifield.eq.nf) then
33.143 + ibeg = indices(i,ifield-2)+1
33.144 + iend = dimsizes(cstrings(i,:))-1
33.145 +;
33.146 +; Any field between first and last field.
33.147 +;
33.148 + else
33.149 + ibeg = indices(i,ifield-2)+1
33.150 + iend = indices(i,ifield-1)-1
33.151 + end if
33.152 + end if
33.153 +;
33.154 +; Here's the code that pulls off the correct string, and converts it
33.155 +; to float if desired.
33.156 +;
33.157 + if(return_type.eq."integer") then
33.158 + return_array(i) = stringtointeger(chartostring(cstrings(i,ibeg:iend)))
33.159 + end if
33.160 + if(return_type.eq."float") then
33.161 + return_array(i) = stringtofloat(chartostring(cstrings(i,ibeg:iend)))
33.162 + end if
33.163 + if(return_type.eq."double") then
33.164 + return_array(i) = stringtodouble(chartostring(cstrings(i,ibeg:iend)))
33.165 + end if
33.166 + if(return_type.eq."string") then
33.167 + return_array(i) = chartostring(cstrings(i,ibeg:iend))
33.168 + end if
33.169 + if(return_type.eq."character") then
33.170 + if( (iend-ibeg+1) .gt. max_len) then
33.171 + max_len = iend-ibeg+1
33.172 + end if
33.173 + tmp_return_array(i,0:iend-ibeg) = cstrings(i,ibeg:iend)
33.174 + end if
33.175 + end do
33.176 +
33.177 + if(return_type.eq."character") then
33.178 + return_array = new((/nrows,max_len/),"character")
33.179 + return_array = tmp_return_array(:,0:max_len-1)
33.180 + end if
33.181 +
33.182 + return(return_array)
33.183 +end
33.184 +
33.185 +
33.186 +;----------------------------------------------------------------------
33.187 +; This function reads in string fields only to get the maximum string
33.188 +; length.
33.189 +;----------------------------------------------------------------------
33.190 +function get_maxlen(strings,ifield,indices)
33.191 +local nstring, cstrings, nf, tmp_str
33.192 +begin
33.193 + nrows = dimsizes(strings)
33.194 +;
33.195 +; Handle special case if we only have one string. Make sure it
33.196 +; is put into a 2D array.
33.197 +;
33.198 + if(nrows.eq.1) then
33.199 + cstrings = new((/1,strlen(strings)+1/),character)
33.200 + end if
33.201 +
33.202 + cstrings = stringtochar(strings)
33.203 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
33.204 +
33.205 +;
33.206 +; Error checking. Make sure user has entered a valid field.
33.207 +;
33.208 + if(ifield.le.0.or.ifield.gt.nf) then
33.209 + print("read_field: fatal: you've selected a field that is")
33.210 + print("out-of-range of the number of fields that you have (" + nf + ").")
33.211 + exit
33.212 + end if
33.213 +;
33.214 +; We don't know what the biggest character array is at this point, so
33.215 +; make it bigger than necessary, and then resize later as necessary.
33.216 +;
33.217 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
33.218 +
33.219 + max_len = 0 ; Use to keep track of max lengths of strings.
33.220 +
33.221 + do i = 0,nrows-1
33.222 +;
33.223 +; Special case of first field in row.
33.224 +;
33.225 + if(ifield.eq.1) then
33.226 + ibeg = 0
33.227 + iend = indices(i,ifield-1)-1
33.228 + else
33.229 +;
33.230 +; Special case of first field in row.
33.231 +;
33.232 + if(ifield.eq.nf) then
33.233 + ibeg = indices(i,ifield-2)+1
33.234 + iend = dimsizes(cstrings(i,:))-1
33.235 +;
33.236 +; Any field between first and last field.
33.237 +;
33.238 + else
33.239 + ibeg = indices(i,ifield-2)+1
33.240 + iend = indices(i,ifield-1)-1
33.241 + end if
33.242 + end if
33.243 + if( (iend-ibeg+1) .gt. max_len) then
33.244 + max_len = iend-ibeg+1
33.245 + end if
33.246 + end do
33.247 +
33.248 + return(max_len)
33.249 +end
33.250 +
33.251 +;----------------------------------------------------------------------
33.252 +; Main code.
33.253 +;----------------------------------------------------------------------
33.254 +begin
33.255 +
33.256 +; Set up defaults here. We are hard-coding the field types here.
33.257 +; You can set up this script to try to determine the field types
33.258 +; automatically, but this is a bit tedious. Maybe later.
33.259 +
33.260 + station = "USHa1"
33.261 + year = 1991
33.262 + nfields = 30 ; # of fields
33.263 + delimiter = "," ; field delimiter
33.264 +
33.265 + filename = station+year+"_L4_m.txt" ; ASCII" file to read.
33.266 + cdf_file = station+year+"_L4_m.nc" ; netCDF file to write.
33.267 +
33.268 +; In this case, fields #2-#2 are integers,
33.269 +; and the rest of the fields are floats.
33.270 +
33.271 + var_types = new(nfields,string)
33.272 + var_strlens = new(nfields,integer) ; var to hold strlens, just in case.
33.273 +
33.274 + var_types = "float" ; Most are floats.
33.275 + var_types(0:1) = "integer"
33.276 +
33.277 + if(isfilepresent(cdf_file))
33.278 + print("Warning: '" + cdf_file + "' exists. Will remove it.")
33.279 + system("/bin/rm " + cdf_file)
33.280 + end if
33.281 +
33.282 +; Read in data as strings. This will create a string array that has the
33.283 +; same number of strings as there are rows in the file. We will then need
33.284 +; to parse each string later.
33.285 +
33.286 + read_data = asciiread(filename,-1,"string")
33.287 + header = read_data(0) ; Header. Use for variable names.
33.288 + data = read_data(1:) ; Get rid of first line which is a header.
33.289 + nrows = dimsizes(data) ; Number of rows.
33.290 +
33.291 +; Read in locations of delimiters in each string row.
33.292 +
33.293 + hindices = delim_indices(header,nfields,delimiter) ; header row
33.294 + dindices = delim_indices(data,nfields,delimiter) ; rest of file
33.295 +
33.296 + print (hindices)
33.297 + print (dindices)
33.298 +
33.299 +; Read in the field names which will become variable names on
33.300 +; the netCDF file.
33.301 +
33.302 + var_names = new(nfields,string)
33.303 +
33.304 + do i=0,nfields-1
33.305 + var_names(i) = read_field(header,i+1,hindices,"string")
33.306 + end do
33.307 +
33.308 +; Write out this netCDF file efficiently so it will be faster.
33.309 +; Try to predefine everything before you write to it.
33.310 +
33.311 + f = addfile(cdf_file,"c")
33.312 + setfileoption(f,"DefineMode",True) ; Enter predefine phase.
33.313 +
33.314 +; Write global attributes to file. It's okay to do this before
33.315 +; predefining the file's variables. We are still in "define" mode.
33.316 +
33.317 + fAtt = True
33.318 + fAtt@description = "Data read in from " + filename + " ASCII file."
33.319 + fAtt@creation_date = systemfunc ("date")
33.320 + fileattdef( f, fAtt )
33.321 +
33.322 +; Write dimension names to file. If there are no character variables,
33.323 +; then there's only one dimension name ("nvalues").
33.324 +
33.325 + nyear = -1
33.326 + nmonth = 12
33.327 +
33.328 + dim_names = (/ "year", "month" /)
33.329 + dim_sizes = (/ nyear , nmonth /)
33.330 + dimUnlim = (/ True , False /)
33.331 +
33.332 + filedimdef( f, dim_names, dim_sizes, dimUnlim )
33.333 +
33.334 +; Define each variable on the file.
33.335 +
33.336 + filevardef( f, "year", "integer", "year" )
33.337 +
33.338 +; Don't deal with variable Month (i=0).
33.339 +
33.340 + do i=1,nfields-1
33.341 + filevardef(f, var_names(i), var_types(i), dim_names)
33.342 + end do
33.343 +
33.344 +; Loop through each field, read the values for that field, print
33.345 +; information about the variable, and then write it to the netCDF
33.346 +; file.
33.347 +
33.348 + do i=1,nfields-1
33.349 + ifield = i+1 ; Fields start at #1, not #0.
33.350 +
33.351 +; Note: you can't write strings to a netCDF file, so these have
33.352 +; to be written out as character arrays.
33.353 +
33.354 + tmp_data = new((/1,nmonth/),var_types(i))
33.355 +
33.356 + out_data = read_field(data,ifield,dindices,var_types(i))
33.357 +
33.358 + tmp_data(0,:) = out_data(:)
33.359 +
33.360 +; Print some info about the variable.
33.361 +
33.362 + print("")
33.363 + print("Writing variable '" + var_names(i) + "' (field #" + ifield + ").")
33.364 + print("Type is " + var_types(i) + ".")
33.365 + print("min/max = " + min(tmp_data) + "/" + max(tmp_data))
33.366 +
33.367 + if(any(ismissing(tmp_data))) then
33.368 + print("This variable does contain missing values.")
33.369 + else
33.370 + print("This variable doesn't contain missing values.")
33.371 + end if
33.372 +
33.373 + f->$var_names(i)$ = tmp_data ; Write to netCDF file.
33.374 +
33.375 + delete(tmp_data) ; Delete for next round.
33.376 + delete(out_data)
33.377 + end do
33.378 +
33.379 + f->year = year
33.380 +end
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/ameriflux/03.read_ascii.ncl Mon Jan 26 22:08:20 2009 -0500
34.3 @@ -0,0 +1,387 @@
34.4 +;----------------------------------------------------------------------
34.5 +; add Month to output
34.6 +; add lat, lon to output
34.7 +; add year to output
34.8 +;
34.9 +; This example reads an ASCII file that is formatted a specific way, and
34.10 +; writes out the results to a netCDF file.
34.11 +;
34.12 +; The first line in the ASCII file must be a header, with each field
34.13 +; separated by a single character delimiter (like a ","). The rest of
34.14 +; the file must be such that each row contains all fields, each
34.15 +; separated by the designated delimiter.
34.16 +;
34.17 +; The fields can be integer, float, double, character, or string.
34.18 +; String fields cannot be written to a netCDF file. They have to
34.19 +; be read in as character arrays and written out that way.
34.20 +;----------------------------------------------------------------------
34.21 +
34.22 +;----------------------------------------------------------------------
34.23 +; This function returns the index locations of the given delimiter
34.24 +; in a row or several rows of strings.
34.25 +;----------------------------------------------------------------------
34.26 +function delim_indices(strings,nfields,delimiter)
34.27 +local cstrings, cdelim
34.28 +begin
34.29 + nrows = dimsizes(strings)
34.30 +;
34.31 +; Handle special case if we only have one string. Make sure it
34.32 +; is put into a 2D array.
34.33 +;
34.34 + if(nrows.eq.1) then
34.35 + cstrings = new((/1,strlen(strings)+1/),character)
34.36 + end if
34.37 +
34.38 + cstrings = stringtochar(strings) ; Convert to characters.
34.39 + cdelim = stringtochar(delimiter) ; Convert delimiter to character.
34.40 +;
34.41 +; Som error checking here. Make sure delimiter is one character.
34.42 +;
34.43 + nc = dimsizes(cdelim)
34.44 + rank = dimsizes(nc)
34.45 + if(rank.ne.1.or.(rank.eq.1.and.nc.ne.2)) then
34.46 + print("delim_indices: fatal: the delimiter you've selected")
34.47 + print("must be a single character. Can't continue.")
34.48 + exit
34.49 + end if
34.50 +
34.51 +;
34.52 +; Create array to hold indices of delimiter locations, and then loop
34.53 +; through each row and find all the delimiters. Make sure each row has
34.54 +; the correct number of delimiters.
34.55 +;
34.56 + ndelims = nfields-1
34.57 + cindices = new((/nrows,ndelims/),integer)
34.58 + do i = 0, nrows-1
34.59 + ii = ind(cstrings(i,:).eq.cdelim(0))
34.60 +;
34.61 +; Make sure there were delimiters on this row. If not, we just quit.
34.62 +; This could probably be modified to do this more gracefully.
34.63 +;
34.64 + if(any(ismissing(ii))) then
34.65 + print("delim_indices: fatal: I didn't find any delimiters")
34.66 + print("('" + delimiter + "') on row " + i + ". Can't continue.")
34.67 + exit
34.68 + end if
34.69 + if(dimsizes(ii).ne.ndelims) then
34.70 + print("delim_indices: fatal: I expected to find " + ndelims)
34.71 + print("delimiters on row " + i + ". Instead, I found " + dimsizes(ii) + ".")
34.72 + print("Can't continue.")
34.73 + exit
34.74 + end if
34.75 +
34.76 + cindices(i,:) = ii
34.77 +
34.78 + delete(ii) ; For next time through loop
34.79 + end do
34.80 +
34.81 + return(cindices)
34.82 +end
34.83 +
34.84 +;----------------------------------------------------------------------
34.85 +; This function reads in a particular field from a string array,
34.86 +; given the field number to read (fields start at #1 and go to #nfield),
34.87 +; and the indices of the delimiters.
34.88 +;
34.89 +; It returns either an integer, float, double, character, or a string,
34.90 +; depending on the input flag "return_type".
34.91 +;----------------------------------------------------------------------
34.92 +function read_field(strings,ifield,indices,return_type)
34.93 +local nstring, cstrings, nf, tmp_str
34.94 +begin
34.95 + nrows = dimsizes(strings)
34.96 +;
34.97 +; Handle special case if we only have one string. Make sure it
34.98 +; is put into a 2D array.
34.99 +;
34.100 + if(nrows.eq.1) then
34.101 + cstrings = new((/1,strlen(strings)+1/),character)
34.102 + end if
34.103 +
34.104 + cstrings = stringtochar(strings)
34.105 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
34.106 +
34.107 +;
34.108 +; Error checking. Make sure user has entered a valid field.
34.109 +;
34.110 + if(ifield.le.0.or.ifield.gt.nf) then
34.111 + print("read_field: fatal: you've selected a field that is")
34.112 + print("out-of-range of the number of fields that you have (" + nf + ").")
34.113 + exit
34.114 + end if
34.115 +
34.116 +;
34.117 +; Set up array to return. For string, int, float, or double arrays,
34.118 +; we don't have to do anything special. For character arrays,
34.119 +; however, we do.
34.120 +;
34.121 + if(return_type.ne."character") then
34.122 + return_array = new(nrows,return_type)
34.123 + else
34.124 +;
34.125 +; We don't know what the biggest character array is at this point, so
34.126 +; make it bigger than necessary, and then resize later as necessary.
34.127 +;
34.128 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
34.129 +
34.130 + max_len = 0 ; Use to keep track of max lengths of strings.
34.131 + end if
34.132 +
34.133 + do i = 0,nrows-1
34.134 +;
34.135 +; Special case of first field in row.
34.136 +;
34.137 + if(ifield.eq.1) then
34.138 + ibeg = 0
34.139 + iend = indices(i,ifield-1)-1
34.140 + else
34.141 +;
34.142 +; Special case of first field in row.
34.143 +;
34.144 + if(ifield.eq.nf) then
34.145 + ibeg = indices(i,ifield-2)+1
34.146 + iend = dimsizes(cstrings(i,:))-1
34.147 +;
34.148 +; Any field between first and last field.
34.149 +;
34.150 + else
34.151 + ibeg = indices(i,ifield-2)+1
34.152 + iend = indices(i,ifield-1)-1
34.153 + end if
34.154 + end if
34.155 +;
34.156 +; Here's the code that pulls off the correct string, and converts it
34.157 +; to float if desired.
34.158 +;
34.159 + if(return_type.eq."integer") then
34.160 + return_array(i) = stringtointeger(chartostring(cstrings(i,ibeg:iend)))
34.161 + end if
34.162 + if(return_type.eq."float") then
34.163 + return_array(i) = stringtofloat(chartostring(cstrings(i,ibeg:iend)))
34.164 + end if
34.165 + if(return_type.eq."double") then
34.166 + return_array(i) = stringtodouble(chartostring(cstrings(i,ibeg:iend)))
34.167 + end if
34.168 + if(return_type.eq."string") then
34.169 + return_array(i) = chartostring(cstrings(i,ibeg:iend))
34.170 + end if
34.171 + if(return_type.eq."character") then
34.172 + if( (iend-ibeg+1) .gt. max_len) then
34.173 + max_len = iend-ibeg+1
34.174 + end if
34.175 + tmp_return_array(i,0:iend-ibeg) = cstrings(i,ibeg:iend)
34.176 + end if
34.177 + end do
34.178 +
34.179 + if(return_type.eq."character") then
34.180 + return_array = new((/nrows,max_len/),"character")
34.181 + return_array = tmp_return_array(:,0:max_len-1)
34.182 + end if
34.183 +
34.184 + return(return_array)
34.185 +end
34.186 +
34.187 +
34.188 +;----------------------------------------------------------------------
34.189 +; This function reads in string fields only to get the maximum string
34.190 +; length.
34.191 +;----------------------------------------------------------------------
34.192 +function get_maxlen(strings,ifield,indices)
34.193 +local nstring, cstrings, nf, tmp_str
34.194 +begin
34.195 + nrows = dimsizes(strings)
34.196 +;
34.197 +; Handle special case if we only have one string. Make sure it
34.198 +; is put into a 2D array.
34.199 +;
34.200 + if(nrows.eq.1) then
34.201 + cstrings = new((/1,strlen(strings)+1/),character)
34.202 + end if
34.203 +
34.204 + cstrings = stringtochar(strings)
34.205 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
34.206 +
34.207 +;
34.208 +; Error checking. Make sure user has entered a valid field.
34.209 +;
34.210 + if(ifield.le.0.or.ifield.gt.nf) then
34.211 + print("read_field: fatal: you've selected a field that is")
34.212 + print("out-of-range of the number of fields that you have (" + nf + ").")
34.213 + exit
34.214 + end if
34.215 +;
34.216 +; We don't know what the biggest character array is at this point, so
34.217 +; make it bigger than necessary, and then resize later as necessary.
34.218 +;
34.219 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
34.220 +
34.221 + max_len = 0 ; Use to keep track of max lengths of strings.
34.222 +
34.223 + do i = 0,nrows-1
34.224 +;
34.225 +; Special case of first field in row.
34.226 +;
34.227 + if(ifield.eq.1) then
34.228 + ibeg = 0
34.229 + iend = indices(i,ifield-1)-1
34.230 + else
34.231 +;
34.232 +; Special case of first field in row.
34.233 +;
34.234 + if(ifield.eq.nf) then
34.235 + ibeg = indices(i,ifield-2)+1
34.236 + iend = dimsizes(cstrings(i,:))-1
34.237 +;
34.238 +; Any field between first and last field.
34.239 +;
34.240 + else
34.241 + ibeg = indices(i,ifield-2)+1
34.242 + iend = indices(i,ifield-1)-1
34.243 + end if
34.244 + end if
34.245 + if( (iend-ibeg+1) .gt. max_len) then
34.246 + max_len = iend-ibeg+1
34.247 + end if
34.248 + end do
34.249 +
34.250 + return(max_len)
34.251 +end
34.252 +
34.253 +;----------------------------------------------------------------------
34.254 +; Main code.
34.255 +;----------------------------------------------------------------------
34.256 +begin
34.257 +
34.258 +; Set up defaults here. We are hard-coding the field types here.
34.259 +; You can set up this script to try to determine the field types
34.260 +; automatically, but this is a bit tedious. Maybe later.
34.261 +
34.262 + station = "USHa1"
34.263 + lat = 42.5378
34.264 + lon = -72.1715 + 360.
34.265 + year = 1991
34.266 + nfields = 30 ; # of fields
34.267 + delimiter = "," ; field delimiter
34.268 +
34.269 + filename = station+year+"_L4_m.txt" ; ASCII" file to read.
34.270 + cdf_file = station+year+"_L4_m.nc" ; netCDF file to write.
34.271 +
34.272 +; In this case, fields #2-#2 are integers,
34.273 +; and the rest of the fields are floats.
34.274 +
34.275 + var_types = new(nfields,string)
34.276 + var_strlens = new(nfields,integer) ; var to hold strlens, just in case.
34.277 +
34.278 + var_types = "float" ; Most are floats.
34.279 + var_types(0:1) = "integer"
34.280 +
34.281 + if(isfilepresent(cdf_file))
34.282 + print("Warning: '" + cdf_file + "' exists. Will remove it.")
34.283 + system("/bin/rm " + cdf_file)
34.284 + end if
34.285 +
34.286 +; Read in data as strings. This will create a string array that has the
34.287 +; same number of strings as there are rows in the file. We will then need
34.288 +; to parse each string later.
34.289 +
34.290 + read_data = asciiread(filename,-1,"string")
34.291 + header = read_data(0) ; Header. Use for variable names.
34.292 + data = read_data(1:) ; Get rid of first line which is a header.
34.293 + nrows = dimsizes(data) ; Number of rows.
34.294 +
34.295 +; Read in locations of delimiters in each string row.
34.296 +
34.297 + hindices = delim_indices(header,nfields,delimiter) ; header row
34.298 + dindices = delim_indices(data,nfields,delimiter) ; rest of file
34.299 +
34.300 +; print (hindices)
34.301 +; print (dindices)
34.302 +
34.303 +; Read in the field names which will become variable names on
34.304 +; the netCDF file.
34.305 +
34.306 + var_names = new(nfields,string)
34.307 +
34.308 + do i=0,nfields-1
34.309 + var_names(i) = read_field(header,i+1,hindices,"string")
34.310 + end do
34.311 +
34.312 +; Write out this netCDF file efficiently so it will be faster.
34.313 +; Try to predefine everything before you write to it.
34.314 +
34.315 + f = addfile(cdf_file,"c")
34.316 + setfileoption(f,"DefineMode",True) ; Enter predefine phase.
34.317 +
34.318 +; Write global attributes to file. It's okay to do this before
34.319 +; predefining the file's variables. We are still in "define" mode.
34.320 +
34.321 + fAtt = True
34.322 + fAtt@description = "Data read in from " + filename + " ASCII file."
34.323 + fAtt@creation_date = systemfunc ("date")
34.324 + fileattdef( f, fAtt )
34.325 +
34.326 +; Write dimension names to file. If there are no character variables,
34.327 +; then there's only one dimension name ("nvalues").
34.328 +
34.329 + nyear = -1
34.330 + nmonth = 12
34.331 +
34.332 + dim_names = (/ "year", "month" /)
34.333 + dim_sizes = (/ nyear , nmonth /)
34.334 + dimUnlim = (/ True , False /)
34.335 +
34.336 + filedimdef( f, dim_names, dim_sizes, dimUnlim )
34.337 + filedimdef( f, "lat", 1, False )
34.338 + filedimdef( f, "lon", 1, False )
34.339 +
34.340 +; Define each variable on the file.
34.341 +
34.342 + filevardef( f, "year", "integer", "year" )
34.343 + filevardef( f, "lat" , "float" , "lat" )
34.344 + filevardef( f, "lon" , "float" , "lon" )
34.345 +
34.346 +; Don't deal with variable Month (i=0).
34.347 +
34.348 + do i=0,nfields-1
34.349 + filevardef(f, var_names(i), var_types(i), dim_names)
34.350 + end do
34.351 +
34.352 +; Loop through each field, read the values for that field, print
34.353 +; information about the variable, and then write it to the netCDF
34.354 +; file.
34.355 +
34.356 + do i=0,nfields-1
34.357 + ifield = i+1 ; Fields start at #1, not #0.
34.358 +
34.359 +; Note: you can't write strings to a netCDF file, so these have
34.360 +; to be written out as character arrays.
34.361 +
34.362 + tmp_data = new((/1,nmonth/),var_types(i))
34.363 +
34.364 + tmp_data(0,:) = read_field(data,ifield,dindices,var_types(i))
34.365 +
34.366 +; tmp_data(0,:) = out_data(:)
34.367 +
34.368 +; Print some info about the variable.
34.369 +
34.370 + print("")
34.371 + print("Writing variable '" + var_names(i) + "' (field #" + ifield + ").")
34.372 + print("Type is " + var_types(i) + ".")
34.373 + print("min/max = " + min(tmp_data) + "/" + max(tmp_data))
34.374 +
34.375 + if(any(ismissing(tmp_data))) then
34.376 + print("This variable does contain missing values.")
34.377 + else
34.378 + print("This variable doesn't contain missing values.")
34.379 + end if
34.380 +
34.381 + f->$var_names(i)$ = tmp_data ; Write to netCDF file.
34.382 +
34.383 + delete(tmp_data) ; Delete for next round.
34.384 +; delete(out_data)
34.385 + end do
34.386 +
34.387 + f->year = year
34.388 + f->lat = lat
34.389 + f->lon = lon
34.390 +end
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/ameriflux/04.read_ascii.ncl Mon Jan 26 22:08:20 2009 -0500
35.3 @@ -0,0 +1,391 @@
35.4 +;----------------------------------------------------------------------
35.5 +; change Month to yyyymm
35.6 +; add Month to output
35.7 +; add lat, lon to output
35.8 +; add year to output
35.9 +;
35.10 +; This example reads an ASCII file that is formatted a specific way, and
35.11 +; writes out the results to a netCDF file.
35.12 +;
35.13 +; The first line in the ASCII file must be a header, with each field
35.14 +; separated by a single character delimiter (like a ","). The rest of
35.15 +; the file must be such that each row contains all fields, each
35.16 +; separated by the designated delimiter.
35.17 +;
35.18 +; The fields can be integer, float, double, character, or string.
35.19 +; String fields cannot be written to a netCDF file. They have to
35.20 +; be read in as character arrays and written out that way.
35.21 +;----------------------------------------------------------------------
35.22 +
35.23 +;----------------------------------------------------------------------
35.24 +; This function returns the index locations of the given delimiter
35.25 +; in a row or several rows of strings.
35.26 +;----------------------------------------------------------------------
35.27 +function delim_indices(strings,nfields,delimiter)
35.28 +local cstrings, cdelim
35.29 +begin
35.30 + nrows = dimsizes(strings)
35.31 +;
35.32 +; Handle special case if we only have one string. Make sure it
35.33 +; is put into a 2D array.
35.34 +;
35.35 + if(nrows.eq.1) then
35.36 + cstrings = new((/1,strlen(strings)+1/),character)
35.37 + end if
35.38 +
35.39 + cstrings = stringtochar(strings) ; Convert to characters.
35.40 + cdelim = stringtochar(delimiter) ; Convert delimiter to character.
35.41 +;
35.42 +; Som error checking here. Make sure delimiter is one character.
35.43 +;
35.44 + nc = dimsizes(cdelim)
35.45 + rank = dimsizes(nc)
35.46 + if(rank.ne.1.or.(rank.eq.1.and.nc.ne.2)) then
35.47 + print("delim_indices: fatal: the delimiter you've selected")
35.48 + print("must be a single character. Can't continue.")
35.49 + exit
35.50 + end if
35.51 +
35.52 +;
35.53 +; Create array to hold indices of delimiter locations, and then loop
35.54 +; through each row and find all the delimiters. Make sure each row has
35.55 +; the correct number of delimiters.
35.56 +;
35.57 + ndelims = nfields-1
35.58 + cindices = new((/nrows,ndelims/),integer)
35.59 + do i = 0, nrows-1
35.60 + ii = ind(cstrings(i,:).eq.cdelim(0))
35.61 +;
35.62 +; Make sure there were delimiters on this row. If not, we just quit.
35.63 +; This could probably be modified to do this more gracefully.
35.64 +;
35.65 + if(any(ismissing(ii))) then
35.66 + print("delim_indices: fatal: I didn't find any delimiters")
35.67 + print("('" + delimiter + "') on row " + i + ". Can't continue.")
35.68 + exit
35.69 + end if
35.70 + if(dimsizes(ii).ne.ndelims) then
35.71 + print("delim_indices: fatal: I expected to find " + ndelims)
35.72 + print("delimiters on row " + i + ". Instead, I found " + dimsizes(ii) + ".")
35.73 + print("Can't continue.")
35.74 + exit
35.75 + end if
35.76 +
35.77 + cindices(i,:) = ii
35.78 +
35.79 + delete(ii) ; For next time through loop
35.80 + end do
35.81 +
35.82 + return(cindices)
35.83 +end
35.84 +
35.85 +;----------------------------------------------------------------------
35.86 +; This function reads in a particular field from a string array,
35.87 +; given the field number to read (fields start at #1 and go to #nfield),
35.88 +; and the indices of the delimiters.
35.89 +;
35.90 +; It returns either an integer, float, double, character, or a string,
35.91 +; depending on the input flag "return_type".
35.92 +;----------------------------------------------------------------------
35.93 +function read_field(strings,ifield,indices,return_type)
35.94 +local nstring, cstrings, nf, tmp_str
35.95 +begin
35.96 + nrows = dimsizes(strings)
35.97 +;
35.98 +; Handle special case if we only have one string. Make sure it
35.99 +; is put into a 2D array.
35.100 +;
35.101 + if(nrows.eq.1) then
35.102 + cstrings = new((/1,strlen(strings)+1/),character)
35.103 + end if
35.104 +
35.105 + cstrings = stringtochar(strings)
35.106 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
35.107 +
35.108 +;
35.109 +; Error checking. Make sure user has entered a valid field.
35.110 +;
35.111 + if(ifield.le.0.or.ifield.gt.nf) then
35.112 + print("read_field: fatal: you've selected a field that is")
35.113 + print("out-of-range of the number of fields that you have (" + nf + ").")
35.114 + exit
35.115 + end if
35.116 +
35.117 +;
35.118 +; Set up array to return. For string, int, float, or double arrays,
35.119 +; we don't have to do anything special. For character arrays,
35.120 +; however, we do.
35.121 +;
35.122 + if(return_type.ne."character") then
35.123 + return_array = new(nrows,return_type)
35.124 + else
35.125 +;
35.126 +; We don't know what the biggest character array is at this point, so
35.127 +; make it bigger than necessary, and then resize later as necessary.
35.128 +;
35.129 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
35.130 +
35.131 + max_len = 0 ; Use to keep track of max lengths of strings.
35.132 + end if
35.133 +
35.134 + do i = 0,nrows-1
35.135 +;
35.136 +; Special case of first field in row.
35.137 +;
35.138 + if(ifield.eq.1) then
35.139 + ibeg = 0
35.140 + iend = indices(i,ifield-1)-1
35.141 + else
35.142 +;
35.143 +; Special case of first field in row.
35.144 +;
35.145 + if(ifield.eq.nf) then
35.146 + ibeg = indices(i,ifield-2)+1
35.147 + iend = dimsizes(cstrings(i,:))-1
35.148 +;
35.149 +; Any field between first and last field.
35.150 +;
35.151 + else
35.152 + ibeg = indices(i,ifield-2)+1
35.153 + iend = indices(i,ifield-1)-1
35.154 + end if
35.155 + end if
35.156 +;
35.157 +; Here's the code that pulls off the correct string, and converts it
35.158 +; to float if desired.
35.159 +;
35.160 + if(return_type.eq."integer") then
35.161 + return_array(i) = stringtointeger(chartostring(cstrings(i,ibeg:iend)))
35.162 + end if
35.163 + if(return_type.eq."float") then
35.164 + return_array(i) = stringtofloat(chartostring(cstrings(i,ibeg:iend)))
35.165 + end if
35.166 + if(return_type.eq."double") then
35.167 + return_array(i) = stringtodouble(chartostring(cstrings(i,ibeg:iend)))
35.168 + end if
35.169 + if(return_type.eq."string") then
35.170 + return_array(i) = chartostring(cstrings(i,ibeg:iend))
35.171 + end if
35.172 + if(return_type.eq."character") then
35.173 + if( (iend-ibeg+1) .gt. max_len) then
35.174 + max_len = iend-ibeg+1
35.175 + end if
35.176 + tmp_return_array(i,0:iend-ibeg) = cstrings(i,ibeg:iend)
35.177 + end if
35.178 + end do
35.179 +
35.180 + if(return_type.eq."character") then
35.181 + return_array = new((/nrows,max_len/),"character")
35.182 + return_array = tmp_return_array(:,0:max_len-1)
35.183 + end if
35.184 +
35.185 + return(return_array)
35.186 +end
35.187 +
35.188 +
35.189 +;----------------------------------------------------------------------
35.190 +; This function reads in string fields only to get the maximum string
35.191 +; length.
35.192 +;----------------------------------------------------------------------
35.193 +function get_maxlen(strings,ifield,indices)
35.194 +local nstring, cstrings, nf, tmp_str
35.195 +begin
35.196 + nrows = dimsizes(strings)
35.197 +;
35.198 +; Handle special case if we only have one string. Make sure it
35.199 +; is put into a 2D array.
35.200 +;
35.201 + if(nrows.eq.1) then
35.202 + cstrings = new((/1,strlen(strings)+1/),character)
35.203 + end if
35.204 +
35.205 + cstrings = stringtochar(strings)
35.206 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
35.207 +
35.208 +;
35.209 +; Error checking. Make sure user has entered a valid field.
35.210 +;
35.211 + if(ifield.le.0.or.ifield.gt.nf) then
35.212 + print("read_field: fatal: you've selected a field that is")
35.213 + print("out-of-range of the number of fields that you have (" + nf + ").")
35.214 + exit
35.215 + end if
35.216 +;
35.217 +; We don't know what the biggest character array is at this point, so
35.218 +; make it bigger than necessary, and then resize later as necessary.
35.219 +;
35.220 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
35.221 +
35.222 + max_len = 0 ; Use to keep track of max lengths of strings.
35.223 +
35.224 + do i = 0,nrows-1
35.225 +;
35.226 +; Special case of first field in row.
35.227 +;
35.228 + if(ifield.eq.1) then
35.229 + ibeg = 0
35.230 + iend = indices(i,ifield-1)-1
35.231 + else
35.232 +;
35.233 +; Special case of first field in row.
35.234 +;
35.235 + if(ifield.eq.nf) then
35.236 + ibeg = indices(i,ifield-2)+1
35.237 + iend = dimsizes(cstrings(i,:))-1
35.238 +;
35.239 +; Any field between first and last field.
35.240 +;
35.241 + else
35.242 + ibeg = indices(i,ifield-2)+1
35.243 + iend = indices(i,ifield-1)-1
35.244 + end if
35.245 + end if
35.246 + if( (iend-ibeg+1) .gt. max_len) then
35.247 + max_len = iend-ibeg+1
35.248 + end if
35.249 + end do
35.250 +
35.251 + return(max_len)
35.252 +end
35.253 +
35.254 +;----------------------------------------------------------------------
35.255 +; Main code.
35.256 +;----------------------------------------------------------------------
35.257 +begin
35.258 +
35.259 +;###############################################################
35.260 +; Set up defaults. We are hard-coding here..
35.261 +
35.262 + year = 1991
35.263 + station = "USHa1"
35.264 + lat = 42.5378
35.265 + lon = -72.1715 + 360.
35.266 +
35.267 + nfields = 30 ; # of fields
35.268 + delimiter = "," ; field delimiter
35.269 +
35.270 + filename = station+year+"_L4_m.txt" ; ASCII" file to read.
35.271 + cdf_file = station+year+"_L4_m.nc" ; netCDF file to write.
35.272 +
35.273 + if(isfilepresent(cdf_file))
35.274 + print("Warning: '" + cdf_file + "' exists. Will remove it.")
35.275 + system("/bin/rm " + cdf_file)
35.276 + end if
35.277 +
35.278 +; In this case, fields #1-#2 are integers,
35.279 +; and the rest of the fields are floats.
35.280 +
35.281 + var_types = new(nfields,string)
35.282 + var_types = "float" ; Most are floats.
35.283 + var_types(0:1) = "integer"
35.284 +
35.285 +;#####################################################################
35.286 +
35.287 +; Read in data as strings. This will create a string array that has the
35.288 +; same number of strings as there are rows in the file. We will then need
35.289 +; to parse each string later.
35.290 +
35.291 + read_data = asciiread(filename,-1,"string")
35.292 +
35.293 + header = read_data(0) ; Header. Use for variable names.
35.294 + data = read_data(1:) ; Get rid of first line which is a header.
35.295 + nmonth = dimsizes(data) ; Number of rows == number of month.
35.296 +
35.297 +; Read in locations of delimiters in each string row.
35.298 +
35.299 + hindices = delim_indices(header,nfields,delimiter) ; header row
35.300 + dindices = delim_indices(data,nfields,delimiter) ; rest of file
35.301 +
35.302 +; Read in the field names which will become variable names on
35.303 +; the netCDF file.
35.304 +
35.305 + var_names = new(nfields,string)
35.306 +
35.307 + do i=0,nfields-1
35.308 + var_names(i) = read_field(header,i+1,hindices,"string")
35.309 + end do
35.310 +
35.311 +;-------------------------------------------------------------------
35.312 +; Write out this netCDF file efficiently so it will be faster.
35.313 +; Try to predefine everything before you write to it.
35.314 +
35.315 + f = addfile(cdf_file,"c")
35.316 + setfileoption(f,"DefineMode",True) ; Enter predefine phase.
35.317 +
35.318 +; Write global attributes to file. It's okay to do this before
35.319 +; predefining the file's variables. We are still in "define" mode.
35.320 +
35.321 + fAtt = True
35.322 + fAtt@description = "Data read in from " + filename + " ASCII file."
35.323 + fAtt@creation_date = systemfunc ("date")
35.324 + fileattdef( f, fAtt )
35.325 +
35.326 +; Write dimension names to file.
35.327 +
35.328 + dim_names = (/ "year", "month" /)
35.329 + dim_sizes = (/ -1 , nmonth /)
35.330 + dimUnlim = (/ True , False /)
35.331 + filedimdef( f, dim_names, dim_sizes, dimUnlim )
35.332 +
35.333 + filedimdef( f, "lat", 1, False )
35.334 + filedimdef( f, "lon", 1, False )
35.335 +
35.336 +; Define each variable on the file.
35.337 +
35.338 + filevardef( f, "year", "integer", "year" )
35.339 + filevardef( f, "lat" , "float" , "lat" )
35.340 + filevardef( f, "lon" , "float" , "lon" )
35.341 +
35.342 + do i=0,nfields-1
35.343 + filevardef(f, var_names(i), var_types(i), dim_names)
35.344 + end do
35.345 +;-----------------------------------------------------------------
35.346 +
35.347 +; Loop through each field, read the values for that field, print
35.348 +; information about the variable, and then write it to the netCDF file.
35.349 +
35.350 + do i=0,nfields-1
35.351 + ifield = i+1 ; Fields start at #1, not #0.
35.352 +
35.353 + tmp_data = new((/1,nmonth/),var_types(i))
35.354 +
35.355 + if (i.le.1) then
35.356 + tmp_data@_FillValue = -999
35.357 + else
35.358 + tmp_data@_FillValue = -9999.00
35.359 + end if
35.360 +
35.361 + tmp_data(0,:) = read_field(data,ifield,dindices,var_types(i))
35.362 +
35.363 +; change Month to yyyymm
35.364 +
35.365 + if (i.eq.0) then
35.366 + tmp_data(0,:) = tmp_data(0,:) + year*100
35.367 + end if
35.368 +
35.369 +; Print some info about the variable.
35.370 +
35.371 +; print("")
35.372 +; print("Writing variable '" + var_names(i) + "' (field #" + ifield + ").")
35.373 +; print("Type is " + var_types(i) + ".")
35.374 +; print("min/max = " + min(tmp_data) + "/" + max(tmp_data))
35.375 +
35.376 +; if(any(ismissing(tmp_data))) then
35.377 +; print("This variable does contain missing values.")
35.378 +; else
35.379 +; print("This variable doesn't contain missing values.")
35.380 +; end if
35.381 +
35.382 +; write variable to file
35.383 +
35.384 + f->$var_names(i)$ = tmp_data ; Write to netCDF file.
35.385 +
35.386 + delete(tmp_data) ; Delete for next round.
35.387 + end do
35.388 +
35.389 +; write variable to file
35.390 +
35.391 + f->year = year
35.392 + f->lat = lat
35.393 + f->lon = lon
35.394 +end
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
36.2 +++ b/ameriflux/05.read_ascii.ncl Mon Jan 26 22:08:20 2009 -0500
36.3 @@ -0,0 +1,413 @@
36.4 +;----------------------------------------------------------------------
36.5 +; set _FillValue
36.6 +; change Month to yyyymm
36.7 +; add Month to output
36.8 +; add lat, lon to output
36.9 +; add year to output
36.10 +;
36.11 +; This example reads an ASCII file that is formatted a specific way, and
36.12 +; writes out the results to a netCDF file.
36.13 +;
36.14 +; The first line in the ASCII file must be a header, with each field
36.15 +; separated by a single character delimiter (like a ","). The rest of
36.16 +; the file must be such that each row contains all fields, each
36.17 +; separated by the designated delimiter.
36.18 +;
36.19 +; The fields can be integer, float, double, character, or string.
36.20 +; String fields cannot be written to a netCDF file. They have to
36.21 +; be read in as character arrays and written out that way.
36.22 +;----------------------------------------------------------------------
36.23 +
36.24 +;----------------------------------------------------------------------
36.25 +; This function returns the index locations of the given delimiter
36.26 +; in a row or several rows of strings.
36.27 +;----------------------------------------------------------------------
36.28 +function delim_indices(strings,nfields,delimiter)
36.29 +local cstrings, cdelim
36.30 +begin
36.31 + nrows = dimsizes(strings)
36.32 +;
36.33 +; Handle special case if we only have one string. Make sure it
36.34 +; is put into a 2D array.
36.35 +;
36.36 + if(nrows.eq.1) then
36.37 + cstrings = new((/1,strlen(strings)+1/),character)
36.38 + end if
36.39 +
36.40 + cstrings = stringtochar(strings) ; Convert to characters.
36.41 + cdelim = stringtochar(delimiter) ; Convert delimiter to character.
36.42 +;
36.43 +; Som error checking here. Make sure delimiter is one character.
36.44 +;
36.45 + nc = dimsizes(cdelim)
36.46 + rank = dimsizes(nc)
36.47 + if(rank.ne.1.or.(rank.eq.1.and.nc.ne.2)) then
36.48 + print("delim_indices: fatal: the delimiter you've selected")
36.49 + print("must be a single character. Can't continue.")
36.50 + exit
36.51 + end if
36.52 +
36.53 +;
36.54 +; Create array to hold indices of delimiter locations, and then loop
36.55 +; through each row and find all the delimiters. Make sure each row has
36.56 +; the correct number of delimiters.
36.57 +;
36.58 + ndelims = nfields-1
36.59 + cindices = new((/nrows,ndelims/),integer)
36.60 + do i = 0, nrows-1
36.61 + ii = ind(cstrings(i,:).eq.cdelim(0))
36.62 +;
36.63 +; Make sure there were delimiters on this row. If not, we just quit.
36.64 +; This could probably be modified to do this more gracefully.
36.65 +;
36.66 + if(any(ismissing(ii))) then
36.67 + print("delim_indices: fatal: I didn't find any delimiters")
36.68 + print("('" + delimiter + "') on row " + i + ". Can't continue.")
36.69 + exit
36.70 + end if
36.71 + if(dimsizes(ii).ne.ndelims) then
36.72 + print("delim_indices: fatal: I expected to find " + ndelims)
36.73 + print("delimiters on row " + i + ". Instead, I found " + dimsizes(ii) + ".")
36.74 + print("Can't continue.")
36.75 + exit
36.76 + end if
36.77 +
36.78 + cindices(i,:) = ii
36.79 +
36.80 + delete(ii) ; For next time through loop
36.81 + end do
36.82 +
36.83 + return(cindices)
36.84 +end
36.85 +
36.86 +;----------------------------------------------------------------------
36.87 +; This function reads in a particular field from a string array,
36.88 +; given the field number to read (fields start at #1 and go to #nfield),
36.89 +; and the indices of the delimiters.
36.90 +;
36.91 +; It returns either an integer, float, double, character, or a string,
36.92 +; depending on the input flag "return_type".
36.93 +;----------------------------------------------------------------------
36.94 +function read_field(strings,ifield,indices,return_type)
36.95 +local nstring, cstrings, nf, tmp_str
36.96 +begin
36.97 + nrows = dimsizes(strings)
36.98 +;
36.99 +; Handle special case if we only have one string. Make sure it
36.100 +; is put into a 2D array.
36.101 +;
36.102 + if(nrows.eq.1) then
36.103 + cstrings = new((/1,strlen(strings)+1/),character)
36.104 + end if
36.105 +
36.106 + cstrings = stringtochar(strings)
36.107 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
36.108 +
36.109 +;
36.110 +; Error checking. Make sure user has entered a valid field.
36.111 +;
36.112 + if(ifield.le.0.or.ifield.gt.nf) then
36.113 + print("read_field: fatal: you've selected a field that is")
36.114 + print("out-of-range of the number of fields that you have (" + nf + ").")
36.115 + exit
36.116 + end if
36.117 +
36.118 +;
36.119 +; Set up array to return. For string, int, float, or double arrays,
36.120 +; we don't have to do anything special. For character arrays,
36.121 +; however, we do.
36.122 +;
36.123 + if(return_type.ne."character") then
36.124 + return_array = new(nrows,return_type)
36.125 + else
36.126 +;
36.127 +; We don't know what the biggest character array is at this point, so
36.128 +; make it bigger than necessary, and then resize later as necessary.
36.129 +;
36.130 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
36.131 +
36.132 + max_len = 0 ; Use to keep track of max lengths of strings.
36.133 + end if
36.134 +
36.135 + do i = 0,nrows-1
36.136 +;
36.137 +; Special case of first field in row.
36.138 +;
36.139 + if(ifield.eq.1) then
36.140 + ibeg = 0
36.141 + iend = indices(i,ifield-1)-1
36.142 + else
36.143 +;
36.144 +; Special case of first field in row.
36.145 +;
36.146 + if(ifield.eq.nf) then
36.147 + ibeg = indices(i,ifield-2)+1
36.148 + iend = dimsizes(cstrings(i,:))-1
36.149 +;
36.150 +; Any field between first and last field.
36.151 +;
36.152 + else
36.153 + ibeg = indices(i,ifield-2)+1
36.154 + iend = indices(i,ifield-1)-1
36.155 + end if
36.156 + end if
36.157 +;
36.158 +; Here's the code that pulls off the correct string, and converts it
36.159 +; to float if desired.
36.160 +;
36.161 + if(return_type.eq."integer") then
36.162 + return_array(i) = stringtointeger(chartostring(cstrings(i,ibeg:iend)))
36.163 + end if
36.164 + if(return_type.eq."float") then
36.165 + return_array(i) = stringtofloat(chartostring(cstrings(i,ibeg:iend)))
36.166 + end if
36.167 + if(return_type.eq."double") then
36.168 + return_array(i) = stringtodouble(chartostring(cstrings(i,ibeg:iend)))
36.169 + end if
36.170 + if(return_type.eq."string") then
36.171 + return_array(i) = chartostring(cstrings(i,ibeg:iend))
36.172 + end if
36.173 + if(return_type.eq."character") then
36.174 + if( (iend-ibeg+1) .gt. max_len) then
36.175 + max_len = iend-ibeg+1
36.176 + end if
36.177 + tmp_return_array(i,0:iend-ibeg) = cstrings(i,ibeg:iend)
36.178 + end if
36.179 + end do
36.180 +
36.181 + if(return_type.eq."character") then
36.182 + return_array = new((/nrows,max_len/),"character")
36.183 + return_array = tmp_return_array(:,0:max_len-1)
36.184 + end if
36.185 +
36.186 + return(return_array)
36.187 +end
36.188 +
36.189 +
36.190 +;----------------------------------------------------------------------
36.191 +; This function reads in string fields only to get the maximum string
36.192 +; length.
36.193 +;----------------------------------------------------------------------
36.194 +function get_maxlen(strings,ifield,indices)
36.195 +local nstring, cstrings, nf, tmp_str
36.196 +begin
36.197 + nrows = dimsizes(strings)
36.198 +;
36.199 +; Handle special case if we only have one string. Make sure it
36.200 +; is put into a 2D array.
36.201 +;
36.202 + if(nrows.eq.1) then
36.203 + cstrings = new((/1,strlen(strings)+1/),character)
36.204 + end if
36.205 +
36.206 + cstrings = stringtochar(strings)
36.207 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
36.208 +
36.209 +;
36.210 +; Error checking. Make sure user has entered a valid field.
36.211 +;
36.212 + if(ifield.le.0.or.ifield.gt.nf) then
36.213 + print("read_field: fatal: you've selected a field that is")
36.214 + print("out-of-range of the number of fields that you have (" + nf + ").")
36.215 + exit
36.216 + end if
36.217 +;
36.218 +; We don't know what the biggest character array is at this point, so
36.219 +; make it bigger than necessary, and then resize later as necessary.
36.220 +;
36.221 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
36.222 +
36.223 + max_len = 0 ; Use to keep track of max lengths of strings.
36.224 +
36.225 + do i = 0,nrows-1
36.226 +;
36.227 +; Special case of first field in row.
36.228 +;
36.229 + if(ifield.eq.1) then
36.230 + ibeg = 0
36.231 + iend = indices(i,ifield-1)-1
36.232 + else
36.233 +;
36.234 +; Special case of first field in row.
36.235 +;
36.236 + if(ifield.eq.nf) then
36.237 + ibeg = indices(i,ifield-2)+1
36.238 + iend = dimsizes(cstrings(i,:))-1
36.239 +;
36.240 +; Any field between first and last field.
36.241 +;
36.242 + else
36.243 + ibeg = indices(i,ifield-2)+1
36.244 + iend = indices(i,ifield-1)-1
36.245 + end if
36.246 + end if
36.247 + if( (iend-ibeg+1) .gt. max_len) then
36.248 + max_len = iend-ibeg+1
36.249 + end if
36.250 + end do
36.251 +
36.252 + return(max_len)
36.253 +end
36.254 +
36.255 +;----------------------------------------------------------------------
36.256 +; Main code.
36.257 +;----------------------------------------------------------------------
36.258 +begin
36.259 +
36.260 +;###############################################################
36.261 +; Set up defaults. We are hard-coding here..
36.262 +
36.263 + year = 1991
36.264 + station = "USHa1"
36.265 + lat = 42.5378
36.266 + lon = -72.1715 + 360.
36.267 +
36.268 + nfields = 30 ; # of fields
36.269 + delimiter = "," ; field delimiter
36.270 +
36.271 + filename = station+year+"_L4_m.txt" ; ASCII" file to read.
36.272 + cdf_file = station+year+"_L4_m.nc" ; netCDF file to write.
36.273 +
36.274 + if(isfilepresent(cdf_file))
36.275 + print("Warning: '" + cdf_file + "' exists. Will remove it.")
36.276 + system("/bin/rm " + cdf_file)
36.277 + end if
36.278 +
36.279 +; In this case, fields #1-#2 are integers,
36.280 +; and the rest of the fields are floats.
36.281 +
36.282 + var_types = new(nfields,string)
36.283 + var_types = "float" ; Most are floats.
36.284 + var_types(0:1) = "integer"
36.285 +
36.286 +;#####################################################################
36.287 +
36.288 +; Read in data as strings. This will create a string array that has the
36.289 +; same number of strings as there are rows in the file. We will then need
36.290 +; to parse each string later.
36.291 +
36.292 + read_data = asciiread(filename,-1,"string")
36.293 +
36.294 + header = read_data(0) ; Header. Use for variable names.
36.295 + data = read_data(1:) ; Get rid of first line which is a header.
36.296 + nmonth = dimsizes(data) ; Number of rows == number of month.
36.297 +
36.298 +; Read in locations of delimiters in each string row.
36.299 +
36.300 + hindices = delim_indices(header,nfields,delimiter) ; header row
36.301 + dindices = delim_indices(data,nfields,delimiter) ; rest of file
36.302 +
36.303 +; Read in the field names which will become variable names on
36.304 +; the netCDF file.
36.305 +
36.306 + var_names = new(nfields,string)
36.307 +
36.308 + do i=0,nfields-1
36.309 + var_names(i) = read_field(header,i+1,hindices,"string")
36.310 + end do
36.311 +
36.312 +;-------------------------------------------------------------------
36.313 +; Write out this netCDF file efficiently so it will be faster.
36.314 +; Try to predefine everything before you write to it.
36.315 +
36.316 + f = addfile(cdf_file,"c")
36.317 + setfileoption(f,"DefineMode",True) ; Enter predefine phase.
36.318 +
36.319 +; Write global attributes to file. It's okay to do this before
36.320 +; predefining the file's variables. We are still in "define" mode.
36.321 +
36.322 + fAtt = True
36.323 + fAtt@description = "Data read in from " + filename + " ASCII file."
36.324 + fAtt@creation_date = systemfunc ("date")
36.325 + fileattdef( f, fAtt )
36.326 +
36.327 +; Write dimension names to file.
36.328 +
36.329 + dim_names = (/ "year", "month" /)
36.330 + dim_sizes = (/ -1 , nmonth /)
36.331 + dimUnlim = (/ True , False /)
36.332 + filedimdef( f, dim_names, dim_sizes, dimUnlim )
36.333 +
36.334 + filedimdef( f, "lat", 1, False )
36.335 + filedimdef( f, "lon", 1, False )
36.336 +
36.337 +; Define each variable on the file.
36.338 +
36.339 + filevardef( f, "year", "integer", "year" )
36.340 + filevardef( f, "lat" , "float" , "lat" )
36.341 + filevardef( f, "lon" , "float" , "lon" )
36.342 +
36.343 + do i=0,nfields-1
36.344 +
36.345 +; define variable
36.346 +
36.347 + filevardef(f, var_names(i), var_types(i), dim_names)
36.348 +
36.349 +; define variable attributes
36.350 +
36.351 + if (i.le.1) then
36.352 + varAtt = 0
36.353 +; varAtt@_FillValue = -999
36.354 + else
36.355 + varAtt = 0.
36.356 +; varAtt@_FillValue = 1.e36
36.357 + end if
36.358 +
36.359 + varAtt@long_name = var_names(i)
36.360 +
36.361 + filevarattdef( f, var_names(i) , varAtt )
36.362 +
36.363 + delete (varAtt)
36.364 + end do
36.365 +;-----------------------------------------------------------------
36.366 +
36.367 +; Loop through each field, read the values for that field, print
36.368 +; information about the variable, and then write it to the netCDF file.
36.369 +
36.370 + do i=0,nfields-1
36.371 + ifield = i+1 ; Fields start at #1, not #0.
36.372 +
36.373 + tmp_data = new((/1,nmonth/),var_types(i))
36.374 +
36.375 + if (i.le.1) then
36.376 + tmp_data@_FillValue = -999
36.377 + else
36.378 + tmp_data@_FillValue = 1.e36
36.379 + end if
36.380 +
36.381 + tmp_data(0,:) = read_field(data,ifield,dindices,var_types(i))
36.382 +
36.383 + tmp_data = where(tmp_data .le. -9000.,tmp_data@_FillValue,tmp_data)
36.384 +
36.385 +; change Month to yyyymm
36.386 +
36.387 + if (i.eq.0) then
36.388 + tmp_data(0,:) = tmp_data(0,:) + year*100
36.389 + end if
36.390 +
36.391 +; Print some info about the variable.
36.392 +
36.393 +; print("")
36.394 +; print("Writing variable '" + var_names(i) + "' (field #" + ifield + ").")
36.395 +; print("Type is " + var_types(i) + ".")
36.396 +; print("min/max = " + min(tmp_data) + "/" + max(tmp_data))
36.397 +
36.398 +; if(any(ismissing(tmp_data))) then
36.399 +; print("This variable does contain missing values.")
36.400 +; else
36.401 +; print("This variable doesn't contain missing values.")
36.402 +; end if
36.403 +
36.404 +; write variable to file
36.405 +
36.406 + f->$var_names(i)$ = tmp_data ; Write to netCDF file.
36.407 +
36.408 + delete(tmp_data) ; Delete for next round.
36.409 + end do
36.410 +
36.411 +; write variable to file
36.412 +
36.413 + f->year = year
36.414 + f->lat = lat
36.415 + f->lon = lon
36.416 +end
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/ameriflux/06.ncl Mon Jan 26 22:08:20 2009 -0500
37.3 @@ -0,0 +1,412 @@
37.4 +;----------------------------------------------------------------------
37.5 +; set _FillValue
37.6 +; change Month to yyyymm
37.7 +; add Month to output
37.8 +; add lat, lon to output
37.9 +; add year to output
37.10 +;
37.11 +; This example reads an ASCII file that is formatted a specific way, and
37.12 +; writes out the results to a netCDF file.
37.13 +;
37.14 +; The first line in the ASCII file must be a header, with each field
37.15 +; separated by a single character delimiter (like a ","). The rest of
37.16 +; the file must be such that each row contains all fields, each
37.17 +; separated by the designated delimiter.
37.18 +;
37.19 +; The fields can be integer, float, double, character, or string.
37.20 +; String fields cannot be written to a netCDF file. They have to
37.21 +; be read in as character arrays and written out that way.
37.22 +;----------------------------------------------------------------------
37.23 +
37.24 +;----------------------------------------------------------------------
37.25 +; This function returns the index locations of the given delimiter
37.26 +; in a row or several rows of strings.
37.27 +;----------------------------------------------------------------------
37.28 +function delim_indices(strings,nfields,delimiter)
37.29 +local cstrings, cdelim
37.30 +begin
37.31 + nrows = dimsizes(strings)
37.32 +;
37.33 +; Handle special case if we only have one string. Make sure it
37.34 +; is put into a 2D array.
37.35 +;
37.36 + if(nrows.eq.1) then
37.37 + cstrings = new((/1,strlen(strings)+1/),character)
37.38 + end if
37.39 +
37.40 + cstrings = stringtochar(strings) ; Convert to characters.
37.41 + cdelim = stringtochar(delimiter) ; Convert delimiter to character.
37.42 +;
37.43 +; Som error checking here. Make sure delimiter is one character.
37.44 +;
37.45 + nc = dimsizes(cdelim)
37.46 + rank = dimsizes(nc)
37.47 + if(rank.ne.1.or.(rank.eq.1.and.nc.ne.2)) then
37.48 + print("delim_indices: fatal: the delimiter you've selected")
37.49 + print("must be a single character. Can't continue.")
37.50 + exit
37.51 + end if
37.52 +
37.53 +;
37.54 +; Create array to hold indices of delimiter locations, and then loop
37.55 +; through each row and find all the delimiters. Make sure each row has
37.56 +; the correct number of delimiters.
37.57 +;
37.58 + ndelims = nfields-1
37.59 + cindices = new((/nrows,ndelims/),integer)
37.60 + do i = 0, nrows-1
37.61 + ii = ind(cstrings(i,:).eq.cdelim(0))
37.62 +;
37.63 +; Make sure there were delimiters on this row. If not, we just quit.
37.64 +; This could probably be modified to do this more gracefully.
37.65 +;
37.66 + if(any(ismissing(ii))) then
37.67 + print("delim_indices: fatal: I didn't find any delimiters")
37.68 + print("('" + delimiter + "') on row " + i + ". Can't continue.")
37.69 + exit
37.70 + end if
37.71 + if(dimsizes(ii).ne.ndelims) then
37.72 + print("delim_indices: fatal: I expected to find " + ndelims)
37.73 + print("delimiters on row " + i + ". Instead, I found " + dimsizes(ii) + ".")
37.74 + print("Can't continue.")
37.75 + exit
37.76 + end if
37.77 +
37.78 + cindices(i,:) = ii
37.79 +
37.80 + delete(ii) ; For next time through loop
37.81 + end do
37.82 +
37.83 + return(cindices)
37.84 +end
37.85 +
37.86 +;----------------------------------------------------------------------
37.87 +; This function reads in a particular field from a string array,
37.88 +; given the field number to read (fields start at #1 and go to #nfield),
37.89 +; and the indices of the delimiters.
37.90 +;
37.91 +; It returns either an integer, float, double, character, or a string,
37.92 +; depending on the input flag "return_type".
37.93 +;----------------------------------------------------------------------
37.94 +function read_field(strings,ifield,indices,return_type)
37.95 +local nstring, cstrings, nf, tmp_str
37.96 +begin
37.97 + nrows = dimsizes(strings)
37.98 +;
37.99 +; Handle special case if we only have one string. Make sure it
37.100 +; is put into a 2D array.
37.101 +;
37.102 + if(nrows.eq.1) then
37.103 + cstrings = new((/1,strlen(strings)+1/),character)
37.104 + end if
37.105 +
37.106 + cstrings = stringtochar(strings)
37.107 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
37.108 +
37.109 +;
37.110 +; Error checking. Make sure user has entered a valid field.
37.111 +;
37.112 + if(ifield.le.0.or.ifield.gt.nf) then
37.113 + print("read_field: fatal: you've selected a field that is")
37.114 + print("out-of-range of the number of fields that you have (" + nf + ").")
37.115 + exit
37.116 + end if
37.117 +
37.118 +;
37.119 +; Set up array to return. For string, int, float, or double arrays,
37.120 +; we don't have to do anything special. For character arrays,
37.121 +; however, we do.
37.122 +;
37.123 + if(return_type.ne."character") then
37.124 + return_array = new(nrows,return_type)
37.125 + else
37.126 +;
37.127 +; We don't know what the biggest character array is at this point, so
37.128 +; make it bigger than necessary, and then resize later as necessary.
37.129 +;
37.130 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
37.131 +
37.132 + max_len = 0 ; Use to keep track of max lengths of strings.
37.133 + end if
37.134 +
37.135 + do i = 0,nrows-1
37.136 +;
37.137 +; Special case of first field in row.
37.138 +;
37.139 + if(ifield.eq.1) then
37.140 + ibeg = 0
37.141 + iend = indices(i,ifield-1)-1
37.142 + else
37.143 +;
37.144 +; Special case of first field in row.
37.145 +;
37.146 + if(ifield.eq.nf) then
37.147 + ibeg = indices(i,ifield-2)+1
37.148 + iend = dimsizes(cstrings(i,:))-1
37.149 +;
37.150 +; Any field between first and last field.
37.151 +;
37.152 + else
37.153 + ibeg = indices(i,ifield-2)+1
37.154 + iend = indices(i,ifield-1)-1
37.155 + end if
37.156 + end if
37.157 +;
37.158 +; Here's the code that pulls off the correct string, and converts it
37.159 +; to float if desired.
37.160 +;
37.161 + if(return_type.eq."integer") then
37.162 + return_array(i) = stringtointeger(chartostring(cstrings(i,ibeg:iend)))
37.163 + end if
37.164 + if(return_type.eq."float") then
37.165 + return_array(i) = stringtofloat(chartostring(cstrings(i,ibeg:iend)))
37.166 + end if
37.167 + if(return_type.eq."double") then
37.168 + return_array(i) = stringtodouble(chartostring(cstrings(i,ibeg:iend)))
37.169 + end if
37.170 + if(return_type.eq."string") then
37.171 + return_array(i) = chartostring(cstrings(i,ibeg:iend))
37.172 + end if
37.173 + if(return_type.eq."character") then
37.174 + if( (iend-ibeg+1) .gt. max_len) then
37.175 + max_len = iend-ibeg+1
37.176 + end if
37.177 + tmp_return_array(i,0:iend-ibeg) = cstrings(i,ibeg:iend)
37.178 + end if
37.179 + end do
37.180 +
37.181 + if(return_type.eq."character") then
37.182 + return_array = new((/nrows,max_len/),"character")
37.183 + return_array = tmp_return_array(:,0:max_len-1)
37.184 + end if
37.185 +
37.186 + return(return_array)
37.187 +end
37.188 +
37.189 +
37.190 +;----------------------------------------------------------------------
37.191 +; This function reads in string fields only to get the maximum string
37.192 +; length.
37.193 +;----------------------------------------------------------------------
37.194 +function get_maxlen(strings,ifield,indices)
37.195 +local nstring, cstrings, nf, tmp_str
37.196 +begin
37.197 + nrows = dimsizes(strings)
37.198 +;
37.199 +; Handle special case if we only have one string. Make sure it
37.200 +; is put into a 2D array.
37.201 +;
37.202 + if(nrows.eq.1) then
37.203 + cstrings = new((/1,strlen(strings)+1/),character)
37.204 + end if
37.205 +
37.206 + cstrings = stringtochar(strings)
37.207 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
37.208 +
37.209 +;
37.210 +; Error checking. Make sure user has entered a valid field.
37.211 +;
37.212 + if(ifield.le.0.or.ifield.gt.nf) then
37.213 + print("read_field: fatal: you've selected a field that is")
37.214 + print("out-of-range of the number of fields that you have (" + nf + ").")
37.215 + exit
37.216 + end if
37.217 +;
37.218 +; We don't know what the biggest character array is at this point, so
37.219 +; make it bigger than necessary, and then resize later as necessary.
37.220 +;
37.221 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
37.222 +
37.223 + max_len = 0 ; Use to keep track of max lengths of strings.
37.224 +
37.225 + do i = 0,nrows-1
37.226 +;
37.227 +; Special case of first field in row.
37.228 +;
37.229 + if(ifield.eq.1) then
37.230 + ibeg = 0
37.231 + iend = indices(i,ifield-1)-1
37.232 + else
37.233 +;
37.234 +; Special case of first field in row.
37.235 +;
37.236 + if(ifield.eq.nf) then
37.237 + ibeg = indices(i,ifield-2)+1
37.238 + iend = dimsizes(cstrings(i,:))-1
37.239 +;
37.240 +; Any field between first and last field.
37.241 +;
37.242 + else
37.243 + ibeg = indices(i,ifield-2)+1
37.244 + iend = indices(i,ifield-1)-1
37.245 + end if
37.246 + end if
37.247 + if( (iend-ibeg+1) .gt. max_len) then
37.248 + max_len = iend-ibeg+1
37.249 + end if
37.250 + end do
37.251 +
37.252 + return(max_len)
37.253 +end
37.254 +
37.255 +;----------------------------------------------------------------------
37.256 +; Main code.
37.257 +;----------------------------------------------------------------------
37.258 +begin
37.259 +
37.260 +;###############################################################
37.261 +; Set up defaults. We are hard-coding here..
37.262 +
37.263 + year = 2002
37.264 + lat = 46.61878
37.265 + lon = -91.08144 + 360.
37.266 +
37.267 + nfields = 30 ; # of fields
37.268 + delimiter = "," ; field delimiter
37.269 +
37.270 + filename = year+".txt" ; ASCII" file to read.
37.271 + cdf_file = year+"_L4_m.nc" ; netCDF file to write.
37.272 +
37.273 + if(isfilepresent(cdf_file))
37.274 + print("Warning: '" + cdf_file + "' exists. Will remove it.")
37.275 + system("/bin/rm " + cdf_file)
37.276 + end if
37.277 +
37.278 +; In this case, fields #1-#2 are integers,
37.279 +; and the rest of the fields are floats.
37.280 +
37.281 + var_types = new(nfields,string)
37.282 + var_types = "float" ; Most are floats.
37.283 + var_types(0:1) = "integer"
37.284 +
37.285 +;#####################################################################
37.286 +
37.287 +; Read in data as strings. This will create a string array that has the
37.288 +; same number of strings as there are rows in the file. We will then need
37.289 +; to parse each string later.
37.290 +
37.291 + read_data = asciiread(filename,-1,"string")
37.292 +
37.293 + header = read_data(0) ; Header. Use for variable names.
37.294 + data = read_data(1:) ; Get rid of first line which is a header.
37.295 + nmonth = dimsizes(data) ; Number of rows == number of month.
37.296 +
37.297 +; Read in locations of delimiters in each string row.
37.298 +
37.299 + hindices = delim_indices(header,nfields,delimiter) ; header row
37.300 + dindices = delim_indices(data,nfields,delimiter) ; rest of file
37.301 +
37.302 +; Read in the field names which will become variable names on
37.303 +; the netCDF file.
37.304 +
37.305 + var_names = new(nfields,string)
37.306 +
37.307 + do i=0,nfields-1
37.308 + var_names(i) = read_field(header,i+1,hindices,"string")
37.309 + end do
37.310 +
37.311 +;-------------------------------------------------------------------
37.312 +; Write out this netCDF file efficiently so it will be faster.
37.313 +; Try to predefine everything before you write to it.
37.314 +
37.315 + f = addfile(cdf_file,"c")
37.316 + setfileoption(f,"DefineMode",True) ; Enter predefine phase.
37.317 +
37.318 +; Write global attributes to file. It's okay to do this before
37.319 +; predefining the file's variables. We are still in "define" mode.
37.320 +
37.321 + fAtt = True
37.322 + fAtt@description = "Data read in from " + filename + " ASCII file."
37.323 + fAtt@creation_date = systemfunc ("date")
37.324 + fileattdef( f, fAtt )
37.325 +
37.326 +; Write dimension names to file.
37.327 +
37.328 + dim_names = (/ "year", "month" /)
37.329 + dim_sizes = (/ -1 , nmonth /)
37.330 + dimUnlim = (/ True , False /)
37.331 + filedimdef( f, dim_names, dim_sizes, dimUnlim )
37.332 +
37.333 + filedimdef( f, "lat", 1, False )
37.334 + filedimdef( f, "lon", 1, False )
37.335 +
37.336 +; Define each variable on the file.
37.337 +
37.338 + filevardef( f, "year", "integer", "year" )
37.339 + filevardef( f, "lat" , "float" , "lat" )
37.340 + filevardef( f, "lon" , "float" , "lon" )
37.341 +
37.342 + do i=0,nfields-1
37.343 +
37.344 +; define variable
37.345 +
37.346 + filevardef(f, var_names(i), var_types(i), dim_names)
37.347 +
37.348 +; define variable attributes
37.349 +
37.350 + if (i.le.1) then
37.351 + varAtt = 0
37.352 +; varAtt@_FillValue = -999
37.353 + else
37.354 + varAtt = 0.
37.355 +; varAtt@_FillValue = 1.e36
37.356 + end if
37.357 +
37.358 + varAtt@long_name = var_names(i)
37.359 +
37.360 + filevarattdef( f, var_names(i) , varAtt )
37.361 +
37.362 + delete (varAtt)
37.363 + end do
37.364 +;-----------------------------------------------------------------
37.365 +
37.366 +; Loop through each field, read the values for that field, print
37.367 +; information about the variable, and then write it to the netCDF file.
37.368 +
37.369 + do i=0,nfields-1
37.370 + ifield = i+1 ; Fields start at #1, not #0.
37.371 +
37.372 + tmp_data = new((/1,nmonth/),var_types(i))
37.373 +
37.374 + if (i.le.1) then
37.375 + tmp_data@_FillValue = -999
37.376 + else
37.377 + tmp_data@_FillValue = 1.e36
37.378 + end if
37.379 +
37.380 + tmp_data(0,:) = read_field(data,ifield,dindices,var_types(i))
37.381 +
37.382 + tmp_data = where(tmp_data .le. -9000.,tmp_data@_FillValue,tmp_data)
37.383 +
37.384 +; change Month to yyyymm
37.385 +
37.386 + if (i.eq.0) then
37.387 + tmp_data(0,:) = tmp_data(0,:) + year*100
37.388 + end if
37.389 +
37.390 +; Print some info about the variable.
37.391 +
37.392 +; print("")
37.393 +; print("Writing variable '" + var_names(i) + "' (field #" + ifield + ").")
37.394 +; print("Type is " + var_types(i) + ".")
37.395 +; print("min/max = " + min(tmp_data) + "/" + max(tmp_data))
37.396 +
37.397 +; if(any(ismissing(tmp_data))) then
37.398 +; print("This variable does contain missing values.")
37.399 +; else
37.400 +; print("This variable doesn't contain missing values.")
37.401 +; end if
37.402 +
37.403 +; write variable to file
37.404 +
37.405 + f->$var_names(i)$ = tmp_data ; Write to netCDF file.
37.406 +
37.407 + delete(tmp_data) ; Delete for next round.
37.408 + end do
37.409 +
37.410 +; write variable to file
37.411 +
37.412 + f->year = year
37.413 + f->lat = lat
37.414 + f->lon = lon
37.415 +end
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
38.2 +++ b/ameriflux/06.read_ascii.ncl Mon Jan 26 22:08:20 2009 -0500
38.3 @@ -0,0 +1,412 @@
38.4 +;----------------------------------------------------------------------
38.5 +; set _FillValue
38.6 +; change Month to yyyymm
38.7 +; add Month to output
38.8 +; add lat, lon to output
38.9 +; add year to output
38.10 +;
38.11 +; This example reads an ASCII file that is formatted a specific way, and
38.12 +; writes out the results to a netCDF file.
38.13 +;
38.14 +; The first line in the ASCII file must be a header, with each field
38.15 +; separated by a single character delimiter (like a ","). The rest of
38.16 +; the file must be such that each row contains all fields, each
38.17 +; separated by the designated delimiter.
38.18 +;
38.19 +; The fields can be integer, float, double, character, or string.
38.20 +; String fields cannot be written to a netCDF file. They have to
38.21 +; be read in as character arrays and written out that way.
38.22 +;----------------------------------------------------------------------
38.23 +
38.24 +;----------------------------------------------------------------------
38.25 +; This function returns the index locations of the given delimiter
38.26 +; in a row or several rows of strings.
38.27 +;----------------------------------------------------------------------
38.28 +function delim_indices(strings,nfields,delimiter)
38.29 +local cstrings, cdelim
38.30 +begin
38.31 + nrows = dimsizes(strings)
38.32 +;
38.33 +; Handle special case if we only have one string. Make sure it
38.34 +; is put into a 2D array.
38.35 +;
38.36 + if(nrows.eq.1) then
38.37 + cstrings = new((/1,strlen(strings)+1/),character)
38.38 + end if
38.39 +
38.40 + cstrings = stringtochar(strings) ; Convert to characters.
38.41 + cdelim = stringtochar(delimiter) ; Convert delimiter to character.
38.42 +;
38.43 +; Som error checking here. Make sure delimiter is one character.
38.44 +;
38.45 + nc = dimsizes(cdelim)
38.46 + rank = dimsizes(nc)
38.47 + if(rank.ne.1.or.(rank.eq.1.and.nc.ne.2)) then
38.48 + print("delim_indices: fatal: the delimiter you've selected")
38.49 + print("must be a single character. Can't continue.")
38.50 + exit
38.51 + end if
38.52 +
38.53 +;
38.54 +; Create array to hold indices of delimiter locations, and then loop
38.55 +; through each row and find all the delimiters. Make sure each row has
38.56 +; the correct number of delimiters.
38.57 +;
38.58 + ndelims = nfields-1
38.59 + cindices = new((/nrows,ndelims/),integer)
38.60 + do i = 0, nrows-1
38.61 + ii = ind(cstrings(i,:).eq.cdelim(0))
38.62 +;
38.63 +; Make sure there were delimiters on this row. If not, we just quit.
38.64 +; This could probably be modified to do this more gracefully.
38.65 +;
38.66 + if(any(ismissing(ii))) then
38.67 + print("delim_indices: fatal: I didn't find any delimiters")
38.68 + print("('" + delimiter + "') on row " + i + ". Can't continue.")
38.69 + exit
38.70 + end if
38.71 + if(dimsizes(ii).ne.ndelims) then
38.72 + print("delim_indices: fatal: I expected to find " + ndelims)
38.73 + print("delimiters on row " + i + ". Instead, I found " + dimsizes(ii) + ".")
38.74 + print("Can't continue.")
38.75 + exit
38.76 + end if
38.77 +
38.78 + cindices(i,:) = ii
38.79 +
38.80 + delete(ii) ; For next time through loop
38.81 + end do
38.82 +
38.83 + return(cindices)
38.84 +end
38.85 +
38.86 +;----------------------------------------------------------------------
38.87 +; This function reads in a particular field from a string array,
38.88 +; given the field number to read (fields start at #1 and go to #nfield),
38.89 +; and the indices of the delimiters.
38.90 +;
38.91 +; It returns either an integer, float, double, character, or a string,
38.92 +; depending on the input flag "return_type".
38.93 +;----------------------------------------------------------------------
38.94 +function read_field(strings,ifield,indices,return_type)
38.95 +local nstring, cstrings, nf, tmp_str
38.96 +begin
38.97 + nrows = dimsizes(strings)
38.98 +;
38.99 +; Handle special case if we only have one string. Make sure it
38.100 +; is put into a 2D array.
38.101 +;
38.102 + if(nrows.eq.1) then
38.103 + cstrings = new((/1,strlen(strings)+1/),character)
38.104 + end if
38.105 +
38.106 + cstrings = stringtochar(strings)
38.107 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
38.108 +
38.109 +;
38.110 +; Error checking. Make sure user has entered a valid field.
38.111 +;
38.112 + if(ifield.le.0.or.ifield.gt.nf) then
38.113 + print("read_field: fatal: you've selected a field that is")
38.114 + print("out-of-range of the number of fields that you have (" + nf + ").")
38.115 + exit
38.116 + end if
38.117 +
38.118 +;
38.119 +; Set up array to return. For string, int, float, or double arrays,
38.120 +; we don't have to do anything special. For character arrays,
38.121 +; however, we do.
38.122 +;
38.123 + if(return_type.ne."character") then
38.124 + return_array = new(nrows,return_type)
38.125 + else
38.126 +;
38.127 +; We don't know what the biggest character array is at this point, so
38.128 +; make it bigger than necessary, and then resize later as necessary.
38.129 +;
38.130 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
38.131 +
38.132 + max_len = 0 ; Use to keep track of max lengths of strings.
38.133 + end if
38.134 +
38.135 + do i = 0,nrows-1
38.136 +;
38.137 +; Special case of first field in row.
38.138 +;
38.139 + if(ifield.eq.1) then
38.140 + ibeg = 0
38.141 + iend = indices(i,ifield-1)-1
38.142 + else
38.143 +;
38.144 +; Special case of first field in row.
38.145 +;
38.146 + if(ifield.eq.nf) then
38.147 + ibeg = indices(i,ifield-2)+1
38.148 + iend = dimsizes(cstrings(i,:))-1
38.149 +;
38.150 +; Any field between first and last field.
38.151 +;
38.152 + else
38.153 + ibeg = indices(i,ifield-2)+1
38.154 + iend = indices(i,ifield-1)-1
38.155 + end if
38.156 + end if
38.157 +;
38.158 +; Here's the code that pulls off the correct string, and converts it
38.159 +; to float if desired.
38.160 +;
38.161 + if(return_type.eq."integer") then
38.162 + return_array(i) = stringtointeger(chartostring(cstrings(i,ibeg:iend)))
38.163 + end if
38.164 + if(return_type.eq."float") then
38.165 + return_array(i) = stringtofloat(chartostring(cstrings(i,ibeg:iend)))
38.166 + end if
38.167 + if(return_type.eq."double") then
38.168 + return_array(i) = stringtodouble(chartostring(cstrings(i,ibeg:iend)))
38.169 + end if
38.170 + if(return_type.eq."string") then
38.171 + return_array(i) = chartostring(cstrings(i,ibeg:iend))
38.172 + end if
38.173 + if(return_type.eq."character") then
38.174 + if( (iend-ibeg+1) .gt. max_len) then
38.175 + max_len = iend-ibeg+1
38.176 + end if
38.177 + tmp_return_array(i,0:iend-ibeg) = cstrings(i,ibeg:iend)
38.178 + end if
38.179 + end do
38.180 +
38.181 + if(return_type.eq."character") then
38.182 + return_array = new((/nrows,max_len/),"character")
38.183 + return_array = tmp_return_array(:,0:max_len-1)
38.184 + end if
38.185 +
38.186 + return(return_array)
38.187 +end
38.188 +
38.189 +
38.190 +;----------------------------------------------------------------------
38.191 +; This function reads in string fields only to get the maximum string
38.192 +; length.
38.193 +;----------------------------------------------------------------------
38.194 +function get_maxlen(strings,ifield,indices)
38.195 +local nstring, cstrings, nf, tmp_str
38.196 +begin
38.197 + nrows = dimsizes(strings)
38.198 +;
38.199 +; Handle special case if we only have one string. Make sure it
38.200 +; is put into a 2D array.
38.201 +;
38.202 + if(nrows.eq.1) then
38.203 + cstrings = new((/1,strlen(strings)+1/),character)
38.204 + end if
38.205 +
38.206 + cstrings = stringtochar(strings)
38.207 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
38.208 +
38.209 +;
38.210 +; Error checking. Make sure user has entered a valid field.
38.211 +;
38.212 + if(ifield.le.0.or.ifield.gt.nf) then
38.213 + print("read_field: fatal: you've selected a field that is")
38.214 + print("out-of-range of the number of fields that you have (" + nf + ").")
38.215 + exit
38.216 + end if
38.217 +;
38.218 +; We don't know what the biggest character array is at this point, so
38.219 +; make it bigger than necessary, and then resize later as necessary.
38.220 +;
38.221 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
38.222 +
38.223 + max_len = 0 ; Use to keep track of max lengths of strings.
38.224 +
38.225 + do i = 0,nrows-1
38.226 +;
38.227 +; Special case of first field in row.
38.228 +;
38.229 + if(ifield.eq.1) then
38.230 + ibeg = 0
38.231 + iend = indices(i,ifield-1)-1
38.232 + else
38.233 +;
38.234 +; Special case of first field in row.
38.235 +;
38.236 + if(ifield.eq.nf) then
38.237 + ibeg = indices(i,ifield-2)+1
38.238 + iend = dimsizes(cstrings(i,:))-1
38.239 +;
38.240 +; Any field between first and last field.
38.241 +;
38.242 + else
38.243 + ibeg = indices(i,ifield-2)+1
38.244 + iend = indices(i,ifield-1)-1
38.245 + end if
38.246 + end if
38.247 + if( (iend-ibeg+1) .gt. max_len) then
38.248 + max_len = iend-ibeg+1
38.249 + end if
38.250 + end do
38.251 +
38.252 + return(max_len)
38.253 +end
38.254 +
38.255 +;----------------------------------------------------------------------
38.256 +; Main code.
38.257 +;----------------------------------------------------------------------
38.258 +begin
38.259 +
38.260 +;###############################################################
38.261 +; Set up defaults. We are hard-coding here..
38.262 +
38.263 + year = 2005
38.264 + lat = 35.9735823
38.265 + lon = -79.1004304 + 360.
38.266 +
38.267 + nfields = 30 ; # of fields
38.268 + delimiter = "," ; field delimiter
38.269 +
38.270 + filename = year+".txt" ; ASCII" file to read.
38.271 + cdf_file = year+"_L4_m.nc" ; netCDF file to write.
38.272 +
38.273 + if(isfilepresent(cdf_file))
38.274 + print("Warning: '" + cdf_file + "' exists. Will remove it.")
38.275 + system("/bin/rm " + cdf_file)
38.276 + end if
38.277 +
38.278 +; In this case, fields #1-#2 are integers,
38.279 +; and the rest of the fields are floats.
38.280 +
38.281 + var_types = new(nfields,string)
38.282 + var_types = "float" ; Most are floats.
38.283 + var_types(0:1) = "integer"
38.284 +
38.285 +;#####################################################################
38.286 +
38.287 +; Read in data as strings. This will create a string array that has the
38.288 +; same number of strings as there are rows in the file. We will then need
38.289 +; to parse each string later.
38.290 +
38.291 + read_data = asciiread(filename,-1,"string")
38.292 +
38.293 + header = read_data(0) ; Header. Use for variable names.
38.294 + data = read_data(1:) ; Get rid of first line which is a header.
38.295 + nmonth = dimsizes(data) ; Number of rows == number of month.
38.296 +
38.297 +; Read in locations of delimiters in each string row.
38.298 +
38.299 + hindices = delim_indices(header,nfields,delimiter) ; header row
38.300 + dindices = delim_indices(data,nfields,delimiter) ; rest of file
38.301 +
38.302 +; Read in the field names which will become variable names on
38.303 +; the netCDF file.
38.304 +
38.305 + var_names = new(nfields,string)
38.306 +
38.307 + do i=0,nfields-1
38.308 + var_names(i) = read_field(header,i+1,hindices,"string")
38.309 + end do
38.310 +
38.311 +;-------------------------------------------------------------------
38.312 +; Write out this netCDF file efficiently so it will be faster.
38.313 +; Try to predefine everything before you write to it.
38.314 +
38.315 + f = addfile(cdf_file,"c")
38.316 + setfileoption(f,"DefineMode",True) ; Enter predefine phase.
38.317 +
38.318 +; Write global attributes to file. It's okay to do this before
38.319 +; predefining the file's variables. We are still in "define" mode.
38.320 +
38.321 + fAtt = True
38.322 + fAtt@description = "Data read in from " + filename + " ASCII file."
38.323 + fAtt@creation_date = systemfunc ("date")
38.324 + fileattdef( f, fAtt )
38.325 +
38.326 +; Write dimension names to file.
38.327 +
38.328 + dim_names = (/ "year", "month" /)
38.329 + dim_sizes = (/ -1 , nmonth /)
38.330 + dimUnlim = (/ True , False /)
38.331 + filedimdef( f, dim_names, dim_sizes, dimUnlim )
38.332 +
38.333 + filedimdef( f, "lat", 1, False )
38.334 + filedimdef( f, "lon", 1, False )
38.335 +
38.336 +; Define each variable on the file.
38.337 +
38.338 + filevardef( f, "year", "integer", "year" )
38.339 + filevardef( f, "lat" , "float" , "lat" )
38.340 + filevardef( f, "lon" , "float" , "lon" )
38.341 +
38.342 + do i=0,nfields-1
38.343 +
38.344 +; define variable
38.345 +
38.346 + filevardef(f, var_names(i), var_types(i), dim_names)
38.347 +
38.348 +; define variable attributes
38.349 +
38.350 + if (i.le.1) then
38.351 + varAtt = 0
38.352 +; varAtt@_FillValue = -999
38.353 + else
38.354 + varAtt = 0.
38.355 +; varAtt@_FillValue = 1.e36
38.356 + end if
38.357 +
38.358 + varAtt@long_name = var_names(i)
38.359 +
38.360 + filevarattdef( f, var_names(i) , varAtt )
38.361 +
38.362 + delete (varAtt)
38.363 + end do
38.364 +;-----------------------------------------------------------------
38.365 +
38.366 +; Loop through each field, read the values for that field, print
38.367 +; information about the variable, and then write it to the netCDF file.
38.368 +
38.369 + do i=0,nfields-1
38.370 + ifield = i+1 ; Fields start at #1, not #0.
38.371 +
38.372 + tmp_data = new((/1,nmonth/),var_types(i))
38.373 +
38.374 + if (i.le.1) then
38.375 + tmp_data@_FillValue = -999
38.376 + else
38.377 + tmp_data@_FillValue = 1.e36
38.378 + end if
38.379 +
38.380 + tmp_data(0,:) = read_field(data,ifield,dindices,var_types(i))
38.381 +
38.382 + tmp_data = where(tmp_data .le. -9000.,tmp_data@_FillValue,tmp_data)
38.383 +
38.384 +; change Month to yyyymm
38.385 +
38.386 + if (i.eq.0) then
38.387 + tmp_data(0,:) = tmp_data(0,:) + year*100
38.388 + end if
38.389 +
38.390 +; Print some info about the variable.
38.391 +
38.392 +; print("")
38.393 +; print("Writing variable '" + var_names(i) + "' (field #" + ifield + ").")
38.394 +; print("Type is " + var_types(i) + ".")
38.395 +; print("min/max = " + min(tmp_data) + "/" + max(tmp_data))
38.396 +
38.397 +; if(any(ismissing(tmp_data))) then
38.398 +; print("This variable does contain missing values.")
38.399 +; else
38.400 +; print("This variable doesn't contain missing values.")
38.401 +; end if
38.402 +
38.403 +; write variable to file
38.404 +
38.405 + f->$var_names(i)$ = tmp_data ; Write to netCDF file.
38.406 +
38.407 + delete(tmp_data) ; Delete for next round.
38.408 + end do
38.409 +
38.410 +; write variable to file
38.411 +
38.412 + f->year = year
38.413 + f->lat = lat
38.414 + f->lon = lon
38.415 +end
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
39.2 +++ b/ameriflux/07.missing_year.ncl Mon Jan 26 22:08:20 2009 -0500
39.3 @@ -0,0 +1,63 @@
39.4 +;************************************************************
39.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
39.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
39.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
39.8 +;************************************************************
39.9 +
39.10 +begin
39.11 +
39.12 + year_new = 2000
39.13 + file_input = "1999_L4_m.nc"
39.14 + file_output = year_new+"_L4_m.nc"
39.15 +
39.16 + a = addfile(file_input,"r")
39.17 + b = addfile(file_output,"c")
39.18 +;-------------------------------------------------------------------
39.19 +; Enter predefine phase.
39.20 +
39.21 +; Write global attributes to file. It's okay to do this before
39.22 +; predefining the file's variables. We are still in "define" mode.
39.23 +
39.24 + fAtt = True
39.25 + fAtt@description = "Data read in from " + file_input
39.26 + fAtt@creation_date = systemfunc ("date")
39.27 + fileattdef( b, fAtt )
39.28 +
39.29 + filedimdef( b,"year",-1,True)
39.30 +;-------------------------------------------------------------------
39.31 + month_of_year = (/1,2,3,4,5,6,7,8,9,10,11,12/)
39.32 +
39.33 + Var = getfilevarnames(a)
39.34 + nVar= dimsizes(Var)
39.35 +
39.36 +; do n = 0,nVar-1
39.37 +; print( (/Var(n)/))
39.38 +; end do
39.39 +
39.40 + do n = 0,nVar-1
39.41 +
39.42 + if (Var(n).ne."year" .and. Var(n).ne."Month" .and. Var(n).ne."n_days" .and. Var(n).ne."lat" .and. Var(n).ne."lon" ) then
39.43 +
39.44 + temp = a->$Var(n)$
39.45 + temp(0,:) = -999.
39.46 + b->$Var(n)$ = temp
39.47 + else
39.48 +
39.49 + if (Var(n).eq."year") then
39.50 + b->$Var(n)$ = year_new
39.51 + end if
39.52 +
39.53 + if (Var(n).eq."Month") then
39.54 + Month = a->$Var(n)$
39.55 + Month(0,:)= month_of_year + year_new * 100
39.56 + b->$Var(n)$ = Month
39.57 + end if
39.58 +
39.59 + if (Var(n).eq."n_days" .or. Var(n).eq."lat" .or. Var(n).eq."lon") then
39.60 + b->$Var(n)$ = a->$Var(n)$
39.61 + end if
39.62 +
39.63 + end if
39.64 + end do
39.65 +
39.66 +end
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
40.2 +++ b/ameriflux/07.ncl Mon Jan 26 22:08:20 2009 -0500
40.3 @@ -0,0 +1,63 @@
40.4 +;************************************************************
40.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
40.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
40.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
40.8 +;************************************************************
40.9 +
40.10 +begin
40.11 +
40.12 + year_new = 2000
40.13 + file_input = "1999_L4_m.nc"
40.14 + file_output = year_new+"_L4_m.nc"
40.15 +
40.16 + a = addfile(file_input,"r")
40.17 + b = addfile(file_output,"c")
40.18 +;-------------------------------------------------------------------
40.19 +; Enter predefine phase.
40.20 +
40.21 +; Write global attributes to file. It's okay to do this before
40.22 +; predefining the file's variables. We are still in "define" mode.
40.23 +
40.24 + fAtt = True
40.25 + fAtt@description = "Data read in from " + file_input
40.26 + fAtt@creation_date = systemfunc ("date")
40.27 + fileattdef( b, fAtt )
40.28 +
40.29 + filedimdef( b,"year",-1,True)
40.30 +;-------------------------------------------------------------------
40.31 + month_of_year = (/1,2,3,4,5,6,7,8,9,10,11,12/)
40.32 +
40.33 + Var = getfilevarnames(a)
40.34 + nVar= dimsizes(Var)
40.35 +
40.36 +; do n = 0,nVar-1
40.37 +; print( (/Var(n)/))
40.38 +; end do
40.39 +
40.40 + do n = 0,nVar-1
40.41 +
40.42 + if (Var(n).ne."year" .and. Var(n).ne."Month" .and. Var(n).ne."n_days" .and. Var(n).ne."lat" .and. Var(n).ne."lon" ) then
40.43 +
40.44 + temp = a->$Var(n)$
40.45 + temp(0,:) = -999.
40.46 + b->$Var(n)$ = temp
40.47 + else
40.48 +
40.49 + if (Var(n).eq."year") then
40.50 + b->$Var(n)$ = year_new
40.51 + end if
40.52 +
40.53 + if (Var(n).eq."Month") then
40.54 + Month = a->$Var(n)$
40.55 + Month(0,:)= month_of_year + year_new * 100
40.56 + b->$Var(n)$ = Month
40.57 + end if
40.58 +
40.59 + if (Var(n).eq."n_days" .or. Var(n).eq."lat" .or. Var(n).eq."lon") then
40.60 + b->$Var(n)$ = a->$Var(n)$
40.61 + end if
40.62 +
40.63 + end if
40.64 + end do
40.65 +
40.66 +end
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
41.2 +++ b/ameriflux/10.plot.ncl Mon Jan 26 22:08:20 2009 -0500
41.3 @@ -0,0 +1,575 @@
41.4 +;************************************************************
41.5 +; required command line input parameters:
41.6 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
41.7 +;
41.8 +; using gsn_table for all
41.9 +; output: line plot for each site (4 fields)
41.10 +; table for M_score
41.11 +;************************************************************
41.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
41.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
41.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
41.15 +;************************************************************
41.16 +procedure set_line(lines:string,nline:integer,newlines:string)
41.17 +begin
41.18 +; add line to ascci/html file
41.19 +
41.20 + nnewlines = dimsizes(newlines)
41.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
41.22 + print("set_line: bad index, not setting anything.")
41.23 + return
41.24 + end if
41.25 + lines(nline:nline+nnewlines-1) = newlines
41.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
41.27 + nline = nline + nnewlines
41.28 + return
41.29 +end
41.30 +;*************************************************************
41.31 +begin
41.32 +
41.33 + plot_type = "ps"
41.34 + plot_type_new = "png"
41.35 +
41.36 +; for 6 fields, 12-monthly
41.37 + nmon = 12
41.38 + nfield = 6
41.39 +
41.40 +;************************************************
41.41 +; read model data
41.42 +;************************************************
41.43 +; model = "cn"
41.44 + model = "casa"
41.45 +
41.46 + model_name = "i01.10" + model
41.47 +
41.48 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
41.49 + film = "lnd_T42.nc"
41.50 + fm = addfile(dirm+film,"r")
41.51 +
41.52 + xm = fm->lon
41.53 + ym = fm->lat
41.54 +;------------------------------------------------
41.55 + nlat = dimsizes(ym)
41.56 + nlon = dimsizes(xm)
41.57 +
41.58 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
41.59 +
41.60 +; change to unit of observed (u mol/m2/s)
41.61 +; Model_units [=] gC/m2/s
41.62 +; 12. = molecular weight of C
41.63 +; u mol = 1e-6 mol
41.64 + factor = 1e6 /12.
41.65 +
41.66 + ENERGY ="new"
41.67 +
41.68 +;************************************************
41.69 +; read data: observed
41.70 +;************************************************
41.71 +
41.72 + station = (/"HarvardForest" \
41.73 + /)
41.74 +
41.75 + year_ob = (/"1991-2004" \
41.76 + /)
41.77 +
41.78 + field = (/"CO2 Flux" \
41.79 + ,"Net Radiation" \
41.80 + ,"Latent Heat" \
41.81 + ,"Sensible Heat" \
41.82 + ,"GPP Flux" \
41.83 + ,"Respiration" \
41.84 + /)
41.85 +
41.86 + nstation = dimsizes(station)
41.87 +
41.88 + data_mod = new ((/nstation, nfield, nmon/),float)
41.89 + data_ob = new ((/nstation, nfield, nmon/),float)
41.90 + lat_ob = new ((/nstation/),float)
41.91 + lon_ob = new ((/nstation/),float)
41.92 +
41.93 + diro_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/"
41.94 + dirm_root = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
41.95 +
41.96 + do n = 0,nstation-1
41.97 +
41.98 +;-------------------------------------------------
41.99 +; get ob data
41.100 +
41.101 + diro = diro_root + station(n)+"/"
41.102 + filo = station(n)+"_"+year_ob(n)+"_monthly.nc"
41.103 + fo = addfile (diro+filo,"r")
41.104 +
41.105 + print (filo)
41.106 +
41.107 + lon_ob(n) = fo->lon
41.108 + lat_ob(n) = fo->lat
41.109 +
41.110 + data = fo->NEE_or_fMDS
41.111 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
41.112 + delete (data)
41.113 +
41.114 + data = fo->Rg_f
41.115 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
41.116 + delete (data)
41.117 +
41.118 + data = fo->LE_f
41.119 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
41.120 + delete (data)
41.121 +
41.122 + data = fo->H_f
41.123 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
41.124 + delete (data)
41.125 +
41.126 + data = fo->GPP_or_MDS
41.127 + data_ob(n,4,:) = dim_avg(data(month|:,year|:))
41.128 + delete (data)
41.129 +
41.130 + data = fo->Reco_or
41.131 + data_ob(n,5,:) = dim_avg(data(month|:,year|:))
41.132 + delete (data)
41.133 +
41.134 + delete (fo)
41.135 +;---------------------------------------------------
41.136 +; get model data
41.137 +
41.138 + film = model_name+"_"+year_ob(n)+"_MONS_climo.nc"
41.139 + fm = addfile (dirm_root+film,"r")
41.140 +
41.141 + print (film)
41.142 +
41.143 +if (ENERGY .eq. "old") then
41.144 +
41.145 + data = fm->NEE
41.146 + data_mod0(0,:,:,:) = data(:,:,:) * factor
41.147 + delete (data)
41.148 +
41.149 +; data = fm->LATENT
41.150 + data1 = fm->FCEV
41.151 + data2 = fm->FCTR
41.152 + data3 = fm->FGEV
41.153 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
41.154 + delete (data1)
41.155 + delete (data2)
41.156 + delete (data3)
41.157 +
41.158 +; data = fm->SENSIBLE
41.159 + data = fm->FSH
41.160 + data_mod0(3,:,:,:) = data(:,:,:)
41.161 + delete (data)
41.162 +
41.163 +; data = fm->NETRAD
41.164 + data1 = fm->FSA
41.165 + data2 = fm->FIRA
41.166 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)-data_mod0(2,:,:,:)-data_mod0(3,:,:,:)
41.167 + delete (data1)
41.168 + delete (data2)
41.169 +
41.170 +else
41.171 +
41.172 + data = fm->NEE
41.173 + data_mod0(0,:,:,:) = data(:,:,:) * factor
41.174 + delete (data)
41.175 +
41.176 + data = fm->NETRAD
41.177 + data_mod0(1,:,:,:) = data(:,:,:)
41.178 + delete (data)
41.179 +
41.180 + data = fm->LATENT
41.181 + data_mod0(2,:,:,:) = data(:,:,:)
41.182 + delete (data)
41.183 +
41.184 +; data = fm->SENSIBLE
41.185 + data = fm->FSH
41.186 + data_mod0(3,:,:,:) = data(:,:,:)
41.187 + delete (data)
41.188 +end if
41.189 +
41.190 + data = fm->GPP
41.191 + data_mod0(4,:,:,:) = data(:,:,:) * factor
41.192 + delete (data)
41.193 +
41.194 + if (model .eq. "cn") then
41.195 + data = fm->ER
41.196 + else
41.197 + data1 = fm->AR
41.198 + data2 = fm->HR
41.199 + data = data1 + data2
41.200 +
41.201 + delete (data1)
41.202 + delete (data2)
41.203 + end if
41.204 +
41.205 + data_mod0(5,:,:,:) = data(:,:,:) * factor
41.206 + delete (data)
41.207 +
41.208 + delete (fm)
41.209 +
41.210 +;************************************************************
41.211 +; interpolate model data into observed station
41.212 +; note: model is 0-360E, 90S-90N
41.213 +;************************************************************
41.214 +
41.215 +; to be able to handle observation at (-89.98,-24.80)
41.216 + ym(0) = -90.
41.217 +
41.218 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob(n),lat_ob(n),0)
41.219 +
41.220 +; print (yy)
41.221 +
41.222 + data_mod(n,:,:) = yy(:,:,0)
41.223 +
41.224 + delete (yy)
41.225 +
41.226 + end do
41.227 +;************************************************************
41.228 +; compute correlation coef and M score
41.229 +;************************************************************
41.230 +
41.231 + score_max = 5.
41.232 +
41.233 + ccr = new ((/nstation, nfield/),float)
41.234 + M_score = new ((/nstation, nfield/),float)
41.235 +
41.236 + do n=0,nstation-1
41.237 + do m=0,nfield-1
41.238 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
41.239 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
41.240 + M_score(n,m) = (1. -(bias/nmon)) * score_max
41.241 + end do
41.242 + end do
41.243 +
41.244 + M_co2 = avg(M_score(:,0))
41.245 + M_rad = avg(M_score(:,1))
41.246 + M_lh = avg(M_score(:,2))
41.247 + M_sh = avg(M_score(:,3))
41.248 + M_gpp = avg(M_score(:,4))
41.249 + M_er = avg(M_score(:,5))
41.250 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
41.251 +
41.252 + M_energy_co2 = sprintf("%.2f", M_co2)
41.253 + M_energy_rad = sprintf("%.2f", M_rad)
41.254 + M_energy_lh = sprintf("%.2f", M_lh )
41.255 + M_energy_sh = sprintf("%.2f", M_sh )
41.256 + M_energy_gpp = sprintf("%.2f", M_gpp)
41.257 + M_energy_er = sprintf("%.2f", M_er )
41.258 + M_energy_all = sprintf("%.2f", M_all)
41.259 +
41.260 +;*******************************************************************
41.261 +; for station line plot
41.262 +;*******************************************************************
41.263 +
41.264 +; for x-axis in xyplot
41.265 + mon = ispan(1,12,1)
41.266 + mon@long_name = "month"
41.267 +
41.268 + res = True ; plot mods desired
41.269 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
41.270 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
41.271 +;-------------------------------------------------------------------------
41.272 +; Add a boxed legend using the more simple method
41.273 +
41.274 + res@pmLegendDisplayMode = "Always"
41.275 +; res@pmLegendWidthF = 0.1
41.276 + res@pmLegendWidthF = 0.08
41.277 + res@pmLegendHeightF = 0.06
41.278 +; res@pmLegendOrthogonalPosF = -1.17
41.279 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
41.280 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
41.281 +
41.282 +; res@pmLegendParallelPosF = 0.18
41.283 + res@pmLegendParallelPosF = 0.23 ;(rightward)
41.284 +
41.285 +; res@lgPerimOn = False
41.286 + res@lgLabelFontHeightF = 0.015
41.287 + res@xyExplicitLegendLabels = (/"observed",model_name/)
41.288 +;-------------------------------------------------------------------
41.289 +; for panel plot
41.290 + res@gsnFrame = False ; Do not draw plot
41.291 + res@gsnDraw = False ; Do not advance frame
41.292 +
41.293 + pres = True ; panel plot mods desired
41.294 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
41.295 + ; indiv. plots in panel
41.296 + pres@gsnMaximize = True ; fill the page
41.297 +;-------------------------------------------------------------------
41.298 +
41.299 + plot_data = new((/2,12/),float)
41.300 + plot_data!0 = "case"
41.301 + plot_data!1 = "month"
41.302 +
41.303 + do n = 0,nstation-1
41.304 +;----------------------------
41.305 +; for observed
41.306 +
41.307 + plot_name = station(n)+"_ob"
41.308 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
41.309 + res@tiMainString = title
41.310 +
41.311 + wks = gsn_open_wks (plot_type,plot_name)
41.312 + plot=new(nfield,graphic) ; create graphic array
41.313 +
41.314 + plot_data(0,:) = (/data_ob (n,0,:)/)
41.315 + plot_data@long_name = field(0)
41.316 + plot(0)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 1
41.317 +
41.318 + plot_data(0,:) = (/data_ob (n,1,:)/)
41.319 + plot_data@long_name = field(1)
41.320 + plot(1)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 2
41.321 +
41.322 + plot_data(0,:) = (/data_ob (n,2,:)/)
41.323 + plot_data@long_name = field(2)
41.324 + plot(2)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 3
41.325 +
41.326 + plot_data(0,:) = (/data_ob (n,3,:)/)
41.327 + plot_data@long_name = field(3)
41.328 + plot(3)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 4
41.329 +
41.330 + plot_data(0,:) = (/data_ob (n,4,:)/)
41.331 + plot_data@long_name = field(4)
41.332 + plot(4)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 5
41.333 +
41.334 + plot_data(0,:) = (/data_ob (n,5,:)/)
41.335 + plot_data@long_name = field(5)
41.336 + plot(5)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 6
41.337 +
41.338 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
41.339 +
41.340 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
41.341 + "rm "+plot_name+"."+plot_type)
41.342 +
41.343 + clear (wks)
41.344 + delete (plot)
41.345 +;----------------------------
41.346 +; for model_vs_ob
41.347 +
41.348 + plot_name = station(n)+"_model_vs_ob"
41.349 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
41.350 + res@tiMainString = title
41.351 +
41.352 + wks = gsn_open_wks (plot_type,plot_name)
41.353 + plot=new(nfield,graphic) ; create graphic array
41.354 +
41.355 + plot_data(0,:) = (/data_ob (n,0,:)/)
41.356 + plot_data(1,:) = (/data_mod(n,0,:)/)
41.357 + plot_data@long_name = field(0)
41.358 + plot(0)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 1
41.359 +
41.360 + plot_data(0,:) = (/data_ob (n,1,:)/)
41.361 + plot_data(1,:) = (/data_mod(n,1,:)/)
41.362 + plot_data@long_name = field(1)
41.363 + plot(1)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 2
41.364 +
41.365 + plot_data(0,:) = (/data_ob (n,2,:)/)
41.366 + plot_data(1,:) = (/data_mod(n,2,:)/)
41.367 + plot_data@long_name = field(2)
41.368 + plot(2)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 3
41.369 +
41.370 + plot_data(0,:) = (/data_ob (n,3,:)/)
41.371 + plot_data(1,:) = (/data_mod(n,3,:)/)
41.372 + plot_data@long_name = field(3)
41.373 + plot(3)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 4
41.374 +
41.375 +
41.376 + plot_data(0,:) = (/data_ob (n,4,:)/)
41.377 + plot_data(1,:) = (/data_mod(n,4,:)/)
41.378 + plot_data@long_name = field(4)
41.379 + plot(4)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 5
41.380 +
41.381 +
41.382 + plot_data(0,:) = (/data_ob (n,5,:)/)
41.383 + plot_data(1,:) = (/data_mod(n,5,:)/)
41.384 + plot_data@long_name = field(5)
41.385 + plot(5)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 6
41.386 +
41.387 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
41.388 +
41.389 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
41.390 + "rm "+plot_name+"."+plot_type)
41.391 +
41.392 + clear (wks)
41.393 + delete (plot)
41.394 + end do
41.395 +
41.396 +;*******************************************************************
41.397 +; html table of site: observed
41.398 +;*******************************************************************
41.399 + output_html = "line_ob.html"
41.400 +
41.401 + header = (/"<HTML>" \
41.402 + ,"<HEAD>" \
41.403 + ,"<TITLE>CLAMP metrics</TITLE>" \
41.404 + ,"</HEAD>" \
41.405 + ,"<H1>Energy at Site: Observation</H1>" \
41.406 + /)
41.407 + footer = "</HTML>"
41.408 +
41.409 + table_header = (/ \
41.410 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
41.411 + ,"<tr>" \
41.412 + ," <th bgcolor=DDDDDD >Site Name</th>" \
41.413 + ," <th bgcolor=DDDDDD >Latitude</th>" \
41.414 + ," <th bgcolor=DDDDDD >Longitude</th>" \
41.415 + ," <th bgcolor=DDDDDD >Observed</th>" \
41.416 + ,"</tr>" \
41.417 + /)
41.418 + table_footer = "</table>"
41.419 + row_header = "<tr>"
41.420 + row_footer = "</tr>"
41.421 +
41.422 + lines = new(50000,string)
41.423 + nline = 0
41.424 +
41.425 + set_line(lines,nline,header)
41.426 + set_line(lines,nline,table_header)
41.427 +;-----------------------------------------------
41.428 +; row of table
41.429 +
41.430 + do n = 0,nstation-1
41.431 + set_line(lines,nline,row_header)
41.432 +
41.433 + txt0 = station(n)
41.434 + txt1 = sprintf("%5.2f", lat_ob(n))
41.435 + txt2 = sprintf("%5.2f", lon_ob(n))
41.436 + txt3 = year_ob(n)
41.437 +
41.438 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
41.439 + set_line(lines,nline,"<th>"+txt1+"</th>")
41.440 + set_line(lines,nline,"<th>"+txt2+"</th>")
41.441 + set_line(lines,nline,"<th>"+txt3+"</th>")
41.442 +
41.443 + set_line(lines,nline,row_footer)
41.444 + end do
41.445 +;-----------------------------------------------
41.446 + set_line(lines,nline,table_footer)
41.447 + set_line(lines,nline,footer)
41.448 +
41.449 +; Now write to an HTML file.
41.450 + idx = ind(.not.ismissing(lines))
41.451 + if(.not.any(ismissing(idx))) then
41.452 + asciiwrite(output_html,lines(idx))
41.453 + else
41.454 + print ("error?")
41.455 + end if
41.456 + delete (idx)
41.457 +
41.458 +;*******************************************************************
41.459 +; score and line table : model vs observed
41.460 +;*******************************************************************
41.461 + output_html = "score+line_vs_ob.html"
41.462 +
41.463 + header = (/"<HTML>" \
41.464 + ,"<HEAD>" \
41.465 + ,"<TITLE>CLAMP metrics</TITLE>" \
41.466 + ,"</HEAD>" \
41.467 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
41.468 + /)
41.469 + footer = "</HTML>"
41.470 +
41.471 + delete (table_header)
41.472 + table_header = (/ \
41.473 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
41.474 + ,"<tr>" \
41.475 + ," <th bgcolor=DDDDDD >Site Name</th>" \
41.476 + ," <th bgcolor=DDDDDD >Latitude</th>" \
41.477 + ," <th bgcolor=DDDDDD >Longitude</th>" \
41.478 + ," <th bgcolor=DDDDDD >Observed</th>" \
41.479 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
41.480 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
41.481 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
41.482 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
41.483 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
41.484 + ," <th bgcolor=DDDDDD >Respiration</th>" \
41.485 + ," <th bgcolor=DDDDDD >Average</th>" \
41.486 + ,"</tr>" \
41.487 + /)
41.488 + table_footer = "</table>"
41.489 + row_header = "<tr>"
41.490 + row_footer = "</tr>"
41.491 +
41.492 + lines = new(50000,string)
41.493 + nline = 0
41.494 +
41.495 + set_line(lines,nline,header)
41.496 + set_line(lines,nline,table_header)
41.497 +;-----------------------------------------------
41.498 +; row of table
41.499 +
41.500 + do n = 0,nstation-1
41.501 + set_line(lines,nline,row_header)
41.502 +
41.503 + txt0 = station(n)
41.504 + txt1 = sprintf("%5.2f", lat_ob(n))
41.505 + txt2 = sprintf("%5.2f", lon_ob(n))
41.506 + txt3 = year_ob(n)
41.507 + txt4 = sprintf("%5.2f", M_score(n,0))
41.508 + txt5 = sprintf("%5.2f", M_score(n,1))
41.509 + txt6 = sprintf("%5.2f", M_score(n,2))
41.510 + txt7 = sprintf("%5.2f", M_score(n,3))
41.511 + txt8 = sprintf("%5.2f", M_score(n,4))
41.512 + txt9 = sprintf("%5.2f", M_score(n,5))
41.513 + txt10 = sprintf("%5.2f", avg(M_score(n,:)))
41.514 +
41.515 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
41.516 + set_line(lines,nline,"<th>"+txt1+"</th>")
41.517 + set_line(lines,nline,"<th>"+txt2+"</th>")
41.518 + set_line(lines,nline,"<th>"+txt3+"</th>")
41.519 + set_line(lines,nline,"<th>"+txt4+"</th>")
41.520 + set_line(lines,nline,"<th>"+txt5+"</th>")
41.521 + set_line(lines,nline,"<th>"+txt6+"</th>")
41.522 + set_line(lines,nline,"<th>"+txt7+"</th>")
41.523 + set_line(lines,nline,"<th>"+txt8+"</th>")
41.524 + set_line(lines,nline,"<th>"+txt9+"</th>")
41.525 + set_line(lines,nline,"<th>"+txt10+"</th>")
41.526 +
41.527 + set_line(lines,nline,row_footer)
41.528 + end do
41.529 +
41.530 +; last row, summary
41.531 + set_line(lines,nline,row_header)
41.532 +
41.533 + txt0 = "All_"+sprintf("%.0f", nstation)
41.534 + txt1 = "-"
41.535 + txt2 = "-"
41.536 + txt3 = "-"
41.537 + txt4 = M_energy_co2
41.538 + txt5 = M_energy_rad
41.539 + txt6 = M_energy_lh
41.540 + txt7 = M_energy_sh
41.541 + txt8 = M_energy_gpp
41.542 + txt9 = M_energy_er
41.543 + txt10 = M_energy_all
41.544 +
41.545 + set_line(lines,nline,"<th>"+txt0+"</th>")
41.546 + set_line(lines,nline,"<th>"+txt1+"</th>")
41.547 + set_line(lines,nline,"<th>"+txt2+"</th>")
41.548 + set_line(lines,nline,"<th>"+txt3+"</th>")
41.549 + set_line(lines,nline,"<th>"+txt4+"</th>")
41.550 + set_line(lines,nline,"<th>"+txt5+"</th>")
41.551 + set_line(lines,nline,"<th>"+txt6+"</th>")
41.552 + set_line(lines,nline,"<th>"+txt7+"</th>")
41.553 + set_line(lines,nline,"<th>"+txt8+"</th>")
41.554 + set_line(lines,nline,"<th>"+txt9+"</th>")
41.555 + set_line(lines,nline,"<th>"+txt10+"</th>")
41.556 +
41.557 + set_line(lines,nline,row_footer)
41.558 +;-----------------------------------------------
41.559 + set_line(lines,nline,table_footer)
41.560 + set_line(lines,nline,footer)
41.561 +
41.562 +; Now write to an HTML file.
41.563 + idx = ind(.not.ismissing(lines))
41.564 + if(.not.any(ismissing(idx))) then
41.565 + asciiwrite(output_html,lines(idx))
41.566 + else
41.567 + print ("error?")
41.568 + end if
41.569 + delete (idx)
41.570 +
41.571 +;***************************************************************************
41.572 +; output plots
41.573 +;***************************************************************************
41.574 + output_dir = model_name+"/ameriflux"
41.575 +
41.576 + system("mv *.png *.html " + output_dir)
41.577 +;***************************************************************************
41.578 +end
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/ameriflux/11.ameriflux.ncl Mon Jan 26 22:08:20 2009 -0500
42.3 @@ -0,0 +1,910 @@
42.4 +;************************************************************
42.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
42.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
42.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
42.8 +;************************************************************
42.9 +procedure set_line(lines:string,nline:integer,newlines:string)
42.10 +begin
42.11 +; add line to ascci/html file
42.12 +
42.13 + nnewlines = dimsizes(newlines)
42.14 + if(nline+nnewlines-1.ge.dimsizes(lines))
42.15 + print("set_line: bad index, not setting anything.")
42.16 + return
42.17 + end if
42.18 + lines(nline:nline+nnewlines-1) = newlines
42.19 +; print ("lines = " + lines(nline:nline+nnewlines-1))
42.20 + nline = nline + nnewlines
42.21 + return
42.22 +end
42.23 +;*************************************************************
42.24 +begin
42.25 +
42.26 + plot_type = "ps"
42.27 + plot_type_new = "png"
42.28 +
42.29 +;------------------------------------------------------
42.30 +; edit table.html of current model for movel1_vs_model2
42.31 +
42.32 + if (isvar("compare")) then
42.33 + html_name2 = compare+"/table.html"
42.34 + html_new2 = html_name2 +".new"
42.35 + end if
42.36 +
42.37 +;------------------------------------------------------
42.38 +; edit table.html for current model
42.39 +
42.40 + html_name = model_name+"/table.html"
42.41 + html_new = html_name +".new"
42.42 +
42.43 +;------------------------------------------------------
42.44 +
42.45 + nmonth = 12
42.46 +
42.47 +; for nee, gpp, and ar
42.48 +; observed unit is gC/m2/day
42.49 +; model unit is gC/m2/s
42.50 +; to change to observed unit,
42.51 +
42.52 + factor_flux = 86400.
42.53 +
42.54 +; for incident solar radiation,
42.55 +; observed Rg_f unit is MJ/m2/day
42.56 +; model (FSDS) unit is W/m2
42.57 +; to change to model unit,
42.58 +
42.59 + factor_rad = 1.e6/86400.
42.60 +
42.61 +;************************************************
42.62 +; observed data info
42.63 +;************************************************
42.64 +
42.65 + station = (/"ARM_Oklahoma" \
42.66 + ,"ARM_Oklahoma_burn" \
42.67 + ,"ARM_Oklahoma_control" \
42.68 + ,"Atqasuk" \
42.69 + ,"Audubon" \
42.70 + ,"AustinCary" \
42.71 + ,"Bartlett" \
42.72 + ,"Bondville" \
42.73 + ,"Brookings" \
42.74 + ,"Donaldson" \
42.75 + ,"Duke_Forest_Hardwoods" \
42.76 + ,"Duke_Forest_Open_Field" \
42.77 + ,"Duke_Forest_Pine" \
42.78 + ,"Fermi_Ag" \
42.79 + ,"Fermi_Prairie" \
42.80 + ,"Flagstaff_Managed" \
42.81 + ,"Flagstaff_Unmanaged" \
42.82 + ,"Flagstaff_Wildfire" \
42.83 + ,"FortPeck" \
42.84 + ,"FreemanRanch_mesquite" \
42.85 + ,"Goodwin_Creek" \
42.86 + ,"HarvardForest" \
42.87 + ,"HarvardForestHemlock" \
42.88 + ,"HowlandForestMain" \
42.89 + ,"HowlandForestWest" \
42.90 + ,"Ivotuk" \
42.91 + ,"KendallGrasslands" \
42.92 + ,"KennedySpaceCenterPine" \
42.93 + ,"KennedySpaceCenterScrub" \
42.94 + ,"LittleProspect" \
42.95 + ,"LostCreek" \
42.96 + ,"Mead-irrigated" \
42.97 + ,"Mead-irrigated-rotation" \
42.98 + ,"Mead-rainfed" \
42.99 + ,"Metolius_2nd_YoungPonderosaPine" \
42.100 + ,"MetoliusEyerly" \
42.101 + ,"MetoliusIntermediatePine" \
42.102 + ,"MetoliusOldPonderosaPine" \
42.103 + ,"MissouriOzark" \
42.104 + ,"Mize" \
42.105 + ,"MorganMonroe" \
42.106 + ,"NiwotRidge" \
42.107 + ,"NorthCarolina_cc" \
42.108 + ,"NorthCarolina_lp" \
42.109 + ,"ParkFalls" \
42.110 + ,"Rayonier" \
42.111 + ,"SantaRita" \
42.112 + ,"SkyOaks_Old" \
42.113 + ,"SkyOaks_PostFire" \
42.114 + ,"SkyOaks_Young" \
42.115 + ,"SylvaniaWilderness" \
42.116 + ,"Toledo" \
42.117 + ,"Tonzi" \
42.118 + ,"UCI_1850" \
42.119 + ,"UCI_1930" \
42.120 + ,"UCI_1964" \
42.121 + ,"UCI_1964wet" \
42.122 + ,"UCI_1981" \
42.123 + ,"UCI_1989" \
42.124 + ,"UCI_1998" \
42.125 + ,"UMBS" \
42.126 + ,"Vaira" \
42.127 + ,"WalkerBranch" \
42.128 + ,"WillowCreek" \
42.129 + ,"WindRiver" \
42.130 + ,"Wisconsin_ihw" \
42.131 + ,"Wisconsin_irp" \
42.132 + ,"Wisconsin_mrp" \
42.133 + ,"Wisconsin_myjp" \
42.134 + ,"Wisconsin_pb" \
42.135 + ,"Wisconsin_rpcc" \
42.136 + ,"Wisconsin_yhw" \
42.137 + ,"Wisconsin_yjp" \
42.138 + ,"Wisconsin_yrp" \
42.139 + /)
42.140 +
42.141 + field = (/"NEE Flux" \
42.142 + ,"Shortwave Incoming" \
42.143 + ,"Latent Heat" \
42.144 + ,"Sensible Heat" \
42.145 + ,"GPP Flux" \
42.146 + ,"Respiration" \
42.147 + /)
42.148 +
42.149 + field_unit = (/"gC/m2/day" \
42.150 + ,"W/m2" \
42.151 + ,"W/m2" \
42.152 + ,"W/m2" \
42.153 + ,"gC/m2/day" \
42.154 + ,"gC/m2/day" \
42.155 + /)
42.156 +
42.157 + nstation = dimsizes(station)
42.158 + nfield = dimsizes(field)
42.159 +
42.160 +;========================================================================
42.161 +; get observed info: number of year, first/last year, lat, lon
42.162 +; and annual data
42.163 +
42.164 + dir_root = diro + "ameriflux/"
42.165 +
42.166 + year_station = new ((/nstation/),integer) ; number of year
42.167 + year_ob = new ((/nstation/),string) ; observed year
42.168 + year_ob_i = new ((/nstation/),integer) ; first year
42.169 + year_ob_f = new ((/nstation/),integer) ; last year
42.170 + lat_ob = new ((/nstation/),float) ; latitude
42.171 + lon_ob = new ((/nstation/),float) ; longitude
42.172 +
42.173 + data_ob_ann = new ((/nfield, nmonth, nstation/),float)
42.174 +
42.175 + do n = 0, nstation-1
42.176 +
42.177 + dir_f = dir_root + station(n)+"/"
42.178 + fil_f = "timeseries_L4_m.nc"
42.179 + fo = addfile (dir_f+fil_f,"r")
42.180 +
42.181 + lat_ob(n) = fo->lat
42.182 + lon_ob(n) = fo->lon
42.183 +
42.184 + year = fo->year
42.185 +
42.186 + year_station(n) = dimsizes(year)
42.187 + year_ob_i(n) = year(0)
42.188 + year_ob_f(n) = year(year_station(n)-1)
42.189 + year_ob(n) = year_ob_i(n) + "-" + year_ob_f(n)
42.190 +
42.191 + delete (year)
42.192 +
42.193 + data = fo->NEE_or_fMDS
42.194 + data_ob_ann(0,:,n) = dim_avg(data(month|:,year|:))
42.195 +
42.196 + data = fo->Rg_f
42.197 + data_ob_ann(1,:,n) = dim_avg(data(month|:,year|:)) * factor_rad
42.198 +
42.199 + data = fo->LE_f
42.200 + data_ob_ann(2,:,n) = dim_avg(data(month|:,year|:))
42.201 +
42.202 + data = fo->H_f
42.203 + data_ob_ann(3,:,n) = dim_avg(data(month|:,year|:))
42.204 +
42.205 + data = fo->GPP_or_MDS
42.206 + data_ob_ann(4,:,n) = dim_avg(data(month|:,year|:))
42.207 +
42.208 + data = fo->Reco_or
42.209 + data_ob_ann(5,:,n) = dim_avg(data(month|:,year|:))
42.210 +
42.211 + delete (data)
42.212 + delete (fo)
42.213 + end do
42.214 +
42.215 +;--------------------------------------------------------------
42.216 +; find (# of year observed) >=4 and year_ob_i <= 2001
42.217 +
42.218 + i_long_ob = ind(year_station .ge. 4 .and. year_ob_i .le. 2001)
42.219 +
42.220 + station_long = station(i_long_ob)
42.221 + lat_ob_long = lat_ob(i_long_ob)
42.222 + lon_ob_long = lat_ob(i_long_ob)
42.223 + year_ob_long = year_ob(i_long_ob)
42.224 + year_ob_i_long = year_ob_i(i_long_ob)
42.225 + year_ob_f_long = year_ob_f(i_long_ob)
42.226 + year_station_long = year_station(i_long_ob)
42.227 +
42.228 + nstation_long = dimsizes(station_long)
42.229 +
42.230 +;=========================================================
42.231 +; get model data at observed lat-lon
42.232 +
42.233 + fm = addfile (dirm+film8,"r")
42.234 +
42.235 + xm = fm->lon
42.236 + ym = fm->lat
42.237 + date = fm->date
42.238 +
42.239 + date_dim = dimsizes(date)
42.240 + nyear = date_dim(0)
42.241 +
42.242 + data_mod = new ((/nfield,nyear,nmonth,nstation/),float)
42.243 + data_mod_ann = new ((/nfield,nmonth,nstation/),float)
42.244 + data_mod_long = new ((/nfield,nyear,nmonth,nstation_long/),float)
42.245 +
42.246 +; change to unit of observed (u mol/m2/s)
42.247 +; Model_units [=] gC/m2/s
42.248 +; 12. = molecular weight of C
42.249 +; u mol = 1e-6 mol
42.250 +
42.251 + factor = 1.e6 /12.
42.252 +
42.253 +;------------------------------------------------------------
42.254 +; interpolate model data into observed station
42.255 +; note: model is 0-360E, 90S-90N
42.256 +
42.257 +; to be able to handle observation at (-89.98,-24.80)
42.258 + ym(0) = -90.
42.259 +;------------------------------------------------------------
42.260 +
42.261 +if (ENERGY .eq. "old") then
42.262 +
42.263 + data = fm->NEE
42.264 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
42.265 + data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
42.266 + data_mod(0,:,:,:) = yy(:,:,:) * factor_flux
42.267 +
42.268 +;;data = fm->NETRAD
42.269 +; data = fm->FSA
42.270 +; data1 = fm->FIRA
42.271 +; data = data - data1
42.272 +; delete (data1)
42.273 +
42.274 + data = fm->FSDS
42.275 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
42.276 + data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:))
42.277 + data_mod(1,:,:,:) = yy(:,:,:)
42.278 +
42.279 +
42.280 +; data = fm->LATENT
42.281 + data = fm->FCEV
42.282 + data1 = fm->FCTR
42.283 + data2 = fm->FGEV
42.284 + data = data + data1 + data2
42.285 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
42.286 + data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:))
42.287 + data_mod(2,:,:,:) = yy(:,:,:)
42.288 + delete (data1)
42.289 + delete (data2)
42.290 +
42.291 +; data = fm->SENSIBLE
42.292 + data = fm->FSH
42.293 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
42.294 + data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:))
42.295 + data_mod(3,:,:,:) = yy(:,:,:)
42.296 +
42.297 +else
42.298 +
42.299 + data = fm->NEE
42.300 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
42.301 + data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
42.302 + data_mod(0,:,:,:) = yy(:,:,:) * factor_flux
42.303 +
42.304 +; data = fm->NETRAD
42.305 + data = fm->FSDS
42.306 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
42.307 + data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:))
42.308 + data_mod(1,:,:,:) = yy(:,:,:)
42.309 +
42.310 + data = fm->LATENT
42.311 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
42.312 + data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:))
42.313 + data_mod(2,:,:,:) = yy(:,:,:)
42.314 +
42.315 +; data = fm->SENSIBLE
42.316 + data = fm->FSH
42.317 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
42.318 + data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:))
42.319 + data_mod(3,:,:,:) = yy(:,:,:)
42.320 +
42.321 +end if
42.322 +
42.323 + data = fm->GPP
42.324 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
42.325 + data_mod_ann(4,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
42.326 + data_mod(4,:,:,:) = yy(:,:,:) * factor_flux
42.327 +
42.328 + data = fm->ER
42.329 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
42.330 + data_mod_ann(5,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
42.331 + data_mod(5,:,:,:) = yy(:,:,:) * factor_flux
42.332 +
42.333 + data_mod_long(:,:,:,:) = data_mod(:,:,:,i_long_ob)
42.334 +
42.335 + delete (data_mod)
42.336 + delete (fm)
42.337 + delete (data)
42.338 + delete (yy)
42.339 +
42.340 + asciiwrite(station(0)+"_ob.txt", data_ob_ann(:,:,0))
42.341 + asciiwrite(station(0)+"_"+model_name+".txt", data_mod_ann(:,:,0))
42.342 +
42.343 + asciiwrite(station(7)+"_ob.txt", data_ob_ann(:,:,7))
42.344 + asciiwrite(station(7)+"_"+model_name+".txt", data_mod_ann(:,:,7))
42.345 +
42.346 + asciiwrite(station(21)+"_ob.txt", data_ob_ann(:,:,21))
42.347 + asciiwrite(station(21)+"_"+model_name+".txt", data_mod_ann(:,:,21))
42.348 +
42.349 + asciiwrite(station(44)+"_ob.txt", data_ob_ann(:,:,44))
42.350 + asciiwrite(station(44)+"_"+model_name+".txt", data_mod_ann(:,:,44))
42.351 +
42.352 + asciiwrite(station(50)+"_ob.txt", data_ob_ann(:,:,50))
42.353 + asciiwrite(station(50)+"_"+model_name+".txt", data_mod_ann(:,:,50))
42.354 +
42.355 + asciiwrite(station(54)+"_ob.txt", data_ob_ann(:,:,54))
42.356 + asciiwrite(station(54)+"_"+model_name+".txt", data_mod_ann(:,:,54))
42.357 +
42.358 + asciiwrite(station(62)+"_ob.txt", data_ob_ann(:,:,62))
42.359 + asciiwrite(station(62)+"_"+model_name+".txt", data_mod_ann(:,:,62))
42.360 +exit
42.361 +
42.362 +;*******************************************************************
42.363 +; for station line plot
42.364 +;*******************************************************************
42.365 +
42.366 +; for x-axis in xyplot
42.367 + mon = ispan(1,12,1)
42.368 + mon@long_name = "month"
42.369 +
42.370 + res = True ; plot mods desired
42.371 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
42.372 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
42.373 +
42.374 + res@tmXBFormat = "f" ; not to add trailing zeros
42.375 +
42.376 +;-------------------------------------------------------------------------
42.377 +; Add a boxed legend using the more simple method
42.378 +
42.379 + res@pmLegendDisplayMode = "Always"
42.380 +; res@pmLegendWidthF = 0.1
42.381 + res@pmLegendWidthF = 0.08
42.382 + res@pmLegendHeightF = 0.06
42.383 +; res@pmLegendOrthogonalPosF = -1.17
42.384 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
42.385 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
42.386 +
42.387 +; res@pmLegendParallelPosF = 0.18
42.388 + res@pmLegendParallelPosF = 0.23 ;(rightward)
42.389 +
42.390 +; res@lgPerimOn = False
42.391 + res@lgLabelFontHeightF = 0.015
42.392 + res@xyExplicitLegendLabels = (/"observed",model_name/)
42.393 +;-------------------------------------------------------------------
42.394 +; for panel plot
42.395 + res@gsnFrame = False ; Do not draw plot
42.396 + res@gsnDraw = False ; Do not advance frame
42.397 +
42.398 + pres = True ; panel plot mods desired
42.399 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
42.400 + ; indiv. plots in panel
42.401 + pres@gsnMaximize = True ; fill the page
42.402 +;-------------------------------------------------------------------
42.403 +
42.404 +;==============================================================
42.405 +; get ob data at each site with long observation
42.406 +
42.407 + do n = 0,nstation_long-1
42.408 +
42.409 +;##################################################################
42.410 +; hardwired: model up to year 2004
42.411 +; observed up to year 2006
42.412 +
42.413 + year_setback = 0
42.414 +
42.415 + nyear = year_station_long(n)
42.416 +
42.417 + if (year_ob_f_long(n).eq. 2006) then
42.418 + year_setback = 2006 -2004
42.419 + end if
42.420 + if (year_ob_f_long(n).eq. 2005) then
42.421 + year_setback = 2005 -2004
42.422 + end if
42.423 +;##################################################################
42.424 +
42.425 + ntime = (nyear - year_setback) * nmonth
42.426 +
42.427 + data_ob = new ((/nfield, nyear, nmonth/),float)
42.428 +
42.429 + dir_f = dir_root + station_long(n)+"/"
42.430 + fil_f = "timeseries_L4_m.nc"
42.431 + fo = addfile (dir_f+fil_f,"r")
42.432 +
42.433 + data_ob(0,:,:) = fo->NEE_or_fMDS
42.434 + data_ob(1,:,:) = fo->Rg_f
42.435 + data_ob(2,:,:) = fo->LE_f
42.436 + data_ob(3,:,:) = fo->H_f
42.437 + data_ob(4,:,:) = fo->GPP_or_MDS
42.438 + data_ob(5,:,:) = fo->Reco_or
42.439 +
42.440 + data_ob(1,:,:) = data_ob(1,:,:) * factor_rad
42.441 +
42.442 + delete (fo)
42.443 +
42.444 + timeI = new((/ntime/),integer)
42.445 + timeF = new((/ntime/),float)
42.446 + timeI = ispan(1,ntime,1)
42.447 + timeF = year_ob_i_long(n) + (timeI-1)/12.
42.448 + timeF@long_name = "year"
42.449 +
42.450 + plot_data = new((/2,ntime/),float)
42.451 +
42.452 +;----------------------------
42.453 +; for model_vs_ob
42.454 +
42.455 + plot_name = station_long(n)+"_tseries_vs_ob"
42.456 + title = station_long(n)+"("+sprintf("%5.2f",lat_ob_long(n))+","+sprintf("%5.2f",lon_ob_long(n))+")"
42.457 + res@tiMainString = title
42.458 +
42.459 + wks = gsn_open_wks (plot_type,plot_name)
42.460 + plot=new(nfield,graphic) ; create graphic array
42.461 +
42.462 + i_year_mod_i = year_ob_i_long(n) - 1990
42.463 + i_year_mod_f = i_year_mod_i + nyear - 1 - year_setback
42.464 +
42.465 + i_year_ob_f = nyear - year_setback - 1
42.466 +
42.467 +; print (nyear)
42.468 +; print (i_year_ob_f)
42.469 +; print (i_year_mod_i)
42.470 +; print (i_year_mod_f)
42.471 +
42.472 + do i = 0,nfield-1
42.473 + plot_data(0,:) = ndtooned(data_ob (i,0:i_year_ob_f,:))
42.474 + plot_data(1,:) = ndtooned(data_mod_long(i,i_year_mod_i:i_year_mod_f,:,n))
42.475 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
42.476 + plot(i)=gsn_csm_xy(wks,timeF,plot_data,res) ; create plot
42.477 + end do
42.478 +
42.479 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
42.480 +
42.481 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
42.482 + "rm "+plot_name+"."+plot_type)
42.483 +
42.484 + clear (wks)
42.485 + delete (plot)
42.486 +
42.487 + delete (data_ob)
42.488 + delete (timeI)
42.489 + delete (timeF)
42.490 + delete (plot_data)
42.491 +
42.492 + end do
42.493 +
42.494 +;###################################################################
42.495 +; for the following tables,
42.496 +; sort by latitude in decending order (N->S)
42.497 +
42.498 + isort = dim_pqsort(lat_ob_long,-1)
42.499 +
42.500 + station_sort = station_long(isort)
42.501 + year_ob_sort = year_ob_long(isort)
42.502 + lat_ob_sort = lat_ob_long(isort)
42.503 + lon_ob_sort = lon_ob_long(isort)
42.504 +
42.505 +; print(isort)
42.506 +; print(lat_ob_sort)
42.507 +
42.508 +;*******************************************************************
42.509 +; html table of site: observed
42.510 +;*******************************************************************
42.511 + output_html = "tseries_vs_ob.html"
42.512 +
42.513 + header = (/"<HTML>" \
42.514 + ,"<HEAD>" \
42.515 + ,"<TITLE>CLAMP metrics</TITLE>" \
42.516 + ,"</HEAD>" \
42.517 + ,"<H1>Timeseries at Site: "+model_name+" vs Observation</H1>" \
42.518 + /)
42.519 + footer = "</HTML>"
42.520 +
42.521 + table_header = (/ \
42.522 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
42.523 + ,"<tr>" \
42.524 + ," <th bgcolor=DDDDDD >Site Name</th>" \
42.525 + ," <th bgcolor=DDDDDD >Latitude</th>" \
42.526 + ," <th bgcolor=DDDDDD >Longitude</th>" \
42.527 + ," <th bgcolor=DDDDDD >Observed</th>" \
42.528 + ,"</tr>" \
42.529 + /)
42.530 + table_footer = "</table>"
42.531 + row_header = "<tr>"
42.532 + row_footer = "</tr>"
42.533 +
42.534 + lines = new(50000,string)
42.535 + nline = 0
42.536 +
42.537 + set_line(lines,nline,header)
42.538 + set_line(lines,nline,table_header)
42.539 +;-----------------------------------------------
42.540 +; row of table
42.541 +
42.542 + do n = 0,nstation_long-1
42.543 +
42.544 + set_line(lines,nline,row_header)
42.545 +
42.546 + txt0 = station_sort(n)
42.547 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
42.548 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
42.549 + txt3 = year_ob_sort(n)
42.550 +
42.551 + set_line(lines,nline,"<th><a href="+txt0+"_tseries_vs_ob.png>"+txt0+"</a></th>")
42.552 + set_line(lines,nline,"<th>"+txt1+"</th>")
42.553 + set_line(lines,nline,"<th>"+txt2+"</th>")
42.554 + set_line(lines,nline,"<th>"+txt3+"</th>")
42.555 +
42.556 + set_line(lines,nline,row_footer)
42.557 + end do
42.558 +;-----------------------------------------------
42.559 + set_line(lines,nline,table_footer)
42.560 + set_line(lines,nline,footer)
42.561 +
42.562 +; Now write to an HTML file.
42.563 + idx = ind(.not.ismissing(lines))
42.564 + if(.not.any(ismissing(idx))) then
42.565 + asciiwrite(output_html,lines(idx))
42.566 + else
42.567 + print ("error?")
42.568 + end if
42.569 + delete (idx)
42.570 +
42.571 + delete (isort)
42.572 + delete (station_sort)
42.573 + delete (year_ob_sort)
42.574 + delete (lat_ob_sort)
42.575 + delete (lon_ob_sort)
42.576 +
42.577 +;************************************************************
42.578 +; compute annual cycle correlation coef and M score
42.579 +;************************************************************
42.580 +
42.581 + score_max = 1.
42.582 +
42.583 + ccr = new ((/nstation, nfield/),float)
42.584 + M_score = new ((/nstation, nfield/),float)
42.585 +
42.586 + do n=0,nstation-1
42.587 + do m=0,nfield-1
42.588 + ccr(n,m) = esccr(data_ob_ann(m,:,n),data_mod_ann(m,:,n),0)
42.589 + 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))))
42.590 + M_score(n,m) = (1. -(bias/nmonth)) * score_max
42.591 + end do
42.592 + end do
42.593 +
42.594 + M_nee = avg(M_score(:,0))
42.595 + M_rad = avg(M_score(:,1))
42.596 + M_lh = avg(M_score(:,2))
42.597 + M_sh = avg(M_score(:,3))
42.598 + M_gpp = avg(M_score(:,4))
42.599 + M_er = avg(M_score(:,5))
42.600 + M_all = M_nee+ M_rad +M_lh + M_sh + M_gpp + M_er
42.601 +
42.602 + M_ameriflux_nee = sprintf("%.2f", M_nee)
42.603 + M_ameriflux_rad = sprintf("%.2f", M_rad)
42.604 + M_ameriflux_lh = sprintf("%.2f", M_lh )
42.605 + M_ameriflux_sh = sprintf("%.2f", M_sh )
42.606 + M_ameriflux_gpp = sprintf("%.2f", M_gpp)
42.607 + M_ameriflux_er = sprintf("%.2f", M_er )
42.608 + M_ameriflux_all = sprintf("%.2f", M_all)
42.609 +
42.610 +;*******************************************************************
42.611 +; for station line plot
42.612 +;*******************************************************************
42.613 +
42.614 +; for x-axis in xyplot
42.615 + mon = ispan(1,12,1)
42.616 + mon@long_name = "month"
42.617 +
42.618 +;-------------------------------------------------------------------
42.619 +
42.620 + plot_data = new((/2,nmonth/),float)
42.621 + plot_data!0 = "case"
42.622 + plot_data!1 = "month"
42.623 +
42.624 + do n = 0,nstation-1
42.625 +;----------------------------
42.626 +; for observed
42.627 +
42.628 + plot_name = station(n)+"_ob"
42.629 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
42.630 + res@tiMainString = title
42.631 +
42.632 + wks = gsn_open_wks (plot_type,plot_name)
42.633 + plot=new(nfield,graphic) ; create graphic array
42.634 +
42.635 + do i = 0,nfield-1
42.636 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
42.637 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
42.638 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
42.639 + end do
42.640 +
42.641 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
42.642 +
42.643 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
42.644 + "rm "+plot_name+"."+plot_type)
42.645 +
42.646 + clear (wks)
42.647 + delete (plot)
42.648 +;----------------------------
42.649 +; for model_vs_ob
42.650 +
42.651 + plot_name = station(n)+"_model_vs_ob"
42.652 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
42.653 + res@tiMainString = title
42.654 +
42.655 + wks = gsn_open_wks (plot_type,plot_name)
42.656 + plot=new(nfield,graphic) ; create graphic array
42.657 +
42.658 + do i = 0,nfield-1
42.659 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
42.660 + plot_data(1,:) = (/data_mod_ann(i,:,n)/)
42.661 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
42.662 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
42.663 + end do
42.664 +
42.665 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
42.666 +
42.667 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
42.668 + "rm "+plot_name+"."+plot_type)
42.669 +
42.670 + clear (wks)
42.671 + delete (plot)
42.672 + end do
42.673 +
42.674 +;###################################################################
42.675 +; for the following tables,
42.676 +; sort by latitude in decending order (N->S)
42.677 +; sort by lat in decending order (N->S)
42.678 +
42.679 + isort = dim_pqsort(lat_ob,-1)
42.680 +
42.681 + station_sort = station(isort)
42.682 + year_ob_sort = year_ob(isort)
42.683 + lat_ob_sort = lat_ob(isort)
42.684 + lon_ob_sort = lon_ob(isort)
42.685 + M_score_sort = M_score(isort,:)
42.686 +
42.687 +; print(isort)
42.688 +; print(lat_ob_sort)
42.689 +;###################################################################
42.690 +;*******************************************************************
42.691 +; html table of site: observed
42.692 +;*******************************************************************
42.693 + output_html = "line_ob.html"
42.694 +
42.695 + header = (/"<HTML>" \
42.696 + ,"<HEAD>" \
42.697 + ,"<TITLE>CLAMP metrics</TITLE>" \
42.698 + ,"</HEAD>" \
42.699 + ,"<H1>Energy at Site: Observation</H1>" \
42.700 + /)
42.701 + footer = "</HTML>"
42.702 +
42.703 + table_header = (/ \
42.704 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
42.705 + ,"<tr>" \
42.706 + ," <th bgcolor=DDDDDD >Site Name</th>" \
42.707 + ," <th bgcolor=DDDDDD >Latitude</th>" \
42.708 + ," <th bgcolor=DDDDDD >Longitude</th>" \
42.709 + ," <th bgcolor=DDDDDD >Observed</th>" \
42.710 + ,"</tr>" \
42.711 + /)
42.712 + table_footer = "</table>"
42.713 + row_header = "<tr>"
42.714 + row_footer = "</tr>"
42.715 +
42.716 + lines = new(50000,string)
42.717 + nline = 0
42.718 +
42.719 + set_line(lines,nline,header)
42.720 + set_line(lines,nline,table_header)
42.721 +;-----------------------------------------------
42.722 +; row of table
42.723 +
42.724 + do n = 0,nstation-1
42.725 + set_line(lines,nline,row_header)
42.726 +
42.727 + txt0 = station_sort(n)
42.728 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
42.729 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
42.730 + txt3 = year_ob_sort(n)
42.731 +
42.732 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
42.733 + set_line(lines,nline,"<th>"+txt1+"</th>")
42.734 + set_line(lines,nline,"<th>"+txt2+"</th>")
42.735 + set_line(lines,nline,"<th>"+txt3+"</th>")
42.736 +
42.737 + set_line(lines,nline,row_footer)
42.738 + end do
42.739 +;-----------------------------------------------
42.740 + set_line(lines,nline,table_footer)
42.741 + set_line(lines,nline,footer)
42.742 +
42.743 +; Now write to an HTML file.
42.744 + idx = ind(.not.ismissing(lines))
42.745 + if(.not.any(ismissing(idx))) then
42.746 + asciiwrite(output_html,lines(idx))
42.747 + else
42.748 + print ("error?")
42.749 + end if
42.750 + delete (idx)
42.751 +
42.752 +;*******************************************************************
42.753 +; score and line table : model vs observed
42.754 +;*******************************************************************
42.755 + output_html = "score+line_vs_ob.html"
42.756 +
42.757 + header = (/"<HTML>" \
42.758 + ,"<HEAD>" \
42.759 + ,"<TITLE>CLAMP metrics</TITLE>" \
42.760 + ,"</HEAD>" \
42.761 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
42.762 + /)
42.763 + footer = "</HTML>"
42.764 +
42.765 + delete (table_header)
42.766 + table_header = (/ \
42.767 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
42.768 + ,"<tr>" \
42.769 + ," <th bgcolor=DDDDDD >Site Name</th>" \
42.770 + ," <th bgcolor=DDDDDD >Latitude</th>" \
42.771 + ," <th bgcolor=DDDDDD >Longitude</th>" \
42.772 + ," <th bgcolor=DDDDDD >Observed</th>" \
42.773 + ," <th bgcolor=DDDDDD >NEE Flux</th>" \
42.774 + ," <th bgcolor=DDDDDD >Shortwave <br> Incoming</th>" \
42.775 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
42.776 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
42.777 + ," <th bgcolor=DDDDDD >GPP Flux</th>" \
42.778 + ," <th bgcolor=DDDDDD >Respiration</th>" \
42.779 + ," <th bgcolor=DDDDDD >Average</th>" \
42.780 + ,"</tr>" \
42.781 + /)
42.782 + table_footer = "</table>"
42.783 + row_header = "<tr>"
42.784 + row_footer = "</tr>"
42.785 +
42.786 + lines = new(50000,string)
42.787 + nline = 0
42.788 +
42.789 + set_line(lines,nline,header)
42.790 + set_line(lines,nline,table_header)
42.791 +;-----------------------------------------------
42.792 +; row of table
42.793 +
42.794 + do n = 0,nstation-1
42.795 + set_line(lines,nline,row_header)
42.796 +
42.797 + txt0 = station_sort(n)
42.798 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
42.799 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
42.800 + txt3 = year_ob_sort(n)
42.801 + txt4 = sprintf("%5.2f", M_score_sort(n,0))
42.802 + txt5 = sprintf("%5.2f", M_score_sort(n,1))
42.803 + txt6 = sprintf("%5.2f", M_score_sort(n,2))
42.804 + txt7 = sprintf("%5.2f", M_score_sort(n,3))
42.805 + txt8 = sprintf("%5.2f", M_score_sort(n,4))
42.806 + txt9 = sprintf("%5.2f", M_score_sort(n,5))
42.807 + txt10 = sprintf("%5.2f", avg(M_score_sort(n,:)))
42.808 +
42.809 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
42.810 + set_line(lines,nline,"<th>"+txt1+"</th>")
42.811 + set_line(lines,nline,"<th>"+txt2+"</th>")
42.812 + set_line(lines,nline,"<th>"+txt3+"</th>")
42.813 + set_line(lines,nline,"<th>"+txt4+"</th>")
42.814 + set_line(lines,nline,"<th>"+txt5+"</th>")
42.815 + set_line(lines,nline,"<th>"+txt6+"</th>")
42.816 + set_line(lines,nline,"<th>"+txt7+"</th>")
42.817 + set_line(lines,nline,"<th>"+txt8+"</th>")
42.818 + set_line(lines,nline,"<th>"+txt9+"</th>")
42.819 + set_line(lines,nline,"<th>"+txt10+"</th>")
42.820 +
42.821 + set_line(lines,nline,row_footer)
42.822 + end do
42.823 +
42.824 +; last row, summary
42.825 + set_line(lines,nline,row_header)
42.826 +
42.827 + txt0 = "All_"+sprintf("%.0f", nstation)
42.828 + txt1 = "-"
42.829 + txt2 = "-"
42.830 + txt3 = "-"
42.831 + txt4 = M_ameriflux_nee
42.832 + txt5 = M_ameriflux_rad
42.833 + txt6 = M_ameriflux_lh
42.834 + txt7 = M_ameriflux_sh
42.835 + txt8 = M_ameriflux_gpp
42.836 + txt9 = M_ameriflux_er
42.837 + txt10 = M_ameriflux_all
42.838 +
42.839 + set_line(lines,nline,"<th>"+txt0+"</th>")
42.840 + set_line(lines,nline,"<th>"+txt1+"</th>")
42.841 + set_line(lines,nline,"<th>"+txt2+"</th>")
42.842 + set_line(lines,nline,"<th>"+txt3+"</th>")
42.843 + set_line(lines,nline,"<th>"+txt4+"</th>")
42.844 + set_line(lines,nline,"<th>"+txt5+"</th>")
42.845 + set_line(lines,nline,"<th>"+txt6+"</th>")
42.846 + set_line(lines,nline,"<th>"+txt7+"</th>")
42.847 + set_line(lines,nline,"<th>"+txt8+"</th>")
42.848 + set_line(lines,nline,"<th>"+txt9+"</th>")
42.849 + set_line(lines,nline,"<th>"+txt10+"</th>")
42.850 +
42.851 + set_line(lines,nline,row_footer)
42.852 +;-----------------------------------------------
42.853 + set_line(lines,nline,table_footer)
42.854 + set_line(lines,nline,footer)
42.855 +
42.856 +; Now write to an HTML file.
42.857 + idx = ind(.not.ismissing(lines))
42.858 + if(.not.any(ismissing(idx))) then
42.859 + asciiwrite(output_html,lines(idx))
42.860 + else
42.861 + print ("error?")
42.862 + end if
42.863 + delete (idx)
42.864 +
42.865 +;**************************************************************************************
42.866 +; update score
42.867 +;**************************************************************************************
42.868 +
42.869 + if (isvar("compare")) then
42.870 + system("sed 1,/M_ameriflux_nee/s//"+M_ameriflux_nee+"/ "+html_name2+" > "+html_new2+";"+ \
42.871 + "mv -f "+html_new2+" "+html_name2+";"+ \
42.872 + "sed 1,/M_ameriflux_rad/s//"+M_ameriflux_rad+"/ "+html_name2+" > "+html_new2+";"+ \
42.873 + "mv -f "+html_new2+" "+html_name2+";"+ \
42.874 + "sed 1,/M_ameriflux_lh/s//"+M_ameriflux_lh+"/ "+html_name2+" > "+html_new2+";"+ \
42.875 + "mv -f "+html_new2+" "+html_name2+";"+ \
42.876 + "sed 1,/M_ameriflux_sh/s//"+M_ameriflux_sh+"/ "+html_name2+" > "+html_new2+";"+ \
42.877 + "mv -f "+html_new2+" "+html_name2+";"+ \
42.878 + "sed 1,/M_ameriflux_gpp/s//"+M_ameriflux_gpp+"/ "+html_name2+" > "+html_new2+";"+ \
42.879 + "mv -f "+html_new2+" "+html_name2+";"+ \
42.880 + "sed 1,/M_ameriflux_er/s//"+M_ameriflux_er+"/ "+html_name2+" > "+html_new2+";"+ \
42.881 + "mv -f "+html_new2+" "+html_name2)
42.882 + end if
42.883 +
42.884 + system("sed s#M_ameriflux_nee#"+M_ameriflux_nee+"# "+html_name+" > "+html_new+";"+ \
42.885 + "mv -f "+html_new+" "+html_name+";"+ \
42.886 + "sed s#M_ameriflux_rad#"+M_ameriflux_rad+"# "+html_name+" > "+html_new+";"+ \
42.887 + "mv -f "+html_new+" "+html_name+";"+ \
42.888 + "sed s#M_ameriflux_lh#"+M_ameriflux_lh+"# "+html_name+" > "+html_new+";"+ \
42.889 + "mv -f "+html_new+" "+html_name+";"+ \
42.890 + "sed s#M_ameriflux_sh#"+M_ameriflux_sh+"# "+html_name+" > "+html_new+";"+ \
42.891 + "mv -f "+html_new+" "+html_name+";"+ \
42.892 + "sed s#M_ameriflux_gpp#"+M_ameriflux_gpp+"# "+html_name+" > "+html_new+";"+ \
42.893 + "mv -f "+html_new+" "+html_name+";"+ \
42.894 + "sed s#M_ameriflux_er#"+M_ameriflux_er+"# "+html_name+" > "+html_new+";"+ \
42.895 + "mv -f "+html_new+" "+html_name)
42.896 +
42.897 +;***************************************************************************
42.898 +; add total score and write to file
42.899 +;***************************************************************************
42.900 + M_total = M_ameriflux_all
42.901 +
42.902 + asciiwrite("M_save.ameriflux", M_total)
42.903 +
42.904 +;***************************************************************************
42.905 +; output plot and html
42.906 +;***************************************************************************
42.907 + output_dir = model_name+"/ameriflux"
42.908 +
42.909 + system("mv *.png *.html " + output_dir)
42.910 +;***************************************************************************
42.911 +
42.912 +end
42.913 +
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
43.2 +++ b/ameriflux/11.plot.ncl Mon Jan 26 22:08:20 2009 -0500
43.3 @@ -0,0 +1,581 @@
43.4 +;************************************************************
43.5 +; required command line input parameters:
43.6 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
43.7 +;
43.8 +; using gsn_table for all
43.9 +; output: line plot for each site (4 fields)
43.10 +; table for M_score
43.11 +;************************************************************
43.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
43.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
43.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
43.15 +;************************************************************
43.16 +procedure set_line(lines:string,nline:integer,newlines:string)
43.17 +begin
43.18 +; add line to ascci/html file
43.19 +
43.20 + nnewlines = dimsizes(newlines)
43.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
43.22 + print("set_line: bad index, not setting anything.")
43.23 + return
43.24 + end if
43.25 + lines(nline:nline+nnewlines-1) = newlines
43.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
43.27 + nline = nline + nnewlines
43.28 + return
43.29 +end
43.30 +;*************************************************************
43.31 +begin
43.32 +
43.33 + plot_type = "ps"
43.34 + plot_type_new = "png"
43.35 +
43.36 +; for 6 fields, 12-monthly
43.37 + nmon = 12
43.38 + nfield = 6
43.39 +
43.40 +;************************************************
43.41 +; read model data
43.42 +;************************************************
43.43 +; model = "cn"
43.44 + model = "casa"
43.45 +
43.46 + model_name = "i01.10" + model
43.47 +
43.48 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
43.49 + film = "lnd_T42.nc"
43.50 + fm = addfile(dirm+film,"r")
43.51 +
43.52 + xm = fm->lon
43.53 + ym = fm->lat
43.54 +;------------------------------------------------
43.55 + nlat = dimsizes(ym)
43.56 + nlon = dimsizes(xm)
43.57 +
43.58 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
43.59 +
43.60 +; change to unit of observed (u mol/m2/s)
43.61 +; Model_units [=] gC/m2/s
43.62 +; 12. = molecular weight of C
43.63 +; u mol = 1e-6 mol
43.64 + factor = 1e6 /12.
43.65 +
43.66 + ENERGY ="new"
43.67 +
43.68 +;************************************************
43.69 +; read data: observed
43.70 +;************************************************
43.71 +
43.72 + station = (/"Duke_Forest_Hardwoods" \
43.73 + ,"Duke_Forest_Open_Field" \
43.74 + ,"Duke_Forest_Pine" \
43.75 + ,"HarvardForest" \
43.76 + /)
43.77 +
43.78 + year_ob = (/"2003-2005" \
43.79 + ,"2001-2005" \
43.80 + ,"2001-2005" \
43.81 + ,"1991-2004" \
43.82 + /)
43.83 +
43.84 + field = (/"CO2 Flux" \
43.85 + ,"Net Radiation" \
43.86 + ,"Latent Heat" \
43.87 + ,"Sensible Heat" \
43.88 + ,"GPP Flux" \
43.89 + ,"Respiration" \
43.90 + /)
43.91 +
43.92 + nstation = dimsizes(station)
43.93 +
43.94 + data_mod = new ((/nstation, nfield, nmon/),float)
43.95 + data_ob = new ((/nstation, nfield, nmon/),float)
43.96 + lat_ob = new ((/nstation/),float)
43.97 + lon_ob = new ((/nstation/),float)
43.98 +
43.99 + diro_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/"
43.100 + dirm_root = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
43.101 +
43.102 + do n = 0,nstation-1
43.103 +
43.104 +;-------------------------------------------------
43.105 +; get ob data
43.106 +
43.107 + diro = diro_root + station(n)+"/"
43.108 + filo = year_ob(n)+"_L4_m.nc"
43.109 + fo = addfile (diro+filo,"r")
43.110 +
43.111 + print (filo)
43.112 +
43.113 + lon_ob(n) = fo->lon
43.114 + lat_ob(n) = fo->lat
43.115 +
43.116 + data = fo->NEE_or_fMDS
43.117 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
43.118 + delete (data)
43.119 +
43.120 + data = fo->Rg_f
43.121 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
43.122 + delete (data)
43.123 +
43.124 + data = fo->LE_f
43.125 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
43.126 + delete (data)
43.127 +
43.128 + data = fo->H_f
43.129 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
43.130 + delete (data)
43.131 +
43.132 + data = fo->GPP_or_MDS
43.133 + data_ob(n,4,:) = dim_avg(data(month|:,year|:))
43.134 + delete (data)
43.135 +
43.136 + data = fo->Reco_or
43.137 + data_ob(n,5,:) = dim_avg(data(month|:,year|:))
43.138 + delete (data)
43.139 +
43.140 + delete (fo)
43.141 +;---------------------------------------------------
43.142 +; get model data
43.143 +
43.144 + film = model_name+"_"+year_ob(n)+"_MONS_climo.nc"
43.145 + fm = addfile (dirm_root+film,"r")
43.146 +
43.147 + print (film)
43.148 +
43.149 +if (ENERGY .eq. "old") then
43.150 +
43.151 + data = fm->NEE
43.152 + data_mod0(0,:,:,:) = data(:,:,:) * factor
43.153 + delete (data)
43.154 +
43.155 +; data = fm->LATENT
43.156 + data1 = fm->FCEV
43.157 + data2 = fm->FCTR
43.158 + data3 = fm->FGEV
43.159 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
43.160 + delete (data1)
43.161 + delete (data2)
43.162 + delete (data3)
43.163 +
43.164 +; data = fm->SENSIBLE
43.165 + data = fm->FSH
43.166 + data_mod0(3,:,:,:) = data(:,:,:)
43.167 + delete (data)
43.168 +
43.169 +; data = fm->NETRAD
43.170 + data1 = fm->FSA
43.171 + data2 = fm->FIRA
43.172 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)-data_mod0(2,:,:,:)-data_mod0(3,:,:,:)
43.173 + delete (data1)
43.174 + delete (data2)
43.175 +
43.176 +else
43.177 +
43.178 + data = fm->NEE
43.179 + data_mod0(0,:,:,:) = data(:,:,:) * factor
43.180 + delete (data)
43.181 +
43.182 + data = fm->NETRAD
43.183 + data_mod0(1,:,:,:) = data(:,:,:)
43.184 + delete (data)
43.185 +
43.186 + data = fm->LATENT
43.187 + data_mod0(2,:,:,:) = data(:,:,:)
43.188 + delete (data)
43.189 +
43.190 +; data = fm->SENSIBLE
43.191 + data = fm->FSH
43.192 + data_mod0(3,:,:,:) = data(:,:,:)
43.193 + delete (data)
43.194 +end if
43.195 +
43.196 + data = fm->GPP
43.197 + data_mod0(4,:,:,:) = data(:,:,:) * factor
43.198 + delete (data)
43.199 +
43.200 + if (model .eq. "cn") then
43.201 + data = fm->ER
43.202 + else
43.203 + data1 = fm->AR
43.204 + data2 = fm->HR
43.205 + data = data1 + data2
43.206 +
43.207 + delete (data1)
43.208 + delete (data2)
43.209 + end if
43.210 +
43.211 + data_mod0(5,:,:,:) = data(:,:,:) * factor
43.212 + delete (data)
43.213 +
43.214 + delete (fm)
43.215 +
43.216 +;************************************************************
43.217 +; interpolate model data into observed station
43.218 +; note: model is 0-360E, 90S-90N
43.219 +;************************************************************
43.220 +
43.221 +; to be able to handle observation at (-89.98,-24.80)
43.222 + ym(0) = -90.
43.223 +
43.224 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob(n),lat_ob(n),0)
43.225 +
43.226 +; print (yy)
43.227 +
43.228 + data_mod(n,:,:) = yy(:,:,0)
43.229 +
43.230 + delete (yy)
43.231 +
43.232 + end do
43.233 +;************************************************************
43.234 +; compute correlation coef and M score
43.235 +;************************************************************
43.236 +
43.237 + score_max = 5.
43.238 +
43.239 + ccr = new ((/nstation, nfield/),float)
43.240 + M_score = new ((/nstation, nfield/),float)
43.241 +
43.242 + do n=0,nstation-1
43.243 + do m=0,nfield-1
43.244 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
43.245 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
43.246 + M_score(n,m) = (1. -(bias/nmon)) * score_max
43.247 + end do
43.248 + end do
43.249 +
43.250 + M_co2 = avg(M_score(:,0))
43.251 + M_rad = avg(M_score(:,1))
43.252 + M_lh = avg(M_score(:,2))
43.253 + M_sh = avg(M_score(:,3))
43.254 + M_gpp = avg(M_score(:,4))
43.255 + M_er = avg(M_score(:,5))
43.256 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
43.257 +
43.258 + M_energy_co2 = sprintf("%.2f", M_co2)
43.259 + M_energy_rad = sprintf("%.2f", M_rad)
43.260 + M_energy_lh = sprintf("%.2f", M_lh )
43.261 + M_energy_sh = sprintf("%.2f", M_sh )
43.262 + M_energy_gpp = sprintf("%.2f", M_gpp)
43.263 + M_energy_er = sprintf("%.2f", M_er )
43.264 + M_energy_all = sprintf("%.2f", M_all)
43.265 +
43.266 +;*******************************************************************
43.267 +; for station line plot
43.268 +;*******************************************************************
43.269 +
43.270 +; for x-axis in xyplot
43.271 + mon = ispan(1,12,1)
43.272 + mon@long_name = "month"
43.273 +
43.274 + res = True ; plot mods desired
43.275 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
43.276 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
43.277 +;-------------------------------------------------------------------------
43.278 +; Add a boxed legend using the more simple method
43.279 +
43.280 + res@pmLegendDisplayMode = "Always"
43.281 +; res@pmLegendWidthF = 0.1
43.282 + res@pmLegendWidthF = 0.08
43.283 + res@pmLegendHeightF = 0.06
43.284 +; res@pmLegendOrthogonalPosF = -1.17
43.285 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
43.286 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
43.287 +
43.288 +; res@pmLegendParallelPosF = 0.18
43.289 + res@pmLegendParallelPosF = 0.23 ;(rightward)
43.290 +
43.291 +; res@lgPerimOn = False
43.292 + res@lgLabelFontHeightF = 0.015
43.293 + res@xyExplicitLegendLabels = (/"observed",model_name/)
43.294 +;-------------------------------------------------------------------
43.295 +; for panel plot
43.296 + res@gsnFrame = False ; Do not draw plot
43.297 + res@gsnDraw = False ; Do not advance frame
43.298 +
43.299 + pres = True ; panel plot mods desired
43.300 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
43.301 + ; indiv. plots in panel
43.302 + pres@gsnMaximize = True ; fill the page
43.303 +;-------------------------------------------------------------------
43.304 +
43.305 + plot_data = new((/2,12/),float)
43.306 + plot_data!0 = "case"
43.307 + plot_data!1 = "month"
43.308 +
43.309 + do n = 0,nstation-1
43.310 +;----------------------------
43.311 +; for observed
43.312 +
43.313 + plot_name = station(n)+"_ob"
43.314 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
43.315 + res@tiMainString = title
43.316 +
43.317 + wks = gsn_open_wks (plot_type,plot_name)
43.318 + plot=new(nfield,graphic) ; create graphic array
43.319 +
43.320 + plot_data(0,:) = (/data_ob (n,0,:)/)
43.321 + plot_data@long_name = field(0)
43.322 + plot(0)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 1
43.323 +
43.324 + plot_data(0,:) = (/data_ob (n,1,:)/)
43.325 + plot_data@long_name = field(1)
43.326 + plot(1)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 2
43.327 +
43.328 + plot_data(0,:) = (/data_ob (n,2,:)/)
43.329 + plot_data@long_name = field(2)
43.330 + plot(2)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 3
43.331 +
43.332 + plot_data(0,:) = (/data_ob (n,3,:)/)
43.333 + plot_data@long_name = field(3)
43.334 + plot(3)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 4
43.335 +
43.336 + plot_data(0,:) = (/data_ob (n,4,:)/)
43.337 + plot_data@long_name = field(4)
43.338 + plot(4)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 5
43.339 +
43.340 + plot_data(0,:) = (/data_ob (n,5,:)/)
43.341 + plot_data@long_name = field(5)
43.342 + plot(5)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 6
43.343 +
43.344 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
43.345 +
43.346 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
43.347 + "rm "+plot_name+"."+plot_type)
43.348 +
43.349 + clear (wks)
43.350 + delete (plot)
43.351 +;----------------------------
43.352 +; for model_vs_ob
43.353 +
43.354 + plot_name = station(n)+"_model_vs_ob"
43.355 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
43.356 + res@tiMainString = title
43.357 +
43.358 + wks = gsn_open_wks (plot_type,plot_name)
43.359 + plot=new(nfield,graphic) ; create graphic array
43.360 +
43.361 + plot_data(0,:) = (/data_ob (n,0,:)/)
43.362 + plot_data(1,:) = (/data_mod(n,0,:)/)
43.363 + plot_data@long_name = field(0)
43.364 + plot(0)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 1
43.365 +
43.366 + plot_data(0,:) = (/data_ob (n,1,:)/)
43.367 + plot_data(1,:) = (/data_mod(n,1,:)/)
43.368 + plot_data@long_name = field(1)
43.369 + plot(1)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 2
43.370 +
43.371 + plot_data(0,:) = (/data_ob (n,2,:)/)
43.372 + plot_data(1,:) = (/data_mod(n,2,:)/)
43.373 + plot_data@long_name = field(2)
43.374 + plot(2)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 3
43.375 +
43.376 + plot_data(0,:) = (/data_ob (n,3,:)/)
43.377 + plot_data(1,:) = (/data_mod(n,3,:)/)
43.378 + plot_data@long_name = field(3)
43.379 + plot(3)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 4
43.380 +
43.381 +
43.382 + plot_data(0,:) = (/data_ob (n,4,:)/)
43.383 + plot_data(1,:) = (/data_mod(n,4,:)/)
43.384 + plot_data@long_name = field(4)
43.385 + plot(4)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 5
43.386 +
43.387 +
43.388 + plot_data(0,:) = (/data_ob (n,5,:)/)
43.389 + plot_data(1,:) = (/data_mod(n,5,:)/)
43.390 + plot_data@long_name = field(5)
43.391 + plot(5)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 6
43.392 +
43.393 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
43.394 +
43.395 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
43.396 + "rm "+plot_name+"."+plot_type)
43.397 +
43.398 + clear (wks)
43.399 + delete (plot)
43.400 + end do
43.401 +
43.402 +;*******************************************************************
43.403 +; html table of site: observed
43.404 +;*******************************************************************
43.405 + output_html = "line_ob.html"
43.406 +
43.407 + header = (/"<HTML>" \
43.408 + ,"<HEAD>" \
43.409 + ,"<TITLE>CLAMP metrics</TITLE>" \
43.410 + ,"</HEAD>" \
43.411 + ,"<H1>Energy at Site: Observation</H1>" \
43.412 + /)
43.413 + footer = "</HTML>"
43.414 +
43.415 + table_header = (/ \
43.416 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
43.417 + ,"<tr>" \
43.418 + ," <th bgcolor=DDDDDD >Site Name</th>" \
43.419 + ," <th bgcolor=DDDDDD >Latitude</th>" \
43.420 + ," <th bgcolor=DDDDDD >Longitude</th>" \
43.421 + ," <th bgcolor=DDDDDD >Observed</th>" \
43.422 + ,"</tr>" \
43.423 + /)
43.424 + table_footer = "</table>"
43.425 + row_header = "<tr>"
43.426 + row_footer = "</tr>"
43.427 +
43.428 + lines = new(50000,string)
43.429 + nline = 0
43.430 +
43.431 + set_line(lines,nline,header)
43.432 + set_line(lines,nline,table_header)
43.433 +;-----------------------------------------------
43.434 +; row of table
43.435 +
43.436 + do n = 0,nstation-1
43.437 + set_line(lines,nline,row_header)
43.438 +
43.439 + txt0 = station(n)
43.440 + txt1 = sprintf("%5.2f", lat_ob(n))
43.441 + txt2 = sprintf("%5.2f", lon_ob(n))
43.442 + txt3 = year_ob(n)
43.443 +
43.444 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
43.445 + set_line(lines,nline,"<th>"+txt1+"</th>")
43.446 + set_line(lines,nline,"<th>"+txt2+"</th>")
43.447 + set_line(lines,nline,"<th>"+txt3+"</th>")
43.448 +
43.449 + set_line(lines,nline,row_footer)
43.450 + end do
43.451 +;-----------------------------------------------
43.452 + set_line(lines,nline,table_footer)
43.453 + set_line(lines,nline,footer)
43.454 +
43.455 +; Now write to an HTML file.
43.456 + idx = ind(.not.ismissing(lines))
43.457 + if(.not.any(ismissing(idx))) then
43.458 + asciiwrite(output_html,lines(idx))
43.459 + else
43.460 + print ("error?")
43.461 + end if
43.462 + delete (idx)
43.463 +
43.464 +;*******************************************************************
43.465 +; score and line table : model vs observed
43.466 +;*******************************************************************
43.467 + output_html = "score+line_vs_ob.html"
43.468 +
43.469 + header = (/"<HTML>" \
43.470 + ,"<HEAD>" \
43.471 + ,"<TITLE>CLAMP metrics</TITLE>" \
43.472 + ,"</HEAD>" \
43.473 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
43.474 + /)
43.475 + footer = "</HTML>"
43.476 +
43.477 + delete (table_header)
43.478 + table_header = (/ \
43.479 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
43.480 + ,"<tr>" \
43.481 + ," <th bgcolor=DDDDDD >Site Name</th>" \
43.482 + ," <th bgcolor=DDDDDD >Latitude</th>" \
43.483 + ," <th bgcolor=DDDDDD >Longitude</th>" \
43.484 + ," <th bgcolor=DDDDDD >Observed</th>" \
43.485 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
43.486 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
43.487 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
43.488 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
43.489 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
43.490 + ," <th bgcolor=DDDDDD >Respiration</th>" \
43.491 + ," <th bgcolor=DDDDDD >Average</th>" \
43.492 + ,"</tr>" \
43.493 + /)
43.494 + table_footer = "</table>"
43.495 + row_header = "<tr>"
43.496 + row_footer = "</tr>"
43.497 +
43.498 + lines = new(50000,string)
43.499 + nline = 0
43.500 +
43.501 + set_line(lines,nline,header)
43.502 + set_line(lines,nline,table_header)
43.503 +;-----------------------------------------------
43.504 +; row of table
43.505 +
43.506 + do n = 0,nstation-1
43.507 + set_line(lines,nline,row_header)
43.508 +
43.509 + txt0 = station(n)
43.510 + txt1 = sprintf("%5.2f", lat_ob(n))
43.511 + txt2 = sprintf("%5.2f", lon_ob(n))
43.512 + txt3 = year_ob(n)
43.513 + txt4 = sprintf("%5.2f", M_score(n,0))
43.514 + txt5 = sprintf("%5.2f", M_score(n,1))
43.515 + txt6 = sprintf("%5.2f", M_score(n,2))
43.516 + txt7 = sprintf("%5.2f", M_score(n,3))
43.517 + txt8 = sprintf("%5.2f", M_score(n,4))
43.518 + txt9 = sprintf("%5.2f", M_score(n,5))
43.519 + txt10 = sprintf("%5.2f", avg(M_score(n,:)))
43.520 +
43.521 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
43.522 + set_line(lines,nline,"<th>"+txt1+"</th>")
43.523 + set_line(lines,nline,"<th>"+txt2+"</th>")
43.524 + set_line(lines,nline,"<th>"+txt3+"</th>")
43.525 + set_line(lines,nline,"<th>"+txt4+"</th>")
43.526 + set_line(lines,nline,"<th>"+txt5+"</th>")
43.527 + set_line(lines,nline,"<th>"+txt6+"</th>")
43.528 + set_line(lines,nline,"<th>"+txt7+"</th>")
43.529 + set_line(lines,nline,"<th>"+txt8+"</th>")
43.530 + set_line(lines,nline,"<th>"+txt9+"</th>")
43.531 + set_line(lines,nline,"<th>"+txt10+"</th>")
43.532 +
43.533 + set_line(lines,nline,row_footer)
43.534 + end do
43.535 +
43.536 +; last row, summary
43.537 + set_line(lines,nline,row_header)
43.538 +
43.539 + txt0 = "All_"+sprintf("%.0f", nstation)
43.540 + txt1 = "-"
43.541 + txt2 = "-"
43.542 + txt3 = "-"
43.543 + txt4 = M_energy_co2
43.544 + txt5 = M_energy_rad
43.545 + txt6 = M_energy_lh
43.546 + txt7 = M_energy_sh
43.547 + txt8 = M_energy_gpp
43.548 + txt9 = M_energy_er
43.549 + txt10 = M_energy_all
43.550 +
43.551 + set_line(lines,nline,"<th>"+txt0+"</th>")
43.552 + set_line(lines,nline,"<th>"+txt1+"</th>")
43.553 + set_line(lines,nline,"<th>"+txt2+"</th>")
43.554 + set_line(lines,nline,"<th>"+txt3+"</th>")
43.555 + set_line(lines,nline,"<th>"+txt4+"</th>")
43.556 + set_line(lines,nline,"<th>"+txt5+"</th>")
43.557 + set_line(lines,nline,"<th>"+txt6+"</th>")
43.558 + set_line(lines,nline,"<th>"+txt7+"</th>")
43.559 + set_line(lines,nline,"<th>"+txt8+"</th>")
43.560 + set_line(lines,nline,"<th>"+txt9+"</th>")
43.561 + set_line(lines,nline,"<th>"+txt10+"</th>")
43.562 +
43.563 + set_line(lines,nline,row_footer)
43.564 +;-----------------------------------------------
43.565 + set_line(lines,nline,table_footer)
43.566 + set_line(lines,nline,footer)
43.567 +
43.568 +; Now write to an HTML file.
43.569 + idx = ind(.not.ismissing(lines))
43.570 + if(.not.any(ismissing(idx))) then
43.571 + asciiwrite(output_html,lines(idx))
43.572 + else
43.573 + print ("error?")
43.574 + end if
43.575 + delete (idx)
43.576 +
43.577 +;***************************************************************************
43.578 +; output plots
43.579 +;***************************************************************************
43.580 + output_dir = model_name+"/ameriflux"
43.581 +
43.582 + system("mv *.png *.html " + output_dir)
43.583 +;***************************************************************************
43.584 +end
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
44.2 +++ b/ameriflux/12.plot.ncl Mon Jan 26 22:08:20 2009 -0500
44.3 @@ -0,0 +1,722 @@
44.4 +;************************************************************
44.5 +; required command line input parameters:
44.6 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
44.7 +;
44.8 +; using gsn_table for all
44.9 +; output: line plot for each site (4 fields)
44.10 +; table for M_score
44.11 +;************************************************************
44.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
44.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
44.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
44.15 +;************************************************************
44.16 +procedure set_line(lines:string,nline:integer,newlines:string)
44.17 +begin
44.18 +; add line to ascci/html file
44.19 +
44.20 + nnewlines = dimsizes(newlines)
44.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
44.22 + print("set_line: bad index, not setting anything.")
44.23 + return
44.24 + end if
44.25 + lines(nline:nline+nnewlines-1) = newlines
44.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
44.27 + nline = nline + nnewlines
44.28 + return
44.29 +end
44.30 +;*************************************************************
44.31 +begin
44.32 +
44.33 + plot_type = "ps"
44.34 + plot_type_new = "png"
44.35 +
44.36 +; for 6 fields, 12-monthly
44.37 + nmon = 12
44.38 + nfield = 6
44.39 +
44.40 +;************************************************
44.41 +; read model data
44.42 +;************************************************
44.43 + model = "cn"
44.44 +; model = "casa"
44.45 +
44.46 + model_name = "i01.10" + model
44.47 +
44.48 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
44.49 + film = "lnd_T42.nc"
44.50 + fm = addfile(dirm+film,"r")
44.51 +
44.52 + xm = fm->lon
44.53 + ym = fm->lat
44.54 +;------------------------------------------------
44.55 + nlat = dimsizes(ym)
44.56 + nlon = dimsizes(xm)
44.57 +
44.58 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
44.59 +
44.60 +; change to unit of observed (u mol/m2/s)
44.61 +; Model_units [=] gC/m2/s
44.62 +; 12. = molecular weight of C
44.63 +; u mol = 1e-6 mol
44.64 + factor = 1e6 /12.
44.65 +
44.66 + ENERGY ="new"
44.67 +
44.68 +;************************************************
44.69 +; read data: observed
44.70 +;************************************************
44.71 +
44.72 + station = (/"ARM_Oklahoma" \
44.73 + ,"ARM_Oklahoma_burn" \
44.74 + ,"ARM_Oklahoma_control" \
44.75 + ,"Atqasuk" \
44.76 + ,"Audubon" \
44.77 + ,"AustinCary" \
44.78 + ,"Bartlett" \
44.79 + ,"Bondville" \
44.80 + ,"Brookings" \
44.81 + ,"Donaldson" \
44.82 + ,"Duke_Forest_Hardwoods" \
44.83 + ,"Duke_Forest_Open_Field" \
44.84 + ,"Duke_Forest_Pine" \
44.85 + ,"Fermi_Ag" \
44.86 + ,"Fermi_Prairie" \
44.87 + ,"Flagstaff_Managed" \
44.88 + ,"Flagstaff_Unmanaged" \
44.89 + ,"Flagstaff_Wildfire" \
44.90 + ,"FortPeck" \
44.91 + ,"FreemanRanch_mesquite" \
44.92 + ,"Goodwin_Creek" \
44.93 + ,"HarvardForest" \
44.94 + ,"HarvardForestHemlock" \
44.95 + ,"HowlandForestMain" \
44.96 + ,"HowlandForestWest" \
44.97 + ,"Ivotuk" \
44.98 + ,"KendallGrasslands" \
44.99 + ,"KennedySpaceCenterPine" \
44.100 + ,"KennedySpaceCenterScrub" \
44.101 + ,"LittleProspect" \
44.102 + ,"LostCreek" \
44.103 + ,"Mead-irrigated" \
44.104 + ,"Mead-irrigated-rotation" \
44.105 + ,"Mead-rainfed" \
44.106 + ,"Metolius_2nd_YoungPonderosaPine" \
44.107 + ,"MetoliusEyerly" \
44.108 + ,"MetoliusIntermediatePine" \
44.109 + ,"MetoliusOldPonderosaPine" \
44.110 + ,"MissouriOzark" \
44.111 + ,"Mize" \
44.112 + ,"MorganMonroe" \
44.113 + ,"NiwotRidge" \
44.114 + ,"NorthCarolina_cc" \
44.115 + ,"NorthCarolina_lp" \
44.116 + ,"ParkFalls" \
44.117 + ,"Rayonier" \
44.118 + ,"SantaRita" \
44.119 + ,"SkyOaks_Old" \
44.120 + ,"SkyOaks_PostFire" \
44.121 + ,"SkyOaks_Young" \
44.122 + ,"SylvaniaWilderness" \
44.123 + ,"Toledo" \
44.124 + ,"Tonzi" \
44.125 + ,"UCI_1850" \
44.126 + ,"UCI_1930" \
44.127 + ,"UCI_1964" \
44.128 + ,"UCI_1964wet" \
44.129 + ,"UCI_1981" \
44.130 + ,"UCI_1989" \
44.131 + ,"UCI_1998" \
44.132 + ,"UMBS" \
44.133 + ,"Vaira" \
44.134 + ,"WalkerBranch" \
44.135 + ,"WillowCreek" \
44.136 + ,"WindRiver" \
44.137 + ,"Wisconsin_ihw" \
44.138 + ,"Wisconsin_irp" \
44.139 + ,"Wisconsin_mrp" \
44.140 + ,"Wisconsin_myjp" \
44.141 + ,"Wisconsin_pb" \
44.142 + ,"Wisconsin_rpcc" \
44.143 + ,"Wisconsin_yhw" \
44.144 + ,"Wisconsin_yjp" \
44.145 + ,"Wisconsin_yrp" \
44.146 + /)
44.147 +
44.148 + year_ob = (/"2003-2006" \
44.149 + ,"2005-2006" \
44.150 + ,"2005-2006" \
44.151 + ,"1999-2006" \
44.152 + ,"2002-2006" \
44.153 + ,"2000-2005" \
44.154 + ,"2004-2005" \
44.155 + ,"1996-2006" \
44.156 + ,"2004-2006" \
44.157 + ,"1999-2004" \
44.158 + ,"2003-2005" \
44.159 + ,"2001-2005" \
44.160 + ,"2001-2005" \
44.161 + ,"2005-2006" \
44.162 + ,"2004-2006" \
44.163 + ,"2005-2006" \
44.164 + ,"2005-2006" \
44.165 + ,"2005-2006" \
44.166 + ,"2000-2006" \
44.167 + ,"2004-2006" \
44.168 + ,"2002-2006" \
44.169 + ,"1991-2004" \
44.170 + ,"2004-2004" \
44.171 + ,"1996-2004" \
44.172 + ,"1999-2004" \
44.173 + ,"2003-2006" \
44.174 + ,"2004-2006" \
44.175 + ,"2002-2002" \
44.176 + ,"2000-2006" \
44.177 + ,"2002-2005" \
44.178 + ,"2001-2005" \
44.179 + ,"2001-2005" \
44.180 + ,"2001-2005" \
44.181 + ,"2001-2005" \
44.182 + ,"2004-2005" \
44.183 + ,"2004-2005" \
44.184 + ,"2003-2005" \
44.185 + ,"1996-2000" \
44.186 + ,"2004-2006" \
44.187 + ,"1998-2004" \
44.188 + ,"1999-2005" \
44.189 + ,"1999-2003" \
44.190 + ,"2005-2006" \
44.191 + ,"2005-2006" \
44.192 + ,"1996-2003" \
44.193 + ,"1998-1998" \
44.194 + ,"2004-2006" \
44.195 + ,"1997-2006" \
44.196 + ,"2004-2006" \
44.197 + ,"1997-2006" \
44.198 + ,"2002-2006" \
44.199 + ,"2004-2005" \
44.200 + ,"2001-2006" \
44.201 + ,"2004-2005" \
44.202 + ,"2001-2005" \
44.203 + ,"2001-2005" \
44.204 + ,"2002-2004" \
44.205 + ,"2001-2005" \
44.206 + ,"2001-2005" \
44.207 + ,"2002-2005" \
44.208 + ,"1999-2003" \
44.209 + ,"2001-2006" \
44.210 + ,"1995-1999" \
44.211 + ,"1999-2005" \
44.212 + ,"1999-2004" \
44.213 + ,"2003-2003" \
44.214 + ,"2003-2003" \
44.215 + ,"2002-2005" \
44.216 + ,"2004-2004" \
44.217 + ,"2002-2002" \
44.218 + ,"2005-2005" \
44.219 + ,"2002-2002" \
44.220 + ,"2004-2005" \
44.221 + ,"2002-2002" \
44.222 + /)
44.223 +
44.224 + field = (/"CO2 Flux" \
44.225 + ,"Net Radiation" \
44.226 + ,"Latent Heat" \
44.227 + ,"Sensible Heat" \
44.228 + ,"GPP Flux" \
44.229 + ,"Respiration" \
44.230 + /)
44.231 +
44.232 + nstation = dimsizes(station)
44.233 +
44.234 + data_mod = new ((/nstation, nfield, nmon/),float)
44.235 + data_ob = new ((/nstation, nfield, nmon/),float)
44.236 + lat_ob = new ((/nstation/),float)
44.237 + lon_ob = new ((/nstation/),float)
44.238 +
44.239 + diro_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
44.240 + dirm_root = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
44.241 +
44.242 + do n = 0,nstation-1
44.243 +
44.244 +;-------------------------------------------------
44.245 +; get ob data
44.246 +
44.247 + diro = diro_root + station(n)+"/"
44.248 + filo = year_ob(n)+"_L4_m.nc"
44.249 + fo = addfile (diro+filo,"r")
44.250 +
44.251 + print (filo)
44.252 +
44.253 + lon_ob(n) = fo->lon
44.254 + lat_ob(n) = fo->lat
44.255 +
44.256 + data = fo->NEE_or_fMDS
44.257 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
44.258 + delete (data)
44.259 +
44.260 + data = fo->Rg_f
44.261 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
44.262 + delete (data)
44.263 +
44.264 + data = fo->LE_f
44.265 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
44.266 + delete (data)
44.267 +
44.268 + data = fo->H_f
44.269 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
44.270 + delete (data)
44.271 +
44.272 + data = fo->GPP_or_MDS
44.273 + data_ob(n,4,:) = dim_avg(data(month|:,year|:))
44.274 + delete (data)
44.275 +
44.276 + data = fo->Reco_or
44.277 + data_ob(n,5,:) = dim_avg(data(month|:,year|:))
44.278 + delete (data)
44.279 +
44.280 + delete (fo)
44.281 +;---------------------------------------------------
44.282 +; get model data
44.283 +
44.284 +; film = model_name+"_"+ year_ob(n)+"_MONS_climo.nc"
44.285 + film = model_name+"_"+"1990-2004"+"_MONS_climo.nc"
44.286 + fm = addfile (dirm_root+film,"r")
44.287 +
44.288 + print (film)
44.289 +
44.290 +if (ENERGY .eq. "old") then
44.291 +
44.292 + data = fm->NEE
44.293 + data_mod0(0,:,:,:) = data(:,:,:) * factor
44.294 + delete (data)
44.295 +
44.296 +; data = fm->LATENT
44.297 + data1 = fm->FCEV
44.298 + data2 = fm->FCTR
44.299 + data3 = fm->FGEV
44.300 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
44.301 + delete (data1)
44.302 + delete (data2)
44.303 + delete (data3)
44.304 +
44.305 +; data = fm->SENSIBLE
44.306 + data = fm->FSH
44.307 + data_mod0(3,:,:,:) = data(:,:,:)
44.308 + delete (data)
44.309 +
44.310 +; data = fm->NETRAD
44.311 + data1 = fm->FSA
44.312 + data2 = fm->FIRA
44.313 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)-data_mod0(2,:,:,:)-data_mod0(3,:,:,:)
44.314 + delete (data1)
44.315 + delete (data2)
44.316 +
44.317 +else
44.318 +
44.319 + data = fm->NEE
44.320 + data_mod0(0,:,:,:) = data(:,:,:) * factor
44.321 + delete (data)
44.322 +
44.323 + data = fm->NETRAD
44.324 + data_mod0(1,:,:,:) = data(:,:,:)
44.325 + delete (data)
44.326 +
44.327 + data = fm->LATENT
44.328 + data_mod0(2,:,:,:) = data(:,:,:)
44.329 + delete (data)
44.330 +
44.331 +; data = fm->SENSIBLE
44.332 + data = fm->FSH
44.333 + data_mod0(3,:,:,:) = data(:,:,:)
44.334 + delete (data)
44.335 +end if
44.336 +
44.337 + data = fm->GPP
44.338 + data_mod0(4,:,:,:) = data(:,:,:) * factor
44.339 + delete (data)
44.340 +
44.341 + if (model .eq. "cn") then
44.342 + data = fm->ER
44.343 + else
44.344 + data1 = fm->AR
44.345 + data2 = fm->HR
44.346 + data = data1 + data2
44.347 +
44.348 + delete (data1)
44.349 + delete (data2)
44.350 + end if
44.351 +
44.352 + data_mod0(5,:,:,:) = data(:,:,:) * factor
44.353 + delete (data)
44.354 +
44.355 + delete (fm)
44.356 +
44.357 +;************************************************************
44.358 +; interpolate model data into observed station
44.359 +; note: model is 0-360E, 90S-90N
44.360 +;************************************************************
44.361 +
44.362 +; to be able to handle observation at (-89.98,-24.80)
44.363 + ym(0) = -90.
44.364 +
44.365 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob(n),lat_ob(n),0)
44.366 +
44.367 +; print (yy)
44.368 +
44.369 + data_mod(n,:,:) = yy(:,:,0)
44.370 +
44.371 + delete (yy)
44.372 +
44.373 + end do
44.374 +;************************************************************
44.375 +; compute correlation coef and M score
44.376 +;************************************************************
44.377 +
44.378 + score_max = 5.
44.379 +
44.380 + ccr = new ((/nstation, nfield/),float)
44.381 + M_score = new ((/nstation, nfield/),float)
44.382 +
44.383 + do n=0,nstation-1
44.384 + do m=0,nfield-1
44.385 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
44.386 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
44.387 + M_score(n,m) = (1. -(bias/nmon)) * score_max
44.388 + end do
44.389 + end do
44.390 +
44.391 + M_co2 = avg(M_score(:,0))
44.392 + M_rad = avg(M_score(:,1))
44.393 + M_lh = avg(M_score(:,2))
44.394 + M_sh = avg(M_score(:,3))
44.395 + M_gpp = avg(M_score(:,4))
44.396 + M_er = avg(M_score(:,5))
44.397 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
44.398 +
44.399 + M_energy_co2 = sprintf("%.2f", M_co2)
44.400 + M_energy_rad = sprintf("%.2f", M_rad)
44.401 + M_energy_lh = sprintf("%.2f", M_lh )
44.402 + M_energy_sh = sprintf("%.2f", M_sh )
44.403 + M_energy_gpp = sprintf("%.2f", M_gpp)
44.404 + M_energy_er = sprintf("%.2f", M_er )
44.405 + M_energy_all = sprintf("%.2f", M_all)
44.406 +
44.407 +;*******************************************************************
44.408 +; for station line plot
44.409 +;*******************************************************************
44.410 +
44.411 +; for x-axis in xyplot
44.412 + mon = ispan(1,12,1)
44.413 + mon@long_name = "month"
44.414 +
44.415 + res = True ; plot mods desired
44.416 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
44.417 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
44.418 +;-------------------------------------------------------------------------
44.419 +; Add a boxed legend using the more simple method
44.420 +
44.421 + res@pmLegendDisplayMode = "Always"
44.422 +; res@pmLegendWidthF = 0.1
44.423 + res@pmLegendWidthF = 0.08
44.424 + res@pmLegendHeightF = 0.06
44.425 +; res@pmLegendOrthogonalPosF = -1.17
44.426 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
44.427 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
44.428 +
44.429 +; res@pmLegendParallelPosF = 0.18
44.430 + res@pmLegendParallelPosF = 0.23 ;(rightward)
44.431 +
44.432 +; res@lgPerimOn = False
44.433 + res@lgLabelFontHeightF = 0.015
44.434 + res@xyExplicitLegendLabels = (/"observed",model_name/)
44.435 +;-------------------------------------------------------------------
44.436 +; for panel plot
44.437 + res@gsnFrame = False ; Do not draw plot
44.438 + res@gsnDraw = False ; Do not advance frame
44.439 +
44.440 + pres = True ; panel plot mods desired
44.441 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
44.442 + ; indiv. plots in panel
44.443 + pres@gsnMaximize = True ; fill the page
44.444 +;-------------------------------------------------------------------
44.445 +
44.446 + plot_data = new((/2,12/),float)
44.447 + plot_data!0 = "case"
44.448 + plot_data!1 = "month"
44.449 +
44.450 + do n = 0,nstation-1
44.451 +;----------------------------
44.452 +; for observed
44.453 +
44.454 + plot_name = station(n)+"_ob"
44.455 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
44.456 + res@tiMainString = title
44.457 +
44.458 + wks = gsn_open_wks (plot_type,plot_name)
44.459 + plot=new(nfield,graphic) ; create graphic array
44.460 +
44.461 + plot_data(0,:) = (/data_ob (n,0,:)/)
44.462 + plot_data@long_name = field(0)
44.463 + plot(0)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 1
44.464 +
44.465 + plot_data(0,:) = (/data_ob (n,1,:)/)
44.466 + plot_data@long_name = field(1)
44.467 + plot(1)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 2
44.468 +
44.469 + plot_data(0,:) = (/data_ob (n,2,:)/)
44.470 + plot_data@long_name = field(2)
44.471 + plot(2)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 3
44.472 +
44.473 + plot_data(0,:) = (/data_ob (n,3,:)/)
44.474 + plot_data@long_name = field(3)
44.475 + plot(3)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 4
44.476 +
44.477 + plot_data(0,:) = (/data_ob (n,4,:)/)
44.478 + plot_data@long_name = field(4)
44.479 + plot(4)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 5
44.480 +
44.481 + plot_data(0,:) = (/data_ob (n,5,:)/)
44.482 + plot_data@long_name = field(5)
44.483 + plot(5)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 6
44.484 +
44.485 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
44.486 +
44.487 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
44.488 + "rm "+plot_name+"."+plot_type)
44.489 +
44.490 + clear (wks)
44.491 + delete (plot)
44.492 +;----------------------------
44.493 +; for model_vs_ob
44.494 +
44.495 + plot_name = station(n)+"_model_vs_ob"
44.496 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
44.497 + res@tiMainString = title
44.498 +
44.499 + wks = gsn_open_wks (plot_type,plot_name)
44.500 + plot=new(nfield,graphic) ; create graphic array
44.501 +
44.502 + plot_data(0,:) = (/data_ob (n,0,:)/)
44.503 + plot_data(1,:) = (/data_mod(n,0,:)/)
44.504 + plot_data@long_name = field(0)
44.505 + plot(0)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 1
44.506 +
44.507 + plot_data(0,:) = (/data_ob (n,1,:)/)
44.508 + plot_data(1,:) = (/data_mod(n,1,:)/)
44.509 + plot_data@long_name = field(1)
44.510 + plot(1)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 2
44.511 +
44.512 + plot_data(0,:) = (/data_ob (n,2,:)/)
44.513 + plot_data(1,:) = (/data_mod(n,2,:)/)
44.514 + plot_data@long_name = field(2)
44.515 + plot(2)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 3
44.516 +
44.517 + plot_data(0,:) = (/data_ob (n,3,:)/)
44.518 + plot_data(1,:) = (/data_mod(n,3,:)/)
44.519 + plot_data@long_name = field(3)
44.520 + plot(3)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 4
44.521 +
44.522 +
44.523 + plot_data(0,:) = (/data_ob (n,4,:)/)
44.524 + plot_data(1,:) = (/data_mod(n,4,:)/)
44.525 + plot_data@long_name = field(4)
44.526 + plot(4)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 5
44.527 +
44.528 +
44.529 + plot_data(0,:) = (/data_ob (n,5,:)/)
44.530 + plot_data(1,:) = (/data_mod(n,5,:)/)
44.531 + plot_data@long_name = field(5)
44.532 + plot(5)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 6
44.533 +
44.534 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
44.535 +
44.536 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
44.537 + "rm "+plot_name+"."+plot_type)
44.538 +
44.539 + clear (wks)
44.540 + delete (plot)
44.541 + end do
44.542 +
44.543 +;*******************************************************************
44.544 +; html table of site: observed
44.545 +;*******************************************************************
44.546 + output_html = "line_ob.html"
44.547 +
44.548 + header = (/"<HTML>" \
44.549 + ,"<HEAD>" \
44.550 + ,"<TITLE>CLAMP metrics</TITLE>" \
44.551 + ,"</HEAD>" \
44.552 + ,"<H1>Energy at Site: Observation</H1>" \
44.553 + /)
44.554 + footer = "</HTML>"
44.555 +
44.556 + table_header = (/ \
44.557 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
44.558 + ,"<tr>" \
44.559 + ," <th bgcolor=DDDDDD >Site Name</th>" \
44.560 + ," <th bgcolor=DDDDDD >Latitude</th>" \
44.561 + ," <th bgcolor=DDDDDD >Longitude</th>" \
44.562 + ," <th bgcolor=DDDDDD >Observed</th>" \
44.563 + ,"</tr>" \
44.564 + /)
44.565 + table_footer = "</table>"
44.566 + row_header = "<tr>"
44.567 + row_footer = "</tr>"
44.568 +
44.569 + lines = new(50000,string)
44.570 + nline = 0
44.571 +
44.572 + set_line(lines,nline,header)
44.573 + set_line(lines,nline,table_header)
44.574 +;-----------------------------------------------
44.575 +; row of table
44.576 +
44.577 + do n = 0,nstation-1
44.578 + set_line(lines,nline,row_header)
44.579 +
44.580 + txt0 = station(n)
44.581 + txt1 = sprintf("%5.2f", lat_ob(n))
44.582 + txt2 = sprintf("%5.2f", lon_ob(n))
44.583 + txt3 = year_ob(n)
44.584 +
44.585 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
44.586 + set_line(lines,nline,"<th>"+txt1+"</th>")
44.587 + set_line(lines,nline,"<th>"+txt2+"</th>")
44.588 + set_line(lines,nline,"<th>"+txt3+"</th>")
44.589 +
44.590 + set_line(lines,nline,row_footer)
44.591 + end do
44.592 +;-----------------------------------------------
44.593 + set_line(lines,nline,table_footer)
44.594 + set_line(lines,nline,footer)
44.595 +
44.596 +; Now write to an HTML file.
44.597 + idx = ind(.not.ismissing(lines))
44.598 + if(.not.any(ismissing(idx))) then
44.599 + asciiwrite(output_html,lines(idx))
44.600 + else
44.601 + print ("error?")
44.602 + end if
44.603 + delete (idx)
44.604 +
44.605 +;*******************************************************************
44.606 +; score and line table : model vs observed
44.607 +;*******************************************************************
44.608 + output_html = "score+line_vs_ob.html"
44.609 +
44.610 + header = (/"<HTML>" \
44.611 + ,"<HEAD>" \
44.612 + ,"<TITLE>CLAMP metrics</TITLE>" \
44.613 + ,"</HEAD>" \
44.614 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
44.615 + /)
44.616 + footer = "</HTML>"
44.617 +
44.618 + delete (table_header)
44.619 + table_header = (/ \
44.620 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
44.621 + ,"<tr>" \
44.622 + ," <th bgcolor=DDDDDD >Site Name</th>" \
44.623 + ," <th bgcolor=DDDDDD >Latitude</th>" \
44.624 + ," <th bgcolor=DDDDDD >Longitude</th>" \
44.625 + ," <th bgcolor=DDDDDD >Observed</th>" \
44.626 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
44.627 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
44.628 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
44.629 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
44.630 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
44.631 + ," <th bgcolor=DDDDDD >Respiration</th>" \
44.632 + ," <th bgcolor=DDDDDD >Average</th>" \
44.633 + ,"</tr>" \
44.634 + /)
44.635 + table_footer = "</table>"
44.636 + row_header = "<tr>"
44.637 + row_footer = "</tr>"
44.638 +
44.639 + lines = new(50000,string)
44.640 + nline = 0
44.641 +
44.642 + set_line(lines,nline,header)
44.643 + set_line(lines,nline,table_header)
44.644 +;-----------------------------------------------
44.645 +; row of table
44.646 +
44.647 + do n = 0,nstation-1
44.648 + set_line(lines,nline,row_header)
44.649 +
44.650 + txt0 = station(n)
44.651 + txt1 = sprintf("%5.2f", lat_ob(n))
44.652 + txt2 = sprintf("%5.2f", lon_ob(n))
44.653 + txt3 = year_ob(n)
44.654 + txt4 = sprintf("%5.2f", M_score(n,0))
44.655 + txt5 = sprintf("%5.2f", M_score(n,1))
44.656 + txt6 = sprintf("%5.2f", M_score(n,2))
44.657 + txt7 = sprintf("%5.2f", M_score(n,3))
44.658 + txt8 = sprintf("%5.2f", M_score(n,4))
44.659 + txt9 = sprintf("%5.2f", M_score(n,5))
44.660 + txt10 = sprintf("%5.2f", avg(M_score(n,:)))
44.661 +
44.662 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
44.663 + set_line(lines,nline,"<th>"+txt1+"</th>")
44.664 + set_line(lines,nline,"<th>"+txt2+"</th>")
44.665 + set_line(lines,nline,"<th>"+txt3+"</th>")
44.666 + set_line(lines,nline,"<th>"+txt4+"</th>")
44.667 + set_line(lines,nline,"<th>"+txt5+"</th>")
44.668 + set_line(lines,nline,"<th>"+txt6+"</th>")
44.669 + set_line(lines,nline,"<th>"+txt7+"</th>")
44.670 + set_line(lines,nline,"<th>"+txt8+"</th>")
44.671 + set_line(lines,nline,"<th>"+txt9+"</th>")
44.672 + set_line(lines,nline,"<th>"+txt10+"</th>")
44.673 +
44.674 + set_line(lines,nline,row_footer)
44.675 + end do
44.676 +
44.677 +; last row, summary
44.678 + set_line(lines,nline,row_header)
44.679 +
44.680 + txt0 = "All_"+sprintf("%.0f", nstation)
44.681 + txt1 = "-"
44.682 + txt2 = "-"
44.683 + txt3 = "-"
44.684 + txt4 = M_energy_co2
44.685 + txt5 = M_energy_rad
44.686 + txt6 = M_energy_lh
44.687 + txt7 = M_energy_sh
44.688 + txt8 = M_energy_gpp
44.689 + txt9 = M_energy_er
44.690 + txt10 = M_energy_all
44.691 +
44.692 + set_line(lines,nline,"<th>"+txt0+"</th>")
44.693 + set_line(lines,nline,"<th>"+txt1+"</th>")
44.694 + set_line(lines,nline,"<th>"+txt2+"</th>")
44.695 + set_line(lines,nline,"<th>"+txt3+"</th>")
44.696 + set_line(lines,nline,"<th>"+txt4+"</th>")
44.697 + set_line(lines,nline,"<th>"+txt5+"</th>")
44.698 + set_line(lines,nline,"<th>"+txt6+"</th>")
44.699 + set_line(lines,nline,"<th>"+txt7+"</th>")
44.700 + set_line(lines,nline,"<th>"+txt8+"</th>")
44.701 + set_line(lines,nline,"<th>"+txt9+"</th>")
44.702 + set_line(lines,nline,"<th>"+txt10+"</th>")
44.703 +
44.704 + set_line(lines,nline,row_footer)
44.705 +;-----------------------------------------------
44.706 + set_line(lines,nline,table_footer)
44.707 + set_line(lines,nline,footer)
44.708 +
44.709 +; Now write to an HTML file.
44.710 + idx = ind(.not.ismissing(lines))
44.711 + if(.not.any(ismissing(idx))) then
44.712 + asciiwrite(output_html,lines(idx))
44.713 + else
44.714 + print ("error?")
44.715 + end if
44.716 + delete (idx)
44.717 +
44.718 +;***************************************************************************
44.719 +; output plots
44.720 +;***************************************************************************
44.721 + output_dir = model_name+"/ameriflux"
44.722 +
44.723 + system("mv *.png *.html " + output_dir)
44.724 +;***************************************************************************
44.725 +end
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45.2 +++ b/ameriflux/13.plot.ncl Mon Jan 26 22:08:20 2009 -0500
45.3 @@ -0,0 +1,683 @@
45.4 +;************************************************************
45.5 +; change long_name
45.6 +;************************************************************
45.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
45.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
45.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
45.10 +;************************************************************
45.11 +procedure set_line(lines:string,nline:integer,newlines:string)
45.12 +begin
45.13 +; add line to ascci/html file
45.14 +
45.15 + nnewlines = dimsizes(newlines)
45.16 + if(nline+nnewlines-1.ge.dimsizes(lines))
45.17 + print("set_line: bad index, not setting anything.")
45.18 + return
45.19 + end if
45.20 + lines(nline:nline+nnewlines-1) = newlines
45.21 +; print ("lines = " + lines(nline:nline+nnewlines-1))
45.22 + nline = nline + nnewlines
45.23 + return
45.24 +end
45.25 +;*************************************************************
45.26 +begin
45.27 +
45.28 + plot_type = "ps"
45.29 + plot_type_new = "png"
45.30 +
45.31 +; for 6 fields, 12-monthly
45.32 + nmon = 12
45.33 + nfield = 6
45.34 +
45.35 +;************************************************
45.36 +; read model data
45.37 +;************************************************
45.38 + model = "cn"
45.39 +; model = "casa"
45.40 +
45.41 + model_name = "i01.10" + model
45.42 +
45.43 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
45.44 + film = "lnd_T42.nc"
45.45 + fm = addfile(dirm+film,"r")
45.46 +
45.47 + xm = fm->lon
45.48 + ym = fm->lat
45.49 +;------------------------------------------------
45.50 + nlat = dimsizes(ym)
45.51 + nlon = dimsizes(xm)
45.52 +
45.53 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
45.54 +
45.55 +; change to unit of observed (u mol/m2/s)
45.56 +; Model_units [=] gC/m2/s
45.57 +; 12. = molecular weight of C
45.58 +; u mol = 1e-6 mol
45.59 + factor = 1e6 /12.
45.60 +
45.61 + ENERGY ="new"
45.62 +
45.63 +;************************************************
45.64 +; read data: observed
45.65 +;************************************************
45.66 +
45.67 + station = (/"ARM_Oklahoma" \
45.68 + ,"ARM_Oklahoma_burn" \
45.69 + ,"ARM_Oklahoma_control" \
45.70 + ,"Atqasuk" \
45.71 + ,"Audubon" \
45.72 + ,"AustinCary" \
45.73 + ,"Bartlett" \
45.74 + ,"Bondville" \
45.75 + ,"Brookings" \
45.76 + ,"Donaldson" \
45.77 + ,"Duke_Forest_Hardwoods" \
45.78 + ,"Duke_Forest_Open_Field" \
45.79 + ,"Duke_Forest_Pine" \
45.80 + ,"Fermi_Ag" \
45.81 + ,"Fermi_Prairie" \
45.82 + ,"Flagstaff_Managed" \
45.83 + ,"Flagstaff_Unmanaged" \
45.84 + ,"Flagstaff_Wildfire" \
45.85 + ,"FortPeck" \
45.86 + ,"FreemanRanch_mesquite" \
45.87 + ,"Goodwin_Creek" \
45.88 + ,"HarvardForest" \
45.89 + ,"HarvardForestHemlock" \
45.90 + ,"HowlandForestMain" \
45.91 + ,"HowlandForestWest" \
45.92 + ,"Ivotuk" \
45.93 + ,"KendallGrasslands" \
45.94 + ,"KennedySpaceCenterPine" \
45.95 + ,"KennedySpaceCenterScrub" \
45.96 + ,"LittleProspect" \
45.97 + ,"LostCreek" \
45.98 + ,"Mead-irrigated" \
45.99 + ,"Mead-irrigated-rotation" \
45.100 + ,"Mead-rainfed" \
45.101 + ,"Metolius_2nd_YoungPonderosaPine" \
45.102 + ,"MetoliusEyerly" \
45.103 + ,"MetoliusIntermediatePine" \
45.104 + ,"MetoliusOldPonderosaPine" \
45.105 + ,"MissouriOzark" \
45.106 + ,"Mize" \
45.107 + ,"MorganMonroe" \
45.108 + ,"NiwotRidge" \
45.109 + ,"NorthCarolina_cc" \
45.110 + ,"NorthCarolina_lp" \
45.111 + ,"ParkFalls" \
45.112 + ,"Rayonier" \
45.113 + ,"SantaRita" \
45.114 + ,"SkyOaks_Old" \
45.115 + ,"SkyOaks_PostFire" \
45.116 + ,"SkyOaks_Young" \
45.117 + ,"SylvaniaWilderness" \
45.118 + ,"Toledo" \
45.119 + ,"Tonzi" \
45.120 + ,"UCI_1850" \
45.121 + ,"UCI_1930" \
45.122 + ,"UCI_1964" \
45.123 + ,"UCI_1964wet" \
45.124 + ,"UCI_1981" \
45.125 + ,"UCI_1989" \
45.126 + ,"UCI_1998" \
45.127 + ,"UMBS" \
45.128 + ,"Vaira" \
45.129 + ,"WalkerBranch" \
45.130 + ,"WillowCreek" \
45.131 + ,"WindRiver" \
45.132 + ,"Wisconsin_ihw" \
45.133 + ,"Wisconsin_irp" \
45.134 + ,"Wisconsin_mrp" \
45.135 + ,"Wisconsin_myjp" \
45.136 + ,"Wisconsin_pb" \
45.137 + ,"Wisconsin_rpcc" \
45.138 + ,"Wisconsin_yhw" \
45.139 + ,"Wisconsin_yjp" \
45.140 + ,"Wisconsin_yrp" \
45.141 + /)
45.142 +
45.143 + year_ob = (/"2003-2006" \
45.144 + ,"2005-2006" \
45.145 + ,"2005-2006" \
45.146 + ,"1999-2006" \
45.147 + ,"2002-2006" \
45.148 + ,"2000-2005" \
45.149 + ,"2004-2005" \
45.150 + ,"1996-2006" \
45.151 + ,"2004-2006" \
45.152 + ,"1999-2004" \
45.153 + ,"2003-2005" \
45.154 + ,"2001-2005" \
45.155 + ,"2001-2005" \
45.156 + ,"2005-2006" \
45.157 + ,"2004-2006" \
45.158 + ,"2005-2006" \
45.159 + ,"2005-2006" \
45.160 + ,"2005-2006" \
45.161 + ,"2000-2006" \
45.162 + ,"2004-2006" \
45.163 + ,"2002-2006" \
45.164 + ,"1991-2004" \
45.165 + ,"2004-2004" \
45.166 + ,"1996-2004" \
45.167 + ,"1999-2004" \
45.168 + ,"2003-2006" \
45.169 + ,"2004-2006" \
45.170 + ,"2002-2002" \
45.171 + ,"2000-2006" \
45.172 + ,"2002-2005" \
45.173 + ,"2001-2005" \
45.174 + ,"2001-2005" \
45.175 + ,"2001-2005" \
45.176 + ,"2001-2005" \
45.177 + ,"2004-2005" \
45.178 + ,"2004-2005" \
45.179 + ,"2003-2005" \
45.180 + ,"1996-2000" \
45.181 + ,"2004-2006" \
45.182 + ,"1998-2004" \
45.183 + ,"1999-2005" \
45.184 + ,"1999-2003" \
45.185 + ,"2005-2006" \
45.186 + ,"2005-2006" \
45.187 + ,"1996-2003" \
45.188 + ,"1998-1998" \
45.189 + ,"2004-2006" \
45.190 + ,"1997-2006" \
45.191 + ,"2004-2006" \
45.192 + ,"1997-2006" \
45.193 + ,"2002-2006" \
45.194 + ,"2004-2005" \
45.195 + ,"2001-2006" \
45.196 + ,"2004-2005" \
45.197 + ,"2001-2005" \
45.198 + ,"2001-2005" \
45.199 + ,"2002-2004" \
45.200 + ,"2001-2005" \
45.201 + ,"2001-2005" \
45.202 + ,"2002-2005" \
45.203 + ,"1999-2003" \
45.204 + ,"2001-2006" \
45.205 + ,"1995-1999" \
45.206 + ,"1999-2005" \
45.207 + ,"1999-2004" \
45.208 + ,"2003-2003" \
45.209 + ,"2003-2003" \
45.210 + ,"2002-2005" \
45.211 + ,"2004-2004" \
45.212 + ,"2002-2002" \
45.213 + ,"2005-2005" \
45.214 + ,"2002-2002" \
45.215 + ,"2004-2005" \
45.216 + ,"2002-2002" \
45.217 + /)
45.218 +
45.219 + field = (/"NEE Flux" \
45.220 + ,"Net Radiation" \
45.221 + ,"Latent Heat" \
45.222 + ,"Sensible Heat" \
45.223 + ,"GPP Flux" \
45.224 + ,"Respiration" \
45.225 + /)
45.226 +
45.227 + field_unit = (/"u mol/m2/s" \
45.228 + ,"W/m2" \
45.229 + ,"W/m2" \
45.230 + ,"W/m2" \
45.231 + ,"u mol/m2/s" \
45.232 + ,"u mol/m2/s" \
45.233 + /)
45.234 +
45.235 + nstation = dimsizes(station)
45.236 +
45.237 + data_mod = new ((/nstation, nfield, nmon/),float)
45.238 + data_ob = new ((/nstation, nfield, nmon/),float)
45.239 + lat_ob = new ((/nstation/),float)
45.240 + lon_ob = new ((/nstation/),float)
45.241 + unit_ob = new ((/nfield/),string)
45.242 +
45.243 + diro_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
45.244 + dirm_root = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
45.245 +
45.246 + do n = 0,nstation-1
45.247 +
45.248 +;-------------------------------------------------
45.249 +; get ob data
45.250 +
45.251 + diro = diro_root + station(n)+"/"
45.252 + filo = year_ob(n)+"_L4_m.nc"
45.253 + fo = addfile (diro+filo,"r")
45.254 +
45.255 + print (filo)
45.256 +
45.257 + lon_ob(n) = fo->lon
45.258 + lat_ob(n) = fo->lat
45.259 +
45.260 + data = fo->NEE_or_fMDS
45.261 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
45.262 + delete (data)
45.263 +
45.264 + data = fo->Rg_f
45.265 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
45.266 + delete (data)
45.267 +
45.268 + data = fo->LE_f
45.269 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
45.270 + delete (data)
45.271 +
45.272 + data = fo->H_f
45.273 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
45.274 + delete (data)
45.275 +
45.276 + data = fo->GPP_or_MDS
45.277 + data_ob(n,4,:) = dim_avg(data(month|:,year|:))
45.278 + delete (data)
45.279 +
45.280 + data = fo->Reco_or
45.281 + data_ob(n,5,:) = dim_avg(data(month|:,year|:))
45.282 + delete (data)
45.283 +
45.284 + delete (fo)
45.285 +;---------------------------------------------------
45.286 +; get model data
45.287 +
45.288 +; film = model_name+"_"+ year_ob(n)+"_MONS_climo.nc"
45.289 + film = model_name+"_"+"1990-2004"+"_MONS_climo.nc"
45.290 + fm = addfile (dirm_root+film,"r")
45.291 +
45.292 + print (film)
45.293 +
45.294 +if (ENERGY .eq. "old") then
45.295 +
45.296 + data = fm->NEE
45.297 + data_mod0(0,:,:,:) = data(:,:,:) * factor
45.298 + delete (data)
45.299 +
45.300 +; data = fm->LATENT
45.301 + data1 = fm->FCEV
45.302 + data2 = fm->FCTR
45.303 + data3 = fm->FGEV
45.304 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
45.305 + delete (data1)
45.306 + delete (data2)
45.307 + delete (data3)
45.308 +
45.309 +; data = fm->SENSIBLE
45.310 + data = fm->FSH
45.311 + data_mod0(3,:,:,:) = data(:,:,:)
45.312 + delete (data)
45.313 +
45.314 +; data = fm->NETRAD
45.315 + data1 = fm->FSA
45.316 + data2 = fm->FIRA
45.317 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)-data_mod0(2,:,:,:)-data_mod0(3,:,:,:)
45.318 + delete (data1)
45.319 + delete (data2)
45.320 +
45.321 +else
45.322 +
45.323 + data = fm->NEE
45.324 + data_mod0(0,:,:,:) = data(:,:,:) * factor
45.325 + delete (data)
45.326 +
45.327 + data = fm->NETRAD
45.328 + data_mod0(1,:,:,:) = data(:,:,:)
45.329 + delete (data)
45.330 +
45.331 + data = fm->LATENT
45.332 + data_mod0(2,:,:,:) = data(:,:,:)
45.333 + delete (data)
45.334 +
45.335 +; data = fm->SENSIBLE
45.336 + data = fm->FSH
45.337 + data_mod0(3,:,:,:) = data(:,:,:)
45.338 + delete (data)
45.339 +end if
45.340 +
45.341 + data = fm->GPP
45.342 + data_mod0(4,:,:,:) = data(:,:,:) * factor
45.343 + delete (data)
45.344 +
45.345 + if (model .eq. "cn") then
45.346 + data = fm->ER
45.347 + else
45.348 + data1 = fm->AR
45.349 + data2 = fm->HR
45.350 + data = data1 + data2
45.351 +
45.352 + delete (data1)
45.353 + delete (data2)
45.354 + end if
45.355 +
45.356 + data_mod0(5,:,:,:) = data(:,:,:) * factor
45.357 + delete (data)
45.358 +
45.359 + delete (fm)
45.360 +
45.361 +;************************************************************
45.362 +; interpolate model data into observed station
45.363 +; note: model is 0-360E, 90S-90N
45.364 +;************************************************************
45.365 +
45.366 +; to be able to handle observation at (-89.98,-24.80)
45.367 + ym(0) = -90.
45.368 +
45.369 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob(n),lat_ob(n),0)
45.370 +
45.371 +; print (yy)
45.372 +
45.373 + data_mod(n,:,:) = yy(:,:,0)
45.374 +
45.375 + delete (yy)
45.376 +
45.377 + end do
45.378 +;************************************************************
45.379 +; compute correlation coef and M score
45.380 +;************************************************************
45.381 +
45.382 + score_max = 5.
45.383 +
45.384 + ccr = new ((/nstation, nfield/),float)
45.385 + M_score = new ((/nstation, nfield/),float)
45.386 +
45.387 + do n=0,nstation-1
45.388 + do m=0,nfield-1
45.389 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
45.390 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
45.391 + M_score(n,m) = (1. -(bias/nmon)) * score_max
45.392 + end do
45.393 + end do
45.394 +
45.395 + M_co2 = avg(M_score(:,0))
45.396 + M_rad = avg(M_score(:,1))
45.397 + M_lh = avg(M_score(:,2))
45.398 + M_sh = avg(M_score(:,3))
45.399 + M_gpp = avg(M_score(:,4))
45.400 + M_er = avg(M_score(:,5))
45.401 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
45.402 +
45.403 + M_energy_co2 = sprintf("%.2f", M_co2)
45.404 + M_energy_rad = sprintf("%.2f", M_rad)
45.405 + M_energy_lh = sprintf("%.2f", M_lh )
45.406 + M_energy_sh = sprintf("%.2f", M_sh )
45.407 + M_energy_gpp = sprintf("%.2f", M_gpp)
45.408 + M_energy_er = sprintf("%.2f", M_er )
45.409 + M_energy_all = sprintf("%.2f", M_all)
45.410 +
45.411 +;*******************************************************************
45.412 +; for station line plot
45.413 +;*******************************************************************
45.414 +
45.415 +; for x-axis in xyplot
45.416 + mon = ispan(1,12,1)
45.417 + mon@long_name = "month"
45.418 +
45.419 + res = True ; plot mods desired
45.420 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
45.421 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
45.422 +;-------------------------------------------------------------------------
45.423 +; Add a boxed legend using the more simple method
45.424 +
45.425 + res@pmLegendDisplayMode = "Always"
45.426 +; res@pmLegendWidthF = 0.1
45.427 + res@pmLegendWidthF = 0.08
45.428 + res@pmLegendHeightF = 0.06
45.429 +; res@pmLegendOrthogonalPosF = -1.17
45.430 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
45.431 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
45.432 +
45.433 +; res@pmLegendParallelPosF = 0.18
45.434 + res@pmLegendParallelPosF = 0.23 ;(rightward)
45.435 +
45.436 +; res@lgPerimOn = False
45.437 + res@lgLabelFontHeightF = 0.015
45.438 + res@xyExplicitLegendLabels = (/"observed",model_name/)
45.439 +;-------------------------------------------------------------------
45.440 +; for panel plot
45.441 + res@gsnFrame = False ; Do not draw plot
45.442 + res@gsnDraw = False ; Do not advance frame
45.443 +
45.444 + pres = True ; panel plot mods desired
45.445 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
45.446 + ; indiv. plots in panel
45.447 + pres@gsnMaximize = True ; fill the page
45.448 +;-------------------------------------------------------------------
45.449 +
45.450 + plot_data = new((/2,12/),float)
45.451 + plot_data!0 = "case"
45.452 + plot_data!1 = "month"
45.453 +
45.454 + do n = 0,nstation-1
45.455 +;----------------------------
45.456 +; for observed
45.457 +
45.458 + plot_name = station(n)+"_ob"
45.459 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
45.460 + res@tiMainString = title
45.461 +
45.462 + wks = gsn_open_wks (plot_type,plot_name)
45.463 + plot=new(nfield,graphic) ; create graphic array
45.464 +
45.465 + do i = 0,nfield-1
45.466 + plot_data(0,:) = (/data_ob (n,i,:)/)
45.467 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
45.468 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
45.469 + end do
45.470 +
45.471 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
45.472 +
45.473 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
45.474 + "rm "+plot_name+"."+plot_type)
45.475 +
45.476 + clear (wks)
45.477 + delete (plot)
45.478 +;----------------------------
45.479 +; for model_vs_ob
45.480 +
45.481 + plot_name = station(n)+"_model_vs_ob"
45.482 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
45.483 + res@tiMainString = title
45.484 +
45.485 + wks = gsn_open_wks (plot_type,plot_name)
45.486 + plot=new(nfield,graphic) ; create graphic array
45.487 +
45.488 + do i = 0,nfield-1
45.489 + plot_data(0,:) = (/data_ob (n,i,:)/)
45.490 + plot_data(1,:) = (/data_mod(n,i,:)/)
45.491 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
45.492 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
45.493 + end do
45.494 +
45.495 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
45.496 +
45.497 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
45.498 + "rm "+plot_name+"."+plot_type)
45.499 +
45.500 + clear (wks)
45.501 + delete (plot)
45.502 + end do
45.503 +
45.504 +;*******************************************************************
45.505 +; html table of site: observed
45.506 +;*******************************************************************
45.507 + output_html = "line_ob.html"
45.508 +
45.509 + header = (/"<HTML>" \
45.510 + ,"<HEAD>" \
45.511 + ,"<TITLE>CLAMP metrics</TITLE>" \
45.512 + ,"</HEAD>" \
45.513 + ,"<H1>Energy at Site: Observation</H1>" \
45.514 + /)
45.515 + footer = "</HTML>"
45.516 +
45.517 + table_header = (/ \
45.518 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
45.519 + ,"<tr>" \
45.520 + ," <th bgcolor=DDDDDD >Site Name</th>" \
45.521 + ," <th bgcolor=DDDDDD >Latitude</th>" \
45.522 + ," <th bgcolor=DDDDDD >Longitude</th>" \
45.523 + ," <th bgcolor=DDDDDD >Observed</th>" \
45.524 + ,"</tr>" \
45.525 + /)
45.526 + table_footer = "</table>"
45.527 + row_header = "<tr>"
45.528 + row_footer = "</tr>"
45.529 +
45.530 + lines = new(50000,string)
45.531 + nline = 0
45.532 +
45.533 + set_line(lines,nline,header)
45.534 + set_line(lines,nline,table_header)
45.535 +;-----------------------------------------------
45.536 +; row of table
45.537 +
45.538 + do n = 0,nstation-1
45.539 + set_line(lines,nline,row_header)
45.540 +
45.541 + txt0 = station(n)
45.542 + txt1 = sprintf("%5.2f", lat_ob(n))
45.543 + txt2 = sprintf("%5.2f", lon_ob(n))
45.544 + txt3 = year_ob(n)
45.545 +
45.546 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
45.547 + set_line(lines,nline,"<th>"+txt1+"</th>")
45.548 + set_line(lines,nline,"<th>"+txt2+"</th>")
45.549 + set_line(lines,nline,"<th>"+txt3+"</th>")
45.550 +
45.551 + set_line(lines,nline,row_footer)
45.552 + end do
45.553 +;-----------------------------------------------
45.554 + set_line(lines,nline,table_footer)
45.555 + set_line(lines,nline,footer)
45.556 +
45.557 +; Now write to an HTML file.
45.558 + idx = ind(.not.ismissing(lines))
45.559 + if(.not.any(ismissing(idx))) then
45.560 + asciiwrite(output_html,lines(idx))
45.561 + else
45.562 + print ("error?")
45.563 + end if
45.564 + delete (idx)
45.565 +
45.566 +;*******************************************************************
45.567 +; score and line table : model vs observed
45.568 +;*******************************************************************
45.569 + output_html = "score+line_vs_ob.html"
45.570 +
45.571 + header = (/"<HTML>" \
45.572 + ,"<HEAD>" \
45.573 + ,"<TITLE>CLAMP metrics</TITLE>" \
45.574 + ,"</HEAD>" \
45.575 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
45.576 + /)
45.577 + footer = "</HTML>"
45.578 +
45.579 + delete (table_header)
45.580 + table_header = (/ \
45.581 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
45.582 + ,"<tr>" \
45.583 + ," <th bgcolor=DDDDDD >Site Name</th>" \
45.584 + ," <th bgcolor=DDDDDD >Latitude</th>" \
45.585 + ," <th bgcolor=DDDDDD >Longitude</th>" \
45.586 + ," <th bgcolor=DDDDDD >Observed</th>" \
45.587 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
45.588 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
45.589 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
45.590 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
45.591 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
45.592 + ," <th bgcolor=DDDDDD >Respiration</th>" \
45.593 + ," <th bgcolor=DDDDDD >Average</th>" \
45.594 + ,"</tr>" \
45.595 + /)
45.596 + table_footer = "</table>"
45.597 + row_header = "<tr>"
45.598 + row_footer = "</tr>"
45.599 +
45.600 + lines = new(50000,string)
45.601 + nline = 0
45.602 +
45.603 + set_line(lines,nline,header)
45.604 + set_line(lines,nline,table_header)
45.605 +;-----------------------------------------------
45.606 +; row of table
45.607 +
45.608 + do n = 0,nstation-1
45.609 + set_line(lines,nline,row_header)
45.610 +
45.611 + txt0 = station(n)
45.612 + txt1 = sprintf("%5.2f", lat_ob(n))
45.613 + txt2 = sprintf("%5.2f", lon_ob(n))
45.614 + txt3 = year_ob(n)
45.615 + txt4 = sprintf("%5.2f", M_score(n,0))
45.616 + txt5 = sprintf("%5.2f", M_score(n,1))
45.617 + txt6 = sprintf("%5.2f", M_score(n,2))
45.618 + txt7 = sprintf("%5.2f", M_score(n,3))
45.619 + txt8 = sprintf("%5.2f", M_score(n,4))
45.620 + txt9 = sprintf("%5.2f", M_score(n,5))
45.621 + txt10 = sprintf("%5.2f", avg(M_score(n,:)))
45.622 +
45.623 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
45.624 + set_line(lines,nline,"<th>"+txt1+"</th>")
45.625 + set_line(lines,nline,"<th>"+txt2+"</th>")
45.626 + set_line(lines,nline,"<th>"+txt3+"</th>")
45.627 + set_line(lines,nline,"<th>"+txt4+"</th>")
45.628 + set_line(lines,nline,"<th>"+txt5+"</th>")
45.629 + set_line(lines,nline,"<th>"+txt6+"</th>")
45.630 + set_line(lines,nline,"<th>"+txt7+"</th>")
45.631 + set_line(lines,nline,"<th>"+txt8+"</th>")
45.632 + set_line(lines,nline,"<th>"+txt9+"</th>")
45.633 + set_line(lines,nline,"<th>"+txt10+"</th>")
45.634 +
45.635 + set_line(lines,nline,row_footer)
45.636 + end do
45.637 +
45.638 +; last row, summary
45.639 + set_line(lines,nline,row_header)
45.640 +
45.641 + txt0 = "All_"+sprintf("%.0f", nstation)
45.642 + txt1 = "-"
45.643 + txt2 = "-"
45.644 + txt3 = "-"
45.645 + txt4 = M_energy_co2
45.646 + txt5 = M_energy_rad
45.647 + txt6 = M_energy_lh
45.648 + txt7 = M_energy_sh
45.649 + txt8 = M_energy_gpp
45.650 + txt9 = M_energy_er
45.651 + txt10 = M_energy_all
45.652 +
45.653 + set_line(lines,nline,"<th>"+txt0+"</th>")
45.654 + set_line(lines,nline,"<th>"+txt1+"</th>")
45.655 + set_line(lines,nline,"<th>"+txt2+"</th>")
45.656 + set_line(lines,nline,"<th>"+txt3+"</th>")
45.657 + set_line(lines,nline,"<th>"+txt4+"</th>")
45.658 + set_line(lines,nline,"<th>"+txt5+"</th>")
45.659 + set_line(lines,nline,"<th>"+txt6+"</th>")
45.660 + set_line(lines,nline,"<th>"+txt7+"</th>")
45.661 + set_line(lines,nline,"<th>"+txt8+"</th>")
45.662 + set_line(lines,nline,"<th>"+txt9+"</th>")
45.663 + set_line(lines,nline,"<th>"+txt10+"</th>")
45.664 +
45.665 + set_line(lines,nline,row_footer)
45.666 +;-----------------------------------------------
45.667 + set_line(lines,nline,table_footer)
45.668 + set_line(lines,nline,footer)
45.669 +
45.670 +; Now write to an HTML file.
45.671 + idx = ind(.not.ismissing(lines))
45.672 + if(.not.any(ismissing(idx))) then
45.673 + asciiwrite(output_html,lines(idx))
45.674 + else
45.675 + print ("error?")
45.676 + end if
45.677 + delete (idx)
45.678 +
45.679 +;***************************************************************************
45.680 +; output plots
45.681 +;***************************************************************************
45.682 + output_dir = model_name+"/ameriflux"
45.683 +
45.684 + system("mv *.png *.html " + output_dir)
45.685 +;***************************************************************************
45.686 +end
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
46.2 +++ b/ameriflux/14.plot.ncl Mon Jan 26 22:08:20 2009 -0500
46.3 @@ -0,0 +1,854 @@
46.4 +;************************************************************
46.5 +; sort by latitude in decending order (N->S)
46.6 +; add year_ob_i and year_ob_f
46.7 +; change long_name
46.8 +;************************************************************
46.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
46.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
46.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
46.12 +;************************************************************
46.13 +procedure set_line(lines:string,nline:integer,newlines:string)
46.14 +begin
46.15 +; add line to ascci/html file
46.16 +
46.17 + nnewlines = dimsizes(newlines)
46.18 + if(nline+nnewlines-1.ge.dimsizes(lines))
46.19 + print("set_line: bad index, not setting anything.")
46.20 + return
46.21 + end if
46.22 + lines(nline:nline+nnewlines-1) = newlines
46.23 +; print ("lines = " + lines(nline:nline+nnewlines-1))
46.24 + nline = nline + nnewlines
46.25 + return
46.26 +end
46.27 +;*************************************************************
46.28 +begin
46.29 +
46.30 + plot_type = "ps"
46.31 + plot_type_new = "png"
46.32 +
46.33 +; for 6 fields, 12-monthly
46.34 + nmon = 12
46.35 + nfield = 6
46.36 +
46.37 +;************************************************
46.38 +; read model data
46.39 +;************************************************
46.40 + model = "cn"
46.41 +; model = "casa"
46.42 +
46.43 + model_name = "i01.10" + model
46.44 +
46.45 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
46.46 + film = "lnd_T42.nc"
46.47 + fm = addfile(dirm+film,"r")
46.48 +
46.49 + xm = fm->lon
46.50 + ym = fm->lat
46.51 +;------------------------------------------------
46.52 + nlat = dimsizes(ym)
46.53 + nlon = dimsizes(xm)
46.54 +
46.55 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
46.56 +
46.57 +; change to unit of observed (u mol/m2/s)
46.58 +; Model_units [=] gC/m2/s
46.59 +; 12. = molecular weight of C
46.60 +; u mol = 1e-6 mol
46.61 + factor = 1e6 /12.
46.62 +
46.63 + ENERGY ="new"
46.64 +
46.65 +;************************************************
46.66 +; read data: observed
46.67 +;************************************************
46.68 +
46.69 + station = (/"ARM_Oklahoma" \
46.70 + ,"ARM_Oklahoma_burn" \
46.71 + ,"ARM_Oklahoma_control" \
46.72 + ,"Atqasuk" \
46.73 + ,"Audubon" \
46.74 + ,"AustinCary" \
46.75 + ,"Bartlett" \
46.76 + ,"Bondville" \
46.77 + ,"Brookings" \
46.78 + ,"Donaldson" \
46.79 + ,"Duke_Forest_Hardwoods" \
46.80 + ,"Duke_Forest_Open_Field" \
46.81 + ,"Duke_Forest_Pine" \
46.82 + ,"Fermi_Ag" \
46.83 + ,"Fermi_Prairie" \
46.84 + ,"Flagstaff_Managed" \
46.85 + ,"Flagstaff_Unmanaged" \
46.86 + ,"Flagstaff_Wildfire" \
46.87 + ,"FortPeck" \
46.88 + ,"FreemanRanch_mesquite" \
46.89 + ,"Goodwin_Creek" \
46.90 + ,"HarvardForest" \
46.91 + ,"HarvardForestHemlock" \
46.92 + ,"HowlandForestMain" \
46.93 + ,"HowlandForestWest" \
46.94 + ,"Ivotuk" \
46.95 + ,"KendallGrasslands" \
46.96 + ,"KennedySpaceCenterPine" \
46.97 + ,"KennedySpaceCenterScrub" \
46.98 + ,"LittleProspect" \
46.99 + ,"LostCreek" \
46.100 + ,"Mead-irrigated" \
46.101 + ,"Mead-irrigated-rotation" \
46.102 + ,"Mead-rainfed" \
46.103 + ,"Metolius_2nd_YoungPonderosaPine" \
46.104 + ,"MetoliusEyerly" \
46.105 + ,"MetoliusIntermediatePine" \
46.106 + ,"MetoliusOldPonderosaPine" \
46.107 + ,"MissouriOzark" \
46.108 + ,"Mize" \
46.109 + ,"MorganMonroe" \
46.110 + ,"NiwotRidge" \
46.111 + ,"NorthCarolina_cc" \
46.112 + ,"NorthCarolina_lp" \
46.113 + ,"ParkFalls" \
46.114 + ,"Rayonier" \
46.115 + ,"SantaRita" \
46.116 + ,"SkyOaks_Old" \
46.117 + ,"SkyOaks_PostFire" \
46.118 + ,"SkyOaks_Young" \
46.119 + ,"SylvaniaWilderness" \
46.120 + ,"Toledo" \
46.121 + ,"Tonzi" \
46.122 + ,"UCI_1850" \
46.123 + ,"UCI_1930" \
46.124 + ,"UCI_1964" \
46.125 + ,"UCI_1964wet" \
46.126 + ,"UCI_1981" \
46.127 + ,"UCI_1989" \
46.128 + ,"UCI_1998" \
46.129 + ,"UMBS" \
46.130 + ,"Vaira" \
46.131 + ,"WalkerBranch" \
46.132 + ,"WillowCreek" \
46.133 + ,"WindRiver" \
46.134 + ,"Wisconsin_ihw" \
46.135 + ,"Wisconsin_irp" \
46.136 + ,"Wisconsin_mrp" \
46.137 + ,"Wisconsin_myjp" \
46.138 + ,"Wisconsin_pb" \
46.139 + ,"Wisconsin_rpcc" \
46.140 + ,"Wisconsin_yhw" \
46.141 + ,"Wisconsin_yjp" \
46.142 + ,"Wisconsin_yrp" \
46.143 + /)
46.144 +
46.145 + year_ob = (/"2003-2006" \
46.146 + ,"2005-2006" \
46.147 + ,"2005-2006" \
46.148 + ,"1999-2006" \
46.149 + ,"2002-2006" \
46.150 + ,"2000-2005" \
46.151 + ,"2004-2005" \
46.152 + ,"1996-2006" \
46.153 + ,"2004-2006" \
46.154 + ,"1999-2004" \
46.155 + ,"2003-2005" \
46.156 + ,"2001-2005" \
46.157 + ,"2001-2005" \
46.158 + ,"2005-2006" \
46.159 + ,"2004-2006" \
46.160 + ,"2005-2006" \
46.161 + ,"2005-2006" \
46.162 + ,"2005-2006" \
46.163 + ,"2000-2006" \
46.164 + ,"2004-2006" \
46.165 + ,"2002-2006" \
46.166 + ,"1991-2004" \
46.167 + ,"2004-2004" \
46.168 + ,"1996-2004" \
46.169 + ,"1999-2004" \
46.170 + ,"2003-2006" \
46.171 + ,"2004-2006" \
46.172 + ,"2002-2002" \
46.173 + ,"2000-2006" \
46.174 + ,"2002-2005" \
46.175 + ,"2001-2005" \
46.176 + ,"2001-2005" \
46.177 + ,"2001-2005" \
46.178 + ,"2001-2005" \
46.179 + ,"2004-2005" \
46.180 + ,"2004-2005" \
46.181 + ,"2003-2005" \
46.182 + ,"1996-2000" \
46.183 + ,"2004-2006" \
46.184 + ,"1998-2004" \
46.185 + ,"1999-2005" \
46.186 + ,"1999-2003" \
46.187 + ,"2005-2006" \
46.188 + ,"2005-2006" \
46.189 + ,"1996-2003" \
46.190 + ,"1998-1998" \
46.191 + ,"2004-2006" \
46.192 + ,"1997-2006" \
46.193 + ,"2004-2006" \
46.194 + ,"1997-2006" \
46.195 + ,"2002-2006" \
46.196 + ,"2004-2005" \
46.197 + ,"2001-2006" \
46.198 + ,"2004-2005" \
46.199 + ,"2001-2005" \
46.200 + ,"2001-2005" \
46.201 + ,"2002-2004" \
46.202 + ,"2001-2005" \
46.203 + ,"2001-2005" \
46.204 + ,"2002-2005" \
46.205 + ,"1999-2003" \
46.206 + ,"2001-2006" \
46.207 + ,"1995-1999" \
46.208 + ,"1999-2005" \
46.209 + ,"1999-2004" \
46.210 + ,"2003-2003" \
46.211 + ,"2003-2003" \
46.212 + ,"2002-2005" \
46.213 + ,"2004-2004" \
46.214 + ,"2002-2002" \
46.215 + ,"2005-2005" \
46.216 + ,"2002-2002" \
46.217 + ,"2004-2005" \
46.218 + ,"2002-2002" \
46.219 + /)
46.220 +
46.221 + year_ob_i = (/2003 \
46.222 + ,2005 \
46.223 + ,2005 \
46.224 + ,1999 \
46.225 + ,2002 \
46.226 + ,2000 \
46.227 + ,2004 \
46.228 + ,1996 \
46.229 + ,2004 \
46.230 + ,1999 \
46.231 + ,2003 \
46.232 + ,2001 \
46.233 + ,2001 \
46.234 + ,2005 \
46.235 + ,2004 \
46.236 + ,2005 \
46.237 + ,2005 \
46.238 + ,2005 \
46.239 + ,2000 \
46.240 + ,2004 \
46.241 + ,2002 \
46.242 + ,1991 \
46.243 + ,2004 \
46.244 + ,1996 \
46.245 + ,1999 \
46.246 + ,2003 \
46.247 + ,2004 \
46.248 + ,2002 \
46.249 + ,2000 \
46.250 + ,2002 \
46.251 + ,2001 \
46.252 + ,2001 \
46.253 + ,2001 \
46.254 + ,2001 \
46.255 + ,2004 \
46.256 + ,2004 \
46.257 + ,2003 \
46.258 + ,1996 \
46.259 + ,2004 \
46.260 + ,1998 \
46.261 + ,1999 \
46.262 + ,1999 \
46.263 + ,2005 \
46.264 + ,2005 \
46.265 + ,1996 \
46.266 + ,1998 \
46.267 + ,2004 \
46.268 + ,1997 \
46.269 + ,2004 \
46.270 + ,1997 \
46.271 + ,2002 \
46.272 + ,2004 \
46.273 + ,2001 \
46.274 + ,2004 \
46.275 + ,2001 \
46.276 + ,2001 \
46.277 + ,2002 \
46.278 + ,2001 \
46.279 + ,2001 \
46.280 + ,2002 \
46.281 + ,1999 \
46.282 + ,2001 \
46.283 + ,1995 \
46.284 + ,1999 \
46.285 + ,1999 \
46.286 + ,2003 \
46.287 + ,2003 \
46.288 + ,2002 \
46.289 + ,2004 \
46.290 + ,2002 \
46.291 + ,2005 \
46.292 + ,2002 \
46.293 + ,2004 \
46.294 + ,2002 \
46.295 + /)
46.296 +
46.297 + year_ob_f = (/2006 \
46.298 + ,2006 \
46.299 + ,2006 \
46.300 + ,2006 \
46.301 + ,2006 \
46.302 + ,2005 \
46.303 + ,2005 \
46.304 + ,2006 \
46.305 + ,2006 \
46.306 + ,2004 \
46.307 + ,2005 \
46.308 + ,2005 \
46.309 + ,2005 \
46.310 + ,2006 \
46.311 + ,2006 \
46.312 + ,2006 \
46.313 + ,2006 \
46.314 + ,2006 \
46.315 + ,2006 \
46.316 + ,2006 \
46.317 + ,2006 \
46.318 + ,2004 \
46.319 + ,2004 \
46.320 + ,2004 \
46.321 + ,2004 \
46.322 + ,2006 \
46.323 + ,2006 \
46.324 + ,2002 \
46.325 + ,2006 \
46.326 + ,2005 \
46.327 + ,2005 \
46.328 + ,2005 \
46.329 + ,2005 \
46.330 + ,2005 \
46.331 + ,2005 \
46.332 + ,2005 \
46.333 + ,2005 \
46.334 + ,2000 \
46.335 + ,2006 \
46.336 + ,2004 \
46.337 + ,2005 \
46.338 + ,2003 \
46.339 + ,2006 \
46.340 + ,2006 \
46.341 + ,2003 \
46.342 + ,1998 \
46.343 + ,2006 \
46.344 + ,2006 \
46.345 + ,2006 \
46.346 + ,2006 \
46.347 + ,2006 \
46.348 + ,2005 \
46.349 + ,2006 \
46.350 + ,2005 \
46.351 + ,2005 \
46.352 + ,2005 \
46.353 + ,2004 \
46.354 + ,2005 \
46.355 + ,2005 \
46.356 + ,2005 \
46.357 + ,2003 \
46.358 + ,2006 \
46.359 + ,1999 \
46.360 + ,2005 \
46.361 + ,2004 \
46.362 + ,2003 \
46.363 + ,2003 \
46.364 + ,2005 \
46.365 + ,2004 \
46.366 + ,2002 \
46.367 + ,2005 \
46.368 + ,2002 \
46.369 + ,2005 \
46.370 + ,2002 \
46.371 + /)
46.372 +
46.373 + field = (/"NEE Flux" \
46.374 + ,"Net Radiation" \
46.375 + ,"Latent Heat" \
46.376 + ,"Sensible Heat" \
46.377 + ,"GPP Flux" \
46.378 + ,"Respiration" \
46.379 + /)
46.380 +
46.381 + field_unit = (/"u mol/m2/s" \
46.382 + ,"W/m2" \
46.383 + ,"W/m2" \
46.384 + ,"W/m2" \
46.385 + ,"u mol/m2/s" \
46.386 + ,"u mol/m2/s" \
46.387 + /)
46.388 +
46.389 + nstation = dimsizes(station)
46.390 +
46.391 + data_mod = new ((/nstation, nfield, nmon/),float)
46.392 + data_ob = new ((/nstation, nfield, nmon/),float)
46.393 + lat_ob = new ((/nstation/),float)
46.394 + lon_ob = new ((/nstation/),float)
46.395 + unit_ob = new ((/nfield/),string)
46.396 +
46.397 + diro_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
46.398 + dirm_root = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
46.399 +
46.400 + do n = 0,nstation-1
46.401 +
46.402 +;-------------------------------------------------
46.403 +; get ob data
46.404 +
46.405 + diro = diro_root + station(n)+"/"
46.406 + filo = year_ob_i(n)+"-"+year_ob_f(n)+"_L4_m.nc"
46.407 + fo = addfile (diro+filo,"r")
46.408 +
46.409 + print (filo)
46.410 +
46.411 + lon_ob(n) = fo->lon
46.412 + lat_ob(n) = fo->lat
46.413 +
46.414 + data = fo->NEE_or_fMDS
46.415 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
46.416 + delete (data)
46.417 +
46.418 + data = fo->Rg_f
46.419 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
46.420 + delete (data)
46.421 +
46.422 + data = fo->LE_f
46.423 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
46.424 + delete (data)
46.425 +
46.426 + data = fo->H_f
46.427 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
46.428 + delete (data)
46.429 +
46.430 + data = fo->GPP_or_MDS
46.431 + data_ob(n,4,:) = dim_avg(data(month|:,year|:))
46.432 + delete (data)
46.433 +
46.434 + data = fo->Reco_or
46.435 + data_ob(n,5,:) = dim_avg(data(month|:,year|:))
46.436 + delete (data)
46.437 +
46.438 + delete (fo)
46.439 +;---------------------------------------------------
46.440 +; get model data
46.441 +
46.442 +; film = model_name+"_"+ year_ob(n)+"_MONS_climo.nc"
46.443 + film = model_name+"_"+"1990-2004"+"_MONS_climo.nc"
46.444 + fm = addfile (dirm_root+film,"r")
46.445 +
46.446 +; print (film)
46.447 +
46.448 +if (ENERGY .eq. "old") then
46.449 +
46.450 + data = fm->NEE
46.451 + data_mod0(0,:,:,:) = data(:,:,:) * factor
46.452 + delete (data)
46.453 +
46.454 +; data = fm->LATENT
46.455 + data1 = fm->FCEV
46.456 + data2 = fm->FCTR
46.457 + data3 = fm->FGEV
46.458 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
46.459 + delete (data1)
46.460 + delete (data2)
46.461 + delete (data3)
46.462 +
46.463 +; data = fm->SENSIBLE
46.464 + data = fm->FSH
46.465 + data_mod0(3,:,:,:) = data(:,:,:)
46.466 + delete (data)
46.467 +
46.468 +; data = fm->NETRAD
46.469 + data1 = fm->FSA
46.470 + data2 = fm->FIRA
46.471 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)-data_mod0(2,:,:,:)-data_mod0(3,:,:,:)
46.472 + delete (data1)
46.473 + delete (data2)
46.474 +
46.475 +else
46.476 +
46.477 + data = fm->NEE
46.478 + data_mod0(0,:,:,:) = data(:,:,:) * factor
46.479 + delete (data)
46.480 +
46.481 + data = fm->NETRAD
46.482 + data_mod0(1,:,:,:) = data(:,:,:)
46.483 + delete (data)
46.484 +
46.485 + data = fm->LATENT
46.486 + data_mod0(2,:,:,:) = data(:,:,:)
46.487 + delete (data)
46.488 +
46.489 +; data = fm->SENSIBLE
46.490 + data = fm->FSH
46.491 + data_mod0(3,:,:,:) = data(:,:,:)
46.492 + delete (data)
46.493 +end if
46.494 +
46.495 + data = fm->GPP
46.496 + data_mod0(4,:,:,:) = data(:,:,:) * factor
46.497 + delete (data)
46.498 +
46.499 + if (model .eq. "cn") then
46.500 + data = fm->ER
46.501 + else
46.502 + data1 = fm->AR
46.503 + data2 = fm->HR
46.504 + data = data1 + data2
46.505 +
46.506 + delete (data1)
46.507 + delete (data2)
46.508 + end if
46.509 +
46.510 + data_mod0(5,:,:,:) = data(:,:,:) * factor
46.511 + delete (data)
46.512 +
46.513 + delete (fm)
46.514 +
46.515 +;************************************************************
46.516 +; interpolate model data into observed station
46.517 +; note: model is 0-360E, 90S-90N
46.518 +;************************************************************
46.519 +
46.520 +; to be able to handle observation at (-89.98,-24.80)
46.521 + ym(0) = -90.
46.522 +
46.523 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob(n),lat_ob(n),0)
46.524 +
46.525 +; print (yy)
46.526 +
46.527 + data_mod(n,:,:) = yy(:,:,0)
46.528 +
46.529 + delete (yy)
46.530 +
46.531 + end do
46.532 +
46.533 +;************************************************************
46.534 +; compute correlation coef and M score
46.535 +;************************************************************
46.536 +
46.537 + score_max = 5.
46.538 +
46.539 + ccr = new ((/nstation, nfield/),float)
46.540 + M_score = new ((/nstation, nfield/),float)
46.541 +
46.542 + do n=0,nstation-1
46.543 + do m=0,nfield-1
46.544 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
46.545 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
46.546 + M_score(n,m) = (1. -(bias/nmon)) * score_max
46.547 + end do
46.548 + end do
46.549 +
46.550 + M_co2 = avg(M_score(:,0))
46.551 + M_rad = avg(M_score(:,1))
46.552 + M_lh = avg(M_score(:,2))
46.553 + M_sh = avg(M_score(:,3))
46.554 + M_gpp = avg(M_score(:,4))
46.555 + M_er = avg(M_score(:,5))
46.556 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
46.557 +
46.558 + M_energy_co2 = sprintf("%.2f", M_co2)
46.559 + M_energy_rad = sprintf("%.2f", M_rad)
46.560 + M_energy_lh = sprintf("%.2f", M_lh )
46.561 + M_energy_sh = sprintf("%.2f", M_sh )
46.562 + M_energy_gpp = sprintf("%.2f", M_gpp)
46.563 + M_energy_er = sprintf("%.2f", M_er )
46.564 + M_energy_all = sprintf("%.2f", M_all)
46.565 +
46.566 +;*******************************************************************
46.567 +; for station line plot
46.568 +;*******************************************************************
46.569 +
46.570 +; for x-axis in xyplot
46.571 + mon = ispan(1,12,1)
46.572 + mon@long_name = "month"
46.573 +
46.574 + res = True ; plot mods desired
46.575 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
46.576 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
46.577 +;-------------------------------------------------------------------------
46.578 +; Add a boxed legend using the more simple method
46.579 +
46.580 + res@pmLegendDisplayMode = "Always"
46.581 +; res@pmLegendWidthF = 0.1
46.582 + res@pmLegendWidthF = 0.08
46.583 + res@pmLegendHeightF = 0.06
46.584 +; res@pmLegendOrthogonalPosF = -1.17
46.585 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
46.586 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
46.587 +
46.588 +; res@pmLegendParallelPosF = 0.18
46.589 + res@pmLegendParallelPosF = 0.23 ;(rightward)
46.590 +
46.591 +; res@lgPerimOn = False
46.592 + res@lgLabelFontHeightF = 0.015
46.593 + res@xyExplicitLegendLabels = (/"observed",model_name/)
46.594 +;-------------------------------------------------------------------
46.595 +; for panel plot
46.596 + res@gsnFrame = False ; Do not draw plot
46.597 + res@gsnDraw = False ; Do not advance frame
46.598 +
46.599 + pres = True ; panel plot mods desired
46.600 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
46.601 + ; indiv. plots in panel
46.602 + pres@gsnMaximize = True ; fill the page
46.603 +;-------------------------------------------------------------------
46.604 +
46.605 + plot_data = new((/2,12/),float)
46.606 + plot_data!0 = "case"
46.607 + plot_data!1 = "month"
46.608 +
46.609 + do n = 0,nstation-1
46.610 +;----------------------------
46.611 +; for observed
46.612 +
46.613 + plot_name = station(n)+"_ob"
46.614 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
46.615 + res@tiMainString = title
46.616 +
46.617 + wks = gsn_open_wks (plot_type,plot_name)
46.618 + plot=new(nfield,graphic) ; create graphic array
46.619 +
46.620 + do i = 0,nfield-1
46.621 + plot_data(0,:) = (/data_ob (n,i,:)/)
46.622 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
46.623 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
46.624 + end do
46.625 +
46.626 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
46.627 +
46.628 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
46.629 + "rm "+plot_name+"."+plot_type)
46.630 +
46.631 + clear (wks)
46.632 + delete (plot)
46.633 +;----------------------------
46.634 +; for model_vs_ob
46.635 +
46.636 + plot_name = station(n)+"_model_vs_ob"
46.637 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
46.638 + res@tiMainString = title
46.639 +
46.640 + wks = gsn_open_wks (plot_type,plot_name)
46.641 + plot=new(nfield,graphic) ; create graphic array
46.642 +
46.643 + do i = 0,nfield-1
46.644 + plot_data(0,:) = (/data_ob (n,i,:)/)
46.645 + plot_data(1,:) = (/data_mod(n,i,:)/)
46.646 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
46.647 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
46.648 + end do
46.649 +
46.650 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
46.651 +
46.652 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
46.653 + "rm "+plot_name+"."+plot_type)
46.654 +
46.655 + clear (wks)
46.656 + delete (plot)
46.657 + end do
46.658 +
46.659 +;###################################################################
46.660 +; for the following tables,
46.661 +; sort by latitude in decending order (N->S)
46.662 +; sort by lat in decending order (N->S)
46.663 +
46.664 + isort = dim_pqsort(lat_ob,-1)
46.665 +
46.666 + station_sort = station(isort)
46.667 + lat_ob_sort = lat_ob(isort)
46.668 + lon_ob_sort = lon_ob(isort)
46.669 + year_ob_sort = year_ob(isort)
46.670 + M_score_sort = M_score(isort,:)
46.671 +
46.672 + print(isort)
46.673 + print(lat_ob_sort)
46.674 +;###################################################################
46.675 +;*******************************************************************
46.676 +; html table of site: observed
46.677 +;*******************************************************************
46.678 + output_html = "line_ob.html"
46.679 +
46.680 + header = (/"<HTML>" \
46.681 + ,"<HEAD>" \
46.682 + ,"<TITLE>CLAMP metrics</TITLE>" \
46.683 + ,"</HEAD>" \
46.684 + ,"<H1>Energy at Site: Observation</H1>" \
46.685 + /)
46.686 + footer = "</HTML>"
46.687 +
46.688 + table_header = (/ \
46.689 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
46.690 + ,"<tr>" \
46.691 + ," <th bgcolor=DDDDDD >Site Name</th>" \
46.692 + ," <th bgcolor=DDDDDD >Latitude</th>" \
46.693 + ," <th bgcolor=DDDDDD >Longitude</th>" \
46.694 + ," <th bgcolor=DDDDDD >Observed</th>" \
46.695 + ,"</tr>" \
46.696 + /)
46.697 + table_footer = "</table>"
46.698 + row_header = "<tr>"
46.699 + row_footer = "</tr>"
46.700 +
46.701 + lines = new(50000,string)
46.702 + nline = 0
46.703 +
46.704 + set_line(lines,nline,header)
46.705 + set_line(lines,nline,table_header)
46.706 +;-----------------------------------------------
46.707 +; row of table
46.708 +
46.709 + do n = 0,nstation-1
46.710 + set_line(lines,nline,row_header)
46.711 +
46.712 + txt0 = station_sort(n)
46.713 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
46.714 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
46.715 + txt3 = year_ob_sort(n)
46.716 +
46.717 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
46.718 + set_line(lines,nline,"<th>"+txt1+"</th>")
46.719 + set_line(lines,nline,"<th>"+txt2+"</th>")
46.720 + set_line(lines,nline,"<th>"+txt3+"</th>")
46.721 +
46.722 + set_line(lines,nline,row_footer)
46.723 + end do
46.724 +;-----------------------------------------------
46.725 + set_line(lines,nline,table_footer)
46.726 + set_line(lines,nline,footer)
46.727 +
46.728 +; Now write to an HTML file.
46.729 + idx = ind(.not.ismissing(lines))
46.730 + if(.not.any(ismissing(idx))) then
46.731 + asciiwrite(output_html,lines(idx))
46.732 + else
46.733 + print ("error?")
46.734 + end if
46.735 + delete (idx)
46.736 +
46.737 +;*******************************************************************
46.738 +; score and line table : model vs observed
46.739 +;*******************************************************************
46.740 + output_html = "score+line_vs_ob.html"
46.741 +
46.742 + header = (/"<HTML>" \
46.743 + ,"<HEAD>" \
46.744 + ,"<TITLE>CLAMP metrics</TITLE>" \
46.745 + ,"</HEAD>" \
46.746 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
46.747 + /)
46.748 + footer = "</HTML>"
46.749 +
46.750 + delete (table_header)
46.751 + table_header = (/ \
46.752 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
46.753 + ,"<tr>" \
46.754 + ," <th bgcolor=DDDDDD >Site Name</th>" \
46.755 + ," <th bgcolor=DDDDDD >Latitude</th>" \
46.756 + ," <th bgcolor=DDDDDD >Longitude</th>" \
46.757 + ," <th bgcolor=DDDDDD >Observed</th>" \
46.758 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
46.759 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
46.760 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
46.761 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
46.762 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
46.763 + ," <th bgcolor=DDDDDD >Respiration</th>" \
46.764 + ," <th bgcolor=DDDDDD >Average</th>" \
46.765 + ,"</tr>" \
46.766 + /)
46.767 + table_footer = "</table>"
46.768 + row_header = "<tr>"
46.769 + row_footer = "</tr>"
46.770 +
46.771 + lines = new(50000,string)
46.772 + nline = 0
46.773 +
46.774 + set_line(lines,nline,header)
46.775 + set_line(lines,nline,table_header)
46.776 +;-----------------------------------------------
46.777 +; row of table
46.778 +
46.779 + do n = 0,nstation-1
46.780 + set_line(lines,nline,row_header)
46.781 +
46.782 + txt0 = station_sort(n)
46.783 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
46.784 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
46.785 + txt3 = year_ob_sort(n)
46.786 + txt4 = sprintf("%5.2f", M_score_sort(n,0))
46.787 + txt5 = sprintf("%5.2f", M_score_sort(n,1))
46.788 + txt6 = sprintf("%5.2f", M_score_sort(n,2))
46.789 + txt7 = sprintf("%5.2f", M_score_sort(n,3))
46.790 + txt8 = sprintf("%5.2f", M_score_sort(n,4))
46.791 + txt9 = sprintf("%5.2f", M_score_sort(n,5))
46.792 + txt10 = sprintf("%5.2f", avg(M_score_sort(n,:)))
46.793 +
46.794 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
46.795 + set_line(lines,nline,"<th>"+txt1+"</th>")
46.796 + set_line(lines,nline,"<th>"+txt2+"</th>")
46.797 + set_line(lines,nline,"<th>"+txt3+"</th>")
46.798 + set_line(lines,nline,"<th>"+txt4+"</th>")
46.799 + set_line(lines,nline,"<th>"+txt5+"</th>")
46.800 + set_line(lines,nline,"<th>"+txt6+"</th>")
46.801 + set_line(lines,nline,"<th>"+txt7+"</th>")
46.802 + set_line(lines,nline,"<th>"+txt8+"</th>")
46.803 + set_line(lines,nline,"<th>"+txt9+"</th>")
46.804 + set_line(lines,nline,"<th>"+txt10+"</th>")
46.805 +
46.806 + set_line(lines,nline,row_footer)
46.807 + end do
46.808 +
46.809 +; last row, summary
46.810 + set_line(lines,nline,row_header)
46.811 +
46.812 + txt0 = "All_"+sprintf("%.0f", nstation)
46.813 + txt1 = "-"
46.814 + txt2 = "-"
46.815 + txt3 = "-"
46.816 + txt4 = M_energy_co2
46.817 + txt5 = M_energy_rad
46.818 + txt6 = M_energy_lh
46.819 + txt7 = M_energy_sh
46.820 + txt8 = M_energy_gpp
46.821 + txt9 = M_energy_er
46.822 + txt10 = M_energy_all
46.823 +
46.824 + set_line(lines,nline,"<th>"+txt0+"</th>")
46.825 + set_line(lines,nline,"<th>"+txt1+"</th>")
46.826 + set_line(lines,nline,"<th>"+txt2+"</th>")
46.827 + set_line(lines,nline,"<th>"+txt3+"</th>")
46.828 + set_line(lines,nline,"<th>"+txt4+"</th>")
46.829 + set_line(lines,nline,"<th>"+txt5+"</th>")
46.830 + set_line(lines,nline,"<th>"+txt6+"</th>")
46.831 + set_line(lines,nline,"<th>"+txt7+"</th>")
46.832 + set_line(lines,nline,"<th>"+txt8+"</th>")
46.833 + set_line(lines,nline,"<th>"+txt9+"</th>")
46.834 + set_line(lines,nline,"<th>"+txt10+"</th>")
46.835 +
46.836 + set_line(lines,nline,row_footer)
46.837 +;-----------------------------------------------
46.838 + set_line(lines,nline,table_footer)
46.839 + set_line(lines,nline,footer)
46.840 +
46.841 +; Now write to an HTML file.
46.842 + idx = ind(.not.ismissing(lines))
46.843 + if(.not.any(ismissing(idx))) then
46.844 + asciiwrite(output_html,lines(idx))
46.845 + else
46.846 + print ("error?")
46.847 + end if
46.848 + delete (idx)
46.849 +
46.850 +;***************************************************************************
46.851 +; output plots
46.852 +;***************************************************************************
46.853 + output_dir = model_name+"/ameriflux"
46.854 +
46.855 + system("mv *.png *.html " + output_dir)
46.856 +;***************************************************************************
46.857 +end
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
47.2 +++ b/ameriflux/15.plot.ncl Mon Jan 26 22:08:20 2009 -0500
47.3 @@ -0,0 +1,858 @@
47.4 +;************************************************************
47.5 +; find year_ob >= 4
47.6 +; add year_ob_i and year_ob_f
47.7 +; change long_name
47.8 +;************************************************************
47.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
47.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
47.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
47.12 +;************************************************************
47.13 +procedure set_line(lines:string,nline:integer,newlines:string)
47.14 +begin
47.15 +; add line to ascci/html file
47.16 +
47.17 + nnewlines = dimsizes(newlines)
47.18 + if(nline+nnewlines-1.ge.dimsizes(lines))
47.19 + print("set_line: bad index, not setting anything.")
47.20 + return
47.21 + end if
47.22 + lines(nline:nline+nnewlines-1) = newlines
47.23 +; print ("lines = " + lines(nline:nline+nnewlines-1))
47.24 + nline = nline + nnewlines
47.25 + return
47.26 +end
47.27 +;*************************************************************
47.28 +begin
47.29 +
47.30 + plot_type = "ps"
47.31 + plot_type_new = "png"
47.32 +
47.33 +; for 6 fields, 12-monthly
47.34 + nmon = 12
47.35 + nfield = 6
47.36 +
47.37 +;************************************************
47.38 +; read model data
47.39 +;************************************************
47.40 + model = "cn"
47.41 +; model = "casa"
47.42 +
47.43 + model_name = "i01.10" + model
47.44 +
47.45 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
47.46 + film = "lnd_T42.nc"
47.47 + fm = addfile(dirm+film,"r")
47.48 +
47.49 + xm = fm->lon
47.50 + ym = fm->lat
47.51 +;------------------------------------------------
47.52 + nlat = dimsizes(ym)
47.53 + nlon = dimsizes(xm)
47.54 +
47.55 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
47.56 +
47.57 +; change to unit of observed (u mol/m2/s)
47.58 +; Model_units [=] gC/m2/s
47.59 +; 12. = molecular weight of C
47.60 +; u mol = 1e-6 mol
47.61 + factor = 1e6 /12.
47.62 +
47.63 + ENERGY ="new"
47.64 +
47.65 +;************************************************
47.66 +; read data: observed
47.67 +;************************************************
47.68 +
47.69 + station = (/"ARM_Oklahoma" \
47.70 + ,"ARM_Oklahoma_burn" \
47.71 + ,"ARM_Oklahoma_control" \
47.72 + ,"Atqasuk" \
47.73 + ,"Audubon" \
47.74 + ,"AustinCary" \
47.75 + ,"Bartlett" \
47.76 + ,"Bondville" \
47.77 + ,"Brookings" \
47.78 + ,"Donaldson" \
47.79 + ,"Duke_Forest_Hardwoods" \
47.80 + ,"Duke_Forest_Open_Field" \
47.81 + ,"Duke_Forest_Pine" \
47.82 + ,"Fermi_Ag" \
47.83 + ,"Fermi_Prairie" \
47.84 + ,"Flagstaff_Managed" \
47.85 + ,"Flagstaff_Unmanaged" \
47.86 + ,"Flagstaff_Wildfire" \
47.87 + ,"FortPeck" \
47.88 + ,"FreemanRanch_mesquite" \
47.89 + ,"Goodwin_Creek" \
47.90 + ,"HarvardForest" \
47.91 + ,"HarvardForestHemlock" \
47.92 + ,"HowlandForestMain" \
47.93 + ,"HowlandForestWest" \
47.94 + ,"Ivotuk" \
47.95 + ,"KendallGrasslands" \
47.96 + ,"KennedySpaceCenterPine" \
47.97 + ,"KennedySpaceCenterScrub" \
47.98 + ,"LittleProspect" \
47.99 + ,"LostCreek" \
47.100 + ,"Mead-irrigated" \
47.101 + ,"Mead-irrigated-rotation" \
47.102 + ,"Mead-rainfed" \
47.103 + ,"Metolius_2nd_YoungPonderosaPine" \
47.104 + ,"MetoliusEyerly" \
47.105 + ,"MetoliusIntermediatePine" \
47.106 + ,"MetoliusOldPonderosaPine" \
47.107 + ,"MissouriOzark" \
47.108 + ,"Mize" \
47.109 + ,"MorganMonroe" \
47.110 + ,"NiwotRidge" \
47.111 + ,"NorthCarolina_cc" \
47.112 + ,"NorthCarolina_lp" \
47.113 + ,"ParkFalls" \
47.114 + ,"Rayonier" \
47.115 + ,"SantaRita" \
47.116 + ,"SkyOaks_Old" \
47.117 + ,"SkyOaks_PostFire" \
47.118 + ,"SkyOaks_Young" \
47.119 + ,"SylvaniaWilderness" \
47.120 + ,"Toledo" \
47.121 + ,"Tonzi" \
47.122 + ,"UCI_1850" \
47.123 + ,"UCI_1930" \
47.124 + ,"UCI_1964" \
47.125 + ,"UCI_1964wet" \
47.126 + ,"UCI_1981" \
47.127 + ,"UCI_1989" \
47.128 + ,"UCI_1998" \
47.129 + ,"UMBS" \
47.130 + ,"Vaira" \
47.131 + ,"WalkerBranch" \
47.132 + ,"WillowCreek" \
47.133 + ,"WindRiver" \
47.134 + ,"Wisconsin_ihw" \
47.135 + ,"Wisconsin_irp" \
47.136 + ,"Wisconsin_mrp" \
47.137 + ,"Wisconsin_myjp" \
47.138 + ,"Wisconsin_pb" \
47.139 + ,"Wisconsin_rpcc" \
47.140 + ,"Wisconsin_yhw" \
47.141 + ,"Wisconsin_yjp" \
47.142 + ,"Wisconsin_yrp" \
47.143 + /)
47.144 +
47.145 + year_ob = (/"2003-2006" \
47.146 + ,"2005-2006" \
47.147 + ,"2005-2006" \
47.148 + ,"1999-2006" \
47.149 + ,"2002-2006" \
47.150 + ,"2000-2005" \
47.151 + ,"2004-2005" \
47.152 + ,"1996-2006" \
47.153 + ,"2004-2006" \
47.154 + ,"1999-2004" \
47.155 + ,"2003-2005" \
47.156 + ,"2001-2005" \
47.157 + ,"2001-2005" \
47.158 + ,"2005-2006" \
47.159 + ,"2004-2006" \
47.160 + ,"2005-2006" \
47.161 + ,"2005-2006" \
47.162 + ,"2005-2006" \
47.163 + ,"2000-2006" \
47.164 + ,"2004-2006" \
47.165 + ,"2002-2006" \
47.166 + ,"1991-2004" \
47.167 + ,"2004-2004" \
47.168 + ,"1996-2004" \
47.169 + ,"1999-2004" \
47.170 + ,"2003-2006" \
47.171 + ,"2004-2006" \
47.172 + ,"2002-2002" \
47.173 + ,"2000-2006" \
47.174 + ,"2002-2005" \
47.175 + ,"2001-2005" \
47.176 + ,"2001-2005" \
47.177 + ,"2001-2005" \
47.178 + ,"2001-2005" \
47.179 + ,"2004-2005" \
47.180 + ,"2004-2005" \
47.181 + ,"2003-2005" \
47.182 + ,"1996-2000" \
47.183 + ,"2004-2006" \
47.184 + ,"1998-2004" \
47.185 + ,"1999-2005" \
47.186 + ,"1999-2003" \
47.187 + ,"2005-2006" \
47.188 + ,"2005-2006" \
47.189 + ,"1996-2003" \
47.190 + ,"1998-1998" \
47.191 + ,"2004-2006" \
47.192 + ,"1997-2006" \
47.193 + ,"2004-2006" \
47.194 + ,"1997-2006" \
47.195 + ,"2002-2006" \
47.196 + ,"2004-2005" \
47.197 + ,"2001-2006" \
47.198 + ,"2004-2005" \
47.199 + ,"2001-2005" \
47.200 + ,"2001-2005" \
47.201 + ,"2002-2004" \
47.202 + ,"2001-2005" \
47.203 + ,"2001-2005" \
47.204 + ,"2002-2005" \
47.205 + ,"1999-2003" \
47.206 + ,"2001-2006" \
47.207 + ,"1995-1999" \
47.208 + ,"1999-2005" \
47.209 + ,"1999-2004" \
47.210 + ,"2003-2003" \
47.211 + ,"2003-2003" \
47.212 + ,"2002-2005" \
47.213 + ,"2004-2004" \
47.214 + ,"2002-2002" \
47.215 + ,"2005-2005" \
47.216 + ,"2002-2002" \
47.217 + ,"2004-2005" \
47.218 + ,"2002-2002" \
47.219 + /)
47.220 +
47.221 + year_ob_i = (/2003 \
47.222 + ,2005 \
47.223 + ,2005 \
47.224 + ,1999 \
47.225 + ,2002 \
47.226 + ,2000 \
47.227 + ,2004 \
47.228 + ,1996 \
47.229 + ,2004 \
47.230 + ,1999 \
47.231 + ,2003 \
47.232 + ,2001 \
47.233 + ,2001 \
47.234 + ,2005 \
47.235 + ,2004 \
47.236 + ,2005 \
47.237 + ,2005 \
47.238 + ,2005 \
47.239 + ,2000 \
47.240 + ,2004 \
47.241 + ,2002 \
47.242 + ,1991 \
47.243 + ,2004 \
47.244 + ,1996 \
47.245 + ,1999 \
47.246 + ,2003 \
47.247 + ,2004 \
47.248 + ,2002 \
47.249 + ,2000 \
47.250 + ,2002 \
47.251 + ,2001 \
47.252 + ,2001 \
47.253 + ,2001 \
47.254 + ,2001 \
47.255 + ,2004 \
47.256 + ,2004 \
47.257 + ,2003 \
47.258 + ,1996 \
47.259 + ,2004 \
47.260 + ,1998 \
47.261 + ,1999 \
47.262 + ,1999 \
47.263 + ,2005 \
47.264 + ,2005 \
47.265 + ,1996 \
47.266 + ,1998 \
47.267 + ,2004 \
47.268 + ,1997 \
47.269 + ,2004 \
47.270 + ,1997 \
47.271 + ,2002 \
47.272 + ,2004 \
47.273 + ,2001 \
47.274 + ,2004 \
47.275 + ,2001 \
47.276 + ,2001 \
47.277 + ,2002 \
47.278 + ,2001 \
47.279 + ,2001 \
47.280 + ,2002 \
47.281 + ,1999 \
47.282 + ,2001 \
47.283 + ,1995 \
47.284 + ,1999 \
47.285 + ,1999 \
47.286 + ,2003 \
47.287 + ,2003 \
47.288 + ,2002 \
47.289 + ,2004 \
47.290 + ,2002 \
47.291 + ,2005 \
47.292 + ,2002 \
47.293 + ,2004 \
47.294 + ,2002 \
47.295 + /)
47.296 +
47.297 + year_ob_f = (/2006 \
47.298 + ,2006 \
47.299 + ,2006 \
47.300 + ,2006 \
47.301 + ,2006 \
47.302 + ,2005 \
47.303 + ,2005 \
47.304 + ,2006 \
47.305 + ,2006 \
47.306 + ,2004 \
47.307 + ,2005 \
47.308 + ,2005 \
47.309 + ,2005 \
47.310 + ,2006 \
47.311 + ,2006 \
47.312 + ,2006 \
47.313 + ,2006 \
47.314 + ,2006 \
47.315 + ,2006 \
47.316 + ,2006 \
47.317 + ,2006 \
47.318 + ,2004 \
47.319 + ,2004 \
47.320 + ,2004 \
47.321 + ,2004 \
47.322 + ,2006 \
47.323 + ,2006 \
47.324 + ,2002 \
47.325 + ,2006 \
47.326 + ,2005 \
47.327 + ,2005 \
47.328 + ,2005 \
47.329 + ,2005 \
47.330 + ,2005 \
47.331 + ,2005 \
47.332 + ,2005 \
47.333 + ,2005 \
47.334 + ,2000 \
47.335 + ,2006 \
47.336 + ,2004 \
47.337 + ,2005 \
47.338 + ,2003 \
47.339 + ,2006 \
47.340 + ,2006 \
47.341 + ,2003 \
47.342 + ,1998 \
47.343 + ,2006 \
47.344 + ,2006 \
47.345 + ,2006 \
47.346 + ,2006 \
47.347 + ,2006 \
47.348 + ,2005 \
47.349 + ,2006 \
47.350 + ,2005 \
47.351 + ,2005 \
47.352 + ,2005 \
47.353 + ,2004 \
47.354 + ,2005 \
47.355 + ,2005 \
47.356 + ,2005 \
47.357 + ,2003 \
47.358 + ,2006 \
47.359 + ,1999 \
47.360 + ,2005 \
47.361 + ,2004 \
47.362 + ,2003 \
47.363 + ,2003 \
47.364 + ,2005 \
47.365 + ,2004 \
47.366 + ,2002 \
47.367 + ,2005 \
47.368 + ,2002 \
47.369 + ,2005 \
47.370 + ,2002 \
47.371 + /)
47.372 +
47.373 + year_ob_long = ind((year_ob_f - year_ob_i) .ge. 4 .and. year_ob_i .le. 2001)
47.374 + print (year_ob_long)
47.375 + print (year_ob_i(year_ob_long))
47.376 +
47.377 +
47.378 + field = (/"NEE Flux" \
47.379 + ,"Net Radiation" \
47.380 + ,"Latent Heat" \
47.381 + ,"Sensible Heat" \
47.382 + ,"GPP Flux" \
47.383 + ,"Respiration" \
47.384 + /)
47.385 +
47.386 + field_unit = (/"u mol/m2/s" \
47.387 + ,"W/m2" \
47.388 + ,"W/m2" \
47.389 + ,"W/m2" \
47.390 + ,"u mol/m2/s" \
47.391 + ,"u mol/m2/s" \
47.392 + /)
47.393 +
47.394 +;nstation = dimsizes(station)
47.395 + nstation = dimsizes(year_ob_long)
47.396 +
47.397 + data_mod = new ((/nstation, nfield, nmon/),float)
47.398 + data_ob = new ((/nstation, nfield, nmon/),float)
47.399 + lat_ob = new ((/nstation/),float)
47.400 + lon_ob = new ((/nstation/),float)
47.401 + unit_ob = new ((/nfield/),string)
47.402 +
47.403 + diro_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
47.404 + dirm_root = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
47.405 +
47.406 + do n = 0,nstation-1
47.407 +
47.408 +;-------------------------------------------------
47.409 +; get ob data
47.410 +
47.411 +; nn = n
47.412 + nn = year_ob_long(n)
47.413 +
47.414 + diro = diro_root + station(nn)+"/"
47.415 + filo = year_ob_i(nn)+"-"+year_ob_f(nn)+"_L4_m.nc"
47.416 + fo = addfile (diro+filo,"r")
47.417 +
47.418 + print (filo)
47.419 +
47.420 + lon_ob(n) = fo->lon
47.421 + lat_ob(n) = fo->lat
47.422 +
47.423 + data = fo->NEE_or_fMDS
47.424 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
47.425 + delete (data)
47.426 +
47.427 + data = fo->Rg_f
47.428 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
47.429 + delete (data)
47.430 +
47.431 + data = fo->LE_f
47.432 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
47.433 + delete (data)
47.434 +
47.435 + data = fo->H_f
47.436 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
47.437 + delete (data)
47.438 +
47.439 + data = fo->GPP_or_MDS
47.440 + data_ob(n,4,:) = dim_avg(data(month|:,year|:))
47.441 + delete (data)
47.442 +
47.443 + data = fo->Reco_or
47.444 + data_ob(n,5,:) = dim_avg(data(month|:,year|:))
47.445 + delete (data)
47.446 +
47.447 + delete (fo)
47.448 +;---------------------------------------------------
47.449 +; get model data
47.450 +
47.451 +; film = model_name+"_"+ year_ob(n)+"_MONS_climo.nc"
47.452 + film = model_name+"_"+"1990-2004"+"_MONS_climo.nc"
47.453 + fm = addfile (dirm_root+film,"r")
47.454 +
47.455 +; print (film)
47.456 +
47.457 +if (ENERGY .eq. "old") then
47.458 +
47.459 + data = fm->NEE
47.460 + data_mod0(0,:,:,:) = data(:,:,:) * factor
47.461 + delete (data)
47.462 +
47.463 +; data = fm->LATENT
47.464 + data1 = fm->FCEV
47.465 + data2 = fm->FCTR
47.466 + data3 = fm->FGEV
47.467 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
47.468 + delete (data1)
47.469 + delete (data2)
47.470 + delete (data3)
47.471 +
47.472 +; data = fm->SENSIBLE
47.473 + data = fm->FSH
47.474 + data_mod0(3,:,:,:) = data(:,:,:)
47.475 + delete (data)
47.476 +
47.477 +; data = fm->NETRAD
47.478 + data1 = fm->FSA
47.479 + data2 = fm->FIRA
47.480 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)-data_mod0(2,:,:,:)-data_mod0(3,:,:,:)
47.481 + delete (data1)
47.482 + delete (data2)
47.483 +
47.484 +else
47.485 +
47.486 + data = fm->NEE
47.487 + data_mod0(0,:,:,:) = data(:,:,:) * factor
47.488 + delete (data)
47.489 +
47.490 + data = fm->NETRAD
47.491 + data_mod0(1,:,:,:) = data(:,:,:)
47.492 + delete (data)
47.493 +
47.494 + data = fm->LATENT
47.495 + data_mod0(2,:,:,:) = data(:,:,:)
47.496 + delete (data)
47.497 +
47.498 +; data = fm->SENSIBLE
47.499 + data = fm->FSH
47.500 + data_mod0(3,:,:,:) = data(:,:,:)
47.501 + delete (data)
47.502 +end if
47.503 +
47.504 + data = fm->GPP
47.505 + data_mod0(4,:,:,:) = data(:,:,:) * factor
47.506 + delete (data)
47.507 +
47.508 + if (model .eq. "cn") then
47.509 + data = fm->ER
47.510 + else
47.511 + data1 = fm->AR
47.512 + data2 = fm->HR
47.513 + data = data1 + data2
47.514 +
47.515 + delete (data1)
47.516 + delete (data2)
47.517 + end if
47.518 +
47.519 + data_mod0(5,:,:,:) = data(:,:,:) * factor
47.520 + delete (data)
47.521 +
47.522 + delete (fm)
47.523 +
47.524 +;************************************************************
47.525 +; interpolate model data into observed station
47.526 +; note: model is 0-360E, 90S-90N
47.527 +;************************************************************
47.528 +
47.529 +; to be able to handle observation at (-89.98,-24.80)
47.530 + ym(0) = -90.
47.531 +
47.532 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob(n),lat_ob(n),0)
47.533 +
47.534 +; print (yy)
47.535 +
47.536 + data_mod(n,:,:) = yy(:,:,0)
47.537 +
47.538 + delete (yy)
47.539 +
47.540 + end do
47.541 +;************************************************************
47.542 +; compute correlation coef and M score
47.543 +;************************************************************
47.544 +
47.545 + score_max = 5.
47.546 +
47.547 + ccr = new ((/nstation, nfield/),float)
47.548 + M_score = new ((/nstation, nfield/),float)
47.549 +
47.550 + do n=0,nstation-1
47.551 + do m=0,nfield-1
47.552 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
47.553 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
47.554 + M_score(n,m) = (1. -(bias/nmon)) * score_max
47.555 + end do
47.556 + end do
47.557 +
47.558 + M_co2 = avg(M_score(:,0))
47.559 + M_rad = avg(M_score(:,1))
47.560 + M_lh = avg(M_score(:,2))
47.561 + M_sh = avg(M_score(:,3))
47.562 + M_gpp = avg(M_score(:,4))
47.563 + M_er = avg(M_score(:,5))
47.564 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
47.565 +
47.566 + M_energy_co2 = sprintf("%.2f", M_co2)
47.567 + M_energy_rad = sprintf("%.2f", M_rad)
47.568 + M_energy_lh = sprintf("%.2f", M_lh )
47.569 + M_energy_sh = sprintf("%.2f", M_sh )
47.570 + M_energy_gpp = sprintf("%.2f", M_gpp)
47.571 + M_energy_er = sprintf("%.2f", M_er )
47.572 + M_energy_all = sprintf("%.2f", M_all)
47.573 +
47.574 +;*******************************************************************
47.575 +; for station line plot
47.576 +;*******************************************************************
47.577 +
47.578 +; for x-axis in xyplot
47.579 + mon = ispan(1,12,1)
47.580 + mon@long_name = "month"
47.581 +
47.582 + res = True ; plot mods desired
47.583 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
47.584 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
47.585 +;-------------------------------------------------------------------------
47.586 +; Add a boxed legend using the more simple method
47.587 +
47.588 + res@pmLegendDisplayMode = "Always"
47.589 +; res@pmLegendWidthF = 0.1
47.590 + res@pmLegendWidthF = 0.08
47.591 + res@pmLegendHeightF = 0.06
47.592 +; res@pmLegendOrthogonalPosF = -1.17
47.593 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
47.594 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
47.595 +
47.596 +; res@pmLegendParallelPosF = 0.18
47.597 + res@pmLegendParallelPosF = 0.23 ;(rightward)
47.598 +
47.599 +; res@lgPerimOn = False
47.600 + res@lgLabelFontHeightF = 0.015
47.601 + res@xyExplicitLegendLabels = (/"observed",model_name/)
47.602 +;-------------------------------------------------------------------
47.603 +; for panel plot
47.604 + res@gsnFrame = False ; Do not draw plot
47.605 + res@gsnDraw = False ; Do not advance frame
47.606 +
47.607 + pres = True ; panel plot mods desired
47.608 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
47.609 + ; indiv. plots in panel
47.610 + pres@gsnMaximize = True ; fill the page
47.611 +;-------------------------------------------------------------------
47.612 +
47.613 + plot_data = new((/2,12/),float)
47.614 + plot_data!0 = "case"
47.615 + plot_data!1 = "month"
47.616 +
47.617 + do n = 0,nstation-1
47.618 +
47.619 +; nn = n
47.620 + nn = year_ob_long(n)
47.621 +
47.622 +;----------------------------
47.623 +; for observed
47.624 +
47.625 + plot_name = station(nn)+"_ob"
47.626 + title = station(nn)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
47.627 + res@tiMainString = title
47.628 +
47.629 + wks = gsn_open_wks (plot_type,plot_name)
47.630 + plot=new(nfield,graphic) ; create graphic array
47.631 +
47.632 + do i = 0,nfield-1
47.633 + plot_data(0,:) = (/data_ob (n,i,:)/)
47.634 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
47.635 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
47.636 + end do
47.637 +
47.638 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
47.639 +
47.640 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
47.641 + "rm "+plot_name+"."+plot_type)
47.642 +
47.643 + clear (wks)
47.644 + delete (plot)
47.645 +;----------------------------
47.646 +; for model_vs_ob
47.647 +
47.648 + plot_name = station(nn)+"_model_vs_ob"
47.649 + title = station(nn)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
47.650 + res@tiMainString = title
47.651 +
47.652 + wks = gsn_open_wks (plot_type,plot_name)
47.653 + plot=new(nfield,graphic) ; create graphic array
47.654 +
47.655 + do i = 0,nfield-1
47.656 + plot_data(0,:) = (/data_ob (n,i,:)/)
47.657 + plot_data(1,:) = (/data_mod(n,i,:)/)
47.658 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
47.659 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
47.660 + end do
47.661 +
47.662 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
47.663 +
47.664 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
47.665 + "rm "+plot_name+"."+plot_type)
47.666 +
47.667 + clear (wks)
47.668 + delete (plot)
47.669 + end do
47.670 +
47.671 +;*******************************************************************
47.672 +; html table of site: observed
47.673 +;*******************************************************************
47.674 + output_html = "line_ob.html"
47.675 +
47.676 + header = (/"<HTML>" \
47.677 + ,"<HEAD>" \
47.678 + ,"<TITLE>CLAMP metrics</TITLE>" \
47.679 + ,"</HEAD>" \
47.680 + ,"<H1>Energy at Site: Observation</H1>" \
47.681 + /)
47.682 + footer = "</HTML>"
47.683 +
47.684 + table_header = (/ \
47.685 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
47.686 + ,"<tr>" \
47.687 + ," <th bgcolor=DDDDDD >Site Name</th>" \
47.688 + ," <th bgcolor=DDDDDD >Latitude</th>" \
47.689 + ," <th bgcolor=DDDDDD >Longitude</th>" \
47.690 + ," <th bgcolor=DDDDDD >Observed</th>" \
47.691 + ,"</tr>" \
47.692 + /)
47.693 + table_footer = "</table>"
47.694 + row_header = "<tr>"
47.695 + row_footer = "</tr>"
47.696 +
47.697 + lines = new(50000,string)
47.698 + nline = 0
47.699 +
47.700 + set_line(lines,nline,header)
47.701 + set_line(lines,nline,table_header)
47.702 +;-----------------------------------------------
47.703 +; row of table
47.704 +
47.705 + do n = 0,nstation-1
47.706 +
47.707 +; nn = n
47.708 + nn = year_ob_long(n)
47.709 +
47.710 + set_line(lines,nline,row_header)
47.711 +
47.712 + txt0 = station(nn)
47.713 + txt1 = sprintf("%5.2f", lat_ob(n))
47.714 + txt2 = sprintf("%5.2f", lon_ob(n))
47.715 + txt3 = year_ob(nn)
47.716 +
47.717 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
47.718 + set_line(lines,nline,"<th>"+txt1+"</th>")
47.719 + set_line(lines,nline,"<th>"+txt2+"</th>")
47.720 + set_line(lines,nline,"<th>"+txt3+"</th>")
47.721 +
47.722 + set_line(lines,nline,row_footer)
47.723 + end do
47.724 +;-----------------------------------------------
47.725 + set_line(lines,nline,table_footer)
47.726 + set_line(lines,nline,footer)
47.727 +
47.728 +; Now write to an HTML file.
47.729 + idx = ind(.not.ismissing(lines))
47.730 + if(.not.any(ismissing(idx))) then
47.731 + asciiwrite(output_html,lines(idx))
47.732 + else
47.733 + print ("error?")
47.734 + end if
47.735 + delete (idx)
47.736 +
47.737 +;*******************************************************************
47.738 +; score and line table : model vs observed
47.739 +;*******************************************************************
47.740 + output_html = "score+line_vs_ob.html"
47.741 +
47.742 + header = (/"<HTML>" \
47.743 + ,"<HEAD>" \
47.744 + ,"<TITLE>CLAMP metrics</TITLE>" \
47.745 + ,"</HEAD>" \
47.746 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
47.747 + /)
47.748 + footer = "</HTML>"
47.749 +
47.750 + delete (table_header)
47.751 + table_header = (/ \
47.752 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
47.753 + ,"<tr>" \
47.754 + ," <th bgcolor=DDDDDD >Site Name</th>" \
47.755 + ," <th bgcolor=DDDDDD >Latitude</th>" \
47.756 + ," <th bgcolor=DDDDDD >Longitude</th>" \
47.757 + ," <th bgcolor=DDDDDD >Observed</th>" \
47.758 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
47.759 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
47.760 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
47.761 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
47.762 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
47.763 + ," <th bgcolor=DDDDDD >Respiration</th>" \
47.764 + ," <th bgcolor=DDDDDD >Average</th>" \
47.765 + ,"</tr>" \
47.766 + /)
47.767 + table_footer = "</table>"
47.768 + row_header = "<tr>"
47.769 + row_footer = "</tr>"
47.770 +
47.771 + lines = new(50000,string)
47.772 + nline = 0
47.773 +
47.774 + set_line(lines,nline,header)
47.775 + set_line(lines,nline,table_header)
47.776 +;-----------------------------------------------
47.777 +; row of table
47.778 +
47.779 + do n = 0,nstation-1
47.780 +
47.781 +; nn = n
47.782 + nn = year_ob_long(n)
47.783 +
47.784 + set_line(lines,nline,row_header)
47.785 +
47.786 + txt0 = station(nn)
47.787 + txt1 = sprintf("%5.2f", lat_ob(n))
47.788 + txt2 = sprintf("%5.2f", lon_ob(n))
47.789 + txt3 = year_ob(nn)
47.790 + txt4 = sprintf("%5.2f", M_score(n,0))
47.791 + txt5 = sprintf("%5.2f", M_score(n,1))
47.792 + txt6 = sprintf("%5.2f", M_score(n,2))
47.793 + txt7 = sprintf("%5.2f", M_score(n,3))
47.794 + txt8 = sprintf("%5.2f", M_score(n,4))
47.795 + txt9 = sprintf("%5.2f", M_score(n,5))
47.796 + txt10 = sprintf("%5.2f", avg(M_score(n,:)))
47.797 +
47.798 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
47.799 + set_line(lines,nline,"<th>"+txt1+"</th>")
47.800 + set_line(lines,nline,"<th>"+txt2+"</th>")
47.801 + set_line(lines,nline,"<th>"+txt3+"</th>")
47.802 + set_line(lines,nline,"<th>"+txt4+"</th>")
47.803 + set_line(lines,nline,"<th>"+txt5+"</th>")
47.804 + set_line(lines,nline,"<th>"+txt6+"</th>")
47.805 + set_line(lines,nline,"<th>"+txt7+"</th>")
47.806 + set_line(lines,nline,"<th>"+txt8+"</th>")
47.807 + set_line(lines,nline,"<th>"+txt9+"</th>")
47.808 + set_line(lines,nline,"<th>"+txt10+"</th>")
47.809 +
47.810 + set_line(lines,nline,row_footer)
47.811 + end do
47.812 +
47.813 +; last row, summary
47.814 + set_line(lines,nline,row_header)
47.815 +
47.816 + txt0 = "All_"+sprintf("%.0f", nstation)
47.817 + txt1 = "-"
47.818 + txt2 = "-"
47.819 + txt3 = "-"
47.820 + txt4 = M_energy_co2
47.821 + txt5 = M_energy_rad
47.822 + txt6 = M_energy_lh
47.823 + txt7 = M_energy_sh
47.824 + txt8 = M_energy_gpp
47.825 + txt9 = M_energy_er
47.826 + txt10 = M_energy_all
47.827 +
47.828 + set_line(lines,nline,"<th>"+txt0+"</th>")
47.829 + set_line(lines,nline,"<th>"+txt1+"</th>")
47.830 + set_line(lines,nline,"<th>"+txt2+"</th>")
47.831 + set_line(lines,nline,"<th>"+txt3+"</th>")
47.832 + set_line(lines,nline,"<th>"+txt4+"</th>")
47.833 + set_line(lines,nline,"<th>"+txt5+"</th>")
47.834 + set_line(lines,nline,"<th>"+txt6+"</th>")
47.835 + set_line(lines,nline,"<th>"+txt7+"</th>")
47.836 + set_line(lines,nline,"<th>"+txt8+"</th>")
47.837 + set_line(lines,nline,"<th>"+txt9+"</th>")
47.838 + set_line(lines,nline,"<th>"+txt10+"</th>")
47.839 +
47.840 + set_line(lines,nline,row_footer)
47.841 +;-----------------------------------------------
47.842 + set_line(lines,nline,table_footer)
47.843 + set_line(lines,nline,footer)
47.844 +
47.845 +; Now write to an HTML file.
47.846 + idx = ind(.not.ismissing(lines))
47.847 + if(.not.any(ismissing(idx))) then
47.848 + asciiwrite(output_html,lines(idx))
47.849 + else
47.850 + print ("error?")
47.851 + end if
47.852 + delete (idx)
47.853 +
47.854 +;***************************************************************************
47.855 +; output plots
47.856 +;***************************************************************************
47.857 + output_dir = model_name+"/ameriflux"
47.858 +
47.859 + system("mv *.png *.html " + output_dir)
47.860 +;***************************************************************************
47.861 +end
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
48.2 +++ b/ameriflux/16.plot.ncl Mon Jan 26 22:08:20 2009 -0500
48.3 @@ -0,0 +1,872 @@
48.4 +;************************************************************
48.5 +; sort by latitude in decending order (N->S)
48.6 +; find year_ob >= 4
48.7 +; add year_ob_i and year_ob_f
48.8 +; change long_name
48.9 +;************************************************************
48.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
48.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
48.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
48.13 +;************************************************************
48.14 +procedure set_line(lines:string,nline:integer,newlines:string)
48.15 +begin
48.16 +; add line to ascci/html file
48.17 +
48.18 + nnewlines = dimsizes(newlines)
48.19 + if(nline+nnewlines-1.ge.dimsizes(lines))
48.20 + print("set_line: bad index, not setting anything.")
48.21 + return
48.22 + end if
48.23 + lines(nline:nline+nnewlines-1) = newlines
48.24 +; print ("lines = " + lines(nline:nline+nnewlines-1))
48.25 + nline = nline + nnewlines
48.26 + return
48.27 +end
48.28 +;*************************************************************
48.29 +begin
48.30 +
48.31 + plot_type = "ps"
48.32 + plot_type_new = "png"
48.33 +
48.34 +; for 6 fields, 12-monthly
48.35 + nmon = 12
48.36 + nfield = 6
48.37 +
48.38 +;************************************************
48.39 +; read model data
48.40 +;************************************************
48.41 + model = "cn"
48.42 +; model = "casa"
48.43 +
48.44 + model_name = "i01.10" + model
48.45 +
48.46 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
48.47 + film = "lnd_T42.nc"
48.48 + fm = addfile(dirm+film,"r")
48.49 +
48.50 + xm = fm->lon
48.51 + ym = fm->lat
48.52 +;------------------------------------------------
48.53 + nlat = dimsizes(ym)
48.54 + nlon = dimsizes(xm)
48.55 +
48.56 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
48.57 +
48.58 +; change to unit of observed (u mol/m2/s)
48.59 +; Model_units [=] gC/m2/s
48.60 +; 12. = molecular weight of C
48.61 +; u mol = 1e-6 mol
48.62 + factor = 1e6 /12.
48.63 +
48.64 + ENERGY ="new"
48.65 +
48.66 +;************************************************
48.67 +; read data: observed
48.68 +;************************************************
48.69 +
48.70 + station = (/"ARM_Oklahoma" \
48.71 + ,"ARM_Oklahoma_burn" \
48.72 + ,"ARM_Oklahoma_control" \
48.73 + ,"Atqasuk" \
48.74 + ,"Audubon" \
48.75 + ,"AustinCary" \
48.76 + ,"Bartlett" \
48.77 + ,"Bondville" \
48.78 + ,"Brookings" \
48.79 + ,"Donaldson" \
48.80 + ,"Duke_Forest_Hardwoods" \
48.81 + ,"Duke_Forest_Open_Field" \
48.82 + ,"Duke_Forest_Pine" \
48.83 + ,"Fermi_Ag" \
48.84 + ,"Fermi_Prairie" \
48.85 + ,"Flagstaff_Managed" \
48.86 + ,"Flagstaff_Unmanaged" \
48.87 + ,"Flagstaff_Wildfire" \
48.88 + ,"FortPeck" \
48.89 + ,"FreemanRanch_mesquite" \
48.90 + ,"Goodwin_Creek" \
48.91 + ,"HarvardForest" \
48.92 + ,"HarvardForestHemlock" \
48.93 + ,"HowlandForestMain" \
48.94 + ,"HowlandForestWest" \
48.95 + ,"Ivotuk" \
48.96 + ,"KendallGrasslands" \
48.97 + ,"KennedySpaceCenterPine" \
48.98 + ,"KennedySpaceCenterScrub" \
48.99 + ,"LittleProspect" \
48.100 + ,"LostCreek" \
48.101 + ,"Mead-irrigated" \
48.102 + ,"Mead-irrigated-rotation" \
48.103 + ,"Mead-rainfed" \
48.104 + ,"Metolius_2nd_YoungPonderosaPine" \
48.105 + ,"MetoliusEyerly" \
48.106 + ,"MetoliusIntermediatePine" \
48.107 + ,"MetoliusOldPonderosaPine" \
48.108 + ,"MissouriOzark" \
48.109 + ,"Mize" \
48.110 + ,"MorganMonroe" \
48.111 + ,"NiwotRidge" \
48.112 + ,"NorthCarolina_cc" \
48.113 + ,"NorthCarolina_lp" \
48.114 + ,"ParkFalls" \
48.115 + ,"Rayonier" \
48.116 + ,"SantaRita" \
48.117 + ,"SkyOaks_Old" \
48.118 + ,"SkyOaks_PostFire" \
48.119 + ,"SkyOaks_Young" \
48.120 + ,"SylvaniaWilderness" \
48.121 + ,"Toledo" \
48.122 + ,"Tonzi" \
48.123 + ,"UCI_1850" \
48.124 + ,"UCI_1930" \
48.125 + ,"UCI_1964" \
48.126 + ,"UCI_1964wet" \
48.127 + ,"UCI_1981" \
48.128 + ,"UCI_1989" \
48.129 + ,"UCI_1998" \
48.130 + ,"UMBS" \
48.131 + ,"Vaira" \
48.132 + ,"WalkerBranch" \
48.133 + ,"WillowCreek" \
48.134 + ,"WindRiver" \
48.135 + ,"Wisconsin_ihw" \
48.136 + ,"Wisconsin_irp" \
48.137 + ,"Wisconsin_mrp" \
48.138 + ,"Wisconsin_myjp" \
48.139 + ,"Wisconsin_pb" \
48.140 + ,"Wisconsin_rpcc" \
48.141 + ,"Wisconsin_yhw" \
48.142 + ,"Wisconsin_yjp" \
48.143 + ,"Wisconsin_yrp" \
48.144 + /)
48.145 +
48.146 + year_ob = (/"2003-2006" \
48.147 + ,"2005-2006" \
48.148 + ,"2005-2006" \
48.149 + ,"1999-2006" \
48.150 + ,"2002-2006" \
48.151 + ,"2000-2005" \
48.152 + ,"2004-2005" \
48.153 + ,"1996-2006" \
48.154 + ,"2004-2006" \
48.155 + ,"1999-2004" \
48.156 + ,"2003-2005" \
48.157 + ,"2001-2005" \
48.158 + ,"2001-2005" \
48.159 + ,"2005-2006" \
48.160 + ,"2004-2006" \
48.161 + ,"2005-2006" \
48.162 + ,"2005-2006" \
48.163 + ,"2005-2006" \
48.164 + ,"2000-2006" \
48.165 + ,"2004-2006" \
48.166 + ,"2002-2006" \
48.167 + ,"1991-2004" \
48.168 + ,"2004-2004" \
48.169 + ,"1996-2004" \
48.170 + ,"1999-2004" \
48.171 + ,"2003-2006" \
48.172 + ,"2004-2006" \
48.173 + ,"2002-2002" \
48.174 + ,"2000-2006" \
48.175 + ,"2002-2005" \
48.176 + ,"2001-2005" \
48.177 + ,"2001-2005" \
48.178 + ,"2001-2005" \
48.179 + ,"2001-2005" \
48.180 + ,"2004-2005" \
48.181 + ,"2004-2005" \
48.182 + ,"2003-2005" \
48.183 + ,"1996-2000" \
48.184 + ,"2004-2006" \
48.185 + ,"1998-2004" \
48.186 + ,"1999-2005" \
48.187 + ,"1999-2003" \
48.188 + ,"2005-2006" \
48.189 + ,"2005-2006" \
48.190 + ,"1996-2003" \
48.191 + ,"1998-1998" \
48.192 + ,"2004-2006" \
48.193 + ,"1997-2006" \
48.194 + ,"2004-2006" \
48.195 + ,"1997-2006" \
48.196 + ,"2002-2006" \
48.197 + ,"2004-2005" \
48.198 + ,"2001-2006" \
48.199 + ,"2004-2005" \
48.200 + ,"2001-2005" \
48.201 + ,"2001-2005" \
48.202 + ,"2002-2004" \
48.203 + ,"2001-2005" \
48.204 + ,"2001-2005" \
48.205 + ,"2002-2005" \
48.206 + ,"1999-2003" \
48.207 + ,"2001-2006" \
48.208 + ,"1995-1999" \
48.209 + ,"1999-2005" \
48.210 + ,"1999-2004" \
48.211 + ,"2003-2003" \
48.212 + ,"2003-2003" \
48.213 + ,"2002-2005" \
48.214 + ,"2004-2004" \
48.215 + ,"2002-2002" \
48.216 + ,"2005-2005" \
48.217 + ,"2002-2002" \
48.218 + ,"2004-2005" \
48.219 + ,"2002-2002" \
48.220 + /)
48.221 +
48.222 + year_ob_i = (/2003 \
48.223 + ,2005 \
48.224 + ,2005 \
48.225 + ,1999 \
48.226 + ,2002 \
48.227 + ,2000 \
48.228 + ,2004 \
48.229 + ,1996 \
48.230 + ,2004 \
48.231 + ,1999 \
48.232 + ,2003 \
48.233 + ,2001 \
48.234 + ,2001 \
48.235 + ,2005 \
48.236 + ,2004 \
48.237 + ,2005 \
48.238 + ,2005 \
48.239 + ,2005 \
48.240 + ,2000 \
48.241 + ,2004 \
48.242 + ,2002 \
48.243 + ,1991 \
48.244 + ,2004 \
48.245 + ,1996 \
48.246 + ,1999 \
48.247 + ,2003 \
48.248 + ,2004 \
48.249 + ,2002 \
48.250 + ,2000 \
48.251 + ,2002 \
48.252 + ,2001 \
48.253 + ,2001 \
48.254 + ,2001 \
48.255 + ,2001 \
48.256 + ,2004 \
48.257 + ,2004 \
48.258 + ,2003 \
48.259 + ,1996 \
48.260 + ,2004 \
48.261 + ,1998 \
48.262 + ,1999 \
48.263 + ,1999 \
48.264 + ,2005 \
48.265 + ,2005 \
48.266 + ,1996 \
48.267 + ,1998 \
48.268 + ,2004 \
48.269 + ,1997 \
48.270 + ,2004 \
48.271 + ,1997 \
48.272 + ,2002 \
48.273 + ,2004 \
48.274 + ,2001 \
48.275 + ,2004 \
48.276 + ,2001 \
48.277 + ,2001 \
48.278 + ,2002 \
48.279 + ,2001 \
48.280 + ,2001 \
48.281 + ,2002 \
48.282 + ,1999 \
48.283 + ,2001 \
48.284 + ,1995 \
48.285 + ,1999 \
48.286 + ,1999 \
48.287 + ,2003 \
48.288 + ,2003 \
48.289 + ,2002 \
48.290 + ,2004 \
48.291 + ,2002 \
48.292 + ,2005 \
48.293 + ,2002 \
48.294 + ,2004 \
48.295 + ,2002 \
48.296 + /)
48.297 +
48.298 + year_ob_f = (/2006 \
48.299 + ,2006 \
48.300 + ,2006 \
48.301 + ,2006 \
48.302 + ,2006 \
48.303 + ,2005 \
48.304 + ,2005 \
48.305 + ,2006 \
48.306 + ,2006 \
48.307 + ,2004 \
48.308 + ,2005 \
48.309 + ,2005 \
48.310 + ,2005 \
48.311 + ,2006 \
48.312 + ,2006 \
48.313 + ,2006 \
48.314 + ,2006 \
48.315 + ,2006 \
48.316 + ,2006 \
48.317 + ,2006 \
48.318 + ,2006 \
48.319 + ,2004 \
48.320 + ,2004 \
48.321 + ,2004 \
48.322 + ,2004 \
48.323 + ,2006 \
48.324 + ,2006 \
48.325 + ,2002 \
48.326 + ,2006 \
48.327 + ,2005 \
48.328 + ,2005 \
48.329 + ,2005 \
48.330 + ,2005 \
48.331 + ,2005 \
48.332 + ,2005 \
48.333 + ,2005 \
48.334 + ,2005 \
48.335 + ,2000 \
48.336 + ,2006 \
48.337 + ,2004 \
48.338 + ,2005 \
48.339 + ,2003 \
48.340 + ,2006 \
48.341 + ,2006 \
48.342 + ,2003 \
48.343 + ,1998 \
48.344 + ,2006 \
48.345 + ,2006 \
48.346 + ,2006 \
48.347 + ,2006 \
48.348 + ,2006 \
48.349 + ,2005 \
48.350 + ,2006 \
48.351 + ,2005 \
48.352 + ,2005 \
48.353 + ,2005 \
48.354 + ,2004 \
48.355 + ,2005 \
48.356 + ,2005 \
48.357 + ,2005 \
48.358 + ,2003 \
48.359 + ,2006 \
48.360 + ,1999 \
48.361 + ,2005 \
48.362 + ,2004 \
48.363 + ,2003 \
48.364 + ,2003 \
48.365 + ,2005 \
48.366 + ,2004 \
48.367 + ,2002 \
48.368 + ,2005 \
48.369 + ,2002 \
48.370 + ,2005 \
48.371 + ,2002 \
48.372 + /)
48.373 +
48.374 + field = (/"NEE Flux" \
48.375 + ,"Net Radiation" \
48.376 + ,"Latent Heat" \
48.377 + ,"Sensible Heat" \
48.378 + ,"GPP Flux" \
48.379 + ,"Respiration" \
48.380 + /)
48.381 +
48.382 + field_unit = (/"u mol/m2/s" \
48.383 + ,"W/m2" \
48.384 + ,"W/m2" \
48.385 + ,"W/m2" \
48.386 + ,"u mol/m2/s" \
48.387 + ,"u mol/m2/s" \
48.388 + /)
48.389 +
48.390 +;========================================================================
48.391 +; find # year observed >=4 and year_ob_i <= 2001
48.392 +
48.393 + i_long_ob = ind((year_ob_f - year_ob_i) .ge. 4 .and. year_ob_i .le. 2001)
48.394 +
48.395 + station_long = station(i_long_ob)
48.396 + year_ob_long = year_ob(i_long_ob)
48.397 + year_ob_i_long = year_ob_i(i_long_ob)
48.398 + year_ob_f_long = year_ob_f(i_long_ob)
48.399 +
48.400 +;print (i_long_ob)
48.401 +;print (year_ob_i(i_long_ob))
48.402 +;print (station_long)
48.403 +;========================================================================
48.404 +
48.405 + nstation = dimsizes(station_long)
48.406 +
48.407 + data_mod = new ((/nstation, nfield, nmon/),float)
48.408 + data_ob = new ((/nstation, nfield, nmon/),float)
48.409 + lat_ob = new ((/nstation/),float)
48.410 + lon_ob = new ((/nstation/),float)
48.411 + unit_ob = new ((/nfield/),string)
48.412 +
48.413 + diro_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
48.414 + dirm_root = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
48.415 +
48.416 + do n = 0,nstation-1
48.417 +
48.418 +;-------------------------------------------------
48.419 +; get ob data
48.420 +
48.421 + diro = diro_root + station_long(n)+"/"
48.422 + filo = year_ob_i_long(n)+"-"+year_ob_f_long(n)+"_L4_m.nc"
48.423 + fo = addfile (diro+filo,"r")
48.424 +
48.425 + print (filo)
48.426 +
48.427 + lon_ob(n) = fo->lon
48.428 + lat_ob(n) = fo->lat
48.429 +
48.430 + data = fo->NEE_or_fMDS
48.431 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
48.432 + delete (data)
48.433 +
48.434 + data = fo->Rg_f
48.435 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
48.436 + delete (data)
48.437 +
48.438 + data = fo->LE_f
48.439 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
48.440 + delete (data)
48.441 +
48.442 + data = fo->H_f
48.443 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
48.444 + delete (data)
48.445 +
48.446 + data = fo->GPP_or_MDS
48.447 + data_ob(n,4,:) = dim_avg(data(month|:,year|:))
48.448 + delete (data)
48.449 +
48.450 + data = fo->Reco_or
48.451 + data_ob(n,5,:) = dim_avg(data(month|:,year|:))
48.452 + delete (data)
48.453 +
48.454 + delete (fo)
48.455 +;---------------------------------------------------
48.456 +; get model data
48.457 +
48.458 +; film = model_name+"_"+ year_ob(n)+"_MONS_climo.nc"
48.459 + film = model_name+"_"+"1990-2004"+"_MONS_climo.nc"
48.460 + fm = addfile (dirm_root+film,"r")
48.461 +
48.462 +; print (film)
48.463 +
48.464 +if (ENERGY .eq. "old") then
48.465 +
48.466 + data = fm->NEE
48.467 + data_mod0(0,:,:,:) = data(:,:,:) * factor
48.468 + delete (data)
48.469 +
48.470 +; data = fm->LATENT
48.471 + data1 = fm->FCEV
48.472 + data2 = fm->FCTR
48.473 + data3 = fm->FGEV
48.474 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
48.475 + delete (data1)
48.476 + delete (data2)
48.477 + delete (data3)
48.478 +
48.479 +; data = fm->SENSIBLE
48.480 + data = fm->FSH
48.481 + data_mod0(3,:,:,:) = data(:,:,:)
48.482 + delete (data)
48.483 +
48.484 +; data = fm->NETRAD
48.485 + data1 = fm->FSA
48.486 + data2 = fm->FIRA
48.487 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)-data_mod0(2,:,:,:)-data_mod0(3,:,:,:)
48.488 + delete (data1)
48.489 + delete (data2)
48.490 +
48.491 +else
48.492 +
48.493 + data = fm->NEE
48.494 + data_mod0(0,:,:,:) = data(:,:,:) * factor
48.495 + delete (data)
48.496 +
48.497 + data = fm->NETRAD
48.498 + data_mod0(1,:,:,:) = data(:,:,:)
48.499 + delete (data)
48.500 +
48.501 + data = fm->LATENT
48.502 + data_mod0(2,:,:,:) = data(:,:,:)
48.503 + delete (data)
48.504 +
48.505 +; data = fm->SENSIBLE
48.506 + data = fm->FSH
48.507 + data_mod0(3,:,:,:) = data(:,:,:)
48.508 + delete (data)
48.509 +end if
48.510 +
48.511 + data = fm->GPP
48.512 + data_mod0(4,:,:,:) = data(:,:,:) * factor
48.513 + delete (data)
48.514 +
48.515 + if (model .eq. "cn") then
48.516 + data = fm->ER
48.517 + else
48.518 + data1 = fm->AR
48.519 + data2 = fm->HR
48.520 + data = data1 + data2
48.521 +
48.522 + delete (data1)
48.523 + delete (data2)
48.524 + end if
48.525 +
48.526 + data_mod0(5,:,:,:) = data(:,:,:) * factor
48.527 + delete (data)
48.528 +
48.529 + delete (fm)
48.530 +
48.531 +;************************************************************
48.532 +; interpolate model data into observed station
48.533 +; note: model is 0-360E, 90S-90N
48.534 +;************************************************************
48.535 +
48.536 +; to be able to handle observation at (-89.98,-24.80)
48.537 + ym(0) = -90.
48.538 +
48.539 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob(n),lat_ob(n),0)
48.540 +
48.541 +; print (yy)
48.542 +
48.543 + data_mod(n,:,:) = yy(:,:,0)
48.544 +
48.545 + delete (yy)
48.546 +
48.547 + end do
48.548 +
48.549 +;************************************************************
48.550 +; compute correlation coef and M score
48.551 +;************************************************************
48.552 +
48.553 + score_max = 5.
48.554 +
48.555 + ccr = new ((/nstation, nfield/),float)
48.556 + M_score = new ((/nstation, nfield/),float)
48.557 +
48.558 + do n=0,nstation-1
48.559 + do m=0,nfield-1
48.560 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
48.561 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
48.562 + M_score(n,m) = (1. -(bias/nmon)) * score_max
48.563 + end do
48.564 + end do
48.565 +
48.566 + M_co2 = avg(M_score(:,0))
48.567 + M_rad = avg(M_score(:,1))
48.568 + M_lh = avg(M_score(:,2))
48.569 + M_sh = avg(M_score(:,3))
48.570 + M_gpp = avg(M_score(:,4))
48.571 + M_er = avg(M_score(:,5))
48.572 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
48.573 +
48.574 + M_energy_co2 = sprintf("%.2f", M_co2)
48.575 + M_energy_rad = sprintf("%.2f", M_rad)
48.576 + M_energy_lh = sprintf("%.2f", M_lh )
48.577 + M_energy_sh = sprintf("%.2f", M_sh )
48.578 + M_energy_gpp = sprintf("%.2f", M_gpp)
48.579 + M_energy_er = sprintf("%.2f", M_er )
48.580 + M_energy_all = sprintf("%.2f", M_all)
48.581 +
48.582 +;*******************************************************************
48.583 +; for station line plot
48.584 +;*******************************************************************
48.585 +
48.586 +; for x-axis in xyplot
48.587 + mon = ispan(1,12,1)
48.588 + mon@long_name = "month"
48.589 +
48.590 + res = True ; plot mods desired
48.591 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
48.592 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
48.593 +;-------------------------------------------------------------------------
48.594 +; Add a boxed legend using the more simple method
48.595 +
48.596 + res@pmLegendDisplayMode = "Always"
48.597 +; res@pmLegendWidthF = 0.1
48.598 + res@pmLegendWidthF = 0.08
48.599 + res@pmLegendHeightF = 0.06
48.600 +; res@pmLegendOrthogonalPosF = -1.17
48.601 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
48.602 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
48.603 +
48.604 +; res@pmLegendParallelPosF = 0.18
48.605 + res@pmLegendParallelPosF = 0.23 ;(rightward)
48.606 +
48.607 +; res@lgPerimOn = False
48.608 + res@lgLabelFontHeightF = 0.015
48.609 + res@xyExplicitLegendLabels = (/"observed",model_name/)
48.610 +;-------------------------------------------------------------------
48.611 +; for panel plot
48.612 + res@gsnFrame = False ; Do not draw plot
48.613 + res@gsnDraw = False ; Do not advance frame
48.614 +
48.615 + pres = True ; panel plot mods desired
48.616 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
48.617 + ; indiv. plots in panel
48.618 + pres@gsnMaximize = True ; fill the page
48.619 +;-------------------------------------------------------------------
48.620 +
48.621 + plot_data = new((/2,12/),float)
48.622 + plot_data!0 = "case"
48.623 + plot_data!1 = "month"
48.624 +
48.625 + do n = 0,nstation-1
48.626 +
48.627 +;----------------------------
48.628 +; for observed
48.629 +
48.630 + plot_name = station_long(n)+"_ob"
48.631 + title = station_long(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
48.632 + res@tiMainString = title
48.633 +
48.634 + wks = gsn_open_wks (plot_type,plot_name)
48.635 + plot=new(nfield,graphic) ; create graphic array
48.636 +
48.637 + do i = 0,nfield-1
48.638 + plot_data(0,:) = (/data_ob (n,i,:)/)
48.639 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
48.640 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
48.641 + end do
48.642 +
48.643 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
48.644 +
48.645 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
48.646 + "rm "+plot_name+"."+plot_type)
48.647 +
48.648 + clear (wks)
48.649 + delete (plot)
48.650 +;----------------------------
48.651 +; for model_vs_ob
48.652 +
48.653 + plot_name = station_long(n)+"_model_vs_ob"
48.654 + title = station_long(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
48.655 + res@tiMainString = title
48.656 +
48.657 + wks = gsn_open_wks (plot_type,plot_name)
48.658 + plot=new(nfield,graphic) ; create graphic array
48.659 +
48.660 + do i = 0,nfield-1
48.661 + plot_data(0,:) = (/data_ob (n,i,:)/)
48.662 + plot_data(1,:) = (/data_mod(n,i,:)/)
48.663 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
48.664 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
48.665 + end do
48.666 +
48.667 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
48.668 +
48.669 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
48.670 + "rm "+plot_name+"."+plot_type)
48.671 +
48.672 + clear (wks)
48.673 + delete (plot)
48.674 + end do
48.675 +
48.676 +;###################################################################
48.677 +; for the following tables,
48.678 +; sort by latitude in decending order (N->S)
48.679 +
48.680 + isort = dim_pqsort(lat_ob,-1)
48.681 +
48.682 + station_sort = station_long(isort)
48.683 + year_ob_sort = year_ob_long(isort)
48.684 + lat_ob_sort = lat_ob(isort)
48.685 + lon_ob_sort = lon_ob(isort)
48.686 + M_score_sort = M_score(isort,:)
48.687 +
48.688 + print(isort)
48.689 + print(lat_ob_sort)
48.690 +
48.691 +;*******************************************************************
48.692 +; html table of site: observed
48.693 +;*******************************************************************
48.694 + output_html = "line_ob.html"
48.695 +
48.696 + header = (/"<HTML>" \
48.697 + ,"<HEAD>" \
48.698 + ,"<TITLE>CLAMP metrics</TITLE>" \
48.699 + ,"</HEAD>" \
48.700 + ,"<H1>Energy at Site: Observation</H1>" \
48.701 + /)
48.702 + footer = "</HTML>"
48.703 +
48.704 + table_header = (/ \
48.705 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
48.706 + ,"<tr>" \
48.707 + ," <th bgcolor=DDDDDD >Site Name</th>" \
48.708 + ," <th bgcolor=DDDDDD >Latitude</th>" \
48.709 + ," <th bgcolor=DDDDDD >Longitude</th>" \
48.710 + ," <th bgcolor=DDDDDD >Observed</th>" \
48.711 + ,"</tr>" \
48.712 + /)
48.713 + table_footer = "</table>"
48.714 + row_header = "<tr>"
48.715 + row_footer = "</tr>"
48.716 +
48.717 + lines = new(50000,string)
48.718 + nline = 0
48.719 +
48.720 + set_line(lines,nline,header)
48.721 + set_line(lines,nline,table_header)
48.722 +;-----------------------------------------------
48.723 +; row of table
48.724 +
48.725 + do n = 0,nstation-1
48.726 +
48.727 + set_line(lines,nline,row_header)
48.728 +
48.729 + txt0 = station_sort(n)
48.730 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
48.731 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
48.732 + txt3 = year_ob_sort(n)
48.733 +
48.734 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
48.735 + set_line(lines,nline,"<th>"+txt1+"</th>")
48.736 + set_line(lines,nline,"<th>"+txt2+"</th>")
48.737 + set_line(lines,nline,"<th>"+txt3+"</th>")
48.738 +
48.739 + set_line(lines,nline,row_footer)
48.740 + end do
48.741 +;-----------------------------------------------
48.742 + set_line(lines,nline,table_footer)
48.743 + set_line(lines,nline,footer)
48.744 +
48.745 +; Now write to an HTML file.
48.746 + idx = ind(.not.ismissing(lines))
48.747 + if(.not.any(ismissing(idx))) then
48.748 + asciiwrite(output_html,lines(idx))
48.749 + else
48.750 + print ("error?")
48.751 + end if
48.752 + delete (idx)
48.753 +
48.754 +;*******************************************************************
48.755 +; score and line table : model vs observed
48.756 +;*******************************************************************
48.757 + output_html = "score+line_vs_ob.html"
48.758 +
48.759 + header = (/"<HTML>" \
48.760 + ,"<HEAD>" \
48.761 + ,"<TITLE>CLAMP metrics</TITLE>" \
48.762 + ,"</HEAD>" \
48.763 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
48.764 + /)
48.765 + footer = "</HTML>"
48.766 +
48.767 + delete (table_header)
48.768 + table_header = (/ \
48.769 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
48.770 + ,"<tr>" \
48.771 + ," <th bgcolor=DDDDDD >Site Name</th>" \
48.772 + ," <th bgcolor=DDDDDD >Latitude</th>" \
48.773 + ," <th bgcolor=DDDDDD >Longitude</th>" \
48.774 + ," <th bgcolor=DDDDDD >Observed</th>" \
48.775 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
48.776 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
48.777 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
48.778 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
48.779 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
48.780 + ," <th bgcolor=DDDDDD >Respiration</th>" \
48.781 + ," <th bgcolor=DDDDDD >Average</th>" \
48.782 + ,"</tr>" \
48.783 + /)
48.784 + table_footer = "</table>"
48.785 + row_header = "<tr>"
48.786 + row_footer = "</tr>"
48.787 +
48.788 + lines = new(50000,string)
48.789 + nline = 0
48.790 +
48.791 + set_line(lines,nline,header)
48.792 + set_line(lines,nline,table_header)
48.793 +;-----------------------------------------------
48.794 +; row of table
48.795 +
48.796 + do n = 0,nstation-1
48.797 +
48.798 + set_line(lines,nline,row_header)
48.799 +
48.800 + txt0 = station_sort(n)
48.801 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
48.802 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
48.803 + txt3 = year_ob_sort(n)
48.804 + txt4 = sprintf("%5.2f", M_score_sort(n,0))
48.805 + txt5 = sprintf("%5.2f", M_score_sort(n,1))
48.806 + txt6 = sprintf("%5.2f", M_score_sort(n,2))
48.807 + txt7 = sprintf("%5.2f", M_score_sort(n,3))
48.808 + txt8 = sprintf("%5.2f", M_score_sort(n,4))
48.809 + txt9 = sprintf("%5.2f", M_score_sort(n,5))
48.810 + txt10 = sprintf("%5.2f", avg(M_score_sort(n,:)))
48.811 +
48.812 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
48.813 + set_line(lines,nline,"<th>"+txt1+"</th>")
48.814 + set_line(lines,nline,"<th>"+txt2+"</th>")
48.815 + set_line(lines,nline,"<th>"+txt3+"</th>")
48.816 + set_line(lines,nline,"<th>"+txt4+"</th>")
48.817 + set_line(lines,nline,"<th>"+txt5+"</th>")
48.818 + set_line(lines,nline,"<th>"+txt6+"</th>")
48.819 + set_line(lines,nline,"<th>"+txt7+"</th>")
48.820 + set_line(lines,nline,"<th>"+txt8+"</th>")
48.821 + set_line(lines,nline,"<th>"+txt9+"</th>")
48.822 + set_line(lines,nline,"<th>"+txt10+"</th>")
48.823 +
48.824 + set_line(lines,nline,row_footer)
48.825 + end do
48.826 +
48.827 +; last row, summary
48.828 + set_line(lines,nline,row_header)
48.829 +
48.830 + txt0 = "All_"+sprintf("%.0f", nstation)
48.831 + txt1 = "-"
48.832 + txt2 = "-"
48.833 + txt3 = "-"
48.834 + txt4 = M_energy_co2
48.835 + txt5 = M_energy_rad
48.836 + txt6 = M_energy_lh
48.837 + txt7 = M_energy_sh
48.838 + txt8 = M_energy_gpp
48.839 + txt9 = M_energy_er
48.840 + txt10 = M_energy_all
48.841 +
48.842 + set_line(lines,nline,"<th>"+txt0+"</th>")
48.843 + set_line(lines,nline,"<th>"+txt1+"</th>")
48.844 + set_line(lines,nline,"<th>"+txt2+"</th>")
48.845 + set_line(lines,nline,"<th>"+txt3+"</th>")
48.846 + set_line(lines,nline,"<th>"+txt4+"</th>")
48.847 + set_line(lines,nline,"<th>"+txt5+"</th>")
48.848 + set_line(lines,nline,"<th>"+txt6+"</th>")
48.849 + set_line(lines,nline,"<th>"+txt7+"</th>")
48.850 + set_line(lines,nline,"<th>"+txt8+"</th>")
48.851 + set_line(lines,nline,"<th>"+txt9+"</th>")
48.852 + set_line(lines,nline,"<th>"+txt10+"</th>")
48.853 +
48.854 + set_line(lines,nline,row_footer)
48.855 +;-----------------------------------------------
48.856 + set_line(lines,nline,table_footer)
48.857 + set_line(lines,nline,footer)
48.858 +
48.859 +; Now write to an HTML file.
48.860 + idx = ind(.not.ismissing(lines))
48.861 + if(.not.any(ismissing(idx))) then
48.862 + asciiwrite(output_html,lines(idx))
48.863 + else
48.864 + print ("error?")
48.865 + end if
48.866 + delete (idx)
48.867 +
48.868 +;***************************************************************************
48.869 +; output plots
48.870 +;***************************************************************************
48.871 + output_dir = model_name+"/ameriflux"
48.872 +
48.873 + system("mv *.png *.html " + output_dir)
48.874 +;***************************************************************************
48.875 +end
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
49.2 +++ b/ameriflux/17.plot.ncl Mon Jan 26 22:08:20 2009 -0500
49.3 @@ -0,0 +1,879 @@
49.4 +;************************************************************
49.5 +; add time series plot
49.6 +; sort by latitude in decending order (N->S)
49.7 +; find year_ob >= 4
49.8 +; add year_ob_i and year_ob_f
49.9 +; change long_name
49.10 +;************************************************************
49.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
49.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
49.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
49.14 +;************************************************************
49.15 +procedure set_line(lines:string,nline:integer,newlines:string)
49.16 +begin
49.17 +; add line to ascci/html file
49.18 +
49.19 + nnewlines = dimsizes(newlines)
49.20 + if(nline+nnewlines-1.ge.dimsizes(lines))
49.21 + print("set_line: bad index, not setting anything.")
49.22 + return
49.23 + end if
49.24 + lines(nline:nline+nnewlines-1) = newlines
49.25 +; print ("lines = " + lines(nline:nline+nnewlines-1))
49.26 + nline = nline + nnewlines
49.27 + return
49.28 +end
49.29 +;*************************************************************
49.30 +begin
49.31 +
49.32 + plot_type = "ps"
49.33 + plot_type_new = "png"
49.34 +
49.35 +;************************************************
49.36 +; read model data
49.37 +;************************************************
49.38 + model = "cn"
49.39 +; model = "casa"
49.40 +
49.41 + model_name = "i01.10" + model
49.42 +
49.43 +; change to unit of observed (u mol/m2/s)
49.44 +; Model_units [=] gC/m2/s
49.45 +; 12. = molecular weight of C
49.46 +; u mol = 1e-6 mol
49.47 + factor = 1e6 /12.
49.48 +
49.49 + ENERGY ="new"
49.50 +
49.51 +;************************************************
49.52 +; read data: observed
49.53 +;************************************************
49.54 +
49.55 + station = (/"ARM_Oklahoma" \
49.56 + ,"ARM_Oklahoma_burn" \
49.57 + ,"ARM_Oklahoma_control" \
49.58 + ,"Atqasuk" \
49.59 + ,"Audubon" \
49.60 + ,"AustinCary" \
49.61 + ,"Bartlett" \
49.62 + ,"Bondville" \
49.63 + ,"Brookings" \
49.64 + ,"Donaldson" \
49.65 + ,"Duke_Forest_Hardwoods" \
49.66 + ,"Duke_Forest_Open_Field" \
49.67 + ,"Duke_Forest_Pine" \
49.68 + ,"Fermi_Ag" \
49.69 + ,"Fermi_Prairie" \
49.70 + ,"Flagstaff_Managed" \
49.71 + ,"Flagstaff_Unmanaged" \
49.72 + ,"Flagstaff_Wildfire" \
49.73 + ,"FortPeck" \
49.74 + ,"FreemanRanch_mesquite" \
49.75 + ,"Goodwin_Creek" \
49.76 + ,"HarvardForest" \
49.77 + ,"HarvardForestHemlock" \
49.78 + ,"HowlandForestMain" \
49.79 + ,"HowlandForestWest" \
49.80 + ,"Ivotuk" \
49.81 + ,"KendallGrasslands" \
49.82 + ,"KennedySpaceCenterPine" \
49.83 + ,"KennedySpaceCenterScrub" \
49.84 + ,"LittleProspect" \
49.85 + ,"LostCreek" \
49.86 + ,"Mead-irrigated" \
49.87 + ,"Mead-irrigated-rotation" \
49.88 + ,"Mead-rainfed" \
49.89 + ,"Metolius_2nd_YoungPonderosaPine" \
49.90 + ,"MetoliusEyerly" \
49.91 + ,"MetoliusIntermediatePine" \
49.92 + ,"MetoliusOldPonderosaPine" \
49.93 + ,"MissouriOzark" \
49.94 + ,"Mize" \
49.95 + ,"MorganMonroe" \
49.96 + ,"NiwotRidge" \
49.97 + ,"NorthCarolina_cc" \
49.98 + ,"NorthCarolina_lp" \
49.99 + ,"ParkFalls" \
49.100 + ,"Rayonier" \
49.101 + ,"SantaRita" \
49.102 + ,"SkyOaks_Old" \
49.103 + ,"SkyOaks_PostFire" \
49.104 + ,"SkyOaks_Young" \
49.105 + ,"SylvaniaWilderness" \
49.106 + ,"Toledo" \
49.107 + ,"Tonzi" \
49.108 + ,"UCI_1850" \
49.109 + ,"UCI_1930" \
49.110 + ,"UCI_1964" \
49.111 + ,"UCI_1964wet" \
49.112 + ,"UCI_1981" \
49.113 + ,"UCI_1989" \
49.114 + ,"UCI_1998" \
49.115 + ,"UMBS" \
49.116 + ,"Vaira" \
49.117 + ,"WalkerBranch" \
49.118 + ,"WillowCreek" \
49.119 + ,"WindRiver" \
49.120 + ,"Wisconsin_ihw" \
49.121 + ,"Wisconsin_irp" \
49.122 + ,"Wisconsin_mrp" \
49.123 + ,"Wisconsin_myjp" \
49.124 + ,"Wisconsin_pb" \
49.125 + ,"Wisconsin_rpcc" \
49.126 + ,"Wisconsin_yhw" \
49.127 + ,"Wisconsin_yjp" \
49.128 + ,"Wisconsin_yrp" \
49.129 + /)
49.130 +
49.131 + year_ob = (/"2003-2006" \
49.132 + ,"2005-2006" \
49.133 + ,"2005-2006" \
49.134 + ,"1999-2006" \
49.135 + ,"2002-2006" \
49.136 + ,"2000-2005" \
49.137 + ,"2004-2005" \
49.138 + ,"1996-2006" \
49.139 + ,"2004-2006" \
49.140 + ,"1999-2004" \
49.141 + ,"2003-2005" \
49.142 + ,"2001-2005" \
49.143 + ,"2001-2005" \
49.144 + ,"2005-2006" \
49.145 + ,"2004-2006" \
49.146 + ,"2005-2006" \
49.147 + ,"2005-2006" \
49.148 + ,"2005-2006" \
49.149 + ,"2000-2006" \
49.150 + ,"2004-2006" \
49.151 + ,"2002-2006" \
49.152 + ,"1991-2004" \
49.153 + ,"2004-2004" \
49.154 + ,"1996-2004" \
49.155 + ,"1999-2004" \
49.156 + ,"2003-2006" \
49.157 + ,"2004-2006" \
49.158 + ,"2002-2002" \
49.159 + ,"2000-2006" \
49.160 + ,"2002-2005" \
49.161 + ,"2001-2005" \
49.162 + ,"2001-2005" \
49.163 + ,"2001-2005" \
49.164 + ,"2001-2005" \
49.165 + ,"2004-2005" \
49.166 + ,"2004-2005" \
49.167 + ,"2003-2005" \
49.168 + ,"1996-2000" \
49.169 + ,"2004-2006" \
49.170 + ,"1998-2004" \
49.171 + ,"1999-2005" \
49.172 + ,"1999-2003" \
49.173 + ,"2005-2006" \
49.174 + ,"2005-2006" \
49.175 + ,"1996-2003" \
49.176 + ,"1998-1998" \
49.177 + ,"2004-2006" \
49.178 + ,"1997-2006" \
49.179 + ,"2004-2006" \
49.180 + ,"1997-2006" \
49.181 + ,"2002-2006" \
49.182 + ,"2004-2005" \
49.183 + ,"2001-2006" \
49.184 + ,"2004-2005" \
49.185 + ,"2001-2005" \
49.186 + ,"2001-2005" \
49.187 + ,"2002-2004" \
49.188 + ,"2001-2005" \
49.189 + ,"2001-2005" \
49.190 + ,"2002-2005" \
49.191 + ,"1999-2003" \
49.192 + ,"2001-2006" \
49.193 + ,"1995-1999" \
49.194 + ,"1999-2005" \
49.195 + ,"1999-2004" \
49.196 + ,"2003-2003" \
49.197 + ,"2003-2003" \
49.198 + ,"2002-2005" \
49.199 + ,"2004-2004" \
49.200 + ,"2002-2002" \
49.201 + ,"2005-2005" \
49.202 + ,"2002-2002" \
49.203 + ,"2004-2005" \
49.204 + ,"2002-2002" \
49.205 + /)
49.206 +
49.207 + year_ob_i = (/2003 \
49.208 + ,2005 \
49.209 + ,2005 \
49.210 + ,1999 \
49.211 + ,2002 \
49.212 + ,2000 \
49.213 + ,2004 \
49.214 + ,1996 \
49.215 + ,2004 \
49.216 + ,1999 \
49.217 + ,2003 \
49.218 + ,2001 \
49.219 + ,2001 \
49.220 + ,2005 \
49.221 + ,2004 \
49.222 + ,2005 \
49.223 + ,2005 \
49.224 + ,2005 \
49.225 + ,2000 \
49.226 + ,2004 \
49.227 + ,2002 \
49.228 + ,1991 \
49.229 + ,2004 \
49.230 + ,1996 \
49.231 + ,1999 \
49.232 + ,2003 \
49.233 + ,2004 \
49.234 + ,2002 \
49.235 + ,2000 \
49.236 + ,2002 \
49.237 + ,2001 \
49.238 + ,2001 \
49.239 + ,2001 \
49.240 + ,2001 \
49.241 + ,2004 \
49.242 + ,2004 \
49.243 + ,2003 \
49.244 + ,1996 \
49.245 + ,2004 \
49.246 + ,1998 \
49.247 + ,1999 \
49.248 + ,1999 \
49.249 + ,2005 \
49.250 + ,2005 \
49.251 + ,1996 \
49.252 + ,1998 \
49.253 + ,2004 \
49.254 + ,1997 \
49.255 + ,2004 \
49.256 + ,1997 \
49.257 + ,2002 \
49.258 + ,2004 \
49.259 + ,2001 \
49.260 + ,2004 \
49.261 + ,2001 \
49.262 + ,2001 \
49.263 + ,2002 \
49.264 + ,2001 \
49.265 + ,2001 \
49.266 + ,2002 \
49.267 + ,1999 \
49.268 + ,2001 \
49.269 + ,1995 \
49.270 + ,1999 \
49.271 + ,1999 \
49.272 + ,2003 \
49.273 + ,2003 \
49.274 + ,2002 \
49.275 + ,2004 \
49.276 + ,2002 \
49.277 + ,2005 \
49.278 + ,2002 \
49.279 + ,2004 \
49.280 + ,2002 \
49.281 + /)
49.282 +
49.283 + year_ob_f = (/2006 \
49.284 + ,2006 \
49.285 + ,2006 \
49.286 + ,2006 \
49.287 + ,2006 \
49.288 + ,2005 \
49.289 + ,2005 \
49.290 + ,2006 \
49.291 + ,2006 \
49.292 + ,2004 \
49.293 + ,2005 \
49.294 + ,2005 \
49.295 + ,2005 \
49.296 + ,2006 \
49.297 + ,2006 \
49.298 + ,2006 \
49.299 + ,2006 \
49.300 + ,2006 \
49.301 + ,2006 \
49.302 + ,2006 \
49.303 + ,2006 \
49.304 + ,2004 \
49.305 + ,2004 \
49.306 + ,2004 \
49.307 + ,2004 \
49.308 + ,2006 \
49.309 + ,2006 \
49.310 + ,2002 \
49.311 + ,2006 \
49.312 + ,2005 \
49.313 + ,2005 \
49.314 + ,2005 \
49.315 + ,2005 \
49.316 + ,2005 \
49.317 + ,2005 \
49.318 + ,2005 \
49.319 + ,2005 \
49.320 + ,2000 \
49.321 + ,2006 \
49.322 + ,2004 \
49.323 + ,2005 \
49.324 + ,2003 \
49.325 + ,2006 \
49.326 + ,2006 \
49.327 + ,2003 \
49.328 + ,1998 \
49.329 + ,2006 \
49.330 + ,2006 \
49.331 + ,2006 \
49.332 + ,2006 \
49.333 + ,2006 \
49.334 + ,2005 \
49.335 + ,2006 \
49.336 + ,2005 \
49.337 + ,2005 \
49.338 + ,2005 \
49.339 + ,2004 \
49.340 + ,2005 \
49.341 + ,2005 \
49.342 + ,2005 \
49.343 + ,2003 \
49.344 + ,2006 \
49.345 + ,1999 \
49.346 + ,2005 \
49.347 + ,2004 \
49.348 + ,2003 \
49.349 + ,2003 \
49.350 + ,2005 \
49.351 + ,2004 \
49.352 + ,2002 \
49.353 + ,2005 \
49.354 + ,2002 \
49.355 + ,2005 \
49.356 + ,2002 \
49.357 + /)
49.358 +
49.359 + field = (/"NEE Flux" \
49.360 + ,"Net Radiation" \
49.361 + ,"Latent Heat" \
49.362 + ,"Sensible Heat" \
49.363 + ,"GPP Flux" \
49.364 + ,"Respiration" \
49.365 + /)
49.366 +
49.367 + field_unit = (/"u mol/m2/s" \
49.368 + ,"W/m2" \
49.369 + ,"W/m2" \
49.370 + ,"W/m2" \
49.371 + ,"u mol/m2/s" \
49.372 + ,"u mol/m2/s" \
49.373 + /)
49.374 +
49.375 + nfield = dimsizes(field)
49.376 +
49.377 +;========================================================================
49.378 +; find (# of year observed) >=4 and year_ob_i <= 2001
49.379 +
49.380 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
49.381 +
49.382 + nstation = dimsizes(station)
49.383 +
49.384 + year_station = new ((/nstation/),integer)
49.385 +
49.386 + do n = 0,nstation-1
49.387 +
49.388 + diro = dir_root + station(n)+"/"
49.389 + filo = year_ob_i(n)+"-"+year_ob_f(n)+"_L4_m.nc"
49.390 + fo = addfile (diro+filo,"r")
49.391 +
49.392 + year = fo->year
49.393 + year_station(n) = dimsizes(year)
49.394 + delete (year)
49.395 +
49.396 + end do
49.397 +
49.398 + delete (fo)
49.399 +
49.400 + i_long_ob = ind(year_station .ge. 4 .and. year_ob_i .le. 2001)
49.401 +
49.402 + station_long = station(i_long_ob)
49.403 + year_ob_long = year_ob(i_long_ob)
49.404 + year_ob_i_long = year_ob_i(i_long_ob)
49.405 + year_ob_f_long = year_ob_f(i_long_ob)
49.406 + year_station_long = year_station(i_long_ob)
49.407 +
49.408 + nstation = dimsizes(station_long)
49.409 +; print (nstation)
49.410 +; print (i_long_ob)
49.411 +; print (year_ob_i(i_long_ob))
49.412 +; print (station_long)
49.413 +
49.414 +;========================================================================
49.415 +; get observed lat and lon
49.416 +
49.417 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
49.418 +
49.419 + lat_ob = new ((/nstation/),float)
49.420 + lon_ob = new ((/nstation/),float)
49.421 +
49.422 + do n = 0,nstation-1
49.423 +
49.424 + diro = dir_root + station_long(n)+"/"
49.425 + filo = year_ob_i_long(n)+"-"+year_ob_f_long(n)+"_L4_m.nc"
49.426 + fo = addfile (diro+filo,"r")
49.427 +
49.428 +; print (diro)
49.429 +; print (filo)
49.430 +
49.431 + lon_ob(n) = fo->lon
49.432 + lat_ob(n) = fo->lat
49.433 +
49.434 + delete (fo)
49.435 +
49.436 + end do
49.437 +
49.438 +;=========================================================
49.439 +; get model data at observed lat-lon
49.440 +
49.441 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
49.442 + film = model_name+"_ameriflux_1990-2004_monthly.nc"
49.443 + fm = addfile (dirm+film,"r")
49.444 +
49.445 + xm = fm->lon
49.446 + ym = fm->lat
49.447 + date = fm->date
49.448 +
49.449 + date_dim = dimsizes(date)
49.450 + nyear = date_dim(0)
49.451 +
49.452 + nmonth =12
49.453 +
49.454 + data_mod = new ((/nfield,nyear,nmonth,nstation/),float)
49.455 +
49.456 +;************************************************************
49.457 +; interpolate model data into observed station
49.458 +; note: model is 0-360E, 90S-90N
49.459 +;************************************************************
49.460 +
49.461 +; to be able to handle observation at (-89.98,-24.80)
49.462 + ym(0) = -90.
49.463 +
49.464 +if (ENERGY .eq. "old") then
49.465 +
49.466 + data = fm->NEE
49.467 + data_mod(0,:,:,:) = data(:,:,:) * factor
49.468 +
49.469 +; data = fm->LATENT
49.470 + data1 = fm->FCEV
49.471 + data2 = fm->FCTR
49.472 + data3 = fm->FGEV
49.473 + data_mod(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
49.474 + delete (data1)
49.475 + delete (data2)
49.476 + delete (data3)
49.477 +
49.478 +; data = fm->SENSIBLE
49.479 + data = fm->FSH
49.480 + data_mod(3,:,:,:) = data(:,:,:)
49.481 +
49.482 +; data = fm->NETRAD
49.483 + data1 = fm->FSA
49.484 + data2 = fm->FIRA
49.485 + data_mod(1,:,:,:) = data1(:,:,:)-data2(:,:,:)
49.486 + delete (data1)
49.487 + delete (data2)
49.488 +
49.489 +else
49.490 +
49.491 + data = fm->NEE
49.492 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
49.493 + data_mod(0,:,:,:) = yy(:,:,:) * factor
49.494 +
49.495 + data = fm->NETRAD
49.496 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
49.497 + data_mod(1,:,:,:) = yy(:,:,:)
49.498 +
49.499 + data = fm->LATENT
49.500 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
49.501 + data_mod(2,:,:,:) = yy(:,:,:)
49.502 +
49.503 +; data = fm->SENSIBLE
49.504 + data = fm->FSH
49.505 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
49.506 + data_mod(3,:,:,:) = yy(:,:,:)
49.507 +
49.508 +end if
49.509 +
49.510 + data = fm->GPP
49.511 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
49.512 + data_mod(4,:,:,:) = yy(:,:,:) * factor
49.513 +
49.514 + if (model .eq. "cn") then
49.515 + data = fm->ER
49.516 + else
49.517 + data1 = fm->AR
49.518 + data2 = fm->HR
49.519 + data = data1 + data2
49.520 +
49.521 + delete (data1)
49.522 + delete (data2)
49.523 + end if
49.524 +
49.525 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
49.526 + data_mod(5,:,:,:) = yy(:,:,:) * factor
49.527 +
49.528 + delete (fm)
49.529 + delete (data)
49.530 +
49.531 +;*******************************************************************
49.532 +; for station line plot
49.533 +;*******************************************************************
49.534 +
49.535 +; for x-axis in xyplot
49.536 + mon = ispan(1,12,1)
49.537 + mon@long_name = "month"
49.538 +
49.539 + res = True ; plot mods desired
49.540 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
49.541 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
49.542 +
49.543 + res@tmXBFormat = "f" ; not to add trailing zeros
49.544 +
49.545 +;-------------------------------------------------------------------------
49.546 +; Add a boxed legend using the more simple method
49.547 +
49.548 + res@pmLegendDisplayMode = "Always"
49.549 +; res@pmLegendWidthF = 0.1
49.550 + res@pmLegendWidthF = 0.08
49.551 + res@pmLegendHeightF = 0.06
49.552 +; res@pmLegendOrthogonalPosF = -1.17
49.553 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
49.554 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
49.555 +
49.556 +; res@pmLegendParallelPosF = 0.18
49.557 + res@pmLegendParallelPosF = 0.23 ;(rightward)
49.558 +
49.559 +; res@lgPerimOn = False
49.560 + res@lgLabelFontHeightF = 0.015
49.561 + res@xyExplicitLegendLabels = (/"observed",model_name/)
49.562 +;-------------------------------------------------------------------
49.563 +; for panel plot
49.564 + res@gsnFrame = False ; Do not draw plot
49.565 + res@gsnDraw = False ; Do not advance frame
49.566 +
49.567 + pres = True ; panel plot mods desired
49.568 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
49.569 + ; indiv. plots in panel
49.570 + pres@gsnMaximize = True ; fill the page
49.571 +;-------------------------------------------------------------------
49.572 +
49.573 +;==============================================================
49.574 +; get ob data at each site
49.575 +
49.576 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
49.577 +
49.578 + do n = 0,nstation-1
49.579 +; do n = 2,6
49.580 +
49.581 + year_setback = 0
49.582 +
49.583 + nyear = year_station_long(n)
49.584 +
49.585 + if (year_ob_f_long(n).eq. 2006) then
49.586 + year_setback = 2006 -2004
49.587 + end if
49.588 + if (year_ob_f_long(n).eq. 2005) then
49.589 + year_setback = 2005 -2004
49.590 + end if
49.591 +
49.592 + ntime = (nyear - year_setback) * nmonth
49.593 + print (nyear)
49.594 +
49.595 + data_ob = new ((/nfield, nyear, nmonth/),float)
49.596 +
49.597 + diro = dir_root + station_long(n)+"/"
49.598 + filo = year_ob_i_long(n)+"-"+year_ob_f_long(n)+"_L4_m.nc"
49.599 + fo = addfile (diro+filo,"r")
49.600 +
49.601 + print (diro)
49.602 + print (filo)
49.603 +
49.604 + lon_ob(n) = fo->lon
49.605 + lat_ob(n) = fo->lat
49.606 +
49.607 + data = fo->NEE_or_fMDS
49.608 + data_ob(0,:,:) = data(:,:)
49.609 + delete (data)
49.610 +
49.611 + data = fo->Rg_f
49.612 + data_ob(1,:,:) = data(:,:)
49.613 + delete (data)
49.614 +
49.615 + data = fo->LE_f
49.616 + data_ob(2,:,:) = data(:,:)
49.617 + delete (data)
49.618 +
49.619 + data = fo->H_f
49.620 + data_ob(3,:,:) = data(:,:)
49.621 + delete (data)
49.622 +
49.623 + data = fo->GPP_or_MDS
49.624 + data_ob(4,:,:) = data(:,:)
49.625 + delete (data)
49.626 +
49.627 + data = fo->Reco_or
49.628 + data_ob(5,:,:) = data(:,:)
49.629 + delete (data)
49.630 +
49.631 + delete (fo)
49.632 +
49.633 + timeI = new((/ntime/),integer)
49.634 + timeF = new((/ntime/),float)
49.635 + timeI = ispan(1,ntime,1)
49.636 + timeF = year_ob_i_long(n) + (timeI-1)/12.
49.637 + timeF@long_name = "year"
49.638 +
49.639 + plot_data = new((/2,ntime/),float)
49.640 +
49.641 +;----------------------------
49.642 +; for model_vs_ob
49.643 +
49.644 + plot_name = station_long(n)+"_model_vs_ob"
49.645 + title = station_long(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
49.646 + res@tiMainString = title
49.647 +
49.648 + wks = gsn_open_wks (plot_type,plot_name)
49.649 + plot=new(nfield,graphic) ; create graphic array
49.650 +
49.651 + i_year_mod_i = year_ob_i_long(n) - 1990
49.652 + i_year_mod_f = i_year_mod_i + nyear - 1 - year_setback
49.653 +
49.654 + i_year_ob_f = nyear - year_setback - 1
49.655 +
49.656 + print (nyear)
49.657 + print (i_year_ob_f)
49.658 + print (i_year_mod_i)
49.659 + print (i_year_mod_f)
49.660 +
49.661 + do i = 0,nfield-1
49.662 + plot_data(0,:) = ndtooned(data_ob (i,0:i_year_ob_f,:))
49.663 + plot_data(1,:) = ndtooned(data_mod(i,i_year_mod_i:i_year_mod_f,:,n))
49.664 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
49.665 + plot(i)=gsn_csm_xy(wks,timeF,plot_data,res) ; create plot
49.666 + end do
49.667 +
49.668 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
49.669 +
49.670 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
49.671 + "rm "+plot_name+"."+plot_type)
49.672 +
49.673 + clear (wks)
49.674 + delete (plot)
49.675 +
49.676 + delete (data_ob)
49.677 + delete (timeI)
49.678 + delete (timeF)
49.679 + delete (plot_data)
49.680 +
49.681 + end do
49.682 +exit
49.683 +;###################################################################
49.684 +; for the following tables,
49.685 +; sort by latitude in decending order (N->S)
49.686 +
49.687 + isort = dim_pqsort(lat_ob,-1)
49.688 +
49.689 + station_sort = station_long(isort)
49.690 + year_ob_sort = year_ob_long(isort)
49.691 + lat_ob_sort = lat_ob(isort)
49.692 + lon_ob_sort = lon_ob(isort)
49.693 + M_score_sort = M_score(isort,:)
49.694 +
49.695 + print(isort)
49.696 + print(lat_ob_sort)
49.697 +
49.698 +;*******************************************************************
49.699 +; html table of site: observed
49.700 +;*******************************************************************
49.701 + output_html = "line_ob.html"
49.702 +
49.703 + header = (/"<HTML>" \
49.704 + ,"<HEAD>" \
49.705 + ,"<TITLE>CLAMP metrics</TITLE>" \
49.706 + ,"</HEAD>" \
49.707 + ,"<H1>Energy at Site: Observation</H1>" \
49.708 + /)
49.709 + footer = "</HTML>"
49.710 +
49.711 + table_header = (/ \
49.712 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
49.713 + ,"<tr>" \
49.714 + ," <th bgcolor=DDDDDD >Site Name</th>" \
49.715 + ," <th bgcolor=DDDDDD >Latitude</th>" \
49.716 + ," <th bgcolor=DDDDDD >Longitude</th>" \
49.717 + ," <th bgcolor=DDDDDD >Observed</th>" \
49.718 + ,"</tr>" \
49.719 + /)
49.720 + table_footer = "</table>"
49.721 + row_header = "<tr>"
49.722 + row_footer = "</tr>"
49.723 +
49.724 + lines = new(50000,string)
49.725 + nline = 0
49.726 +
49.727 + set_line(lines,nline,header)
49.728 + set_line(lines,nline,table_header)
49.729 +;-----------------------------------------------
49.730 +; row of table
49.731 +
49.732 + do n = 0,nstation-1
49.733 +
49.734 + set_line(lines,nline,row_header)
49.735 +
49.736 + txt0 = station_sort(n)
49.737 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
49.738 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
49.739 + txt3 = year_ob_sort(n)
49.740 +
49.741 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
49.742 + set_line(lines,nline,"<th>"+txt1+"</th>")
49.743 + set_line(lines,nline,"<th>"+txt2+"</th>")
49.744 + set_line(lines,nline,"<th>"+txt3+"</th>")
49.745 +
49.746 + set_line(lines,nline,row_footer)
49.747 + end do
49.748 +;-----------------------------------------------
49.749 + set_line(lines,nline,table_footer)
49.750 + set_line(lines,nline,footer)
49.751 +
49.752 +; Now write to an HTML file.
49.753 + idx = ind(.not.ismissing(lines))
49.754 + if(.not.any(ismissing(idx))) then
49.755 + asciiwrite(output_html,lines(idx))
49.756 + else
49.757 + print ("error?")
49.758 + end if
49.759 + delete (idx)
49.760 +
49.761 +;*******************************************************************
49.762 +; score and line table : model vs observed
49.763 +;*******************************************************************
49.764 + output_html = "score+line_vs_ob.html"
49.765 +
49.766 + header = (/"<HTML>" \
49.767 + ,"<HEAD>" \
49.768 + ,"<TITLE>CLAMP metrics</TITLE>" \
49.769 + ,"</HEAD>" \
49.770 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
49.771 + /)
49.772 + footer = "</HTML>"
49.773 +
49.774 + delete (table_header)
49.775 + table_header = (/ \
49.776 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
49.777 + ,"<tr>" \
49.778 + ," <th bgcolor=DDDDDD >Site Name</th>" \
49.779 + ," <th bgcolor=DDDDDD >Latitude</th>" \
49.780 + ," <th bgcolor=DDDDDD >Longitude</th>" \
49.781 + ," <th bgcolor=DDDDDD >Observed</th>" \
49.782 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
49.783 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
49.784 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
49.785 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
49.786 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
49.787 + ," <th bgcolor=DDDDDD >Respiration</th>" \
49.788 + ," <th bgcolor=DDDDDD >Average</th>" \
49.789 + ,"</tr>" \
49.790 + /)
49.791 + table_footer = "</table>"
49.792 + row_header = "<tr>"
49.793 + row_footer = "</tr>"
49.794 +
49.795 + lines = new(50000,string)
49.796 + nline = 0
49.797 +
49.798 + set_line(lines,nline,header)
49.799 + set_line(lines,nline,table_header)
49.800 +;-----------------------------------------------
49.801 +; row of table
49.802 +
49.803 + do n = 0,nstation-1
49.804 +
49.805 + set_line(lines,nline,row_header)
49.806 +
49.807 + txt0 = station_sort(n)
49.808 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
49.809 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
49.810 + txt3 = year_ob_sort(n)
49.811 + txt4 = sprintf("%5.2f", M_score_sort(n,0))
49.812 + txt5 = sprintf("%5.2f", M_score_sort(n,1))
49.813 + txt6 = sprintf("%5.2f", M_score_sort(n,2))
49.814 + txt7 = sprintf("%5.2f", M_score_sort(n,3))
49.815 + txt8 = sprintf("%5.2f", M_score_sort(n,4))
49.816 + txt9 = sprintf("%5.2f", M_score_sort(n,5))
49.817 + txt10 = sprintf("%5.2f", avg(M_score_sort(n,:)))
49.818 +
49.819 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
49.820 + set_line(lines,nline,"<th>"+txt1+"</th>")
49.821 + set_line(lines,nline,"<th>"+txt2+"</th>")
49.822 + set_line(lines,nline,"<th>"+txt3+"</th>")
49.823 + set_line(lines,nline,"<th>"+txt4+"</th>")
49.824 + set_line(lines,nline,"<th>"+txt5+"</th>")
49.825 + set_line(lines,nline,"<th>"+txt6+"</th>")
49.826 + set_line(lines,nline,"<th>"+txt7+"</th>")
49.827 + set_line(lines,nline,"<th>"+txt8+"</th>")
49.828 + set_line(lines,nline,"<th>"+txt9+"</th>")
49.829 + set_line(lines,nline,"<th>"+txt10+"</th>")
49.830 +
49.831 + set_line(lines,nline,row_footer)
49.832 + end do
49.833 +
49.834 +; last row, summary
49.835 + set_line(lines,nline,row_header)
49.836 +
49.837 + txt0 = "All_"+sprintf("%.0f", nstation)
49.838 + txt1 = "-"
49.839 + txt2 = "-"
49.840 + txt3 = "-"
49.841 + txt4 = M_energy_co2
49.842 + txt5 = M_energy_rad
49.843 + txt6 = M_energy_lh
49.844 + txt7 = M_energy_sh
49.845 + txt8 = M_energy_gpp
49.846 + txt9 = M_energy_er
49.847 + txt10 = M_energy_all
49.848 +
49.849 + set_line(lines,nline,"<th>"+txt0+"</th>")
49.850 + set_line(lines,nline,"<th>"+txt1+"</th>")
49.851 + set_line(lines,nline,"<th>"+txt2+"</th>")
49.852 + set_line(lines,nline,"<th>"+txt3+"</th>")
49.853 + set_line(lines,nline,"<th>"+txt4+"</th>")
49.854 + set_line(lines,nline,"<th>"+txt5+"</th>")
49.855 + set_line(lines,nline,"<th>"+txt6+"</th>")
49.856 + set_line(lines,nline,"<th>"+txt7+"</th>")
49.857 + set_line(lines,nline,"<th>"+txt8+"</th>")
49.858 + set_line(lines,nline,"<th>"+txt9+"</th>")
49.859 + set_line(lines,nline,"<th>"+txt10+"</th>")
49.860 +
49.861 + set_line(lines,nline,row_footer)
49.862 +;-----------------------------------------------
49.863 + set_line(lines,nline,table_footer)
49.864 + set_line(lines,nline,footer)
49.865 +
49.866 +; Now write to an HTML file.
49.867 + idx = ind(.not.ismissing(lines))
49.868 + if(.not.any(ismissing(idx))) then
49.869 + asciiwrite(output_html,lines(idx))
49.870 + else
49.871 + print ("error?")
49.872 + end if
49.873 + delete (idx)
49.874 +
49.875 +;***************************************************************************
49.876 +; output plots
49.877 +;***************************************************************************
49.878 + output_dir = model_name+"/ameriflux"
49.879 +
49.880 + system("mv *.png *.html " + output_dir)
49.881 +;***************************************************************************
49.882 +end
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
50.2 +++ b/ameriflux/18.plot.ncl Mon Jan 26 22:08:20 2009 -0500
50.3 @@ -0,0 +1,745 @@
50.4 +;************************************************************
50.5 +; add table
50.6 +; add time series plot
50.7 +; sort by latitude in decending order (N->S)
50.8 +; find year_ob >= 4
50.9 +; add year_ob_i and year_ob_f
50.10 +; change long_name
50.11 +;************************************************************
50.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
50.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
50.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
50.15 +;************************************************************
50.16 +procedure set_line(lines:string,nline:integer,newlines:string)
50.17 +begin
50.18 +; add line to ascci/html file
50.19 +
50.20 + nnewlines = dimsizes(newlines)
50.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
50.22 + print("set_line: bad index, not setting anything.")
50.23 + return
50.24 + end if
50.25 + lines(nline:nline+nnewlines-1) = newlines
50.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
50.27 + nline = nline + nnewlines
50.28 + return
50.29 +end
50.30 +;*************************************************************
50.31 +begin
50.32 +
50.33 + plot_type = "ps"
50.34 + plot_type_new = "png"
50.35 +
50.36 +;************************************************
50.37 +; read model data
50.38 +;************************************************
50.39 + model = "cn"
50.40 +; model = "casa"
50.41 +
50.42 + model_name = "i01.10" + model
50.43 +
50.44 +; change to unit of observed (u mol/m2/s)
50.45 +; Model_units [=] gC/m2/s
50.46 +; 12. = molecular weight of C
50.47 +; u mol = 1e-6 mol
50.48 + factor = 1e6 /12.
50.49 +
50.50 + ENERGY ="new"
50.51 +
50.52 +;************************************************
50.53 +; read data: observed
50.54 +;************************************************
50.55 +
50.56 + station = (/"ARM_Oklahoma" \
50.57 + ,"ARM_Oklahoma_burn" \
50.58 + ,"ARM_Oklahoma_control" \
50.59 + ,"Atqasuk" \
50.60 + ,"Audubon" \
50.61 + ,"AustinCary" \
50.62 + ,"Bartlett" \
50.63 + ,"Bondville" \
50.64 + ,"Brookings" \
50.65 + ,"Donaldson" \
50.66 + ,"Duke_Forest_Hardwoods" \
50.67 + ,"Duke_Forest_Open_Field" \
50.68 + ,"Duke_Forest_Pine" \
50.69 + ,"Fermi_Ag" \
50.70 + ,"Fermi_Prairie" \
50.71 + ,"Flagstaff_Managed" \
50.72 + ,"Flagstaff_Unmanaged" \
50.73 + ,"Flagstaff_Wildfire" \
50.74 + ,"FortPeck" \
50.75 + ,"FreemanRanch_mesquite" \
50.76 + ,"Goodwin_Creek" \
50.77 + ,"HarvardForest" \
50.78 + ,"HarvardForestHemlock" \
50.79 + ,"HowlandForestMain" \
50.80 + ,"HowlandForestWest" \
50.81 + ,"Ivotuk" \
50.82 + ,"KendallGrasslands" \
50.83 + ,"KennedySpaceCenterPine" \
50.84 + ,"KennedySpaceCenterScrub" \
50.85 + ,"LittleProspect" \
50.86 + ,"LostCreek" \
50.87 + ,"Mead-irrigated" \
50.88 + ,"Mead-irrigated-rotation" \
50.89 + ,"Mead-rainfed" \
50.90 + ,"Metolius_2nd_YoungPonderosaPine" \
50.91 + ,"MetoliusEyerly" \
50.92 + ,"MetoliusIntermediatePine" \
50.93 + ,"MetoliusOldPonderosaPine" \
50.94 + ,"MissouriOzark" \
50.95 + ,"Mize" \
50.96 + ,"MorganMonroe" \
50.97 + ,"NiwotRidge" \
50.98 + ,"NorthCarolina_cc" \
50.99 + ,"NorthCarolina_lp" \
50.100 + ,"ParkFalls" \
50.101 + ,"Rayonier" \
50.102 + ,"SantaRita" \
50.103 + ,"SkyOaks_Old" \
50.104 + ,"SkyOaks_PostFire" \
50.105 + ,"SkyOaks_Young" \
50.106 + ,"SylvaniaWilderness" \
50.107 + ,"Toledo" \
50.108 + ,"Tonzi" \
50.109 + ,"UCI_1850" \
50.110 + ,"UCI_1930" \
50.111 + ,"UCI_1964" \
50.112 + ,"UCI_1964wet" \
50.113 + ,"UCI_1981" \
50.114 + ,"UCI_1989" \
50.115 + ,"UCI_1998" \
50.116 + ,"UMBS" \
50.117 + ,"Vaira" \
50.118 + ,"WalkerBranch" \
50.119 + ,"WillowCreek" \
50.120 + ,"WindRiver" \
50.121 + ,"Wisconsin_ihw" \
50.122 + ,"Wisconsin_irp" \
50.123 + ,"Wisconsin_mrp" \
50.124 + ,"Wisconsin_myjp" \
50.125 + ,"Wisconsin_pb" \
50.126 + ,"Wisconsin_rpcc" \
50.127 + ,"Wisconsin_yhw" \
50.128 + ,"Wisconsin_yjp" \
50.129 + ,"Wisconsin_yrp" \
50.130 + /)
50.131 +
50.132 + year_ob = (/"2003-2006" \
50.133 + ,"2005-2006" \
50.134 + ,"2005-2006" \
50.135 + ,"1999-2006" \
50.136 + ,"2002-2006" \
50.137 + ,"2000-2005" \
50.138 + ,"2004-2005" \
50.139 + ,"1996-2006" \
50.140 + ,"2004-2006" \
50.141 + ,"1999-2004" \
50.142 + ,"2003-2005" \
50.143 + ,"2001-2005" \
50.144 + ,"2001-2005" \
50.145 + ,"2005-2006" \
50.146 + ,"2004-2006" \
50.147 + ,"2005-2006" \
50.148 + ,"2005-2006" \
50.149 + ,"2005-2006" \
50.150 + ,"2000-2006" \
50.151 + ,"2004-2006" \
50.152 + ,"2002-2006" \
50.153 + ,"1991-2004" \
50.154 + ,"2004-2004" \
50.155 + ,"1996-2004" \
50.156 + ,"1999-2004" \
50.157 + ,"2003-2006" \
50.158 + ,"2004-2006" \
50.159 + ,"2002-2002" \
50.160 + ,"2000-2006" \
50.161 + ,"2002-2005" \
50.162 + ,"2001-2005" \
50.163 + ,"2001-2005" \
50.164 + ,"2001-2005" \
50.165 + ,"2001-2005" \
50.166 + ,"2004-2005" \
50.167 + ,"2004-2005" \
50.168 + ,"2003-2005" \
50.169 + ,"1996-2000" \
50.170 + ,"2004-2006" \
50.171 + ,"1998-2004" \
50.172 + ,"1999-2005" \
50.173 + ,"1999-2003" \
50.174 + ,"2005-2006" \
50.175 + ,"2005-2006" \
50.176 + ,"1996-2003" \
50.177 + ,"1998-1998" \
50.178 + ,"2004-2006" \
50.179 + ,"1997-2006" \
50.180 + ,"2004-2006" \
50.181 + ,"1997-2006" \
50.182 + ,"2002-2006" \
50.183 + ,"2004-2005" \
50.184 + ,"2001-2006" \
50.185 + ,"2004-2005" \
50.186 + ,"2001-2005" \
50.187 + ,"2001-2005" \
50.188 + ,"2002-2004" \
50.189 + ,"2001-2005" \
50.190 + ,"2001-2005" \
50.191 + ,"2002-2005" \
50.192 + ,"1999-2003" \
50.193 + ,"2001-2006" \
50.194 + ,"1995-1999" \
50.195 + ,"1999-2005" \
50.196 + ,"1999-2004" \
50.197 + ,"2003-2003" \
50.198 + ,"2003-2003" \
50.199 + ,"2002-2005" \
50.200 + ,"2004-2004" \
50.201 + ,"2002-2002" \
50.202 + ,"2005-2005" \
50.203 + ,"2002-2002" \
50.204 + ,"2004-2005" \
50.205 + ,"2002-2002" \
50.206 + /)
50.207 +
50.208 + year_ob_i = (/2003 \
50.209 + ,2005 \
50.210 + ,2005 \
50.211 + ,1999 \
50.212 + ,2002 \
50.213 + ,2000 \
50.214 + ,2004 \
50.215 + ,1996 \
50.216 + ,2004 \
50.217 + ,1999 \
50.218 + ,2003 \
50.219 + ,2001 \
50.220 + ,2001 \
50.221 + ,2005 \
50.222 + ,2004 \
50.223 + ,2005 \
50.224 + ,2005 \
50.225 + ,2005 \
50.226 + ,2000 \
50.227 + ,2004 \
50.228 + ,2002 \
50.229 + ,1991 \
50.230 + ,2004 \
50.231 + ,1996 \
50.232 + ,1999 \
50.233 + ,2003 \
50.234 + ,2004 \
50.235 + ,2002 \
50.236 + ,2000 \
50.237 + ,2002 \
50.238 + ,2001 \
50.239 + ,2001 \
50.240 + ,2001 \
50.241 + ,2001 \
50.242 + ,2004 \
50.243 + ,2004 \
50.244 + ,2003 \
50.245 + ,1996 \
50.246 + ,2004 \
50.247 + ,1998 \
50.248 + ,1999 \
50.249 + ,1999 \
50.250 + ,2005 \
50.251 + ,2005 \
50.252 + ,1996 \
50.253 + ,1998 \
50.254 + ,2004 \
50.255 + ,1997 \
50.256 + ,2004 \
50.257 + ,1997 \
50.258 + ,2002 \
50.259 + ,2004 \
50.260 + ,2001 \
50.261 + ,2004 \
50.262 + ,2001 \
50.263 + ,2001 \
50.264 + ,2002 \
50.265 + ,2001 \
50.266 + ,2001 \
50.267 + ,2002 \
50.268 + ,1999 \
50.269 + ,2001 \
50.270 + ,1995 \
50.271 + ,1999 \
50.272 + ,1999 \
50.273 + ,2003 \
50.274 + ,2003 \
50.275 + ,2002 \
50.276 + ,2004 \
50.277 + ,2002 \
50.278 + ,2005 \
50.279 + ,2002 \
50.280 + ,2004 \
50.281 + ,2002 \
50.282 + /)
50.283 +
50.284 + year_ob_f = (/2006 \
50.285 + ,2006 \
50.286 + ,2006 \
50.287 + ,2006 \
50.288 + ,2006 \
50.289 + ,2005 \
50.290 + ,2005 \
50.291 + ,2006 \
50.292 + ,2006 \
50.293 + ,2004 \
50.294 + ,2005 \
50.295 + ,2005 \
50.296 + ,2005 \
50.297 + ,2006 \
50.298 + ,2006 \
50.299 + ,2006 \
50.300 + ,2006 \
50.301 + ,2006 \
50.302 + ,2006 \
50.303 + ,2006 \
50.304 + ,2006 \
50.305 + ,2004 \
50.306 + ,2004 \
50.307 + ,2004 \
50.308 + ,2004 \
50.309 + ,2006 \
50.310 + ,2006 \
50.311 + ,2002 \
50.312 + ,2006 \
50.313 + ,2005 \
50.314 + ,2005 \
50.315 + ,2005 \
50.316 + ,2005 \
50.317 + ,2005 \
50.318 + ,2005 \
50.319 + ,2005 \
50.320 + ,2005 \
50.321 + ,2000 \
50.322 + ,2006 \
50.323 + ,2004 \
50.324 + ,2005 \
50.325 + ,2003 \
50.326 + ,2006 \
50.327 + ,2006 \
50.328 + ,2003 \
50.329 + ,1998 \
50.330 + ,2006 \
50.331 + ,2006 \
50.332 + ,2006 \
50.333 + ,2006 \
50.334 + ,2006 \
50.335 + ,2005 \
50.336 + ,2006 \
50.337 + ,2005 \
50.338 + ,2005 \
50.339 + ,2005 \
50.340 + ,2004 \
50.341 + ,2005 \
50.342 + ,2005 \
50.343 + ,2005 \
50.344 + ,2003 \
50.345 + ,2006 \
50.346 + ,1999 \
50.347 + ,2005 \
50.348 + ,2004 \
50.349 + ,2003 \
50.350 + ,2003 \
50.351 + ,2005 \
50.352 + ,2004 \
50.353 + ,2002 \
50.354 + ,2005 \
50.355 + ,2002 \
50.356 + ,2005 \
50.357 + ,2002 \
50.358 + /)
50.359 +
50.360 + field = (/"NEE Flux" \
50.361 + ,"Net Radiation" \
50.362 + ,"Latent Heat" \
50.363 + ,"Sensible Heat" \
50.364 + ,"GPP Flux" \
50.365 + ,"Respiration" \
50.366 + /)
50.367 +
50.368 + field_unit = (/"u mol/m2/s" \
50.369 + ,"W/m2" \
50.370 + ,"W/m2" \
50.371 + ,"W/m2" \
50.372 + ,"u mol/m2/s" \
50.373 + ,"u mol/m2/s" \
50.374 + /)
50.375 +
50.376 + nfield = dimsizes(field)
50.377 +
50.378 +;========================================================================
50.379 +; find (# of year observed) >=4 and year_ob_i <= 2001
50.380 +
50.381 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
50.382 +
50.383 + nstation = dimsizes(station)
50.384 +
50.385 + year_station = new ((/nstation/),integer)
50.386 +
50.387 + do n = 0,nstation-1
50.388 +
50.389 + diro = dir_root + station(n)+"/"
50.390 + filo = year_ob_i(n)+"-"+year_ob_f(n)+"_L4_m.nc"
50.391 + fo = addfile (diro+filo,"r")
50.392 +
50.393 + year = fo->year
50.394 + year_station(n) = dimsizes(year)
50.395 + delete (year)
50.396 +
50.397 + end do
50.398 +
50.399 + delete (fo)
50.400 +
50.401 + i_long_ob = ind(year_station .ge. 4 .and. year_ob_i .le. 2001)
50.402 +
50.403 + station_long = station(i_long_ob)
50.404 + year_ob_long = year_ob(i_long_ob)
50.405 + year_ob_i_long = year_ob_i(i_long_ob)
50.406 + year_ob_f_long = year_ob_f(i_long_ob)
50.407 + year_station_long = year_station(i_long_ob)
50.408 +
50.409 + nstation_long = dimsizes(station_long)
50.410 +; print (nstation_long)
50.411 +; print (i_long_ob)
50.412 +; print (year_ob_i(i_long_ob))
50.413 +; print (station_long)
50.414 +
50.415 +;========================================================================
50.416 +; get long observed lat and lon
50.417 +
50.418 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
50.419 +
50.420 + lat_ob_long = new ((/nstation_long/),float)
50.421 + lon_ob_long = new ((/nstation_long/),float)
50.422 +
50.423 + do n = 0,nstation_long-1
50.424 +
50.425 + diro = dir_root + station_long(n)+"/"
50.426 + filo = year_ob_i_long(n)+"-"+year_ob_f_long(n)+"_L4_m.nc"
50.427 + fo = addfile (diro+filo,"r")
50.428 +
50.429 +; print (diro)
50.430 +; print (filo)
50.431 +
50.432 + lon_ob_long(n) = fo->lon
50.433 + lat_ob_long(n) = fo->lat
50.434 +
50.435 + delete (fo)
50.436 +
50.437 + end do
50.438 +
50.439 +;=========================================================
50.440 +; get model data at observed lat-lon
50.441 +
50.442 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
50.443 + film = model_name+"_ameriflux_1990-2004_monthly.nc"
50.444 + fm = addfile (dirm+film,"r")
50.445 +
50.446 + xm = fm->lon
50.447 + ym = fm->lat
50.448 + date = fm->date
50.449 +
50.450 + date_dim = dimsizes(date)
50.451 + nyear = date_dim(0)
50.452 +
50.453 + nmonth =12
50.454 +
50.455 + data_mod = new ((/nfield,nyear,nmonth,nstation_long/),float)
50.456 +
50.457 +;************************************************************
50.458 +; interpolate model data into observed station
50.459 +; note: model is 0-360E, 90S-90N
50.460 +;************************************************************
50.461 +
50.462 +; to be able to handle observation at (-89.98,-24.80)
50.463 + ym(0) = -90.
50.464 +
50.465 +if (ENERGY .eq. "old") then
50.466 +
50.467 + data = fm->NEE
50.468 + data_mod(0,:,:,:) = data(:,:,:) * factor
50.469 +
50.470 +; data = fm->LATENT
50.471 + data1 = fm->FCEV
50.472 + data2 = fm->FCTR
50.473 + data3 = fm->FGEV
50.474 + data_mod(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
50.475 + delete (data1)
50.476 + delete (data2)
50.477 + delete (data3)
50.478 +
50.479 +; data = fm->SENSIBLE
50.480 + data = fm->FSH
50.481 + data_mod(3,:,:,:) = data(:,:,:)
50.482 +
50.483 +; data = fm->NETRAD
50.484 + data1 = fm->FSA
50.485 + data2 = fm->FIRA
50.486 + data_mod(1,:,:,:) = data1(:,:,:)-data2(:,:,:)
50.487 + delete (data1)
50.488 + delete (data2)
50.489 +
50.490 +else
50.491 +
50.492 + data = fm->NEE
50.493 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob_long,lat_ob_long,0)
50.494 + data_mod(0,:,:,:) = yy(:,:,:) * factor
50.495 +
50.496 + data = fm->NETRAD
50.497 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob_long,lat_ob_long,0)
50.498 + data_mod(1,:,:,:) = yy(:,:,:)
50.499 +
50.500 + data = fm->LATENT
50.501 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob_long,lat_ob_long,0)
50.502 + data_mod(2,:,:,:) = yy(:,:,:)
50.503 +
50.504 +; data = fm->SENSIBLE
50.505 + data = fm->FSH
50.506 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob_long,lat_ob_long,0)
50.507 + data_mod(3,:,:,:) = yy(:,:,:)
50.508 +
50.509 +end if
50.510 +
50.511 + data = fm->GPP
50.512 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob_long,lat_ob_long,0)
50.513 + data_mod(4,:,:,:) = yy(:,:,:) * factor
50.514 +
50.515 + if (model .eq. "cn") then
50.516 + data = fm->ER
50.517 + else
50.518 + data1 = fm->AR
50.519 + data2 = fm->HR
50.520 + data = data1 + data2
50.521 +
50.522 + delete (data1)
50.523 + delete (data2)
50.524 + end if
50.525 +
50.526 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob_long,lat_ob_long,0)
50.527 + data_mod(5,:,:,:) = yy(:,:,:) * factor
50.528 +
50.529 + delete (fm)
50.530 + delete (data)
50.531 +
50.532 +;*******************************************************************
50.533 +; for station line plot
50.534 +;*******************************************************************
50.535 +
50.536 +; for x-axis in xyplot
50.537 + mon = ispan(1,12,1)
50.538 + mon@long_name = "month"
50.539 +
50.540 + res = True ; plot mods desired
50.541 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
50.542 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
50.543 +
50.544 + res@tmXBFormat = "f" ; not to add trailing zeros
50.545 +
50.546 +;-------------------------------------------------------------------------
50.547 +; Add a boxed legend using the more simple method
50.548 +
50.549 + res@pmLegendDisplayMode = "Always"
50.550 +; res@pmLegendWidthF = 0.1
50.551 + res@pmLegendWidthF = 0.08
50.552 + res@pmLegendHeightF = 0.06
50.553 +; res@pmLegendOrthogonalPosF = -1.17
50.554 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
50.555 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
50.556 +
50.557 +; res@pmLegendParallelPosF = 0.18
50.558 + res@pmLegendParallelPosF = 0.23 ;(rightward)
50.559 +
50.560 +; res@lgPerimOn = False
50.561 + res@lgLabelFontHeightF = 0.015
50.562 + res@xyExplicitLegendLabels = (/"observed",model_name/)
50.563 +;-------------------------------------------------------------------
50.564 +; for panel plot
50.565 + res@gsnFrame = False ; Do not draw plot
50.566 + res@gsnDraw = False ; Do not advance frame
50.567 +
50.568 + pres = True ; panel plot mods desired
50.569 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
50.570 + ; indiv. plots in panel
50.571 + pres@gsnMaximize = True ; fill the page
50.572 +;-------------------------------------------------------------------
50.573 +
50.574 +;==============================================================
50.575 +; get ob data at each site
50.576 +
50.577 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
50.578 +
50.579 + do n = 0,nstation_long-1
50.580 +; do n = 2,6
50.581 +
50.582 + year_setback = 0
50.583 +
50.584 + nyear = year_station_long(n)
50.585 +
50.586 + if (year_ob_f_long(n).eq. 2006) then
50.587 + year_setback = 2006 -2004
50.588 + end if
50.589 + if (year_ob_f_long(n).eq. 2005) then
50.590 + year_setback = 2005 -2004
50.591 + end if
50.592 +
50.593 + ntime = (nyear - year_setback) * nmonth
50.594 + print (nyear)
50.595 +
50.596 + data_ob = new ((/nfield, nyear, nmonth/),float)
50.597 +
50.598 + diro = dir_root + station_long(n)+"/"
50.599 + filo = year_ob_i_long(n)+"-"+year_ob_f_long(n)+"_L4_m.nc"
50.600 + fo = addfile (diro+filo,"r")
50.601 +
50.602 +; print (diro)
50.603 +; print (filo)
50.604 +
50.605 + data_ob(0,:,:) = fo->NEE_or_fMDS
50.606 + data_ob(1,:,:) = fo->Rg_f
50.607 + data_ob(2,:,:) = fo->LE_f
50.608 + data_ob(3,:,:) = fo->H_f
50.609 + data_ob(4,:,:) = fo->GPP_or_MDS
50.610 + data_ob(5,:,:) = fo->Reco_or
50.611 +
50.612 + delete (fo)
50.613 +
50.614 + timeI = new((/ntime/),integer)
50.615 + timeF = new((/ntime/),float)
50.616 + timeI = ispan(1,ntime,1)
50.617 + timeF = year_ob_i_long(n) + (timeI-1)/12.
50.618 + timeF@long_name = "year"
50.619 +
50.620 + plot_data = new((/2,ntime/),float)
50.621 +
50.622 +;----------------------------
50.623 +; for model_vs_ob
50.624 +
50.625 + plot_name = station_long(n)+"_tseries_vs_ob"
50.626 + title = station_long(n)+"("+sprintf("%5.2f",lat_ob_long(n))+","+sprintf("%5.2f",lon_ob_long(n))+")"
50.627 + res@tiMainString = title
50.628 +
50.629 + wks = gsn_open_wks (plot_type,plot_name)
50.630 + plot=new(nfield,graphic) ; create graphic array
50.631 +
50.632 + i_year_mod_i = year_ob_i_long(n) - 1990
50.633 + i_year_mod_f = i_year_mod_i + nyear - 1 - year_setback
50.634 +
50.635 + i_year_ob_f = nyear - year_setback - 1
50.636 +
50.637 +; print (nyear)
50.638 +; print (i_year_ob_f)
50.639 +; print (i_year_mod_i)
50.640 +; print (i_year_mod_f)
50.641 +
50.642 + do i = 0,nfield-1
50.643 + plot_data(0,:) = ndtooned(data_ob (i,0:i_year_ob_f,:))
50.644 + plot_data(1,:) = ndtooned(data_mod(i,i_year_mod_i:i_year_mod_f,:,n))
50.645 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
50.646 + plot(i)=gsn_csm_xy(wks,timeF,plot_data,res) ; create plot
50.647 + end do
50.648 +
50.649 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
50.650 +
50.651 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
50.652 + "rm "+plot_name+"."+plot_type)
50.653 +
50.654 + clear (wks)
50.655 + delete (plot)
50.656 +
50.657 + delete (data_ob)
50.658 + delete (timeI)
50.659 + delete (timeF)
50.660 + delete (plot_data)
50.661 +
50.662 + end do
50.663 +
50.664 +;###################################################################
50.665 +; for the following tables,
50.666 +; sort by latitude in decending order (N->S)
50.667 +
50.668 + isort = dim_pqsort(lat_ob_long,-1)
50.669 +
50.670 + station_sort = station_long(isort)
50.671 + year_ob_sort = year_ob_long(isort)
50.672 + lat_ob_sort = lat_ob_long(isort)
50.673 + lon_ob_sort = lon_ob_long(isort)
50.674 +
50.675 +; print(isort)
50.676 +; print(lat_ob_sort)
50.677 +
50.678 +;*******************************************************************
50.679 +; html table of site: observed
50.680 +;*******************************************************************
50.681 + output_html = "tseries_vs_ob.html"
50.682 +
50.683 + header = (/"<HTML>" \
50.684 + ,"<HEAD>" \
50.685 + ,"<TITLE>CLAMP metrics</TITLE>" \
50.686 + ,"</HEAD>" \
50.687 + ,"<H1>Timeseries at Site: "+model_name+" vs Observation</H1>" \
50.688 + /)
50.689 + footer = "</HTML>"
50.690 +
50.691 + table_header = (/ \
50.692 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
50.693 + ,"<tr>" \
50.694 + ," <th bgcolor=DDDDDD >Site Name</th>" \
50.695 + ," <th bgcolor=DDDDDD >Latitude</th>" \
50.696 + ," <th bgcolor=DDDDDD >Longitude</th>" \
50.697 + ," <th bgcolor=DDDDDD >Observed</th>" \
50.698 + ,"</tr>" \
50.699 + /)
50.700 + table_footer = "</table>"
50.701 + row_header = "<tr>"
50.702 + row_footer = "</tr>"
50.703 +
50.704 + lines = new(50000,string)
50.705 + nline = 0
50.706 +
50.707 + set_line(lines,nline,header)
50.708 + set_line(lines,nline,table_header)
50.709 +;-----------------------------------------------
50.710 +; row of table
50.711 +
50.712 + do n = 0,nstation_long-1
50.713 +
50.714 + set_line(lines,nline,row_header)
50.715 +
50.716 + txt0 = station_sort(n)
50.717 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
50.718 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
50.719 + txt3 = year_ob_sort(n)
50.720 +
50.721 + set_line(lines,nline,"<th><a href="+txt0+"_tseries_vs_ob.png>"+txt0+"</a></th>")
50.722 + set_line(lines,nline,"<th>"+txt1+"</th>")
50.723 + set_line(lines,nline,"<th>"+txt2+"</th>")
50.724 + set_line(lines,nline,"<th>"+txt3+"</th>")
50.725 +
50.726 + set_line(lines,nline,row_footer)
50.727 + end do
50.728 +;-----------------------------------------------
50.729 + set_line(lines,nline,table_footer)
50.730 + set_line(lines,nline,footer)
50.731 +
50.732 +; Now write to an HTML file.
50.733 + idx = ind(.not.ismissing(lines))
50.734 + if(.not.any(ismissing(idx))) then
50.735 + asciiwrite(output_html,lines(idx))
50.736 + else
50.737 + print ("error?")
50.738 + end if
50.739 + delete (idx)
50.740 +
50.741 +;***************************************************************************
50.742 +; output plots
50.743 +;***************************************************************************
50.744 + output_dir = model_name+"/ameriflux"
50.745 +
50.746 + system("mv *.png *.html " + output_dir)
50.747 +;***************************************************************************
50.748 +end
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
51.2 +++ b/ameriflux/20.plot.ncl Mon Jan 26 22:08:20 2009 -0500
51.3 @@ -0,0 +1,842 @@
51.4 +;************************************************************
51.5 +; merge 14 and 18
51.6 +; sort by latitude in decending order (N->S)
51.7 +; add year_ob_i and year_ob_f
51.8 +; change long_name
51.9 +;************************************************************
51.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
51.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
51.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
51.13 +;************************************************************
51.14 +procedure set_line(lines:string,nline:integer,newlines:string)
51.15 +begin
51.16 +; add line to ascci/html file
51.17 +
51.18 + nnewlines = dimsizes(newlines)
51.19 + if(nline+nnewlines-1.ge.dimsizes(lines))
51.20 + print("set_line: bad index, not setting anything.")
51.21 + return
51.22 + end if
51.23 + lines(nline:nline+nnewlines-1) = newlines
51.24 +; print ("lines = " + lines(nline:nline+nnewlines-1))
51.25 + nline = nline + nnewlines
51.26 + return
51.27 +end
51.28 +;*************************************************************
51.29 +begin
51.30 +
51.31 + plot_type = "ps"
51.32 + plot_type_new = "png"
51.33 +
51.34 +; for 6 fields, 12-monthly
51.35 + nmon = 12
51.36 +
51.37 +;************************************************
51.38 +; read model
51.39 +;************************************************
51.40 + model = "cn"
51.41 +; model = "casa"
51.42 +
51.43 + model_name = "i01.10" + model
51.44 +
51.45 +;************************************************
51.46 +; read data: observed
51.47 +;************************************************
51.48 +
51.49 + station = (/"ARM_Oklahoma" \
51.50 + ,"ARM_Oklahoma_burn" \
51.51 + ,"ARM_Oklahoma_control" \
51.52 + ,"Atqasuk" \
51.53 + ,"Audubon" \
51.54 + ,"AustinCary" \
51.55 + ,"Bartlett" \
51.56 + ,"Bondville" \
51.57 + ,"Brookings" \
51.58 + ,"Donaldson" \
51.59 + ,"Duke_Forest_Hardwoods" \
51.60 + ,"Duke_Forest_Open_Field" \
51.61 + ,"Duke_Forest_Pine" \
51.62 + ,"Fermi_Ag" \
51.63 + ,"Fermi_Prairie" \
51.64 + ,"Flagstaff_Managed" \
51.65 + ,"Flagstaff_Unmanaged" \
51.66 + ,"Flagstaff_Wildfire" \
51.67 + ,"FortPeck" \
51.68 + ,"FreemanRanch_mesquite" \
51.69 + ,"Goodwin_Creek" \
51.70 + ,"HarvardForest" \
51.71 + ,"HarvardForestHemlock" \
51.72 + ,"HowlandForestMain" \
51.73 + ,"HowlandForestWest" \
51.74 + ,"Ivotuk" \
51.75 + ,"KendallGrasslands" \
51.76 + ,"KennedySpaceCenterPine" \
51.77 + ,"KennedySpaceCenterScrub" \
51.78 + ,"LittleProspect" \
51.79 + ,"LostCreek" \
51.80 + ,"Mead-irrigated" \
51.81 + ,"Mead-irrigated-rotation" \
51.82 + ,"Mead-rainfed" \
51.83 + ,"Metolius_2nd_YoungPonderosaPine" \
51.84 + ,"MetoliusEyerly" \
51.85 + ,"MetoliusIntermediatePine" \
51.86 + ,"MetoliusOldPonderosaPine" \
51.87 + ,"MissouriOzark" \
51.88 + ,"Mize" \
51.89 + ,"MorganMonroe" \
51.90 + ,"NiwotRidge" \
51.91 + ,"NorthCarolina_cc" \
51.92 + ,"NorthCarolina_lp" \
51.93 + ,"ParkFalls" \
51.94 + ,"Rayonier" \
51.95 + ,"SantaRita" \
51.96 + ,"SkyOaks_Old" \
51.97 + ,"SkyOaks_PostFire" \
51.98 + ,"SkyOaks_Young" \
51.99 + ,"SylvaniaWilderness" \
51.100 + ,"Toledo" \
51.101 + ,"Tonzi" \
51.102 + ,"UCI_1850" \
51.103 + ,"UCI_1930" \
51.104 + ,"UCI_1964" \
51.105 + ,"UCI_1964wet" \
51.106 + ,"UCI_1981" \
51.107 + ,"UCI_1989" \
51.108 + ,"UCI_1998" \
51.109 + ,"UMBS" \
51.110 + ,"Vaira" \
51.111 + ,"WalkerBranch" \
51.112 + ,"WillowCreek" \
51.113 + ,"WindRiver" \
51.114 + ,"Wisconsin_ihw" \
51.115 + ,"Wisconsin_irp" \
51.116 + ,"Wisconsin_mrp" \
51.117 + ,"Wisconsin_myjp" \
51.118 + ,"Wisconsin_pb" \
51.119 + ,"Wisconsin_rpcc" \
51.120 + ,"Wisconsin_yhw" \
51.121 + ,"Wisconsin_yjp" \
51.122 + ,"Wisconsin_yrp" \
51.123 + /)
51.124 +
51.125 + year_ob = (/"2003-2006" \
51.126 + ,"2005-2006" \
51.127 + ,"2005-2006" \
51.128 + ,"1999-2006" \
51.129 + ,"2002-2006" \
51.130 + ,"2000-2005" \
51.131 + ,"2004-2005" \
51.132 + ,"1996-2006" \
51.133 + ,"2004-2006" \
51.134 + ,"1999-2004" \
51.135 + ,"2003-2005" \
51.136 + ,"2001-2005" \
51.137 + ,"2001-2005" \
51.138 + ,"2005-2006" \
51.139 + ,"2004-2006" \
51.140 + ,"2005-2006" \
51.141 + ,"2005-2006" \
51.142 + ,"2005-2006" \
51.143 + ,"2000-2006" \
51.144 + ,"2004-2006" \
51.145 + ,"2002-2006" \
51.146 + ,"1991-2004" \
51.147 + ,"2004-2004" \
51.148 + ,"1996-2004" \
51.149 + ,"1999-2004" \
51.150 + ,"2003-2006" \
51.151 + ,"2004-2006" \
51.152 + ,"2002-2002" \
51.153 + ,"2000-2006" \
51.154 + ,"2002-2005" \
51.155 + ,"2001-2005" \
51.156 + ,"2001-2005" \
51.157 + ,"2001-2005" \
51.158 + ,"2001-2005" \
51.159 + ,"2004-2005" \
51.160 + ,"2004-2005" \
51.161 + ,"2003-2005" \
51.162 + ,"1996-2000" \
51.163 + ,"2004-2006" \
51.164 + ,"1998-2004" \
51.165 + ,"1999-2005" \
51.166 + ,"1999-2003" \
51.167 + ,"2005-2006" \
51.168 + ,"2005-2006" \
51.169 + ,"1996-2003" \
51.170 + ,"1998-1998" \
51.171 + ,"2004-2006" \
51.172 + ,"1997-2006" \
51.173 + ,"2004-2006" \
51.174 + ,"1997-2006" \
51.175 + ,"2002-2006" \
51.176 + ,"2004-2005" \
51.177 + ,"2001-2006" \
51.178 + ,"2004-2005" \
51.179 + ,"2001-2005" \
51.180 + ,"2001-2005" \
51.181 + ,"2002-2004" \
51.182 + ,"2001-2005" \
51.183 + ,"2001-2005" \
51.184 + ,"2002-2005" \
51.185 + ,"1999-2003" \
51.186 + ,"2001-2006" \
51.187 + ,"1995-1999" \
51.188 + ,"1999-2005" \
51.189 + ,"1999-2004" \
51.190 + ,"2003-2003" \
51.191 + ,"2003-2003" \
51.192 + ,"2002-2005" \
51.193 + ,"2004-2004" \
51.194 + ,"2002-2002" \
51.195 + ,"2005-2005" \
51.196 + ,"2002-2002" \
51.197 + ,"2004-2005" \
51.198 + ,"2002-2002" \
51.199 + /)
51.200 +
51.201 + year_ob_i = (/2003 \
51.202 + ,2005 \
51.203 + ,2005 \
51.204 + ,1999 \
51.205 + ,2002 \
51.206 + ,2000 \
51.207 + ,2004 \
51.208 + ,1996 \
51.209 + ,2004 \
51.210 + ,1999 \
51.211 + ,2003 \
51.212 + ,2001 \
51.213 + ,2001 \
51.214 + ,2005 \
51.215 + ,2004 \
51.216 + ,2005 \
51.217 + ,2005 \
51.218 + ,2005 \
51.219 + ,2000 \
51.220 + ,2004 \
51.221 + ,2002 \
51.222 + ,1991 \
51.223 + ,2004 \
51.224 + ,1996 \
51.225 + ,1999 \
51.226 + ,2003 \
51.227 + ,2004 \
51.228 + ,2002 \
51.229 + ,2000 \
51.230 + ,2002 \
51.231 + ,2001 \
51.232 + ,2001 \
51.233 + ,2001 \
51.234 + ,2001 \
51.235 + ,2004 \
51.236 + ,2004 \
51.237 + ,2003 \
51.238 + ,1996 \
51.239 + ,2004 \
51.240 + ,1998 \
51.241 + ,1999 \
51.242 + ,1999 \
51.243 + ,2005 \
51.244 + ,2005 \
51.245 + ,1996 \
51.246 + ,1998 \
51.247 + ,2004 \
51.248 + ,1997 \
51.249 + ,2004 \
51.250 + ,1997 \
51.251 + ,2002 \
51.252 + ,2004 \
51.253 + ,2001 \
51.254 + ,2004 \
51.255 + ,2001 \
51.256 + ,2001 \
51.257 + ,2002 \
51.258 + ,2001 \
51.259 + ,2001 \
51.260 + ,2002 \
51.261 + ,1999 \
51.262 + ,2001 \
51.263 + ,1995 \
51.264 + ,1999 \
51.265 + ,1999 \
51.266 + ,2003 \
51.267 + ,2003 \
51.268 + ,2002 \
51.269 + ,2004 \
51.270 + ,2002 \
51.271 + ,2005 \
51.272 + ,2002 \
51.273 + ,2004 \
51.274 + ,2002 \
51.275 + /)
51.276 +
51.277 + year_ob_f = (/2006 \
51.278 + ,2006 \
51.279 + ,2006 \
51.280 + ,2006 \
51.281 + ,2006 \
51.282 + ,2005 \
51.283 + ,2005 \
51.284 + ,2006 \
51.285 + ,2006 \
51.286 + ,2004 \
51.287 + ,2005 \
51.288 + ,2005 \
51.289 + ,2005 \
51.290 + ,2006 \
51.291 + ,2006 \
51.292 + ,2006 \
51.293 + ,2006 \
51.294 + ,2006 \
51.295 + ,2006 \
51.296 + ,2006 \
51.297 + ,2006 \
51.298 + ,2004 \
51.299 + ,2004 \
51.300 + ,2004 \
51.301 + ,2004 \
51.302 + ,2006 \
51.303 + ,2006 \
51.304 + ,2002 \
51.305 + ,2006 \
51.306 + ,2005 \
51.307 + ,2005 \
51.308 + ,2005 \
51.309 + ,2005 \
51.310 + ,2005 \
51.311 + ,2005 \
51.312 + ,2005 \
51.313 + ,2005 \
51.314 + ,2000 \
51.315 + ,2006 \
51.316 + ,2004 \
51.317 + ,2005 \
51.318 + ,2003 \
51.319 + ,2006 \
51.320 + ,2006 \
51.321 + ,2003 \
51.322 + ,1998 \
51.323 + ,2006 \
51.324 + ,2006 \
51.325 + ,2006 \
51.326 + ,2006 \
51.327 + ,2006 \
51.328 + ,2005 \
51.329 + ,2006 \
51.330 + ,2005 \
51.331 + ,2005 \
51.332 + ,2005 \
51.333 + ,2004 \
51.334 + ,2005 \
51.335 + ,2005 \
51.336 + ,2005 \
51.337 + ,2003 \
51.338 + ,2006 \
51.339 + ,1999 \
51.340 + ,2005 \
51.341 + ,2004 \
51.342 + ,2003 \
51.343 + ,2003 \
51.344 + ,2005 \
51.345 + ,2004 \
51.346 + ,2002 \
51.347 + ,2005 \
51.348 + ,2002 \
51.349 + ,2005 \
51.350 + ,2002 \
51.351 + /)
51.352 +
51.353 + field = (/"NEE Flux" \
51.354 + ,"Net Radiation" \
51.355 + ,"Latent Heat" \
51.356 + ,"Sensible Heat" \
51.357 + ,"GPP Flux" \
51.358 + ,"Respiration" \
51.359 + /)
51.360 +
51.361 + field_unit = (/"u mol/m2/s" \
51.362 + ,"W/m2" \
51.363 + ,"W/m2" \
51.364 + ,"W/m2" \
51.365 + ,"u mol/m2/s" \
51.366 + ,"u mol/m2/s" \
51.367 + /)
51.368 +
51.369 + nstation = dimsizes(station)
51.370 + nfield = dimsizes(field)
51.371 +;-------------------------------------------------
51.372 +; get ob data
51.373 +
51.374 + nmon = 12
51.375 +
51.376 + data_ob = new ((/nstation, nfield, nmon/),float)
51.377 + lat_ob = new ((/nstation/),float)
51.378 + lon_ob = new ((/nstation/),float)
51.379 +
51.380 + diro_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
51.381 +
51.382 + do n = 0,nstation-1
51.383 +
51.384 + diro = diro_root + station(n)+"/"
51.385 + filo = year_ob_i(n)+"-"+year_ob_f(n)+"_L4_m.nc"
51.386 + fo = addfile (diro+filo,"r")
51.387 +
51.388 + print (filo)
51.389 +
51.390 + lon_ob(n) = fo->lon
51.391 + lat_ob(n) = fo->lat
51.392 +
51.393 + data = fo->NEE_or_fMDS
51.394 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
51.395 +
51.396 + data = fo->Rg_f
51.397 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
51.398 +
51.399 + data = fo->LE_f
51.400 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
51.401 +
51.402 + data = fo->H_f
51.403 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
51.404 +
51.405 + data = fo->GPP_or_MDS
51.406 + data_ob(n,4,:) = dim_avg(data(month|:,year|:))
51.407 +
51.408 + data = fo->Reco_or
51.409 + data_ob(n,5,:) = dim_avg(data(month|:,year|:))
51.410 +
51.411 + delete (data)
51.412 + delete (fo)
51.413 +
51.414 + end do
51.415 +
51.416 +;---------------------------------------------------
51.417 +; get model data
51.418 +
51.419 + dirm_root = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
51.420 + film = model_name+"_"+"1990-2004"+"_MONS_climo.nc"
51.421 + fm = addfile (dirm_root+film,"r")
51.422 +
51.423 +; print (film)
51.424 +
51.425 +; change to unit of observed (u mol/m2/s)
51.426 +; Model_units [=] gC/m2/s
51.427 +; 12. = molecular weight of C
51.428 +; u mol = 1e-6 mol
51.429 + factor = 1e6 /12.
51.430 +
51.431 + ENERGY ="new"
51.432 +
51.433 + xm = fm->lon
51.434 + ym = fm->lat
51.435 +
51.436 + nlat = dimsizes(ym)
51.437 + nlon = dimsizes(xm)
51.438 +
51.439 + data_mod0 = new ((/nfield, nmon, nlat, nlon/),float)
51.440 + data_mod = new ((/nstation, nfield, nmon/),float)
51.441 +
51.442 +if (ENERGY .eq. "old") then
51.443 +
51.444 + data = fm->NEE
51.445 + data_mod0(0,:,:,:) = data(:,:,:) * factor
51.446 +
51.447 +; data = fm->LATENT
51.448 + data1 = fm->FCEV
51.449 + data2 = fm->FCTR
51.450 + data3 = fm->FGEV
51.451 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
51.452 + delete (data1)
51.453 + delete (data2)
51.454 + delete (data3)
51.455 +
51.456 +; data = fm->SENSIBLE
51.457 + data = fm->FSH
51.458 + data_mod0(3,:,:,:) = data(:,:,:)
51.459 +
51.460 +; data = fm->NETRAD
51.461 + data1 = fm->FSA
51.462 + data2 = fm->FIRA
51.463 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)
51.464 + delete (data1)
51.465 + delete (data2)
51.466 +
51.467 +else
51.468 +
51.469 + data = fm->NEE
51.470 + data_mod0(0,:,:,:) = data(:,:,:) * factor
51.471 +
51.472 + data = fm->NETRAD
51.473 + data_mod0(1,:,:,:) = data(:,:,:)
51.474 +
51.475 + data = fm->LATENT
51.476 + data_mod0(2,:,:,:) = data(:,:,:)
51.477 +
51.478 +; data = fm->SENSIBLE
51.479 + data = fm->FSH
51.480 + data_mod0(3,:,:,:) = data(:,:,:)
51.481 +end if
51.482 +
51.483 + data = fm->GPP
51.484 + data_mod0(4,:,:,:) = data(:,:,:) * factor
51.485 +
51.486 + if (model .eq. "cn") then
51.487 + data = fm->ER
51.488 + else
51.489 + data1 = fm->AR
51.490 + data2 = fm->HR
51.491 + data = data1 + data2
51.492 +
51.493 + delete (data1)
51.494 + delete (data2)
51.495 + end if
51.496 +
51.497 + data_mod0(5,:,:,:) = data(:,:,:) * factor
51.498 +
51.499 + delete (data)
51.500 + delete (fm)
51.501 +
51.502 +;************************************************************
51.503 +; interpolate model data into observed station
51.504 +; note: model is 0-360E, 90S-90N
51.505 +;************************************************************
51.506 +
51.507 +; to be able to handle observation at (-89.98,-24.80)
51.508 + ym(0) = -90.
51.509 +
51.510 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob,lat_ob,0)
51.511 +
51.512 +; print (yy)
51.513 +
51.514 + do n = 0, nstation-1
51.515 + data_mod(n,:,:) = yy(:,:,n)
51.516 + end do
51.517 +
51.518 + delete (data_mod0)
51.519 + delete (yy)
51.520 +
51.521 +;************************************************************
51.522 +; compute correlation coef and M score
51.523 +;************************************************************
51.524 +
51.525 + score_max = 5.
51.526 +
51.527 + ccr = new ((/nstation, nfield/),float)
51.528 + M_score = new ((/nstation, nfield/),float)
51.529 +
51.530 + do n=0,nstation-1
51.531 + do m=0,nfield-1
51.532 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
51.533 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
51.534 + M_score(n,m) = (1. -(bias/nmon)) * score_max
51.535 + end do
51.536 + end do
51.537 +
51.538 + M_co2 = avg(M_score(:,0))
51.539 + M_rad = avg(M_score(:,1))
51.540 + M_lh = avg(M_score(:,2))
51.541 + M_sh = avg(M_score(:,3))
51.542 + M_gpp = avg(M_score(:,4))
51.543 + M_er = avg(M_score(:,5))
51.544 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
51.545 +
51.546 + M_energy_co2 = sprintf("%.2f", M_co2)
51.547 + M_energy_rad = sprintf("%.2f", M_rad)
51.548 + M_energy_lh = sprintf("%.2f", M_lh )
51.549 + M_energy_sh = sprintf("%.2f", M_sh )
51.550 + M_energy_gpp = sprintf("%.2f", M_gpp)
51.551 + M_energy_er = sprintf("%.2f", M_er )
51.552 + M_energy_all = sprintf("%.2f", M_all)
51.553 +
51.554 +;*******************************************************************
51.555 +; for station line plot
51.556 +;*******************************************************************
51.557 +
51.558 +; for x-axis in xyplot
51.559 + mon = ispan(1,12,1)
51.560 + mon@long_name = "month"
51.561 +
51.562 + res = True ; plot mods desired
51.563 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
51.564 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
51.565 +;-------------------------------------------------------------------------
51.566 +; Add a boxed legend using the more simple method
51.567 +
51.568 + res@pmLegendDisplayMode = "Always"
51.569 +; res@pmLegendWidthF = 0.1
51.570 + res@pmLegendWidthF = 0.08
51.571 + res@pmLegendHeightF = 0.06
51.572 +; res@pmLegendOrthogonalPosF = -1.17
51.573 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
51.574 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
51.575 +
51.576 +; res@pmLegendParallelPosF = 0.18
51.577 + res@pmLegendParallelPosF = 0.23 ;(rightward)
51.578 +
51.579 +; res@lgPerimOn = False
51.580 + res@lgLabelFontHeightF = 0.015
51.581 + res@xyExplicitLegendLabels = (/"observed",model_name/)
51.582 +;-------------------------------------------------------------------
51.583 +; for panel plot
51.584 + res@gsnFrame = False ; Do not draw plot
51.585 + res@gsnDraw = False ; Do not advance frame
51.586 +
51.587 + pres = True ; panel plot mods desired
51.588 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
51.589 + ; indiv. plots in panel
51.590 + pres@gsnMaximize = True ; fill the page
51.591 +;-------------------------------------------------------------------
51.592 +
51.593 + plot_data = new((/2,12/),float)
51.594 + plot_data!0 = "case"
51.595 + plot_data!1 = "month"
51.596 +
51.597 + do n = 0,nstation-1
51.598 +;----------------------------
51.599 +; for observed
51.600 +
51.601 + plot_name = station(n)+"_ob"
51.602 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
51.603 + res@tiMainString = title
51.604 +
51.605 + wks = gsn_open_wks (plot_type,plot_name)
51.606 + plot=new(nfield,graphic) ; create graphic array
51.607 +
51.608 + do i = 0,nfield-1
51.609 + plot_data(0,:) = (/data_ob (n,i,:)/)
51.610 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
51.611 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
51.612 + end do
51.613 +
51.614 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
51.615 +
51.616 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
51.617 + "rm "+plot_name+"."+plot_type)
51.618 +
51.619 + clear (wks)
51.620 + delete (plot)
51.621 +;----------------------------
51.622 +; for model_vs_ob
51.623 +
51.624 + plot_name = station(n)+"_model_vs_ob"
51.625 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
51.626 + res@tiMainString = title
51.627 +
51.628 + wks = gsn_open_wks (plot_type,plot_name)
51.629 + plot=new(nfield,graphic) ; create graphic array
51.630 +
51.631 + do i = 0,nfield-1
51.632 + plot_data(0,:) = (/data_ob (n,i,:)/)
51.633 + plot_data(1,:) = (/data_mod(n,i,:)/)
51.634 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
51.635 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
51.636 + end do
51.637 +
51.638 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
51.639 +
51.640 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
51.641 + "rm "+plot_name+"."+plot_type)
51.642 +
51.643 + clear (wks)
51.644 + delete (plot)
51.645 + end do
51.646 +
51.647 +;###################################################################
51.648 +; for the following tables,
51.649 +; sort by latitude in decending order (N->S)
51.650 +; sort by lat in decending order (N->S)
51.651 +
51.652 + isort = dim_pqsort(lat_ob,-1)
51.653 +
51.654 + station_sort = station(isort)
51.655 + lat_ob_sort = lat_ob(isort)
51.656 + lon_ob_sort = lon_ob(isort)
51.657 + year_ob_sort = year_ob(isort)
51.658 + M_score_sort = M_score(isort,:)
51.659 +
51.660 + print(isort)
51.661 + print(lat_ob_sort)
51.662 +;###################################################################
51.663 +;*******************************************************************
51.664 +; html table of site: observed
51.665 +;*******************************************************************
51.666 + output_html = "line_ob.html"
51.667 +
51.668 + header = (/"<HTML>" \
51.669 + ,"<HEAD>" \
51.670 + ,"<TITLE>CLAMP metrics</TITLE>" \
51.671 + ,"</HEAD>" \
51.672 + ,"<H1>Energy at Site: Observation</H1>" \
51.673 + /)
51.674 + footer = "</HTML>"
51.675 +
51.676 + table_header = (/ \
51.677 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
51.678 + ,"<tr>" \
51.679 + ," <th bgcolor=DDDDDD >Site Name</th>" \
51.680 + ," <th bgcolor=DDDDDD >Latitude</th>" \
51.681 + ," <th bgcolor=DDDDDD >Longitude</th>" \
51.682 + ," <th bgcolor=DDDDDD >Observed</th>" \
51.683 + ,"</tr>" \
51.684 + /)
51.685 + table_footer = "</table>"
51.686 + row_header = "<tr>"
51.687 + row_footer = "</tr>"
51.688 +
51.689 + lines = new(50000,string)
51.690 + nline = 0
51.691 +
51.692 + set_line(lines,nline,header)
51.693 + set_line(lines,nline,table_header)
51.694 +;-----------------------------------------------
51.695 +; row of table
51.696 +
51.697 + do n = 0,nstation-1
51.698 + set_line(lines,nline,row_header)
51.699 +
51.700 + txt0 = station_sort(n)
51.701 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
51.702 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
51.703 + txt3 = year_ob_sort(n)
51.704 +
51.705 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
51.706 + set_line(lines,nline,"<th>"+txt1+"</th>")
51.707 + set_line(lines,nline,"<th>"+txt2+"</th>")
51.708 + set_line(lines,nline,"<th>"+txt3+"</th>")
51.709 +
51.710 + set_line(lines,nline,row_footer)
51.711 + end do
51.712 +;-----------------------------------------------
51.713 + set_line(lines,nline,table_footer)
51.714 + set_line(lines,nline,footer)
51.715 +
51.716 +; Now write to an HTML file.
51.717 + idx = ind(.not.ismissing(lines))
51.718 + if(.not.any(ismissing(idx))) then
51.719 + asciiwrite(output_html,lines(idx))
51.720 + else
51.721 + print ("error?")
51.722 + end if
51.723 + delete (idx)
51.724 +
51.725 +;*******************************************************************
51.726 +; score and line table : model vs observed
51.727 +;*******************************************************************
51.728 + output_html = "score+line_vs_ob.html"
51.729 +
51.730 + header = (/"<HTML>" \
51.731 + ,"<HEAD>" \
51.732 + ,"<TITLE>CLAMP metrics</TITLE>" \
51.733 + ,"</HEAD>" \
51.734 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
51.735 + /)
51.736 + footer = "</HTML>"
51.737 +
51.738 + delete (table_header)
51.739 + table_header = (/ \
51.740 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
51.741 + ,"<tr>" \
51.742 + ," <th bgcolor=DDDDDD >Site Name</th>" \
51.743 + ," <th bgcolor=DDDDDD >Latitude</th>" \
51.744 + ," <th bgcolor=DDDDDD >Longitude</th>" \
51.745 + ," <th bgcolor=DDDDDD >Observed</th>" \
51.746 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
51.747 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
51.748 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
51.749 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
51.750 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
51.751 + ," <th bgcolor=DDDDDD >Respiration</th>" \
51.752 + ," <th bgcolor=DDDDDD >Average</th>" \
51.753 + ,"</tr>" \
51.754 + /)
51.755 + table_footer = "</table>"
51.756 + row_header = "<tr>"
51.757 + row_footer = "</tr>"
51.758 +
51.759 + lines = new(50000,string)
51.760 + nline = 0
51.761 +
51.762 + set_line(lines,nline,header)
51.763 + set_line(lines,nline,table_header)
51.764 +;-----------------------------------------------
51.765 +; row of table
51.766 +
51.767 + do n = 0,nstation-1
51.768 + set_line(lines,nline,row_header)
51.769 +
51.770 + txt0 = station_sort(n)
51.771 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
51.772 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
51.773 + txt3 = year_ob_sort(n)
51.774 + txt4 = sprintf("%5.2f", M_score_sort(n,0))
51.775 + txt5 = sprintf("%5.2f", M_score_sort(n,1))
51.776 + txt6 = sprintf("%5.2f", M_score_sort(n,2))
51.777 + txt7 = sprintf("%5.2f", M_score_sort(n,3))
51.778 + txt8 = sprintf("%5.2f", M_score_sort(n,4))
51.779 + txt9 = sprintf("%5.2f", M_score_sort(n,5))
51.780 + txt10 = sprintf("%5.2f", avg(M_score_sort(n,:)))
51.781 +
51.782 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
51.783 + set_line(lines,nline,"<th>"+txt1+"</th>")
51.784 + set_line(lines,nline,"<th>"+txt2+"</th>")
51.785 + set_line(lines,nline,"<th>"+txt3+"</th>")
51.786 + set_line(lines,nline,"<th>"+txt4+"</th>")
51.787 + set_line(lines,nline,"<th>"+txt5+"</th>")
51.788 + set_line(lines,nline,"<th>"+txt6+"</th>")
51.789 + set_line(lines,nline,"<th>"+txt7+"</th>")
51.790 + set_line(lines,nline,"<th>"+txt8+"</th>")
51.791 + set_line(lines,nline,"<th>"+txt9+"</th>")
51.792 + set_line(lines,nline,"<th>"+txt10+"</th>")
51.793 +
51.794 + set_line(lines,nline,row_footer)
51.795 + end do
51.796 +
51.797 +; last row, summary
51.798 + set_line(lines,nline,row_header)
51.799 +
51.800 + txt0 = "All_"+sprintf("%.0f", nstation)
51.801 + txt1 = "-"
51.802 + txt2 = "-"
51.803 + txt3 = "-"
51.804 + txt4 = M_energy_co2
51.805 + txt5 = M_energy_rad
51.806 + txt6 = M_energy_lh
51.807 + txt7 = M_energy_sh
51.808 + txt8 = M_energy_gpp
51.809 + txt9 = M_energy_er
51.810 + txt10 = M_energy_all
51.811 +
51.812 + set_line(lines,nline,"<th>"+txt0+"</th>")
51.813 + set_line(lines,nline,"<th>"+txt1+"</th>")
51.814 + set_line(lines,nline,"<th>"+txt2+"</th>")
51.815 + set_line(lines,nline,"<th>"+txt3+"</th>")
51.816 + set_line(lines,nline,"<th>"+txt4+"</th>")
51.817 + set_line(lines,nline,"<th>"+txt5+"</th>")
51.818 + set_line(lines,nline,"<th>"+txt6+"</th>")
51.819 + set_line(lines,nline,"<th>"+txt7+"</th>")
51.820 + set_line(lines,nline,"<th>"+txt8+"</th>")
51.821 + set_line(lines,nline,"<th>"+txt9+"</th>")
51.822 + set_line(lines,nline,"<th>"+txt10+"</th>")
51.823 +
51.824 + set_line(lines,nline,row_footer)
51.825 +;-----------------------------------------------
51.826 + set_line(lines,nline,table_footer)
51.827 + set_line(lines,nline,footer)
51.828 +
51.829 +; Now write to an HTML file.
51.830 + idx = ind(.not.ismissing(lines))
51.831 + if(.not.any(ismissing(idx))) then
51.832 + asciiwrite(output_html,lines(idx))
51.833 + else
51.834 + print ("error?")
51.835 + end if
51.836 + delete (idx)
51.837 +
51.838 +;***************************************************************************
51.839 +; output plots
51.840 +;***************************************************************************
51.841 + output_dir = model_name+"/ameriflux"
51.842 +
51.843 + system("mv *.png *.html " + output_dir)
51.844 +;***************************************************************************
51.845 +end
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
52.2 +++ b/ameriflux/21.plot.ncl Mon Jan 26 22:08:20 2009 -0500
52.3 @@ -0,0 +1,602 @@
52.4 +;************************************************************
52.5 +; add table
52.6 +; add time series plot
52.7 +; sort by latitude in decending order (N->S)
52.8 +; find year_ob >= 4
52.9 +; add year_ob_i and year_ob_f
52.10 +; change long_name
52.11 +;************************************************************
52.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
52.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
52.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
52.15 +;************************************************************
52.16 +procedure set_line(lines:string,nline:integer,newlines:string)
52.17 +begin
52.18 +; add line to ascci/html file
52.19 +
52.20 + nnewlines = dimsizes(newlines)
52.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
52.22 + print("set_line: bad index, not setting anything.")
52.23 + return
52.24 + end if
52.25 + lines(nline:nline+nnewlines-1) = newlines
52.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
52.27 + nline = nline + nnewlines
52.28 + return
52.29 +end
52.30 +;*************************************************************
52.31 +begin
52.32 +
52.33 + plot_type = "ps"
52.34 + plot_type_new = "png"
52.35 +
52.36 +;************************************************
52.37 +; model data info
52.38 +;************************************************
52.39 + model = "cn"
52.40 +; model = "casa"
52.41 +
52.42 + model_name = "i01.10" + model
52.43 +
52.44 + ENERGY ="new"
52.45 +
52.46 +;************************************************
52.47 +; observed data info
52.48 +;************************************************
52.49 +
52.50 + station = (/"ARM_Oklahoma" \
52.51 + ,"ARM_Oklahoma_burn" \
52.52 + ,"ARM_Oklahoma_control" \
52.53 + ,"Atqasuk" \
52.54 + ,"Audubon" \
52.55 + ,"AustinCary" \
52.56 + ,"Bartlett" \
52.57 + ,"Bondville" \
52.58 + ,"Brookings" \
52.59 + ,"Donaldson" \
52.60 + ,"Duke_Forest_Hardwoods" \
52.61 + ,"Duke_Forest_Open_Field" \
52.62 + ,"Duke_Forest_Pine" \
52.63 + ,"Fermi_Ag" \
52.64 + ,"Fermi_Prairie" \
52.65 + ,"Flagstaff_Managed" \
52.66 + ,"Flagstaff_Unmanaged" \
52.67 + ,"Flagstaff_Wildfire" \
52.68 + ,"FortPeck" \
52.69 + ,"FreemanRanch_mesquite" \
52.70 + ,"Goodwin_Creek" \
52.71 + ,"HarvardForest" \
52.72 + ,"HarvardForestHemlock" \
52.73 + ,"HowlandForestMain" \
52.74 + ,"HowlandForestWest" \
52.75 + ,"Ivotuk" \
52.76 + ,"KendallGrasslands" \
52.77 + ,"KennedySpaceCenterPine" \
52.78 + ,"KennedySpaceCenterScrub" \
52.79 + ,"LittleProspect" \
52.80 + ,"LostCreek" \
52.81 + ,"Mead-irrigated" \
52.82 + ,"Mead-irrigated-rotation" \
52.83 + ,"Mead-rainfed" \
52.84 + ,"Metolius_2nd_YoungPonderosaPine" \
52.85 + ,"MetoliusEyerly" \
52.86 + ,"MetoliusIntermediatePine" \
52.87 + ,"MetoliusOldPonderosaPine" \
52.88 + ,"MissouriOzark" \
52.89 + ,"Mize" \
52.90 + ,"MorganMonroe" \
52.91 + ,"NiwotRidge" \
52.92 + ,"NorthCarolina_cc" \
52.93 + ,"NorthCarolina_lp" \
52.94 + ,"ParkFalls" \
52.95 + ,"Rayonier" \
52.96 + ,"SantaRita" \
52.97 + ,"SkyOaks_Old" \
52.98 + ,"SkyOaks_PostFire" \
52.99 + ,"SkyOaks_Young" \
52.100 + ,"SylvaniaWilderness" \
52.101 + ,"Toledo" \
52.102 + ,"Tonzi" \
52.103 + ,"UCI_1850" \
52.104 + ,"UCI_1930" \
52.105 + ,"UCI_1964" \
52.106 + ,"UCI_1964wet" \
52.107 + ,"UCI_1981" \
52.108 + ,"UCI_1989" \
52.109 + ,"UCI_1998" \
52.110 + ,"UMBS" \
52.111 + ,"Vaira" \
52.112 + ,"WalkerBranch" \
52.113 + ,"WillowCreek" \
52.114 + ,"WindRiver" \
52.115 + ,"Wisconsin_ihw" \
52.116 + ,"Wisconsin_irp" \
52.117 + ,"Wisconsin_mrp" \
52.118 + ,"Wisconsin_myjp" \
52.119 + ,"Wisconsin_pb" \
52.120 + ,"Wisconsin_rpcc" \
52.121 + ,"Wisconsin_yhw" \
52.122 + ,"Wisconsin_yjp" \
52.123 + ,"Wisconsin_yrp" \
52.124 + /)
52.125 +
52.126 + year_ob = (/"2003-2006" \
52.127 + ,"2005-2006" \
52.128 + ,"2005-2006" \
52.129 + ,"1999-2006" \
52.130 + ,"2002-2006" \
52.131 + ,"2000-2005" \
52.132 + ,"2004-2005" \
52.133 + ,"1996-2006" \
52.134 + ,"2004-2006" \
52.135 + ,"1999-2004" \
52.136 + ,"2003-2005" \
52.137 + ,"2001-2005" \
52.138 + ,"2001-2005" \
52.139 + ,"2005-2006" \
52.140 + ,"2004-2006" \
52.141 + ,"2005-2006" \
52.142 + ,"2005-2006" \
52.143 + ,"2005-2006" \
52.144 + ,"2000-2006" \
52.145 + ,"2004-2006" \
52.146 + ,"2002-2006" \
52.147 + ,"1991-2004" \
52.148 + ,"2004-2004" \
52.149 + ,"1996-2004" \
52.150 + ,"1999-2004" \
52.151 + ,"2003-2006" \
52.152 + ,"2004-2006" \
52.153 + ,"2002-2002" \
52.154 + ,"2000-2006" \
52.155 + ,"2002-2005" \
52.156 + ,"2001-2005" \
52.157 + ,"2001-2005" \
52.158 + ,"2001-2005" \
52.159 + ,"2001-2005" \
52.160 + ,"2004-2005" \
52.161 + ,"2004-2005" \
52.162 + ,"2003-2005" \
52.163 + ,"1996-2000" \
52.164 + ,"2004-2006" \
52.165 + ,"1998-2004" \
52.166 + ,"1999-2005" \
52.167 + ,"1999-2003" \
52.168 + ,"2005-2006" \
52.169 + ,"2005-2006" \
52.170 + ,"1996-2003" \
52.171 + ,"1998-1998" \
52.172 + ,"2004-2006" \
52.173 + ,"1997-2006" \
52.174 + ,"2004-2006" \
52.175 + ,"1997-2006" \
52.176 + ,"2002-2006" \
52.177 + ,"2004-2005" \
52.178 + ,"2001-2006" \
52.179 + ,"2004-2005" \
52.180 + ,"2001-2005" \
52.181 + ,"2001-2005" \
52.182 + ,"2002-2004" \
52.183 + ,"2001-2005" \
52.184 + ,"2001-2005" \
52.185 + ,"2002-2005" \
52.186 + ,"1999-2003" \
52.187 + ,"2001-2006" \
52.188 + ,"1995-1999" \
52.189 + ,"1999-2005" \
52.190 + ,"1999-2004" \
52.191 + ,"2003-2003" \
52.192 + ,"2003-2003" \
52.193 + ,"2002-2005" \
52.194 + ,"2004-2004" \
52.195 + ,"2002-2002" \
52.196 + ,"2005-2005" \
52.197 + ,"2002-2002" \
52.198 + ,"2004-2005" \
52.199 + ,"2002-2002" \
52.200 + /)
52.201 +
52.202 + field = (/"NEE Flux" \
52.203 + ,"Net Radiation" \
52.204 + ,"Latent Heat" \
52.205 + ,"Sensible Heat" \
52.206 + ,"GPP Flux" \
52.207 + ,"Respiration" \
52.208 + /)
52.209 +
52.210 + field_unit = (/"u mol/m2/s" \
52.211 + ,"W/m2" \
52.212 + ,"W/m2" \
52.213 + ,"W/m2" \
52.214 + ,"u mol/m2/s" \
52.215 + ,"u mol/m2/s" \
52.216 + /)
52.217 +
52.218 + nstation = dimsizes(station)
52.219 + nfield = dimsizes(field)
52.220 +
52.221 +;========================================================================
52.222 +; get observed info: number of year, first/last year, lat, lon
52.223 +
52.224 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
52.225 +
52.226 + year_station = new ((/nstation/),integer) ; number of year
52.227 + year_ob_i = new ((/nstation/),integer) ; first year
52.228 + year_ob_f = new ((/nstation/),integer) ; last year
52.229 + lat_ob = new ((/nstation/),float) ; latitude
52.230 + lon_ob = new ((/nstation/),float) ; longitude
52.231 +
52.232 + do n = 0, nstation-1
52.233 +
52.234 + diro = dir_root + station(n)+"/"
52.235 + filo = year_ob(n)+"_L4_m.nc"
52.236 + fo = addfile (diro+filo,"r")
52.237 +
52.238 + lat_ob(n) = fo->lat
52.239 + lon_ob(n) = fo->lon
52.240 +
52.241 + year = fo->year
52.242 +
52.243 + year_station(n) = dimsizes(year)
52.244 + year_ob_i(n) = year(0)
52.245 + year_ob_f(n) = year(year_station(n)-1)
52.246 +
52.247 + delete (year)
52.248 +
52.249 + end do
52.250 +
52.251 + delete (fo)
52.252 +;print (year_ob_i)
52.253 +;print (year_ob_f)
52.254 +
52.255 +;--------------------------------------------------------------
52.256 +; find (# of year observed) >=4 and year_ob_i <= 2001
52.257 +
52.258 + i_long_ob = ind(year_station .ge. 4 .and. year_ob_i .le. 2001)
52.259 +
52.260 + station_long = station(i_long_ob)
52.261 + lat_ob_long = lat_ob(i_long_ob)
52.262 + lon_ob_long = lat_ob(i_long_ob)
52.263 + year_ob_long = year_ob(i_long_ob)
52.264 + year_ob_i_long = year_ob_i(i_long_ob)
52.265 + year_ob_f_long = year_ob_f(i_long_ob)
52.266 + year_station_long = year_station(i_long_ob)
52.267 +
52.268 + nstation_long = dimsizes(station_long)
52.269 +
52.270 +; print (i_long_ob)
52.271 +; print (nstation_long)
52.272 +; print (station_long)
52.273 +; print (year_ob_i(i_long_ob))
52.274 +
52.275 +;=========================================================
52.276 +; get model data at observed lat-lon
52.277 +
52.278 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
52.279 + film = model_name+"_ameriflux_1990-2004_monthly.nc"
52.280 + fm = addfile (dirm+film,"r")
52.281 +
52.282 + xm = fm->lon
52.283 + ym = fm->lat
52.284 + date = fm->date
52.285 +
52.286 + date_dim = dimsizes(date)
52.287 + nyear = date_dim(0)
52.288 +
52.289 + nmonth =12
52.290 +
52.291 + data_mod = new ((/nfield,nyear,nmonth,nstation/),float)
52.292 + data_mod_ann = new ((/nfield,nmonth,nstation/),float)
52.293 + data_mod_long = new ((/nfield,nyear,nmonth,nstation_long/),float)
52.294 +
52.295 +; change to unit of observed (u mol/m2/s)
52.296 +; Model_units [=] gC/m2/s
52.297 +; 12. = molecular weight of C
52.298 +; u mol = 1e-6 mol
52.299 +
52.300 + factor = 1.e6 /12.
52.301 +
52.302 +;------------------------------------------------------------
52.303 +; interpolate model data into observed station
52.304 +; note: model is 0-360E, 90S-90N
52.305 +
52.306 +; to be able to handle observation at (-89.98,-24.80)
52.307 + ym(0) = -90.
52.308 +;------------------------------------------------------------
52.309 +
52.310 +if (ENERGY .eq. "old") then
52.311 +
52.312 + data = fm->NEE
52.313 + data_mod(0,:,:,:) = data(:,:,:) * factor
52.314 +
52.315 +; data = fm->LATENT
52.316 + data1 = fm->FCEV
52.317 + data2 = fm->FCTR
52.318 + data3 = fm->FGEV
52.319 + data_mod(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
52.320 + delete (data1)
52.321 + delete (data2)
52.322 + delete (data3)
52.323 +
52.324 +; data = fm->SENSIBLE
52.325 + data = fm->FSH
52.326 + data_mod(3,:,:,:) = data(:,:,:)
52.327 +
52.328 +; data = fm->NETRAD
52.329 + data1 = fm->FSA
52.330 + data2 = fm->FIRA
52.331 + data_mod(1,:,:,:) = data1(:,:,:)-data2(:,:,:)
52.332 + delete (data1)
52.333 + delete (data2)
52.334 +
52.335 +else
52.336 +
52.337 + data = fm->NEE
52.338 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
52.339 + data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
52.340 + data_mod(0,:,:,:) = yy(:,:,:) * factor
52.341 +
52.342 +; printVarSummary(yy)
52.343 +
52.344 + data = fm->NETRAD
52.345 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
52.346 + data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:))
52.347 + data_mod(1,:,:,:) = yy(:,:,:)
52.348 +
52.349 + data = fm->LATENT
52.350 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
52.351 + data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:))
52.352 + data_mod(2,:,:,:) = yy(:,:,:)
52.353 +
52.354 +; data = fm->SENSIBLE
52.355 + data = fm->FSH
52.356 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
52.357 + data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:))
52.358 + data_mod(3,:,:,:) = yy(:,:,:)
52.359 +
52.360 +end if
52.361 +
52.362 + data = fm->GPP
52.363 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
52.364 + data_mod_ann(4,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
52.365 + data_mod(4,:,:,:) = yy(:,:,:) * factor
52.366 +
52.367 + if (model .eq. "cn") then
52.368 + data = fm->ER
52.369 + else
52.370 + data1 = fm->AR
52.371 + data2 = fm->HR
52.372 + data = data1 + data2
52.373 +
52.374 + delete (data1)
52.375 + delete (data2)
52.376 + end if
52.377 +
52.378 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
52.379 + data_mod_ann(5,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
52.380 + data_mod(5,:,:,:) = yy(:,:,:) * factor
52.381 +
52.382 + data_mod_long(:,:,:,:) = data_mod(:,:,:,i_long_ob)
52.383 +
52.384 + delete (data_mod)
52.385 + delete (fm)
52.386 + delete (data)
52.387 + delete (yy)
52.388 +
52.389 +;*******************************************************************
52.390 +; for station line plot
52.391 +;*******************************************************************
52.392 +
52.393 +; for x-axis in xyplot
52.394 + mon = ispan(1,12,1)
52.395 + mon@long_name = "month"
52.396 +
52.397 + res = True ; plot mods desired
52.398 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
52.399 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
52.400 +
52.401 + res@tmXBFormat = "f" ; not to add trailing zeros
52.402 +
52.403 +;-------------------------------------------------------------------------
52.404 +; Add a boxed legend using the more simple method
52.405 +
52.406 + res@pmLegendDisplayMode = "Always"
52.407 +; res@pmLegendWidthF = 0.1
52.408 + res@pmLegendWidthF = 0.08
52.409 + res@pmLegendHeightF = 0.06
52.410 +; res@pmLegendOrthogonalPosF = -1.17
52.411 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
52.412 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
52.413 +
52.414 +; res@pmLegendParallelPosF = 0.18
52.415 + res@pmLegendParallelPosF = 0.23 ;(rightward)
52.416 +
52.417 +; res@lgPerimOn = False
52.418 + res@lgLabelFontHeightF = 0.015
52.419 + res@xyExplicitLegendLabels = (/"observed",model_name/)
52.420 +;-------------------------------------------------------------------
52.421 +; for panel plot
52.422 + res@gsnFrame = False ; Do not draw plot
52.423 + res@gsnDraw = False ; Do not advance frame
52.424 +
52.425 + pres = True ; panel plot mods desired
52.426 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
52.427 + ; indiv. plots in panel
52.428 + pres@gsnMaximize = True ; fill the page
52.429 +;-------------------------------------------------------------------
52.430 +
52.431 +;==============================================================
52.432 +; get ob data at each site with long observation
52.433 +
52.434 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
52.435 +
52.436 + do n = 0,nstation_long-1
52.437 +; do n = 0,0
52.438 +
52.439 + year_setback = 0
52.440 +
52.441 + nyear = year_station_long(n)
52.442 +
52.443 + if (year_ob_f_long(n).eq. 2006) then
52.444 + year_setback = 2006 -2004
52.445 + end if
52.446 + if (year_ob_f_long(n).eq. 2005) then
52.447 + year_setback = 2005 -2004
52.448 + end if
52.449 +
52.450 + ntime = (nyear - year_setback) * nmonth
52.451 + print (nyear)
52.452 +
52.453 + data_ob = new ((/nfield, nyear, nmonth/),float)
52.454 +
52.455 + diro = dir_root + station_long(n)+"/"
52.456 + filo = year_ob_long(n)+"_L4_m.nc"
52.457 + fo = addfile (diro+filo,"r")
52.458 +
52.459 +; print (diro)
52.460 +; print (filo)
52.461 +
52.462 + data_ob(0,:,:) = fo->NEE_or_fMDS
52.463 + data_ob(1,:,:) = fo->Rg_f
52.464 + data_ob(2,:,:) = fo->LE_f
52.465 + data_ob(3,:,:) = fo->H_f
52.466 + data_ob(4,:,:) = fo->GPP_or_MDS
52.467 + data_ob(5,:,:) = fo->Reco_or
52.468 +
52.469 + delete (fo)
52.470 +
52.471 + timeI = new((/ntime/),integer)
52.472 + timeF = new((/ntime/),float)
52.473 + timeI = ispan(1,ntime,1)
52.474 + timeF = year_ob_i_long(n) + (timeI-1)/12.
52.475 + timeF@long_name = "year"
52.476 +
52.477 + plot_data = new((/2,ntime/),float)
52.478 +
52.479 +;----------------------------
52.480 +; for model_vs_ob
52.481 +
52.482 + plot_name = station_long(n)+"_tseries_vs_ob"
52.483 + title = station_long(n)+"("+sprintf("%5.2f",lat_ob_long(n))+","+sprintf("%5.2f",lon_ob_long(n))+")"
52.484 + res@tiMainString = title
52.485 +
52.486 + wks = gsn_open_wks (plot_type,plot_name)
52.487 + plot=new(nfield,graphic) ; create graphic array
52.488 +
52.489 + i_year_mod_i = year_ob_i_long(n) - 1990
52.490 + i_year_mod_f = i_year_mod_i + nyear - 1 - year_setback
52.491 +
52.492 + i_year_ob_f = nyear - year_setback - 1
52.493 +
52.494 +; print (nyear)
52.495 +; print (i_year_ob_f)
52.496 +; print (i_year_mod_i)
52.497 +; print (i_year_mod_f)
52.498 +
52.499 + do i = 0,nfield-1
52.500 + plot_data(0,:) = ndtooned(data_ob (i,0:i_year_ob_f,:))
52.501 + plot_data(1,:) = ndtooned(data_mod_long(i,i_year_mod_i:i_year_mod_f,:,n))
52.502 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
52.503 + plot(i)=gsn_csm_xy(wks,timeF,plot_data,res) ; create plot
52.504 + end do
52.505 +
52.506 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
52.507 +
52.508 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
52.509 + "rm "+plot_name+"."+plot_type)
52.510 +
52.511 + clear (wks)
52.512 + delete (plot)
52.513 +
52.514 + delete (data_ob)
52.515 + delete (timeI)
52.516 + delete (timeF)
52.517 + delete (plot_data)
52.518 +
52.519 + end do
52.520 +
52.521 +;###################################################################
52.522 +; for the following tables,
52.523 +; sort by latitude in decending order (N->S)
52.524 +
52.525 + isort = dim_pqsort(lat_ob_long,-1)
52.526 +
52.527 + station_sort = station_long(isort)
52.528 + year_ob_sort = year_ob_long(isort)
52.529 + lat_ob_sort = lat_ob_long(isort)
52.530 + lon_ob_sort = lon_ob_long(isort)
52.531 +
52.532 +; print(isort)
52.533 +; print(lat_ob_sort)
52.534 +
52.535 +;*******************************************************************
52.536 +; html table of site: observed
52.537 +;*******************************************************************
52.538 + output_html = "tseries_vs_ob.html"
52.539 +
52.540 + header = (/"<HTML>" \
52.541 + ,"<HEAD>" \
52.542 + ,"<TITLE>CLAMP metrics</TITLE>" \
52.543 + ,"</HEAD>" \
52.544 + ,"<H1>Timeseries at Site: "+model_name+" vs Observation</H1>" \
52.545 + /)
52.546 + footer = "</HTML>"
52.547 +
52.548 + table_header = (/ \
52.549 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
52.550 + ,"<tr>" \
52.551 + ," <th bgcolor=DDDDDD >Site Name</th>" \
52.552 + ," <th bgcolor=DDDDDD >Latitude</th>" \
52.553 + ," <th bgcolor=DDDDDD >Longitude</th>" \
52.554 + ," <th bgcolor=DDDDDD >Observed</th>" \
52.555 + ,"</tr>" \
52.556 + /)
52.557 + table_footer = "</table>"
52.558 + row_header = "<tr>"
52.559 + row_footer = "</tr>"
52.560 +
52.561 + lines = new(50000,string)
52.562 + nline = 0
52.563 +
52.564 + set_line(lines,nline,header)
52.565 + set_line(lines,nline,table_header)
52.566 +;-----------------------------------------------
52.567 +; row of table
52.568 +
52.569 + do n = 0,nstation_long-1
52.570 +
52.571 + set_line(lines,nline,row_header)
52.572 +
52.573 + txt0 = station_sort(n)
52.574 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
52.575 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
52.576 + txt3 = year_ob_sort(n)
52.577 +
52.578 + set_line(lines,nline,"<th><a href="+txt0+"_tseries_vs_ob.png>"+txt0+"</a></th>")
52.579 + set_line(lines,nline,"<th>"+txt1+"</th>")
52.580 + set_line(lines,nline,"<th>"+txt2+"</th>")
52.581 + set_line(lines,nline,"<th>"+txt3+"</th>")
52.582 +
52.583 + set_line(lines,nline,row_footer)
52.584 + end do
52.585 +;-----------------------------------------------
52.586 + set_line(lines,nline,table_footer)
52.587 + set_line(lines,nline,footer)
52.588 +
52.589 +; Now write to an HTML file.
52.590 + idx = ind(.not.ismissing(lines))
52.591 + if(.not.any(ismissing(idx))) then
52.592 + asciiwrite(output_html,lines(idx))
52.593 + else
52.594 + print ("error?")
52.595 + end if
52.596 + delete (idx)
52.597 +
52.598 +;***************************************************************************
52.599 +; output plots
52.600 +;***************************************************************************
52.601 + output_dir = model_name+"/ameriflux"
52.602 +
52.603 + system("mv *.png *.html " + output_dir)
52.604 +;***************************************************************************
52.605 +end
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
53.2 +++ b/ameriflux/22.plot.ncl Mon Jan 26 22:08:20 2009 -0500
53.3 @@ -0,0 +1,919 @@
53.4 +;************************************************************
53.5 +; merge annual
53.6 +; add table
53.7 +; add time series plot
53.8 +; sort by latitude in decending order (N->S)
53.9 +; find year_ob >= 4
53.10 +; add year_ob_i and year_ob_f
53.11 +; change long_name
53.12 +;************************************************************
53.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
53.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
53.15 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
53.16 +;************************************************************
53.17 +procedure set_line(lines:string,nline:integer,newlines:string)
53.18 +begin
53.19 +; add line to ascci/html file
53.20 +
53.21 + nnewlines = dimsizes(newlines)
53.22 + if(nline+nnewlines-1.ge.dimsizes(lines))
53.23 + print("set_line: bad index, not setting anything.")
53.24 + return
53.25 + end if
53.26 + lines(nline:nline+nnewlines-1) = newlines
53.27 +; print ("lines = " + lines(nline:nline+nnewlines-1))
53.28 + nline = nline + nnewlines
53.29 + return
53.30 +end
53.31 +;*************************************************************
53.32 +begin
53.33 +
53.34 + plot_type = "ps"
53.35 + plot_type_new = "png"
53.36 +
53.37 +;************************************************
53.38 +; model data info
53.39 +;************************************************
53.40 + model = "cn"
53.41 +; model = "casa"
53.42 +
53.43 + model_name = "i01.10" + model
53.44 +
53.45 + ENERGY ="new"
53.46 +
53.47 + nmonth = 12
53.48 +
53.49 +;************************************************
53.50 +; observed data info
53.51 +;************************************************
53.52 +
53.53 + station = (/"ARM_Oklahoma" \
53.54 + ,"ARM_Oklahoma_burn" \
53.55 + ,"ARM_Oklahoma_control" \
53.56 + ,"Atqasuk" \
53.57 + ,"Audubon" \
53.58 + ,"AustinCary" \
53.59 + ,"Bartlett" \
53.60 + ,"Bondville" \
53.61 + ,"Brookings" \
53.62 + ,"Donaldson" \
53.63 + ,"Duke_Forest_Hardwoods" \
53.64 + ,"Duke_Forest_Open_Field" \
53.65 + ,"Duke_Forest_Pine" \
53.66 + ,"Fermi_Ag" \
53.67 + ,"Fermi_Prairie" \
53.68 + ,"Flagstaff_Managed" \
53.69 + ,"Flagstaff_Unmanaged" \
53.70 + ,"Flagstaff_Wildfire" \
53.71 + ,"FortPeck" \
53.72 + ,"FreemanRanch_mesquite" \
53.73 + ,"Goodwin_Creek" \
53.74 + ,"HarvardForest" \
53.75 + ,"HarvardForestHemlock" \
53.76 + ,"HowlandForestMain" \
53.77 + ,"HowlandForestWest" \
53.78 + ,"Ivotuk" \
53.79 + ,"KendallGrasslands" \
53.80 + ,"KennedySpaceCenterPine" \
53.81 + ,"KennedySpaceCenterScrub" \
53.82 + ,"LittleProspect" \
53.83 + ,"LostCreek" \
53.84 + ,"Mead-irrigated" \
53.85 + ,"Mead-irrigated-rotation" \
53.86 + ,"Mead-rainfed" \
53.87 + ,"Metolius_2nd_YoungPonderosaPine" \
53.88 + ,"MetoliusEyerly" \
53.89 + ,"MetoliusIntermediatePine" \
53.90 + ,"MetoliusOldPonderosaPine" \
53.91 + ,"MissouriOzark" \
53.92 + ,"Mize" \
53.93 + ,"MorganMonroe" \
53.94 + ,"NiwotRidge" \
53.95 + ,"NorthCarolina_cc" \
53.96 + ,"NorthCarolina_lp" \
53.97 + ,"ParkFalls" \
53.98 + ,"Rayonier" \
53.99 + ,"SantaRita" \
53.100 + ,"SkyOaks_Old" \
53.101 + ,"SkyOaks_PostFire" \
53.102 + ,"SkyOaks_Young" \
53.103 + ,"SylvaniaWilderness" \
53.104 + ,"Toledo" \
53.105 + ,"Tonzi" \
53.106 + ,"UCI_1850" \
53.107 + ,"UCI_1930" \
53.108 + ,"UCI_1964" \
53.109 + ,"UCI_1964wet" \
53.110 + ,"UCI_1981" \
53.111 + ,"UCI_1989" \
53.112 + ,"UCI_1998" \
53.113 + ,"UMBS" \
53.114 + ,"Vaira" \
53.115 + ,"WalkerBranch" \
53.116 + ,"WillowCreek" \
53.117 + ,"WindRiver" \
53.118 + ,"Wisconsin_ihw" \
53.119 + ,"Wisconsin_irp" \
53.120 + ,"Wisconsin_mrp" \
53.121 + ,"Wisconsin_myjp" \
53.122 + ,"Wisconsin_pb" \
53.123 + ,"Wisconsin_rpcc" \
53.124 + ,"Wisconsin_yhw" \
53.125 + ,"Wisconsin_yjp" \
53.126 + ,"Wisconsin_yrp" \
53.127 + /)
53.128 +
53.129 + year_ob = (/"2003-2006" \
53.130 + ,"2005-2006" \
53.131 + ,"2005-2006" \
53.132 + ,"1999-2006" \
53.133 + ,"2002-2006" \
53.134 + ,"2000-2005" \
53.135 + ,"2004-2005" \
53.136 + ,"1996-2006" \
53.137 + ,"2004-2006" \
53.138 + ,"1999-2004" \
53.139 + ,"2003-2005" \
53.140 + ,"2001-2005" \
53.141 + ,"2001-2005" \
53.142 + ,"2005-2006" \
53.143 + ,"2004-2006" \
53.144 + ,"2005-2006" \
53.145 + ,"2005-2006" \
53.146 + ,"2005-2006" \
53.147 + ,"2000-2006" \
53.148 + ,"2004-2006" \
53.149 + ,"2002-2006" \
53.150 + ,"1991-2004" \
53.151 + ,"2004-2004" \
53.152 + ,"1996-2004" \
53.153 + ,"1999-2004" \
53.154 + ,"2003-2006" \
53.155 + ,"2004-2006" \
53.156 + ,"2002-2002" \
53.157 + ,"2000-2006" \
53.158 + ,"2002-2005" \
53.159 + ,"2001-2005" \
53.160 + ,"2001-2005" \
53.161 + ,"2001-2005" \
53.162 + ,"2001-2005" \
53.163 + ,"2004-2005" \
53.164 + ,"2004-2005" \
53.165 + ,"2003-2005" \
53.166 + ,"1996-2000" \
53.167 + ,"2004-2006" \
53.168 + ,"1998-2004" \
53.169 + ,"1999-2005" \
53.170 + ,"1999-2003" \
53.171 + ,"2005-2006" \
53.172 + ,"2005-2006" \
53.173 + ,"1996-2003" \
53.174 + ,"1998-1998" \
53.175 + ,"2004-2006" \
53.176 + ,"1997-2006" \
53.177 + ,"2004-2006" \
53.178 + ,"1997-2006" \
53.179 + ,"2002-2006" \
53.180 + ,"2004-2005" \
53.181 + ,"2001-2006" \
53.182 + ,"2004-2005" \
53.183 + ,"2001-2005" \
53.184 + ,"2001-2005" \
53.185 + ,"2002-2004" \
53.186 + ,"2001-2005" \
53.187 + ,"2001-2005" \
53.188 + ,"2002-2005" \
53.189 + ,"1999-2003" \
53.190 + ,"2001-2006" \
53.191 + ,"1995-1999" \
53.192 + ,"1999-2005" \
53.193 + ,"1999-2004" \
53.194 + ,"2003-2003" \
53.195 + ,"2003-2003" \
53.196 + ,"2002-2005" \
53.197 + ,"2004-2004" \
53.198 + ,"2002-2002" \
53.199 + ,"2005-2005" \
53.200 + ,"2002-2002" \
53.201 + ,"2004-2005" \
53.202 + ,"2002-2002" \
53.203 + /)
53.204 +
53.205 + field = (/"NEE Flux" \
53.206 + ,"Net Radiation" \
53.207 + ,"Latent Heat" \
53.208 + ,"Sensible Heat" \
53.209 + ,"GPP Flux" \
53.210 + ,"Respiration" \
53.211 + /)
53.212 +
53.213 + field_unit = (/"u mol/m2/s" \
53.214 + ,"W/m2" \
53.215 + ,"W/m2" \
53.216 + ,"W/m2" \
53.217 + ,"u mol/m2/s" \
53.218 + ,"u mol/m2/s" \
53.219 + /)
53.220 +
53.221 + nstation = dimsizes(station)
53.222 + nfield = dimsizes(field)
53.223 +
53.224 +;========================================================================
53.225 +; get observed info: number of year, first/last year, lat, lon
53.226 +; and annual data
53.227 +
53.228 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
53.229 +
53.230 + year_station = new ((/nstation/),integer) ; number of year
53.231 + year_ob_i = new ((/nstation/),integer) ; first year
53.232 + year_ob_f = new ((/nstation/),integer) ; last year
53.233 + lat_ob = new ((/nstation/),float) ; latitude
53.234 + lon_ob = new ((/nstation/),float) ; longitude
53.235 +
53.236 + data_ob_ann = new ((/nfield, nmonth, nstation/),float)
53.237 +
53.238 + do n = 0, nstation-1
53.239 +
53.240 + diro = dir_root + station(n)+"/"
53.241 + filo = year_ob(n)+"_L4_m.nc"
53.242 + fo = addfile (diro+filo,"r")
53.243 +
53.244 + lat_ob(n) = fo->lat
53.245 + lon_ob(n) = fo->lon
53.246 +
53.247 + year = fo->year
53.248 +
53.249 + year_station(n) = dimsizes(year)
53.250 + year_ob_i(n) = year(0)
53.251 + year_ob_f(n) = year(year_station(n)-1)
53.252 +
53.253 + delete (year)
53.254 +
53.255 + data = fo->NEE_or_fMDS
53.256 + data_ob_ann(0,:,n) = dim_avg(data(month|:,year|:))
53.257 +
53.258 + data = fo->Rg_f
53.259 + data_ob_ann(1,:,n) = dim_avg(data(month|:,year|:))
53.260 +
53.261 + data = fo->LE_f
53.262 + data_ob_ann(2,:,n) = dim_avg(data(month|:,year|:))
53.263 +
53.264 + data = fo->H_f
53.265 + data_ob_ann(3,:,n) = dim_avg(data(month|:,year|:))
53.266 +
53.267 + data = fo->GPP_or_MDS
53.268 + data_ob_ann(4,:,n) = dim_avg(data(month|:,year|:))
53.269 +
53.270 + data = fo->Reco_or
53.271 + data_ob_ann(5,:,n) = dim_avg(data(month|:,year|:))
53.272 +
53.273 + delete (data)
53.274 + delete (fo)
53.275 + end do
53.276 +
53.277 +;print (year_ob_i)
53.278 +;print (year_ob_f)
53.279 +
53.280 +;--------------------------------------------------------------
53.281 +; find (# of year observed) >=4 and year_ob_i <= 2001
53.282 +
53.283 + i_long_ob = ind(year_station .ge. 4 .and. year_ob_i .le. 2001)
53.284 +
53.285 + station_long = station(i_long_ob)
53.286 + lat_ob_long = lat_ob(i_long_ob)
53.287 + lon_ob_long = lat_ob(i_long_ob)
53.288 + year_ob_long = year_ob(i_long_ob)
53.289 + year_ob_i_long = year_ob_i(i_long_ob)
53.290 + year_ob_f_long = year_ob_f(i_long_ob)
53.291 + year_station_long = year_station(i_long_ob)
53.292 +
53.293 + nstation_long = dimsizes(station_long)
53.294 +
53.295 +; print (i_long_ob)
53.296 +; print (nstation_long)
53.297 +; print (station_long)
53.298 +; print (year_ob_i(i_long_ob))
53.299 +
53.300 +;=========================================================
53.301 +; get model data at observed lat-lon
53.302 +
53.303 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
53.304 + film = model_name+"_ameriflux_1990-2004_monthly.nc"
53.305 + fm = addfile (dirm+film,"r")
53.306 +
53.307 + xm = fm->lon
53.308 + ym = fm->lat
53.309 + date = fm->date
53.310 +
53.311 + date_dim = dimsizes(date)
53.312 + nyear = date_dim(0)
53.313 +
53.314 + data_mod = new ((/nfield,nyear,nmonth,nstation/),float)
53.315 + data_mod_ann = new ((/nfield,nmonth,nstation/),float)
53.316 + data_mod_long = new ((/nfield,nyear,nmonth,nstation_long/),float)
53.317 +
53.318 +; change to unit of observed (u mol/m2/s)
53.319 +; Model_units [=] gC/m2/s
53.320 +; 12. = molecular weight of C
53.321 +; u mol = 1e-6 mol
53.322 +
53.323 + factor = 1.e6 /12.
53.324 +
53.325 +;------------------------------------------------------------
53.326 +; interpolate model data into observed station
53.327 +; note: model is 0-360E, 90S-90N
53.328 +
53.329 +; to be able to handle observation at (-89.98,-24.80)
53.330 + ym(0) = -90.
53.331 +;------------------------------------------------------------
53.332 +
53.333 +if (ENERGY .eq. "old") then
53.334 +
53.335 + data = fm->NEE
53.336 + data_mod(0,:,:,:) = data(:,:,:) * factor
53.337 +
53.338 +; data = fm->LATENT
53.339 + data1 = fm->FCEV
53.340 + data2 = fm->FCTR
53.341 + data3 = fm->FGEV
53.342 + data_mod(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
53.343 + delete (data1)
53.344 + delete (data2)
53.345 + delete (data3)
53.346 +
53.347 +; data = fm->SENSIBLE
53.348 + data = fm->FSH
53.349 + data_mod(3,:,:,:) = data(:,:,:)
53.350 +
53.351 +; data = fm->NETRAD
53.352 + data1 = fm->FSA
53.353 + data2 = fm->FIRA
53.354 + data_mod(1,:,:,:) = data1(:,:,:)-data2(:,:,:)
53.355 + delete (data1)
53.356 + delete (data2)
53.357 +
53.358 +else
53.359 +
53.360 + data = fm->NEE
53.361 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
53.362 + data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
53.363 + data_mod(0,:,:,:) = yy(:,:,:) * factor
53.364 +
53.365 +; printVarSummary(yy)
53.366 +
53.367 + data = fm->NETRAD
53.368 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
53.369 + data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:))
53.370 + data_mod(1,:,:,:) = yy(:,:,:)
53.371 +
53.372 + data = fm->LATENT
53.373 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
53.374 + data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:))
53.375 + data_mod(2,:,:,:) = yy(:,:,:)
53.376 +
53.377 +; data = fm->SENSIBLE
53.378 + data = fm->FSH
53.379 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
53.380 + data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:))
53.381 + data_mod(3,:,:,:) = yy(:,:,:)
53.382 +
53.383 +end if
53.384 +
53.385 + data = fm->GPP
53.386 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
53.387 + data_mod_ann(4,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
53.388 + data_mod(4,:,:,:) = yy(:,:,:) * factor
53.389 +
53.390 + if (model .eq. "cn") then
53.391 + data = fm->ER
53.392 + else
53.393 + data1 = fm->AR
53.394 + data2 = fm->HR
53.395 + data = data1 + data2
53.396 +
53.397 + delete (data1)
53.398 + delete (data2)
53.399 + end if
53.400 +
53.401 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
53.402 + data_mod_ann(5,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
53.403 + data_mod(5,:,:,:) = yy(:,:,:) * factor
53.404 +
53.405 + data_mod_long(:,:,:,:) = data_mod(:,:,:,i_long_ob)
53.406 +
53.407 + delete (data_mod)
53.408 + delete (fm)
53.409 + delete (data)
53.410 + delete (yy)
53.411 +
53.412 +;*******************************************************************
53.413 +; for station line plot
53.414 +;*******************************************************************
53.415 +
53.416 +; for x-axis in xyplot
53.417 + mon = ispan(1,12,1)
53.418 + mon@long_name = "month"
53.419 +
53.420 + res = True ; plot mods desired
53.421 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
53.422 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
53.423 +
53.424 + res@tmXBFormat = "f" ; not to add trailing zeros
53.425 +
53.426 +;-------------------------------------------------------------------------
53.427 +; Add a boxed legend using the more simple method
53.428 +
53.429 + res@pmLegendDisplayMode = "Always"
53.430 +; res@pmLegendWidthF = 0.1
53.431 + res@pmLegendWidthF = 0.08
53.432 + res@pmLegendHeightF = 0.06
53.433 +; res@pmLegendOrthogonalPosF = -1.17
53.434 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
53.435 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
53.436 +
53.437 +; res@pmLegendParallelPosF = 0.18
53.438 + res@pmLegendParallelPosF = 0.23 ;(rightward)
53.439 +
53.440 +; res@lgPerimOn = False
53.441 + res@lgLabelFontHeightF = 0.015
53.442 + res@xyExplicitLegendLabels = (/"observed",model_name/)
53.443 +;-------------------------------------------------------------------
53.444 +; for panel plot
53.445 + res@gsnFrame = False ; Do not draw plot
53.446 + res@gsnDraw = False ; Do not advance frame
53.447 +
53.448 + pres = True ; panel plot mods desired
53.449 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
53.450 + ; indiv. plots in panel
53.451 + pres@gsnMaximize = True ; fill the page
53.452 +;-------------------------------------------------------------------
53.453 +
53.454 +;==============================================================
53.455 +; get ob data at each site with long observation
53.456 +
53.457 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
53.458 +
53.459 + do n = 0,nstation_long-1
53.460 +; do n = 0,0
53.461 +
53.462 + year_setback = 0
53.463 +
53.464 + nyear = year_station_long(n)
53.465 +
53.466 + if (year_ob_f_long(n).eq. 2006) then
53.467 + year_setback = 2006 -2004
53.468 + end if
53.469 + if (year_ob_f_long(n).eq. 2005) then
53.470 + year_setback = 2005 -2004
53.471 + end if
53.472 +
53.473 + ntime = (nyear - year_setback) * nmonth
53.474 +
53.475 + data_ob = new ((/nfield, nyear, nmonth/),float)
53.476 +
53.477 + diro = dir_root + station_long(n)+"/"
53.478 + filo = year_ob_long(n)+"_L4_m.nc"
53.479 + fo = addfile (diro+filo,"r")
53.480 +
53.481 +; print (diro)
53.482 +; print (filo)
53.483 +
53.484 + data_ob(0,:,:) = fo->NEE_or_fMDS
53.485 + data_ob(1,:,:) = fo->Rg_f
53.486 + data_ob(2,:,:) = fo->LE_f
53.487 + data_ob(3,:,:) = fo->H_f
53.488 + data_ob(4,:,:) = fo->GPP_or_MDS
53.489 + data_ob(5,:,:) = fo->Reco_or
53.490 +
53.491 + delete (fo)
53.492 +
53.493 + timeI = new((/ntime/),integer)
53.494 + timeF = new((/ntime/),float)
53.495 + timeI = ispan(1,ntime,1)
53.496 + timeF = year_ob_i_long(n) + (timeI-1)/12.
53.497 + timeF@long_name = "year"
53.498 +
53.499 + plot_data = new((/2,ntime/),float)
53.500 +
53.501 +;----------------------------
53.502 +; for model_vs_ob
53.503 +
53.504 + plot_name = station_long(n)+"_tseries_vs_ob"
53.505 + title = station_long(n)+"("+sprintf("%5.2f",lat_ob_long(n))+","+sprintf("%5.2f",lon_ob_long(n))+")"
53.506 + res@tiMainString = title
53.507 +
53.508 + wks = gsn_open_wks (plot_type,plot_name)
53.509 + plot=new(nfield,graphic) ; create graphic array
53.510 +
53.511 + i_year_mod_i = year_ob_i_long(n) - 1990
53.512 + i_year_mod_f = i_year_mod_i + nyear - 1 - year_setback
53.513 +
53.514 + i_year_ob_f = nyear - year_setback - 1
53.515 +
53.516 +; print (nyear)
53.517 +; print (i_year_ob_f)
53.518 +; print (i_year_mod_i)
53.519 +; print (i_year_mod_f)
53.520 +
53.521 + do i = 0,nfield-1
53.522 + plot_data(0,:) = ndtooned(data_ob (i,0:i_year_ob_f,:))
53.523 + plot_data(1,:) = ndtooned(data_mod_long(i,i_year_mod_i:i_year_mod_f,:,n))
53.524 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
53.525 + plot(i)=gsn_csm_xy(wks,timeF,plot_data,res) ; create plot
53.526 + end do
53.527 +
53.528 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
53.529 +
53.530 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
53.531 + "rm "+plot_name+"."+plot_type)
53.532 +
53.533 + clear (wks)
53.534 + delete (plot)
53.535 +
53.536 + delete (data_ob)
53.537 + delete (timeI)
53.538 + delete (timeF)
53.539 + delete (plot_data)
53.540 +
53.541 + end do
53.542 +
53.543 +;###################################################################
53.544 +; for the following tables,
53.545 +; sort by latitude in decending order (N->S)
53.546 +
53.547 + isort = dim_pqsort(lat_ob_long,-1)
53.548 +
53.549 + station_sort = station_long(isort)
53.550 + year_ob_sort = year_ob_long(isort)
53.551 + lat_ob_sort = lat_ob_long(isort)
53.552 + lon_ob_sort = lon_ob_long(isort)
53.553 +
53.554 +; print(isort)
53.555 +; print(lat_ob_sort)
53.556 +
53.557 +;*******************************************************************
53.558 +; html table of site: observed
53.559 +;*******************************************************************
53.560 + output_html = "tseries_vs_ob.html"
53.561 +
53.562 + header = (/"<HTML>" \
53.563 + ,"<HEAD>" \
53.564 + ,"<TITLE>CLAMP metrics</TITLE>" \
53.565 + ,"</HEAD>" \
53.566 + ,"<H1>Timeseries at Site: "+model_name+" vs Observation</H1>" \
53.567 + /)
53.568 + footer = "</HTML>"
53.569 +
53.570 + table_header = (/ \
53.571 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
53.572 + ,"<tr>" \
53.573 + ," <th bgcolor=DDDDDD >Site Name</th>" \
53.574 + ," <th bgcolor=DDDDDD >Latitude</th>" \
53.575 + ," <th bgcolor=DDDDDD >Longitude</th>" \
53.576 + ," <th bgcolor=DDDDDD >Observed</th>" \
53.577 + ,"</tr>" \
53.578 + /)
53.579 + table_footer = "</table>"
53.580 + row_header = "<tr>"
53.581 + row_footer = "</tr>"
53.582 +
53.583 + lines = new(50000,string)
53.584 + nline = 0
53.585 +
53.586 + set_line(lines,nline,header)
53.587 + set_line(lines,nline,table_header)
53.588 +;-----------------------------------------------
53.589 +; row of table
53.590 +
53.591 + do n = 0,nstation_long-1
53.592 +
53.593 + set_line(lines,nline,row_header)
53.594 +
53.595 + txt0 = station_sort(n)
53.596 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
53.597 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
53.598 + txt3 = year_ob_sort(n)
53.599 +
53.600 + set_line(lines,nline,"<th><a href="+txt0+"_tseries_vs_ob.png>"+txt0+"</a></th>")
53.601 + set_line(lines,nline,"<th>"+txt1+"</th>")
53.602 + set_line(lines,nline,"<th>"+txt2+"</th>")
53.603 + set_line(lines,nline,"<th>"+txt3+"</th>")
53.604 +
53.605 + set_line(lines,nline,row_footer)
53.606 + end do
53.607 +;-----------------------------------------------
53.608 + set_line(lines,nline,table_footer)
53.609 + set_line(lines,nline,footer)
53.610 +
53.611 +; Now write to an HTML file.
53.612 + idx = ind(.not.ismissing(lines))
53.613 + if(.not.any(ismissing(idx))) then
53.614 + asciiwrite(output_html,lines(idx))
53.615 + else
53.616 + print ("error?")
53.617 + end if
53.618 + delete (idx)
53.619 +
53.620 + delete (isort)
53.621 + delete (station_sort)
53.622 + delete (year_ob_sort)
53.623 + delete (lat_ob_sort)
53.624 + delete (lon_ob_sort)
53.625 +
53.626 +;************************************************************
53.627 +; compute annual cycle correlation coef and M score
53.628 +;************************************************************
53.629 +
53.630 + score_max = 5.
53.631 +
53.632 + ccr = new ((/nstation, nfield/),float)
53.633 + M_score = new ((/nstation, nfield/),float)
53.634 +
53.635 + do n=0,nstation-1
53.636 + do m=0,nfield-1
53.637 + ccr(n,m) = esccr(data_ob_ann(m,:,n),data_mod_ann(m,:,n),0)
53.638 + 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))))
53.639 + M_score(n,m) = (1. -(bias/nmonth)) * score_max
53.640 + end do
53.641 + end do
53.642 +
53.643 + M_co2 = avg(M_score(:,0))
53.644 + M_rad = avg(M_score(:,1))
53.645 + M_lh = avg(M_score(:,2))
53.646 + M_sh = avg(M_score(:,3))
53.647 + M_gpp = avg(M_score(:,4))
53.648 + M_er = avg(M_score(:,5))
53.649 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
53.650 +
53.651 + M_energy_co2 = sprintf("%.2f", M_co2)
53.652 + M_energy_rad = sprintf("%.2f", M_rad)
53.653 + M_energy_lh = sprintf("%.2f", M_lh )
53.654 + M_energy_sh = sprintf("%.2f", M_sh )
53.655 + M_energy_gpp = sprintf("%.2f", M_gpp)
53.656 + M_energy_er = sprintf("%.2f", M_er )
53.657 + M_energy_all = sprintf("%.2f", M_all)
53.658 +
53.659 +;*******************************************************************
53.660 +; for station line plot
53.661 +;*******************************************************************
53.662 +
53.663 +; for x-axis in xyplot
53.664 + mon = ispan(1,12,1)
53.665 + mon@long_name = "month"
53.666 +
53.667 +;-------------------------------------------------------------------
53.668 +
53.669 + plot_data = new((/2,nmonth/),float)
53.670 + plot_data!0 = "case"
53.671 + plot_data!1 = "month"
53.672 +
53.673 + do n = 0,nstation-1
53.674 +;----------------------------
53.675 +; for observed
53.676 +
53.677 + plot_name = station(n)+"_ob"
53.678 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
53.679 + res@tiMainString = title
53.680 +
53.681 + wks = gsn_open_wks (plot_type,plot_name)
53.682 + plot=new(nfield,graphic) ; create graphic array
53.683 +
53.684 + do i = 0,nfield-1
53.685 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
53.686 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
53.687 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
53.688 + end do
53.689 +
53.690 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
53.691 +
53.692 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
53.693 + "rm "+plot_name+"."+plot_type)
53.694 +
53.695 + clear (wks)
53.696 + delete (plot)
53.697 +;----------------------------
53.698 +; for model_vs_ob
53.699 +
53.700 + plot_name = station(n)+"_model_vs_ob"
53.701 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
53.702 + res@tiMainString = title
53.703 +
53.704 + wks = gsn_open_wks (plot_type,plot_name)
53.705 + plot=new(nfield,graphic) ; create graphic array
53.706 +
53.707 + do i = 0,nfield-1
53.708 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
53.709 + plot_data(1,:) = (/data_mod_ann(i,:,n)/)
53.710 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
53.711 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
53.712 + end do
53.713 +
53.714 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
53.715 +
53.716 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
53.717 + "rm "+plot_name+"."+plot_type)
53.718 +
53.719 + clear (wks)
53.720 + delete (plot)
53.721 + end do
53.722 +
53.723 +;###################################################################
53.724 +; for the following tables,
53.725 +; sort by latitude in decending order (N->S)
53.726 +; sort by lat in decending order (N->S)
53.727 +
53.728 + isort = dim_pqsort(lat_ob,-1)
53.729 +
53.730 + station_sort = station(isort)
53.731 + year_ob_sort = year_ob(isort)
53.732 + lat_ob_sort = lat_ob(isort)
53.733 + lon_ob_sort = lon_ob(isort)
53.734 + M_score_sort = M_score(isort,:)
53.735 +
53.736 +; print(isort)
53.737 +; print(lat_ob_sort)
53.738 +;###################################################################
53.739 +;*******************************************************************
53.740 +; html table of site: observed
53.741 +;*******************************************************************
53.742 + output_html = "line_ob.html"
53.743 +
53.744 + header = (/"<HTML>" \
53.745 + ,"<HEAD>" \
53.746 + ,"<TITLE>CLAMP metrics</TITLE>" \
53.747 + ,"</HEAD>" \
53.748 + ,"<H1>Energy at Site: Observation</H1>" \
53.749 + /)
53.750 + footer = "</HTML>"
53.751 +
53.752 + table_header = (/ \
53.753 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
53.754 + ,"<tr>" \
53.755 + ," <th bgcolor=DDDDDD >Site Name</th>" \
53.756 + ," <th bgcolor=DDDDDD >Latitude</th>" \
53.757 + ," <th bgcolor=DDDDDD >Longitude</th>" \
53.758 + ," <th bgcolor=DDDDDD >Observed</th>" \
53.759 + ,"</tr>" \
53.760 + /)
53.761 + table_footer = "</table>"
53.762 + row_header = "<tr>"
53.763 + row_footer = "</tr>"
53.764 +
53.765 + lines = new(50000,string)
53.766 + nline = 0
53.767 +
53.768 + set_line(lines,nline,header)
53.769 + set_line(lines,nline,table_header)
53.770 +;-----------------------------------------------
53.771 +; row of table
53.772 +
53.773 + do n = 0,nstation-1
53.774 + set_line(lines,nline,row_header)
53.775 +
53.776 + txt0 = station_sort(n)
53.777 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
53.778 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
53.779 + txt3 = year_ob_sort(n)
53.780 +
53.781 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
53.782 + set_line(lines,nline,"<th>"+txt1+"</th>")
53.783 + set_line(lines,nline,"<th>"+txt2+"</th>")
53.784 + set_line(lines,nline,"<th>"+txt3+"</th>")
53.785 +
53.786 + set_line(lines,nline,row_footer)
53.787 + end do
53.788 +;-----------------------------------------------
53.789 + set_line(lines,nline,table_footer)
53.790 + set_line(lines,nline,footer)
53.791 +
53.792 +; Now write to an HTML file.
53.793 + idx = ind(.not.ismissing(lines))
53.794 + if(.not.any(ismissing(idx))) then
53.795 + asciiwrite(output_html,lines(idx))
53.796 + else
53.797 + print ("error?")
53.798 + end if
53.799 + delete (idx)
53.800 +
53.801 +;*******************************************************************
53.802 +; score and line table : model vs observed
53.803 +;*******************************************************************
53.804 + output_html = "score+line_vs_ob.html"
53.805 +
53.806 + header = (/"<HTML>" \
53.807 + ,"<HEAD>" \
53.808 + ,"<TITLE>CLAMP metrics</TITLE>" \
53.809 + ,"</HEAD>" \
53.810 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
53.811 + /)
53.812 + footer = "</HTML>"
53.813 +
53.814 + delete (table_header)
53.815 + table_header = (/ \
53.816 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
53.817 + ,"<tr>" \
53.818 + ," <th bgcolor=DDDDDD >Site Name</th>" \
53.819 + ," <th bgcolor=DDDDDD >Latitude</th>" \
53.820 + ," <th bgcolor=DDDDDD >Longitude</th>" \
53.821 + ," <th bgcolor=DDDDDD >Observed</th>" \
53.822 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
53.823 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
53.824 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
53.825 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
53.826 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
53.827 + ," <th bgcolor=DDDDDD >Respiration</th>" \
53.828 + ," <th bgcolor=DDDDDD >Average</th>" \
53.829 + ,"</tr>" \
53.830 + /)
53.831 + table_footer = "</table>"
53.832 + row_header = "<tr>"
53.833 + row_footer = "</tr>"
53.834 +
53.835 + lines = new(50000,string)
53.836 + nline = 0
53.837 +
53.838 + set_line(lines,nline,header)
53.839 + set_line(lines,nline,table_header)
53.840 +;-----------------------------------------------
53.841 +; row of table
53.842 +
53.843 + do n = 0,nstation-1
53.844 + set_line(lines,nline,row_header)
53.845 +
53.846 + txt0 = station_sort(n)
53.847 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
53.848 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
53.849 + txt3 = year_ob_sort(n)
53.850 + txt4 = sprintf("%5.2f", M_score_sort(n,0))
53.851 + txt5 = sprintf("%5.2f", M_score_sort(n,1))
53.852 + txt6 = sprintf("%5.2f", M_score_sort(n,2))
53.853 + txt7 = sprintf("%5.2f", M_score_sort(n,3))
53.854 + txt8 = sprintf("%5.2f", M_score_sort(n,4))
53.855 + txt9 = sprintf("%5.2f", M_score_sort(n,5))
53.856 + txt10 = sprintf("%5.2f", avg(M_score_sort(n,:)))
53.857 +
53.858 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
53.859 + set_line(lines,nline,"<th>"+txt1+"</th>")
53.860 + set_line(lines,nline,"<th>"+txt2+"</th>")
53.861 + set_line(lines,nline,"<th>"+txt3+"</th>")
53.862 + set_line(lines,nline,"<th>"+txt4+"</th>")
53.863 + set_line(lines,nline,"<th>"+txt5+"</th>")
53.864 + set_line(lines,nline,"<th>"+txt6+"</th>")
53.865 + set_line(lines,nline,"<th>"+txt7+"</th>")
53.866 + set_line(lines,nline,"<th>"+txt8+"</th>")
53.867 + set_line(lines,nline,"<th>"+txt9+"</th>")
53.868 + set_line(lines,nline,"<th>"+txt10+"</th>")
53.869 +
53.870 + set_line(lines,nline,row_footer)
53.871 + end do
53.872 +
53.873 +; last row, summary
53.874 + set_line(lines,nline,row_header)
53.875 +
53.876 + txt0 = "All_"+sprintf("%.0f", nstation)
53.877 + txt1 = "-"
53.878 + txt2 = "-"
53.879 + txt3 = "-"
53.880 + txt4 = M_energy_co2
53.881 + txt5 = M_energy_rad
53.882 + txt6 = M_energy_lh
53.883 + txt7 = M_energy_sh
53.884 + txt8 = M_energy_gpp
53.885 + txt9 = M_energy_er
53.886 + txt10 = M_energy_all
53.887 +
53.888 + set_line(lines,nline,"<th>"+txt0+"</th>")
53.889 + set_line(lines,nline,"<th>"+txt1+"</th>")
53.890 + set_line(lines,nline,"<th>"+txt2+"</th>")
53.891 + set_line(lines,nline,"<th>"+txt3+"</th>")
53.892 + set_line(lines,nline,"<th>"+txt4+"</th>")
53.893 + set_line(lines,nline,"<th>"+txt5+"</th>")
53.894 + set_line(lines,nline,"<th>"+txt6+"</th>")
53.895 + set_line(lines,nline,"<th>"+txt7+"</th>")
53.896 + set_line(lines,nline,"<th>"+txt8+"</th>")
53.897 + set_line(lines,nline,"<th>"+txt9+"</th>")
53.898 + set_line(lines,nline,"<th>"+txt10+"</th>")
53.899 +
53.900 + set_line(lines,nline,row_footer)
53.901 +;-----------------------------------------------
53.902 + set_line(lines,nline,table_footer)
53.903 + set_line(lines,nline,footer)
53.904 +
53.905 +; Now write to an HTML file.
53.906 + idx = ind(.not.ismissing(lines))
53.907 + if(.not.any(ismissing(idx))) then
53.908 + asciiwrite(output_html,lines(idx))
53.909 + else
53.910 + print ("error?")
53.911 + end if
53.912 + delete (idx)
53.913 +
53.914 +;***************************************************************************
53.915 +; output plots
53.916 +;***************************************************************************
53.917 + output_dir = model_name+"/ameriflux"
53.918 +
53.919 + system("mv *.png *.html " + output_dir)
53.920 +;***************************************************************************
53.921 +end
53.922 +
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
54.2 +++ b/ameriflux/23.plot.ncl Mon Jan 26 22:08:20 2009 -0500
54.3 @@ -0,0 +1,920 @@
54.4 +;************************************************************
54.5 +; move data
54.6 +; merge annual
54.7 +; add table
54.8 +; add time series plot
54.9 +; sort by latitude in decending order (N->S)
54.10 +; find year_ob >= 4
54.11 +; add year_ob_i and year_ob_f
54.12 +; change long_name
54.13 +;************************************************************
54.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
54.15 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
54.16 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
54.17 +;************************************************************
54.18 +procedure set_line(lines:string,nline:integer,newlines:string)
54.19 +begin
54.20 +; add line to ascci/html file
54.21 +
54.22 + nnewlines = dimsizes(newlines)
54.23 + if(nline+nnewlines-1.ge.dimsizes(lines))
54.24 + print("set_line: bad index, not setting anything.")
54.25 + return
54.26 + end if
54.27 + lines(nline:nline+nnewlines-1) = newlines
54.28 +; print ("lines = " + lines(nline:nline+nnewlines-1))
54.29 + nline = nline + nnewlines
54.30 + return
54.31 +end
54.32 +;*************************************************************
54.33 +begin
54.34 +
54.35 + plot_type = "ps"
54.36 + plot_type_new = "png"
54.37 +
54.38 +;************************************************
54.39 +; model data info
54.40 +;************************************************
54.41 + model = "cn"
54.42 +; model = "casa"
54.43 +
54.44 + model_name = "i01.10" + model
54.45 +
54.46 + ENERGY ="new"
54.47 +
54.48 + nmonth = 12
54.49 +
54.50 +;************************************************
54.51 +; observed data info
54.52 +;************************************************
54.53 +
54.54 + station = (/"ARM_Oklahoma" \
54.55 + ,"ARM_Oklahoma_burn" \
54.56 + ,"ARM_Oklahoma_control" \
54.57 + ,"Atqasuk" \
54.58 + ,"Audubon" \
54.59 + ,"AustinCary" \
54.60 + ,"Bartlett" \
54.61 + ,"Bondville" \
54.62 + ,"Brookings" \
54.63 + ,"Donaldson" \
54.64 + ,"Duke_Forest_Hardwoods" \
54.65 + ,"Duke_Forest_Open_Field" \
54.66 + ,"Duke_Forest_Pine" \
54.67 + ,"Fermi_Ag" \
54.68 + ,"Fermi_Prairie" \
54.69 + ,"Flagstaff_Managed" \
54.70 + ,"Flagstaff_Unmanaged" \
54.71 + ,"Flagstaff_Wildfire" \
54.72 + ,"FortPeck" \
54.73 + ,"FreemanRanch_mesquite" \
54.74 + ,"Goodwin_Creek" \
54.75 + ,"HarvardForest" \
54.76 + ,"HarvardForestHemlock" \
54.77 + ,"HowlandForestMain" \
54.78 + ,"HowlandForestWest" \
54.79 + ,"Ivotuk" \
54.80 + ,"KendallGrasslands" \
54.81 + ,"KennedySpaceCenterPine" \
54.82 + ,"KennedySpaceCenterScrub" \
54.83 + ,"LittleProspect" \
54.84 + ,"LostCreek" \
54.85 + ,"Mead-irrigated" \
54.86 + ,"Mead-irrigated-rotation" \
54.87 + ,"Mead-rainfed" \
54.88 + ,"Metolius_2nd_YoungPonderosaPine" \
54.89 + ,"MetoliusEyerly" \
54.90 + ,"MetoliusIntermediatePine" \
54.91 + ,"MetoliusOldPonderosaPine" \
54.92 + ,"MissouriOzark" \
54.93 + ,"Mize" \
54.94 + ,"MorganMonroe" \
54.95 + ,"NiwotRidge" \
54.96 + ,"NorthCarolina_cc" \
54.97 + ,"NorthCarolina_lp" \
54.98 + ,"ParkFalls" \
54.99 + ,"Rayonier" \
54.100 + ,"SantaRita" \
54.101 + ,"SkyOaks_Old" \
54.102 + ,"SkyOaks_PostFire" \
54.103 + ,"SkyOaks_Young" \
54.104 + ,"SylvaniaWilderness" \
54.105 + ,"Toledo" \
54.106 + ,"Tonzi" \
54.107 + ,"UCI_1850" \
54.108 + ,"UCI_1930" \
54.109 + ,"UCI_1964" \
54.110 + ,"UCI_1964wet" \
54.111 + ,"UCI_1981" \
54.112 + ,"UCI_1989" \
54.113 + ,"UCI_1998" \
54.114 + ,"UMBS" \
54.115 + ,"Vaira" \
54.116 + ,"WalkerBranch" \
54.117 + ,"WillowCreek" \
54.118 + ,"WindRiver" \
54.119 + ,"Wisconsin_ihw" \
54.120 + ,"Wisconsin_irp" \
54.121 + ,"Wisconsin_mrp" \
54.122 + ,"Wisconsin_myjp" \
54.123 + ,"Wisconsin_pb" \
54.124 + ,"Wisconsin_rpcc" \
54.125 + ,"Wisconsin_yhw" \
54.126 + ,"Wisconsin_yjp" \
54.127 + ,"Wisconsin_yrp" \
54.128 + /)
54.129 +
54.130 + year_ob = (/"2003-2006" \
54.131 + ,"2005-2006" \
54.132 + ,"2005-2006" \
54.133 + ,"1999-2006" \
54.134 + ,"2002-2006" \
54.135 + ,"2000-2005" \
54.136 + ,"2004-2005" \
54.137 + ,"1996-2006" \
54.138 + ,"2004-2006" \
54.139 + ,"1999-2004" \
54.140 + ,"2003-2005" \
54.141 + ,"2001-2005" \
54.142 + ,"2001-2005" \
54.143 + ,"2005-2006" \
54.144 + ,"2004-2006" \
54.145 + ,"2005-2006" \
54.146 + ,"2005-2006" \
54.147 + ,"2005-2006" \
54.148 + ,"2000-2006" \
54.149 + ,"2004-2006" \
54.150 + ,"2002-2006" \
54.151 + ,"1991-2004" \
54.152 + ,"2004-2004" \
54.153 + ,"1996-2004" \
54.154 + ,"1999-2004" \
54.155 + ,"2003-2006" \
54.156 + ,"2004-2006" \
54.157 + ,"2002-2002" \
54.158 + ,"2000-2006" \
54.159 + ,"2002-2005" \
54.160 + ,"2001-2005" \
54.161 + ,"2001-2005" \
54.162 + ,"2001-2005" \
54.163 + ,"2001-2005" \
54.164 + ,"2004-2005" \
54.165 + ,"2004-2005" \
54.166 + ,"2003-2005" \
54.167 + ,"1996-2000" \
54.168 + ,"2004-2006" \
54.169 + ,"1998-2004" \
54.170 + ,"1999-2005" \
54.171 + ,"1999-2003" \
54.172 + ,"2005-2006" \
54.173 + ,"2005-2006" \
54.174 + ,"1996-2003" \
54.175 + ,"1998-1998" \
54.176 + ,"2004-2006" \
54.177 + ,"1997-2006" \
54.178 + ,"2004-2006" \
54.179 + ,"1997-2006" \
54.180 + ,"2002-2006" \
54.181 + ,"2004-2005" \
54.182 + ,"2001-2006" \
54.183 + ,"2004-2005" \
54.184 + ,"2001-2005" \
54.185 + ,"2001-2005" \
54.186 + ,"2002-2004" \
54.187 + ,"2001-2005" \
54.188 + ,"2001-2005" \
54.189 + ,"2002-2005" \
54.190 + ,"1999-2003" \
54.191 + ,"2001-2006" \
54.192 + ,"1995-1999" \
54.193 + ,"1999-2005" \
54.194 + ,"1999-2004" \
54.195 + ,"2003-2003" \
54.196 + ,"2003-2003" \
54.197 + ,"2002-2005" \
54.198 + ,"2004-2004" \
54.199 + ,"2002-2002" \
54.200 + ,"2005-2005" \
54.201 + ,"2002-2002" \
54.202 + ,"2004-2005" \
54.203 + ,"2002-2002" \
54.204 + /)
54.205 +
54.206 + field = (/"NEE Flux" \
54.207 + ,"Net Radiation" \
54.208 + ,"Latent Heat" \
54.209 + ,"Sensible Heat" \
54.210 + ,"GPP Flux" \
54.211 + ,"Respiration" \
54.212 + /)
54.213 +
54.214 + field_unit = (/"u mol/m2/s" \
54.215 + ,"W/m2" \
54.216 + ,"W/m2" \
54.217 + ,"W/m2" \
54.218 + ,"u mol/m2/s" \
54.219 + ,"u mol/m2/s" \
54.220 + /)
54.221 +
54.222 + nstation = dimsizes(station)
54.223 + nfield = dimsizes(field)
54.224 +
54.225 +;========================================================================
54.226 +; get observed info: number of year, first/last year, lat, lon
54.227 +; and annual data
54.228 +
54.229 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/observed/ameriflux/"
54.230 +
54.231 + year_station = new ((/nstation/),integer) ; number of year
54.232 + year_ob_i = new ((/nstation/),integer) ; first year
54.233 + year_ob_f = new ((/nstation/),integer) ; last year
54.234 + lat_ob = new ((/nstation/),float) ; latitude
54.235 + lon_ob = new ((/nstation/),float) ; longitude
54.236 +
54.237 + data_ob_ann = new ((/nfield, nmonth, nstation/),float)
54.238 +
54.239 + do n = 0, nstation-1
54.240 +
54.241 + diro = dir_root + station(n)+"/"
54.242 + filo = year_ob(n)+"_L4_m.nc"
54.243 + fo = addfile (diro+filo,"r")
54.244 +
54.245 + lat_ob(n) = fo->lat
54.246 + lon_ob(n) = fo->lon
54.247 +
54.248 + year = fo->year
54.249 +
54.250 + year_station(n) = dimsizes(year)
54.251 + year_ob_i(n) = year(0)
54.252 + year_ob_f(n) = year(year_station(n)-1)
54.253 +
54.254 + delete (year)
54.255 +
54.256 + data = fo->NEE_or_fMDS
54.257 + data_ob_ann(0,:,n) = dim_avg(data(month|:,year|:))
54.258 +
54.259 + data = fo->Rg_f
54.260 + data_ob_ann(1,:,n) = dim_avg(data(month|:,year|:))
54.261 +
54.262 + data = fo->LE_f
54.263 + data_ob_ann(2,:,n) = dim_avg(data(month|:,year|:))
54.264 +
54.265 + data = fo->H_f
54.266 + data_ob_ann(3,:,n) = dim_avg(data(month|:,year|:))
54.267 +
54.268 + data = fo->GPP_or_MDS
54.269 + data_ob_ann(4,:,n) = dim_avg(data(month|:,year|:))
54.270 +
54.271 + data = fo->Reco_or
54.272 + data_ob_ann(5,:,n) = dim_avg(data(month|:,year|:))
54.273 +
54.274 + delete (data)
54.275 + delete (fo)
54.276 + end do
54.277 +
54.278 +;print (year_ob_i)
54.279 +;print (year_ob_f)
54.280 +
54.281 +;--------------------------------------------------------------
54.282 +; find (# of year observed) >=4 and year_ob_i <= 2001
54.283 +
54.284 + i_long_ob = ind(year_station .ge. 4 .and. year_ob_i .le. 2001)
54.285 +
54.286 + station_long = station(i_long_ob)
54.287 + lat_ob_long = lat_ob(i_long_ob)
54.288 + lon_ob_long = lat_ob(i_long_ob)
54.289 + year_ob_long = year_ob(i_long_ob)
54.290 + year_ob_i_long = year_ob_i(i_long_ob)
54.291 + year_ob_f_long = year_ob_f(i_long_ob)
54.292 + year_station_long = year_station(i_long_ob)
54.293 +
54.294 + nstation_long = dimsizes(station_long)
54.295 +
54.296 +; print (i_long_ob)
54.297 +; print (nstation_long)
54.298 +; print (station_long)
54.299 +; print (year_ob_i(i_long_ob))
54.300 +
54.301 +;=========================================================
54.302 +; get model data at observed lat-lon
54.303 +
54.304 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
54.305 + film = model_name+"_ameriflux_1990-2004_monthly.nc"
54.306 + fm = addfile (dirm+film,"r")
54.307 +
54.308 + xm = fm->lon
54.309 + ym = fm->lat
54.310 + date = fm->date
54.311 +
54.312 + date_dim = dimsizes(date)
54.313 + nyear = date_dim(0)
54.314 +
54.315 + data_mod = new ((/nfield,nyear,nmonth,nstation/),float)
54.316 + data_mod_ann = new ((/nfield,nmonth,nstation/),float)
54.317 + data_mod_long = new ((/nfield,nyear,nmonth,nstation_long/),float)
54.318 +
54.319 +; change to unit of observed (u mol/m2/s)
54.320 +; Model_units [=] gC/m2/s
54.321 +; 12. = molecular weight of C
54.322 +; u mol = 1e-6 mol
54.323 +
54.324 + factor = 1.e6 /12.
54.325 +
54.326 +;------------------------------------------------------------
54.327 +; interpolate model data into observed station
54.328 +; note: model is 0-360E, 90S-90N
54.329 +
54.330 +; to be able to handle observation at (-89.98,-24.80)
54.331 + ym(0) = -90.
54.332 +;------------------------------------------------------------
54.333 +
54.334 +if (ENERGY .eq. "old") then
54.335 +
54.336 + data = fm->NEE
54.337 + data_mod(0,:,:,:) = data(:,:,:) * factor
54.338 +
54.339 +; data = fm->LATENT
54.340 + data1 = fm->FCEV
54.341 + data2 = fm->FCTR
54.342 + data3 = fm->FGEV
54.343 + data_mod(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
54.344 + delete (data1)
54.345 + delete (data2)
54.346 + delete (data3)
54.347 +
54.348 +; data = fm->SENSIBLE
54.349 + data = fm->FSH
54.350 + data_mod(3,:,:,:) = data(:,:,:)
54.351 +
54.352 +; data = fm->NETRAD
54.353 + data1 = fm->FSA
54.354 + data2 = fm->FIRA
54.355 + data_mod(1,:,:,:) = data1(:,:,:)-data2(:,:,:)
54.356 + delete (data1)
54.357 + delete (data2)
54.358 +
54.359 +else
54.360 +
54.361 + data = fm->NEE
54.362 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
54.363 + data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
54.364 + data_mod(0,:,:,:) = yy(:,:,:) * factor
54.365 +
54.366 +; printVarSummary(yy)
54.367 +
54.368 + data = fm->NETRAD
54.369 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
54.370 + data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:))
54.371 + data_mod(1,:,:,:) = yy(:,:,:)
54.372 +
54.373 + data = fm->LATENT
54.374 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
54.375 + data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:))
54.376 + data_mod(2,:,:,:) = yy(:,:,:)
54.377 +
54.378 +; data = fm->SENSIBLE
54.379 + data = fm->FSH
54.380 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
54.381 + data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:))
54.382 + data_mod(3,:,:,:) = yy(:,:,:)
54.383 +
54.384 +end if
54.385 +
54.386 + data = fm->GPP
54.387 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
54.388 + data_mod_ann(4,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
54.389 + data_mod(4,:,:,:) = yy(:,:,:) * factor
54.390 +
54.391 + if (model .eq. "cn") then
54.392 + data = fm->ER
54.393 + else
54.394 + data1 = fm->AR
54.395 + data2 = fm->HR
54.396 + data = data1 + data2
54.397 +
54.398 + delete (data1)
54.399 + delete (data2)
54.400 + end if
54.401 +
54.402 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
54.403 + data_mod_ann(5,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
54.404 + data_mod(5,:,:,:) = yy(:,:,:) * factor
54.405 +
54.406 + data_mod_long(:,:,:,:) = data_mod(:,:,:,i_long_ob)
54.407 +
54.408 + delete (data_mod)
54.409 + delete (fm)
54.410 + delete (data)
54.411 + delete (yy)
54.412 +
54.413 +;*******************************************************************
54.414 +; for station line plot
54.415 +;*******************************************************************
54.416 +
54.417 +; for x-axis in xyplot
54.418 + mon = ispan(1,12,1)
54.419 + mon@long_name = "month"
54.420 +
54.421 + res = True ; plot mods desired
54.422 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
54.423 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
54.424 +
54.425 + res@tmXBFormat = "f" ; not to add trailing zeros
54.426 +
54.427 +;-------------------------------------------------------------------------
54.428 +; Add a boxed legend using the more simple method
54.429 +
54.430 + res@pmLegendDisplayMode = "Always"
54.431 +; res@pmLegendWidthF = 0.1
54.432 + res@pmLegendWidthF = 0.08
54.433 + res@pmLegendHeightF = 0.06
54.434 +; res@pmLegendOrthogonalPosF = -1.17
54.435 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
54.436 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
54.437 +
54.438 +; res@pmLegendParallelPosF = 0.18
54.439 + res@pmLegendParallelPosF = 0.23 ;(rightward)
54.440 +
54.441 +; res@lgPerimOn = False
54.442 + res@lgLabelFontHeightF = 0.015
54.443 + res@xyExplicitLegendLabels = (/"observed",model_name/)
54.444 +;-------------------------------------------------------------------
54.445 +; for panel plot
54.446 + res@gsnFrame = False ; Do not draw plot
54.447 + res@gsnDraw = False ; Do not advance frame
54.448 +
54.449 + pres = True ; panel plot mods desired
54.450 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
54.451 + ; indiv. plots in panel
54.452 + pres@gsnMaximize = True ; fill the page
54.453 +;-------------------------------------------------------------------
54.454 +
54.455 +;==============================================================
54.456 +; get ob data at each site with long observation
54.457 +
54.458 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
54.459 +
54.460 + do n = 0,nstation_long-1
54.461 +; do n = 0,0
54.462 +
54.463 + year_setback = 0
54.464 +
54.465 + nyear = year_station_long(n)
54.466 +
54.467 + if (year_ob_f_long(n).eq. 2006) then
54.468 + year_setback = 2006 -2004
54.469 + end if
54.470 + if (year_ob_f_long(n).eq. 2005) then
54.471 + year_setback = 2005 -2004
54.472 + end if
54.473 +
54.474 + ntime = (nyear - year_setback) * nmonth
54.475 +
54.476 + data_ob = new ((/nfield, nyear, nmonth/),float)
54.477 +
54.478 + diro = dir_root + station_long(n)+"/"
54.479 + filo = year_ob_long(n)+"_L4_m.nc"
54.480 + fo = addfile (diro+filo,"r")
54.481 +
54.482 +; print (diro)
54.483 +; print (filo)
54.484 +
54.485 + data_ob(0,:,:) = fo->NEE_or_fMDS
54.486 + data_ob(1,:,:) = fo->Rg_f
54.487 + data_ob(2,:,:) = fo->LE_f
54.488 + data_ob(3,:,:) = fo->H_f
54.489 + data_ob(4,:,:) = fo->GPP_or_MDS
54.490 + data_ob(5,:,:) = fo->Reco_or
54.491 +
54.492 + delete (fo)
54.493 +
54.494 + timeI = new((/ntime/),integer)
54.495 + timeF = new((/ntime/),float)
54.496 + timeI = ispan(1,ntime,1)
54.497 + timeF = year_ob_i_long(n) + (timeI-1)/12.
54.498 + timeF@long_name = "year"
54.499 +
54.500 + plot_data = new((/2,ntime/),float)
54.501 +
54.502 +;----------------------------
54.503 +; for model_vs_ob
54.504 +
54.505 + plot_name = station_long(n)+"_tseries_vs_ob"
54.506 + title = station_long(n)+"("+sprintf("%5.2f",lat_ob_long(n))+","+sprintf("%5.2f",lon_ob_long(n))+")"
54.507 + res@tiMainString = title
54.508 +
54.509 + wks = gsn_open_wks (plot_type,plot_name)
54.510 + plot=new(nfield,graphic) ; create graphic array
54.511 +
54.512 + i_year_mod_i = year_ob_i_long(n) - 1990
54.513 + i_year_mod_f = i_year_mod_i + nyear - 1 - year_setback
54.514 +
54.515 + i_year_ob_f = nyear - year_setback - 1
54.516 +
54.517 +; print (nyear)
54.518 +; print (i_year_ob_f)
54.519 +; print (i_year_mod_i)
54.520 +; print (i_year_mod_f)
54.521 +
54.522 + do i = 0,nfield-1
54.523 + plot_data(0,:) = ndtooned(data_ob (i,0:i_year_ob_f,:))
54.524 + plot_data(1,:) = ndtooned(data_mod_long(i,i_year_mod_i:i_year_mod_f,:,n))
54.525 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
54.526 + plot(i)=gsn_csm_xy(wks,timeF,plot_data,res) ; create plot
54.527 + end do
54.528 +
54.529 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
54.530 +
54.531 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
54.532 + "rm "+plot_name+"."+plot_type)
54.533 +
54.534 + clear (wks)
54.535 + delete (plot)
54.536 +
54.537 + delete (data_ob)
54.538 + delete (timeI)
54.539 + delete (timeF)
54.540 + delete (plot_data)
54.541 +
54.542 + end do
54.543 +
54.544 +;###################################################################
54.545 +; for the following tables,
54.546 +; sort by latitude in decending order (N->S)
54.547 +
54.548 + isort = dim_pqsort(lat_ob_long,-1)
54.549 +
54.550 + station_sort = station_long(isort)
54.551 + year_ob_sort = year_ob_long(isort)
54.552 + lat_ob_sort = lat_ob_long(isort)
54.553 + lon_ob_sort = lon_ob_long(isort)
54.554 +
54.555 +; print(isort)
54.556 +; print(lat_ob_sort)
54.557 +
54.558 +;*******************************************************************
54.559 +; html table of site: observed
54.560 +;*******************************************************************
54.561 + output_html = "tseries_vs_ob.html"
54.562 +
54.563 + header = (/"<HTML>" \
54.564 + ,"<HEAD>" \
54.565 + ,"<TITLE>CLAMP metrics</TITLE>" \
54.566 + ,"</HEAD>" \
54.567 + ,"<H1>Timeseries at Site: "+model_name+" vs Observation</H1>" \
54.568 + /)
54.569 + footer = "</HTML>"
54.570 +
54.571 + table_header = (/ \
54.572 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
54.573 + ,"<tr>" \
54.574 + ," <th bgcolor=DDDDDD >Site Name</th>" \
54.575 + ," <th bgcolor=DDDDDD >Latitude</th>" \
54.576 + ," <th bgcolor=DDDDDD >Longitude</th>" \
54.577 + ," <th bgcolor=DDDDDD >Observed</th>" \
54.578 + ,"</tr>" \
54.579 + /)
54.580 + table_footer = "</table>"
54.581 + row_header = "<tr>"
54.582 + row_footer = "</tr>"
54.583 +
54.584 + lines = new(50000,string)
54.585 + nline = 0
54.586 +
54.587 + set_line(lines,nline,header)
54.588 + set_line(lines,nline,table_header)
54.589 +;-----------------------------------------------
54.590 +; row of table
54.591 +
54.592 + do n = 0,nstation_long-1
54.593 +
54.594 + set_line(lines,nline,row_header)
54.595 +
54.596 + txt0 = station_sort(n)
54.597 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
54.598 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
54.599 + txt3 = year_ob_sort(n)
54.600 +
54.601 + set_line(lines,nline,"<th><a href="+txt0+"_tseries_vs_ob.png>"+txt0+"</a></th>")
54.602 + set_line(lines,nline,"<th>"+txt1+"</th>")
54.603 + set_line(lines,nline,"<th>"+txt2+"</th>")
54.604 + set_line(lines,nline,"<th>"+txt3+"</th>")
54.605 +
54.606 + set_line(lines,nline,row_footer)
54.607 + end do
54.608 +;-----------------------------------------------
54.609 + set_line(lines,nline,table_footer)
54.610 + set_line(lines,nline,footer)
54.611 +
54.612 +; Now write to an HTML file.
54.613 + idx = ind(.not.ismissing(lines))
54.614 + if(.not.any(ismissing(idx))) then
54.615 + asciiwrite(output_html,lines(idx))
54.616 + else
54.617 + print ("error?")
54.618 + end if
54.619 + delete (idx)
54.620 +
54.621 + delete (isort)
54.622 + delete (station_sort)
54.623 + delete (year_ob_sort)
54.624 + delete (lat_ob_sort)
54.625 + delete (lon_ob_sort)
54.626 +
54.627 +;************************************************************
54.628 +; compute annual cycle correlation coef and M score
54.629 +;************************************************************
54.630 +
54.631 + score_max = 5.
54.632 +
54.633 + ccr = new ((/nstation, nfield/),float)
54.634 + M_score = new ((/nstation, nfield/),float)
54.635 +
54.636 + do n=0,nstation-1
54.637 + do m=0,nfield-1
54.638 + ccr(n,m) = esccr(data_ob_ann(m,:,n),data_mod_ann(m,:,n),0)
54.639 + 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))))
54.640 + M_score(n,m) = (1. -(bias/nmonth)) * score_max
54.641 + end do
54.642 + end do
54.643 +
54.644 + M_co2 = avg(M_score(:,0))
54.645 + M_rad = avg(M_score(:,1))
54.646 + M_lh = avg(M_score(:,2))
54.647 + M_sh = avg(M_score(:,3))
54.648 + M_gpp = avg(M_score(:,4))
54.649 + M_er = avg(M_score(:,5))
54.650 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
54.651 +
54.652 + M_energy_co2 = sprintf("%.2f", M_co2)
54.653 + M_energy_rad = sprintf("%.2f", M_rad)
54.654 + M_energy_lh = sprintf("%.2f", M_lh )
54.655 + M_energy_sh = sprintf("%.2f", M_sh )
54.656 + M_energy_gpp = sprintf("%.2f", M_gpp)
54.657 + M_energy_er = sprintf("%.2f", M_er )
54.658 + M_energy_all = sprintf("%.2f", M_all)
54.659 +
54.660 +;*******************************************************************
54.661 +; for station line plot
54.662 +;*******************************************************************
54.663 +
54.664 +; for x-axis in xyplot
54.665 + mon = ispan(1,12,1)
54.666 + mon@long_name = "month"
54.667 +
54.668 +;-------------------------------------------------------------------
54.669 +
54.670 + plot_data = new((/2,nmonth/),float)
54.671 + plot_data!0 = "case"
54.672 + plot_data!1 = "month"
54.673 +
54.674 + do n = 0,nstation-1
54.675 +;----------------------------
54.676 +; for observed
54.677 +
54.678 + plot_name = station(n)+"_ob"
54.679 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
54.680 + res@tiMainString = title
54.681 +
54.682 + wks = gsn_open_wks (plot_type,plot_name)
54.683 + plot=new(nfield,graphic) ; create graphic array
54.684 +
54.685 + do i = 0,nfield-1
54.686 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
54.687 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
54.688 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
54.689 + end do
54.690 +
54.691 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
54.692 +
54.693 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
54.694 + "rm "+plot_name+"."+plot_type)
54.695 +
54.696 + clear (wks)
54.697 + delete (plot)
54.698 +;----------------------------
54.699 +; for model_vs_ob
54.700 +
54.701 + plot_name = station(n)+"_model_vs_ob"
54.702 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
54.703 + res@tiMainString = title
54.704 +
54.705 + wks = gsn_open_wks (plot_type,plot_name)
54.706 + plot=new(nfield,graphic) ; create graphic array
54.707 +
54.708 + do i = 0,nfield-1
54.709 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
54.710 + plot_data(1,:) = (/data_mod_ann(i,:,n)/)
54.711 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
54.712 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
54.713 + end do
54.714 +
54.715 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
54.716 +
54.717 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
54.718 + "rm "+plot_name+"."+plot_type)
54.719 +
54.720 + clear (wks)
54.721 + delete (plot)
54.722 + end do
54.723 +
54.724 +;###################################################################
54.725 +; for the following tables,
54.726 +; sort by latitude in decending order (N->S)
54.727 +; sort by lat in decending order (N->S)
54.728 +
54.729 + isort = dim_pqsort(lat_ob,-1)
54.730 +
54.731 + station_sort = station(isort)
54.732 + year_ob_sort = year_ob(isort)
54.733 + lat_ob_sort = lat_ob(isort)
54.734 + lon_ob_sort = lon_ob(isort)
54.735 + M_score_sort = M_score(isort,:)
54.736 +
54.737 +; print(isort)
54.738 +; print(lat_ob_sort)
54.739 +;###################################################################
54.740 +;*******************************************************************
54.741 +; html table of site: observed
54.742 +;*******************************************************************
54.743 + output_html = "line_ob.html"
54.744 +
54.745 + header = (/"<HTML>" \
54.746 + ,"<HEAD>" \
54.747 + ,"<TITLE>CLAMP metrics</TITLE>" \
54.748 + ,"</HEAD>" \
54.749 + ,"<H1>Energy at Site: Observation</H1>" \
54.750 + /)
54.751 + footer = "</HTML>"
54.752 +
54.753 + table_header = (/ \
54.754 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
54.755 + ,"<tr>" \
54.756 + ," <th bgcolor=DDDDDD >Site Name</th>" \
54.757 + ," <th bgcolor=DDDDDD >Latitude</th>" \
54.758 + ," <th bgcolor=DDDDDD >Longitude</th>" \
54.759 + ," <th bgcolor=DDDDDD >Observed</th>" \
54.760 + ,"</tr>" \
54.761 + /)
54.762 + table_footer = "</table>"
54.763 + row_header = "<tr>"
54.764 + row_footer = "</tr>"
54.765 +
54.766 + lines = new(50000,string)
54.767 + nline = 0
54.768 +
54.769 + set_line(lines,nline,header)
54.770 + set_line(lines,nline,table_header)
54.771 +;-----------------------------------------------
54.772 +; row of table
54.773 +
54.774 + do n = 0,nstation-1
54.775 + set_line(lines,nline,row_header)
54.776 +
54.777 + txt0 = station_sort(n)
54.778 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
54.779 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
54.780 + txt3 = year_ob_sort(n)
54.781 +
54.782 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
54.783 + set_line(lines,nline,"<th>"+txt1+"</th>")
54.784 + set_line(lines,nline,"<th>"+txt2+"</th>")
54.785 + set_line(lines,nline,"<th>"+txt3+"</th>")
54.786 +
54.787 + set_line(lines,nline,row_footer)
54.788 + end do
54.789 +;-----------------------------------------------
54.790 + set_line(lines,nline,table_footer)
54.791 + set_line(lines,nline,footer)
54.792 +
54.793 +; Now write to an HTML file.
54.794 + idx = ind(.not.ismissing(lines))
54.795 + if(.not.any(ismissing(idx))) then
54.796 + asciiwrite(output_html,lines(idx))
54.797 + else
54.798 + print ("error?")
54.799 + end if
54.800 + delete (idx)
54.801 +
54.802 +;*******************************************************************
54.803 +; score and line table : model vs observed
54.804 +;*******************************************************************
54.805 + output_html = "score+line_vs_ob.html"
54.806 +
54.807 + header = (/"<HTML>" \
54.808 + ,"<HEAD>" \
54.809 + ,"<TITLE>CLAMP metrics</TITLE>" \
54.810 + ,"</HEAD>" \
54.811 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
54.812 + /)
54.813 + footer = "</HTML>"
54.814 +
54.815 + delete (table_header)
54.816 + table_header = (/ \
54.817 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
54.818 + ,"<tr>" \
54.819 + ," <th bgcolor=DDDDDD >Site Name</th>" \
54.820 + ," <th bgcolor=DDDDDD >Latitude</th>" \
54.821 + ," <th bgcolor=DDDDDD >Longitude</th>" \
54.822 + ," <th bgcolor=DDDDDD >Observed</th>" \
54.823 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
54.824 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
54.825 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
54.826 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
54.827 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
54.828 + ," <th bgcolor=DDDDDD >Respiration</th>" \
54.829 + ," <th bgcolor=DDDDDD >Average</th>" \
54.830 + ,"</tr>" \
54.831 + /)
54.832 + table_footer = "</table>"
54.833 + row_header = "<tr>"
54.834 + row_footer = "</tr>"
54.835 +
54.836 + lines = new(50000,string)
54.837 + nline = 0
54.838 +
54.839 + set_line(lines,nline,header)
54.840 + set_line(lines,nline,table_header)
54.841 +;-----------------------------------------------
54.842 +; row of table
54.843 +
54.844 + do n = 0,nstation-1
54.845 + set_line(lines,nline,row_header)
54.846 +
54.847 + txt0 = station_sort(n)
54.848 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
54.849 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
54.850 + txt3 = year_ob_sort(n)
54.851 + txt4 = sprintf("%5.2f", M_score_sort(n,0))
54.852 + txt5 = sprintf("%5.2f", M_score_sort(n,1))
54.853 + txt6 = sprintf("%5.2f", M_score_sort(n,2))
54.854 + txt7 = sprintf("%5.2f", M_score_sort(n,3))
54.855 + txt8 = sprintf("%5.2f", M_score_sort(n,4))
54.856 + txt9 = sprintf("%5.2f", M_score_sort(n,5))
54.857 + txt10 = sprintf("%5.2f", avg(M_score_sort(n,:)))
54.858 +
54.859 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
54.860 + set_line(lines,nline,"<th>"+txt1+"</th>")
54.861 + set_line(lines,nline,"<th>"+txt2+"</th>")
54.862 + set_line(lines,nline,"<th>"+txt3+"</th>")
54.863 + set_line(lines,nline,"<th>"+txt4+"</th>")
54.864 + set_line(lines,nline,"<th>"+txt5+"</th>")
54.865 + set_line(lines,nline,"<th>"+txt6+"</th>")
54.866 + set_line(lines,nline,"<th>"+txt7+"</th>")
54.867 + set_line(lines,nline,"<th>"+txt8+"</th>")
54.868 + set_line(lines,nline,"<th>"+txt9+"</th>")
54.869 + set_line(lines,nline,"<th>"+txt10+"</th>")
54.870 +
54.871 + set_line(lines,nline,row_footer)
54.872 + end do
54.873 +
54.874 +; last row, summary
54.875 + set_line(lines,nline,row_header)
54.876 +
54.877 + txt0 = "All_"+sprintf("%.0f", nstation)
54.878 + txt1 = "-"
54.879 + txt2 = "-"
54.880 + txt3 = "-"
54.881 + txt4 = M_energy_co2
54.882 + txt5 = M_energy_rad
54.883 + txt6 = M_energy_lh
54.884 + txt7 = M_energy_sh
54.885 + txt8 = M_energy_gpp
54.886 + txt9 = M_energy_er
54.887 + txt10 = M_energy_all
54.888 +
54.889 + set_line(lines,nline,"<th>"+txt0+"</th>")
54.890 + set_line(lines,nline,"<th>"+txt1+"</th>")
54.891 + set_line(lines,nline,"<th>"+txt2+"</th>")
54.892 + set_line(lines,nline,"<th>"+txt3+"</th>")
54.893 + set_line(lines,nline,"<th>"+txt4+"</th>")
54.894 + set_line(lines,nline,"<th>"+txt5+"</th>")
54.895 + set_line(lines,nline,"<th>"+txt6+"</th>")
54.896 + set_line(lines,nline,"<th>"+txt7+"</th>")
54.897 + set_line(lines,nline,"<th>"+txt8+"</th>")
54.898 + set_line(lines,nline,"<th>"+txt9+"</th>")
54.899 + set_line(lines,nline,"<th>"+txt10+"</th>")
54.900 +
54.901 + set_line(lines,nline,row_footer)
54.902 +;-----------------------------------------------
54.903 + set_line(lines,nline,table_footer)
54.904 + set_line(lines,nline,footer)
54.905 +
54.906 +; Now write to an HTML file.
54.907 + idx = ind(.not.ismissing(lines))
54.908 + if(.not.any(ismissing(idx))) then
54.909 + asciiwrite(output_html,lines(idx))
54.910 + else
54.911 + print ("error?")
54.912 + end if
54.913 + delete (idx)
54.914 +
54.915 +;***************************************************************************
54.916 +; output plots
54.917 +;***************************************************************************
54.918 + output_dir = model_name+"/ameriflux"
54.919 +
54.920 + system("mv *.png *.html " + output_dir)
54.921 +;***************************************************************************
54.922 +end
54.923 +
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
55.2 +++ b/ameriflux/24.plot.ncl Mon Jan 26 22:08:20 2009 -0500
55.3 @@ -0,0 +1,847 @@
55.4 +;************************************************************
55.5 +; change data name to timeseries_L4_m.nc
55.6 +; move data
55.7 +; merge annual
55.8 +; add table
55.9 +; add time series plot
55.10 +; sort by latitude in decending order (N->S)
55.11 +; find year_ob >= 4
55.12 +; add year_ob_i and year_ob_f
55.13 +; change long_name
55.14 +;************************************************************
55.15 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
55.16 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
55.17 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
55.18 +;************************************************************
55.19 +procedure set_line(lines:string,nline:integer,newlines:string)
55.20 +begin
55.21 +; add line to ascci/html file
55.22 +
55.23 + nnewlines = dimsizes(newlines)
55.24 + if(nline+nnewlines-1.ge.dimsizes(lines))
55.25 + print("set_line: bad index, not setting anything.")
55.26 + return
55.27 + end if
55.28 + lines(nline:nline+nnewlines-1) = newlines
55.29 +; print ("lines = " + lines(nline:nline+nnewlines-1))
55.30 + nline = nline + nnewlines
55.31 + return
55.32 +end
55.33 +;*************************************************************
55.34 +begin
55.35 +
55.36 + plot_type = "ps"
55.37 + plot_type_new = "png"
55.38 +
55.39 +;************************************************
55.40 +; model data info
55.41 +;************************************************
55.42 + model = "cn"
55.43 +; model = "casa"
55.44 +
55.45 + model_name = "i01.10" + model
55.46 +
55.47 + ENERGY ="new"
55.48 +
55.49 + nmonth = 12
55.50 +
55.51 +;************************************************
55.52 +; observed data info
55.53 +;************************************************
55.54 +
55.55 + station = (/"ARM_Oklahoma" \
55.56 + ,"ARM_Oklahoma_burn" \
55.57 + ,"ARM_Oklahoma_control" \
55.58 + ,"Atqasuk" \
55.59 + ,"Audubon" \
55.60 + ,"AustinCary" \
55.61 + ,"Bartlett" \
55.62 + ,"Bondville" \
55.63 + ,"Brookings" \
55.64 + ,"Donaldson" \
55.65 + ,"Duke_Forest_Hardwoods" \
55.66 + ,"Duke_Forest_Open_Field" \
55.67 + ,"Duke_Forest_Pine" \
55.68 + ,"Fermi_Ag" \
55.69 + ,"Fermi_Prairie" \
55.70 + ,"Flagstaff_Managed" \
55.71 + ,"Flagstaff_Unmanaged" \
55.72 + ,"Flagstaff_Wildfire" \
55.73 + ,"FortPeck" \
55.74 + ,"FreemanRanch_mesquite" \
55.75 + ,"Goodwin_Creek" \
55.76 + ,"HarvardForest" \
55.77 + ,"HarvardForestHemlock" \
55.78 + ,"HowlandForestMain" \
55.79 + ,"HowlandForestWest" \
55.80 + ,"Ivotuk" \
55.81 + ,"KendallGrasslands" \
55.82 + ,"KennedySpaceCenterPine" \
55.83 + ,"KennedySpaceCenterScrub" \
55.84 + ,"LittleProspect" \
55.85 + ,"LostCreek" \
55.86 + ,"Mead-irrigated" \
55.87 + ,"Mead-irrigated-rotation" \
55.88 + ,"Mead-rainfed" \
55.89 + ,"Metolius_2nd_YoungPonderosaPine" \
55.90 + ,"MetoliusEyerly" \
55.91 + ,"MetoliusIntermediatePine" \
55.92 + ,"MetoliusOldPonderosaPine" \
55.93 + ,"MissouriOzark" \
55.94 + ,"Mize" \
55.95 + ,"MorganMonroe" \
55.96 + ,"NiwotRidge" \
55.97 + ,"NorthCarolina_cc" \
55.98 + ,"NorthCarolina_lp" \
55.99 + ,"ParkFalls" \
55.100 + ,"Rayonier" \
55.101 + ,"SantaRita" \
55.102 + ,"SkyOaks_Old" \
55.103 + ,"SkyOaks_PostFire" \
55.104 + ,"SkyOaks_Young" \
55.105 + ,"SylvaniaWilderness" \
55.106 + ,"Toledo" \
55.107 + ,"Tonzi" \
55.108 + ,"UCI_1850" \
55.109 + ,"UCI_1930" \
55.110 + ,"UCI_1964" \
55.111 + ,"UCI_1964wet" \
55.112 + ,"UCI_1981" \
55.113 + ,"UCI_1989" \
55.114 + ,"UCI_1998" \
55.115 + ,"UMBS" \
55.116 + ,"Vaira" \
55.117 + ,"WalkerBranch" \
55.118 + ,"WillowCreek" \
55.119 + ,"WindRiver" \
55.120 + ,"Wisconsin_ihw" \
55.121 + ,"Wisconsin_irp" \
55.122 + ,"Wisconsin_mrp" \
55.123 + ,"Wisconsin_myjp" \
55.124 + ,"Wisconsin_pb" \
55.125 + ,"Wisconsin_rpcc" \
55.126 + ,"Wisconsin_yhw" \
55.127 + ,"Wisconsin_yjp" \
55.128 + ,"Wisconsin_yrp" \
55.129 + /)
55.130 +
55.131 + field = (/"NEE Flux" \
55.132 + ,"Net Radiation" \
55.133 + ,"Latent Heat" \
55.134 + ,"Sensible Heat" \
55.135 + ,"GPP Flux" \
55.136 + ,"Respiration" \
55.137 + /)
55.138 +
55.139 + field_unit = (/"u mol/m2/s" \
55.140 + ,"W/m2" \
55.141 + ,"W/m2" \
55.142 + ,"W/m2" \
55.143 + ,"u mol/m2/s" \
55.144 + ,"u mol/m2/s" \
55.145 + /)
55.146 +
55.147 + nstation = dimsizes(station)
55.148 + nfield = dimsizes(field)
55.149 +
55.150 +;========================================================================
55.151 +; get observed info: number of year, first/last year, lat, lon
55.152 +; and annual data
55.153 +
55.154 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/observed/ameriflux/"
55.155 +
55.156 + year_station = new ((/nstation/),integer) ; number of year
55.157 + year_ob = new ((/nstation/),string) ; observed year
55.158 + year_ob_i = new ((/nstation/),integer) ; first year
55.159 + year_ob_f = new ((/nstation/),integer) ; last year
55.160 + lat_ob = new ((/nstation/),float) ; latitude
55.161 + lon_ob = new ((/nstation/),float) ; longitude
55.162 +
55.163 + data_ob_ann = new ((/nfield, nmonth, nstation/),float)
55.164 +
55.165 + do n = 0, nstation-1
55.166 +
55.167 + diro = dir_root + station(n)+"/"
55.168 + filo = "timeseries_L4_m.nc"
55.169 + fo = addfile (diro+filo,"r")
55.170 +
55.171 + lat_ob(n) = fo->lat
55.172 + lon_ob(n) = fo->lon
55.173 +
55.174 + year = fo->year
55.175 +
55.176 + year_station(n) = dimsizes(year)
55.177 + year_ob_i(n) = year(0)
55.178 + year_ob_f(n) = year(year_station(n)-1)
55.179 + year_ob(n) = year_ob_i(n) + "-" + year_ob_f(n)
55.180 +
55.181 + delete (year)
55.182 +
55.183 + data = fo->NEE_or_fMDS
55.184 + data_ob_ann(0,:,n) = dim_avg(data(month|:,year|:))
55.185 +
55.186 + data = fo->Rg_f
55.187 + data_ob_ann(1,:,n) = dim_avg(data(month|:,year|:))
55.188 +
55.189 + data = fo->LE_f
55.190 + data_ob_ann(2,:,n) = dim_avg(data(month|:,year|:))
55.191 +
55.192 + data = fo->H_f
55.193 + data_ob_ann(3,:,n) = dim_avg(data(month|:,year|:))
55.194 +
55.195 + data = fo->GPP_or_MDS
55.196 + data_ob_ann(4,:,n) = dim_avg(data(month|:,year|:))
55.197 +
55.198 + data = fo->Reco_or
55.199 + data_ob_ann(5,:,n) = dim_avg(data(month|:,year|:))
55.200 +
55.201 + delete (data)
55.202 + delete (fo)
55.203 + end do
55.204 +
55.205 +;print (year_ob_i)
55.206 +;print (year_ob_f)
55.207 +
55.208 +;--------------------------------------------------------------
55.209 +; find (# of year observed) >=4 and year_ob_i <= 2001
55.210 +
55.211 + i_long_ob = ind(year_station .ge. 4 .and. year_ob_i .le. 2001)
55.212 +
55.213 + station_long = station(i_long_ob)
55.214 + lat_ob_long = lat_ob(i_long_ob)
55.215 + lon_ob_long = lat_ob(i_long_ob)
55.216 + year_ob_long = year_ob(i_long_ob)
55.217 + year_ob_i_long = year_ob_i(i_long_ob)
55.218 + year_ob_f_long = year_ob_f(i_long_ob)
55.219 + year_station_long = year_station(i_long_ob)
55.220 +
55.221 + nstation_long = dimsizes(station_long)
55.222 +
55.223 +; print (i_long_ob)
55.224 +; print (nstation_long)
55.225 +; print (station_long)
55.226 +; print (year_ob_i(i_long_ob))
55.227 +
55.228 +;=========================================================
55.229 +; get model data at observed lat-lon
55.230 +
55.231 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
55.232 + film = model_name+"_ameriflux_1990-2004_monthly.nc"
55.233 + fm = addfile (dirm+film,"r")
55.234 +
55.235 + xm = fm->lon
55.236 + ym = fm->lat
55.237 + date = fm->date
55.238 +
55.239 + date_dim = dimsizes(date)
55.240 + nyear = date_dim(0)
55.241 +
55.242 + data_mod = new ((/nfield,nyear,nmonth,nstation/),float)
55.243 + data_mod_ann = new ((/nfield,nmonth,nstation/),float)
55.244 + data_mod_long = new ((/nfield,nyear,nmonth,nstation_long/),float)
55.245 +
55.246 +; change to unit of observed (u mol/m2/s)
55.247 +; Model_units [=] gC/m2/s
55.248 +; 12. = molecular weight of C
55.249 +; u mol = 1e-6 mol
55.250 +
55.251 + factor = 1.e6 /12.
55.252 +
55.253 +;------------------------------------------------------------
55.254 +; interpolate model data into observed station
55.255 +; note: model is 0-360E, 90S-90N
55.256 +
55.257 +; to be able to handle observation at (-89.98,-24.80)
55.258 + ym(0) = -90.
55.259 +;------------------------------------------------------------
55.260 +
55.261 +if (ENERGY .eq. "old") then
55.262 +
55.263 + data = fm->NEE
55.264 + data_mod(0,:,:,:) = data(:,:,:) * factor
55.265 +
55.266 +; data = fm->LATENT
55.267 + data1 = fm->FCEV
55.268 + data2 = fm->FCTR
55.269 + data3 = fm->FGEV
55.270 + data_mod(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
55.271 + delete (data1)
55.272 + delete (data2)
55.273 + delete (data3)
55.274 +
55.275 +; data = fm->SENSIBLE
55.276 + data = fm->FSH
55.277 + data_mod(3,:,:,:) = data(:,:,:)
55.278 +
55.279 +; data = fm->NETRAD
55.280 + data1 = fm->FSA
55.281 + data2 = fm->FIRA
55.282 + data_mod(1,:,:,:) = data1(:,:,:)-data2(:,:,:)
55.283 + delete (data1)
55.284 + delete (data2)
55.285 +
55.286 +else
55.287 +
55.288 + data = fm->NEE
55.289 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
55.290 + data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
55.291 + data_mod(0,:,:,:) = yy(:,:,:) * factor
55.292 +
55.293 +; printVarSummary(yy)
55.294 +
55.295 + data = fm->NETRAD
55.296 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
55.297 + data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:))
55.298 + data_mod(1,:,:,:) = yy(:,:,:)
55.299 +
55.300 + data = fm->LATENT
55.301 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
55.302 + data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:))
55.303 + data_mod(2,:,:,:) = yy(:,:,:)
55.304 +
55.305 +; data = fm->SENSIBLE
55.306 + data = fm->FSH
55.307 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
55.308 + data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:))
55.309 + data_mod(3,:,:,:) = yy(:,:,:)
55.310 +
55.311 +end if
55.312 +
55.313 + data = fm->GPP
55.314 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
55.315 + data_mod_ann(4,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
55.316 + data_mod(4,:,:,:) = yy(:,:,:) * factor
55.317 +
55.318 + if (model .eq. "cn") then
55.319 + data = fm->ER
55.320 + else
55.321 + data1 = fm->AR
55.322 + data2 = fm->HR
55.323 + data = data1 + data2
55.324 +
55.325 + delete (data1)
55.326 + delete (data2)
55.327 + end if
55.328 +
55.329 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
55.330 + data_mod_ann(5,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor
55.331 + data_mod(5,:,:,:) = yy(:,:,:) * factor
55.332 +
55.333 + data_mod_long(:,:,:,:) = data_mod(:,:,:,i_long_ob)
55.334 +
55.335 + delete (data_mod)
55.336 + delete (fm)
55.337 + delete (data)
55.338 + delete (yy)
55.339 +
55.340 +;*******************************************************************
55.341 +; for station line plot
55.342 +;*******************************************************************
55.343 +
55.344 +; for x-axis in xyplot
55.345 + mon = ispan(1,12,1)
55.346 + mon@long_name = "month"
55.347 +
55.348 + res = True ; plot mods desired
55.349 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
55.350 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
55.351 +
55.352 + res@tmXBFormat = "f" ; not to add trailing zeros
55.353 +
55.354 +;-------------------------------------------------------------------------
55.355 +; Add a boxed legend using the more simple method
55.356 +
55.357 + res@pmLegendDisplayMode = "Always"
55.358 +; res@pmLegendWidthF = 0.1
55.359 + res@pmLegendWidthF = 0.08
55.360 + res@pmLegendHeightF = 0.06
55.361 +; res@pmLegendOrthogonalPosF = -1.17
55.362 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
55.363 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
55.364 +
55.365 +; res@pmLegendParallelPosF = 0.18
55.366 + res@pmLegendParallelPosF = 0.23 ;(rightward)
55.367 +
55.368 +; res@lgPerimOn = False
55.369 + res@lgLabelFontHeightF = 0.015
55.370 + res@xyExplicitLegendLabels = (/"observed",model_name/)
55.371 +;-------------------------------------------------------------------
55.372 +; for panel plot
55.373 + res@gsnFrame = False ; Do not draw plot
55.374 + res@gsnDraw = False ; Do not advance frame
55.375 +
55.376 + pres = True ; panel plot mods desired
55.377 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
55.378 + ; indiv. plots in panel
55.379 + pres@gsnMaximize = True ; fill the page
55.380 +;-------------------------------------------------------------------
55.381 +
55.382 +;==============================================================
55.383 +; get ob data at each site with long observation
55.384 +
55.385 + dir_root = "/fis/cgd/cseg/people/jeff/clamp/ameriflux/data/"
55.386 +
55.387 + do n = 0,nstation_long-1
55.388 +; do n = 0,0
55.389 +
55.390 + year_setback = 0
55.391 +
55.392 + nyear = year_station_long(n)
55.393 +
55.394 + if (year_ob_f_long(n).eq. 2006) then
55.395 + year_setback = 2006 -2004
55.396 + end if
55.397 + if (year_ob_f_long(n).eq. 2005) then
55.398 + year_setback = 2005 -2004
55.399 + end if
55.400 +
55.401 + ntime = (nyear - year_setback) * nmonth
55.402 +
55.403 + data_ob = new ((/nfield, nyear, nmonth/),float)
55.404 +
55.405 + diro = dir_root + station_long(n)+"/"
55.406 + filo = year_ob_long(n)+"_L4_m.nc"
55.407 + fo = addfile (diro+filo,"r")
55.408 +
55.409 +; print (diro)
55.410 +; print (filo)
55.411 +
55.412 + data_ob(0,:,:) = fo->NEE_or_fMDS
55.413 + data_ob(1,:,:) = fo->Rg_f
55.414 + data_ob(2,:,:) = fo->LE_f
55.415 + data_ob(3,:,:) = fo->H_f
55.416 + data_ob(4,:,:) = fo->GPP_or_MDS
55.417 + data_ob(5,:,:) = fo->Reco_or
55.418 +
55.419 + delete (fo)
55.420 +
55.421 + timeI = new((/ntime/),integer)
55.422 + timeF = new((/ntime/),float)
55.423 + timeI = ispan(1,ntime,1)
55.424 + timeF = year_ob_i_long(n) + (timeI-1)/12.
55.425 + timeF@long_name = "year"
55.426 +
55.427 + plot_data = new((/2,ntime/),float)
55.428 +
55.429 +;----------------------------
55.430 +; for model_vs_ob
55.431 +
55.432 + plot_name = station_long(n)+"_tseries_vs_ob"
55.433 + title = station_long(n)+"("+sprintf("%5.2f",lat_ob_long(n))+","+sprintf("%5.2f",lon_ob_long(n))+")"
55.434 + res@tiMainString = title
55.435 +
55.436 + wks = gsn_open_wks (plot_type,plot_name)
55.437 + plot=new(nfield,graphic) ; create graphic array
55.438 +
55.439 + i_year_mod_i = year_ob_i_long(n) - 1990
55.440 + i_year_mod_f = i_year_mod_i + nyear - 1 - year_setback
55.441 +
55.442 + i_year_ob_f = nyear - year_setback - 1
55.443 +
55.444 +; print (nyear)
55.445 +; print (i_year_ob_f)
55.446 +; print (i_year_mod_i)
55.447 +; print (i_year_mod_f)
55.448 +
55.449 + do i = 0,nfield-1
55.450 + plot_data(0,:) = ndtooned(data_ob (i,0:i_year_ob_f,:))
55.451 + plot_data(1,:) = ndtooned(data_mod_long(i,i_year_mod_i:i_year_mod_f,:,n))
55.452 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
55.453 + plot(i)=gsn_csm_xy(wks,timeF,plot_data,res) ; create plot
55.454 + end do
55.455 +
55.456 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
55.457 +
55.458 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
55.459 + "rm "+plot_name+"."+plot_type)
55.460 +
55.461 + clear (wks)
55.462 + delete (plot)
55.463 +
55.464 + delete (data_ob)
55.465 + delete (timeI)
55.466 + delete (timeF)
55.467 + delete (plot_data)
55.468 +
55.469 + end do
55.470 +
55.471 +;###################################################################
55.472 +; for the following tables,
55.473 +; sort by latitude in decending order (N->S)
55.474 +
55.475 + isort = dim_pqsort(lat_ob_long,-1)
55.476 +
55.477 + station_sort = station_long(isort)
55.478 + year_ob_sort = year_ob_long(isort)
55.479 + lat_ob_sort = lat_ob_long(isort)
55.480 + lon_ob_sort = lon_ob_long(isort)
55.481 +
55.482 +; print(isort)
55.483 +; print(lat_ob_sort)
55.484 +
55.485 +;*******************************************************************
55.486 +; html table of site: observed
55.487 +;*******************************************************************
55.488 + output_html = "tseries_vs_ob.html"
55.489 +
55.490 + header = (/"<HTML>" \
55.491 + ,"<HEAD>" \
55.492 + ,"<TITLE>CLAMP metrics</TITLE>" \
55.493 + ,"</HEAD>" \
55.494 + ,"<H1>Timeseries at Site: "+model_name+" vs Observation</H1>" \
55.495 + /)
55.496 + footer = "</HTML>"
55.497 +
55.498 + table_header = (/ \
55.499 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
55.500 + ,"<tr>" \
55.501 + ," <th bgcolor=DDDDDD >Site Name</th>" \
55.502 + ," <th bgcolor=DDDDDD >Latitude</th>" \
55.503 + ," <th bgcolor=DDDDDD >Longitude</th>" \
55.504 + ," <th bgcolor=DDDDDD >Observed</th>" \
55.505 + ,"</tr>" \
55.506 + /)
55.507 + table_footer = "</table>"
55.508 + row_header = "<tr>"
55.509 + row_footer = "</tr>"
55.510 +
55.511 + lines = new(50000,string)
55.512 + nline = 0
55.513 +
55.514 + set_line(lines,nline,header)
55.515 + set_line(lines,nline,table_header)
55.516 +;-----------------------------------------------
55.517 +; row of table
55.518 +
55.519 + do n = 0,nstation_long-1
55.520 +
55.521 + set_line(lines,nline,row_header)
55.522 +
55.523 + txt0 = station_sort(n)
55.524 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
55.525 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
55.526 + txt3 = year_ob_sort(n)
55.527 +
55.528 + set_line(lines,nline,"<th><a href="+txt0+"_tseries_vs_ob.png>"+txt0+"</a></th>")
55.529 + set_line(lines,nline,"<th>"+txt1+"</th>")
55.530 + set_line(lines,nline,"<th>"+txt2+"</th>")
55.531 + set_line(lines,nline,"<th>"+txt3+"</th>")
55.532 +
55.533 + set_line(lines,nline,row_footer)
55.534 + end do
55.535 +;-----------------------------------------------
55.536 + set_line(lines,nline,table_footer)
55.537 + set_line(lines,nline,footer)
55.538 +
55.539 +; Now write to an HTML file.
55.540 + idx = ind(.not.ismissing(lines))
55.541 + if(.not.any(ismissing(idx))) then
55.542 + asciiwrite(output_html,lines(idx))
55.543 + else
55.544 + print ("error?")
55.545 + end if
55.546 + delete (idx)
55.547 +
55.548 + delete (isort)
55.549 + delete (station_sort)
55.550 + delete (year_ob_sort)
55.551 + delete (lat_ob_sort)
55.552 + delete (lon_ob_sort)
55.553 +
55.554 +;************************************************************
55.555 +; compute annual cycle correlation coef and M score
55.556 +;************************************************************
55.557 +
55.558 + score_max = 5.
55.559 +
55.560 + ccr = new ((/nstation, nfield/),float)
55.561 + M_score = new ((/nstation, nfield/),float)
55.562 +
55.563 + do n=0,nstation-1
55.564 + do m=0,nfield-1
55.565 + ccr(n,m) = esccr(data_ob_ann(m,:,n),data_mod_ann(m,:,n),0)
55.566 + 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))))
55.567 + M_score(n,m) = (1. -(bias/nmonth)) * score_max
55.568 + end do
55.569 + end do
55.570 +
55.571 + M_co2 = avg(M_score(:,0))
55.572 + M_rad = avg(M_score(:,1))
55.573 + M_lh = avg(M_score(:,2))
55.574 + M_sh = avg(M_score(:,3))
55.575 + M_gpp = avg(M_score(:,4))
55.576 + M_er = avg(M_score(:,5))
55.577 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
55.578 +
55.579 + M_energy_co2 = sprintf("%.2f", M_co2)
55.580 + M_energy_rad = sprintf("%.2f", M_rad)
55.581 + M_energy_lh = sprintf("%.2f", M_lh )
55.582 + M_energy_sh = sprintf("%.2f", M_sh )
55.583 + M_energy_gpp = sprintf("%.2f", M_gpp)
55.584 + M_energy_er = sprintf("%.2f", M_er )
55.585 + M_energy_all = sprintf("%.2f", M_all)
55.586 +
55.587 +;*******************************************************************
55.588 +; for station line plot
55.589 +;*******************************************************************
55.590 +
55.591 +; for x-axis in xyplot
55.592 + mon = ispan(1,12,1)
55.593 + mon@long_name = "month"
55.594 +
55.595 +;-------------------------------------------------------------------
55.596 +
55.597 + plot_data = new((/2,nmonth/),float)
55.598 + plot_data!0 = "case"
55.599 + plot_data!1 = "month"
55.600 +
55.601 + do n = 0,nstation-1
55.602 +;----------------------------
55.603 +; for observed
55.604 +
55.605 + plot_name = station(n)+"_ob"
55.606 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
55.607 + res@tiMainString = title
55.608 +
55.609 + wks = gsn_open_wks (plot_type,plot_name)
55.610 + plot=new(nfield,graphic) ; create graphic array
55.611 +
55.612 + do i = 0,nfield-1
55.613 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
55.614 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
55.615 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
55.616 + end do
55.617 +
55.618 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
55.619 +
55.620 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
55.621 + "rm "+plot_name+"."+plot_type)
55.622 +
55.623 + clear (wks)
55.624 + delete (plot)
55.625 +;----------------------------
55.626 +; for model_vs_ob
55.627 +
55.628 + plot_name = station(n)+"_model_vs_ob"
55.629 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
55.630 + res@tiMainString = title
55.631 +
55.632 + wks = gsn_open_wks (plot_type,plot_name)
55.633 + plot=new(nfield,graphic) ; create graphic array
55.634 +
55.635 + do i = 0,nfield-1
55.636 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
55.637 + plot_data(1,:) = (/data_mod_ann(i,:,n)/)
55.638 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
55.639 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
55.640 + end do
55.641 +
55.642 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
55.643 +
55.644 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
55.645 + "rm "+plot_name+"."+plot_type)
55.646 +
55.647 + clear (wks)
55.648 + delete (plot)
55.649 + end do
55.650 +
55.651 +;###################################################################
55.652 +; for the following tables,
55.653 +; sort by latitude in decending order (N->S)
55.654 +; sort by lat in decending order (N->S)
55.655 +
55.656 + isort = dim_pqsort(lat_ob,-1)
55.657 +
55.658 + station_sort = station(isort)
55.659 + year_ob_sort = year_ob(isort)
55.660 + lat_ob_sort = lat_ob(isort)
55.661 + lon_ob_sort = lon_ob(isort)
55.662 + M_score_sort = M_score(isort,:)
55.663 +
55.664 +; print(isort)
55.665 +; print(lat_ob_sort)
55.666 +;###################################################################
55.667 +;*******************************************************************
55.668 +; html table of site: observed
55.669 +;*******************************************************************
55.670 + output_html = "line_ob.html"
55.671 +
55.672 + header = (/"<HTML>" \
55.673 + ,"<HEAD>" \
55.674 + ,"<TITLE>CLAMP metrics</TITLE>" \
55.675 + ,"</HEAD>" \
55.676 + ,"<H1>Energy at Site: Observation</H1>" \
55.677 + /)
55.678 + footer = "</HTML>"
55.679 +
55.680 + table_header = (/ \
55.681 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
55.682 + ,"<tr>" \
55.683 + ," <th bgcolor=DDDDDD >Site Name</th>" \
55.684 + ," <th bgcolor=DDDDDD >Latitude</th>" \
55.685 + ," <th bgcolor=DDDDDD >Longitude</th>" \
55.686 + ," <th bgcolor=DDDDDD >Observed</th>" \
55.687 + ,"</tr>" \
55.688 + /)
55.689 + table_footer = "</table>"
55.690 + row_header = "<tr>"
55.691 + row_footer = "</tr>"
55.692 +
55.693 + lines = new(50000,string)
55.694 + nline = 0
55.695 +
55.696 + set_line(lines,nline,header)
55.697 + set_line(lines,nline,table_header)
55.698 +;-----------------------------------------------
55.699 +; row of table
55.700 +
55.701 + do n = 0,nstation-1
55.702 + set_line(lines,nline,row_header)
55.703 +
55.704 + txt0 = station_sort(n)
55.705 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
55.706 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
55.707 + txt3 = year_ob_sort(n)
55.708 +
55.709 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
55.710 + set_line(lines,nline,"<th>"+txt1+"</th>")
55.711 + set_line(lines,nline,"<th>"+txt2+"</th>")
55.712 + set_line(lines,nline,"<th>"+txt3+"</th>")
55.713 +
55.714 + set_line(lines,nline,row_footer)
55.715 + end do
55.716 +;-----------------------------------------------
55.717 + set_line(lines,nline,table_footer)
55.718 + set_line(lines,nline,footer)
55.719 +
55.720 +; Now write to an HTML file.
55.721 + idx = ind(.not.ismissing(lines))
55.722 + if(.not.any(ismissing(idx))) then
55.723 + asciiwrite(output_html,lines(idx))
55.724 + else
55.725 + print ("error?")
55.726 + end if
55.727 + delete (idx)
55.728 +
55.729 +;*******************************************************************
55.730 +; score and line table : model vs observed
55.731 +;*******************************************************************
55.732 + output_html = "score+line_vs_ob.html"
55.733 +
55.734 + header = (/"<HTML>" \
55.735 + ,"<HEAD>" \
55.736 + ,"<TITLE>CLAMP metrics</TITLE>" \
55.737 + ,"</HEAD>" \
55.738 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
55.739 + /)
55.740 + footer = "</HTML>"
55.741 +
55.742 + delete (table_header)
55.743 + table_header = (/ \
55.744 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
55.745 + ,"<tr>" \
55.746 + ," <th bgcolor=DDDDDD >Site Name</th>" \
55.747 + ," <th bgcolor=DDDDDD >Latitude</th>" \
55.748 + ," <th bgcolor=DDDDDD >Longitude</th>" \
55.749 + ," <th bgcolor=DDDDDD >Observed</th>" \
55.750 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
55.751 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
55.752 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
55.753 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
55.754 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
55.755 + ," <th bgcolor=DDDDDD >Respiration</th>" \
55.756 + ," <th bgcolor=DDDDDD >Average</th>" \
55.757 + ,"</tr>" \
55.758 + /)
55.759 + table_footer = "</table>"
55.760 + row_header = "<tr>"
55.761 + row_footer = "</tr>"
55.762 +
55.763 + lines = new(50000,string)
55.764 + nline = 0
55.765 +
55.766 + set_line(lines,nline,header)
55.767 + set_line(lines,nline,table_header)
55.768 +;-----------------------------------------------
55.769 +; row of table
55.770 +
55.771 + do n = 0,nstation-1
55.772 + set_line(lines,nline,row_header)
55.773 +
55.774 + txt0 = station_sort(n)
55.775 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
55.776 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
55.777 + txt3 = year_ob_sort(n)
55.778 + txt4 = sprintf("%5.2f", M_score_sort(n,0))
55.779 + txt5 = sprintf("%5.2f", M_score_sort(n,1))
55.780 + txt6 = sprintf("%5.2f", M_score_sort(n,2))
55.781 + txt7 = sprintf("%5.2f", M_score_sort(n,3))
55.782 + txt8 = sprintf("%5.2f", M_score_sort(n,4))
55.783 + txt9 = sprintf("%5.2f", M_score_sort(n,5))
55.784 + txt10 = sprintf("%5.2f", avg(M_score_sort(n,:)))
55.785 +
55.786 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
55.787 + set_line(lines,nline,"<th>"+txt1+"</th>")
55.788 + set_line(lines,nline,"<th>"+txt2+"</th>")
55.789 + set_line(lines,nline,"<th>"+txt3+"</th>")
55.790 + set_line(lines,nline,"<th>"+txt4+"</th>")
55.791 + set_line(lines,nline,"<th>"+txt5+"</th>")
55.792 + set_line(lines,nline,"<th>"+txt6+"</th>")
55.793 + set_line(lines,nline,"<th>"+txt7+"</th>")
55.794 + set_line(lines,nline,"<th>"+txt8+"</th>")
55.795 + set_line(lines,nline,"<th>"+txt9+"</th>")
55.796 + set_line(lines,nline,"<th>"+txt10+"</th>")
55.797 +
55.798 + set_line(lines,nline,row_footer)
55.799 + end do
55.800 +
55.801 +; last row, summary
55.802 + set_line(lines,nline,row_header)
55.803 +
55.804 + txt0 = "All_"+sprintf("%.0f", nstation)
55.805 + txt1 = "-"
55.806 + txt2 = "-"
55.807 + txt3 = "-"
55.808 + txt4 = M_energy_co2
55.809 + txt5 = M_energy_rad
55.810 + txt6 = M_energy_lh
55.811 + txt7 = M_energy_sh
55.812 + txt8 = M_energy_gpp
55.813 + txt9 = M_energy_er
55.814 + txt10 = M_energy_all
55.815 +
55.816 + set_line(lines,nline,"<th>"+txt0+"</th>")
55.817 + set_line(lines,nline,"<th>"+txt1+"</th>")
55.818 + set_line(lines,nline,"<th>"+txt2+"</th>")
55.819 + set_line(lines,nline,"<th>"+txt3+"</th>")
55.820 + set_line(lines,nline,"<th>"+txt4+"</th>")
55.821 + set_line(lines,nline,"<th>"+txt5+"</th>")
55.822 + set_line(lines,nline,"<th>"+txt6+"</th>")
55.823 + set_line(lines,nline,"<th>"+txt7+"</th>")
55.824 + set_line(lines,nline,"<th>"+txt8+"</th>")
55.825 + set_line(lines,nline,"<th>"+txt9+"</th>")
55.826 + set_line(lines,nline,"<th>"+txt10+"</th>")
55.827 +
55.828 + set_line(lines,nline,row_footer)
55.829 +;-----------------------------------------------
55.830 + set_line(lines,nline,table_footer)
55.831 + set_line(lines,nline,footer)
55.832 +
55.833 +; Now write to an HTML file.
55.834 + idx = ind(.not.ismissing(lines))
55.835 + if(.not.any(ismissing(idx))) then
55.836 + asciiwrite(output_html,lines(idx))
55.837 + else
55.838 + print ("error?")
55.839 + end if
55.840 + delete (idx)
55.841 +
55.842 +;***************************************************************************
55.843 +; output plots
55.844 +;***************************************************************************
55.845 + output_dir = model_name+"/ameriflux"
55.846 +
55.847 + system("mv *.png *.html " + output_dir)
55.848 +;***************************************************************************
55.849 +end
55.850 +
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
56.2 +++ b/ameriflux/25.plot.ncl Mon Jan 26 22:08:20 2009 -0500
56.3 @@ -0,0 +1,863 @@
56.4 +;************************************************************
56.5 +; change data name to timeseries_L4_m.nc
56.6 +; move data
56.7 +; merge annual
56.8 +; add table
56.9 +; add time series plot
56.10 +; sort by latitude in decending order (N->S)
56.11 +; find year_ob >= 4
56.12 +; add year_ob_i and year_ob_f
56.13 +; change long_name
56.14 +;************************************************************
56.15 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
56.16 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
56.17 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
56.18 +;************************************************************
56.19 +procedure set_line(lines:string,nline:integer,newlines:string)
56.20 +begin
56.21 +; add line to ascci/html file
56.22 +
56.23 + nnewlines = dimsizes(newlines)
56.24 + if(nline+nnewlines-1.ge.dimsizes(lines))
56.25 + print("set_line: bad index, not setting anything.")
56.26 + return
56.27 + end if
56.28 + lines(nline:nline+nnewlines-1) = newlines
56.29 +; print ("lines = " + lines(nline:nline+nnewlines-1))
56.30 + nline = nline + nnewlines
56.31 + return
56.32 +end
56.33 +;*************************************************************
56.34 +begin
56.35 +
56.36 + plot_type = "ps"
56.37 + plot_type_new = "png"
56.38 +
56.39 +;************************************************
56.40 +; model data info
56.41 +;************************************************
56.42 + model = "cn"
56.43 +; model = "casa"
56.44 +
56.45 + model_name = "i01.10" + model
56.46 +
56.47 + ENERGY ="new"
56.48 +
56.49 + nmonth = 12
56.50 +
56.51 +; for nee, gpp, and ar
56.52 +; observed unit is gC/m2/day
56.53 +; model unit is gC/m2/s
56.54 +; to change to observed unit,
56.55 +
56.56 + factor_flux = 86400.
56.57 +
56.58 +; for incident solar radiation,
56.59 +; observed Rg_f unit is MJ/m2/day
56.60 +; model (FSDS) unit is W/m2
56.61 +; to change to model unit,
56.62 +
56.63 + factor_rad = 1.e6/86400.
56.64 +
56.65 +; model unit is gC/m2/s
56.66 +; change to unit of observed (u mol/m2/s)
56.67 +; 12. = molecular weight of C
56.68 +; u mol = 1e-6 mol
56.69 +; factor_flux = 1.e6 /12.
56.70 +
56.71 +;************************************************
56.72 +; observed data info
56.73 +;************************************************
56.74 +
56.75 + station = (/"ARM_Oklahoma" \
56.76 + ,"ARM_Oklahoma_burn" \
56.77 + ,"ARM_Oklahoma_control" \
56.78 + ,"Atqasuk" \
56.79 + ,"Audubon" \
56.80 + ,"AustinCary" \
56.81 + ,"Bartlett" \
56.82 + ,"Bondville" \
56.83 + ,"Brookings" \
56.84 + ,"Donaldson" \
56.85 + ,"Duke_Forest_Hardwoods" \
56.86 + ,"Duke_Forest_Open_Field" \
56.87 + ,"Duke_Forest_Pine" \
56.88 + ,"Fermi_Ag" \
56.89 + ,"Fermi_Prairie" \
56.90 + ,"Flagstaff_Managed" \
56.91 + ,"Flagstaff_Unmanaged" \
56.92 + ,"Flagstaff_Wildfire" \
56.93 + ,"FortPeck" \
56.94 + ,"FreemanRanch_mesquite" \
56.95 + ,"Goodwin_Creek" \
56.96 + ,"HarvardForest" \
56.97 + ,"HarvardForestHemlock" \
56.98 + ,"HowlandForestMain" \
56.99 + ,"HowlandForestWest" \
56.100 + ,"Ivotuk" \
56.101 + ,"KendallGrasslands" \
56.102 + ,"KennedySpaceCenterPine" \
56.103 + ,"KennedySpaceCenterScrub" \
56.104 + ,"LittleProspect" \
56.105 + ,"LostCreek" \
56.106 + ,"Mead-irrigated" \
56.107 + ,"Mead-irrigated-rotation" \
56.108 + ,"Mead-rainfed" \
56.109 + ,"Metolius_2nd_YoungPonderosaPine" \
56.110 + ,"MetoliusEyerly" \
56.111 + ,"MetoliusIntermediatePine" \
56.112 + ,"MetoliusOldPonderosaPine" \
56.113 + ,"MissouriOzark" \
56.114 + ,"Mize" \
56.115 + ,"MorganMonroe" \
56.116 + ,"NiwotRidge" \
56.117 + ,"NorthCarolina_cc" \
56.118 + ,"NorthCarolina_lp" \
56.119 + ,"ParkFalls" \
56.120 + ,"Rayonier" \
56.121 + ,"SantaRita" \
56.122 + ,"SkyOaks_Old" \
56.123 + ,"SkyOaks_PostFire" \
56.124 + ,"SkyOaks_Young" \
56.125 + ,"SylvaniaWilderness" \
56.126 + ,"Toledo" \
56.127 + ,"Tonzi" \
56.128 + ,"UCI_1850" \
56.129 + ,"UCI_1930" \
56.130 + ,"UCI_1964" \
56.131 + ,"UCI_1964wet" \
56.132 + ,"UCI_1981" \
56.133 + ,"UCI_1989" \
56.134 + ,"UCI_1998" \
56.135 + ,"UMBS" \
56.136 + ,"Vaira" \
56.137 + ,"WalkerBranch" \
56.138 + ,"WillowCreek" \
56.139 + ,"WindRiver" \
56.140 + ,"Wisconsin_ihw" \
56.141 + ,"Wisconsin_irp" \
56.142 + ,"Wisconsin_mrp" \
56.143 + ,"Wisconsin_myjp" \
56.144 + ,"Wisconsin_pb" \
56.145 + ,"Wisconsin_rpcc" \
56.146 + ,"Wisconsin_yhw" \
56.147 + ,"Wisconsin_yjp" \
56.148 + ,"Wisconsin_yrp" \
56.149 + /)
56.150 +
56.151 + field = (/"NEE Flux" \
56.152 + ,"Shortwave Incoming" \
56.153 + ,"Latent Heat" \
56.154 + ,"Sensible Heat" \
56.155 + ,"GPP Flux" \
56.156 + ,"Respiration" \
56.157 + /)
56.158 +
56.159 + field_unit = (/"gC/m2/day" \
56.160 + ,"W/m2" \
56.161 + ,"W/m2" \
56.162 + ,"W/m2" \
56.163 + ,"gC/m2/day" \
56.164 + ,"gC/m2/day" \
56.165 + /)
56.166 +
56.167 + nstation = dimsizes(station)
56.168 + nfield = dimsizes(field)
56.169 +
56.170 +;========================================================================
56.171 +; get observed info: number of year, first/last year, lat, lon
56.172 +; and annual data
56.173 +
56.174 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/observed/ameriflux/"
56.175 +
56.176 + year_station = new ((/nstation/),integer) ; number of year
56.177 + year_ob = new ((/nstation/),string) ; observed year
56.178 + year_ob_i = new ((/nstation/),integer) ; first year
56.179 + year_ob_f = new ((/nstation/),integer) ; last year
56.180 + lat_ob = new ((/nstation/),float) ; latitude
56.181 + lon_ob = new ((/nstation/),float) ; longitude
56.182 +
56.183 + data_ob_ann = new ((/nfield, nmonth, nstation/),float)
56.184 +
56.185 + do n = 0, nstation-1
56.186 +
56.187 + diro = dir_root + station(n)+"/"
56.188 + filo = "timeseries_L4_m.nc"
56.189 + fo = addfile (diro+filo,"r")
56.190 +
56.191 + lat_ob(n) = fo->lat
56.192 + lon_ob(n) = fo->lon
56.193 +
56.194 + year = fo->year
56.195 +
56.196 + year_station(n) = dimsizes(year)
56.197 + year_ob_i(n) = year(0)
56.198 + year_ob_f(n) = year(year_station(n)-1)
56.199 + year_ob(n) = year_ob_i(n) + "-" + year_ob_f(n)
56.200 +
56.201 + delete (year)
56.202 +
56.203 + data = fo->NEE_or_fMDS
56.204 + data_ob_ann(0,:,n) = dim_avg(data(month|:,year|:))
56.205 +
56.206 + data = fo->Rg_f
56.207 + data_ob_ann(1,:,n) = dim_avg(data(month|:,year|:))*factor_rad
56.208 +
56.209 + data = fo->LE_f
56.210 + data_ob_ann(2,:,n) = dim_avg(data(month|:,year|:))
56.211 +
56.212 + data = fo->H_f
56.213 + data_ob_ann(3,:,n) = dim_avg(data(month|:,year|:))
56.214 +
56.215 + data = fo->GPP_or_MDS
56.216 + data_ob_ann(4,:,n) = dim_avg(data(month|:,year|:))
56.217 +
56.218 + data = fo->Reco_or
56.219 + data_ob_ann(5,:,n) = dim_avg(data(month|:,year|:))
56.220 +
56.221 + delete (data)
56.222 + delete (fo)
56.223 + end do
56.224 +
56.225 +;print (year_ob_i)
56.226 +;print (year_ob_f)
56.227 +
56.228 +;--------------------------------------------------------------
56.229 +; find (# of year observed) >=4 and year_ob_i <= 2001
56.230 +
56.231 + i_long_ob = ind(year_station .ge. 4 .and. year_ob_i .le. 2001)
56.232 +
56.233 + station_long = station(i_long_ob)
56.234 + lat_ob_long = lat_ob(i_long_ob)
56.235 + lon_ob_long = lat_ob(i_long_ob)
56.236 + year_ob_long = year_ob(i_long_ob)
56.237 + year_ob_i_long = year_ob_i(i_long_ob)
56.238 + year_ob_f_long = year_ob_f(i_long_ob)
56.239 + year_station_long = year_station(i_long_ob)
56.240 +
56.241 + nstation_long = dimsizes(station_long)
56.242 +
56.243 +; print (i_long_ob)
56.244 +; print (nstation_long)
56.245 +; print (station_long)
56.246 +; print (year_ob_i(i_long_ob))
56.247 +
56.248 +;=========================================================
56.249 +; get model data at observed lat-lon
56.250 +
56.251 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
56.252 + film = model_name+"_ameriflux_1990-2004_monthly.nc"
56.253 + fm = addfile (dirm+film,"r")
56.254 +
56.255 + xm = fm->lon
56.256 + ym = fm->lat
56.257 + date = fm->date
56.258 +
56.259 + date_dim = dimsizes(date)
56.260 + nyear = date_dim(0)
56.261 +
56.262 + data_mod = new ((/nfield,nyear,nmonth,nstation/),float)
56.263 + data_mod_ann = new ((/nfield,nmonth,nstation/),float)
56.264 + data_mod_long = new ((/nfield,nyear,nmonth,nstation_long/),float)
56.265 +
56.266 +;------------------------------------------------------------
56.267 +; interpolate model data into observed station
56.268 +; note: model is 0-360E, 90S-90N
56.269 +
56.270 +; to be able to handle observation at (-89.98,-24.80)
56.271 + ym(0) = -90.
56.272 +;------------------------------------------------------------
56.273 +
56.274 +if (ENERGY .eq. "old") then
56.275 +
56.276 + data = fm->NEE
56.277 + data_mod(0,:,:,:) = data(:,:,:) * factor
56.278 +
56.279 +; data = fm->LATENT
56.280 + data1 = fm->FCEV
56.281 + data2 = fm->FCTR
56.282 + data3 = fm->FGEV
56.283 + data_mod(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
56.284 + delete (data1)
56.285 + delete (data2)
56.286 + delete (data3)
56.287 +
56.288 +; data = fm->SENSIBLE
56.289 + data = fm->FSH
56.290 + data_mod(3,:,:,:) = data(:,:,:)
56.291 +
56.292 +; data = fm->NETRAD
56.293 + data1 = fm->FSA
56.294 + data2 = fm->FIRA
56.295 + data_mod(1,:,:,:) = data1(:,:,:)-data2(:,:,:)
56.296 + delete (data1)
56.297 + delete (data2)
56.298 +
56.299 +else
56.300 +
56.301 + data = fm->NEE
56.302 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
56.303 + data_mod_ann(0,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
56.304 + data_mod(0,:,:,:) = yy(:,:,:) * factor_flux
56.305 +
56.306 +; printVarSummary(yy)
56.307 +
56.308 +; data = fm->NETRAD
56.309 + data = fm->FSDS
56.310 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
56.311 + data_mod_ann(1,:,:)= dim_avg(yy(month|:,pts|:,year|:))
56.312 + data_mod(1,:,:,:) = yy(:,:,:)
56.313 +
56.314 + data = fm->LATENT
56.315 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
56.316 + data_mod_ann(2,:,:)= dim_avg(yy(month|:,pts|:,year|:))
56.317 + data_mod(2,:,:,:) = yy(:,:,:)
56.318 +
56.319 +; data = fm->SENSIBLE
56.320 + data = fm->FSH
56.321 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
56.322 + data_mod_ann(3,:,:)= dim_avg(yy(month|:,pts|:,year|:))
56.323 + data_mod(3,:,:,:) = yy(:,:,:)
56.324 +
56.325 +end if
56.326 +
56.327 + data = fm->GPP
56.328 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
56.329 + data_mod_ann(4,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
56.330 + data_mod(4,:,:,:) = yy(:,:,:) * factor_flux
56.331 +
56.332 + if (model .eq. "cn") then
56.333 + data = fm->ER
56.334 + else
56.335 + data1 = fm->AR
56.336 + data2 = fm->HR
56.337 + data = data1 + data2
56.338 +
56.339 + delete (data1)
56.340 + delete (data2)
56.341 + end if
56.342 +
56.343 + yy = linint2_points_Wrap(xm,ym,data,True,lon_ob,lat_ob,0)
56.344 + data_mod_ann(5,:,:)= dim_avg(yy(month|:,pts|:,year|:)) * factor_flux
56.345 + data_mod(5,:,:,:) = yy(:,:,:) * factor_flux
56.346 +
56.347 + data_mod_long(:,:,:,:) = data_mod(:,:,:,i_long_ob)
56.348 +
56.349 + delete (data_mod)
56.350 + delete (fm)
56.351 + delete (data)
56.352 + delete (yy)
56.353 +
56.354 +;*******************************************************************
56.355 +; for station line plot
56.356 +;*******************************************************************
56.357 +
56.358 +; for x-axis in xyplot
56.359 + mon = ispan(1,12,1)
56.360 + mon@long_name = "month"
56.361 +
56.362 + res = True ; plot mods desired
56.363 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
56.364 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
56.365 +
56.366 + res@tmXBFormat = "f" ; not to add trailing zeros
56.367 +
56.368 +;-------------------------------------------------------------------------
56.369 +; Add a boxed legend using the more simple method
56.370 +
56.371 + res@pmLegendDisplayMode = "Always"
56.372 +; res@pmLegendWidthF = 0.1
56.373 + res@pmLegendWidthF = 0.08
56.374 + res@pmLegendHeightF = 0.06
56.375 +; res@pmLegendOrthogonalPosF = -1.17
56.376 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
56.377 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
56.378 +
56.379 +; res@pmLegendParallelPosF = 0.18
56.380 + res@pmLegendParallelPosF = 0.23 ;(rightward)
56.381 +
56.382 +; res@lgPerimOn = False
56.383 + res@lgLabelFontHeightF = 0.015
56.384 + res@xyExplicitLegendLabels = (/"observed",model_name/)
56.385 +;-------------------------------------------------------------------
56.386 +; for panel plot
56.387 + res@gsnFrame = False ; Do not draw plot
56.388 + res@gsnDraw = False ; Do not advance frame
56.389 +
56.390 + pres = True ; panel plot mods desired
56.391 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
56.392 + ; indiv. plots in panel
56.393 + pres@gsnMaximize = True ; fill the page
56.394 +;-------------------------------------------------------------------
56.395 +
56.396 +;==============================================================
56.397 +; get ob data at each site with long observation
56.398 +
56.399 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/observed/ameriflux/"
56.400 +
56.401 + do n = 0,nstation_long-1
56.402 +; do n = 0,0
56.403 +
56.404 + year_setback = 0
56.405 +
56.406 + nyear = year_station_long(n)
56.407 +
56.408 + if (year_ob_f_long(n).eq. 2006) then
56.409 + year_setback = 2006 -2004
56.410 + end if
56.411 + if (year_ob_f_long(n).eq. 2005) then
56.412 + year_setback = 2005 -2004
56.413 + end if
56.414 +
56.415 + ntime = (nyear - year_setback) * nmonth
56.416 +
56.417 + data_ob = new ((/nfield, nyear, nmonth/),float)
56.418 +
56.419 + diro = dir_root + station_long(n)+"/"
56.420 + filo = "timeseries_L4_m.nc"
56.421 + fo = addfile (diro+filo,"r")
56.422 +
56.423 +; print (diro)
56.424 +; print (filo)
56.425 +
56.426 + data_ob(0,:,:) = fo->NEE_or_fMDS
56.427 + data_ob(1,:,:) = fo->Rg_f
56.428 + data_ob(2,:,:) = fo->LE_f
56.429 + data_ob(3,:,:) = fo->H_f
56.430 + data_ob(4,:,:) = fo->GPP_or_MDS
56.431 + data_ob(5,:,:) = fo->Reco_or
56.432 +
56.433 + data_ob(1,:,:) = data_ob(1,:,:) * factor_rad
56.434 +
56.435 + delete (fo)
56.436 +
56.437 + timeI = new((/ntime/),integer)
56.438 + timeF = new((/ntime/),float)
56.439 + timeI = ispan(1,ntime,1)
56.440 + timeF = year_ob_i_long(n) + (timeI-1)/12.
56.441 + timeF@long_name = "year"
56.442 +
56.443 + plot_data = new((/2,ntime/),float)
56.444 +
56.445 +;----------------------------
56.446 +; for model_vs_ob
56.447 +
56.448 + plot_name = station_long(n)+"_tseries_vs_ob"
56.449 + title = station_long(n)+"("+sprintf("%5.2f",lat_ob_long(n))+","+sprintf("%5.2f",lon_ob_long(n))+")"
56.450 + res@tiMainString = title
56.451 +
56.452 + wks = gsn_open_wks (plot_type,plot_name)
56.453 + plot=new(nfield,graphic) ; create graphic array
56.454 +
56.455 + i_year_mod_i = year_ob_i_long(n) - 1990
56.456 + i_year_mod_f = i_year_mod_i + nyear - 1 - year_setback
56.457 +
56.458 + i_year_ob_f = nyear - year_setback - 1
56.459 +
56.460 +; print (nyear)
56.461 +; print (i_year_ob_f)
56.462 +; print (i_year_mod_i)
56.463 +; print (i_year_mod_f)
56.464 +
56.465 + do i = 0,nfield-1
56.466 + plot_data(0,:) = ndtooned(data_ob (i,0:i_year_ob_f,:))
56.467 + plot_data(1,:) = ndtooned(data_mod_long(i,i_year_mod_i:i_year_mod_f,:,n))
56.468 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
56.469 + plot(i)=gsn_csm_xy(wks,timeF,plot_data,res) ; create plot
56.470 + end do
56.471 +
56.472 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
56.473 +
56.474 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
56.475 + "rm "+plot_name+"."+plot_type)
56.476 +
56.477 + clear (wks)
56.478 + delete (plot)
56.479 +
56.480 + delete (data_ob)
56.481 + delete (timeI)
56.482 + delete (timeF)
56.483 + delete (plot_data)
56.484 +
56.485 + end do
56.486 +
56.487 +;###################################################################
56.488 +; for the following tables,
56.489 +; sort by latitude in decending order (N->S)
56.490 +
56.491 + isort = dim_pqsort(lat_ob_long,-1)
56.492 +
56.493 + station_sort = station_long(isort)
56.494 + year_ob_sort = year_ob_long(isort)
56.495 + lat_ob_sort = lat_ob_long(isort)
56.496 + lon_ob_sort = lon_ob_long(isort)
56.497 +
56.498 +; print(isort)
56.499 +; print(lat_ob_sort)
56.500 +
56.501 +;*******************************************************************
56.502 +; html table of site: observed
56.503 +;*******************************************************************
56.504 + output_html = "tseries_vs_ob.html"
56.505 +
56.506 + header = (/"<HTML>" \
56.507 + ,"<HEAD>" \
56.508 + ,"<TITLE>CLAMP metrics</TITLE>" \
56.509 + ,"</HEAD>" \
56.510 + ,"<H1>Timeseries at Site: "+model_name+" vs Observation</H1>" \
56.511 + /)
56.512 + footer = "</HTML>"
56.513 +
56.514 + table_header = (/ \
56.515 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
56.516 + ,"<tr>" \
56.517 + ," <th bgcolor=DDDDDD >Site Name</th>" \
56.518 + ," <th bgcolor=DDDDDD >Latitude</th>" \
56.519 + ," <th bgcolor=DDDDDD >Longitude</th>" \
56.520 + ," <th bgcolor=DDDDDD >Observed</th>" \
56.521 + ,"</tr>" \
56.522 + /)
56.523 + table_footer = "</table>"
56.524 + row_header = "<tr>"
56.525 + row_footer = "</tr>"
56.526 +
56.527 + lines = new(50000,string)
56.528 + nline = 0
56.529 +
56.530 + set_line(lines,nline,header)
56.531 + set_line(lines,nline,table_header)
56.532 +;-----------------------------------------------
56.533 +; row of table
56.534 +
56.535 + do n = 0,nstation_long-1
56.536 +
56.537 + set_line(lines,nline,row_header)
56.538 +
56.539 + txt0 = station_sort(n)
56.540 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
56.541 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
56.542 + txt3 = year_ob_sort(n)
56.543 +
56.544 + set_line(lines,nline,"<th><a href="+txt0+"_tseries_vs_ob.png>"+txt0+"</a></th>")
56.545 + set_line(lines,nline,"<th>"+txt1+"</th>")
56.546 + set_line(lines,nline,"<th>"+txt2+"</th>")
56.547 + set_line(lines,nline,"<th>"+txt3+"</th>")
56.548 +
56.549 + set_line(lines,nline,row_footer)
56.550 + end do
56.551 +;-----------------------------------------------
56.552 + set_line(lines,nline,table_footer)
56.553 + set_line(lines,nline,footer)
56.554 +
56.555 +; Now write to an HTML file.
56.556 + idx = ind(.not.ismissing(lines))
56.557 + if(.not.any(ismissing(idx))) then
56.558 + asciiwrite(output_html,lines(idx))
56.559 + else
56.560 + print ("error?")
56.561 + end if
56.562 + delete (idx)
56.563 +
56.564 + delete (isort)
56.565 + delete (station_sort)
56.566 + delete (year_ob_sort)
56.567 + delete (lat_ob_sort)
56.568 + delete (lon_ob_sort)
56.569 +
56.570 +;************************************************************
56.571 +; compute annual cycle correlation coef and M score
56.572 +;************************************************************
56.573 +
56.574 + score_max = 1.
56.575 +
56.576 + ccr = new ((/nstation, nfield/),float)
56.577 + M_score = new ((/nstation, nfield/),float)
56.578 +
56.579 + do n=0,nstation-1
56.580 + do m=0,nfield-1
56.581 + ccr(n,m) = esccr(data_ob_ann(m,:,n),data_mod_ann(m,:,n),0)
56.582 + 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))))
56.583 + M_score(n,m) = (1. -(bias/nmonth)) * score_max
56.584 + end do
56.585 + end do
56.586 +
56.587 + M_co2 = avg(M_score(:,0))
56.588 + M_rad = avg(M_score(:,1))
56.589 + M_lh = avg(M_score(:,2))
56.590 + M_sh = avg(M_score(:,3))
56.591 + M_gpp = avg(M_score(:,4))
56.592 + M_er = avg(M_score(:,5))
56.593 + M_all = M_co2+ M_rad +M_lh + M_sh + M_gpp + M_er
56.594 +
56.595 + M_energy_co2 = sprintf("%.2f", M_co2)
56.596 + M_energy_rad = sprintf("%.2f", M_rad)
56.597 + M_energy_lh = sprintf("%.2f", M_lh )
56.598 + M_energy_sh = sprintf("%.2f", M_sh )
56.599 + M_energy_gpp = sprintf("%.2f", M_gpp)
56.600 + M_energy_er = sprintf("%.2f", M_er )
56.601 + M_energy_all = sprintf("%.2f", M_all)
56.602 +
56.603 +;*******************************************************************
56.604 +; for station line plot
56.605 +;*******************************************************************
56.606 +
56.607 +; for x-axis in xyplot
56.608 + mon = ispan(1,12,1)
56.609 + mon@long_name = "month"
56.610 +
56.611 +;-------------------------------------------------------------------
56.612 +
56.613 + plot_data = new((/2,nmonth/),float)
56.614 + plot_data!0 = "case"
56.615 + plot_data!1 = "month"
56.616 +
56.617 + do n = 0,nstation-1
56.618 +;----------------------------
56.619 +; for observed
56.620 +
56.621 + plot_name = station(n)+"_ob"
56.622 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
56.623 + res@tiMainString = title
56.624 +
56.625 + wks = gsn_open_wks (plot_type,plot_name)
56.626 + plot=new(nfield,graphic) ; create graphic array
56.627 +
56.628 + do i = 0,nfield-1
56.629 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
56.630 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
56.631 + plot(i)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot
56.632 + end do
56.633 +
56.634 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
56.635 +
56.636 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
56.637 + "rm "+plot_name+"."+plot_type)
56.638 +
56.639 + clear (wks)
56.640 + delete (plot)
56.641 +;----------------------------
56.642 +; for model_vs_ob
56.643 +
56.644 + plot_name = station(n)+"_model_vs_ob"
56.645 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
56.646 + res@tiMainString = title
56.647 +
56.648 + wks = gsn_open_wks (plot_type,plot_name)
56.649 + plot=new(nfield,graphic) ; create graphic array
56.650 +
56.651 + do i = 0,nfield-1
56.652 + plot_data(0,:) = (/data_ob_ann(i,:,n)/)
56.653 + plot_data(1,:) = (/data_mod_ann(i,:,n)/)
56.654 + plot_data@long_name = field(i)+" ("+field_unit(i)+")"
56.655 + plot(i)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot
56.656 + end do
56.657 +
56.658 + gsn_panel(wks,plot,(/3,2/),pres) ; create panel plot
56.659 +
56.660 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
56.661 + "rm "+plot_name+"."+plot_type)
56.662 +
56.663 + clear (wks)
56.664 + delete (plot)
56.665 + end do
56.666 +
56.667 +;###################################################################
56.668 +; for the following tables,
56.669 +; sort by latitude in decending order (N->S)
56.670 +; sort by lat in decending order (N->S)
56.671 +
56.672 + isort = dim_pqsort(lat_ob,-1)
56.673 +
56.674 + station_sort = station(isort)
56.675 + year_ob_sort = year_ob(isort)
56.676 + lat_ob_sort = lat_ob(isort)
56.677 + lon_ob_sort = lon_ob(isort)
56.678 + M_score_sort = M_score(isort,:)
56.679 +
56.680 +; print(isort)
56.681 +; print(lat_ob_sort)
56.682 +;###################################################################
56.683 +;*******************************************************************
56.684 +; html table of site: observed
56.685 +;*******************************************************************
56.686 + output_html = "line_ob.html"
56.687 +
56.688 + header = (/"<HTML>" \
56.689 + ,"<HEAD>" \
56.690 + ,"<TITLE>CLAMP metrics</TITLE>" \
56.691 + ,"</HEAD>" \
56.692 + ,"<H1>Energy at Site: Observation</H1>" \
56.693 + /)
56.694 + footer = "</HTML>"
56.695 +
56.696 + table_header = (/ \
56.697 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
56.698 + ,"<tr>" \
56.699 + ," <th bgcolor=DDDDDD >Site Name</th>" \
56.700 + ," <th bgcolor=DDDDDD >Latitude</th>" \
56.701 + ," <th bgcolor=DDDDDD >Longitude</th>" \
56.702 + ," <th bgcolor=DDDDDD >Observed</th>" \
56.703 + ,"</tr>" \
56.704 + /)
56.705 + table_footer = "</table>"
56.706 + row_header = "<tr>"
56.707 + row_footer = "</tr>"
56.708 +
56.709 + lines = new(50000,string)
56.710 + nline = 0
56.711 +
56.712 + set_line(lines,nline,header)
56.713 + set_line(lines,nline,table_header)
56.714 +;-----------------------------------------------
56.715 +; row of table
56.716 +
56.717 + do n = 0,nstation-1
56.718 + set_line(lines,nline,row_header)
56.719 +
56.720 + txt0 = station_sort(n)
56.721 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
56.722 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
56.723 + txt3 = year_ob_sort(n)
56.724 +
56.725 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
56.726 + set_line(lines,nline,"<th>"+txt1+"</th>")
56.727 + set_line(lines,nline,"<th>"+txt2+"</th>")
56.728 + set_line(lines,nline,"<th>"+txt3+"</th>")
56.729 +
56.730 + set_line(lines,nline,row_footer)
56.731 + end do
56.732 +;-----------------------------------------------
56.733 + set_line(lines,nline,table_footer)
56.734 + set_line(lines,nline,footer)
56.735 +
56.736 +; Now write to an HTML file.
56.737 + idx = ind(.not.ismissing(lines))
56.738 + if(.not.any(ismissing(idx))) then
56.739 + asciiwrite(output_html,lines(idx))
56.740 + else
56.741 + print ("error?")
56.742 + end if
56.743 + delete (idx)
56.744 +
56.745 +;*******************************************************************
56.746 +; score and line table : model vs observed
56.747 +;*******************************************************************
56.748 + output_html = "score+line_vs_ob.html"
56.749 +
56.750 + header = (/"<HTML>" \
56.751 + ,"<HEAD>" \
56.752 + ,"<TITLE>CLAMP metrics</TITLE>" \
56.753 + ,"</HEAD>" \
56.754 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
56.755 + /)
56.756 + footer = "</HTML>"
56.757 +
56.758 + delete (table_header)
56.759 + table_header = (/ \
56.760 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
56.761 + ,"<tr>" \
56.762 + ," <th bgcolor=DDDDDD >Site Name</th>" \
56.763 + ," <th bgcolor=DDDDDD >Latitude</th>" \
56.764 + ," <th bgcolor=DDDDDD >Longitude</th>" \
56.765 + ," <th bgcolor=DDDDDD >Observed</th>" \
56.766 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
56.767 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
56.768 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
56.769 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
56.770 + ," <th bgcolor=DDDDDD >GPP Glux</th>" \
56.771 + ," <th bgcolor=DDDDDD >Respiration</th>" \
56.772 + ," <th bgcolor=DDDDDD >Average</th>" \
56.773 + ,"</tr>" \
56.774 + /)
56.775 + table_footer = "</table>"
56.776 + row_header = "<tr>"
56.777 + row_footer = "</tr>"
56.778 +
56.779 + lines = new(50000,string)
56.780 + nline = 0
56.781 +
56.782 + set_line(lines,nline,header)
56.783 + set_line(lines,nline,table_header)
56.784 +;-----------------------------------------------
56.785 +; row of table
56.786 +
56.787 + do n = 0,nstation-1
56.788 + set_line(lines,nline,row_header)
56.789 +
56.790 + txt0 = station_sort(n)
56.791 + txt1 = sprintf("%5.2f", lat_ob_sort(n))
56.792 + txt2 = sprintf("%5.2f", lon_ob_sort(n))
56.793 + txt3 = year_ob_sort(n)
56.794 + txt4 = sprintf("%5.2f", M_score_sort(n,0))
56.795 + txt5 = sprintf("%5.2f", M_score_sort(n,1))
56.796 + txt6 = sprintf("%5.2f", M_score_sort(n,2))
56.797 + txt7 = sprintf("%5.2f", M_score_sort(n,3))
56.798 + txt8 = sprintf("%5.2f", M_score_sort(n,4))
56.799 + txt9 = sprintf("%5.2f", M_score_sort(n,5))
56.800 + txt10 = sprintf("%5.2f", avg(M_score_sort(n,:)))
56.801 +
56.802 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
56.803 + set_line(lines,nline,"<th>"+txt1+"</th>")
56.804 + set_line(lines,nline,"<th>"+txt2+"</th>")
56.805 + set_line(lines,nline,"<th>"+txt3+"</th>")
56.806 + set_line(lines,nline,"<th>"+txt4+"</th>")
56.807 + set_line(lines,nline,"<th>"+txt5+"</th>")
56.808 + set_line(lines,nline,"<th>"+txt6+"</th>")
56.809 + set_line(lines,nline,"<th>"+txt7+"</th>")
56.810 + set_line(lines,nline,"<th>"+txt8+"</th>")
56.811 + set_line(lines,nline,"<th>"+txt9+"</th>")
56.812 + set_line(lines,nline,"<th>"+txt10+"</th>")
56.813 +
56.814 + set_line(lines,nline,row_footer)
56.815 + end do
56.816 +
56.817 +; last row, summary
56.818 + set_line(lines,nline,row_header)
56.819 +
56.820 + txt0 = "All_"+sprintf("%.0f", nstation)
56.821 + txt1 = "-"
56.822 + txt2 = "-"
56.823 + txt3 = "-"
56.824 + txt4 = M_energy_co2
56.825 + txt5 = M_energy_rad
56.826 + txt6 = M_energy_lh
56.827 + txt7 = M_energy_sh
56.828 + txt8 = M_energy_gpp
56.829 + txt9 = M_energy_er
56.830 + txt10 = M_energy_all
56.831 +
56.832 + set_line(lines,nline,"<th>"+txt0+"</th>")
56.833 + set_line(lines,nline,"<th>"+txt1+"</th>")
56.834 + set_line(lines,nline,"<th>"+txt2+"</th>")
56.835 + set_line(lines,nline,"<th>"+txt3+"</th>")
56.836 + set_line(lines,nline,"<th>"+txt4+"</th>")
56.837 + set_line(lines,nline,"<th>"+txt5+"</th>")
56.838 + set_line(lines,nline,"<th>"+txt6+"</th>")
56.839 + set_line(lines,nline,"<th>"+txt7+"</th>")
56.840 + set_line(lines,nline,"<th>"+txt8+"</th>")
56.841 + set_line(lines,nline,"<th>"+txt9+"</th>")
56.842 + set_line(lines,nline,"<th>"+txt10+"</th>")
56.843 +
56.844 + set_line(lines,nline,row_footer)
56.845 +;-----------------------------------------------
56.846 + set_line(lines,nline,table_footer)
56.847 + set_line(lines,nline,footer)
56.848 +
56.849 +; Now write to an HTML file.
56.850 + idx = ind(.not.ismissing(lines))
56.851 + if(.not.any(ismissing(idx))) then
56.852 + asciiwrite(output_html,lines(idx))
56.853 + else
56.854 + print ("error?")
56.855 + end if
56.856 + delete (idx)
56.857 +
56.858 +;***************************************************************************
56.859 +; output plots
56.860 +;***************************************************************************
56.861 + output_dir = model_name+"/ameriflux"
56.862 +
56.863 + system("mv *.png *.html " + output_dir)
56.864 +;***************************************************************************
56.865 +end
56.866 +
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
57.2 +++ b/ameriflux/line_ob.html Mon Jan 26 22:08:20 2009 -0500
57.3 @@ -0,0 +1,458 @@
57.4 +<HTML>
57.5 +<HEAD>
57.6 +<TITLE>CLAMP metrics</TITLE>
57.7 +</HEAD>
57.8 +<H1>Energy at Site: Observation</H1>
57.9 +<table border=1 cellspacing=0 cellpadding=3 width=60%>
57.10 +<tr>
57.11 + <th bgcolor=DDDDDD >Site Name</th>
57.12 + <th bgcolor=DDDDDD >Latitude</th>
57.13 + <th bgcolor=DDDDDD >Longitude</th>
57.14 + <th bgcolor=DDDDDD >Observed</th>
57.15 +</tr>
57.16 +<tr>
57.17 +<th><a href=Atqasuk_ob.png>Atqasuk</a></th>
57.18 +<th>70.47</th>
57.19 +<th>202.59</th>
57.20 +<th>1999-2006</th>
57.21 +</tr>
57.22 +<tr>
57.23 +<th><a href=Ivotuk_ob.png>Ivotuk</a></th>
57.24 +<th>68.49</th>
57.25 +<th>204.25</th>
57.26 +<th>2003-2006</th>
57.27 +</tr>
57.28 +<tr>
57.29 +<th><a href=UCI_1998_ob.png>UCI_1998</a></th>
57.30 +<th>56.64</th>
57.31 +<th>260.05</th>
57.32 +<th>2002-2005</th>
57.33 +</tr>
57.34 +<tr>
57.35 +<th><a href=UCI_1989_ob.png>UCI_1989</a></th>
57.36 +<th>55.92</th>
57.37 +<th>261.04</th>
57.38 +<th>2001-2005</th>
57.39 +</tr>
57.40 +<tr>
57.41 +<th><a href=UCI_1964wet_ob.png>UCI_1964wet</a></th>
57.42 +<th>55.91</th>
57.43 +<th>261.62</th>
57.44 +<th>2002-2004</th>
57.45 +</tr>
57.46 +<tr>
57.47 +<th><a href=UCI_1964_ob.png>UCI_1964</a></th>
57.48 +<th>55.91</th>
57.49 +<th>261.62</th>
57.50 +<th>2001-2005</th>
57.51 +</tr>
57.52 +<tr>
57.53 +<th><a href=UCI_1930_ob.png>UCI_1930</a></th>
57.54 +<th>55.91</th>
57.55 +<th>261.48</th>
57.56 +<th>2001-2005</th>
57.57 +</tr>
57.58 +<tr>
57.59 +<th><a href=UCI_1850_ob.png>UCI_1850</a></th>
57.60 +<th>55.88</th>
57.61 +<th>261.52</th>
57.62 +<th>2004-2005</th>
57.63 +</tr>
57.64 +<tr>
57.65 +<th><a href=UCI_1981_ob.png>UCI_1981</a></th>
57.66 +<th>55.86</th>
57.67 +<th>261.52</th>
57.68 +<th>2001-2005</th>
57.69 +</tr>
57.70 +<tr>
57.71 +<th><a href=FortPeck_ob.png>FortPeck</a></th>
57.72 +<th>48.31</th>
57.73 +<th>254.90</th>
57.74 +<th>2000-2006</th>
57.75 +</tr>
57.76 +<tr>
57.77 +<th><a href=Wisconsin_mrp_ob.png>Wisconsin_mrp</a></th>
57.78 +<th>46.74</th>
57.79 +<th>268.83</th>
57.80 +<th>2002-2005</th>
57.81 +</tr>
57.82 +<tr>
57.83 +<th><a href=Wisconsin_ihw_ob.png>Wisconsin_ihw</a></th>
57.84 +<th>46.73</th>
57.85 +<th>268.77</th>
57.86 +<th>2003-2003</th>
57.87 +</tr>
57.88 +<tr>
57.89 +<th><a href=Wisconsin_yhw_ob.png>Wisconsin_yhw</a></th>
57.90 +<th>46.72</th>
57.91 +<th>268.75</th>
57.92 +<th>2002-2002</th>
57.93 +</tr>
57.94 +<tr>
57.95 +<th><a href=Wisconsin_irp_ob.png>Wisconsin_irp</a></th>
57.96 +<th>46.69</th>
57.97 +<th>268.85</th>
57.98 +<th>2003-2003</th>
57.99 +</tr>
57.100 +<tr>
57.101 +<th><a href=Wisconsin_myjp_ob.png>Wisconsin_myjp</a></th>
57.102 +<th>46.65</th>
57.103 +<th>268.91</th>
57.104 +<th>2004-2004</th>
57.105 +</tr>
57.106 +<tr>
57.107 +<th><a href=Wisconsin_rpcc_ob.png>Wisconsin_rpcc</a></th>
57.108 +<th>46.65</th>
57.109 +<th>268.93</th>
57.110 +<th>2005-2005</th>
57.111 +</tr>
57.112 +<tr>
57.113 +<th><a href=Wisconsin_pb_ob.png>Wisconsin_pb</a></th>
57.114 +<th>46.62</th>
57.115 +<th>268.70</th>
57.116 +<th>2002-2002</th>
57.117 +</tr>
57.118 +<tr>
57.119 +<th><a href=Wisconsin_yjp_ob.png>Wisconsin_yjp</a></th>
57.120 +<th>46.62</th>
57.121 +<th>268.92</th>
57.122 +<th>2004-2005</th>
57.123 +</tr>
57.124 +<tr>
57.125 +<th><a href=Wisconsin_yrp_ob.png>Wisconsin_yrp</a></th>
57.126 +<th>46.62</th>
57.127 +<th>268.92</th>
57.128 +<th>2002-2002</th>
57.129 +</tr>
57.130 +<tr>
57.131 +<th><a href=SylvaniaWilderness_ob.png>SylvaniaWilderness</a></th>
57.132 +<th>46.24</th>
57.133 +<th>270.65</th>
57.134 +<th>2002-2006</th>
57.135 +</tr>
57.136 +<tr>
57.137 +<th><a href=LostCreek_ob.png>LostCreek</a></th>
57.138 +<th>46.08</th>
57.139 +<th>270.02</th>
57.140 +<th>2001-2005</th>
57.141 +</tr>
57.142 +<tr>
57.143 +<th><a href=ParkFalls_ob.png>ParkFalls</a></th>
57.144 +<th>45.95</th>
57.145 +<th>269.73</th>
57.146 +<th>1996-2003</th>
57.147 +</tr>
57.148 +<tr>
57.149 +<th><a href=WindRiver_ob.png>WindRiver</a></th>
57.150 +<th>45.82</th>
57.151 +<th>238.05</th>
57.152 +<th>1999-2004</th>
57.153 +</tr>
57.154 +<tr>
57.155 +<th><a href=WillowCreek_ob.png>WillowCreek</a></th>
57.156 +<th>45.81</th>
57.157 +<th>269.92</th>
57.158 +<th>1999-2005</th>
57.159 +</tr>
57.160 +<tr>
57.161 +<th><a href=UMBS_ob.png>UMBS</a></th>
57.162 +<th>45.56</th>
57.163 +<th>275.29</th>
57.164 +<th>1999-2003</th>
57.165 +</tr>
57.166 +<tr>
57.167 +<th><a href=HowlandForestWest_ob.png>HowlandForestWest</a></th>
57.168 +<th>45.21</th>
57.169 +<th>291.25</th>
57.170 +<th>1999-2004</th>
57.171 +</tr>
57.172 +<tr>
57.173 +<th><a href=HowlandForestMain_ob.png>HowlandForestMain</a></th>
57.174 +<th>45.20</th>
57.175 +<th>291.26</th>
57.176 +<th>1996-2004</th>
57.177 +</tr>
57.178 +<tr>
57.179 +<th><a href=MetoliusEyerly_ob.png>MetoliusEyerly</a></th>
57.180 +<th>44.58</th>
57.181 +<th>238.50</th>
57.182 +<th>2004-2005</th>
57.183 +</tr>
57.184 +<tr>
57.185 +<th><a href=MetoliusOldPonderosaPine_ob.png>MetoliusOldPonderosaPine</a></th>
57.186 +<th>44.50</th>
57.187 +<th>238.38</th>
57.188 +<th>1996-2000</th>
57.189 +</tr>
57.190 +<tr>
57.191 +<th><a href=MetoliusIntermediatePine_ob.png>MetoliusIntermediatePine</a></th>
57.192 +<th>44.45</th>
57.193 +<th>238.44</th>
57.194 +<th>2003-2005</th>
57.195 +</tr>
57.196 +<tr>
57.197 +<th><a href=Brookings_ob.png>Brookings</a></th>
57.198 +<th>44.35</th>
57.199 +<th>263.16</th>
57.200 +<th>2004-2006</th>
57.201 +</tr>
57.202 +<tr>
57.203 +<th><a href=Metolius_2nd_YoungPonderosaPine_ob.png>Metolius_2nd_YoungPonderosaPine</a></th>
57.204 +<th>44.32</th>
57.205 +<th>238.39</th>
57.206 +<th>2004-2005</th>
57.207 +</tr>
57.208 +<tr>
57.209 +<th><a href=Bartlett_ob.png>Bartlett</a></th>
57.210 +<th>44.06</th>
57.211 +<th>288.71</th>
57.212 +<th>2004-2005</th>
57.213 +</tr>
57.214 +<tr>
57.215 +<th><a href=LittleProspect_ob.png>LittleProspect</a></th>
57.216 +<th>42.54</th>
57.217 +<th>287.82</th>
57.218 +<th>2002-2005</th>
57.219 +</tr>
57.220 +<tr>
57.221 +<th><a href=HarvardForestHemlock_ob.png>HarvardForestHemlock</a></th>
57.222 +<th>42.54</th>
57.223 +<th>287.82</th>
57.224 +<th>2004-2004</th>
57.225 +</tr>
57.226 +<tr>
57.227 +<th><a href=HarvardForest_ob.png>HarvardForest</a></th>
57.228 +<th>42.54</th>
57.229 +<th>287.83</th>
57.230 +<th>1991-2004</th>
57.231 +</tr>
57.232 +<tr>
57.233 +<th><a href=Fermi_Ag_ob.png>Fermi_Ag</a></th>
57.234 +<th>41.86</th>
57.235 +<th>271.78</th>
57.236 +<th>2005-2006</th>
57.237 +</tr>
57.238 +<tr>
57.239 +<th><a href=Fermi_Prairie_ob.png>Fermi_Prairie</a></th>
57.240 +<th>41.84</th>
57.241 +<th>271.76</th>
57.242 +<th>2004-2006</th>
57.243 +</tr>
57.244 +<tr>
57.245 +<th><a href=Toledo_ob.png>Toledo</a></th>
57.246 +<th>41.55</th>
57.247 +<th>276.16</th>
57.248 +<th>2004-2005</th>
57.249 +</tr>
57.250 +<tr>
57.251 +<th><a href=Mead-rainfed_ob.png>Mead-rainfed</a></th>
57.252 +<th>41.18</th>
57.253 +<th>263.56</th>
57.254 +<th>2001-2005</th>
57.255 +</tr>
57.256 +<tr>
57.257 +<th><a href=Mead-irrigated_ob.png>Mead-irrigated</a></th>
57.258 +<th>41.17</th>
57.259 +<th>263.52</th>
57.260 +<th>2001-2005</th>
57.261 +</tr>
57.262 +<tr>
57.263 +<th><a href=Mead-irrigated-rotation_ob.png>Mead-irrigated-rotation</a></th>
57.264 +<th>41.16</th>
57.265 +<th>263.53</th>
57.266 +<th>2001-2005</th>
57.267 +</tr>
57.268 +<tr>
57.269 +<th><a href=NiwotRidge_ob.png>NiwotRidge</a></th>
57.270 +<th>40.03</th>
57.271 +<th>254.45</th>
57.272 +<th>1999-2003</th>
57.273 +</tr>
57.274 +<tr>
57.275 +<th><a href=Bondville_ob.png>Bondville</a></th>
57.276 +<th>40.01</th>
57.277 +<th>271.71</th>
57.278 +<th>1996-2006</th>
57.279 +</tr>
57.280 +<tr>
57.281 +<th><a href=MorganMonroe_ob.png>MorganMonroe</a></th>
57.282 +<th>39.32</th>
57.283 +<th>273.59</th>
57.284 +<th>1999-2005</th>
57.285 +</tr>
57.286 +<tr>
57.287 +<th><a href=MissouriOzark_ob.png>MissouriOzark</a></th>
57.288 +<th>38.74</th>
57.289 +<th>267.80</th>
57.290 +<th>2004-2006</th>
57.291 +</tr>
57.292 +<tr>
57.293 +<th><a href=Tonzi_ob.png>Tonzi</a></th>
57.294 +<th>38.43</th>
57.295 +<th>239.03</th>
57.296 +<th>2001-2006</th>
57.297 +</tr>
57.298 +<tr>
57.299 +<th><a href=Vaira_ob.png>Vaira</a></th>
57.300 +<th>38.41</th>
57.301 +<th>239.05</th>
57.302 +<th>2001-2006</th>
57.303 +</tr>
57.304 +<tr>
57.305 +<th><a href=ARM_Oklahoma_ob.png>ARM_Oklahoma</a></th>
57.306 +<th>36.60</th>
57.307 +<th>262.51</th>
57.308 +<th>2003-2006</th>
57.309 +</tr>
57.310 +<tr>
57.311 +<th><a href=Duke_Forest_Pine_ob.png>Duke_Forest_Pine</a></th>
57.312 +<th>35.98</th>
57.313 +<th>280.91</th>
57.314 +<th>2001-2005</th>
57.315 +</tr>
57.316 +<tr>
57.317 +<th><a href=Duke_Forest_Hardwoods_ob.png>Duke_Forest_Hardwoods</a></th>
57.318 +<th>35.97</th>
57.319 +<th>280.90</th>
57.320 +<th>2003-2005</th>
57.321 +</tr>
57.322 +<tr>
57.323 +<th><a href=Duke_Forest_Open_Field_ob.png>Duke_Forest_Open_Field</a></th>
57.324 +<th>35.97</th>
57.325 +<th>280.91</th>
57.326 +<th>2001-2005</th>
57.327 +</tr>
57.328 +<tr>
57.329 +<th><a href=WalkerBranch_ob.png>WalkerBranch</a></th>
57.330 +<th>35.96</th>
57.331 +<th>275.71</th>
57.332 +<th>1995-1999</th>
57.333 +</tr>
57.334 +<tr>
57.335 +<th><a href=NorthCarolina_cc_ob.png>NorthCarolina_cc</a></th>
57.336 +<th>35.81</th>
57.337 +<th>283.29</th>
57.338 +<th>2005-2006</th>
57.339 +</tr>
57.340 +<tr>
57.341 +<th><a href=NorthCarolina_lp_ob.png>NorthCarolina_lp</a></th>
57.342 +<th>35.80</th>
57.343 +<th>283.33</th>
57.344 +<th>2005-2006</th>
57.345 +</tr>
57.346 +<tr>
57.347 +<th><a href=ARM_Oklahoma_burn_ob.png>ARM_Oklahoma_burn</a></th>
57.348 +<th>35.55</th>
57.349 +<th>261.96</th>
57.350 +<th>2005-2006</th>
57.351 +</tr>
57.352 +<tr>
57.353 +<th><a href=ARM_Oklahoma_control_ob.png>ARM_Oklahoma_control</a></th>
57.354 +<th>35.55</th>
57.355 +<th>261.96</th>
57.356 +<th>2005-2006</th>
57.357 +</tr>
57.358 +<tr>
57.359 +<th><a href=Flagstaff_Wildfire_ob.png>Flagstaff_Wildfire</a></th>
57.360 +<th>35.45</th>
57.361 +<th>248.23</th>
57.362 +<th>2005-2006</th>
57.363 +</tr>
57.364 +<tr>
57.365 +<th><a href=Flagstaff_Managed_ob.png>Flagstaff_Managed</a></th>
57.366 +<th>35.13</th>
57.367 +<th>248.27</th>
57.368 +<th>2005-2006</th>
57.369 +</tr>
57.370 +<tr>
57.371 +<th><a href=Flagstaff_Unmanaged_ob.png>Flagstaff_Unmanaged</a></th>
57.372 +<th>35.09</th>
57.373 +<th>248.24</th>
57.374 +<th>2005-2006</th>
57.375 +</tr>
57.376 +<tr>
57.377 +<th><a href=Goodwin_Creek_ob.png>Goodwin_Creek</a></th>
57.378 +<th>34.25</th>
57.379 +<th>270.03</th>
57.380 +<th>2002-2006</th>
57.381 +</tr>
57.382 +<tr>
57.383 +<th><a href=SkyOaks_PostFire_ob.png>SkyOaks_PostFire</a></th>
57.384 +<th>33.38</th>
57.385 +<th>243.36</th>
57.386 +<th>2004-2006</th>
57.387 +</tr>
57.388 +<tr>
57.389 +<th><a href=SkyOaks_Young_ob.png>SkyOaks_Young</a></th>
57.390 +<th>33.38</th>
57.391 +<th>243.38</th>
57.392 +<th>1997-2006</th>
57.393 +</tr>
57.394 +<tr>
57.395 +<th><a href=SkyOaks_Old_ob.png>SkyOaks_Old</a></th>
57.396 +<th>33.37</th>
57.397 +<th>243.38</th>
57.398 +<th>1997-2006</th>
57.399 +</tr>
57.400 +<tr>
57.401 +<th><a href=SantaRita_ob.png>SantaRita</a></th>
57.402 +<th>31.82</th>
57.403 +<th>249.13</th>
57.404 +<th>2004-2006</th>
57.405 +</tr>
57.406 +<tr>
57.407 +<th><a href=KendallGrasslands_ob.png>KendallGrasslands</a></th>
57.408 +<th>31.74</th>
57.409 +<th>250.06</th>
57.410 +<th>2004-2006</th>
57.411 +</tr>
57.412 +<tr>
57.413 +<th><a href=Audubon_ob.png>Audubon</a></th>
57.414 +<th>31.59</th>
57.415 +<th>249.49</th>
57.416 +<th>2002-2006</th>
57.417 +</tr>
57.418 +<tr>
57.419 +<th><a href=FreemanRanch_mesquite_ob.png>FreemanRanch_mesquite</a></th>
57.420 +<th>29.95</th>
57.421 +<th>262.00</th>
57.422 +<th>2004-2006</th>
57.423 +</tr>
57.424 +<tr>
57.425 +<th><a href=Rayonier_ob.png>Rayonier</a></th>
57.426 +<th>29.80</th>
57.427 +<th>277.80</th>
57.428 +<th>1998-1998</th>
57.429 +</tr>
57.430 +<tr>
57.431 +<th><a href=Mize_ob.png>Mize</a></th>
57.432 +<th>29.76</th>
57.433 +<th>277.76</th>
57.434 +<th>1998-2004</th>
57.435 +</tr>
57.436 +<tr>
57.437 +<th><a href=Donaldson_ob.png>Donaldson</a></th>
57.438 +<th>29.75</th>
57.439 +<th>277.84</th>
57.440 +<th>1999-2004</th>
57.441 +</tr>
57.442 +<tr>
57.443 +<th><a href=AustinCary_ob.png>AustinCary</a></th>
57.444 +<th>29.74</th>
57.445 +<th>277.78</th>
57.446 +<th>2000-2005</th>
57.447 +</tr>
57.448 +<tr>
57.449 +<th><a href=KennedySpaceCenterScrub_ob.png>KennedySpaceCenterScrub</a></th>
57.450 +<th>28.61</th>
57.451 +<th>279.33</th>
57.452 +<th>2000-2006</th>
57.453 +</tr>
57.454 +<tr>
57.455 +<th><a href=KennedySpaceCenterPine_ob.png>KennedySpaceCenterPine</a></th>
57.456 +<th>28.46</th>
57.457 +<th>279.33</th>
57.458 +<th>2002-2002</th>
57.459 +</tr>
57.460 +</table>
57.461 +</HTML>
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
58.2 +++ b/ameriflux/note.1 Mon Jan 26 22:08:20 2009 -0500
58.3 @@ -0,0 +1,2 @@
58.4 +I believe the observed Reco = AR + HR, the sum of autotrophic and
58.5 +heterotrophic respiration. Forrest
58.6 \ No newline at end of file
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
59.2 +++ b/ameriflux/note.list_lat-lon Mon Jan 26 22:08:20 2009 -0500
59.3 @@ -0,0 +1,148 @@
59.4 +
59.5 +ARM_Oklahoma: 36.605 -97.4884
59.6 +
59.7 +ARM_Oklahoma_burn: 35.54974 -98.04023
59.8 +
59.9 +ARM_Oklahoma_control: 35.54649 -98.04006
59.10 +
59.11 +Atqasuk: 70.46961 -157.4089
59.12 +
59.13 +Audubon: 31.59073 -110.5104
59.14 +
59.15 +AustinCary: 29.73807 -82.21877
59.16 +
59.17 +Bartlett: 44.06464 -71.28808
59.18 +
59.19 +Bondville: 40.0061 -88.29187
59.20 +
59.21 +Brookings: 44.34529 -96.83617
59.22 +
59.23 +Donaldson: 29.75477 -82.16328
59.24 +
59.25 +Duke_Forest_Hardwoods: 35.9735823 -79.1004304
59.26 +
59.27 +Duke_Forest_Open_Field: 35.9712024 -79.0933759
59.28 +
59.29 +Duke_Forest_Pine: 35.9781659 -79.0941956
59.30 +
59.31 +Fermi_Ag: 41.8593 -88.22273
59.32 +
59.33 +Fermi_Prairie: 41.84062 -88.24103
59.34 +
59.35 +Flagstaff_Managed: 35.13333 -111.7275
59.36 +
59.37 +Flagstaff_Unmanaged: 35.08973 -111.7625
59.38 +
59.39 +Flagstaff_Wildfire: 35.44557 -111.7718
59.40 +
59.41 +FortPeck: 48.30788 -105.10005
59.42 +
59.43 +FreemanRanch_mesquite: 29.94949 -97.99623
59.44 +
59.45 +Goodwin_Creek: 34.25 -89.97
59.46 +
59.47 +HarvardForest: 42.53776 -72.17148
59.48 +
59.49 +HarvardForestHemlock: 42.53933 -72.17794
59.50 +
59.51 +HowlandForestMain: 45.20407 -68.74028
59.52 +
59.53 +HowlandForestWest: 45.20912 -68.747
59.54 +
59.55 +Ivotuk: 68.48647 -155.7503
59.56 +
59.57 +KendallGrasslands: 31.73653 -109.9419
59.58 +
59.59 +KennedySpaceCenterPine: 28.4583 -80.6709
59.60 +
59.61 +KennedySpaceCenterScrub: 28.60858 -80.67153
59.62 +
59.63 +LittleProspect: 42.54186 -72.18496
59.64 +
59.65 +LostCreek: 46.08268 -89.97919
59.66 +
59.67 +Mead-irrigated: 41.16506 -96.47664
59.68 +
59.69 +Mead-irrigated-rotation: 41.16487 -96.4701
59.70 +
59.71 +Mead-rainfed: 41.17967 -96.43965
59.72 +
59.73 +Metolius_2nd_YoungPonderosaPine: 44.31569 -121.6079
59.74 +
59.75 +MetoliusEyerly: 44.57944 -121.5001
59.76 +
59.77 +MetoliusIntermediatePine: 44.45243 -121.5572
59.78 +
59.79 +MetoliusOldPonderosaPine: 44.49917 -121.6224
59.80 +
59.81 +MissouriOzark: 38.74411 -92.20001
59.82 +
59.83 +Mize: 29.7648 -82.24482
59.84 +
59.85 +MorganMonroe: 39.32315 -86.41314
59.86 +
59.87 +NiwotRidge: 40.03288 -105.5464
59.88 +
59.89 +NorthCarolina_cc: 35.81147 -76.71147
59.90 +
59.91 +NorthCarolina_lp: 35.8031 -76.66791
59.92 +
59.93 +ParkFalls: 45.94588 -90.2723
59.94 +
59.95 +Rayonier: 29.80282 -82.20315
59.96 +
59.97 +SantaRita: 31.82143 -110.8661
59.98 +
59.99 +SkyOaks_Old: 33.37389 -116.6229
59.100 +
59.101 +SkyOaks_PostFire: 33.3844 -116.6403
59.102 +
59.103 +SkyOaks_Young: 33.37719 -116.6227
59.104 +
59.105 +SylvaniaWilderness: 46.24202 -89.34765
59.106 +
59.107 +Toledo: 41.55454 -83.84376
59.108 +
59.109 +Tonzi: 38.4316 -120.966
59.110 +
59.111 +UCI_1850: 55.87917 -98.48389
59.112 +
59.113 +UCI_1930: 55.90583 -98.52472
59.114 +
59.115 +UCI_1964: 55.91167 -98.38222
59.116 +
59.117 +UCI_1964wet: 55.91167 -98.38222
59.118 +
59.119 +UCI_1981: 55.86306 -98.485
59.120 +
59.121 +UCI_1989: 55.91667 -98.96444
59.122 +
59.123 +UCI_1998: 56.63583 -99.94883
59.124 +
59.125 +UMBS: 45.55984 -84.71382
59.126 +
59.127 +Vaira: 38.40667 -120.9507
59.128 +
59.129 +WalkerBranch: 35.95877 -84.28743
59.130 +
59.131 +WillowCreek: 45.80593 -90.07986
59.132 +
59.133 +WindRiver: 45.82049 -121.9519
59.134 +
59.135 +Wisconsin_ihw: 46.73047 -91.23294
59.136 +
59.137 +Wisconsin_irp: 46.68689 -91.15283
59.138 +
59.139 +Wisconsin_mrp: 46.73933 -91.16625
59.140 +
59.141 +Wisconsin_myjp: 46.65308 -91.08581
59.142 +
59.143 +Wisconsin_pb: 46.62489 -91.29822
59.144 +
59.145 +Wisconsin_rpcc: 46.64911 -91.06928
59.146 +
59.147 +Wisconsin_yhw: 46.72233 -91.25242
59.148 +
59.149 +Wisconsin_yjp: 46.61878 -91.08144
59.150 +
59.151 +Wisconsin_yrp: 46.61878 -91.08144
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
60.2 +++ b/ameriflux/note.missing_year Mon Jan 26 22:08:20 2009 -0500
60.3 @@ -0,0 +1,15 @@
60.4 +Atqasuk 2000 2002
60.5 +
60.6 +Bondville 2000
60.7 +
60.8 +NiwotRidge 2001
60.9 +
60.10 +ParkFalls 2001 2002
60.11 +
60.12 +SkyOaks_Old 2000 2001 2002 2003
60.13 +
60.14 +SkyOaks_Young 1999 2000 2002 2004
60.15 +
60.16 +UCI_1989 2003
60.17 +
60.18 +WindRiver 2003
60.19 \ No newline at end of file
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
61.2 +++ b/ameriflux/note.ncract Mon Jan 26 22:08:20 2009 -0500
61.3 @@ -0,0 +1,1 @@
61.4 +ncrcat ????_L4_m.nc 2003-2005_L4_m.nc
61.5 \ No newline at end of file
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
62.2 +++ b/ameriflux/note.unit Mon Jan 26 22:08:20 2009 -0500
62.3 @@ -0,0 +1,37 @@
62.4 +For the monthly files from L4 Ameriflux, we are comparing the
62.5 +following quantities with the models:
62.6 +
62.7 +H_f This is sensible heat flux, in units of
62.8 +W/m2/day according to Ameriflux documentation
62.9 +LE_f This is latent heat flux, in units of
62.10 +W/m2/day according to Ameriflux documentation
62.11 +Rg_f This is global radiation, in units of MJ/m2/day
62.12 +Reco_or This is the ecosystem respiration flux, in
62.13 +units of gC/m2/day
62.14 +NEE_or_fMDS This is the net ecosystem exchange flux, in units of
62.15 +gC/m2/day
62.16 +GPP_or_MDS This is the gross primary production flux, in units
62.17 +of gC/m2/day
62.18 +
62.19 +I do not personally understand the H and LE units for the
62.20 +observations and have asked Ameriflux for clarification. Please skip for now.
62.21 +
62.22 +For Rg_f, please compare with the model variable SOLAR. Please label:
62.23 +Shortwave incoming (Wm-2)
62.24 +To convert Rg_f to units of Wm-2:
62.25 +
62.26 +X MJ/m2/day * (1 x 10^6 J/MJ)/(24*3600s/day) = Y Wm-2
62.27 +
62.28 +For Reco_or please compare with the sum of model variables ar and hr.
62.29 +Please label: Re (gC/m2/day)
62.30 +For NEE_or_fMDS please compare with model variable nep. Please label
62.31 +NEE (gC/m2/day)
62.32 +For GPP_or_MDS please compare with model variable gpp. Please label
62.33 +GPP (gC/m2/day)
62.34 +
62.35 +The last three model variables have units of KgC/m2/s. To convert to
62.36 +gC/m2/day, please use this approach:
62.37 +
62.38 +X Kg C/m2/s *(1000 g C/Kg C)*(3600*24 s/day) = Y gC/m2/day
62.39 +
62.40 +Jim
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
63.2 +++ b/beta/01.co2_f.ncl Mon Jan 26 22:08:20 2009 -0500
63.3 @@ -0,0 +1,25 @@
63.4 +; ****************************************************
63.5 +; combine scatter, histogram, global and zonal plots
63.6 +; compute all correlation coef and M score
63.7 +; ****************************************************
63.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
63.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
63.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
63.11 +;************************************************
63.12 +
63.13 +; Main code.
63.14 +begin
63.15 +
63.16 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
63.17 + film = "surf_co2.clamp.T42.20070208.nc"
63.18 + fm = addfile (dirm+film,"r")
63.19 +
63.20 + surf_co2 = fm->surf_co2
63.21 +
63.22 + print (surf_co2(:,0,0))
63.23 +
63.24 + avg_co2_1990_2004 = avg(surf_co2(192:206,0,0))
63.25 +
63.26 + print (avg_co2_1990_2004)
63.27 +
63.28 +end
64.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
64.2 +++ b/beta/02.site.ncl Mon Jan 26 22:08:20 2009 -0500
64.3 @@ -0,0 +1,83 @@
64.4 +; ****************************************************
64.5 +; combine scatter, histogram, global and zonal plots
64.6 +; *********************************************************
64.7 +
64.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
64.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
64.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
64.11 +; **********************************************************
64.12 +
64.13 +; Main code.
64.14 +begin
64.15 +
64.16 +;===================================================
64.17 +; observed station name and location (lat,lon)
64.18 +;===================================================
64.19 +
64.20 + beta_4_ob = 0.60
64.21 +
64.22 + station = (/"DukeFACE" \
64.23 + ,"AspenFACE" \
64.24 + ,"ORNL-FACE" \
64.25 + ,"POP-EUROFACE" \
64.26 + /)
64.27 +
64.28 + lat_ob = (/ 35.58, 45.40, 35.54, 42.22/)
64.29 + lon_ob = (/-79.05, -89.37, -84.20, 11.48/)
64.30 + lon_ob = where(lon_ob.lt.0.,lon_ob+360.,lon_ob)
64.31 +;print (lon_ob)
64.32 +
64.33 + n_sta = dimsizes(station)
64.34 +
64.35 +;====================================================
64.36 +; model data
64.37 +;====================================================
64.38 +
64.39 + co2_i = 283.1878
64.40 + co2_f = 364.1252
64.41 +
64.42 +;model_name_i = "i01.07cn"
64.43 +;model_name_f = "i01.10cn"
64.44 +
64.45 + model_name_i = "i01.07casa"
64.46 + model_name_f = "i01.10casa"
64.47 +
64.48 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
64.49 + film_i = model_name_i + "_1990-2004_ANN_climo.nc"
64.50 + film_f = model_name_f + "_1990-2004_ANN_climo.nc"
64.51 +
64.52 + fm_i = addfile (dirm+film_i,"r")
64.53 + fm_f = addfile (dirm+film_f,"r")
64.54 +
64.55 + npp_i = fm_i->NPP
64.56 + npp_f = fm_f->NPP
64.57 +
64.58 + xm = fm_i->lon
64.59 + ym = fm_i->lat
64.60 +
64.61 + npp_i_4 =linint2_points(xm,ym,npp_i,True,lon_ob,lat_ob,0)
64.62 +
64.63 + npp_f_4 =linint2_points(xm,ym,npp_f,True,lon_ob,lat_ob,0)
64.64 +
64.65 +; Units for these variables are:
64.66 +; npp_i: g C/m^2/s
64.67 +
64.68 + print (npp_i_4)
64.69 + print (npp_f_4)
64.70 +;============================
64.71 +;compute beta
64.72 +;============================
64.73 +
64.74 + beta_4 = new((/n_sta/),float)
64.75 +
64.76 + beta_4 = ((npp_f_4/npp_i_4) - 1.)/log(co2_f/co2_i)
64.77 +
64.78 + beta_4_avg = avg(beta_4)
64.79 +
64.80 + print (beta_4)
64.81 + print (beta_4_avg)
64.82 +
64.83 + M_beta = abs((beta_4_avg/beta_4_ob) - 1.)* 5.
64.84 +
64.85 + print (M_beta)
64.86 +end
65.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
65.2 +++ b/beta/03.biome.ncl Mon Jan 26 22:08:20 2009 -0500
65.3 @@ -0,0 +1,185 @@
65.4 +;********************************************************
65.5 +; histogram normalized by rain and compute correleration
65.6 +;********************************************************
65.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
65.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
65.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
65.10 +
65.11 +procedure pminmax(data:numeric,name:string)
65.12 +begin
65.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
65.14 + if(isatt(data,"units")) then
65.15 + print (name + " units = " + data@units)
65.16 + end if
65.17 +end
65.18 +
65.19 +; Main code.
65.20 +begin
65.21 +
65.22 + nclass = 20
65.23 +
65.24 + plot_type = "ps"
65.25 + plot_type_new = "png"
65.26 +
65.27 +;************************************************
65.28 +; read data: model
65.29 +;************************************************
65.30 + co2_i = 283.1878
65.31 + co2_f = 364.1252
65.32 +
65.33 + model_grid = "T42"
65.34 +
65.35 +;model_name_i = "i01.07cn"
65.36 +;model_name_f = "i01.10cn"
65.37 +
65.38 + model_name_i = "i01.07casa"
65.39 + model_name_f = "i01.10casa"
65.40 +
65.41 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
65.42 + film_i = model_name_i + "_1990-2004_ANN_climo.nc"
65.43 + film_f = model_name_f + "_1990-2004_ANN_climo.nc"
65.44 +
65.45 + fm_i = addfile (dirm+film_i,"r")
65.46 + fm_f = addfile (dirm+film_f,"r")
65.47 +
65.48 + npp_i = fm_i->NPP
65.49 + npp_f = fm_f->NPP
65.50 +
65.51 +;************************************************
65.52 +; read data: observed
65.53 +;************************************************
65.54 +
65.55 + ob_name = "MODIS MOD 15A2 2000-2005"
65.56 +
65.57 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
65.58 + filo = "land_class_"+model_grid+".nc"
65.59 +
65.60 + fo = addfile(diro+filo,"r")
65.61 +
65.62 + classob = tofloat(fo->LAND_CLASS)
65.63 +
65.64 + class_name = (/"Water Bodies" \
65.65 + ,"Evergreen Needleleaf Forests" \
65.66 + ,"Evergreen Broadleaf Forests" \
65.67 + ,"Deciduous Needleleaf Forest" \
65.68 + ,"Deciduous Broadleaf Forests" \
65.69 + ,"Mixed Forests" \
65.70 + ,"Closed Bushlands" \
65.71 + ,"Open Bushlands" \
65.72 + ,"Woody Savannas (S. Hem.)" \
65.73 + ,"Savannas (S. Hem.)" \
65.74 + ,"Grasslands" \
65.75 + ,"Permanent Wetlands" \
65.76 + ,"Croplands" \
65.77 + ,"Urban and Built-Up" \
65.78 + ,"Cropland/Natural Vegetation Mosaic" \
65.79 + ,"Permanent Snow and Ice" \
65.80 + ,"Barren or Sparsely Vegetated" \
65.81 + ,"Unclassified" \
65.82 + ,"Woody Savannas (N. Hem.)" \
65.83 + ,"Savannas (N. Hem.)" \
65.84 + /)
65.85 +
65.86 +;*******************************************************************
65.87 +; Calculate "nice" bins for binning the data in equally spaced ranges
65.88 +;********************************************************************
65.89 + nclassn = nclass + 1
65.90 + range = fspan(0,nclassn-1,nclassn)
65.91 +; print (range)
65.92 +
65.93 +; Use this range information to grab all the values in a
65.94 +; particular range, and then take an average.
65.95 +
65.96 + nr = dimsizes(range)
65.97 + nx = nr-1
65.98 + xvalues = new((/2,nx/),float)
65.99 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
65.100 + dx = xvalues(0,1) - xvalues(0,0) ; range width
65.101 + dx4 = dx/4 ; 1/4 of the range
65.102 + xvalues(1,:) = xvalues(0,:) - dx/5.
65.103 +
65.104 +; get data
65.105 +
65.106 + DATA11_1D = ndtooned(classob)
65.107 + DATA12_1D = ndtooned(npp_i)
65.108 + DATA22_1D = ndtooned(npp_f)
65.109 +
65.110 + yvalues = new((/2,nx/),float)
65.111 + mn_yvalues = new((/2,nx/),float)
65.112 + mx_yvalues = new((/2,nx/),float)
65.113 +
65.114 + do nd=0,1
65.115 +
65.116 +; See if we are doing model or observational data.
65.117 +
65.118 + if(nd.eq.0) then
65.119 + data_ob = DATA11_1D
65.120 + data_mod = DATA12_1D
65.121 + else
65.122 + data_ob = DATA11_1D
65.123 + data_mod = DATA22_1D
65.124 + end if
65.125 +
65.126 +; Loop through each range and check for values.
65.127 +
65.128 + do i=0,nr-2
65.129 + if (i.ne.(nr-2)) then
65.130 +; print("")
65.131 +; print("In range ["+range(i)+","+range(i+1)+")")
65.132 + idx = ind((data_ob.ge.range(i)).and.(data_ob.lt.range(i+1)))
65.133 + else
65.134 +; print("")
65.135 +; print("In range ["+range(i)+",)")
65.136 + idx = ind(data_ob.ge.range(i))
65.137 + end if
65.138 +
65.139 +; Calculate average, and get min and max.
65.140 +
65.141 + if(.not.any(ismissing(idx))) then
65.142 + yvalues(nd,i) = avg(data_mod(idx))
65.143 + mn_yvalues(nd,i) = min(data_mod(idx))
65.144 + mx_yvalues(nd,i) = max(data_mod(idx))
65.145 + count = dimsizes(idx)
65.146 + else
65.147 + count = 0
65.148 + yvalues(nd,i) = yvalues@_FillValue
65.149 + mn_yvalues(nd,i) = yvalues@_FillValue
65.150 + mx_yvalues(nd,i) = yvalues@_FillValue
65.151 + end if
65.152 +
65.153 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
65.154 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
65.155 +
65.156 +; Clean up for next time in loop.
65.157 +
65.158 + delete(idx)
65.159 + end do
65.160 + delete(data_ob)
65.161 + delete(data_mod)
65.162 + end do
65.163 +
65.164 +;============================
65.165 +;compute beta
65.166 +;============================
65.167 +
65.168 + u = yvalues(0,:)
65.169 + v = yvalues(1,:)
65.170 +
65.171 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
65.172 + uu = u(good)
65.173 + vv = v(good)
65.174 + ww = class_name(good)
65.175 +
65.176 + n_biome = dimsizes(uu)
65.177 +
65.178 + beta_biome = new((/n_biome/),float)
65.179 +
65.180 + beta_biome = ((vv/uu) - 1.)/log(co2_f/co2_i)
65.181 +
65.182 + beta_biome_avg = avg(beta_biome)
65.183 +
65.184 + print("class/beta: " + ww + "/" + beta_biome)
65.185 + print (beta_biome_avg)
65.186 +
65.187 +end
65.188 +
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
66.2 +++ b/beta/04.biome.ncl Mon Jan 26 22:08:20 2009 -0500
66.3 @@ -0,0 +1,290 @@
66.4 +;********************************************************
66.5 +; required command line input parameters:
66.6 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
66.7 +;
66.8 +; histogram normalized by rain and compute correleration
66.9 +;**************************************************************
66.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
66.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
66.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
66.13 +;**************************************************************
66.14 +procedure set_line(lines:string,nline:integer,newlines:string)
66.15 +begin
66.16 +; add line to ascci/html file
66.17 +
66.18 + nnewlines = dimsizes(newlines)
66.19 + if(nline+nnewlines-1.ge.dimsizes(lines))
66.20 + print("set_line: bad index, not setting anything.")
66.21 + return
66.22 + end if
66.23 + lines(nline:nline+nnewlines-1) = newlines
66.24 +; print ("lines = " + lines(nline:nline+nnewlines-1))
66.25 + nline = nline + nnewlines
66.26 + return
66.27 +end
66.28 +;**************************************************************
66.29 +; Main code.
66.30 +begin
66.31 +
66.32 + nclass = 20
66.33 +
66.34 + plot_type = "ps"
66.35 + plot_type_new = "png"
66.36 +;************************************************
66.37 +; read data: model
66.38 +;************************************************
66.39 + co2_i = 283.1878
66.40 + co2_f = 364.1252
66.41 +
66.42 + model_grid = "T42"
66.43 +
66.44 +;model_name_i = "i01.07cn"
66.45 +;model_name_f = "i01.10cn"
66.46 +
66.47 + model_name_i = "i01.07casa"
66.48 + model_name_f = "i01.10casa"
66.49 +
66.50 + model_name = model_name_f
66.51 +
66.52 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
66.53 + film_i = model_name_i + "_1990-2004_ANN_climo.nc"
66.54 + film_f = model_name_f + "_1990-2004_ANN_climo.nc"
66.55 +
66.56 + fm_i = addfile (dirm+film_i,"r")
66.57 + fm_f = addfile (dirm+film_f,"r")
66.58 +
66.59 + npp_i = fm_i->NPP
66.60 + npp_f = fm_f->NPP
66.61 +
66.62 +;************************************************
66.63 +; read data: observed
66.64 +;************************************************
66.65 +
66.66 + ob_name = "MODIS MOD 15A2 2000-2005"
66.67 +
66.68 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
66.69 + filo = "land_class_"+model_grid+".nc"
66.70 +
66.71 + fo = addfile(diro+filo,"r")
66.72 +
66.73 + classob = tofloat(fo->LAND_CLASS)
66.74 +
66.75 +;*******************************************************************
66.76 +; Calculate "nice" bins for binning the data in equally spaced ranges
66.77 +;********************************************************************
66.78 + nclassn = nclass + 1
66.79 + range = fspan(0,nclassn-1,nclassn)
66.80 +; print (range)
66.81 +
66.82 +; Use this range information to grab all the values in a
66.83 +; particular range, and then take an average.
66.84 +
66.85 + nr = dimsizes(range)
66.86 + nx = nr-1
66.87 + xvalues = new((/2,nx/),float)
66.88 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
66.89 + dx = xvalues(0,1) - xvalues(0,0) ; range width
66.90 + dx4 = dx/4 ; 1/4 of the range
66.91 + xvalues(1,:) = xvalues(0,:) - dx/5.
66.92 +
66.93 +; get data
66.94 +
66.95 + DATA11_1D = ndtooned(classob)
66.96 + DATA12_1D = ndtooned(npp_i)
66.97 + DATA22_1D = ndtooned(npp_f)
66.98 +
66.99 + yvalues = new((/2,nx/),float)
66.100 + mn_yvalues = new((/2,nx/),float)
66.101 + mx_yvalues = new((/2,nx/),float)
66.102 +
66.103 + do nd=0,1
66.104 +
66.105 +; See if we are doing model or observational data.
66.106 +
66.107 + if(nd.eq.0) then
66.108 + data_ob = DATA11_1D
66.109 + data_mod = DATA12_1D
66.110 + else
66.111 + data_ob = DATA11_1D
66.112 + data_mod = DATA22_1D
66.113 + end if
66.114 +
66.115 +; Loop through each range and check for values.
66.116 +
66.117 + do i=0,nr-2
66.118 + if (i.ne.(nr-2)) then
66.119 +; print("")
66.120 +; print("In range ["+range(i)+","+range(i+1)+")")
66.121 + idx = ind((data_ob.ge.range(i)).and.(data_ob.lt.range(i+1)))
66.122 + else
66.123 +; print("")
66.124 +; print("In range ["+range(i)+",)")
66.125 + idx = ind(data_ob.ge.range(i))
66.126 + end if
66.127 +
66.128 +; Calculate average, and get min and max.
66.129 +
66.130 + if(.not.any(ismissing(idx))) then
66.131 + yvalues(nd,i) = avg(data_mod(idx))
66.132 + mn_yvalues(nd,i) = min(data_mod(idx))
66.133 + mx_yvalues(nd,i) = max(data_mod(idx))
66.134 + count = dimsizes(idx)
66.135 + else
66.136 + count = 0
66.137 + yvalues(nd,i) = yvalues@_FillValue
66.138 + mn_yvalues(nd,i) = yvalues@_FillValue
66.139 + mx_yvalues(nd,i) = yvalues@_FillValue
66.140 + end if
66.141 +
66.142 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
66.143 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
66.144 +
66.145 +; Clean up for next time in loop.
66.146 +
66.147 + delete(idx)
66.148 + end do
66.149 + delete(data_ob)
66.150 + delete(data_mod)
66.151 + end do
66.152 +;============================
66.153 +;compute beta
66.154 +;============================
66.155 +
66.156 + nsec_per_year = 60*60*24*365
66.157 +
66.158 + u = yvalues(0,:)
66.159 + v = yvalues(1,:)
66.160 +
66.161 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
66.162 + uu = u(good)* nsec_per_year
66.163 + vv = v(good)* nsec_per_year
66.164 +
66.165 + n_biome = dimsizes(uu)
66.166 +
66.167 + beta_biome = new((/n_biome/),float)
66.168 +
66.169 + beta_biome = ((vv/uu) - 1.)/log(co2_f/co2_i)
66.170 +
66.171 + beta_biome_avg = avg(beta_biome)
66.172 +
66.173 + print (beta_biome_avg)
66.174 +;*******************************************************************
66.175 +; for html table
66.176 +;*******************************************************************
66.177 +
66.178 +; column (not including header column)
66.179 +
66.180 + col_head = (/"CO2_i","CO2_f","NPP_i","NPP_f","Beta"/)
66.181 +
66.182 + ncol = dimsizes(col_head)
66.183 +
66.184 +; row (not including header row)
66.185 + row_head = (/"Water Bodies" \
66.186 + ,"Evergreen Needleleaf Forests" \
66.187 + ,"Evergreen Broadleaf Forests" \
66.188 + ,"Deciduous Needleleaf Forest" \
66.189 + ,"Deciduous Broadleaf Forests" \
66.190 + ,"Mixed Forests" \
66.191 + ,"Closed Bushlands" \
66.192 + ,"Open Bushlands" \
66.193 + ,"Woody Savannas (S. Hem.)" \
66.194 + ,"Savannas (S. Hem.)" \
66.195 + ,"Grasslands" \
66.196 + ,"Permanent Wetlands" \
66.197 + ,"Croplands" \
66.198 + ,"Cropland/Natural Vegetation Mosaic" \
66.199 + ,"Permanent Snow and Ice" \
66.200 + ,"Barren or Sparsely Vegetated" \
66.201 + ,"Woody Savannas (N. Hem.)" \
66.202 + ,"Savannas (N. Hem.)" \
66.203 + ,"All Biome" \
66.204 + /)
66.205 + nrow = dimsizes(row_head)
66.206 +
66.207 +; arrays to be passed to table.
66.208 + text4 = new ((/nrow, ncol/),string )
66.209 +
66.210 + do i=0,nrow-2
66.211 + text4(i,0) = sprintf("%.2f",co2_i)
66.212 + text4(i,1) = sprintf("%.2f",co2_f)
66.213 + text4(i,2) = sprintf("%.2f",uu(i))
66.214 + text4(i,3) = sprintf("%.2f",vv(i))
66.215 + text4(i,4) = sprintf("%.2f",beta_biome(i))
66.216 + end do
66.217 + text4(nrow-1,0) = "-"
66.218 + text4(nrow-1,1) = "-"
66.219 + text4(nrow-1,2) = "-"
66.220 + text4(nrow-1,3) = "-"
66.221 + text4(nrow-1,4) = sprintf("%.2f",beta_biome_avg)
66.222 +
66.223 +;**************************************************
66.224 +; html table
66.225 +;**************************************************
66.226 + output_html = "table_biome.html"
66.227 +
66.228 + header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
66.229 +
66.230 + header = (/"<HTML>" \
66.231 + ,"<HEAD>" \
66.232 + ,"<TITLE>CLAMP metrics</TITLE>" \
66.233 + ,"</HEAD>" \
66.234 + ,header_text \
66.235 + /)
66.236 + footer = "</HTML>"
66.237 +
66.238 + table_header = (/ \
66.239 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
66.240 + ,"<tr>" \
66.241 + ," <th bgcolor=DDDDDD >Biome Class</th>" \
66.242 + ," <th bgcolor=DDDDDD >CO2_i</th>" \
66.243 + ," <th bgcolor=DDDDDD >CO2_f</th>" \
66.244 + ," <th bgcolor=DDDDDD >NPP_i</th>" \
66.245 + ," <th bgcolor=DDDDDD >NPP_f</th>" \
66.246 + ," <th bgcolor=DDDDDD >Beta</th>" \
66.247 + ,"</tr>" \
66.248 + /)
66.249 + table_footer = "</table>"
66.250 + row_header = "<tr>"
66.251 + row_footer = "</tr>"
66.252 +
66.253 + lines = new(50000,string)
66.254 + nline = 0
66.255 +
66.256 + set_line(lines,nline,header)
66.257 + set_line(lines,nline,table_header)
66.258 +;-----------------------------------------------
66.259 +;row of table
66.260 +
66.261 + do n = 0,nrow-1
66.262 + set_line(lines,nline,row_header)
66.263 +
66.264 + txt1 = row_head(n)
66.265 + txt2 = text4(n,0)
66.266 + txt3 = text4(n,1)
66.267 + txt4 = text4(n,2)
66.268 + txt5 = text4(n,3)
66.269 + txt6 = text4(n,4)
66.270 +
66.271 + set_line(lines,nline,"<th>"+txt1+"</th>")
66.272 + set_line(lines,nline,"<th>"+txt2+"</th>")
66.273 + set_line(lines,nline,"<th>"+txt3+"</th>")
66.274 + set_line(lines,nline,"<th>"+txt4+"</th>")
66.275 + set_line(lines,nline,"<th>"+txt5+"</th>")
66.276 + set_line(lines,nline,"<th>"+txt6+"</th>")
66.277 +
66.278 + set_line(lines,nline,row_footer)
66.279 + end do
66.280 +;-----------------------------------------------
66.281 + set_line(lines,nline,table_footer)
66.282 + set_line(lines,nline,footer)
66.283 +
66.284 +; Now write to an HTML file.
66.285 + idx = ind(.not.ismissing(lines))
66.286 + if(.not.any(ismissing(idx))) then
66.287 + asciiwrite(output_html,lines(idx))
66.288 + else
66.289 + print ("error?")
66.290 + end if
66.291 +
66.292 +end
66.293 +
67.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
67.2 +++ b/beta/05.biome.ncl Mon Jan 26 22:08:20 2009 -0500
67.3 @@ -0,0 +1,487 @@
67.4 +;********************************************************
67.5 +; required command line input parameters:
67.6 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
67.7 +;
67.8 +; histogram normalized by rain and compute correleration
67.9 +;**************************************************************
67.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
67.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
67.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
67.13 +;**************************************************************
67.14 +procedure set_line(lines:string,nline:integer,newlines:string)
67.15 +begin
67.16 +; add line to ascci/html file
67.17 +
67.18 + nnewlines = dimsizes(newlines)
67.19 + if(nline+nnewlines-1.ge.dimsizes(lines))
67.20 + print("set_line: bad index, not setting anything.")
67.21 + return
67.22 + end if
67.23 + lines(nline:nline+nnewlines-1) = newlines
67.24 +; print ("lines = " + lines(nline:nline+nnewlines-1))
67.25 + nline = nline + nnewlines
67.26 + return
67.27 +end
67.28 +;**************************************************************
67.29 +; Main code.
67.30 +begin
67.31 +
67.32 + plot_type = "ps"
67.33 + plot_type_new = "png"
67.34 +
67.35 +;************************************************
67.36 +; read data: model
67.37 +;************************************************
67.38 + co2_i = 283.1878
67.39 + co2_f = 364.1252
67.40 +
67.41 + model_grid = "T42"
67.42 +
67.43 + model_name_i = "i01.07cn"
67.44 + model_name_f = "i01.10cn"
67.45 +
67.46 +;model_name_i = "i01.07casa"
67.47 +;model_name_f = "i01.10casa"
67.48 +
67.49 + model_name = model_name_f
67.50 +
67.51 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
67.52 + film_i = model_name_i + "_1990-2004_ANN_climo.nc"
67.53 + film_f = model_name_f + "_1990-2004_ANN_climo.nc"
67.54 +
67.55 + fm_i = addfile (dirm+film_i,"r")
67.56 + fm_f = addfile (dirm+film_f,"r")
67.57 +
67.58 + xm = fm_f->lon
67.59 + ym = fm_f->lat
67.60 +
67.61 + npp_i = fm_i->NPP
67.62 + npp_f = fm_f->NPP
67.63 +
67.64 +;Units for these variables are:
67.65 +;npp_i: g C/m^2/s
67.66 +
67.67 + nsec_per_year = 60*60*24*365
67.68 +
67.69 + npp_i = npp_i * nsec_per_year
67.70 + npp_f = npp_f * nsec_per_year
67.71 +
67.72 +;===================================================
67.73 +; read data: observed -station
67.74 +;===================================================
67.75 +
67.76 + station = (/"DukeFACE" \
67.77 + ,"AspenFACE" \
67.78 + ,"ORNL-FACE" \
67.79 + ,"POP-EUROFACE" \
67.80 + /)
67.81 +
67.82 + lat_ob = (/ 35.58, 45.40, 35.54, 42.22/)
67.83 + lon_ob = (/-79.05, -89.37, -84.20, 11.48/)
67.84 + lon_ob = where(lon_ob.lt.0.,lon_ob+360.,lon_ob)
67.85 +;print (lon_ob)
67.86 +
67.87 + n_sta = dimsizes(station)
67.88 + beta_4_ob = new((/n_sta/),float)
67.89 + beta_4_ob = 0.60
67.90 +
67.91 +;===================================================
67.92 +; get model data at station
67.93 +;===================================================
67.94 +
67.95 + npp_i_4 =linint2_points(xm,ym,npp_i,True,lon_ob,lat_ob,0)
67.96 +
67.97 + npp_f_4 =linint2_points(xm,ym,npp_f,True,lon_ob,lat_ob,0)
67.98 +
67.99 +;print (npp_i_4)
67.100 +;print (npp_f_4)
67.101 +;============================
67.102 +;compute beta_4
67.103 +;============================
67.104 + beta_4 = new((/n_sta/),float)
67.105 +
67.106 + beta_4 = ((npp_f_4/npp_i_4) - 1.)/log(co2_f/co2_i)
67.107 +
67.108 + beta_4_avg = avg(beta_4)
67.109 +
67.110 +;print (beta_4)
67.111 +;print (beta_4_avg)
67.112 +
67.113 +;M_beta = abs((beta_4_avg/beta_4_ob) - 1.)* 3.
67.114 +
67.115 + bias = sum(abs(beta_4-beta_4_ob)/(abs(beta_4)+abs(beta_4_ob)))
67.116 + M_beta = (1. - (bias/n_sta))*3.
67.117 +
67.118 + print (M_beta)
67.119 +
67.120 +;=========================
67.121 +; for html table - station
67.122 +;=========================
67.123 +
67.124 + output_html = "table_station.html"
67.125 +
67.126 +; column (not including header column)
67.127 +
67.128 + col_head = (/"Latitude","Longitude","CO2_i","CO2_f","NPP_i","NPP_f","Beta_model","Beta_ob"/)
67.129 +
67.130 + ncol = dimsizes(col_head)
67.131 +
67.132 +; row (not including header row)
67.133 + row_head = (/"DukeFACE" \
67.134 + ,"AspenFACE" \
67.135 + ,"ORNL-FACE" \
67.136 + ,"POP-EUROFACE" \
67.137 + ,"All Station" \
67.138 + /)
67.139 + nrow = dimsizes(row_head)
67.140 +
67.141 +; arrays to be passed to table.
67.142 + text4 = new ((/nrow, ncol/),string )
67.143 +
67.144 + do i=0,nrow-2
67.145 + text4(i,0) = sprintf("%.1f",lat_ob(i))
67.146 + text4(i,1) = sprintf("%.1f",lon_ob(i))
67.147 + text4(i,2) = sprintf("%.1f",co2_i)
67.148 + text4(i,3) = sprintf("%.1f",co2_f)
67.149 + text4(i,4) = sprintf("%.1f",npp_i_4(0,i))
67.150 + text4(i,5) = sprintf("%.1f",npp_f_4(0,i))
67.151 + text4(i,6) = sprintf("%.1f",beta_4(i))
67.152 + text4(i,7) = "-"
67.153 + end do
67.154 + text4(nrow-1,0) = "-"
67.155 + text4(nrow-1,1) = "-"
67.156 + text4(nrow-1,2) = "-"
67.157 + text4(nrow-1,3) = "-"
67.158 + text4(nrow-1,4) = "-"
67.159 + text4(nrow-1,5) = "-"
67.160 + text4(nrow-1,6) = sprintf("%.1f",beta_4_avg)
67.161 + text4(nrow-1,7) = sprintf("%.1f",avg(beta_4_ob))
67.162 +
67.163 +;-----------
67.164 +; html table
67.165 +;-----------
67.166 +
67.167 + header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
67.168 +
67.169 + header = (/"<HTML>" \
67.170 + ,"<HEAD>" \
67.171 + ,"<TITLE>CLAMP metrics</TITLE>" \
67.172 + ,"</HEAD>" \
67.173 + ,header_text \
67.174 + /)
67.175 + footer = "</HTML>"
67.176 +
67.177 + table_header = (/ \
67.178 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
67.179 + ,"<tr>" \
67.180 + ," <th bgcolor=DDDDDD >Station</th>" \
67.181 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
67.182 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
67.183 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
67.184 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
67.185 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
67.186 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
67.187 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
67.188 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
67.189 + ,"</tr>" \
67.190 + /)
67.191 + table_footer = "</table>"
67.192 + row_header = "<tr>"
67.193 + row_footer = "</tr>"
67.194 +
67.195 + lines = new(50000,string)
67.196 + nline = 0
67.197 +
67.198 + set_line(lines,nline,header)
67.199 + set_line(lines,nline,table_header)
67.200 +;-----------------------------------------------
67.201 +;row of table
67.202 +
67.203 + do n = 0,nrow-1
67.204 + set_line(lines,nline,row_header)
67.205 +
67.206 + txt1 = row_head(n)
67.207 + txt2 = text4(n,0)
67.208 + txt3 = text4(n,1)
67.209 + txt4 = text4(n,2)
67.210 + txt5 = text4(n,3)
67.211 + txt6 = text4(n,4)
67.212 + txt7 = text4(n,5)
67.213 + txt8 = text4(n,6)
67.214 + txt9 = text4(n,7)
67.215 +
67.216 + set_line(lines,nline,"<th>"+txt1+"</th>")
67.217 + set_line(lines,nline,"<th>"+txt2+"</th>")
67.218 + set_line(lines,nline,"<th>"+txt3+"</th>")
67.219 + set_line(lines,nline,"<th>"+txt4+"</th>")
67.220 + set_line(lines,nline,"<th>"+txt5+"</th>")
67.221 + set_line(lines,nline,"<th>"+txt6+"</th>")
67.222 + set_line(lines,nline,"<th>"+txt7+"</th>")
67.223 + set_line(lines,nline,"<th>"+txt8+"</th>")
67.224 + set_line(lines,nline,"<th>"+txt9+"</th>")
67.225 +
67.226 + set_line(lines,nline,row_footer)
67.227 + end do
67.228 +;-----------------------------------------------
67.229 + set_line(lines,nline,table_footer)
67.230 + set_line(lines,nline,footer)
67.231 +
67.232 +; Now write to an HTML file.
67.233 + idx = ind(.not.ismissing(lines))
67.234 + if(.not.any(ismissing(idx))) then
67.235 + asciiwrite(output_html,lines(idx))
67.236 + else
67.237 + print ("error?")
67.238 + end if
67.239 +
67.240 + delete (col_head)
67.241 + delete (row_head)
67.242 + delete (text4)
67.243 + delete (table_header)
67.244 + delete (idx)
67.245 +
67.246 +;************************************************
67.247 +; read data: observed-2
67.248 +;************************************************
67.249 +
67.250 + ob_name = "MODIS MOD 15A2 2000-2005"
67.251 +
67.252 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
67.253 + filo = "land_class_"+model_grid+".nc"
67.254 +
67.255 + fo = addfile(diro+filo,"r")
67.256 +
67.257 + classob = tofloat(fo->LAND_CLASS)
67.258 +
67.259 + nclass = 20
67.260 +
67.261 +;*******************************************************************
67.262 +; Calculate "nice" bins for binning the data in equally spaced ranges
67.263 +;********************************************************************
67.264 +
67.265 + nclassn = nclass + 1
67.266 + range = fspan(0,nclassn-1,nclassn)
67.267 +; print (range)
67.268 +
67.269 +; Use this range information to grab all the values in a
67.270 +; particular range, and then take an average.
67.271 +
67.272 + nr = dimsizes(range)
67.273 + nx = nr-1
67.274 + xvalues = new((/2,nx/),float)
67.275 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
67.276 + dx = xvalues(0,1) - xvalues(0,0) ; range width
67.277 + dx4 = dx/4 ; 1/4 of the range
67.278 + xvalues(1,:) = xvalues(0,:) - dx/5.
67.279 +; get data
67.280 +
67.281 + base_1D = ndtooned(classob)
67.282 + data1_1D = ndtooned(npp_i)
67.283 + data2_1D = ndtooned(npp_f)
67.284 +
67.285 +; output
67.286 +
67.287 + yvalues = new((/2,nx/),float)
67.288 +
67.289 + do nd=0,1
67.290 +
67.291 +; See if we are doing data1 (nd=0) or data2 (nd=1).
67.292 +
67.293 + base = base_1D
67.294 +
67.295 + if(nd.eq.0) then
67.296 + data = data1_1D
67.297 + else
67.298 + data = data2_1D
67.299 + end if
67.300 +
67.301 +; Loop through each range, using base.
67.302 +
67.303 + do i=0,nr-2
67.304 + if (i.ne.(nr-2)) then
67.305 +; print("")
67.306 +; print("In range ["+range(i)+","+range(i+1)+")")
67.307 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
67.308 + else
67.309 +; print("")
67.310 +; print("In range ["+range(i)+",)")
67.311 + idx = ind(base.ge.range(i))
67.312 + end if
67.313 +
67.314 +; Calculate average
67.315 +
67.316 + if(.not.any(ismissing(idx))) then
67.317 + yvalues(nd,i) = avg(data(idx))
67.318 + count = dimsizes(idx)
67.319 + else
67.320 + yvalues(nd,i) = yvalues@_FillValue
67.321 + count = 0
67.322 + end if
67.323 +
67.324 +;#############################################################
67.325 +; set the following 4 classes to _FillValue:
67.326 +; Water Bodies(0), Urban and Build-Up(13),
67.327 +; Permenant Snow and Ice(15), Unclassified(17)
67.328 +
67.329 + if (i.eq.0 .or. i.eq.13 .or. i.eq.15 .or. i.eq.17) then
67.330 + yvalues(nd,i) = yvalues@_FillValue
67.331 + count = 0
67.332 + end if
67.333 +;#############################################################
67.334 +
67.335 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
67.336 +
67.337 +; Clean up for next time in loop.
67.338 +
67.339 + delete(idx)
67.340 + end do
67.341 +
67.342 + delete(data)
67.343 + end do
67.344 +
67.345 +
67.346 +;============================
67.347 +;compute beta
67.348 +;============================
67.349 +
67.350 + u = yvalues(0,:)
67.351 + v = yvalues(1,:)
67.352 +
67.353 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
67.354 +
67.355 + uu = u(good)
67.356 + vv = v(good)
67.357 +
67.358 + n_biome = dimsizes(uu)
67.359 +
67.360 + beta_biome = new((/n_biome/),float)
67.361 +
67.362 + beta_biome = ((vv/uu) - 1.)/log(co2_f/co2_i)
67.363 +
67.364 + beta_biome_avg = avg(beta_biome)
67.365 +
67.366 +;print (beta_biome_avg)
67.367 +
67.368 +;===========================
67.369 +; for html table - biome
67.370 +;===========================
67.371 +
67.372 + output_html = "table_biome.html"
67.373 +
67.374 +; column (not including header column)
67.375 +
67.376 + col_head = (/"CO2_i","CO2_f","NPP_i","NPP_f","Beta_model"/)
67.377 +
67.378 + ncol = dimsizes(col_head)
67.379 +
67.380 +; row (not including header row)
67.381 +; 3 classes removed: Water Bodies, Urban and Build-Up, Unclassified
67.382 +; function "good" removed the last 2 classes
67.383 +; text4(i,2) = sprintf("%.2f",uu(i+1)) remove the first class
67.384 +
67.385 + row_head = (/"Evergreen Needleleaf Forests" \
67.386 + ,"Evergreen Broadleaf Forests" \
67.387 + ,"Deciduous Needleleaf Forest" \
67.388 + ,"Deciduous Broadleaf Forests" \
67.389 + ,"Mixed Forests" \
67.390 + ,"Closed Bushlands" \
67.391 + ,"Open Bushlands" \
67.392 + ,"Woody Savannas (S. Hem.)" \
67.393 + ,"Savannas (S. Hem.)" \
67.394 + ,"Grasslands" \
67.395 + ,"Permanent Wetlands" \
67.396 + ,"Croplands" \
67.397 + ,"Cropland/Natural Vegetation Mosaic" \
67.398 + ,"Barren or Sparsely Vegetated" \
67.399 + ,"Woody Savannas (N. Hem.)" \
67.400 + ,"Savannas (N. Hem.)" \
67.401 + ,"All Biome" \
67.402 + /)
67.403 + nrow = dimsizes(row_head)
67.404 +
67.405 +; arrays to be passed to table.
67.406 + text4 = new ((/nrow, ncol/),string )
67.407 +
67.408 + do i=0,nrow-2
67.409 + text4(i,0) = sprintf("%.1f",co2_i)
67.410 + text4(i,1) = sprintf("%.1f",co2_f)
67.411 + text4(i,2) = sprintf("%.1f",uu(i))
67.412 + text4(i,3) = sprintf("%.1f",vv(i))
67.413 + text4(i,4) = sprintf("%.1f",beta_biome(i))
67.414 + end do
67.415 + text4(nrow-1,0) = "-"
67.416 + text4(nrow-1,1) = "-"
67.417 + text4(nrow-1,2) = "-"
67.418 + text4(nrow-1,3) = "-"
67.419 + text4(nrow-1,4) = sprintf("%.1f",beta_biome_avg)
67.420 +
67.421 +;**************************************************
67.422 +; html table
67.423 +;**************************************************
67.424 +
67.425 + header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
67.426 +
67.427 + header = (/"<HTML>" \
67.428 + ,"<HEAD>" \
67.429 + ,"<TITLE>CLAMP metrics</TITLE>" \
67.430 + ,"</HEAD>" \
67.431 + ,header_text \
67.432 + /)
67.433 + footer = "</HTML>"
67.434 +
67.435 + table_header = (/ \
67.436 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
67.437 + ,"<tr>" \
67.438 + ," <th bgcolor=DDDDDD >Biome Class</th>" \
67.439 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
67.440 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
67.441 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
67.442 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
67.443 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
67.444 + ,"</tr>" \
67.445 + /)
67.446 + table_footer = "</table>"
67.447 + row_header = "<tr>"
67.448 + row_footer = "</tr>"
67.449 +
67.450 + lines = new(50000,string)
67.451 + nline = 0
67.452 +
67.453 + set_line(lines,nline,header)
67.454 + set_line(lines,nline,table_header)
67.455 +;-----------------------------------------------
67.456 +;row of table
67.457 +
67.458 + do n = 0,nrow-1
67.459 + set_line(lines,nline,row_header)
67.460 +
67.461 + txt1 = row_head(n)
67.462 + txt2 = text4(n,0)
67.463 + txt3 = text4(n,1)
67.464 + txt4 = text4(n,2)
67.465 + txt5 = text4(n,3)
67.466 + txt6 = text4(n,4)
67.467 +
67.468 + set_line(lines,nline,"<th>"+txt1+"</th>")
67.469 + set_line(lines,nline,"<th>"+txt2+"</th>")
67.470 + set_line(lines,nline,"<th>"+txt3+"</th>")
67.471 + set_line(lines,nline,"<th>"+txt4+"</th>")
67.472 + set_line(lines,nline,"<th>"+txt5+"</th>")
67.473 + set_line(lines,nline,"<th>"+txt6+"</th>")
67.474 +
67.475 + set_line(lines,nline,row_footer)
67.476 + end do
67.477 +;-----------------------------------------------
67.478 + set_line(lines,nline,table_footer)
67.479 + set_line(lines,nline,footer)
67.480 +
67.481 +; Now write to an HTML file.
67.482 + idx = ind(.not.ismissing(lines))
67.483 + if(.not.any(ismissing(idx))) then
67.484 + asciiwrite(output_html,lines(idx))
67.485 + else
67.486 + print ("error?")
67.487 + end if
67.488 +
67.489 +end
67.490 +
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
68.2 +++ b/beta/06.biome_model.ncl Mon Jan 26 22:08:20 2009 -0500
68.3 @@ -0,0 +1,571 @@
68.4 +;********************************************************
68.5 +; using model biome
68.6 +;
68.7 +; required command line input parameters:
68.8 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
68.9 +;
68.10 +;**************************************************************
68.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
68.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
68.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
68.14 +;**************************************************************
68.15 +procedure set_line(lines:string,nline:integer,newlines:string)
68.16 +begin
68.17 +; add line to ascci/html file
68.18 +
68.19 + nnewlines = dimsizes(newlines)
68.20 + if(nline+nnewlines-1.ge.dimsizes(lines))
68.21 + print("set_line: bad index, not setting anything.")
68.22 + return
68.23 + end if
68.24 + lines(nline:nline+nnewlines-1) = newlines
68.25 +; print ("lines = " + lines(nline:nline+nnewlines-1))
68.26 + nline = nline + nnewlines
68.27 + return
68.28 +end
68.29 +;**************************************************************
68.30 +; Main code.
68.31 +begin
68.32 +
68.33 + plot_type = "ps"
68.34 + plot_type_new = "png"
68.35 +
68.36 +;************************************************
68.37 +; read data: model
68.38 +;************************************************
68.39 + co2_i = 283.1878
68.40 + co2_f = 364.1252
68.41 +
68.42 + model_grid = "T42"
68.43 +
68.44 +;model_name_i = "i01.07cn"
68.45 +;model_name_f = "i01.10cn"
68.46 +
68.47 + model_name_i = "i01.07casa"
68.48 + model_name_f = "i01.10casa"
68.49 +
68.50 + model_name = model_name_f
68.51 +
68.52 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
68.53 + film_i = model_name_i + "_1990-2004_ANN_climo.nc"
68.54 + film_f = model_name_f + "_1990-2004_ANN_climo.nc"
68.55 +
68.56 + fm_i = addfile (dirm+film_i,"r")
68.57 + fm_f = addfile (dirm+film_f,"r")
68.58 +
68.59 + xm = fm_f->lon
68.60 + ym = fm_f->lat
68.61 +
68.62 + npp_i = fm_i->NPP
68.63 + npp_f = fm_f->NPP
68.64 +
68.65 + delete (fm_i)
68.66 + delete (fm_f)
68.67 +
68.68 +;Units for these variables are:
68.69 +;npp_i: g C/m^2/s
68.70 +
68.71 + nsec_per_year = 60*60*24*365
68.72 +
68.73 + npp_i = npp_i * nsec_per_year
68.74 + npp_f = npp_f * nsec_per_year
68.75 +
68.76 +;===================================================
68.77 +; read data: observed at stations
68.78 +;===================================================
68.79 +
68.80 + station = (/"DukeFACE" \
68.81 + ,"AspenFACE" \
68.82 + ,"ORNL-FACE" \
68.83 + ,"POP-EUROFACE" \
68.84 + /)
68.85 +
68.86 + lat_ob = (/ 35.58, 45.40, 35.54, 42.22/)
68.87 + lon_ob = (/-79.05, -89.37, -84.20, 11.48/)
68.88 + lon_ob = where(lon_ob.lt.0.,lon_ob+360.,lon_ob)
68.89 +;print (lon_ob)
68.90 +
68.91 + n_sta = dimsizes(station)
68.92 + beta_4_ob = new((/n_sta/),float)
68.93 + beta_4_ob = 0.60
68.94 +
68.95 +;===================================================
68.96 +; get model data at station
68.97 +;===================================================
68.98 +
68.99 + npp_i_4 =linint2_points(xm,ym,npp_i,True,lon_ob,lat_ob,0)
68.100 +
68.101 + npp_f_4 =linint2_points(xm,ym,npp_f,True,lon_ob,lat_ob,0)
68.102 +
68.103 +;print (npp_i_4)
68.104 +;print (npp_f_4)
68.105 +
68.106 +;============================
68.107 +;compute beta_4
68.108 +;============================
68.109 +
68.110 + beta_4 = new((/n_sta/),float)
68.111 +
68.112 + beta_4 = ((npp_f_4/npp_i_4) - 1.)/log(co2_f/co2_i)
68.113 +
68.114 + beta_4_avg = avg(beta_4)
68.115 +
68.116 +;print (beta_4)
68.117 +;print (beta_4_avg)
68.118 +
68.119 +;M_beta = abs((beta_4_avg/beta_4_ob) - 1.)* 3.
68.120 +
68.121 + bias = sum(abs(beta_4-beta_4_ob)/(abs(beta_4)+abs(beta_4_ob)))
68.122 + M_beta = (1. - (bias/n_sta))*3.
68.123 +
68.124 + print (M_beta)
68.125 +
68.126 +;=========================
68.127 +; for html table - station
68.128 +;=========================
68.129 +
68.130 + output_html = "table_station.html"
68.131 +
68.132 +; column (not including header column)
68.133 +
68.134 + col_head = (/"Latitude","Longitude","CO2_i","CO2_f","NPP_i","NPP_f","Beta_model","Beta_ob"/)
68.135 +
68.136 + ncol = dimsizes(col_head)
68.137 +
68.138 +; row (not including header row)
68.139 + row_head = (/"DukeFACE" \
68.140 + ,"AspenFACE" \
68.141 + ,"ORNL-FACE" \
68.142 + ,"POP-EUROFACE" \
68.143 + ,"All Station" \
68.144 + /)
68.145 + nrow = dimsizes(row_head)
68.146 +
68.147 +; arrays to be passed to table.
68.148 + text4 = new ((/nrow, ncol/),string )
68.149 +
68.150 + do i=0,nrow-2
68.151 + text4(i,0) = sprintf("%.1f",lat_ob(i))
68.152 + text4(i,1) = sprintf("%.1f",lon_ob(i))
68.153 + text4(i,2) = sprintf("%.1f",co2_i)
68.154 + text4(i,3) = sprintf("%.1f",co2_f)
68.155 + text4(i,4) = sprintf("%.1f",npp_i_4(0,i))
68.156 + text4(i,5) = sprintf("%.1f",npp_f_4(0,i))
68.157 + text4(i,6) = sprintf("%.2f",beta_4(i))
68.158 + text4(i,7) = "-"
68.159 + end do
68.160 + text4(nrow-1,0) = "-"
68.161 + text4(nrow-1,1) = "-"
68.162 + text4(nrow-1,2) = "-"
68.163 + text4(nrow-1,3) = "-"
68.164 + text4(nrow-1,4) = "-"
68.165 + text4(nrow-1,5) = "-"
68.166 + text4(nrow-1,6) = sprintf("%.2f",beta_4_avg)
68.167 + text4(nrow-1,7) = sprintf("%.2f",avg(beta_4_ob))
68.168 +
68.169 +;-----------
68.170 +; html table
68.171 +;-----------
68.172 +
68.173 + header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
68.174 +
68.175 + header = (/"<HTML>" \
68.176 + ,"<HEAD>" \
68.177 + ,"<TITLE>CLAMP metrics</TITLE>" \
68.178 + ,"</HEAD>" \
68.179 + ,header_text \
68.180 + /)
68.181 + footer = "</HTML>"
68.182 +
68.183 + table_header = (/ \
68.184 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
68.185 + ,"<tr>" \
68.186 + ," <th bgcolor=DDDDDD >Station</th>" \
68.187 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
68.188 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
68.189 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
68.190 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
68.191 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
68.192 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
68.193 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
68.194 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
68.195 + ,"</tr>" \
68.196 + /)
68.197 + table_footer = "</table>"
68.198 + row_header = "<tr>"
68.199 + row_footer = "</tr>"
68.200 +
68.201 + lines = new(50000,string)
68.202 + nline = 0
68.203 +
68.204 + set_line(lines,nline,header)
68.205 + set_line(lines,nline,table_header)
68.206 +;-----------------------------------------------
68.207 +;row of table
68.208 +
68.209 + do n = 0,nrow-1
68.210 + set_line(lines,nline,row_header)
68.211 +
68.212 + txt1 = row_head(n)
68.213 + txt2 = text4(n,0)
68.214 + txt3 = text4(n,1)
68.215 + txt4 = text4(n,2)
68.216 + txt5 = text4(n,3)
68.217 + txt6 = text4(n,4)
68.218 + txt7 = text4(n,5)
68.219 + txt8 = text4(n,6)
68.220 + txt9 = text4(n,7)
68.221 +
68.222 + set_line(lines,nline,"<th>"+txt1+"</th>")
68.223 + set_line(lines,nline,"<th>"+txt2+"</th>")
68.224 + set_line(lines,nline,"<th>"+txt3+"</th>")
68.225 + set_line(lines,nline,"<th>"+txt4+"</th>")
68.226 + set_line(lines,nline,"<th>"+txt5+"</th>")
68.227 + set_line(lines,nline,"<th>"+txt6+"</th>")
68.228 + set_line(lines,nline,"<th>"+txt7+"</th>")
68.229 + set_line(lines,nline,"<th>"+txt8+"</th>")
68.230 + set_line(lines,nline,"<th>"+txt9+"</th>")
68.231 +
68.232 + set_line(lines,nline,row_footer)
68.233 + end do
68.234 +;-----------------------------------------------
68.235 + set_line(lines,nline,table_footer)
68.236 + set_line(lines,nline,footer)
68.237 +
68.238 +; Now write to an HTML file.
68.239 + idx = ind(.not.ismissing(lines))
68.240 + if(.not.any(ismissing(idx))) then
68.241 + asciiwrite(output_html,lines(idx))
68.242 + else
68.243 + print ("error?")
68.244 + end if
68.245 +
68.246 + delete (col_head)
68.247 + delete (row_head)
68.248 + delete (text4)
68.249 + delete (table_header)
68.250 + delete (idx)
68.251 +
68.252 +;------------------------------------------------
68.253 +; read biome data: model
68.254 +
68.255 + biome_name_mod = "Model PFT Class"
68.256 +
68.257 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
68.258 + film = "class_pft_"+model_grid+".nc"
68.259 +
68.260 + fm = addfile(dirm+film,"r")
68.261 +
68.262 + classmod = fm->CLASS_PFT
68.263 +
68.264 + delete (fm)
68.265 +
68.266 +; model data has 17 land-type classes
68.267 +
68.268 + nclass_mod = 17
68.269 +
68.270 +;------------------------------------------------
68.271 +; read biome data: observed
68.272 +
68.273 + biome_name_ob = "MODIS LandCover"
68.274 +
68.275 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
68.276 + filo = "land_class_"+model_grid+".nc"
68.277 +
68.278 + fo = addfile(diro+filo,"r")
68.279 +
68.280 + classob = tofloat(fo->LAND_CLASS)
68.281 +
68.282 + delete (fo)
68.283 +
68.284 +; input observed data has 20 land-type classes
68.285 +
68.286 + nclass_ob = 20
68.287 +
68.288 +;********************************************************************
68.289 +; use land-type class to bin the data in equally spaced ranges
68.290 +;********************************************************************
68.291 +
68.292 +; using observed biome class
68.293 +; nclass = nclass_ob
68.294 +; using model biome class
68.295 + nclass = nclass_mod
68.296 +
68.297 + nclassn = nclass + 1
68.298 + range = fspan(0,nclassn-1,nclassn)
68.299 +; print (range)
68.300 +
68.301 +; Use this range information to grab all the values in a
68.302 +; particular range, and then take an average.
68.303 +
68.304 + nr = dimsizes(range)
68.305 + nx = nr-1
68.306 + xvalues = new((/2,nx/),float)
68.307 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
68.308 + dx = xvalues(0,1) - xvalues(0,0) ; range width
68.309 + dx4 = dx/4 ; 1/4 of the range
68.310 + xvalues(1,:) = xvalues(0,:) - dx/5.
68.311 +
68.312 +;==============================
68.313 +; put data into bins
68.314 +;==============================
68.315 +
68.316 +; using observed biome class
68.317 +; base_1D = ndtooned(classob)
68.318 +; using model biome class
68.319 + base_1D = ndtooned(classmod)
68.320 +
68.321 + data1_1D = ndtooned(npp_i)
68.322 + data2_1D = ndtooned(npp_f)
68.323 +
68.324 +; output
68.325 +
68.326 + yvalues = new((/2,nx/),float)
68.327 + count = new((/2,nx/),float)
68.328 +
68.329 + do nd=0,1
68.330 +
68.331 +; See if we are doing data1 (nd=0) or data2 (nd=1).
68.332 +
68.333 + base = base_1D
68.334 +
68.335 + if(nd.eq.0) then
68.336 + data = data1_1D
68.337 + else
68.338 + data = data2_1D
68.339 + end if
68.340 +
68.341 +; Loop through each range, using base.
68.342 +
68.343 + do i=0,nr-2
68.344 + if (i.ne.(nr-2)) then
68.345 +; print("")
68.346 +; print("In range ["+range(i)+","+range(i+1)+")")
68.347 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
68.348 + else
68.349 +; print("")
68.350 +; print("In range ["+range(i)+",)")
68.351 + idx = ind(base.ge.range(i))
68.352 + end if
68.353 +
68.354 +; Calculate average
68.355 +
68.356 + if(.not.any(ismissing(idx))) then
68.357 + yvalues(nd,i) = avg(data(idx))
68.358 + count(nd,i) = dimsizes(idx)
68.359 + else
68.360 + yvalues(nd,i) = yvalues@_FillValue
68.361 + count(nd,i) = 0
68.362 + end if
68.363 +
68.364 +;#############################################################
68.365 +;using observed biome class:
68.366 +;
68.367 +; set the following 4 classes to _FillValue:
68.368 +; Water Bodies(0), Urban and Build-Up(13),
68.369 +; Permenant Snow and Ice(15), Unclassified(17)
68.370 +
68.371 +; if (i.eq.0 .or. i.eq.13 .or. i.eq.15 .or. i.eq.17) then
68.372 +; yvalues(nd,i) = yvalues@_FillValue
68.373 +; count(nd,i) = 0
68.374 +; end if
68.375 +;#############################################################
68.376 +
68.377 +;#############################################################
68.378 +;using model biome class:
68.379 +;
68.380 +; set the following 4 classes to _FillValue:
68.381 +; (3)Needleleaf Deciduous Boreal Tree,
68.382 +; (8)Broadleaf Deciduous Boreal Tree,
68.383 +; (9)Broadleaf Evergreen Shrub,
68.384 +; (16)Wheat
68.385 +
68.386 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
68.387 + yvalues(nd,i) = yvalues@_FillValue
68.388 + count(nd,i) = 0
68.389 + end if
68.390 +;#############################################################
68.391 +
68.392 +; print(nd + ": " + count(nd,i) + " points, avg = " + yvalues(nd,i))
68.393 +
68.394 +; Clean up for next time in loop.
68.395 +
68.396 + delete(idx)
68.397 + end do
68.398 +
68.399 + delete(data)
68.400 + end do
68.401 +
68.402 +;============================
68.403 +;compute beta
68.404 +;============================
68.405 +
68.406 + u = yvalues(0,:)
68.407 + v = yvalues(1,:)
68.408 + u_count = count(0,:)
68.409 + v_count = count(1,:)
68.410 +
68.411 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
68.412 +
68.413 + uu = u(good)
68.414 + vv = v(good)
68.415 + uu_count = u_count(good)
68.416 + vv_count = v_count(good)
68.417 +
68.418 + n_biome = dimsizes(uu)
68.419 + beta_biome = new((/n_biome/),float)
68.420 +
68.421 + beta_biome = ((vv/uu) - 1.)/log(co2_f/co2_i)
68.422 +
68.423 +;beta_biome_avg = avg(beta_biome)
68.424 + beta_biome_avg = (sum(vv*vv_count)/sum(uu*uu_count) - 1.)/log(co2_f/co2_i)
68.425 +
68.426 +;print (beta_biome_avg)
68.427 +
68.428 +;===========================
68.429 +; for html table - biome
68.430 +;===========================
68.431 +
68.432 + output_html = "table_biome.html"
68.433 +
68.434 +; column (not including header column)
68.435 +
68.436 + col_head = (/"CO2_i","CO2_f","NPP_i","NPP_f","Beta_model"/)
68.437 +
68.438 + ncol = dimsizes(col_head)
68.439 +
68.440 +; row (not including header row)
68.441 +
68.442 +;----------------------------------------------------
68.443 +; using observed biome class:
68.444 +;
68.445 +; row_head = (/"Evergreen Needleleaf Forests" \
68.446 +; ,"Evergreen Broadleaf Forests" \
68.447 +; ,"Deciduous Needleleaf Forest" \
68.448 +; ,"Deciduous Broadleaf Forests" \
68.449 +; ,"Mixed Forests" \
68.450 +; ,"Closed Bushlands" \
68.451 +; ,"Open Bushlands" \
68.452 +; ,"Woody Savannas (S. Hem.)" \
68.453 +; ,"Savannas (S. Hem.)" \
68.454 +; ,"Grasslands" \
68.455 +; ,"Permanent Wetlands" \
68.456 +; ,"Croplands" \
68.457 +; ,"Cropland/Natural Vegetation Mosaic" \
68.458 +; ,"Barren or Sparsely Vegetated" \
68.459 +; ,"Woody Savannas (N. Hem.)" \
68.460 +; ,"Savannas (N. Hem.)" \
68.461 +; ,"All Biome" \
68.462 +; /)
68.463 +
68.464 +;----------------------------------------------------
68.465 +; using model biome class:
68.466 +;
68.467 + row_head = (/"Not Vegetated" \
68.468 + ,"Needleleaf Evergreen Temperate Tree" \
68.469 + ,"Needleleaf Evergreen Boreal Tree" \
68.470 +; ,"Needleleaf Deciduous Boreal Tree" \
68.471 + ,"Broadleaf Evergreen Tropical Tree" \
68.472 + ,"Broadleaf Evergreen Temperate Tree" \
68.473 + ,"Broadleaf Deciduous Tropical Tree" \
68.474 + ,"Broadleaf Deciduous Temperate Tree" \
68.475 +; ,"Broadleaf Deciduous Boreal Tree" \
68.476 +; ,"Broadleaf Evergreen Shrub" \
68.477 + ,"Broadleaf Deciduous Temperate Shrub" \
68.478 + ,"Broadleaf Deciduous Boreal Shrub" \
68.479 + ,"C3 Arctic Grass" \
68.480 + ,"C3 Non-Arctic Grass" \
68.481 + ,"C4 Grass" \
68.482 + ,"Corn" \
68.483 +; ,"Wheat" \
68.484 + ,"All Biome" \
68.485 + /)
68.486 +
68.487 + nrow = dimsizes(row_head)
68.488 +
68.489 +; arrays to be passed to table.
68.490 + text4 = new ((/nrow, ncol/),string )
68.491 +
68.492 + do i=0,nrow-2
68.493 + text4(i,0) = sprintf("%.1f",co2_i)
68.494 + text4(i,1) = sprintf("%.1f",co2_f)
68.495 + text4(i,2) = sprintf("%.1f",uu(i))
68.496 + text4(i,3) = sprintf("%.1f",vv(i))
68.497 + text4(i,4) = sprintf("%.2f",beta_biome(i))
68.498 + end do
68.499 + text4(nrow-1,0) = "-"
68.500 + text4(nrow-1,1) = "-"
68.501 + text4(nrow-1,2) = "-"
68.502 + text4(nrow-1,3) = "-"
68.503 + text4(nrow-1,4) = sprintf("%.2f",beta_biome_avg)
68.504 +
68.505 +;**************************************************
68.506 +; html table
68.507 +;**************************************************
68.508 +
68.509 + header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
68.510 +
68.511 + header = (/"<HTML>" \
68.512 + ,"<HEAD>" \
68.513 + ,"<TITLE>CLAMP metrics</TITLE>" \
68.514 + ,"</HEAD>" \
68.515 + ,header_text \
68.516 + /)
68.517 + footer = "</HTML>"
68.518 +
68.519 + table_header = (/ \
68.520 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
68.521 + ,"<tr>" \
68.522 + ," <th bgcolor=DDDDDD >Biome Class</th>" \
68.523 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
68.524 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
68.525 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
68.526 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
68.527 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
68.528 + ,"</tr>" \
68.529 + /)
68.530 + table_footer = "</table>"
68.531 + row_header = "<tr>"
68.532 + row_footer = "</tr>"
68.533 +
68.534 + lines = new(50000,string)
68.535 + nline = 0
68.536 +
68.537 + set_line(lines,nline,header)
68.538 + set_line(lines,nline,table_header)
68.539 +;-----------------------------------------------
68.540 +;row of table
68.541 +
68.542 + do n = 0,nrow-1
68.543 + set_line(lines,nline,row_header)
68.544 +
68.545 + txt1 = row_head(n)
68.546 + txt2 = text4(n,0)
68.547 + txt3 = text4(n,1)
68.548 + txt4 = text4(n,2)
68.549 + txt5 = text4(n,3)
68.550 + txt6 = text4(n,4)
68.551 +
68.552 + set_line(lines,nline,"<th>"+txt1+"</th>")
68.553 + set_line(lines,nline,"<th>"+txt2+"</th>")
68.554 + set_line(lines,nline,"<th>"+txt3+"</th>")
68.555 + set_line(lines,nline,"<th>"+txt4+"</th>")
68.556 + set_line(lines,nline,"<th>"+txt5+"</th>")
68.557 + set_line(lines,nline,"<th>"+txt6+"</th>")
68.558 +
68.559 + set_line(lines,nline,row_footer)
68.560 + end do
68.561 +;-----------------------------------------------
68.562 + set_line(lines,nline,table_footer)
68.563 + set_line(lines,nline,footer)
68.564 +
68.565 +; Now write to an HTML file.
68.566 + idx = ind(.not.ismissing(lines))
68.567 + if(.not.any(ismissing(idx))) then
68.568 + asciiwrite(output_html,lines(idx))
68.569 + else
68.570 + print ("error?")
68.571 + end if
68.572 +
68.573 +end
68.574 +
69.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
69.2 +++ b/beta/06.biome_ob.ncl Mon Jan 26 22:08:20 2009 -0500
69.3 @@ -0,0 +1,494 @@
69.4 +;********************************************************
69.5 +; required command line input parameters:
69.6 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
69.7 +;
69.8 +; histogram normalized by rain and compute correleration
69.9 +;**************************************************************
69.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
69.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
69.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
69.13 +;**************************************************************
69.14 +procedure set_line(lines:string,nline:integer,newlines:string)
69.15 +begin
69.16 +; add line to ascci/html file
69.17 +
69.18 + nnewlines = dimsizes(newlines)
69.19 + if(nline+nnewlines-1.ge.dimsizes(lines))
69.20 + print("set_line: bad index, not setting anything.")
69.21 + return
69.22 + end if
69.23 + lines(nline:nline+nnewlines-1) = newlines
69.24 +; print ("lines = " + lines(nline:nline+nnewlines-1))
69.25 + nline = nline + nnewlines
69.26 + return
69.27 +end
69.28 +;**************************************************************
69.29 +; Main code.
69.30 +begin
69.31 +
69.32 + plot_type = "ps"
69.33 + plot_type_new = "png"
69.34 +
69.35 +;************************************************
69.36 +; read data: model
69.37 +;************************************************
69.38 + co2_i = 283.1878
69.39 + co2_f = 364.1252
69.40 +
69.41 + model_grid = "T42"
69.42 +
69.43 + model_name_i = "i01.07cn"
69.44 + model_name_f = "i01.10cn"
69.45 +
69.46 +;model_name_i = "i01.07casa"
69.47 +;model_name_f = "i01.10casa"
69.48 +
69.49 + model_name = model_name_f
69.50 +
69.51 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
69.52 + film_i = model_name_i + "_1990-2004_ANN_climo.nc"
69.53 + film_f = model_name_f + "_1990-2004_ANN_climo.nc"
69.54 +
69.55 + fm_i = addfile (dirm+film_i,"r")
69.56 + fm_f = addfile (dirm+film_f,"r")
69.57 +
69.58 + xm = fm_f->lon
69.59 + ym = fm_f->lat
69.60 +
69.61 + npp_i = fm_i->NPP
69.62 + npp_f = fm_f->NPP
69.63 +
69.64 +;Units for these variables are:
69.65 +;npp_i: g C/m^2/s
69.66 +
69.67 + nsec_per_year = 60*60*24*365
69.68 +
69.69 + npp_i = npp_i * nsec_per_year
69.70 + npp_f = npp_f * nsec_per_year
69.71 +
69.72 +;===================================================
69.73 +; read data: observed -station
69.74 +;===================================================
69.75 +
69.76 + station = (/"DukeFACE" \
69.77 + ,"AspenFACE" \
69.78 + ,"ORNL-FACE" \
69.79 + ,"POP-EUROFACE" \
69.80 + /)
69.81 +
69.82 + lat_ob = (/ 35.58, 45.40, 35.54, 42.22/)
69.83 + lon_ob = (/-79.05, -89.37, -84.20, 11.48/)
69.84 + lon_ob = where(lon_ob.lt.0.,lon_ob+360.,lon_ob)
69.85 +;print (lon_ob)
69.86 +
69.87 + n_sta = dimsizes(station)
69.88 + beta_4_ob = new((/n_sta/),float)
69.89 + beta_4_ob = 0.60
69.90 +
69.91 +;===================================================
69.92 +; get model data at station
69.93 +;===================================================
69.94 +
69.95 + npp_i_4 =linint2_points(xm,ym,npp_i,True,lon_ob,lat_ob,0)
69.96 +
69.97 + npp_f_4 =linint2_points(xm,ym,npp_f,True,lon_ob,lat_ob,0)
69.98 +
69.99 +;print (npp_i_4)
69.100 +;print (npp_f_4)
69.101 +
69.102 +;============================
69.103 +;compute beta_4
69.104 +;============================
69.105 +
69.106 + beta_4 = new((/n_sta/),float)
69.107 +
69.108 + beta_4 = ((npp_f_4/npp_i_4) - 1.)/log(co2_f/co2_i)
69.109 +
69.110 + beta_4_avg = avg(beta_4)
69.111 +
69.112 +;print (beta_4)
69.113 +;print (beta_4_avg)
69.114 +
69.115 +;M_beta = abs((beta_4_avg/beta_4_ob) - 1.)* 3.
69.116 +
69.117 + bias = sum(abs(beta_4-beta_4_ob)/(abs(beta_4)+abs(beta_4_ob)))
69.118 + M_beta = (1. - (bias/n_sta))*3.
69.119 +
69.120 + print (M_beta)
69.121 +
69.122 +;=========================
69.123 +; for html table - station
69.124 +;=========================
69.125 +
69.126 + output_html = "table_station.html"
69.127 +
69.128 +; column (not including header column)
69.129 +
69.130 + col_head = (/"Latitude","Longitude","CO2_i","CO2_f","NPP_i","NPP_f","Beta_model","Beta_ob"/)
69.131 +
69.132 + ncol = dimsizes(col_head)
69.133 +
69.134 +; row (not including header row)
69.135 + row_head = (/"DukeFACE" \
69.136 + ,"AspenFACE" \
69.137 + ,"ORNL-FACE" \
69.138 + ,"POP-EUROFACE" \
69.139 + ,"All Station" \
69.140 + /)
69.141 + nrow = dimsizes(row_head)
69.142 +
69.143 +; arrays to be passed to table.
69.144 + text4 = new ((/nrow, ncol/),string )
69.145 +
69.146 + do i=0,nrow-2
69.147 + text4(i,0) = sprintf("%.1f",lat_ob(i))
69.148 + text4(i,1) = sprintf("%.1f",lon_ob(i))
69.149 + text4(i,2) = sprintf("%.1f",co2_i)
69.150 + text4(i,3) = sprintf("%.1f",co2_f)
69.151 + text4(i,4) = sprintf("%.1f",npp_i_4(0,i))
69.152 + text4(i,5) = sprintf("%.1f",npp_f_4(0,i))
69.153 + text4(i,6) = sprintf("%.2f",beta_4(i))
69.154 + text4(i,7) = "-"
69.155 + end do
69.156 + text4(nrow-1,0) = "-"
69.157 + text4(nrow-1,1) = "-"
69.158 + text4(nrow-1,2) = "-"
69.159 + text4(nrow-1,3) = "-"
69.160 + text4(nrow-1,4) = "-"
69.161 + text4(nrow-1,5) = "-"
69.162 + text4(nrow-1,6) = sprintf("%.2f",beta_4_avg)
69.163 + text4(nrow-1,7) = sprintf("%.2f",avg(beta_4_ob))
69.164 +
69.165 +;-----------
69.166 +; html table
69.167 +;-----------
69.168 +
69.169 + header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
69.170 +
69.171 + header = (/"<HTML>" \
69.172 + ,"<HEAD>" \
69.173 + ,"<TITLE>CLAMP metrics</TITLE>" \
69.174 + ,"</HEAD>" \
69.175 + ,header_text \
69.176 + /)
69.177 + footer = "</HTML>"
69.178 +
69.179 + table_header = (/ \
69.180 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
69.181 + ,"<tr>" \
69.182 + ," <th bgcolor=DDDDDD >Station</th>" \
69.183 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
69.184 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
69.185 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
69.186 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
69.187 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
69.188 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
69.189 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
69.190 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
69.191 + ,"</tr>" \
69.192 + /)
69.193 + table_footer = "</table>"
69.194 + row_header = "<tr>"
69.195 + row_footer = "</tr>"
69.196 +
69.197 + lines = new(50000,string)
69.198 + nline = 0
69.199 +
69.200 + set_line(lines,nline,header)
69.201 + set_line(lines,nline,table_header)
69.202 +;-----------------------------------------------
69.203 +;row of table
69.204 +
69.205 + do n = 0,nrow-1
69.206 + set_line(lines,nline,row_header)
69.207 +
69.208 + txt1 = row_head(n)
69.209 + txt2 = text4(n,0)
69.210 + txt3 = text4(n,1)
69.211 + txt4 = text4(n,2)
69.212 + txt5 = text4(n,3)
69.213 + txt6 = text4(n,4)
69.214 + txt7 = text4(n,5)
69.215 + txt8 = text4(n,6)
69.216 + txt9 = text4(n,7)
69.217 +
69.218 + set_line(lines,nline,"<th>"+txt1+"</th>")
69.219 + set_line(lines,nline,"<th>"+txt2+"</th>")
69.220 + set_line(lines,nline,"<th>"+txt3+"</th>")
69.221 + set_line(lines,nline,"<th>"+txt4+"</th>")
69.222 + set_line(lines,nline,"<th>"+txt5+"</th>")
69.223 + set_line(lines,nline,"<th>"+txt6+"</th>")
69.224 + set_line(lines,nline,"<th>"+txt7+"</th>")
69.225 + set_line(lines,nline,"<th>"+txt8+"</th>")
69.226 + set_line(lines,nline,"<th>"+txt9+"</th>")
69.227 +
69.228 + set_line(lines,nline,row_footer)
69.229 + end do
69.230 +;-----------------------------------------------
69.231 + set_line(lines,nline,table_footer)
69.232 + set_line(lines,nline,footer)
69.233 +
69.234 +; Now write to an HTML file.
69.235 + idx = ind(.not.ismissing(lines))
69.236 + if(.not.any(ismissing(idx))) then
69.237 + asciiwrite(output_html,lines(idx))
69.238 + else
69.239 + print ("error?")
69.240 + end if
69.241 +
69.242 + delete (col_head)
69.243 + delete (row_head)
69.244 + delete (text4)
69.245 + delete (table_header)
69.246 + delete (idx)
69.247 +
69.248 +;************************************************
69.249 +; read data: observed-2
69.250 +;************************************************
69.251 +
69.252 + ob_name = "MODIS MOD 15A2 2000-2005"
69.253 +
69.254 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
69.255 + filo = "land_class_"+model_grid+".nc"
69.256 +
69.257 + fo = addfile(diro+filo,"r")
69.258 +
69.259 + classob = tofloat(fo->LAND_CLASS)
69.260 +
69.261 +; observed data has 20 land-type classes
69.262 + nclass = 20
69.263 +
69.264 +;*******************************************************************
69.265 +; Calculate "nice" bins for binning the data in equally spaced ranges
69.266 +;********************************************************************
69.267 +
69.268 + nclassn = nclass + 1
69.269 + range = fspan(0,nclassn-1,nclassn)
69.270 +; print (range)
69.271 +
69.272 +; Use this range information to grab all the values in a
69.273 +; particular range, and then take an average.
69.274 +
69.275 + nr = dimsizes(range)
69.276 + nx = nr-1
69.277 + xvalues = new((/2,nx/),float)
69.278 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
69.279 + dx = xvalues(0,1) - xvalues(0,0) ; range width
69.280 + dx4 = dx/4 ; 1/4 of the range
69.281 + xvalues(1,:) = xvalues(0,:) - dx/5.
69.282 +; get data
69.283 +
69.284 + base_1D = ndtooned(classob)
69.285 + data1_1D = ndtooned(npp_i)
69.286 + data2_1D = ndtooned(npp_f)
69.287 +
69.288 +; output
69.289 +
69.290 + yvalues = new((/2,nx/),float)
69.291 + count = new((/2,nx/),float)
69.292 +
69.293 + do nd=0,1
69.294 +
69.295 +; See if we are doing data1 (nd=0) or data2 (nd=1).
69.296 +
69.297 + base = base_1D
69.298 +
69.299 + if(nd.eq.0) then
69.300 + data = data1_1D
69.301 + else
69.302 + data = data2_1D
69.303 + end if
69.304 +
69.305 +; Loop through each range, using base.
69.306 +
69.307 + do i=0,nr-2
69.308 + if (i.ne.(nr-2)) then
69.309 +; print("")
69.310 +; print("In range ["+range(i)+","+range(i+1)+")")
69.311 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
69.312 + else
69.313 +; print("")
69.314 +; print("In range ["+range(i)+",)")
69.315 + idx = ind(base.ge.range(i))
69.316 + end if
69.317 +
69.318 +; Calculate average
69.319 +
69.320 + if(.not.any(ismissing(idx))) then
69.321 + yvalues(nd,i) = avg(data(idx))
69.322 + count(nd,i) = dimsizes(idx)
69.323 + else
69.324 + yvalues(nd,i) = yvalues@_FillValue
69.325 + count(nd,i) = 0
69.326 + end if
69.327 +
69.328 +;#############################################################
69.329 +; set the following 4 classes to _FillValue:
69.330 +; Water Bodies(0), Urban and Build-Up(13),
69.331 +; Permenant Snow and Ice(15), Unclassified(17)
69.332 +
69.333 + if (i.eq.0 .or. i.eq.13 .or. i.eq.15 .or. i.eq.17) then
69.334 + yvalues(nd,i) = yvalues@_FillValue
69.335 + count(nd,i) = 0
69.336 + end if
69.337 +;#############################################################
69.338 +
69.339 +; print(nd + ": " + count(nd,i) + " points, avg = " + yvalues(nd,i))
69.340 +
69.341 +; Clean up for next time in loop.
69.342 +
69.343 + delete(idx)
69.344 + end do
69.345 +
69.346 + delete(data)
69.347 + end do
69.348 +
69.349 +;============================
69.350 +;compute beta
69.351 +;============================
69.352 +
69.353 + u = yvalues(0,:)
69.354 + v = yvalues(1,:)
69.355 + u_count = count(0,:)
69.356 + v_count = count(1,:)
69.357 +
69.358 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
69.359 +
69.360 + uu = u(good)
69.361 + vv = v(good)
69.362 + uu_count = u_count(good)
69.363 + vv_count = v_count(good)
69.364 +
69.365 + n_biome = dimsizes(uu)
69.366 + beta_biome = new((/n_biome/),float)
69.367 +
69.368 + beta_biome = ((vv/uu) - 1.)/log(co2_f/co2_i)
69.369 +
69.370 +;beta_biome_avg = avg(beta_biome)
69.371 + beta_biome_avg = (sum(vv*vv_count)/sum(uu*uu_count) - 1.)/log(co2_f/co2_i)
69.372 +
69.373 + print (beta_biome_avg)
69.374 +
69.375 +;===========================
69.376 +; for html table - biome
69.377 +;===========================
69.378 +
69.379 + output_html = "table_biome.html"
69.380 +
69.381 +; column (not including header column)
69.382 +
69.383 + col_head = (/"CO2_i","CO2_f","NPP_i","NPP_f","Beta_model"/)
69.384 +
69.385 + ncol = dimsizes(col_head)
69.386 +
69.387 +; row (not including header row)
69.388 +; 3 classes removed: Water Bodies, Urban and Build-Up, Unclassified
69.389 +; function "good" removed the last 2 classes
69.390 +; text4(i,2) = sprintf("%.2f",uu(i+1)) remove the first class
69.391 +
69.392 + row_head = (/"Evergreen Needleleaf Forests" \
69.393 + ,"Evergreen Broadleaf Forests" \
69.394 + ,"Deciduous Needleleaf Forest" \
69.395 + ,"Deciduous Broadleaf Forests" \
69.396 + ,"Mixed Forests" \
69.397 + ,"Closed Bushlands" \
69.398 + ,"Open Bushlands" \
69.399 + ,"Woody Savannas (S. Hem.)" \
69.400 + ,"Savannas (S. Hem.)" \
69.401 + ,"Grasslands" \
69.402 + ,"Permanent Wetlands" \
69.403 + ,"Croplands" \
69.404 + ,"Cropland/Natural Vegetation Mosaic" \
69.405 + ,"Barren or Sparsely Vegetated" \
69.406 + ,"Woody Savannas (N. Hem.)" \
69.407 + ,"Savannas (N. Hem.)" \
69.408 + ,"All Biome" \
69.409 + /)
69.410 + nrow = dimsizes(row_head)
69.411 +
69.412 +; arrays to be passed to table.
69.413 + text4 = new ((/nrow, ncol/),string )
69.414 +
69.415 + do i=0,nrow-2
69.416 + text4(i,0) = sprintf("%.1f",co2_i)
69.417 + text4(i,1) = sprintf("%.1f",co2_f)
69.418 + text4(i,2) = sprintf("%.1f",uu(i))
69.419 + text4(i,3) = sprintf("%.1f",vv(i))
69.420 + text4(i,4) = sprintf("%.2f",beta_biome(i))
69.421 + end do
69.422 + text4(nrow-1,0) = "-"
69.423 + text4(nrow-1,1) = "-"
69.424 + text4(nrow-1,2) = "-"
69.425 + text4(nrow-1,3) = "-"
69.426 + text4(nrow-1,4) = sprintf("%.2f",beta_biome_avg)
69.427 +
69.428 +;**************************************************
69.429 +; html table
69.430 +;**************************************************
69.431 +
69.432 + header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
69.433 +
69.434 + header = (/"<HTML>" \
69.435 + ,"<HEAD>" \
69.436 + ,"<TITLE>CLAMP metrics</TITLE>" \
69.437 + ,"</HEAD>" \
69.438 + ,header_text \
69.439 + /)
69.440 + footer = "</HTML>"
69.441 +
69.442 + table_header = (/ \
69.443 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
69.444 + ,"<tr>" \
69.445 + ," <th bgcolor=DDDDDD >Biome Class</th>" \
69.446 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
69.447 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
69.448 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
69.449 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
69.450 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
69.451 + ,"</tr>" \
69.452 + /)
69.453 + table_footer = "</table>"
69.454 + row_header = "<tr>"
69.455 + row_footer = "</tr>"
69.456 +
69.457 + lines = new(50000,string)
69.458 + nline = 0
69.459 +
69.460 + set_line(lines,nline,header)
69.461 + set_line(lines,nline,table_header)
69.462 +;-----------------------------------------------
69.463 +;row of table
69.464 +
69.465 + do n = 0,nrow-1
69.466 + set_line(lines,nline,row_header)
69.467 +
69.468 + txt1 = row_head(n)
69.469 + txt2 = text4(n,0)
69.470 + txt3 = text4(n,1)
69.471 + txt4 = text4(n,2)
69.472 + txt5 = text4(n,3)
69.473 + txt6 = text4(n,4)
69.474 +
69.475 + set_line(lines,nline,"<th>"+txt1+"</th>")
69.476 + set_line(lines,nline,"<th>"+txt2+"</th>")
69.477 + set_line(lines,nline,"<th>"+txt3+"</th>")
69.478 + set_line(lines,nline,"<th>"+txt4+"</th>")
69.479 + set_line(lines,nline,"<th>"+txt5+"</th>")
69.480 + set_line(lines,nline,"<th>"+txt6+"</th>")
69.481 +
69.482 + set_line(lines,nline,row_footer)
69.483 + end do
69.484 +;-----------------------------------------------
69.485 + set_line(lines,nline,table_footer)
69.486 + set_line(lines,nline,footer)
69.487 +
69.488 +; Now write to an HTML file.
69.489 + idx = ind(.not.ismissing(lines))
69.490 + if(.not.any(ismissing(idx))) then
69.491 + asciiwrite(output_html,lines(idx))
69.492 + else
69.493 + print ("error?")
69.494 + end if
69.495 +
69.496 +end
69.497 +
70.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
70.2 +++ b/beta/07.landfrac.ncl Mon Jan 26 22:08:20 2009 -0500
70.3 @@ -0,0 +1,591 @@
70.4 +;********************************************************
70.5 +; take into account landfrac
70.6 +; note: landfrac from lnd_T42.nc
70.7 +; <= lnd_diag_4.0 has correct landfrac
70.8 +; lnd_diag_3.1 has wrong landfrac
70.9 +;
70.10 +; using model biome
70.11 +;
70.12 +; required command line input parameters:
70.13 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
70.14 +;
70.15 +;**************************************************************
70.16 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
70.17 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
70.18 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
70.19 +;**************************************************************
70.20 +procedure set_line(lines:string,nline:integer,newlines:string)
70.21 +begin
70.22 +; add line to ascci/html file
70.23 +
70.24 + nnewlines = dimsizes(newlines)
70.25 + if(nline+nnewlines-1.ge.dimsizes(lines))
70.26 + print("set_line: bad index, not setting anything.")
70.27 + return
70.28 + end if
70.29 + lines(nline:nline+nnewlines-1) = newlines
70.30 +; print ("lines = " + lines(nline:nline+nnewlines-1))
70.31 + nline = nline + nnewlines
70.32 + return
70.33 +end
70.34 +;**************************************************************
70.35 +; Main code.
70.36 +begin
70.37 +
70.38 + plot_type = "ps"
70.39 + plot_type_new = "png"
70.40 +
70.41 +;************************************************
70.42 +; read data: model
70.43 +;************************************************
70.44 + co2_i = 283.1878
70.45 + co2_f = 364.1252
70.46 +
70.47 + model_grid = "T42"
70.48 +
70.49 +;model_name_i = "i01.07cn"
70.50 +;model_name_f = "i01.10cn"
70.51 +
70.52 + model_name_i = "i01.07casa"
70.53 + model_name_f = "i01.10casa"
70.54 +
70.55 + model_name = model_name_f
70.56 +
70.57 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
70.58 + film_i = model_name_i + "_1990-2004_ANN_climo.nc"
70.59 + film_f = model_name_f + "_1990-2004_ANN_climo.nc"
70.60 +
70.61 + fm_i = addfile (dirm+film_i,"r")
70.62 + fm_f = addfile (dirm+film_f,"r")
70.63 +
70.64 + xm = fm_f->lon
70.65 + ym = fm_f->lat
70.66 +
70.67 + npp_i = fm_i->NPP
70.68 + npp_f = fm_f->NPP
70.69 +
70.70 + delete (fm_i)
70.71 + delete (fm_f)
70.72 +
70.73 +;Units for these variables are:
70.74 +;npp_i: g C/m^2/s
70.75 +
70.76 + nsec_per_year = 60*60*24*365
70.77 +
70.78 + npp_i = npp_i * nsec_per_year
70.79 + npp_f = npp_f * nsec_per_year
70.80 +
70.81 +;--------------------------------------------------
70.82 +;get landfrac data
70.83 +
70.84 + dirm= "/fis/cgd/cseg/people/jeff/surface_data/"
70.85 + film_l = "lnd_T42.nc"
70.86 + fm_l = addfile (dirm+film_l,"r")
70.87 +
70.88 + landfrac = fm_l->landfrac
70.89 +
70.90 +;npp_i(0,:,:) = npp_i(0,:,:) * landfrac(:,:)
70.91 +;npp_f(0,:,:) = npp_f(0,:,:) * landfrac(:,:)
70.92 +
70.93 + npp_i = npp_i * conform(npp_i, landfrac, (/1,2/))
70.94 + npp_f = npp_f * conform(npp_f, landfrac, (/1,2/))
70.95 +
70.96 +;===================================================
70.97 +; read data: observed at stations
70.98 +;===================================================
70.99 +
70.100 + station = (/"DukeFACE" \
70.101 + ,"AspenFACE" \
70.102 + ,"ORNL-FACE" \
70.103 + ,"POP-EUROFACE" \
70.104 + /)
70.105 +
70.106 + lat_ob = (/ 35.58, 45.40, 35.54, 42.22/)
70.107 + lon_ob = (/-79.05, -89.37, -84.20, 11.48/)
70.108 + lon_ob = where(lon_ob.lt.0.,lon_ob+360.,lon_ob)
70.109 +;print (lon_ob)
70.110 +
70.111 + n_sta = dimsizes(station)
70.112 + beta_4_ob = new((/n_sta/),float)
70.113 + beta_4_ob = 0.60
70.114 +
70.115 +;===================================================
70.116 +; get model data at station
70.117 +;===================================================
70.118 +
70.119 + npp_i_4 =linint2_points(xm,ym,npp_i,True,lon_ob,lat_ob,0)
70.120 +
70.121 + npp_f_4 =linint2_points(xm,ym,npp_f,True,lon_ob,lat_ob,0)
70.122 +
70.123 +;print (npp_i_4)
70.124 +;print (npp_f_4)
70.125 +
70.126 +;============================
70.127 +;compute beta_4
70.128 +;============================
70.129 +
70.130 + beta_4 = new((/n_sta/),float)
70.131 +
70.132 + beta_4 = ((npp_f_4/npp_i_4) - 1.)/log(co2_f/co2_i)
70.133 +
70.134 + beta_4_avg = avg(beta_4)
70.135 +
70.136 +;print (beta_4)
70.137 +;print (beta_4_avg)
70.138 +
70.139 +;M_beta = abs((beta_4_avg/beta_4_ob) - 1.)* 3.
70.140 +
70.141 + bias = sum(abs(beta_4-beta_4_ob)/(abs(beta_4)+abs(beta_4_ob)))
70.142 + M_beta = (1. - (bias/n_sta))*3.
70.143 +
70.144 + print (M_beta)
70.145 +
70.146 +;=========================
70.147 +; for html table - station
70.148 +;=========================
70.149 +
70.150 + output_html = "table_station.html"
70.151 +
70.152 +; column (not including header column)
70.153 +
70.154 + col_head = (/"Latitude","Longitude","CO2_i","CO2_f","NPP_i","NPP_f","Beta_model","Beta_ob"/)
70.155 +
70.156 + ncol = dimsizes(col_head)
70.157 +
70.158 +; row (not including header row)
70.159 + row_head = (/"DukeFACE" \
70.160 + ,"AspenFACE" \
70.161 + ,"ORNL-FACE" \
70.162 + ,"POP-EUROFACE" \
70.163 + ,"All Station" \
70.164 + /)
70.165 + nrow = dimsizes(row_head)
70.166 +
70.167 +; arrays to be passed to table.
70.168 + text4 = new ((/nrow, ncol/),string )
70.169 +
70.170 + do i=0,nrow-2
70.171 + text4(i,0) = sprintf("%.1f",lat_ob(i))
70.172 + text4(i,1) = sprintf("%.1f",lon_ob(i))
70.173 + text4(i,2) = sprintf("%.1f",co2_i)
70.174 + text4(i,3) = sprintf("%.1f",co2_f)
70.175 + text4(i,4) = sprintf("%.1f",npp_i_4(0,i))
70.176 + text4(i,5) = sprintf("%.1f",npp_f_4(0,i))
70.177 + text4(i,6) = sprintf("%.2f",beta_4(i))
70.178 + text4(i,7) = "-"
70.179 + end do
70.180 + text4(nrow-1,0) = "-"
70.181 + text4(nrow-1,1) = "-"
70.182 + text4(nrow-1,2) = "-"
70.183 + text4(nrow-1,3) = "-"
70.184 + text4(nrow-1,4) = "-"
70.185 + text4(nrow-1,5) = "-"
70.186 + text4(nrow-1,6) = sprintf("%.2f",beta_4_avg)
70.187 + text4(nrow-1,7) = sprintf("%.2f",avg(beta_4_ob))
70.188 +
70.189 +;-----------
70.190 +; html table
70.191 +;-----------
70.192 +
70.193 + header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
70.194 +
70.195 + header = (/"<HTML>" \
70.196 + ,"<HEAD>" \
70.197 + ,"<TITLE>CLAMP metrics</TITLE>" \
70.198 + ,"</HEAD>" \
70.199 + ,header_text \
70.200 + /)
70.201 + footer = "</HTML>"
70.202 +
70.203 + table_header = (/ \
70.204 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
70.205 + ,"<tr>" \
70.206 + ," <th bgcolor=DDDDDD >Station</th>" \
70.207 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
70.208 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
70.209 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
70.210 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
70.211 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
70.212 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
70.213 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
70.214 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
70.215 + ,"</tr>" \
70.216 + /)
70.217 + table_footer = "</table>"
70.218 + row_header = "<tr>"
70.219 + row_footer = "</tr>"
70.220 +
70.221 + lines = new(50000,string)
70.222 + nline = 0
70.223 +
70.224 + set_line(lines,nline,header)
70.225 + set_line(lines,nline,table_header)
70.226 +;-----------------------------------------------
70.227 +;row of table
70.228 +
70.229 + do n = 0,nrow-1
70.230 + set_line(lines,nline,row_header)
70.231 +
70.232 + txt1 = row_head(n)
70.233 + txt2 = text4(n,0)
70.234 + txt3 = text4(n,1)
70.235 + txt4 = text4(n,2)
70.236 + txt5 = text4(n,3)
70.237 + txt6 = text4(n,4)
70.238 + txt7 = text4(n,5)
70.239 + txt8 = text4(n,6)
70.240 + txt9 = text4(n,7)
70.241 +
70.242 + set_line(lines,nline,"<th>"+txt1+"</th>")
70.243 + set_line(lines,nline,"<th>"+txt2+"</th>")
70.244 + set_line(lines,nline,"<th>"+txt3+"</th>")
70.245 + set_line(lines,nline,"<th>"+txt4+"</th>")
70.246 + set_line(lines,nline,"<th>"+txt5+"</th>")
70.247 + set_line(lines,nline,"<th>"+txt6+"</th>")
70.248 + set_line(lines,nline,"<th>"+txt7+"</th>")
70.249 + set_line(lines,nline,"<th>"+txt8+"</th>")
70.250 + set_line(lines,nline,"<th>"+txt9+"</th>")
70.251 +
70.252 + set_line(lines,nline,row_footer)
70.253 + end do
70.254 +;-----------------------------------------------
70.255 + set_line(lines,nline,table_footer)
70.256 + set_line(lines,nline,footer)
70.257 +
70.258 +; Now write to an HTML file.
70.259 + idx = ind(.not.ismissing(lines))
70.260 + if(.not.any(ismissing(idx))) then
70.261 + asciiwrite(output_html,lines(idx))
70.262 + else
70.263 + print ("error?")
70.264 + end if
70.265 +
70.266 + delete (col_head)
70.267 + delete (row_head)
70.268 + delete (text4)
70.269 + delete (table_header)
70.270 + delete (idx)
70.271 +
70.272 +;------------------------------------------------
70.273 +; read biome data: model
70.274 +
70.275 + biome_name_mod = "Model PFT Class"
70.276 +
70.277 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
70.278 + film = "class_pft_"+model_grid+".nc"
70.279 +
70.280 + fm = addfile(dirm+film,"r")
70.281 +
70.282 + classmod = fm->CLASS_PFT
70.283 +
70.284 + delete (fm)
70.285 +
70.286 +; model data has 17 land-type classes
70.287 +
70.288 + nclass_mod = 17
70.289 +
70.290 +;------------------------------------------------
70.291 +; read biome data: observed
70.292 +
70.293 + biome_name_ob = "MODIS LandCover"
70.294 +
70.295 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
70.296 + filo = "land_class_"+model_grid+".nc"
70.297 +
70.298 + fo = addfile(diro+filo,"r")
70.299 +
70.300 + classob = tofloat(fo->LAND_CLASS)
70.301 +
70.302 + delete (fo)
70.303 +
70.304 +; input observed data has 20 land-type classes
70.305 +
70.306 + nclass_ob = 20
70.307 +
70.308 +;********************************************************************
70.309 +; use land-type class to bin the data in equally spaced ranges
70.310 +;********************************************************************
70.311 +
70.312 +; using observed biome class
70.313 +; nclass = nclass_ob
70.314 +; using model biome class
70.315 + nclass = nclass_mod
70.316 +
70.317 + nclassn = nclass + 1
70.318 + range = fspan(0,nclassn-1,nclassn)
70.319 +; print (range)
70.320 +
70.321 +; Use this range information to grab all the values in a
70.322 +; particular range, and then take an average.
70.323 +
70.324 + nr = dimsizes(range)
70.325 + nx = nr-1
70.326 + xvalues = new((/2,nx/),float)
70.327 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
70.328 + dx = xvalues(0,1) - xvalues(0,0) ; range width
70.329 + dx4 = dx/4 ; 1/4 of the range
70.330 + xvalues(1,:) = xvalues(0,:) - dx/5.
70.331 +
70.332 +;==============================
70.333 +; put data into bins
70.334 +;==============================
70.335 +
70.336 +; using observed biome class
70.337 +; base_1D = ndtooned(classob)
70.338 +; using model biome class
70.339 + base_1D = ndtooned(classmod)
70.340 +
70.341 + data1_1D = ndtooned(npp_i)
70.342 + data2_1D = ndtooned(npp_f)
70.343 +
70.344 +; output
70.345 +
70.346 + yvalues = new((/2,nx/),float)
70.347 + count = new((/2,nx/),float)
70.348 +
70.349 + do nd=0,1
70.350 +
70.351 +; See if we are doing data1 (nd=0) or data2 (nd=1).
70.352 +
70.353 + base = base_1D
70.354 +
70.355 + if(nd.eq.0) then
70.356 + data = data1_1D
70.357 + else
70.358 + data = data2_1D
70.359 + end if
70.360 +
70.361 +; Loop through each range, using base.
70.362 +
70.363 + do i=0,nr-2
70.364 + if (i.ne.(nr-2)) then
70.365 +; print("")
70.366 +; print("In range ["+range(i)+","+range(i+1)+")")
70.367 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
70.368 + else
70.369 +; print("")
70.370 +; print("In range ["+range(i)+",)")
70.371 + idx = ind(base.ge.range(i))
70.372 + end if
70.373 +
70.374 +; Calculate average
70.375 +
70.376 + if(.not.any(ismissing(idx))) then
70.377 + yvalues(nd,i) = avg(data(idx))
70.378 + count(nd,i) = dimsizes(idx)
70.379 + else
70.380 + yvalues(nd,i) = yvalues@_FillValue
70.381 + count(nd,i) = 0
70.382 + end if
70.383 +
70.384 +;#############################################################
70.385 +;using observed biome class:
70.386 +;
70.387 +; set the following 4 classes to _FillValue:
70.388 +; Water Bodies(0), Urban and Build-Up(13),
70.389 +; Permenant Snow and Ice(15), Unclassified(17)
70.390 +
70.391 +; if (i.eq.0 .or. i.eq.13 .or. i.eq.15 .or. i.eq.17) then
70.392 +; yvalues(nd,i) = yvalues@_FillValue
70.393 +; count(nd,i) = 0
70.394 +; end if
70.395 +;#############################################################
70.396 +
70.397 +;#############################################################
70.398 +;using model biome class:
70.399 +;
70.400 +; set the following 4 classes to _FillValue:
70.401 +; (3)Needleleaf Deciduous Boreal Tree,
70.402 +; (8)Broadleaf Deciduous Boreal Tree,
70.403 +; (9)Broadleaf Evergreen Shrub,
70.404 +; (16)Wheat
70.405 +
70.406 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
70.407 + yvalues(nd,i) = yvalues@_FillValue
70.408 + count(nd,i) = 0
70.409 + end if
70.410 +;#############################################################
70.411 +
70.412 +; print(nd + ": " + count(nd,i) + " points, avg = " + yvalues(nd,i))
70.413 +
70.414 +; Clean up for next time in loop.
70.415 +
70.416 + delete(idx)
70.417 + end do
70.418 +
70.419 + delete(data)
70.420 + end do
70.421 +
70.422 +;============================
70.423 +;compute beta
70.424 +;============================
70.425 +
70.426 + u = yvalues(0,:)
70.427 + v = yvalues(1,:)
70.428 + u_count = count(0,:)
70.429 + v_count = count(1,:)
70.430 +
70.431 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
70.432 +
70.433 + uu = u(good)
70.434 + vv = v(good)
70.435 + uu_count = u_count(good)
70.436 + vv_count = v_count(good)
70.437 +
70.438 + n_biome = dimsizes(uu)
70.439 + beta_biome = new((/n_biome/),float)
70.440 +
70.441 + beta_biome = ((vv/uu) - 1.)/log(co2_f/co2_i)
70.442 +
70.443 +;beta_biome_avg = avg(beta_biome)
70.444 + beta_biome_avg = (sum(vv*vv_count)/sum(uu*uu_count) - 1.)/log(co2_f/co2_i)
70.445 +
70.446 +;print (beta_biome_avg)
70.447 +
70.448 +;===========================
70.449 +; for html table - biome
70.450 +;===========================
70.451 +
70.452 + output_html = "table_biome.html"
70.453 +
70.454 +; column (not including header column)
70.455 +
70.456 + col_head = (/"CO2_i","CO2_f","NPP_i","NPP_f","Beta_model"/)
70.457 +
70.458 + ncol = dimsizes(col_head)
70.459 +
70.460 +; row (not including header row)
70.461 +
70.462 +;----------------------------------------------------
70.463 +; using observed biome class:
70.464 +;
70.465 +; row_head = (/"Evergreen Needleleaf Forests" \
70.466 +; ,"Evergreen Broadleaf Forests" \
70.467 +; ,"Deciduous Needleleaf Forest" \
70.468 +; ,"Deciduous Broadleaf Forests" \
70.469 +; ,"Mixed Forests" \
70.470 +; ,"Closed Bushlands" \
70.471 +; ,"Open Bushlands" \
70.472 +; ,"Woody Savannas (S. Hem.)" \
70.473 +; ,"Savannas (S. Hem.)" \
70.474 +; ,"Grasslands" \
70.475 +; ,"Permanent Wetlands" \
70.476 +; ,"Croplands" \
70.477 +; ,"Cropland/Natural Vegetation Mosaic" \
70.478 +; ,"Barren or Sparsely Vegetated" \
70.479 +; ,"Woody Savannas (N. Hem.)" \
70.480 +; ,"Savannas (N. Hem.)" \
70.481 +; ,"All Biome" \
70.482 +; /)
70.483 +
70.484 +;----------------------------------------------------
70.485 +; using model biome class:
70.486 +;
70.487 + row_head = (/"Not Vegetated" \
70.488 + ,"Needleleaf Evergreen Temperate Tree" \
70.489 + ,"Needleleaf Evergreen Boreal Tree" \
70.490 +; ,"Needleleaf Deciduous Boreal Tree" \
70.491 + ,"Broadleaf Evergreen Tropical Tree" \
70.492 + ,"Broadleaf Evergreen Temperate Tree" \
70.493 + ,"Broadleaf Deciduous Tropical Tree" \
70.494 + ,"Broadleaf Deciduous Temperate Tree" \
70.495 +; ,"Broadleaf Deciduous Boreal Tree" \
70.496 +; ,"Broadleaf Evergreen Shrub" \
70.497 + ,"Broadleaf Deciduous Temperate Shrub" \
70.498 + ,"Broadleaf Deciduous Boreal Shrub" \
70.499 + ,"C3 Arctic Grass" \
70.500 + ,"C3 Non-Arctic Grass" \
70.501 + ,"C4 Grass" \
70.502 + ,"Corn" \
70.503 +; ,"Wheat" \
70.504 + ,"All Biome" \
70.505 + /)
70.506 +
70.507 + nrow = dimsizes(row_head)
70.508 +
70.509 +; arrays to be passed to table.
70.510 + text4 = new ((/nrow, ncol/),string )
70.511 +
70.512 + do i=0,nrow-2
70.513 + text4(i,0) = sprintf("%.1f",co2_i)
70.514 + text4(i,1) = sprintf("%.1f",co2_f)
70.515 + text4(i,2) = sprintf("%.1f",uu(i))
70.516 + text4(i,3) = sprintf("%.1f",vv(i))
70.517 + text4(i,4) = sprintf("%.2f",beta_biome(i))
70.518 + end do
70.519 + text4(nrow-1,0) = "-"
70.520 + text4(nrow-1,1) = "-"
70.521 + text4(nrow-1,2) = "-"
70.522 + text4(nrow-1,3) = "-"
70.523 + text4(nrow-1,4) = sprintf("%.2f",beta_biome_avg)
70.524 +
70.525 +;**************************************************
70.526 +; html table
70.527 +;**************************************************
70.528 +
70.529 + header_text = "<H1>Beta Factor: Model "+model_name+"</H1>"
70.530 +
70.531 + header = (/"<HTML>" \
70.532 + ,"<HEAD>" \
70.533 + ,"<TITLE>CLAMP metrics</TITLE>" \
70.534 + ,"</HEAD>" \
70.535 + ,header_text \
70.536 + /)
70.537 + footer = "</HTML>"
70.538 +
70.539 + table_header = (/ \
70.540 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
70.541 + ,"<tr>" \
70.542 + ," <th bgcolor=DDDDDD >Biome Class</th>" \
70.543 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
70.544 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
70.545 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
70.546 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
70.547 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
70.548 + ,"</tr>" \
70.549 + /)
70.550 + table_footer = "</table>"
70.551 + row_header = "<tr>"
70.552 + row_footer = "</tr>"
70.553 +
70.554 + lines = new(50000,string)
70.555 + nline = 0
70.556 +
70.557 + set_line(lines,nline,header)
70.558 + set_line(lines,nline,table_header)
70.559 +;-----------------------------------------------
70.560 +;row of table
70.561 +
70.562 + do n = 0,nrow-1
70.563 + set_line(lines,nline,row_header)
70.564 +
70.565 + txt1 = row_head(n)
70.566 + txt2 = text4(n,0)
70.567 + txt3 = text4(n,1)
70.568 + txt4 = text4(n,2)
70.569 + txt5 = text4(n,3)
70.570 + txt6 = text4(n,4)
70.571 +
70.572 + set_line(lines,nline,"<th>"+txt1+"</th>")
70.573 + set_line(lines,nline,"<th>"+txt2+"</th>")
70.574 + set_line(lines,nline,"<th>"+txt3+"</th>")
70.575 + set_line(lines,nline,"<th>"+txt4+"</th>")
70.576 + set_line(lines,nline,"<th>"+txt5+"</th>")
70.577 + set_line(lines,nline,"<th>"+txt6+"</th>")
70.578 +
70.579 + set_line(lines,nline,row_footer)
70.580 + end do
70.581 +;-----------------------------------------------
70.582 + set_line(lines,nline,table_footer)
70.583 + set_line(lines,nline,footer)
70.584 +
70.585 +; Now write to an HTML file.
70.586 + idx = ind(.not.ismissing(lines))
70.587 + if(.not.any(ismissing(idx))) then
70.588 + asciiwrite(output_html,lines(idx))
70.589 + else
70.590 + print ("error?")
70.591 + end if
70.592 +
70.593 +end
70.594 +
71.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
71.2 +++ b/biomass/01.read.byte.ncl Mon Jan 26 22:08:20 2009 -0500
71.3 @@ -0,0 +1,71 @@
71.4 +;************************************************
71.5 +; Read byte, Write nc
71.6 +; input data is : 13.8533N -> -21.1277S
71.7 +; -82.7209 -> -33.5739
71.8 +; output data is : -21.1277S -> 13.8533N
71.9 +; 277.2791 -> 326.4261
71.10 +;************************************************
71.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
71.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
71.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
71.14 +;************************************************
71.15 +begin
71.16 +; final output
71.17 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/biomass/ob/"
71.18 + filo = "amazon_biomass.nc"
71.19 + c = addfile(diro+filo,"c")
71.20 +
71.21 +; input byte file
71.22 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/biomass/ob/"
71.23 + fili = "amazon_biomass_byte.nc"
71.24 + b = addfile(diri+fili,"r")
71.25 +
71.26 + data = byte2flt(b->biomass)
71.27 +
71.28 + dsizes_data = dimsizes(data)
71.29 + nlat = dsizes_data(0)
71.30 + nlon = dsizes_data(1)
71.31 +; print (nlat)
71.32 +; print (nlon)
71.33 +
71.34 + lat = new((/nlat/),float)
71.35 + lon = new((/nlon/),float)
71.36 +
71.37 + latS = -21.1277
71.38 + latN = 13.8533
71.39 + lonL = -82.7209
71.40 + lonR = -33.5739
71.41 +
71.42 + dy = abs((latN-latS)/(nlat-1))
71.43 + dx = abs((lonR-lonL)/(nlon-1))
71.44 +
71.45 + do n = 0,nlat-1
71.46 + lat(n) = latS + n*dy
71.47 + end do
71.48 +
71.49 + do n = 0,nlon-1
71.50 + lon(n) = lonL + n*dx + 360.
71.51 + end do
71.52 +
71.53 + lat!0 = "lat"
71.54 + lon!0 = "lon"
71.55 + lat@units = "degrees_north"
71.56 + lat@long_name = "Latitude"
71.57 + lon@units = "degrees_east"
71.58 + lon@long_name = "Longitude"
71.59 + print (lat)
71.60 + print (lon)
71.61 +
71.62 + data!0 = "lat"
71.63 + data!1 = "lon"
71.64 +
71.65 + data@units = "Mg C/ha"
71.66 + data@long_name = "Amoazon Biomass"
71.67 + data@_FillValue = 1.e+36
71.68 +
71.69 +; print (data)
71.70 +
71.71 + c->lat = lat
71.72 + c->lon = lon
71.73 + c->BIOMASS = data(::-1,:)
71.74 +end
72.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
72.2 +++ b/biomass/03.ncl Mon Jan 26 22:08:20 2009 -0500
72.3 @@ -0,0 +1,115 @@
72.4 +; ***********************************************
72.5 +; interpolate into model grids (T31)
72.6 +; ***********************************************
72.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
72.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
72.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
72.10 +;************************************************
72.11 +begin
72.12 +
72.13 +
72.14 +;************************************************
72.15 +; read in observed data
72.16 +;************************************************
72.17 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/biomass/ob/"
72.18 + fili = "amazon_biomass.nc"
72.19 + g = addfile (diri+fili,"r")
72.20 + bi = g->BIOMASS
72.21 + xi = g->lon
72.22 + yi = g->lat
72.23 +
72.24 +
72.25 +;************************************************
72.26 +; read in model data
72.27 +;************************************************
72.28 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
72.29 + fili2 = "b30.061n_1995-2004_ANN_climo_lnd.nc"
72.30 + f = addfile (diri2+fili2,"r")
72.31 +
72.32 + lon = f->lon
72.33 + lat = f->lat
72.34 + nlon = dimsizes(lon)
72.35 + nlat = dimsizes(lat)
72.36 +
72.37 +; print (xi)
72.38 +; print (yi)
72.39 +
72.40 + ind_lonL = min(ind(lon .ge. xi(0)))
72.41 + ind_lonR = max(ind(lon .le. xi(dimsizes(xi)-1)))
72.42 +
72.43 +print (ind_lonL)
72.44 +print (xi(0))
72.45 +print (lon(ind_lonL))
72.46 +
72.47 +print (ind_lonR)
72.48 +print (xi(dimsizes(xi)-1))
72.49 +print (lon(ind_lonR))
72.50 +
72.51 + ind_latS = min(ind(lat .ge. yi(0)))
72.52 + ind_latN = max(ind(lat .le. yi(dimsizes(yi)-1)))
72.53 +
72.54 +print (ind_latS)
72.55 +print (yi(0))
72.56 +print (lat(ind_latS))
72.57 +
72.58 +print (ind_latN)
72.59 +print (yi(dimsizes(yi)-1))
72.60 +print (lat(ind_latN))
72.61 +exit
72.62 + bo = new((/nlat,nlon/),float)
72.63 + do j=0,nlat-1
72.64 + if (j.eq.0 .or. j.eq.nlat-1) then
72.65 + if (j.eq.0) then
72.66 + LATS = -90.
72.67 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
72.68 + end if
72.69 + if (j.eq.nlat-1) then
72.70 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
72.71 + LATN = 90.
72.72 + end if
72.73 + else
72.74 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
72.75 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
72.76 + end if
72.77 +
72.78 +; CLAT = clat({LATS:LATN}) ; do once for *slight* efficiency
72.79 +; TEMP = bi({LATS:LATN},:) ; 2D [lat,lon]
72.80 +
72.81 + do i=0,nlon-1
72.82 + if (i.eq.0 .or. i.eq.nlon-1) then
72.83 + if (i.eq.0) then
72.84 + LONL = 0.
72.85 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
72.86 + end if
72.87 + if (i.eq.nlon-1) then
72.88 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
72.89 + LONR = 360.
72.90 + end if
72.91 + else
72.92 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
72.93 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
72.94 + end if
72.95 +
72.96 +;print (LATS)
72.97 +;print (LATN)
72.98 +;print (LONL)
72.99 +;print (LONR)
72.100 + bo(j,i) = avg(bi({LATS:LATN},{LONL:LONR}))
72.101 +; bo(j,i) = wgt_areaave(TEMP(:,{LONL:LONR}), CLAT, 1.0, 0)
72.102 + end do
72.103 +
72.104 +; delete(CLAT)
72.105 +; delete(TEMP)
72.106 + end do
72.107 +
72.108 + bo!0 = "lat"
72.109 + bo!1 = "lon"
72.110 + bo&lat = lat
72.111 + bo&lon = lon
72.112 + bo@units = bi@units
72.113 + bo@long_name = bi@long_name
72.114 +; bo@_FillValue = bi@_FillValue
72.115 + bo@_FillValue = 1.e+36
72.116 +
72.117 + c->NPP = bo
72.118 +end
72.119 \ No newline at end of file
73.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
73.2 +++ b/biomass/03.ob_to_T31.ncl Mon Jan 26 22:08:20 2009 -0500
73.3 @@ -0,0 +1,188 @@
73.4 +; ***********************************************
73.5 +; interpolate into model grids (T31)
73.6 +; ***********************************************
73.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
73.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
73.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
73.10 +;************************************************
73.11 +begin
73.12 +
73.13 +;************************************************
73.14 +; read in model data
73.15 +;************************************************
73.16 +;fili2 = "b30.061n_1995-2004_ANN_climo_lnd.nc"
73.17 +;model_grid = "T31"
73.18 +;fili2 = "i01.03cn_1545-1569_ANN_climo.nc"
73.19 +;model_grid = "T42"
73.20 + fili2 = "newcn05_ncep_1i_ANN_climo_lnd.nc"
73.21 + model_grid = "1.9"
73.22 +
73.23 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
73.24 + f = addfile (diri2+fili2,"r")
73.25 +
73.26 + lon = f->lon
73.27 + lat = f->lat
73.28 + nlon = dimsizes(lon)
73.29 + nlat = dimsizes(lat)
73.30 +
73.31 +; print (xi)
73.32 +; print (yi)
73.33 +;************************************************
73.34 +; output data
73.35 +;************************************************
73.36 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/biomass/ob/"
73.37 + filo = "amazon_biomass_"+model_grid+".nc"
73.38 + c = addfile(diro+filo,"c")
73.39 +;************************************************
73.40 +; read in observed data
73.41 +;************************************************
73.42 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/biomass/ob/"
73.43 + fili = "amazon_biomass.nc"
73.44 + g = addfile (diri+fili,"r")
73.45 + bi = g->BIOMASS
73.46 + xi = g->lon
73.47 + yi = g->lat
73.48 +;************************************************
73.49 +; from class to value:
73.50 +; Biomass map has 11 classes: (unit= Mg/ha)
73.51 +; 0: (_FillValue)
73.52 +; 1: 0-25 (12.5)
73.53 +; 2: 25-50 (37.5)
73.54 +; 3: 50-75 (62.5)
73.55 +; 4: 75-100 (87.5)
73.56 +; 5: 100-150 (125)
73.57 +; 6: 150-200 (175)
73.58 +; 7: 200-250 (225)
73.59 +; 8: 250-300 (275)
73.60 +; 9: 300-350 (325)
73.61 +; 10: 350-400 (375)
73.62 +; 11: >400 (425)
73.63 +;--------------------------
73.64 +
73.65 + bi@_FillValue = 1.e+36
73.66 +
73.67 + bi = where(bi.eq.0., bi@_FillValue,bi)
73.68 + bi = where(bi.eq.1., 12.5,bi)
73.69 + bi = where(bi.eq.2., 37.5,bi)
73.70 + bi = where(bi.eq.3., 62.5,bi)
73.71 + bi = where(bi.eq.4., 87.5,bi)
73.72 + bi = where(bi.eq.5., 125.,bi)
73.73 + bi = where(bi.eq.6., 175.,bi)
73.74 + bi = where(bi.eq.7., 225.,bi)
73.75 + bi = where(bi.eq.8., 275.,bi)
73.76 + bi = where(bi.eq.9., 325.,bi)
73.77 + bi = where(bi.eq.10.,375.,bi)
73.78 + bi = where(bi.eq.11.,425.,bi)
73.79 +
73.80 +;print("min/max = " + min(bi) + "/" + max(bi))
73.81 +
73.82 +;************************************************
73.83 +; Observed factor_aboveground = 0.5
73.84 +;************************************************
73.85 +
73.86 + factor_aboveground = 0.5
73.87 +;bi = bi * factor_aboveground
73.88 +
73.89 +
73.90 +;************************************************
73.91 +; find model grids that is inside observed grids
73.92 +;************************************************
73.93 + ind_lonL = min(ind(lon .ge. xi(0)))
73.94 + ind_lonR = max(ind(lon .le. xi(dimsizes(xi)-1)))
73.95 +
73.96 + print (ind_lonL)
73.97 +;print (xi(0))
73.98 +;print (lon(ind_lonL))
73.99 +
73.100 + print (ind_lonR)
73.101 +;print (xi(dimsizes(xi)-1))
73.102 +;print (lon(ind_lonR))
73.103 +
73.104 + ind_latS = min(ind(lat .ge. yi(0)))
73.105 + ind_latN = max(ind(lat .le. yi(dimsizes(yi)-1)))
73.106 +
73.107 + print (ind_latS)
73.108 +;print (yi(0))
73.109 +;print (lat(ind_latS))
73.110 +
73.111 + print (ind_latN)
73.112 +;print (yi(dimsizes(yi)-1))
73.113 +;print (lat(ind_latN))
73.114 +
73.115 + nlat_out = ind_latN - ind_latS + 1
73.116 + nlon_out = ind_lonR - ind_lonL + 1
73.117 +
73.118 +print (nlat_out)
73.119 +print (nlon_out)
73.120 +
73.121 + bo = new((/nlat_out,nlon_out/),float)
73.122 + lat_out = new((/nlat_out/),float)
73.123 + lon_out = new((/nlon_out/),float)
73.124 +
73.125 + do jj=0,nlat_out-1
73.126 + j = ind_latS + jj
73.127 + lat_out(jj) = lat(j)
73.128 + if (j.eq.0 .or. j.eq.nlat-1) then
73.129 + if (j.eq.0) then
73.130 + LATS = -90.
73.131 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
73.132 + end if
73.133 + if (j.eq.nlat-1) then
73.134 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
73.135 + LATN = 90.
73.136 + end if
73.137 + else
73.138 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
73.139 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
73.140 + end if
73.141 + do ii=0,nlon_out-1
73.142 + i = ind_lonL + ii
73.143 + if (jj.eq.0) then
73.144 + lon_out(ii) = lon(i)
73.145 + end if
73.146 + if (i.eq.0 .or. i.eq.nlon-1) then
73.147 + if (i.eq.0) then
73.148 + LONL = 0.
73.149 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
73.150 + end if
73.151 + if (i.eq.nlon-1) then
73.152 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
73.153 + LONR = 360.
73.154 + end if
73.155 + else
73.156 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
73.157 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
73.158 + end if
73.159 +
73.160 + print (LATS)
73.161 + print (LATN)
73.162 + print (LONL)
73.163 + print (LONR)
73.164 +
73.165 + bo(jj,ii) = avg(bi({LATS:LATN},{LONL:LONR}))
73.166 + end do
73.167 + end do
73.168 +
73.169 + lon_out!0 = "lon"
73.170 + lon_out@long_name = "longitude"
73.171 + lon_out@units = "degrees_east"
73.172 + lon_out&lon = lon_out
73.173 +
73.174 + lat_out!0 = "lat"
73.175 + lat_out@long_name = "latitude"
73.176 + lat_out@units = "degrees_north"
73.177 + lat_out&lat = lat_out
73.178 +
73.179 + bo!0 = "lat"
73.180 + bo!1 = "lon"
73.181 + bo&lat = lat_out
73.182 + bo&lon = lon_out
73.183 + bo@units = bi@units
73.184 + bo@long_name = bi@long_name
73.185 +; bo@_FillValue = bi@_FillValue
73.186 + bo@_FillValue = 1.e+36
73.187 +
73.188 + c->BIOMASS = bo
73.189 + c->lat = lat_out
73.190 + c->lon = lon_out
73.191 +end
73.192 \ No newline at end of file
74.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
74.2 +++ b/biomass/11.contour_ob.ncl Mon Jan 26 22:08:20 2009 -0500
74.3 @@ -0,0 +1,59 @@
74.4 +;*************************************************
74.5 +; ce_1.ncl
74.6 +;************************************************
74.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
74.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
74.9 +;************************************************
74.10 +begin
74.11 +;************************************************
74.12 +; read in observed data
74.13 +;************************************************
74.14 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/biomass/ob/"
74.15 +; fili = "amazon_biomass.nc"
74.16 +; fili = "amazon_biomass_T31.nc"
74.17 + fili = "amazon_biomass_T42.nc"
74.18 + f = addfile(diri+fili,"r")
74.19 +
74.20 +; y = f->BIOMASS(::50,::50)
74.21 + y = f->BIOMASS
74.22 + printVarSummary(y)
74.23 +
74.24 + print (min(y)+"/"+max(y))
74.25 +
74.26 +;************************************************
74.27 +; create default plot
74.28 +;************************************************
74.29 +
74.30 + wks = gsn_open_wks("ps","xy") ; open a ps file
74.31 + gsn_define_colormap(wks,"gui_default") ; choose colormap
74.32 +
74.33 + res = True ; Use plot options
74.34 + res@cnFillOn = True ; Turn on color fill
74.35 + res@gsnSpreadColors = True ; use full colormap
74.36 +; res@cnFillMode = "RasterFill" ; Turn on raster color
74.37 +; res@lbLabelAutoStride = True
74.38 + res@cnLinesOn = False ; Turn off contourn lines
74.39 + res@mpFillOn = False ; Turn off map fill
74.40 + res@gsnAddCyclic = False
74.41 + res@tiMainString = "LC15_amazon_biomass"
74.42 +
74.43 + res@mpMinLatF = -21.1 ; range to zoom in on
74.44 + res@mpMaxLatF = 13.8
74.45 + res@mpMinLonF = 277.28
74.46 + res@mpMaxLonF = 326.43
74.47 +
74.48 + res@gsnSpreadColors = True ; use full colormap
74.49 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
74.50 +; res@cnMinLevelValF = 1. ; Min level
74.51 +; res@cnMaxLevelValF = 11. ; Max level
74.52 +; res@cnLevelSpacingF = 1. ; interval
74.53 + res@cnMinLevelValF = 0. ; Min level
74.54 + res@cnMaxLevelValF = 450. ; Max level
74.55 + res@cnLevelSpacingF = 50. ; interval
74.56 +; pres = True ; panel plot mods desired
74.57 +; pres@gsnMaximize = True ; fill the page
74.58 +
74.59 + plot = gsn_csm_contour_map_ce(wks,y,res) ; for observed
74.60 +; gsn_panel(wks,plot,(/1,1/),pres) ; create panel plot
74.61 +; system("convert xy.ps xy.png")
74.62 +end
74.63 \ No newline at end of file
75.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
75.2 +++ b/biomass/20.mask_to_1x1.ncl Mon Jan 26 22:08:20 2009 -0500
75.3 @@ -0,0 +1,112 @@
75.4 +;************************************************
75.5 +; Read ascii, Write nc
75.6 +;************************************************
75.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
75.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
75.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
75.10 +;************************************************
75.11 +begin
75.12 +;---------------------------------------------------
75.13 +; final data
75.14 +
75.15 + c = addfile("amazon_mask_1x1.nc","c")
75.16 +
75.17 + nlat = 180
75.18 + nlon = 360
75.19 +
75.20 +;************************************************
75.21 +; read 1x1 mask data
75.22 +;************************************************
75.23 +
75.24 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/observed/biomass/"
75.25 + fili = "mask_1x1.txt"
75.26 + t = asciiread(diri+fili,(/180,360/),"integer")
75.27 +
75.28 + printVarSummary(t)
75.29 +
75.30 + print (min(t)+"/"+max(t))
75.31 +
75.32 + lon = new((/nlon/),float)
75.33 + lat = new((/nlat/),float)
75.34 +
75.35 +; data is (89.5N->89.5S) (-179.5->179.5)
75.36 +
75.37 +; sam result
75.38 +; lon = fspan(-179.5,179.5,nlon)
75.39 +; lat = fspan( -89.5, 89.5,nlat)
75.40 +
75.41 + do i = 0,nlon-1
75.42 + lon(i) = -179.5 + i*(360./nlon)
75.43 + end do
75.44 +
75.45 + do j = 0,nlat-1
75.46 +; lat(j) = -89.5 + j*(180./nlat)
75.47 + lat(j) = 89.5 - j*(180./nlat)
75.48 + end do
75.49 +
75.50 +; print (lon)
75.51 +; print (lat)
75.52 +;=============================
75.53 + ; create lat and long coordinate variables
75.54 + ;============================
75.55 + lon!0 = "lon"
75.56 + lon@long_name = "lon"
75.57 + lon@units = "degrees-east"
75.58 + lon&lon = lon
75.59 +
75.60 + lat!0 = "lat"
75.61 + lat@long_name = "lat"
75.62 + lat@units = "degrees_north"
75.63 + lat&lat = lat
75.64 + ;=============================
75.65 + ; name dimensions of t and assign coordinate variables
75.66 + ;============================
75.67 + t!0 = "lat"
75.68 + t!1 = "lon"
75.69 + t&lat = lat
75.70 + t&lon = lon
75.71 + t@long_name = "amazon mask"
75.72 +; t@units = ""
75.73 + t@_FillValue= -999
75.74 + t@missing_value= -999
75.75 +
75.76 + c->mask_amazon = t
75.77 + c->lat = lat
75.78 + c->lon = lon
75.79 +
75.80 +;************************************************
75.81 +; create default plot
75.82 +;************************************************
75.83 +
75.84 + wks = gsn_open_wks("ps","xy") ; open a ps file
75.85 + gsn_define_colormap(wks,"gui_default") ; choose colormap
75.86 +
75.87 + res = True ; Use plot options
75.88 + res@cnFillOn = True ; Turn on color fill
75.89 + res@gsnSpreadColors = True ; use full colormap
75.90 +; res@cnFillMode = "RasterFill" ; Turn on raster color
75.91 +; res@lbLabelAutoStride = True
75.92 + res@cnLinesOn = False ; Turn off contourn lines
75.93 + res@mpFillOn = False ; Turn off map fill
75.94 + res@gsnAddCyclic = False
75.95 + res@tiMainString = "LC15_amazon_biomass"
75.96 +
75.97 + res@mpMinLatF = -21.1 ; range to zoom in on
75.98 + res@mpMaxLatF = 13.8
75.99 + res@mpMinLonF = 277.28
75.100 + res@mpMaxLonF = 326.43
75.101 +
75.102 + res@gsnSpreadColors = True ; use full colormap
75.103 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
75.104 +; res@cnMinLevelValF = 1. ; Min level
75.105 +; res@cnMaxLevelValF = 11. ; Max level
75.106 +; res@cnLevelSpacingF = 1. ; interval
75.107 + res@cnMinLevelValF = 0. ; Min level
75.108 + res@cnMaxLevelValF = 1. ; Max level
75.109 + res@cnLevelSpacingF = 0.1 ; interval
75.110 +; pres = True ; panel plot mods desired
75.111 +; pres@gsnMaximize = True ; fill the page
75.112 +
75.113 + plot = gsn_csm_contour_map_ce(wks,t,res) ; for observed
75.114 +
75.115 +end
76.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
76.2 +++ b/biomass/25.contour.ncl Mon Jan 26 22:08:20 2009 -0500
76.3 @@ -0,0 +1,61 @@
76.4 +;*************************************************
76.5 +; ce_1.ncl
76.6 +;************************************************
76.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
76.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
76.9 +;************************************************
76.10 +begin
76.11 +;************************************************
76.12 +; read data
76.13 +;************************************************
76.14 + grid = "1x1"
76.15 +; grid = "T31"
76.16 +; grid = "T42"
76.17 +; grid = "1.9"
76.18 +
76.19 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/observed/biomass/"
76.20 + fili = "amazon_mask_"+ grid + ".nc"
76.21 + f = addfile (diri+fili,"r")
76.22 +
76.23 + y = f->mask_amazon
76.24 +
76.25 + printVarSummary(y)
76.26 +
76.27 +;************************************************
76.28 +; create default plot
76.29 +;************************************************
76.30 +
76.31 + wks = gsn_open_wks("ps","mask_"+grid) ; open a ps file
76.32 + gsn_define_colormap(wks,"gui_default") ; choose colormap
76.33 +
76.34 + res = True ; Use plot options
76.35 + res@cnFillOn = True ; Turn on color fill
76.36 + res@gsnSpreadColors = True ; use full colormap
76.37 +; res@cnFillMode = "RasterFill" ; Turn on raster color
76.38 +; res@lbLabelAutoStride = True
76.39 + res@cnLinesOn = False ; Turn off contourn lines
76.40 + res@mpFillOn = False ; Turn off map fill
76.41 + res@gsnAddCyclic = False
76.42 + res@tiMainString = "Amazon Mask: grid = "+ grid
76.43 +
76.44 + res@mpMinLatF = -21.1 ; range to zoom in on
76.45 + res@mpMaxLatF = 13.8
76.46 + res@mpMinLonF = 277.28
76.47 + res@mpMaxLonF = 326.43
76.48 +
76.49 + res@gsnSpreadColors = True ; use full colormap
76.50 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
76.51 +; res@cnMinLevelValF = 1. ; Min level
76.52 +; res@cnMaxLevelValF = 11. ; Max level
76.53 +; res@cnLevelSpacingF = 1. ; interval
76.54 + res@cnMinLevelValF = 0. ; Min level
76.55 + res@cnMaxLevelValF = 1. ; Max level
76.56 + res@cnLevelSpacingF = 0.1 ; interval
76.57 +
76.58 +; pres = True ; panel plot mods desired
76.59 +; pres@gsnMaximize = True ; fill the page
76.60 +
76.61 + plot = gsn_csm_contour_map_ce(wks,y,res) ; for observed
76.62 +; gsn_panel(wks,plot,(/1,1/),pres) ; create panel plot
76.63 +; system("convert xy.ps xy.png")
76.64 +end
76.65 \ No newline at end of file
77.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
77.2 +++ b/biomass/26.contour.ncl Mon Jan 26 22:08:20 2009 -0500
77.3 @@ -0,0 +1,75 @@
77.4 +;*************************************************
77.5 +; ce_1.ncl
77.6 +;************************************************
77.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
77.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
77.9 +;************************************************
77.10 +begin
77.11 +;************************************************
77.12 +; read data
77.13 +;************************************************
77.14 + grid = "1x1"
77.15 +; grid = "T31"
77.16 +; grid = "T42"
77.17 +; grid = "1.9"
77.18 +
77.19 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/observed/biomass/"
77.20 + fili = "amazon_mask_"+ grid + ".nc"
77.21 + f = addfile (diri+fili,"r")
77.22 +
77.23 + y = f->mask_amazon
77.24 +
77.25 + printVarSummary(y)
77.26 +
77.27 + wks = gsn_open_wks ("ps","test") ; open workstation
77.28 + gsn_define_colormap(wks,"gui_default") ; choose colormap
77.29 +
77.30 +;-----------------------------------------
77.31 +; plot area sum
77.32 +
77.33 + gRes = True
77.34 + gRes@txFontHeightF = 0.02
77.35 +; gRes@txAngleF = 90
77.36 +
77.37 + Sum_area = 7.41
77.38 +
77.39 + area_sum_text = "(mask area = "+sprintf("%.2f", Sum_area)+"(x1.e12 m2))"
77.40 +
77.41 + gsn_text_ndc(wks,area_sum_text,0.50,0.80,gRes)
77.42 +;-----------------------------------------
77.43 +
77.44 +;************************************************
77.45 +; create default plot
77.46 +;************************************************
77.47 +
77.48 + res = True ; Use plot options
77.49 + res@cnFillOn = True ; Turn on color fill
77.50 + res@gsnSpreadColors = True ; use full colormap
77.51 +; res@cnFillMode = "RasterFill" ; Turn on raster color
77.52 +; res@lbLabelAutoStride = True
77.53 + res@cnLinesOn = False ; Turn off contourn lines
77.54 + res@mpFillOn = False ; Turn off map fill
77.55 + res@gsnAddCyclic = False
77.56 + res@tiMainString = "Amazon Mask: grid = "+ grid
77.57 +
77.58 + res@mpMinLatF = -21.1 ; range to zoom in on
77.59 + res@mpMaxLatF = 13.8
77.60 + res@mpMinLonF = 277.28
77.61 + res@mpMaxLonF = 326.43
77.62 +
77.63 + res@gsnSpreadColors = True ; use full colormap
77.64 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
77.65 +; res@cnMinLevelValF = 1. ; Min level
77.66 +; res@cnMaxLevelValF = 11. ; Max level
77.67 +; res@cnLevelSpacingF = 1. ; interval
77.68 + res@cnMinLevelValF = 0. ; Min level
77.69 + res@cnMaxLevelValF = 1. ; Max level
77.70 + res@cnLevelSpacingF = 0.1 ; interval
77.71 +
77.72 +; pres = True ; panel plot mods desired
77.73 +; pres@gsnMaximize = True ; fill the page
77.74 +
77.75 + plot = gsn_csm_contour_map_ce(wks,y,res) ; for observed
77.76 +; gsn_panel(wks,plot,(/1,1/),pres) ; create panel plot
77.77 +; system("convert xy.ps xy.png")
77.78 +end
77.79 \ No newline at end of file
78.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
78.2 +++ b/biomass/30.mask_to_T31-T42_1.9.ncl Mon Jan 26 22:08:20 2009 -0500
78.3 @@ -0,0 +1,147 @@
78.4 +; ***********************************************
78.5 +; interpolate into model grids (T31)
78.6 +; ***********************************************
78.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
78.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
78.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
78.10 +;************************************************
78.11 +begin
78.12 +
78.13 +;************************************************
78.14 +; read model grid
78.15 +;************************************************
78.16 +
78.17 + model_grid = "T31"
78.18 +;model_grid = "T42"
78.19 +;model_grid = "1.9"
78.20 +
78.21 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/surface_model/"
78.22 + fili = "lnd_"+ model_grid +".nc"
78.23 + f = addfile (diri+fili,"r")
78.24 +
78.25 + lon = f->lon
78.26 + lat = f->lat
78.27 + nlon = dimsizes(lon)
78.28 + nlat = dimsizes(lat)
78.29 +
78.30 +;************************************************
78.31 +; output data
78.32 +;************************************************
78.33 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/observed/biomass/"
78.34 + filo = "amazon_mask_"+model_grid + ".nc"
78.35 + c = addfile(diro+filo,"c")
78.36 +
78.37 +;************************************************
78.38 +; read 1x1 amazon_mask data
78.39 +;************************************************
78.40 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/observed/biomass/"
78.41 + fili = "amazon_mask_1x1.nc"
78.42 + g = addfile(diri+fili,"r")
78.43 +
78.44 + bi = g->mask_amazon
78.45 + xi = g->lon
78.46 + yi = g->lat
78.47 +
78.48 +;************************************************
78.49 +; change from -180-180, 90N-90S into 0-360E, 90S-90N
78.50 +; Observed NPP*scale_factor
78.51 +;************************************************
78.52 +
78.53 + yi = (/ yi(::-1) /)
78.54 + bi = (/ bi(::-1,:) /)
78.55 + b2 = bi
78.56 + x2 = xi
78.57 +
78.58 + nx = dimsizes(xi)
78.59 + do i= 0,nx-1
78.60 + if (i .lt. 180) then
78.61 + p = i + 180
78.62 + xi(p) = x2(i) + 360.
78.63 + else
78.64 + p = i - 180
78.65 + xi(p) = x2(i)
78.66 + end if
78.67 + bi(:,p)= b2(:,i)
78.68 + end do
78.69 +
78.70 + bi&lat = yi
78.71 + bi&lon = xi
78.72 +
78.73 +;print (xi)
78.74 +;print (yi)
78.75 +
78.76 +;(A)
78.77 +;bo = linint2_Wrap(xi,yi,bi,True,xo,yo,0)
78.78 +
78.79 +;(B)
78.80 +
78.81 + rad = 4.*atan(1.)/180.
78.82 + clat = lat
78.83 + clat = cos(lat*rad)
78.84 +
78.85 + clat@long_name = "cos(latitude)"
78.86 + delete(clat@units)
78.87 +; printVarSummary(clat)
78.88 +
78.89 + bo = new ((/nlat,nlon/),"float")
78.90 +
78.91 + do j=0,nlat-1
78.92 + if (j.eq.0 .or. j.eq.nlat-1) then
78.93 + if (j.eq.0) then
78.94 + LATS = -90.
78.95 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
78.96 + end if
78.97 + if (j.eq.nlat-1) then
78.98 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
78.99 + LATN = 90.
78.100 + end if
78.101 + else
78.102 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
78.103 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
78.104 + end if
78.105 +
78.106 +; CLAT = clat({LATS:LATN}) ; do once for *slight* efficiency
78.107 +; TEMP = bi({LATS:LATN},:) ; 2D [lat,lon]
78.108 +
78.109 + do i=0,nlon-1
78.110 + if (i.eq.0 .or. i.eq.nlon-1) then
78.111 + if (i.eq.0) then
78.112 + LONL = 0.
78.113 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
78.114 + end if
78.115 + if (i.eq.nlon-1) then
78.116 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
78.117 + LONR = 360.
78.118 + end if
78.119 + else
78.120 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
78.121 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
78.122 + end if
78.123 +
78.124 +;print (LATS)
78.125 +;print (LATN)
78.126 +;print (LONL)
78.127 +;print (LONR)
78.128 +
78.129 + bo(j,i) = avg(bi({LATS:LATN},{LONL:LONR}))
78.130 +; bo(j,i) = wgt_areaave(TEMP(:,{LONL:LONR}), CLAT, 1.0, 0)
78.131 +
78.132 + end do
78.133 +
78.134 +; delete(CLAT)
78.135 +; delete(TEMP)
78.136 + end do
78.137 +
78.138 +; bo = where(bo.ge.0.5, 1.0,0.)
78.139 +
78.140 + bo!0 = "lat"
78.141 + bo!1 = "lon"
78.142 + bo&lat = lat
78.143 + bo&lon = lon
78.144 +; bo@units = bi@units
78.145 + bo@long_name = "amazon mask"
78.146 +; bo@_FillValue = bi@_FillValue
78.147 + bo@_FillValue = 1.e+36
78.148 +
78.149 + c->mask_amazon = bo
78.150 +end
78.151 \ No newline at end of file
79.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
79.2 +++ b/biomass/31_area_sum.ncl Mon Jan 26 22:08:20 2009 -0500
79.3 @@ -0,0 +1,194 @@
79.4 +;*************************************************
79.5 +; ce_1.ncl
79.6 +;************************************************
79.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
79.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
79.9 +;************************************************
79.10 +begin
79.11 +
79.12 + plot_type = "ps"
79.13 + plot_type_new = "png"
79.14 +
79.15 +;***********************************************
79.16 +
79.17 + model = "cn"
79.18 +;model = "casa"
79.19 +
79.20 + model_grid = "T42"
79.21 +
79.22 + model_name = "10" + model
79.23 +
79.24 +;************************************************
79.25 +; read amazon mask data
79.26 +;************************************************
79.27 +
79.28 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/observed/biomass/"
79.29 + fili = "amazon_mask_"+ model_grid + ".nc"
79.30 + f = addfile (diri+fili,"r")
79.31 +
79.32 + mask_amazon0 = f->mask_amazon
79.33 +
79.34 + delete (f)
79.35 +
79.36 +;--------------------------------------------------
79.37 +; get model data: landfrac and area
79.38 +
79.39 + dirs = "/fis/cgd/cseg/people/jeff/clamp_data/surface_model/"
79.40 + fils = "lnd_"+ model_grid +".nc"
79.41 + fs = addfile (dirs+fils,"r")
79.42 +
79.43 + landfrac = fs->landfrac
79.44 + area0 = fs->area
79.45 +
79.46 + delete (fs)
79.47 +
79.48 +; change area from km**2 to m**2
79.49 + area0 = area0 * 1.e6
79.50 +
79.51 +;-----------------------------
79.52 +; take into account landfrac
79.53 +
79.54 + area0 = area0 * landfrac
79.55 +
79.56 +;--------------------------------------------
79.57 +; read model data
79.58 +
79.59 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
79.60 + film = "i01.10"+ model +"_1948-2004_ANN_climo.nc"
79.61 + fm = addfile (dirm+film,"r")
79.62 +
79.63 + if (model .eq. "cn") then
79.64 +; unit: gC/m2
79.65 + data1 = fm->LIVESTEMC
79.66 + data2 = fm->DEADSTEMC
79.67 + data3 = fm->LEAFC
79.68 +
79.69 + datamod0 = data1(0,:,:)
79.70 + datamod0 = data1(0,:,:) + data2(0,:,:) + data3(0,:,:)
79.71 + end if
79.72 +
79.73 + if (model .eq. "casa") then
79.74 +; unit: gC/m2
79.75 +; factor_WOODC = 0.7
79.76 + data1 = fm->WOODC
79.77 + data2 = fm->LEAFC
79.78 +
79.79 + datamod0 = data1(0,:,:)
79.80 + datamod0 = data1(0,:,:)*factor_WOODC + data2(0,:,:)
79.81 + end if
79.82 +;----------------------------------------------------
79.83 +
79.84 + xm = fm->lon
79.85 + ym = fm->lat
79.86 +
79.87 + delete (fm)
79.88 +;************************************************
79.89 +; read observed data
79.90 +;************************************************
79.91 + ob_name = "LC15_Amazon_Biomass"
79.92 +
79.93 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/observed/biomass/"
79.94 + filo = "amazon_biomass_"+model_grid+".nc"
79.95 + fo = addfile (diro+filo,"r")
79.96 +
79.97 + dataob = fo->BIOMASS
79.98 + xo = fo->lon
79.99 + yo = fo->lat
79.100 +
79.101 + delete (fo)
79.102 +;************************************************
79.103 +; Units for these variables are:
79.104 +
79.105 +; dataob : MgC/ha
79.106 +; datamod0 : gC/m2
79.107 +
79.108 +; We want to convert these to KgC/m2
79.109 +; ha = 100m*100m = 10,000 m2
79.110 +; MgC/ha*1000/10,000 = KgC/m2
79.111 +; Peta g = 1.e15 g = 1.e12 Kg
79.112 +
79.113 + factor_aboveground = 0.5
79.114 + factor_unit_ob = 0.1
79.115 + factor_unit_mod = 0.001
79.116 +
79.117 + dataob = dataob * factor_aboveground * factor_unit_ob
79.118 + datamod0 = datamod0 * factor_unit_mod
79.119 +
79.120 + dataob@units = "KgC/m2"
79.121 + datamod0@units = "KgC/m2"
79.122 +
79.123 + dataob@long_name = "Amazon Biomass"
79.124 + datamod0@long_name = "Amazon Biomass"
79.125 +
79.126 +;********************************************************
79.127 +; get subset of datamod that match dataob
79.128 +
79.129 + nlon = dimsizes(xo)
79.130 + nlat = dimsizes(yo)
79.131 +
79.132 + ind_lonL = ind(xm .eq. xo(0))
79.133 + ind_lonR = ind(xm .eq. xo(nlon-1))
79.134 + ind_latS = ind(ym .eq. yo(0))
79.135 + ind_latN = ind(ym .eq. yo(nlat-1))
79.136 +
79.137 + datamod = dataob
79.138 + datamod(:,:) = datamod0(ind_latS:ind_latN,ind_lonL:ind_lonR)
79.139 +
79.140 + area = dataob
79.141 + area(:,:) = area0(ind_latS:ind_latN,ind_lonL:ind_lonR)
79.142 +
79.143 + mask_amazon = dataob
79.144 + mask_amazon(:,:) = mask_amazon0(ind_latS:ind_latN,ind_lonL:ind_lonR)
79.145 +
79.146 +;********************************************************
79.147 +; sum over amazom_mask area:
79.148 +
79.149 +; mask_amazon = where(mask_amazon .ge. 0.5, mask_amazon ,0.)
79.150 +
79.151 + area_sum = sum(area*mask_amazon)
79.152 +
79.153 + area_sum_amazon_ob = sum(dataob*area*mask_amazon)
79.154 + area_sum_amazon_mod = sum(datamod*area*mask_amazon)
79.155 +
79.156 +; Peta g = 1.e15 g = 1.e12 Kg
79.157 +
79.158 + print (area_sum_amazon_ob)
79.159 + print (area_sum_amazon_mod)
79.160 + print (area_sum)
79.161 +exit
79.162 +;----------------------------------------------------------------------
79.163 +; global contour
79.164 +
79.165 +;res
79.166 + resg = True ; Use plot options
79.167 + resg@cnFillOn = True ; Turn on color fill
79.168 + resg@gsnSpreadColors = True ; use full colormap
79.169 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
79.170 +; resg@lbLabelAutoStride = True
79.171 + resg@cnLinesOn = False ; Turn off contourn lines
79.172 + resg@mpFillOn = False ; Turn off map fill
79.173 + resg@gsnAddCyclic = False
79.174 +
79.175 + resg@gsnSpreadColors = True ; use full colormap
79.176 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
79.177 + resg@cnMinLevelValF = 0. ; Min level
79.178 + resg@cnMaxLevelValF = 30. ; Max level
79.179 + resg@cnLevelSpacingF = 2. ; interval
79.180 +
79.181 + resg@mpMinLatF = -21.1 ; range to zoom in on
79.182 + resg@mpMaxLatF = 13.8
79.183 + resg@mpMinLonF = 277.28
79.184 + resg@mpMaxLonF = 326.43
79.185 +;------------------------------------------------------------------------
79.186 +;global contour ob
79.187 +
79.188 + plot_name = "global_ob"
79.189 + title = ob_name+" "+ model_grid
79.190 + resg@tiMainString = title
79.191 +
79.192 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
79.193 + gsn_define_colormap(wks,"gui_default") ; choose colormap
79.194 +
79.195 + plot = gsn_csm_contour_map_ce(wks,dataob,resg)
79.196 + frame(wks)
79.197 +end
79.198 \ No newline at end of file
80.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
80.2 +++ b/biomass/99.all.ncl Mon Jan 26 22:08:20 2009 -0500
80.3 @@ -0,0 +1,262 @@
80.4 +; ****************************************************
80.5 +; combine scatter, histogram, global and zonal plots
80.6 +; compute all correlation coef and M score
80.7 +; ****************************************************
80.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
80.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
80.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
80.11 +;************************************************
80.12 +begin
80.13 +
80.14 + plot_type = "ps"
80.15 + plot_type_new = "png"
80.16 +;************************************************
80.17 +; read in model data
80.18 +;************************************************
80.19 +;film = "b30.061n_1995-2004_ANN_climo_lnd.nc"
80.20 +;model_name = "b30.061n"
80.21 +;model_grid = "T31"
80.22 +
80.23 +;film = "newcn05_ncep_1i_ANN_climo_lnd.nc"
80.24 +;model_name = "newcn"
80.25 +;model_grid = "1.9"
80.26 +;--------------------------------------------
80.27 + film = "i01.10cn_1948-2004_ANN_climo.nc"
80.28 + model_name = "10cn"
80.29 + model_grid = "T42"
80.30 +
80.31 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
80.32 + fm = addfile (dirm+film,"r")
80.33 +
80.34 +;unit: gC/m2
80.35 + data1 = fm->LIVESTEMC
80.36 + data2 = fm->DEADSTEMC
80.37 + data3 = fm->LEAFC
80.38 + datamod0 = data1(0,:,:)
80.39 + datamod0 = data1(0,:,:) + data2(0,:,:) + data3(0,:,:)
80.40 +;-------------------------------------------
80.41 +;film = "i01.10casa_1948-2004_ANN_climo.nc"
80.42 +;model_name = "10casa"
80.43 +;model_grid = "T42"
80.44 +
80.45 +;dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
80.46 +;fm = addfile (dirm+film,"r")
80.47 +
80.48 +;unit: gC/m2
80.49 +;factor_WOODC = 0.7
80.50 +;data1 = fm->WOODC
80.51 +;data2 = fm->LEAFC
80.52 +;datamod0 = data1(0,:,:)
80.53 +;datamod0 = data1(0,:,:)*factor_WOODC + data2(0,:,:)
80.54 +;----------------------------------------------------
80.55 + html_name = "table.html." + model_name
80.56 + html_new = html_name +".new"
80.57 + system("sed s#model_name#"+model_name+"# "+html_name+" > "+html_new+";"+ \
80.58 + "mv -f "+html_new+" "+html_name)
80.59 +
80.60 + xm = fm->lon
80.61 + ym = fm->lat
80.62 +;************************************************
80.63 +; read in ob data
80.64 +;************************************************
80.65 + ob_name = "LC15_Amazon_Biomass"
80.66 +
80.67 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/biomass/ob/"
80.68 + filo = "amazon_biomass_"+model_grid+".nc"
80.69 + fo = addfile (diro+filo,"r")
80.70 +
80.71 + dataob = fo->BIOMASS
80.72 + xo = fo->lon
80.73 + yo = fo->lat
80.74 +;************************************************
80.75 +; Units for these variables are:
80.76 +; dataob : MgC/ha
80.77 +; datamod0 : gC/m2
80.78 +; We want to convert these to KgC/m2
80.79 +; ha = 100m*100m = 10,000 m2
80.80 +; MgC/ha*1000/10,000 = KgC/m2
80.81 +
80.82 + factor_aboveground = 0.5
80.83 + factor_unit_ob = 0.1
80.84 + factor_unit_mod = 0.001
80.85 +
80.86 + dataob = dataob * factor_aboveground * factor_unit_ob
80.87 + datamod0 = datamod0 * factor_unit_mod
80.88 +
80.89 + dataob@units = "KgC/m2"
80.90 + datamod0@units = "KgC/m2"
80.91 +
80.92 + dataob@long_name = "Amazon Biomass"
80.93 + datamod0@long_name = "Amazon Biomass"
80.94 +;********************************************************
80.95 +; get subset of datamod0 that match dataob
80.96 +
80.97 + nlon = dimsizes(xo)
80.98 + nlat = dimsizes(yo)
80.99 +
80.100 + ind_lonL = ind(xm .eq. xo(0))
80.101 + ind_lonR = ind(xm .eq. xo(nlon-1))
80.102 + ind_latS = ind(ym .eq. yo(0))
80.103 + ind_latN = ind(ym .eq. yo(nlat-1))
80.104 +
80.105 + datamod = dataob
80.106 + datamod(:,:) = datamod0(ind_latS:ind_latN,ind_lonL:ind_lonR)
80.107 +
80.108 +; print (datamod)
80.109 +
80.110 +;----------------------------------------------------------------------
80.111 +; global contour
80.112 +
80.113 +;res
80.114 + resg = True ; Use plot options
80.115 + resg@cnFillOn = True ; Turn on color fill
80.116 + resg@gsnSpreadColors = True ; use full colormap
80.117 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
80.118 +; resg@lbLabelAutoStride = True
80.119 + resg@cnLinesOn = False ; Turn off contourn lines
80.120 + resg@mpFillOn = False ; Turn off map fill
80.121 + resg@gsnAddCyclic = False
80.122 +
80.123 + resg@gsnSpreadColors = True ; use full colormap
80.124 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
80.125 + resg@cnMinLevelValF = 0. ; Min level
80.126 + resg@cnMaxLevelValF = 30. ; Max level
80.127 + resg@cnLevelSpacingF = 2. ; interval
80.128 +
80.129 + resg@mpMinLatF = -21.1 ; range to zoom in on
80.130 + resg@mpMaxLatF = 13.8
80.131 + resg@mpMinLonF = 277.28
80.132 + resg@mpMaxLonF = 326.43
80.133 +;------------------------------------------------------------------------
80.134 +;global contour ob
80.135 +
80.136 + plot_name = "global_ob"
80.137 + title = ob_name+" "+ model_grid
80.138 + resg@tiMainString = title
80.139 +
80.140 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
80.141 + gsn_define_colormap(wks,"gui_default") ; choose colormap
80.142 +
80.143 + plot = gsn_csm_contour_map_ce(wks,dataob,resg)
80.144 + frame(wks)
80.145 +
80.146 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
80.147 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
80.148 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
80.149 + "rm "+plot_name+"."+plot_type)
80.150 +
80.151 + clear (wks)
80.152 +;------------------------------------------------------------------------
80.153 +;global contour model
80.154 +
80.155 + plot_name = "global_model"
80.156 + title = "Model "+ model_name
80.157 + resg@tiMainString = title
80.158 +
80.159 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
80.160 + gsn_define_colormap(wks,"gui_default") ; choose colormap
80.161 +
80.162 + plot = gsn_csm_contour_map_ce(wks,datamod,resg)
80.163 + frame(wks)
80.164 +
80.165 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
80.166 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
80.167 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
80.168 + "rm "+plot_name+"."+plot_type)
80.169 +
80.170 + clear (wks)
80.171 +;------------------------------------------------------------------------
80.172 +;global contour model vs ob
80.173 +
80.174 + plot_name = "global_model_vs_ob"
80.175 +
80.176 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
80.177 + gsn_define_colormap(wks,"gui_default") ; choose colormap
80.178 +
80.179 + delete (plot)
80.180 + plot=new(3,graphic) ; create graphic array
80.181 +
80.182 + resg@gsnFrame = False ; Do not draw plot
80.183 + resg@gsnDraw = False ; Do not advance frame
80.184 +
80.185 +;(d) compute correlation coef and M score
80.186 +
80.187 + uu = ndtooned(datamod)
80.188 + vv = ndtooned(dataob)
80.189 +
80.190 + good = ind(.not.ismissing(uu) .and. .not.ismissing(vv))
80.191 +
80.192 + ug = uu(good)
80.193 + vg = vv(good)
80.194 +
80.195 + ccrG = esccr(ug,vg,0)
80.196 +; print (ccrG)
80.197 +
80.198 + MG = (ccrG*ccrG)* 5.0
80.199 +; new eq
80.200 + bias = sum(abs(ug-vg)/(abs(ug)+abs(vg)))
80.201 + MG = (1. - (bias/dimsizes(ug)))*5.
80.202 +
80.203 + M_biomass = sprintf("%.2f", MG)
80.204 + system("sed s#M_biomass#"+M_biomass+"# "+html_name+" > "+html_new+";"+ \
80.205 + "mv -f "+html_new+" "+html_name)
80.206 + print (M_biomass)
80.207 +
80.208 +; plot correlation coef
80.209 +
80.210 + gRes = True
80.211 + gRes@txFontHeightF = 0.02
80.212 + gRes@txAngleF = 90
80.213 +
80.214 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrG)+")"
80.215 +
80.216 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
80.217 +;--------------------------------------------------------------------
80.218 +
80.219 +;(a) ob
80.220 +
80.221 + title = ob_name+" "+ model_grid
80.222 + resg@tiMainString = title
80.223 +
80.224 + plot(0) = gsn_csm_contour_map_ce(wks,dataob,resg)
80.225 +
80.226 +;(b) model
80.227 +
80.228 + title = "Model "+ model_name
80.229 + resg@tiMainString = title
80.230 +
80.231 + plot(1) = gsn_csm_contour_map_ce(wks,datamod,resg)
80.232 +
80.233 +;(c) model-ob
80.234 +
80.235 + zz = datamod
80.236 + zz = datamod - dataob
80.237 + title = "Model_"+model_name+" - Observed"
80.238 +
80.239 + resg@cnMinLevelValF = -10. ; Min level
80.240 + resg@cnMaxLevelValF = 10. ; Max level
80.241 + resg@cnLevelSpacingF = 2. ; interval
80.242 + resg@tiMainString = title
80.243 +
80.244 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
80.245 +
80.246 + pres = True ; panel plot mods desired
80.247 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
80.248 + ; indiv. plots in panel
80.249 + pres@gsnMaximize = True ; fill the page
80.250 +
80.251 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
80.252 +
80.253 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
80.254 + "rm "+plot_name+"."+plot_type)
80.255 +
80.256 + clear (wks)
80.257 + delete (plot)
80.258 +;-------------------------------------------------------------------
80.259 + temp_name = "biomass." + model_name
80.260 + system("mkdir -p " + temp_name+";"+ \
80.261 + "cp "+ html_name + " " +temp_name+"/table.html"+";"+ \
80.262 + "mv *.png " + temp_name +";"+ \
80.263 + "tar cf "+ temp_name +".tar " + temp_name)
80.264 +;-------------------------------------------------------------------
80.265 +end
81.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
81.2 +++ b/biomass/99.all.ncl.0 Mon Jan 26 22:08:20 2009 -0500
81.3 @@ -0,0 +1,258 @@
81.4 +; ****************************************************
81.5 +; combine scatter, histogram, global and zonal plots
81.6 +; compute all correlation coef and M score
81.7 +; ****************************************************
81.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
81.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
81.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
81.11 +;************************************************
81.12 +begin
81.13 +
81.14 + plot_type = "ps"
81.15 + plot_type_new = "png"
81.16 +;************************************************
81.17 +; read in model data
81.18 +;************************************************
81.19 +;film = "i01.03cn_1545-1569_ANN_climo.nc"
81.20 +;model_name = "i01.03cn"
81.21 +;model_grid = "T42"
81.22 +
81.23 +;film = "b30.061n_1995-2004_ANN_climo_lnd.nc"
81.24 +;model_name = "b30.061n"
81.25 +;model_grid = "T31"
81.26 +
81.27 +;film = "newcn05_ncep_1i_ANN_climo_lnd.nc"
81.28 +;model_name = "newcn"
81.29 +;model_grid = "1.9"
81.30 +
81.31 +;film = "i01.06cn_1798-2004_ANN_climo.nc"
81.32 +;model_name = "06cn"
81.33 +;model_grid = "T42"
81.34 +
81.35 +;film = "i01.06casa_1798-2004_ANN_climo.nc"
81.36 +;model_name = "06casa"
81.37 +;model_grid = "T42"
81.38 +;note: use 98.all.ncl
81.39 +
81.40 + film = "i01.10cn_1948-2004_ANN_climo.nc"
81.41 + model_name = "10cn"
81.42 + model_grid = "T42"
81.43 +
81.44 +;film = "i01.10casa_1948-2004_ANN_climo.nc"
81.45 +;model_name = "10casa"
81.46 +;model_grid = "T42"
81.47 +;----------------------------------------------------
81.48 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
81.49 + fm = addfile (dirm+film,"r")
81.50 +
81.51 +;unit: gC/m2
81.52 + data1 = fm->LIVESTEMC
81.53 + data2 = fm->DEADSTEMC
81.54 + data3 = fm->LEAFC
81.55 + datamod0 = data1(0,:,:)
81.56 + datamod0 = data1(0,:,:) + data2(0,:,:) + data3(0,:,:)
81.57 +
81.58 + xm = fm->lon
81.59 + ym = fm->lat
81.60 +;************************************************
81.61 +; read in ob data
81.62 +;************************************************
81.63 + ob_name = "LC15_Amazon_Biomass"
81.64 +
81.65 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/biomass/ob/"
81.66 + filo = "amazon_biomass_"+model_grid+".nc"
81.67 + fo = addfile (diro+filo,"r")
81.68 +
81.69 + dataob = fo->BIOMASS
81.70 + xo = fo->lon
81.71 + yo = fo->lat
81.72 +;************************************************
81.73 +; Units for these variables are:
81.74 +; dataob : MgC/ha
81.75 +; datamod0 : gC/m2
81.76 +; We want to convert these to KgC/m2
81.77 +; ha = 100m*100m = 10,000 m2
81.78 +; MgC/ha*1000/10,000 = KgC/m2
81.79 +
81.80 + factor_aboveground = 0.5
81.81 + factor_unit_ob = 0.1
81.82 + factor_unit_mod = 0.001
81.83 +
81.84 + dataob = dataob * factor_aboveground * factor_unit_ob
81.85 + datamod0 = datamod0 * factor_unit_mod
81.86 +
81.87 + dataob@units = "KgC/m2"
81.88 + datamod0@units = "KgC/m2"
81.89 +
81.90 + dataob@long_name = "Amazon Biomass"
81.91 + datamod0@long_name = "Amazon Biomass"
81.92 +;********************************************************
81.93 +; get subset of datamod0 that match dataob
81.94 +
81.95 + nlon = dimsizes(xo)
81.96 + nlat = dimsizes(yo)
81.97 +
81.98 + ind_lonL = ind(xm .eq. xo(0))
81.99 + ind_lonR = ind(xm .eq. xo(nlon-1))
81.100 + ind_latS = ind(ym .eq. yo(0))
81.101 + ind_latN = ind(ym .eq. yo(nlat-1))
81.102 +
81.103 + datamod = dataob
81.104 + datamod(:,:) = datamod0(ind_latS:ind_latN,ind_lonL:ind_lonR)
81.105 +
81.106 +; print (datamod)
81.107 +
81.108 +;----------------------------------------------------------------------
81.109 +; global contour
81.110 +
81.111 +;res
81.112 + resg = True ; Use plot options
81.113 + resg@cnFillOn = True ; Turn on color fill
81.114 + resg@gsnSpreadColors = True ; use full colormap
81.115 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
81.116 +; resg@lbLabelAutoStride = True
81.117 + resg@cnLinesOn = False ; Turn off contourn lines
81.118 + resg@mpFillOn = False ; Turn off map fill
81.119 + resg@gsnAddCyclic = False
81.120 +
81.121 + resg@gsnSpreadColors = True ; use full colormap
81.122 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
81.123 + resg@cnMinLevelValF = 0. ; Min level
81.124 + resg@cnMaxLevelValF = 30. ; Max level
81.125 + resg@cnLevelSpacingF = 2. ; interval
81.126 +
81.127 + resg@mpMinLatF = -21.1 ; range to zoom in on
81.128 + resg@mpMaxLatF = 13.8
81.129 + resg@mpMinLonF = 277.28
81.130 + resg@mpMaxLonF = 326.43
81.131 +;------------------------------------------------------------------------
81.132 +;global contour ob
81.133 +
81.134 + plot_name = "global_ob"
81.135 + title = ob_name+" "+ model_grid
81.136 + resg@tiMainString = title
81.137 +
81.138 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
81.139 + gsn_define_colormap(wks,"gui_default") ; choose colormap
81.140 +
81.141 + plot = gsn_csm_contour_map_ce(wks,dataob,resg)
81.142 + frame(wks)
81.143 +
81.144 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
81.145 +; system("rm "+plot_name+"."+plot_type)
81.146 + system("rm "+plot_name+"-1."+plot_type_new)
81.147 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
81.148 +
81.149 + clear (wks)
81.150 +;------------------------------------------------------------------------
81.151 +;global contour model
81.152 +
81.153 + plot_name = "global_model"
81.154 + title = "Model "+ model_name
81.155 + resg@tiMainString = title
81.156 +
81.157 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
81.158 + gsn_define_colormap(wks,"gui_default") ; choose colormap
81.159 +
81.160 + plot = gsn_csm_contour_map_ce(wks,datamod,resg)
81.161 + frame(wks)
81.162 +
81.163 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
81.164 +; system("rm "+plot_name+"."+plot_type)
81.165 + system("rm "+plot_name+"-1."+plot_type_new)
81.166 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
81.167 +
81.168 + clear (wks)
81.169 +;------------------------------------------------------------------------
81.170 +;global contour model vs ob
81.171 +
81.172 + plot_name = "global_model_vs_ob"
81.173 +
81.174 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
81.175 + gsn_define_colormap(wks,"gui_default") ; choose colormap
81.176 +
81.177 + delete (plot)
81.178 + plot=new(3,graphic) ; create graphic array
81.179 +
81.180 + resg@gsnFrame = False ; Do not draw plot
81.181 + resg@gsnDraw = False ; Do not advance frame
81.182 +
81.183 +;(d) compute correlation coef and M score
81.184 +
81.185 + uu = ndtooned(datamod)
81.186 + vv = ndtooned(dataob)
81.187 +
81.188 + good = ind(.not.ismissing(uu) .and. .not.ismissing(vv))
81.189 +
81.190 + ug = uu(good)
81.191 + vg = vv(good)
81.192 +
81.193 + ccrG = esccr(ug,vg,0)
81.194 +; print (ccrG)
81.195 +
81.196 + MG = (ccrG*ccrG)* 5.0
81.197 +; new eq
81.198 + bias = sum(abs(ug-vg)/(abs(ug)+abs(vg)))
81.199 + MG = (1. - (bias/dimsizes(ug)))*5.
81.200 + print (MG)
81.201 +
81.202 +; plot correlation coef
81.203 +
81.204 + gRes = True
81.205 + gRes@txFontHeightF = 0.02
81.206 + gRes@txAngleF = 90
81.207 +
81.208 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrG)+")"
81.209 +
81.210 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
81.211 +;--------------------------------------------------------------------
81.212 +
81.213 +;(a) ob
81.214 +
81.215 + title = ob_name+" "+ model_grid
81.216 + resg@tiMainString = title
81.217 +
81.218 + plot(0) = gsn_csm_contour_map_ce(wks,dataob,resg)
81.219 +
81.220 +;(b) model
81.221 +
81.222 + title = "Model "+ model_name
81.223 + resg@tiMainString = title
81.224 +
81.225 + plot(1) = gsn_csm_contour_map_ce(wks,datamod,resg)
81.226 +
81.227 +;(c) model-ob
81.228 +
81.229 + zz = datamod
81.230 + zz = datamod - dataob
81.231 + title = "Model_"+model_name+" - Observed"
81.232 +
81.233 + resg@cnMinLevelValF = -10. ; Min level
81.234 + resg@cnMaxLevelValF = 10. ; Max level
81.235 + resg@cnLevelSpacingF = 2. ; interval
81.236 + resg@tiMainString = title
81.237 +
81.238 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
81.239 +
81.240 + pres = True ; panel plot mods desired
81.241 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
81.242 + ; indiv. plots in panel
81.243 + pres@gsnMaximize = True ; fill the page
81.244 +
81.245 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
81.246 +
81.247 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
81.248 +; system("rm "+plot_name+"."+plot_type)
81.249 +; system("rm "+plot_name+"-1."+plot_type_new)
81.250 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
81.251 +
81.252 + frame (wks)
81.253 + clear (wks)
81.254 + delete (plot)
81.255 +;------------------------------------------------------------------------
81.256 +; temp_name = "temp." + model_name
81.257 +; system("mkdir -p " + temp_name)
81.258 +; system("mv *.png " + temp_name)
81.259 +; system("tar cf "+ temp_name +".tar " + temp_name)
81.260 +;------------------------------------------------------------------------
81.261 +end
82.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
82.2 +++ b/biomass/99.all.ncl.1 Mon Jan 26 22:08:20 2009 -0500
82.3 @@ -0,0 +1,264 @@
82.4 +; ****************************************************
82.5 +; combine scatter, histogram, global and zonal plots
82.6 +; compute all correlation coef and M score
82.7 +; ****************************************************
82.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
82.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
82.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
82.11 +;************************************************
82.12 +begin
82.13 +
82.14 + plot_type = "ps"
82.15 + plot_type_new = "png"
82.16 +;************************************************
82.17 +; read in model data
82.18 +;************************************************
82.19 +;film = "b30.061n_1995-2004_ANN_climo_lnd.nc"
82.20 +;model_name = "b30.061n"
82.21 +;model_grid = "T31"
82.22 +
82.23 +;film = "newcn05_ncep_1i_ANN_climo_lnd.nc"
82.24 +;model_name = "newcn"
82.25 +;model_grid = "1.9"
82.26 +;--------------------------------------------
82.27 +;film = "i01.10cn_1948-2004_ANN_climo.nc"
82.28 +;model_name = "10cn"
82.29 +;model_grid = "T42"
82.30 +
82.31 +;dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
82.32 +;fm = addfile (dirm+film,"r")
82.33 +
82.34 +;unit: gC/m2
82.35 +;data1 = fm->LIVESTEMC
82.36 +;data2 = fm->DEADSTEMC
82.37 +;data3 = fm->LEAFC
82.38 +;datamod0 = data1(0,:,:)
82.39 +;datamod0 = data1(0,:,:) + data2(0,:,:) + data3(0,:,:)
82.40 +;-------------------------------------------
82.41 + film = "i01.10casa_1948-2004_ANN_climo.nc"
82.42 + model_name = "10casa"
82.43 + model_grid = "T42"
82.44 +
82.45 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
82.46 + fm = addfile (dirm+film,"r")
82.47 +
82.48 +;unit: gC/m2
82.49 + factor_WOODC = 0.7
82.50 + data1 = fm->WOODC
82.51 + data2 = fm->LEAFC
82.52 + datamod0 = data1(0,:,:)
82.53 + datamod0 = data1(0,:,:)*factor_WOODC + data2(0,:,:)
82.54 +;----------------------------------------------------
82.55 +
82.56 + system("sed s#model_name#"+model_name+"# table.html > table.html.new")
82.57 + system("mv -f table.html.new table.html")
82.58 +
82.59 + xm = fm->lon
82.60 + ym = fm->lat
82.61 +;************************************************
82.62 +; read in ob data
82.63 +;************************************************
82.64 + ob_name = "LC15_Amazon_Biomass"
82.65 +
82.66 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/biomass/ob/"
82.67 + filo = "amazon_biomass_"+model_grid+".nc"
82.68 + fo = addfile (diro+filo,"r")
82.69 +
82.70 + dataob = fo->BIOMASS
82.71 + xo = fo->lon
82.72 + yo = fo->lat
82.73 +;************************************************
82.74 +; Units for these variables are:
82.75 +; dataob : MgC/ha
82.76 +; datamod0 : gC/m2
82.77 +; We want to convert these to KgC/m2
82.78 +; ha = 100m*100m = 10,000 m2
82.79 +; MgC/ha*1000/10,000 = KgC/m2
82.80 +
82.81 + factor_aboveground = 0.5
82.82 + factor_unit_ob = 0.1
82.83 + factor_unit_mod = 0.001
82.84 +
82.85 + dataob = dataob * factor_aboveground * factor_unit_ob
82.86 + datamod0 = datamod0 * factor_unit_mod
82.87 +
82.88 + dataob@units = "KgC/m2"
82.89 + datamod0@units = "KgC/m2"
82.90 +
82.91 + dataob@long_name = "Amazon Biomass"
82.92 + datamod0@long_name = "Amazon Biomass"
82.93 +;********************************************************
82.94 +; get subset of datamod0 that match dataob
82.95 +
82.96 + nlon = dimsizes(xo)
82.97 + nlat = dimsizes(yo)
82.98 +
82.99 + ind_lonL = ind(xm .eq. xo(0))
82.100 + ind_lonR = ind(xm .eq. xo(nlon-1))
82.101 + ind_latS = ind(ym .eq. yo(0))
82.102 + ind_latN = ind(ym .eq. yo(nlat-1))
82.103 +
82.104 + datamod = dataob
82.105 + datamod(:,:) = datamod0(ind_latS:ind_latN,ind_lonL:ind_lonR)
82.106 +
82.107 +; print (datamod)
82.108 +
82.109 +;----------------------------------------------------------------------
82.110 +; global contour
82.111 +
82.112 +;res
82.113 + resg = True ; Use plot options
82.114 + resg@cnFillOn = True ; Turn on color fill
82.115 + resg@gsnSpreadColors = True ; use full colormap
82.116 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
82.117 +; resg@lbLabelAutoStride = True
82.118 + resg@cnLinesOn = False ; Turn off contourn lines
82.119 + resg@mpFillOn = False ; Turn off map fill
82.120 + resg@gsnAddCyclic = False
82.121 +
82.122 + resg@gsnSpreadColors = True ; use full colormap
82.123 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
82.124 + resg@cnMinLevelValF = 0. ; Min level
82.125 + resg@cnMaxLevelValF = 30. ; Max level
82.126 + resg@cnLevelSpacingF = 2. ; interval
82.127 +
82.128 + resg@mpMinLatF = -21.1 ; range to zoom in on
82.129 + resg@mpMaxLatF = 13.8
82.130 + resg@mpMinLonF = 277.28
82.131 + resg@mpMaxLonF = 326.43
82.132 +;------------------------------------------------------------------------
82.133 +;global contour ob
82.134 +
82.135 + plot_name = "global_ob"
82.136 + title = ob_name+" "+ model_grid
82.137 + resg@tiMainString = title
82.138 +
82.139 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
82.140 + gsn_define_colormap(wks,"gui_default") ; choose colormap
82.141 +
82.142 + plot = gsn_csm_contour_map_ce(wks,dataob,resg)
82.143 + frame(wks)
82.144 +
82.145 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
82.146 +; system("rm "+plot_name+"."+plot_type)
82.147 + system("rm "+plot_name+"-1."+plot_type_new)
82.148 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
82.149 +
82.150 + clear (wks)
82.151 +;------------------------------------------------------------------------
82.152 +;global contour model
82.153 +
82.154 + plot_name = "global_model"
82.155 + title = "Model "+ model_name
82.156 + resg@tiMainString = title
82.157 +
82.158 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
82.159 + gsn_define_colormap(wks,"gui_default") ; choose colormap
82.160 +
82.161 + plot = gsn_csm_contour_map_ce(wks,datamod,resg)
82.162 + frame(wks)
82.163 +
82.164 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
82.165 +; system("rm "+plot_name+"."+plot_type)
82.166 + system("rm "+plot_name+"-1."+plot_type_new)
82.167 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
82.168 +
82.169 + clear (wks)
82.170 +;------------------------------------------------------------------------
82.171 +;global contour model vs ob
82.172 +
82.173 + plot_name = "global_model_vs_ob"
82.174 +
82.175 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
82.176 + gsn_define_colormap(wks,"gui_default") ; choose colormap
82.177 +
82.178 + delete (plot)
82.179 + plot=new(3,graphic) ; create graphic array
82.180 +
82.181 + resg@gsnFrame = False ; Do not draw plot
82.182 + resg@gsnDraw = False ; Do not advance frame
82.183 +
82.184 +;(d) compute correlation coef and M score
82.185 +
82.186 + uu = ndtooned(datamod)
82.187 + vv = ndtooned(dataob)
82.188 +
82.189 + good = ind(.not.ismissing(uu) .and. .not.ismissing(vv))
82.190 +
82.191 + ug = uu(good)
82.192 + vg = vv(good)
82.193 +
82.194 + ccrG = esccr(ug,vg,0)
82.195 +; print (ccrG)
82.196 +
82.197 + MG = (ccrG*ccrG)* 5.0
82.198 +; new eq
82.199 + bias = sum(abs(ug-vg)/(abs(ug)+abs(vg)))
82.200 + MG = (1. - (bias/dimsizes(ug)))*5.
82.201 +
82.202 + M_biomass = sprintf("%.2f", MG)
82.203 + system("sed s#M_biomass#"+M_biomass+"# table.html > table.html.new")
82.204 + system("mv -f table.html.new table.html")
82.205 + print (M_biomass)
82.206 +
82.207 +; plot correlation coef
82.208 +
82.209 + gRes = True
82.210 + gRes@txFontHeightF = 0.02
82.211 + gRes@txAngleF = 90
82.212 +
82.213 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrG)+")"
82.214 +
82.215 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
82.216 +;--------------------------------------------------------------------
82.217 +
82.218 +;(a) ob
82.219 +
82.220 + title = ob_name+" "+ model_grid
82.221 + resg@tiMainString = title
82.222 +
82.223 + plot(0) = gsn_csm_contour_map_ce(wks,dataob,resg)
82.224 +
82.225 +;(b) model
82.226 +
82.227 + title = "Model "+ model_name
82.228 + resg@tiMainString = title
82.229 +
82.230 + plot(1) = gsn_csm_contour_map_ce(wks,datamod,resg)
82.231 +
82.232 +;(c) model-ob
82.233 +
82.234 + zz = datamod
82.235 + zz = datamod - dataob
82.236 + title = "Model_"+model_name+" - Observed"
82.237 +
82.238 + resg@cnMinLevelValF = -10. ; Min level
82.239 + resg@cnMaxLevelValF = 10. ; Max level
82.240 + resg@cnLevelSpacingF = 2. ; interval
82.241 + resg@tiMainString = title
82.242 +
82.243 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
82.244 +
82.245 + pres = True ; panel plot mods desired
82.246 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
82.247 + ; indiv. plots in panel
82.248 + pres@gsnMaximize = True ; fill the page
82.249 +
82.250 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
82.251 +
82.252 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
82.253 +; system("rm "+plot_name+"."+plot_type)
82.254 +; system("rm "+plot_name+"-1."+plot_type_new)
82.255 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
82.256 +
82.257 + frame (wks)
82.258 + clear (wks)
82.259 + delete (plot)
82.260 +;------------------------------------------------------------------------
82.261 + temp_name = "biomass." + model_name
82.262 + system("mkdir -p " + temp_name)
82.263 + system("cp table.html " + temp_name)
82.264 + system("mv *.png " + temp_name)
82.265 + system("tar cf "+ temp_name +".tar " + temp_name)
82.266 +;------------------------------------------------------------------------
82.267 +end
83.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
83.2 +++ b/carbon_sink/01.write_tseries_casa.ncl Mon Jan 26 22:08:20 2009 -0500
83.3 @@ -0,0 +1,122 @@
83.4 +;************************************************
83.5 +; read from /ptmp/
83.6 +; output NPP, NEE
83.7 +;************************************************
83.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
83.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
83.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
83.11 +;************************************************
83.12 +begin
83.13 +
83.14 +; input data
83.15 +
83.16 + model_name = "i01.10casa"
83.17 +
83.18 + nlat = 64
83.19 + nlon = 128
83.20 +
83.21 + year_start = 1991
83.22 + year_end = 2004
83.23 +
83.24 + diri = "/ptmp/jeff/"+model_name+"/"
83.25 +
83.26 + system("mkdir "+diri)
83.27 +
83.28 +; output
83.29 +
83.30 + diro = "/ptmp/jeff/"
83.31 + filo = model_name + "_Fire_C_"+year_start+"-"+year_end+"_monthly.nc"
83.32 + c = addfile(diro+filo,"c")
83.33 + filedimdef(c,"year",-1,True)
83.34 +
83.35 +
83.36 + nyear = year_end - year_start + 1
83.37 + nmonth = 12
83.38 +
83.39 +; data1 = new((/nyear,nmonth,nlat,nlon/),float)
83.40 + data2 = new((/nyear,nmonth,nlat,nlon/),float)
83.41 + data3 = new((/nyear,nmonth,nlat,nlon/),float)
83.42 + date = new((/nyear,nmonth/),integer)
83.43 +
83.44 +; input from /ptmp/
83.45 +
83.46 +
83.47 + do m = 0,nyear-1
83.48 + year = year_start + m
83.49 +
83.50 +; text = "mss:/FORREST/CCSM/results/"+model_name+"/lnd/hist/*"+year+"* "
83.51 +; print (text)
83.52 +
83.53 +; system("msrcp "+text+diri)
83.54 +; system("dcswait")
83.55 + print (year)
83.56 +
83.57 + do n = 0,nmonth-1
83.58 + nn = n+1
83.59 + date(m,n) = year*100 +nn
83.60 +
83.61 +; input file
83.62 + if (nn .ge. 10) then
83.63 + fili = model_name+".clm2.h0."+year+"-"+nn+".nc"
83.64 + else
83.65 + fili = model_name+".clm2.h0."+year+"-0"+nn+".nc"
83.66 + end if
83.67 +
83.68 +; print (fili)
83.69 +
83.70 + g = addfile (diri+fili,"r")
83.71 +
83.72 +; b1 = g->COL_FIRE_CLOSS
83.73 +; data1(m,n,:,:) = (/b1(0,:,:)/)
83.74 +
83.75 + b2 = g->NPP
83.76 + data2(m,n,:,:) = (/b2(0,:,:)/)
83.77 +
83.78 + b3 = g->NEE
83.79 + data3(m,n,:,:) = (/b3(0,:,:)/)
83.80 +
83.81 + end do
83.82 +
83.83 +; system("rm "+diri+"*")
83.84 +
83.85 + end do
83.86 +
83.87 +; name dimensions and assign coordinate variables
83.88 +
83.89 +; data1!0 ="year"
83.90 +; data1!1 ="month"
83.91 +; data1!2 = "lat"
83.92 +; data1!3 = "lon"
83.93 +; data1@long_name = b1@long_name
83.94 +; data1@units = b1@units
83.95 +; data1@_FillValue = b1@_FillValue
83.96 +
83.97 + data2!0 ="year"
83.98 + data2!1 ="month"
83.99 + data2!2 = "lat"
83.100 + data2!3 = "lon"
83.101 + data2@long_name = b2@long_name
83.102 + data2@units = b2@units
83.103 + data2@_FillValue = b2@_FillValue
83.104 +
83.105 + data3!0 ="year"
83.106 + data3!1 ="month"
83.107 + data3!2 = "lat"
83.108 + data3!3 = "lon"
83.109 + data3@long_name = b3@long_name
83.110 + data3@units = b3@units
83.111 + data3@_FillValue = b3@_FillValue
83.112 +
83.113 + date!0 ="year"
83.114 + date!1 ="month"
83.115 + date@long_name = "date: yyyymm"
83.116 +
83.117 +; c->COL_FIRE_CLOSS = data1
83.118 + c->NPP = data2
83.119 + c->NEE = data3
83.120 + c->date = date
83.121 + c->area = g->area
83.122 +
83.123 + print (date)
83.124 +
83.125 +end
84.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
84.2 +++ b/carbon_sink/01.write_tseries_cn.ncl Mon Jan 26 22:08:20 2009 -0500
84.3 @@ -0,0 +1,122 @@
84.4 +;************************************************
84.5 +; read from /ptmp/
84.6 +; output fire(COL_FIRE_CLOSS), NPP, NEE
84.7 +;************************************************
84.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
84.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
84.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
84.11 +;************************************************
84.12 +begin
84.13 +
84.14 +; input data
84.15 +
84.16 + model_name = "i01.10cn"
84.17 +
84.18 + nlat = 64
84.19 + nlon = 128
84.20 +
84.21 + year_start = 1991
84.22 + year_end = 2004
84.23 +
84.24 + diri = "/ptmp/jeff/"+model_name+"/"
84.25 +
84.26 + system("mkdir "+diri)
84.27 +
84.28 +; output
84.29 +
84.30 + diro = "/ptmp/jeff/"
84.31 + filo = model_name + "_Fire_C_"+year_start+"-"+year_end+"_monthly.nc"
84.32 + c = addfile(diro+filo,"c")
84.33 + filedimdef(c,"year",-1,True)
84.34 +
84.35 +
84.36 + nyear = year_end - year_start + 1
84.37 + nmonth = 12
84.38 +
84.39 + data1 = new((/nyear,nmonth,nlat,nlon/),float)
84.40 + data2 = new((/nyear,nmonth,nlat,nlon/),float)
84.41 + data3 = new((/nyear,nmonth,nlat,nlon/),float)
84.42 + date = new((/nyear,nmonth/),integer)
84.43 +
84.44 +; input from /ptmp/
84.45 +
84.46 +
84.47 + do m = 0,nyear-1
84.48 + year = year_start + m
84.49 +
84.50 +; text = "mss:/FORREST/CCSM/results/"+model_name+"/lnd/hist/*"+year+"* "
84.51 +; print (text)
84.52 +
84.53 +; system("msrcp "+text+diri)
84.54 +; system("dcswait")
84.55 + print (year)
84.56 +
84.57 + do n = 0,nmonth-1
84.58 + nn = n+1
84.59 + date(m,n) = year*100 +nn
84.60 +
84.61 +; input file
84.62 + if (nn .ge. 10) then
84.63 + fili = model_name+".clm2.h0."+year+"-"+nn+".nc"
84.64 + else
84.65 + fili = model_name+".clm2.h0."+year+"-0"+nn+".nc"
84.66 + end if
84.67 +
84.68 +; print (fili)
84.69 +
84.70 + g = addfile (diri+fili,"r")
84.71 +
84.72 + b1 = g->COL_FIRE_CLOSS
84.73 + data1(m,n,:,:) = (/b1(0,:,:)/)
84.74 +
84.75 + b2 = g->NPP
84.76 + data2(m,n,:,:) = (/b2(0,:,:)/)
84.77 +
84.78 + b3 = g->NEE
84.79 + data3(m,n,:,:) = (/b3(0,:,:)/)
84.80 +
84.81 + end do
84.82 +
84.83 +; system("rm "+diri+"*")
84.84 +
84.85 + end do
84.86 +
84.87 +; name dimensions and assign coordinate variables
84.88 +
84.89 + data1!0 ="year"
84.90 + data1!1 ="month"
84.91 + data1!2 = "lat"
84.92 + data1!3 = "lon"
84.93 + data1@long_name = b1@long_name
84.94 + data1@units = b1@units
84.95 + data1@_FillValue = b1@_FillValue
84.96 +
84.97 + data2!0 ="year"
84.98 + data2!1 ="month"
84.99 + data2!2 = "lat"
84.100 + data2!3 = "lon"
84.101 + data2@long_name = b2@long_name
84.102 + data2@units = b2@units
84.103 + data2@_FillValue = b2@_FillValue
84.104 +
84.105 + data3!0 ="year"
84.106 + data3!1 ="month"
84.107 + data3!2 = "lat"
84.108 + data3!3 = "lon"
84.109 + data3@long_name = b3@long_name
84.110 + data3@units = b3@units
84.111 + data3@_FillValue = b3@_FillValue
84.112 +
84.113 + date!0 ="year"
84.114 + date!1 ="month"
84.115 + date@long_name = "date: yyyymm"
84.116 +
84.117 + c->COL_FIRE_CLOSS = data1
84.118 + c->NPP = data2
84.119 + c->NEE = data3
84.120 + c->date = date
84.121 + c->area = g->area
84.122 +
84.123 + print (date)
84.124 +
84.125 +end
85.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
85.2 +++ b/carbon_sink/02.write_tseries_casa.ncl Mon Jan 26 22:08:20 2009 -0500
85.3 @@ -0,0 +1,121 @@
85.4 +;************************************************
85.5 +; read from mss
85.6 +; output fire(COL_FIRE_CLOSS), NPP, NEE
85.7 +;************************************************
85.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
85.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
85.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
85.11 +;************************************************
85.12 +begin
85.13 +
85.14 +; input data
85.15 +
85.16 + model_name = "i01.10casa"
85.17 +
85.18 + nlat = 64
85.19 + nlon = 128
85.20 +
85.21 + year_start = 1979
85.22 + year_end = 2004
85.23 +
85.24 + diri = "/ptmp/jeff/"+model_name+"/"
85.25 +
85.26 + system("mkdir "+diri)
85.27 +
85.28 +; output
85.29 +
85.30 + diro = "/ptmp/jeff/"
85.31 + filo = model_name + "_Fire_C_"+year_start+"-"+year_end+"_monthly.nc"
85.32 + c = addfile(diro+filo,"c")
85.33 + filedimdef(c,"year",-1,True)
85.34 +
85.35 +
85.36 + nyear = year_end - year_start + 1
85.37 + nmonth = 12
85.38 +
85.39 +; data1 = new((/nyear,nmonth,nlat,nlon/),float)
85.40 + data2 = new((/nyear,nmonth,nlat,nlon/),float)
85.41 + data3 = new((/nyear,nmonth,nlat,nlon/),float)
85.42 + date = new((/nyear,nmonth/),integer)
85.43 +
85.44 +; input from mss
85.45 +
85.46 + do m = 0,nyear-1
85.47 + year = year_start + m
85.48 +
85.49 + text = "mss:/FORREST/CCSM/results/"+model_name+"/lnd/hist/*"+year+"* "
85.50 + print (text)
85.51 +
85.52 + system("msrcp "+text+diri)
85.53 + system("dcswait")
85.54 + print (year)
85.55 +
85.56 + do n = 0,nmonth-1
85.57 + nn = n+1
85.58 + date(m,n) = year*100 +nn
85.59 +
85.60 +; input file
85.61 + if (nn .ge. 10) then
85.62 + fili = model_name+".clm2.h0."+year+"-"+nn+".nc"
85.63 + else
85.64 + fili = model_name+".clm2.h0."+year+"-0"+nn+".nc"
85.65 + end if
85.66 +
85.67 +; print (fili)
85.68 +
85.69 + g = addfile (diri+fili,"r")
85.70 +
85.71 +; b1 = g->COL_FIRE_CLOSS
85.72 +; data1(m,n,:,:) = (/b1(0,:,:)/)
85.73 +
85.74 + b2 = g->NPP
85.75 + data2(m,n,:,:) = (/b2(0,:,:)/)
85.76 +
85.77 + b3 = g->NEE
85.78 + data3(m,n,:,:) = (/b3(0,:,:)/)
85.79 +
85.80 + end do
85.81 +
85.82 +; system("rm "+diri+"*")
85.83 +
85.84 + end do
85.85 +
85.86 +; name dimensions and assign coordinate variables
85.87 +
85.88 +; data1!0 ="year"
85.89 +; data1!1 ="month"
85.90 +; data1!2 = "lat"
85.91 +; data1!3 = "lon"
85.92 +; data1@long_name = b1@long_name
85.93 +; data1@units = b1@units
85.94 +; data1@_FillValue = b1@_FillValue
85.95 +
85.96 + data2!0 ="year"
85.97 + data2!1 ="month"
85.98 + data2!2 = "lat"
85.99 + data2!3 = "lon"
85.100 + data2@long_name = b2@long_name
85.101 + data2@units = b2@units
85.102 + data2@_FillValue = b2@_FillValue
85.103 +
85.104 + data3!0 ="year"
85.105 + data3!1 ="month"
85.106 + data3!2 = "lat"
85.107 + data3!3 = "lon"
85.108 + data3@long_name = b3@long_name
85.109 + data3@units = b3@units
85.110 + data3@_FillValue = b3@_FillValue
85.111 +
85.112 + date!0 ="year"
85.113 + date!1 ="month"
85.114 + date@long_name = "date: yyyymm"
85.115 +
85.116 +; c->COL_FIRE_CLOSS = data1
85.117 + c->NPP = data2
85.118 + c->NEE = data3
85.119 + c->date = date
85.120 + c->area = g->area
85.121 +
85.122 + print (date)
85.123 +
85.124 +end
86.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
86.2 +++ b/carbon_sink/02.write_tseries_cn.ncl Mon Jan 26 22:08:20 2009 -0500
86.3 @@ -0,0 +1,122 @@
86.4 +;************************************************
86.5 +; read from mss
86.6 +; output fire(COL_FIRE_CLOSS), NPP, NEE
86.7 +;************************************************
86.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
86.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
86.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
86.11 +;************************************************
86.12 +begin
86.13 +
86.14 +; input data
86.15 +
86.16 +; model_name = "i01.10cn"
86.17 + model_name = "i01.10casa"
86.18 +
86.19 + nlat = 64
86.20 + nlon = 128
86.21 +
86.22 + year_start = 1979
86.23 + year_end = 1990
86.24 +
86.25 + diri = "/ptmp/jeff/"+model_name+"/"
86.26 +
86.27 + system("mkdir "+diri)
86.28 +
86.29 +; output
86.30 +
86.31 + diro = "/ptmp/jeff/"
86.32 + filo = model_name + "_Fire_C_"+year_start+"-"+year_end+"_monthly.nc"
86.33 + c = addfile(diro+filo,"c")
86.34 + filedimdef(c,"year",-1,True)
86.35 +
86.36 +
86.37 + nyear = year_end - year_start + 1
86.38 + nmonth = 12
86.39 +
86.40 + data1 = new((/nyear,nmonth,nlat,nlon/),float)
86.41 + data2 = new((/nyear,nmonth,nlat,nlon/),float)
86.42 + data3 = new((/nyear,nmonth,nlat,nlon/),float)
86.43 + date = new((/nyear,nmonth/),integer)
86.44 +
86.45 +; input from mss
86.46 +
86.47 + do m = 0,nyear-1
86.48 + year = year_start + m
86.49 +
86.50 + text = "mss:/FORREST/CCSM/results/"+model_name+"/lnd/hist/*"+year+"* "
86.51 + print (text)
86.52 +
86.53 + system("msrcp "+text+diri)
86.54 + system("dcswait")
86.55 + print (year)
86.56 +
86.57 + do n = 0,nmonth-1
86.58 + nn = n+1
86.59 + date(m,n) = year*100 +nn
86.60 +
86.61 +; input file
86.62 + if (nn .ge. 10) then
86.63 + fili = model_name+".clm2.h0."+year+"-"+nn+".nc"
86.64 + else
86.65 + fili = model_name+".clm2.h0."+year+"-0"+nn+".nc"
86.66 + end if
86.67 +
86.68 +; print (fili)
86.69 +
86.70 + g = addfile (diri+fili,"r")
86.71 +
86.72 + b1 = g->COL_FIRE_CLOSS
86.73 + data1(m,n,:,:) = (/b1(0,:,:)/)
86.74 +
86.75 + b2 = g->NPP
86.76 + data2(m,n,:,:) = (/b2(0,:,:)/)
86.77 +
86.78 + b3 = g->NEE
86.79 + data3(m,n,:,:) = (/b3(0,:,:)/)
86.80 +
86.81 + end do
86.82 +
86.83 +; system("rm "+diri+"*")
86.84 +
86.85 + end do
86.86 +
86.87 +; name dimensions and assign coordinate variables
86.88 +
86.89 + data1!0 ="year"
86.90 + data1!1 ="month"
86.91 + data1!2 = "lat"
86.92 + data1!3 = "lon"
86.93 + data1@long_name = b1@long_name
86.94 + data1@units = b1@units
86.95 + data1@_FillValue = b1@_FillValue
86.96 +
86.97 + data2!0 ="year"
86.98 + data2!1 ="month"
86.99 + data2!2 = "lat"
86.100 + data2!3 = "lon"
86.101 + data2@long_name = b2@long_name
86.102 + data2@units = b2@units
86.103 + data2@_FillValue = b2@_FillValue
86.104 +
86.105 + data3!0 ="year"
86.106 + data3!1 ="month"
86.107 + data3!2 = "lat"
86.108 + data3!3 = "lon"
86.109 + data3@long_name = b3@long_name
86.110 + data3@units = b3@units
86.111 + data3@_FillValue = b3@_FillValue
86.112 +
86.113 + date!0 ="year"
86.114 + date!1 ="month"
86.115 + date@long_name = "date: yyyymm"
86.116 +
86.117 + c->COL_FIRE_CLOSS = data1
86.118 + c->NPP = data2
86.119 + c->NEE = data3
86.120 + c->date = date
86.121 + c->area = g->area
86.122 +
86.123 + print (date)
86.124 +
86.125 +end
87.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
87.2 +++ b/carbon_sink/11.table1.ncl Mon Jan 26 22:08:20 2009 -0500
87.3 @@ -0,0 +1,447 @@
87.4 +;********************************************************
87.5 +;using model biome vlass
87.6 +;
87.7 +; required command line input parameters:
87.8 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
87.9 +;
87.10 +; histogram normalized by rain and compute correleration
87.11 +;**************************************************************
87.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
87.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
87.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
87.15 +;**************************************************************
87.16 +procedure set_line(lines:string,nline:integer,newlines:string)
87.17 +begin
87.18 +; add line to ascci/html file
87.19 +
87.20 + nnewlines = dimsizes(newlines)
87.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
87.22 + print("set_line: bad index, not setting anything.")
87.23 + return
87.24 + end if
87.25 + lines(nline:nline+nnewlines-1) = newlines
87.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
87.27 + nline = nline + nnewlines
87.28 + return
87.29 +end
87.30 +;**************************************************************
87.31 +; Main code.
87.32 +begin
87.33 +
87.34 + plot_type = "ps"
87.35 + plot_type_new = "png"
87.36 +
87.37 +;************************************************
87.38 +; model name and grid
87.39 +;************************************************
87.40 +
87.41 + model_grid = "T42"
87.42 +
87.43 + model_name = "cn"
87.44 + model_name1 = "i01.06cn"
87.45 + model_name2 = "i01.10cn"
87.46 +
87.47 +;---------------------------------------------------
87.48 +; get biome data: model
87.49 +
87.50 + biome_name_mod = "Model PFT Class"
87.51 +
87.52 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
87.53 + film = "class_pft_"+model_grid+".nc"
87.54 +
87.55 + fm = addfile(dirm+film,"r")
87.56 +
87.57 + classmod = fm->CLASS_PFT
87.58 +
87.59 + delete (fm)
87.60 +
87.61 +; model data has 17 land-type classes
87.62 +
87.63 + nclass_mod = 17
87.64 +
87.65 +;--------------------------------------------------
87.66 +; get model data: landfrac and area
87.67 +
87.68 + dirm_l= "/fis/cgd/cseg/people/jeff/surface_data/"
87.69 + film_l = "lnd_T42.nc"
87.70 + fm_l = addfile (dirm_l+film_l,"r")
87.71 +
87.72 + landfrac = fm_l->landfrac
87.73 + area = fm_l->area
87.74 +
87.75 +; change area from km**2 to m**2
87.76 + area = area * 1.e6
87.77 +;---------------------------------------------------
87.78 +; read data: model, group 1
87.79 +
87.80 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
87.81 + film = model_name1 + "_1980-2004_ANN_climo.nc"
87.82 + fm = addfile (dirm+film,"r")
87.83 +
87.84 + NPP1 = fm->NPP
87.85 +
87.86 + leafc = fm->LEAFC
87.87 + woodc = fm->WOODC
87.88 + frootc = fm->FROOTC
87.89 + VegC = leafc
87.90 + VegC = leafc + woodc + frootc
87.91 +
87.92 + litterc = fm->LITTERC
87.93 + cwdc = fm->CWDC
87.94 + LiCwC = litterc
87.95 + LiCwC = litterc + cwdc
87.96 +
87.97 + SoilC = fm->SOILC
87.98 +
87.99 + delete (fm)
87.100 +;---------------------------------------------------
87.101 +; read data: model, group 2
87.102 +
87.103 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
87.104 + film = model_name2 + "_1990-2004_ANN_climo.nc"
87.105 + fm = addfile (dirm+film,"r")
87.106 +
87.107 + NPP2 = fm->NPP
87.108 + NEE2 = fm->NEE
87.109 +
87.110 +;---------------------------------------------------
87.111 +; Units for these variables are:
87.112 +
87.113 +;NPP1: g C/m^2/s
87.114 +;NPP2: g C/m^2/s
87.115 +;NEE2: g C/m^2/s
87.116 +
87.117 +;VegC: g C/m^2
87.118 +;LiCwC: g C/m^2
87.119 +;SoilC: g C/m^2
87.120 +
87.121 + nsec_per_year = 60*60*24*365
87.122 +
87.123 +; change unit to g C/m^2/year
87.124 +
87.125 + NPP1 = NPP1 * nsec_per_year
87.126 + NPP2 = NPP2 * nsec_per_year
87.127 + NEE2 = NEE2 * nsec_per_year
87.128 +
87.129 +;---------------------------------------------------
87.130 +; take into account landfrac
87.131 +
87.132 + area(:,:) = area(:,:) * landfrac(:,:)
87.133 + NPP1(0,:,:) = NPP1(0,:,:) * landfrac(:,:)
87.134 + VegC(0,:,:) = VegC(0,:,:) * landfrac(:,:)
87.135 + LiCwC(0,:,:) = LiCwC(0,:,:) * landfrac(:,:)
87.136 + SoilC(0,:,:) = SoilC(0,:,:) * landfrac(:,:)
87.137 + NPP2(0,:,:) = NPP2(0,:,:) * landfrac(:,:)
87.138 + NEE2(0,:,:) = NEE2(0,:,:) * landfrac(:,:)
87.139 +
87.140 + data_n = 7
87.141 +
87.142 +;*******************************************************************
87.143 +; Calculate "nice" bins for binning the data in equally spaced ranges
87.144 +;********************************************************************
87.145 +
87.146 +; using model biome class
87.147 + nclass = nclass_mod
87.148 +
87.149 + range = fspan(0,nclass,nclass+1)
87.150 +
87.151 +; print (range)
87.152 +; Use this range information to grab all the values in a
87.153 +; particular range, and then take an average.
87.154 +
87.155 + nx = dimsizes(range) - 1
87.156 +
87.157 +;==============================
87.158 +; put data into bins
87.159 +;==============================
87.160 +
87.161 +; using observed biome class
87.162 +; base = ndtooned(classob)
87.163 +; using model biome class
87.164 + base = ndtooned(classmod)
87.165 +
87.166 +; output
87.167 +
87.168 + yvalues = new((/data_n,nx/),float)
87.169 + count = new((/data_n,nx/),float)
87.170 +
87.171 + do n = 0,data_n-1
87.172 +
87.173 + if(n.eq.0) then
87.174 + data = ndtooned(area)
87.175 + end if
87.176 +
87.177 + if(n.eq.1) then
87.178 + data = ndtooned(NPP1)
87.179 + end if
87.180 +
87.181 + if(n.eq.2) then
87.182 + data = ndtooned(VegC)
87.183 + end if
87.184 +
87.185 + if(n.eq.3) then
87.186 + data = ndtooned(LiCwC)
87.187 + end if
87.188 +
87.189 + if(n.eq.4) then
87.190 + data = ndtooned(SoilC)
87.191 + end if
87.192 +
87.193 + if(n.eq.5) then
87.194 + data = ndtooned(NPP2)
87.195 + end if
87.196 +
87.197 + if(n.eq.6) then
87.198 + data = ndtooned(NEE2)
87.199 + end if
87.200 +
87.201 +; Loop through each range, using base.
87.202 +
87.203 + do i=0,nx-1
87.204 + if (i.ne.(nx-1)) then
87.205 +; print("")
87.206 +; print("In range ["+range(i)+","+range(i+1)+")")
87.207 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
87.208 + else
87.209 +; print("")
87.210 +; print("In range ["+range(i)+",)")
87.211 + idx = ind(base.ge.range(i))
87.212 + end if
87.213 +
87.214 +; Calculate average
87.215 +
87.216 + if(.not.any(ismissing(idx))) then
87.217 + if (n.eq.0) then
87.218 + yvalues(n,i) = sum(data(idx))
87.219 + else
87.220 + yvalues(n,i) = avg(data(idx))
87.221 + end if
87.222 +
87.223 + count(n,i) = dimsizes(idx)
87.224 + else
87.225 + yvalues(n,i) = yvalues@_FillValue
87.226 + count(n,i) = 0
87.227 + end if
87.228 +
87.229 +;#############################################################
87.230 +; using model biome class:
87.231 +; set the following 4 classes to _FillValue:
87.232 +; (3)Needleleaf Deciduous Boreal Tree,
87.233 +; (8)Broadleaf Deciduous Boreal Tree,
87.234 +; (9)Broadleaf Evergreen Shrub,
87.235 +; (16)Wheat
87.236 +
87.237 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
87.238 + yvalues(n,i) = yvalues@_FillValue
87.239 + count(n,i) = 0
87.240 + end if
87.241 +;#############################################################
87.242 +
87.243 +; print(n + ": " + count + " points, avg = " + yvalues(n,i))
87.244 +
87.245 + delete(idx)
87.246 + end do
87.247 +
87.248 + delete(data)
87.249 + end do
87.250 +
87.251 + delete (base)
87.252 + delete (area)
87.253 + delete (NPP1)
87.254 + delete (VegC)
87.255 + delete (LiCwC)
87.256 + delete (SoilC)
87.257 + delete (NPP2)
87.258 + delete (NEE2)
87.259 +
87.260 +;----------------------------------------------------------------
87.261 +; data for table1
87.262 +
87.263 + good = ind(.not.ismissing(yvalues(5,:)) .and. .not.ismissing(yvalues(1,:)))
87.264 +;print (good)
87.265 +
87.266 + w = yvalues(0,:)
87.267 + area_g = w(good)
87.268 +
87.269 + w = yvalues(1,:)
87.270 + NPP1_g = w(good)
87.271 +
87.272 + w = yvalues(2,:)
87.273 + VegC_g = w(good)
87.274 +
87.275 + w = yvalues(3,:)
87.276 + LiCwC_g = w(good)
87.277 +
87.278 + w = yvalues(4,:)
87.279 + SoilC_g = w(good)
87.280 +
87.281 + w = yvalues(5,:)
87.282 + NPP2_g = w(good)
87.283 +
87.284 + w = yvalues(6,:)
87.285 + NEE2_g = w(good)
87.286 +
87.287 + n_biome = dimsizes(NPP1_g)
87.288 +
87.289 + NPP1_t = new((/n_biome/),float)
87.290 + VegC_t = new((/n_biome/),float)
87.291 + LiCwC_t = new((/n_biome/),float)
87.292 + SoilC_t = new((/n_biome/),float)
87.293 + NEE2_t = new((/n_biome/),float)
87.294 + NPP_ratio = new((/n_biome/),float)
87.295 +
87.296 + NPP_ratio = NPP2_g/NPP1_g
87.297 +
87.298 +;-----------------------------------------------------------------
87.299 +; data for table2
87.300 +
87.301 +; change unit from g to Pg (Peta gram)
87.302 + factor_unit = 1.e-15
87.303 +
87.304 + NPP1_t = NPP1_g * area_g * factor_unit
87.305 + VegC_t = VegC_g * area_g * factor_unit
87.306 + LiCwC_t = LiCwC_g * area_g * factor_unit
87.307 + SoilC_t = SoilC_g * area_g * factor_unit
87.308 + NEE2_t = NEE2_g * area_g * factor_unit
87.309 +
87.310 + print (NPP1_t)
87.311 +
87.312 +;-------------------------------------------------------------
87.313 +; html table1 data
87.314 +
87.315 +; column (not including header column)
87.316 +
87.317 + col_head = (/"Area (1.e12m2)" \
87.318 + ,"NPP (gC/m2/yr)" \
87.319 + ,"VegC (gC/m2)" \
87.320 + ,"Litter+CWD (gC/m2)" \
87.321 + ,"SoilC (gC/m2)" \
87.322 + ,"NPP ratio" \
87.323 + ,"NEE (gC/m2/yr)" \
87.324 + /)
87.325 +
87.326 + ncol = dimsizes(col_head)
87.327 +
87.328 +; row (not including header row)
87.329 +
87.330 +; using model biome class:
87.331 + row_head = (/"Not Vegetated" \
87.332 + ,"Needleleaf Evergreen Temperate Tree" \
87.333 + ,"Needleleaf Evergreen Boreal Tree" \
87.334 +; ,"Needleleaf Deciduous Boreal Tree" \
87.335 + ,"Broadleaf Evergreen Tropical Tree" \
87.336 + ,"Broadleaf Evergreen Temperate Tree" \
87.337 + ,"Broadleaf Deciduous Tropical Tree" \
87.338 + ,"Broadleaf Deciduous Temperate Tree" \
87.339 +; ,"Broadleaf Deciduous Boreal Tree" \
87.340 +; ,"Broadleaf Evergreen Shrub" \
87.341 + ,"Broadleaf Deciduous Temperate Shrub" \
87.342 + ,"Broadleaf Deciduous Boreal Shrub" \
87.343 + ,"C3 Arctic Grass" \
87.344 + ,"C3 Non-Arctic Grass" \
87.345 + ,"C4 Grass" \
87.346 + ,"Corn" \
87.347 +; ,"Wheat" \
87.348 + ,"All Biome" \
87.349 + /)
87.350 + nrow = dimsizes(row_head)
87.351 +
87.352 +; arrays to be passed to table.
87.353 + text4 = new ((/nrow, ncol/),string )
87.354 +
87.355 + do i=0,nrow-2
87.356 + text4(i,0) = sprintf("%.1f",area_g(i)*1.e-12)
87.357 + text4(i,1) = sprintf("%.1f",NPP1_g(i))
87.358 + text4(i,2) = sprintf("%.1f",VegC_g(i))
87.359 + text4(i,3) = sprintf("%.1f",LiCwC_g(i))
87.360 + text4(i,4) = sprintf("%.1f",SoilC_g(i))
87.361 + text4(i,5) = sprintf("%.1f",NPP_ratio(i))
87.362 + text4(i,6) = sprintf("%.1f",NEE2_g(i))
87.363 + end do
87.364 + text4(nrow-1,0) = "-"
87.365 + text4(nrow-1,1) = "-"
87.366 + text4(nrow-1,2) = "-"
87.367 +
87.368 +;-------------------------------------------------------
87.369 +; create html table1
87.370 +
87.371 + header_text = "<H1>NEE and Carbon Stocks and Fluxes: Model "+model_name+"</H1>"
87.372 +
87.373 + header = (/"<HTML>" \
87.374 + ,"<HEAD>" \
87.375 + ,"<TITLE>CLAMP metrics</TITLE>" \
87.376 + ,"</HEAD>" \
87.377 + ,header_text \
87.378 + /)
87.379 + footer = "</HTML>"
87.380 +
87.381 + table_header = (/ \
87.382 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
87.383 + ,"<tr>" \
87.384 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
87.385 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
87.386 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
87.387 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
87.388 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
87.389 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
87.390 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
87.391 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
87.392 + ,"</tr>" \
87.393 + /)
87.394 + table_footer = "</table>"
87.395 + row_header = "<tr>"
87.396 + row_footer = "</tr>"
87.397 +
87.398 + lines = new(50000,string)
87.399 + nline = 0
87.400 +
87.401 + set_line(lines,nline,header)
87.402 + set_line(lines,nline,table_header)
87.403 +
87.404 +;----------------------------
87.405 +;row of table
87.406 +
87.407 + do n = 0,nrow-2
87.408 + set_line(lines,nline,row_header)
87.409 +
87.410 + txt0 = row_head(n)
87.411 + txt1 = text4(n,0)
87.412 + txt2 = text4(n,1)
87.413 + txt3 = text4(n,2)
87.414 + txt4 = text4(n,3)
87.415 + txt5 = text4(n,4)
87.416 + txt6 = text4(n,5)
87.417 + txt7 = text4(n,6)
87.418 +
87.419 + set_line(lines,nline,"<th>"+txt0+"</th>")
87.420 + set_line(lines,nline,"<th>"+txt1+"</th>")
87.421 + set_line(lines,nline,"<th>"+txt2+"</th>")
87.422 + set_line(lines,nline,"<th>"+txt3+"</th>")
87.423 + set_line(lines,nline,"<th>"+txt4+"</th>")
87.424 + set_line(lines,nline,"<th>"+txt5+"</th>")
87.425 + set_line(lines,nline,"<th>"+txt6+"</th>")
87.426 + set_line(lines,nline,"<th>"+txt7+"</th>")
87.427 +
87.428 + set_line(lines,nline,row_footer)
87.429 + end do
87.430 +;----------------------------
87.431 + set_line(lines,nline,table_footer)
87.432 + set_line(lines,nline,footer)
87.433 +
87.434 +; Now write to an HTML file.
87.435 +
87.436 + output_html = "table_carbon_sink1.html"
87.437 +
87.438 + idx = ind(.not.ismissing(lines))
87.439 + if(.not.any(ismissing(idx))) then
87.440 + asciiwrite(output_html,lines(idx))
87.441 + else
87.442 + print ("error?")
87.443 + end if
87.444 +
87.445 + delete (col_head)
87.446 + delete (row_head)
87.447 + delete (text4)
87.448 +
87.449 +end
87.450 +
88.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
88.2 +++ b/carbon_sink/12.table1+2.ncl Mon Jan 26 22:08:20 2009 -0500
88.3 @@ -0,0 +1,593 @@
88.4 +;********************************************************
88.5 +;using model biome vlass
88.6 +;
88.7 +; required command line input parameters:
88.8 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
88.9 +;
88.10 +; histogram normalized by rain and compute correleration
88.11 +;**************************************************************
88.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
88.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
88.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
88.15 +;**************************************************************
88.16 +procedure set_line(lines:string,nline:integer,newlines:string)
88.17 +begin
88.18 +; add line to ascci/html file
88.19 +
88.20 + nnewlines = dimsizes(newlines)
88.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
88.22 + print("set_line: bad index, not setting anything.")
88.23 + return
88.24 + end if
88.25 + lines(nline:nline+nnewlines-1) = newlines
88.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
88.27 + nline = nline + nnewlines
88.28 + return
88.29 +end
88.30 +;**************************************************************
88.31 +; Main code.
88.32 +begin
88.33 +
88.34 + plot_type = "ps"
88.35 + plot_type_new = "png"
88.36 +
88.37 +;************************************************
88.38 +; model name and grid
88.39 +;************************************************
88.40 +
88.41 + model_grid = "T42"
88.42 +
88.43 + model_name = "cn"
88.44 + model_name1 = "i01.06cn"
88.45 + model_name2 = "i01.10cn"
88.46 +
88.47 +;---------------------------------------------------
88.48 +; get biome data: model
88.49 +
88.50 + biome_name_mod = "Model PFT Class"
88.51 +
88.52 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
88.53 + film = "class_pft_"+model_grid+".nc"
88.54 +
88.55 + fm = addfile(dirm+film,"r")
88.56 +
88.57 + classmod = fm->CLASS_PFT
88.58 +
88.59 + delete (fm)
88.60 +
88.61 +; model data has 17 land-type classes
88.62 +
88.63 + nclass_mod = 17
88.64 +
88.65 +;--------------------------------------------------
88.66 +; get model data: landfrac and area
88.67 +
88.68 + dirm_l= "/fis/cgd/cseg/people/jeff/surface_data/"
88.69 + film_l = "lnd_T42.nc"
88.70 + fm_l = addfile (dirm_l+film_l,"r")
88.71 +
88.72 + landfrac = fm_l->landfrac
88.73 + area = fm_l->area
88.74 +
88.75 +; change area from km**2 to m**2
88.76 + area = area * 1.e6
88.77 +;---------------------------------------------------
88.78 +; read data: model, group 1
88.79 +
88.80 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
88.81 + film = model_name1 + "_1980-2004_ANN_climo.nc"
88.82 + fm = addfile (dirm+film,"r")
88.83 +
88.84 + NPP1 = fm->NPP
88.85 +
88.86 + leafc = fm->LEAFC
88.87 + woodc = fm->WOODC
88.88 + frootc = fm->FROOTC
88.89 + VegC = leafc
88.90 + VegC = leafc + woodc + frootc
88.91 +
88.92 + litterc = fm->LITTERC
88.93 + cwdc = fm->CWDC
88.94 + LiCwC = litterc
88.95 + LiCwC = litterc + cwdc
88.96 +
88.97 + SoilC = fm->SOILC
88.98 +
88.99 + delete (fm)
88.100 +;---------------------------------------------------
88.101 +; read data: model, group 2
88.102 +
88.103 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
88.104 + film = model_name2 + "_1990-2004_ANN_climo.nc"
88.105 + fm = addfile (dirm+film,"r")
88.106 +
88.107 + NPP2 = fm->NPP
88.108 + NEE2 = fm->NEE
88.109 +
88.110 +;---------------------------------------------------
88.111 +; Units for these variables are:
88.112 +
88.113 +;NPP1: g C/m^2/s
88.114 +;NPP2: g C/m^2/s
88.115 +;NEE2: g C/m^2/s
88.116 +
88.117 +;VegC: g C/m^2
88.118 +;LiCwC: g C/m^2
88.119 +;SoilC: g C/m^2
88.120 +
88.121 + nsec_per_year = 60*60*24*365
88.122 +
88.123 +; change unit to g C/m^2/year
88.124 +
88.125 + NPP1 = NPP1 * nsec_per_year
88.126 + NPP2 = NPP2 * nsec_per_year
88.127 + NEE2 = NEE2 * nsec_per_year
88.128 +
88.129 +;---------------------------------------------------
88.130 +; take into account landfrac
88.131 +
88.132 + area(:,:) = area(:,:) * landfrac(:,:)
88.133 + NPP1(0,:,:) = NPP1(0,:,:) * landfrac(:,:)
88.134 + VegC(0,:,:) = VegC(0,:,:) * landfrac(:,:)
88.135 + LiCwC(0,:,:) = LiCwC(0,:,:) * landfrac(:,:)
88.136 + SoilC(0,:,:) = SoilC(0,:,:) * landfrac(:,:)
88.137 + NPP2(0,:,:) = NPP2(0,:,:) * landfrac(:,:)
88.138 + NEE2(0,:,:) = NEE2(0,:,:) * landfrac(:,:)
88.139 +
88.140 + data_n = 7
88.141 +
88.142 +;*******************************************************************
88.143 +; Calculate "nice" bins for binning the data in equally spaced ranges
88.144 +;********************************************************************
88.145 +
88.146 +; using model biome class
88.147 + nclass = nclass_mod
88.148 +
88.149 + range = fspan(0,nclass,nclass+1)
88.150 +
88.151 +; print (range)
88.152 +; Use this range information to grab all the values in a
88.153 +; particular range, and then take an average.
88.154 +
88.155 + nx = dimsizes(range) - 1
88.156 +
88.157 +;==============================
88.158 +; put data into bins
88.159 +;==============================
88.160 +
88.161 +; using observed biome class
88.162 +; base = ndtooned(classob)
88.163 +; using model biome class
88.164 + base = ndtooned(classmod)
88.165 +
88.166 +; output
88.167 +
88.168 + yvalues = new((/data_n,nx/),float)
88.169 + count = new((/data_n,nx/),float)
88.170 +
88.171 + do n = 0,data_n-1
88.172 +
88.173 + if(n.eq.0) then
88.174 + data = ndtooned(area)
88.175 + end if
88.176 +
88.177 + if(n.eq.1) then
88.178 + data = ndtooned(NPP1)
88.179 + end if
88.180 +
88.181 + if(n.eq.2) then
88.182 + data = ndtooned(VegC)
88.183 + end if
88.184 +
88.185 + if(n.eq.3) then
88.186 + data = ndtooned(LiCwC)
88.187 + end if
88.188 +
88.189 + if(n.eq.4) then
88.190 + data = ndtooned(SoilC)
88.191 + end if
88.192 +
88.193 + if(n.eq.5) then
88.194 + data = ndtooned(NPP2)
88.195 + end if
88.196 +
88.197 + if(n.eq.6) then
88.198 + data = ndtooned(NEE2)
88.199 + end if
88.200 +
88.201 +; Loop through each range, using base.
88.202 +
88.203 + do i=0,nx-1
88.204 + if (i.ne.(nx-1)) then
88.205 +; print("")
88.206 +; print("In range ["+range(i)+","+range(i+1)+")")
88.207 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
88.208 + else
88.209 +; print("")
88.210 +; print("In range ["+range(i)+",)")
88.211 + idx = ind(base.ge.range(i))
88.212 + end if
88.213 +
88.214 +; Calculate average
88.215 +
88.216 + if(.not.any(ismissing(idx))) then
88.217 + if (n.eq.0) then
88.218 + yvalues(n,i) = sum(data(idx))
88.219 + else
88.220 + yvalues(n,i) = avg(data(idx))
88.221 + end if
88.222 +
88.223 + count(n,i) = dimsizes(idx)
88.224 + else
88.225 + yvalues(n,i) = yvalues@_FillValue
88.226 + count(n,i) = 0
88.227 + end if
88.228 +
88.229 +;#############################################################
88.230 +; using model biome class:
88.231 +; set the following 4 classes to _FillValue:
88.232 +; (3)Needleleaf Deciduous Boreal Tree,
88.233 +; (8)Broadleaf Deciduous Boreal Tree,
88.234 +; (9)Broadleaf Evergreen Shrub,
88.235 +; (16)Wheat
88.236 +
88.237 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
88.238 + yvalues(n,i) = yvalues@_FillValue
88.239 + count(n,i) = 0
88.240 + end if
88.241 +;#############################################################
88.242 +
88.243 +; print(n + ": " + count + " points, avg = " + yvalues(n,i))
88.244 +
88.245 + delete(idx)
88.246 + end do
88.247 +
88.248 + delete(data)
88.249 + end do
88.250 +
88.251 + delete (base)
88.252 + delete (area)
88.253 + delete (NPP1)
88.254 + delete (VegC)
88.255 + delete (LiCwC)
88.256 + delete (SoilC)
88.257 + delete (NPP2)
88.258 + delete (NEE2)
88.259 +
88.260 +;----------------------------------------------------------------
88.261 +; data for table1
88.262 +
88.263 + good = ind(.not.ismissing(yvalues(5,:)) .and. .not.ismissing(yvalues(1,:)))
88.264 +;print (good)
88.265 +
88.266 + w = yvalues(0,:)
88.267 + area_g = w(good)
88.268 +
88.269 + w = yvalues(1,:)
88.270 + NPP1_g = w(good)
88.271 +
88.272 + w = yvalues(2,:)
88.273 + VegC_g = w(good)
88.274 +
88.275 + w = yvalues(3,:)
88.276 + LiCwC_g = w(good)
88.277 +
88.278 + w = yvalues(4,:)
88.279 + SoilC_g = w(good)
88.280 +
88.281 + w = yvalues(5,:)
88.282 + NPP2_g = w(good)
88.283 +
88.284 + w = yvalues(6,:)
88.285 + NEE2_g = w(good)
88.286 +
88.287 + n_biome = dimsizes(NPP1_g)
88.288 +
88.289 + NPP1_t = new((/n_biome/),float)
88.290 + VegC_t = new((/n_biome/),float)
88.291 + LiCwC_t = new((/n_biome/),float)
88.292 + SoilC_t = new((/n_biome/),float)
88.293 + NEE2_t = new((/n_biome/),float)
88.294 + NPP_ratio = new((/n_biome/),float)
88.295 +
88.296 + NPP_ratio = NPP2_g/NPP1_g
88.297 +
88.298 +;-----------------------------------------------------------------
88.299 +; data for table2
88.300 +
88.301 +; change unit from g to Pg (Peta gram)
88.302 + factor_unit = 1.e-15
88.303 +
88.304 + NPP1_t = NPP1_g * area_g * factor_unit
88.305 + VegC_t = VegC_g * area_g * factor_unit
88.306 + LiCwC_t = LiCwC_g * area_g * factor_unit
88.307 + SoilC_t = SoilC_g * area_g * factor_unit
88.308 + NEE2_t = NEE2_g * area_g * factor_unit
88.309 +
88.310 + print (NPP1_t)
88.311 +
88.312 +;-------------------------------------------------------------
88.313 +; html table1 data
88.314 +
88.315 +; column (not including header column)
88.316 +
88.317 + col_head = (/"Area (1.e12m2)" \
88.318 + ,"NPP (gC/m2/yr)" \
88.319 + ,"VegC (gC/m2)" \
88.320 + ,"Litter+CWD (gC/m2)" \
88.321 + ,"SoilC (gC/m2)" \
88.322 + ,"NPP_ratio" \
88.323 + ,"NEE (gC/m2/yr)" \
88.324 + /)
88.325 +
88.326 + ncol = dimsizes(col_head)
88.327 +
88.328 +; row (not including header row)
88.329 +
88.330 +; using model biome class:
88.331 + row_head = (/"Not Vegetated" \
88.332 + ,"Needleleaf Evergreen Temperate Tree" \
88.333 + ,"Needleleaf Evergreen Boreal Tree" \
88.334 +; ,"Needleleaf Deciduous Boreal Tree" \
88.335 + ,"Broadleaf Evergreen Tropical Tree" \
88.336 + ,"Broadleaf Evergreen Temperate Tree" \
88.337 + ,"Broadleaf Deciduous Tropical Tree" \
88.338 + ,"Broadleaf Deciduous Temperate Tree" \
88.339 +; ,"Broadleaf Deciduous Boreal Tree" \
88.340 +; ,"Broadleaf Evergreen Shrub" \
88.341 + ,"Broadleaf Deciduous Temperate Shrub" \
88.342 + ,"Broadleaf Deciduous Boreal Shrub" \
88.343 + ,"C3 Arctic Grass" \
88.344 + ,"C3 Non-Arctic Grass" \
88.345 + ,"C4 Grass" \
88.346 + ,"Corn" \
88.347 +; ,"Wheat" \
88.348 + ,"All Biome" \
88.349 + /)
88.350 + nrow = dimsizes(row_head)
88.351 +
88.352 +; arrays to be passed to table.
88.353 + text4 = new ((/nrow, ncol/),string )
88.354 +
88.355 + do i=0,nrow-2
88.356 + text4(i,0) = sprintf("%.1f",area_g(i)*1.e-12)
88.357 + text4(i,1) = sprintf("%.1f",NPP1_g(i))
88.358 + text4(i,2) = sprintf("%.1f",VegC_g(i))
88.359 + text4(i,3) = sprintf("%.1f",LiCwC_g(i))
88.360 + text4(i,4) = sprintf("%.1f",SoilC_g(i))
88.361 + text4(i,5) = sprintf("%.1f",NPP_ratio(i))
88.362 + text4(i,6) = sprintf("%.1f",NEE2_g(i))
88.363 + end do
88.364 + text4(nrow-1,0) = "-"
88.365 + text4(nrow-1,1) = "-"
88.366 + text4(nrow-1,2) = "-"
88.367 +
88.368 +;-------------------------------------------------------
88.369 +; create html table1
88.370 +
88.371 + header_text = "<H1>NEE and Carbon Stocks and Fluxes: Model "+model_name+"</H1>"
88.372 +
88.373 + header = (/"<HTML>" \
88.374 + ,"<HEAD>" \
88.375 + ,"<TITLE>CLAMP metrics</TITLE>" \
88.376 + ,"</HEAD>" \
88.377 + ,header_text \
88.378 + /)
88.379 + footer = "</HTML>"
88.380 +
88.381 + table_header = (/ \
88.382 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
88.383 + ,"<tr>" \
88.384 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
88.385 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
88.386 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
88.387 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
88.388 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
88.389 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
88.390 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
88.391 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
88.392 + ,"</tr>" \
88.393 + /)
88.394 + table_footer = "</table>"
88.395 + row_header = "<tr>"
88.396 + row_footer = "</tr>"
88.397 +
88.398 + lines = new(50000,string)
88.399 + nline = 0
88.400 +
88.401 + set_line(lines,nline,header)
88.402 + set_line(lines,nline,table_header)
88.403 +
88.404 +;----------------------------
88.405 +;row of table
88.406 +
88.407 + do n = 0,nrow-2
88.408 + set_line(lines,nline,row_header)
88.409 +
88.410 + txt0 = row_head(n)
88.411 + txt1 = text4(n,0)
88.412 + txt2 = text4(n,1)
88.413 + txt3 = text4(n,2)
88.414 + txt4 = text4(n,3)
88.415 + txt5 = text4(n,4)
88.416 + txt6 = text4(n,5)
88.417 + txt7 = text4(n,6)
88.418 +
88.419 + set_line(lines,nline,"<th>"+txt0+"</th>")
88.420 + set_line(lines,nline,"<th>"+txt1+"</th>")
88.421 + set_line(lines,nline,"<th>"+txt2+"</th>")
88.422 + set_line(lines,nline,"<th>"+txt3+"</th>")
88.423 + set_line(lines,nline,"<th>"+txt4+"</th>")
88.424 + set_line(lines,nline,"<th>"+txt5+"</th>")
88.425 + set_line(lines,nline,"<th>"+txt6+"</th>")
88.426 + set_line(lines,nline,"<th>"+txt7+"</th>")
88.427 +
88.428 + set_line(lines,nline,row_footer)
88.429 + end do
88.430 +;----------------------------
88.431 + set_line(lines,nline,table_footer)
88.432 + set_line(lines,nline,footer)
88.433 +
88.434 +; Now write to an HTML file.
88.435 +
88.436 + output_html = "table_carbon_sink1.html"
88.437 +
88.438 + idx = ind(.not.ismissing(lines))
88.439 + if(.not.any(ismissing(idx))) then
88.440 + asciiwrite(output_html,lines(idx))
88.441 + else
88.442 + print ("error?")
88.443 + end if
88.444 +
88.445 + delete (idx)
88.446 +
88.447 + delete (col_head)
88.448 + delete (row_head)
88.449 + delete (text4)
88.450 + delete (table_header)
88.451 +
88.452 +;-----------------------------------------------------------------
88.453 +; html table2 data
88.454 +
88.455 +; column (not including header column)
88.456 +
88.457 + col_head = (/"NPP (PgC/yr)" \
88.458 + ,"VegC (PgC)" \
88.459 + ,"Litter+CWD (PgC)" \
88.460 + ,"SoilC (PgC)" \
88.461 + ,"NEE (PgC/yr)" \
88.462 + ,"NPP timeseries" \
88.463 + ,"NEE timeseries" \
88.464 + ,"Fire timeseries" \
88.465 + /)
88.466 +
88.467 + ncol = dimsizes(col_head)
88.468 +
88.469 +; row (not including header row)
88.470 +
88.471 +; using model biome class:
88.472 + row_head = (/"Not Vegetated" \
88.473 + ,"Needleleaf Evergreen Temperate Tree" \
88.474 + ,"Needleleaf Evergreen Boreal Tree" \
88.475 +; ,"Needleleaf Deciduous Boreal Tree" \
88.476 + ,"Broadleaf Evergreen Tropical Tree" \
88.477 + ,"Broadleaf Evergreen Temperate Tree" \
88.478 + ,"Broadleaf Deciduous Tropical Tree" \
88.479 + ,"Broadleaf Deciduous Temperate Tree" \
88.480 +; ,"Broadleaf Deciduous Boreal Tree" \
88.481 +; ,"Broadleaf Evergreen Shrub" \
88.482 + ,"Broadleaf Deciduous Temperate Shrub" \
88.483 + ,"Broadleaf Deciduous Boreal Shrub" \
88.484 + ,"C3 Arctic Grass" \
88.485 + ,"C3 Non-Arctic Grass" \
88.486 + ,"C4 Grass" \
88.487 + ,"Corn" \
88.488 +; ,"Wheat" \
88.489 + ,"All Biome" \
88.490 + /)
88.491 + nrow = dimsizes(row_head)
88.492 +
88.493 +; arrays to be passed to table.
88.494 + text4 = new ((/nrow, ncol/),string )
88.495 +
88.496 + do i=0,nrow-2
88.497 + text4(i,0) = sprintf("%.1f",NPP1_t(i))
88.498 + text4(i,1) = sprintf("%.1f",VegC_t(i))
88.499 + text4(i,2) = sprintf("%.1f",LiCwC_t(i))
88.500 + text4(i,3) = sprintf("%.1f",SoilC_t(i))
88.501 + text4(i,4) = sprintf("%.1f",NEE2_t(i))
88.502 + text4(i,5) = "-"
88.503 + text4(i,6) = "-"
88.504 + text4(i,7) = "-"
88.505 + end do
88.506 + text4(nrow-1,0) = sprintf("%.1f",sum(NPP1_t))
88.507 + text4(nrow-1,1) = sprintf("%.1f",sum(VegC_t))
88.508 + text4(nrow-1,2) = sprintf("%.1f",sum(LiCwC_t))
88.509 + text4(nrow-1,3) = sprintf("%.1f",sum(SoilC_t))
88.510 + text4(nrow-1,4) = sprintf("%.1f",sum(NEE2_t))
88.511 + text4(nrow-1,5) = "-"
88.512 + text4(nrow-1,6) = "-"
88.513 + text4(nrow-1,7) = "-"
88.514 +
88.515 +;**************************************************
88.516 +; create html table1
88.517 +;**************************************************
88.518 +
88.519 + header_text = "<H1>NEE and Carbon Stocks and Fluxes (per biome): Model "+model_name+"</H1>"
88.520 +
88.521 + header = (/"<HTML>" \
88.522 + ,"<HEAD>" \
88.523 + ,"<TITLE>CLAMP metrics</TITLE>" \
88.524 + ,"</HEAD>" \
88.525 + ,header_text \
88.526 + /)
88.527 + footer = "</HTML>"
88.528 +
88.529 + table_header = (/ \
88.530 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
88.531 + ,"<tr>" \
88.532 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
88.533 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
88.534 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
88.535 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
88.536 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
88.537 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
88.538 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
88.539 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
88.540 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
88.541 + ,"</tr>" \
88.542 + /)
88.543 + table_footer = "</table>"
88.544 + row_header = "<tr>"
88.545 + row_footer = "</tr>"
88.546 +
88.547 + lines = new(50000,string)
88.548 + nline = 0
88.549 +
88.550 + set_line(lines,nline,header)
88.551 + set_line(lines,nline,table_header)
88.552 +;-----------------------------------------------
88.553 +;row of table
88.554 +
88.555 + do n = 0,nrow-1
88.556 + set_line(lines,nline,row_header)
88.557 +
88.558 + txt0 = row_head(n)
88.559 + txt1 = text4(n,0)
88.560 + txt2 = text4(n,1)
88.561 + txt3 = text4(n,2)
88.562 + txt4 = text4(n,3)
88.563 + txt5 = text4(n,4)
88.564 + txt6 = text4(n,5)
88.565 + txt7 = text4(n,6)
88.566 + txt8 = text4(n,7)
88.567 +
88.568 + set_line(lines,nline,"<th>"+txt0+"</th>")
88.569 + set_line(lines,nline,"<th>"+txt1+"</th>")
88.570 + set_line(lines,nline,"<th>"+txt2+"</th>")
88.571 + set_line(lines,nline,"<th>"+txt3+"</th>")
88.572 + set_line(lines,nline,"<th>"+txt4+"</th>")
88.573 + set_line(lines,nline,"<th>"+txt5+"</th>")
88.574 + set_line(lines,nline,"<th>"+txt6+"</th>")
88.575 + set_line(lines,nline,"<th>"+txt7+"</th>")
88.576 + set_line(lines,nline,"<th>"+txt8+"</th>")
88.577 +
88.578 + set_line(lines,nline,row_footer)
88.579 + end do
88.580 +;-----------------------------------------------
88.581 + set_line(lines,nline,table_footer)
88.582 + set_line(lines,nline,footer)
88.583 +
88.584 +; Now write to an HTML file.
88.585 +
88.586 + output_html = "table_carbon_sink2.html"
88.587 +
88.588 + idx = ind(.not.ismissing(lines))
88.589 + if(.not.any(ismissing(idx))) then
88.590 + asciiwrite(output_html,lines(idx))
88.591 + else
88.592 + print ("error?")
88.593 + end if
88.594 +
88.595 +end
88.596 +
89.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
89.2 +++ b/carbon_sink/20.table+tseries.ncl Mon Jan 26 22:08:20 2009 -0500
89.3 @@ -0,0 +1,867 @@
89.4 +;********************************************************
89.5 +;using model biome vlass
89.6 +;
89.7 +; required command line input parameters:
89.8 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
89.9 +;
89.10 +; histogram normalized by rain and compute correleration
89.11 +;**************************************************************
89.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
89.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
89.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
89.15 +;**************************************************************
89.16 +procedure set_line(lines:string,nline:integer,newlines:string)
89.17 +begin
89.18 +; add line to ascci/html file
89.19 +
89.20 + nnewlines = dimsizes(newlines)
89.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
89.22 + print("set_line: bad index, not setting anything.")
89.23 + return
89.24 + end if
89.25 + lines(nline:nline+nnewlines-1) = newlines
89.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
89.27 + nline = nline + nnewlines
89.28 + return
89.29 +end
89.30 +;**************************************************************
89.31 +; Main code.
89.32 +begin
89.33 +
89.34 + plot_type = "ps"
89.35 + plot_type_new = "png"
89.36 +
89.37 +;************************************************
89.38 +; model name and grid
89.39 +;************************************************
89.40 +
89.41 + model_grid = "T42"
89.42 +
89.43 + model_name = "cn"
89.44 + model_name1 = "i01.06cn"
89.45 + model_name2 = "i01.10cn"
89.46 +
89.47 +;---------------------------------------------------
89.48 +; get biome data: model
89.49 +
89.50 + biome_name_mod = "Model PFT Class"
89.51 +
89.52 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
89.53 + film = "class_pft_"+model_grid+".nc"
89.54 +
89.55 + fm = addfile(dirm+film,"r")
89.56 +
89.57 + classmod = fm->CLASS_PFT
89.58 +
89.59 + delete (fm)
89.60 +
89.61 +; model data has 17 land-type classes
89.62 +
89.63 + nclass_mod = 17
89.64 +
89.65 +;--------------------------------------------------
89.66 +; get model data: landfrac and area
89.67 +
89.68 + dirm_l= "/fis/cgd/cseg/people/jeff/surface_data/"
89.69 + film_l = "lnd_T42.nc"
89.70 + fm_l = addfile (dirm_l+film_l,"r")
89.71 +
89.72 + landfrac = fm_l->landfrac
89.73 + area = fm_l->area
89.74 +
89.75 +; change area from km**2 to m**2
89.76 + area = area * 1.e6
89.77 +
89.78 +;---------------------------------------------------
89.79 +; take into account landfrac
89.80 +
89.81 + area = area * landfrac
89.82 +
89.83 + delete (landfrac)
89.84 +
89.85 +;---------------------------------------------------
89.86 +; read data: model, group 1
89.87 +
89.88 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
89.89 + film = model_name1 + "_1980-2004_ANN_climo.nc"
89.90 + fm = addfile (dirm+film,"r")
89.91 +
89.92 + NPP1 = fm->NPP
89.93 +
89.94 + leafc = fm->LEAFC
89.95 + woodc = fm->WOODC
89.96 + frootc = fm->FROOTC
89.97 + VegC = leafc
89.98 + VegC = leafc + woodc + frootc
89.99 +
89.100 + litterc = fm->LITTERC
89.101 + cwdc = fm->CWDC
89.102 + LiCwC = litterc
89.103 + LiCwC = litterc + cwdc
89.104 +
89.105 + SoilC = fm->SOILC
89.106 +
89.107 + delete (fm)
89.108 +;---------------------------------------------------
89.109 +; read data: model, group 2
89.110 +
89.111 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
89.112 + film = model_name2 + "_1990-2004_ANN_climo.nc"
89.113 + fm = addfile (dirm+film,"r")
89.114 +
89.115 + NPP2 = fm->NPP
89.116 + NEE2 = fm->NEE
89.117 +
89.118 +;---------------------------------------------------
89.119 +; Units for these variables are:
89.120 +
89.121 +;NPP1: g C/m^2/s
89.122 +;NPP2: g C/m^2/s
89.123 +;NEE2: g C/m^2/s
89.124 +
89.125 +;VegC: g C/m^2
89.126 +;LiCwC: g C/m^2
89.127 +;SoilC: g C/m^2
89.128 +
89.129 + nsec_per_year = 60*60*24*365
89.130 +
89.131 +; change unit to g C/m^2/year
89.132 +
89.133 + NPP1 = NPP1 * nsec_per_year
89.134 + NPP2 = NPP2 * nsec_per_year
89.135 + NEE2 = NEE2 * nsec_per_year
89.136 +
89.137 + data_n = 7
89.138 +
89.139 +;*******************************************************************
89.140 +; Calculate "nice" bins for binning the data in equally spaced ranges
89.141 +;********************************************************************
89.142 +
89.143 +; using model biome class
89.144 + nclass = nclass_mod
89.145 +
89.146 + range = fspan(0,nclass,nclass+1)
89.147 +
89.148 +; print (range)
89.149 +; Use this range information to grab all the values in a
89.150 +; particular range, and then take an average.
89.151 +
89.152 + nx = dimsizes(range) - 1
89.153 +
89.154 +;==============================
89.155 +; put data into bins
89.156 +;==============================
89.157 +
89.158 +; using observed biome class
89.159 +; base = ndtooned(classob)
89.160 +; using model biome class
89.161 + base = ndtooned(classmod)
89.162 +
89.163 + area_1d = ndtooned(area)
89.164 +
89.165 +; output
89.166 +
89.167 + yvalues = new((/data_n,nx/),float)
89.168 + yvalues_t = new((/data_n,nx/),float)
89.169 +
89.170 +
89.171 +; Loop through each range, using base.
89.172 +
89.173 + do i=0,nx-1
89.174 +
89.175 + if (i.ne.(nx-1)) then
89.176 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
89.177 + else
89.178 + idx = ind(base.ge.range(i))
89.179 + end if
89.180 +
89.181 + do n = 0,data_n-1
89.182 +
89.183 + if (n.eq.0) then
89.184 + data = ndtooned(area)
89.185 + end if
89.186 +
89.187 + if (n.eq.1) then
89.188 + data = ndtooned(NPP1)
89.189 + end if
89.190 +
89.191 + if (n.eq.2) then
89.192 + data = ndtooned(VegC)
89.193 + end if
89.194 +
89.195 + if (n.eq.3) then
89.196 + data = ndtooned(LiCwC)
89.197 + end if
89.198 +
89.199 + if (n.eq.4) then
89.200 + data = ndtooned(SoilC)
89.201 + end if
89.202 +
89.203 + if (n.eq.5) then
89.204 + data = ndtooned(NPP2)
89.205 + end if
89.206 +
89.207 + if (n.eq.6) then
89.208 + data = ndtooned(NEE2)
89.209 + end if
89.210 +
89.211 +; Calculate sum and average
89.212 +
89.213 + if (.not.any(ismissing(idx))) then
89.214 + if (n.eq.0) then
89.215 + yvalues(n,i) = sum(data(idx))
89.216 + yvalues_t(n,i) = sum(data(idx))
89.217 + else
89.218 + yvalues(n,i) = avg(data(idx))
89.219 + yvalues_t(n,i) = sum(data(idx)*area_1d(idx))
89.220 + end if
89.221 + else
89.222 + yvalues(n,i) = yvalues@_FillValue
89.223 + yvalues_t(n,i) = yvalues@_FillValue
89.224 + end if
89.225 +
89.226 +;#############################################################
89.227 +; using model biome class:
89.228 +; set the following 4 classes to _FillValue:
89.229 +; (3)Needleleaf Deciduous Boreal Tree,
89.230 +; (8)Broadleaf Deciduous Boreal Tree,
89.231 +; (9)Broadleaf Evergreen Shrub,
89.232 +; (16)Wheat
89.233 +
89.234 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
89.235 + yvalues(n,i) = yvalues@_FillValue
89.236 + yvalues_t(n,i) = yvalues@_FillValue
89.237 + end if
89.238 +;#############################################################
89.239 +
89.240 + delete (data)
89.241 + end do
89.242 +
89.243 + delete (idx)
89.244 + end do
89.245 +
89.246 + delete (base)
89.247 + delete (area)
89.248 + delete (NPP1)
89.249 + delete (VegC)
89.250 + delete (LiCwC)
89.251 + delete (SoilC)
89.252 + delete (NPP2)
89.253 + delete (NEE2)
89.254 +
89.255 +;----------------------------------------------------------------
89.256 +; data for table1
89.257 +
89.258 + good = ind(.not.ismissing(yvalues(5,:)) .and. .not.ismissing(yvalues(1,:)))
89.259 +;print (good)
89.260 +
89.261 + area_g = yvalues(0,good)
89.262 + NPP1_g = yvalues(1,good)
89.263 + VegC_g = yvalues(2,good)
89.264 + LiCwC_g = yvalues(3,good)
89.265 + SoilC_g = yvalues(4,good)
89.266 + NPP2_g = yvalues(5,good)
89.267 + NEE2_g = yvalues(6,good)
89.268 +
89.269 + n_biome = dimsizes(NPP1_g)
89.270 +
89.271 + NPP_ratio = NPP2_g/NPP1_g
89.272 +
89.273 +;-----------------------------------------------------------------
89.274 +; data for table2
89.275 +
89.276 +; change unit from g to Pg (Peta gram)
89.277 + factor_unit = 1.e-15
89.278 +
89.279 + NPP1_t = yvalues_t(1,good) * factor_unit
89.280 + VegC_t = yvalues_t(2,good) * factor_unit
89.281 + LiCwC_t = yvalues_t(3,good) * factor_unit
89.282 + SoilC_t = yvalues_t(4,good) * factor_unit
89.283 + NEE2_t = yvalues_t(6,good) * factor_unit
89.284 +
89.285 + delete (yvalues)
89.286 + delete (yvalues_t)
89.287 +
89.288 +;-------------------------------------------------------------
89.289 +; html table1 data
89.290 +
89.291 +; column (not including header column)
89.292 +
89.293 + col_head = (/"Area (1.e12m2)" \
89.294 + ,"NPP (gC/m2/yr)" \
89.295 + ,"VegC (gC/m2)" \
89.296 + ,"Litter+CWD (gC/m2)" \
89.297 + ,"SoilC (gC/m2)" \
89.298 + ,"NPP_ratio" \
89.299 + ,"NEE (gC/m2/yr)" \
89.300 + /)
89.301 +
89.302 + ncol = dimsizes(col_head)
89.303 +
89.304 +; row (not including header row)
89.305 +
89.306 +; using model biome class:
89.307 + row_head = (/"Not Vegetated" \
89.308 + ,"Needleleaf Evergreen Temperate Tree" \
89.309 + ,"Needleleaf Evergreen Boreal Tree" \
89.310 +; ,"Needleleaf Deciduous Boreal Tree" \
89.311 + ,"Broadleaf Evergreen Tropical Tree" \
89.312 + ,"Broadleaf Evergreen Temperate Tree" \
89.313 + ,"Broadleaf Deciduous Tropical Tree" \
89.314 + ,"Broadleaf Deciduous Temperate Tree" \
89.315 +; ,"Broadleaf Deciduous Boreal Tree" \
89.316 +; ,"Broadleaf Evergreen Shrub" \
89.317 + ,"Broadleaf Deciduous Temperate Shrub" \
89.318 + ,"Broadleaf Deciduous Boreal Shrub" \
89.319 + ,"C3 Arctic Grass" \
89.320 + ,"C3 Non-Arctic Grass" \
89.321 + ,"C4 Grass" \
89.322 + ,"Corn" \
89.323 +; ,"Wheat" \
89.324 + ,"All Biome" \
89.325 + /)
89.326 + nrow = dimsizes(row_head)
89.327 +
89.328 +; arrays to be passed to table.
89.329 + text4 = new ((/nrow, ncol/),string )
89.330 +
89.331 + do i=0,nrow-2
89.332 + text4(i,0) = sprintf("%.1f",area_g(i)*1.e-12)
89.333 + text4(i,1) = sprintf("%.1f",NPP1_g(i))
89.334 + text4(i,2) = sprintf("%.1f",VegC_g(i))
89.335 + text4(i,3) = sprintf("%.1f",LiCwC_g(i))
89.336 + text4(i,4) = sprintf("%.1f",SoilC_g(i))
89.337 + text4(i,5) = sprintf("%.2f",NPP_ratio(i))
89.338 + text4(i,6) = sprintf("%.1f",NEE2_g(i))
89.339 + end do
89.340 +
89.341 +;-------------------------------------------------------
89.342 +; create html table1
89.343 +
89.344 + header_text = "<H1>NEE and Carbon Stocks and Fluxes: Model "+model_name+"</H1>"
89.345 +
89.346 + header = (/"<HTML>" \
89.347 + ,"<HEAD>" \
89.348 + ,"<TITLE>CLAMP metrics</TITLE>" \
89.349 + ,"</HEAD>" \
89.350 + ,header_text \
89.351 + /)
89.352 + footer = "</HTML>"
89.353 +
89.354 + table_header = (/ \
89.355 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
89.356 + ,"<tr>" \
89.357 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
89.358 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
89.359 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
89.360 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
89.361 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
89.362 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
89.363 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
89.364 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
89.365 + ,"</tr>" \
89.366 + /)
89.367 + table_footer = "</table>"
89.368 + row_header = "<tr>"
89.369 + row_footer = "</tr>"
89.370 +
89.371 + lines = new(50000,string)
89.372 + nline = 0
89.373 +
89.374 + set_line(lines,nline,header)
89.375 + set_line(lines,nline,table_header)
89.376 +
89.377 +;----------------------------
89.378 +;row of table
89.379 +
89.380 + do n = 0,nrow-2
89.381 + set_line(lines,nline,row_header)
89.382 +
89.383 + txt0 = row_head(n)
89.384 + txt1 = text4(n,0)
89.385 + txt2 = text4(n,1)
89.386 + txt3 = text4(n,2)
89.387 + txt4 = text4(n,3)
89.388 + txt5 = text4(n,4)
89.389 + txt6 = text4(n,5)
89.390 + txt7 = text4(n,6)
89.391 +
89.392 + set_line(lines,nline,"<th>"+txt0+"</th>")
89.393 + set_line(lines,nline,"<th>"+txt1+"</th>")
89.394 + set_line(lines,nline,"<th>"+txt2+"</th>")
89.395 + set_line(lines,nline,"<th>"+txt3+"</th>")
89.396 + set_line(lines,nline,"<th>"+txt4+"</th>")
89.397 + set_line(lines,nline,"<th>"+txt5+"</th>")
89.398 + set_line(lines,nline,"<th>"+txt6+"</th>")
89.399 + set_line(lines,nline,"<th>"+txt7+"</th>")
89.400 +
89.401 + set_line(lines,nline,row_footer)
89.402 + end do
89.403 +;----------------------------
89.404 + set_line(lines,nline,table_footer)
89.405 + set_line(lines,nline,footer)
89.406 +
89.407 +; Now write to an HTML file.
89.408 +
89.409 + output_html = "table_carbon_sink1.html"
89.410 +
89.411 + idx = ind(.not.ismissing(lines))
89.412 + if(.not.any(ismissing(idx))) then
89.413 + asciiwrite(output_html,lines(idx))
89.414 + else
89.415 + print ("error?")
89.416 + end if
89.417 +
89.418 + delete (idx)
89.419 +
89.420 + delete (col_head)
89.421 + delete (row_head)
89.422 + delete (text4)
89.423 + delete (table_header)
89.424 +
89.425 +;-----------------------------------------------------------------
89.426 +; html table2 data
89.427 +
89.428 +; column (not including header column)
89.429 +
89.430 + col_head = (/"NPP (PgC/yr)" \
89.431 + ,"VegC (PgC)" \
89.432 + ,"Litter+CWD (PgC)" \
89.433 + ,"SoilC (PgC)" \
89.434 + ,"NEE (PgC/yr)" \
89.435 + ,"NPP timeseries" \
89.436 + ,"NEE timeseries" \
89.437 + ,"Fire timeseries" \
89.438 + /)
89.439 +
89.440 + ncol = dimsizes(col_head)
89.441 +
89.442 +; row (not including header row)
89.443 +
89.444 +; using model biome class:
89.445 + row_head = (/"Not Vegetated" \
89.446 + ,"Needleleaf Evergreen Temperate Tree" \
89.447 + ,"Needleleaf Evergreen Boreal Tree" \
89.448 +; ,"Needleleaf Deciduous Boreal Tree" \
89.449 + ,"Broadleaf Evergreen Tropical Tree" \
89.450 + ,"Broadleaf Evergreen Temperate Tree" \
89.451 + ,"Broadleaf Deciduous Tropical Tree" \
89.452 + ,"Broadleaf Deciduous Temperate Tree" \
89.453 +; ,"Broadleaf Deciduous Boreal Tree" \
89.454 +; ,"Broadleaf Evergreen Shrub" \
89.455 + ,"Broadleaf Deciduous Temperate Shrub" \
89.456 + ,"Broadleaf Deciduous Boreal Shrub" \
89.457 + ,"C3 Arctic Grass" \
89.458 + ,"C3 Non-Arctic Grass" \
89.459 + ,"C4 Grass" \
89.460 + ,"Corn" \
89.461 +; ,"Wheat" \
89.462 + ,"All Biome" \
89.463 + /)
89.464 + nrow = dimsizes(row_head)
89.465 +
89.466 +; arrays to be passed to table.
89.467 + text4 = new ((/nrow, ncol/),string )
89.468 +
89.469 + do i=0,nrow-2
89.470 + text4(i,0) = sprintf("%.1f",NPP1_t(i))
89.471 + text4(i,1) = sprintf("%.1f",VegC_t(i))
89.472 + text4(i,2) = sprintf("%.1f",LiCwC_t(i))
89.473 + text4(i,3) = sprintf("%.1f",SoilC_t(i))
89.474 + text4(i,4) = sprintf("%.1f",NEE2_t(i))
89.475 + text4(i,5) = "<a href=./NPP_monthly_biome_"+i+".png>monthly_plot</a> <br> <a href=./NPP_annual_biome_"+i+".png>annual_plot</a>"
89.476 + text4(i,6) = "<a href=./NEE_monthly_biome_"+i+".png>monthly_plot</a> <br> <a href=./NEE_annual_biome_"+i+".png>annual_plot</a>"
89.477 + text4(i,7) = "<a href=./Fire_monthly_biome_"+i+".png>monthly_plot</a> <br> <a href=./Fire_annual_biome_"+i+".png>annual_plot</a>"
89.478 + end do
89.479 + text4(nrow-1,0) = sprintf("%.1f",sum(NPP1_t))
89.480 + text4(nrow-1,1) = sprintf("%.1f",sum(VegC_t))
89.481 + text4(nrow-1,2) = sprintf("%.1f",sum(LiCwC_t))
89.482 + text4(nrow-1,3) = sprintf("%.1f",sum(SoilC_t))
89.483 + text4(nrow-1,4) = sprintf("%.1f",sum(NEE2_t))
89.484 + text4(nrow-1,5) = "<a href=./NPP_monthly_global.png>monthly_plot</a> <br> <a href=./NPP_annual_global.png>annual_plot</a>"
89.485 + text4(nrow-1,6) = "<a href=./NEE_monthly_global.png>monthly_plot</a> <br> <a href=./NEE_annual_global.png>annual_plot</a>"
89.486 + text4(nrow-1,7) = "<a href=./Fire_monthly_global.png>monthly_plot</a> <br> <a href=./Fire_annual_global.png>annual_plot</a>"
89.487 +
89.488 +;**************************************************
89.489 +; create html table2
89.490 +;**************************************************
89.491 +
89.492 + header_text = "<H1>NEE and Carbon Stocks and Fluxes (per biome): Model "+model_name+"</H1>"
89.493 +
89.494 + header = (/"<HTML>" \
89.495 + ,"<HEAD>" \
89.496 + ,"<TITLE>CLAMP metrics</TITLE>" \
89.497 + ,"</HEAD>" \
89.498 + ,header_text \
89.499 + /)
89.500 + footer = "</HTML>"
89.501 +
89.502 + table_header = (/ \
89.503 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
89.504 + ,"<tr>" \
89.505 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
89.506 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
89.507 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
89.508 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
89.509 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
89.510 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
89.511 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
89.512 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
89.513 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
89.514 + ,"</tr>" \
89.515 + /)
89.516 + table_footer = "</table>"
89.517 + row_header = "<tr>"
89.518 + row_footer = "</tr>"
89.519 +
89.520 + lines = new(50000,string)
89.521 + nline = 0
89.522 +
89.523 + set_line(lines,nline,header)
89.524 + set_line(lines,nline,table_header)
89.525 +;-----------------------------------------------
89.526 +;row of table
89.527 +
89.528 + do n = 0,nrow-1
89.529 + set_line(lines,nline,row_header)
89.530 +
89.531 + txt0 = row_head(n)
89.532 + txt1 = text4(n,0)
89.533 + txt2 = text4(n,1)
89.534 + txt3 = text4(n,2)
89.535 + txt4 = text4(n,3)
89.536 + txt5 = text4(n,4)
89.537 + txt6 = text4(n,5)
89.538 + txt7 = text4(n,6)
89.539 + txt8 = text4(n,7)
89.540 +
89.541 + set_line(lines,nline,"<th>"+txt0+"</th>")
89.542 + set_line(lines,nline,"<th>"+txt1+"</th>")
89.543 + set_line(lines,nline,"<th>"+txt2+"</th>")
89.544 + set_line(lines,nline,"<th>"+txt3+"</th>")
89.545 + set_line(lines,nline,"<th>"+txt4+"</th>")
89.546 + set_line(lines,nline,"<th>"+txt5+"</th>")
89.547 + set_line(lines,nline,"<th>"+txt6+"</th>")
89.548 + set_line(lines,nline,"<th>"+txt7+"</th>")
89.549 + set_line(lines,nline,"<th>"+txt8+"</th>")
89.550 +
89.551 + set_line(lines,nline,row_footer)
89.552 + end do
89.553 +;-----------------------------------------------
89.554 + set_line(lines,nline,table_footer)
89.555 + set_line(lines,nline,footer)
89.556 +
89.557 +; Now write to an HTML file.
89.558 +
89.559 + output_html = "table_carbon_sink2.html"
89.560 +
89.561 + idx = ind(.not.ismissing(lines))
89.562 + if(.not.any(ismissing(idx))) then
89.563 + asciiwrite(output_html,lines(idx))
89.564 + else
89.565 + print ("error?")
89.566 + end if
89.567 +
89.568 + delete (idx)
89.569 +
89.570 +;---------------------------------------------------
89.571 +; read data: model, time series
89.572 +
89.573 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
89.574 + film = model_name2 + "_Fire_C_1979-2004_monthly.nc"
89.575 + fm = addfile (dirm+film,"r")
89.576 +
89.577 + NPP3 = fm->NPP
89.578 + NEE3 = fm->NEE
89.579 + Fire = fm->COL_FIRE_CLOSS
89.580 +
89.581 + delete (fm)
89.582 +
89.583 +; Units for these variables are:
89.584 +
89.585 +;NPP3: g C/m^2/s
89.586 +;NEE3: g C/m^2/s
89.587 +;Fire: g C/m^2/s
89.588 +
89.589 + nsec_per_month = 60*60*24*30
89.590 +
89.591 +; change unit to g C/m^2/month
89.592 +
89.593 + NPP3 = NPP3 * nsec_per_month
89.594 + NEE3 = NEE3 * nsec_per_month
89.595 + Fire = Fire * nsec_per_month
89.596 +
89.597 + data_n = 3
89.598 +
89.599 + dsizes = dimsizes(NPP3)
89.600 + nyear = dsizes(0)
89.601 + nmonth = dsizes(1)
89.602 + ntime = nyear * nmonth
89.603 +
89.604 + year_start = 1979
89.605 + year_end = 2004
89.606 +
89.607 +;*******************************************************************
89.608 +; Calculate "nice" bins for binning the data in equally spaced ranges
89.609 +;********************************************************************
89.610 +
89.611 +; using model biome class
89.612 + nclass = nclass_mod
89.613 +
89.614 + range = fspan(0,nclass,nclass+1)
89.615 +
89.616 +; print (range)
89.617 +; Use this range information to grab all the values in a
89.618 +; particular range, and then take an average.
89.619 +
89.620 + nx = dimsizes(range) - 1
89.621 +
89.622 +;==============================
89.623 +; put data into bins
89.624 +;==============================
89.625 +
89.626 +; using observed biome class
89.627 +; base = ndtooned(classob)
89.628 +; using model biome class
89.629 + base = ndtooned(classmod)
89.630 +
89.631 +; output
89.632 +
89.633 + yvalues = new((/ntime,data_n,nx/),float)
89.634 +
89.635 +; Loop through each range, using base.
89.636 +
89.637 + do i=0,nx-1
89.638 +
89.639 + if (i.ne.(nx-1)) then
89.640 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
89.641 + else
89.642 + idx = ind(base.ge.range(i))
89.643 + end if
89.644 +
89.645 + do n = 0,data_n-1
89.646 +
89.647 + t = -1
89.648 + do m = 0,nyear-1
89.649 + do k = 0,nmonth-1
89.650 +
89.651 + t = t + 1
89.652 +
89.653 + if (n.eq.0) then
89.654 + data = ndtooned(NPP3(m,k,:,:))
89.655 + end if
89.656 +
89.657 + if (n.eq.1) then
89.658 + data = ndtooned(NEE3(m,k,:,:))
89.659 + end if
89.660 +
89.661 + if (n.eq.2) then
89.662 + data = ndtooned(Fire(m,k,:,:))
89.663 + end if
89.664 +
89.665 +; Calculate average
89.666 +
89.667 + if (.not.any(ismissing(idx))) then
89.668 + yvalues(t,n,i) = sum(data(idx)*area_1d(idx))
89.669 + else
89.670 + yvalues(t,n,i) = yvalues@_FillValue
89.671 + end if
89.672 +
89.673 +;#############################################################
89.674 +; using model biome class:
89.675 +; set the following 4 classes to _FillValue:
89.676 +; (3)Needleleaf Deciduous Boreal Tree,
89.677 +; (8)Broadleaf Deciduous Boreal Tree,
89.678 +; (9)Broadleaf Evergreen Shrub,
89.679 +; (16)Wheat
89.680 +
89.681 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
89.682 + yvalues(t,n,i) = yvalues@_FillValue
89.683 + end if
89.684 +;#############################################################
89.685 +
89.686 + end do
89.687 + end do
89.688 +
89.689 + delete(data)
89.690 + end do
89.691 +
89.692 + delete(idx)
89.693 + end do
89.694 +
89.695 + delete (base)
89.696 + delete (NPP3)
89.697 + delete (NEE3)
89.698 + delete (Fire)
89.699 +
89.700 +;----------------------------------------------------------------
89.701 +; data for tseries plot
89.702 +
89.703 + yvalues_g = new((/ntime,data_n,n_biome/),float)
89.704 +
89.705 + yvalues_g@units = "TgC/month"
89.706 +
89.707 +; change unit to Tg C/month
89.708 +; change unit from g to Tg (Tera gram)
89.709 + factor_unit = 1.e-12
89.710 +
89.711 + yvalues_g = yvalues(:,:,good) * factor_unit
89.712 +
89.713 +;*******************************************************************
89.714 +; general settings for line plot
89.715 +;*******************************************************************
89.716 +
89.717 +; res
89.718 + res = True
89.719 + res@xyDashPatterns = (/0/) ; make lines solid
89.720 + res@xyLineThicknesses = (/2.0/) ; make lines thicker
89.721 + res@xyLineColors = (/"blue"/) ; line color
89.722 +
89.723 + res@trXMinF = year_start
89.724 + res@trXMaxF = year_end + 1
89.725 +
89.726 + res@vpHeightF = 0.4 ; change aspect ratio of plot
89.727 +; res@vpWidthF = 0.8
89.728 + res@vpWidthF = 0.75
89.729 +
89.730 +; res@gsnMaximize = True
89.731 +
89.732 +;*******************************************************************
89.733 +; (A) 1 component in each biome: monthly
89.734 +;*******************************************************************
89.735 +
89.736 + component = (/"NPP","NEE","Fire"/)
89.737 +
89.738 +; for x-axis in xyplot
89.739 +
89.740 + timeI = new((/ntime/),integer)
89.741 + timeF = new((/ntime/),float)
89.742 + timeI = ispan(1,ntime,1)
89.743 + timeF = year_start + (timeI-1)/12.
89.744 + timeF@long_name = "year"
89.745 +
89.746 + plot_data = new((/ntime/),float)
89.747 + plot_data@long_name = "TgC/month"
89.748 +
89.749 + do n = 0, data_n-1
89.750 + do m = 0, n_biome-1
89.751 +
89.752 + plot_name = component(n)+"_monthly_biome_"+ m
89.753 +
89.754 + wks = gsn_open_wks (plot_type,plot_name)
89.755 +
89.756 + title = component(n)+ ": "+ row_head(m)
89.757 + res@tiMainString = title
89.758 + res@tiMainFontHeightF = 0.025
89.759 +
89.760 + plot_data(:) = yvalues_g(:,n,m)
89.761 +
89.762 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
89.763 +
89.764 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
89.765 + "rm "+plot_name+"."+plot_type)
89.766 +
89.767 + clear (wks)
89.768 + delete (plot)
89.769 + end do
89.770 + end do
89.771 +
89.772 + do n = 0, data_n-1
89.773 +
89.774 + plot_name = component(n)+"_monthly_global"
89.775 +
89.776 + wks = gsn_open_wks (plot_type,plot_name)
89.777 +
89.778 + title = component(n)+ ": Global"
89.779 + res@tiMainString = title
89.780 + res@tiMainFontHeightF = 0.025
89.781 +
89.782 + do k = 0,ntime-1
89.783 + plot_data(k) = sum(yvalues_g(k,n,:))
89.784 + end do
89.785 +
89.786 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
89.787 +
89.788 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
89.789 + "rm "+plot_name+"."+plot_type)
89.790 +
89.791 + clear (wks)
89.792 + delete (plot)
89.793 + end do
89.794 +
89.795 + delete (plot_data)
89.796 + delete (timeI)
89.797 + delete (timeF)
89.798 +
89.799 +;*******************************************************************
89.800 +; (B) 1 component in each biome: annually
89.801 +;*******************************************************************
89.802 +
89.803 + yvalues_a = new((/nyear,data_n,n_biome/),float)
89.804 + yvalues_g!0 = "time"
89.805 + yvalues_g!1 = "case"
89.806 + yvalues_g!2 = "record"
89.807 +
89.808 + yvalues_a = month_to_annual(yvalues_g,0)
89.809 +
89.810 + delete (yvalues_g)
89.811 +
89.812 +; for x-axis in xyplot
89.813 +
89.814 + timeI = new((/nyear/),integer)
89.815 + timeF = new((/nyear/),float)
89.816 + timeI = ispan(1,nyear,1)
89.817 + timeF = year_start + (timeI-1)
89.818 + timeF@long_name = "year"
89.819 +
89.820 + plot_data = new((/nyear/),float)
89.821 + plot_data@long_name = "TgC/year"
89.822 +
89.823 + do n = 0, data_n-1
89.824 + do m = 0, n_biome-1
89.825 +
89.826 + plot_name = component(n)+"_annual_biome_"+ m
89.827 +
89.828 + wks = gsn_open_wks (plot_type,plot_name)
89.829 +
89.830 + title = component(n)+ ": "+ row_head(m)
89.831 + res@tiMainString = title
89.832 + res@tiMainFontHeightF = 0.025
89.833 +
89.834 + plot_data(:) = yvalues_a(:,n,m)
89.835 +
89.836 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
89.837 +
89.838 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
89.839 + "rm "+plot_name+"."+plot_type)
89.840 +
89.841 + clear (wks)
89.842 + delete (plot)
89.843 + end do
89.844 + end do
89.845 +
89.846 + do n = 0, data_n-1
89.847 +
89.848 + plot_name = component(n)+"_annual_global"
89.849 +
89.850 + wks = gsn_open_wks (plot_type,plot_name)
89.851 +
89.852 + title = component(n)+ ": Global"
89.853 + res@tiMainString = title
89.854 + res@tiMainFontHeightF = 0.025
89.855 +
89.856 + do k = 0,nyear-1
89.857 + plot_data(k) = sum(yvalues_a(k,n,:))
89.858 + end do
89.859 +
89.860 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
89.861 +
89.862 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
89.863 + "rm "+plot_name+"."+plot_type)
89.864 +
89.865 + clear (wks)
89.866 + delete (plot)
89.867 + end do
89.868 +
89.869 +end
89.870 +
90.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
90.2 +++ b/carbon_sink/20x.table+tseries.ncl Mon Jan 26 22:08:20 2009 -0500
90.3 @@ -0,0 +1,869 @@
90.4 +;********************************************************
90.5 +; for casa (no fire)
90.6 +; using model biome vlass
90.7 +;
90.8 +; required command line input parameters:
90.9 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
90.10 +;
90.11 +; histogram normalized by rain and compute correleration
90.12 +;**************************************************************
90.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
90.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
90.15 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
90.16 +;**************************************************************
90.17 +procedure set_line(lines:string,nline:integer,newlines:string)
90.18 +begin
90.19 +; add line to ascci/html file
90.20 +
90.21 + nnewlines = dimsizes(newlines)
90.22 + if(nline+nnewlines-1.ge.dimsizes(lines))
90.23 + print("set_line: bad index, not setting anything.")
90.24 + return
90.25 + end if
90.26 + lines(nline:nline+nnewlines-1) = newlines
90.27 +; print ("lines = " + lines(nline:nline+nnewlines-1))
90.28 + nline = nline + nnewlines
90.29 + return
90.30 +end
90.31 +;**************************************************************
90.32 +; Main code.
90.33 +begin
90.34 +
90.35 + plot_type = "ps"
90.36 + plot_type_new = "png"
90.37 +
90.38 +;************************************************
90.39 +; model name and grid
90.40 +;************************************************
90.41 +
90.42 + model_grid = "T42"
90.43 +
90.44 + model_name = "casa"
90.45 + model_name1 = "i01.06casa"
90.46 + model_name2 = "i01.10casa"
90.47 +
90.48 +;---------------------------------------------------
90.49 +; get biome data: model
90.50 +
90.51 + biome_name_mod = "Model PFT Class"
90.52 +
90.53 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
90.54 + film = "class_pft_"+model_grid+".nc"
90.55 +
90.56 + fm = addfile(dirm+film,"r")
90.57 +
90.58 + classmod = fm->CLASS_PFT
90.59 +
90.60 + delete (fm)
90.61 +
90.62 +; model data has 17 land-type classes
90.63 +
90.64 + nclass_mod = 17
90.65 +
90.66 +;--------------------------------------------------
90.67 +; get model data: landfrac and area
90.68 +
90.69 + dirm_l= "/fis/cgd/cseg/people/jeff/surface_data/"
90.70 + film_l = "lnd_T42.nc"
90.71 + fm_l = addfile (dirm_l+film_l,"r")
90.72 +
90.73 + landfrac = fm_l->landfrac
90.74 + area = fm_l->area
90.75 +
90.76 +; change area from km**2 to m**2
90.77 + area = area * 1.e6
90.78 +
90.79 +;---------------------------------------------------
90.80 +; take into account landfrac
90.81 +
90.82 + area = area * landfrac
90.83 +
90.84 + delete (landfrac)
90.85 +
90.86 +;---------------------------------------------------
90.87 +; read data: model, group 1
90.88 +
90.89 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
90.90 + film = model_name1 + "_1980-2004_ANN_climo.nc"
90.91 + fm = addfile (dirm+film,"r")
90.92 +
90.93 + NPP1 = fm->NPP
90.94 +
90.95 + leafc = fm->LEAFC
90.96 + woodc = fm->WOODC
90.97 + frootc = fm->FROOTC
90.98 + VegC = leafc
90.99 + VegC = leafc + woodc + frootc
90.100 +
90.101 + litterc = fm->LITTERC
90.102 + cwdc = fm->CWDC
90.103 + LiCwC = litterc
90.104 + LiCwC = litterc + cwdc
90.105 +
90.106 + SoilC = fm->SOILC
90.107 +
90.108 + delete (fm)
90.109 +;---------------------------------------------------
90.110 +; read data: model, group 2
90.111 +
90.112 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
90.113 + film = model_name2 + "_1990-2004_ANN_climo.nc"
90.114 + fm = addfile (dirm+film,"r")
90.115 +
90.116 + NPP2 = fm->NPP
90.117 + NEE2 = fm->NEE
90.118 +
90.119 +;---------------------------------------------------
90.120 +; Units for these variables are:
90.121 +
90.122 +;NPP1: g C/m^2/s
90.123 +;NPP2: g C/m^2/s
90.124 +;NEE2: g C/m^2/s
90.125 +
90.126 +;VegC: g C/m^2
90.127 +;LiCwC: g C/m^2
90.128 +;SoilC: g C/m^2
90.129 +
90.130 + nsec_per_year = 60*60*24*365
90.131 +
90.132 +; change unit to g C/m^2/year
90.133 +
90.134 + NPP1 = NPP1 * nsec_per_year
90.135 + NPP2 = NPP2 * nsec_per_year
90.136 + NEE2 = NEE2 * nsec_per_year
90.137 +
90.138 + data_n = 7
90.139 +
90.140 +;*******************************************************************
90.141 +; Calculate "nice" bins for binning the data in equally spaced ranges
90.142 +;********************************************************************
90.143 +
90.144 +; using model biome class
90.145 + nclass = nclass_mod
90.146 +
90.147 + range = fspan(0,nclass,nclass+1)
90.148 +
90.149 +; print (range)
90.150 +; Use this range information to grab all the values in a
90.151 +; particular range, and then take an average.
90.152 +
90.153 + nx = dimsizes(range) - 1
90.154 +
90.155 +;==============================
90.156 +; put data into bins
90.157 +;==============================
90.158 +
90.159 +; using observed biome class
90.160 +; base = ndtooned(classob)
90.161 +; using model biome class
90.162 + base = ndtooned(classmod)
90.163 +
90.164 + area_1d = ndtooned(area)
90.165 +
90.166 +; output
90.167 +
90.168 + yvalues = new((/data_n,nx/),float)
90.169 + yvalues_t = new((/data_n,nx/),float)
90.170 +
90.171 +; Loop through each range, using base.
90.172 +
90.173 + do i=0,nx-1
90.174 +
90.175 + if (i.ne.(nx-1)) then
90.176 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
90.177 + else
90.178 + idx = ind(base.ge.range(i))
90.179 + end if
90.180 +
90.181 + do n = 0,data_n-1
90.182 +
90.183 + if (n.eq.0) then
90.184 + data = ndtooned(area)
90.185 + end if
90.186 +
90.187 + if (n.eq.1) then
90.188 + data = ndtooned(NPP1)
90.189 + end if
90.190 +
90.191 + if (n.eq.2) then
90.192 + data = ndtooned(VegC)
90.193 + end if
90.194 +
90.195 + if (n.eq.3) then
90.196 + data = ndtooned(LiCwC)
90.197 + end if
90.198 +
90.199 + if (n.eq.4) then
90.200 + data = ndtooned(SoilC)
90.201 + end if
90.202 +
90.203 + if (n.eq.5) then
90.204 + data = ndtooned(NPP2)
90.205 + end if
90.206 +
90.207 + if (n.eq.6) then
90.208 + data = ndtooned(NEE2)
90.209 + end if
90.210 +
90.211 +; Calculate sum and average
90.212 +
90.213 + if (.not.any(ismissing(idx))) then
90.214 + if (n.eq.0) then
90.215 + yvalues(n,i) = sum(data(idx))
90.216 + yvalues_t(n,i) = sum(data(idx))
90.217 + else
90.218 + yvalues(n,i) = avg(data(idx))
90.219 + yvalues_t(n,i) = sum(data(idx)*area_1d(idx))
90.220 + end if
90.221 + else
90.222 + yvalues(n,i) = yvalues@_FillValue
90.223 + yvalues_t(n,i) = yvalues@_FillValue
90.224 + end if
90.225 +
90.226 +;#############################################################
90.227 +; using model biome class:
90.228 +; set the following 4 classes to _FillValue:
90.229 +; (3)Needleleaf Deciduous Boreal Tree,
90.230 +; (8)Broadleaf Deciduous Boreal Tree,
90.231 +; (9)Broadleaf Evergreen Shrub,
90.232 +; (16)Wheat
90.233 +
90.234 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
90.235 + yvalues(n,i) = yvalues@_FillValue
90.236 + yvalues_t(n,i) = yvalues@_FillValue
90.237 + end if
90.238 +;#############################################################
90.239 +
90.240 + delete (data)
90.241 + end do
90.242 +
90.243 + delete (idx)
90.244 + end do
90.245 +
90.246 + delete (base)
90.247 + delete (area)
90.248 + delete (NPP1)
90.249 + delete (VegC)
90.250 + delete (LiCwC)
90.251 + delete (SoilC)
90.252 + delete (NPP2)
90.253 + delete (NEE2)
90.254 +
90.255 +;----------------------------------------------------------------
90.256 +; data for table1
90.257 +
90.258 + good = ind(.not.ismissing(yvalues(5,:)) .and. .not.ismissing(yvalues(1,:)))
90.259 +;print (good)
90.260 +
90.261 + area_g = yvalues(0,good)
90.262 + NPP1_g = yvalues(1,good)
90.263 + VegC_g = yvalues(2,good)
90.264 + LiCwC_g = yvalues(3,good)
90.265 + SoilC_g = yvalues(4,good)
90.266 + NPP2_g = yvalues(5,good)
90.267 + NEE2_g = yvalues(6,good)
90.268 +
90.269 + n_biome = dimsizes(NPP1_g)
90.270 +
90.271 + NPP_ratio = NPP2_g/NPP1_g
90.272 +
90.273 +;-----------------------------------------------------------------
90.274 +; data for table2
90.275 +
90.276 +; change unit from g to Pg (Peta gram)
90.277 + factor_unit = 1.e-15
90.278 +
90.279 + NPP1_t = yvalues_t(1,good) * factor_unit
90.280 + VegC_t = yvalues_t(2,good) * factor_unit
90.281 + LiCwC_t = yvalues_t(3,good) * factor_unit
90.282 + SoilC_t = yvalues_t(4,good) * factor_unit
90.283 + NEE2_t = yvalues_t(6,good) * factor_unit
90.284 +
90.285 + delete (yvalues)
90.286 + delete (yvalues_t)
90.287 +
90.288 +;-------------------------------------------------------------
90.289 +; html table1 data
90.290 +
90.291 +; column (not including header column)
90.292 +
90.293 + col_head = (/"Area (1.e12m2)" \
90.294 + ,"NPP (gC/m2/yr)" \
90.295 + ,"VegC (gC/m2)" \
90.296 + ,"Litter+CWD (gC/m2)" \
90.297 + ,"SoilC (gC/m2)" \
90.298 + ,"NPP_ratio" \
90.299 + ,"NEE (gC/m2/yr)" \
90.300 + /)
90.301 +
90.302 + ncol = dimsizes(col_head)
90.303 +
90.304 +; row (not including header row)
90.305 +
90.306 +; using model biome class:
90.307 + row_head = (/"Not Vegetated" \
90.308 + ,"Needleleaf Evergreen Temperate Tree" \
90.309 + ,"Needleleaf Evergreen Boreal Tree" \
90.310 +; ,"Needleleaf Deciduous Boreal Tree" \
90.311 + ,"Broadleaf Evergreen Tropical Tree" \
90.312 + ,"Broadleaf Evergreen Temperate Tree" \
90.313 + ,"Broadleaf Deciduous Tropical Tree" \
90.314 + ,"Broadleaf Deciduous Temperate Tree" \
90.315 +; ,"Broadleaf Deciduous Boreal Tree" \
90.316 +; ,"Broadleaf Evergreen Shrub" \
90.317 + ,"Broadleaf Deciduous Temperate Shrub" \
90.318 + ,"Broadleaf Deciduous Boreal Shrub" \
90.319 + ,"C3 Arctic Grass" \
90.320 + ,"C3 Non-Arctic Grass" \
90.321 + ,"C4 Grass" \
90.322 + ,"Corn" \
90.323 +; ,"Wheat" \
90.324 + ,"All Biome" \
90.325 + /)
90.326 + nrow = dimsizes(row_head)
90.327 +
90.328 +; arrays to be passed to table.
90.329 + text4 = new ((/nrow, ncol/),string )
90.330 +
90.331 + do i=0,nrow-2
90.332 + text4(i,0) = sprintf("%.1f",area_g(i)*1.e-12)
90.333 + text4(i,1) = sprintf("%.1f",NPP1_g(i))
90.334 + text4(i,2) = sprintf("%.1f",VegC_g(i))
90.335 + text4(i,3) = sprintf("%.1f",LiCwC_g(i))
90.336 + text4(i,4) = sprintf("%.1f",SoilC_g(i))
90.337 + text4(i,5) = sprintf("%.2f",NPP_ratio(i))
90.338 + text4(i,6) = sprintf("%.1f",NEE2_g(i))
90.339 + end do
90.340 +
90.341 +;-------------------------------------------------------
90.342 +; create html table1
90.343 +
90.344 + header_text = "<H1>NEE and Carbon Stocks and Fluxes: Model "+model_name+"</H1>"
90.345 +
90.346 + header = (/"<HTML>" \
90.347 + ,"<HEAD>" \
90.348 + ,"<TITLE>CLAMP metrics</TITLE>" \
90.349 + ,"</HEAD>" \
90.350 + ,header_text \
90.351 + /)
90.352 + footer = "</HTML>"
90.353 +
90.354 + table_header = (/ \
90.355 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
90.356 + ,"<tr>" \
90.357 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
90.358 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
90.359 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
90.360 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
90.361 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
90.362 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
90.363 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
90.364 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
90.365 + ,"</tr>" \
90.366 + /)
90.367 + table_footer = "</table>"
90.368 + row_header = "<tr>"
90.369 + row_footer = "</tr>"
90.370 +
90.371 + lines = new(50000,string)
90.372 + nline = 0
90.373 +
90.374 + set_line(lines,nline,header)
90.375 + set_line(lines,nline,table_header)
90.376 +
90.377 +;----------------------------
90.378 +;row of table
90.379 +
90.380 + do n = 0,nrow-2
90.381 + set_line(lines,nline,row_header)
90.382 +
90.383 + txt0 = row_head(n)
90.384 + txt1 = text4(n,0)
90.385 + txt2 = text4(n,1)
90.386 + txt3 = text4(n,2)
90.387 + txt4 = text4(n,3)
90.388 + txt5 = text4(n,4)
90.389 + txt6 = text4(n,5)
90.390 + txt7 = text4(n,6)
90.391 +
90.392 + set_line(lines,nline,"<th>"+txt0+"</th>")
90.393 + set_line(lines,nline,"<th>"+txt1+"</th>")
90.394 + set_line(lines,nline,"<th>"+txt2+"</th>")
90.395 + set_line(lines,nline,"<th>"+txt3+"</th>")
90.396 + set_line(lines,nline,"<th>"+txt4+"</th>")
90.397 + set_line(lines,nline,"<th>"+txt5+"</th>")
90.398 + set_line(lines,nline,"<th>"+txt6+"</th>")
90.399 + set_line(lines,nline,"<th>"+txt7+"</th>")
90.400 +
90.401 + set_line(lines,nline,row_footer)
90.402 + end do
90.403 +;----------------------------
90.404 + set_line(lines,nline,table_footer)
90.405 + set_line(lines,nline,footer)
90.406 +
90.407 +; Now write to an HTML file.
90.408 +
90.409 + output_html = "table_carbon_sink1.html"
90.410 +
90.411 + idx = ind(.not.ismissing(lines))
90.412 + if(.not.any(ismissing(idx))) then
90.413 + asciiwrite(output_html,lines(idx))
90.414 + else
90.415 + print ("error?")
90.416 + end if
90.417 +
90.418 + delete (idx)
90.419 +
90.420 + delete (col_head)
90.421 + delete (row_head)
90.422 + delete (text4)
90.423 + delete (table_header)
90.424 +
90.425 +;-----------------------------------------------------------------
90.426 +; html table2 data
90.427 +
90.428 +; column (not including header column)
90.429 +
90.430 + col_head = (/"NPP (PgC/yr)" \
90.431 + ,"VegC (PgC)" \
90.432 + ,"Litter+CWD (PgC)" \
90.433 + ,"SoilC (PgC)" \
90.434 + ,"NEE (PgC/yr)" \
90.435 + ,"NPP timeseries" \
90.436 + ,"NEE timeseries" \
90.437 + ,"Fire timeseries" \
90.438 + /)
90.439 +
90.440 + ncol = dimsizes(col_head)
90.441 +
90.442 +; row (not including header row)
90.443 +
90.444 +; using model biome class:
90.445 + row_head = (/"Not Vegetated" \
90.446 + ,"Needleleaf Evergreen Temperate Tree" \
90.447 + ,"Needleleaf Evergreen Boreal Tree" \
90.448 +; ,"Needleleaf Deciduous Boreal Tree" \
90.449 + ,"Broadleaf Evergreen Tropical Tree" \
90.450 + ,"Broadleaf Evergreen Temperate Tree" \
90.451 + ,"Broadleaf Deciduous Tropical Tree" \
90.452 + ,"Broadleaf Deciduous Temperate Tree" \
90.453 +; ,"Broadleaf Deciduous Boreal Tree" \
90.454 +; ,"Broadleaf Evergreen Shrub" \
90.455 + ,"Broadleaf Deciduous Temperate Shrub" \
90.456 + ,"Broadleaf Deciduous Boreal Shrub" \
90.457 + ,"C3 Arctic Grass" \
90.458 + ,"C3 Non-Arctic Grass" \
90.459 + ,"C4 Grass" \
90.460 + ,"Corn" \
90.461 +; ,"Wheat" \
90.462 + ,"All Biome" \
90.463 + /)
90.464 + nrow = dimsizes(row_head)
90.465 +
90.466 +; arrays to be passed to table.
90.467 + text4 = new ((/nrow, ncol/),string )
90.468 +
90.469 + do i=0,nrow-2
90.470 + text4(i,0) = sprintf("%.1f",NPP1_t(i))
90.471 + text4(i,1) = sprintf("%.1f",VegC_t(i))
90.472 + text4(i,2) = sprintf("%.1f",LiCwC_t(i))
90.473 + text4(i,3) = sprintf("%.1f",SoilC_t(i))
90.474 + text4(i,4) = sprintf("%.1f",NEE2_t(i))
90.475 + text4(i,5) = "<a href=./NPP_monthly_biome_"+i+".png>monthly_plot</a> <br> <a href=./NPP_annual_biome_"+i+".png>annual_plot</a>"
90.476 + text4(i,6) = "<a href=./NEE_monthly_biome_"+i+".png>monthly_plot</a> <br> <a href=./NEE_annual_biome_"+i+".png>annual_plot</a>"
90.477 + text4(i,7) = "--"
90.478 + end do
90.479 + text4(nrow-1,0) = sprintf("%.1f",sum(NPP1_t))
90.480 + text4(nrow-1,1) = sprintf("%.1f",sum(VegC_t))
90.481 + text4(nrow-1,2) = sprintf("%.1f",sum(LiCwC_t))
90.482 + text4(nrow-1,3) = sprintf("%.1f",sum(SoilC_t))
90.483 + text4(nrow-1,4) = sprintf("%.1f",sum(NEE2_t))
90.484 + text4(nrow-1,5) = "<a href=./NPP_monthly_global.png>monthly_plot</a> <br> <a href=./NPP_annual_global.png>annual_plot</a>"
90.485 + text4(nrow-1,6) = "<a href=./NEE_monthly_global.png>monthly_plot</a> <br> <a href=./NEE_annual_global.png>annual_plot</a>"
90.486 + text4(nrow-1,7) = "--"
90.487 +
90.488 +;**************************************************
90.489 +; create html table2
90.490 +;**************************************************
90.491 +
90.492 + header_text = "<H1>NEE and Carbon Stocks and Fluxes (per biome): Model "+model_name+"</H1>"
90.493 +
90.494 + header = (/"<HTML>" \
90.495 + ,"<HEAD>" \
90.496 + ,"<TITLE>CLAMP metrics</TITLE>" \
90.497 + ,"</HEAD>" \
90.498 + ,header_text \
90.499 + /)
90.500 + footer = "</HTML>"
90.501 +
90.502 + table_header = (/ \
90.503 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
90.504 + ,"<tr>" \
90.505 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
90.506 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
90.507 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
90.508 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
90.509 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
90.510 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
90.511 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
90.512 + ," <th bgcolor=DDDDDD >"+col_head(6)+"</th>" \
90.513 + ," <th bgcolor=DDDDDD >"+col_head(7)+"</th>" \
90.514 + ,"</tr>" \
90.515 + /)
90.516 + table_footer = "</table>"
90.517 + row_header = "<tr>"
90.518 + row_footer = "</tr>"
90.519 +
90.520 + lines = new(50000,string)
90.521 + nline = 0
90.522 +
90.523 + set_line(lines,nline,header)
90.524 + set_line(lines,nline,table_header)
90.525 +;-----------------------------------------------
90.526 +;row of table
90.527 +
90.528 + do n = 0,nrow-1
90.529 + set_line(lines,nline,row_header)
90.530 +
90.531 + txt0 = row_head(n)
90.532 + txt1 = text4(n,0)
90.533 + txt2 = text4(n,1)
90.534 + txt3 = text4(n,2)
90.535 + txt4 = text4(n,3)
90.536 + txt5 = text4(n,4)
90.537 + txt6 = text4(n,5)
90.538 + txt7 = text4(n,6)
90.539 + txt8 = text4(n,7)
90.540 +
90.541 + set_line(lines,nline,"<th>"+txt0+"</th>")
90.542 + set_line(lines,nline,"<th>"+txt1+"</th>")
90.543 + set_line(lines,nline,"<th>"+txt2+"</th>")
90.544 + set_line(lines,nline,"<th>"+txt3+"</th>")
90.545 + set_line(lines,nline,"<th>"+txt4+"</th>")
90.546 + set_line(lines,nline,"<th>"+txt5+"</th>")
90.547 + set_line(lines,nline,"<th>"+txt6+"</th>")
90.548 + set_line(lines,nline,"<th>"+txt7+"</th>")
90.549 + set_line(lines,nline,"<th>"+txt8+"</th>")
90.550 +
90.551 + set_line(lines,nline,row_footer)
90.552 + end do
90.553 +;-----------------------------------------------
90.554 + set_line(lines,nline,table_footer)
90.555 + set_line(lines,nline,footer)
90.556 +
90.557 +; Now write to an HTML file.
90.558 +
90.559 + output_html = "table_carbon_sink2.html"
90.560 +
90.561 + idx = ind(.not.ismissing(lines))
90.562 + if(.not.any(ismissing(idx))) then
90.563 + asciiwrite(output_html,lines(idx))
90.564 + else
90.565 + print ("error?")
90.566 + end if
90.567 +
90.568 + delete (idx)
90.569 +
90.570 +;---------------------------------------------------
90.571 +; read data: model, time series
90.572 +
90.573 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
90.574 + film = model_name2 + "_Fire_C_1979-2004_monthly.nc"
90.575 + fm = addfile (dirm+film,"r")
90.576 +
90.577 + NPP3 = fm->NPP
90.578 + NEE3 = fm->NEE
90.579 +;Fire = fm->COL_FIRE_CLOSS
90.580 +
90.581 + delete (fm)
90.582 +
90.583 +; Units for these variables are:
90.584 +
90.585 +;NPP3: g C/m^2/s
90.586 +;NEE3: g C/m^2/s
90.587 +;Fire: g C/m^2/s
90.588 +
90.589 + nsec_per_month = 60*60*24*30
90.590 +
90.591 +; change unit to g C/m^2/month
90.592 +
90.593 + NPP3 = NPP3 * nsec_per_month
90.594 + NEE3 = NEE3 * nsec_per_month
90.595 +;Fire = Fire * nsec_per_month
90.596 +
90.597 +;data_n = 3
90.598 + data_n = 2
90.599 +
90.600 + dsizes = dimsizes(NPP3)
90.601 + nyear = dsizes(0)
90.602 + nmonth = dsizes(1)
90.603 + ntime = nyear * nmonth
90.604 +
90.605 + year_start = 1979
90.606 + year_end = 2004
90.607 +
90.608 +;*******************************************************************
90.609 +; Calculate "nice" bins for binning the data in equally spaced ranges
90.610 +;********************************************************************
90.611 +
90.612 +; using model biome class
90.613 + nclass = nclass_mod
90.614 +
90.615 + range = fspan(0,nclass,nclass+1)
90.616 +
90.617 +; print (range)
90.618 +; Use this range information to grab all the values in a
90.619 +; particular range, and then take an average.
90.620 +
90.621 + nx = dimsizes(range) - 1
90.622 +
90.623 +;==============================
90.624 +; put data into bins
90.625 +;==============================
90.626 +
90.627 +; using observed biome class
90.628 +; base = ndtooned(classob)
90.629 +; using model biome class
90.630 + base = ndtooned(classmod)
90.631 +
90.632 +; output
90.633 +
90.634 + yvalues = new((/ntime,data_n,nx/),float)
90.635 +
90.636 +; Loop through each range, using base.
90.637 +
90.638 + do i=0,nx-1
90.639 +
90.640 + if (i.ne.(nx-1)) then
90.641 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
90.642 + else
90.643 + idx = ind(base.ge.range(i))
90.644 + end if
90.645 +
90.646 + do n = 0,data_n-1
90.647 +
90.648 + t = -1
90.649 + do m = 0,nyear-1
90.650 + do k = 0,nmonth-1
90.651 +
90.652 + t = t + 1
90.653 +
90.654 + if (n.eq.0) then
90.655 + data = ndtooned(NPP3(m,k,:,:))
90.656 + end if
90.657 +
90.658 + if (n.eq.1) then
90.659 + data = ndtooned(NEE3(m,k,:,:))
90.660 + end if
90.661 +
90.662 +; if (n.eq.2) then
90.663 +; data = ndtooned(Fire(m,k,:,:))
90.664 +; end if
90.665 +
90.666 +; Calculate average
90.667 +
90.668 + if (.not.any(ismissing(idx))) then
90.669 + yvalues(t,n,i) = sum(data(idx)*area_1d(idx))
90.670 + else
90.671 + yvalues(t,n,i) = yvalues@_FillValue
90.672 + end if
90.673 +
90.674 +;#############################################################
90.675 +; using model biome class:
90.676 +; set the following 4 classes to _FillValue:
90.677 +; (3)Needleleaf Deciduous Boreal Tree,
90.678 +; (8)Broadleaf Deciduous Boreal Tree,
90.679 +; (9)Broadleaf Evergreen Shrub,
90.680 +; (16)Wheat
90.681 +
90.682 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
90.683 + yvalues(t,n,i) = yvalues@_FillValue
90.684 + end if
90.685 +;#############################################################
90.686 +
90.687 + end do
90.688 + end do
90.689 +
90.690 + delete(data)
90.691 + end do
90.692 +
90.693 + delete(idx)
90.694 + end do
90.695 +
90.696 + delete (base)
90.697 + delete (NPP3)
90.698 + delete (NEE3)
90.699 +; delete (Fire)
90.700 +
90.701 +;----------------------------------------------------------------
90.702 +; data for tseries plot
90.703 +
90.704 + yvalues_g = new((/ntime,data_n,n_biome/),float)
90.705 +
90.706 + yvalues_g@units = "TgC/month"
90.707 +
90.708 +; change unit to Tg C/month
90.709 +; change unit from g to Tg (Tera gram)
90.710 + factor_unit = 1.e-12
90.711 +
90.712 + yvalues_g = yvalues(:,:,good) * factor_unit
90.713 +
90.714 +;*******************************************************************
90.715 +; general settings for line plot
90.716 +;*******************************************************************
90.717 +
90.718 +; res
90.719 + res = True
90.720 + res@xyDashPatterns = (/0/) ; make lines solid
90.721 + res@xyLineThicknesses = (/2.0/) ; make lines thicker
90.722 + res@xyLineColors = (/"blue"/) ; line color
90.723 +
90.724 + res@trXMinF = year_start
90.725 + res@trXMaxF = year_end + 1
90.726 +
90.727 + res@vpHeightF = 0.4 ; change aspect ratio of plot
90.728 +; res@vpWidthF = 0.8
90.729 + res@vpWidthF = 0.75
90.730 +
90.731 +; res@gsnMaximize = True
90.732 +
90.733 +;*******************************************************************
90.734 +; (A) 1 component in each biome: monthly
90.735 +;*******************************************************************
90.736 +
90.737 +; component = (/"NPP","NEE","Fire"/)
90.738 + component = (/"NPP","NEE"/)
90.739 +
90.740 +; for x-axis in xyplot
90.741 +
90.742 + timeI = new((/ntime/),integer)
90.743 + timeF = new((/ntime/),float)
90.744 + timeI = ispan(1,ntime,1)
90.745 + timeF = year_start + (timeI-1)/12.
90.746 + timeF@long_name = "year"
90.747 +
90.748 + plot_data = new((/ntime/),float)
90.749 + plot_data@long_name = "TgC/month"
90.750 +
90.751 + do n = 0, data_n-1
90.752 + do m = 0, n_biome-1
90.753 +
90.754 + plot_name = component(n)+"_monthly_biome_"+ m
90.755 +
90.756 + wks = gsn_open_wks (plot_type,plot_name)
90.757 +
90.758 + title = component(n)+ ": "+ row_head(m)
90.759 + res@tiMainString = title
90.760 + res@tiMainFontHeightF = 0.025
90.761 +
90.762 + plot_data(:) = yvalues_g(:,n,m)
90.763 +
90.764 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
90.765 +
90.766 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
90.767 + "rm "+plot_name+"."+plot_type)
90.768 +
90.769 + clear (wks)
90.770 + delete (plot)
90.771 + end do
90.772 + end do
90.773 +
90.774 + do n = 0, data_n-1
90.775 +
90.776 + plot_name = component(n)+"_monthly_global"
90.777 +
90.778 + wks = gsn_open_wks (plot_type,plot_name)
90.779 +
90.780 + title = component(n)+ ": Global"
90.781 + res@tiMainString = title
90.782 + res@tiMainFontHeightF = 0.025
90.783 +
90.784 + do k = 0,ntime-1
90.785 + plot_data(k) = sum(yvalues_g(k,n,:))
90.786 + end do
90.787 +
90.788 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
90.789 +
90.790 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
90.791 + "rm "+plot_name+"."+plot_type)
90.792 +
90.793 + clear (wks)
90.794 + delete (plot)
90.795 + end do
90.796 +
90.797 + delete (plot_data)
90.798 + delete (timeI)
90.799 + delete (timeF)
90.800 +
90.801 +;*******************************************************************
90.802 +; (B) 1 component in each biome: annually
90.803 +;*******************************************************************
90.804 +
90.805 + yvalues_a = new((/nyear,data_n,n_biome/),float)
90.806 + yvalues_g!0 = "time"
90.807 + yvalues_g!1 = "case"
90.808 + yvalues_g!2 = "record"
90.809 +
90.810 + yvalues_a = month_to_annual(yvalues_g,0)
90.811 +
90.812 + delete (yvalues_g)
90.813 +
90.814 +; for x-axis in xyplot
90.815 +
90.816 + timeI = new((/nyear/),integer)
90.817 + timeF = new((/nyear/),float)
90.818 + timeI = ispan(1,nyear,1)
90.819 + timeF = year_start + (timeI-1)
90.820 + timeF@long_name = "year"
90.821 +
90.822 + plot_data = new((/nyear/),float)
90.823 + plot_data@long_name = "TgC/year"
90.824 +
90.825 + do n = 0, data_n-1
90.826 + do m = 0, n_biome-1
90.827 +
90.828 + plot_name = component(n)+"_annual_biome_"+ m
90.829 +
90.830 + wks = gsn_open_wks (plot_type,plot_name)
90.831 +
90.832 + title = component(n)+ ": "+ row_head(m)
90.833 + res@tiMainString = title
90.834 + res@tiMainFontHeightF = 0.025
90.835 +
90.836 + plot_data(:) = yvalues_a(:,n,m)
90.837 +
90.838 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
90.839 +
90.840 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
90.841 + "rm "+plot_name+"."+plot_type)
90.842 +
90.843 + clear (wks)
90.844 + delete (plot)
90.845 + end do
90.846 + end do
90.847 +
90.848 + do n = 0, data_n-1
90.849 +
90.850 + plot_name = component(n)+"_annual_global"
90.851 +
90.852 + wks = gsn_open_wks (plot_type,plot_name)
90.853 +
90.854 + title = component(n)+ ": Global"
90.855 + res@tiMainString = title
90.856 + res@tiMainFontHeightF = 0.025
90.857 +
90.858 + do k = 0,nyear-1
90.859 + plot_data(k) = sum(yvalues_a(k,n,:))
90.860 + end do
90.861 +
90.862 + plot=gsn_csm_xy(wks,timeF,plot_data,res)
90.863 +
90.864 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
90.865 + "rm "+plot_name+"."+plot_type)
90.866 +
90.867 + clear (wks)
90.868 + delete (plot)
90.869 + end do
90.870 +
90.871 +end
90.872 +
91.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
91.2 +++ b/carbon_sink/note.1 Mon Jan 26 22:08:20 2009 -0500
91.3 @@ -0,0 +1,1 @@
91.4 +casa does not have fire.
91.5 \ No newline at end of file
92.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
92.2 +++ b/class/01.test.ncl Mon Jan 26 22:08:20 2009 -0500
92.3 @@ -0,0 +1,33 @@
92.4 +;*************************************************
92.5 +; ce_1.ncl
92.6 +;************************************************
92.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
92.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
92.9 +;************************************************
92.10 +begin
92.11 +
92.12 +;************************************************
92.13 +; read in model data
92.14 +;************************************************
92.15 + diri = "/fis/cgd/cseg/people/jeff/clamp/class/"
92.16 + fili = "T42.clamp.surface-data.060412.nc"
92.17 + f = addfile(diri+fili,"r")
92.18 +
92.19 + y = f->PCT_PFT
92.20 + printVarSummary(y)
92.21 +
92.22 + x = y(0,:,:)
92.23 +
92.24 + dimx = dimsizes(y)
92.25 + nlat = dimx(1)
92.26 + nlon = dimx(2)
92.27 +
92.28 + do j= 0,nlat-1
92.29 + do i= 0,nlon-1
92.30 + x(j,i) = sum(y(:,j,i))
92.31 + end do
92.32 + end do
92.33 +
92.34 + print (x)
92.35 +
92.36 +end
92.37 \ No newline at end of file
93.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
93.2 +++ b/class/02.class.ncl Mon Jan 26 22:08:20 2009 -0500
93.3 @@ -0,0 +1,72 @@
93.4 +;*************************************************
93.5 +; ce_1.ncl
93.6 +;************************************************
93.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
93.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
93.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
93.10 +;************************************************
93.11 +begin
93.12 +
93.13 +;************************************************
93.14 +; read in model data
93.15 +;************************************************
93.16 + diri = "/fis/cgd/cseg/people/jeff/clamp/class/"
93.17 + fili = "T42.clamp.surface-data.060412.nc"
93.18 + f = addfile(diri+fili,"r")
93.19 +
93.20 + y = f->PCT_PFT
93.21 + printVarSummary(y)
93.22 +
93.23 + diri = "/fis/cgd/cseg/people/jeff/surface_data/"
93.24 + fili = "lnd_T42.nc"
93.25 + g = addfile(diri+fili,"r")
93.26 +
93.27 + landmask = g->landmask
93.28 + lat = g->lat
93.29 + lon = g->lon
93.30 +
93.31 + nlat = dimsizes(lat)
93.32 + nlon = dimsizes(lon)
93.33 +
93.34 + x = y(0,:,:)
93.35 +
93.36 + x!0 = "lat"
93.37 + x&lat = lat
93.38 + x!1 = "lon"
93.39 + x&lon = lon
93.40 + x@_FillValue = 1.e36
93.41 + x@long_name = "Model PFT Classes"
93.42 +
93.43 + do j= 0,nlat-1
93.44 + do i= 0,nlon-1
93.45 + x(j,i) = maxind(y(:,j,i))
93.46 + end do
93.47 + end do
93.48 +
93.49 +; print (x)
93.50 +
93.51 + x = where(landmask .lt. 1.,x@_FillValue,x)
93.52 +
93.53 +;************************************************
93.54 +; create default plot
93.55 +;************************************************
93.56 +
93.57 + wks = gsn_open_wks("ps","class") ; open a ps file
93.58 + gsn_define_colormap(wks,"gui_default") ; choose colormap
93.59 +
93.60 + res = True ; Use plot options
93.61 + res@cnFillOn = True ; Turn on color fill
93.62 + res@gsnSpreadColors = True ; use full colormap
93.63 + res@cnLinesOn = False ; Turn off contourn lines
93.64 + res@mpFillOn = False ; Turn off map fill
93.65 + res@tiMainString = "Class"
93.66 +
93.67 + res@gsnSpreadColors = True ; use full colormap
93.68 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
93.69 + res@cnMinLevelValF = 0. ; Min level
93.70 + res@cnMaxLevelValF = 16. ; Max level
93.71 + res@cnLevelSpacingF = 1. ; interval
93.72 +
93.73 + plot = gsn_csm_contour_map_ce(wks,x,res)
93.74 +
93.75 +end
93.76 \ No newline at end of file
94.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
94.2 +++ b/class/03.class_1.9_write.ncl Mon Jan 26 22:08:20 2009 -0500
94.3 @@ -0,0 +1,61 @@
94.4 +;*************************************************
94.5 +; ce_1.ncl
94.6 +;************************************************
94.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
94.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
94.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
94.10 +;************************************************
94.11 +begin
94.12 +
94.13 +; final output
94.14 +
94.15 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
94.16 + filo = "class_pft_1.9.nc"
94.17 + c = addfile(diro+filo,"c")
94.18 +
94.19 +; read model data
94.20 +
94.21 + diri = "/fis/cgd/cseg/people/jeff/surface_data/"
94.22 + fili = "surfdata_1.9x2.5_cn_070119.nc"
94.23 + f = addfile(diri+fili,"r")
94.24 +
94.25 + y = f->PCT_PFT
94.26 +; printVarSummary(y)
94.27 +
94.28 +; read model grid data
94.29 +
94.30 + diri = "/fis/cgd/cseg/people/jeff/surface_data/"
94.31 + fili = "lnd_1.9.nc"
94.32 + g = addfile(diri+fili,"r")
94.33 +
94.34 + landmask = g->landmask
94.35 + lat = g->lat
94.36 + lon = g->lon
94.37 +
94.38 + nlat = dimsizes(lat)
94.39 + nlon = dimsizes(lon)
94.40 +
94.41 + x = y(0,:,:)
94.42 +
94.43 + x!0 = "lat"
94.44 + x&lat = lat
94.45 + x!1 = "lon"
94.46 + x&lon = lon
94.47 + x@_FillValue = 1.e36
94.48 + x@long_name = "Model PFT Classes"
94.49 +
94.50 + do j= 0,nlat-1
94.51 + do i= 0,nlon-1
94.52 + x(j,i) = maxind(y(:,j,i))
94.53 + end do
94.54 + end do
94.55 +
94.56 +; print (x)
94.57 +
94.58 + x = where(landmask .lt. 1.,x@_FillValue,x)
94.59 +
94.60 + c->CLASS_PFT = x
94.61 + c->lat = lat
94.62 + c->lon = lon
94.63 +
94.64 +end
94.65 \ No newline at end of file
95.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
95.2 +++ b/class/03.class_T31_write.ncl Mon Jan 26 22:08:20 2009 -0500
95.3 @@ -0,0 +1,61 @@
95.4 +;*************************************************
95.5 +; ce_1.ncl
95.6 +;************************************************
95.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
95.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
95.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
95.10 +;************************************************
95.11 +begin
95.12 +
95.13 +; final output
95.14 +
95.15 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
95.16 + filo = "class_pft_T31.nc"
95.17 + c = addfile(diro+filo,"c")
95.18 +
95.19 +; read model data
95.20 +
95.21 + diri = "/fis/cgd/cseg/people/jeff/surface_data/"
95.22 + fili = "surfdata_48x96_c070501.nc"
95.23 + f = addfile(diri+fili,"r")
95.24 +
95.25 + y = f->PCT_PFT
95.26 +; printVarSummary(y)
95.27 +
95.28 +; read model grid data
95.29 +
95.30 + diri = "/fis/cgd/cseg/people/jeff/surface_data/"
95.31 + fili = "lnd_T31.nc"
95.32 + g = addfile(diri+fili,"r")
95.33 +
95.34 + landmask = g->landmask
95.35 + lat = g->lat
95.36 + lon = g->lon
95.37 +
95.38 + nlat = dimsizes(lat)
95.39 + nlon = dimsizes(lon)
95.40 +
95.41 + x = y(0,:,:)
95.42 +
95.43 + x!0 = "lat"
95.44 + x&lat = lat
95.45 + x!1 = "lon"
95.46 + x&lon = lon
95.47 + x@_FillValue = 1.e36
95.48 + x@long_name = "Model PFT Classes"
95.49 +
95.50 + do j= 0,nlat-1
95.51 + do i= 0,nlon-1
95.52 + x(j,i) = maxind(y(:,j,i))
95.53 + end do
95.54 + end do
95.55 +
95.56 +; print (x)
95.57 +
95.58 + x = where(landmask .lt. 1.,x@_FillValue,x)
95.59 +
95.60 + c->CLASS_PFT = x
95.61 + c->lat = lat
95.62 + c->lon = lon
95.63 +
95.64 +end
95.65 \ No newline at end of file
96.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
96.2 +++ b/class/03.class_T42_write.ncl Mon Jan 26 22:08:20 2009 -0500
96.3 @@ -0,0 +1,61 @@
96.4 +;*************************************************
96.5 +; ce_1.ncl
96.6 +;************************************************
96.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
96.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
96.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
96.10 +;************************************************
96.11 +begin
96.12 +
96.13 +; final output
96.14 +
96.15 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
96.16 + filo = "class_pft_T42.nc"
96.17 + c = addfile(diro+filo,"c")
96.18 +
96.19 +; read model data
96.20 +
96.21 + diri = "/fis/cgd/cseg/people/jeff/surface_data/"
96.22 + fili = "T42.clamp.surface-data.060412.nc"
96.23 + f = addfile(diri+fili,"r")
96.24 +
96.25 + y = f->PCT_PFT
96.26 +; printVarSummary(y)
96.27 +
96.28 +; read model grid data
96.29 +
96.30 + diri = "/fis/cgd/cseg/people/jeff/surface_data/"
96.31 + fili = "lnd_T42.nc"
96.32 + g = addfile(diri+fili,"r")
96.33 +
96.34 + landmask = g->landmask
96.35 + lat = g->lat
96.36 + lon = g->lon
96.37 +
96.38 + nlat = dimsizes(lat)
96.39 + nlon = dimsizes(lon)
96.40 +
96.41 + x = y(0,:,:)
96.42 +
96.43 + x!0 = "lat"
96.44 + x&lat = lat
96.45 + x!1 = "lon"
96.46 + x&lon = lon
96.47 + x@_FillValue = 1.e36
96.48 + x@long_name = "Model PFT Classes"
96.49 +
96.50 + do j= 0,nlat-1
96.51 + do i= 0,nlon-1
96.52 + x(j,i) = maxind(y(:,j,i))
96.53 + end do
96.54 + end do
96.55 +
96.56 +; print (x)
96.57 +
96.58 + x = where(landmask .lt. 1.,x@_FillValue,x)
96.59 +
96.60 + c->CLASS_PFT = x
96.61 + c->lat = lat
96.62 + c->lon = lon
96.63 +
96.64 +end
96.65 \ No newline at end of file
97.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
97.2 +++ b/class/04.check_write.ncl Mon Jan 26 22:08:20 2009 -0500
97.3 @@ -0,0 +1,42 @@
97.4 +;*************************************************
97.5 +; ce_1.ncl
97.6 +;************************************************
97.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
97.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
97.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
97.10 +;************************************************
97.11 +begin
97.12 +
97.13 +; read data
97.14 +
97.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
97.16 + fili = "class_pft_T42.nc"
97.17 + fili = "class_pft_1.9.nc"
97.18 + f = addfile(diri+fili,"r")
97.19 +
97.20 + x = f->CLASS_PFT
97.21 + printVarSummary(x)
97.22 +
97.23 +;************************************************
97.24 +; create default plot
97.25 +;************************************************
97.26 +
97.27 + wks = gsn_open_wks("ps","class") ; open a ps file
97.28 + gsn_define_colormap(wks,"gui_default") ; choose colormap
97.29 +
97.30 + res = True ; Use plot options
97.31 + res@cnFillOn = True ; Turn on color fill
97.32 + res@gsnSpreadColors = True ; use full colormap
97.33 + res@cnLinesOn = False ; Turn off contourn lines
97.34 + res@mpFillOn = False ; Turn off map fill
97.35 + res@tiMainString = "Class"
97.36 +
97.37 + res@gsnSpreadColors = True ; use full colormap
97.38 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
97.39 + res@cnMinLevelValF = 0. ; Min level
97.40 + res@cnMaxLevelValF = 16. ; Max level
97.41 + res@cnLevelSpacingF = 1. ; interval
97.42 +
97.43 + plot = gsn_csm_contour_map_ce(wks,x,res)
97.44 +
97.45 +end
97.46 \ No newline at end of file
98.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
98.2 +++ b/class/note.1 Mon Jan 26 22:08:20 2009 -0500
98.3 @@ -0,0 +1,1 @@
98.4 +create from /surface_data/T42.clamp.surface-data.060412.nc
98.5 \ No newline at end of file
99.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
99.2 +++ b/co2/00.test.html.csh Mon Jan 26 22:08:20 2009 -0500
99.3 @@ -0,0 +1,8 @@
99.4 +#!/bin/sh
99.5 +
99.6 +fout=test.html
99.7 +
99.8 +echo "<meta name=\"description\">" > $fout
99.9 +
99.10 +
99.11 +exit
100.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
100.2 +++ b/co2/01.test.html.csh Mon Jan 26 22:08:20 2009 -0500
100.3 @@ -0,0 +1,30 @@
100.4 +#!/bin/sh
100.5 +
100.6 +fout=test2.html
100.7 +
100.8 +echo "<html>" > $fout
100.9 +echo "<head>" >> $fout
100.10 +echo "<title> CO2 Model </title>" >> $fout
100.11 +echo "<meta name=\"description\" content=\"co2 model\">" >> $fout
100.12 +echo "<meta name=\"keywords\" content=\"score CLAMP co2 model\">" >> $fout
100.13 +echo "<meta name=\"Authors\" content=\"Jeff Lee\">" >> $fout
100.14 +echo "</head>" >> $fout
100.15 +
100.16 +echo "<!----------------------------------------------------------------------------->" >>$ fout
100.17 +echo "<h3 align=center>CLAMP Metric</h3>" >> $fout
100.18 +echo "<h2 align=center>Seasonal cycle of atmospheric CO2 metrics</h2>" >> $fout
100.19 +echo "<h1 align=center>Stations In 60N-90N (in progress)</h2>" >> $fout
100.20 +echo "<!----------------------------------------------------------------------------->" >> $fout
100.21 +echo "<table border=1 cellspacing=\"0\" cellpadding=\"3\" width=\"100%\">" >> $fout
100.22 +echo "<tr>" >> $fout
100.23 + echo "<th bgcolor=\"DDDDDD\" align=center> Name of <br> Station</th>" >> $fout
100.24 + echo "<th bgcolor=\"DDDDDD\" align=center> Latitude</th>" >> $fout
100.25 + echo "<th bgcolor=\"DDDDDD\" align=center> Longitude</th>" >> $fout
100.26 + echo "<th bgcolor=\"DDDDDD\" align=center> Amplitude <br> Ratio </th>" >> $fout
100.27 + echo "<th bgcolor=\"DDDDDD\" align=center> Correlation <br> Coefficient</th>" >> $fout
100.28 + echo "<th bgcolor=\"DDDDDD\" align=center> M <br> Score</th>" >> $fout
100.29 + echo "<th bgcolor=\"DDDDDD\" align=center> Combined <br> Score </th>" >> $fout
100.30 +echo "</tr>" >> $fout
100.31 +
100.32 +
100.33 +exit
101.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
101.2 +++ b/co2/01.test.read.ncl Mon Jan 26 22:08:20 2009 -0500
101.3 @@ -0,0 +1,19 @@
101.4 +;************************************************
101.5 +; Read ascii, Write nc
101.6 +;************************************************
101.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
101.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
101.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
101.10 +;************************************************
101.11 +begin
101.12 +
101.13 + b = "zot005_45D2_seas.co2"
101.14 + ncol = 4
101.15 + data = readAsciiTable(b, ncol, "float", (/10,17/))
101.16 + print (data)
101.17 +
101.18 + ncol = 5
101.19 + data2 = readAsciiTable(b, ncol, "float", 16)
101.20 + print (data2)
101.21 +
101.22 +end
102.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
102.2 +++ b/co2/02.test.read.ncl Mon Jan 26 22:08:20 2009 -0500
102.3 @@ -0,0 +1,22 @@
102.4 +;************************************************
102.5 +; Read ascii, Write nc
102.6 +;************************************************
102.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
102.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
102.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
102.10 +;************************************************
102.11 +begin
102.12 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/globalView-C4Mip/seas/"
102.13 + b = (/"zot005_45D2_seas.co2", "zot015_45D2_seas.co2"/)
102.14 + do n = 0,1
102.15 + print (b(n))
102.16 + ncol1 = 4
102.17 + data1 = readAsciiTable(diri+b(n), ncol1, "float", (/10,17/))
102.18 + print (data1)
102.19 +
102.20 + ncol2 = 5
102.21 + data2 = readAsciiTable(diri+b(n), ncol2, "float", 16)
102.22 + print (data2)
102.23 + end do
102.24 +
102.25 +end
103.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
103.2 +++ b/co2/03.test.read.ncl Mon Jan 26 22:08:20 2009 -0500
103.3 @@ -0,0 +1,249 @@
103.4 +;************************************************
103.5 +; Read ascii, Write nc
103.6 +;************************************************
103.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
103.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
103.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
103.10 +;************************************************
103.11 +begin
103.12 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/globalView-C4Mip/seas/"
103.13 + b = (/ \
103.14 +"aia005_02D2_seas.co2", \
103.15 +"aia015_02D2_seas.co2", \
103.16 +"aia025_02D2_seas.co2", \
103.17 +"aia035_02D2_seas.co2", \
103.18 +"aia045_02D2_seas.co2", \
103.19 +"aia055_02D2_seas.co2", \
103.20 +"aia065_02D2_seas.co2", \
103.21 +"alt_01D0_seas.co2", \
103.22 +"alt_02D0_seas.co2", \
103.23 +"alt_04D0_seas.co2", \
103.24 +"alt_06C0_seas.co2", \
103.25 +"alt_06D0_seas.co2", \
103.26 +"ams_01D0_seas.co2", \
103.27 +"ams_11C0_seas.co2", \
103.28 +"asc_01D0_seas.co2", \
103.29 +"ask_01D0_seas.co2", \
103.30 +"avi_01D0_seas.co2", \
103.31 +"azr_01D0_seas.co2", \
103.32 +"bal_01D1_seas.co2", \
103.33 +"bgu_11D0_seas.co2", \
103.34 +"bhd_15C0_seas.co2", \
103.35 +"bme_01D0_seas.co2", \
103.36 +"bmw_01D0_seas.co2", \
103.37 +"brw_01C0_seas.co2", \
103.38 +"brw_01D0_seas.co2", \
103.39 +"bsc_01D0_seas.co2", \
103.40 +"car030_01D2_seas.co2", \
103.41 +"car040_01D2_seas.co2", \
103.42 +"car050_01D2_seas.co2", \
103.43 +"car060_01D2_seas.co2", \
103.44 +"car070_01D2_seas.co2", \
103.45 +"car080_01D2_seas.co2", \
103.46 +"cba_01D0_seas.co2", \
103.47 +"cba_04D0_seas.co2", \
103.48 +"cfa_02D0_seas.co2", \
103.49 +"cgo_01D0_seas.co2", \
103.50 +"cgo_02D0_seas.co2", \
103.51 +"cgo_04D0_seas.co2", \
103.52 +"chr_01D0_seas.co2", \
103.53 +"cmn_17C0_seas.co2", \
103.54 +"cmo_01D0_seas.co2", \
103.55 +"coi_20C0_seas.co2", \
103.56 +"cpt_36C0_seas.co2", \
103.57 +"cri_02D0_seas.co2", \
103.58 +"crz_01D0_seas.co2", \
103.59 +"csj_06D0_seas.co2", \
103.60 +"daa_02D0_seas.co2", \
103.61 +"eic_01D0_seas.co2", \
103.62 +"esp005_01D2_seas.co2", \
103.63 +"esp015_01D2_seas.co2", \
103.64 +"esp025_01D2_seas.co2", \
103.65 +"esp035_01D2_seas.co2", \
103.66 +"esp045_01D2_seas.co2", \
103.67 +"esp055_01D2_seas.co2", \
103.68 +"esp_02D0_seas.co2", \
103.69 +"esp_06D0_seas.co2", \
103.70 +"frd040_06C3_seas.co2", \
103.71 +"gmi_01D0_seas.co2", \
103.72 +"goz_01D0_seas.co2", \
103.73 +"gsn_24D0_seas.co2", \
103.74 +"haa005_01D2_seas.co2", \
103.75 +"haa015_01D2_seas.co2", \
103.76 +"haa025_01D2_seas.co2", \
103.77 +"haa035_01D2_seas.co2", \
103.78 +"haa045_01D2_seas.co2", \
103.79 +"haa055_01D2_seas.co2", \
103.80 +"haa065_01D2_seas.co2", \
103.81 +"haa075_01D2_seas.co2", \
103.82 +"hat_20C0_seas.co2", \
103.83 +"hba_01D0_seas.co2", \
103.84 +"hfm005_01D2_seas.co2", \
103.85 +"hfm015_01D2_seas.co2", \
103.86 +"hfm025_01D2_seas.co2", \
103.87 +"hfm035_01D2_seas.co2", \
103.88 +"hfm045_01D2_seas.co2", \
103.89 +"hfm055_01D2_seas.co2", \
103.90 +"hfm065_01D2_seas.co2", \
103.91 +"hfm075_01D2_seas.co2", \
103.92 +"hun010_35C3_seas.co2", \
103.93 +"hun048_35C3_seas.co2", \
103.94 +"hun082_35C3_seas.co2", \
103.95 +"hun115_35C3_seas.co2", \
103.96 +"hun_01D0_seas.co2", \
103.97 +"ice_01D0_seas.co2", \
103.98 +"itn051_01C3_seas.co2", \
103.99 +"itn123_01C3_seas.co2", \
103.100 +"itn496_01C3_seas.co2", \
103.101 +"itn_01D0_seas.co2", \
103.102 +"izo_01D0_seas.co2", \
103.103 +"izo_27C0_seas.co2", \
103.104 +"jbn_29C0_seas.co2", \
103.105 +"key_01D0_seas.co2", \
103.106 +"kum_01D0_seas.co2", \
103.107 +"kum_04D0_seas.co2", \
103.108 +"kzd_01D0_seas.co2", \
103.109 +"kzm_01D0_seas.co2", \
103.110 +"lef011_01C3_seas.co2", \
103.111 +"lef030_01C3_seas.co2", \
103.112 +"lef076_01C3_seas.co2", \
103.113 +"lef122_01C3_seas.co2", \
103.114 +"lef244_01C3_seas.co2", \
103.115 +"lef396_01C3_seas.co2", \
103.116 +"lef_01D0_seas.co2", \
103.117 +"ljo_04D0_seas.co2", \
103.118 +"lmp_28D0_seas.co2", \
103.119 +"maa_02D0_seas.co2", \
103.120 +"mbc_01D0_seas.co2", \
103.121 +"mhd_01D0_seas.co2", \
103.122 +"mhdcbc_11C0_seas.co2", \
103.123 +"mhdrbc_11C0_seas.co2", \
103.124 +"mid_01D0_seas.co2", \
103.125 +"mlo_01C0_seas.co2", \
103.126 +"mlo_01D0_seas.co2", \
103.127 +"mlo_02D0_seas.co2", \
103.128 +"mlo_04D0_seas.co2", \
103.129 +"mnm_19C0_seas.co2", \
103.130 +"mqa_02D0_seas.co2", \
103.131 +"nwr_01D0_seas.co2", \
103.132 +"obs023_06C3_seas.co2", \
103.133 +"opw_01D0_seas.co2", \
103.134 +"orl005_11D2_seas.co2", \
103.135 +"orl015_11D2_seas.co2", \
103.136 +"orl025_11D2_seas.co2", \
103.137 +"orl035_11D2_seas.co2", \
103.138 +"palcbc_30C0_seas.co2", \
103.139 +"palmbc_30C0_seas.co2", \
103.140 +"pdm_11D0_seas.co2", \
103.141 +"pfa015_01D2_seas.co2", \
103.142 +"pfa025_01D2_seas.co2", \
103.143 +"pfa035_01D2_seas.co2", \
103.144 +"pfa045_01D2_seas.co2", \
103.145 +"pfa055_01D2_seas.co2", \
103.146 +"pfa065_01D2_seas.co2", \
103.147 +"pfa075_01D2_seas.co2", \
103.148 +"poc000_01D1_seas.co2", \
103.149 +"pocn05_01D1_seas.co2", \
103.150 +"pocn10_01D1_seas.co2", \
103.151 +"pocn15_01D1_seas.co2", \
103.152 +"pocn20_01D1_seas.co2", \
103.153 +"pocn25_01D1_seas.co2", \
103.154 +"pocn30_01D1_seas.co2", \
103.155 +"pocn35_01D1_seas.co2", \
103.156 +"pocn40_01D1_seas.co2", \
103.157 +"pocn45_01D1_seas.co2", \
103.158 +"pocs05_01D1_seas.co2", \
103.159 +"pocs10_01D1_seas.co2", \
103.160 +"pocs15_01D1_seas.co2", \
103.161 +"pocs20_01D1_seas.co2", \
103.162 +"pocs25_01D1_seas.co2", \
103.163 +"pocs30_01D1_seas.co2", \
103.164 +"pocs35_01D1_seas.co2", \
103.165 +"prs_21C0_seas.co2", \
103.166 +"prs_21D0_seas.co2", \
103.167 +"psa_01D0_seas.co2", \
103.168 +"psa_04D0_seas.co2", \
103.169 +"rpb_01D0_seas.co2", \
103.170 +"rta005_01D2_seas.co2", \
103.171 +"rta015_01D2_seas.co2", \
103.172 +"rta025_01D2_seas.co2", \
103.173 +"rta035_01D2_seas.co2", \
103.174 +"rta045_01D2_seas.co2", \
103.175 +"ryo_19C0_seas.co2", \
103.176 +"sbl_06C0_seas.co2", \
103.177 +"sbl_06D0_seas.co2", \
103.178 +"sch_23C0_seas.co2", \
103.179 +"scsn03_01D1_seas.co2", \
103.180 +"scsn06_01D1_seas.co2", \
103.181 +"scsn09_01D1_seas.co2", \
103.182 +"scsn12_01D1_seas.co2", \
103.183 +"scsn15_01D1_seas.co2", \
103.184 +"scsn18_01D1_seas.co2", \
103.185 +"scsn21_01D1_seas.co2", \
103.186 +"sey_01D0_seas.co2", \
103.187 +"shm_01D0_seas.co2", \
103.188 +"sis_02D0_seas.co2", \
103.189 +"smo_01C0_seas.co2", \
103.190 +"smo_01D0_seas.co2", \
103.191 +"smo_04D0_seas.co2", \
103.192 +"spo_01C0_seas.co2", \
103.193 +"spo_01D0_seas.co2", \
103.194 +"spo_02D0_seas.co2", \
103.195 +"spo_04D0_seas.co2", \
103.196 +"stm_01D0_seas.co2", \
103.197 +"stmebc_01D0_seas.co2", \
103.198 +"stp_12D0_seas.co2", \
103.199 +"sum_01D0_seas.co2", \
103.200 +"syo_01D0_seas.co2", \
103.201 +"syo_09C0_seas.co2", \
103.202 +"tap_01D0_seas.co2", \
103.203 +"tdf_01D0_seas.co2", \
103.204 +"trm_11D0_seas.co2", \
103.205 +"uta_01D0_seas.co2", \
103.206 +"uum_01D0_seas.co2", \
103.207 +"wes_23C0_seas.co2", \
103.208 +"wis_01D0_seas.co2", \
103.209 +"wkt009_01C3_seas.co2", \
103.210 +"wkt030_01C3_seas.co2", \
103.211 +"wkt061_01C3_seas.co2", \
103.212 +"wkt122_01C3_seas.co2", \
103.213 +"wkt244_01C3_seas.co2", \
103.214 +"wkt457_01C3_seas.co2", \
103.215 +"wlg_01D0_seas.co2", \
103.216 +"wlg_33C0_seas.co2", \
103.217 +"wpo000_10D2_seas.co2", \
103.218 +"wpon05_10D2_seas.co2", \
103.219 +"wpon10_10D2_seas.co2", \
103.220 +"wpon15_10D2_seas.co2", \
103.221 +"wpon20_10D2_seas.co2", \
103.222 +"wpon25_10D2_seas.co2", \
103.223 +"wpon30_10D2_seas.co2", \
103.224 +"wpos05_10D2_seas.co2", \
103.225 +"wpos10_10D2_seas.co2", \
103.226 +"wpos15_10D2_seas.co2", \
103.227 +"wpos20_10D2_seas.co2", \
103.228 +"wpos25_10D2_seas.co2", \
103.229 +"yon_19C0_seas.co2", \
103.230 +"zep_01D0_seas.co2", \
103.231 +"zep_31C0_seas.co2", \
103.232 +"zot005_45D2_seas.co2", \
103.233 +"zot015_45D2_seas.co2", \
103.234 +"zot025_45D2_seas.co2", \
103.235 +"zot035_45D2_seas.co2"/)
103.236 +
103.237 +print (dimsizes(b))
103.238 +exit
103.239 + do n = 0,dimsizes(b)-1
103.240 + print (b(n))
103.241 + end do
103.242 + exit
103.243 + ncol1 = 4
103.244 + data1 = readAsciiTable(diri+b(n), ncol1, "float", (/10,17/))
103.245 + print (data1)
103.246 +
103.247 + ncol2 = 5
103.248 + data2 = readAsciiTable(diri+b(n), ncol2, "float", 16)
103.249 + print (data2)
103.250 +; end do
103.251 +
103.252 +end
104.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
104.2 +++ b/co2/04.test.read.ncl Mon Jan 26 22:08:20 2009 -0500
104.3 @@ -0,0 +1,270 @@
104.4 +;************************************************
104.5 +; Read ascii, Write nc
104.6 +;************************************************
104.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
104.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
104.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
104.10 +;************************************************
104.11 +begin
104.12 +; final output
104.13 +; diro = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
104.14 +; filo = "co2_globalView_222.nc"
104.15 +; c = addfile(diro+filo,"c")
104.16 +
104.17 +; input ascii files
104.18 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/globalView-C4Mip/seas/"
104.19 + b = (/ \
104.20 +"aia005_02D2_seas.co2", \
104.21 +"aia015_02D2_seas.co2", \
104.22 +"aia025_02D2_seas.co2", \
104.23 +"aia035_02D2_seas.co2", \
104.24 +"aia045_02D2_seas.co2", \
104.25 +"aia055_02D2_seas.co2", \
104.26 +"aia065_02D2_seas.co2", \
104.27 +"alt_01D0_seas.co2", \
104.28 +"alt_02D0_seas.co2", \
104.29 +"alt_04D0_seas.co2", \
104.30 +"alt_06C0_seas.co2", \
104.31 +"alt_06D0_seas.co2", \
104.32 +"ams_01D0_seas.co2", \
104.33 +"ams_11C0_seas.co2", \
104.34 +"asc_01D0_seas.co2", \
104.35 +"ask_01D0_seas.co2", \
104.36 +"avi_01D0_seas.co2", \
104.37 +"azr_01D0_seas.co2", \
104.38 +"bal_01D1_seas.co2", \
104.39 +"bgu_11D0_seas.co2", \
104.40 +"bhd_15C0_seas.co2", \
104.41 +"bme_01D0_seas.co2", \
104.42 +"bmw_01D0_seas.co2", \
104.43 +"brw_01C0_seas.co2", \
104.44 +"brw_01D0_seas.co2", \
104.45 +"bsc_01D0_seas.co2", \
104.46 +"car030_01D2_seas.co2", \
104.47 +"car040_01D2_seas.co2", \
104.48 +"car050_01D2_seas.co2", \
104.49 +"car060_01D2_seas.co2", \
104.50 +"car070_01D2_seas.co2", \
104.51 +"car080_01D2_seas.co2", \
104.52 +"cba_01D0_seas.co2", \
104.53 +"cba_04D0_seas.co2", \
104.54 +"cfa_02D0_seas.co2", \
104.55 +"cgo_01D0_seas.co2", \
104.56 +"cgo_02D0_seas.co2", \
104.57 +"cgo_04D0_seas.co2", \
104.58 +"chr_01D0_seas.co2", \
104.59 +"cmn_17C0_seas.co2", \
104.60 +"cmo_01D0_seas.co2", \
104.61 +"coi_20C0_seas.co2", \
104.62 +"cpt_36C0_seas.co2", \
104.63 +"cri_02D0_seas.co2", \
104.64 +"crz_01D0_seas.co2", \
104.65 +"csj_06D0_seas.co2", \
104.66 +"daa_02D0_seas.co2", \
104.67 +"eic_01D0_seas.co2", \
104.68 +"esp005_01D2_seas.co2", \
104.69 +"esp015_01D2_seas.co2", \
104.70 +"esp025_01D2_seas.co2", \
104.71 +"esp035_01D2_seas.co2", \
104.72 +"esp045_01D2_seas.co2", \
104.73 +"esp055_01D2_seas.co2", \
104.74 +"esp_02D0_seas.co2", \
104.75 +"esp_06D0_seas.co2", \
104.76 +"frd040_06C3_seas.co2", \
104.77 +"gmi_01D0_seas.co2", \
104.78 +"goz_01D0_seas.co2", \
104.79 +"gsn_24D0_seas.co2", \
104.80 +"haa005_01D2_seas.co2", \
104.81 +"haa015_01D2_seas.co2", \
104.82 +"haa025_01D2_seas.co2", \
104.83 +"haa035_01D2_seas.co2", \
104.84 +"haa045_01D2_seas.co2", \
104.85 +"haa055_01D2_seas.co2", \
104.86 +"haa065_01D2_seas.co2", \
104.87 +"haa075_01D2_seas.co2", \
104.88 +"hat_20C0_seas.co2", \
104.89 +"hba_01D0_seas.co2", \
104.90 +"hfm005_01D2_seas.co2", \
104.91 +"hfm015_01D2_seas.co2", \
104.92 +"hfm025_01D2_seas.co2", \
104.93 +"hfm035_01D2_seas.co2", \
104.94 +"hfm045_01D2_seas.co2", \
104.95 +"hfm055_01D2_seas.co2", \
104.96 +"hfm065_01D2_seas.co2", \
104.97 +"hfm075_01D2_seas.co2", \
104.98 +"hun010_35C3_seas.co2", \
104.99 +"hun048_35C3_seas.co2", \
104.100 +"hun082_35C3_seas.co2", \
104.101 +"hun115_35C3_seas.co2", \
104.102 +"hun_01D0_seas.co2", \
104.103 +"ice_01D0_seas.co2", \
104.104 +"itn051_01C3_seas.co2", \
104.105 +"itn123_01C3_seas.co2", \
104.106 +"itn496_01C3_seas.co2", \
104.107 +"itn_01D0_seas.co2", \
104.108 +"izo_01D0_seas.co2", \
104.109 +"izo_27C0_seas.co2", \
104.110 +"jbn_29C0_seas.co2", \
104.111 +"key_01D0_seas.co2", \
104.112 +"kum_01D0_seas.co2", \
104.113 +"kum_04D0_seas.co2", \
104.114 +"kzd_01D0_seas.co2", \
104.115 +"kzm_01D0_seas.co2", \
104.116 +"lef011_01C3_seas.co2", \
104.117 +"lef030_01C3_seas.co2", \
104.118 +"lef076_01C3_seas.co2", \
104.119 +"lef122_01C3_seas.co2", \
104.120 +"lef244_01C3_seas.co2", \
104.121 +"lef396_01C3_seas.co2", \
104.122 +"lef_01D0_seas.co2", \
104.123 +"ljo_04D0_seas.co2", \
104.124 +"lmp_28D0_seas.co2", \
104.125 +"maa_02D0_seas.co2", \
104.126 +"mbc_01D0_seas.co2", \
104.127 +"mhd_01D0_seas.co2", \
104.128 +"mhdcbc_11C0_seas.co2", \
104.129 +"mhdrbc_11C0_seas.co2", \
104.130 +"mid_01D0_seas.co2", \
104.131 +"mlo_01C0_seas.co2", \
104.132 +"mlo_01D0_seas.co2", \
104.133 +"mlo_02D0_seas.co2", \
104.134 +"mlo_04D0_seas.co2", \
104.135 +"mnm_19C0_seas.co2", \
104.136 +"mqa_02D0_seas.co2", \
104.137 +"nwr_01D0_seas.co2", \
104.138 +"obs023_06C3_seas.co2", \
104.139 +"opw_01D0_seas.co2", \
104.140 +"orl005_11D2_seas.co2", \
104.141 +"orl015_11D2_seas.co2", \
104.142 +"orl025_11D2_seas.co2", \
104.143 +"orl035_11D2_seas.co2", \
104.144 +"palcbc_30C0_seas.co2", \
104.145 +"palmbc_30C0_seas.co2", \
104.146 +"pdm_11D0_seas.co2", \
104.147 +"pfa015_01D2_seas.co2", \
104.148 +"pfa025_01D2_seas.co2", \
104.149 +"pfa035_01D2_seas.co2", \
104.150 +"pfa045_01D2_seas.co2", \
104.151 +"pfa055_01D2_seas.co2", \
104.152 +"pfa065_01D2_seas.co2", \
104.153 +"pfa075_01D2_seas.co2", \
104.154 +"poc000_01D1_seas.co2", \
104.155 +"pocn05_01D1_seas.co2", \
104.156 +"pocn10_01D1_seas.co2", \
104.157 +"pocn15_01D1_seas.co2", \
104.158 +"pocn20_01D1_seas.co2", \
104.159 +"pocn25_01D1_seas.co2", \
104.160 +"pocn30_01D1_seas.co2", \
104.161 +"pocn35_01D1_seas.co2", \
104.162 +"pocn40_01D1_seas.co2", \
104.163 +"pocn45_01D1_seas.co2", \
104.164 +"pocs05_01D1_seas.co2", \
104.165 +"pocs10_01D1_seas.co2", \
104.166 +"pocs15_01D1_seas.co2", \
104.167 +"pocs20_01D1_seas.co2", \
104.168 +"pocs25_01D1_seas.co2", \
104.169 +"pocs30_01D1_seas.co2", \
104.170 +"pocs35_01D1_seas.co2", \
104.171 +"prs_21C0_seas.co2", \
104.172 +"prs_21D0_seas.co2", \
104.173 +"psa_01D0_seas.co2", \
104.174 +"psa_04D0_seas.co2", \
104.175 +"rpb_01D0_seas.co2", \
104.176 +"rta005_01D2_seas.co2", \
104.177 +"rta015_01D2_seas.co2", \
104.178 +"rta025_01D2_seas.co2", \
104.179 +"rta035_01D2_seas.co2", \
104.180 +"rta045_01D2_seas.co2", \
104.181 +"ryo_19C0_seas.co2", \
104.182 +"sbl_06C0_seas.co2", \
104.183 +"sbl_06D0_seas.co2", \
104.184 +"sch_23C0_seas.co2", \
104.185 +"scsn03_01D1_seas.co2", \
104.186 +"scsn06_01D1_seas.co2", \
104.187 +"scsn09_01D1_seas.co2", \
104.188 +"scsn12_01D1_seas.co2", \
104.189 +"scsn15_01D1_seas.co2", \
104.190 +"scsn18_01D1_seas.co2", \
104.191 +"scsn21_01D1_seas.co2", \
104.192 +"sey_01D0_seas.co2", \
104.193 +"shm_01D0_seas.co2", \
104.194 +"sis_02D0_seas.co2", \
104.195 +"smo_01C0_seas.co2", \
104.196 +"smo_01D0_seas.co2", \
104.197 +"smo_04D0_seas.co2", \
104.198 +"spo_01C0_seas.co2", \
104.199 +"spo_01D0_seas.co2", \
104.200 +"spo_02D0_seas.co2", \
104.201 +"spo_04D0_seas.co2", \
104.202 +"stm_01D0_seas.co2", \
104.203 +"stmebc_01D0_seas.co2", \
104.204 +"stp_12D0_seas.co2", \
104.205 +"sum_01D0_seas.co2", \
104.206 +"syo_01D0_seas.co2", \
104.207 +"syo_09C0_seas.co2", \
104.208 +"tap_01D0_seas.co2", \
104.209 +"tdf_01D0_seas.co2", \
104.210 +"trm_11D0_seas.co2", \
104.211 +"uta_01D0_seas.co2", \
104.212 +"uum_01D0_seas.co2", \
104.213 +"wes_23C0_seas.co2", \
104.214 +"wis_01D0_seas.co2", \
104.215 +"wkt009_01C3_seas.co2", \
104.216 +"wkt030_01C3_seas.co2", \
104.217 +"wkt061_01C3_seas.co2", \
104.218 +"wkt122_01C3_seas.co2", \
104.219 +"wkt244_01C3_seas.co2", \
104.220 +"wkt457_01C3_seas.co2", \
104.221 +"wlg_01D0_seas.co2", \
104.222 +"wlg_33C0_seas.co2", \
104.223 +"wpo000_10D2_seas.co2", \
104.224 +"wpon05_10D2_seas.co2", \
104.225 +"wpon10_10D2_seas.co2", \
104.226 +"wpon15_10D2_seas.co2", \
104.227 +"wpon20_10D2_seas.co2", \
104.228 +"wpon25_10D2_seas.co2", \
104.229 +"wpon30_10D2_seas.co2", \
104.230 +"wpos05_10D2_seas.co2", \
104.231 +"wpos10_10D2_seas.co2", \
104.232 +"wpos15_10D2_seas.co2", \
104.233 +"wpos20_10D2_seas.co2", \
104.234 +"wpos25_10D2_seas.co2", \
104.235 +"yon_19C0_seas.co2", \
104.236 +"zep_01D0_seas.co2", \
104.237 +"zep_31C0_seas.co2", \
104.238 +"zot005_45D2_seas.co2", \
104.239 +"zot015_45D2_seas.co2", \
104.240 +"zot025_45D2_seas.co2", \
104.241 +"zot035_45D2_seas.co2"/)
104.242 +
104.243 + ntime = 12
104.244 + ncase = dimsizes(b)
104.245 + print (ncase)
104.246 +
104.247 + mean = new((/ncase,ntime/),float)
104.248 + lat = new((/ncase/),float)
104.249 + lon = new((/ncase/),float)
104.250 + elev = new((/ncase/),float)
104.251 +
104.252 + do n = 0,dimsizes(b)-1
104.253 + fili = diri + b(n)
104.254 + print (fili)
104.255 +
104.256 + ncol1 = 4
104.257 + data1 = readAsciiTable(fili, ncol1, "float", (/10,17/))
104.258 +
104.259 + lat(n) = data1(0,0)
104.260 + lon(n) = data1(0,1)
104.261 + elev(n) = data1(0,2)
104.262 +
104.263 + ncol2 = 5
104.264 + data2 = readAsciiTable(fili, ncol2, "float", 16)
104.265 +
104.266 + mean(n,:) = data2(:,1)
104.267 + end do
104.268 +
104.269 + print (lat)
104.270 + print (mean)
104.271 +
104.272 +
104.273 +end
105.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
105.2 +++ b/co2/05.read_ascci_122.ncl Mon Jan 26 22:08:20 2009 -0500
105.3 @@ -0,0 +1,195 @@
105.4 +;************************************************
105.5 +; Read ascii, Write nc
105.6 +;************************************************
105.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
105.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
105.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
105.10 +;************************************************
105.11 +begin
105.12 +; final output
105.13 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
105.14 + filo = "co2_globalView_.nc"
105.15 + c = addfile(diro+filo,"c")
105.16 + filedimdef(c,"time",-1,True)
105.17 +
105.18 +; input ascii files
105.19 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/globalView-C4Mip/seas/"
105.20 + b = (/ \
105.21 +"aia005_02D2_seas.co2", \
105.22 +"alt_01D0_seas.co2", \
105.23 +"alt_06C0_seas.co2", \
105.24 +"alt_06D0_seas.co2", \
105.25 +"ams_01D0_seas.co2", \
105.26 +"ams_11C0_seas.co2", \
105.27 +"asc_01D0_seas.co2", \
105.28 +"ask_01D0_seas.co2", \
105.29 +"avi_01D0_seas.co2", \
105.30 +"azr_01D0_seas.co2", \
105.31 +"bal_01D1_seas.co2", \
105.32 +"bgu_11D0_seas.co2", \
105.33 +"bhd_15C0_seas.co2", \
105.34 +"bme_01D0_seas.co2", \
105.35 +"bmw_01D0_seas.co2", \
105.36 +"brw_01C0_seas.co2", \
105.37 +"brw_01D0_seas.co2", \
105.38 +"bsc_01D0_seas.co2", \
105.39 +"car030_01D2_seas.co2", \
105.40 +"cba_01D0_seas.co2", \
105.41 +"cba_04D0_seas.co2", \
105.42 +"cfa_02D0_seas.co2", \
105.43 +"cgo_01D0_seas.co2", \
105.44 +"chr_01D0_seas.co2", \
105.45 +"cmn_17C0_seas.co2", \
105.46 +"cmo_01D0_seas.co2", \
105.47 +"coi_20C0_seas.co2", \
105.48 +"cpt_36C0_seas.co2", \
105.49 +"cri_02D0_seas.co2", \
105.50 +"crz_01D0_seas.co2", \
105.51 +"csj_06D0_seas.co2", \
105.52 +"daa_02D0_seas.co2", \
105.53 +"eic_01D0_seas.co2", \
105.54 +"esp005_01D2_seas.co2", \
105.55 +"esp_02D0_seas.co2", \
105.56 +"frd040_06C3_seas.co2", \
105.57 +"gmi_01D0_seas.co2", \
105.58 +"goz_01D0_seas.co2", \
105.59 +"gsn_24D0_seas.co2", \
105.60 +"haa005_01D2_seas.co2", \
105.61 +"hat_20C0_seas.co2", \
105.62 +"hba_01D0_seas.co2", \
105.63 +"hfm005_01D2_seas.co2", \
105.64 +"hun010_35C3_seas.co2", \
105.65 +"hun_01D0_seas.co2", \
105.66 +"ice_01D0_seas.co2", \
105.67 +"itn051_01C3_seas.co2", \
105.68 +"itn123_01C3_seas.co2", \
105.69 +"itn496_01C3_seas.co2", \
105.70 +"itn_01D0_seas.co2", \
105.71 +"izo_01D0_seas.co2", \
105.72 +"izo_27C0_seas.co2", \
105.73 +"jbn_29C0_seas.co2", \
105.74 +"key_01D0_seas.co2", \
105.75 +"kum_01D0_seas.co2", \
105.76 +"kzd_01D0_seas.co2", \
105.77 +"kzm_01D0_seas.co2", \
105.78 +"lef011_01C3_seas.co2", \
105.79 +"lef_01D0_seas.co2", \
105.80 +"ljo_04D0_seas.co2", \
105.81 +"lmp_28D0_seas.co2", \
105.82 +"maa_02D0_seas.co2", \
105.83 +"mbc_01D0_seas.co2", \
105.84 +"mhd_01D0_seas.co2", \
105.85 +"mhdcbc_11C0_seas.co2", \
105.86 +"mhdrbc_11C0_seas.co2", \
105.87 +"mid_01D0_seas.co2", \
105.88 +"mlo_01C0_seas.co2", \
105.89 +"mlo_01D0_seas.co2", \
105.90 +"mnm_19C0_seas.co2", \
105.91 +"mqa_02D0_seas.co2", \
105.92 +"nwr_01D0_seas.co2", \
105.93 +"obs023_06C3_seas.co2", \
105.94 +"opw_01D0_seas.co2", \
105.95 +"orl005_11D2_seas.co2", \
105.96 +"palcbc_30C0_seas.co2", \
105.97 +"palmbc_30C0_seas.co2", \
105.98 +"pdm_11D0_seas.co2", \
105.99 +"pfa015_01D2_seas.co2", \
105.100 +"poc000_01D1_seas.co2", \
105.101 +"pocn05_01D1_seas.co2", \
105.102 +"pocs05_01D1_seas.co2", \
105.103 +"prs_21C0_seas.co2", \
105.104 +"prs_21D0_seas.co2", \
105.105 +"psa_01D0_seas.co2", \
105.106 +"rpb_01D0_seas.co2", \
105.107 +"rta005_01D2_seas.co2", \
105.108 +"ryo_19C0_seas.co2", \
105.109 +"sbl_06C0_seas.co2", \
105.110 +"sbl_06D0_seas.co2", \
105.111 +"sch_23C0_seas.co2", \
105.112 +"scsn03_01D1_seas.co2", \
105.113 +"sey_01D0_seas.co2", \
105.114 +"shm_01D0_seas.co2", \
105.115 +"sis_02D0_seas.co2", \
105.116 +"smo_01C0_seas.co2", \
105.117 +"smo_01D0_seas.co2", \
105.118 +"spo_01C0_seas.co2", \
105.119 +"spo_01D0_seas.co2", \
105.120 +"stm_01D0_seas.co2", \
105.121 +"stmebc_01D0_seas.co2", \
105.122 +"stp_12D0_seas.co2", \
105.123 +"sum_01D0_seas.co2", \
105.124 +"syo_01D0_seas.co2", \
105.125 +"syo_09C0_seas.co2", \
105.126 +"tap_01D0_seas.co2", \
105.127 +"tdf_01D0_seas.co2", \
105.128 +"trm_11D0_seas.co2", \
105.129 +"uta_01D0_seas.co2", \
105.130 +"uum_01D0_seas.co2", \
105.131 +"wes_23C0_seas.co2", \
105.132 +"wis_01D0_seas.co2", \
105.133 +"wkt009_01C3_seas.co2", \
105.134 +"wlg_01D0_seas.co2", \
105.135 +"wlg_33C0_seas.co2", \
105.136 +"wpo000_10D2_seas.co2", \
105.137 +"wpon05_10D2_seas.co2", \
105.138 +"wpos05_10D2_seas.co2", \
105.139 +"yon_19C0_seas.co2", \
105.140 +"zep_01D0_seas.co2", \
105.141 +"zep_31C0_seas.co2", \
105.142 +"zot005_45D2_seas.co2"/)
105.143 +
105.144 + ntime = 12
105.145 + ncase = dimsizes(b)
105.146 + print (ncase)
105.147 +
105.148 + mean = new((/ncase,ntime/),float)
105.149 + lat = new((/ncase/),float)
105.150 + lon = new((/ncase/),float)
105.151 + elev = new((/ncase/),float)
105.152 +
105.153 + do n = 0,dimsizes(b)-1
105.154 + fili = diri + b(n)
105.155 + print (fili)
105.156 +
105.157 + ncol1 = 4
105.158 + data1 = readAsciiTable(fili, ncol1, "float", (/10,17/))
105.159 +
105.160 + lat(n) = data1(0,0)
105.161 + lon(n) = data1(0,1)
105.162 + elev(n) = data1(0,2)
105.163 +
105.164 + ncol2 = 5
105.165 + data2 = readAsciiTable(fili, ncol2, "float", 16)
105.166 +
105.167 + mean(n,:) = data2(:,1)
105.168 + end do
105.169 +
105.170 +; mean!0 = "case"
105.171 +; mean!1 = "time"
105.172 +; mean&case= ispan(1,ncase,1)
105.173 +; mean&time= ispan(1,ntime,1)
105.174 + mean@units = "u mol/mol"
105.175 + mean@long_name = "CO2 GlobalView seasonal"
105.176 +
105.177 +; lat!0 = "case"
105.178 +; lon!0 = "case"
105.179 +; elev!0 = "case"
105.180 +; lat&case = mean&case
105.181 +; lon&case = mean&case
105.182 +; elev&case = mean&case
105.183 +
105.184 + lat@units = "degrees_north"
105.185 + lat@long_name = "Latitude"
105.186 + lon@units = "degrees_ease"
105.187 + lon@long_name = "Longitude"
105.188 + elev@units = "m"
105.189 + elev@long_name = "Elevation above sea level"
105.190 +
105.191 + print (lat)
105.192 + print (mean)
105.193 +
105.194 + c->LAT = lat
105.195 + c->LON = lon
105.196 + c->ELEV = elev
105.197 + c->CO2_SEAS = mean
105.198 +end
106.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
106.2 +++ b/co2/05.read_ascci_222.ncl Mon Jan 26 22:08:20 2009 -0500
106.3 @@ -0,0 +1,295 @@
106.4 +;************************************************
106.5 +; Read ascii, Write nc
106.6 +;************************************************
106.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
106.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
106.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
106.10 +;************************************************
106.11 +begin
106.12 +; final output
106.13 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
106.14 + filo = "co2_globalView_222.nc"
106.15 + c = addfile(diro+filo,"c")
106.16 + filedimdef(c,"time",-1,True)
106.17 +
106.18 +; input ascii files
106.19 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/globalView-C4Mip/seas/"
106.20 + b = (/ \
106.21 +"aia005_02D2_seas.co2", \
106.22 +"aia015_02D2_seas.co2", \
106.23 +"aia025_02D2_seas.co2", \
106.24 +"aia035_02D2_seas.co2", \
106.25 +"aia045_02D2_seas.co2", \
106.26 +"aia055_02D2_seas.co2", \
106.27 +"aia065_02D2_seas.co2", \
106.28 +"alt_01D0_seas.co2", \
106.29 +"alt_02D0_seas.co2", \
106.30 +"alt_04D0_seas.co2", \
106.31 +"alt_06C0_seas.co2", \
106.32 +"alt_06D0_seas.co2", \
106.33 +"ams_01D0_seas.co2", \
106.34 +"ams_11C0_seas.co2", \
106.35 +"asc_01D0_seas.co2", \
106.36 +"ask_01D0_seas.co2", \
106.37 +"avi_01D0_seas.co2", \
106.38 +"azr_01D0_seas.co2", \
106.39 +"bal_01D1_seas.co2", \
106.40 +"bgu_11D0_seas.co2", \
106.41 +"bhd_15C0_seas.co2", \
106.42 +"bme_01D0_seas.co2", \
106.43 +"bmw_01D0_seas.co2", \
106.44 +"brw_01C0_seas.co2", \
106.45 +"brw_01D0_seas.co2", \
106.46 +"bsc_01D0_seas.co2", \
106.47 +"car030_01D2_seas.co2", \
106.48 +"car040_01D2_seas.co2", \
106.49 +"car050_01D2_seas.co2", \
106.50 +"car060_01D2_seas.co2", \
106.51 +"car070_01D2_seas.co2", \
106.52 +"car080_01D2_seas.co2", \
106.53 +"cba_01D0_seas.co2", \
106.54 +"cba_04D0_seas.co2", \
106.55 +"cfa_02D0_seas.co2", \
106.56 +"cgo_01D0_seas.co2", \
106.57 +"cgo_02D0_seas.co2", \
106.58 +"cgo_04D0_seas.co2", \
106.59 +"chr_01D0_seas.co2", \
106.60 +"cmn_17C0_seas.co2", \
106.61 +"cmo_01D0_seas.co2", \
106.62 +"coi_20C0_seas.co2", \
106.63 +"cpt_36C0_seas.co2", \
106.64 +"cri_02D0_seas.co2", \
106.65 +"crz_01D0_seas.co2", \
106.66 +"csj_06D0_seas.co2", \
106.67 +"daa_02D0_seas.co2", \
106.68 +"eic_01D0_seas.co2", \
106.69 +"esp005_01D2_seas.co2", \
106.70 +"esp015_01D2_seas.co2", \
106.71 +"esp025_01D2_seas.co2", \
106.72 +"esp035_01D2_seas.co2", \
106.73 +"esp045_01D2_seas.co2", \
106.74 +"esp055_01D2_seas.co2", \
106.75 +"esp_02D0_seas.co2", \
106.76 +"esp_06D0_seas.co2", \
106.77 +"frd040_06C3_seas.co2", \
106.78 +"gmi_01D0_seas.co2", \
106.79 +"goz_01D0_seas.co2", \
106.80 +"gsn_24D0_seas.co2", \
106.81 +"haa005_01D2_seas.co2", \
106.82 +"haa015_01D2_seas.co2", \
106.83 +"haa025_01D2_seas.co2", \
106.84 +"haa035_01D2_seas.co2", \
106.85 +"haa045_01D2_seas.co2", \
106.86 +"haa055_01D2_seas.co2", \
106.87 +"haa065_01D2_seas.co2", \
106.88 +"haa075_01D2_seas.co2", \
106.89 +"hat_20C0_seas.co2", \
106.90 +"hba_01D0_seas.co2", \
106.91 +"hfm005_01D2_seas.co2", \
106.92 +"hfm015_01D2_seas.co2", \
106.93 +"hfm025_01D2_seas.co2", \
106.94 +"hfm035_01D2_seas.co2", \
106.95 +"hfm045_01D2_seas.co2", \
106.96 +"hfm055_01D2_seas.co2", \
106.97 +"hfm065_01D2_seas.co2", \
106.98 +"hfm075_01D2_seas.co2", \
106.99 +"hun010_35C3_seas.co2", \
106.100 +"hun048_35C3_seas.co2", \
106.101 +"hun082_35C3_seas.co2", \
106.102 +"hun115_35C3_seas.co2", \
106.103 +"hun_01D0_seas.co2", \
106.104 +"ice_01D0_seas.co2", \
106.105 +"itn051_01C3_seas.co2", \
106.106 +"itn123_01C3_seas.co2", \
106.107 +"itn496_01C3_seas.co2", \
106.108 +"itn_01D0_seas.co2", \
106.109 +"izo_01D0_seas.co2", \
106.110 +"izo_27C0_seas.co2", \
106.111 +"jbn_29C0_seas.co2", \
106.112 +"key_01D0_seas.co2", \
106.113 +"kum_01D0_seas.co2", \
106.114 +"kum_04D0_seas.co2", \
106.115 +"kzd_01D0_seas.co2", \
106.116 +"kzm_01D0_seas.co2", \
106.117 +"lef011_01C3_seas.co2", \
106.118 +"lef030_01C3_seas.co2", \
106.119 +"lef076_01C3_seas.co2", \
106.120 +"lef122_01C3_seas.co2", \
106.121 +"lef244_01C3_seas.co2", \
106.122 +"lef396_01C3_seas.co2", \
106.123 +"lef_01D0_seas.co2", \
106.124 +"ljo_04D0_seas.co2", \
106.125 +"lmp_28D0_seas.co2", \
106.126 +"maa_02D0_seas.co2", \
106.127 +"mbc_01D0_seas.co2", \
106.128 +"mhd_01D0_seas.co2", \
106.129 +"mhdcbc_11C0_seas.co2", \
106.130 +"mhdrbc_11C0_seas.co2", \
106.131 +"mid_01D0_seas.co2", \
106.132 +"mlo_01C0_seas.co2", \
106.133 +"mlo_01D0_seas.co2", \
106.134 +"mlo_02D0_seas.co2", \
106.135 +"mlo_04D0_seas.co2", \
106.136 +"mnm_19C0_seas.co2", \
106.137 +"mqa_02D0_seas.co2", \
106.138 +"nwr_01D0_seas.co2", \
106.139 +"obs023_06C3_seas.co2", \
106.140 +"opw_01D0_seas.co2", \
106.141 +"orl005_11D2_seas.co2", \
106.142 +"orl015_11D2_seas.co2", \
106.143 +"orl025_11D2_seas.co2", \
106.144 +"orl035_11D2_seas.co2", \
106.145 +"palcbc_30C0_seas.co2", \
106.146 +"palmbc_30C0_seas.co2", \
106.147 +"pdm_11D0_seas.co2", \
106.148 +"pfa015_01D2_seas.co2", \
106.149 +"pfa025_01D2_seas.co2", \
106.150 +"pfa035_01D2_seas.co2", \
106.151 +"pfa045_01D2_seas.co2", \
106.152 +"pfa055_01D2_seas.co2", \
106.153 +"pfa065_01D2_seas.co2", \
106.154 +"pfa075_01D2_seas.co2", \
106.155 +"poc000_01D1_seas.co2", \
106.156 +"pocn05_01D1_seas.co2", \
106.157 +"pocn10_01D1_seas.co2", \
106.158 +"pocn15_01D1_seas.co2", \
106.159 +"pocn20_01D1_seas.co2", \
106.160 +"pocn25_01D1_seas.co2", \
106.161 +"pocn30_01D1_seas.co2", \
106.162 +"pocn35_01D1_seas.co2", \
106.163 +"pocn40_01D1_seas.co2", \
106.164 +"pocn45_01D1_seas.co2", \
106.165 +"pocs05_01D1_seas.co2", \
106.166 +"pocs10_01D1_seas.co2", \
106.167 +"pocs15_01D1_seas.co2", \
106.168 +"pocs20_01D1_seas.co2", \
106.169 +"pocs25_01D1_seas.co2", \
106.170 +"pocs30_01D1_seas.co2", \
106.171 +"pocs35_01D1_seas.co2", \
106.172 +"prs_21C0_seas.co2", \
106.173 +"prs_21D0_seas.co2", \
106.174 +"psa_01D0_seas.co2", \
106.175 +"psa_04D0_seas.co2", \
106.176 +"rpb_01D0_seas.co2", \
106.177 +"rta005_01D2_seas.co2", \
106.178 +"rta015_01D2_seas.co2", \
106.179 +"rta025_01D2_seas.co2", \
106.180 +"rta035_01D2_seas.co2", \
106.181 +"rta045_01D2_seas.co2", \
106.182 +"ryo_19C0_seas.co2", \
106.183 +"sbl_06C0_seas.co2", \
106.184 +"sbl_06D0_seas.co2", \
106.185 +"sch_23C0_seas.co2", \
106.186 +"scsn03_01D1_seas.co2", \
106.187 +"scsn06_01D1_seas.co2", \
106.188 +"scsn09_01D1_seas.co2", \
106.189 +"scsn12_01D1_seas.co2", \
106.190 +"scsn15_01D1_seas.co2", \
106.191 +"scsn18_01D1_seas.co2", \
106.192 +"scsn21_01D1_seas.co2", \
106.193 +"sey_01D0_seas.co2", \
106.194 +"shm_01D0_seas.co2", \
106.195 +"sis_02D0_seas.co2", \
106.196 +"smo_01C0_seas.co2", \
106.197 +"smo_01D0_seas.co2", \
106.198 +"smo_04D0_seas.co2", \
106.199 +"spo_01C0_seas.co2", \
106.200 +"spo_01D0_seas.co2", \
106.201 +"spo_02D0_seas.co2", \
106.202 +"spo_04D0_seas.co2", \
106.203 +"stm_01D0_seas.co2", \
106.204 +"stmebc_01D0_seas.co2", \
106.205 +"stp_12D0_seas.co2", \
106.206 +"sum_01D0_seas.co2", \
106.207 +"syo_01D0_seas.co2", \
106.208 +"syo_09C0_seas.co2", \
106.209 +"tap_01D0_seas.co2", \
106.210 +"tdf_01D0_seas.co2", \
106.211 +"trm_11D0_seas.co2", \
106.212 +"uta_01D0_seas.co2", \
106.213 +"uum_01D0_seas.co2", \
106.214 +"wes_23C0_seas.co2", \
106.215 +"wis_01D0_seas.co2", \
106.216 +"wkt009_01C3_seas.co2", \
106.217 +"wkt030_01C3_seas.co2", \
106.218 +"wkt061_01C3_seas.co2", \
106.219 +"wkt122_01C3_seas.co2", \
106.220 +"wkt244_01C3_seas.co2", \
106.221 +"wkt457_01C3_seas.co2", \
106.222 +"wlg_01D0_seas.co2", \
106.223 +"wlg_33C0_seas.co2", \
106.224 +"wpo000_10D2_seas.co2", \
106.225 +"wpon05_10D2_seas.co2", \
106.226 +"wpon10_10D2_seas.co2", \
106.227 +"wpon15_10D2_seas.co2", \
106.228 +"wpon20_10D2_seas.co2", \
106.229 +"wpon25_10D2_seas.co2", \
106.230 +"wpon30_10D2_seas.co2", \
106.231 +"wpos05_10D2_seas.co2", \
106.232 +"wpos10_10D2_seas.co2", \
106.233 +"wpos15_10D2_seas.co2", \
106.234 +"wpos20_10D2_seas.co2", \
106.235 +"wpos25_10D2_seas.co2", \
106.236 +"yon_19C0_seas.co2", \
106.237 +"zep_01D0_seas.co2", \
106.238 +"zep_31C0_seas.co2", \
106.239 +"zot005_45D2_seas.co2", \
106.240 +"zot015_45D2_seas.co2", \
106.241 +"zot025_45D2_seas.co2", \
106.242 +"zot035_45D2_seas.co2"/)
106.243 +
106.244 + ntime = 12
106.245 + ncase = dimsizes(b)
106.246 + print (ncase)
106.247 +
106.248 + mean = new((/ncase,ntime/),float)
106.249 + lat = new((/ncase/),float)
106.250 + lon = new((/ncase/),float)
106.251 + elev = new((/ncase/),float)
106.252 +
106.253 + do n = 0,dimsizes(b)-1
106.254 + fili = diri + b(n)
106.255 + print (fili)
106.256 +
106.257 + ncol1 = 4
106.258 + data1 = readAsciiTable(fili, ncol1, "float", (/10,17/))
106.259 +
106.260 + lat(n) = data1(0,0)
106.261 + lon(n) = data1(0,1)
106.262 + elev(n) = data1(0,2)
106.263 +
106.264 + ncol2 = 5
106.265 + data2 = readAsciiTable(fili, ncol2, "float", 16)
106.266 +
106.267 + mean(n,:) = data2(:,1)
106.268 + end do
106.269 +
106.270 +; mean!0 = "case"
106.271 +; mean!1 = "time"
106.272 +; mean&case= ispan(1,ncase,1)
106.273 +; mean&time= ispan(1,ntime,1)
106.274 + mean@units = "u mol/mol"
106.275 + mean@long_name = "CO2 GlobalView seasonal"
106.276 +
106.277 +; lat!0 = "case"
106.278 +; lon!0 = "case"
106.279 +; elev!0 = "case"
106.280 +; lat&case = mean&case
106.281 +; lon&case = mean&case
106.282 +; elev&case = mean&case
106.283 +
106.284 + lat@units = "degrees_north"
106.285 + lat@long_name = "Latitude"
106.286 + lon@units = "degrees_ease"
106.287 + lon@long_name = "Longitude"
106.288 + elev@units = "m"
106.289 + elev@long_name = "Elevation above sea level"
106.290 +
106.291 + print (lat)
106.292 + print (mean)
106.293 +
106.294 + c->LAT = lat
106.295 + c->LON = lon
106.296 + c->ELEV = elev
106.297 + c->CO2_SEAS = mean
106.298 +end
107.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
107.2 +++ b/co2/06.read_ascci_98.ncl Mon Jan 26 22:08:20 2009 -0500
107.3 @@ -0,0 +1,175 @@
107.4 +;************************************************
107.5 +; Read ascii, Write nc
107.6 +;************************************************
107.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
107.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
107.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
107.10 +;************************************************
107.11 +begin
107.12 +; final output
107.13 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
107.14 + filo = "co2_globalView_98.nc"
107.15 + c = addfile(diro+filo,"c")
107.16 + filedimdef(c,"time",-1,True)
107.17 +
107.18 +; input ascii files
107.19 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/globalView-C4Mip/seas/"
107.20 + b = (/ \
107.21 +"aia005_02D2", \
107.22 +"alt_01D0", \
107.23 +"ams_01D0", \
107.24 +"asc_01D0", \
107.25 +"ask_01D0", \
107.26 +"avi_01D0", \
107.27 +"azr_01D0", \
107.28 +"bal_01D1", \
107.29 +"bgu_11D0", \
107.30 +"bhd_15C0", \
107.31 +"bme_01D0", \
107.32 +"bmw_01D0", \
107.33 +"brw_01C0", \
107.34 +"bsc_01D0", \
107.35 +"car030_01D2", \
107.36 +"cba_01D0", \
107.37 +"cfa_02D0", \
107.38 +"cgo_01D0", \
107.39 +"chr_01D0", \
107.40 +"cmn_17C0", \
107.41 +"cmo_01D0", \
107.42 +"coi_20C0", \
107.43 +"cpt_36C0", \
107.44 +"cri_02D0", \
107.45 +"crz_01D0", \
107.46 +"csj_06D0", \
107.47 +"daa_02D0", \
107.48 +"eic_01D0", \
107.49 +"esp_02D0", \
107.50 +"frd040_06C3", \
107.51 +"gmi_01D0", \
107.52 +"goz_01D0", \
107.53 +"gsn_24D0", \
107.54 +"haa005_01D2", \
107.55 +"hat_20C0", \
107.56 +"hba_01D0", \
107.57 +"hfm005_01D2", \
107.58 +"hun010_35C3", \
107.59 +"ice_01D0", \
107.60 +"itn051_01C3", \
107.61 +"izo_01D0", \
107.62 +"jbn_29C0", \
107.63 +"key_01D0", \
107.64 +"kum_01D0", \
107.65 +"kzd_01D0", \
107.66 +"kzm_01D0", \
107.67 +"lef011_01C3", \
107.68 +"ljo_04D0", \
107.69 +"lmp_28D0", \
107.70 +"maa_02D0", \
107.71 +"mbc_01D0", \
107.72 +"mhd_01D0", \
107.73 +"mid_01D0", \
107.74 +"mlo_01C0", \
107.75 +"mnm_19C0", \
107.76 +"mqa_02D0", \
107.77 +"nwr_01D0", \
107.78 +"obs023_06C3", \
107.79 +"opw_01D0", \
107.80 +"orl005_11D2", \
107.81 +"palcbc_30C0", \
107.82 +"pdm_11D0", \
107.83 +"pfa015_01D2", \
107.84 +"poc000_01D1", \
107.85 +"pocn05_01D1", \
107.86 +"pocs05_01D1", \
107.87 +"prs_21C0", \
107.88 +"psa_01D0", \
107.89 +"rpb_01D0", \
107.90 +"rta005_01D2", \
107.91 +"ryo_19C0", \
107.92 +"sbl_06C0", \
107.93 +"sch_23C0", \
107.94 +"scsn03_01D1", \
107.95 +"sey_01D0", \
107.96 +"shm_01D0", \
107.97 +"sis_02D0", \
107.98 +"smo_01C0", \
107.99 +"spo_01C0", \
107.100 +"stm_01D0", \
107.101 +"stp_12D0", \
107.102 +"sum_01D0", \
107.103 +"syo_01D0", \
107.104 +"tap_01D0", \
107.105 +"tdf_01D0", \
107.106 +"trm_11D0", \
107.107 +"uta_01D0", \
107.108 +"uum_01D0", \
107.109 +"wes_23C0", \
107.110 +"wis_01D0", \
107.111 +"wkt009_01C3", \
107.112 +"wlg_01D0", \
107.113 +"wpo000_10D2", \
107.114 +"wpon05_10D2", \
107.115 +"wpos05_10D2", \
107.116 +"yon_19C0", \
107.117 +"zep_01D0", \
107.118 +"zot005_45D2"/)
107.119 +
107.120 + ntime = 12
107.121 + ncase = dimsizes(b)
107.122 + print (ncase)
107.123 +
107.124 + mean = new((/ncase,ntime/),float)
107.125 + lat = new((/ncase/),float)
107.126 + lon = new((/ncase/),float)
107.127 + elev = new((/ncase/),float)
107.128 +
107.129 + do n = 0,dimsizes(b)-1
107.130 + fili = diri + b(n) + "_seas.co2"
107.131 + print (fili)
107.132 +
107.133 + ncol1 = 4
107.134 + data1 = readAsciiTable(fili, ncol1, "float", (/10,17/))
107.135 +
107.136 + lat(n) = data1(0,0)
107.137 + lon(n) = data1(0,1)
107.138 + elev(n) = data1(0,2)
107.139 +
107.140 + ncol2 = 5
107.141 + data2 = readAsciiTable(fili, ncol2, "float", 16)
107.142 +
107.143 + mean(n,:) = data2(:,1)
107.144 + end do
107.145 +
107.146 +; mean!0 = "case"
107.147 +; mean!1 = "time"
107.148 +; mean&case= ispan(1,ncase,1)
107.149 +; mean&time= ispan(1,ntime,1)
107.150 + mean@units = "u mol/mol"
107.151 + mean@long_name = "CO2 GlobalView seasonal"
107.152 +
107.153 +; lat!0 = "case"
107.154 +; lon!0 = "case"
107.155 +; elev!0 = "case"
107.156 +; lat&case = mean&case
107.157 +; lon&case = mean&case
107.158 +; elev&case = mean&case
107.159 +
107.160 + lat@units = "degrees_north"
107.161 + lat@long_name = "Latitude"
107.162 + lon@units = "degrees_ease"
107.163 + lon@long_name = "Longitude"
107.164 + elev@units = "m"
107.165 + elev@long_name = "Elevation above sea level"
107.166 + b@units = ""
107.167 + b@long_name = "Station"
107.168 +
107.169 + print (lat)
107.170 + print (mean)
107.171 + print (b)
107.172 +
107.173 + c->LAT = lat
107.174 + c->LON = lon
107.175 + c->ELEV = elev
107.176 + c->CO2_SEAS = mean
107.177 + c->STATION = stringtochar(b)
107.178 +end
108.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
108.2 +++ b/co2/11.test.ncl Mon Jan 26 22:08:20 2009 -0500
108.3 @@ -0,0 +1,44 @@
108.4 +; ***********************************************
108.5 +; xy_4.ncl
108.6 +; ***********************************************
108.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
108.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
108.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
108.10 +;************************************************
108.11 +begin
108.12 +;************************************************
108.13 +; read in data: observed
108.14 +;************************************************
108.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
108.16 + fili = "co2_globalView_222.nc"
108.17 + g = addfile (diri+fili,"r")
108.18 + a = g->CO2_SEAS
108.19 + lon = g->LON
108.20 + lat = g->LAT
108.21 +
108.22 + ncase = dimsizes(lat)
108.23 + print (ncase)
108.24 +
108.25 + lat_tmp = lat
108.26 + lat_tmp@_FillValue = 1.e+36
108.27 +
108.28 + do n = 0,ncase-1
108.29 + if (.not. ismissing(lat_tmp(n))) then
108.30 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
108.31 + if (dimsizes(indexes) .gt. 1) then
108.32 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
108.33 + end if
108.34 + delete (indexes)
108.35 + end if
108.36 + end do
108.37 +
108.38 + indexes = ind(.not. ismissing(lat_tmp))
108.39 + print (indexes)
108.40 +
108.41 + lat_new = lat(indexes)
108.42 + lon_new = lon(indexes)
108.43 + print (lat_new +"/"+lon_new)
108.44 +
108.45 +exit
108.46 +
108.47 +end
109.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
109.2 +++ b/co2/12.test.ncl Mon Jan 26 22:08:20 2009 -0500
109.3 @@ -0,0 +1,104 @@
109.4 +; ***********************************************
109.5 +; xy_4.ncl
109.6 +; ***********************************************
109.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
109.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
109.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
109.10 +;************************************************
109.11 +begin
109.12 +;************************************************
109.13 +; read in data: observed
109.14 +;************************************************
109.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
109.16 + fili = "co2_globalView_222.nc"
109.17 + g = addfile (diri+fili,"r")
109.18 + val = g->CO2_SEAS
109.19 + lon = g->LON
109.20 + lat = g->LAT
109.21 + delete (g)
109.22 +
109.23 + ncase = dimsizes(lat)
109.24 +;print (ncase)
109.25 +
109.26 +;**************************************************************
109.27 +; get only the lowest level at each station
109.28 +;**************************************************************
109.29 + lat_tmp = lat
109.30 + lat_tmp@_FillValue = 1.e+36
109.31 +
109.32 + do n = 0,ncase-1
109.33 + if (.not. ismissing(lat_tmp(n))) then
109.34 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
109.35 + if (dimsizes(indexes) .gt. 1) then
109.36 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
109.37 + end if
109.38 + delete (indexes)
109.39 + end if
109.40 + end do
109.41 +
109.42 + indexes = ind(.not. ismissing(lat_tmp))
109.43 +;print (indexes)
109.44 +
109.45 + lat_ob = lat(indexes)
109.46 + lon_ob = lon(indexes)
109.47 + val_ob = val(indexes,:)
109.48 +;printVarSummary (val_ob)
109.49 +;print (lat_ob +"/"+lon_ob)
109.50 +
109.51 +;************************************************
109.52 +; read in model data
109.53 +;************************************************
109.54 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
109.55 + fili2 = "b30.061m_401_425_MONS_climo.nc"
109.56 +
109.57 + g = addfile(diri2+fili2,"r")
109.58 + x = g->CO2
109.59 + xi = g->lon
109.60 + yi = g->lat
109.61 + xdim = dimsizes(x)
109.62 + nlev = xdim(1)
109.63 + y = x(:,0,:,:)
109.64 +; printVarSummary (y)
109.65 +
109.66 +; get the co2 at the lowest level
109.67 + y = x(:,nlev-1,:,:)
109.68 +
109.69 +; change to unit of observed (u mol/mol)
109.70 +; Model_units [=] kgCO2 / kgDryAir
109.71 +; 28.966 = molecular weight of dry air
109.72 +; 44. = molecular weight of CO2
109.73 +; u mol = 1e-6 mol
109.74 +
109.75 + factor = (28.966/44.) * 1e6
109.76 + y = y * factor
109.77 +
109.78 + y@_FillValue = 1.e36
109.79 + y@units = "u mol/mol"
109.80 +; y = where(y0 .lt. 287.,y@_FillValue,y)
109.81 +; printVarSummary (y)
109.82 +; print (min(y)+"/"+max(y))
109.83 +
109.84 +; interpolate into observed station
109.85 +
109.86 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
109.87 +
109.88 + val_model = val_ob
109.89 + val_model = yo(pts|:,time|:)
109.90 + printVarSummary (val_model)
109.91 + print (min(val_model)+"/"+max(val_model))
109.92 +
109.93 +; remove annual mean
109.94 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
109.95 + print (min(val_model)+"/"+max(val_model))
109.96 +exit
109.97 +;**************************************************************
109.98 +; get stations of 60N-90N
109.99 +;**************************************************************
109.100 +
109.101 + ind_1 = ind(lat_new .gt. 60.)
109.102 + print (ind_1)
109.103 + print (lat_new(ind_1)+"/"+lon_new(ind_1))
109.104 + print (val_new(ind_1(0),:))
109.105 +exit
109.106 +
109.107 +end
110.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
110.2 +++ b/co2/13.metric.ncl Mon Jan 26 22:08:20 2009 -0500
110.3 @@ -0,0 +1,191 @@
110.4 +; ***********************************************
110.5 +; xy_4.ncl
110.6 +; ***********************************************
110.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
110.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
110.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
110.10 +;************************************************
110.11 +begin
110.12 +;************************************************
110.13 +; read in data: observed
110.14 +;************************************************
110.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
110.16 + fili = "co2_globalView_222.nc"
110.17 + g = addfile (diri+fili,"r")
110.18 + val = g->CO2_SEAS
110.19 + lon = g->LON
110.20 + lat = g->LAT
110.21 + delete (g)
110.22 +
110.23 + ncase = dimsizes(lat)
110.24 +;print (ncase)
110.25 +
110.26 +;**************************************************************
110.27 +; get only the lowest level at each station
110.28 +;**************************************************************
110.29 + lat_tmp = lat
110.30 + lat_tmp@_FillValue = 1.e+36
110.31 +
110.32 + do n = 0,ncase-1
110.33 + if (.not. ismissing(lat_tmp(n))) then
110.34 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
110.35 + if (dimsizes(indexes) .gt. 1) then
110.36 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
110.37 + end if
110.38 + delete (indexes)
110.39 + end if
110.40 + end do
110.41 +
110.42 + indexes = ind(.not. ismissing(lat_tmp))
110.43 +;print (indexes)
110.44 +
110.45 + lat_ob = lat(indexes)
110.46 + lon_ob = lon(indexes)
110.47 + val_ob = val(indexes,:)
110.48 +;printVarSummary (val_ob)
110.49 +;print (lat_ob +"/"+lon_ob)
110.50 +
110.51 +;************************************************
110.52 +; read in model data
110.53 +;************************************************
110.54 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
110.55 + fili2 = "b30.061m_401_425_MONS_climo.nc"
110.56 +
110.57 + g = addfile(diri2+fili2,"r")
110.58 + x = g->CO2
110.59 + xi = g->lon
110.60 + yi = g->lat
110.61 + xdim = dimsizes(x)
110.62 + nlev = xdim(1)
110.63 + y = x(:,0,:,:)
110.64 +; printVarSummary (y)
110.65 +
110.66 +; get the co2 at the lowest level
110.67 + y = x(:,nlev-1,:,:)
110.68 +
110.69 +; change to unit of observed (u mol/mol)
110.70 +; Model_units [=] kgCO2 / kgDryAir
110.71 +; 28.966 = molecular weight of dry air
110.72 +; 44. = molecular weight of CO2
110.73 +; u mol = 1e-6 mol
110.74 +
110.75 + factor = (28.966/44.) * 1e6
110.76 + y = y * factor
110.77 +
110.78 + y@_FillValue = 1.e36
110.79 + y@units = "u mol/mol"
110.80 +; y = where(y0 .lt. 287.,y@_FillValue,y)
110.81 +; printVarSummary (y)
110.82 +; print (min(y)+"/"+max(y))
110.83 +
110.84 +; interpolate into observed station
110.85 +; note: model is 0-360E, 90S-90N
110.86 +
110.87 + i = ind(lon_ob .lt. 0.)
110.88 + lon_ob(i) = lon_ob(i) + 360.
110.89 +
110.90 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
110.91 +
110.92 + val_model = val_ob
110.93 + val_model = yo(pts|:,time|:)
110.94 +; printVarSummary (val_model)
110.95 +; print (min(val_model)+"/"+max(val_model))
110.96 +
110.97 +; remove annual mean
110.98 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
110.99 +; print (min(val_model)+"/"+max(val_model))
110.100 +
110.101 + nzone = 4
110.102 + do z = 0,nzone-1
110.103 +
110.104 + if (z .eq. 0) then
110.105 +; maximum score for the zone, 60N-90N
110.106 + score_max = 5.0
110.107 +; index of stations in this zone
110.108 + ind_z = ind(lat_ob .ge. 60.)
110.109 +; print (ind_z)
110.110 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
110.111 +; print (val_ob(ind_z,:))
110.112 +; print (val_model(ind_z,:))
110.113 + end if
110.114 +
110.115 + if (z .eq. 1) then
110.116 +; maximum score for the zone, 30N-60N
110.117 + score_max = 5.0
110.118 +; index of stations in this zone
110.119 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
110.120 +; print (ind_z)
110.121 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
110.122 +; print (val_ob(ind_z,:))
110.123 +; print (val_model(ind_z,:))
110.124 + end if
110.125 +
110.126 + if (z .eq. 2) then
110.127 +; maximum score for the zone, EQ-30N
110.128 + score_max = 5.0
110.129 +; index of stations in this zone
110.130 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
110.131 +; print (ind_z)
110.132 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
110.133 +; print (val_ob(ind_z,:))
110.134 +; print (val_model(ind_z,:))
110.135 + end if
110.136 +
110.137 + if (z .eq. 3) then
110.138 +; maximum score for the zone, 90S-EQ
110.139 + score_max = 5.0
110.140 +; index of stations in this zone
110.141 + ind_z = ind(lat_ob .lt. 0. )
110.142 +; print (ind_z)
110.143 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
110.144 +; print (val_ob(ind_z,:))
110.145 +; print (val_model(ind_z,:))
110.146 + end if
110.147 +
110.148 + u = ndtooned(val_ob(ind_z,:))
110.149 + v = ndtooned(val_model(ind_z,:))
110.150 +
110.151 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
110.152 +
110.153 + uu = u(good)
110.154 + vv = v(good)
110.155 +
110.156 + npts = dimsizes(uu)/12
110.157 + print (npts)
110.158 +
110.159 + ccr = esccr(uu,vv,0)
110.160 + print (ccr)
110.161 +
110.162 + un = onedtond(uu,(/npts,12/))
110.163 + vn = onedtond(vv,(/npts,12/))
110.164 +;print (un)
110.165 +;print (vn)
110.166 +
110.167 + score = new((/npts/),float)
110.168 +
110.169 + do n=0,npts-1
110.170 + amp_ob = max(un(n,:)) - min(un(n,:))
110.171 + amp_model = max(vn(n,:)) - min(vn(n,:))
110.172 + score(n) = 1.-abs((amp_model/amp_ob)-1.)
110.173 +; print (amp_ob)
110.174 +; print (amp_model)
110.175 + end do
110.176 +;print (score)
110.177 +
110.178 + M = avg(score)
110.179 + print (M)
110.180 +
110.181 + M_total = (ccr*ccr + M)*0.5 * score_max
110.182 + print (M_total)
110.183 +
110.184 + delete (ind_z)
110.185 + delete (good)
110.186 + delete (u)
110.187 + delete (v)
110.188 + delete (uu)
110.189 + delete (vv)
110.190 + delete (un)
110.191 + delete (vn)
110.192 + delete (score)
110.193 + end do
110.194 +end
111.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
111.2 +++ b/co2/14.metric.ncl Mon Jan 26 22:08:20 2009 -0500
111.3 @@ -0,0 +1,197 @@
111.4 +; ***********************************************
111.5 +; xy_4.ncl
111.6 +; ***********************************************
111.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
111.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
111.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
111.10 +;************************************************
111.11 +begin
111.12 +;************************************************
111.13 +; read in data: observed
111.14 +;************************************************
111.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
111.16 + fili = "co2_globalView_98.nc"
111.17 + g = addfile (diri+fili,"r")
111.18 + val = g->CO2_SEAS
111.19 + lon = g->LON
111.20 + lat = g->LAT
111.21 + sta = chartostring(g->STATION)
111.22 + delete (g)
111.23 +
111.24 +;print (sta(0))
111.25 +
111.26 + ncase = dimsizes(lat)
111.27 +;print (ncase)
111.28 +
111.29 +;**************************************************************
111.30 +; get only the lowest level at each station
111.31 +;**************************************************************
111.32 + lat_tmp = lat
111.33 + lat_tmp@_FillValue = 1.e+36
111.34 +
111.35 + do n = 0,ncase-1
111.36 + if (.not. ismissing(lat_tmp(n))) then
111.37 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
111.38 + if (dimsizes(indexes) .gt. 1) then
111.39 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
111.40 + end if
111.41 + delete (indexes)
111.42 + end if
111.43 + end do
111.44 +
111.45 + indexes = ind(.not. ismissing(lat_tmp))
111.46 +;print (dimsizes(indexes))
111.47 +;print (indexes)
111.48 +
111.49 + lat_ob = lat(indexes)
111.50 + lon_ob = lon(indexes)
111.51 + val_ob = val(indexes,:)
111.52 +;printVarSummary (val_ob)
111.53 +;print (lat_ob +"/"+lon_ob)
111.54 +
111.55 +;************************************************
111.56 +; read in model data
111.57 +;************************************************
111.58 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
111.59 + fili2 = "b30.061m_401_425_MONS_climo.nc"
111.60 +
111.61 + g = addfile(diri2+fili2,"r")
111.62 + x = g->CO2
111.63 + xi = g->lon
111.64 + yi = g->lat
111.65 + xdim = dimsizes(x)
111.66 + nlev = xdim(1)
111.67 + y = x(:,0,:,:)
111.68 +; printVarSummary (y)
111.69 +
111.70 +; get the co2 at the lowest level
111.71 + y = x(:,nlev-1,:,:)
111.72 +
111.73 +; change to unit of observed (u mol/mol)
111.74 +; Model_units [=] kgCO2 / kgDryAir
111.75 +; 28.966 = molecular weight of dry air
111.76 +; 44. = molecular weight of CO2
111.77 +; u mol = 1e-6 mol
111.78 +
111.79 + factor = (28.966/44.) * 1e6
111.80 + y = y * factor
111.81 +
111.82 + y@_FillValue = 1.e36
111.83 + y@units = "u mol/mol"
111.84 +; y = where(y0 .lt. 287.,y@_FillValue,y)
111.85 +; printVarSummary (y)
111.86 +; print (min(y)+"/"+max(y))
111.87 +
111.88 +; interpolate into observed station
111.89 +; note: model is 0-360E, 90S-90N
111.90 +
111.91 + i = ind(lon_ob .lt. 0.)
111.92 + lon_ob(i) = lon_ob(i) + 360.
111.93 +
111.94 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
111.95 +
111.96 + val_model = val_ob
111.97 + val_model = yo(pts|:,time|:)
111.98 +; printVarSummary (val_model)
111.99 +; print (min(val_model)+"/"+max(val_model))
111.100 +
111.101 +; remove annual mean
111.102 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
111.103 +; print (min(val_model)+"/"+max(val_model))
111.104 +
111.105 + nzone = 4
111.106 + do z = 0,nzone-1
111.107 +
111.108 + if (z .eq. 0) then
111.109 +; maximum score for the zone, 60N-90N
111.110 + score_max = 5.0
111.111 +; index of stations in this zone
111.112 + ind_z = ind(lat_ob .ge. 60.)
111.113 +; print (ind_z)
111.114 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
111.115 +; print (val_ob(ind_z,:))
111.116 +; print (val_model(ind_z,:))
111.117 + end if
111.118 +
111.119 + if (z .eq. 1) then
111.120 +; maximum score for the zone, 30N-60N
111.121 + score_max = 5.0
111.122 +; index of stations in this zone
111.123 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
111.124 +; print (ind_z)
111.125 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
111.126 +; print (val_ob(ind_z,:))
111.127 +; print (val_model(ind_z,:))
111.128 + end if
111.129 +
111.130 + if (z .eq. 2) then
111.131 +; maximum score for the zone, EQ-30N
111.132 + score_max = 5.0
111.133 +; index of stations in this zone
111.134 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
111.135 +; print (ind_z)
111.136 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
111.137 +; print (val_ob(ind_z,:))
111.138 +; print (val_model(ind_z,:))
111.139 + end if
111.140 +
111.141 + if (z .eq. 3) then
111.142 +; maximum score for the zone, 90S-EQ
111.143 + score_max = 5.0
111.144 +; index of stations in this zone
111.145 + ind_z = ind(lat_ob .lt. 0. )
111.146 +; print (ind_z)
111.147 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
111.148 +; print (val_ob(ind_z,:))
111.149 +; print (val_model(ind_z,:))
111.150 + end if
111.151 +
111.152 + u = ndtooned(val_ob(ind_z,:))
111.153 + v = ndtooned(val_model(ind_z,:))
111.154 +
111.155 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
111.156 +
111.157 + uu = u(good)
111.158 + vv = v(good)
111.159 + st = sta(ind_z)
111.160 +
111.161 + npts = dimsizes(st)
111.162 + print (npts)
111.163 +
111.164 + ccr = esccr(uu,vv,0)
111.165 +;print (ccr)
111.166 +
111.167 + un = onedtond(uu,(/npts,12/))
111.168 + vn = onedtond(vv,(/npts,12/))
111.169 +;print (un)
111.170 +;print (vn)
111.171 +
111.172 + score = new((/npts/),float)
111.173 +
111.174 + do n=0,npts-1
111.175 + amp_ob = max(un(n,:)) - min(un(n,:))
111.176 + amp_model = max(vn(n,:)) - min(vn(n,:))
111.177 + score(n) = 1.-abs((amp_model/amp_ob)-1.)
111.178 +; print (amp_ob)
111.179 +; print (amp_model)
111.180 + end do
111.181 +;print (score)
111.182 +
111.183 + M = avg(score)
111.184 + print (M)
111.185 +
111.186 + M_total = (ccr*ccr + M)*0.5 * score_max
111.187 + print (M_total)
111.188 +
111.189 + delete (ind_z)
111.190 + delete (good)
111.191 + delete (u)
111.192 + delete (v)
111.193 + delete (uu)
111.194 + delete (vv)
111.195 + delete (un)
111.196 + delete (vn)
111.197 + delete (st)
111.198 + delete (score)
111.199 + end do
111.200 +end
112.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
112.2 +++ b/co2/15.metric.ncl Mon Jan 26 22:08:20 2009 -0500
112.3 @@ -0,0 +1,191 @@
112.4 +; ***********************************************
112.5 +; xy_4.ncl
112.6 +; ***********************************************
112.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
112.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
112.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
112.10 +;************************************************
112.11 +begin
112.12 +;************************************************
112.13 +; read in data: observed
112.14 +;************************************************
112.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
112.16 + fili = "co2_globalView_98.nc"
112.17 + g = addfile (diri+fili,"r")
112.18 + val = g->CO2_SEAS
112.19 + lon = g->LON
112.20 + lat = g->LAT
112.21 + sta = chartostring(g->STATION)
112.22 + delete (g)
112.23 +
112.24 +;print (sta(0))
112.25 +
112.26 + ncase = dimsizes(lat)
112.27 +;print (ncase)
112.28 +
112.29 +;**************************************************************
112.30 +; get only the lowest level at each station
112.31 +;**************************************************************
112.32 + lat_tmp = lat
112.33 + lat_tmp@_FillValue = 1.e+36
112.34 +
112.35 + do n = 0,ncase-1
112.36 + if (.not. ismissing(lat_tmp(n))) then
112.37 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
112.38 + if (dimsizes(indexes) .gt. 1) then
112.39 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
112.40 + end if
112.41 + delete (indexes)
112.42 + end if
112.43 + end do
112.44 +
112.45 + indexes = ind(.not. ismissing(lat_tmp))
112.46 +;print (dimsizes(indexes))
112.47 +;print (indexes)
112.48 +
112.49 + lat_ob = lat(indexes)
112.50 + lon_ob = lon(indexes)
112.51 + val_ob = val(indexes,:)
112.52 +;printVarSummary (val_ob)
112.53 +;print (lat_ob +"/"+lon_ob)
112.54 +
112.55 +;************************************************
112.56 +; read in model data
112.57 +;************************************************
112.58 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
112.59 +; fili2 = "b30.061m_401_425_MONS_climo.nc"
112.60 + fili2 = "b30.061n_1995-2004_MONS_climo.nc"
112.61 +
112.62 + g = addfile(diri2+fili2,"r")
112.63 + x = g->CO2
112.64 + xi = g->lon
112.65 + yi = g->lat
112.66 + xdim = dimsizes(x)
112.67 + nlev = xdim(1)
112.68 + y = x(:,0,:,:)
112.69 +; printVarSummary (y)
112.70 +
112.71 +; get the co2 at the lowest level
112.72 + y = x(:,nlev-1,:,:)
112.73 +
112.74 +; change to unit of observed (u mol/mol)
112.75 +; Model_units [=] kgCO2 / kgDryAir
112.76 +; 28.966 = molecular weight of dry air
112.77 +; 44. = molecular weight of CO2
112.78 +; u mol = 1e-6 mol
112.79 +
112.80 + factor = (28.966/44.) * 1e6
112.81 + y = y * factor
112.82 +
112.83 + y@_FillValue = 1.e36
112.84 + y@units = "u mol/mol"
112.85 +; y = where(y0 .lt. 287.,y@_FillValue,y)
112.86 +; printVarSummary (y)
112.87 +; print (min(y)+"/"+max(y))
112.88 +
112.89 +; interpolate into observed station
112.90 +; note: model is 0-360E, 90S-90N
112.91 +
112.92 +; to be able to handle observation at (-89.98,-24.80)
112.93 + print (yi(0))
112.94 + yi(0) = -90.
112.95 +
112.96 + i = ind(lon_ob .lt. 0.)
112.97 + lon_ob(i) = lon_ob(i) + 360.
112.98 +
112.99 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
112.100 +
112.101 + val_model = yo(pts|:,time|:)
112.102 +; printVarSummary (val_model)
112.103 +; print (min(val_model)+"/"+max(val_model))
112.104 +
112.105 +; remove annual mean
112.106 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
112.107 +; print (min(val_model)+"/"+max(val_model))
112.108 +
112.109 + nzone = 4
112.110 + do z = 0,nzone-1
112.111 +
112.112 + if (z .eq. 0) then
112.113 +; maximum score for the zone, 60N-90N
112.114 + score_max = 5.0
112.115 +; index of stations in this zone
112.116 + ind_z = ind(lat_ob .ge. 60.)
112.117 +; print (ind_z)
112.118 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
112.119 +; print (val_ob(ind_z,:))
112.120 +; print (val_model(ind_z,:))
112.121 + end if
112.122 +
112.123 + if (z .eq. 1) then
112.124 +; maximum score for the zone, 30N-60N
112.125 + score_max = 5.0
112.126 +; index of stations in this zone
112.127 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
112.128 +; print (ind_z)
112.129 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
112.130 +; print (val_ob(ind_z,:))
112.131 +; print (val_model(ind_z,:))
112.132 + end if
112.133 +
112.134 + if (z .eq. 2) then
112.135 +; maximum score for the zone, EQ-30N
112.136 + score_max = 5.0
112.137 +; index of stations in this zone
112.138 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
112.139 +; print (ind_z)
112.140 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
112.141 +; print (val_ob(ind_z,:))
112.142 +; print (val_model(ind_z,:))
112.143 + end if
112.144 +
112.145 + if (z .eq. 3) then
112.146 +; maximum score for the zone, 90S-EQ
112.147 + score_max = 5.0
112.148 +; index of stations in this zone
112.149 + ind_z = ind(lat_ob .lt. 0. )
112.150 +; print (ind_z)
112.151 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
112.152 +; print (val_ob(ind_z,:))
112.153 +; print (val_model(ind_z,:))
112.154 + end if
112.155 +
112.156 + npts = dimsizes(ind_z)
112.157 + print (npts)
112.158 +
112.159 + amp_ob = new((/npts/),float)
112.160 + amp_model = new((/npts/),float)
112.161 +
112.162 + amp_ratio_sta = new((/npts/),float)
112.163 + ccr_sta = new((/npts/),float)
112.164 + M_sta = new((/npts/),float)
112.165 + score_sta = new((/npts/),float)
112.166 +
112.167 + do n=0,npts-1
112.168 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
112.169 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
112.170 +
112.171 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
112.172 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
112.173 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
112.174 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
112.175 +
112.176 + print (sta(ind_z(n))+"/"+lat(ind_z(n))+"/"+lon(ind_z(n))+"/"+amp_ratio_sta(n)+"/"+ccr_sta(n)+"/"+M_sta(n)+"/"+score_sta(n))
112.177 + end do
112.178 +
112.179 + amp_ratio_zone = avg(amp_ratio_sta)
112.180 + ccr_zone = avg(ccr_sta)
112.181 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
112.182 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
112.183 +
112.184 + print (npts+"/"+amp_ratio_zone+"/"+ccr_zone+"/"+M_zone+"/"+score_zone)
112.185 +
112.186 + delete (ind_z)
112.187 + delete (amp_model)
112.188 + delete (amp_ob)
112.189 + delete (amp_ratio_sta)
112.190 + delete (ccr_sta)
112.191 + delete (M_sta)
112.192 + delete (score_sta)
112.193 + end do
112.194 +end
113.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
113.2 +++ b/co2/16.metric_plot.ncl Mon Jan 26 22:08:20 2009 -0500
113.3 @@ -0,0 +1,241 @@
113.4 +; ***********************************************
113.5 +; xy_4.ncl
113.6 +; ***********************************************
113.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
113.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
113.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
113.10 +load "/fis/cgd/cseg/people/jeff/clamp/co2/taylor_metrics_table.ncl"
113.11 +;************************************************
113.12 +begin
113.13 +;************************************************
113.14 +; read in data: observed
113.15 +;************************************************
113.16 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
113.17 + fili = "co2_globalView_98.nc"
113.18 + g = addfile (diri+fili,"r")
113.19 + val = g->CO2_SEAS
113.20 + lon = g->LON
113.21 + lat = g->LAT
113.22 + sta = chartostring(g->STATION)
113.23 + delete (g)
113.24 +
113.25 +;print (sta(0))
113.26 +
113.27 + ncase = dimsizes(lat)
113.28 +;print (ncase)
113.29 +
113.30 +;**************************************************************
113.31 +; get only the lowest level at each station
113.32 +;**************************************************************
113.33 + lat_tmp = lat
113.34 + lat_tmp@_FillValue = 1.e+36
113.35 +
113.36 + do n = 0,ncase-1
113.37 + if (.not. ismissing(lat_tmp(n))) then
113.38 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
113.39 + if (dimsizes(indexes) .gt. 1) then
113.40 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
113.41 + end if
113.42 + delete (indexes)
113.43 + end if
113.44 + end do
113.45 +
113.46 + indexes = ind(.not. ismissing(lat_tmp))
113.47 +;print (dimsizes(indexes))
113.48 +;print (indexes)
113.49 +
113.50 + lat_ob = lat(indexes)
113.51 + lon_ob = lon(indexes)
113.52 + val_ob = val(indexes,:)
113.53 +;printVarSummary (val_ob)
113.54 +;print (lat_ob +"/"+lon_ob)
113.55 +
113.56 +;************************************************
113.57 +; read in model data
113.58 +;************************************************
113.59 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
113.60 +; fili2 = "b30.061m_401_425_MONS_climo_atm.nc"
113.61 + fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
113.62 +
113.63 + g = addfile(diri2+fili2,"r")
113.64 + x = g->CO2
113.65 + xi = g->lon
113.66 + yi = g->lat
113.67 + xdim = dimsizes(x)
113.68 + nlev = xdim(1)
113.69 + y = x(:,0,:,:)
113.70 +; printVarSummary (y)
113.71 +
113.72 +; get the co2 at the lowest level
113.73 + y = x(:,nlev-1,:,:)
113.74 +
113.75 +; change to unit of observed (u mol/mol)
113.76 +; Model_units [=] kgCO2 / kgDryAir
113.77 +; 28.966 = molecular weight of dry air
113.78 +; 44. = molecular weight of CO2
113.79 +; u mol = 1e-6 mol
113.80 +
113.81 + factor = (28.966/44.) * 1e6
113.82 + y = y * factor
113.83 +
113.84 + y@_FillValue = 1.e36
113.85 + y@units = "u mol/mol"
113.86 +; y = where(y0 .lt. 287.,y@_FillValue,y)
113.87 +; printVarSummary (y)
113.88 +; print (min(y)+"/"+max(y))
113.89 +
113.90 +; interpolate into observed station
113.91 +; note: model is 0-360E, 90S-90N
113.92 +
113.93 +; to be able to handle observation at (-89.98,-24.80)
113.94 + print (yi(0))
113.95 + yi(0) = -90.
113.96 +
113.97 + i = ind(lon_ob .lt. 0.)
113.98 + lon_ob(i) = lon_ob(i) + 360.
113.99 +
113.100 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
113.101 +
113.102 + val_model = yo(pts|:,time|:)
113.103 +; printVarSummary (val_model)
113.104 +; print (min(val_model)+"/"+max(val_model))
113.105 +
113.106 +; remove annual mean
113.107 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
113.108 +; print (min(val_model)+"/"+max(val_model))
113.109 +
113.110 + nzone = 1
113.111 + do z = 0,nzone-1
113.112 +
113.113 + if (z .eq. 0) then
113.114 +; maximum score for the zone, 60N-90N
113.115 + score_max = 5.0
113.116 +; index of stations in this zone
113.117 + ind_z = ind(lat_ob .ge. 60.)
113.118 +; print (ind_z)
113.119 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
113.120 +; print (val_ob(ind_z,:))
113.121 +; print (val_model(ind_z,:))
113.122 + end if
113.123 +
113.124 + if (z .eq. 1) then
113.125 +; maximum score for the zone, 30N-60N
113.126 + score_max = 5.0
113.127 +; index of stations in this zone
113.128 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
113.129 +; print (ind_z)
113.130 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
113.131 +; print (val_ob(ind_z,:))
113.132 +; print (val_model(ind_z,:))
113.133 + end if
113.134 +
113.135 + if (z .eq. 2) then
113.136 +; maximum score for the zone, EQ-30N
113.137 + score_max = 5.0
113.138 +; index of stations in this zone
113.139 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
113.140 +; print (ind_z)
113.141 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
113.142 +; print (val_ob(ind_z,:))
113.143 +; print (val_model(ind_z,:))
113.144 + end if
113.145 +
113.146 + if (z .eq. 3) then
113.147 +; maximum score for the zone, 90S-EQ
113.148 + score_max = 5.0
113.149 +; index of stations in this zone
113.150 + ind_z = ind(lat_ob .lt. 0. )
113.151 +; print (ind_z)
113.152 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
113.153 +; print (val_ob(ind_z,:))
113.154 +; print (val_model(ind_z,:))
113.155 + end if
113.156 +
113.157 + npts = dimsizes(ind_z)
113.158 + print (npts)
113.159 +
113.160 + amp_ob = new((/npts/),float)
113.161 + amp_model = new((/npts/),float)
113.162 +
113.163 + amp_ratio_sta = new((/npts/),float)
113.164 + ccr_sta = new((/npts/),float)
113.165 + M_sta = new((/npts/),float)
113.166 + score_sta = new((/npts/),float)
113.167 +
113.168 + do n=0,npts-1
113.169 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
113.170 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
113.171 +
113.172 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
113.173 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
113.174 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
113.175 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
113.176 +
113.177 + print (sta(ind_z(n))+"/"+lat(ind_z(n))+"/"+lon(ind_z(n))+"/"+amp_ratio_sta(n)+"/"+ccr_sta(n)+"/"+M_sta(n)+"/"+score_sta(n))
113.178 + end do
113.179 +
113.180 + amp_ratio_zone = avg(amp_ratio_sta)
113.181 + ccr_zone = avg(ccr_sta)
113.182 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
113.183 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
113.184 +
113.185 + print (npts+"/"+amp_ratio_zone+"/"+ccr_zone+"/"+M_zone+"/"+score_zone)
113.186 +;****************************************************************************
113.187 +; Cases [Model]
113.188 + case = (/ "Lat", "Lon", "AR" /)
113.189 + nCase = dimsizes(case ) ; # of Cases [Cases]
113.190 +
113.191 +; variables compared
113.192 + var = sta(ind_z)
113.193 + nVar = dimsizes(var) ; # of Variables
113.194 +
113.195 +; "Case A"
113.196 + CA_ratio = (/lat(ind_z)/)
113.197 +
113.198 +; "Case B"
113.199 + CB_ratio = (/lon(ind_z)/)
113.200 +
113.201 +; "Case C"
113.202 + CC_ratio = (/amp_ratio_sta/)
113.203 +
113.204 +
113.205 +; arrays to be passed to taylor_diagram. It will calculate the x xnd y coordinates.
113.206 + ratio = new ((/nCase, nVar/),typeof(CA_ratio) )
113.207 +
113.208 + ratio(0,:) = CA_ratio
113.209 + ratio(1,:) = CB_ratio
113.210 + ratio(2,:) = CC_ratio
113.211 +
113.212 +;**************************************************
113.213 +; fill an array for a "taylor metrics table"
113.214 +;**************************************************
113.215 +
113.216 +; season = (/ "ANN" /)
113.217 +; nSeason = dimsizes(season)
113.218 + season = (/ "" /)
113.219 + nSeason = dimsizes(season)
113.220 +
113.221 + table = new ( (/nCase,nSeason,nVar/), typeof(ratio) )
113.222 + table(0,0,:) = CA_ratio
113.223 + table(1,0,:) = CB_ratio
113.224 + table(2,0,:) = CC_ratio
113.225 +
113.226 + tt_opt = True
113.227 + tt_opt@pltType= "ps" ; "eps" [default], "pdf", "ps"
113.228 + ; "png", "gif" [if you have ImageMajik 'convert']
113.229 +
113.230 + tt_opt@tableTitle = "Station in 60N_90N"
113.231 +
113.232 + varSource =var
113.233 +
113.234 + taylor_metrics_table("metrics", varSource, case ,season, table, tt_opt)
113.235 +
113.236 + delete (ind_z)
113.237 + delete (amp_model)
113.238 + delete (amp_ob)
113.239 + delete (amp_ratio_sta)
113.240 + delete (ccr_sta)
113.241 + delete (M_sta)
113.242 + delete (score_sta)
113.243 + end do
113.244 +end
114.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
114.2 +++ b/co2/17.metric_plot.ncl Mon Jan 26 22:08:20 2009 -0500
114.3 @@ -0,0 +1,241 @@
114.4 +; ***********************************************
114.5 +; xy_4.ncl
114.6 +; ***********************************************
114.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
114.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
114.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
114.10 +load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
114.11 +;************************************************
114.12 +begin
114.13 +;************************************************
114.14 +; read in data: observed
114.15 +;************************************************
114.16 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
114.17 + fili = "co2_globalView_98.nc"
114.18 + g = addfile (diri+fili,"r")
114.19 + val = g->CO2_SEAS
114.20 + lon = g->LON
114.21 + lat = g->LAT
114.22 + sta = chartostring(g->STATION)
114.23 + delete (g)
114.24 +
114.25 +;print (sta(0))
114.26 +
114.27 + ncase = dimsizes(lat)
114.28 +;print (ncase)
114.29 +
114.30 +;**************************************************************
114.31 +; get only the lowest level at each station
114.32 +;**************************************************************
114.33 + lat_tmp = lat
114.34 + lat_tmp@_FillValue = 1.e+36
114.35 +
114.36 + do n = 0,ncase-1
114.37 + if (.not. ismissing(lat_tmp(n))) then
114.38 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
114.39 + if (dimsizes(indexes) .gt. 1) then
114.40 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
114.41 + end if
114.42 + delete (indexes)
114.43 + end if
114.44 + end do
114.45 +
114.46 + indexes = ind(.not. ismissing(lat_tmp))
114.47 +;print (dimsizes(indexes))
114.48 +;print (indexes)
114.49 +
114.50 + lat_ob = lat(indexes)
114.51 + lon_ob = lon(indexes)
114.52 + val_ob = val(indexes,:)
114.53 +;printVarSummary (val_ob)
114.54 +;print (lat_ob +"/"+lon_ob)
114.55 +
114.56 +;************************************************
114.57 +; read in model data
114.58 +;************************************************
114.59 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
114.60 +; fili2 = "b30.061m_401_425_MONS_climo_atm.nc"
114.61 + fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
114.62 +
114.63 + g = addfile(diri2+fili2,"r")
114.64 + x = g->CO2
114.65 + xi = g->lon
114.66 + yi = g->lat
114.67 + xdim = dimsizes(x)
114.68 + nlev = xdim(1)
114.69 + y = x(:,0,:,:)
114.70 +; printVarSummary (y)
114.71 +
114.72 +; get the co2 at the lowest level
114.73 + y = x(:,nlev-1,:,:)
114.74 +
114.75 +; change to unit of observed (u mol/mol)
114.76 +; Model_units [=] kgCO2 / kgDryAir
114.77 +; 28.966 = molecular weight of dry air
114.78 +; 44. = molecular weight of CO2
114.79 +; u mol = 1e-6 mol
114.80 +
114.81 + factor = (28.966/44.) * 1e6
114.82 + y = y * factor
114.83 +
114.84 + y@_FillValue = 1.e36
114.85 + y@units = "u mol/mol"
114.86 +; y = where(y0 .lt. 287.,y@_FillValue,y)
114.87 +; printVarSummary (y)
114.88 +; print (min(y)+"/"+max(y))
114.89 +
114.90 +; interpolate into observed station
114.91 +; note: model is 0-360E, 90S-90N
114.92 +
114.93 +; to be able to handle observation at (-89.98,-24.80)
114.94 + print (yi(0))
114.95 + yi(0) = -90.
114.96 +
114.97 + i = ind(lon_ob .lt. 0.)
114.98 + lon_ob(i) = lon_ob(i) + 360.
114.99 +
114.100 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
114.101 +
114.102 + val_model = yo(pts|:,time|:)
114.103 +; printVarSummary (val_model)
114.104 +; print (min(val_model)+"/"+max(val_model))
114.105 +
114.106 +; remove annual mean
114.107 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
114.108 +; print (min(val_model)+"/"+max(val_model))
114.109 +
114.110 + nzone = 1
114.111 + do z = 0,nzone-1
114.112 +
114.113 + if (z .eq. 0) then
114.114 +; maximum score for the zone, 60N-90N
114.115 + score_max = 5.0
114.116 +; index of stations in this zone
114.117 + ind_z = ind(lat_ob .ge. 60.)
114.118 +; print (ind_z)
114.119 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
114.120 +; print (val_ob(ind_z,:))
114.121 +; print (val_model(ind_z,:))
114.122 + end if
114.123 +
114.124 + if (z .eq. 1) then
114.125 +; maximum score for the zone, 30N-60N
114.126 + score_max = 5.0
114.127 +; index of stations in this zone
114.128 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
114.129 +; print (ind_z)
114.130 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
114.131 +; print (val_ob(ind_z,:))
114.132 +; print (val_model(ind_z,:))
114.133 + end if
114.134 +
114.135 + if (z .eq. 2) then
114.136 +; maximum score for the zone, EQ-30N
114.137 + score_max = 5.0
114.138 +; index of stations in this zone
114.139 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
114.140 +; print (ind_z)
114.141 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
114.142 +; print (val_ob(ind_z,:))
114.143 +; print (val_model(ind_z,:))
114.144 + end if
114.145 +
114.146 + if (z .eq. 3) then
114.147 +; maximum score for the zone, 90S-EQ
114.148 + score_max = 5.0
114.149 +; index of stations in this zone
114.150 + ind_z = ind(lat_ob .lt. 0. )
114.151 +; print (ind_z)
114.152 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
114.153 +; print (val_ob(ind_z,:))
114.154 +; print (val_model(ind_z,:))
114.155 + end if
114.156 +
114.157 + npts = dimsizes(ind_z)
114.158 + print (npts)
114.159 +
114.160 + amp_ob = new((/npts/),float)
114.161 + amp_model = new((/npts/),float)
114.162 +
114.163 + amp_ratio_sta = new((/npts/),float)
114.164 + ccr_sta = new((/npts/),float)
114.165 + M_sta = new((/npts/),float)
114.166 + score_sta = new((/npts/),float)
114.167 +
114.168 + do n=0,npts-1
114.169 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
114.170 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
114.171 +
114.172 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
114.173 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
114.174 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
114.175 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
114.176 +
114.177 + print (sta(ind_z(n))+"/"+lat(ind_z(n))+"/"+lon(ind_z(n))+"/"+amp_ratio_sta(n)+"/"+ccr_sta(n)+"/"+M_sta(n)+"/"+score_sta(n))
114.178 + end do
114.179 +
114.180 + amp_ratio_zone = avg(amp_ratio_sta)
114.181 + ccr_zone = avg(ccr_sta)
114.182 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
114.183 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
114.184 +
114.185 + print (npts+"/"+amp_ratio_zone+"/"+ccr_zone+"/"+M_zone+"/"+score_zone)
114.186 +;****************************************************************************
114.187 +; Cases [Model]
114.188 + case = (/ "Lat", "Lon", "AR" /)
114.189 + nCase = dimsizes(case ) ; # of Cases [Cases]
114.190 +
114.191 +; variables compared
114.192 + var = sta(ind_z)
114.193 + nVar = dimsizes(var) ; # of Variables
114.194 +
114.195 +; "Case A"
114.196 + CA_ratio = (/lat(ind_z)/)
114.197 +
114.198 +; "Case B"
114.199 + CB_ratio = (/lon(ind_z)/)
114.200 +
114.201 +; "Case C"
114.202 + CC_ratio = (/amp_ratio_sta/)
114.203 +
114.204 +
114.205 +; arrays to be passed to taylor_diagram. It will calculate the x xnd y coordinates.
114.206 + ratio = new ((/nCase, nVar/),typeof(CA_ratio) )
114.207 +
114.208 + ratio(0,:) = CA_ratio
114.209 + ratio(1,:) = CB_ratio
114.210 + ratio(2,:) = CC_ratio
114.211 +
114.212 +;**************************************************
114.213 +; fill an array for a "taylor metrics table"
114.214 +;**************************************************
114.215 +
114.216 +; season = (/ "ANN" /)
114.217 +; nSeason = dimsizes(season)
114.218 + season = (/ "" /)
114.219 + nSeason = dimsizes(season)
114.220 +
114.221 + table = new ( (/nCase,nVar/), typeof(ratio) )
114.222 + table(0,:) = CA_ratio
114.223 + table(1,:) = CB_ratio
114.224 + table(2,:) = CC_ratio
114.225 +
114.226 + tt_opt = True
114.227 + tt_opt@pltType= "ps" ; "eps" [default], "pdf", "ps"
114.228 + ; "png", "gif" [if you have ImageMajik 'convert']
114.229 +
114.230 + tt_opt@tableTitle = "Station in 60N_90N"
114.231 +
114.232 + varSource =var
114.233 +
114.234 + metrics_table("metrics", varSource, case , table, tt_opt)
114.235 +
114.236 + delete (ind_z)
114.237 + delete (amp_model)
114.238 + delete (amp_ob)
114.239 + delete (amp_ratio_sta)
114.240 + delete (ccr_sta)
114.241 + delete (M_sta)
114.242 + delete (score_sta)
114.243 + end do
114.244 +end
115.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
115.2 +++ b/co2/18.metric_plot.ncl Mon Jan 26 22:08:20 2009 -0500
115.3 @@ -0,0 +1,230 @@
115.4 +; ***********************************************
115.5 +; xy_4.ncl
115.6 +; ***********************************************
115.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
115.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
115.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
115.10 +load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
115.11 +;************************************************
115.12 +begin
115.13 +;************************************************
115.14 +; read in data: observed
115.15 +;************************************************
115.16 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
115.17 + fili = "co2_globalView_98.nc"
115.18 + g = addfile (diri+fili,"r")
115.19 + val = g->CO2_SEAS
115.20 + lon = g->LON
115.21 + lat = g->LAT
115.22 + sta = chartostring(g->STATION)
115.23 + delete (g)
115.24 +
115.25 +;print (sta(0))
115.26 +
115.27 + ncase = dimsizes(lat)
115.28 +;print (ncase)
115.29 +
115.30 +;**************************************************************
115.31 +; get only the lowest level at each station
115.32 +;**************************************************************
115.33 + lat_tmp = lat
115.34 + lat_tmp@_FillValue = 1.e+36
115.35 +
115.36 + do n = 0,ncase-1
115.37 + if (.not. ismissing(lat_tmp(n))) then
115.38 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
115.39 + if (dimsizes(indexes) .gt. 1) then
115.40 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
115.41 + end if
115.42 + delete (indexes)
115.43 + end if
115.44 + end do
115.45 +
115.46 + indexes = ind(.not. ismissing(lat_tmp))
115.47 +;print (dimsizes(indexes))
115.48 +;print (indexes)
115.49 +
115.50 + lat_ob = lat(indexes)
115.51 + lon_ob = lon(indexes)
115.52 + val_ob = val(indexes,:)
115.53 +;printVarSummary (val_ob)
115.54 +;print (lat_ob +"/"+lon_ob)
115.55 +
115.56 +;************************************************
115.57 +; read in model data
115.58 +;************************************************
115.59 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
115.60 +; fili2 = "b30.061m_401_425_MONS_climo_atm.nc"
115.61 + fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
115.62 +
115.63 + g = addfile(diri2+fili2,"r")
115.64 + x = g->CO2
115.65 + xi = g->lon
115.66 + yi = g->lat
115.67 + xdim = dimsizes(x)
115.68 + nlev = xdim(1)
115.69 + y = x(:,0,:,:)
115.70 +; printVarSummary (y)
115.71 +
115.72 +; get the co2 at the lowest level
115.73 + y = x(:,nlev-1,:,:)
115.74 +
115.75 +; change to unit of observed (u mol/mol)
115.76 +; Model_units [=] kgCO2 / kgDryAir
115.77 +; 28.966 = molecular weight of dry air
115.78 +; 44. = molecular weight of CO2
115.79 +; u mol = 1e-6 mol
115.80 +
115.81 + factor = (28.966/44.) * 1e6
115.82 + y = y * factor
115.83 +
115.84 + y@_FillValue = 1.e36
115.85 + y@units = "u mol/mol"
115.86 +; y = where(y0 .lt. 287.,y@_FillValue,y)
115.87 +; printVarSummary (y)
115.88 +; print (min(y)+"/"+max(y))
115.89 +
115.90 +; interpolate into observed station
115.91 +; note: model is 0-360E, 90S-90N
115.92 +
115.93 +; to be able to handle observation at (-89.98,-24.80)
115.94 + print (yi(0))
115.95 + yi(0) = -90.
115.96 +
115.97 + i = ind(lon_ob .lt. 0.)
115.98 + lon_ob(i) = lon_ob(i) + 360.
115.99 +
115.100 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
115.101 +
115.102 + val_model = yo(pts|:,time|:)
115.103 +; printVarSummary (val_model)
115.104 +; print (min(val_model)+"/"+max(val_model))
115.105 +
115.106 +; remove annual mean
115.107 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
115.108 +; print (min(val_model)+"/"+max(val_model))
115.109 +
115.110 + nzone = 4
115.111 + do z = 0,nzone-1
115.112 +
115.113 + if (z .eq. 0) then
115.114 +; maximum score for the zone, 60N-90N
115.115 + zone = "60N-90N"
115.116 + score_max = 5.0
115.117 +; index of stations in this zone
115.118 + ind_z = ind(lat_ob .ge. 60.)
115.119 +; print (ind_z)
115.120 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
115.121 +; print (val_ob(ind_z,:))
115.122 +; print (val_model(ind_z,:))
115.123 + end if
115.124 +
115.125 + if (z .eq. 1) then
115.126 +; maximum score for the zone, 30N-60N
115.127 + zone = "30N-60N"
115.128 + score_max = 5.0
115.129 +; index of stations in this zone
115.130 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
115.131 +; print (ind_z)
115.132 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
115.133 +; print (val_ob(ind_z,:))
115.134 +; print (val_model(ind_z,:))
115.135 + end if
115.136 +
115.137 + if (z .eq. 2) then
115.138 +; maximum score for the zone, EQ-30N
115.139 + zone = "EQ-30N"
115.140 + score_max = 5.0
115.141 +; index of stations in this zone
115.142 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
115.143 +; print (ind_z)
115.144 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
115.145 +; print (val_ob(ind_z,:))
115.146 +; print (val_model(ind_z,:))
115.147 + end if
115.148 +
115.149 + if (z .eq. 3) then
115.150 +; maximum score for the zone, 90S-EQ
115.151 + zone = "90S-EQ"
115.152 + score_max = 5.0
115.153 +; index of stations in this zone
115.154 + ind_z = ind(lat_ob .lt. 0. )
115.155 +; print (ind_z)
115.156 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
115.157 +; print (val_ob(ind_z,:))
115.158 +; print (val_model(ind_z,:))
115.159 + end if
115.160 +
115.161 + npts = dimsizes(ind_z)
115.162 + print (npts)
115.163 +
115.164 + amp_ob = new((/npts/),float)
115.165 + amp_model = new((/npts/),float)
115.166 +
115.167 + amp_ratio_sta = new((/npts/),float)
115.168 + ccr_sta = new((/npts/),float)
115.169 + M_sta = new((/npts/),float)
115.170 + score_sta = new((/npts/),float)
115.171 +
115.172 + do n=0,npts-1
115.173 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
115.174 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
115.175 +
115.176 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
115.177 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
115.178 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
115.179 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
115.180 +
115.181 + print (sta(ind_z(n))+"/"+lat(ind_z(n))+"/"+lon(ind_z(n))+"/"+amp_ratio_sta(n)+"/"+ccr_sta(n)+"/"+M_sta(n)+"/"+score_sta(n))
115.182 + end do
115.183 +
115.184 + amp_ratio_zone = avg(amp_ratio_sta)
115.185 + ccr_zone = avg(ccr_sta)
115.186 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
115.187 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
115.188 +
115.189 + print (npts+"/"+amp_ratio_zone+"/"+ccr_zone+"/"+M_zone+"/"+score_zone)
115.190 +;****************************************************************************
115.191 +; Cases [Model]
115.192 + case = (/"Latitude","Longitude","Amplitude Ratio", \
115.193 + "Correlation Coef","M score","Combined Score"/)
115.194 + nCase = dimsizes(case ) ; # of Cases [Cases]
115.195 +
115.196 +; variables compared
115.197 + var = sta(ind_z)
115.198 + nVar = dimsizes(var) ; # of Variables
115.199 +
115.200 +; arrays to be passed to diagram. It will calculate the x xnd y coordinates.
115.201 + case_value = new ((/nCase, nVar/),float )
115.202 +
115.203 + case_value(0,:) = (/lat(ind_z)/)
115.204 + case_value(1,:) = (/lon(ind_z)/)
115.205 + case_value(2,:) = (/amp_ratio_sta/)
115.206 + case_value(3,:) = (/ccr_sta/)
115.207 + case_value(4,:) = (/M_sta/)
115.208 + case_value(5,:) = (/score_sta/)
115.209 +
115.210 +;**************************************************
115.211 +; fill an array for a "metrics table"
115.212 +;**************************************************
115.213 +
115.214 + tt_opt = True
115.215 + tt_opt@pltType= "ps" ; "eps" [default], "pdf", "ps"
115.216 + ; "png", "gif" [if you have ImageMajik 'convert']
115.217 +
115.218 + tt_opt@tableTitle = "Zone "+ zone
115.219 + plot_name = "co2." + zone
115.220 +
115.221 + metrics_table(plot_name, var, case , case_value, tt_opt)
115.222 +
115.223 + delete (ind_z)
115.224 + delete (amp_model)
115.225 + delete (amp_ob)
115.226 + delete (amp_ratio_sta)
115.227 + delete (ccr_sta)
115.228 + delete (M_sta)
115.229 + delete (score_sta)
115.230 + delete (var)
115.231 + delete (case_value)
115.232 + end do
115.233 +end
116.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
116.2 +++ b/co2/19.metric_plot.ncl Mon Jan 26 22:08:20 2009 -0500
116.3 @@ -0,0 +1,268 @@
116.4 +; ***********************************************
116.5 +; xy_4.ncl
116.6 +; ***********************************************
116.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
116.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
116.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
116.10 +load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
116.11 +;************************************************
116.12 +begin
116.13 +;************************************************
116.14 +; read in data: observed
116.15 +;************************************************
116.16 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
116.17 + fili = "co2_globalView_98.nc"
116.18 + g = addfile (diri+fili,"r")
116.19 + val = g->CO2_SEAS
116.20 + lon = g->LON
116.21 + lat = g->LAT
116.22 + sta = chartostring(g->STATION)
116.23 + delete (g)
116.24 +
116.25 +;print (sta(0))
116.26 +
116.27 + ncase = dimsizes(lat)
116.28 +;print (ncase)
116.29 +
116.30 +;**************************************************************
116.31 +; get only the lowest level at each station
116.32 +;**************************************************************
116.33 + lat_tmp = lat
116.34 + lat_tmp@_FillValue = 1.e+36
116.35 +
116.36 + do n = 0,ncase-1
116.37 + if (.not. ismissing(lat_tmp(n))) then
116.38 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
116.39 + if (dimsizes(indexes) .gt. 1) then
116.40 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
116.41 + end if
116.42 + delete (indexes)
116.43 + end if
116.44 + end do
116.45 +
116.46 + indexes = ind(.not. ismissing(lat_tmp))
116.47 +;print (dimsizes(indexes))
116.48 +;print (indexes)
116.49 +
116.50 + lat_ob = lat(indexes)
116.51 + lon_ob = lon(indexes)
116.52 + val_ob = val(indexes,:)
116.53 +;printVarSummary (val_ob)
116.54 +;print (lat_ob +"/"+lon_ob)
116.55 +
116.56 +;************************************************
116.57 +; read in model data
116.58 +;************************************************
116.59 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
116.60 +; fili2 = "b30.061m_401_425_MONS_climo_atm.nc"
116.61 + fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
116.62 +
116.63 + g = addfile(diri2+fili2,"r")
116.64 + x = g->CO2
116.65 + xi = g->lon
116.66 + yi = g->lat
116.67 + xdim = dimsizes(x)
116.68 + nlev = xdim(1)
116.69 + y = x(:,0,:,:)
116.70 +; printVarSummary (y)
116.71 +
116.72 +; get the co2 at the lowest level
116.73 + y = x(:,nlev-1,:,:)
116.74 +
116.75 +; change to unit of observed (u mol/mol)
116.76 +; Model_units [=] kgCO2 / kgDryAir
116.77 +; 28.966 = molecular weight of dry air
116.78 +; 44. = molecular weight of CO2
116.79 +; u mol = 1e-6 mol
116.80 +
116.81 + factor = (28.966/44.) * 1e6
116.82 + y = y * factor
116.83 +
116.84 + y@_FillValue = 1.e36
116.85 + y@units = "u mol/mol"
116.86 +; y = where(y0 .lt. 287.,y@_FillValue,y)
116.87 +; printVarSummary (y)
116.88 +; print (min(y)+"/"+max(y))
116.89 +
116.90 +; interpolate into observed station
116.91 +; note: model is 0-360E, 90S-90N
116.92 +
116.93 +; to be able to handle observation at (-89.98,-24.80)
116.94 + print (yi(0))
116.95 + yi(0) = -90.
116.96 +
116.97 + i = ind(lon_ob .lt. 0.)
116.98 + lon_ob(i) = lon_ob(i) + 360.
116.99 +
116.100 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
116.101 +
116.102 + val_model = yo(pts|:,time|:)
116.103 +; printVarSummary (val_model)
116.104 +; print (min(val_model)+"/"+max(val_model))
116.105 +
116.106 +; remove annual mean
116.107 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
116.108 +; print (min(val_model)+"/"+max(val_model))
116.109 +
116.110 + nzone = 4
116.111 +
116.112 +; column
116.113 + case_zone = (/"Stations","Amplitude Ratio", \
116.114 + "Correlation Coef","M score","Combined Score"/)
116.115 + nCase_zone = dimsizes(case_zone )
116.116 +
116.117 +; row
116.118 + var_zone = (/"60N-90N","30N-60N","EQ-30N","90S-EQ","Total"/)
116.119 + nVar_zone = dimsizes(var_zone)
116.120 +
116.121 +; arrays to be passed to diagram.
116.122 + case_value_zone = new ((/nCase_zone, nVar_zone/),float )
116.123 +
116.124 + do z = 0,nzone-1
116.125 +
116.126 + if (z .eq. 0) then
116.127 +; maximum score for the zone, 60N-90N
116.128 + zone = "60N-90N"
116.129 + score_max = 5.0
116.130 +; index of stations in this zone
116.131 + ind_z = ind(lat_ob .ge. 60.)
116.132 +; print (ind_z)
116.133 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
116.134 +; print (val_ob(ind_z,:))
116.135 +; print (val_model(ind_z,:))
116.136 + end if
116.137 +
116.138 + if (z .eq. 1) then
116.139 +; maximum score for the zone, 30N-60N
116.140 + zone = "30N-60N"
116.141 + score_max = 5.0
116.142 +; index of stations in this zone
116.143 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
116.144 +; print (ind_z)
116.145 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
116.146 +; print (val_ob(ind_z,:))
116.147 +; print (val_model(ind_z,:))
116.148 + end if
116.149 +
116.150 + if (z .eq. 2) then
116.151 +; maximum score for the zone, EQ-30N
116.152 + zone = "EQ-30N"
116.153 + score_max = 5.0
116.154 +; index of stations in this zone
116.155 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
116.156 +; print (ind_z)
116.157 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
116.158 +; print (val_ob(ind_z,:))
116.159 +; print (val_model(ind_z,:))
116.160 + end if
116.161 +
116.162 + if (z .eq. 3) then
116.163 +; maximum score for the zone, 90S-EQ
116.164 + zone = "90S-EQ"
116.165 + score_max = 5.0
116.166 +; index of stations in this zone
116.167 + ind_z = ind(lat_ob .lt. 0. )
116.168 +; print (ind_z)
116.169 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
116.170 +; print (val_ob(ind_z,:))
116.171 +; print (val_model(ind_z,:))
116.172 + end if
116.173 +
116.174 + npts = dimsizes(ind_z)
116.175 + print (npts)
116.176 +
116.177 + amp_ob = new((/npts/),float)
116.178 + amp_model = new((/npts/),float)
116.179 +
116.180 + amp_ratio_sta = new((/npts/),float)
116.181 + ccr_sta = new((/npts/),float)
116.182 + M_sta = new((/npts/),float)
116.183 + score_sta = new((/npts/),float)
116.184 +
116.185 + do n=0,npts-1
116.186 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
116.187 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
116.188 +
116.189 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
116.190 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
116.191 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
116.192 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
116.193 +
116.194 + print (sta(ind_z(n))+"/"+lat(ind_z(n))+"/"+lon(ind_z(n))+"/"+amp_ratio_sta(n)+"/"+ccr_sta(n)+"/"+M_sta(n)+"/"+score_sta(n))
116.195 + end do
116.196 +
116.197 + amp_ratio_zone = avg(amp_ratio_sta)
116.198 + ccr_zone = avg(ccr_sta)
116.199 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
116.200 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
116.201 +
116.202 + print (npts+"/"+amp_ratio_zone+"/"+ccr_zone+"/"+M_zone+"/"+score_zone)
116.203 +
116.204 + case_value_zone(0,z) = npts
116.205 + case_value_zone(1,z) = (/amp_ratio_zone/)
116.206 + case_value_zone(2,z) = (/ccr_zone/)
116.207 + case_value_zone(3,z) = (/M_zone/)
116.208 + case_value_zone(4,z) = (/score_zone/)
116.209 +;**************************************************
116.210 +; plot station table
116.211 +;**************************************************
116.212 +; column for station table
116.213 + case_sta = (/"Latitude","Longitude","Amplitude Ratio", \
116.214 + "Correlation Coef","M score","Combined Score"/)
116.215 + nCase_sta = dimsizes(case_sta )
116.216 +
116.217 +; row for station table
116.218 + var_sta = sta(ind_z)
116.219 + nVar_sta = dimsizes(var_sta)
116.220 +
116.221 +; arrays to be passed to diagram.
116.222 + case_value_sta = new ((/nCase_sta, nVar_sta/),float )
116.223 +
116.224 + case_value_sta(0,:) = (/lat(ind_z)/)
116.225 + case_value_sta(1,:) = (/lon(ind_z)/)
116.226 + case_value_sta(2,:) = (/amp_ratio_sta/)
116.227 + case_value_sta(3,:) = (/ccr_sta/)
116.228 + case_value_sta(4,:) = (/M_sta/)
116.229 + case_value_sta(5,:) = (/score_sta/)
116.230 +
116.231 +;**************************************************
116.232 +; plot station table
116.233 +;**************************************************
116.234 + tt_opt = True
116.235 + tt_opt@pltType= "png" ; "eps" [default], "pdf", "ps"
116.236 + ; "png", "gif" [if you have ImageMajik 'convert']
116.237 +
116.238 + tt_opt@tableTitle = "Zone "+ zone
116.239 + plot_name = "table_sta." + zone
116.240 +
116.241 + metrics_table(plot_name, var_sta, case_sta , case_value_sta, tt_opt)
116.242 +
116.243 + delete (ind_z)
116.244 + delete (amp_model)
116.245 + delete (amp_ob)
116.246 + delete (amp_ratio_sta)
116.247 + delete (ccr_sta)
116.248 + delete (M_sta)
116.249 + delete (score_sta)
116.250 + delete (var_sta)
116.251 + delete (case_value_sta)
116.252 + end do
116.253 +;**************************************************
116.254 +; plot zone table
116.255 +;**************************************************
116.256 + case_value_zone(0,4) = case_value_zone(0,0)+case_value_zone(0,1)+case_value_zone(0,2)+case_value_zone(0,3)
116.257 + case_value_zone(1,4) = 0.
116.258 + case_value_zone(2,4) = 0.
116.259 + case_value_zone(3,4) = 0.
116.260 + case_value_zone(4,4) = case_value_zone(4,0)+case_value_zone(4,1)+case_value_zone(4,2)+case_value_zone(4,3)
116.261 +
116.262 + tt_opt = True
116.263 + tt_opt@pltType= "png" ; "eps" [default], "pdf", "ps"
116.264 + ; "png", "gif" [if you have ImageMajik 'convert']
116.265 +
116.266 + tt_opt@tableTitle = "Zone"
116.267 + plot_name = "table_zone"
116.268 +
116.269 + metrics_table(plot_name, var_zone, case_zone , case_value_zone, tt_opt)
116.270 +
116.271 +end
117.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
117.2 +++ b/co2/21.lines.ncl Mon Jan 26 22:08:20 2009 -0500
117.3 @@ -0,0 +1,215 @@
117.4 +; ***********************************************
117.5 +; xy_4.ncl
117.6 +; ***********************************************
117.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
117.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
117.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
117.10 +;************************************************
117.11 +begin
117.12 +;************************************************
117.13 +; read in data: observed
117.14 +;************************************************
117.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
117.16 + fili = "co2_globalView_98.nc"
117.17 + g = addfile (diri+fili,"r")
117.18 + val = g->CO2_SEAS
117.19 + lon = g->LON
117.20 + lat = g->LAT
117.21 + sta = chartostring(g->STATION)
117.22 + delete (g)
117.23 +
117.24 +;print (sta(0))
117.25 +
117.26 + ncase = dimsizes(lat)
117.27 +;print (ncase)
117.28 +
117.29 +;**************************************************************
117.30 +; get only the lowest level at each station
117.31 +;**************************************************************
117.32 + lat_tmp = lat
117.33 + lat_tmp@_FillValue = 1.e+36
117.34 +
117.35 + do n = 0,ncase-1
117.36 + if (.not. ismissing(lat_tmp(n))) then
117.37 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
117.38 + if (dimsizes(indexes) .gt. 1) then
117.39 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
117.40 + end if
117.41 + delete (indexes)
117.42 + end if
117.43 + end do
117.44 +
117.45 + indexes = ind(.not. ismissing(lat_tmp))
117.46 +;print (dimsizes(indexes))
117.47 +;print (indexes)
117.48 +
117.49 + lat_ob = lat(indexes)
117.50 + lon_ob = lon(indexes)
117.51 + val_ob = val(indexes,:)
117.52 +;printVarSummary (val_ob)
117.53 +;print (lat_ob +"/"+lon_ob)
117.54 +
117.55 +;************************************************
117.56 +; read in model data
117.57 +;************************************************
117.58 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
117.59 + fili2 = "b30.061m_401_425_MONS_climo.nc"
117.60 +
117.61 + g = addfile(diri2+fili2,"r")
117.62 + x = g->CO2
117.63 + xi = g->lon
117.64 + yi = g->lat
117.65 + xdim = dimsizes(x)
117.66 + nlev = xdim(1)
117.67 + y = x(:,0,:,:)
117.68 +; printVarSummary (y)
117.69 +
117.70 +; get the co2 at the lowest level
117.71 + y = x(:,nlev-1,:,:)
117.72 +
117.73 +; change to unit of observed (u mol/mol)
117.74 +; Model_units [=] kgCO2 / kgDryAir
117.75 +; 28.966 = molecular weight of dry air
117.76 +; 44. = molecular weight of CO2
117.77 +; u mol = 1e-6 mol
117.78 +
117.79 + factor = (28.966/44.) * 1e6
117.80 + y = y * factor
117.81 +
117.82 + y@_FillValue = 1.e36
117.83 + y@units = "u mol/mol"
117.84 +; y = where(y0 .lt. 287.,y@_FillValue,y)
117.85 +; printVarSummary (y)
117.86 +; print (min(y)+"/"+max(y))
117.87 +
117.88 +; interpolate into observed station
117.89 +; note: model is 0-360E, 90S-90N
117.90 +
117.91 +; to be able to handle observation at (-89.98,-24.80)
117.92 + print (yi(0))
117.93 + yi(0) = -90.
117.94 +
117.95 + i = ind(lon_ob .lt. 0.)
117.96 + lon_ob(i) = lon_ob(i) + 360.
117.97 +
117.98 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
117.99 +
117.100 + val_model = yo(pts|:,time|:)
117.101 +; printVarSummary (val_model)
117.102 +; print (min(val_model)+"/"+max(val_model))
117.103 +
117.104 +; remove annual mean
117.105 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
117.106 +; print (min(val_model)+"/"+max(val_model))
117.107 +
117.108 + plot_sta = new((/2,12/),float)
117.109 + plot_sta@long_name = "Seasonal CO2"
117.110 +
117.111 + mon = ispan(1,12,1)
117.112 + mon@long_name = "month"
117.113 +
117.114 + plot_type = "ps"
117.115 + plot_type_new = "png"
117.116 +
117.117 + res = True ; plot mods desired
117.118 + res@xyLineThicknesses = (/1.0,2.0/) ; make 2nd lines thicker
117.119 + res@xyLineColors = (/"blue","red"/) ; change line color
117.120 +
117.121 +;------------------------------------------------------------------
117.122 +; Add a boxed legend using the more simple method, which won't have
117.123 +; vertical lines going through the markers.
117.124 +
117.125 + res@pmLegendDisplayMode = "Always"
117.126 +; res@pmLegendWidthF = 0.1
117.127 + res@pmLegendWidthF = 0.08
117.128 + res@pmLegendHeightF = 0.05
117.129 +; res@pmLegendOrthogonalPosF = -1.17
117.130 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
117.131 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
117.132 +
117.133 +; res@pmLegendParallelPosF = 0.18
117.134 + res@pmLegendParallelPosF = 0.23 ;(rightward)
117.135 +
117.136 +; res@lgPerimOn = False
117.137 + res@lgLabelFontHeightF = 0.015
117.138 + res@xyExplicitLegendLabels = (/"observed","model_b30.061m"/)
117.139 +;-------------------------------------------------------------------
117.140 +
117.141 + nzone = 4
117.142 + do z = 0,nzone-1
117.143 +
117.144 + if (z .eq. 0) then
117.145 +; maximum score for the zone, 60N-90N
117.146 + score_max = 5.0
117.147 +; index of stations in this zone
117.148 + ind_z = ind(lat_ob .ge. 60.)
117.149 +; print (ind_z)
117.150 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
117.151 +; print (val_ob(ind_z,:))
117.152 +; print (val_model(ind_z,:))
117.153 + end if
117.154 +
117.155 + if (z .eq. 1) then
117.156 +; maximum score for the zone, 30N-60N
117.157 + score_max = 5.0
117.158 +; index of stations in this zone
117.159 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
117.160 +; print (ind_z)
117.161 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
117.162 +; print (val_ob(ind_z,:))
117.163 +; print (val_model(ind_z,:))
117.164 + end if
117.165 +
117.166 + if (z .eq. 2) then
117.167 +; maximum score for the zone, EQ-30N
117.168 + score_max = 5.0
117.169 +; index of stations in this zone
117.170 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
117.171 +; print (ind_z)
117.172 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
117.173 +; print (val_ob(ind_z,:))
117.174 +; print (val_model(ind_z,:))
117.175 + end if
117.176 +
117.177 + if (z .eq. 3) then
117.178 +; maximum score for the zone, 90S-EQ
117.179 + score_max = 5.0
117.180 +; index of stations in this zone
117.181 + ind_z = ind(lat_ob .lt. 0. )
117.182 +; print (ind_z)
117.183 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
117.184 +; print (val_ob(ind_z,:))
117.185 +; print (val_model(ind_z,:))
117.186 + end if
117.187 +
117.188 + npts = dimsizes(ind_z)
117.189 + print (npts)
117.190 +
117.191 + do n=0,npts-1
117.192 +
117.193 + plot_sta(0,:) = (/val_ob(ind_z(n),:)/)
117.194 + plot_sta(1,:) = (/val_model(ind_z(n),:)/)
117.195 +
117.196 + title = sta(ind_z(n))+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
117.197 + plot_name = sta(ind_z(n))
117.198 +
117.199 +; print (title)
117.200 +; print (plot_name)
117.201 +
117.202 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
117.203 + res@tiMainString = title ; add title
117.204 +
117.205 + plot = gsn_csm_xy (wks,mon,plot_sta,res) ; create plot
117.206 + frame(wks)
117.207 +
117.208 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
117.209 + system("rm "+plot_name+"."+plot_type)
117.210 + system("rm "+plot_name+"-1."+plot_type_new)
117.211 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
117.212 + clear (wks)
117.213 + end do
117.214 +
117.215 + delete (ind_z)
117.216 +
117.217 + end do
117.218 +end
118.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
118.2 +++ b/co2/22.lines.ncl Mon Jan 26 22:08:20 2009 -0500
118.3 @@ -0,0 +1,247 @@
118.4 +; ***********************************************
118.5 +; add zone plot to 21.lines.ncl
118.6 +; ***********************************************
118.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
118.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
118.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
118.10 +;************************************************
118.11 +begin
118.12 +;************************************************
118.13 +; read in data: observed
118.14 +;************************************************
118.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
118.16 + fili = "co2_globalView_98.nc"
118.17 + g = addfile (diri+fili,"r")
118.18 + val = g->CO2_SEAS
118.19 + lon = g->LON
118.20 + lat = g->LAT
118.21 + sta = chartostring(g->STATION)
118.22 + delete (g)
118.23 +
118.24 +;print (sta(0))
118.25 +
118.26 + ncase = dimsizes(lat)
118.27 +;print (ncase)
118.28 +
118.29 +;**************************************************************
118.30 +; get only the lowest level at each station
118.31 +;**************************************************************
118.32 + lat_tmp = lat
118.33 + lat_tmp@_FillValue = 1.e+36
118.34 +
118.35 + do n = 0,ncase-1
118.36 + if (.not. ismissing(lat_tmp(n))) then
118.37 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
118.38 + if (dimsizes(indexes) .gt. 1) then
118.39 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
118.40 + end if
118.41 + delete (indexes)
118.42 + end if
118.43 + end do
118.44 +
118.45 + indexes = ind(.not. ismissing(lat_tmp))
118.46 +;print (dimsizes(indexes))
118.47 +;print (indexes)
118.48 +
118.49 + lat_ob = lat(indexes)
118.50 + lon_ob = lon(indexes)
118.51 + val_ob = val(indexes,:)
118.52 +;printVarSummary (val_ob)
118.53 +;print (lat_ob +"/"+lon_ob)
118.54 +
118.55 +;************************************************
118.56 +; read in model data
118.57 +;************************************************
118.58 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
118.59 + fili2 = "b30.061m_401_425_MONS_climo.nc"
118.60 +
118.61 + g = addfile(diri2+fili2,"r")
118.62 + x = g->CO2
118.63 + xi = g->lon
118.64 + yi = g->lat
118.65 + xdim = dimsizes(x)
118.66 + nlev = xdim(1)
118.67 + y = x(:,0,:,:)
118.68 +; printVarSummary (y)
118.69 +
118.70 +; get the co2 at the lowest level
118.71 + y = x(:,nlev-1,:,:)
118.72 +
118.73 +; change to unit of observed (u mol/mol)
118.74 +; Model_units [=] kgCO2 / kgDryAir
118.75 +; 28.966 = molecular weight of dry air
118.76 +; 44. = molecular weight of CO2
118.77 +; u mol = 1e-6 mol
118.78 +
118.79 + factor = (28.966/44.) * 1e6
118.80 + y = y * factor
118.81 +
118.82 + y@_FillValue = 1.e36
118.83 + y@units = "u mol/mol"
118.84 +; y = where(y0 .lt. 287.,y@_FillValue,y)
118.85 +; printVarSummary (y)
118.86 +; print (min(y)+"/"+max(y))
118.87 +
118.88 +; interpolate into observed station
118.89 +; note: model is 0-360E, 90S-90N
118.90 +
118.91 +; to be able to handle observation at (-89.98,-24.80)
118.92 + print (yi(0))
118.93 + yi(0) = -90.
118.94 +
118.95 + i = ind(lon_ob .lt. 0.)
118.96 + lon_ob(i) = lon_ob(i) + 360.
118.97 +
118.98 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
118.99 +
118.100 + val_model = yo(pts|:,time|:)
118.101 +; printVarSummary (val_model)
118.102 +; print (min(val_model)+"/"+max(val_model))
118.103 +
118.104 +; remove annual mean
118.105 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
118.106 +; print (min(val_model)+"/"+max(val_model))
118.107 +
118.108 + plot_sta = new((/2,12/),float)
118.109 + plot_sta@long_name = "Seasonal CO2"
118.110 +
118.111 + mon = ispan(1,12,1)
118.112 + mon@long_name = "month"
118.113 +
118.114 + plot_type = "ps"
118.115 + plot_type_new = "png"
118.116 +
118.117 + res = True ; plot mods desired
118.118 + res@xyLineThicknesses = (/1.0,2.0/) ; make 2nd lines thicker
118.119 + res@xyLineColors = (/"blue","red"/) ; change line color
118.120 +
118.121 +;------------------------------------------------------------------
118.122 +; Add a boxed legend using the more simple method, which won't have
118.123 +; vertical lines going through the markers.
118.124 +
118.125 + res@pmLegendDisplayMode = "Always"
118.126 +; res@pmLegendWidthF = 0.1
118.127 + res@pmLegendWidthF = 0.08
118.128 + res@pmLegendHeightF = 0.05
118.129 +; res@pmLegendOrthogonalPosF = -1.17
118.130 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
118.131 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
118.132 +
118.133 +; res@pmLegendParallelPosF = 0.18
118.134 + res@pmLegendParallelPosF = 0.23 ;(rightward)
118.135 +
118.136 +; res@lgPerimOn = False
118.137 + res@lgLabelFontHeightF = 0.015
118.138 + res@xyExplicitLegendLabels = (/"observed","model_b30.061m"/)
118.139 +;-------------------------------------------------------------------
118.140 +
118.141 + nzone = 4
118.142 + do z = 0,nzone-1
118.143 +
118.144 + if (z .eq. 0) then
118.145 +; maximum score for the zone, 60N-90N
118.146 + score_max = 5.0
118.147 + zone = "60N-90N"
118.148 +; index of stations in this zone
118.149 + ind_z = ind(lat_ob .ge. 60.)
118.150 +; print (ind_z)
118.151 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
118.152 +; print (val_ob(ind_z,:))
118.153 +; print (val_model(ind_z,:))
118.154 + end if
118.155 +
118.156 + if (z .eq. 1) then
118.157 +; maximum score for the zone, 30N-60N
118.158 + score_max = 5.0
118.159 + zone = "30N-60N"
118.160 +; index of stations in this zone
118.161 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
118.162 +; print (ind_z)
118.163 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
118.164 +; print (val_ob(ind_z,:))
118.165 +; print (val_model(ind_z,:))
118.166 + end if
118.167 +
118.168 + if (z .eq. 2) then
118.169 +; maximum score for the zone, EQ-30N
118.170 + score_max = 5.0
118.171 + zone = "EQ-30N"
118.172 +; index of stations in this zone
118.173 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
118.174 +; print (ind_z)
118.175 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
118.176 +; print (val_ob(ind_z,:))
118.177 +; print (val_model(ind_z,:))
118.178 + end if
118.179 +
118.180 + if (z .eq. 3) then
118.181 +; maximum score for the zone, 90S-EQ
118.182 + score_max = 5.0
118.183 + zone = "90S-EQ"
118.184 +; index of stations in this zone
118.185 + ind_z = ind(lat_ob .lt. 0. )
118.186 +; print (ind_z)
118.187 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
118.188 +; print (val_ob(ind_z,:))
118.189 +; print (val_model(ind_z,:))
118.190 + end if
118.191 +
118.192 + npts = dimsizes(ind_z)
118.193 + print (npts)
118.194 +
118.195 + npts_str = ""
118.196 + npts_str = npts
118.197 +;print (npts_str)
118.198 +
118.199 + plot_zon = new((/2,12,npts/),float)
118.200 +
118.201 + do n=0,npts-1
118.202 + plot_zon(0,:,n) = (/val_ob(ind_z(n),:)/)
118.203 + plot_zon(1,:,n) = (/val_model(ind_z(n),:)/)
118.204 +
118.205 +; plot_sta(0,:) = (/val_ob(ind_z(n),:)/)
118.206 +; plot_sta(1,:) = (/val_model(ind_z(n),:)/)
118.207 +
118.208 +; title = sta(ind_z(n))+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
118.209 +; plot_name = sta(ind_z(n))
118.210 +
118.211 +; print (title)
118.212 +; print (plot_name)
118.213 +
118.214 +; wks = gsn_open_wks (plot_type,plot_name) ; open workstation
118.215 +; res@tiMainString = title ; add title
118.216 +
118.217 +; plot = gsn_csm_xy (wks,mon,plot_sta,res) ; create plot
118.218 +; frame(wks)
118.219 +
118.220 +; system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
118.221 +; system("rm "+plot_name+"."+plot_type)
118.222 +; system("rm "+plot_name+"-1."+plot_type_new)
118.223 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
118.224 +; clear (wks)
118.225 + end do
118.226 +
118.227 + plot_sta = dim_avg(plot_zon)
118.228 +
118.229 + plot_name = "All_"+npts_str
118.230 + title = plot_name + " in "+ zone
118.231 +
118.232 + print (title)
118.233 + print (plot_name)
118.234 +
118.235 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
118.236 + res@tiMainString = title ; add title
118.237 +
118.238 + plot = gsn_csm_xy (wks,mon,plot_sta,res) ; create plot
118.239 + frame(wks)
118.240 +
118.241 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
118.242 + system("rm "+plot_name+"."+plot_type)
118.243 + system("rm "+plot_name+"-1."+plot_type_new)
118.244 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
118.245 + clear (wks)
118.246 + delete (ind_z)
118.247 + delete (plot_zon)
118.248 +
118.249 + end do
118.250 +end
119.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
119.2 +++ b/co2/23.lines.ncl Mon Jan 26 22:08:20 2009 -0500
119.3 @@ -0,0 +1,288 @@
119.4 +; ***********************************************
119.5 +; add panel plot to 22.lines.ncl
119.6 +; add zone plot to 21.lines.ncl
119.7 +; ***********************************************
119.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
119.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
119.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
119.11 +;************************************************
119.12 +begin
119.13 +;************************************************
119.14 +; read in data: observed
119.15 +;************************************************
119.16 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
119.17 + fili = "co2_globalView_98.nc"
119.18 + g = addfile (diri+fili,"r")
119.19 + val = g->CO2_SEAS
119.20 + lon = g->LON
119.21 + lat = g->LAT
119.22 + sta = chartostring(g->STATION)
119.23 + delete (g)
119.24 +
119.25 +;print (sta(0))
119.26 +
119.27 + ncase = dimsizes(lat)
119.28 +;print (ncase)
119.29 +
119.30 +;**************************************************************
119.31 +; get only the lowest level at each station
119.32 +;**************************************************************
119.33 + lat_tmp = lat
119.34 + lat_tmp@_FillValue = 1.e+36
119.35 +
119.36 + do n = 0,ncase-1
119.37 + if (.not. ismissing(lat_tmp(n))) then
119.38 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
119.39 + if (dimsizes(indexes) .gt. 1) then
119.40 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
119.41 + end if
119.42 + delete (indexes)
119.43 + end if
119.44 + end do
119.45 +
119.46 + indexes = ind(.not. ismissing(lat_tmp))
119.47 +;print (dimsizes(indexes))
119.48 +;print (indexes)
119.49 +
119.50 + lat_ob = lat(indexes)
119.51 + lon_ob = lon(indexes)
119.52 + val_ob = val(indexes,:)
119.53 +;printVarSummary (val_ob)
119.54 +;print (lat_ob +"/"+lon_ob)
119.55 +
119.56 +;************************************************
119.57 +; read in model data
119.58 +;************************************************
119.59 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
119.60 +; fili2 = "b30.061m_401_425_MONS_climo.nc"
119.61 + fili2 = "b30.061n_1995-2004_MONS_climo.nc"
119.62 +
119.63 + g = addfile(diri2+fili2,"r")
119.64 + x = g->CO2
119.65 + xi = g->lon
119.66 + yi = g->lat
119.67 + xdim = dimsizes(x)
119.68 + nlev = xdim(1)
119.69 + y = x(:,0,:,:)
119.70 +; printVarSummary (y)
119.71 +
119.72 +; get the co2 at the lowest level
119.73 + y = x(:,nlev-1,:,:)
119.74 +
119.75 +; change to unit of observed (u mol/mol)
119.76 +; Model_units [=] kgCO2 / kgDryAir
119.77 +; 28.966 = molecular weight of dry air
119.78 +; 44. = molecular weight of CO2
119.79 +; u mol = 1e-6 mol
119.80 +
119.81 + factor = (28.966/44.) * 1e6
119.82 + y = y * factor
119.83 +
119.84 + y@_FillValue = 1.e36
119.85 + y@units = "u mol/mol"
119.86 +; y = where(y0 .lt. 287.,y@_FillValue,y)
119.87 +; printVarSummary (y)
119.88 +; print (min(y)+"/"+max(y))
119.89 +
119.90 +; interpolate into observed station
119.91 +; note: model is 0-360E, 90S-90N
119.92 +
119.93 +; to be able to handle observation at (-89.98,-24.80)
119.94 + print (yi(0))
119.95 + yi(0) = -90.
119.96 +
119.97 + i = ind(lon_ob .lt. 0.)
119.98 + lon_ob(i) = lon_ob(i) + 360.
119.99 +
119.100 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
119.101 +
119.102 + val_model = yo(pts|:,time|:)
119.103 + val_model_0 = val_model
119.104 +; printVarSummary (val_model)
119.105 +; print (min(val_model)+"/"+max(val_model))
119.106 +
119.107 +; remove annual mean
119.108 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
119.109 +; print (min(val_model)+"/"+max(val_model))
119.110 +
119.111 + mon = ispan(1,12,1)
119.112 + mon@long_name = "month"
119.113 +
119.114 + plot_type = "ps"
119.115 + plot_type_new = "png"
119.116 +
119.117 + res = True ; plot mods desired
119.118 + res@xyLineThicknesses = (/1.0,2.0/) ; make 2nd lines thicker
119.119 + res@xyLineColors = (/"red","blue"/) ; change line color
119.120 +
119.121 +;------------------------------------------------------------------
119.122 +; Add a boxed legend using the more simple method, which won't have
119.123 +; vertical lines going through the markers.
119.124 +
119.125 + res@pmLegendDisplayMode = "Always"
119.126 +; res@pmLegendWidthF = 0.1
119.127 + res@pmLegendWidthF = 0.08
119.128 + res@pmLegendHeightF = 0.05
119.129 +; res@pmLegendOrthogonalPosF = -1.17
119.130 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
119.131 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
119.132 +
119.133 +; res@pmLegendParallelPosF = 0.18
119.134 + res@pmLegendParallelPosF = 0.23 ;(rightward)
119.135 +
119.136 +; res@lgPerimOn = False
119.137 + res@lgLabelFontHeightF = 0.015
119.138 +; res@xyExplicitLegendLabels = (/"model_b30.061m","observed"/)
119.139 + res@xyExplicitLegendLabels = (/"model_b30.061n","observed"/)
119.140 +;-------------------------------------------------------------------
119.141 +
119.142 + nzone = 4
119.143 + do z = 0,nzone-1
119.144 +
119.145 + if (z .eq. 0) then
119.146 +; maximum score for the zone, 60N-90N
119.147 + score_max = 5.0
119.148 + zone = "60N-90N"
119.149 +; index of stations in this zone
119.150 + ind_z = ind(lat_ob .ge. 60.)
119.151 +; print (ind_z)
119.152 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
119.153 +; print (val_ob(ind_z,:))
119.154 +; print (val_model(ind_z,:))
119.155 + end if
119.156 +
119.157 + if (z .eq. 1) then
119.158 +; maximum score for the zone, 30N-60N
119.159 + score_max = 5.0
119.160 + zone = "30N-60N"
119.161 +; index of stations in this zone
119.162 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
119.163 +; print (ind_z)
119.164 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
119.165 +; print (val_ob(ind_z,:))
119.166 +; print (val_model(ind_z,:))
119.167 + end if
119.168 +
119.169 + if (z .eq. 2) then
119.170 +; maximum score for the zone, EQ-30N
119.171 + score_max = 5.0
119.172 + zone = "EQ-30N"
119.173 +; index of stations in this zone
119.174 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
119.175 +; print (ind_z)
119.176 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
119.177 +; print (val_ob(ind_z,:))
119.178 +; print (val_model(ind_z,:))
119.179 + end if
119.180 +
119.181 + if (z .eq. 3) then
119.182 +; maximum score for the zone, 90S-EQ
119.183 + score_max = 5.0
119.184 + zone = "90S-EQ"
119.185 +; index of stations in this zone
119.186 + ind_z = ind(lat_ob .lt. 0. )
119.187 +; print (ind_z)
119.188 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
119.189 +; print (val_ob(ind_z,:))
119.190 +; print (val_model(ind_z,:))
119.191 + end if
119.192 +
119.193 + npts = dimsizes(ind_z)
119.194 + print (npts)
119.195 +
119.196 + npts_str = ""
119.197 + npts_str = npts
119.198 +; print (npts_str)
119.199 +
119.200 + plot_data = new((/2,12,npts/),float)
119.201 + plot_data_0 = new((/12,npts/),float)
119.202 +
119.203 + plot_data!0 = "case"
119.204 + plot_data!1 = "month"
119.205 + plot_data!2 = "pts"
119.206 + plot_data@long_name = "CO2 Seasonal"
119.207 +
119.208 + plot_data_0!0 = "month"
119.209 + plot_data_0!1 = "pts"
119.210 + plot_data_0@long_name = "CO2"
119.211 +
119.212 + do n=0,npts-1
119.213 +
119.214 + plot_data(1,:,n) = (/val_ob(ind_z(n),:)/)
119.215 + plot_data(0,:,n) = (/val_model(ind_z(n),:)/)
119.216 + plot_data_0(:,n) = (/val_model_0(ind_z(n),:)/)
119.217 +
119.218 + title1 = sta(ind_z(n))+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
119.219 + plot_name = sta(ind_z(n))
119.220 +
119.221 +; print (title1)
119.222 +; print (plot_name)
119.223 +;***********************************************
119.224 +; create panel plot
119.225 +;***********************************************
119.226 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
119.227 + plot=new(2,graphic) ; create graphic array
119.228 + res@gsnFrame = False ; Do not draw plot
119.229 + res@gsnDraw = False ; Do not advance frame
119.230 +
119.231 + res@tiMainString = title1 ; add title
119.232 + plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res) ; create plot 1
119.233 +
119.234 +; title2 = "Model b30.061m"
119.235 + title2 = "Model b30.061n"
119.236 + res@tiMainString = title2 ; add title
119.237 + plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,n),res) ; create plot 2
119.238 +
119.239 + pres = True ; panel plot mods desired
119.240 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
119.241 + ; indiv. plots in panel
119.242 + pres@gsnMaximize = True ; fill the page
119.243 +
119.244 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
119.245 +
119.246 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
119.247 + system("rm "+plot_name+"."+plot_type)
119.248 +; system("rm "+plot_name+"-1."+plot_type_new)
119.249 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
119.250 + clear (wks)
119.251 + end do
119.252 +
119.253 +; plot zone average
119.254 +
119.255 + plot_name = "All_"+npts_str
119.256 + title = plot_name + " in "+ zone
119.257 +
119.258 + print (title)
119.259 + print (plot_name)
119.260 +
119.261 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
119.262 + plot=new(2,graphic) ; create graphic array
119.263 + res@gsnFrame = False ; Do not draw plot
119.264 + res@gsnDraw = False ; Do not advance frame
119.265 +
119.266 + res@tiMainString = title ; add title
119.267 + plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res) ; create plot 1
119.268 +
119.269 +; title2 = "Model b30.061m"
119.270 + title2 = "Model b30.061n"
119.271 + res@tiMainString = title2
119.272 + plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
119.273 +
119.274 + pres = True ; panel plot mods desired
119.275 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
119.276 + ; indiv. plots in panel
119.277 + pres@gsnMaximize = True ; fill the page
119.278 +
119.279 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
119.280 +
119.281 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
119.282 + system("rm "+plot_name+"."+plot_type)
119.283 +; system("rm "+plot_name+"-1."+plot_type_new)
119.284 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
119.285 +
119.286 + clear (wks)
119.287 + delete (ind_z)
119.288 + delete (plot_data)
119.289 + delete (plot_data_0)
119.290 + end do
119.291 +end
120.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
120.2 +++ b/co2/24.check.ncl Mon Jan 26 22:08:20 2009 -0500
120.3 @@ -0,0 +1,143 @@
120.4 +; ***********************************************
120.5 +; add another model to plot
120.6 +; add panel plot to 22.lines.ncl
120.7 +; add zone plot to 21.lines.ncl
120.8 +; ***********************************************
120.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
120.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
120.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
120.12 +;************************************************
120.13 +begin
120.14 +;************************************************
120.15 +; read in data: observed
120.16 +;************************************************
120.17 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
120.18 + fili = "co2_globalView_98.nc"
120.19 + g = addfile (diri+fili,"r")
120.20 + val = g->CO2_SEAS
120.21 + lon = g->LON
120.22 + lat = g->LAT
120.23 + sta = chartostring(g->STATION)
120.24 + delete (g)
120.25 +
120.26 +;print (sta(0))
120.27 +
120.28 + ncase = dimsizes(lat)
120.29 +;print (ncase)
120.30 +
120.31 +;**************************************************************
120.32 +; get only the lowest level at each station
120.33 +;**************************************************************
120.34 + lat_tmp = lat
120.35 + lat_tmp@_FillValue = 1.e+36
120.36 +
120.37 + do n = 0,ncase-1
120.38 + if (.not. ismissing(lat_tmp(n))) then
120.39 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
120.40 + if (dimsizes(indexes) .gt. 1) then
120.41 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
120.42 + end if
120.43 + delete (indexes)
120.44 + end if
120.45 + end do
120.46 +
120.47 + indexes = ind(.not. ismissing(lat_tmp))
120.48 +;print (dimsizes(indexes))
120.49 +;print (indexes)
120.50 +
120.51 + lat_ob = lat(indexes)
120.52 + lon_ob = lon(indexes)
120.53 + val_ob = val(indexes,:)
120.54 +;printVarSummary (val_ob)
120.55 +;print (lat_ob +"/"+lon_ob)
120.56 +
120.57 +;************************************************
120.58 +; read in model data
120.59 +;************************************************
120.60 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
120.61 + fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
120.62 + fili3 = "b30.061m_401_425_MONS_climo_atm.nc"
120.63 +;--------------------------------------------
120.64 + g = addfile(diri2+fili2,"r")
120.65 + x1 = g->CO2
120.66 + xi = g->lon
120.67 + yi = g->lat
120.68 + delete (g)
120.69 +
120.70 + xdim = dimsizes(x1)
120.71 + nlev = xdim(1)
120.72 +; y1 = x1(:,0,:,:)
120.73 + y1 = x1
120.74 +; printVarSummary (y1)
120.75 +
120.76 +; get the co2 at the lowest level
120.77 +; y1 = x1(:,nlev-1,:,:)
120.78 + delete (x1)
120.79 +;---------------------------------------------
120.80 +; g = addfile(diri2+fili3,"r")
120.81 +; x2 = g->CO2
120.82 +; delete (g)
120.83 +; y2 = x2(:,0,:,:)
120.84 +; y2 = x2(:,nlev-1,:,:)
120.85 +; delete (x2)
120.86 +;---------------------------------------------
120.87 +; change to unit of observed (u mol/mol)
120.88 +; Model_units [=] kgCO2 / kgDryAir
120.89 +; 28.966 = molecular weight of dry air
120.90 +; 44. = molecular weight of CO2
120.91 +; u mol = 1e-6 mol
120.92 +
120.93 + factor = (28.966/44.) * 1e6
120.94 +;---------------------------------------------
120.95 + y1 = y1 * factor
120.96 + y1@_FillValue = 1.e36
120.97 + y1@units = "u mol/mol"
120.98 +; y1 = where(y0 .lt. 287.,y1@_FillValue,y1)
120.99 +; printVarSummary (y1)
120.100 +; print (min(y1)+"/"+max(y1))
120.101 +;---------------------------------------------
120.102 +; y2 = y2 * factor
120.103 +; y2@_FillValue = 1.e36
120.104 +; y2@units = "u mol/mol"
120.105 +;---------------------------------------------
120.106 +; interpolate into observed station
120.107 +; note: model is 0-360E, 90S-90N
120.108 +; ob is -180-180, 90S-90N
120.109 +
120.110 +; to be able to handle observation at (-89.98,-24.80)
120.111 +; print (yi(0))
120.112 + yi(0) = -90.
120.113 +
120.114 + i = ind(lon_ob .lt. 0.)
120.115 + lon_ob(i) = lon_ob(i) + 360.
120.116 +;----------------------------------------------------------------
120.117 + yo = linint2_points_Wrap(xi,yi,y1,True,lon_ob,lat_ob,0)
120.118 + printVarSummary (yo)
120.119 +; yo:[time | 12] x [lev | 26] x [pts | 98]
120.120 +
120.121 + val_model1 = yo(pts|:,lev|:,time|:)
120.122 + delete (yo)
120.123 + val_model1_0 = val_model1
120.124 +; printVarSummary (val_model1)
120.125 +; print (min(val_model1)+"/"+max(val_model1))
120.126 +
120.127 +; remove annual mean
120.128 + val_model1 = val_model1 - conform(val_model1,dim_avg(val_model1),(/0,1/))
120.129 +; print (min(val_model1)+"/"+max(val_model1))
120.130 +
120.131 +;-----------------------------------------------------------------
120.132 +; index of station Barrow, Alaska (71.32,-156.60)
120.133 + ind_z = ind(lat_ob .eq. 71.32)
120.134 + print (ind_z)
120.135 + print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
120.136 + print ("observation at Barrow, Alaska (71.32,-156.60)")
120.137 + print (val_ob(ind_z,:))
120.138 + print ("model top atm at Barrow, Alaska (71.32,-156.60)")
120.139 + print (val_model1_0(ind_z,0,:))
120.140 + print ("model surface at Barrow, Alaska (71.32,-156.60)")
120.141 + print (val_model1_0(ind_z,nlev-1,:))
120.142 + print ("model top atm at Barrow, Alaska (71.32,-156.60)")
120.143 + print (val_model1(ind_z,0,:))
120.144 + print ("model surface at Barrow, Alaska (71.32,-156.60)")
120.145 + print (val_model1(ind_z,nlev-1,:))
120.146 +end
121.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
121.2 +++ b/co2/24.lines.ncl Mon Jan 26 22:08:20 2009 -0500
121.3 @@ -0,0 +1,319 @@
121.4 +; ***********************************************
121.5 +; add another model to plot
121.6 +; add panel plot to 22.lines.ncl
121.7 +; add zone plot to 21.lines.ncl
121.8 +; ***********************************************
121.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
121.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
121.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
121.12 +;************************************************
121.13 +begin
121.14 +;************************************************
121.15 +; read in data: observed
121.16 +;************************************************
121.17 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
121.18 + fili = "co2_globalView_98.nc"
121.19 + g = addfile (diri+fili,"r")
121.20 + val = g->CO2_SEAS
121.21 + lon = g->LON
121.22 + lat = g->LAT
121.23 + sta = chartostring(g->STATION)
121.24 + delete (g)
121.25 +
121.26 +;print (sta(0))
121.27 +
121.28 + ncase = dimsizes(lat)
121.29 +;print (ncase)
121.30 +
121.31 +;**************************************************************
121.32 +; get only the lowest level at each station
121.33 +;**************************************************************
121.34 + lat_tmp = lat
121.35 + lat_tmp@_FillValue = 1.e+36
121.36 +
121.37 + do n = 0,ncase-1
121.38 + if (.not. ismissing(lat_tmp(n))) then
121.39 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
121.40 + if (dimsizes(indexes) .gt. 1) then
121.41 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
121.42 + end if
121.43 + delete (indexes)
121.44 + end if
121.45 + end do
121.46 +
121.47 + indexes = ind(.not. ismissing(lat_tmp))
121.48 +;print (dimsizes(indexes))
121.49 +;print (indexes)
121.50 +
121.51 + lat_ob = lat(indexes)
121.52 + lon_ob = lon(indexes)
121.53 + val_ob = val(indexes,:)
121.54 +;printVarSummary (val_ob)
121.55 +;print (lat_ob +"/"+lon_ob)
121.56 +
121.57 +;************************************************
121.58 +; read in model data
121.59 +;************************************************
121.60 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
121.61 + fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
121.62 + fili3 = "b30.061m_401_425_MONS_climo_atm.nc"
121.63 +;--------------------------------------------
121.64 + g = addfile(diri2+fili2,"r")
121.65 + x1 = g->CO2
121.66 + xi = g->lon
121.67 + yi = g->lat
121.68 + delete (g)
121.69 +
121.70 + xdim = dimsizes(x1)
121.71 + nlev = xdim(1)
121.72 + y1 = x1(:,0,:,:)
121.73 +; printVarSummary (y1)
121.74 +
121.75 +; get the co2 at the lowest level
121.76 + y1 = x1(:,nlev-1,:,:)
121.77 + delete (x1)
121.78 +;---------------------------------------------
121.79 + g = addfile(diri2+fili3,"r")
121.80 + x2 = g->CO2
121.81 + delete (g)
121.82 + y2 = x2(:,0,:,:)
121.83 + y2 = x2(:,nlev-1,:,:)
121.84 + delete (x2)
121.85 +;---------------------------------------------
121.86 +; change to unit of observed (u mol/mol)
121.87 +; Model_units [=] kgCO2 / kgDryAir
121.88 +; 28.966 = molecular weight of dry air
121.89 +; 44. = molecular weight of CO2
121.90 +; u mol = 1e-6 mol
121.91 +
121.92 + factor = (28.966/44.) * 1e6
121.93 +;---------------------------------------------
121.94 + y1 = y1 * factor
121.95 + y1@_FillValue = 1.e36
121.96 + y1@units = "u mol/mol"
121.97 +; y1 = where(y0 .lt. 287.,1y@_FillValue,y1)
121.98 +; printVarSummary (y1)
121.99 +; print (min(y1)+"/"+max(y1))
121.100 +;---------------------------------------------
121.101 + y2 = y2 * factor
121.102 + y2@_FillValue = 1.e36
121.103 + y2@units = "u mol/mol"
121.104 +;---------------------------------------------
121.105 +; interpolate into observed station
121.106 +; note: model is 0-360E, 90S-90N
121.107 +; ob is -180-180, 90S-90N
121.108 +
121.109 +; to be able to handle observation at (-89.98,-24.80)
121.110 + print (yi(0))
121.111 + yi(0) = -90.
121.112 +
121.113 + i = ind(lon_ob .lt. 0.)
121.114 + lon_ob(i) = lon_ob(i) + 360.
121.115 +;----------------------------------------------------------------
121.116 + yo = linint2_points_Wrap(xi,yi,y1,True,lon_ob,lat_ob,0)
121.117 +
121.118 + val_model1 = yo(pts|:,time|:)
121.119 + val_model1_0 = val_model1
121.120 +; printVarSummary (val_model1)
121.121 +; print (min(val_model1)+"/"+max(val_model1))
121.122 +
121.123 +; remove annual mean
121.124 + val_model1 = val_model1 - conform(val_model1,dim_avg(val_model1),0)
121.125 +; print (min(val_model1)+"/"+max(val_model1))
121.126 + delete (yo)
121.127 +;-----------------------------------------------------------------
121.128 + yo = linint2_points_Wrap(xi,yi,y2,True,lon_ob,lat_ob,0)
121.129 +
121.130 + val_model2 = yo(pts|:,time|:)
121.131 + val_model2_0 = val_model2
121.132 +; printVarSummary (val_model2)
121.133 +; print (min(val_model2)+"/"+max(val_model2))
121.134 +
121.135 +; remove annual mean
121.136 + val_model2 = val_model2 - conform(val_model2,dim_avg(val_model2),0)
121.137 +; print (min(val_model2)+"/"+max(val_model2))
121.138 + delete (yo)
121.139 +;-----------------------------------------------------------------
121.140 +; for x-axis in xyplot
121.141 + mon = ispan(1,12,1)
121.142 + mon@long_name = "month"
121.143 +;-----------------------------------------------------------------
121.144 + plot_type = "ps"
121.145 + plot_type_new = "png"
121.146 +
121.147 + res = True ; plot mods desired
121.148 + res@xyLineThicknesses = (/2.0,2.0,2.0/) ; make 2nd lines thicker
121.149 + res@xyLineColors = (/"red","blue","black"/) ; change line color
121.150 +;------------------------------------------------------------------
121.151 +; Add a boxed legend using the more simple method
121.152 +
121.153 + res@pmLegendDisplayMode = "Always"
121.154 +; res@pmLegendWidthF = 0.1
121.155 + res@pmLegendWidthF = 0.08
121.156 + res@pmLegendHeightF = 0.06
121.157 +; res@pmLegendOrthogonalPosF = -1.17
121.158 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
121.159 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
121.160 +
121.161 +; res@pmLegendParallelPosF = 0.18
121.162 + res@pmLegendParallelPosF = 0.23 ;(rightward)
121.163 +
121.164 +; res@lgPerimOn = False
121.165 + res@lgLabelFontHeightF = 0.015
121.166 + res@xyExplicitLegendLabels = (/"b30.061n","b30.061m","observed"/)
121.167 +;-------------------------------------------------------------------
121.168 +
121.169 + nzone = 4
121.170 + do z = 0,nzone-1
121.171 +
121.172 + if (z .eq. 0) then
121.173 +; maximum score for the zone, 60N-90N
121.174 + score_max = 5.0
121.175 + zone = "60N-90N"
121.176 +; index of stations in this zone
121.177 + ind_z = ind(lat_ob .ge. 60.)
121.178 +; print (ind_z)
121.179 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
121.180 +; print (val_ob(ind_z,:))
121.181 +; print (val_model(ind_z,:))
121.182 + end if
121.183 +
121.184 + if (z .eq. 1) then
121.185 +; maximum score for the zone, 30N-60N
121.186 + score_max = 5.0
121.187 + zone = "30N-60N"
121.188 +; index of stations in this zone
121.189 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
121.190 +; print (ind_z)
121.191 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
121.192 +; print (val_ob(ind_z,:))
121.193 +; print (val_model(ind_z,:))
121.194 + end if
121.195 +
121.196 + if (z .eq. 2) then
121.197 +; maximum score for the zone, EQ-30N
121.198 + score_max = 5.0
121.199 + zone = "EQ-30N"
121.200 +; index of stations in this zone
121.201 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
121.202 +; print (ind_z)
121.203 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
121.204 +; print (val_ob(ind_z,:))
121.205 +; print (val_model(ind_z,:))
121.206 + end if
121.207 +
121.208 + if (z .eq. 3) then
121.209 +; maximum score for the zone, 90S-EQ
121.210 + score_max = 5.0
121.211 + zone = "90S-EQ"
121.212 +; index of stations in this zone
121.213 + ind_z = ind(lat_ob .lt. 0. )
121.214 +; print (ind_z)
121.215 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
121.216 +; print (val_ob(ind_z,:))
121.217 +; print (val_model(ind_z,:))
121.218 + end if
121.219 +
121.220 + npts = dimsizes(ind_z)
121.221 + print (npts)
121.222 +
121.223 + npts_str = ""
121.224 + npts_str = npts
121.225 +; print (npts_str)
121.226 +
121.227 + plot_data = new((/3,12,npts/),float)
121.228 + plot_data_0 = new((/2,12,npts/),float)
121.229 +
121.230 + plot_data!0 = "case"
121.231 + plot_data!1 = "month"
121.232 + plot_data!2 = "pts"
121.233 + plot_data@long_name = "CO2 Seasonal"
121.234 +
121.235 + plot_data_0!0 = "month"
121.236 + plot_data_0!1 = "pts"
121.237 + plot_data_0@long_name = "CO2"
121.238 +
121.239 + do n=0,npts-1
121.240 +
121.241 + plot_data(0,:,n) = (/val_model1(ind_z(n),:)/)
121.242 + plot_data(1,:,n) = (/val_model2(ind_z(n),:)/)
121.243 + plot_data(2,:,n) = (/val_ob(ind_z(n),:)/)
121.244 +
121.245 + plot_data_0(0,:,n) = (/val_model1_0(ind_z(n),:)/)
121.246 + plot_data_0(1,:,n) = (/val_model2_0(ind_z(n),:)/)
121.247 +
121.248 +;*****************************************************
121.249 +; create plot with 3 lines for each observed station
121.250 +;*****************************************************
121.251 + plot_name = sta(ind_z(n))
121.252 + title = plot_name+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
121.253 +; print (title)
121.254 +; print (plot_name)
121.255 +
121.256 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
121.257 +;---------------------------------------------------------------------------
121.258 +; for panel plot
121.259 +
121.260 + plot=new(2,graphic) ; create graphic array
121.261 + res@gsnFrame = False ; Do not draw plot
121.262 + res@gsnDraw = False ; Do not advance frame
121.263 +
121.264 + pres = True ; panel plot mods desired
121.265 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
121.266 + ; indiv. plots in panel
121.267 + pres@gsnMaximize = True ; fill the page
121.268 +;---------------------------------------------------------------------------
121.269 + res@tiMainString = title ; add title
121.270 +
121.271 + plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res) ; create plot 1
121.272 +
121.273 +; plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,:,n),res) ; create plot 2
121.274 + plot(1)=gsn_csm_xy(wks,mon,plot_data_0(0,:,n),res) ; create plot 2
121.275 +
121.276 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
121.277 +
121.278 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
121.279 + system("rm "+plot_name+"."+plot_type)
121.280 + clear (wks)
121.281 + end do
121.282 +;*****************************************************************************
121.283 +; plot zone average
121.284 +;*****************************************************************************
121.285 + plot_name = "All_"+npts_str
121.286 + title = plot_name + " in "+ zone
121.287 +; print (title)
121.288 +; print (plot_name)
121.289 +
121.290 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
121.291 +;---------------------------------------------------------------------------
121.292 +; for panel plot
121.293 +
121.294 + plot=new(2,graphic) ; create graphic array
121.295 + res@gsnFrame = False ; Do not draw plot
121.296 + res@gsnDraw = False ; Do not advance frame
121.297 +
121.298 + pres = True ; panel plot mods desired
121.299 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
121.300 + ; indiv. plots in panel
121.301 + pres@gsnMaximize = True ; fill the page
121.302 +;---------------------------------------------------------------------------
121.303 + res@tiMainString = title ; add title
121.304 +
121.305 + plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res) ; create plot 1
121.306 +
121.307 +; plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
121.308 +
121.309 + xx = dim_avg_Wrap(plot_data_0)
121.310 + plot(1) = gsn_csm_xy (wks,mon,xx(0,:),res) ; create plot 2
121.311 +
121.312 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
121.313 +
121.314 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
121.315 + system("rm "+plot_name+"."+plot_type)
121.316 +
121.317 + clear (wks)
121.318 + delete (ind_z)
121.319 + delete (plot_data)
121.320 + delete (plot_data_0)
121.321 + end do
121.322 +end
122.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
122.2 +++ b/co2/31.contour_model.ncl Mon Jan 26 22:08:20 2009 -0500
122.3 @@ -0,0 +1,61 @@
122.4 +;*************************************************
122.5 +; ce_1.ncl
122.6 +;************************************************
122.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
122.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
122.9 +;************************************************
122.10 +begin
122.11 +;************************************************
122.12 +; read in model data
122.13 +;************************************************
122.14 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
122.15 + fili = "b30.061m_401_425_ANN_climo.nc"
122.16 +
122.17 + g = addfile(diri+fili,"r")
122.18 + x = g->CO2
122.19 + xdim = dimsizes(x)
122.20 + nlev = xdim(1)
122.21 + y0 = x(0,0,:,:)
122.22 +
122.23 +; get the co2 at the lowest level
122.24 + y0 = x(0,nlev-1,:,:)
122.25 +
122.26 +; change to unit of observed (u mol/mol)
122.27 +; Model_units [=] kgCO2 / kgDryAir
122.28 +; 28.966 = molecular weight of dry air
122.29 +; 44. = molecular weight of CO2
122.30 +; u mol = 1e-6 mol
122.31 +
122.32 + factor = (28.966/44.) * 1e6
122.33 + y0 = y0 * factor
122.34 +
122.35 + y0@_FillValue = 1.e36
122.36 + y0@units = "u mol/mol"
122.37 +; y0 = where(y0 .lt. 287.,y0@_FillValue,y0)
122.38 + print (min(y0)+"/"+max(y0))
122.39 +
122.40 +;************************************************
122.41 +; create default plot
122.42 +;************************************************
122.43 +
122.44 + wks = gsn_open_wks("ps","xy") ; open a ps file
122.45 + gsn_define_colormap(wks,"gui_default") ; choose colormap
122.46 +
122.47 + res = True ; Use plot options
122.48 + res@cnFillOn = True ; Turn on color fill
122.49 + res@gsnSpreadColors = True ; use full colormap
122.50 +; res@cnFillMode = "RasterFill" ; Turn on raster color
122.51 +; res@lbLabelAutoStride = True
122.52 + res@cnLinesOn = False ; Turn off contourn lines
122.53 + res@mpFillOn = False ; Turn off map fill
122.54 + res@tiMainString = "Model b30.061m 401-425"
122.55 +
122.56 + res@gsnSpreadColors = True ; use full colormap
122.57 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
122.58 + res@cnMinLevelValF = 286. ; Min level
122.59 + res@cnMaxLevelValF = 310. ; Max level
122.60 + res@cnLevelSpacingF = 2. ; interval
122.61 +
122.62 + plot = gsn_csm_contour_map_ce(wks,y0,res) ; for model
122.63 + system("convert xy.ps xy.png")
122.64 +end
122.65 \ No newline at end of file
123.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
123.2 +++ b/co2/41.metric+lines.ncl Mon Jan 26 22:08:20 2009 -0500
123.3 @@ -0,0 +1,396 @@
123.4 +; ***********************************************
123.5 +; combine 19.metric_plot.ncl and 24.lines.ncl
123.6 +; ***********************************************
123.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
123.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
123.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
123.10 +load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
123.11 +;************************************************
123.12 +begin
123.13 +;************************************************
123.14 +; read in data: observed
123.15 +;************************************************
123.16 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
123.17 + fili = "co2_globalView_98.nc"
123.18 + g = addfile (diri+fili,"r")
123.19 + val = g->CO2_SEAS
123.20 + lon = g->LON
123.21 + lat = g->LAT
123.22 + sta = chartostring(g->STATION)
123.23 + delete (g)
123.24 +
123.25 +;print (sta(0))
123.26 +
123.27 + ncase = dimsizes(lat)
123.28 +;print (ncase)
123.29 +
123.30 +;**************************************************************
123.31 +; get only the lowest level at each station
123.32 +;**************************************************************
123.33 + lat_tmp = lat
123.34 + lat_tmp@_FillValue = 1.e+36
123.35 +
123.36 + do n = 0,ncase-1
123.37 + if (.not. ismissing(lat_tmp(n))) then
123.38 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
123.39 + if (dimsizes(indexes) .gt. 1) then
123.40 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
123.41 + end if
123.42 + delete (indexes)
123.43 + end if
123.44 + end do
123.45 +
123.46 + indexes = ind(.not. ismissing(lat_tmp))
123.47 +;print (dimsizes(indexes))
123.48 +;print (indexes)
123.49 +
123.50 + lat_ob = lat(indexes)
123.51 + lon_ob = lon(indexes)
123.52 + val_ob = val(indexes,:)
123.53 +;printVarSummary (val_ob)
123.54 +;print (lat_ob +"/"+lon_ob)
123.55 +
123.56 +;************************************************
123.57 +; read in model data
123.58 +;************************************************
123.59 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
123.60 +; fili2 = "b30.061m_401_425_MONS_climo_atm.nc"
123.61 + fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
123.62 +
123.63 + g = addfile(diri2+fili2,"r")
123.64 + x = g->CO2
123.65 + xi = g->lon
123.66 + yi = g->lat
123.67 + xdim = dimsizes(x)
123.68 + nlev = xdim(1)
123.69 + y = x(:,0,:,:)
123.70 +; printVarSummary (y)
123.71 +
123.72 +; get the co2 at the lowest level
123.73 + y = x(:,nlev-1,:,:)
123.74 +
123.75 +; change to unit of observed (u mol/mol)
123.76 +; Model_units [=] kgCO2 / kgDryAir
123.77 +; 28.966 = molecular weight of dry air
123.78 +; 44. = molecular weight of CO2
123.79 +; u mol = 1e-6 mol
123.80 +
123.81 + factor = (28.966/44.) * 1e6
123.82 + y = y * factor
123.83 +
123.84 + y@_FillValue = 1.e36
123.85 + y@units = "u mol/mol"
123.86 +; y = where(y0 .lt. 287.,y@_FillValue,y)
123.87 +; printVarSummary (y)
123.88 +; print (min(y)+"/"+max(y))
123.89 +
123.90 +; interpolate into observed station
123.91 +; note: model is 0-360E, 90S-90N
123.92 +
123.93 +; to be able to handle observation at (-89.98,-24.80)
123.94 + print (yi(0))
123.95 + yi(0) = -90.
123.96 +
123.97 + i = ind(lon_ob .lt. 0.)
123.98 + lon_ob(i) = lon_ob(i) + 360.
123.99 +
123.100 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
123.101 +
123.102 + val_model = yo(pts|:,time|:)
123.103 + val_model_0 = val_model
123.104 +; printVarSummary (val_model)
123.105 +; print (min(val_model)+"/"+max(val_model))
123.106 +
123.107 +; remove annual mean
123.108 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
123.109 +; print (min(val_model)+"/"+max(val_model))
123.110 +
123.111 + nzone = 4
123.112 +;--------------------------------------------------------------
123.113 +; for metric table plots
123.114 +; column
123.115 + case_zone = (/"Stations","Amplitude Ratio", \
123.116 + "Correlation Coef","M score","Combined Score"/)
123.117 + nCase_zone = dimsizes(case_zone )
123.118 +
123.119 +; row
123.120 + var_zone = (/"60N-90N","30N-60N","EQ-30N","90S-EQ","Total"/)
123.121 + nVar_zone = dimsizes(var_zone)
123.122 +
123.123 +; arrays to be passed to diagram.
123.124 + case_value_zone = new ((/nCase_zone, nVar_zone/),float )
123.125 +;--------------------------------------------------------------
123.126 +; for station line plot
123.127 +
123.128 +; for x-axis in xyplot
123.129 + mon = ispan(1,12,1)
123.130 + mon@long_name = "month"
123.131 +
123.132 + plot_type = "ps"
123.133 + plot_type_new = "png"
123.134 +
123.135 + res = True ; plot mods desired
123.136 + res@xyLineThicknesses = (/2.0,2.0,2.0/) ; make 2nd lines thicker
123.137 + res@xyLineColors = (/"red","black"/) ; change line color
123.138 +
123.139 +; Add a boxed legend using the more simple method
123.140 +
123.141 + res@pmLegendDisplayMode = "Always"
123.142 +; res@pmLegendWidthF = 0.1
123.143 + res@pmLegendWidthF = 0.08
123.144 + res@pmLegendHeightF = 0.06
123.145 +; res@pmLegendOrthogonalPosF = -1.17
123.146 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
123.147 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
123.148 +
123.149 +; res@pmLegendParallelPosF = 0.18
123.150 + res@pmLegendParallelPosF = 0.23 ;(rightward)
123.151 +
123.152 +; res@lgPerimOn = False
123.153 + res@lgLabelFontHeightF = 0.015
123.154 + res@xyExplicitLegendLabels = (/"b30.061n","observed"/)
123.155 +;-------------------------------------------------------------------
123.156 +
123.157 + do z = 0,nzone-1
123.158 +
123.159 + if (z .eq. 0) then
123.160 +; maximum score for the zone, 60N-90N
123.161 + zone = "60N-90N"
123.162 + score_max = 5.0
123.163 +; index of stations in this zone
123.164 + ind_z = ind(lat_ob .ge. 60.)
123.165 +; print (ind_z)
123.166 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
123.167 +; print (val_ob(ind_z,:))
123.168 +; print (val_model(ind_z,:))
123.169 + end if
123.170 +
123.171 + if (z .eq. 1) then
123.172 +; maximum score for the zone, 30N-60N
123.173 + zone = "30N-60N"
123.174 + score_max = 5.0
123.175 +; index of stations in this zone
123.176 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
123.177 +; print (ind_z)
123.178 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
123.179 +; print (val_ob(ind_z,:))
123.180 +; print (val_model(ind_z,:))
123.181 + end if
123.182 +
123.183 + if (z .eq. 2) then
123.184 +; maximum score for the zone, EQ-30N
123.185 + zone = "EQ-30N"
123.186 + score_max = 5.0
123.187 +; index of stations in this zone
123.188 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
123.189 +; print (ind_z)
123.190 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
123.191 +; print (val_ob(ind_z,:))
123.192 +; print (val_model(ind_z,:))
123.193 + end if
123.194 +
123.195 + if (z .eq. 3) then
123.196 +; maximum score for the zone, 90S-EQ
123.197 + zone = "90S-EQ"
123.198 + score_max = 5.0
123.199 +; index of stations in this zone
123.200 + ind_z = ind(lat_ob .lt. 0. )
123.201 +; print (ind_z)
123.202 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
123.203 +; print (val_ob(ind_z,:))
123.204 +; print (val_model(ind_z,:))
123.205 + end if
123.206 +
123.207 + npts = dimsizes(ind_z)
123.208 + print (npts)
123.209 +;-------------------------------------------------------------------------
123.210 +; for metric table plot
123.211 +
123.212 + amp_ob = new((/npts/),float)
123.213 + amp_model = new((/npts/),float)
123.214 +
123.215 + amp_ratio_sta = new((/npts/),float)
123.216 + ccr_sta = new((/npts/),float)
123.217 + M_sta = new((/npts/),float)
123.218 + score_sta = new((/npts/),float)
123.219 +;-------------------------------------------------------------------------
123.220 +; for station line plot
123.221 +
123.222 + npts_str = ""
123.223 + npts_str = npts
123.224 +; print (npts_str)
123.225 +
123.226 + plot_data = new((/2,12,npts/),float)
123.227 + plot_data_0 = new((/12,npts/),float)
123.228 +
123.229 + plot_data!0 = "case"
123.230 + plot_data!1 = "month"
123.231 + plot_data!2 = "pts"
123.232 + plot_data@long_name = "CO2 Seasonal"
123.233 +
123.234 + plot_data_0!0 = "month"
123.235 + plot_data_0!1 = "pts"
123.236 + plot_data_0@long_name = "CO2"
123.237 +;--------------------------------------------------------------------------
123.238 + do n=0,npts-1
123.239 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
123.240 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
123.241 +
123.242 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
123.243 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
123.244 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
123.245 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
123.246 +
123.247 + print (sta(ind_z(n))+"/"+lat(ind_z(n))+"/"+lon(ind_z(n))+"/"+amp_ratio_sta(n)+"/"+ccr_sta(n)+"/"+M_sta(n)+"/"+score_sta(n))
123.248 +;----------------------------------------------------------------------
123.249 +; for station line plot
123.250 +
123.251 + plot_data(0,:,n) = (/val_model(ind_z(n),:)/)
123.252 + plot_data(1,:,n) = (/val_ob(ind_z(n),:)/)
123.253 +
123.254 + plot_data_0(:,n) = (/val_model_0(ind_z(n),:)/)
123.255 +
123.256 + plot_name = sta(ind_z(n))
123.257 + title = plot_name+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
123.258 +; print (title)
123.259 +; print (plot_name)
123.260 +
123.261 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
123.262 +;------------------------------------------
123.263 +; for panel plot
123.264 +
123.265 + plot=new(2,graphic) ; create graphic array
123.266 + res@gsnFrame = False ; Do not draw plot
123.267 + res@gsnDraw = False ; Do not advance frame
123.268 +
123.269 + pres = True ; panel plot mods desired
123.270 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
123.271 + ; indiv. plots in panel
123.272 + pres@gsnMaximize = True ; fill the page
123.273 +;------------------------------------------
123.274 + res@tiMainString = title ; add title
123.275 +
123.276 + plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res) ; create plot 1
123.277 +
123.278 + plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,n),res) ; create plot 2
123.279 +
123.280 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
123.281 +
123.282 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
123.283 + system("rm "+plot_name+"."+plot_type)
123.284 + clear (wks)
123.285 +;---------------------------------------------------------------------------
123.286 + end do
123.287 +;-------------------------------------------------------------------------
123.288 +; fo line plot in a zone
123.289 +
123.290 + plot_name = "All_"+npts_str
123.291 + title = plot_name + " in "+ zone
123.292 +; print (title)
123.293 +; print (plot_name)
123.294 +
123.295 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
123.296 +;-----------------------------------------
123.297 +; for panel plot
123.298 +
123.299 + plot=new(2,graphic) ; create graphic array
123.300 + res@gsnFrame = False ; Do not draw plot
123.301 + res@gsnDraw = False ; Do not advance frame
123.302 +
123.303 + pres = True ; panel plot mods desired
123.304 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
123.305 + ; indiv. plots in panel
123.306 + pres@gsnMaximize = True ; fill the page
123.307 +;-----------------------------------------
123.308 + res@tiMainString = title ; add title
123.309 +
123.310 + plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res) ; create plot 1
123.311 +
123.312 + plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
123.313 +
123.314 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
123.315 +
123.316 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
123.317 + system("rm "+plot_name+"."+plot_type)
123.318 +
123.319 + clear (wks)
123.320 +; delete (ind_z)
123.321 + delete (plot_data)
123.322 + delete (plot_data_0)
123.323 +;---------------------------------------------------------------------------
123.324 +;---------------------------------------------------------------------------
123.325 +; metric table in a zone
123.326 +
123.327 + amp_ratio_zone = avg(amp_ratio_sta)
123.328 + ccr_zone = avg(ccr_sta)
123.329 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
123.330 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
123.331 +
123.332 + print (npts+"/"+amp_ratio_zone+"/"+ccr_zone+"/"+M_zone+"/"+score_zone)
123.333 +
123.334 + case_value_zone(0,z) = npts
123.335 + case_value_zone(1,z) = (/amp_ratio_zone/)
123.336 + case_value_zone(2,z) = (/ccr_zone/)
123.337 + case_value_zone(3,z) = (/M_zone/)
123.338 + case_value_zone(4,z) = (/score_zone/)
123.339 +
123.340 +; column for station table
123.341 + case_sta = (/"Latitude","Longitude","Amplitude Ratio", \
123.342 + "Correlation Coef","M score","Combined Score"/)
123.343 + nCase_sta = dimsizes(case_sta )
123.344 +
123.345 +; row for station table
123.346 + var_sta = sta(ind_z)
123.347 + nVar_sta = dimsizes(var_sta)
123.348 +
123.349 +; arrays to be passed to diagram.
123.350 + case_value_sta = new ((/nCase_sta, nVar_sta/),float )
123.351 +
123.352 + case_value_sta(0,:) = (/lat(ind_z)/)
123.353 + case_value_sta(1,:) = (/lon(ind_z)/)
123.354 + case_value_sta(2,:) = (/amp_ratio_sta/)
123.355 + case_value_sta(3,:) = (/ccr_sta/)
123.356 + case_value_sta(4,:) = (/M_sta/)
123.357 + case_value_sta(5,:) = (/score_sta/)
123.358 +
123.359 +;**************************************************
123.360 +; plot station table
123.361 +;**************************************************
123.362 + tt_opt = True
123.363 + tt_opt@pltType= "png" ; "eps" [default], "pdf", "ps"
123.364 + ; "png", "gif" [if you have ImageMajik 'convert']
123.365 +
123.366 + tt_opt@tableTitle = "Zone "+ zone
123.367 + plot_name = "table_sta." + zone
123.368 +
123.369 + metrics_table(plot_name, var_sta, case_sta , case_value_sta, tt_opt)
123.370 +
123.371 + delete (ind_z)
123.372 + delete (amp_model)
123.373 + delete (amp_ob)
123.374 + delete (amp_ratio_sta)
123.375 + delete (ccr_sta)
123.376 + delete (M_sta)
123.377 + delete (score_sta)
123.378 + delete (var_sta)
123.379 + delete (case_value_sta)
123.380 + end do
123.381 +;**************************************************
123.382 +; plot zone table
123.383 +;**************************************************
123.384 + case_value_zone(0,4) = case_value_zone(0,0)+case_value_zone(0,1)+case_value_zone(0,2)+case_value_zone(0,3)
123.385 + case_value_zone(1,4) = 0.
123.386 + case_value_zone(2,4) = 0.
123.387 + case_value_zone(3,4) = 0.
123.388 + case_value_zone(4,4) = case_value_zone(4,0)+case_value_zone(4,1)+case_value_zone(4,2)+case_value_zone(4,3)
123.389 +
123.390 + tt_opt = True
123.391 + tt_opt@pltType= "png" ; "eps" [default], "pdf", "ps"
123.392 + ; "png", "gif" [if you have ImageMajik 'convert']
123.393 +
123.394 + tt_opt@tableTitle = "Zone"
123.395 + plot_name = "table_zone"
123.396 +
123.397 + metrics_table(plot_name, var_zone, case_zone , case_value_zone, tt_opt)
123.398 +
123.399 +end
124.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
124.2 +++ b/co2/42.metric+lines.ncl Mon Jan 26 22:08:20 2009 -0500
124.3 @@ -0,0 +1,514 @@
124.4 +; ***********************************************
124.5 +; combine 19.metric_plot.ncl and 24.lines.ncl
124.6 +; ***********************************************
124.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
124.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
124.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
124.10 +;load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
124.11 +;************************************************
124.12 +begin
124.13 +;************************************************
124.14 +; read in data: observed
124.15 +;************************************************
124.16 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
124.17 + fili = "co2_globalView_98.nc"
124.18 + g = addfile (diri+fili,"r")
124.19 + val = g->CO2_SEAS
124.20 + lon = g->LON
124.21 + lat = g->LAT
124.22 + sta = chartostring(g->STATION)
124.23 + delete (g)
124.24 +
124.25 +;print (sta(0))
124.26 +
124.27 + ncase = dimsizes(lat)
124.28 +;print (ncase)
124.29 +
124.30 +;**************************************************************
124.31 +; get only the lowest level at each station
124.32 +;**************************************************************
124.33 + lat_tmp = lat
124.34 + lat_tmp@_FillValue = 1.e+36
124.35 +
124.36 + do n = 0,ncase-1
124.37 + if (.not. ismissing(lat_tmp(n))) then
124.38 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
124.39 + if (dimsizes(indexes) .gt. 1) then
124.40 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
124.41 + end if
124.42 + delete (indexes)
124.43 + end if
124.44 + end do
124.45 +
124.46 + indexes = ind(.not. ismissing(lat_tmp))
124.47 +;print (dimsizes(indexes))
124.48 +;print (indexes)
124.49 +
124.50 + lat_ob = lat(indexes)
124.51 + lon_ob = lon(indexes)
124.52 + val_ob = val(indexes,:)
124.53 +;printVarSummary (val_ob)
124.54 +;print (lat_ob +"/"+lon_ob)
124.55 +
124.56 +;************************************************
124.57 +; read in model data
124.58 +;************************************************
124.59 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
124.60 +; fili2 = "b30.061m_401_425_MONS_climo_atm.nc"
124.61 + fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
124.62 +
124.63 + g = addfile(diri2+fili2,"r")
124.64 + x = g->CO2
124.65 + xi = g->lon
124.66 + yi = g->lat
124.67 + xdim = dimsizes(x)
124.68 + nlev = xdim(1)
124.69 + y = x(:,0,:,:)
124.70 +; printVarSummary (y)
124.71 +
124.72 +; get the co2 at the lowest level
124.73 + y = x(:,nlev-1,:,:)
124.74 +
124.75 +; change to unit of observed (u mol/mol)
124.76 +; Model_units [=] kgCO2 / kgDryAir
124.77 +; 28.966 = molecular weight of dry air
124.78 +; 44. = molecular weight of CO2
124.79 +; u mol = 1e-6 mol
124.80 +
124.81 + factor = (28.966/44.) * 1e6
124.82 + y = y * factor
124.83 +
124.84 + y@_FillValue = 1.e36
124.85 + y@units = "u mol/mol"
124.86 +; y = where(y0 .lt. 287.,y@_FillValue,y)
124.87 +; printVarSummary (y)
124.88 +; print (min(y)+"/"+max(y))
124.89 +
124.90 +; interpolate into observed station
124.91 +; note: model is 0-360E, 90S-90N
124.92 +
124.93 +; to be able to handle observation at (-89.98,-24.80)
124.94 + print (yi(0))
124.95 + yi(0) = -90.
124.96 +
124.97 + i = ind(lon_ob .lt. 0.)
124.98 + lon_ob(i) = lon_ob(i) + 360.
124.99 +
124.100 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
124.101 +
124.102 + val_model = yo(pts|:,time|:)
124.103 + val_model_0 = val_model
124.104 +; printVarSummary (val_model)
124.105 +; print (min(val_model)+"/"+max(val_model))
124.106 +
124.107 +; remove annual mean
124.108 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
124.109 +; print (min(val_model)+"/"+max(val_model))
124.110 +
124.111 + nzone = 4
124.112 +
124.113 +;*******************************************************************
124.114 +; for table -- zone
124.115 +;*******************************************************************
124.116 +; table header name
124.117 + table_header_name = "Zone"
124.118 +
124.119 +; column (not including header column)
124.120 + col_header_zone = (/"Stations","Amplitude Ratio", \
124.121 + "Correlation Coef","M score","Combined Score"/)
124.122 + ncol_zone = dimsizes(col_header_zone )
124.123 +
124.124 +; row (not including header row)
124.125 + row_header_zone = (/"60N-90N","30N-60N","EQ-30N","90S-EQ","Total"/)
124.126 + nrow_zone = dimsizes(row_header_zone)
124.127 +
124.128 +; arrays to be passed to table.
124.129 + value_zone = new ((/nrow_zone, ncol_zone/),string )
124.130 +;--------------------------------------------------------------------
124.131 +
124.132 + table_length_zone = 0.4
124.133 +
124.134 +; Table header
124.135 + ncr1 = (/1,1/) ; 1 row, 1 column
124.136 + x1 = (/0.005,0.15/) ; Start and end X
124.137 + y1 = (/0.900,0.995/) ; Start and end Y
124.138 + text1 = table_header_name
124.139 + res1 = True
124.140 + res1@txFontHeightF = 0.03
124.141 + res1@gsFillColor = "CornFlowerBlue"
124.142 +
124.143 +; Column header (equally space in x2)
124.144 + ncr2 = (/1,ncol_zone/) ; 1 rows, 5 columns
124.145 + x2 = (/x1(1),0.995/) ; start from end of x1
124.146 + y2 = y1 ; same as y1
124.147 + text2 = col_header_zone
124.148 + res2 = True
124.149 + res2@txFontHeightF = 0.015
124.150 + res2@gsFillColor = "Gray"
124.151 +
124.152 +; Row header (equally space in y2)
124.153 + ncr3 = (/nrow_zone,1/) ; 5 rows, 1 columns
124.154 + x3 = x1 ; same as x1
124.155 + y3 = (/1.0-table_length_zone,0.900/) ; end at start of y1
124.156 + text3 = row_header_zone
124.157 + res3 = True
124.158 + res3@txFontHeightF = 0.02
124.159 + res3@gsFillColor = "Gray"
124.160 +
124.161 +; Main table body
124.162 + ncr4 = (/nrow_zone,ncol_zone/) ; 5 rows, 5 columns
124.163 + x4 = x2 ; Start and end x
124.164 + y4 = y3 ; Start and end Y
124.165 + text4 = new((/nrow_zone,ncol_zone/),string)
124.166 +
124.167 + color_fill4 = new((/nrow_zone,ncol_zone/),string)
124.168 + color_fill4 = "white"
124.169 + color_fill4(:,ncol_zone-1) = "grey"
124.170 +
124.171 + res4 = True ; Set up resource list
124.172 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
124.173 + res4@txFontHeightF = 0.02
124.174 + res4@gsFillColor = color_fill4
124.175 +
124.176 + delete (color_fill4)
124.177 +
124.178 +;*******************************************************************
124.179 +; for table -- station
124.180 +;*******************************************************************
124.181 +; table header name
124.182 + table_header_name = "Zone"
124.183 +
124.184 +; column (not including header column)
124.185 + col_header_zone = (/"Stations","Amplitude Ratio", \
124.186 + "Correlation Coef","M score","Combined Score"/)
124.187 + ncol_zone = dimsizes(col_header_zone )
124.188 +
124.189 +; row (not including header row)
124.190 + row_header_zone = (/"60N-90N","30N-60N","EQ-30N","90S-EQ","Total"/)
124.191 + nrow_zone = dimsizes(row_header_zone)
124.192 +
124.193 +; arrays to be passed to table.
124.194 + value_zone = new ((/nrow_zone, ncol_zone/),string )
124.195 +;-------------------------------------------------------------------
124.196 +
124.197 + table_length_zone = 0.4
124.198 +
124.199 +; Table header
124.200 + ncr1 = (/1,1/) ; 1 row, 1 column
124.201 + x1 = (/0.005,0.15/) ; Start and end X
124.202 + y1 = (/0.900,0.995/) ; Start and end Y
124.203 + text1 = table_header_name
124.204 + res1 = True
124.205 + res1@txFontHeightF = 0.03
124.206 + res1@gsFillColor = "CornFlowerBlue"
124.207 +
124.208 +; Column header (equally space in x2)
124.209 + ncr2 = (/1,ncol_zone/) ; 1 rows, 5 columns
124.210 + x2 = (/x1(1),0.995/) ; start from end of x1
124.211 + y2 = y1 ; same as y1
124.212 + text2 = col_header_zone
124.213 + res2 = True
124.214 + res2@txFontHeightF = 0.015
124.215 + res2@gsFillColor = "Gray"
124.216 +
124.217 +; Row header (equally space in y2)
124.218 + ncr3 = (/nrow_zone,1/) ; 5 rows, 1 columns
124.219 + x3 = x1 ; same as x1
124.220 + y3 = (/1.0-table_length_zone,0.900/) ; end at start of y1
124.221 + text3 = row_header_zone
124.222 + res3 = True
124.223 + res3@txFontHeightF = 0.02
124.224 + res3@gsFillColor = "Gray"
124.225 +
124.226 +; Main table body
124.227 + ncr4 = (/nrow_zone,ncol_zone/) ; 5 rows, 5 columns
124.228 + x4 = x2 ; Start and end x
124.229 + y4 = y3 ; Start and end Y
124.230 + text4 = new((/nrow_zone,ncol_zone/),string)
124.231 +
124.232 + color_fill4 = new((/nrow_zone,ncol_zone/),string)
124.233 + color_fill4 = "white"
124.234 + color_fill4(:,ncol_zone-1) = "grey"
124.235 +
124.236 + res4 = True ; Set up resource list
124.237 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
124.238 + res4@txFontHeightF = 0.02
124.239 + res4@gsFillColor = color_fill4
124.240 +
124.241 + delete (color_fill4)
124.242 +;--------------------------------------------------------------
124.243 +; for station line plot
124.244 +
124.245 +; for x-axis in xyplot
124.246 + mon = ispan(1,12,1)
124.247 + mon@long_name = "month"
124.248 +
124.249 + plot_type = "ps"
124.250 + plot_type_new = "png"
124.251 +
124.252 + res = True ; plot mods desired
124.253 + res@xyLineThicknesses = (/2.0,2.0,2.0/) ; make 2nd lines thicker
124.254 + res@xyLineColors = (/"red","black"/) ; change line color
124.255 +
124.256 +; Add a boxed legend using the more simple method
124.257 +
124.258 + res@pmLegendDisplayMode = "Always"
124.259 +; res@pmLegendWidthF = 0.1
124.260 + res@pmLegendWidthF = 0.08
124.261 + res@pmLegendHeightF = 0.06
124.262 +; res@pmLegendOrthogonalPosF = -1.17
124.263 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
124.264 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
124.265 +
124.266 +; res@pmLegendParallelPosF = 0.18
124.267 + res@pmLegendParallelPosF = 0.23 ;(rightward)
124.268 +
124.269 +; res@lgPerimOn = False
124.270 + res@lgLabelFontHeightF = 0.015
124.271 + res@xyExplicitLegendLabels = (/"b30.061n","observed"/)
124.272 +;-------------------------------------------------------------------
124.273 +
124.274 + do z = 0,nzone-1
124.275 +
124.276 + if (z .eq. 0) then
124.277 +; maximum score for the zone, 60N-90N
124.278 + zone = "60N-90N"
124.279 + score_max = 5.0
124.280 +; index of stations in this zone
124.281 + ind_z = ind(lat_ob .ge. 60.)
124.282 +; print (ind_z)
124.283 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
124.284 +; print (val_ob(ind_z,:))
124.285 +; print (val_model(ind_z,:))
124.286 + end if
124.287 +
124.288 + if (z .eq. 1) then
124.289 +; maximum score for the zone, 30N-60N
124.290 + zone = "30N-60N"
124.291 + score_max = 5.0
124.292 +; index of stations in this zone
124.293 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
124.294 +; print (ind_z)
124.295 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
124.296 +; print (val_ob(ind_z,:))
124.297 +; print (val_model(ind_z,:))
124.298 + end if
124.299 +
124.300 + if (z .eq. 2) then
124.301 +; maximum score for the zone, EQ-30N
124.302 + zone = "EQ-30N"
124.303 + score_max = 5.0
124.304 +; index of stations in this zone
124.305 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
124.306 +; print (ind_z)
124.307 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
124.308 +; print (val_ob(ind_z,:))
124.309 +; print (val_model(ind_z,:))
124.310 + end if
124.311 +
124.312 + if (z .eq. 3) then
124.313 +; maximum score for the zone, 90S-EQ
124.314 + zone = "90S-EQ"
124.315 + score_max = 5.0
124.316 +; index of stations in this zone
124.317 + ind_z = ind(lat_ob .lt. 0. )
124.318 +; print (ind_z)
124.319 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
124.320 +; print (val_ob(ind_z,:))
124.321 +; print (val_model(ind_z,:))
124.322 + end if
124.323 +
124.324 + npts = dimsizes(ind_z)
124.325 + print (npts)
124.326 +;-------------------------------------------------------------------------
124.327 +; for metric table
124.328 +
124.329 + amp_ob = new((/npts/),float)
124.330 + amp_model = new((/npts/),float)
124.331 +
124.332 + amp_ratio_sta = new((/npts/),float)
124.333 + ccr_sta = new((/npts/),float)
124.334 + M_sta = new((/npts/),float)
124.335 + score_sta = new((/npts/),float)
124.336 +;-------------------------------------------------------------------------
124.337 +; for station line plot
124.338 +
124.339 + npts_str = ""
124.340 + npts_str = npts
124.341 +; print (npts_str)
124.342 +
124.343 + plot_data = new((/2,12,npts/),float)
124.344 + plot_data_0 = new((/12,npts/),float)
124.345 +
124.346 + plot_data!0 = "case"
124.347 + plot_data!1 = "month"
124.348 + plot_data!2 = "pts"
124.349 + plot_data@long_name = "CO2 Seasonal"
124.350 +
124.351 + plot_data_0!0 = "month"
124.352 + plot_data_0!1 = "pts"
124.353 + plot_data_0@long_name = "CO2"
124.354 +;--------------------------------------------------------------------------
124.355 + do n=0,npts-1
124.356 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
124.357 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
124.358 +
124.359 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
124.360 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
124.361 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
124.362 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
124.363 +
124.364 + print (sta(ind_z(n))+"/"+lat(ind_z(n))+"/"+lon(ind_z(n))+"/"+amp_ratio_sta(n)+"/"+ccr_sta(n)+"/"+M_sta(n)+"/"+score_sta(n))
124.365 +;----------------------------------------------------------------------
124.366 +; for station line plot
124.367 +
124.368 + plot_data(0,:,n) = (/val_model(ind_z(n),:)/)
124.369 + plot_data(1,:,n) = (/val_ob(ind_z(n),:)/)
124.370 +
124.371 + plot_data_0(:,n) = (/val_model_0(ind_z(n),:)/)
124.372 +
124.373 + plot_name = sta(ind_z(n))
124.374 + title = plot_name+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
124.375 +; print (title)
124.376 +; print (plot_name)
124.377 +
124.378 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
124.379 +;------------------------------------------
124.380 +; for panel plot
124.381 +
124.382 + plot=new(2,graphic) ; create graphic array
124.383 + res@gsnFrame = False ; Do not draw plot
124.384 + res@gsnDraw = False ; Do not advance frame
124.385 +
124.386 + pres = True ; panel plot mods desired
124.387 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
124.388 + ; indiv. plots in panel
124.389 + pres@gsnMaximize = True ; fill the page
124.390 +;------------------------------------------
124.391 + res@tiMainString = title ; add title
124.392 +
124.393 + plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res) ; create plot 1
124.394 +
124.395 + plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,n),res) ; create plot 2
124.396 +
124.397 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
124.398 +
124.399 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
124.400 + system("rm "+plot_name+"."+plot_type)
124.401 + clear (wks)
124.402 +;---------------------------------------------------------------------------
124.403 + end do
124.404 +;-------------------------------------------------------------------------
124.405 +; for line plot in a zone
124.406 +
124.407 + plot_name = "All_"+npts_str
124.408 + title = plot_name + " in "+ zone
124.409 +; print (title)
124.410 +; print (plot_name)
124.411 +
124.412 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
124.413 +;-----------------------------------------
124.414 +; for panel plot
124.415 +
124.416 + plot=new(2,graphic) ; create graphic array
124.417 + res@gsnFrame = False ; Do not draw plot
124.418 + res@gsnDraw = False ; Do not advance frame
124.419 +
124.420 + pres = True ; panel plot mods desired
124.421 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
124.422 + ; indiv. plots in panel
124.423 + pres@gsnMaximize = True ; fill the page
124.424 +;-----------------------------------------
124.425 + res@tiMainString = title ; add title
124.426 +
124.427 + plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res) ; create plot 1
124.428 +
124.429 + plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
124.430 +
124.431 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
124.432 +
124.433 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
124.434 + system("rm "+plot_name+"."+plot_type)
124.435 +
124.436 + clear (wks)
124.437 +; delete (ind_z)
124.438 + delete (plot_data)
124.439 + delete (plot_data_0)
124.440 +;---------------------------------------------------------------------------
124.441 +; for zone table
124.442 +
124.443 + amp_ratio_zone = avg(amp_ratio_sta)
124.444 + ccr_zone = avg(ccr_sta)
124.445 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
124.446 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
124.447 +
124.448 + print (npts+"/"+amp_ratio_zone+"/"+ccr_zone+"/"+M_zone+"/"+score_zone)
124.449 +
124.450 + text4(z,0) = sprintf("%5.2f", npts)
124.451 + text4(z,1) = sprintf("%5.2f", amp_ratio_zone)
124.452 + text4(z,2) = sprintf("%5.2f", ccr_zone)
124.453 + text4(z,3) = sprintf("%5.2f", M_zone)
124.454 + text4(z,4) = sprintf("%5.2f", score_zone)
124.455 +;---------------------------------------------------------------------------
124.456 +; column for station table
124.457 + case_sta = (/"Latitude","Longitude","Amplitude Ratio", \
124.458 + "Correlation Coef","M score","Combined Score"/)
124.459 + nCase_sta = dimsizes(case_sta )
124.460 +
124.461 +; row for station table
124.462 + var_sta = sta(ind_z)
124.463 + nVar_sta = dimsizes(var_sta)
124.464 +
124.465 +; arrays to be passed to diagram.
124.466 + case_value_sta = new ((/nCase_sta, nVar_sta/),float )
124.467 +
124.468 + case_value_sta(0,:) = (/lat(ind_z)/)
124.469 + case_value_sta(1,:) = (/lon(ind_z)/)
124.470 + case_value_sta(2,:) = (/amp_ratio_sta/)
124.471 + case_value_sta(3,:) = (/ccr_sta/)
124.472 + case_value_sta(4,:) = (/M_sta/)
124.473 + case_value_sta(5,:) = (/score_sta/)
124.474 +
124.475 +;**************************************************
124.476 +; plot station table
124.477 +;**************************************************
124.478 + tt_opt = True
124.479 + tt_opt@pltType= "png" ; "eps" [default], "pdf", "ps"
124.480 + ; "png", "gif" [if you have ImageMajik 'convert']
124.481 +
124.482 + tt_opt@tableTitle = "Zone "+ zone
124.483 + plot_name = "table_sta." + zone
124.484 +
124.485 +; metrics_table(plot_name, var_sta, case_sta , case_value_sta, tt_opt)
124.486 +
124.487 + delete (ind_z)
124.488 + delete (amp_model)
124.489 + delete (amp_ob)
124.490 + delete (amp_ratio_sta)
124.491 + delete (ccr_sta)
124.492 + delete (M_sta)
124.493 + delete (score_sta)
124.494 + delete (var_sta)
124.495 + delete (case_value_sta)
124.496 + end do
124.497 +;**************************************************
124.498 +; plot zone table
124.499 +;**************************************************
124.500 +
124.501 + text4(4,0) = sum(stringtofloat(text4(0:3,0)))
124.502 + text4(4,1) = 0.
124.503 + text4(4,2) = 0.
124.504 + text4(4,3) = 0.
124.505 + text4(4,4) = sum(stringtofloat(text4(0:3,4)))
124.506 +
124.507 + plot_name = "table_zone"
124.508 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
124.509 +
124.510 + gsn_table(wks,ncr1,x1,y1,text1,res1)
124.511 + gsn_table(wks,ncr2,x2,y2,text2,res2)
124.512 + gsn_table(wks,ncr3,x3,y3,text3,res3)
124.513 + gsn_table(wks,ncr4,x4,y4,text4,res4)
124.514 +
124.515 + frame(wks)
124.516 +
124.517 +end
125.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
125.2 +++ b/co2/42.metric+lines.ncl.0 Mon Jan 26 22:08:20 2009 -0500
125.3 @@ -0,0 +1,448 @@
125.4 +; ***********************************************
125.5 +; combine 19.metric_plot.ncl and 24.lines.ncl
125.6 +; ***********************************************
125.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
125.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
125.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
125.10 +;load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
125.11 +;************************************************
125.12 +begin
125.13 +;************************************************
125.14 +; read in data: observed
125.15 +;************************************************
125.16 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
125.17 + fili = "co2_globalView_98.nc"
125.18 + g = addfile (diri+fili,"r")
125.19 + val = g->CO2_SEAS
125.20 + lon = g->LON
125.21 + lat = g->LAT
125.22 + sta = chartostring(g->STATION)
125.23 + delete (g)
125.24 +
125.25 +;print (sta(0))
125.26 +
125.27 + ncase = dimsizes(lat)
125.28 +;print (ncase)
125.29 +
125.30 +;**************************************************************
125.31 +; get only the lowest level at each station
125.32 +;**************************************************************
125.33 + lat_tmp = lat
125.34 + lat_tmp@_FillValue = 1.e+36
125.35 +
125.36 + do n = 0,ncase-1
125.37 + if (.not. ismissing(lat_tmp(n))) then
125.38 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
125.39 + if (dimsizes(indexes) .gt. 1) then
125.40 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
125.41 + end if
125.42 + delete (indexes)
125.43 + end if
125.44 + end do
125.45 +
125.46 + indexes = ind(.not. ismissing(lat_tmp))
125.47 +;print (dimsizes(indexes))
125.48 +;print (indexes)
125.49 +
125.50 + lat_ob = lat(indexes)
125.51 + lon_ob = lon(indexes)
125.52 + val_ob = val(indexes,:)
125.53 +;printVarSummary (val_ob)
125.54 +;print (lat_ob +"/"+lon_ob)
125.55 +
125.56 +;************************************************
125.57 +; read in model data
125.58 +;************************************************
125.59 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
125.60 +; fili2 = "b30.061m_401_425_MONS_climo_atm.nc"
125.61 + fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
125.62 +
125.63 + g = addfile(diri2+fili2,"r")
125.64 + x = g->CO2
125.65 + xi = g->lon
125.66 + yi = g->lat
125.67 + xdim = dimsizes(x)
125.68 + nlev = xdim(1)
125.69 + y = x(:,0,:,:)
125.70 +; printVarSummary (y)
125.71 +
125.72 +; get the co2 at the lowest level
125.73 + y = x(:,nlev-1,:,:)
125.74 +
125.75 +; change to unit of observed (u mol/mol)
125.76 +; Model_units [=] kgCO2 / kgDryAir
125.77 +; 28.966 = molecular weight of dry air
125.78 +; 44. = molecular weight of CO2
125.79 +; u mol = 1e-6 mol
125.80 +
125.81 + factor = (28.966/44.) * 1e6
125.82 + y = y * factor
125.83 +
125.84 + y@_FillValue = 1.e36
125.85 + y@units = "u mol/mol"
125.86 +; y = where(y0 .lt. 287.,y@_FillValue,y)
125.87 +; printVarSummary (y)
125.88 +; print (min(y)+"/"+max(y))
125.89 +
125.90 +; interpolate into observed station
125.91 +; note: model is 0-360E, 90S-90N
125.92 +
125.93 +; to be able to handle observation at (-89.98,-24.80)
125.94 + print (yi(0))
125.95 + yi(0) = -90.
125.96 +
125.97 + i = ind(lon_ob .lt. 0.)
125.98 + lon_ob(i) = lon_ob(i) + 360.
125.99 +
125.100 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
125.101 +
125.102 + val_model = yo(pts|:,time|:)
125.103 + val_model_0 = val_model
125.104 +; printVarSummary (val_model)
125.105 +; print (min(val_model)+"/"+max(val_model))
125.106 +
125.107 +; remove annual mean
125.108 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
125.109 +; print (min(val_model)+"/"+max(val_model))
125.110 +
125.111 + nzone = 4
125.112 +;--------------------------------------------------------------
125.113 +; for zone table
125.114 +;**********************************
125.115 +; table header name
125.116 + table_header_name = "Zone"
125.117 +
125.118 +; column (not including header column)
125.119 + col_header_zone = (/"Stations","Amplitude Ratio", \
125.120 + "Correlation Coef","M score","Combined Score"/)
125.121 + ncol_zone = dimsizes(col_header_zone )
125.122 +
125.123 +; row (not including header row)
125.124 + row_header_zone = (/"60N-90N","30N-60N","EQ-30N","90S-EQ","Total"/)
125.125 + nrow_zone = dimsizes(row_header_zone)
125.126 +
125.127 +; arrays to be passed to table.
125.128 + value_zone = new ((/nrow_zone, ncol_zone/),string )
125.129 +;**********************************
125.130 +
125.131 + table_length_zone = 0.4
125.132 +
125.133 +; Table header
125.134 + ncr1 = (/1,1/) ; 1 row, 1 column
125.135 + x1 = (/0.005,0.15/) ; Start and end X
125.136 + y1 = (/0.900,0.995/) ; Start and end Y
125.137 + text1 = table_header_name
125.138 + res1 = True
125.139 + res1@txFontHeightF = 0.03
125.140 + res1@gsFillColor = "CornFlowerBlue"
125.141 +
125.142 +; Column header (equally space in x2)
125.143 + ncr2 = (/1,ncol_zone/) ; 1 rows, 5 columns
125.144 + x2 = (/x1(1),0.995/) ; start from end of x1
125.145 + y2 = y1 ; same as y1
125.146 + text2 = col_header_zone
125.147 + res2 = True
125.148 + res2@txFontHeightF = 0.015
125.149 + res2@gsFillColor = "Gray"
125.150 +
125.151 +; Row header (equally space in y2)
125.152 + ncr3 = (/nrow_zone,1/) ; 5 rows, 1 columns
125.153 + x3 = x1 ; same as x1
125.154 + y3 = (/1.0-table_length_zone,0.900/) ; end at start of y1
125.155 + text3 = row_header_zone
125.156 + res3 = True
125.157 + res3@txFontHeightF = 0.02
125.158 + res3@gsFillColor = "Gray"
125.159 +
125.160 +; Main table body
125.161 + ncr4 = (/nrow_zone,ncol_zone/) ; 5 rows, 5 columns
125.162 + x4 = x2 ; Start and end x
125.163 + y4 = y3 ; Start and end Y
125.164 + text4 = new((/nrow_zone,ncol_zone/),string)
125.165 +
125.166 + color_fill4 = new((/nrow_zone,ncol_zone/),string)
125.167 + color_fill4 = "white"
125.168 + color_fill4(:,ncol_zone-1) = "grey"
125.169 +
125.170 + res4 = True ; Set up resource list
125.171 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
125.172 + res4@txFontHeightF = 0.02
125.173 + res4@gsFillColor = color_fill4
125.174 +
125.175 + delete (color_fill4)
125.176 +;--------------------------------------------------------------
125.177 +; for station line plot
125.178 +
125.179 +; for x-axis in xyplot
125.180 + mon = ispan(1,12,1)
125.181 + mon@long_name = "month"
125.182 +
125.183 + plot_type = "ps"
125.184 + plot_type_new = "png"
125.185 +
125.186 + res = True ; plot mods desired
125.187 + res@xyLineThicknesses = (/2.0,2.0,2.0/) ; make 2nd lines thicker
125.188 + res@xyLineColors = (/"red","black"/) ; change line color
125.189 +
125.190 +; Add a boxed legend using the more simple method
125.191 +
125.192 + res@pmLegendDisplayMode = "Always"
125.193 +; res@pmLegendWidthF = 0.1
125.194 + res@pmLegendWidthF = 0.08
125.195 + res@pmLegendHeightF = 0.06
125.196 +; res@pmLegendOrthogonalPosF = -1.17
125.197 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
125.198 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
125.199 +
125.200 +; res@pmLegendParallelPosF = 0.18
125.201 + res@pmLegendParallelPosF = 0.23 ;(rightward)
125.202 +
125.203 +; res@lgPerimOn = False
125.204 + res@lgLabelFontHeightF = 0.015
125.205 + res@xyExplicitLegendLabels = (/"b30.061n","observed"/)
125.206 +;-------------------------------------------------------------------
125.207 +
125.208 + do z = 0,nzone-1
125.209 +
125.210 + if (z .eq. 0) then
125.211 +; maximum score for the zone, 60N-90N
125.212 + zone = "60N-90N"
125.213 + score_max = 5.0
125.214 +; index of stations in this zone
125.215 + ind_z = ind(lat_ob .ge. 60.)
125.216 +; print (ind_z)
125.217 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
125.218 +; print (val_ob(ind_z,:))
125.219 +; print (val_model(ind_z,:))
125.220 + end if
125.221 +
125.222 + if (z .eq. 1) then
125.223 +; maximum score for the zone, 30N-60N
125.224 + zone = "30N-60N"
125.225 + score_max = 5.0
125.226 +; index of stations in this zone
125.227 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
125.228 +; print (ind_z)
125.229 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
125.230 +; print (val_ob(ind_z,:))
125.231 +; print (val_model(ind_z,:))
125.232 + end if
125.233 +
125.234 + if (z .eq. 2) then
125.235 +; maximum score for the zone, EQ-30N
125.236 + zone = "EQ-30N"
125.237 + score_max = 5.0
125.238 +; index of stations in this zone
125.239 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
125.240 +; print (ind_z)
125.241 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
125.242 +; print (val_ob(ind_z,:))
125.243 +; print (val_model(ind_z,:))
125.244 + end if
125.245 +
125.246 + if (z .eq. 3) then
125.247 +; maximum score for the zone, 90S-EQ
125.248 + zone = "90S-EQ"
125.249 + score_max = 5.0
125.250 +; index of stations in this zone
125.251 + ind_z = ind(lat_ob .lt. 0. )
125.252 +; print (ind_z)
125.253 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
125.254 +; print (val_ob(ind_z,:))
125.255 +; print (val_model(ind_z,:))
125.256 + end if
125.257 +
125.258 + npts = dimsizes(ind_z)
125.259 + print (npts)
125.260 +;-------------------------------------------------------------------------
125.261 +; for metric table
125.262 +
125.263 + amp_ob = new((/npts/),float)
125.264 + amp_model = new((/npts/),float)
125.265 +
125.266 + amp_ratio_sta = new((/npts/),float)
125.267 + ccr_sta = new((/npts/),float)
125.268 + M_sta = new((/npts/),float)
125.269 + score_sta = new((/npts/),float)
125.270 +;-------------------------------------------------------------------------
125.271 +; for station line plot
125.272 +
125.273 + npts_str = ""
125.274 + npts_str = npts
125.275 +; print (npts_str)
125.276 +
125.277 + plot_data = new((/2,12,npts/),float)
125.278 + plot_data_0 = new((/12,npts/),float)
125.279 +
125.280 + plot_data!0 = "case"
125.281 + plot_data!1 = "month"
125.282 + plot_data!2 = "pts"
125.283 + plot_data@long_name = "CO2 Seasonal"
125.284 +
125.285 + plot_data_0!0 = "month"
125.286 + plot_data_0!1 = "pts"
125.287 + plot_data_0@long_name = "CO2"
125.288 +;--------------------------------------------------------------------------
125.289 + do n=0,npts-1
125.290 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
125.291 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
125.292 +
125.293 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
125.294 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
125.295 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
125.296 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
125.297 +
125.298 + print (sta(ind_z(n))+"/"+lat(ind_z(n))+"/"+lon(ind_z(n))+"/"+amp_ratio_sta(n)+"/"+ccr_sta(n)+"/"+M_sta(n)+"/"+score_sta(n))
125.299 +;----------------------------------------------------------------------
125.300 +; for station line plot
125.301 +
125.302 + plot_data(0,:,n) = (/val_model(ind_z(n),:)/)
125.303 + plot_data(1,:,n) = (/val_ob(ind_z(n),:)/)
125.304 +
125.305 + plot_data_0(:,n) = (/val_model_0(ind_z(n),:)/)
125.306 +
125.307 + plot_name = sta(ind_z(n))
125.308 + title = plot_name+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
125.309 +; print (title)
125.310 +; print (plot_name)
125.311 +
125.312 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
125.313 +;------------------------------------------
125.314 +; for panel plot
125.315 +
125.316 + plot=new(2,graphic) ; create graphic array
125.317 + res@gsnFrame = False ; Do not draw plot
125.318 + res@gsnDraw = False ; Do not advance frame
125.319 +
125.320 + pres = True ; panel plot mods desired
125.321 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
125.322 + ; indiv. plots in panel
125.323 + pres@gsnMaximize = True ; fill the page
125.324 +;------------------------------------------
125.325 + res@tiMainString = title ; add title
125.326 +
125.327 + plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res) ; create plot 1
125.328 +
125.329 + plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,n),res) ; create plot 2
125.330 +
125.331 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
125.332 +
125.333 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
125.334 + system("rm "+plot_name+"."+plot_type)
125.335 + clear (wks)
125.336 +;---------------------------------------------------------------------------
125.337 + end do
125.338 +;-------------------------------------------------------------------------
125.339 +; for line plot in a zone
125.340 +
125.341 + plot_name = "All_"+npts_str
125.342 + title = plot_name + " in "+ zone
125.343 +; print (title)
125.344 +; print (plot_name)
125.345 +
125.346 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
125.347 +;-----------------------------------------
125.348 +; for panel plot
125.349 +
125.350 + plot=new(2,graphic) ; create graphic array
125.351 + res@gsnFrame = False ; Do not draw plot
125.352 + res@gsnDraw = False ; Do not advance frame
125.353 +
125.354 + pres = True ; panel plot mods desired
125.355 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
125.356 + ; indiv. plots in panel
125.357 + pres@gsnMaximize = True ; fill the page
125.358 +;-----------------------------------------
125.359 + res@tiMainString = title ; add title
125.360 +
125.361 + plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res) ; create plot 1
125.362 +
125.363 + plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
125.364 +
125.365 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
125.366 +
125.367 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
125.368 + system("rm "+plot_name+"."+plot_type)
125.369 +
125.370 + clear (wks)
125.371 +; delete (ind_z)
125.372 + delete (plot_data)
125.373 + delete (plot_data_0)
125.374 +;---------------------------------------------------------------------------
125.375 +; for zone table
125.376 +
125.377 + amp_ratio_zone = avg(amp_ratio_sta)
125.378 + ccr_zone = avg(ccr_sta)
125.379 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
125.380 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
125.381 +
125.382 + print (npts+"/"+amp_ratio_zone+"/"+ccr_zone+"/"+M_zone+"/"+score_zone)
125.383 +
125.384 + text4(z,0) = sprintf("%5.2f", npts)
125.385 + text4(z,1) = sprintf("%5.2f", amp_ratio_zone)
125.386 + text4(z,2) = sprintf("%5.2f", ccr_zone)
125.387 + text4(z,3) = sprintf("%5.2f", M_zone)
125.388 + text4(z,4) = sprintf("%5.2f", score_zone)
125.389 +;---------------------------------------------------------------------------
125.390 +; column for station table
125.391 + case_sta = (/"Latitude","Longitude","Amplitude Ratio", \
125.392 + "Correlation Coef","M score","Combined Score"/)
125.393 + nCase_sta = dimsizes(case_sta )
125.394 +
125.395 +; row for station table
125.396 + var_sta = sta(ind_z)
125.397 + nVar_sta = dimsizes(var_sta)
125.398 +
125.399 +; arrays to be passed to diagram.
125.400 + case_value_sta = new ((/nCase_sta, nVar_sta/),float )
125.401 +
125.402 + case_value_sta(0,:) = (/lat(ind_z)/)
125.403 + case_value_sta(1,:) = (/lon(ind_z)/)
125.404 + case_value_sta(2,:) = (/amp_ratio_sta/)
125.405 + case_value_sta(3,:) = (/ccr_sta/)
125.406 + case_value_sta(4,:) = (/M_sta/)
125.407 + case_value_sta(5,:) = (/score_sta/)
125.408 +
125.409 +;**************************************************
125.410 +; plot station table
125.411 +;**************************************************
125.412 + tt_opt = True
125.413 + tt_opt@pltType= "png" ; "eps" [default], "pdf", "ps"
125.414 + ; "png", "gif" [if you have ImageMajik 'convert']
125.415 +
125.416 + tt_opt@tableTitle = "Zone "+ zone
125.417 + plot_name = "table_sta." + zone
125.418 +
125.419 +; metrics_table(plot_name, var_sta, case_sta , case_value_sta, tt_opt)
125.420 +
125.421 + delete (ind_z)
125.422 + delete (amp_model)
125.423 + delete (amp_ob)
125.424 + delete (amp_ratio_sta)
125.425 + delete (ccr_sta)
125.426 + delete (M_sta)
125.427 + delete (score_sta)
125.428 + delete (var_sta)
125.429 + delete (case_value_sta)
125.430 + end do
125.431 +;**************************************************
125.432 +; plot zone table
125.433 +;**************************************************
125.434 +
125.435 + text4(4,0) = sum(stringtofloat(text4(0:3,0)))
125.436 + text4(4,1) = 0.
125.437 + text4(4,2) = 0.
125.438 + text4(4,3) = 0.
125.439 + text4(4,4) = sum(stringtofloat(text4(0:3,4)))
125.440 +
125.441 + plot_name = "table_zone"
125.442 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
125.443 +
125.444 + gsn_table(wks,ncr1,x1,y1,text1,res1)
125.445 + gsn_table(wks,ncr2,x2,y2,text2,res2)
125.446 + gsn_table(wks,ncr3,x3,y3,text3,res3)
125.447 + gsn_table(wks,ncr4,x4,y4,text4,res4)
125.448 +
125.449 + frame(wks)
125.450 +
125.451 +end
126.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
126.2 +++ b/co2/42.test.ncl Mon Jan 26 22:08:20 2009 -0500
126.3 @@ -0,0 +1,93 @@
126.4 +; ***********************************************
126.5 +; combine 19.metric_plot.ncl and 24.lines.ncl
126.6 +; ***********************************************
126.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
126.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
126.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
126.10 +;load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
126.11 +;************************************************
126.12 +begin
126.13 +
126.14 + plot_type ="ps"
126.15 + plot_name = "table_zone"
126.16 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
126.17 +;--------------------------------------------------------------
126.18 +; for zone table
126.19 +
126.20 +;**********************************
126.21 +; table header name
126.22 + table_header_name = "Zone"
126.23 +
126.24 +; column (not including header column)
126.25 + col_header_zone = (/"Stations","Amplitude Ratio", \
126.26 + "Correlation Coef","M score","Combined Score"/)
126.27 + ncol_zone = dimsizes(col_header_zone )
126.28 +
126.29 +; row (not including header row)
126.30 + row_header_zone = (/"60N-90N","30N-60N","EQ-30N","90S-EQ","Total"/)
126.31 + nrow_zone = dimsizes(row_header_zone)
126.32 +
126.33 +; arrays to be passed to table.
126.34 + value_zone = new ((/nrow_zone, ncol_zone/),string )
126.35 +;**********************************
126.36 +
126.37 + table_length_zone = 0.4
126.38 +
126.39 +; Table header
126.40 + ncr1 = (/1,1/) ; 1 row, 1 column
126.41 + x1 = (/0.005,0.15/) ; Start and end X
126.42 + y1 = (/0.900,0.995/) ; Start and end Y
126.43 + text1 = table_header_name
126.44 + res1 = True
126.45 + res1@txFontHeightF = 0.03
126.46 + res1@gsFillColor = "CornFlowerBlue"
126.47 +
126.48 +; Column header (equally space in x2)
126.49 + ncr2 = (/1,ncol_zone/) ; 1 rows, 5 columns
126.50 + x2 = (/x1(1),0.995/) ; start from end of x1
126.51 + y2 = y1 ; same as y1
126.52 + text2 = col_header_zone
126.53 + res2 = True
126.54 + res2@txFontHeightF = 0.015
126.55 + res2@gsFillColor = "Gray"
126.56 +
126.57 +; Row header (equally space in y2)
126.58 + ncr3 = (/nrow_zone,1/) ; 5 rows, 1 columns
126.59 + x3 = x1 ; same as x1
126.60 + y3 = (/1.0-table_length_zone,0.900/) ; end at start of y1
126.61 + text3 = row_header_zone
126.62 + res3 = True
126.63 + res3@txFontHeightF = 0.02
126.64 + res3@gsFillColor = "Gray"
126.65 +
126.66 +; Main table body
126.67 + ncr4 = (/nrow_zone,ncol_zone/) ; 5 rows, 5 columns
126.68 + x4 = x2 ; Start and end x
126.69 + y4 = y3 ; Start and end Y
126.70 + text4 = new((/nrow_zone,ncol_zone/),string)
126.71 +
126.72 + color_fill4 = new((/nrow_zone,ncol_zone/),string)
126.73 + color_fill4 = "white"
126.74 + color_fill4(:,ncol_zone-1) = "grey"
126.75 +
126.76 + res4 = True ; Set up resource list
126.77 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
126.78 + res4@txFontHeightF = 0.02
126.79 + res4@gsFillColor = color_fill4
126.80 +
126.81 + delete (color_fill4)
126.82 +
126.83 +;**************************************************
126.84 +; plot zone table
126.85 +;**************************************************
126.86 +
126.87 + text4 = sprintf("%5.2f", 0.9999 )
126.88 +
126.89 + gsn_table(wks,ncr1,x1,y1,text1,res1)
126.90 + gsn_table(wks,ncr2,x2,y2,text2,res2)
126.91 + gsn_table(wks,ncr3,x3,y3,text3,res3)
126.92 + gsn_table(wks,ncr4,x4,y4,text4,res4)
126.93 +
126.94 + frame(wks)
126.95 +
126.96 +end
127.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
127.2 +++ b/co2/43.metric+lines.ncl Mon Jan 26 22:08:20 2009 -0500
127.3 @@ -0,0 +1,553 @@
127.4 +; ***********************************************
127.5 +; using gsn_table for all
127.6 +; combine 19.metric_plot.ncl and 24.lines.ncl
127.7 +; ***********************************************
127.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
127.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
127.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
127.11 +;load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
127.12 +;************************************************
127.13 +begin
127.14 +;************************************************
127.15 +; read in data: observed
127.16 +;************************************************
127.17 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/"
127.18 + fili = "co2_globalView_98.nc"
127.19 + g = addfile (diri+fili,"r")
127.20 + val = g->CO2_SEAS
127.21 + lon = g->LON
127.22 + lat = g->LAT
127.23 + sta = chartostring(g->STATION)
127.24 + delete (g)
127.25 +
127.26 +;print (sta(0))
127.27 +
127.28 + ncase = dimsizes(lat)
127.29 +;print (ncase)
127.30 +
127.31 +;**************************************************************
127.32 +; get only the lowest level at each station
127.33 +;**************************************************************
127.34 + lat_tmp = lat
127.35 + lat_tmp@_FillValue = 1.e+36
127.36 +
127.37 + do n = 0,ncase-1
127.38 + if (.not. ismissing(lat_tmp(n))) then
127.39 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
127.40 + if (dimsizes(indexes) .gt. 1) then
127.41 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
127.42 + end if
127.43 + delete (indexes)
127.44 + end if
127.45 + end do
127.46 +
127.47 + indexes = ind(.not. ismissing(lat_tmp))
127.48 +;print (dimsizes(indexes))
127.49 +;print (indexes)
127.50 +
127.51 + lat_ob = lat(indexes)
127.52 + lon_ob = lon(indexes)
127.53 + val_ob = val(indexes,:)
127.54 +;printVarSummary (val_ob)
127.55 +;print (lat_ob +"/"+lon_ob)
127.56 +
127.57 +;************************************************
127.58 +; read in model data
127.59 +;************************************************
127.60 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
127.61 +; fili2 = "b30.061m_401_425_MONS_climo_atm.nc"
127.62 + fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
127.63 +
127.64 + g = addfile(diri2+fili2,"r")
127.65 + x = g->CO2
127.66 + xi = g->lon
127.67 + yi = g->lat
127.68 + xdim = dimsizes(x)
127.69 + nlev = xdim(1)
127.70 + y = x(:,0,:,:)
127.71 +; printVarSummary (y)
127.72 +
127.73 +; get the co2 at the lowest level
127.74 + y = x(:,nlev-1,:,:)
127.75 +
127.76 +; change to unit of observed (u mol/mol)
127.77 +; Model_units [=] kgCO2 / kgDryAir
127.78 +; 28.966 = molecular weight of dry air
127.79 +; 44. = molecular weight of CO2
127.80 +; u mol = 1e-6 mol
127.81 +
127.82 + factor = (28.966/44.) * 1e6
127.83 + y = y * factor
127.84 +
127.85 + y@_FillValue = 1.e36
127.86 + y@units = "u mol/mol"
127.87 +; y = where(y0 .lt. 287.,y@_FillValue,y)
127.88 +; printVarSummary (y)
127.89 +; print (min(y)+"/"+max(y))
127.90 +
127.91 +; interpolate into observed station
127.92 +; note: model is 0-360E, 90S-90N
127.93 +
127.94 +; to be able to handle observation at (-89.98,-24.80)
127.95 + print (yi(0))
127.96 + yi(0) = -90.
127.97 +
127.98 + i = ind(lon_ob .lt. 0.)
127.99 + lon_ob(i) = lon_ob(i) + 360.
127.100 +
127.101 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
127.102 +
127.103 + val_model = yo(pts|:,time|:)
127.104 + val_model_0 = val_model
127.105 +; printVarSummary (val_model)
127.106 +; print (min(val_model)+"/"+max(val_model))
127.107 +
127.108 +; remove annual mean
127.109 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
127.110 +; print (min(val_model)+"/"+max(val_model))
127.111 +
127.112 + nzone = 4
127.113 +
127.114 +;*******************************************************************
127.115 +; for table -- zone
127.116 +;*******************************************************************
127.117 +; table header name
127.118 + table_header_name = "Zone"
127.119 +
127.120 +; column (not including header column)
127.121 + col_header_zone = (/"Stations","Amplitude Ratio", \
127.122 + "Correlation Coef","M score","Combined Score"/)
127.123 + ncol_zone = dimsizes(col_header_zone )
127.124 +
127.125 +; row (not including header row)
127.126 + row_header_zone = (/"60N-90N","30N-60N","EQ-30N","90S-EQ","Total"/)
127.127 + nrow_zone = dimsizes(row_header_zone)
127.128 +
127.129 +; arrays to be passed to table.
127.130 + value_zone = new ((/nrow_zone, ncol_zone/),string )
127.131 +;--------------------------------------------------------------------
127.132 +
127.133 + table_length_zone = 0.4
127.134 +
127.135 +; Table header
127.136 + ncr1 = (/1,1/) ; 1 row, 1 column
127.137 + x1 = (/0.005,0.15/) ; Start and end X
127.138 + y1 = (/0.900,0.995/) ; Start and end Y
127.139 + text1 = table_header_name
127.140 + res1 = True
127.141 + res1@txFontHeightF = 0.03
127.142 + res1@gsFillColor = "CornFlowerBlue"
127.143 +
127.144 +; Column header (equally space in x2)
127.145 + ncr2 = (/1,ncol_zone/) ; 1 rows, 5 columns
127.146 + x2 = (/x1(1),0.995/) ; start from end of x1
127.147 + y2 = y1 ; same as y1
127.148 + text2 = col_header_zone
127.149 + res2 = True
127.150 + res2@txFontHeightF = 0.015
127.151 + res2@gsFillColor = "Gray"
127.152 +
127.153 +; Row header (equally space in y2)
127.154 + ncr3 = (/nrow_zone,1/) ; 5 rows, 1 columns
127.155 + x3 = x1 ; same as x1
127.156 + y3 = (/1.0-table_length_zone,0.900/) ; end at start of y1
127.157 + text3 = row_header_zone
127.158 + res3 = True
127.159 + res3@txFontHeightF = 0.02
127.160 + res3@gsFillColor = "Gray"
127.161 +
127.162 +; Main table body
127.163 + ncr4 = (/nrow_zone,ncol_zone/) ; 5 rows, 5 columns
127.164 + x4 = x2 ; Start and end x
127.165 + y4 = y3 ; Start and end Y
127.166 + text4 = new((/nrow_zone,ncol_zone/),string)
127.167 +
127.168 + color_fill4 = new((/nrow_zone,ncol_zone/),string)
127.169 + color_fill4 = "white"
127.170 + color_fill4(:,ncol_zone-1) = "grey"
127.171 +
127.172 + res4 = True ; Set up resource list
127.173 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
127.174 + res4@txFontHeightF = 0.02
127.175 + res4@gsFillColor = color_fill4
127.176 +
127.177 + delete (color_fill4)
127.178 +
127.179 +;*******************************************************************
127.180 +; for table -- station
127.181 +;*******************************************************************
127.182 +; column (not including header column)
127.183 + col_header_sta = (/"Latitude","Longitude","Amplitude Ratio", \
127.184 + "Correlation Coef","M score","Combined Score"/)
127.185 + ncol_sta = dimsizes(col_header_sta )
127.186 +;-------------------------------------------------------------------
127.187 +
127.188 +; Table header
127.189 + ncr5 = (/1,1/) ; 1 row, 1 column
127.190 + x5 = (/0.005,0.15/) ; Start and end X
127.191 + y5 = (/0.900,0.995/) ; Start and end Y
127.192 + res5 = True
127.193 + res5@txFontHeightF = 0.02
127.194 + res5@gsFillColor = "CornFlowerBlue"
127.195 +
127.196 +; Column header (equally space in x2)
127.197 + ncr6 = (/1,ncol_sta/) ; 1 rows, 5 columns
127.198 + x6 = (/x5(1),0.995/) ; start from end of x1
127.199 + y6 = y5 ; same as y1
127.200 + text6 = col_header_sta
127.201 + res6 = True
127.202 + res6@txFontHeightF = 0.012
127.203 + res6@gsFillColor = "Gray"
127.204 +
127.205 +; Row header (equally space in y2)
127.206 +
127.207 + res7 = True
127.208 + res7@txFontHeightF = 0.015
127.209 + res7@gsFillColor = "Gray"
127.210 +;--------------------------------------------------------------
127.211 +; for station line plot
127.212 +
127.213 +; for x-axis in xyplot
127.214 + mon = ispan(1,12,1)
127.215 + mon@long_name = "month"
127.216 +
127.217 + plot_type = "ps"
127.218 + plot_type_new = "png"
127.219 +
127.220 + res = True ; plot mods desired
127.221 + res@xyLineThicknesses = (/2.0,2.0,2.0/) ; make 2nd lines thicker
127.222 + res@xyLineColors = (/"red","black"/) ; change line color
127.223 +
127.224 +; Add a boxed legend using the more simple method
127.225 +
127.226 + res@pmLegendDisplayMode = "Always"
127.227 +; res@pmLegendWidthF = 0.1
127.228 + res@pmLegendWidthF = 0.08
127.229 + res@pmLegendHeightF = 0.06
127.230 +; res@pmLegendOrthogonalPosF = -1.17
127.231 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
127.232 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
127.233 +
127.234 +; res@pmLegendParallelPosF = 0.18
127.235 + res@pmLegendParallelPosF = 0.23 ;(rightward)
127.236 +
127.237 +; res@lgPerimOn = False
127.238 + res@lgLabelFontHeightF = 0.015
127.239 + res@xyExplicitLegendLabels = (/"b30.061n","observed"/)
127.240 +;-------------------------------------------------------------------
127.241 +
127.242 + do z = 0,nzone-1
127.243 +
127.244 + if (z .eq. 0) then
127.245 +; maximum score for the zone, 60N-90N
127.246 + zone = "60N-90N"
127.247 + score_max = 5.0
127.248 +; index of stations in this zone
127.249 + ind_z = ind(lat_ob .ge. 60.)
127.250 +; print (ind_z)
127.251 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
127.252 +; print (val_ob(ind_z,:))
127.253 +; print (val_model(ind_z,:))
127.254 + end if
127.255 +
127.256 + if (z .eq. 1) then
127.257 +; maximum score for the zone, 30N-60N
127.258 + zone = "30N-60N"
127.259 + score_max = 5.0
127.260 +; index of stations in this zone
127.261 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
127.262 +; print (ind_z)
127.263 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
127.264 +; print (val_ob(ind_z,:))
127.265 +; print (val_model(ind_z,:))
127.266 + end if
127.267 +
127.268 + if (z .eq. 2) then
127.269 +; maximum score for the zone, EQ-30N
127.270 + zone = "EQ-30N"
127.271 + score_max = 5.0
127.272 +; index of stations in this zone
127.273 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
127.274 +; print (ind_z)
127.275 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
127.276 +; print (val_ob(ind_z,:))
127.277 +; print (val_model(ind_z,:))
127.278 + end if
127.279 +
127.280 + if (z .eq. 3) then
127.281 +; maximum score for the zone, 90S-EQ
127.282 + zone = "90S-EQ"
127.283 + score_max = 5.0
127.284 +; index of stations in this zone
127.285 + ind_z = ind(lat_ob .lt. 0. )
127.286 +; print (ind_z)
127.287 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
127.288 +; print (val_ob(ind_z,:))
127.289 +; print (val_model(ind_z,:))
127.290 + end if
127.291 +
127.292 + npts = dimsizes(ind_z)
127.293 + print (npts)
127.294 +;-------------------------------------------------------------------------
127.295 +; for metric table computation
127.296 +
127.297 + amp_ob = new((/npts/),float)
127.298 + amp_model = new((/npts/),float)
127.299 +
127.300 + amp_ratio_sta = new((/npts/),float)
127.301 + ccr_sta = new((/npts/),float)
127.302 + M_sta = new((/npts/),float)
127.303 + score_sta = new((/npts/),float)
127.304 +
127.305 +;----------------------
127.306 +; for table -- station
127.307 +;----------------------
127.308 +
127.309 +; row (not including header row)
127.310 + nrow_sta = npts
127.311 +
127.312 +; Table header
127.313 + ncr5 = (/1,1/) ; 1 row, 1 column
127.314 + x5 = (/0.005,0.15/) ; Start and end X
127.315 + y5 = (/0.900,0.995/) ; Start and end Y
127.316 + res5 = True
127.317 + res5@txFontHeightF = 0.02
127.318 + res5@gsFillColor = "CornFlowerBlue"
127.319 +
127.320 +; Column header (equally space in x2)
127.321 + ncr6 = (/1,ncol_sta/) ; 1 rows, 5 columns
127.322 + x6 = (/x1(1),0.995/) ; start from end of x1
127.323 + y6 = y1 ; same as y1
127.324 + text6 = col_header_sta
127.325 + res6 = True
127.326 + res6@txFontHeightF = 0.012
127.327 + res6@gsFillColor = "Gray"
127.328 +
127.329 +; Row header (equally space in y2)
127.330 + ncr7 = (/nrow_sta,1/) ; 5 rows, 1 columns
127.331 + x7 = x1 ; same as x1
127.332 +; y7 = (/1.0-table_length_sta,0.900/) ; end at start of y1
127.333 + text7 = new((/nrow_sta/),string)
127.334 + res7 = True
127.335 + res7@txFontHeightF = 0.015
127.336 + res7@gsFillColor = "Gray"
127.337 +;-------------------------------------------------------------------------
127.338 +; for station line plot
127.339 +
127.340 + npts_str = ""
127.341 + npts_str = npts
127.342 +; print (npts_str)
127.343 +
127.344 + plot_data = new((/2,12,npts/),float)
127.345 + plot_data_0 = new((/12,npts/),float)
127.346 +
127.347 + plot_data!0 = "case"
127.348 + plot_data!1 = "month"
127.349 + plot_data!2 = "pts"
127.350 + plot_data@long_name = "CO2 Seasonal"
127.351 +
127.352 + plot_data_0!0 = "month"
127.353 + plot_data_0!1 = "pts"
127.354 + plot_data_0@long_name = "CO2"
127.355 +;--------------------------------------------------------------------------
127.356 + do n=0,npts-1
127.357 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
127.358 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
127.359 +
127.360 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
127.361 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
127.362 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
127.363 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
127.364 +
127.365 + print (sta(ind_z(n))+"/"+lat(ind_z(n))+"/"+lon(ind_z(n))+"/"+amp_ratio_sta(n)+"/"+ccr_sta(n)+"/"+M_sta(n)+"/"+score_sta(n))
127.366 +;----------------------------------------------------------------------
127.367 +; for station line plot
127.368 +
127.369 + plot_data(0,:,n) = (/val_model(ind_z(n),:)/)
127.370 + plot_data(1,:,n) = (/val_ob(ind_z(n),:)/)
127.371 +
127.372 + plot_data_0(:,n) = (/val_model_0(ind_z(n),:)/)
127.373 +
127.374 + plot_name = sta(ind_z(n))
127.375 + title = plot_name+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
127.376 +; print (title)
127.377 +; print (plot_name)
127.378 +
127.379 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
127.380 +;------------------------------------------
127.381 +; for panel plot
127.382 +
127.383 + plot=new(2,graphic) ; create graphic array
127.384 + res@gsnFrame = False ; Do not draw plot
127.385 + res@gsnDraw = False ; Do not advance frame
127.386 +
127.387 + pres = True ; panel plot mods desired
127.388 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
127.389 + ; indiv. plots in panel
127.390 + pres@gsnMaximize = True ; fill the page
127.391 +;------------------------------------------
127.392 + res@tiMainString = title ; add title
127.393 +
127.394 + plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res) ; create plot 1
127.395 +
127.396 + plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,n),res) ; create plot 2
127.397 +
127.398 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
127.399 +
127.400 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
127.401 + system("rm "+plot_name+"."+plot_type)
127.402 + clear (wks)
127.403 +;---------------------------------------------------------------------------
127.404 + end do
127.405 +;-------------------------------------------------------------------------
127.406 +; for line plot in a zone
127.407 +
127.408 + plot_name = "All_"+npts_str
127.409 + title = plot_name + " in "+ zone
127.410 +; print (title)
127.411 +; print (plot_name)
127.412 +
127.413 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
127.414 +;-----------------------------------------
127.415 +; for panel plot
127.416 +
127.417 + plot=new(2,graphic) ; create graphic array
127.418 + res@gsnFrame = False ; Do not draw plot
127.419 + res@gsnDraw = False ; Do not advance frame
127.420 +
127.421 + pres = True ; panel plot mods desired
127.422 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
127.423 + ; indiv. plots in panel
127.424 + pres@gsnMaximize = True ; fill the page
127.425 +;-----------------------------------------
127.426 + res@tiMainString = title ; add title
127.427 +
127.428 + plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res) ; create plot 1
127.429 +
127.430 + plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
127.431 +
127.432 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
127.433 +
127.434 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
127.435 + system("rm "+plot_name+"."+plot_type)
127.436 +
127.437 + clear (wks)
127.438 +; delete (ind_z)
127.439 + delete (plot_data)
127.440 + delete (plot_data_0)
127.441 +;---------------------------------------------------------------------------
127.442 +; for zone table value
127.443 +
127.444 + amp_ratio_zone = avg(amp_ratio_sta)
127.445 + ccr_zone = avg(ccr_sta)
127.446 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
127.447 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
127.448 +
127.449 + print (npts+"/"+amp_ratio_zone+"/"+ccr_zone+"/"+M_zone+"/"+score_zone)
127.450 +
127.451 + text4(z,0) = sprintf("%5.2f", npts)
127.452 + text4(z,1) = sprintf("%5.2f", amp_ratio_zone)
127.453 + text4(z,2) = sprintf("%5.2f", ccr_zone)
127.454 + text4(z,3) = sprintf("%5.2f", M_zone)
127.455 + text4(z,4) = sprintf("%5.2f", score_zone)
127.456 +;---------------------------------------------------------------------------
127.457 +; plot station table
127.458 +;----------------------------------
127.459 +; header value for station table
127.460 + text5 = zone
127.461 +
127.462 +; row value for station table
127.463 + text7 = sta(ind_z)
127.464 +
127.465 + if (z .eq. 0) then
127.466 + table_length_sta = 0.5
127.467 + end if
127.468 + if (z .eq. 1) then
127.469 + table_length_sta = 0.995
127.470 + end if
127.471 + if (z .eq. 2) then
127.472 + table_length_sta = 0.8
127.473 + end if
127.474 + if (z .eq. 3) then
127.475 + table_length_sta = 0.8
127.476 + end if
127.477 +
127.478 + x7 = x5
127.479 + y7 = (/1.0-table_length_sta,0.900/) ; end at start of y1
127.480 +
127.481 +; Main table body
127.482 + ncr8 = (/nrow_sta,ncol_sta/) ; 5 rows, 5 columns
127.483 + x8 = x6 ; Start and end x
127.484 + y8 = y7 ; Start and end Y
127.485 + text8 = new((/nrow_sta,ncol_sta/),string)
127.486 +
127.487 + color_fill8 = text8
127.488 + color_fill8 = "white"
127.489 + color_fill8(:,ncol_sta-1) = "grey"
127.490 +
127.491 + res8 = True ; Set up resource list
127.492 + res8@gsnDebug = True ; Useful to print NDC row,col values used.
127.493 + res8@txFontHeightF = 0.02
127.494 + res8@gsFillColor = color_fill8
127.495 +
127.496 + delete (color_fill8)
127.497 +
127.498 +; table value for station table
127.499 + text8(:,0) = sprintf("%5.2f", (/lat(ind_z)/))
127.500 + text8(:,1) = sprintf("%5.2f", (/lon(ind_z)/))
127.501 + text8(:,2) = sprintf("%5.2f", (/amp_ratio_sta/))
127.502 + text8(:,3) = sprintf("%5.2f", (/ccr_sta/))
127.503 + text8(:,4) = sprintf("%5.2f", (/M_sta/))
127.504 + text8(:,5) = sprintf("%5.2f", (/score_sta/))
127.505 +
127.506 + plot_name = "table_sta." + zone
127.507 +
127.508 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
127.509 +
127.510 + gsn_table(wks,ncr5,x5,y5,text5,res5)
127.511 + gsn_table(wks,ncr6,x6,y6,text6,res6)
127.512 + gsn_table(wks,ncr7,x7,y7,text7,res7)
127.513 + gsn_table(wks,ncr8,x8,y8,text8,res8)
127.514 +
127.515 + frame(wks)
127.516 +
127.517 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
127.518 + system("rm "+plot_name+"."+plot_type)
127.519 +
127.520 + delete (ind_z)
127.521 + delete (amp_model)
127.522 + delete (amp_ob)
127.523 + delete (amp_ratio_sta)
127.524 + delete (ccr_sta)
127.525 + delete (M_sta)
127.526 + delete (score_sta)
127.527 + delete (text7)
127.528 + delete (text8)
127.529 + delete (res7)
127.530 + delete (res8)
127.531 + clear (wks)
127.532 + end do
127.533 +;**************************************************
127.534 +; plot zone table
127.535 +;**************************************************
127.536 +
127.537 + text4(4,0) = sum(stringtofloat(text4(0:3,0)))
127.538 + text4(4,1) = 0.
127.539 + text4(4,2) = 0.
127.540 + text4(4,3) = 0.
127.541 + text4(4,4) = sum(stringtofloat(text4(0:3,4)))
127.542 +
127.543 + plot_name = "table_zone"
127.544 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
127.545 +
127.546 + gsn_table(wks,ncr1,x1,y1,text1,res1)
127.547 + gsn_table(wks,ncr2,x2,y2,text2,res2)
127.548 + gsn_table(wks,ncr3,x3,y3,text3,res3)
127.549 + gsn_table(wks,ncr4,x4,y4,text4,res4)
127.550 +
127.551 + frame(wks)
127.552 +
127.553 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
127.554 + system("rm "+plot_name+"."+plot_type)
127.555 +
127.556 +end
128.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
128.2 +++ b/co2/99.all.ncl Mon Jan 26 22:08:20 2009 -0500
128.3 @@ -0,0 +1,532 @@
128.4 +; ***********************************************
128.5 +; using gsn_table for all
128.6 +; combine 19.metric_plot.ncl and 24.lines.ncl
128.7 +; ***********************************************
128.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
128.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
128.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
128.11 +;************************************************
128.12 +procedure set_line(lines:string,nline:integer,newlines:string)
128.13 +begin
128.14 +; add line to ascci/html file
128.15 +
128.16 + nnewlines = dimsizes(newlines)
128.17 + if(nline+nnewlines-1.ge.dimsizes(lines))
128.18 + print("set_line: bad index, not setting anything.")
128.19 + return
128.20 + end if
128.21 + lines(nline:nline+nnewlines-1) = newlines
128.22 +; print ("lines = " + lines(nline:nline+nnewlines-1))
128.23 + nline = nline + nnewlines
128.24 + return
128.25 +end
128.26 +;****************************************************************************
128.27 +
128.28 +begin
128.29 +
128.30 + plot_type = "ps"
128.31 + plot_type_new = "png"
128.32 +
128.33 +;************************************************
128.34 +; read model data
128.35 +;************************************************
128.36 +
128.37 +; from command line inputs
128.38 +
128.39 +;--------------------------------------------------
128.40 +; edit table.html of current model for movel1_vs_model2
128.41 +
128.42 + if (isvar("compare")) then
128.43 + html_name2 = compare+"/table.html"
128.44 + html_new2 = html_name2 +".new"
128.45 +
128.46 +; the following only needs to execute once
128.47 +; system("sed 1,/model_nameA/s//"+model_name+"/ "+html_name2+" > "+html_new2+";"+ \
128.48 +; "mv -f "+html_new2+" "+html_name2+";"+ \
128.49 +; "sed 1,/model_nameB/s//"+model_name+"/ "+html_name2+" > "+html_new2+";"+ \
128.50 +; "mv -f "+html_new2+" "+html_name2+";"+ \
128.51 +; "sed s#"+modeln+"#"+model_name+"# "+html_name2+" > "+html_new2+";"+ \
128.52 +; "mv -f "+html_new2+" "+html_name2)
128.53 + end if
128.54 +
128.55 +;-------------------------------------
128.56 +; edit table.html for current model
128.57 +
128.58 + html_name = model_name+"/table.html"
128.59 + html_new = html_name +".new"
128.60 +
128.61 +; the following only needs to execute once
128.62 +; system("sed s#model_name#"+model_name+"# "+html_name+" > "+html_new+";"+ \
128.63 +; "mv -f "+html_new+" "+html_name)
128.64 +;------------------------------------------------
128.65 + fm = addfile(dirm+film3,"r")
128.66 +
128.67 + x = fm->CO2
128.68 + xi = fm->lon
128.69 + yi = fm->lat
128.70 +
128.71 + xdim = dimsizes(x)
128.72 + nlev = xdim(1)
128.73 + y = x(:,0,:,:)
128.74 +
128.75 +; get co2 at the lowest level
128.76 + y = x(:,nlev-1,:,:)
128.77 +
128.78 +; change to unit of observed (u mol/mol)
128.79 +; Model_units [=] kgCO2 / kgDryAir
128.80 +; 28.966 = molecular weight of dry air
128.81 +; 44. = molecular weight of CO2
128.82 +; u mol = 1e-6 mol
128.83 +
128.84 + factor = (28.966/44.) * 1e6
128.85 + y = y * factor
128.86 +
128.87 + y@_FillValue = 1.e36
128.88 + y@units = "u mol/mol"
128.89 +;************************************************
128.90 +; read data: observed
128.91 +;************************************************
128.92 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/ob/"
128.93 + fili = "co2_globalView_98.nc"
128.94 + g = addfile (diri+fili,"r")
128.95 + val = g->CO2_SEAS
128.96 + lon = g->LON
128.97 + lat = g->LAT
128.98 + sta = chartostring(g->STATION)
128.99 + delete (g)
128.100 +
128.101 + ncase = dimsizes(lat)
128.102 +;**************************************************************
128.103 +; get only the lowest level at each station
128.104 +;**************************************************************
128.105 + lat_tmp = lat
128.106 + lat_tmp@_FillValue = 1.e+36
128.107 +
128.108 + do n = 0,ncase-1
128.109 + if (.not. ismissing(lat_tmp(n))) then
128.110 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
128.111 + if (dimsizes(indexes) .gt. 1) then
128.112 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
128.113 + end if
128.114 + delete (indexes)
128.115 + end if
128.116 + end do
128.117 +
128.118 + indexes = ind(.not. ismissing(lat_tmp))
128.119 +
128.120 + lat_ob = lat(indexes)
128.121 + lon_ob = lon(indexes)
128.122 + val_ob = val(indexes,:)
128.123 +;************************************************************
128.124 +; interpolate model data into observed station
128.125 +; note: model is 0-360E, 90S-90N
128.126 +;************************************************************
128.127 +; to be able to handle observation at (-89.98,-24.80)
128.128 + yi(0) = -90.
128.129 +
128.130 + i = ind(lon_ob .lt. 0.)
128.131 + lon_ob(i) = lon_ob(i) + 360.
128.132 +
128.133 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
128.134 +
128.135 + val_model = yo(pts|:,time|:)
128.136 + val_model_0 = val_model
128.137 +;************************************************************
128.138 +; remove annual mean
128.139 +;************************************************************
128.140 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
128.141 +
128.142 +;*******************************************************************
128.143 +; res for station line plot
128.144 +;*******************************************************************
128.145 +; for x-axis in xyplot
128.146 + mon = ispan(1,12,1)
128.147 + mon@long_name = "month"
128.148 +
128.149 + res = True ; plot mods desired
128.150 + res@xyLineThicknesses = (/2.0,2.0,2.0/) ; make 2nd lines thicker
128.151 + res@xyLineColors = (/"red","black"/) ; change line color
128.152 +
128.153 +; Add a boxed legend using the more simple method
128.154 + res@pmLegendDisplayMode = "Always"
128.155 +; res@pmLegendWidthF = 0.1
128.156 + res@pmLegendWidthF = 0.08
128.157 + res@pmLegendHeightF = 0.06
128.158 +; res@pmLegendOrthogonalPosF = -1.17
128.159 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
128.160 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
128.161 +
128.162 +; res@pmLegendParallelPosF = 0.18
128.163 + res@pmLegendParallelPosF = 0.23 ;(rightward)
128.164 +
128.165 +; res@lgPerimOn = False
128.166 + res@lgLabelFontHeightF = 0.015
128.167 + res@xyExplicitLegendLabels = (/model_name,"observed"/)
128.168 +;************************************************************
128.169 +; number of latitude zone
128.170 +;************************************************************
128.171 + nzone = 4
128.172 +
128.173 +; saving data for zone
128.174 +; number of rows for zone table (with data)
128.175 + nrow_zone = nzone
128.176 +
128.177 +; number of columns for zone table
128.178 + ncol_zone = 6
128.179 +
128.180 + text4 = new((/nrow_zone,ncol_zone/),string)
128.181 +
128.182 +do z = 0,nzone-1
128.183 +
128.184 + if (z .eq. 0) then
128.185 + zone = "60N-90N"
128.186 + score_max = 5.0
128.187 + ind_z = ind(lat_ob .ge. 60.)
128.188 + end if
128.189 +
128.190 + if (z .eq. 1) then
128.191 + zone = "30N-60N"
128.192 + score_max = 5.0
128.193 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
128.194 + end if
128.195 +
128.196 + if (z .eq. 2) then
128.197 + zone = "EQ-30N"
128.198 + score_max = 5.0
128.199 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
128.200 + end if
128.201 +
128.202 + if (z .eq. 3) then
128.203 + zone = "90S-EQ"
128.204 + score_max = 5.0
128.205 + ind_z = ind(lat_ob .lt. 0. )
128.206 + end if
128.207 +
128.208 + npts = dimsizes(ind_z)
128.209 +
128.210 +;------------------------------------------------------
128.211 +; for metric table computation
128.212 + amp_ob = new((/npts/),float)
128.213 + amp_model = new((/npts/),float)
128.214 +
128.215 + amp_ratio_sta = new((/npts/),float)
128.216 + ccr_sta = new((/npts/),float)
128.217 + M_sta = new((/npts/),float)
128.218 + score_sta = new((/npts/),float)
128.219 +;-----------------------------------------------------
128.220 +; for station line plot
128.221 + npts_str = ""
128.222 + npts_str = npts
128.223 +
128.224 + plot_data = new((/2,12,npts/),float)
128.225 + plot_data_0 = new((/12,npts/),float)
128.226 +
128.227 + plot_data!0 = "case"
128.228 + plot_data!1 = "month"
128.229 + plot_data!2 = "pts"
128.230 + plot_data@long_name = "CO2 Seasonal"
128.231 +
128.232 + plot_data_0!0 = "month"
128.233 + plot_data_0!1 = "pts"
128.234 + plot_data_0@long_name = "CO2"
128.235 +;--------------------------------------------------------------------------
128.236 + do n=0,npts-1
128.237 +
128.238 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
128.239 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
128.240 +
128.241 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
128.242 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
128.243 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
128.244 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
128.245 +
128.246 +;----------------------------------------------------------------------
128.247 +; for station line plot
128.248 +
128.249 + plot_data(0,:,n) = (/val_model(ind_z(n),:)/)
128.250 + plot_data(1,:,n) = (/val_ob(ind_z(n),:)/)
128.251 +
128.252 + plot_data_0(:,n) = (/val_model_0(ind_z(n),:)/)
128.253 +
128.254 + plot_name = sta(ind_z(n))
128.255 + title = plot_name+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
128.256 +
128.257 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
128.258 +;------------------------------------------
128.259 +; for panel plot
128.260 +
128.261 + plot=new(2,graphic) ; create graphic array
128.262 + res@gsnFrame = False ; Do not draw plot
128.263 + res@gsnDraw = False ; Do not advance frame
128.264 +
128.265 + pres = True ; panel plot mods desired
128.266 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
128.267 + ; indiv. plots in panel
128.268 + pres@gsnMaximize = True ; fill the page
128.269 +;------------------------------------------
128.270 + res@tiMainString = title ; add title
128.271 +
128.272 + plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res) ; create plot 1
128.273 +
128.274 + plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,n),res) ; create plot 2
128.275 +
128.276 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
128.277 +
128.278 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
128.279 + system("rm "+plot_name+"."+plot_type)
128.280 +
128.281 + clear (wks)
128.282 +;---------------------------------------------------------------------------
128.283 + end do
128.284 +;-------------------------------------------------------------------------
128.285 +; for line plot in a zone
128.286 +
128.287 + plot_name = "All_"+npts_str
128.288 + title = plot_name + " in "+ zone
128.289 +
128.290 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
128.291 +;-----------------------------------------
128.292 +; for panel plot
128.293 +
128.294 + plot=new(2,graphic) ; create graphic array
128.295 + res@gsnFrame = False ; Do not draw plot
128.296 + res@gsnDraw = False ; Do not advance frame
128.297 +
128.298 + pres = True ; panel plot mods desired
128.299 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
128.300 + ; indiv. plots in panel
128.301 + pres@gsnMaximize = True ; fill the page
128.302 +;-----------------------------------------
128.303 + res@tiMainString = title ; add title
128.304 +
128.305 + plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res) ; create plot 1
128.306 +
128.307 + plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
128.308 +
128.309 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
128.310 +
128.311 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
128.312 + system("rm "+plot_name+"."+plot_type)
128.313 +
128.314 + clear (wks)
128.315 +; delete (ind_z)
128.316 + delete (plot_data)
128.317 + delete (plot_data_0)
128.318 +;---------------------------------------------------------------------------
128.319 +; values saved for zone table
128.320 +
128.321 + amp_ratio_zone = avg(amp_ratio_sta)
128.322 + ccr_zone = avg(ccr_sta)
128.323 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
128.324 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
128.325 +
128.326 + text4(z,0) = zone
128.327 + text4(z,1) = sprintf("%.0f", npts)
128.328 + text4(z,2) = sprintf("%.2f", amp_ratio_zone)
128.329 + text4(z,3) = sprintf("%.2f", ccr_zone)
128.330 + text4(z,4) = sprintf("%.2f", M_zone)
128.331 + text4(z,5) = sprintf("%.2f", score_zone)
128.332 +
128.333 +;*******************************************************************
128.334 +; html table -- station
128.335 +;*******************************************************************
128.336 + output_html = "score+line_"+zone+".html"
128.337 +
128.338 + header = (/"<HTML>" \
128.339 + ,"<HEAD>" \
128.340 + ,"<TITLE>CLAMP metrics</TITLE>" \
128.341 + ,"</HEAD>" \
128.342 + ,"<H1>CO2 in Zone "+zone+": Model "+model_name+"</H1>" \
128.343 + /)
128.344 + footer = "</HTML>"
128.345 +
128.346 + table_header = (/ \
128.347 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
128.348 + ,"<tr>" \
128.349 + ," <th bgcolor=DDDDDD >Site Name</th>" \
128.350 + ," <th bgcolor=DDDDDD >Latitude</th>" \
128.351 + ," <th bgcolor=DDDDDD >Longitude</th>" \
128.352 + ," <th bgcolor=DDDDDD >Amplitude Ratio</th>" \
128.353 + ," <th bgcolor=DDDDDD >Correleration Coef</th>" \
128.354 + ," <th bgcolor=DDDDDD >M Score</th>" \
128.355 + ," <th bgcolor=DDDDDD >Combined Score</th>" \
128.356 + ,"</tr>" \
128.357 + /)
128.358 + table_footer = "</table>"
128.359 + row_header = "<tr>"
128.360 + row_footer = "</tr>"
128.361 +
128.362 + lines = new(50000,string)
128.363 + nline = 0
128.364 +
128.365 + set_line(lines,nline,header)
128.366 + set_line(lines,nline,table_header)
128.367 +;-----------------------------------------------
128.368 +; row of table
128.369 +
128.370 + do n = 0,npts-1
128.371 + set_line(lines,nline,row_header)
128.372 +
128.373 + txt0 = sta(ind_z(n))
128.374 + txt1 = sprintf("%5.2f", (/lat(ind_z(n))/))
128.375 + txt2 = sprintf("%5.2f", (/lon(ind_z(n))/))
128.376 + txt3 = sprintf("%5.2f", (/amp_ratio_sta(n)/))
128.377 + txt4 = sprintf("%5.2f", (/ccr_sta(n)/))
128.378 + txt5 = sprintf("%5.2f", (/M_sta(n)/))
128.379 + txt6 = sprintf("%5.2f", (/score_sta(n)/))
128.380 +
128.381 + set_line(lines,nline,"<th><a href="+txt0+".png>"+txt0+"</a></th>")
128.382 + set_line(lines,nline,"<th>"+txt1+"</th>")
128.383 + set_line(lines,nline,"<th>"+txt2+"</th>")
128.384 + set_line(lines,nline,"<th>"+txt3+"</th>")
128.385 + set_line(lines,nline,"<th>"+txt4+"</th>")
128.386 + set_line(lines,nline,"<th>"+txt5+"</th>")
128.387 + set_line(lines,nline,"<th>"+txt6+"</th>")
128.388 +
128.389 + set_line(lines,nline,row_footer)
128.390 + end do
128.391 +
128.392 +; last row, summary
128.393 + set_line(lines,nline,row_header)
128.394 +
128.395 + txt0 = "All_"+sprintf("%.0f", (/npts/))
128.396 + txt1 = "-"
128.397 + txt2 = "-"
128.398 + txt3 = sprintf("%5.2f", (/amp_ratio_zone/))
128.399 + txt4 = sprintf("%5.2f", (/ccr_zone/))
128.400 + txt5 = sprintf("%5.2f", (/M_zone/))
128.401 + txt6 = sprintf("%5.2f", (/score_zone/))
128.402 +
128.403 + set_line(lines,nline,"<th><a href="+txt0+".png>"+txt0+"</a></th>")
128.404 + set_line(lines,nline,"<th>"+txt1+"</th>")
128.405 + set_line(lines,nline,"<th>"+txt2+"</th>")
128.406 + set_line(lines,nline,"<th>"+txt3+"</th>")
128.407 + set_line(lines,nline,"<th>"+txt4+"</th>")
128.408 + set_line(lines,nline,"<th>"+txt5+"</th>")
128.409 + set_line(lines,nline,"<th>"+txt6+"</th>")
128.410 +
128.411 + set_line(lines,nline,row_footer)
128.412 +;-----------------------------------------------
128.413 + set_line(lines,nline,table_footer)
128.414 + set_line(lines,nline,footer)
128.415 +
128.416 +; Now write to an HTML file.
128.417 + idx = ind(.not.ismissing(lines))
128.418 + if(.not.any(ismissing(idx))) then
128.419 + asciiwrite(output_html,lines(idx))
128.420 + else
128.421 + print ("error?")
128.422 + end if
128.423 + delete (idx)
128.424 +;-----------------------------------------------------------------
128.425 +
128.426 + delete (ind_z)
128.427 + delete (amp_model)
128.428 + delete (amp_ob)
128.429 + delete (amp_ratio_sta)
128.430 + delete (ccr_sta)
128.431 + delete (M_sta)
128.432 + delete (score_sta)
128.433 + clear (wks)
128.434 +end do
128.435 +
128.436 +;*******************************************************************
128.437 +; html table -- zone
128.438 +;*******************************************************************
128.439 + output_html = "score+line_vs_ob.html"
128.440 +
128.441 + header = (/"<HTML>" \
128.442 + ,"<HEAD>" \
128.443 + ,"<TITLE>CLAMP metrics</TITLE>" \
128.444 + ,"</HEAD>" \
128.445 + ,"<H1>CO2 in Latitude Zone: Model "+model_name+"</H1>" \
128.446 + /)
128.447 + footer = "</HTML>"
128.448 +
128.449 + delete (table_header)
128.450 + table_header = (/ \
128.451 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
128.452 + ,"<tr>" \
128.453 + ," <th bgcolor=DDDDDD >Zone</th>" \
128.454 + ," <th bgcolor=DDDDDD >Number of Site</th>" \
128.455 + ," <th bgcolor=DDDDDD >Amplitide Ratio</th>" \
128.456 + ," <th bgcolor=DDDDDD >Correleration Coef</th>" \
128.457 + ," <th bgcolor=DDDDDD >M Score</th>" \
128.458 + ," <th bgcolor=DDDDDD >Combined Score</th>" \
128.459 + ,"</tr>" \
128.460 + /)
128.461 + table_footer = "</table>"
128.462 + row_header = "<tr>"
128.463 + row_footer = "</tr>"
128.464 +
128.465 + lines = new(50000,string)
128.466 + nline = 0
128.467 +
128.468 + set_line(lines,nline,header)
128.469 + set_line(lines,nline,table_header)
128.470 +;-----------------------------------------------
128.471 +;row of table
128.472 +
128.473 + do n = 0,nrow_zone-1
128.474 + set_line(lines,nline,row_header)
128.475 +
128.476 + set_line(lines,nline,"<th><a href=score+line_"+text4(n,0)+".html>"+text4(n,0)+"</th>")
128.477 + set_line(lines,nline,"<th>"+text4(n,1)+"</th>")
128.478 + set_line(lines,nline,"<th>"+text4(n,2)+"</th>")
128.479 + set_line(lines,nline,"<th>"+text4(n,3)+"</th>")
128.480 + set_line(lines,nline,"<th>"+text4(n,4)+"</th>")
128.481 + set_line(lines,nline,"<th>"+text4(n,5)+"</th>")
128.482 +
128.483 + set_line(lines,nline,row_footer)
128.484 + end do
128.485 +
128.486 +; for the last row
128.487 +
128.488 + txt0 = "All"
128.489 + txt1 = sum(stringtofloat(text4(0:3,1)))
128.490 + txt2 = "-"
128.491 + txt3 = "-"
128.492 + txt4 = "-"
128.493 + txt5 = sum(stringtofloat(text4(0:3,5)))
128.494 +
128.495 + set_line(lines,nline,row_header)
128.496 +
128.497 + set_line(lines,nline,"<th>"+txt0+"</th>")
128.498 + set_line(lines,nline,"<th>"+txt1+"</th>")
128.499 + set_line(lines,nline,"<th>"+txt2+"</th>")
128.500 + set_line(lines,nline,"<th>"+txt3+"</th>")
128.501 + set_line(lines,nline,"<th>"+txt4+"</th>")
128.502 + set_line(lines,nline,"<th>"+txt5+"</th>")
128.503 +
128.504 + set_line(lines,nline,row_footer)
128.505 +;-----------------------------------------------
128.506 + set_line(lines,nline,table_footer)
128.507 + set_line(lines,nline,footer)
128.508 +
128.509 +; Now write to an HTML file.
128.510 + idx = ind(.not.ismissing(lines))
128.511 + if(.not.any(ismissing(idx))) then
128.512 + asciiwrite(output_html,lines(idx))
128.513 + else
128.514 + print ("error?")
128.515 + end if
128.516 + delete (idx)
128.517 +;--------------------------------------------------------------------------
128.518 +
128.519 + M_co2 = txt5
128.520 +
128.521 + if (isvar("compare")) then
128.522 + system("sed 1,/M_co2/s//"+M_co2+"/ "+html_name2+" > "+html_new2+";"+ \
128.523 + "mv -f "+html_new2+" "+html_name2)
128.524 + end if
128.525 +
128.526 + system("sed s#M_co2#"+M_co2+"# "+html_name+" > "+html_new+";"+ \
128.527 + "mv -f "+html_new+" "+html_name)
128.528 +;***************************************************************************
128.529 +; output plots
128.530 +;***************************************************************************
128.531 + output_dir = model_name+"/co2"
128.532 +
128.533 + system("mv *.png *.html " + output_dir)
128.534 +;***************************************************************************
128.535 +end
129.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
129.2 +++ b/co2/99.all.ncl.0 Mon Jan 26 22:08:20 2009 -0500
129.3 @@ -0,0 +1,558 @@
129.4 +; ***********************************************
129.5 +; using gsn_table for all
129.6 +; combine 19.metric_plot.ncl and 24.lines.ncl
129.7 +; ***********************************************
129.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
129.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
129.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
129.11 +;load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
129.12 +;************************************************
129.13 +begin
129.14 +;************************************************
129.15 +; read in model data
129.16 +;************************************************
129.17 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
129.18 +; fili2 = "b30.061m_401_425_MONS_climo_atm.nc"
129.19 + fili2 = "b30.061n_1995-2004_MONS_climo_atm.nc"
129.20 +
129.21 + g = addfile(diri2+fili2,"r")
129.22 + x = g->CO2
129.23 + xi = g->lon
129.24 + yi = g->lat
129.25 + xdim = dimsizes(x)
129.26 + nlev = xdim(1)
129.27 + y = x(:,0,:,:)
129.28 +; printVarSummary (y)
129.29 +
129.30 +; get the co2 at the lowest level
129.31 + y = x(:,nlev-1,:,:)
129.32 +
129.33 +; change to unit of observed (u mol/mol)
129.34 +; Model_units [=] kgCO2 / kgDryAir
129.35 +; 28.966 = molecular weight of dry air
129.36 +; 44. = molecular weight of CO2
129.37 +; u mol = 1e-6 mol
129.38 +
129.39 + factor = (28.966/44.) * 1e6
129.40 + y = y * factor
129.41 +
129.42 + y@_FillValue = 1.e36
129.43 + y@units = "u mol/mol"
129.44 +; y = where(y0 .lt. 287.,y@_FillValue,y)
129.45 +; printVarSummary (y)
129.46 +; print (min(y)+"/"+max(y))
129.47 +
129.48 +;************************************************
129.49 +; read in data: observed
129.50 +;************************************************
129.51 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/ob/"
129.52 + fili = "co2_globalView_98.nc"
129.53 + g = addfile (diri+fili,"r")
129.54 + val = g->CO2_SEAS
129.55 + lon = g->LON
129.56 + lat = g->LAT
129.57 + sta = chartostring(g->STATION)
129.58 + delete (g)
129.59 +
129.60 +;print (sta(0))
129.61 +
129.62 + ncase = dimsizes(lat)
129.63 +;print (ncase)
129.64 +
129.65 +;**************************************************************
129.66 +; get only the lowest level at each station
129.67 +;**************************************************************
129.68 + lat_tmp = lat
129.69 + lat_tmp@_FillValue = 1.e+36
129.70 +
129.71 + do n = 0,ncase-1
129.72 + if (.not. ismissing(lat_tmp(n))) then
129.73 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
129.74 + if (dimsizes(indexes) .gt. 1) then
129.75 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
129.76 + end if
129.77 + delete (indexes)
129.78 + end if
129.79 + end do
129.80 +
129.81 + indexes = ind(.not. ismissing(lat_tmp))
129.82 +;print (dimsizes(indexes))
129.83 +;print (indexes)
129.84 +
129.85 + lat_ob = lat(indexes)
129.86 + lon_ob = lon(indexes)
129.87 + val_ob = val(indexes,:)
129.88 +;printVarSummary (val_ob)
129.89 +;print (lat_ob +"/"+lon_ob)
129.90 +
129.91 +;************************************************************
129.92 +; interpolate model data into observed station
129.93 +; note: model is 0-360E, 90S-90N
129.94 +;************************************************************
129.95 +; to be able to handle observation at (-89.98,-24.80)
129.96 + print (yi(0))
129.97 + yi(0) = -90.
129.98 +
129.99 + i = ind(lon_ob .lt. 0.)
129.100 + lon_ob(i) = lon_ob(i) + 360.
129.101 +
129.102 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
129.103 +
129.104 + val_model = yo(pts|:,time|:)
129.105 + val_model_0 = val_model
129.106 +; printVarSummary (val_model)
129.107 +; print (min(val_model)+"/"+max(val_model))
129.108 +
129.109 +; remove annual mean
129.110 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
129.111 +; print (min(val_model)+"/"+max(val_model))
129.112 +
129.113 + nzone = 4
129.114 +
129.115 +;*******************************************************************
129.116 +; for table -- zone
129.117 +;*******************************************************************
129.118 +; table header name
129.119 + table_header_name = "Zone"
129.120 +
129.121 +; column (not including header column)
129.122 + col_header_zone = (/"Stations","Amplitude Ratio", \
129.123 + "Correlation Coef","M score","Combined Score"/)
129.124 + ncol_zone = dimsizes(col_header_zone )
129.125 +
129.126 +; row (not including header row)
129.127 + row_header_zone = (/"60N-90N","30N-60N","EQ-30N","90S-EQ","Total"/)
129.128 + nrow_zone = dimsizes(row_header_zone)
129.129 +
129.130 +; arrays to be passed to table.
129.131 + value_zone = new ((/nrow_zone, ncol_zone/),string )
129.132 +;--------------------------------------------------------------------
129.133 +
129.134 + table_length_zone = 0.4
129.135 +
129.136 +; Table header
129.137 + ncr1 = (/1,1/) ; 1 row, 1 column
129.138 + x1 = (/0.005,0.15/) ; Start and end X
129.139 + y1 = (/0.900,0.995/) ; Start and end Y
129.140 + text1 = table_header_name
129.141 + res1 = True
129.142 + res1@txFontHeightF = 0.03
129.143 + res1@gsFillColor = "CornFlowerBlue"
129.144 +
129.145 +; Column header (equally space in x2)
129.146 + ncr2 = (/1,ncol_zone/) ; 1 rows, 5 columns
129.147 + x2 = (/x1(1),0.995/) ; start from end of x1
129.148 + y2 = y1 ; same as y1
129.149 + text2 = col_header_zone
129.150 + res2 = True
129.151 + res2@txFontHeightF = 0.015
129.152 + res2@gsFillColor = "Gray"
129.153 +
129.154 +; Row header (equally space in y2)
129.155 + ncr3 = (/nrow_zone,1/) ; 5 rows, 1 columns
129.156 + x3 = x1 ; same as x1
129.157 + y3 = (/1.0-table_length_zone,0.900/) ; end at start of y1
129.158 + text3 = row_header_zone
129.159 + res3 = True
129.160 + res3@txFontHeightF = 0.02
129.161 + res3@gsFillColor = "Gray"
129.162 +
129.163 +; Main table body
129.164 + ncr4 = (/nrow_zone,ncol_zone/) ; 5 rows, 5 columns
129.165 + x4 = x2 ; Start and end x
129.166 + y4 = y3 ; Start and end Y
129.167 + text4 = new((/nrow_zone,ncol_zone/),string)
129.168 +
129.169 + color_fill4 = new((/nrow_zone,ncol_zone/),string)
129.170 + color_fill4 = "white"
129.171 + color_fill4(:,ncol_zone-1) = "grey"
129.172 +
129.173 + res4 = True ; Set up resource list
129.174 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
129.175 + res4@txFontHeightF = 0.02
129.176 + res4@gsFillColor = color_fill4
129.177 +
129.178 + delete (color_fill4)
129.179 +
129.180 +;*******************************************************************
129.181 +; for table -- station
129.182 +;*******************************************************************
129.183 +; column (not including header column)
129.184 + col_header_sta = (/"Latitude","Longitude","Amplitude Ratio", \
129.185 + "Correlation Coef","M score","Combined Score"/)
129.186 + ncol_sta = dimsizes(col_header_sta )
129.187 +;-------------------------------------------------------------------
129.188 +
129.189 +; Table header
129.190 + ncr5 = (/1,1/) ; 1 row, 1 column
129.191 + x5 = (/0.005,0.15/) ; Start and end X
129.192 + y5 = (/0.900,0.995/) ; Start and end Y
129.193 + res5 = True
129.194 + res5@txFontHeightF = 0.02
129.195 + res5@gsFillColor = "CornFlowerBlue"
129.196 +
129.197 +; Column header (equally space in x2)
129.198 + ncr6 = (/1,ncol_sta/) ; 1 rows, 5 columns
129.199 + x6 = (/x5(1),0.995/) ; start from end of x1
129.200 + y6 = y5 ; same as y1
129.201 + text6 = col_header_sta
129.202 + res6 = True
129.203 + res6@txFontHeightF = 0.012
129.204 + res6@gsFillColor = "Gray"
129.205 +
129.206 +; Row header (equally space in y2)
129.207 +
129.208 + res7 = True
129.209 + res7@txFontHeightF = 0.015
129.210 + res7@gsFillColor = "Gray"
129.211 +;--------------------------------------------------------------
129.212 +; for station line plot
129.213 +
129.214 +; for x-axis in xyplot
129.215 + mon = ispan(1,12,1)
129.216 + mon@long_name = "month"
129.217 +
129.218 + plot_type = "ps"
129.219 + plot_type_new = "png"
129.220 +
129.221 + res = True ; plot mods desired
129.222 + res@xyLineThicknesses = (/2.0,2.0,2.0/) ; make 2nd lines thicker
129.223 + res@xyLineColors = (/"red","black"/) ; change line color
129.224 +
129.225 +; Add a boxed legend using the more simple method
129.226 +
129.227 + res@pmLegendDisplayMode = "Always"
129.228 +; res@pmLegendWidthF = 0.1
129.229 + res@pmLegendWidthF = 0.08
129.230 + res@pmLegendHeightF = 0.06
129.231 +; res@pmLegendOrthogonalPosF = -1.17
129.232 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
129.233 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
129.234 +
129.235 +; res@pmLegendParallelPosF = 0.18
129.236 + res@pmLegendParallelPosF = 0.23 ;(rightward)
129.237 +
129.238 +; res@lgPerimOn = False
129.239 + res@lgLabelFontHeightF = 0.015
129.240 + res@xyExplicitLegendLabels = (/"b30.061n","observed"/)
129.241 +;-------------------------------------------------------------------
129.242 +
129.243 + do z = 0,nzone-1
129.244 +
129.245 + if (z .eq. 0) then
129.246 +; maximum score for the zone, 60N-90N
129.247 + zone = "60N-90N"
129.248 + score_max = 5.0
129.249 +; index of stations in this zone
129.250 + ind_z = ind(lat_ob .ge. 60.)
129.251 +; print (ind_z)
129.252 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
129.253 +; print (val_ob(ind_z,:))
129.254 +; print (val_model(ind_z,:))
129.255 + end if
129.256 +
129.257 + if (z .eq. 1) then
129.258 +; maximum score for the zone, 30N-60N
129.259 + zone = "30N-60N"
129.260 + score_max = 5.0
129.261 +; index of stations in this zone
129.262 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
129.263 +; print (ind_z)
129.264 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
129.265 +; print (val_ob(ind_z,:))
129.266 +; print (val_model(ind_z,:))
129.267 + end if
129.268 +
129.269 + if (z .eq. 2) then
129.270 +; maximum score for the zone, EQ-30N
129.271 + zone = "EQ-30N"
129.272 + score_max = 5.0
129.273 +; index of stations in this zone
129.274 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
129.275 +; print (ind_z)
129.276 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
129.277 +; print (val_ob(ind_z,:))
129.278 +; print (val_model(ind_z,:))
129.279 + end if
129.280 +
129.281 + if (z .eq. 3) then
129.282 +; maximum score for the zone, 90S-EQ
129.283 + zone = "90S-EQ"
129.284 + score_max = 5.0
129.285 +; index of stations in this zone
129.286 + ind_z = ind(lat_ob .lt. 0. )
129.287 +; print (ind_z)
129.288 +; print (lat_ob(ind_z)+"/"+lon_ob(ind_z))
129.289 +; print (val_ob(ind_z,:))
129.290 +; print (val_model(ind_z,:))
129.291 + end if
129.292 +
129.293 + npts = dimsizes(ind_z)
129.294 + print (npts)
129.295 +;-------------------------------------------------------------------------
129.296 +; for metric table computation
129.297 +
129.298 + amp_ob = new((/npts/),float)
129.299 + amp_model = new((/npts/),float)
129.300 +
129.301 + amp_ratio_sta = new((/npts/),float)
129.302 + ccr_sta = new((/npts/),float)
129.303 + M_sta = new((/npts/),float)
129.304 + score_sta = new((/npts/),float)
129.305 +
129.306 +;----------------------
129.307 +; for table -- station
129.308 +;----------------------
129.309 +
129.310 +; row (not including header row)
129.311 + nrow_sta = npts
129.312 +
129.313 +; Table header
129.314 + ncr5 = (/1,1/) ; 1 row, 1 column
129.315 + x5 = (/0.005,0.15/) ; Start and end X
129.316 + y5 = (/0.900,0.995/) ; Start and end Y
129.317 + res5 = True
129.318 + res5@txFontHeightF = 0.02
129.319 + res5@gsFillColor = "CornFlowerBlue"
129.320 +
129.321 +; Column header (equally space in x2)
129.322 + ncr6 = (/1,ncol_sta/) ; 1 rows, 5 columns
129.323 + x6 = (/x1(1),0.995/) ; start from end of x1
129.324 + y6 = y1 ; same as y1
129.325 + text6 = col_header_sta
129.326 + res6 = True
129.327 + res6@txFontHeightF = 0.012
129.328 + res6@gsFillColor = "Gray"
129.329 +
129.330 +; Row header (equally space in y2)
129.331 + ncr7 = (/nrow_sta,1/) ; 5 rows, 1 columns
129.332 + x7 = x1 ; same as x1
129.333 +; y7 = (/1.0-table_length_sta,0.900/) ; end at start of y1
129.334 + text7 = new((/nrow_sta/),string)
129.335 + res7 = True
129.336 + res7@txFontHeightF = 0.015
129.337 + res7@gsFillColor = "Gray"
129.338 +;-------------------------------------------------------------------------
129.339 +; for station line plot
129.340 +
129.341 + npts_str = ""
129.342 + npts_str = npts
129.343 +; print (npts_str)
129.344 +
129.345 + plot_data = new((/2,12,npts/),float)
129.346 + plot_data_0 = new((/12,npts/),float)
129.347 +
129.348 + plot_data!0 = "case"
129.349 + plot_data!1 = "month"
129.350 + plot_data!2 = "pts"
129.351 + plot_data@long_name = "CO2 Seasonal"
129.352 +
129.353 + plot_data_0!0 = "month"
129.354 + plot_data_0!1 = "pts"
129.355 + plot_data_0@long_name = "CO2"
129.356 +;--------------------------------------------------------------------------
129.357 + do n=0,npts-1
129.358 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
129.359 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
129.360 +
129.361 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
129.362 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
129.363 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
129.364 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
129.365 +
129.366 + print (sta(ind_z(n))+"/"+lat(ind_z(n))+"/"+lon(ind_z(n))+"/"+amp_ratio_sta(n)+"/"+ccr_sta(n)+"/"+M_sta(n)+"/"+score_sta(n))
129.367 +;----------------------------------------------------------------------
129.368 +; for station line plot
129.369 +
129.370 + plot_data(0,:,n) = (/val_model(ind_z(n),:)/)
129.371 + plot_data(1,:,n) = (/val_ob(ind_z(n),:)/)
129.372 +
129.373 + plot_data_0(:,n) = (/val_model_0(ind_z(n),:)/)
129.374 +
129.375 + plot_name = sta(ind_z(n))
129.376 + title = plot_name+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
129.377 +; print (title)
129.378 +; print (plot_name)
129.379 +
129.380 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
129.381 +;------------------------------------------
129.382 +; for panel plot
129.383 +
129.384 + plot=new(2,graphic) ; create graphic array
129.385 + res@gsnFrame = False ; Do not draw plot
129.386 + res@gsnDraw = False ; Do not advance frame
129.387 +
129.388 + pres = True ; panel plot mods desired
129.389 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
129.390 + ; indiv. plots in panel
129.391 + pres@gsnMaximize = True ; fill the page
129.392 +;------------------------------------------
129.393 + res@tiMainString = title ; add title
129.394 +
129.395 + plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res) ; create plot 1
129.396 +
129.397 + plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,n),res) ; create plot 2
129.398 +
129.399 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
129.400 +
129.401 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
129.402 + system("rm "+plot_name+"."+plot_type)
129.403 + clear (wks)
129.404 +;---------------------------------------------------------------------------
129.405 + end do
129.406 +;-------------------------------------------------------------------------
129.407 +; for line plot in a zone
129.408 +
129.409 + plot_name = "All_"+npts_str
129.410 + title = plot_name + " in "+ zone
129.411 +; print (title)
129.412 +; print (plot_name)
129.413 +
129.414 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
129.415 +;-----------------------------------------
129.416 +; for panel plot
129.417 +
129.418 + plot=new(2,graphic) ; create graphic array
129.419 + res@gsnFrame = False ; Do not draw plot
129.420 + res@gsnDraw = False ; Do not advance frame
129.421 +
129.422 + pres = True ; panel plot mods desired
129.423 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
129.424 + ; indiv. plots in panel
129.425 + pres@gsnMaximize = True ; fill the page
129.426 +;-----------------------------------------
129.427 + res@tiMainString = title ; add title
129.428 +
129.429 + plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res) ; create plot 1
129.430 +
129.431 + plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
129.432 +
129.433 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
129.434 +
129.435 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
129.436 + system("rm "+plot_name+"."+plot_type)
129.437 +
129.438 + clear (wks)
129.439 +; delete (ind_z)
129.440 + delete (plot_data)
129.441 + delete (plot_data_0)
129.442 +;---------------------------------------------------------------------------
129.443 +; for zone table value
129.444 +
129.445 + amp_ratio_zone = avg(amp_ratio_sta)
129.446 + ccr_zone = avg(ccr_sta)
129.447 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
129.448 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
129.449 +
129.450 + print (npts+"/"+amp_ratio_zone+"/"+ccr_zone+"/"+M_zone+"/"+score_zone)
129.451 +
129.452 + text4(z,0) = sprintf("%5.2f", npts)
129.453 + text4(z,1) = sprintf("%5.2f", amp_ratio_zone)
129.454 + text4(z,2) = sprintf("%5.2f", ccr_zone)
129.455 + text4(z,3) = sprintf("%5.2f", M_zone)
129.456 + text4(z,4) = sprintf("%5.2f", score_zone)
129.457 +;---------------------------------------------------------------------------
129.458 +; plot station table
129.459 +;----------------------------------
129.460 +; header value for station table
129.461 + text5 = zone
129.462 +
129.463 +; row value for station table
129.464 + text7 = sta(ind_z)
129.465 +
129.466 + if (z .eq. 0) then
129.467 + table_length_sta = 0.5
129.468 + end if
129.469 + if (z .eq. 1) then
129.470 + table_length_sta = 0.995
129.471 + end if
129.472 + if (z .eq. 2) then
129.473 + table_length_sta = 0.8
129.474 + end if
129.475 + if (z .eq. 3) then
129.476 + table_length_sta = 0.8
129.477 + end if
129.478 +
129.479 + x7 = x5
129.480 + y7 = (/1.0-table_length_sta,0.900/) ; end at start of y1
129.481 +
129.482 +; Main table body
129.483 + ncr8 = (/nrow_sta,ncol_sta/) ; 5 rows, 5 columns
129.484 + x8 = x6 ; Start and end x
129.485 + y8 = y7 ; Start and end Y
129.486 + text8 = new((/nrow_sta,ncol_sta/),string)
129.487 +
129.488 + color_fill8 = text8
129.489 + color_fill8 = "white"
129.490 + color_fill8(:,ncol_sta-1) = "grey"
129.491 +
129.492 + res8 = True ; Set up resource list
129.493 + res8@gsnDebug = True ; Useful to print NDC row,col values used.
129.494 + res8@txFontHeightF = 0.02
129.495 + res8@gsFillColor = color_fill8
129.496 +
129.497 + delete (color_fill8)
129.498 +
129.499 +; table value for station table
129.500 + text8(:,0) = sprintf("%5.2f", (/lat(ind_z)/))
129.501 + text8(:,1) = sprintf("%5.2f", (/lon(ind_z)/))
129.502 + text8(:,2) = sprintf("%5.2f", (/amp_ratio_sta/))
129.503 + text8(:,3) = sprintf("%5.2f", (/ccr_sta/))
129.504 + text8(:,4) = sprintf("%5.2f", (/M_sta/))
129.505 + text8(:,5) = sprintf("%5.2f", (/score_sta/))
129.506 +
129.507 + plot_name = "table_sta." + zone
129.508 +
129.509 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
129.510 +
129.511 + gsn_table(wks,ncr5,x5,y5,text5,res5)
129.512 + gsn_table(wks,ncr6,x6,y6,text6,res6)
129.513 + gsn_table(wks,ncr7,x7,y7,text7,res7)
129.514 + gsn_table(wks,ncr8,x8,y8,text8,res8)
129.515 +
129.516 + frame(wks)
129.517 +
129.518 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
129.519 + system("rm "+plot_name+"."+plot_type)
129.520 +
129.521 + delete (ind_z)
129.522 + delete (amp_model)
129.523 + delete (amp_ob)
129.524 + delete (amp_ratio_sta)
129.525 + delete (ccr_sta)
129.526 + delete (M_sta)
129.527 + delete (score_sta)
129.528 + delete (text7)
129.529 + delete (text8)
129.530 + delete (res7)
129.531 + delete (res8)
129.532 + clear (wks)
129.533 + end do
129.534 +;**************************************************
129.535 +; plot zone table
129.536 +;**************************************************
129.537 +
129.538 + text4(4,0) = sum(stringtofloat(text4(0:3,0)))
129.539 + text4(4,1) = 0.
129.540 + text4(4,2) = 0.
129.541 + text4(4,3) = 0.
129.542 + text4(4,4) = sum(stringtofloat(text4(0:3,4)))
129.543 +
129.544 + plot_name = "table_zone"
129.545 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
129.546 +
129.547 + gsn_table(wks,ncr1,x1,y1,text1,res1)
129.548 + gsn_table(wks,ncr2,x2,y2,text2,res2)
129.549 + gsn_table(wks,ncr3,x3,y3,text3,res3)
129.550 + gsn_table(wks,ncr4,x4,y4,text4,res4)
129.551 +
129.552 + frame(wks)
129.553 +
129.554 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
129.555 + system("rm "+plot_name+"."+plot_type)
129.556 +;-------------------------------------------------------------------
129.557 + system("mkdir temp")
129.558 + system("mv *.png temp")
129.559 + system("tar cf temp.tar temp")
129.560 +;-------------------------------------------------------------------
129.561 +end
130.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
130.2 +++ b/co2/99.all.ncl.1 Mon Jan 26 22:08:20 2009 -0500
130.3 @@ -0,0 +1,558 @@
130.4 +; ***********************************************
130.5 +; using gsn_table for all
130.6 +; combine 19.metric_plot.ncl and 24.lines.ncl
130.7 +; ***********************************************
130.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
130.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
130.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
130.11 +;load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
130.12 +;************************************************
130.13 +begin
130.14 +
130.15 +;************************************************
130.16 +; read model data
130.17 +;************************************************
130.18 +
130.19 +; from command line inputs
130.20 +
130.21 +;--------------------------------------------------
130.22 +; edit table.html of current model for movel1_vs_model2
130.23 +
130.24 + if (isvar("compare")) then
130.25 + html_name2 = compare+"/table.html"
130.26 + html_new2 = html_name2 +".new"
130.27 +
130.28 +; the following only needs to execute once
130.29 +; system("sed 1,/model_nameA/s//"+model_name+"/ "+html_name2+" > "+html_new2+";"+ \
130.30 +; "mv -f "+html_new2+" "+html_name2+";"+ \
130.31 +; "sed 1,/model_nameB/s//"+model_name+"/ "+html_name2+" > "+html_new2+";"+ \
130.32 +; "mv -f "+html_new2+" "+html_name2+";"+ \
130.33 +; "sed s#"+modeln+"#"+model_name+"# "+html_name2+" > "+html_new2+";"+ \
130.34 +; "mv -f "+html_new2+" "+html_name2)
130.35 + end if
130.36 +
130.37 +;-------------------------------------
130.38 +; edit table.html for current model
130.39 +
130.40 + html_name = model_name+"/table.html"
130.41 + html_new = html_name +".new"
130.42 +
130.43 +; the following only needs to execute once
130.44 +; system("sed s#model_name#"+model_name+"# "+html_name+" > "+html_new+";"+ \
130.45 +; "mv -f "+html_new+" "+html_name)
130.46 +;------------------------------------------------
130.47 +
130.48 + fm = addfile(dirm+film3,"r")
130.49 +
130.50 + x = fm->CO2
130.51 + xi = fm->lon
130.52 + yi = fm->lat
130.53 +
130.54 + xdim = dimsizes(x)
130.55 + nlev = xdim(1)
130.56 + y = x(:,0,:,:)
130.57 +
130.58 +; get co2 at the lowest level
130.59 + y = x(:,nlev-1,:,:)
130.60 +
130.61 +; change to unit of observed (u mol/mol)
130.62 +; Model_units [=] kgCO2 / kgDryAir
130.63 +; 28.966 = molecular weight of dry air
130.64 +; 44. = molecular weight of CO2
130.65 +; u mol = 1e-6 mol
130.66 +
130.67 + factor = (28.966/44.) * 1e6
130.68 + y = y * factor
130.69 +
130.70 + y@_FillValue = 1.e36
130.71 + y@units = "u mol/mol"
130.72 +;************************************************
130.73 +; read data: observed
130.74 +;************************************************
130.75 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/ob/"
130.76 + fili = "co2_globalView_98.nc"
130.77 + g = addfile (diri+fili,"r")
130.78 + val = g->CO2_SEAS
130.79 + lon = g->LON
130.80 + lat = g->LAT
130.81 + sta = chartostring(g->STATION)
130.82 + delete (g)
130.83 +
130.84 + ncase = dimsizes(lat)
130.85 +;**************************************************************
130.86 +; get only the lowest level at each station
130.87 +;**************************************************************
130.88 + lat_tmp = lat
130.89 + lat_tmp@_FillValue = 1.e+36
130.90 +
130.91 + do n = 0,ncase-1
130.92 + if (.not. ismissing(lat_tmp(n))) then
130.93 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
130.94 + if (dimsizes(indexes) .gt. 1) then
130.95 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
130.96 + end if
130.97 + delete (indexes)
130.98 + end if
130.99 + end do
130.100 +
130.101 + indexes = ind(.not. ismissing(lat_tmp))
130.102 +
130.103 + lat_ob = lat(indexes)
130.104 + lon_ob = lon(indexes)
130.105 + val_ob = val(indexes,:)
130.106 +;************************************************************
130.107 +; interpolate model data into observed station
130.108 +; note: model is 0-360E, 90S-90N
130.109 +;************************************************************
130.110 +; to be able to handle observation at (-89.98,-24.80)
130.111 + yi(0) = -90.
130.112 +
130.113 + i = ind(lon_ob .lt. 0.)
130.114 + lon_ob(i) = lon_ob(i) + 360.
130.115 +
130.116 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
130.117 +
130.118 + val_model = yo(pts|:,time|:)
130.119 + val_model_0 = val_model
130.120 +
130.121 +; remove annual mean
130.122 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
130.123 +
130.124 + nzone = 4
130.125 +
130.126 +;*******************************************************************
130.127 +; for table -- zone
130.128 +;*******************************************************************
130.129 +; table header name
130.130 + table_header_name = "Zone"
130.131 +
130.132 +; column (not including header column)
130.133 + col_header_zone = (/"Stations","Amplitude Ratio", \
130.134 + "Correlation Coef","M score","Combined Score"/)
130.135 + ncol_zone = dimsizes(col_header_zone )
130.136 +
130.137 +; row (not including header row)
130.138 + row_header_zone = (/"60N-90N","30N-60N","EQ-30N","90S-EQ","Total"/)
130.139 + nrow_zone = dimsizes(row_header_zone)
130.140 +
130.141 +; arrays to be passed to table.
130.142 + value_zone = new ((/nrow_zone, ncol_zone/),string )
130.143 +;--------------------------------------------------------------------
130.144 +
130.145 + table_length_zone = 0.4
130.146 +
130.147 +; Table header
130.148 + ncr1 = (/1,1/) ; 1 row, 1 column
130.149 + x1 = (/0.005,0.15/) ; Start and end X
130.150 + y1 = (/0.900,0.995/) ; Start and end Y
130.151 + text1 = table_header_name
130.152 + res1 = True
130.153 + res1@txFontHeightF = 0.03
130.154 + res1@gsFillColor = "CornFlowerBlue"
130.155 +
130.156 +; Column header (equally space in x2)
130.157 + ncr2 = (/1,ncol_zone/) ; 1 rows, 5 columns
130.158 + x2 = (/x1(1),0.995/) ; start from end of x1
130.159 + y2 = y1 ; same as y1
130.160 + text2 = col_header_zone
130.161 + res2 = True
130.162 + res2@txFontHeightF = 0.015
130.163 + res2@gsFillColor = "Gray"
130.164 +
130.165 +; Row header (equally space in y2)
130.166 + ncr3 = (/nrow_zone,1/) ; 5 rows, 1 columns
130.167 + x3 = x1 ; same as x1
130.168 + y3 = (/1.0-table_length_zone,0.900/) ; end at start of y1
130.169 + text3 = row_header_zone
130.170 + res3 = True
130.171 + res3@txFontHeightF = 0.02
130.172 + res3@gsFillColor = "Gray"
130.173 +
130.174 +; Main table body
130.175 + ncr4 = (/nrow_zone,ncol_zone/) ; 5 rows, 5 columns
130.176 + x4 = x2 ; Start and end x
130.177 + y4 = y3 ; Start and end Y
130.178 + text4 = new((/nrow_zone,ncol_zone/),string)
130.179 +
130.180 + color_fill4 = new((/nrow_zone,ncol_zone/),string)
130.181 + color_fill4 = "white"
130.182 + color_fill4(:,ncol_zone-1) = "grey"
130.183 +
130.184 + res4 = True ; Set up resource list
130.185 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
130.186 + res4@txFontHeightF = 0.02
130.187 + res4@gsFillColor = color_fill4
130.188 +
130.189 + delete (color_fill4)
130.190 +
130.191 +;*******************************************************************
130.192 +; for table -- station
130.193 +;*******************************************************************
130.194 +; column (not including header column)
130.195 + col_header_sta = (/"Latitude","Longitude","Amplitude Ratio", \
130.196 + "Correlation Coef","M score","Combined Score"/)
130.197 + ncol_sta = dimsizes(col_header_sta )
130.198 +;-------------------------------------------------------------------
130.199 +
130.200 +; Table header
130.201 + ncr5 = (/1,1/) ; 1 row, 1 column
130.202 + x5 = (/0.005,0.15/) ; Start and end X
130.203 + y5 = (/0.900,0.995/) ; Start and end Y
130.204 + res5 = True
130.205 + res5@txFontHeightF = 0.02
130.206 + res5@gsFillColor = "CornFlowerBlue"
130.207 +
130.208 +; Column header (equally space in x2)
130.209 + ncr6 = (/1,ncol_sta/) ; 1 rows, 5 columns
130.210 + x6 = (/x5(1),0.995/) ; start from end of x1
130.211 + y6 = y5 ; same as y1
130.212 + text6 = col_header_sta
130.213 + res6 = True
130.214 + res6@txFontHeightF = 0.012
130.215 + res6@gsFillColor = "Gray"
130.216 +
130.217 +; Row header (equally space in y2)
130.218 +
130.219 + res7 = True
130.220 + res7@txFontHeightF = 0.015
130.221 + res7@gsFillColor = "Gray"
130.222 +;--------------------------------------------------------------
130.223 +; for station line plot
130.224 +
130.225 +; for x-axis in xyplot
130.226 + mon = ispan(1,12,1)
130.227 + mon@long_name = "month"
130.228 +
130.229 + plot_type = "ps"
130.230 + plot_type_new = "png"
130.231 +
130.232 + res = True ; plot mods desired
130.233 + res@xyLineThicknesses = (/2.0,2.0,2.0/) ; make 2nd lines thicker
130.234 + res@xyLineColors = (/"red","black"/) ; change line color
130.235 +
130.236 +; Add a boxed legend using the more simple method
130.237 +
130.238 + res@pmLegendDisplayMode = "Always"
130.239 +; res@pmLegendWidthF = 0.1
130.240 + res@pmLegendWidthF = 0.08
130.241 + res@pmLegendHeightF = 0.06
130.242 +; res@pmLegendOrthogonalPosF = -1.17
130.243 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
130.244 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
130.245 +
130.246 +; res@pmLegendParallelPosF = 0.18
130.247 + res@pmLegendParallelPosF = 0.23 ;(rightward)
130.248 +
130.249 +; res@lgPerimOn = False
130.250 + res@lgLabelFontHeightF = 0.015
130.251 + res@xyExplicitLegendLabels = (/"b30.061n","observed"/)
130.252 +;-------------------------------------------------------------------
130.253 +
130.254 + do z = 0,nzone-1
130.255 +
130.256 + if (z .eq. 0) then
130.257 +; maximum score for the zone, 60N-90N
130.258 + zone = "60N-90N"
130.259 + score_max = 5.0
130.260 +; index of stations in this zone
130.261 + ind_z = ind(lat_ob .ge. 60.)
130.262 + end if
130.263 +
130.264 + if (z .eq. 1) then
130.265 +; maximum score for the zone, 30N-60N
130.266 + zone = "30N-60N"
130.267 + score_max = 5.0
130.268 +; index of stations in this zone
130.269 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
130.270 + end if
130.271 +
130.272 + if (z .eq. 2) then
130.273 +; maximum score for the zone, EQ-30N
130.274 + zone = "EQ-30N"
130.275 + score_max = 5.0
130.276 +; index of stations in this zone
130.277 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
130.278 + end if
130.279 +
130.280 + if (z .eq. 3) then
130.281 +; maximum score for the zone, 90S-EQ
130.282 + zone = "90S-EQ"
130.283 + score_max = 5.0
130.284 +; index of stations in this zone
130.285 + ind_z = ind(lat_ob .lt. 0. )
130.286 + end if
130.287 +
130.288 + npts = dimsizes(ind_z)
130.289 +
130.290 +;-------------------------------------------------------------------------
130.291 +; for metric table computation
130.292 +
130.293 + amp_ob = new((/npts/),float)
130.294 + amp_model = new((/npts/),float)
130.295 +
130.296 + amp_ratio_sta = new((/npts/),float)
130.297 + ccr_sta = new((/npts/),float)
130.298 + M_sta = new((/npts/),float)
130.299 + score_sta = new((/npts/),float)
130.300 +
130.301 +;----------------------
130.302 +; for table -- station
130.303 +;----------------------
130.304 +
130.305 +; row (not including header row)
130.306 + nrow_sta = npts
130.307 +
130.308 +; Table header
130.309 + ncr5 = (/1,1/) ; 1 row, 1 column
130.310 + x5 = (/0.005,0.15/) ; Start and end X
130.311 + y5 = (/0.900,0.995/) ; Start and end Y
130.312 + res5 = True
130.313 + res5@txFontHeightF = 0.02
130.314 + res5@gsFillColor = "CornFlowerBlue"
130.315 +
130.316 +; Column header (equally space in x2)
130.317 + ncr6 = (/1,ncol_sta/) ; 1 rows, 5 columns
130.318 + x6 = (/x1(1),0.995/) ; start from end of x1
130.319 + y6 = y1 ; same as y1
130.320 + text6 = col_header_sta
130.321 + res6 = True
130.322 + res6@txFontHeightF = 0.012
130.323 + res6@gsFillColor = "Gray"
130.324 +
130.325 +; Row header (equally space in y2)
130.326 + ncr7 = (/nrow_sta,1/) ; 5 rows, 1 columns
130.327 + x7 = x1 ; same as x1
130.328 +; y7 = (/1.0-table_length_sta,0.900/) ; end at start of y1
130.329 + text7 = new((/nrow_sta/),string)
130.330 + res7 = True
130.331 + res7@txFontHeightF = 0.015
130.332 + res7@gsFillColor = "Gray"
130.333 +;-------------------------------------------------------------------------
130.334 +; for station line plot
130.335 +
130.336 + npts_str = ""
130.337 + npts_str = npts
130.338 +
130.339 + plot_data = new((/2,12,npts/),float)
130.340 + plot_data_0 = new((/12,npts/),float)
130.341 +
130.342 + plot_data!0 = "case"
130.343 + plot_data!1 = "month"
130.344 + plot_data!2 = "pts"
130.345 + plot_data@long_name = "CO2 Seasonal"
130.346 +
130.347 + plot_data_0!0 = "month"
130.348 + plot_data_0!1 = "pts"
130.349 + plot_data_0@long_name = "CO2"
130.350 +;--------------------------------------------------------------------------
130.351 + do n=0,npts-1
130.352 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
130.353 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
130.354 +
130.355 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
130.356 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
130.357 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
130.358 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
130.359 +
130.360 +;----------------------------------------------------------------------
130.361 +; for station line plot
130.362 +
130.363 + plot_data(0,:,n) = (/val_model(ind_z(n),:)/)
130.364 + plot_data(1,:,n) = (/val_ob(ind_z(n),:)/)
130.365 +
130.366 + plot_data_0(:,n) = (/val_model_0(ind_z(n),:)/)
130.367 +
130.368 + plot_name = sta(ind_z(n))
130.369 + title = plot_name+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
130.370 +
130.371 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
130.372 +;------------------------------------------
130.373 +; for panel plot
130.374 +
130.375 + plot=new(2,graphic) ; create graphic array
130.376 + res@gsnFrame = False ; Do not draw plot
130.377 + res@gsnDraw = False ; Do not advance frame
130.378 +
130.379 + pres = True ; panel plot mods desired
130.380 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
130.381 + ; indiv. plots in panel
130.382 + pres@gsnMaximize = True ; fill the page
130.383 +;------------------------------------------
130.384 + res@tiMainString = title ; add title
130.385 +
130.386 + plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res) ; create plot 1
130.387 +
130.388 + plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,n),res) ; create plot 2
130.389 +
130.390 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
130.391 +
130.392 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
130.393 + system("rm "+plot_name+"."+plot_type)
130.394 +
130.395 + clear (wks)
130.396 +;---------------------------------------------------------------------------
130.397 + end do
130.398 +;-------------------------------------------------------------------------
130.399 +; for line plot in a zone
130.400 +
130.401 + plot_name = "All_"+npts_str
130.402 + title = plot_name + " in "+ zone
130.403 +
130.404 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
130.405 +;-----------------------------------------
130.406 +; for panel plot
130.407 +
130.408 + plot=new(2,graphic) ; create graphic array
130.409 + res@gsnFrame = False ; Do not draw plot
130.410 + res@gsnDraw = False ; Do not advance frame
130.411 +
130.412 + pres = True ; panel plot mods desired
130.413 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
130.414 + ; indiv. plots in panel
130.415 + pres@gsnMaximize = True ; fill the page
130.416 +;-----------------------------------------
130.417 + res@tiMainString = title ; add title
130.418 +
130.419 + plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res) ; create plot 1
130.420 +
130.421 + plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
130.422 +
130.423 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
130.424 +
130.425 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
130.426 + system("rm "+plot_name+"."+plot_type)
130.427 +
130.428 + clear (wks)
130.429 +; delete (ind_z)
130.430 + delete (plot_data)
130.431 + delete (plot_data_0)
130.432 +;---------------------------------------------------------------------------
130.433 +; for zone table value
130.434 +
130.435 + amp_ratio_zone = avg(amp_ratio_sta)
130.436 + ccr_zone = avg(ccr_sta)
130.437 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
130.438 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
130.439 +
130.440 + text4(z,0) = sprintf("%5.2f", npts)
130.441 + text4(z,1) = sprintf("%5.2f", amp_ratio_zone)
130.442 + text4(z,2) = sprintf("%5.2f", ccr_zone)
130.443 + text4(z,3) = sprintf("%5.2f", M_zone)
130.444 + text4(z,4) = sprintf("%5.2f", score_zone)
130.445 +;---------------------------------------------------------------------------
130.446 +; plot station table
130.447 +;----------------------------------
130.448 +; header value for station table
130.449 + text5 = zone
130.450 +
130.451 +; row value for station table
130.452 + text7 = sta(ind_z)
130.453 +
130.454 + if (z .eq. 0) then
130.455 + table_length_sta = 0.5
130.456 + end if
130.457 + if (z .eq. 1) then
130.458 + table_length_sta = 0.995
130.459 + end if
130.460 + if (z .eq. 2) then
130.461 + table_length_sta = 0.8
130.462 + end if
130.463 + if (z .eq. 3) then
130.464 + table_length_sta = 0.8
130.465 + end if
130.466 +
130.467 + x7 = x5
130.468 + y7 = (/1.0-table_length_sta,0.900/) ; end at start of y1
130.469 +
130.470 +; Main table body
130.471 + ncr8 = (/nrow_sta,ncol_sta/) ; 5 rows, 5 columns
130.472 + x8 = x6 ; Start and end x
130.473 + y8 = y7 ; Start and end Y
130.474 + text8 = new((/nrow_sta,ncol_sta/),string)
130.475 +
130.476 + color_fill8 = text8
130.477 + color_fill8 = "white"
130.478 + color_fill8(:,ncol_sta-1) = "grey"
130.479 +
130.480 + res8 = True ; Set up resource list
130.481 +; res8@gsnDebug = True ; Useful to print NDC row,col values used.
130.482 + res8@txFontHeightF = 0.02
130.483 + res8@gsFillColor = color_fill8
130.484 +
130.485 + delete (color_fill8)
130.486 +
130.487 +; table value for station table
130.488 + text8(:,0) = sprintf("%5.2f", (/lat(ind_z)/))
130.489 + text8(:,1) = sprintf("%5.2f", (/lon(ind_z)/))
130.490 + text8(:,2) = sprintf("%5.2f", (/amp_ratio_sta/))
130.491 + text8(:,3) = sprintf("%5.2f", (/ccr_sta/))
130.492 + text8(:,4) = sprintf("%5.2f", (/M_sta/))
130.493 + text8(:,5) = sprintf("%5.2f", (/score_sta/))
130.494 +
130.495 + plot_name = "table_sta." + zone
130.496 +
130.497 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
130.498 +
130.499 + gsn_table(wks,ncr5,x5,y5,text5,res5)
130.500 + gsn_table(wks,ncr6,x6,y6,text6,res6)
130.501 + gsn_table(wks,ncr7,x7,y7,text7,res7)
130.502 + gsn_table(wks,ncr8,x8,y8,text8,res8)
130.503 +
130.504 + frame(wks)
130.505 +
130.506 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
130.507 + system("rm "+plot_name+"."+plot_type)
130.508 +
130.509 + delete (ind_z)
130.510 + delete (amp_model)
130.511 + delete (amp_ob)
130.512 + delete (amp_ratio_sta)
130.513 + delete (ccr_sta)
130.514 + delete (M_sta)
130.515 + delete (score_sta)
130.516 + delete (text7)
130.517 + delete (text8)
130.518 + delete (res7)
130.519 + delete (res8)
130.520 + clear (wks)
130.521 + end do
130.522 +;**************************************************
130.523 +; plot zone table
130.524 +;**************************************************
130.525 +
130.526 + text4(4,0) = sum(stringtofloat(text4(0:3,0)))
130.527 + text4(4,1) = 0.
130.528 + text4(4,2) = 0.
130.529 + text4(4,3) = 0.
130.530 + text4(4,4) = sum(stringtofloat(text4(0:3,4)))
130.531 +
130.532 + plot_name = "table_zone"
130.533 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
130.534 +
130.535 + gsn_table(wks,ncr1,x1,y1,text1,res1)
130.536 + gsn_table(wks,ncr2,x2,y2,text2,res2)
130.537 + gsn_table(wks,ncr3,x3,y3,text3,res3)
130.538 + gsn_table(wks,ncr4,x4,y4,text4,res4)
130.539 +
130.540 + frame(wks)
130.541 +
130.542 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
130.543 + system("rm "+plot_name+"."+plot_type)
130.544 +
130.545 + M_co2 = text4(4,4)
130.546 +
130.547 + if (isvar("compare")) then
130.548 + system("sed 1,/M_co2/s//"+M_co2+"/ "+html_name2+" > "+html_new2+";"+ \
130.549 + "mv -f "+html_new2+" "+html_name2)
130.550 + end if
130.551 +
130.552 + system("sed s#M_co2#"+M_co2+"# "+html_name+" > "+html_new+";"+ \
130.553 + "mv -f "+html_new+" "+html_name)
130.554 +;***************************************************************************
130.555 +; output plots
130.556 +;***************************************************************************
130.557 + output_dir = model_name+"/co2"
130.558 +
130.559 + system("mv *.png " + output_dir)
130.560 +;***************************************************************************
130.561 +end
131.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
131.2 +++ b/co2/99.all.ncl.2 Mon Jan 26 22:08:20 2009 -0500
131.3 @@ -0,0 +1,521 @@
131.4 +; ***********************************************
131.5 +; using gsn_table for all
131.6 +; combine 19.metric_plot.ncl and 24.lines.ncl
131.7 +; ***********************************************
131.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
131.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
131.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
131.11 +;load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
131.12 +;************************************************
131.13 +procedure set_line(lines:string,nline:integer,newlines:string)
131.14 +begin
131.15 +; add line to ascci/html file
131.16 +
131.17 + nnewlines = dimsizes(newlines)
131.18 + if(nline+nnewlines-1.ge.dimsizes(lines))
131.19 + print("set_line: bad index, not setting anything.")
131.20 + return
131.21 + end if
131.22 + lines(nline:nline+nnewlines-1) = newlines
131.23 +; print ("lines = " + lines(nline:nline+nnewlines-1))
131.24 + nline = nline + nnewlines
131.25 + return
131.26 +end
131.27 +;****************************************************************************
131.28 +
131.29 +begin
131.30 +
131.31 + plot_type = "ps"
131.32 + plot_type_new = "png"
131.33 +
131.34 +;************************************************
131.35 +; read model data
131.36 +;************************************************
131.37 +
131.38 +; from command line inputs
131.39 +
131.40 +;--------------------------------------------------
131.41 +; edit table.html of current model for movel1_vs_model2
131.42 +
131.43 + if (isvar("compare")) then
131.44 + html_name2 = compare+"/table.html"
131.45 + html_new2 = html_name2 +".new"
131.46 +
131.47 +; the following only needs to execute once
131.48 +; system("sed 1,/model_nameA/s//"+model_name+"/ "+html_name2+" > "+html_new2+";"+ \
131.49 +; "mv -f "+html_new2+" "+html_name2+";"+ \
131.50 +; "sed 1,/model_nameB/s//"+model_name+"/ "+html_name2+" > "+html_new2+";"+ \
131.51 +; "mv -f "+html_new2+" "+html_name2+";"+ \
131.52 +; "sed s#"+modeln+"#"+model_name+"# "+html_name2+" > "+html_new2+";"+ \
131.53 +; "mv -f "+html_new2+" "+html_name2)
131.54 + end if
131.55 +
131.56 +;-------------------------------------
131.57 +; edit table.html for current model
131.58 +
131.59 + html_name = model_name+"/table.html"
131.60 + html_new = html_name +".new"
131.61 +
131.62 +; the following only needs to execute once
131.63 +; system("sed s#model_name#"+model_name+"# "+html_name+" > "+html_new+";"+ \
131.64 +; "mv -f "+html_new+" "+html_name)
131.65 +;------------------------------------------------
131.66 + fm = addfile(dirm+film3,"r")
131.67 +
131.68 + x = fm->CO2
131.69 + xi = fm->lon
131.70 + yi = fm->lat
131.71 +
131.72 + xdim = dimsizes(x)
131.73 + nlev = xdim(1)
131.74 + y = x(:,0,:,:)
131.75 +
131.76 +; get co2 at the lowest level
131.77 + y = x(:,nlev-1,:,:)
131.78 +
131.79 +; change to unit of observed (u mol/mol)
131.80 +; Model_units [=] kgCO2 / kgDryAir
131.81 +; 28.966 = molecular weight of dry air
131.82 +; 44. = molecular weight of CO2
131.83 +; u mol = 1e-6 mol
131.84 +
131.85 + factor = (28.966/44.) * 1e6
131.86 + y = y * factor
131.87 +
131.88 + y@_FillValue = 1.e36
131.89 + y@units = "u mol/mol"
131.90 +;************************************************
131.91 +; read data: observed
131.92 +;************************************************
131.93 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/co2/ob/"
131.94 + fili = "co2_globalView_98.nc"
131.95 + g = addfile (diri+fili,"r")
131.96 + val = g->CO2_SEAS
131.97 + lon = g->LON
131.98 + lat = g->LAT
131.99 + sta = chartostring(g->STATION)
131.100 + delete (g)
131.101 +
131.102 + ncase = dimsizes(lat)
131.103 +;**************************************************************
131.104 +; get only the lowest level at each station
131.105 +;**************************************************************
131.106 + lat_tmp = lat
131.107 + lat_tmp@_FillValue = 1.e+36
131.108 +
131.109 + do n = 0,ncase-1
131.110 + if (.not. ismissing(lat_tmp(n))) then
131.111 + indexes = ind(lat(n) .eq. lat .and. lon(n) .eq. lon)
131.112 + if (dimsizes(indexes) .gt. 1) then
131.113 + lat_tmp(indexes(1:)) = lat_tmp@_FillValue
131.114 + end if
131.115 + delete (indexes)
131.116 + end if
131.117 + end do
131.118 +
131.119 + indexes = ind(.not. ismissing(lat_tmp))
131.120 +
131.121 + lat_ob = lat(indexes)
131.122 + lon_ob = lon(indexes)
131.123 + val_ob = val(indexes,:)
131.124 +;************************************************************
131.125 +; interpolate model data into observed station
131.126 +; note: model is 0-360E, 90S-90N
131.127 +;************************************************************
131.128 +; to be able to handle observation at (-89.98,-24.80)
131.129 + yi(0) = -90.
131.130 +
131.131 + i = ind(lon_ob .lt. 0.)
131.132 + lon_ob(i) = lon_ob(i) + 360.
131.133 +
131.134 + yo = linint2_points_Wrap(xi,yi,y,True,lon_ob,lat_ob,0)
131.135 +
131.136 + val_model = yo(pts|:,time|:)
131.137 + val_model_0 = val_model
131.138 +;************************************************************
131.139 +; remove annual mean
131.140 +;************************************************************
131.141 + val_model = val_model - conform(val_model,dim_avg(val_model),0)
131.142 +
131.143 +;*******************************************************************
131.144 +; res for station line plot
131.145 +;*******************************************************************
131.146 +; for x-axis in xyplot
131.147 + mon = ispan(1,12,1)
131.148 + mon@long_name = "month"
131.149 +
131.150 + res = True ; plot mods desired
131.151 + res@xyLineThicknesses = (/2.0,2.0,2.0/) ; make 2nd lines thicker
131.152 + res@xyLineColors = (/"red","black"/) ; change line color
131.153 +
131.154 +; Add a boxed legend using the more simple method
131.155 + res@pmLegendDisplayMode = "Always"
131.156 +; res@pmLegendWidthF = 0.1
131.157 + res@pmLegendWidthF = 0.08
131.158 + res@pmLegendHeightF = 0.06
131.159 +; res@pmLegendOrthogonalPosF = -1.17
131.160 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
131.161 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
131.162 +
131.163 +; res@pmLegendParallelPosF = 0.18
131.164 + res@pmLegendParallelPosF = 0.23 ;(rightward)
131.165 +
131.166 +; res@lgPerimOn = False
131.167 + res@lgLabelFontHeightF = 0.015
131.168 + res@xyExplicitLegendLabels = (/model_name,"observed"/)
131.169 +;************************************************************
131.170 +; number of latitude zone
131.171 +;************************************************************
131.172 + nzone = 4
131.173 +
131.174 +; number of rows for zone table
131.175 + nrow_zone = nzone + 1
131.176 +
131.177 +; number of columns for zone table
131.178 + ncol_zone = 6
131.179 +
131.180 +; saving data for zone
131.181 + text4 = new((/nrow_zone,ncol_zone/),string)
131.182 +
131.183 +do z = 0,nzone-1
131.184 +
131.185 + if (z .eq. 0) then
131.186 + zone = "60N-90N"
131.187 + score_max = 5.0
131.188 + ind_z = ind(lat_ob .ge. 60.)
131.189 + end if
131.190 +
131.191 + if (z .eq. 1) then
131.192 + zone = "30N-60N"
131.193 + score_max = 5.0
131.194 + ind_z = ind(lat_ob .ge. 30. .and. lat_ob .lt. 60.)
131.195 + end if
131.196 +
131.197 + if (z .eq. 2) then
131.198 + zone = "EQ-30N"
131.199 + score_max = 5.0
131.200 + ind_z = ind(lat_ob .ge. 0. .and. lat_ob .lt. 30.)
131.201 + end if
131.202 +
131.203 + if (z .eq. 3) then
131.204 + zone = "90S-EQ"
131.205 + score_max = 5.0
131.206 + ind_z = ind(lat_ob .lt. 0. )
131.207 + end if
131.208 +
131.209 + npts = dimsizes(ind_z)
131.210 +
131.211 +;------------------------------------------------------
131.212 +; for metric table computation
131.213 + amp_ob = new((/npts/),float)
131.214 + amp_model = new((/npts/),float)
131.215 +
131.216 + amp_ratio_sta = new((/npts/),float)
131.217 + ccr_sta = new((/npts/),float)
131.218 + M_sta = new((/npts/),float)
131.219 + score_sta = new((/npts/),float)
131.220 +;-----------------------------------------------------
131.221 +; for station line plot
131.222 + npts_str = ""
131.223 + npts_str = npts
131.224 +
131.225 + plot_data = new((/2,12,npts/),float)
131.226 + plot_data_0 = new((/12,npts/),float)
131.227 +
131.228 + plot_data!0 = "case"
131.229 + plot_data!1 = "month"
131.230 + plot_data!2 = "pts"
131.231 + plot_data@long_name = "CO2 Seasonal"
131.232 +
131.233 + plot_data_0!0 = "month"
131.234 + plot_data_0!1 = "pts"
131.235 + plot_data_0@long_name = "CO2"
131.236 +;--------------------------------------------------------------------------
131.237 + do n=0,npts-1
131.238 +
131.239 + amp_ob(n) = max(val_ob(ind_z(n),:)) - min(val_ob(ind_z(n),:))
131.240 + amp_model(n) = max(val_model(ind_z(n),:)) - min(val_model(ind_z(n),:))
131.241 +
131.242 + amp_ratio_sta(n) = amp_model(n)/amp_ob(n)
131.243 + ccr_sta(n) = esccr(val_ob(ind_z(n),:),val_model(ind_z(n),:),0)
131.244 + M_sta(n) = 1.-abs(amp_ratio_sta(n)-1.)
131.245 + score_sta(n) = (ccr_sta(n)*ccr_sta(n) + M_sta(n))*0.5 * score_max
131.246 +
131.247 +;----------------------------------------------------------------------
131.248 +; for station line plot
131.249 +
131.250 + plot_data(0,:,n) = (/val_model(ind_z(n),:)/)
131.251 + plot_data(1,:,n) = (/val_ob(ind_z(n),:)/)
131.252 +
131.253 + plot_data_0(:,n) = (/val_model_0(ind_z(n),:)/)
131.254 +
131.255 + plot_name = sta(ind_z(n))
131.256 + title = plot_name+"("+lat(ind_z(n))+","+lon(ind_z(n))+")"
131.257 +
131.258 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
131.259 +;------------------------------------------
131.260 +; for panel plot
131.261 +
131.262 + plot=new(2,graphic) ; create graphic array
131.263 + res@gsnFrame = False ; Do not draw plot
131.264 + res@gsnDraw = False ; Do not advance frame
131.265 +
131.266 + pres = True ; panel plot mods desired
131.267 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
131.268 + ; indiv. plots in panel
131.269 + pres@gsnMaximize = True ; fill the page
131.270 +;------------------------------------------
131.271 + res@tiMainString = title ; add title
131.272 +
131.273 + plot(0)=gsn_csm_xy(wks,mon,plot_data(:,:,n),res) ; create plot 1
131.274 +
131.275 + plot(1)=gsn_csm_xy(wks,mon,plot_data_0(:,n),res) ; create plot 2
131.276 +
131.277 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
131.278 +
131.279 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
131.280 + system("rm "+plot_name+"."+plot_type)
131.281 +
131.282 + clear (wks)
131.283 +;---------------------------------------------------------------------------
131.284 + end do
131.285 +;-------------------------------------------------------------------------
131.286 +; for line plot in a zone
131.287 +
131.288 + plot_name = "All_"+npts_str
131.289 + title = plot_name + " in "+ zone
131.290 +
131.291 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
131.292 +;-----------------------------------------
131.293 +; for panel plot
131.294 +
131.295 + plot=new(2,graphic) ; create graphic array
131.296 + res@gsnFrame = False ; Do not draw plot
131.297 + res@gsnDraw = False ; Do not advance frame
131.298 +
131.299 + pres = True ; panel plot mods desired
131.300 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
131.301 + ; indiv. plots in panel
131.302 + pres@gsnMaximize = True ; fill the page
131.303 +;-----------------------------------------
131.304 + res@tiMainString = title ; add title
131.305 +
131.306 + plot(0) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data),res) ; create plot 1
131.307 +
131.308 + plot(1) = gsn_csm_xy (wks,mon,dim_avg_Wrap(plot_data_0),res) ; create plot 2
131.309 +
131.310 + gsn_panel(wks,plot,(/2,1/),pres) ; create panel plot
131.311 +
131.312 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
131.313 + system("rm "+plot_name+"."+plot_type)
131.314 +
131.315 + clear (wks)
131.316 +; delete (ind_z)
131.317 + delete (plot_data)
131.318 + delete (plot_data_0)
131.319 +;---------------------------------------------------------------------------
131.320 +; values saved for zone table
131.321 +
131.322 + amp_ratio_zone = avg(amp_ratio_sta)
131.323 + ccr_zone = avg(ccr_sta)
131.324 + M_zone = 1.- (sum(abs(amp_model-amp_ob)/(amp_model+amp_ob))/npts)
131.325 + score_zone = (ccr_zone*ccr_zone + M_zone)*0.5 * score_max
131.326 +
131.327 + text4(z,0) = zone
131.328 + text4(z,1) = sprintf("%.0f", npts)
131.329 + text4(z,2) = sprintf("%.2f", amp_ratio_zone)
131.330 + text4(z,3) = sprintf("%.2f", ccr_zone)
131.331 + text4(z,4) = sprintf("%.2f", M_zone)
131.332 + text4(z,5) = sprintf("%.2f", score_zone)
131.333 +
131.334 +;*******************************************************************
131.335 +; html table -- station
131.336 +;*******************************************************************
131.337 + output_html = "score+line_"+zone+".html"
131.338 +
131.339 + header = (/"<HTML>" \
131.340 + ,"<HEAD>" \
131.341 + ,"<TITLE>CLAMP metrics</TITLE>" \
131.342 + ,"</HEAD>" \
131.343 + ,"<H1>CO2 in Zone "+zone+": Model "+model_name+"</H1>" \
131.344 + /)
131.345 + footer = "</HTML>"
131.346 +
131.347 + table_header = (/ \
131.348 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
131.349 + ,"<tr>" \
131.350 + ," <th bgcolor=DDDDDD >Site Name</th>" \
131.351 + ," <th bgcolor=DDDDDD >Latitude</th>" \
131.352 + ," <th bgcolor=DDDDDD >Longitude</th>" \
131.353 + ," <th bgcolor=DDDDDD >Amplitude Ratio</th>" \
131.354 + ," <th bgcolor=DDDDDD >Correleration Coef</th>" \
131.355 + ," <th bgcolor=DDDDDD >M Score</th>" \
131.356 + ," <th bgcolor=DDDDDD >Combined Score</th>" \
131.357 + ,"</tr>" \
131.358 + /)
131.359 + table_footer = "</table>"
131.360 + row_header = "<tr>"
131.361 + row_footer = "</tr>"
131.362 +
131.363 + lines = new(50000,string)
131.364 + nline = 0
131.365 +
131.366 + set_line(lines,nline,header)
131.367 + set_line(lines,nline,table_header)
131.368 +;-----------------------------------------------
131.369 +; row of table
131.370 +
131.371 + do n = 0,npts-1
131.372 + set_line(lines,nline,row_header)
131.373 +
131.374 + txt0 = sta(ind_z(n))
131.375 + txt1 = sprintf("%5.2f", (/lat(ind_z(n))/))
131.376 + txt2 = sprintf("%5.2f", (/lon(ind_z(n))/))
131.377 + txt3 = sprintf("%5.2f", (/amp_ratio_sta(n)/))
131.378 + txt4 = sprintf("%5.2f", (/ccr_sta(n)/))
131.379 + txt5 = sprintf("%5.2f", (/M_sta(n)/))
131.380 + txt6 = sprintf("%5.2f", (/score_sta(n)/))
131.381 +
131.382 + set_line(lines,nline,"<th><a href="+txt0+".png>"+txt0+"</a></th>")
131.383 + set_line(lines,nline,"<th>"+txt1+"</th>")
131.384 + set_line(lines,nline,"<th>"+txt2+"</th>")
131.385 + set_line(lines,nline,"<th>"+txt3+"</th>")
131.386 + set_line(lines,nline,"<th>"+txt4+"</th>")
131.387 + set_line(lines,nline,"<th>"+txt5+"</th>")
131.388 + set_line(lines,nline,"<th>"+txt6+"</th>")
131.389 +
131.390 + set_line(lines,nline,row_footer)
131.391 + end do
131.392 +
131.393 +; last row, summary
131.394 + set_line(lines,nline,row_header)
131.395 +
131.396 + txt0 = "All_"+sprintf("%.0f", (/npts/))
131.397 + txt1 = "-"
131.398 + txt2 = "-"
131.399 + txt3 = sprintf("%5.2f", (/amp_ratio_zone/))
131.400 + txt4 = sprintf("%5.2f", (/ccr_zone/))
131.401 + txt5 = sprintf("%5.2f", (/M_zone/))
131.402 + txt6 = sprintf("%5.2f", (/score_zone/))
131.403 +
131.404 + set_line(lines,nline,"<th><a href="+txt0+".png>"+txt0+"</a></th>")
131.405 + set_line(lines,nline,"<th>"+txt1+"</th>")
131.406 + set_line(lines,nline,"<th>"+txt2+"</th>")
131.407 + set_line(lines,nline,"<th>"+txt3+"</th>")
131.408 + set_line(lines,nline,"<th>"+txt4+"</th>")
131.409 + set_line(lines,nline,"<th>"+txt5+"</th>")
131.410 + set_line(lines,nline,"<th>"+txt6+"</th>")
131.411 +
131.412 + set_line(lines,nline,row_footer)
131.413 +;-----------------------------------------------
131.414 + set_line(lines,nline,table_footer)
131.415 + set_line(lines,nline,footer)
131.416 +
131.417 +; Now write to an HTML file.
131.418 + idx = ind(.not.ismissing(lines))
131.419 + if(.not.any(ismissing(idx))) then
131.420 + asciiwrite(output_html,lines(idx))
131.421 + else
131.422 + print ("error?")
131.423 + end if
131.424 + delete (idx)
131.425 +;-----------------------------------------------------------------
131.426 +
131.427 + delete (ind_z)
131.428 + delete (amp_model)
131.429 + delete (amp_ob)
131.430 + delete (amp_ratio_sta)
131.431 + delete (ccr_sta)
131.432 + delete (M_sta)
131.433 + delete (score_sta)
131.434 + clear (wks)
131.435 +end do
131.436 +
131.437 +;*******************************************************************
131.438 +; html table -- zone
131.439 +;*******************************************************************
131.440 + output_html = "score_zone.html"
131.441 +
131.442 + header = (/"<HTML>" \
131.443 + ,"<HEAD>" \
131.444 + ,"<TITLE>CLAMP metrics</TITLE>" \
131.445 + ,"</HEAD>" \
131.446 + ,"<H1>CO2 in Latitude Zone: Model "+model_name+"</H1>" \
131.447 + /)
131.448 + footer = "</HTML>"
131.449 +
131.450 + delete (table_header)
131.451 + table_header = (/ \
131.452 + "<table border=1 cellspacing=0 cellpadding=3 width=80%>" \
131.453 + ,"<tr>" \
131.454 + ," <th bgcolor=DDDDDD >Zone</th>" \
131.455 + ," <th bgcolor=DDDDDD >Number of Site</th>" \
131.456 + ," <th bgcolor=DDDDDD >Amplitide Ratio</th>" \
131.457 + ," <th bgcolor=DDDDDD >Correleration Coef</th>" \
131.458 + ," <th bgcolor=DDDDDD >M Score</th>" \
131.459 + ," <th bgcolor=DDDDDD >Combined Score</th>" \
131.460 + ,"</tr>" \
131.461 + /)
131.462 + table_footer = "</table>"
131.463 + row_header = "<tr>"
131.464 + row_footer = "</tr>"
131.465 +
131.466 + lines = new(50000,string)
131.467 + nline = 0
131.468 +
131.469 + set_line(lines,nline,header)
131.470 + set_line(lines,nline,table_header)
131.471 +;-----------------------------------------------
131.472 +;row of table
131.473 +
131.474 +; sum for the last row
131.475 + text4(4,0) = "All"
131.476 + text4(4,1) = sum(stringtofloat(text4(0:3,1)))
131.477 + text4(4,2) = "-"
131.478 + text4(4,3) = "-"
131.479 + text4(4,4) = "-"
131.480 + text4(4,5) = sum(stringtofloat(text4(0:3,5)))
131.481 +
131.482 + do n = 0,nrow_zone-1
131.483 + set_line(lines,nline,row_header)
131.484 +
131.485 + set_line(lines,nline,"<th>"+text4(n,0)+"</th>")
131.486 + set_line(lines,nline,"<th>"+text4(n,1)+"</th>")
131.487 + set_line(lines,nline,"<th>"+text4(n,2)+"</th>")
131.488 + set_line(lines,nline,"<th>"+text4(n,3)+"</th>")
131.489 + set_line(lines,nline,"<th>"+text4(n,4)+"</th>")
131.490 + set_line(lines,nline,"<th>"+text4(n,5)+"</th>")
131.491 +
131.492 + set_line(lines,nline,row_footer)
131.493 + end do
131.494 +;-----------------------------------------------
131.495 + set_line(lines,nline,table_footer)
131.496 + set_line(lines,nline,footer)
131.497 +
131.498 +; Now write to an HTML file.
131.499 + idx = ind(.not.ismissing(lines))
131.500 + if(.not.any(ismissing(idx))) then
131.501 + asciiwrite(output_html,lines(idx))
131.502 + else
131.503 + print ("error?")
131.504 + end if
131.505 + delete (idx)
131.506 +;--------------------------------------------------------------------------
131.507 +
131.508 + M_co2 = text4(4,5)
131.509 +
131.510 + if (isvar("compare")) then
131.511 + system("sed 1,/M_co2/s//"+M_co2+"/ "+html_name2+" > "+html_new2+";"+ \
131.512 + "mv -f "+html_new2+" "+html_name2)
131.513 + end if
131.514 +
131.515 + system("sed s#M_co2#"+M_co2+"# "+html_name+" > "+html_new+";"+ \
131.516 + "mv -f "+html_new+" "+html_name)
131.517 +;***************************************************************************
131.518 +; output plots
131.519 +;***************************************************************************
131.520 + output_dir = model_name+"/co2"
131.521 +
131.522 + system("mv *.png *.html " + output_dir)
131.523 +;***************************************************************************
131.524 +end
132.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
132.2 +++ b/co2/metrics_table.ncl Mon Jan 26 22:08:20 2009 -0500
132.3 @@ -0,0 +1,93 @@
132.4 +;*************************************************
132.5 +; NCL Graphics: table_2.ncl
132.6 +;*************************************************
132.7 +
132.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
132.9 +
132.10 +begin
132.11 +; Header
132.12 + ncr1 = (/1,1/) ; 1 row, 1 column
132.13 + x1 = (/0.005,0.335/) ; Start and end X
132.14 + y1 = (/0.900,0.995/) ; Start and end Y
132.15 + text1 = "CAM METRICS"
132.16 +
132.17 +; Sub header
132.18 + ncr2 = (/2,2/) ; 2 rows, 2 columns
132.19 + x2 = (/0.335,0.995/) ; Start and end X
132.20 + y2 = (/0.900,0.995/) ; Start and end Y
132.21 + text2 = (/ (/"Case A","Case B"/),(/"ANN","ANN"/)/)
132.22 +
132.23 +; Main table body
132.24 + ncr3 = (/16,3/) ; 16 rows, 3 columns
132.25 + x3 = (/0.005,0.995/) ; Start and end X
132.26 + y3 = (/0.005,0.900/) ; Start and end Y
132.27 +
132.28 + text3 = (/ (/"SLP_ERA40", "1.230", "1.129"/), \
132.29 + (/"Tsfc_ERA40", "0.988", "0.996"/), \
132.30 + (/"Prc_GPCP", "1.092", "1.016"/), \
132.31 + (/"Prc 30S-30N_GPCP", "1.172", "1.134"/), \
132.32 + (/"LW_ERS", "1.064", "1.023"/), \
132.33 + (/"SW_ERS", "0.966", "0.962"/), \
132.34 + (/"U300_ERA40", "1.079", "1.048"/), \
132.35 + (/"Guess_BOGUS", "0.781", "0.852"/), \
132.36 + (/"RH_NCEP", "1.122", "0.911"/), \
132.37 + (/"LHFLX_ERA40", "1.000", "0.835"/), \
132.38 + (/"TWP_ERA40", "0.998", "0.712"/), \
132.39 + (/"CLDTOT_NCEP", "1.321", "1.122"/), \
132.40 + (/"O3_NASA", "0.842", "0.956"/), \
132.41 + (/"Q_JMA", "0.978", "0.832"/), \
132.42 + (/"PBLH_JMA", "0.998", "0.900"/), \
132.43 + (/"Omega_CAS", "0.811", "1.311"/)/)
132.44 +
132.45 +
132.46 + wks = gsn_open_wks("ps","table")
132.47 +
132.48 +;
132.49 +; Main header.
132.50 +;
132.51 + res1 = True
132.52 + res1@txFontHeightF = 0.03
132.53 + res1@gsFillColor = "CornFlowerBlue"
132.54 +
132.55 + gsn_table(wks,ncr1,x1,y1,text1,res1)
132.56 +
132.57 +;
132.58 +; Sub header
132.59 +;
132.60 + res2 = True
132.61 + res2@txFontHeightF = 0.02
132.62 + res2@gsFillColor = "Gray"
132.63 +
132.64 + gsn_table(wks,ncr2,x2,y2,text2,res2)
132.65 +
132.66 +;
132.67 +; Main body of table.
132.68 +;
132.69 + res3 = True ; Set up resource list
132.70 +
132.71 +; res3@gsnDebug = True ; Useful to print NDC row,col values used.
132.72 +
132.73 + res3@txFontHeightF = 0.02
132.74 +
132.75 + res3@gsFillColor = (/ (/"gray","transparent","palegreen"/), \
132.76 + (/"gray","transparent","hotpink"/), \
132.77 + (/"gray","transparent","palegreen"/), \
132.78 + (/"gray","transparent","palegreen"/), \
132.79 + (/"gray","transparent","palegreen"/), \
132.80 + (/"gray","transparent","palegreen"/), \
132.81 + (/"gray","transparent","palegreen"/), \
132.82 + (/"gray","transparent","hotpink"/), \
132.83 + (/"gray","transparent","palegreen"/), \
132.84 + (/"gray","transparent","palegreen"/), \
132.85 + (/"gray","transparent","palegreen"/), \
132.86 + (/"gray","transparent","palegreen"/), \
132.87 + (/"gray","transparent","hotpink"/), \
132.88 + (/"gray","transparent","palegreen"/), \
132.89 + (/"gray","transparent","palegreen"/), \
132.90 + (/"gray","transparent","hotpink"/)/)
132.91 +
132.92 + gsn_table(wks,ncr3,x3,y3,text3,res3)
132.93 +
132.94 + frame(wks) ; Advance the frame.
132.95 +
132.96 +end
132.97 \ No newline at end of file
133.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
133.2 +++ b/co2/metrics_table.ncl.0 Mon Jan 26 22:08:20 2009 -0500
133.3 @@ -0,0 +1,209 @@
133.4 +;*******************************************************************
133.5 +; procedure to draw the Taylor Diagram Metrics Table
133.6 +;
133.7 +; AWWG METRICS 0.3 ;;;
133.8 +; 27 Jun 06 ASP
133.9 +; 5 Jul 06 DJS
133.10 +;
133.11 +; Arguments:
133.12 +; mfname : name of the output table
133.13 +; varNames : variable names [metrics]
133.14 +; cases : case (model) names
133.15 +; seasons : season names
133.16 +; values : array containing the values to be plotted
133.17 +; opt : used to pass optional arguments
133.18 +
133.19 +procedure metrics_table(mfname[1]:string \ ; plot name
133.20 + ,varNames[*]:string \ ; variables
133.21 + ,cases[*]:string \
133.22 + ,values[*][*]:numeric \
133.23 + ,opt:logical )
133.24 +
133.25 +
133.26 +;;;
133.27 +;;; Output of metrics to a table [grid]
133.28 +
133.29 +begin
133.30 + if (.not.isatt(opt,"pltType") .or. \
133.31 + (opt@pltType.eq."eps" .or. opt@pltType.eq."png" .or. opt@pltType.eq."gif")) then
133.32 + wks = gsn_open_wks("eps",mfname) ; default
133.33 + else
133.34 + wks = gsn_open_wks(opt@pltType,mfname)
133.35 + end if
133.36 +
133.37 + xbox0 = (/0.0,1.0,1.0,0.0,0.0/) ; Box template.
133.38 + ybox0 = (/0.0,0.0,1.0,1.0,0.0/)
133.39 +
133.40 + nvar = dimsizes(varNames)
133.41 + ncases = dimsizes(cases)
133.42 +
133.43 + dimt = dimsizes(values) ; table dimensions
133.44 +
133.45 + if (ncases.ne.dimt(0)) then
133.46 + print("metrics_table fatal error: Number of case names ("+ncases+ \
133.47 + ") does not match the number of cases passed in ("+dimt(0)+")")
133.48 + exit
133.49 + end if
133.50 +
133.51 + if (dimsizes(varNames).ne.dimt(1)) then
133.52 + print("metrics_table fatal error: Number of metric variables names ("+dimsizes(varNames)+ \
133.53 + ") does not match the number of metric variables passed in ("+dimt(1)+")")
133.54 + exit
133.55 + end if
133.56 +
133.57 + ncolm1 = dimt(0)
133.58 + if (ncolm1.le.12) then
133.59 + if (ncolm1.le.6) then
133.60 +; tt_width = .4
133.61 + tt_width = .2
133.62 + end if
133.63 + if (ncolm1.ge.7.and.ncolm1.le.12) then
133.64 + tt_width = .2
133.65 + end if
133.66 + tt_height = 0.1
133.67 + tt_theight = 0.02
133.68 + mn_height = 0.03
133.69 + mn_theight = 0.012
133.70 + else
133.71 + if (ncolm1.le.20) then
133.72 + tt_width = .15
133.73 + tt_height = 0.06
133.74 + tt_theight = 0.012
133.75 + mn_height = 0.018
133.76 + mn_theight = 0.0072
133.77 + else
133.78 + tt_width = .1
133.79 + tt_height = 0.05
133.80 + tt_theight = 0.01
133.81 + mn_height = 0.015
133.82 + mn_theight = 0.006
133.83 + end if
133.84 + end if
133.85 + if (ncolm1.gt.26.or.dimt(1).gt.63) then
133.86 + print("Warning: Recommended maximium size of array passed into metrics_table is "+ \
133.87 + "26 columns (#cases * #seasons) by 63 rows (#variables), continuing")
133.88 + end if
133.89 +
133.90 + mn_width = tt_width
133.91 + mv_height = mn_height
133.92 + mv_width = 0.1
133.93 + mv_theight = mn_theight
133.94 +
133.95 + tt_pRes = True
133.96 + tt_pRes@gsFillColor = "CornflowerBlue" ; background color for + values
133.97 +
133.98 + tt_tRes = True
133.99 + tt_tRes@txFontHeightF = tt_theight
133.100 +
133.101 + mn_pRes = True
133.102 + mn_pRes@gsFillColor = "Gray70" ; background color for variable names
133.103 +
133.104 + mn_tRes = True
133.105 + mn_tRes@txFontHeightF = mn_theight
133.106 +
133.107 + mv_pRes = True
133.108 + mv_pRes@gsFillColor = "White" ; background color for reference values
133.109 +
133.110 + mv_tRes = True
133.111 + mv_tRes@txFontHeightF = mn_theight
133.112 +
133.113 +; Title
133.114 +
133.115 + xbox = tt_width*xbox0
133.116 + ybox = 1.-tt_height*ybox0
133.117 +
133.118 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
133.119 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
133.120 +
133.121 + gsn_polygon_ndc(wks,xbox,ybox,tt_pRes)
133.122 + if (isatt(opt,"tableTitle") ) then
133.123 + gsn_text_ndc(wks, opt@tableTitle ,ixtbox,iytbox, tt_tRes)
133.124 + else
133.125 + gsn_text_ndc(wks,"METRICS",ixtbox,iytbox, tt_tRes)
133.126 + end if
133.127 + gsn_polyline_ndc(wks,xbox,ybox,False)
133.128 +
133.129 + do im = 0,nvar-1
133.130 + ybox = min(ybox)-(ybox0*mn_height)
133.131 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
133.132 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
133.133 +
133.134 + gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
133.135 + gsn_polyline_ndc(wks,xbox,ybox,False)
133.136 + gsn_text_ndc(wks,varNames(im),ixtbox,iytbox, mn_tRes)
133.137 + end do
133.138 +
133.139 + do icase = 0, ncases-1
133.140 +; ybox = 1.-0.5*tt_height*ybox0
133.141 + ybox = 1.-tt_height*ybox0
133.142 + xbox = ((1.-tt_width)/ncases)*(xbox0+icase)+tt_width
133.143 + xboxi = min(xbox)
133.144 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
133.145 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
133.146 + gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
133.147 + gsn_polyline_ndc(wks,xbox,ybox,False)
133.148 + gsn_text_ndc(wks,cases(icase),ixtbox,iytbox, mn_tRes)
133.149 +
133.150 +; do iseas = 0, nseas-1
133.151 +; ybox = 1.-0.5*tt_height-0.5*tt_height*ybox0
133.152 +; xbox = xboxi + ((1.-tt_width)/(ncases*nseas))*(xbox0+iseas)
133.153 +; ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
133.154 +; iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
133.155 +; gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
133.156 +; gsn_polyline_ndc(wks,xbox,ybox,False)
133.157 +; gsn_text_ndc(wks,seasons(iseas),ixtbox,iytbox, mn_tRes)
133.158 +
133.159 + if (icase .eq. ncases-1) then
133.160 + mv_pRes@gsFillColor = "Green"
133.161 + else
133.162 + mv_pRes@gsFillColor = "White"
133.163 + end if
133.164 +
133.165 + do im=0,nvar-1
133.166 + if (im .eq. 0) then
133.167 + ybox = 1.-tt_height-mv_height*ybox0
133.168 + else
133.169 + ybox = ybox - mv_height
133.170 + end if
133.171 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0)) ; add
133.172 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
133.173 +
133.174 +; if (icase .gt. 0) then
133.175 +; if (ismissing(values(icase,im)) .or. \ ; ???
133.176 +; ismissing(values(icase,im)))then
133.177 +; ; print ("Missing values skipped")
133.178 +; else
133.179 +; if (values(icase,im).le.values(0,im)) then
133.180 +; if (isatt(opt,"color0")) then
133.181 +; mv_pRes@gsFillColor = opt@color0
133.182 +; else
133.183 +; mv_pRes@gsFillColor = "DarkOliveGreen3"
133.184 +; end if
133.185 +; else
133.186 +; if (isatt(opt,"color1")) then
133.187 +; mv_pRes@gsFillColor = opt@color1
133.188 +; else
133.189 +; mv_pRes@gsFillColor = "IndianRed1"
133.190 +; end if
133.191 +; end if
133.192 +; end if
133.193 +; end if
133.194 + gsn_polygon_ndc(wks,xbox,ybox,mv_pRes)
133.195 + gsn_polyline_ndc(wks,xbox,ybox,False)
133.196 + gsn_text_ndc(wks,sprintf("%4.2f",values(icase,im)),ixtbox,iytbox, mv_tRes)
133.197 + end do
133.198 +; end do
133.199 + end do
133.200 +
133.201 + draw(wks)
133.202 + ;; activate the ;; lines if this is made a function
133.203 + ;;if (.not.isatt(opt,"gsnFrame") .or. opt@gsnFrame) then
133.204 + frame(wks)
133.205 + ; if png or gif then use convert
133.206 + if (isatt(opt,"pltType") .and. \
133.207 + (opt@pltType.eq."png" .or. opt@pltType.eq."gif")) then
133.208 + system("convert -trim +repage "+mfname+".eps "+mfname+"."+opt@pltType)
133.209 + end if
133.210 + ;;end if
133.211 +
133.212 +end
134.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
134.2 +++ b/co2/metrics_table.ncl.1 Mon Jan 26 22:08:20 2009 -0500
134.3 @@ -0,0 +1,209 @@
134.4 +;*******************************************************************
134.5 +; procedure to draw the Taylor Diagram Metrics Table
134.6 +;
134.7 +; AWWG METRICS 0.3 ;;;
134.8 +; 27 Jun 06 ASP
134.9 +; 5 Jul 06 DJS
134.10 +;
134.11 +; Arguments:
134.12 +; mfname : name of the output table
134.13 +; varNames : variable names [metrics]
134.14 +; cases : case (model) names
134.15 +; seasons : season names
134.16 +; values : array containing the values to be plotted
134.17 +; opt : used to pass optional arguments
134.18 +
134.19 +procedure metrics_table(mfname[1]:string \ ; plot name
134.20 + ,varNames[*]:string \ ; variables
134.21 + ,cases[*]:string \
134.22 + ,values[*][*]:numeric \
134.23 + ,opt:logical )
134.24 +
134.25 +
134.26 +;;;
134.27 +;;; Output of metrics to a table [grid]
134.28 +
134.29 +begin
134.30 + if (.not.isatt(opt,"pltType") .or. \
134.31 + (opt@pltType.eq."eps" .or. opt@pltType.eq."png" .or. opt@pltType.eq."gif")) then
134.32 + wks = gsn_open_wks("eps",mfname) ; default
134.33 + else
134.34 + wks = gsn_open_wks(opt@pltType,mfname)
134.35 + end if
134.36 +
134.37 + xbox0 = (/0.0,1.0,1.0,0.0,0.0/) ; Box template.
134.38 + ybox0 = (/0.0,0.0,1.0,1.0,0.0/)
134.39 +
134.40 + nvar = dimsizes(varNames)
134.41 + ncases = dimsizes(cases)
134.42 +
134.43 + dimt = dimsizes(values) ; table dimensions
134.44 +
134.45 + if (ncases.ne.dimt(0)) then
134.46 + print("metrics_table fatal error: Number of case names ("+ncases+ \
134.47 + ") does not match the number of cases passed in ("+dimt(0)+")")
134.48 + exit
134.49 + end if
134.50 +
134.51 + if (dimsizes(varNames).ne.dimt(1)) then
134.52 + print("metrics_table fatal error: Number of metric variables names ("+dimsizes(varNames)+ \
134.53 + ") does not match the number of metric variables passed in ("+dimt(1)+")")
134.54 + exit
134.55 + end if
134.56 +
134.57 + ncolm1 = dimt(0)
134.58 + if (ncolm1.le.12) then
134.59 + if (ncolm1.le.6) then
134.60 +; tt_width = .4
134.61 + tt_width = .2
134.62 + end if
134.63 + if (ncolm1.ge.7.and.ncolm1.le.12) then
134.64 + tt_width = .2
134.65 + end if
134.66 + tt_height = 0.1
134.67 + tt_theight = 0.02
134.68 + mn_height = 0.03
134.69 + mn_theight = 0.012
134.70 + else
134.71 + if (ncolm1.le.20) then
134.72 + tt_width = .15
134.73 + tt_height = 0.06
134.74 + tt_theight = 0.012
134.75 + mn_height = 0.018
134.76 + mn_theight = 0.0072
134.77 + else
134.78 + tt_width = .1
134.79 + tt_height = 0.05
134.80 + tt_theight = 0.01
134.81 + mn_height = 0.015
134.82 + mn_theight = 0.006
134.83 + end if
134.84 + end if
134.85 + if (ncolm1.gt.26.or.dimt(1).gt.63) then
134.86 + print("Warning: Recommended maximium size of array passed into metrics_table is "+ \
134.87 + "26 columns (#cases * #seasons) by 63 rows (#variables), continuing")
134.88 + end if
134.89 +
134.90 + mn_width = tt_width
134.91 + mv_height = mn_height
134.92 + mv_width = 0.1
134.93 + mv_theight = mn_theight
134.94 +
134.95 + tt_pRes = True
134.96 + tt_pRes@gsFillColor = "CornflowerBlue" ; background color for + values
134.97 +
134.98 + tt_tRes = True
134.99 + tt_tRes@txFontHeightF = tt_theight
134.100 +
134.101 + mn_pRes = True
134.102 + mn_pRes@gsFillColor = "Gray70" ; background color for variable names
134.103 +
134.104 + mn_tRes = True
134.105 + mn_tRes@txFontHeightF = mn_theight
134.106 +
134.107 + mv_pRes = True
134.108 + mv_pRes@gsFillColor = "White" ; background color for reference values
134.109 +
134.110 + mv_tRes = True
134.111 + mv_tRes@txFontHeightF = mn_theight
134.112 +
134.113 +; Title
134.114 +
134.115 + xbox = tt_width*xbox0
134.116 + ybox = 1.-tt_height*ybox0
134.117 +
134.118 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
134.119 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
134.120 +
134.121 + gsn_polygon_ndc(wks,xbox,ybox,tt_pRes)
134.122 + if (isatt(opt,"tableTitle") ) then
134.123 + gsn_text_ndc(wks, opt@tableTitle ,ixtbox,iytbox, tt_tRes)
134.124 + else
134.125 + gsn_text_ndc(wks,"METRICS",ixtbox,iytbox, tt_tRes)
134.126 + end if
134.127 + gsn_polyline_ndc(wks,xbox,ybox,False)
134.128 +
134.129 + do im = 0,nvar-1
134.130 + ybox = min(ybox)-(ybox0*mn_height)
134.131 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
134.132 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
134.133 +
134.134 + gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
134.135 + gsn_polyline_ndc(wks,xbox,ybox,False)
134.136 + gsn_text_ndc(wks,varNames(im),ixtbox,iytbox, mn_tRes)
134.137 + end do
134.138 +
134.139 + do icase = 0, ncases-1
134.140 +; ybox = 1.-0.5*tt_height*ybox0
134.141 + ybox = 1.-tt_height*ybox0
134.142 + xbox = ((1.-tt_width)/ncases)*(xbox0+icase)+tt_width
134.143 + xboxi = min(xbox)
134.144 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
134.145 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
134.146 + gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
134.147 + gsn_polyline_ndc(wks,xbox,ybox,False)
134.148 + gsn_text_ndc(wks,cases(icase),ixtbox,iytbox, mn_tRes)
134.149 +
134.150 +; do iseas = 0, nseas-1
134.151 +; ybox = 1.-0.5*tt_height-0.5*tt_height*ybox0
134.152 +; xbox = xboxi + ((1.-tt_width)/(ncases*nseas))*(xbox0+iseas)
134.153 +; ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
134.154 +; iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
134.155 +; gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
134.156 +; gsn_polyline_ndc(wks,xbox,ybox,False)
134.157 +; gsn_text_ndc(wks,seasons(iseas),ixtbox,iytbox, mn_tRes)
134.158 +
134.159 + if (icase .eq. ncases-1) then
134.160 + mv_pRes@gsFillColor = "Green"
134.161 + else
134.162 + mv_pRes@gsFillColor = "White"
134.163 + end if
134.164 +
134.165 + do im=0,nvar-1
134.166 + if (im .eq. 0) then
134.167 + ybox = 1.-tt_height-mv_height*ybox0
134.168 + else
134.169 + ybox = ybox - mv_height
134.170 + end if
134.171 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0)) ; add
134.172 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
134.173 +
134.174 +; if (icase .gt. 0) then
134.175 +; if (ismissing(values(icase,im)) .or. \ ; ???
134.176 +; ismissing(values(icase,im)))then
134.177 +; ; print ("Missing values skipped")
134.178 +; else
134.179 +; if (values(icase,im).le.values(0,im)) then
134.180 +; if (isatt(opt,"color0")) then
134.181 +; mv_pRes@gsFillColor = opt@color0
134.182 +; else
134.183 +; mv_pRes@gsFillColor = "DarkOliveGreen3"
134.184 +; end if
134.185 +; else
134.186 +; if (isatt(opt,"color1")) then
134.187 +; mv_pRes@gsFillColor = opt@color1
134.188 +; else
134.189 +; mv_pRes@gsFillColor = "IndianRed1"
134.190 +; end if
134.191 +; end if
134.192 +; end if
134.193 +; end if
134.194 + gsn_polygon_ndc(wks,xbox,ybox,mv_pRes)
134.195 + gsn_polyline_ndc(wks,xbox,ybox,False)
134.196 + gsn_text_ndc(wks,sprintf("%4.2f",values(icase,im)),ixtbox,iytbox, mv_tRes)
134.197 + end do
134.198 +; end do
134.199 + end do
134.200 +
134.201 + draw(wks)
134.202 + ;; activate the ;; lines if this is made a function
134.203 + ;;if (.not.isatt(opt,"gsnFrame") .or. opt@gsnFrame) then
134.204 + frame(wks)
134.205 + ; if png or gif then use convert
134.206 + if (isatt(opt,"pltType") .and. \
134.207 + (opt@pltType.eq."png" .or. opt@pltType.eq."gif")) then
134.208 + system("convert -trim +repage "+mfname+".eps "+mfname+"."+opt@pltType)
134.209 + end if
134.210 + ;;end if
134.211 +
134.212 +end
135.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
135.2 +++ b/co2/metrics_table.ncl.example Mon Jan 26 22:08:20 2009 -0500
135.3 @@ -0,0 +1,93 @@
135.4 +;*************************************************
135.5 +; NCL Graphics: table_2.ncl
135.6 +;*************************************************
135.7 +
135.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
135.9 +
135.10 +begin
135.11 +; Header
135.12 + ncr1 = (/1,1/) ; 1 row, 1 column
135.13 + x1 = (/0.005,0.335/) ; Start and end X
135.14 + y1 = (/0.900,0.995/) ; Start and end Y
135.15 + text1 = "CAM METRICS"
135.16 +
135.17 +; Sub header
135.18 + ncr2 = (/2,2/) ; 2 rows, 2 columns
135.19 + x2 = (/0.335,0.995/) ; Start and end X
135.20 + y2 = (/0.900,0.995/) ; Start and end Y
135.21 + text2 = (/ (/"Case A","Case B"/),(/"ANN","ANN"/)/)
135.22 +
135.23 +; Main table body
135.24 + ncr3 = (/16,3/) ; 16 rows, 3 columns
135.25 + x3 = (/0.005,0.995/) ; Start and end X
135.26 + y3 = (/0.005,0.900/) ; Start and end Y
135.27 +
135.28 + text3 = (/ (/"SLP_ERA40", "1.230", "1.129"/), \
135.29 + (/"Tsfc_ERA40", "0.988", "0.996"/), \
135.30 + (/"Prc_GPCP", "1.092", "1.016"/), \
135.31 + (/"Prc 30S-30N_GPCP", "1.172", "1.134"/), \
135.32 + (/"LW_ERS", "1.064", "1.023"/), \
135.33 + (/"SW_ERS", "0.966", "0.962"/), \
135.34 + (/"U300_ERA40", "1.079", "1.048"/), \
135.35 + (/"Guess_BOGUS", "0.781", "0.852"/), \
135.36 + (/"RH_NCEP", "1.122", "0.911"/), \
135.37 + (/"LHFLX_ERA40", "1.000", "0.835"/), \
135.38 + (/"TWP_ERA40", "0.998", "0.712"/), \
135.39 + (/"CLDTOT_NCEP", "1.321", "1.122"/), \
135.40 + (/"O3_NASA", "0.842", "0.956"/), \
135.41 + (/"Q_JMA", "0.978", "0.832"/), \
135.42 + (/"PBLH_JMA", "0.998", "0.900"/), \
135.43 + (/"Omega_CAS", "0.811", "1.311"/)/)
135.44 +
135.45 +
135.46 + wks = gsn_open_wks("ps","table")
135.47 +
135.48 +;
135.49 +; Main header.
135.50 +;
135.51 + res1 = True
135.52 + res1@txFontHeightF = 0.03
135.53 + res1@gsFillColor = "CornFlowerBlue"
135.54 +
135.55 + gsn_table(wks,ncr1,x1,y1,text1,res1)
135.56 +
135.57 +;
135.58 +; Sub header
135.59 +;
135.60 + res2 = True
135.61 + res2@txFontHeightF = 0.02
135.62 + res2@gsFillColor = "Gray"
135.63 +
135.64 + gsn_table(wks,ncr2,x2,y2,text2,res2)
135.65 +
135.66 +;
135.67 +; Main body of table.
135.68 +;
135.69 + res3 = True ; Set up resource list
135.70 +
135.71 +; res3@gsnDebug = True ; Useful to print NDC row,col values used.
135.72 +
135.73 + res3@txFontHeightF = 0.02
135.74 +
135.75 + res3@gsFillColor = (/ (/"gray","transparent","palegreen"/), \
135.76 + (/"gray","transparent","hotpink"/), \
135.77 + (/"gray","transparent","palegreen"/), \
135.78 + (/"gray","transparent","palegreen"/), \
135.79 + (/"gray","transparent","palegreen"/), \
135.80 + (/"gray","transparent","palegreen"/), \
135.81 + (/"gray","transparent","palegreen"/), \
135.82 + (/"gray","transparent","hotpink"/), \
135.83 + (/"gray","transparent","palegreen"/), \
135.84 + (/"gray","transparent","palegreen"/), \
135.85 + (/"gray","transparent","palegreen"/), \
135.86 + (/"gray","transparent","palegreen"/), \
135.87 + (/"gray","transparent","hotpink"/), \
135.88 + (/"gray","transparent","palegreen"/), \
135.89 + (/"gray","transparent","palegreen"/), \
135.90 + (/"gray","transparent","hotpink"/)/)
135.91 +
135.92 + gsn_table(wks,ncr3,x3,y3,text3,res3)
135.93 +
135.94 + frame(wks) ; Advance the frame.
135.95 +
135.96 +end
135.97 \ No newline at end of file
136.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
136.2 +++ b/co2/taylor_metrics_table.ncl Mon Jan 26 22:08:20 2009 -0500
136.3 @@ -0,0 +1,206 @@
136.4 +;*******************************************************************
136.5 +; procedure to draw the Taylor Diagram Metrics Table
136.6 +;
136.7 +; AWWG METRICS 0.3 ;;;
136.8 +; 27 Jun 06 ASP
136.9 +; 5 Jul 06 DJS
136.10 +;
136.11 +; Arguments:
136.12 +; mfname : name of the output table
136.13 +; varNames : variable names [metrics]
136.14 +; cases : case (model) names
136.15 +; seasons : season names
136.16 +; values : array containing the values to be plotted
136.17 +; opt : used to pass optional arguments
136.18 +
136.19 +procedure taylor_metrics_table(mfname[1]:string \ ; plot name
136.20 + ,varNames[*]:string \ ; variables
136.21 + ,cases[*]:string \
136.22 + ,seasons[*]:string \
136.23 + ,values[*][*][*]:numeric \
136.24 + ,opt:logical )
136.25 +
136.26 +
136.27 +;;;
136.28 +;;; Output of metrics to a table [grid]
136.29 +
136.30 +begin
136.31 + if (.not.isatt(opt,"pltType") .or. \
136.32 + (opt@pltType.eq."eps" .or. opt@pltType.eq."png" .or. opt@pltType.eq."gif")) then
136.33 + wks = gsn_open_wks("eps",mfname) ; default
136.34 + else
136.35 + wks = gsn_open_wks(opt@pltType,mfname)
136.36 + end if
136.37 +
136.38 + xbox0 = (/0.0,1.0,1.0,0.0,0.0/) ; Box template.
136.39 + ybox0 = (/0.0,0.0,1.0,1.0,0.0/)
136.40 +
136.41 + nvar = dimsizes(varNames)
136.42 + ncases = dimsizes(cases)
136.43 + nseas = dimsizes(seasons)
136.44 +
136.45 + dimt = dimsizes(values) ; table dimensions
136.46 +
136.47 + if (ncases.ne.dimt(0)) then
136.48 + print("taylor_metrics_table fatal error: Number of case names ("+ncases+ \
136.49 + ") does not match the number of cases passed in ("+dimt(0)+")")
136.50 + exit
136.51 + end if
136.52 + if (nseas.ne.dimt(1)) then
136.53 + print("taylor_metrics_table fatal error: Number of season names ("+nseas+ \
136.54 + ") does not match the number of seasons passed in ("+dimt(1)+")")
136.55 + exit
136.56 + end if
136.57 + if (dimsizes(varNames).ne.dimt(2)) then
136.58 + print("taylor_metrics_table fatal error: Number of metric variables names ("+dimsizes(varNames)+ \
136.59 + ") does not match the number of metric variables passed in ("+dimt(2)+")")
136.60 + exit
136.61 + end if
136.62 +
136.63 + ncolm1 = dimt(0)*dimt(1)
136.64 + if (ncolm1.le.12) then
136.65 + if (ncolm1.le.6) then
136.66 + tt_width = .4
136.67 + end if
136.68 + if (ncolm1.ge.7.and.ncolm1.le.12) then
136.69 + tt_width = .2
136.70 + end if
136.71 + tt_height = 0.1
136.72 + tt_theight = 0.02
136.73 + mn_height = 0.03
136.74 + mn_theight = 0.012
136.75 + else
136.76 + if (ncolm1.le.20) then
136.77 + tt_width = .15
136.78 + tt_height = 0.06
136.79 + tt_theight = 0.012
136.80 + mn_height = 0.018
136.81 + mn_theight = 0.0072
136.82 + else
136.83 + tt_width = .1
136.84 + tt_height = 0.05
136.85 + tt_theight = 0.01
136.86 + mn_height = 0.015
136.87 + mn_theight = 0.006
136.88 + end if
136.89 + end if
136.90 + if (ncolm1.gt.26.or.dimt(2).gt.63) then
136.91 + print("Warning: Recommended maximium size of array passed into taylor_metrics_table is "+ \
136.92 + "26 columns (#cases * #seasons) by 63 rows (#variables), continuing")
136.93 + end if
136.94 +
136.95 + mn_width = tt_width
136.96 + mv_height = mn_height
136.97 + mv_width = 0.1
136.98 + mv_theight = mn_theight
136.99 +
136.100 + tt_pRes = True
136.101 + tt_pRes@gsFillColor = "CornflowerBlue" ; background color for + values
136.102 +
136.103 + tt_tRes = True
136.104 + tt_tRes@txFontHeightF = tt_theight
136.105 +
136.106 + mn_pRes = True
136.107 + mn_pRes@gsFillColor = "Gray70" ; background color for variable names
136.108 +
136.109 + mn_tRes = True
136.110 + mn_tRes@txFontHeightF = mn_theight
136.111 +
136.112 + mv_pRes = True
136.113 + mv_pRes@gsFillColor = "White" ; background color for reference values
136.114 +
136.115 + mv_tRes = True
136.116 + mv_tRes@txFontHeightF = mn_theight
136.117 +
136.118 +; Title
136.119 +
136.120 + xbox = tt_width*xbox0
136.121 + ybox = 1.-tt_height*ybox0
136.122 +
136.123 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
136.124 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
136.125 +
136.126 + gsn_polygon_ndc(wks,xbox,ybox,tt_pRes)
136.127 + if (isatt(opt,"tableTitle") ) then
136.128 + gsn_text_ndc(wks, opt@tableTitle ,ixtbox,iytbox, tt_tRes)
136.129 + else
136.130 + gsn_text_ndc(wks,"CAM METRICS",ixtbox,iytbox, tt_tRes)
136.131 + end if
136.132 + gsn_polyline_ndc(wks,xbox,ybox,False)
136.133 +
136.134 + do im = 0,nvar-1
136.135 + ybox = min(ybox)-(ybox0*mn_height)
136.136 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
136.137 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
136.138 +
136.139 + gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
136.140 + gsn_polyline_ndc(wks,xbox,ybox,False)
136.141 + gsn_text_ndc(wks,varNames(im),ixtbox,iytbox, mn_tRes)
136.142 + end do
136.143 +
136.144 + do icase = 0, ncases-1
136.145 + ybox = 1.-0.5*tt_height*ybox0
136.146 + xbox = ((1.-tt_width)/ncases)*(xbox0+icase)+tt_width
136.147 + xboxi = min(xbox)
136.148 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
136.149 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
136.150 + gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
136.151 + gsn_polyline_ndc(wks,xbox,ybox,False)
136.152 + gsn_text_ndc(wks,cases(icase),ixtbox,iytbox, mn_tRes)
136.153 +
136.154 + do iseas = 0, nseas-1
136.155 + ybox = 1.-0.5*tt_height-0.5*tt_height*ybox0
136.156 + xbox = xboxi + ((1.-tt_width)/(ncases*nseas))*(xbox0+iseas)
136.157 + ixtbox = xbox(0)+0.5*(xbox(1)-xbox(0))
136.158 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
136.159 + gsn_polygon_ndc(wks,xbox,ybox,mn_pRes)
136.160 + gsn_polyline_ndc(wks,xbox,ybox,False)
136.161 + gsn_text_ndc(wks,seasons(iseas),ixtbox,iytbox, mn_tRes)
136.162 +
136.163 + do im=0,nvar-1
136.164 + if (im .eq. 0) then
136.165 + ybox = 1.-tt_height-mv_height*ybox0
136.166 + else
136.167 + ybox = ybox - mv_height
136.168 + end if
136.169 + iytbox = ybox(0)+0.5*(ybox(2)-ybox(0))
136.170 + mv_pRes@gsFillColor = "White"
136.171 + if (icase .gt. 0) then
136.172 + if (ismissing(values(icase,iseas,im)) .or. \ ; ???
136.173 + ismissing(values(icase,iseas,im)))then
136.174 + ; print ("Missing values skipped")
136.175 + else
136.176 + if (values(icase,iseas,im).le.values(0,iseas,im)) then
136.177 + if (isatt(opt,"color0")) then
136.178 + mv_pRes@gsFillColor = opt@color0
136.179 + else
136.180 + mv_pRes@gsFillColor = "DarkOliveGreen3"
136.181 + end if
136.182 + else
136.183 + if (isatt(opt,"color1")) then
136.184 + mv_pRes@gsFillColor = opt@color1
136.185 + else
136.186 + mv_pRes@gsFillColor = "IndianRed1"
136.187 + end if
136.188 + end if
136.189 + end if
136.190 + end if
136.191 + gsn_polygon_ndc(wks,xbox,ybox,mv_pRes)
136.192 + gsn_polyline_ndc(wks,xbox,ybox,False)
136.193 + gsn_text_ndc(wks,sprintf("%4.3f",values(icase,iseas,im)),ixtbox,iytbox, mv_tRes)
136.194 + end do
136.195 + end do
136.196 + end do
136.197 +
136.198 + draw(wks)
136.199 + ;; activate the ;; lines if this is made a function
136.200 + ;;if (.not.isatt(opt,"gsnFrame") .or. opt@gsnFrame) then
136.201 + frame(wks)
136.202 + ; if png or gif then use convert
136.203 + if (isatt(opt,"pltType") .and. \
136.204 + (opt@pltType.eq."png" .or. opt@pltType.eq."gif")) then
136.205 + system("convert -trim +repage "+mfname+".eps "+mfname+"."+opt@pltType)
136.206 + end if
136.207 + ;;end if
136.208 +
136.209 +end
137.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
137.2 +++ b/energy/01.monthly_avg.ncl Mon Jan 26 22:08:20 2009 -0500
137.3 @@ -0,0 +1,161 @@
137.4 +;************************************************
137.5 +; Read half-hourly data and write monthly data
137.6 +; input data is : half-hourly
137.7 +;
137.8 +; output data is : CO2_flux, RAD_FLUX, SH_FLUX, LH_FLUX
137.9 +; date, lat, lon
137.10 +;************************************************
137.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
137.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
137.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
137.14 +;************************************************
137.15 +begin
137.16 +
137.17 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
137.18 + station_name = "Kaamanen"
137.19 + file_name_add = "carboeurope"
137.20 + year_start = 2000
137.21 + year_end = 2003
137.22 +
137.23 +; final output
137.24 + diro = dir_root + station_name + "/"
137.25 + filo = station_name+"_"+year_start+"-"+year_end+"_monthly.nc"
137.26 + c = addfile(diro+filo,"c")
137.27 + print (filo)
137.28 +
137.29 +; input dir
137.30 + diri = dir_root + station_name + "/"
137.31 +
137.32 + nyear = year_end - year_start + 1
137.33 + nmon = 12
137.34 + nlat = 1
137.35 + nlon = 1
137.36 +
137.37 +; day_of_month = (/31.,28.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31./)
137.38 + end_of_month1 = (/31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334.,365./)
137.39 + end_of_month2 = (/31.,60.,91.,121.,152.,182.,213.,244.,274.,305.,335.,366./)
137.40 +
137.41 + data_out1 = new((/nyear,nmon/),float)
137.42 + data_out2 = new((/nyear,nmon/),float)
137.43 + data_out3 = new((/nyear,nmon/),float)
137.44 + data_out4 = new((/nyear,nmon/),float)
137.45 + time_out = new((/nyear,nmon/),integer)
137.46 + lat_out = new((/nlat/),float)
137.47 + lon_out = new((/nlon/),float)
137.48 +
137.49 + do m = 0,nyear-1
137.50 + year = year_start + m
137.51 +
137.52 +; if (mod(year,4) .eq. 0) then
137.53 + if (year .eq. 2000) then
137.54 + hour_of_month = end_of_month2 * 24.
137.55 + else
137.56 + hour_of_month = end_of_month1 * 24.
137.57 + end if
137.58 +; print (hour_of_month)
137.59 +
137.60 +; input file
137.61 + fili = file_name_add+"."+station_name+"."+year+".nc"
137.62 + b = addfile(diri+fili,"r")
137.63 + print (fili)
137.64 +
137.65 +; co2 flux unit: umol m-2 s-1
137.66 + data1 = b->FCO2M
137.67 +; net radiation flux unit: W m-2
137.68 + data2 = b->RN
137.69 +; sensible heat flux unit: W m-2
137.70 + data3 = b->H
137.71 +; latent heat flux unit: W m-2
137.72 + data4 = b->LE
137.73 +
137.74 +; time unit: hour since 01-01 (mm-dd)
137.75 + time = b->time
137.76 +
137.77 + do n= 0,nmon-1
137.78 + if (n.eq.0) then
137.79 + timeL = 0.
137.80 + timeR = hour_of_month(0)
137.81 + else
137.82 + timeL = hour_of_month(n-1)
137.83 + timeR = hour_of_month(n)
137.84 + end if
137.85 +; print (timeL)
137.86 +; print (timeR)
137.87 +
137.88 + i = ind(time.ge.timeL .and. time.lt.timeR)
137.89 +; print (i)
137.90 +
137.91 + data_out1(m,n) = avg(data1(i))
137.92 + data_out2(m,n) = avg(data2(i))
137.93 + data_out3(m,n) = avg(data3(i))
137.94 + data_out4(m,n) = avg(data4(i))
137.95 +
137.96 + time_out(m,n) = year*100 + n + 1
137.97 +; print (time_out(m,n))
137.98 +
137.99 + delete (i)
137.100 + end do
137.101 + if (m.lt.nyear-1) then
137.102 + delete (data1)
137.103 + delete (data2)
137.104 + delete (data3)
137.105 + delete (data4)
137.106 + delete (time)
137.107 + end if
137.108 + end do
137.109 +
137.110 + lat_out = 69.1407
137.111 + lon_out = 27.2950
137.112 +
137.113 + data_out1!0 = "year"
137.114 + data_out1!1 = "month"
137.115 + data_out1@long_name = data1@long_name
137.116 + data_out1@units = data1@units
137.117 + data_out1@_FillValue = 1.e+36
137.118 +; print (data_out1)
137.119 +
137.120 + data_out2!0 = "year"
137.121 + data_out2!1 = "month"
137.122 + data_out2@long_name = data2@long_name
137.123 + data_out2@units = data2@units
137.124 + data_out2@_FillValue = 1.e+36
137.125 +; print (data_out2)
137.126 +
137.127 + data_out3!0 = "year"
137.128 + data_out3!1 = "month"
137.129 + data_out3@long_name = data3@long_name
137.130 + data_out3@units = data3@units
137.131 + data_out3@_FillValue = 1.e+36
137.132 +; print (data_out3)
137.133 +
137.134 + data_out4!0 = "year"
137.135 + data_out4!1 = "month"
137.136 + data_out4@long_name = data4@long_name
137.137 + data_out4@units = data4@units
137.138 + data_out4@_FillValue = 1.e+36
137.139 +; print (data_out4)
137.140 +
137.141 + time_out!0 = "year"
137.142 + time_out!1 = "month"
137.143 + time_out@long_name = "current date as yyyymm"
137.144 + time_out@units = "current date as yyyymm"
137.145 + print (time_out)
137.146 +
137.147 + lat_out!0 = "lat"
137.148 + lon_out!0 = "lon"
137.149 + lat_out@units = "degrees_north"
137.150 + lat_out@long_name = "Latitude"
137.151 + lon_out@units = "degrees_east"
137.152 + lon_out@long_name = "Longitude"
137.153 + print (lat_out)
137.154 + print (lon_out)
137.155 +
137.156 + c->lat = lat_out
137.157 + c->lon = lon_out
137.158 + c->date = time_out
137.159 + c->CO2_FLUX = data_out1
137.160 + c->RAD_FLUX = data_out2
137.161 + c->SH_FLUX = data_out3
137.162 + c->LH_FLUX = data_out4
137.163 +
137.164 +end
138.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
138.2 +++ b/energy/02.monthly_avg.ncl Mon Jan 26 22:08:20 2009 -0500
138.3 @@ -0,0 +1,162 @@
138.4 +;************************************************
138.5 +; Read half-hourly data and write monthly data
138.6 +; input data is : half-hourly
138.7 +;
138.8 +; output data is : CO2_flux, RAD_FLUX, SH_FLUX, LH_FLUX
138.9 +; date, lat, lon
138.10 +;************************************************
138.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
138.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
138.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
138.14 +;************************************************
138.15 +begin
138.16 +
138.17 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
138.18 + station_name = "LBA_Tapajos_KM67"
138.19 + file_name_add = "ameriflux"
138.20 + year_start = 2002
138.21 + year_end = 2005
138.22 + year_leap = 2004
138.23 +
138.24 + lat_out = -3.01030
138.25 + lon_out = -54.58150 + 360.
138.26 +
138.27 +; final output
138.28 + diro = dir_root + station_name + "/"
138.29 + filo = station_name+"_"+year_start+"-"+year_end+"_monthly.nc"
138.30 + c = addfile(diro+filo,"c")
138.31 + print (filo)
138.32 +
138.33 +; input dir
138.34 + diri = dir_root + station_name + "/"
138.35 +
138.36 + nyear = year_end - year_start + 1
138.37 + nmon = 12
138.38 + nlat = 1
138.39 + nlon = 1
138.40 +
138.41 +; day_of_month = (/31.,28.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31./)
138.42 + end_of_month1 = (/31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334.,365./)
138.43 + end_of_month2 = (/31.,60.,91.,121.,152.,182.,213.,244.,274.,305.,335.,366./)
138.44 +
138.45 + data_out1 = new((/nyear,nmon/),float)
138.46 + data_out2 = new((/nyear,nmon/),float)
138.47 + data_out3 = new((/nyear,nmon/),float)
138.48 + data_out4 = new((/nyear,nmon/),float)
138.49 + time_out = new((/nyear,nmon/),integer)
138.50 +; lat_out = new((/nlat/),float)
138.51 +; lon_out = new((/nlon/),float)
138.52 +
138.53 + do m = 0,nyear-1
138.54 + year = year_start + m
138.55 +
138.56 +; if (mod(year,4) .eq. 0) then
138.57 + if (year .eq. year_leap) then
138.58 + hour_of_month = end_of_month2 * 24.
138.59 + else
138.60 + hour_of_month = end_of_month1 * 24.
138.61 + end if
138.62 +; print (hour_of_month)
138.63 +
138.64 +; input file
138.65 + fili = file_name_add+"."+station_name+"."+year+".nc"
138.66 + b = addfile(diri+fili,"r")
138.67 + print (fili)
138.68 +
138.69 +; co2 flux unit: umol m-2 s-1
138.70 + data1 = b->FCO2M
138.71 +; net radiation flux unit: W m-2
138.72 + data2 = b->RN
138.73 +; sensible heat flux unit: W m-2
138.74 + data3 = b->H
138.75 +; latent heat flux unit: W m-2
138.76 + data4 = b->LE
138.77 +
138.78 +; time unit: hour since 01-01 (mm-dd)
138.79 + time = b->time
138.80 +
138.81 + do n= 0,nmon-1
138.82 + if (n.eq.0) then
138.83 + timeL = 0.
138.84 + timeR = hour_of_month(0)
138.85 + else
138.86 + timeL = hour_of_month(n-1)
138.87 + timeR = hour_of_month(n)
138.88 + end if
138.89 +; print (timeL)
138.90 +; print (timeR)
138.91 +
138.92 + i = ind(time.ge.timeL .and. time.lt.timeR)
138.93 +; print (i)
138.94 +
138.95 + data_out1(m,n) = avg(data1(i))
138.96 + data_out2(m,n) = avg(data2(i))
138.97 + data_out3(m,n) = avg(data3(i))
138.98 + data_out4(m,n) = avg(data4(i))
138.99 +
138.100 + time_out(m,n) = year*100 + n + 1
138.101 +; print (time_out(m,n))
138.102 +
138.103 + delete (i)
138.104 + end do
138.105 + if (m.lt.nyear-1) then
138.106 + delete (data1)
138.107 + delete (data2)
138.108 + delete (data3)
138.109 + delete (data4)
138.110 + delete (time)
138.111 + end if
138.112 + end do
138.113 +
138.114 + data_out1!0 = "year"
138.115 + data_out1!1 = "month"
138.116 + data_out1@long_name = data1@long_name
138.117 + data_out1@units = data1@units
138.118 + data_out1@_FillValue = 1.e+36
138.119 +; print (data_out1)
138.120 +
138.121 + data_out2!0 = "year"
138.122 + data_out2!1 = "month"
138.123 + data_out2@long_name = data2@long_name
138.124 + data_out2@units = data2@units
138.125 + data_out2@_FillValue = 1.e+36
138.126 +; print (data_out2)
138.127 +
138.128 + data_out3!0 = "year"
138.129 + data_out3!1 = "month"
138.130 + data_out3@long_name = data3@long_name
138.131 + data_out3@units = data3@units
138.132 + data_out3@_FillValue = 1.e+36
138.133 +; print (data_out3)
138.134 +
138.135 + data_out4!0 = "year"
138.136 + data_out4!1 = "month"
138.137 + data_out4@long_name = data4@long_name
138.138 + data_out4@units = data4@units
138.139 + data_out4@_FillValue = 1.e+36
138.140 +; print (data_out4)
138.141 +
138.142 + time_out!0 = "year"
138.143 + time_out!1 = "month"
138.144 + time_out@long_name = "current date as yyyymm"
138.145 + time_out@units = "current date as yyyymm"
138.146 + print (time_out)
138.147 +
138.148 + lat_out!0 = "lat"
138.149 + lon_out!0 = "lon"
138.150 + lat_out@units = "degrees_north"
138.151 + lat_out@long_name = "Latitude"
138.152 + lon_out@units = "degrees_east"
138.153 + lon_out@long_name = "Longitude"
138.154 + print (lat_out)
138.155 + print (lon_out)
138.156 +
138.157 + c->lat = lat_out
138.158 + c->lon = lon_out
138.159 + c->date = time_out
138.160 + c->CO2_FLUX = data_out1
138.161 + c->RAD_FLUX = data_out2
138.162 + c->SH_FLUX = data_out3
138.163 + c->LH_FLUX = data_out4
138.164 +
138.165 +end
139.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
139.2 +++ b/energy/03.monthly_avg.ncl Mon Jan 26 22:08:20 2009 -0500
139.3 @@ -0,0 +1,163 @@
139.4 +;************************************************
139.5 +; Read half-hourly data and write monthly data
139.6 +; input data is : half-hourly
139.7 +;
139.8 +; output data is : CO2_flux, RAD_FLUX, SH_FLUX, LH_FLUX
139.9 +; date, lat, lon
139.10 +;************************************************
139.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
139.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
139.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
139.14 +;************************************************
139.15 +begin
139.16 +
139.17 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
139.18 + station_name = "Lethbridge"
139.19 + file_name_add = "ameriflux"
139.20 + year_start = 1999
139.21 + year_end = 2004
139.22 + year_leap1 = 2000
139.23 + year_leap2 = 2004
139.24 +
139.25 + lat_out = 49.709278
139.26 + lon_out = -112.940167 + 360.
139.27 +
139.28 +; final output
139.29 + diro = dir_root + station_name + "/"
139.30 + filo = station_name+"_"+year_start+"-"+year_end+"_monthly.nc"
139.31 + c = addfile(diro+filo,"c")
139.32 + print (filo)
139.33 +
139.34 +; input dir
139.35 + diri = dir_root + station_name + "/"
139.36 +
139.37 + nyear = year_end - year_start + 1
139.38 + nmon = 12
139.39 + nlat = 1
139.40 + nlon = 1
139.41 +
139.42 +; day_of_month = (/31.,28.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31./)
139.43 + end_of_month1 = (/31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334.,365./)
139.44 + end_of_month2 = (/31.,60.,91.,121.,152.,182.,213.,244.,274.,305.,335.,366./)
139.45 +
139.46 + data_out1 = new((/nyear,nmon/),float)
139.47 + data_out2 = new((/nyear,nmon/),float)
139.48 + data_out3 = new((/nyear,nmon/),float)
139.49 + data_out4 = new((/nyear,nmon/),float)
139.50 + time_out = new((/nyear,nmon/),integer)
139.51 +; lat_out = new((/nlat/),float)
139.52 +; lon_out = new((/nlon/),float)
139.53 +
139.54 + do m = 0,nyear-1
139.55 + year = year_start + m
139.56 +
139.57 +; if (mod(year,4) .eq. 0) then
139.58 + if (year .eq. year_leap1 .or. year .eq. year_leap2 ) then
139.59 + hour_of_month = end_of_month2 * 24.
139.60 + else
139.61 + hour_of_month = end_of_month1 * 24.
139.62 + end if
139.63 +; print (hour_of_month)
139.64 +
139.65 +; input file
139.66 + fili = file_name_add+"."+station_name+"."+year+".nc"
139.67 + b = addfile(diri+fili,"r")
139.68 + print (fili)
139.69 +
139.70 +; co2 flux unit: umol m-2 s-1
139.71 + data1 = b->FCO2M
139.72 +; net radiation flux unit: W m-2
139.73 + data2 = b->RN
139.74 +; sensible heat flux unit: W m-2
139.75 + data3 = b->H
139.76 +; latent heat flux unit: W m-2
139.77 + data4 = b->LE
139.78 +
139.79 +; time unit: hour since 01-01 (mm-dd)
139.80 + time = b->time
139.81 +
139.82 + do n= 0,nmon-1
139.83 + if (n.eq.0) then
139.84 + timeL = 0.
139.85 + timeR = hour_of_month(0)
139.86 + else
139.87 + timeL = hour_of_month(n-1)
139.88 + timeR = hour_of_month(n)
139.89 + end if
139.90 +; print (timeL)
139.91 +; print (timeR)
139.92 +
139.93 + i = ind(time.ge.timeL .and. time.lt.timeR)
139.94 +; print (i)
139.95 +
139.96 + data_out1(m,n) = avg(data1(i))
139.97 + data_out2(m,n) = avg(data2(i))
139.98 + data_out3(m,n) = avg(data3(i))
139.99 + data_out4(m,n) = avg(data4(i))
139.100 +
139.101 + time_out(m,n) = year*100 + n + 1
139.102 +; print (time_out(m,n))
139.103 +
139.104 + delete (i)
139.105 + end do
139.106 + if (m.lt.nyear-1) then
139.107 + delete (data1)
139.108 + delete (data2)
139.109 + delete (data3)
139.110 + delete (data4)
139.111 + delete (time)
139.112 + end if
139.113 + end do
139.114 +
139.115 + data_out1!0 = "year"
139.116 + data_out1!1 = "month"
139.117 + data_out1@long_name = data1@long_name
139.118 + data_out1@units = data1@units
139.119 + data_out1@_FillValue = 1.e+36
139.120 +; print (data_out1)
139.121 +
139.122 + data_out2!0 = "year"
139.123 + data_out2!1 = "month"
139.124 + data_out2@long_name = data2@long_name
139.125 + data_out2@units = data2@units
139.126 + data_out2@_FillValue = 1.e+36
139.127 +; print (data_out2)
139.128 +
139.129 + data_out3!0 = "year"
139.130 + data_out3!1 = "month"
139.131 + data_out3@long_name = data3@long_name
139.132 + data_out3@units = data3@units
139.133 + data_out3@_FillValue = 1.e+36
139.134 +; print (data_out3)
139.135 +
139.136 + data_out4!0 = "year"
139.137 + data_out4!1 = "month"
139.138 + data_out4@long_name = data4@long_name
139.139 + data_out4@units = data4@units
139.140 + data_out4@_FillValue = 1.e+36
139.141 +; print (data_out4)
139.142 +
139.143 + time_out!0 = "year"
139.144 + time_out!1 = "month"
139.145 + time_out@long_name = "current date as yyyymm"
139.146 + time_out@units = "current date as yyyymm"
139.147 + print (time_out)
139.148 +
139.149 + lat_out!0 = "lat"
139.150 + lon_out!0 = "lon"
139.151 + lat_out@units = "degrees_north"
139.152 + lat_out@long_name = "Latitude"
139.153 + lon_out@units = "degrees_east"
139.154 + lon_out@long_name = "Longitude"
139.155 + print (lat_out)
139.156 + print (lon_out)
139.157 +
139.158 + c->lat = lat_out
139.159 + c->lon = lon_out
139.160 + c->date = time_out
139.161 + c->CO2_FLUX = data_out1
139.162 + c->RAD_FLUX = data_out2
139.163 + c->SH_FLUX = data_out3
139.164 + c->LH_FLUX = data_out4
139.165 +
139.166 +end
140.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
140.2 +++ b/energy/04.monthly_avg.ncl Mon Jan 26 22:08:20 2009 -0500
140.3 @@ -0,0 +1,161 @@
140.4 +;************************************************
140.5 +; Read half-hourly data and write monthly data
140.6 +; input data is : half-hourly
140.7 +;
140.8 +; output data is : CO2_flux, RAD_FLUX, SH_FLUX, LH_FLUX
140.9 +; date, lat, lon
140.10 +;************************************************
140.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
140.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
140.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
140.14 +;************************************************
140.15 +begin
140.16 +
140.17 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
140.18 + station_name = "Tharandt"
140.19 + file_name_add = "carboeurope"
140.20 + year_start = 1996
140.21 + year_end = 2003
140.22 + year_leap1 = 1996
140.23 + year_leap2 = 2000
140.24 +
140.25 + lat_out = 50.9636
140.26 + lon_out = 13.5669
140.27 +
140.28 +; final output
140.29 + diro = dir_root + station_name + "/"
140.30 + filo = station_name+"_"+year_start+"-"+year_end+"_monthly.nc"
140.31 + c = addfile(diro+filo,"c")
140.32 + print (filo)
140.33 +
140.34 +; input dir
140.35 + diri = dir_root + station_name + "/"
140.36 +
140.37 + nyear = year_end - year_start + 1
140.38 + nmon = 12
140.39 + nlat = 1
140.40 + nlon = 1
140.41 +
140.42 +; day_of_month = (/31.,28.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31./)
140.43 + end_of_month1 = (/31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334.,365./)
140.44 + end_of_month2 = (/31.,60.,91.,121.,152.,182.,213.,244.,274.,305.,335.,366./)
140.45 +
140.46 + data_out1 = new((/nyear,nmon/),float)
140.47 + data_out2 = new((/nyear,nmon/),float)
140.48 + data_out3 = new((/nyear,nmon/),float)
140.49 + data_out4 = new((/nyear,nmon/),float)
140.50 + time_out = new((/nyear,nmon/),integer)
140.51 +
140.52 + do m = 0,nyear-1
140.53 + year = year_start + m
140.54 +
140.55 +; if (mod(year,4) .eq. 0) then
140.56 + if (year .eq. year_leap1 .or. year .eq. year_leap2 ) then
140.57 + hour_of_month = end_of_month2 * 24.
140.58 + else
140.59 + hour_of_month = end_of_month1 * 24.
140.60 + end if
140.61 +; print (hour_of_month)
140.62 +
140.63 +; input file
140.64 + fili = file_name_add+"."+station_name+"."+year+".nc"
140.65 + b = addfile(diri+fili,"r")
140.66 + print (fili)
140.67 +
140.68 +; co2 flux unit: umol m-2 s-1
140.69 + data1 = b->FCO2M
140.70 +; net radiation flux unit: W m-2
140.71 + data2 = b->RN
140.72 +; sensible heat flux unit: W m-2
140.73 + data3 = b->H
140.74 +; latent heat flux unit: W m-2
140.75 + data4 = b->LE
140.76 +
140.77 +; time unit: hour since 01-01 (mm-dd)
140.78 + time = b->time
140.79 +
140.80 + do n= 0,nmon-1
140.81 + if (n.eq.0) then
140.82 + timeL = 0.
140.83 + timeR = hour_of_month(0)
140.84 + else
140.85 + timeL = hour_of_month(n-1)
140.86 + timeR = hour_of_month(n)
140.87 + end if
140.88 +; print (timeL)
140.89 +; print (timeR)
140.90 +
140.91 + i = ind(time.ge.timeL .and. time.lt.timeR)
140.92 +; print (i)
140.93 +
140.94 + data_out1(m,n) = avg(data1(i))
140.95 + data_out2(m,n) = avg(data2(i))
140.96 + data_out3(m,n) = avg(data3(i))
140.97 + data_out4(m,n) = avg(data4(i))
140.98 +
140.99 + time_out(m,n) = year*100 + n + 1
140.100 +; print (time_out(m,n))
140.101 +
140.102 + delete (i)
140.103 + end do
140.104 + if (m.lt.nyear-1) then
140.105 + delete (data1)
140.106 + delete (data2)
140.107 + delete (data3)
140.108 + delete (data4)
140.109 + delete (time)
140.110 + end if
140.111 + end do
140.112 +
140.113 + data_out1!0 = "year"
140.114 + data_out1!1 = "month"
140.115 + data_out1@long_name = data1@long_name
140.116 + data_out1@units = data1@units
140.117 + data_out1@_FillValue = 1.e+36
140.118 +; print (data_out1)
140.119 +
140.120 + data_out2!0 = "year"
140.121 + data_out2!1 = "month"
140.122 + data_out2@long_name = data2@long_name
140.123 + data_out2@units = data2@units
140.124 + data_out2@_FillValue = 1.e+36
140.125 +; print (data_out2)
140.126 +
140.127 + data_out3!0 = "year"
140.128 + data_out3!1 = "month"
140.129 + data_out3@long_name = data3@long_name
140.130 + data_out3@units = data3@units
140.131 + data_out3@_FillValue = 1.e+36
140.132 +; print (data_out3)
140.133 +
140.134 + data_out4!0 = "year"
140.135 + data_out4!1 = "month"
140.136 + data_out4@long_name = data4@long_name
140.137 + data_out4@units = data4@units
140.138 + data_out4@_FillValue = 1.e+36
140.139 +; print (data_out4)
140.140 +
140.141 + time_out!0 = "year"
140.142 + time_out!1 = "month"
140.143 + time_out@long_name = "current date as yyyymm"
140.144 + time_out@units = "current date as yyyymm"
140.145 + print (time_out)
140.146 +
140.147 + lat_out!0 = "lat"
140.148 + lon_out!0 = "lon"
140.149 + lat_out@units = "degrees_north"
140.150 + lat_out@long_name = "Latitude"
140.151 + lon_out@units = "degrees_east"
140.152 + lon_out@long_name = "Longitude"
140.153 + print (lat_out)
140.154 + print (lon_out)
140.155 +
140.156 + c->lat = lat_out
140.157 + c->lon = lon_out
140.158 + c->date = time_out
140.159 + c->CO2_FLUX = data_out1
140.160 + c->RAD_FLUX = data_out2
140.161 + c->SH_FLUX = data_out3
140.162 + c->LH_FLUX = data_out4
140.163 +
140.164 +end
141.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
141.2 +++ b/energy/05.monthly_avg.ncl Mon Jan 26 22:08:20 2009 -0500
141.3 @@ -0,0 +1,161 @@
141.4 +;************************************************
141.5 +; Read half-hourly data and write monthly data
141.6 +; input data is : half-hourly
141.7 +;
141.8 +; output data is : CO2_flux, RAD_FLUX, SH_FLUX, LH_FLUX
141.9 +; date, lat, lon
141.10 +;************************************************
141.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
141.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
141.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
141.14 +;************************************************
141.15 +begin
141.16 +
141.17 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
141.18 + station_name = "Vielsalm"
141.19 + file_name_add = "carboeurope"
141.20 + year_start = 1998
141.21 + year_end = 2003
141.22 + year_leap1 = 1996
141.23 + year_leap2 = 2000
141.24 +
141.25 + lat_out = 50.3089
141.26 + lon_out = 5.99861
141.27 +
141.28 +; final output
141.29 + diro = dir_root + station_name + "/"
141.30 + filo = station_name+"_"+year_start+"-"+year_end+"_monthly.nc"
141.31 + c = addfile(diro+filo,"c")
141.32 + print (filo)
141.33 +
141.34 +; input dir
141.35 + diri = dir_root + station_name + "/"
141.36 +
141.37 + nyear = year_end - year_start + 1
141.38 + nmon = 12
141.39 + nlat = 1
141.40 + nlon = 1
141.41 +
141.42 +; day_of_month = (/31.,28.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31./)
141.43 + end_of_month1 = (/31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334.,365./)
141.44 + end_of_month2 = (/31.,60.,91.,121.,152.,182.,213.,244.,274.,305.,335.,366./)
141.45 +
141.46 + data_out1 = new((/nyear,nmon/),float)
141.47 + data_out2 = new((/nyear,nmon/),float)
141.48 + data_out3 = new((/nyear,nmon/),float)
141.49 + data_out4 = new((/nyear,nmon/),float)
141.50 + time_out = new((/nyear,nmon/),integer)
141.51 +
141.52 + do m = 0,nyear-1
141.53 + year = year_start + m
141.54 +
141.55 +; if (mod(year,4) .eq. 0) then
141.56 + if (year .eq. year_leap1 .or. year .eq. year_leap2 ) then
141.57 + hour_of_month = end_of_month2 * 24.
141.58 + else
141.59 + hour_of_month = end_of_month1 * 24.
141.60 + end if
141.61 +; print (hour_of_month)
141.62 +
141.63 +; input file
141.64 + fili = file_name_add+"."+station_name+"."+year+".nc"
141.65 + b = addfile(diri+fili,"r")
141.66 + print (fili)
141.67 +
141.68 +; co2 flux unit: umol m-2 s-1
141.69 + data1 = b->FCO2M
141.70 +; net radiation flux unit: W m-2
141.71 + data2 = b->RN
141.72 +; sensible heat flux unit: W m-2
141.73 + data3 = b->H
141.74 +; latent heat flux unit: W m-2
141.75 + data4 = b->LE
141.76 +
141.77 +; time unit: hour since 01-01 (mm-dd)
141.78 + time = b->time
141.79 +
141.80 + do n= 0,nmon-1
141.81 + if (n.eq.0) then
141.82 + timeL = 0.
141.83 + timeR = hour_of_month(0)
141.84 + else
141.85 + timeL = hour_of_month(n-1)
141.86 + timeR = hour_of_month(n)
141.87 + end if
141.88 +; print (timeL)
141.89 +; print (timeR)
141.90 +
141.91 + i = ind(time.ge.timeL .and. time.lt.timeR)
141.92 +; print (i)
141.93 +
141.94 + data_out1(m,n) = avg(data1(i))
141.95 + data_out2(m,n) = avg(data2(i))
141.96 + data_out3(m,n) = avg(data3(i))
141.97 + data_out4(m,n) = avg(data4(i))
141.98 +
141.99 + time_out(m,n) = year*100 + n + 1
141.100 +; print (time_out(m,n))
141.101 +
141.102 + delete (i)
141.103 + end do
141.104 + if (m.lt.nyear-1) then
141.105 + delete (data1)
141.106 + delete (data2)
141.107 + delete (data3)
141.108 + delete (data4)
141.109 + delete (time)
141.110 + end if
141.111 + end do
141.112 +
141.113 + data_out1!0 = "year"
141.114 + data_out1!1 = "month"
141.115 + data_out1@long_name = data1@long_name
141.116 + data_out1@units = data1@units
141.117 + data_out1@_FillValue = 1.e+36
141.118 +; print (data_out1)
141.119 +
141.120 + data_out2!0 = "year"
141.121 + data_out2!1 = "month"
141.122 + data_out2@long_name = data2@long_name
141.123 + data_out2@units = data2@units
141.124 + data_out2@_FillValue = 1.e+36
141.125 +; print (data_out2)
141.126 +
141.127 + data_out3!0 = "year"
141.128 + data_out3!1 = "month"
141.129 + data_out3@long_name = data3@long_name
141.130 + data_out3@units = data3@units
141.131 + data_out3@_FillValue = 1.e+36
141.132 +; print (data_out3)
141.133 +
141.134 + data_out4!0 = "year"
141.135 + data_out4!1 = "month"
141.136 + data_out4@long_name = data4@long_name
141.137 + data_out4@units = data4@units
141.138 + data_out4@_FillValue = 1.e+36
141.139 +; print (data_out4)
141.140 +
141.141 + time_out!0 = "year"
141.142 + time_out!1 = "month"
141.143 + time_out@long_name = "current date as yyyymm"
141.144 + time_out@units = "current date as yyyymm"
141.145 + print (time_out)
141.146 +
141.147 + lat_out!0 = "lat"
141.148 + lon_out!0 = "lon"
141.149 + lat_out@units = "degrees_north"
141.150 + lat_out@long_name = "Latitude"
141.151 + lon_out@units = "degrees_east"
141.152 + lon_out@long_name = "Longitude"
141.153 + print (lat_out)
141.154 + print (lon_out)
141.155 +
141.156 + c->lat = lat_out
141.157 + c->lon = lon_out
141.158 + c->date = time_out
141.159 + c->CO2_FLUX = data_out1
141.160 + c->RAD_FLUX = data_out2
141.161 + c->SH_FLUX = data_out3
141.162 + c->LH_FLUX = data_out4
141.163 +
141.164 +end
142.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
142.2 +++ b/energy/06.monthly_avg.ncl Mon Jan 26 22:08:20 2009 -0500
142.3 @@ -0,0 +1,162 @@
142.4 +;************************************************
142.5 +; Read half-hourly data and write monthly data
142.6 +; input data is : half-hourly
142.7 +;
142.8 +; output data is : CO2_flux, RAD_FLUX, SH_FLUX, LH_FLUX
142.9 +; date, lat, lon
142.10 +;************************************************
142.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
142.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
142.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
142.14 +;************************************************
142.15 +begin
142.16 +
142.17 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
142.18 + station_name = "BOREAS_NSA_OBS"
142.19 + file_name_add = "ameriflux"
142.20 + year_start = 1994
142.21 + year_end = 2004
142.22 + year_leap1 = 1996
142.23 + year_leap2 = 2000
142.24 + year_leap3 = 2004
142.25 +
142.26 + lat_out = 55.879620
142.27 + lon_out = -98.480810 + 360.
142.28 +
142.29 +; final output
142.30 + diro = dir_root + station_name + "/"
142.31 + filo = station_name+"_"+year_start+"-"+year_end+"_monthly.nc"
142.32 + c = addfile(diro+filo,"c")
142.33 + print (filo)
142.34 +
142.35 +; input dir
142.36 + diri = dir_root + station_name + "/"
142.37 +
142.38 + nyear = year_end - year_start + 1
142.39 + nmon = 12
142.40 + nlat = 1
142.41 + nlon = 1
142.42 +
142.43 +; day_of_month = (/31.,28.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31./)
142.44 + end_of_month1 = (/31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334.,365./)
142.45 + end_of_month2 = (/31.,60.,91.,121.,152.,182.,213.,244.,274.,305.,335.,366./)
142.46 +
142.47 + data_out1 = new((/nyear,nmon/),float)
142.48 + data_out2 = new((/nyear,nmon/),float)
142.49 + data_out3 = new((/nyear,nmon/),float)
142.50 + data_out4 = new((/nyear,nmon/),float)
142.51 + time_out = new((/nyear,nmon/),integer)
142.52 +
142.53 + do m = 0,nyear-1
142.54 + year = year_start + m
142.55 +
142.56 +; if (mod(year,4) .eq. 0) then
142.57 + if (year.eq.year_leap1.or.year.eq.year_leap2.or.year.eq.year_leap3) then
142.58 + hour_of_month = end_of_month2 * 24.
142.59 + else
142.60 + hour_of_month = end_of_month1 * 24.
142.61 + end if
142.62 +; print (hour_of_month)
142.63 +
142.64 +; input file
142.65 + fili = file_name_add+"."+station_name+"."+year+".nc"
142.66 + b = addfile(diri+fili,"r")
142.67 + print (fili)
142.68 +
142.69 +; co2 flux unit: umol m-2 s-1
142.70 + data1 = b->FCO2M
142.71 +; net radiation flux unit: W m-2
142.72 + data2 = b->RN
142.73 +; sensible heat flux unit: W m-2
142.74 + data3 = b->H
142.75 +; latent heat flux unit: W m-2
142.76 + data4 = b->LE
142.77 +
142.78 +; time unit: hour since 01-01 (mm-dd)
142.79 + time = b->time
142.80 +
142.81 + do n= 0,nmon-1
142.82 + if (n.eq.0) then
142.83 + timeL = 0.
142.84 + timeR = hour_of_month(0)
142.85 + else
142.86 + timeL = hour_of_month(n-1)
142.87 + timeR = hour_of_month(n)
142.88 + end if
142.89 +; print (timeL)
142.90 +; print (timeR)
142.91 +
142.92 + i = ind(time.ge.timeL .and. time.lt.timeR)
142.93 +; print (i)
142.94 +
142.95 + data_out1(m,n) = avg(data1(i))
142.96 + data_out2(m,n) = avg(data2(i))
142.97 + data_out3(m,n) = avg(data3(i))
142.98 + data_out4(m,n) = avg(data4(i))
142.99 +
142.100 + time_out(m,n) = year*100 + n + 1
142.101 +; print (time_out(m,n))
142.102 +
142.103 + delete (i)
142.104 + end do
142.105 + if (m.lt.nyear-1) then
142.106 + delete (data1)
142.107 + delete (data2)
142.108 + delete (data3)
142.109 + delete (data4)
142.110 + delete (time)
142.111 + end if
142.112 + end do
142.113 +
142.114 + data_out1!0 = "year"
142.115 + data_out1!1 = "month"
142.116 + data_out1@long_name = data1@long_name
142.117 + data_out1@units = data1@units
142.118 + data_out1@_FillValue = 1.e+36
142.119 +; print (data_out1)
142.120 +
142.121 + data_out2!0 = "year"
142.122 + data_out2!1 = "month"
142.123 + data_out2@long_name = data2@long_name
142.124 + data_out2@units = data2@units
142.125 + data_out2@_FillValue = 1.e+36
142.126 +; print (data_out2)
142.127 +
142.128 + data_out3!0 = "year"
142.129 + data_out3!1 = "month"
142.130 + data_out3@long_name = data3@long_name
142.131 + data_out3@units = data3@units
142.132 + data_out3@_FillValue = 1.e+36
142.133 +; print (data_out3)
142.134 +
142.135 + data_out4!0 = "year"
142.136 + data_out4!1 = "month"
142.137 + data_out4@long_name = data4@long_name
142.138 + data_out4@units = data4@units
142.139 + data_out4@_FillValue = 1.e+36
142.140 +; print (data_out4)
142.141 +
142.142 + time_out!0 = "year"
142.143 + time_out!1 = "month"
142.144 + time_out@long_name = "current date as yyyymm"
142.145 + time_out@units = "current date as yyyymm"
142.146 + print (time_out)
142.147 +
142.148 + lat_out!0 = "lat"
142.149 + lon_out!0 = "lon"
142.150 + lat_out@units = "degrees_north"
142.151 + lat_out@long_name = "Latitude"
142.152 + lon_out@units = "degrees_east"
142.153 + lon_out@long_name = "Longitude"
142.154 + print (lat_out)
142.155 + print (lon_out)
142.156 +
142.157 + c->lat = lat_out
142.158 + c->lon = lon_out
142.159 + c->date = time_out
142.160 + c->CO2_FLUX = data_out1
142.161 + c->RAD_FLUX = data_out2
142.162 + c->SH_FLUX = data_out3
142.163 + c->LH_FLUX = data_out4
142.164 +
142.165 +end
143.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
143.2 +++ b/energy/07.monthly_avg.ncl Mon Jan 26 22:08:20 2009 -0500
143.3 @@ -0,0 +1,169 @@
143.4 +;************************************************
143.5 +; Read half-hourly data and write monthly data
143.6 +; input data is : half-hourly
143.7 +;
143.8 +; output data is : CO2_flux, RAD_FLUX, SH_FLUX, LH_FLUX
143.9 +; date, lat, lon
143.10 +;************************************************
143.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
143.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
143.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
143.14 +;************************************************
143.15 +begin
143.16 +;!!!!!!!!!!!!!!!!!!!!!!!!!!!!
143.17 +; missing year 1999
143.18 +;!!!!!!!!!!!!!!!!!!!!!!!!!!!!
143.19 +
143.20 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
143.21 + station_name = "CastelPorziano"
143.22 + file_name_add = "carboeurope"
143.23 + year_start = 1997
143.24 + year_end = 2003
143.25 + year_leap1 = 1996
143.26 + year_leap2 = 2000
143.27 + year_leap3 = 2004
143.28 +
143.29 + lat_out = 41.7058
143.30 + lon_out = 12.3773
143.31 +
143.32 +; final output
143.33 + diro = dir_root + station_name + "/"
143.34 + filo = station_name+"_"+year_start+"-"+year_end+"_monthly.nc"
143.35 + c = addfile(diro+filo,"c")
143.36 + print (filo)
143.37 +
143.38 +; input dir
143.39 + diri = dir_root + station_name + "/"
143.40 +
143.41 + nyear = year_end - year_start + 1 - 1
143.42 + nmon = 12
143.43 + nlat = 1
143.44 + nlon = 1
143.45 +
143.46 +; day_of_month = (/31.,28.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31./)
143.47 + end_of_month1 = (/31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334.,365./)
143.48 + end_of_month2 = (/31.,60.,91.,121.,152.,182.,213.,244.,274.,305.,335.,366./)
143.49 +
143.50 + data_out1 = new((/nyear,nmon/),float)
143.51 + data_out2 = new((/nyear,nmon/),float)
143.52 + data_out3 = new((/nyear,nmon/),float)
143.53 + data_out4 = new((/nyear,nmon/),float)
143.54 + time_out = new((/nyear,nmon/),integer)
143.55 +
143.56 + do m = 0,nyear-1
143.57 + year = year_start + m
143.58 +
143.59 + if (m.ge.2) then
143.60 + year = year + 1
143.61 + end if
143.62 +
143.63 +; if (mod(year,4) .eq. 0) then
143.64 + if (year.eq.year_leap1.or.year.eq.year_leap2.or.year.eq.year_leap3) then
143.65 + hour_of_month = end_of_month2 * 24.
143.66 + else
143.67 + hour_of_month = end_of_month1 * 24.
143.68 + end if
143.69 +; print (hour_of_month)
143.70 +
143.71 +; input file
143.72 + fili = file_name_add+"."+station_name+"."+year+".nc"
143.73 + b = addfile(diri+fili,"r")
143.74 + print (fili)
143.75 +
143.76 +; co2 flux unit: umol m-2 s-1
143.77 + data1 = b->FCO2M
143.78 +; net radiation flux unit: W m-2
143.79 + data2 = b->RN
143.80 +; sensible heat flux unit: W m-2
143.81 + data3 = b->H
143.82 +; latent heat flux unit: W m-2
143.83 + data4 = b->LE
143.84 +
143.85 +; time unit: hour since 01-01 (mm-dd)
143.86 + time = b->time
143.87 +
143.88 + do n= 0,nmon-1
143.89 + if (n.eq.0) then
143.90 + timeL = 0.
143.91 + timeR = hour_of_month(0)
143.92 + else
143.93 + timeL = hour_of_month(n-1)
143.94 + timeR = hour_of_month(n)
143.95 + end if
143.96 +; print (timeL)
143.97 +; print (timeR)
143.98 +
143.99 + i = ind(time.ge.timeL .and. time.lt.timeR)
143.100 +; print (i)
143.101 +
143.102 + data_out1(m,n) = avg(data1(i))
143.103 + data_out2(m,n) = avg(data2(i))
143.104 + data_out3(m,n) = avg(data3(i))
143.105 + data_out4(m,n) = avg(data4(i))
143.106 +
143.107 + time_out(m,n) = year*100 + n + 1
143.108 +; print (time_out(m,n))
143.109 +
143.110 + delete (i)
143.111 + end do
143.112 + if (m.lt.nyear-1) then
143.113 + delete (data1)
143.114 + delete (data2)
143.115 + delete (data3)
143.116 + delete (data4)
143.117 + delete (time)
143.118 + end if
143.119 + end do
143.120 +
143.121 + data_out1!0 = "year"
143.122 + data_out1!1 = "month"
143.123 + data_out1@long_name = data1@long_name
143.124 + data_out1@units = data1@units
143.125 + data_out1@_FillValue = 1.e+36
143.126 +; print (data_out1)
143.127 +
143.128 + data_out2!0 = "year"
143.129 + data_out2!1 = "month"
143.130 + data_out2@long_name = data2@long_name
143.131 + data_out2@units = data2@units
143.132 + data_out2@_FillValue = 1.e+36
143.133 +; print (data_out2)
143.134 +
143.135 + data_out3!0 = "year"
143.136 + data_out3!1 = "month"
143.137 + data_out3@long_name = data3@long_name
143.138 + data_out3@units = data3@units
143.139 + data_out3@_FillValue = 1.e+36
143.140 +; print (data_out3)
143.141 +
143.142 + data_out4!0 = "year"
143.143 + data_out4!1 = "month"
143.144 + data_out4@long_name = data4@long_name
143.145 + data_out4@units = data4@units
143.146 + data_out4@_FillValue = 1.e+36
143.147 +; print (data_out4)
143.148 +
143.149 + time_out!0 = "year"
143.150 + time_out!1 = "month"
143.151 + time_out@long_name = "current date as yyyymm"
143.152 + time_out@units = "current date as yyyymm"
143.153 + print (time_out)
143.154 +
143.155 + lat_out!0 = "lat"
143.156 + lon_out!0 = "lon"
143.157 + lat_out@units = "degrees_north"
143.158 + lat_out@long_name = "Latitude"
143.159 + lon_out@units = "degrees_east"
143.160 + lon_out@long_name = "Longitude"
143.161 + print (lat_out)
143.162 + print (lon_out)
143.163 +
143.164 + c->lat = lat_out
143.165 + c->lon = lon_out
143.166 + c->date = time_out
143.167 + c->CO2_FLUX = data_out1
143.168 + c->RAD_FLUX = data_out2
143.169 + c->SH_FLUX = data_out3
143.170 + c->LH_FLUX = data_out4
143.171 +
143.172 +end
144.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
144.2 +++ b/energy/08.monthly_avg.ncl Mon Jan 26 22:08:20 2009 -0500
144.3 @@ -0,0 +1,162 @@
144.4 +;************************************************
144.5 +; Read half-hourly data and write monthly data
144.6 +; input data is : half-hourly
144.7 +;
144.8 +; output data is : CO2_flux, RAD_FLUX, SH_FLUX, LH_FLUX
144.9 +; date, lat, lon
144.10 +;************************************************
144.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
144.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
144.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
144.14 +;************************************************
144.15 +begin
144.16 +
144.17 + dir_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
144.18 + station_name = "Hyytiala"
144.19 + file_name_add = "carboeurope"
144.20 + year_start = 1996
144.21 + year_end = 2003
144.22 + year_leap1 = 1996
144.23 + year_leap2 = 2000
144.24 + year_leap3 = 2004
144.25 +
144.26 + lat_out = 61.8474
144.27 + lon_out = 24.2948
144.28 +
144.29 +; final output
144.30 + diro = dir_root + station_name + "/"
144.31 + filo = station_name+"_"+year_start+"-"+year_end+"_monthly.nc"
144.32 + c = addfile(diro+filo,"c")
144.33 + print (filo)
144.34 +
144.35 +; input dir
144.36 + diri = dir_root + station_name + "/"
144.37 +
144.38 + nyear = year_end - year_start + 1
144.39 + nmon = 12
144.40 + nlat = 1
144.41 + nlon = 1
144.42 +
144.43 +; day_of_month = (/31.,28.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31./)
144.44 + end_of_month1 = (/31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334.,365./)
144.45 + end_of_month2 = (/31.,60.,91.,121.,152.,182.,213.,244.,274.,305.,335.,366./)
144.46 +
144.47 + data_out1 = new((/nyear,nmon/),float)
144.48 + data_out2 = new((/nyear,nmon/),float)
144.49 + data_out3 = new((/nyear,nmon/),float)
144.50 + data_out4 = new((/nyear,nmon/),float)
144.51 + time_out = new((/nyear,nmon/),integer)
144.52 +
144.53 + do m = 0,nyear-1
144.54 + year = year_start + m
144.55 +
144.56 +; if (mod(year,4) .eq. 0) then
144.57 + if (year.eq.year_leap1.or.year.eq.year_leap2.or.year.eq.year_leap3) then
144.58 + hour_of_month = end_of_month2 * 24.
144.59 + else
144.60 + hour_of_month = end_of_month1 * 24.
144.61 + end if
144.62 +; print (hour_of_month)
144.63 +
144.64 +; input file
144.65 + fili = file_name_add+"."+station_name+"."+year+".nc"
144.66 + b = addfile(diri+fili,"r")
144.67 + print (fili)
144.68 +
144.69 +; co2 flux unit: umol m-2 s-1
144.70 + data1 = b->FCO2M
144.71 +; net radiation flux unit: W m-2
144.72 + data2 = b->RN
144.73 +; sensible heat flux unit: W m-2
144.74 + data3 = b->H
144.75 +; latent heat flux unit: W m-2
144.76 + data4 = b->LE
144.77 +
144.78 +; time unit: hour since 01-01 (mm-dd)
144.79 + time = b->time
144.80 +
144.81 + do n= 0,nmon-1
144.82 + if (n.eq.0) then
144.83 + timeL = 0.
144.84 + timeR = hour_of_month(0)
144.85 + else
144.86 + timeL = hour_of_month(n-1)
144.87 + timeR = hour_of_month(n)
144.88 + end if
144.89 +; print (timeL)
144.90 +; print (timeR)
144.91 +
144.92 + i = ind(time.ge.timeL .and. time.lt.timeR)
144.93 +; print (i)
144.94 +
144.95 + data_out1(m,n) = avg(data1(i))
144.96 + data_out2(m,n) = avg(data2(i))
144.97 + data_out3(m,n) = avg(data3(i))
144.98 + data_out4(m,n) = avg(data4(i))
144.99 +
144.100 + time_out(m,n) = year*100 + n + 1
144.101 +; print (time_out(m,n))
144.102 +
144.103 + delete (i)
144.104 + end do
144.105 + if (m.lt.nyear-1) then
144.106 + delete (data1)
144.107 + delete (data2)
144.108 + delete (data3)
144.109 + delete (data4)
144.110 + delete (time)
144.111 + end if
144.112 + end do
144.113 +
144.114 + data_out1!0 = "year"
144.115 + data_out1!1 = "month"
144.116 + data_out1@long_name = data1@long_name
144.117 + data_out1@units = data1@units
144.118 + data_out1@_FillValue = 1.e+36
144.119 +; print (data_out1)
144.120 +
144.121 + data_out2!0 = "year"
144.122 + data_out2!1 = "month"
144.123 + data_out2@long_name = data2@long_name
144.124 + data_out2@units = data2@units
144.125 + data_out2@_FillValue = 1.e+36
144.126 +; print (data_out2)
144.127 +
144.128 + data_out3!0 = "year"
144.129 + data_out3!1 = "month"
144.130 + data_out3@long_name = data3@long_name
144.131 + data_out3@units = data3@units
144.132 + data_out3@_FillValue = 1.e+36
144.133 +; print (data_out3)
144.134 +
144.135 + data_out4!0 = "year"
144.136 + data_out4!1 = "month"
144.137 + data_out4@long_name = data4@long_name
144.138 + data_out4@units = data4@units
144.139 + data_out4@_FillValue = 1.e+36
144.140 +; print (data_out4)
144.141 +
144.142 + time_out!0 = "year"
144.143 + time_out!1 = "month"
144.144 + time_out@long_name = "current date as yyyymm"
144.145 + time_out@units = "current date as yyyymm"
144.146 + print (time_out)
144.147 +
144.148 + lat_out!0 = "lat"
144.149 + lon_out!0 = "lon"
144.150 + lat_out@units = "degrees_north"
144.151 + lat_out@long_name = "Latitude"
144.152 + lon_out@units = "degrees_east"
144.153 + lon_out@long_name = "Longitude"
144.154 + print (lat_out)
144.155 + print (lon_out)
144.156 +
144.157 + c->lat = lat_out
144.158 + c->lon = lon_out
144.159 + c->date = time_out
144.160 + c->CO2_FLUX = data_out1
144.161 + c->RAD_FLUX = data_out2
144.162 + c->SH_FLUX = data_out3
144.163 + c->LH_FLUX = data_out4
144.164 +
144.165 +end
145.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
145.2 +++ b/energy/97.all.ncl Mon Jan 26 22:08:20 2009 -0500
145.3 @@ -0,0 +1,421 @@
145.4 +; ***********************************************
145.5 +; using gsn_table for all
145.6 +; output: line plot for each site (4 fields)
145.7 +; table for M_score
145.8 +; ***********************************************
145.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
145.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
145.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
145.12 +;load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
145.13 +;************************************************
145.14 +begin
145.15 +
145.16 + plot_type = "ps"
145.17 + plot_type_new = "png"
145.18 +
145.19 +;************************************************
145.20 +; read model data
145.21 +;************************************************
145.22 + model_name = "newcn"
145.23 + film = "newcn05_ncep_1i_MONS_climo_lnd.nc"
145.24 +
145.25 +; model_name = "b30.061n"
145.26 +; film = "b30.061n_1995-2004_MONS_climo_lnd.nc"
145.27 +;--------------------------------------------
145.28 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
145.29 + fm = addfile(dirm+film,"r")
145.30 +
145.31 + xm = fm->lon
145.32 + ym = fm->lat
145.33 + nlat = dimsizes(ym)
145.34 + nlon = dimsizes(xm)
145.35 +
145.36 + nmon = 12
145.37 + nfield = 4
145.38 +
145.39 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
145.40 +
145.41 +; change to unit of observed (u mol/m2/s)
145.42 +; Model_units [=] gC/m2/s
145.43 +; 12. = molecular weight of C
145.44 +; u mol = 1e-6 mol
145.45 + data = fm->NEE
145.46 +
145.47 + factor = 1e6/12.
145.48 +
145.49 + data_mod0(0,:,:,:) = data(:,:,:) * factor
145.50 + delete (data)
145.51 +; data = fm->LATENT
145.52 + data1 = fm->FCEV
145.53 + data2 = fm->FCTR
145.54 + data3 = fm->FGEV
145.55 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
145.56 + delete (data1)
145.57 + delete (data2)
145.58 + delete (data3)
145.59 +
145.60 + data = fm->FSH
145.61 + data_mod0(3,:,:,:) = data(:,:,:)
145.62 + delete (data)
145.63 +
145.64 +; data = fm->NETRAD
145.65 + data1 = fm->FSA
145.66 + data2 = fm->FIRA
145.67 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)-data_mod0(2,:,:,:)-data_mod0(3,:,:,:)
145.68 + delete (data1)
145.69 + delete (data2)
145.70 +
145.71 +; printVarSummary (data_mod0)
145.72 +;************************************************
145.73 +; read in data: observed
145.74 +;************************************************
145.75 + station = (/"BOREAS_NSA_OBS" \
145.76 + ,"CastelPorziano" \
145.77 + ,"Hyytiala" \
145.78 + ,"Kaamanen" \
145.79 + ,"LBA_Tapajos_KM67" \
145.80 + ,"Lethbridge" \
145.81 + ,"Tharandt" \
145.82 + ,"Vielsalm" \
145.83 + /)
145.84 +
145.85 + year_ob = (/"1994-2004" \
145.86 + ,"1997-2003" \
145.87 + ,"1996-2003" \
145.88 + ,"2000-2003" \
145.89 + ,"2002-2005" \
145.90 + ,"1999-2004" \
145.91 + ,"1996-2003" \
145.92 + ,"1998-2003" \
145.93 + /)
145.94 +
145.95 + field = (/"CO2 Flux" \
145.96 + ,"Net Radiation" \
145.97 + ,"Latent Heat" \
145.98 + ,"Sensible Heat" \
145.99 + /)
145.100 +
145.101 + nstation = dimsizes(station)
145.102 + nmon = 12
145.103 + nfield = dimsizes(field)
145.104 +
145.105 + data_ob = new ((/nstation, nfield, nmon/),float)
145.106 + lat_ob = new ((/nstation/),float)
145.107 + lon_ob = new ((/nstation/),float)
145.108 +
145.109 + diri_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
145.110 +
145.111 + do n = 0,nstation-1
145.112 + diri = diri_root + station(n)+"/"
145.113 + fili = station(n)+"_"+year_ob(n)+"_monthly.nc"
145.114 + g = addfile (diri+fili,"r")
145.115 +
145.116 + lon_ob(n) = g->lon
145.117 + lat_ob(n) = g->lat
145.118 +
145.119 + data = g->CO2_FLUX
145.120 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
145.121 + delete (data)
145.122 +
145.123 + data = g->RAD_FLUX
145.124 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
145.125 + delete (data)
145.126 +
145.127 + data = g->LH_FLUX
145.128 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
145.129 + delete (data)
145.130 +
145.131 + data = g->SH_FLUX
145.132 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
145.133 + delete (data)
145.134 +
145.135 + delete (g)
145.136 + end do
145.137 +
145.138 +;print (lat_ob)
145.139 +;print (lon_ob)
145.140 +;printVarSummary (data_ob)
145.141 +
145.142 +;************************************************************
145.143 +; interpolate model data into observed station
145.144 +; note: model is 0-360E, 90S-90N
145.145 +;************************************************************
145.146 +
145.147 +; to be able to handle observation at (-89.98,-24.80)
145.148 +; print (ym(0))
145.149 + ym(0) = -90.
145.150 +
145.151 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob,lat_ob,0)
145.152 +
145.153 + delete (data_mod0)
145.154 + yy!0 = "field"
145.155 + data_mod = yy(pts|:,field|:,time|:)
145.156 +; printVarSummary (data_mod)
145.157 +
145.158 +;************************************************************
145.159 +; compute correlation coef and M score
145.160 +;************************************************************
145.161 +
145.162 + score_max = 5.
145.163 +
145.164 + ccr = new ((/nstation, nfield/),float)
145.165 + M_score = new ((/nstation, nfield/),float)
145.166 +
145.167 + do n=0,nstation-1
145.168 + do m=0,nfield-1
145.169 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
145.170 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
145.171 + M_score(n,m) = (1. -(bias/nmon)) * score_max
145.172 + end do
145.173 + end do
145.174 +
145.175 +;*******************************************************************
145.176 +; for station line plot
145.177 +;*******************************************************************
145.178 +
145.179 +; for x-axis in xyplot
145.180 + mon = ispan(1,12,1)
145.181 + mon@long_name = "month"
145.182 +
145.183 + res = True ; plot mods desired
145.184 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
145.185 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
145.186 +;-------------------------------------------------------------------------
145.187 +; Add a boxed legend using the more simple method
145.188 +
145.189 + res@pmLegendDisplayMode = "Always"
145.190 +; res@pmLegendWidthF = 0.1
145.191 + res@pmLegendWidthF = 0.08
145.192 + res@pmLegendHeightF = 0.06
145.193 +; res@pmLegendOrthogonalPosF = -1.17
145.194 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
145.195 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
145.196 +
145.197 +; res@pmLegendParallelPosF = 0.18
145.198 + res@pmLegendParallelPosF = 0.23 ;(rightward)
145.199 +
145.200 +; res@lgPerimOn = False
145.201 + res@lgLabelFontHeightF = 0.015
145.202 + res@xyExplicitLegendLabels = (/"observed",model_name/)
145.203 +;-------------------------------------------------------------------
145.204 +; for panel plot
145.205 + res@gsnFrame = False ; Do not draw plot
145.206 + res@gsnDraw = False ; Do not advance frame
145.207 +
145.208 + pres = True ; panel plot mods desired
145.209 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
145.210 + ; indiv. plots in panel
145.211 + pres@gsnMaximize = True ; fill the page
145.212 +;-------------------------------------------------------------------
145.213 +
145.214 + plot_data = new((/2,12/),float)
145.215 + plot_data!0 = "case"
145.216 + plot_data!1 = "month"
145.217 +
145.218 + do n = 0,nstation-1
145.219 +;----------------------------
145.220 +; for observed
145.221 +
145.222 + plot_name = station(n)+"_ob"
145.223 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
145.224 + res@tiMainString = title
145.225 +
145.226 + wks = gsn_open_wks (plot_type,plot_name)
145.227 + plot=new(4,graphic) ; create graphic array
145.228 +
145.229 + plot_data(0,:) = (/data_ob (n,0,:)/)
145.230 + plot_data@long_name = field(0)
145.231 + plot(0)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 1
145.232 +
145.233 + plot_data(0,:) = (/data_ob (n,1,:)/)
145.234 + plot_data@long_name = field(1)
145.235 + plot(1)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 2
145.236 +
145.237 + plot_data(0,:) = (/data_ob (n,2,:)/)
145.238 + plot_data@long_name = field(2)
145.239 + plot(2)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 3
145.240 +
145.241 + plot_data(0,:) = (/data_ob (n,3,:)/)
145.242 + plot_data@long_name = field(3)
145.243 + plot(3)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 4
145.244 +
145.245 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
145.246 +
145.247 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
145.248 + system("rm "+plot_name+"."+plot_type)
145.249 + clear (wks)
145.250 + delete (plot)
145.251 +;----------------------------
145.252 +; for model_vs_ob
145.253 +
145.254 + plot_name = station(n)+"_model_vs_ob"
145.255 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
145.256 + res@tiMainString = title
145.257 +
145.258 + wks = gsn_open_wks (plot_type,plot_name)
145.259 + plot=new(4,graphic) ; create graphic array
145.260 +
145.261 + plot_data(0,:) = (/data_ob (n,0,:)/)
145.262 + plot_data(1,:) = (/data_mod(n,0,:)/)
145.263 + plot_data@long_name = field(0)
145.264 + plot(0)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 1
145.265 +
145.266 + plot_data(0,:) = (/data_ob (n,1,:)/)
145.267 + plot_data(1,:) = (/data_mod(n,1,:)/)
145.268 + plot_data@long_name = field(1)
145.269 + plot(1)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 2
145.270 +
145.271 + plot_data(0,:) = (/data_ob (n,2,:)/)
145.272 + plot_data(1,:) = (/data_mod(n,2,:)/)
145.273 + plot_data@long_name = field(2)
145.274 + plot(2)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 3
145.275 +
145.276 + plot_data(0,:) = (/data_ob (n,3,:)/)
145.277 + plot_data(1,:) = (/data_mod(n,3,:)/)
145.278 + plot_data@long_name = field(3)
145.279 + plot(3)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 4
145.280 +
145.281 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
145.282 +
145.283 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
145.284 + system("rm "+plot_name+"."+plot_type)
145.285 + clear (wks)
145.286 + delete (plot)
145.287 + end do
145.288 +
145.289 +;*******************************************************************
145.290 +; for table of site score
145.291 +;*******************************************************************
145.292 +
145.293 + table_length = 0.8
145.294 +
145.295 +; table header name
145.296 + table_header_name = "Site"
145.297 +
145.298 +; column (not including header column)
145.299 + col_header = (/"Latitude","Longitude","observed" \
145.300 + ,"CO2 Flux","Net Radiation","Latent Heat" \
145.301 + ,"Sensible Heat","Average" \
145.302 + /)
145.303 + ncol = dimsizes(col_header)
145.304 +
145.305 +; row (not including header row)
145.306 + nrow = nstation + 1
145.307 + row_header = new ((/nrow/),string )
145.308 + row_header(0:nstation-1) = station(:)
145.309 + row_header(nrow-1) = "All Sites"
145.310 +
145.311 +; Table header
145.312 + ncr1 = (/1,1/) ; 1 row, 1 column
145.313 + x1 = (/0.005,0.15/) ; Start and end X
145.314 + y1 = (/0.800,0.895/) ; Start and end Y
145.315 + text1 = table_header_name
145.316 + res1 = True
145.317 + res1@txFontHeightF = 0.03
145.318 + res1@gsFillColor = "CornFlowerBlue"
145.319 +
145.320 +; Column header (equally space in x2)
145.321 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
145.322 + x2 = (/x1(1),0.995/) ; start from end of x1
145.323 + y2 = y1 ; same as y1
145.324 + text2 = col_header
145.325 + res2 = True
145.326 + res2@txFontHeightF = 0.010
145.327 + res2@gsFillColor = "Gray"
145.328 +
145.329 +; Row header (equally space in y2)
145.330 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
145.331 + x3 = x1 ; same as x1
145.332 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
145.333 + text3 = row_header
145.334 + res3 = True
145.335 + res3@txFontHeightF = 0.010
145.336 + res3@gsFillColor = "Gray"
145.337 +
145.338 +; Main table body
145.339 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
145.340 + x4 = x2 ; Start and end x
145.341 + y4 = y3 ; Start and end Y
145.342 + text4 = new((/nrow,ncol/),string)
145.343 +
145.344 + color_fill4 = new((/nrow,ncol/),string)
145.345 + color_fill4 = "white"
145.346 + color_fill4(:,ncol-1) = "grey"
145.347 + color_fill4(nrow-1,:) = "green"
145.348 +
145.349 + res4 = True ; Set up resource list
145.350 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
145.351 + res4@txFontHeightF = 0.015
145.352 + res4@gsFillColor = color_fill4
145.353 +
145.354 + delete (color_fill4)
145.355 +;-------------------------------------------------------------------
145.356 +; for table value
145.357 +
145.358 + do n = 0,nrow-2
145.359 + text4(n,0) = sprintf("%5.2f", lat_ob(n))
145.360 + text4(n,1) = sprintf("%5.2f", lon_ob(n))
145.361 + text4(n,2) = year_ob(n)
145.362 + text4(n,3) = sprintf("%5.2f", M_score(n,0)) ; CO2 Flux
145.363 + text4(n,4) = sprintf("%5.2f", M_score(n,1)) ; Net Radiation
145.364 + text4(n,5) = sprintf("%5.2f", M_score(n,2)) ; Latent Heat
145.365 + text4(n,6) = sprintf("%5.2f", M_score(n,3)) ; Sensible Heat
145.366 + text4(n,7) = sprintf("%5.2f", avg(M_score(n,:))) ; avg all fields
145.367 + end do
145.368 +
145.369 +; for the last row
145.370 +
145.371 + M_co2 = avg(M_score(:,0))
145.372 + M_rad = avg(M_score(:,1))
145.373 + M_lh = avg(M_score(:,2))
145.374 + M_sh = avg(M_score(:,3))
145.375 + M_all = M_co2+ M_rad +M_lh + M_sh
145.376 +
145.377 + text4(nrow-1,0) = "-"
145.378 + text4(nrow-1,1) = "-"
145.379 + text4(nrow-1,2) = "-"
145.380 + text4(nrow-1,3) = sprintf("%5.2f", M_co2) ; avg all sites
145.381 + text4(nrow-1,4) = sprintf("%5.2f", M_rad) ; avg all sites
145.382 + text4(nrow-1,5) = sprintf("%5.2f", M_lh ) ; avg all sites
145.383 + text4(nrow-1,6) = sprintf("%5.2f", M_sh ) ; avg all sites
145.384 + text4(nrow-1,7) = sprintf("%5.2f", M_all) ; avg all sites
145.385 +
145.386 + print (M_co2)
145.387 + print (M_rad)
145.388 + print (M_lh )
145.389 + print (M_sh)
145.390 + print (M_all)
145.391 +;---------------------------------------------------------------------------
145.392 +
145.393 + plot_name = "table_site_score"
145.394 +
145.395 + wks = gsn_open_wks (plot_type,plot_name)
145.396 +;------------------------------------------
145.397 +; for table title
145.398 +
145.399 + gRes = True
145.400 + gRes@txFontHeightF = 0.02
145.401 +; gRes@txAngleF = 90
145.402 +
145.403 + title_text = "Model " + model_name + " M_Score"
145.404 +
145.405 + gsn_text_ndc(wks,title_text,0.50,0.95,gRes)
145.406 +;------------------------------------------
145.407 +
145.408 + gsn_table(wks,ncr1,x1,y1,text1,res1)
145.409 + gsn_table(wks,ncr2,x2,y2,text2,res2)
145.410 + gsn_table(wks,ncr3,x3,y3,text3,res3)
145.411 + gsn_table(wks,ncr4,x4,y4,text4,res4)
145.412 +
145.413 + frame(wks)
145.414 +
145.415 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
145.416 + system("rm "+plot_name+"."+plot_type)
145.417 +;-------------------------------------------------------------------
145.418 + temp_name = "temp." + model_name
145.419 + system("mkdir -p " + temp_name)
145.420 + system("mv *.png " + temp_name)
145.421 + system("tar cf "+ temp_name +".tar " + temp_name)
145.422 +;-------------------------------------------------------------------
145.423 +
145.424 +end
146.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
146.2 +++ b/energy/99.all.ncl Mon Jan 26 22:08:20 2009 -0500
146.3 @@ -0,0 +1,553 @@
146.4 +;************************************************************
146.5 +; required command line input parameters:
146.6 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
146.7 +;
146.8 +; using gsn_table for all
146.9 +; output: line plot for each site (4 fields)
146.10 +; table for M_score
146.11 +;************************************************************
146.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
146.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
146.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
146.15 +;************************************************************
146.16 +procedure set_line(lines:string,nline:integer,newlines:string)
146.17 +begin
146.18 +; add line to ascci/html file
146.19 +
146.20 + nnewlines = dimsizes(newlines)
146.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
146.22 + print("set_line: bad index, not setting anything.")
146.23 + return
146.24 + end if
146.25 + lines(nline:nline+nnewlines-1) = newlines
146.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
146.27 + nline = nline + nnewlines
146.28 + return
146.29 +end
146.30 +;*************************************************************
146.31 +begin
146.32 +
146.33 + plot_type = "ps"
146.34 + plot_type_new = "png"
146.35 +
146.36 +;************************************************
146.37 +; read model data
146.38 +;************************************************
146.39 +
146.40 +; from command line inputs
146.41 +
146.42 +;--------------------------------------------------
146.43 +; edit table.html of current model for movel1_vs_model2
146.44 +
146.45 + if (isvar("compare")) then
146.46 + html_name2 = compare+"/table.html"
146.47 + html_new2 = html_name2 +".new"
146.48 +
146.49 +; the following only needs to execute once
146.50 +; system("sed 1,/model_nameA/s//"+model_name+"/ "+html_name2+" > "+html_new2+";"+ \
146.51 +; "mv -f "+html_new2+" "+html_name2+";"+ \
146.52 +; "sed 1,/model_nameB/s//"+model_name+"/ "+html_name2+" > "+html_new2+";"+ \
146.53 +; "mv -f "+html_new2+" "+html_name2+";"+ \
146.54 +; "sed s#"+modeln+"#"+model_name+"# "+html_name2+" > "+html_new2+";"+ \
146.55 +; "mv -f "+html_new2+" "+html_name2)
146.56 + end if
146.57 +
146.58 +;-------------------------------------
146.59 +; edit table.html for current model
146.60 +
146.61 + html_name = model_name+"/table.html"
146.62 + html_new = html_name +".new"
146.63 +
146.64 +; the following only needs to execute once
146.65 +; system("sed s#model_name#"+model_name+"# "+html_name+" > "+html_new+";"+ \
146.66 +; "mv -f "+html_new+" "+html_name)
146.67 +;------------------------------------------------
146.68 + fm = addfile(dirm+film2,"r")
146.69 +
146.70 + xm = fm->lon
146.71 + ym = fm->lat
146.72 +;------------------------------------------------
146.73 + nlat = dimsizes(ym)
146.74 + nlon = dimsizes(xm)
146.75 +
146.76 +; for 4 fields, 12-monthly
146.77 + nmon = 12
146.78 + nfield = 4
146.79 +
146.80 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
146.81 +
146.82 +; change to unit of observed (u mol/m2/s)
146.83 +; Model_units [=] gC/m2/s
146.84 +; 12. = molecular weight of C
146.85 +; u mol = 1e-6 mol
146.86 + factor = 1e6 /12.
146.87 +
146.88 +if (ENERGY .eq. "old") then
146.89 +
146.90 + data = fm->NEE
146.91 + data_mod0(0,:,:,:) = data(:,:,:) * factor
146.92 + delete (data)
146.93 +
146.94 +; data = fm->LATENT
146.95 + data1 = fm->FCEV
146.96 + data2 = fm->FCTR
146.97 + data3 = fm->FGEV
146.98 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
146.99 + delete (data1)
146.100 + delete (data2)
146.101 + delete (data3)
146.102 +
146.103 +; data = fm->SENSIBLE
146.104 + data = fm->FSH
146.105 + data_mod0(3,:,:,:) = data(:,:,:)
146.106 + delete (data)
146.107 +
146.108 +; data = fm->NETRAD
146.109 + data1 = fm->FSA
146.110 + data2 = fm->FIRA
146.111 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)-data_mod0(2,:,:,:)-data_mod0(3,:,:,:)
146.112 + delete (data1)
146.113 + delete (data2)
146.114 +
146.115 +else
146.116 +
146.117 + data = fm->NEE
146.118 + data_mod0(0,:,:,:) = data(:,:,:) * factor
146.119 + delete (data)
146.120 +
146.121 + data = fm->NETRAD
146.122 + data_mod0(1,:,:,:) = data(:,:,:)
146.123 + delete (data)
146.124 +
146.125 + data = fm->LATENT
146.126 + data_mod0(2,:,:,:) = data(:,:,:)
146.127 + delete (data)
146.128 +
146.129 + data = fm->SENSIBLE
146.130 + data_mod0(3,:,:,:) = data(:,:,:)
146.131 + delete (data)
146.132 +end if
146.133 +
146.134 +;************************************************
146.135 +; read data: observed
146.136 +;************************************************
146.137 +
146.138 + station = (/"BOREAS_NSA_OBS" \
146.139 + ,"CastelPorziano" \
146.140 + ,"Hyytiala" \
146.141 + ,"Kaamanen" \
146.142 + ,"LBA_Tapajos_KM67" \
146.143 + ,"Lethbridge" \
146.144 + ,"Tharandt" \
146.145 + ,"Vielsalm" \
146.146 + /)
146.147 +
146.148 + year_ob = (/"1994-2004" \
146.149 + ,"1997-2003" \
146.150 + ,"1996-2003" \
146.151 + ,"2000-2003" \
146.152 + ,"2002-2005" \
146.153 + ,"1999-2004" \
146.154 + ,"1996-2003" \
146.155 + ,"1998-2003" \
146.156 + /)
146.157 +
146.158 + field = (/"CO2 Flux" \
146.159 + ,"Net Radiation" \
146.160 + ,"Latent Heat" \
146.161 + ,"Sensible Heat" \
146.162 + /)
146.163 +
146.164 + nstation = dimsizes(station)
146.165 + nmon = 12
146.166 + nfield = dimsizes(field)
146.167 +
146.168 + data_ob = new ((/nstation, nfield, nmon/),float)
146.169 + lat_ob = new ((/nstation/),float)
146.170 + lon_ob = new ((/nstation/),float)
146.171 +
146.172 + diri_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
146.173 +
146.174 + do n = 0,nstation-1
146.175 + diri = diri_root + station(n)+"/"
146.176 + fili = station(n)+"_"+year_ob(n)+"_monthly.nc"
146.177 + g = addfile (diri+fili,"r")
146.178 +
146.179 + lon_ob(n) = g->lon
146.180 + lat_ob(n) = g->lat
146.181 +
146.182 + data = g->CO2_FLUX
146.183 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
146.184 + delete (data)
146.185 +
146.186 + data = g->RAD_FLUX
146.187 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
146.188 + delete (data)
146.189 +
146.190 + data = g->LH_FLUX
146.191 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
146.192 + delete (data)
146.193 +
146.194 + data = g->SH_FLUX
146.195 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
146.196 + delete (data)
146.197 +
146.198 + delete (g)
146.199 + end do
146.200 +
146.201 +;************************************************************
146.202 +; interpolate model data into observed station
146.203 +; note: model is 0-360E, 90S-90N
146.204 +;************************************************************
146.205 +
146.206 +; to be able to handle observation at (-89.98,-24.80)
146.207 + ym(0) = -90.
146.208 +
146.209 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob,lat_ob,0)
146.210 +
146.211 + delete (data_mod0)
146.212 + yy!0 = "field"
146.213 + data_mod = yy(pts|:,field|:,time|:)
146.214 +
146.215 +;************************************************************
146.216 +; compute correlation coef and M score
146.217 +;************************************************************
146.218 +
146.219 + score_max = 5.
146.220 +
146.221 + ccr = new ((/nstation, nfield/),float)
146.222 + M_score = new ((/nstation, nfield/),float)
146.223 +
146.224 + do n=0,nstation-1
146.225 + do m=0,nfield-1
146.226 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
146.227 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
146.228 + M_score(n,m) = (1. -(bias/nmon)) * score_max
146.229 + end do
146.230 + end do
146.231 +
146.232 + M_co2 = avg(M_score(:,0))
146.233 + M_rad = avg(M_score(:,1))
146.234 + M_lh = avg(M_score(:,2))
146.235 + M_sh = avg(M_score(:,3))
146.236 + M_all = M_co2+ M_rad +M_lh + M_sh
146.237 +
146.238 + M_energy_co2 = sprintf("%.2f", M_co2)
146.239 + M_energy_rad = sprintf("%.2f", M_rad)
146.240 + M_energy_lh = sprintf("%.2f", M_lh )
146.241 + M_energy_sh = sprintf("%.2f", M_sh )
146.242 + M_energy_all = sprintf("%.2f", M_all)
146.243 +
146.244 +;*******************************************************************
146.245 +; for station line plot
146.246 +;*******************************************************************
146.247 +
146.248 +; for x-axis in xyplot
146.249 + mon = ispan(1,12,1)
146.250 + mon@long_name = "month"
146.251 +
146.252 + res = True ; plot mods desired
146.253 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
146.254 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
146.255 +;-------------------------------------------------------------------------
146.256 +; Add a boxed legend using the more simple method
146.257 +
146.258 + res@pmLegendDisplayMode = "Always"
146.259 +; res@pmLegendWidthF = 0.1
146.260 + res@pmLegendWidthF = 0.08
146.261 + res@pmLegendHeightF = 0.06
146.262 +; res@pmLegendOrthogonalPosF = -1.17
146.263 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
146.264 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
146.265 +
146.266 +; res@pmLegendParallelPosF = 0.18
146.267 + res@pmLegendParallelPosF = 0.23 ;(rightward)
146.268 +
146.269 +; res@lgPerimOn = False
146.270 + res@lgLabelFontHeightF = 0.015
146.271 + res@xyExplicitLegendLabels = (/"observed",model_name/)
146.272 +;-------------------------------------------------------------------
146.273 +; for panel plot
146.274 + res@gsnFrame = False ; Do not draw plot
146.275 + res@gsnDraw = False ; Do not advance frame
146.276 +
146.277 + pres = True ; panel plot mods desired
146.278 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
146.279 + ; indiv. plots in panel
146.280 + pres@gsnMaximize = True ; fill the page
146.281 +;-------------------------------------------------------------------
146.282 +
146.283 + plot_data = new((/2,12/),float)
146.284 + plot_data!0 = "case"
146.285 + plot_data!1 = "month"
146.286 +
146.287 + do n = 0,nstation-1
146.288 +;----------------------------
146.289 +; for observed
146.290 +
146.291 + plot_name = station(n)+"_ob"
146.292 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
146.293 + res@tiMainString = title
146.294 +
146.295 + wks = gsn_open_wks (plot_type,plot_name)
146.296 + plot=new(4,graphic) ; create graphic array
146.297 +
146.298 + plot_data(0,:) = (/data_ob (n,0,:)/)
146.299 + plot_data@long_name = field(0)
146.300 + plot(0)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 1
146.301 +
146.302 + plot_data(0,:) = (/data_ob (n,1,:)/)
146.303 + plot_data@long_name = field(1)
146.304 + plot(1)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 2
146.305 +
146.306 + plot_data(0,:) = (/data_ob (n,2,:)/)
146.307 + plot_data@long_name = field(2)
146.308 + plot(2)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 3
146.309 +
146.310 + plot_data(0,:) = (/data_ob (n,3,:)/)
146.311 + plot_data@long_name = field(3)
146.312 + plot(3)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 4
146.313 +
146.314 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
146.315 +
146.316 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
146.317 + "rm "+plot_name+"."+plot_type)
146.318 +
146.319 + clear (wks)
146.320 + delete (plot)
146.321 +;----------------------------
146.322 +; for model_vs_ob
146.323 +
146.324 + plot_name = station(n)+"_model_vs_ob"
146.325 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
146.326 + res@tiMainString = title
146.327 +
146.328 + wks = gsn_open_wks (plot_type,plot_name)
146.329 + plot=new(4,graphic) ; create graphic array
146.330 +
146.331 + plot_data(0,:) = (/data_ob (n,0,:)/)
146.332 + plot_data(1,:) = (/data_mod(n,0,:)/)
146.333 + plot_data@long_name = field(0)
146.334 + plot(0)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 1
146.335 +
146.336 + plot_data(0,:) = (/data_ob (n,1,:)/)
146.337 + plot_data(1,:) = (/data_mod(n,1,:)/)
146.338 + plot_data@long_name = field(1)
146.339 + plot(1)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 2
146.340 +
146.341 + plot_data(0,:) = (/data_ob (n,2,:)/)
146.342 + plot_data(1,:) = (/data_mod(n,2,:)/)
146.343 + plot_data@long_name = field(2)
146.344 + plot(2)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 3
146.345 +
146.346 + plot_data(0,:) = (/data_ob (n,3,:)/)
146.347 + plot_data(1,:) = (/data_mod(n,3,:)/)
146.348 + plot_data@long_name = field(3)
146.349 + plot(3)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 4
146.350 +
146.351 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
146.352 +
146.353 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
146.354 + "rm "+plot_name+"."+plot_type)
146.355 +
146.356 + clear (wks)
146.357 + delete (plot)
146.358 + end do
146.359 +
146.360 +;*******************************************************************
146.361 +; html table of site: observed
146.362 +;*******************************************************************
146.363 + output_html = "line_ob.html"
146.364 +
146.365 + header = (/"<HTML>" \
146.366 + ,"<HEAD>" \
146.367 + ,"<TITLE>CLAMP metrics</TITLE>" \
146.368 + ,"</HEAD>" \
146.369 + ,"<H1>Energy at Site: Observation</H1>" \
146.370 + /)
146.371 + footer = "</HTML>"
146.372 +
146.373 + table_header = (/ \
146.374 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
146.375 + ,"<tr>" \
146.376 + ," <th bgcolor=DDDDDD >Site Name</th>" \
146.377 + ," <th bgcolor=DDDDDD >Latitude</th>" \
146.378 + ," <th bgcolor=DDDDDD >Longitude</th>" \
146.379 + ," <th bgcolor=DDDDDD >Observed</th>" \
146.380 + ,"</tr>" \
146.381 + /)
146.382 + table_footer = "</table>"
146.383 + row_header = "<tr>"
146.384 + row_footer = "</tr>"
146.385 +
146.386 + lines = new(50000,string)
146.387 + nline = 0
146.388 +
146.389 + set_line(lines,nline,header)
146.390 + set_line(lines,nline,table_header)
146.391 +;-----------------------------------------------
146.392 +; row of table
146.393 +
146.394 + do n = 0,nstation-1
146.395 + set_line(lines,nline,row_header)
146.396 +
146.397 + txt0 = station(n)
146.398 + txt1 = sprintf("%5.2f", lat_ob(n))
146.399 + txt2 = sprintf("%5.2f", lon_ob(n))
146.400 + txt3 = year_ob(n)
146.401 +
146.402 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
146.403 + set_line(lines,nline,"<th>"+txt1+"</th>")
146.404 + set_line(lines,nline,"<th>"+txt2+"</th>")
146.405 + set_line(lines,nline,"<th>"+txt3+"</th>")
146.406 +
146.407 + set_line(lines,nline,row_footer)
146.408 + end do
146.409 +;-----------------------------------------------
146.410 + set_line(lines,nline,table_footer)
146.411 + set_line(lines,nline,footer)
146.412 +
146.413 +; Now write to an HTML file.
146.414 + idx = ind(.not.ismissing(lines))
146.415 + if(.not.any(ismissing(idx))) then
146.416 + asciiwrite(output_html,lines(idx))
146.417 + else
146.418 + print ("error?")
146.419 + end if
146.420 + delete (idx)
146.421 +
146.422 +;*******************************************************************
146.423 +; score and line table : model vs observed
146.424 +;*******************************************************************
146.425 + output_html = "score+line_vs_ob.html"
146.426 +
146.427 + header = (/"<HTML>" \
146.428 + ,"<HEAD>" \
146.429 + ,"<TITLE>CLAMP metrics</TITLE>" \
146.430 + ,"</HEAD>" \
146.431 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
146.432 + /)
146.433 + footer = "</HTML>"
146.434 +
146.435 + delete (table_header)
146.436 + table_header = (/ \
146.437 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
146.438 + ,"<tr>" \
146.439 + ," <th bgcolor=DDDDDD >Site Name</th>" \
146.440 + ," <th bgcolor=DDDDDD >Latitude</th>" \
146.441 + ," <th bgcolor=DDDDDD >Longitude</th>" \
146.442 + ," <th bgcolor=DDDDDD >Observed</th>" \
146.443 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
146.444 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
146.445 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
146.446 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
146.447 + ," <th bgcolor=DDDDDD >Average</th>" \
146.448 + ,"</tr>" \
146.449 + /)
146.450 + table_footer = "</table>"
146.451 + row_header = "<tr>"
146.452 + row_footer = "</tr>"
146.453 +
146.454 + lines = new(50000,string)
146.455 + nline = 0
146.456 +
146.457 + set_line(lines,nline,header)
146.458 + set_line(lines,nline,table_header)
146.459 +;-----------------------------------------------
146.460 +; row of table
146.461 +
146.462 + do n = 0,nstation-1
146.463 + set_line(lines,nline,row_header)
146.464 +
146.465 + txt0 = station(n)
146.466 + txt1 = sprintf("%5.2f", lat_ob(n))
146.467 + txt2 = sprintf("%5.2f", lon_ob(n))
146.468 + txt3 = year_ob(n)
146.469 + txt4 = sprintf("%5.2f", M_score(n,0))
146.470 + txt5 = sprintf("%5.2f", M_score(n,1))
146.471 + txt6 = sprintf("%5.2f", M_score(n,2))
146.472 + txt7 = sprintf("%5.2f", M_score(n,3))
146.473 + txt8 = sprintf("%5.2f", avg(M_score(n,:)))
146.474 +
146.475 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
146.476 + set_line(lines,nline,"<th>"+txt1+"</th>")
146.477 + set_line(lines,nline,"<th>"+txt2+"</th>")
146.478 + set_line(lines,nline,"<th>"+txt3+"</th>")
146.479 + set_line(lines,nline,"<th>"+txt4+"</th>")
146.480 + set_line(lines,nline,"<th>"+txt5+"</th>")
146.481 + set_line(lines,nline,"<th>"+txt6+"</th>")
146.482 + set_line(lines,nline,"<th>"+txt7+"</th>")
146.483 + set_line(lines,nline,"<th>"+txt8+"</th>")
146.484 +
146.485 + set_line(lines,nline,row_footer)
146.486 + end do
146.487 +
146.488 +; last row, summary
146.489 + set_line(lines,nline,row_header)
146.490 +
146.491 + txt0 = "All_"+sprintf("%.0f", nstation)
146.492 + txt1 = "-"
146.493 + txt2 = "-"
146.494 + txt3 = "-"
146.495 + txt4 = M_energy_co2
146.496 + txt5 = M_energy_rad
146.497 + txt6 = M_energy_lh
146.498 + txt7 = M_energy_sh
146.499 + txt8 = M_energy_all
146.500 +
146.501 + set_line(lines,nline,"<th>"+txt0+"</th>")
146.502 + set_line(lines,nline,"<th>"+txt1+"</th>")
146.503 + set_line(lines,nline,"<th>"+txt2+"</th>")
146.504 + set_line(lines,nline,"<th>"+txt3+"</th>")
146.505 + set_line(lines,nline,"<th>"+txt4+"</th>")
146.506 + set_line(lines,nline,"<th>"+txt5+"</th>")
146.507 + set_line(lines,nline,"<th>"+txt6+"</th>")
146.508 + set_line(lines,nline,"<th>"+txt7+"</th>")
146.509 + set_line(lines,nline,"<th>"+txt8+"</th>")
146.510 +
146.511 + set_line(lines,nline,row_footer)
146.512 +;-----------------------------------------------
146.513 + set_line(lines,nline,table_footer)
146.514 + set_line(lines,nline,footer)
146.515 +
146.516 +; Now write to an HTML file.
146.517 + idx = ind(.not.ismissing(lines))
146.518 + if(.not.any(ismissing(idx))) then
146.519 + asciiwrite(output_html,lines(idx))
146.520 + else
146.521 + print ("error?")
146.522 + end if
146.523 + delete (idx)
146.524 +
146.525 +;**************************************************************************************
146.526 +; update score
146.527 +;**************************************************************************************
146.528 +
146.529 + if (isvar("compare")) then
146.530 + system("sed 1,/M_energy_co2/s//"+M_energy_co2+"/ "+html_name2+" > "+html_new2+";"+ \
146.531 + "mv -f "+html_new2+" "+html_name2+";"+ \
146.532 + "sed 1,/M_energy_rad/s//"+M_energy_rad+"/ "+html_name2+" > "+html_new2+";"+ \
146.533 + "mv -f "+html_new2+" "+html_name2+";"+ \
146.534 + "sed 1,/M_energy_lh/s//"+M_energy_lh+"/ "+html_name2+" > "+html_new2+";"+ \
146.535 + "mv -f "+html_new2+" "+html_name2+";"+ \
146.536 + "sed 1,/M_energy_sh/s//"+M_energy_sh+"/ "+html_name2+" > "+html_new2+";"+ \
146.537 + "mv -f "+html_new2+" "+html_name2)
146.538 + end if
146.539 +
146.540 + system("sed s#M_energy_co2#"+M_energy_co2+"# "+html_name+" > "+html_new+";"+ \
146.541 + "mv -f "+html_new+" "+html_name+";"+ \
146.542 + "sed s#M_energy_rad#"+M_energy_rad+"# "+html_name+" > "+html_new+";"+ \
146.543 + "mv -f "+html_new+" "+html_name+";"+ \
146.544 + "sed s#M_energy_lh#"+M_energy_lh+"# "+html_name+" > "+html_new+";"+ \
146.545 + "mv -f "+html_new+" "+html_name+";"+ \
146.546 + "sed s#M_energy_sh#"+M_energy_sh+"# "+html_name+" > "+html_new+";"+ \
146.547 + "mv -f "+html_new+" "+html_name)
146.548 +
146.549 +;***************************************************************************
146.550 +; output plots
146.551 +;***************************************************************************
146.552 + output_dir = model_name+"/energy"
146.553 +
146.554 + system("mv *.png *.html " + output_dir)
146.555 +;***************************************************************************
146.556 +end
147.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
147.2 +++ b/energy/99.all.ncl.0 Mon Jan 26 22:08:20 2009 -0500
147.3 @@ -0,0 +1,420 @@
147.4 +; ***********************************************
147.5 +; using gsn_table for all
147.6 +; output: line plot for each site (4 fields)
147.7 +; table for M_score
147.8 +; ***********************************************
147.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
147.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
147.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
147.12 +;load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
147.13 +;************************************************
147.14 +begin
147.15 +
147.16 + plot_type = "ps"
147.17 + plot_type_new = "png"
147.18 +
147.19 +;************************************************
147.20 +; read model data
147.21 +;************************************************
147.22 +; model_name = "06cn"
147.23 +; film = "i01.06cn_1798-2004_MONS_climo.nc"
147.24 +
147.25 +; model_name = "06casa"
147.26 +; film = "i01.06casa_1798-2004_MONS_climo.nc"
147.27 +
147.28 +; model_name = "10cn"
147.29 +; film = "i01.10cn_1948-2004_MONS_climo.nc"
147.30 +
147.31 + model_name = "10casa"
147.32 + film = "i01.10casa_1948-2004_MONS_climo.nc"
147.33 +;--------------------------------------------
147.34 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
147.35 + fm = addfile(dirm+film,"r")
147.36 +
147.37 + xm = fm->lon
147.38 + ym = fm->lat
147.39 + nlat = dimsizes(ym)
147.40 + nlon = dimsizes(xm)
147.41 +
147.42 + nmon = 12
147.43 + nfield = 4
147.44 +
147.45 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
147.46 +
147.47 +; change to unit of observed (u mol/m2/s)
147.48 +; Model_units [=] gC/m2/s
147.49 +; 12. = molecular weight of C
147.50 +; u mol = 1e-6 mol
147.51 + data = fm->NEE
147.52 +
147.53 + factor = 1e6 /12.
147.54 +
147.55 + data_mod0(0,:,:,:) = data(:,:,:) * factor
147.56 + delete (data)
147.57 +
147.58 + data = fm->NETRAD
147.59 + data_mod0(1,:,:,:) = data(:,:,:)
147.60 + delete (data)
147.61 +
147.62 + data = fm->LATENT
147.63 + data_mod0(2,:,:,:) = data(:,:,:)
147.64 + delete (data)
147.65 +
147.66 + data = fm->SENSIBLE
147.67 + data_mod0(3,:,:,:) = data(:,:,:)
147.68 + delete (data)
147.69 +
147.70 +; printVarSummary (data_mod0)
147.71 +;************************************************
147.72 +; read in data: observed
147.73 +;************************************************
147.74 + station = (/"BOREAS_NSA_OBS" \
147.75 + ,"CastelPorziano" \
147.76 + ,"Hyytiala" \
147.77 + ,"Kaamanen" \
147.78 + ,"LBA_Tapajos_KM67" \
147.79 + ,"Lethbridge" \
147.80 + ,"Tharandt" \
147.81 + ,"Vielsalm" \
147.82 + /)
147.83 +
147.84 + year_ob = (/"1994-2004" \
147.85 + ,"1997-2003" \
147.86 + ,"1996-2003" \
147.87 + ,"2000-2003" \
147.88 + ,"2002-2005" \
147.89 + ,"1999-2004" \
147.90 + ,"1996-2003" \
147.91 + ,"1998-2003" \
147.92 + /)
147.93 +
147.94 + field = (/"CO2 Flux" \
147.95 + ,"Net Radiation" \
147.96 + ,"Latent Heat" \
147.97 + ,"Sensible Heat" \
147.98 + /)
147.99 +
147.100 + nstation = dimsizes(station)
147.101 + nmon = 12
147.102 + nfield = dimsizes(field)
147.103 +
147.104 + data_ob = new ((/nstation, nfield, nmon/),float)
147.105 + lat_ob = new ((/nstation/),float)
147.106 + lon_ob = new ((/nstation/),float)
147.107 +
147.108 + diri_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
147.109 +
147.110 + do n = 0,nstation-1
147.111 + diri = diri_root + station(n)+"/"
147.112 + fili = station(n)+"_"+year_ob(n)+"_monthly.nc"
147.113 + g = addfile (diri+fili,"r")
147.114 +
147.115 + lon_ob(n) = g->lon
147.116 + lat_ob(n) = g->lat
147.117 +
147.118 + data = g->CO2_FLUX
147.119 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
147.120 + delete (data)
147.121 +
147.122 + data = g->RAD_FLUX
147.123 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
147.124 + delete (data)
147.125 +
147.126 + data = g->LH_FLUX
147.127 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
147.128 + delete (data)
147.129 +
147.130 + data = g->SH_FLUX
147.131 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
147.132 + delete (data)
147.133 +
147.134 + delete (g)
147.135 + end do
147.136 +
147.137 +;print (lat_ob)
147.138 +;print (lon_ob)
147.139 +;printVarSummary (data_ob)
147.140 +
147.141 +;************************************************************
147.142 +; interpolate model data into observed station
147.143 +; note: model is 0-360E, 90S-90N
147.144 +;************************************************************
147.145 +
147.146 +; to be able to handle observation at (-89.98,-24.80)
147.147 +; print (ym(0))
147.148 + ym(0) = -90.
147.149 +
147.150 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob,lat_ob,0)
147.151 +
147.152 + delete (data_mod0)
147.153 + yy!0 = "field"
147.154 + data_mod = yy(pts|:,field|:,time|:)
147.155 +; printVarSummary (data_mod)
147.156 +
147.157 +;************************************************************
147.158 +; compute correlation coef and M score
147.159 +;************************************************************
147.160 +
147.161 + score_max = 5.
147.162 +
147.163 + ccr = new ((/nstation, nfield/),float)
147.164 + M_score = new ((/nstation, nfield/),float)
147.165 +
147.166 + do n=0,nstation-1
147.167 + do m=0,nfield-1
147.168 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
147.169 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
147.170 + M_score(n,m) = (1. -(bias/nmon)) * score_max
147.171 + end do
147.172 + end do
147.173 +
147.174 +;*******************************************************************
147.175 +; for station line plot
147.176 +;*******************************************************************
147.177 +
147.178 +; for x-axis in xyplot
147.179 + mon = ispan(1,12,1)
147.180 + mon@long_name = "month"
147.181 +
147.182 + res = True ; plot mods desired
147.183 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
147.184 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
147.185 +;-------------------------------------------------------------------------
147.186 +; Add a boxed legend using the more simple method
147.187 +
147.188 + res@pmLegendDisplayMode = "Always"
147.189 +; res@pmLegendWidthF = 0.1
147.190 + res@pmLegendWidthF = 0.08
147.191 + res@pmLegendHeightF = 0.06
147.192 +; res@pmLegendOrthogonalPosF = -1.17
147.193 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
147.194 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
147.195 +
147.196 +; res@pmLegendParallelPosF = 0.18
147.197 + res@pmLegendParallelPosF = 0.23 ;(rightward)
147.198 +
147.199 +; res@lgPerimOn = False
147.200 + res@lgLabelFontHeightF = 0.015
147.201 + res@xyExplicitLegendLabels = (/"observed",model_name/)
147.202 +;-------------------------------------------------------------------
147.203 +; for panel plot
147.204 + res@gsnFrame = False ; Do not draw plot
147.205 + res@gsnDraw = False ; Do not advance frame
147.206 +
147.207 + pres = True ; panel plot mods desired
147.208 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
147.209 + ; indiv. plots in panel
147.210 + pres@gsnMaximize = True ; fill the page
147.211 +;-------------------------------------------------------------------
147.212 +
147.213 + plot_data = new((/2,12/),float)
147.214 + plot_data!0 = "case"
147.215 + plot_data!1 = "month"
147.216 +
147.217 + do n = 0,nstation-1
147.218 +;----------------------------
147.219 +; for observed
147.220 +
147.221 + plot_name = station(n)+"_ob"
147.222 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
147.223 + res@tiMainString = title
147.224 +
147.225 + wks = gsn_open_wks (plot_type,plot_name)
147.226 + plot=new(4,graphic) ; create graphic array
147.227 +
147.228 + plot_data(0,:) = (/data_ob (n,0,:)/)
147.229 + plot_data@long_name = field(0)
147.230 + plot(0)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 1
147.231 +
147.232 + plot_data(0,:) = (/data_ob (n,1,:)/)
147.233 + plot_data@long_name = field(1)
147.234 + plot(1)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 2
147.235 +
147.236 + plot_data(0,:) = (/data_ob (n,2,:)/)
147.237 + plot_data@long_name = field(2)
147.238 + plot(2)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 3
147.239 +
147.240 + plot_data(0,:) = (/data_ob (n,3,:)/)
147.241 + plot_data@long_name = field(3)
147.242 + plot(3)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 4
147.243 +
147.244 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
147.245 +
147.246 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
147.247 + system("rm "+plot_name+"."+plot_type)
147.248 + clear (wks)
147.249 + delete (plot)
147.250 +;----------------------------
147.251 +; for model_vs_ob
147.252 +
147.253 + plot_name = station(n)+"_model_vs_ob"
147.254 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
147.255 + res@tiMainString = title
147.256 +
147.257 + wks = gsn_open_wks (plot_type,plot_name)
147.258 + plot=new(4,graphic) ; create graphic array
147.259 +
147.260 + plot_data(0,:) = (/data_ob (n,0,:)/)
147.261 + plot_data(1,:) = (/data_mod(n,0,:)/)
147.262 + plot_data@long_name = field(0)
147.263 + plot(0)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 1
147.264 +
147.265 + plot_data(0,:) = (/data_ob (n,1,:)/)
147.266 + plot_data(1,:) = (/data_mod(n,1,:)/)
147.267 + plot_data@long_name = field(1)
147.268 + plot(1)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 2
147.269 +
147.270 + plot_data(0,:) = (/data_ob (n,2,:)/)
147.271 + plot_data(1,:) = (/data_mod(n,2,:)/)
147.272 + plot_data@long_name = field(2)
147.273 + plot(2)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 3
147.274 +
147.275 + plot_data(0,:) = (/data_ob (n,3,:)/)
147.276 + plot_data(1,:) = (/data_mod(n,3,:)/)
147.277 + plot_data@long_name = field(3)
147.278 + plot(3)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 4
147.279 +
147.280 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
147.281 +
147.282 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
147.283 + system("rm "+plot_name+"."+plot_type)
147.284 + clear (wks)
147.285 + delete (plot)
147.286 + end do
147.287 +
147.288 +;*******************************************************************
147.289 +; for table of site score
147.290 +;*******************************************************************
147.291 +
147.292 + table_length = 0.8
147.293 +
147.294 +; table header name
147.295 + table_header_name = "Site"
147.296 +
147.297 +; column (not including header column)
147.298 + col_header = (/"Latitude","Longitude","observed" \
147.299 + ,"CO2 Flux","Net Radiation","Latent Heat" \
147.300 + ,"Sensible Heat","Average" \
147.301 + /)
147.302 + ncol = dimsizes(col_header)
147.303 +
147.304 +; row (not including header row)
147.305 + nrow = nstation + 1
147.306 + row_header = new ((/nrow/),string )
147.307 + row_header(0:nstation-1) = station(:)
147.308 + row_header(nrow-1) = "All Sites"
147.309 +
147.310 +; Table header
147.311 + ncr1 = (/1,1/) ; 1 row, 1 column
147.312 + x1 = (/0.005,0.15/) ; Start and end X
147.313 + y1 = (/0.800,0.895/) ; Start and end Y
147.314 + text1 = table_header_name
147.315 + res1 = True
147.316 + res1@txFontHeightF = 0.03
147.317 + res1@gsFillColor = "CornFlowerBlue"
147.318 +
147.319 +; Column header (equally space in x2)
147.320 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
147.321 + x2 = (/x1(1),0.995/) ; start from end of x1
147.322 + y2 = y1 ; same as y1
147.323 + text2 = col_header
147.324 + res2 = True
147.325 + res2@txFontHeightF = 0.010
147.326 + res2@gsFillColor = "Gray"
147.327 +
147.328 +; Row header (equally space in y2)
147.329 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
147.330 + x3 = x1 ; same as x1
147.331 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
147.332 + text3 = row_header
147.333 + res3 = True
147.334 + res3@txFontHeightF = 0.010
147.335 + res3@gsFillColor = "Gray"
147.336 +
147.337 +; Main table body
147.338 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
147.339 + x4 = x2 ; Start and end x
147.340 + y4 = y3 ; Start and end Y
147.341 + text4 = new((/nrow,ncol/),string)
147.342 +
147.343 + color_fill4 = new((/nrow,ncol/),string)
147.344 + color_fill4 = "white"
147.345 + color_fill4(:,ncol-1) = "grey"
147.346 + color_fill4(nrow-1,:) = "green"
147.347 +
147.348 + res4 = True ; Set up resource list
147.349 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
147.350 + res4@txFontHeightF = 0.015
147.351 + res4@gsFillColor = color_fill4
147.352 +
147.353 + delete (color_fill4)
147.354 +;-------------------------------------------------------------------
147.355 +; for table value
147.356 +
147.357 + do n = 0,nrow-2
147.358 + text4(n,0) = sprintf("%5.2f", lat_ob(n))
147.359 + text4(n,1) = sprintf("%5.2f", lon_ob(n))
147.360 + text4(n,2) = year_ob(n)
147.361 + text4(n,3) = sprintf("%5.2f", M_score(n,0)) ; CO2 Flux
147.362 + text4(n,4) = sprintf("%5.2f", M_score(n,1)) ; Net Radiation
147.363 + text4(n,5) = sprintf("%5.2f", M_score(n,2)) ; Latent Heat
147.364 + text4(n,6) = sprintf("%5.2f", M_score(n,3)) ; Sensible Heat
147.365 + text4(n,7) = sprintf("%5.2f", avg(M_score(n,:))) ; avg all fields
147.366 + end do
147.367 +
147.368 +; for the last row
147.369 +
147.370 + M_co2 = avg(M_score(:,0))
147.371 + M_rad = avg(M_score(:,1))
147.372 + M_lh = avg(M_score(:,2))
147.373 + M_sh = avg(M_score(:,3))
147.374 + M_all = M_co2+ M_rad +M_lh + M_sh
147.375 +
147.376 + text4(nrow-1,0) = "-"
147.377 + text4(nrow-1,1) = "-"
147.378 + text4(nrow-1,2) = "-"
147.379 + text4(nrow-1,3) = sprintf("%5.2f", M_co2) ; avg all sites
147.380 + text4(nrow-1,4) = sprintf("%5.2f", M_rad) ; avg all sites
147.381 + text4(nrow-1,5) = sprintf("%5.2f", M_lh ) ; avg all sites
147.382 + text4(nrow-1,6) = sprintf("%5.2f", M_sh ) ; avg all sites
147.383 + text4(nrow-1,7) = sprintf("%5.2f", M_all) ; avg all sites
147.384 +
147.385 + print (M_co2)
147.386 + print (M_rad)
147.387 + print (M_lh )
147.388 + print (M_sh)
147.389 + print (M_all)
147.390 +;---------------------------------------------------------------------------
147.391 +
147.392 + plot_name = "table_site_score"
147.393 +
147.394 + wks = gsn_open_wks (plot_type,plot_name)
147.395 +;------------------------------------------
147.396 +; for table title
147.397 +
147.398 + gRes = True
147.399 + gRes@txFontHeightF = 0.02
147.400 +; gRes@txAngleF = 90
147.401 +
147.402 + title_text = "Model " + model_name + " M_Score"
147.403 +
147.404 + gsn_text_ndc(wks,title_text,0.50,0.95,gRes)
147.405 +;------------------------------------------
147.406 +
147.407 + gsn_table(wks,ncr1,x1,y1,text1,res1)
147.408 + gsn_table(wks,ncr2,x2,y2,text2,res2)
147.409 + gsn_table(wks,ncr3,x3,y3,text3,res3)
147.410 + gsn_table(wks,ncr4,x4,y4,text4,res4)
147.411 +
147.412 + frame(wks)
147.413 +
147.414 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
147.415 + system("rm "+plot_name+"."+plot_type)
147.416 +;-------------------------------------------------------------------
147.417 + temp_name = "temp." + model_name
147.418 + system("mkdir -p " + temp_name)
147.419 + system("mv *.png " + temp_name)
147.420 + system("tar cf "+ temp_name +".tar " + temp_name)
147.421 +;-------------------------------------------------------------------
147.422 +
147.423 +end
148.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
148.2 +++ b/energy/99.all.ncl.1 Mon Jan 26 22:08:20 2009 -0500
148.3 @@ -0,0 +1,438 @@
148.4 +; ***********************************************
148.5 +; using gsn_table for all
148.6 +; output: line plot for each site (4 fields)
148.7 +; table for M_score
148.8 +; ***********************************************
148.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
148.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
148.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
148.12 +;load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
148.13 +;************************************************
148.14 +begin
148.15 +
148.16 + plot_type = "ps"
148.17 + plot_type_new = "png"
148.18 +
148.19 +;************************************************
148.20 +; read model data
148.21 +;************************************************
148.22 + model_name = "10cn"
148.23 + film = "i01.10cn_1948-2004_MONS_climo.nc"
148.24 +
148.25 +; model_name = "10casa"
148.26 +; film = "i01.10casa_1948-2004_MONS_climo.nc"
148.27 +
148.28 + system("sed s#model_name#"+model_name+"# table.html > table.html.new")
148.29 + system("mv -f table.html.new table.html")
148.30 +;--------------------------------------------
148.31 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
148.32 + fm = addfile(dirm+film,"r")
148.33 +
148.34 + xm = fm->lon
148.35 + ym = fm->lat
148.36 + nlat = dimsizes(ym)
148.37 + nlon = dimsizes(xm)
148.38 +
148.39 + nmon = 12
148.40 + nfield = 4
148.41 +
148.42 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
148.43 +
148.44 +; change to unit of observed (u mol/m2/s)
148.45 +; Model_units [=] gC/m2/s
148.46 +; 12. = molecular weight of C
148.47 +; u mol = 1e-6 mol
148.48 + data = fm->NEE
148.49 +
148.50 + factor = 1e6 /12.
148.51 +
148.52 + data_mod0(0,:,:,:) = data(:,:,:) * factor
148.53 + delete (data)
148.54 +
148.55 + data = fm->NETRAD
148.56 + data_mod0(1,:,:,:) = data(:,:,:)
148.57 + delete (data)
148.58 +
148.59 + data = fm->LATENT
148.60 + data_mod0(2,:,:,:) = data(:,:,:)
148.61 + delete (data)
148.62 +
148.63 + data = fm->SENSIBLE
148.64 + data_mod0(3,:,:,:) = data(:,:,:)
148.65 + delete (data)
148.66 +
148.67 +; printVarSummary (data_mod0)
148.68 +;************************************************
148.69 +; read in data: observed
148.70 +;************************************************
148.71 + station = (/"BOREAS_NSA_OBS" \
148.72 + ,"CastelPorziano" \
148.73 + ,"Hyytiala" \
148.74 + ,"Kaamanen" \
148.75 + ,"LBA_Tapajos_KM67" \
148.76 + ,"Lethbridge" \
148.77 + ,"Tharandt" \
148.78 + ,"Vielsalm" \
148.79 + /)
148.80 +
148.81 + year_ob = (/"1994-2004" \
148.82 + ,"1997-2003" \
148.83 + ,"1996-2003" \
148.84 + ,"2000-2003" \
148.85 + ,"2002-2005" \
148.86 + ,"1999-2004" \
148.87 + ,"1996-2003" \
148.88 + ,"1998-2003" \
148.89 + /)
148.90 +
148.91 + field = (/"CO2 Flux" \
148.92 + ,"Net Radiation" \
148.93 + ,"Latent Heat" \
148.94 + ,"Sensible Heat" \
148.95 + /)
148.96 +
148.97 + nstation = dimsizes(station)
148.98 + nmon = 12
148.99 + nfield = dimsizes(field)
148.100 +
148.101 + data_ob = new ((/nstation, nfield, nmon/),float)
148.102 + lat_ob = new ((/nstation/),float)
148.103 + lon_ob = new ((/nstation/),float)
148.104 +
148.105 + diri_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
148.106 +
148.107 + do n = 0,nstation-1
148.108 + diri = diri_root + station(n)+"/"
148.109 + fili = station(n)+"_"+year_ob(n)+"_monthly.nc"
148.110 + g = addfile (diri+fili,"r")
148.111 +
148.112 + lon_ob(n) = g->lon
148.113 + lat_ob(n) = g->lat
148.114 +
148.115 + data = g->CO2_FLUX
148.116 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
148.117 + delete (data)
148.118 +
148.119 + data = g->RAD_FLUX
148.120 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
148.121 + delete (data)
148.122 +
148.123 + data = g->LH_FLUX
148.124 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
148.125 + delete (data)
148.126 +
148.127 + data = g->SH_FLUX
148.128 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
148.129 + delete (data)
148.130 +
148.131 + delete (g)
148.132 + end do
148.133 +
148.134 +;print (lat_ob)
148.135 +;print (lon_ob)
148.136 +;printVarSummary (data_ob)
148.137 +
148.138 +;************************************************************
148.139 +; interpolate model data into observed station
148.140 +; note: model is 0-360E, 90S-90N
148.141 +;************************************************************
148.142 +
148.143 +; to be able to handle observation at (-89.98,-24.80)
148.144 +; print (ym(0))
148.145 + ym(0) = -90.
148.146 +
148.147 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob,lat_ob,0)
148.148 +
148.149 + delete (data_mod0)
148.150 + yy!0 = "field"
148.151 + data_mod = yy(pts|:,field|:,time|:)
148.152 +; printVarSummary (data_mod)
148.153 +
148.154 +;************************************************************
148.155 +; compute correlation coef and M score
148.156 +;************************************************************
148.157 +
148.158 + score_max = 5.
148.159 +
148.160 + ccr = new ((/nstation, nfield/),float)
148.161 + M_score = new ((/nstation, nfield/),float)
148.162 +
148.163 + do n=0,nstation-1
148.164 + do m=0,nfield-1
148.165 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
148.166 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
148.167 + M_score(n,m) = (1. -(bias/nmon)) * score_max
148.168 + end do
148.169 + end do
148.170 +
148.171 +;*******************************************************************
148.172 +; for station line plot
148.173 +;*******************************************************************
148.174 +
148.175 +; for x-axis in xyplot
148.176 + mon = ispan(1,12,1)
148.177 + mon@long_name = "month"
148.178 +
148.179 + res = True ; plot mods desired
148.180 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
148.181 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
148.182 +;-------------------------------------------------------------------------
148.183 +; Add a boxed legend using the more simple method
148.184 +
148.185 + res@pmLegendDisplayMode = "Always"
148.186 +; res@pmLegendWidthF = 0.1
148.187 + res@pmLegendWidthF = 0.08
148.188 + res@pmLegendHeightF = 0.06
148.189 +; res@pmLegendOrthogonalPosF = -1.17
148.190 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
148.191 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
148.192 +
148.193 +; res@pmLegendParallelPosF = 0.18
148.194 + res@pmLegendParallelPosF = 0.23 ;(rightward)
148.195 +
148.196 +; res@lgPerimOn = False
148.197 + res@lgLabelFontHeightF = 0.015
148.198 + res@xyExplicitLegendLabels = (/"observed",model_name/)
148.199 +;-------------------------------------------------------------------
148.200 +; for panel plot
148.201 + res@gsnFrame = False ; Do not draw plot
148.202 + res@gsnDraw = False ; Do not advance frame
148.203 +
148.204 + pres = True ; panel plot mods desired
148.205 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
148.206 + ; indiv. plots in panel
148.207 + pres@gsnMaximize = True ; fill the page
148.208 +;-------------------------------------------------------------------
148.209 +
148.210 + plot_data = new((/2,12/),float)
148.211 + plot_data!0 = "case"
148.212 + plot_data!1 = "month"
148.213 +
148.214 + do n = 0,nstation-1
148.215 +;----------------------------
148.216 +; for observed
148.217 +
148.218 + plot_name = station(n)+"_ob"
148.219 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
148.220 + res@tiMainString = title
148.221 +
148.222 + wks = gsn_open_wks (plot_type,plot_name)
148.223 + plot=new(4,graphic) ; create graphic array
148.224 +
148.225 + plot_data(0,:) = (/data_ob (n,0,:)/)
148.226 + plot_data@long_name = field(0)
148.227 + plot(0)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 1
148.228 +
148.229 + plot_data(0,:) = (/data_ob (n,1,:)/)
148.230 + plot_data@long_name = field(1)
148.231 + plot(1)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 2
148.232 +
148.233 + plot_data(0,:) = (/data_ob (n,2,:)/)
148.234 + plot_data@long_name = field(2)
148.235 + plot(2)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 3
148.236 +
148.237 + plot_data(0,:) = (/data_ob (n,3,:)/)
148.238 + plot_data@long_name = field(3)
148.239 + plot(3)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 4
148.240 +
148.241 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
148.242 +
148.243 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
148.244 + system("rm "+plot_name+"."+plot_type)
148.245 + clear (wks)
148.246 + delete (plot)
148.247 +;----------------------------
148.248 +; for model_vs_ob
148.249 +
148.250 + plot_name = station(n)+"_model_vs_ob"
148.251 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
148.252 + res@tiMainString = title
148.253 +
148.254 + wks = gsn_open_wks (plot_type,plot_name)
148.255 + plot=new(4,graphic) ; create graphic array
148.256 +
148.257 + plot_data(0,:) = (/data_ob (n,0,:)/)
148.258 + plot_data(1,:) = (/data_mod(n,0,:)/)
148.259 + plot_data@long_name = field(0)
148.260 + plot(0)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 1
148.261 +
148.262 + plot_data(0,:) = (/data_ob (n,1,:)/)
148.263 + plot_data(1,:) = (/data_mod(n,1,:)/)
148.264 + plot_data@long_name = field(1)
148.265 + plot(1)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 2
148.266 +
148.267 + plot_data(0,:) = (/data_ob (n,2,:)/)
148.268 + plot_data(1,:) = (/data_mod(n,2,:)/)
148.269 + plot_data@long_name = field(2)
148.270 + plot(2)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 3
148.271 +
148.272 + plot_data(0,:) = (/data_ob (n,3,:)/)
148.273 + plot_data(1,:) = (/data_mod(n,3,:)/)
148.274 + plot_data@long_name = field(3)
148.275 + plot(3)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 4
148.276 +
148.277 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
148.278 +
148.279 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
148.280 + system("rm "+plot_name+"."+plot_type)
148.281 + clear (wks)
148.282 + delete (plot)
148.283 + end do
148.284 +
148.285 +;*******************************************************************
148.286 +; for table of site score
148.287 +;*******************************************************************
148.288 +
148.289 + table_length = 0.8
148.290 +
148.291 +; table header name
148.292 + table_header_name = "Site"
148.293 +
148.294 +; column (not including header column)
148.295 + col_header = (/"Latitude","Longitude","observed" \
148.296 + ,"CO2 Flux","Net Radiation","Latent Heat" \
148.297 + ,"Sensible Heat","Average" \
148.298 + /)
148.299 + ncol = dimsizes(col_header)
148.300 +
148.301 +; row (not including header row)
148.302 + nrow = nstation + 1
148.303 + row_header = new ((/nrow/),string )
148.304 + row_header(0:nstation-1) = station(:)
148.305 + row_header(nrow-1) = "All Sites"
148.306 +
148.307 +; Table header
148.308 + ncr1 = (/1,1/) ; 1 row, 1 column
148.309 + x1 = (/0.005,0.15/) ; Start and end X
148.310 + y1 = (/0.800,0.895/) ; Start and end Y
148.311 + text1 = table_header_name
148.312 + res1 = True
148.313 + res1@txFontHeightF = 0.03
148.314 + res1@gsFillColor = "CornFlowerBlue"
148.315 +
148.316 +; Column header (equally space in x2)
148.317 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
148.318 + x2 = (/x1(1),0.995/) ; start from end of x1
148.319 + y2 = y1 ; same as y1
148.320 + text2 = col_header
148.321 + res2 = True
148.322 + res2@txFontHeightF = 0.010
148.323 + res2@gsFillColor = "Gray"
148.324 +
148.325 +; Row header (equally space in y2)
148.326 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
148.327 + x3 = x1 ; same as x1
148.328 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
148.329 + text3 = row_header
148.330 + res3 = True
148.331 + res3@txFontHeightF = 0.010
148.332 + res3@gsFillColor = "Gray"
148.333 +
148.334 +; Main table body
148.335 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
148.336 + x4 = x2 ; Start and end x
148.337 + y4 = y3 ; Start and end Y
148.338 + text4 = new((/nrow,ncol/),string)
148.339 +
148.340 + color_fill4 = new((/nrow,ncol/),string)
148.341 + color_fill4 = "white"
148.342 + color_fill4(:,ncol-1) = "grey"
148.343 + color_fill4(nrow-1,:) = "green"
148.344 +
148.345 + res4 = True ; Set up resource list
148.346 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
148.347 + res4@txFontHeightF = 0.015
148.348 + res4@gsFillColor = color_fill4
148.349 +
148.350 + delete (color_fill4)
148.351 +;-------------------------------------------------------------------
148.352 +; for table value
148.353 +
148.354 + do n = 0,nrow-2
148.355 + text4(n,0) = sprintf("%5.2f", lat_ob(n))
148.356 + text4(n,1) = sprintf("%5.2f", lon_ob(n))
148.357 + text4(n,2) = year_ob(n)
148.358 + text4(n,3) = sprintf("%5.2f", M_score(n,0)) ; CO2 Flux
148.359 + text4(n,4) = sprintf("%5.2f", M_score(n,1)) ; Net Radiation
148.360 + text4(n,5) = sprintf("%5.2f", M_score(n,2)) ; Latent Heat
148.361 + text4(n,6) = sprintf("%5.2f", M_score(n,3)) ; Sensible Heat
148.362 + text4(n,7) = sprintf("%5.2f", avg(M_score(n,:))) ; avg all fields
148.363 + end do
148.364 +
148.365 +; for the last row
148.366 +
148.367 + M_co2 = avg(M_score(:,0))
148.368 + M_rad = avg(M_score(:,1))
148.369 + M_lh = avg(M_score(:,2))
148.370 + M_sh = avg(M_score(:,3))
148.371 + M_all = M_co2+ M_rad +M_lh + M_sh
148.372 +
148.373 + text4(nrow-1,0) = "-"
148.374 + text4(nrow-1,1) = "-"
148.375 + text4(nrow-1,2) = "-"
148.376 + text4(nrow-1,3) = sprintf("%5.2f", M_co2) ; avg all sites
148.377 + text4(nrow-1,4) = sprintf("%5.2f", M_rad) ; avg all sites
148.378 + text4(nrow-1,5) = sprintf("%5.2f", M_lh ) ; avg all sites
148.379 + text4(nrow-1,6) = sprintf("%5.2f", M_sh ) ; avg all sites
148.380 + text4(nrow-1,7) = sprintf("%5.2f", M_all) ; avg all sites
148.381 +
148.382 + print (M_co2)
148.383 + print (M_rad)
148.384 + print (M_lh )
148.385 + print (M_sh)
148.386 + print (M_all)
148.387 +
148.388 + M_energy_co2 = sprintf("%.2f", M_co2)
148.389 + system("sed s#M_energy_co2#"+M_energy_co2+"# table.html > table.html.new")
148.390 + system("mv -f table.html.new table.html")
148.391 + print (M_energy_co2)
148.392 +
148.393 + M_energy_rad = sprintf("%.2f", M_rad)
148.394 + system("sed s#M_energy_rad#"+M_energy_rad+"# table.html > table.html.new")
148.395 + system("mv -f table.html.new table.html")
148.396 + print (M_energy_rad)
148.397 +
148.398 + M_energy_lh = sprintf("%.2f", M_lh)
148.399 + system("sed s#M_energy_lh#"+M_energy_lh+"# table.html > table.html.new")
148.400 + system("mv -f table.html.new table.html")
148.401 + print (M_energy_lh)
148.402 +
148.403 + M_energy_sh = sprintf("%.2f", M_sh)
148.404 + system("sed s#M_energy_sh#"+M_energy_sh+"# table.html > table.html.new")
148.405 + system("mv -f table.html.new table.html")
148.406 + print (M_energy_sh)
148.407 +;---------------------------------------------------------------------------
148.408 +
148.409 + plot_name = "table_site_score"
148.410 +
148.411 + wks = gsn_open_wks (plot_type,plot_name)
148.412 +;------------------------------------------
148.413 +; for table title
148.414 +
148.415 + gRes = True
148.416 + gRes@txFontHeightF = 0.02
148.417 +; gRes@txAngleF = 90
148.418 +
148.419 + title_text = "Model " + model_name + " M_Score"
148.420 +
148.421 + gsn_text_ndc(wks,title_text,0.50,0.95,gRes)
148.422 +;------------------------------------------
148.423 +
148.424 + gsn_table(wks,ncr1,x1,y1,text1,res1)
148.425 + gsn_table(wks,ncr2,x2,y2,text2,res2)
148.426 + gsn_table(wks,ncr3,x3,y3,text3,res3)
148.427 + gsn_table(wks,ncr4,x4,y4,text4,res4)
148.428 +
148.429 + frame(wks)
148.430 +
148.431 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
148.432 + system("rm "+plot_name+"."+plot_type)
148.433 +;-------------------------------------------------------------------
148.434 + temp_name = "energy." + model_name
148.435 + system("mkdir -p " + temp_name)
148.436 + system("cp table.html " + temp_name)
148.437 + system("mv *.png " + temp_name)
148.438 + system("tar cf "+ temp_name +".tar " + temp_name)
148.439 +;-------------------------------------------------------------------
148.440 +
148.441 +end
149.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
149.2 +++ b/energy/99.all.ncl.2 Mon Jan 26 22:08:20 2009 -0500
149.3 @@ -0,0 +1,442 @@
149.4 +; ***********************************************
149.5 +; using gsn_table for all
149.6 +; output: line plot for each site (4 fields)
149.7 +; table for M_score
149.8 +; ***********************************************
149.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
149.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
149.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
149.12 +;load "/fis/cgd/cseg/people/jeff/clamp/co2/metrics_table.ncl"
149.13 +;************************************************
149.14 +begin
149.15 +
149.16 + plot_type = "ps"
149.17 + plot_type_new = "png"
149.18 +
149.19 +;************************************************
149.20 +; read model data
149.21 +;************************************************
149.22 + model_name = "10cn"
149.23 + film = "i01.10cn_1948-2004_MONS_climo.nc"
149.24 +
149.25 +; model_name = "10casa"
149.26 +; film = "i01.10casa_1948-2004_MONS_climo.nc"
149.27 +;------------------------------------------------------------------------
149.28 + html_name = "table.html." + model_name
149.29 + html_new = html_name +".new"
149.30 + system("sed s#model_name#"+model_name+"# "+html_name+" > "+html_new+";"+ \
149.31 + "mv -f "+html_new+" "+html_name)
149.32 +
149.33 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
149.34 + fm = addfile(dirm+film,"r")
149.35 +
149.36 + xm = fm->lon
149.37 + ym = fm->lat
149.38 + nlat = dimsizes(ym)
149.39 + nlon = dimsizes(xm)
149.40 +
149.41 + nmon = 12
149.42 + nfield = 4
149.43 +
149.44 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
149.45 +
149.46 +; change to unit of observed (u mol/m2/s)
149.47 +; Model_units [=] gC/m2/s
149.48 +; 12. = molecular weight of C
149.49 +; u mol = 1e-6 mol
149.50 + data = fm->NEE
149.51 +
149.52 + factor = 1e6 /12.
149.53 +
149.54 + data_mod0(0,:,:,:) = data(:,:,:) * factor
149.55 + delete (data)
149.56 +
149.57 + data = fm->NETRAD
149.58 + data_mod0(1,:,:,:) = data(:,:,:)
149.59 + delete (data)
149.60 +
149.61 + data = fm->LATENT
149.62 + data_mod0(2,:,:,:) = data(:,:,:)
149.63 + delete (data)
149.64 +
149.65 + data = fm->SENSIBLE
149.66 + data_mod0(3,:,:,:) = data(:,:,:)
149.67 + delete (data)
149.68 +
149.69 +; printVarSummary (data_mod0)
149.70 +;************************************************
149.71 +; read in data: observed
149.72 +;************************************************
149.73 + station = (/"BOREAS_NSA_OBS" \
149.74 + ,"CastelPorziano" \
149.75 + ,"Hyytiala" \
149.76 + ,"Kaamanen" \
149.77 + ,"LBA_Tapajos_KM67" \
149.78 + ,"Lethbridge" \
149.79 + ,"Tharandt" \
149.80 + ,"Vielsalm" \
149.81 + /)
149.82 +
149.83 + year_ob = (/"1994-2004" \
149.84 + ,"1997-2003" \
149.85 + ,"1996-2003" \
149.86 + ,"2000-2003" \
149.87 + ,"2002-2005" \
149.88 + ,"1999-2004" \
149.89 + ,"1996-2003" \
149.90 + ,"1998-2003" \
149.91 + /)
149.92 +
149.93 + field = (/"CO2 Flux" \
149.94 + ,"Net Radiation" \
149.95 + ,"Latent Heat" \
149.96 + ,"Sensible Heat" \
149.97 + /)
149.98 +
149.99 + nstation = dimsizes(station)
149.100 + nmon = 12
149.101 + nfield = dimsizes(field)
149.102 +
149.103 + data_ob = new ((/nstation, nfield, nmon/),float)
149.104 + lat_ob = new ((/nstation/),float)
149.105 + lon_ob = new ((/nstation/),float)
149.106 +
149.107 + diri_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
149.108 +
149.109 + do n = 0,nstation-1
149.110 + diri = diri_root + station(n)+"/"
149.111 + fili = station(n)+"_"+year_ob(n)+"_monthly.nc"
149.112 + g = addfile (diri+fili,"r")
149.113 +
149.114 + lon_ob(n) = g->lon
149.115 + lat_ob(n) = g->lat
149.116 +
149.117 + data = g->CO2_FLUX
149.118 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
149.119 + delete (data)
149.120 +
149.121 + data = g->RAD_FLUX
149.122 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
149.123 + delete (data)
149.124 +
149.125 + data = g->LH_FLUX
149.126 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
149.127 + delete (data)
149.128 +
149.129 + data = g->SH_FLUX
149.130 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
149.131 + delete (data)
149.132 +
149.133 + delete (g)
149.134 + end do
149.135 +
149.136 +;print (lat_ob)
149.137 +;print (lon_ob)
149.138 +;printVarSummary (data_ob)
149.139 +
149.140 +;************************************************************
149.141 +; interpolate model data into observed station
149.142 +; note: model is 0-360E, 90S-90N
149.143 +;************************************************************
149.144 +
149.145 +; to be able to handle observation at (-89.98,-24.80)
149.146 +; print (ym(0))
149.147 + ym(0) = -90.
149.148 +
149.149 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob,lat_ob,0)
149.150 +
149.151 + delete (data_mod0)
149.152 + yy!0 = "field"
149.153 + data_mod = yy(pts|:,field|:,time|:)
149.154 +; printVarSummary (data_mod)
149.155 +
149.156 +;************************************************************
149.157 +; compute correlation coef and M score
149.158 +;************************************************************
149.159 +
149.160 + score_max = 5.
149.161 +
149.162 + ccr = new ((/nstation, nfield/),float)
149.163 + M_score = new ((/nstation, nfield/),float)
149.164 +
149.165 + do n=0,nstation-1
149.166 + do m=0,nfield-1
149.167 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
149.168 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
149.169 + M_score(n,m) = (1. -(bias/nmon)) * score_max
149.170 + end do
149.171 + end do
149.172 +
149.173 +;*******************************************************************
149.174 +; for station line plot
149.175 +;*******************************************************************
149.176 +
149.177 +; for x-axis in xyplot
149.178 + mon = ispan(1,12,1)
149.179 + mon@long_name = "month"
149.180 +
149.181 + res = True ; plot mods desired
149.182 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
149.183 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
149.184 +;-------------------------------------------------------------------------
149.185 +; Add a boxed legend using the more simple method
149.186 +
149.187 + res@pmLegendDisplayMode = "Always"
149.188 +; res@pmLegendWidthF = 0.1
149.189 + res@pmLegendWidthF = 0.08
149.190 + res@pmLegendHeightF = 0.06
149.191 +; res@pmLegendOrthogonalPosF = -1.17
149.192 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
149.193 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
149.194 +
149.195 +; res@pmLegendParallelPosF = 0.18
149.196 + res@pmLegendParallelPosF = 0.23 ;(rightward)
149.197 +
149.198 +; res@lgPerimOn = False
149.199 + res@lgLabelFontHeightF = 0.015
149.200 + res@xyExplicitLegendLabels = (/"observed",model_name/)
149.201 +;-------------------------------------------------------------------
149.202 +; for panel plot
149.203 + res@gsnFrame = False ; Do not draw plot
149.204 + res@gsnDraw = False ; Do not advance frame
149.205 +
149.206 + pres = True ; panel plot mods desired
149.207 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
149.208 + ; indiv. plots in panel
149.209 + pres@gsnMaximize = True ; fill the page
149.210 +;-------------------------------------------------------------------
149.211 +
149.212 + plot_data = new((/2,12/),float)
149.213 + plot_data!0 = "case"
149.214 + plot_data!1 = "month"
149.215 +
149.216 + do n = 0,nstation-1
149.217 +;----------------------------
149.218 +; for observed
149.219 +
149.220 + plot_name = station(n)+"_ob"
149.221 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
149.222 + res@tiMainString = title
149.223 +
149.224 + wks = gsn_open_wks (plot_type,plot_name)
149.225 + plot=new(4,graphic) ; create graphic array
149.226 +
149.227 + plot_data(0,:) = (/data_ob (n,0,:)/)
149.228 + plot_data@long_name = field(0)
149.229 + plot(0)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 1
149.230 +
149.231 + plot_data(0,:) = (/data_ob (n,1,:)/)
149.232 + plot_data@long_name = field(1)
149.233 + plot(1)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 2
149.234 +
149.235 + plot_data(0,:) = (/data_ob (n,2,:)/)
149.236 + plot_data@long_name = field(2)
149.237 + plot(2)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 3
149.238 +
149.239 + plot_data(0,:) = (/data_ob (n,3,:)/)
149.240 + plot_data@long_name = field(3)
149.241 + plot(3)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 4
149.242 +
149.243 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
149.244 +
149.245 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
149.246 + "rm "+plot_name+"."+plot_type)
149.247 +
149.248 + clear (wks)
149.249 + delete (plot)
149.250 +;----------------------------
149.251 +; for model_vs_ob
149.252 +
149.253 + plot_name = station(n)+"_model_vs_ob"
149.254 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
149.255 + res@tiMainString = title
149.256 +
149.257 + wks = gsn_open_wks (plot_type,plot_name)
149.258 + plot=new(4,graphic) ; create graphic array
149.259 +
149.260 + plot_data(0,:) = (/data_ob (n,0,:)/)
149.261 + plot_data(1,:) = (/data_mod(n,0,:)/)
149.262 + plot_data@long_name = field(0)
149.263 + plot(0)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 1
149.264 +
149.265 + plot_data(0,:) = (/data_ob (n,1,:)/)
149.266 + plot_data(1,:) = (/data_mod(n,1,:)/)
149.267 + plot_data@long_name = field(1)
149.268 + plot(1)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 2
149.269 +
149.270 + plot_data(0,:) = (/data_ob (n,2,:)/)
149.271 + plot_data(1,:) = (/data_mod(n,2,:)/)
149.272 + plot_data@long_name = field(2)
149.273 + plot(2)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 3
149.274 +
149.275 + plot_data(0,:) = (/data_ob (n,3,:)/)
149.276 + plot_data(1,:) = (/data_mod(n,3,:)/)
149.277 + plot_data@long_name = field(3)
149.278 + plot(3)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 4
149.279 +
149.280 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
149.281 +
149.282 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
149.283 + "rm "+plot_name+"."+plot_type)
149.284 +
149.285 + clear (wks)
149.286 + delete (plot)
149.287 + end do
149.288 +
149.289 +;*******************************************************************
149.290 +; for table of site score
149.291 +;*******************************************************************
149.292 +
149.293 + table_length = 0.8
149.294 +
149.295 +; table header name
149.296 + table_header_name = "Site"
149.297 +
149.298 +; column (not including header column)
149.299 + col_header = (/"Latitude","Longitude","observed" \
149.300 + ,"CO2 Flux","Net Radiation","Latent Heat" \
149.301 + ,"Sensible Heat","Average" \
149.302 + /)
149.303 + ncol = dimsizes(col_header)
149.304 +
149.305 +; row (not including header row)
149.306 + nrow = nstation + 1
149.307 + row_header = new ((/nrow/),string )
149.308 + row_header(0:nstation-1) = station(:)
149.309 + row_header(nrow-1) = "All Sites"
149.310 +
149.311 +; Table header
149.312 + ncr1 = (/1,1/) ; 1 row, 1 column
149.313 + x1 = (/0.005,0.15/) ; Start and end X
149.314 + y1 = (/0.800,0.895/) ; Start and end Y
149.315 + text1 = table_header_name
149.316 + res1 = True
149.317 + res1@txFontHeightF = 0.03
149.318 + res1@gsFillColor = "CornFlowerBlue"
149.319 +
149.320 +; Column header (equally space in x2)
149.321 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
149.322 + x2 = (/x1(1),0.995/) ; start from end of x1
149.323 + y2 = y1 ; same as y1
149.324 + text2 = col_header
149.325 + res2 = True
149.326 + res2@txFontHeightF = 0.010
149.327 + res2@gsFillColor = "Gray"
149.328 +
149.329 +; Row header (equally space in y2)
149.330 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
149.331 + x3 = x1 ; same as x1
149.332 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
149.333 + text3 = row_header
149.334 + res3 = True
149.335 + res3@txFontHeightF = 0.010
149.336 + res3@gsFillColor = "Gray"
149.337 +
149.338 +; Main table body
149.339 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
149.340 + x4 = x2 ; Start and end x
149.341 + y4 = y3 ; Start and end Y
149.342 + text4 = new((/nrow,ncol/),string)
149.343 +
149.344 + color_fill4 = new((/nrow,ncol/),string)
149.345 + color_fill4 = "white"
149.346 + color_fill4(:,ncol-1) = "grey"
149.347 + color_fill4(nrow-1,:) = "green"
149.348 +
149.349 + res4 = True ; Set up resource list
149.350 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
149.351 + res4@txFontHeightF = 0.015
149.352 + res4@gsFillColor = color_fill4
149.353 +
149.354 + delete (color_fill4)
149.355 +;-------------------------------------------------------------------
149.356 +; for table value
149.357 +
149.358 + do n = 0,nrow-2
149.359 + text4(n,0) = sprintf("%5.2f", lat_ob(n))
149.360 + text4(n,1) = sprintf("%5.2f", lon_ob(n))
149.361 + text4(n,2) = year_ob(n)
149.362 + text4(n,3) = sprintf("%5.2f", M_score(n,0)) ; CO2 Flux
149.363 + text4(n,4) = sprintf("%5.2f", M_score(n,1)) ; Net Radiation
149.364 + text4(n,5) = sprintf("%5.2f", M_score(n,2)) ; Latent Heat
149.365 + text4(n,6) = sprintf("%5.2f", M_score(n,3)) ; Sensible Heat
149.366 + text4(n,7) = sprintf("%5.2f", avg(M_score(n,:))) ; avg all fields
149.367 + end do
149.368 +
149.369 +; for the last row
149.370 +
149.371 + M_co2 = avg(M_score(:,0))
149.372 + M_rad = avg(M_score(:,1))
149.373 + M_lh = avg(M_score(:,2))
149.374 + M_sh = avg(M_score(:,3))
149.375 + M_all = M_co2+ M_rad +M_lh + M_sh
149.376 +
149.377 + text4(nrow-1,0) = "-"
149.378 + text4(nrow-1,1) = "-"
149.379 + text4(nrow-1,2) = "-"
149.380 + text4(nrow-1,3) = sprintf("%5.2f", M_co2) ; avg all sites
149.381 + text4(nrow-1,4) = sprintf("%5.2f", M_rad) ; avg all sites
149.382 + text4(nrow-1,5) = sprintf("%5.2f", M_lh ) ; avg all sites
149.383 + text4(nrow-1,6) = sprintf("%5.2f", M_sh ) ; avg all sites
149.384 + text4(nrow-1,7) = sprintf("%5.2f", M_all) ; avg all sites
149.385 +
149.386 + print (M_co2)
149.387 + print (M_rad)
149.388 + print (M_lh )
149.389 + print (M_sh)
149.390 + print (M_all)
149.391 +
149.392 + M_energy_co2 = sprintf("%.2f", M_co2)
149.393 + system("sed s#M_energy_co2#"+M_energy_co2+"# "+html_name+" > "+html_new+";"+ \
149.394 + "mv -f "+html_new+" "+html_name)
149.395 + print (M_energy_co2)
149.396 +
149.397 + M_energy_rad = sprintf("%.2f", M_rad)
149.398 + system("sed s#M_energy_rad#"+M_energy_rad+"# "+html_name+" > "+html_new+";"+ \
149.399 + "mv -f "+html_new+" "+html_name)
149.400 + print (M_energy_rad)
149.401 +
149.402 + M_energy_lh = sprintf("%.2f", M_lh)
149.403 + system("sed s#M_energy_lh#"+M_energy_lh+"# "+html_name+" > "+html_new+";"+ \
149.404 + "mv -f "+html_new+" "+html_name)
149.405 + print (M_energy_lh)
149.406 +
149.407 + M_energy_sh = sprintf("%.2f", M_sh)
149.408 + system("sed s#M_energy_sh#"+M_energy_sh+"# "+html_name+" > "+html_new+";"+ \
149.409 + "mv -f "+html_new+" "+html_name)
149.410 + print (M_energy_sh)
149.411 +;---------------------------------------------------------------------------
149.412 +
149.413 + plot_name = "table_site_score"
149.414 +
149.415 + wks = gsn_open_wks (plot_type,plot_name)
149.416 +;------------------------------------------
149.417 +; for table title
149.418 +
149.419 + gRes = True
149.420 + gRes@txFontHeightF = 0.02
149.421 +; gRes@txAngleF = 90
149.422 +
149.423 + title_text = "Model " + model_name + " M_Score"
149.424 +
149.425 + gsn_text_ndc(wks,title_text,0.50,0.95,gRes)
149.426 +;------------------------------------------
149.427 +
149.428 + gsn_table(wks,ncr1,x1,y1,text1,res1)
149.429 + gsn_table(wks,ncr2,x2,y2,text2,res2)
149.430 + gsn_table(wks,ncr3,x3,y3,text3,res3)
149.431 + gsn_table(wks,ncr4,x4,y4,text4,res4)
149.432 +
149.433 + frame(wks)
149.434 +
149.435 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
149.436 + "rm "+plot_name+"."+plot_type)
149.437 +;-------------------------------------------------------------------
149.438 + temp_name = "energy." + model_name
149.439 + system("mkdir -p " + temp_name+";"+ \
149.440 + "cp "+ html_name + " " +temp_name+"/table.html"+";"+ \
149.441 + "mv *.png " + temp_name +";"+ \
149.442 + "tar cf "+ temp_name +".tar " + temp_name)
149.443 +;-------------------------------------------------------------------
149.444 +
149.445 +end
150.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
150.2 +++ b/energy/99.new.ncl Mon Jan 26 22:08:20 2009 -0500
150.3 @@ -0,0 +1,528 @@
150.4 +;************************************************************
150.5 +; required command line input parameters:
150.6 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
150.7 +;
150.8 +; using gsn_table for all
150.9 +; output: line plot for each site (4 fields)
150.10 +; table for M_score
150.11 +;************************************************************
150.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
150.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
150.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
150.15 +;************************************************************
150.16 +procedure set_line(lines:string,nline:integer,newlines:string)
150.17 +begin
150.18 +; add line to ascci/html file
150.19 +
150.20 + nnewlines = dimsizes(newlines)
150.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
150.22 + print("set_line: bad index, not setting anything.")
150.23 + return
150.24 + end if
150.25 + lines(nline:nline+nnewlines-1) = newlines
150.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
150.27 + nline = nline + nnewlines
150.28 + return
150.29 +end
150.30 +;*************************************************************
150.31 +begin
150.32 +
150.33 + plot_type = "ps"
150.34 + plot_type_new = "png"
150.35 +
150.36 +;************************************************
150.37 +; read model data
150.38 +;************************************************
150.39 +
150.40 +; model_name = "i01.10cn"
150.41 + model_name = "i01.10casa"
150.42 +
150.43 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
150.44 + film = "lnd_T42.nc"
150.45 + fm = addfile(dirm+film,"r")
150.46 +
150.47 + xm = fm->lon
150.48 + ym = fm->lat
150.49 +;------------------------------------------------
150.50 + nlat = dimsizes(ym)
150.51 + nlon = dimsizes(xm)
150.52 +
150.53 +; for 4 fields, 12-monthly
150.54 + nmon = 12
150.55 + nfield = 4
150.56 +
150.57 + data_mod0 = new ((/nfield,nmon,nlat,nlon/),float)
150.58 +
150.59 +; change to unit of observed (u mol/m2/s)
150.60 +; Model_units [=] gC/m2/s
150.61 +; 12. = molecular weight of C
150.62 +; u mol = 1e-6 mol
150.63 + factor = 1e6 /12.
150.64 +
150.65 + ENERGY ="new"
150.66 +
150.67 +;************************************************
150.68 +; read data: observed
150.69 +;************************************************
150.70 +
150.71 + station = (/"BOREAS_NSA_OBS" \
150.72 + ,"CastelPorziano" \
150.73 + ,"Hyytiala" \
150.74 + ,"Kaamanen" \
150.75 + ,"LBA_Tapajos_KM67" \
150.76 + ,"Lethbridge" \
150.77 + ,"Tharandt" \
150.78 + ,"Vielsalm" \
150.79 + /)
150.80 +
150.81 + year_ob = (/"1994-2004" \
150.82 + ,"1997-2003" \
150.83 + ,"1996-2003" \
150.84 + ,"2000-2003" \
150.85 + ,"2002-2005" \
150.86 + ,"1999-2004" \
150.87 + ,"1996-2003" \
150.88 + ,"1998-2003" \
150.89 + /)
150.90 +
150.91 + field = (/"CO2 Flux" \
150.92 + ,"Net Radiation" \
150.93 + ,"Latent Heat" \
150.94 + ,"Sensible Heat" \
150.95 + /)
150.96 +
150.97 + nstation = dimsizes(station)
150.98 + nmon = 12
150.99 + nfield = dimsizes(field)
150.100 +
150.101 + data_mod = new ((/nstation, nfield, nmon/),float)
150.102 + data_ob = new ((/nstation, nfield, nmon/),float)
150.103 + lat_ob = new ((/nstation/),float)
150.104 + lon_ob = new ((/nstation/),float)
150.105 +
150.106 + diro_root = "/fis/cgd/cseg/people/jeff/clamp_data/fluxnet/"
150.107 + dirm_root = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
150.108 +
150.109 + do n = 0,nstation-1
150.110 +
150.111 +;-------------------------------------------------
150.112 +; get ob data
150.113 +
150.114 + diro = diro_root + station(n)+"/"
150.115 + filo = station(n)+"_"+year_ob(n)+"_monthly.nc"
150.116 + fo = addfile (diro+filo,"r")
150.117 +
150.118 + print (filo)
150.119 +
150.120 + lon_ob(n) = fo->lon
150.121 + lat_ob(n) = fo->lat
150.122 +
150.123 + data = fo->CO2_FLUX
150.124 + data_ob(n,0,:) = dim_avg(data(month|:,year|:))
150.125 + delete (data)
150.126 +
150.127 + data = fo->RAD_FLUX
150.128 + data_ob(n,1,:) = dim_avg(data(month|:,year|:))
150.129 + delete (data)
150.130 +
150.131 + data = fo->LH_FLUX
150.132 + data_ob(n,2,:) = dim_avg(data(month|:,year|:))
150.133 + delete (data)
150.134 +
150.135 + data = fo->SH_FLUX
150.136 + data_ob(n,3,:) = dim_avg(data(month|:,year|:))
150.137 + delete (data)
150.138 +
150.139 + delete (fo)
150.140 +;---------------------------------------------------
150.141 +; get model data
150.142 +
150.143 + film = model_name+"_"+year_ob(n)+"_MONS_climo.nc"
150.144 + fm = addfile (dirm_root+film,"r")
150.145 +
150.146 + print (film)
150.147 +
150.148 +if (ENERGY .eq. "old") then
150.149 +
150.150 + data = fm->NEE
150.151 + data_mod0(0,:,:,:) = data(:,:,:) * factor
150.152 + delete (data)
150.153 +
150.154 +; data = fm->LATENT
150.155 + data1 = fm->FCEV
150.156 + data2 = fm->FCTR
150.157 + data3 = fm->FGEV
150.158 + data_mod0(2,:,:,:) = data1(:,:,:)+data2(:,:,:)+data3(:,:,:)
150.159 + delete (data1)
150.160 + delete (data2)
150.161 + delete (data3)
150.162 +
150.163 +; data = fm->SENSIBLE
150.164 + data = fm->FSH
150.165 + data_mod0(3,:,:,:) = data(:,:,:)
150.166 + delete (data)
150.167 +
150.168 +; data = fm->NETRAD
150.169 + data1 = fm->FSA
150.170 + data2 = fm->FIRA
150.171 + data_mod0(1,:,:,:) = data1(:,:,:)-data2(:,:,:)-data_mod0(2,:,:,:)-data_mod0(3,:,:,:)
150.172 + delete (data1)
150.173 + delete (data2)
150.174 +
150.175 +else
150.176 +
150.177 + data = fm->NEE
150.178 + data_mod0(0,:,:,:) = data(:,:,:) * factor
150.179 + delete (data)
150.180 +
150.181 + data = fm->NETRAD
150.182 + data_mod0(1,:,:,:) = data(:,:,:)
150.183 + delete (data)
150.184 +
150.185 + data = fm->LATENT
150.186 + data_mod0(2,:,:,:) = data(:,:,:)
150.187 + delete (data)
150.188 +
150.189 +; data = fm->SENSIBLE
150.190 + data = fm->FSH
150.191 + data_mod0(3,:,:,:) = data(:,:,:)
150.192 + delete (data)
150.193 +end if
150.194 +
150.195 + delete (fm)
150.196 +
150.197 +;************************************************************
150.198 +; interpolate model data into observed station
150.199 +; note: model is 0-360E, 90S-90N
150.200 +;************************************************************
150.201 +
150.202 +; to be able to handle observation at (-89.98,-24.80)
150.203 + ym(0) = -90.
150.204 +
150.205 + yy = linint2_points_Wrap(xm,ym,data_mod0,True,lon_ob(n),lat_ob(n),0)
150.206 +
150.207 +; print (yy)
150.208 +
150.209 + data_mod(n,:,:) = yy(:,:,0)
150.210 +
150.211 + delete (yy)
150.212 +
150.213 + end do
150.214 +;************************************************************
150.215 +; compute correlation coef and M score
150.216 +;************************************************************
150.217 +
150.218 + score_max = 5.
150.219 +
150.220 + ccr = new ((/nstation, nfield/),float)
150.221 + M_score = new ((/nstation, nfield/),float)
150.222 +
150.223 + do n=0,nstation-1
150.224 + do m=0,nfield-1
150.225 + ccr(n,m) = esccr(data_ob(n,m,:),data_mod(n,m,:),0)
150.226 + bias = sum(abs(data_mod(n,m,:)-data_ob(n,m,:))/(abs(data_mod(n,m,:))+abs(data_ob(n,m,:))))
150.227 + M_score(n,m) = (1. -(bias/nmon)) * score_max
150.228 + end do
150.229 + end do
150.230 +
150.231 + M_co2 = avg(M_score(:,0))
150.232 + M_rad = avg(M_score(:,1))
150.233 + M_lh = avg(M_score(:,2))
150.234 + M_sh = avg(M_score(:,3))
150.235 + M_all = M_co2+ M_rad +M_lh + M_sh
150.236 +
150.237 + M_energy_co2 = sprintf("%.2f", M_co2)
150.238 + M_energy_rad = sprintf("%.2f", M_rad)
150.239 + M_energy_lh = sprintf("%.2f", M_lh )
150.240 + M_energy_sh = sprintf("%.2f", M_sh )
150.241 + M_energy_all = sprintf("%.2f", M_all)
150.242 +
150.243 +;*******************************************************************
150.244 +; for station line plot
150.245 +;*******************************************************************
150.246 +
150.247 +; for x-axis in xyplot
150.248 + mon = ispan(1,12,1)
150.249 + mon@long_name = "month"
150.250 +
150.251 + res = True ; plot mods desired
150.252 + res@xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
150.253 + res@xyLineColors = (/"blue","red"/) ; line color (ob,model)
150.254 +;-------------------------------------------------------------------------
150.255 +; Add a boxed legend using the more simple method
150.256 +
150.257 + res@pmLegendDisplayMode = "Always"
150.258 +; res@pmLegendWidthF = 0.1
150.259 + res@pmLegendWidthF = 0.08
150.260 + res@pmLegendHeightF = 0.06
150.261 +; res@pmLegendOrthogonalPosF = -1.17
150.262 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
150.263 + res@pmLegendOrthogonalPosF = -0.30 ;(downward)
150.264 +
150.265 +; res@pmLegendParallelPosF = 0.18
150.266 + res@pmLegendParallelPosF = 0.23 ;(rightward)
150.267 +
150.268 +; res@lgPerimOn = False
150.269 + res@lgLabelFontHeightF = 0.015
150.270 + res@xyExplicitLegendLabels = (/"observed",model_name/)
150.271 +;-------------------------------------------------------------------
150.272 +; for panel plot
150.273 + res@gsnFrame = False ; Do not draw plot
150.274 + res@gsnDraw = False ; Do not advance frame
150.275 +
150.276 + pres = True ; panel plot mods desired
150.277 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
150.278 + ; indiv. plots in panel
150.279 + pres@gsnMaximize = True ; fill the page
150.280 +;-------------------------------------------------------------------
150.281 +
150.282 + plot_data = new((/2,12/),float)
150.283 + plot_data!0 = "case"
150.284 + plot_data!1 = "month"
150.285 +
150.286 + do n = 0,nstation-1
150.287 +;----------------------------
150.288 +; for observed
150.289 +
150.290 + plot_name = station(n)+"_ob"
150.291 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
150.292 + res@tiMainString = title
150.293 +
150.294 + wks = gsn_open_wks (plot_type,plot_name)
150.295 + plot=new(4,graphic) ; create graphic array
150.296 +
150.297 + plot_data(0,:) = (/data_ob (n,0,:)/)
150.298 + plot_data@long_name = field(0)
150.299 + plot(0)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 1
150.300 +
150.301 + plot_data(0,:) = (/data_ob (n,1,:)/)
150.302 + plot_data@long_name = field(1)
150.303 + plot(1)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 2
150.304 +
150.305 + plot_data(0,:) = (/data_ob (n,2,:)/)
150.306 + plot_data@long_name = field(2)
150.307 + plot(2)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 3
150.308 +
150.309 + plot_data(0,:) = (/data_ob (n,3,:)/)
150.310 + plot_data@long_name = field(3)
150.311 + plot(3)=gsn_csm_xy(wks,mon,plot_data(0,:),res) ; create plot 4
150.312 +
150.313 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
150.314 +
150.315 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
150.316 + "rm "+plot_name+"."+plot_type)
150.317 +
150.318 + clear (wks)
150.319 + delete (plot)
150.320 +;----------------------------
150.321 +; for model_vs_ob
150.322 +
150.323 + plot_name = station(n)+"_model_vs_ob"
150.324 + title = station(n)+"("+sprintf("%5.2f",lat_ob(n))+","+sprintf("%5.2f",lon_ob(n))+")"
150.325 + res@tiMainString = title
150.326 +
150.327 + wks = gsn_open_wks (plot_type,plot_name)
150.328 + plot=new(4,graphic) ; create graphic array
150.329 +
150.330 + plot_data(0,:) = (/data_ob (n,0,:)/)
150.331 + plot_data(1,:) = (/data_mod(n,0,:)/)
150.332 + plot_data@long_name = field(0)
150.333 + plot(0)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 1
150.334 +
150.335 + plot_data(0,:) = (/data_ob (n,1,:)/)
150.336 + plot_data(1,:) = (/data_mod(n,1,:)/)
150.337 + plot_data@long_name = field(1)
150.338 + plot(1)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 2
150.339 +
150.340 + plot_data(0,:) = (/data_ob (n,2,:)/)
150.341 + plot_data(1,:) = (/data_mod(n,2,:)/)
150.342 + plot_data@long_name = field(2)
150.343 + plot(2)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 3
150.344 +
150.345 + plot_data(0,:) = (/data_ob (n,3,:)/)
150.346 + plot_data(1,:) = (/data_mod(n,3,:)/)
150.347 + plot_data@long_name = field(3)
150.348 + plot(3)=gsn_csm_xy(wks,mon,plot_data,res) ; create plot 4
150.349 +
150.350 + gsn_panel(wks,plot,(/2,2/),pres) ; create panel plot
150.351 +
150.352 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
150.353 + "rm "+plot_name+"."+plot_type)
150.354 +
150.355 + clear (wks)
150.356 + delete (plot)
150.357 + end do
150.358 +
150.359 +;*******************************************************************
150.360 +; html table of site: observed
150.361 +;*******************************************************************
150.362 + output_html = "line_ob.html"
150.363 +
150.364 + header = (/"<HTML>" \
150.365 + ,"<HEAD>" \
150.366 + ,"<TITLE>CLAMP metrics</TITLE>" \
150.367 + ,"</HEAD>" \
150.368 + ,"<H1>Energy at Site: Observation</H1>" \
150.369 + /)
150.370 + footer = "</HTML>"
150.371 +
150.372 + table_header = (/ \
150.373 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
150.374 + ,"<tr>" \
150.375 + ," <th bgcolor=DDDDDD >Site Name</th>" \
150.376 + ," <th bgcolor=DDDDDD >Latitude</th>" \
150.377 + ," <th bgcolor=DDDDDD >Longitude</th>" \
150.378 + ," <th bgcolor=DDDDDD >Observed</th>" \
150.379 + ,"</tr>" \
150.380 + /)
150.381 + table_footer = "</table>"
150.382 + row_header = "<tr>"
150.383 + row_footer = "</tr>"
150.384 +
150.385 + lines = new(50000,string)
150.386 + nline = 0
150.387 +
150.388 + set_line(lines,nline,header)
150.389 + set_line(lines,nline,table_header)
150.390 +;-----------------------------------------------
150.391 +; row of table
150.392 +
150.393 + do n = 0,nstation-1
150.394 + set_line(lines,nline,row_header)
150.395 +
150.396 + txt0 = station(n)
150.397 + txt1 = sprintf("%5.2f", lat_ob(n))
150.398 + txt2 = sprintf("%5.2f", lon_ob(n))
150.399 + txt3 = year_ob(n)
150.400 +
150.401 + set_line(lines,nline,"<th><a href="+txt0+"_ob.png>"+txt0+"</a></th>")
150.402 + set_line(lines,nline,"<th>"+txt1+"</th>")
150.403 + set_line(lines,nline,"<th>"+txt2+"</th>")
150.404 + set_line(lines,nline,"<th>"+txt3+"</th>")
150.405 +
150.406 + set_line(lines,nline,row_footer)
150.407 + end do
150.408 +;-----------------------------------------------
150.409 + set_line(lines,nline,table_footer)
150.410 + set_line(lines,nline,footer)
150.411 +
150.412 +; Now write to an HTML file.
150.413 + idx = ind(.not.ismissing(lines))
150.414 + if(.not.any(ismissing(idx))) then
150.415 + asciiwrite(output_html,lines(idx))
150.416 + else
150.417 + print ("error?")
150.418 + end if
150.419 + delete (idx)
150.420 +
150.421 +;*******************************************************************
150.422 +; score and line table : model vs observed
150.423 +;*******************************************************************
150.424 + output_html = "score+line_vs_ob.html"
150.425 +
150.426 + header = (/"<HTML>" \
150.427 + ,"<HEAD>" \
150.428 + ,"<TITLE>CLAMP metrics</TITLE>" \
150.429 + ,"</HEAD>" \
150.430 + ,"<H1>Energy at Site: Model "+model_name+"</H1>" \
150.431 + /)
150.432 + footer = "</HTML>"
150.433 +
150.434 + delete (table_header)
150.435 + table_header = (/ \
150.436 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
150.437 + ,"<tr>" \
150.438 + ," <th bgcolor=DDDDDD >Site Name</th>" \
150.439 + ," <th bgcolor=DDDDDD >Latitude</th>" \
150.440 + ," <th bgcolor=DDDDDD >Longitude</th>" \
150.441 + ," <th bgcolor=DDDDDD >Observed</th>" \
150.442 + ," <th bgcolor=DDDDDD >CO2 Flux</th>" \
150.443 + ," <th bgcolor=DDDDDD >Net Radiation</th>" \
150.444 + ," <th bgcolor=DDDDDD >Latent Heat</th>" \
150.445 + ," <th bgcolor=DDDDDD >Sensible Heat</th>" \
150.446 + ," <th bgcolor=DDDDDD >Average</th>" \
150.447 + ,"</tr>" \
150.448 + /)
150.449 + table_footer = "</table>"
150.450 + row_header = "<tr>"
150.451 + row_footer = "</tr>"
150.452 +
150.453 + lines = new(50000,string)
150.454 + nline = 0
150.455 +
150.456 + set_line(lines,nline,header)
150.457 + set_line(lines,nline,table_header)
150.458 +;-----------------------------------------------
150.459 +; row of table
150.460 +
150.461 + do n = 0,nstation-1
150.462 + set_line(lines,nline,row_header)
150.463 +
150.464 + txt0 = station(n)
150.465 + txt1 = sprintf("%5.2f", lat_ob(n))
150.466 + txt2 = sprintf("%5.2f", lon_ob(n))
150.467 + txt3 = year_ob(n)
150.468 + txt4 = sprintf("%5.2f", M_score(n,0))
150.469 + txt5 = sprintf("%5.2f", M_score(n,1))
150.470 + txt6 = sprintf("%5.2f", M_score(n,2))
150.471 + txt7 = sprintf("%5.2f", M_score(n,3))
150.472 + txt8 = sprintf("%5.2f", avg(M_score(n,:)))
150.473 +
150.474 + set_line(lines,nline,"<th><a href="+txt0+"_model_vs_ob.png>"+txt0+"</a></th>")
150.475 + set_line(lines,nline,"<th>"+txt1+"</th>")
150.476 + set_line(lines,nline,"<th>"+txt2+"</th>")
150.477 + set_line(lines,nline,"<th>"+txt3+"</th>")
150.478 + set_line(lines,nline,"<th>"+txt4+"</th>")
150.479 + set_line(lines,nline,"<th>"+txt5+"</th>")
150.480 + set_line(lines,nline,"<th>"+txt6+"</th>")
150.481 + set_line(lines,nline,"<th>"+txt7+"</th>")
150.482 + set_line(lines,nline,"<th>"+txt8+"</th>")
150.483 +
150.484 + set_line(lines,nline,row_footer)
150.485 + end do
150.486 +
150.487 +; last row, summary
150.488 + set_line(lines,nline,row_header)
150.489 +
150.490 + txt0 = "All_"+sprintf("%.0f", nstation)
150.491 + txt1 = "-"
150.492 + txt2 = "-"
150.493 + txt3 = "-"
150.494 + txt4 = M_energy_co2
150.495 + txt5 = M_energy_rad
150.496 + txt6 = M_energy_lh
150.497 + txt7 = M_energy_sh
150.498 + txt8 = M_energy_all
150.499 +
150.500 + set_line(lines,nline,"<th>"+txt0+"</th>")
150.501 + set_line(lines,nline,"<th>"+txt1+"</th>")
150.502 + set_line(lines,nline,"<th>"+txt2+"</th>")
150.503 + set_line(lines,nline,"<th>"+txt3+"</th>")
150.504 + set_line(lines,nline,"<th>"+txt4+"</th>")
150.505 + set_line(lines,nline,"<th>"+txt5+"</th>")
150.506 + set_line(lines,nline,"<th>"+txt6+"</th>")
150.507 + set_line(lines,nline,"<th>"+txt7+"</th>")
150.508 + set_line(lines,nline,"<th>"+txt8+"</th>")
150.509 +
150.510 + set_line(lines,nline,row_footer)
150.511 +;-----------------------------------------------
150.512 + set_line(lines,nline,table_footer)
150.513 + set_line(lines,nline,footer)
150.514 +
150.515 +; Now write to an HTML file.
150.516 + idx = ind(.not.ismissing(lines))
150.517 + if(.not.any(ismissing(idx))) then
150.518 + asciiwrite(output_html,lines(idx))
150.519 + else
150.520 + print ("error?")
150.521 + end if
150.522 + delete (idx)
150.523 +
150.524 +;***************************************************************************
150.525 +; output plots
150.526 +;***************************************************************************
150.527 + output_dir = model_name+"/energy"
150.528 +
150.529 + system("mv *.png *.html " + output_dir)
150.530 +;***************************************************************************
150.531 +end
151.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
151.2 +++ b/fire/10.1x1_to_1.9.ncl Mon Jan 26 22:08:20 2009 -0500
151.3 @@ -0,0 +1,141 @@
151.4 +;---------------------------------------------------------------
151.5 +; convert from 1x1 to T31/T42
151.6 +;
151.7 +; use model T31/T42 lat and lon
151.8 +; output model area, too.
151.9 +;
151.10 +;-------------------------------------------------------------
151.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
151.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
151.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
151.14 +undef("copyatt")
151.15 +load "/fis/cgd/cseg/people/jeff/ncl/remap_areaave.ncl"
151.16 +begin
151.17 +;************************************************
151.18 +; output data
151.19 +;************************************************
151.20 + diro = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
151.21 + filo = "Fire_C_1997-2006_monthly_1.9.nc"
151.22 + c = addfile(diro+filo,"c")
151.23 + filedimdef(c,"year",-1,True)
151.24 +
151.25 +;******************************************************
151.26 +; input grid: 1deg x 1deg, N->S, 180W-180E
151.27 +;******************************************************
151.28 + diri = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
151.29 + fili = "Fire_C_1997-2006_monthly_1x1.nc"
151.30 + g = addfile (diri+fili,"r")
151.31 + bi = g->FIRE_C
151.32 + xi = g->lon
151.33 + yi = g->lat
151.34 +
151.35 + dsizes = dimsizes(bi)
151.36 + nyear = dsizes(0)
151.37 + nmonth = dsizes(1)
151.38 + nlatx = dsizes(2)
151.39 + nlonx = dsizes(3)
151.40 +
151.41 +;===================================================
151.42 +; change from 180W-180E, 90N-90S to 0-360E, 90S-90N
151.43 +;===================================================
151.44 +
151.45 + yi = (/ yi(::-1) /)
151.46 + bi = (/ bi(:,:,::-1,:) /)
151.47 +
151.48 + b2 = bi
151.49 + x2 = xi
151.50 +
151.51 + do i= 0,nlonx-1
151.52 + if (i .lt. 180) then
151.53 + p = i + 180
151.54 + xi(p) = x2(i) + 360.
151.55 + else
151.56 + p = i - 180
151.57 + xi(p) = x2(i)
151.58 + end if
151.59 + bi(:,:,:,p)= b2(:,:,:,i)
151.60 + end do
151.61 +
151.62 + bi&lat = yi
151.63 + bi&lon = xi
151.64 +
151.65 + print (xi)
151.66 + print (yi)
151.67 +
151.68 +;==================================================
151.69 +; edges
151.70 +;==================================================
151.71 +
151.72 + xi_edge = fspan(0.0, 360.0, nlonx+1)
151.73 + xi_edge@units = "degrees_east"
151.74 + yi_edge = fspan(-90.0, 90.0, nlatx+1)
151.75 + yi_edge@units = "degrees_north"
151.76 +
151.77 +;==================================================
151.78 +; area
151.79 +;==================================================
151.80 +
151.81 + deg2rad = 4.0*atan(1.0)/180.0
151.82 + earth_rad = 6.37122e6
151.83 + dx = earth_rad * deg2rad * (xi_edge(1)-xi_edge(0))
151.84 + dsin = sin(deg2rad*yi_edge(1:180)) - sin(deg2rad*yi_edge(0:179))
151.85 + area_in = new((/ nlatx, nlonx /), float)
151.86 + area_in = conform(area_in, earth_rad*dx*dsin,0)
151.87 + area_in@units = "m^2"
151.88 +
151.89 +;**************************************************************
151.90 +; output grid: (0-360), (90S-90N)
151.91 +;**************************************************************
151.92 +; interpolate into model T31/T42, using model lat and lon
151.93 +
151.94 + diri = "/fis/cgd/cseg/people/jeff/surface_data/"
151.95 + fili = "lnd_1.9.nc"
151.96 + b = addfile(diri+fili,"r")
151.97 +
151.98 + yo = b->lat
151.99 + xo = b->lon
151.100 + nlat = dimsizes(yo)
151.101 + nlon = dimsizes(xo)
151.102 +
151.103 + xo_edge = fspan(0.0, 360.0, nlon+1) - 0.5*360.0/nlon
151.104 + xo_edge@units = "degrees_east"
151.105 +
151.106 + yo_edge = new(nlat+1, float)
151.107 + gau_info = gaus(nlat/2)
151.108 + yo_edge(0) = -90.0
151.109 + yo_edge(1:nlat-1) = doubletofloat(0.5*(gau_info(0:nlat-2,0)+gau_info(1:nlat-1,0)))
151.110 + yo_edge(nlat) = 90.0
151.111 + yo_edge@units = "degrees_north"
151.112 +
151.113 +; yo = 0.5*(yo_edge(0:nlat-1) + yo_edge(1:nlat))
151.114 +; yo@units = yo_edge@units
151.115 +; xo = 0.5*(xo_edge(0:nlon-1) + xo_edge(1:nlon))
151.116 +; xo@units = xo_edge@units
151.117 +
151.118 +;===================================================
151.119 +; output
151.120 +;===================================================
151.121 +
151.122 + w = new((/nyear,nmonth,nlat,nlon/),float)
151.123 +
151.124 + do m = 0,nyear-1
151.125 + do n = 0,nmonth-1
151.126 + w(m,n,:,:) = remap_areaave(xi_edge, yi_edge, bi(m,n,:,:), xo_edge, yo_edge)
151.127 + end do
151.128 + end do
151.129 +
151.130 + w!0 = "year"
151.131 + w!1 = "month"
151.132 + w!2 = "lat"
151.133 + w&lat = yo
151.134 + w!3 = "lon"
151.135 + w&lon = xo
151.136 + w@units = bi@units
151.137 + w@long_name = bi@long_name
151.138 + w@_FillValue = bi@_FillValue
151.139 +
151.140 + c->FIRE_C = w
151.141 + c->date = g->date
151.142 + c->area = b->area
151.143 +
151.144 +end
152.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
152.2 +++ b/fire/10.1x1_to_T31.ncl Mon Jan 26 22:08:20 2009 -0500
152.3 @@ -0,0 +1,140 @@
152.4 +;---------------------------------------------------------------
152.5 +; convert from 1x1 to T31/T42
152.6 +;
152.7 +; use model T31/T42 lat and lon
152.8 +; output model area, too.
152.9 +;
152.10 +;-------------------------------------------------------------
152.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
152.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
152.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
152.14 +undef("copyatt")
152.15 +load "/fis/cgd/cseg/people/jeff/ncl/remap_areaave.ncl"
152.16 +begin
152.17 +;************************************************
152.18 +; output data
152.19 +;************************************************
152.20 + diro = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
152.21 + filo = "Fire_C_1997-2006_monthly_T31.nc"
152.22 + c = addfile(diro+filo,"c")
152.23 + filedimdef(c,"year",-1,True)
152.24 +
152.25 +;******************************************************
152.26 +; input grid: 1deg x 1deg, N->S, 180W-180E
152.27 +;******************************************************
152.28 + diri = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
152.29 + fili = "Fire_C_1997-2006_monthly_1x1.nc"
152.30 + g = addfile (diri+fili,"r")
152.31 + bi = g->FIRE_C
152.32 + xi = g->lon
152.33 + yi = g->lat
152.34 +
152.35 + dsizes = dimsizes(bi)
152.36 + nyear = dsizes(0)
152.37 + nmonth = dsizes(1)
152.38 + nlatx = dsizes(2)
152.39 + nlonx = dsizes(3)
152.40 +
152.41 +;===================================================
152.42 +; change from 180W-180E, 90N-90S to 0-360E, 90S-90N
152.43 +;===================================================
152.44 +
152.45 + yi = (/ yi(::-1) /)
152.46 + bi = (/ bi(:,:,::-1,:) /)
152.47 +
152.48 + b2 = bi
152.49 + x2 = xi
152.50 +
152.51 + do i= 0,nlonx-1
152.52 + if (i .lt. 180) then
152.53 + p = i + 180
152.54 + xi(p) = x2(i) + 360.
152.55 + else
152.56 + p = i - 180
152.57 + xi(p) = x2(i)
152.58 + end if
152.59 + bi(:,:,:,p)= b2(:,:,:,i)
152.60 + end do
152.61 +
152.62 + bi&lat = yi
152.63 + bi&lon = xi
152.64 +
152.65 + print (xi)
152.66 + print (yi)
152.67 +
152.68 +;==================================================
152.69 +; edges
152.70 +;==================================================
152.71 +
152.72 + xi_edge = fspan(0.0, 360.0, nlonx+1)
152.73 + xi_edge@units = "degrees_east"
152.74 + yi_edge = fspan(-90.0, 90.0, nlatx+1)
152.75 + yi_edge@units = "degrees_north"
152.76 +
152.77 +;==================================================
152.78 +; area
152.79 +;==================================================
152.80 +
152.81 + deg2rad = 4.0*atan(1.0)/180.0
152.82 + earth_rad = 6.37122e6
152.83 + dx = earth_rad * deg2rad * (xi_edge(1)-xi_edge(0))
152.84 + dsin = sin(deg2rad*yi_edge(1:180)) - sin(deg2rad*yi_edge(0:179))
152.85 + area_in = new((/ nlatx, nlonx /), float)
152.86 + area_in = conform(area_in, earth_rad*dx*dsin,0)
152.87 + area_in@units = "m^2"
152.88 +
152.89 +;**************************************************************
152.90 +; output grid: (0-360), (90S-90N)
152.91 +;**************************************************************
152.92 +; interpolate into model T31/T42, using model data
152.93 + diri = "/fis/cgd/cseg/people/jeff/fire_data/model/"
152.94 + fili = "b30.061n_1980-1990_ANN_climo.nc"
152.95 + b = addfile(diri+fili,"r")
152.96 +
152.97 + yo = b->lat
152.98 + xo = b->lon
152.99 + nlat = dimsizes(yo)
152.100 + nlon = dimsizes(xo)
152.101 +
152.102 + xo_edge = fspan(0.0, 360.0, nlon+1) - 0.5*360.0/nlon
152.103 + xo_edge@units = "degrees_east"
152.104 +
152.105 + yo_edge = new(nlat+1, float)
152.106 + gau_info = gaus(nlat/2)
152.107 + yo_edge(0) = -90.0
152.108 + yo_edge(1:nlat-1) = doubletofloat(0.5*(gau_info(0:nlat-2,0)+gau_info(1:nlat-1,0)))
152.109 + yo_edge(nlat) = 90.0
152.110 + yo_edge@units = "degrees_north"
152.111 +
152.112 +; yo = 0.5*(yo_edge(0:nlat-1) + yo_edge(1:nlat))
152.113 +; yo@units = yo_edge@units
152.114 +; xo = 0.5*(xo_edge(0:nlon-1) + xo_edge(1:nlon))
152.115 +; xo@units = xo_edge@units
152.116 +
152.117 +;===================================================
152.118 +; output
152.119 +;===================================================
152.120 +
152.121 + w = new((/nyear,nmonth,nlat,nlon/),float)
152.122 +
152.123 + do m = 0,nyear-1
152.124 + do n = 0,nmonth-1
152.125 + w(m,n,:,:) = remap_areaave(xi_edge, yi_edge, bi(m,n,:,:), xo_edge, yo_edge)
152.126 + end do
152.127 + end do
152.128 +
152.129 + w!0 = "year"
152.130 + w!1 = "month"
152.131 + w!2 = "lat"
152.132 + w&lat = yo
152.133 + w!3 = "lon"
152.134 + w&lon = xo
152.135 + w@units = bi@units
152.136 + w@long_name = bi@long_name
152.137 + w@_FillValue = bi@_FillValue
152.138 +
152.139 + c->FIRE_C = w
152.140 + c->date = g->date
152.141 + c->area = b->area
152.142 +
152.143 +end
153.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
153.2 +++ b/fire/10.1x1_to_T42.ncl Mon Jan 26 22:08:20 2009 -0500
153.3 @@ -0,0 +1,141 @@
153.4 +;---------------------------------------------------------------
153.5 +; convert from 1x1 to T31/T42
153.6 +;
153.7 +; use model T31/T42 lat and lon
153.8 +; output model area, too.
153.9 +;
153.10 +;-------------------------------------------------------------
153.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
153.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
153.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
153.14 +undef("copyatt")
153.15 +load "/fis/cgd/cseg/people/jeff/ncl/remap_areaave.ncl"
153.16 +begin
153.17 +;************************************************
153.18 +; output data
153.19 +;************************************************
153.20 + diro = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
153.21 + filo = "Fire_C_1997-2006_monthly_T42.nc"
153.22 + c = addfile(diro+filo,"c")
153.23 + filedimdef(c,"year",-1,True)
153.24 +
153.25 +;******************************************************
153.26 +; input grid: 1deg x 1deg, N->S, 180W-180E
153.27 +;******************************************************
153.28 + diri = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
153.29 + fili = "Fire_C_1997-2006_monthly_1x1.nc"
153.30 + g = addfile (diri+fili,"r")
153.31 + bi = g->FIRE_C
153.32 + xi = g->lon
153.33 + yi = g->lat
153.34 +
153.35 + dsizes = dimsizes(bi)
153.36 + nyear = dsizes(0)
153.37 + nmonth = dsizes(1)
153.38 + nlatx = dsizes(2)
153.39 + nlonx = dsizes(3)
153.40 +
153.41 +;===================================================
153.42 +; change from 180W-180E, 90N-90S to 0-360E, 90S-90N
153.43 +;===================================================
153.44 +
153.45 + yi = (/ yi(::-1) /)
153.46 + bi = (/ bi(:,:,::-1,:) /)
153.47 +
153.48 + b2 = bi
153.49 + x2 = xi
153.50 +
153.51 + do i= 0,nlonx-1
153.52 + if (i .lt. 180) then
153.53 + p = i + 180
153.54 + xi(p) = x2(i) + 360.
153.55 + else
153.56 + p = i - 180
153.57 + xi(p) = x2(i)
153.58 + end if
153.59 + bi(:,:,:,p)= b2(:,:,:,i)
153.60 + end do
153.61 +
153.62 + bi&lat = yi
153.63 + bi&lon = xi
153.64 +
153.65 + print (xi)
153.66 + print (yi)
153.67 +
153.68 +;==================================================
153.69 +; edges
153.70 +;==================================================
153.71 +
153.72 + xi_edge = fspan(0.0, 360.0, nlonx+1)
153.73 + xi_edge@units = "degrees_east"
153.74 + yi_edge = fspan(-90.0, 90.0, nlatx+1)
153.75 + yi_edge@units = "degrees_north"
153.76 +
153.77 +;==================================================
153.78 +; area
153.79 +;==================================================
153.80 +
153.81 + deg2rad = 4.0*atan(1.0)/180.0
153.82 + earth_rad = 6.37122e6
153.83 + dx = earth_rad * deg2rad * (xi_edge(1)-xi_edge(0))
153.84 + dsin = sin(deg2rad*yi_edge(1:180)) - sin(deg2rad*yi_edge(0:179))
153.85 + area_in = new((/ nlatx, nlonx /), float)
153.86 + area_in = conform(area_in, earth_rad*dx*dsin,0)
153.87 + area_in@units = "m^2"
153.88 +
153.89 +;**************************************************************
153.90 +; output grid: (0-360), (90S-90N)
153.91 +;**************************************************************
153.92 +; interpolate into model T31/T42, using model lat and lon
153.93 +
153.94 + diri = "/fis/cgd/cseg/people/jeff/surface_data/"
153.95 + fili = "lnd_T42.nc"
153.96 + b = addfile(diri+fili,"r")
153.97 +
153.98 + yo = b->lat
153.99 + xo = b->lon
153.100 + nlat = dimsizes(yo)
153.101 + nlon = dimsizes(xo)
153.102 +
153.103 + xo_edge = fspan(0.0, 360.0, nlon+1) - 0.5*360.0/nlon
153.104 + xo_edge@units = "degrees_east"
153.105 +
153.106 + yo_edge = new(nlat+1, float)
153.107 + gau_info = gaus(nlat/2)
153.108 + yo_edge(0) = -90.0
153.109 + yo_edge(1:nlat-1) = doubletofloat(0.5*(gau_info(0:nlat-2,0)+gau_info(1:nlat-1,0)))
153.110 + yo_edge(nlat) = 90.0
153.111 + yo_edge@units = "degrees_north"
153.112 +
153.113 +; yo = 0.5*(yo_edge(0:nlat-1) + yo_edge(1:nlat))
153.114 +; yo@units = yo_edge@units
153.115 +; xo = 0.5*(xo_edge(0:nlon-1) + xo_edge(1:nlon))
153.116 +; xo@units = xo_edge@units
153.117 +
153.118 +;===================================================
153.119 +; output
153.120 +;===================================================
153.121 +
153.122 + w = new((/nyear,nmonth,nlat,nlon/),float)
153.123 +
153.124 + do m = 0,nyear-1
153.125 + do n = 0,nmonth-1
153.126 + w(m,n,:,:) = remap_areaave(xi_edge, yi_edge, bi(m,n,:,:), xo_edge, yo_edge)
153.127 + end do
153.128 + end do
153.129 +
153.130 + w!0 = "year"
153.131 + w!1 = "month"
153.132 + w!2 = "lat"
153.133 + w&lat = yo
153.134 + w!3 = "lon"
153.135 + w&lon = xo
153.136 + w@units = bi@units
153.137 + w@long_name = bi@long_name
153.138 + w@_FillValue = bi@_FillValue
153.139 +
153.140 + c->FIRE_C = w
153.141 + c->date = g->date
153.142 + c->area = b->area
153.143 +
153.144 +end
154.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
154.2 +++ b/fire/21.table+tseries.ncl Mon Jan 26 22:08:20 2009 -0500
154.3 @@ -0,0 +1,258 @@
154.4 +;********************************************************
154.5 +;using model biome vlass
154.6 +;
154.7 +; required command line input parameters:
154.8 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
154.9 +;
154.10 +; histogram normalized by rain and compute correleration
154.11 +;**************************************************************
154.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
154.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
154.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
154.15 +;**************************************************************
154.16 +procedure set_line(lines:string,nline:integer,newlines:string)
154.17 +begin
154.18 +; add line to ascci/html file
154.19 +
154.20 + nnewlines = dimsizes(newlines)
154.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
154.22 + print("set_line: bad index, not setting anything.")
154.23 + return
154.24 + end if
154.25 + lines(nline:nline+nnewlines-1) = newlines
154.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
154.27 + nline = nline + nnewlines
154.28 + return
154.29 +end
154.30 +;**************************************************************
154.31 +; Main code.
154.32 +begin
154.33 +
154.34 + plot_type = "ps"
154.35 + plot_type_new = "png"
154.36 +
154.37 +;---------------------------------------------------
154.38 +; model name and grid
154.39 +
154.40 + model_grid = "T42"
154.41 +
154.42 + model_name = "cn"
154.43 + model_name1 = "i01.06cn"
154.44 + model_name2 = "i01.10cn"
154.45 +
154.46 +;---------------------------------------------------
154.47 +; get biome data: model
154.48 +
154.49 + biome_name_mod = "Model PFT Class"
154.50 +
154.51 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
154.52 + film = "class_pft_"+model_grid+".nc"
154.53 + fm = addfile(dirm+film,"r")
154.54 +
154.55 + classmod = fm->CLASS_PFT
154.56 +
154.57 + delete (fm)
154.58 +
154.59 +; model data has 17 land-type classes
154.60 +
154.61 + nclass_mod = 17
154.62 +
154.63 +;--------------------------------------------------
154.64 +; get model data: landfrac and area
154.65 +
154.66 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
154.67 + film = "lnd_T42.nc"
154.68 + fm = addfile (dirm+film,"r")
154.69 +
154.70 + landmask = fm->landmask
154.71 + landfrac = fm->landfrac
154.72 + area = fm->area
154.73 +
154.74 + delete (fm)
154.75 +
154.76 +; change area from km**2 to m**2
154.77 + area = area * 1.e6
154.78 +
154.79 +;----------------------------------------------------
154.80 +; read data: time series, model
154.81 +
154.82 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
154.83 + film = model_name2 + "_Fire_C_1979-2004_monthly.nc"
154.84 + fm = addfile (dirm+film,"r")
154.85 +
154.86 + data_mod = fm->COL_FIRE_CLOSS(18:25,:,:,:)
154.87 +
154.88 + delete (fm)
154.89 +
154.90 +; Units for these variables are:
154.91 +; g C/m^2/s
154.92 +
154.93 +; change unit to g C/m^2/month
154.94 +
154.95 + nsec_per_month = 60*60*24*30
154.96 +
154.97 + data_mod = data_mod * nsec_per_month
154.98 +
154.99 + data_mod@unit = "gC/m2/month"
154.100 +;----------------------------------------------------
154.101 +; read data: time series, observed
154.102 +
154.103 + dirm = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
154.104 + film = "Fire_C_1997-2006_monthly_"+ model_grid+".nc"
154.105 + fm = addfile (dirm+film,"r")
154.106 +
154.107 + data_ob = fm->FIRE_C(0:7,:,:,:)
154.108 +
154.109 + delete (fm)
154.110 +
154.111 + ob_name = "GFEDv2"
154.112 +
154.113 +; Units for these variables are:
154.114 +; g C/m^2/month
154.115 +
154.116 +;---------------------------------------------------
154.117 +; take into account landfrac
154.118 +
154.119 + data_mod = data_mod * conform(data_mod, landfrac, (/2,3/))
154.120 + data_ob = data_ob * conform(data_ob, landfrac, (/2,3/))
154.121 +
154.122 +;---------------------------------------------------
154.123 +; get time-mean
154.124 +
154.125 + x = dim_avg_Wrap(data_mod(lat|:,lon|:,month|:,year|:))
154.126 + data_mod_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
154.127 + delete (x)
154.128 +
154.129 + x = dim_avg_Wrap( data_ob(lat|:,lon|:,month|:,year|:))
154.130 + data_ob_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
154.131 + delete (x)
154.132 +
154.133 +; printVarSummary(y)
154.134 +
154.135 +;----------------------------------------------------
154.136 +; compute correlation coef
154.137 +
154.138 + landmask_1d = ndtooned(landmask)
154.139 + data_mod_1d = ndtooned(data_mod_m)
154.140 + data_ob_1d = ndtooned(data_ob_m)
154.141 +
154.142 + good = ind(landmask_1d .gt. 0.)
154.143 +; print (dimsizes(good))
154.144 +
154.145 + cc = esccr(data_mod_1d(good),data_ob_1d(good),0)
154.146 +; print (cc)
154.147 +
154.148 + delete (landmask_1d)
154.149 + delete (data_mod_1d)
154.150 + delete (data_ob_id)
154.151 +
154.152 +;----------------------------------------------------
154.153 +; compute M_global
154.154 +
154.155 + score_max = 1.
154.156 +
154.157 + Mscore = cc * cc * score_max
154.158 +
154.159 + M_global = sprintf("%.2f", Mscore)
154.160 +
154.161 +;----------------------------------------------------
154.162 +; global res
154.163 +
154.164 + resg = True ; Use plot options
154.165 + resg@cnFillOn = True ; Turn on color fill
154.166 + resg@gsnSpreadColors = True ; use full colormap
154.167 + resg@cnLinesOn = False ; Turn off contourn lines
154.168 + resg@mpFillOn = False ; Turn off map fill
154.169 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
154.170 +
154.171 +;----------------------------------------------------
154.172 +; global contour: model vs ob
154.173 +
154.174 + plot_name = "global_model_vs_ob"
154.175 +
154.176 + wks = gsn_open_wks (plot_type,plot_name)
154.177 + gsn_define_colormap(wks,"gui_default")
154.178 +
154.179 + plot=new(3,graphic) ; create graphic array
154.180 +
154.181 + resg@gsnFrame = False ; Do not draw plot
154.182 + resg@gsnDraw = False ; Do not advance frame
154.183 +
154.184 +;----------------------
154.185 +; plot correlation coef
154.186 +
154.187 + gRes = True
154.188 + gRes@txFontHeightF = 0.02
154.189 + gRes@txAngleF = 90
154.190 +
154.191 + correlation_text = "(correlation coef = "+sprintf("%.2f", cc)+")"
154.192 +
154.193 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
154.194 +
154.195 +;-----------------------
154.196 +; plot ob
154.197 +
154.198 + data_ob_m = where(landmask .gt. 0., data_ob_m, data_ob_m@_FillValue)
154.199 +
154.200 + title = ob_name
154.201 + resg@tiMainString = title
154.202 +
154.203 + resg@cnMinLevelValF = 1.
154.204 + resg@cnMaxLevelValF = 10.
154.205 + resg@cnLevelSpacingF = 1.
154.206 +
154.207 + plot(0) = gsn_csm_contour_map_ce(wks,data_ob_m,resg)
154.208 +
154.209 +;-----------------------
154.210 +; plot model
154.211 +
154.212 + data_mod_m = where(landmask .gt. 0., data_mod_m, data_mod_m@_FillValue)
154.213 +
154.214 + title = "Model "+ model_name
154.215 + resg@tiMainString = title
154.216 +
154.217 + resg@cnMinLevelValF = 1.
154.218 + resg@cnMaxLevelValF = 10.
154.219 + resg@cnLevelSpacingF = 1.
154.220 +
154.221 + plot(1) = gsn_csm_contour_map_ce(wks,data_mod_m,resg)
154.222 +
154.223 +;-----------------------
154.224 +; plot model-ob
154.225 +
154.226 + resg@cnMinLevelValF = -8.
154.227 + resg@cnMaxLevelValF = 2.
154.228 + resg@cnLevelSpacingF = 1.
154.229 +
154.230 + zz = data_ob_m
154.231 + zz = data_mod_m - data_ob_m
154.232 + title = "Model_"+model_name+" - Observed"
154.233 + resg@tiMainString = title
154.234 +
154.235 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
154.236 +
154.237 +; plot panel
154.238 +
154.239 + pres = True ; panel plot mods desired
154.240 + pres@gsnMaximize = True ; fill the page
154.241 +
154.242 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
154.243 +
154.244 +exit
154.245 +
154.246 +; system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
154.247 +; "rm "+plot_name+"."+plot_type)
154.248 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
154.249 +
154.250 + clear (wks)
154.251 + delete (plot)
154.252 +
154.253 + delete (data_ob_m)
154.254 + delete (data_mod_m)
154.255 + delete (zz)
154.256 +
154.257 + resg@gsnFrame = True ; Do advance frame
154.258 + resg@gsnDraw = True ; Do draw plot
154.259 +
154.260 +end
154.261 +
155.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
155.2 +++ b/fire/22.table+tseries.ncl Mon Jan 26 22:08:20 2009 -0500
155.3 @@ -0,0 +1,554 @@
155.4 +;********************************************************
155.5 +;using model biome vlass
155.6 +;
155.7 +; required command line input parameters:
155.8 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
155.9 +;
155.10 +; histogram normalized by rain and compute correleration
155.11 +;**************************************************************
155.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
155.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
155.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
155.15 +;**************************************************************
155.16 +procedure set_line(lines:string,nline:integer,newlines:string)
155.17 +begin
155.18 +; add line to ascci/html file
155.19 +
155.20 + nnewlines = dimsizes(newlines)
155.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
155.22 + print("set_line: bad index, not setting anything.")
155.23 + return
155.24 + end if
155.25 + lines(nline:nline+nnewlines-1) = newlines
155.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
155.27 + nline = nline + nnewlines
155.28 + return
155.29 +end
155.30 +;**************************************************************
155.31 +; Main code.
155.32 +begin
155.33 +
155.34 + plot_type = "ps"
155.35 + plot_type_new = "png"
155.36 +
155.37 +;---------------------------------------------------
155.38 +; model name and grid
155.39 +
155.40 + model_grid = "T42"
155.41 +
155.42 + model_name = "cn"
155.43 + model_name1 = "i01.06cn"
155.44 + model_name2 = "i01.10cn"
155.45 +
155.46 +;---------------------------------------------------
155.47 +; get biome data: model
155.48 +
155.49 + biome_name_mod = "Model PFT Class"
155.50 +
155.51 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
155.52 + film = "class_pft_"+model_grid+".nc"
155.53 + fm = addfile(dirm+film,"r")
155.54 +
155.55 + classmod = fm->CLASS_PFT
155.56 +
155.57 + delete (fm)
155.58 +
155.59 +; model data has 17 land-type classes
155.60 +
155.61 + nclass_mod = 17
155.62 +
155.63 +;--------------------------------------------------
155.64 +; get model data: landmask, landfrac and area
155.65 +
155.66 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
155.67 + film = "lnd_T42.nc"
155.68 + fm = addfile (dirm+film,"r")
155.69 +
155.70 + landmask = fm->landmask
155.71 + landfrac = fm->landfrac
155.72 + area = fm->area
155.73 +
155.74 + delete (fm)
155.75 +
155.76 +; change area from km**2 to m**2
155.77 + area = area * 1.e6
155.78 +
155.79 +;----------------------------------------------------
155.80 +; read data: time series, model
155.81 +
155.82 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
155.83 + film = model_name2 + "_Fire_C_1979-2004_monthly.nc"
155.84 + fm = addfile (dirm+film,"r")
155.85 +
155.86 + data_mod = fm->COL_FIRE_CLOSS(18:25,:,:,:)
155.87 +
155.88 + delete (fm)
155.89 +
155.90 +; Units for these variables are:
155.91 +; g C/m^2/s
155.92 +
155.93 +; change unit to g C/m^2/month
155.94 +
155.95 + nsec_per_month = 60*60*24*30
155.96 +
155.97 + data_mod = data_mod * nsec_per_month
155.98 +
155.99 + data_mod@unit = "gC/m2/month"
155.100 +;----------------------------------------------------
155.101 +; read data: time series, observed
155.102 +
155.103 + dirm = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
155.104 + film = "Fire_C_1997-2006_monthly_"+ model_grid+".nc"
155.105 + fm = addfile (dirm+film,"r")
155.106 +
155.107 + data_ob = fm->FIRE_C(0:7,:,:,:)
155.108 +
155.109 + delete (fm)
155.110 +
155.111 + ob_name = "GFEDv2"
155.112 +
155.113 +; Units for these variables are:
155.114 +; g C/m^2/month
155.115 +
155.116 +;---------------------------------------------------
155.117 +; take into account landfrac
155.118 +
155.119 + area = area * landfrac
155.120 + data_mod = data_mod * conform(data_mod, landfrac, (/2,3/))
155.121 + data_ob = data_ob * conform(data_ob, landfrac, (/2,3/))
155.122 +
155.123 + delete (landfrac)
155.124 +
155.125 +;-------------------------------------------------------------
155.126 +; html table1 data
155.127 +
155.128 +; column (not including header column)
155.129 +
155.130 + col_head = (/"Model Fire_Flux (PgC/yr)" \
155.131 + ,"Observed Fire_Flux (PgC/yr)" \
155.132 + ,"Correlation Coefficient" \
155.133 + ,"Ratio model/observed" \
155.134 + ,"M_score" \
155.135 + ,"Timeseries plot" \
155.136 + /)
155.137 +
155.138 + ncol = dimsizes(col_head)
155.139 +
155.140 +; row (not including header row)
155.141 +
155.142 +; using model biome class:
155.143 + row_head = (/"Not Vegetated" \
155.144 + ,"Needleleaf Evergreen Temperate Tree" \
155.145 + ,"Needleleaf Evergreen Boreal Tree" \
155.146 +; ,"Needleleaf Deciduous Boreal Tree" \
155.147 + ,"Broadleaf Evergreen Tropical Tree" \
155.148 + ,"Broadleaf Evergreen Temperate Tree" \
155.149 + ,"Broadleaf Deciduous Tropical Tree" \
155.150 + ,"Broadleaf Deciduous Temperate Tree" \
155.151 +; ,"Broadleaf Deciduous Boreal Tree" \
155.152 +; ,"Broadleaf Evergreen Shrub" \
155.153 + ,"Broadleaf Deciduous Temperate Shrub" \
155.154 + ,"Broadleaf Deciduous Boreal Shrub" \
155.155 + ,"C3 Arctic Grass" \
155.156 + ,"C3 Non-Arctic Grass" \
155.157 + ,"C4 Grass" \
155.158 + ,"Corn" \
155.159 +; ,"Wheat" \
155.160 + ,"All Biome" \
155.161 + /)
155.162 + nrow = dimsizes(row_head)
155.163 +
155.164 +; arrays to be passed to table.
155.165 + text = new ((/nrow, ncol/),string )
155.166 +
155.167 +;*****************************************************************
155.168 +; (A) get time-mean
155.169 +;*****************************************************************
155.170 +
155.171 + x = dim_avg_Wrap(data_mod(lat|:,lon|:,month|:,year|:))
155.172 + data_mod_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
155.173 + delete (x)
155.174 +
155.175 + x = dim_avg_Wrap( data_ob(lat|:,lon|:,month|:,year|:))
155.176 + data_ob_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
155.177 + delete (x)
155.178 +
155.179 +;----------------------------------------------------
155.180 +; compute correlation coef
155.181 +
155.182 + landmask_1d = ndtooned(landmask)
155.183 + data_mod_1d = ndtooned(data_mod_m)
155.184 + data_ob_1d = ndtooned(data_ob_m)
155.185 +
155.186 + good = ind(landmask_1d .gt. 0.)
155.187 +; print (dimsizes(good))
155.188 +
155.189 + cc = esccr(data_mod_1d(good),data_ob_1d(good),0)
155.190 +; print (cc)
155.191 +
155.192 + delete (landmask_1d)
155.193 + delete (data_mod_1d)
155.194 + delete (data_ob_1d)
155.195 + delete (good)
155.196 +
155.197 +;----------------------------------------------------
155.198 +; compute M_global
155.199 +
155.200 + score_max = 1.
155.201 +
155.202 + Mscore = cc * cc * score_max
155.203 +
155.204 + M_global = sprintf("%.2f", Mscore)
155.205 +
155.206 +;----------------------------------------------------
155.207 +; global res
155.208 +
155.209 + resg = True ; Use plot options
155.210 + resg@cnFillOn = True ; Turn on color fill
155.211 + resg@gsnSpreadColors = True ; use full colormap
155.212 + resg@cnLinesOn = False ; Turn off contourn lines
155.213 + resg@mpFillOn = False ; Turn off map fill
155.214 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
155.215 +
155.216 +;----------------------------------------------------
155.217 +; global contour: model vs ob
155.218 +
155.219 + plot_name = "global_model_vs_ob"
155.220 +
155.221 + wks = gsn_open_wks (plot_type,plot_name)
155.222 + gsn_define_colormap(wks,"gui_default")
155.223 +
155.224 + plot=new(3,graphic) ; create graphic array
155.225 +
155.226 + resg@gsnFrame = False ; Do not draw plot
155.227 + resg@gsnDraw = False ; Do not advance frame
155.228 +
155.229 +;----------------------
155.230 +; plot correlation coef
155.231 +
155.232 + gRes = True
155.233 + gRes@txFontHeightF = 0.02
155.234 + gRes@txAngleF = 90
155.235 +
155.236 + correlation_text = "(correlation coef = "+sprintf("%.2f", cc)+")"
155.237 +
155.238 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
155.239 +
155.240 +;-----------------------
155.241 +; plot ob
155.242 +
155.243 + data_ob_m = where(landmask .gt. 0., data_ob_m, data_ob_m@_FillValue)
155.244 +
155.245 + title = ob_name
155.246 + resg@tiMainString = title
155.247 +
155.248 + resg@cnMinLevelValF = 1.
155.249 + resg@cnMaxLevelValF = 10.
155.250 + resg@cnLevelSpacingF = 1.
155.251 +
155.252 + plot(0) = gsn_csm_contour_map_ce(wks,data_ob_m,resg)
155.253 +
155.254 +;-----------------------
155.255 +; plot model
155.256 +
155.257 + data_mod_m = where(landmask .gt. 0., data_mod_m, data_mod_m@_FillValue)
155.258 +
155.259 + title = "Model "+ model_name
155.260 + resg@tiMainString = title
155.261 +
155.262 + resg@cnMinLevelValF = 1.
155.263 + resg@cnMaxLevelValF = 10.
155.264 + resg@cnLevelSpacingF = 1.
155.265 +
155.266 + plot(1) = gsn_csm_contour_map_ce(wks,data_mod_m,resg)
155.267 +
155.268 +;-----------------------
155.269 +; plot model-ob
155.270 +
155.271 + resg@cnMinLevelValF = -8.
155.272 + resg@cnMaxLevelValF = 2.
155.273 + resg@cnLevelSpacingF = 1.
155.274 +
155.275 + zz = data_ob_m
155.276 + zz = data_mod_m - data_ob_m
155.277 + title = "Model_"+model_name+" - Observed"
155.278 + resg@tiMainString = title
155.279 +
155.280 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
155.281 +
155.282 +; plot panel
155.283 +
155.284 + pres = True ; panel plot mods desired
155.285 + pres@gsnMaximize = True ; fill the page
155.286 +
155.287 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
155.288 +
155.289 +; system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
155.290 +; "rm "+plot_name+"."+plot_type)
155.291 +
155.292 + clear (wks)
155.293 + delete (plot)
155.294 +
155.295 + delete (data_ob_m)
155.296 + delete (data_mod_m)
155.297 + delete (zz)
155.298 +
155.299 + resg@gsnFrame = True ; Do advance frame
155.300 + resg@gsnDraw = True ; Do draw plot
155.301 +
155.302 +;*******************************************************************
155.303 +; (B) Time series : per biome
155.304 +;*******************************************************************
155.305 +
155.306 + data_n = 2
155.307 +
155.308 + dsizes = dimsizes(data_mod)
155.309 + nyear = dsizes(0)
155.310 + nmonth = dsizes(1)
155.311 + ntime = nyear * nmonth
155.312 +
155.313 + year_start = 1997
155.314 + year_end = 2004
155.315 +
155.316 +;-------------------------------------------
155.317 +; Calculate "nice" bins for binning the data
155.318 +
155.319 +; using model biome class
155.320 + nclass = nclass_mod
155.321 +
155.322 + range = fspan(0,nclass,nclass+1)
155.323 +
155.324 +; print (range)
155.325 +; Use this range information to grab all the values in a
155.326 +; particular range, and then take an average.
155.327 +
155.328 + nx = dimsizes(range) - 1
155.329 +
155.330 +;-------------------------------------------
155.331 +; put data into bins
155.332 +
155.333 +; using observed biome class
155.334 +; base = ndtooned(classob)
155.335 +; using model biome class
155.336 + base = ndtooned(classmod)
155.337 +
155.338 +; output
155.339 +
155.340 + area_bin = new((/nx/),float)
155.341 + yvalues = new((/ntime,data_n,nx/),float)
155.342 +
155.343 +; Loop through each range, using base.
155.344 +
155.345 + do i=0,nx-1
155.346 +
155.347 + if (i.ne.(nx-1)) then
155.348 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
155.349 + else
155.350 + idx = ind(base.ge.range(i))
155.351 + end if
155.352 +;---------------------
155.353 +; for area
155.354 +
155.355 + data = ndtooned(area)
155.356 +
155.357 + if (.not.any(ismissing(idx))) then
155.358 + area_bin(i) = sum(data(idx))
155.359 + else
155.360 + area_bin(i) = area_bin@_FillValue
155.361 + end if
155.362 +
155.363 +;#############################################################
155.364 +; using model biome class:
155.365 +; set the following 4 classes to _FillValue:
155.366 +; (3)Needleleaf Deciduous Boreal Tree,
155.367 +; (8)Broadleaf Deciduous Boreal Tree,
155.368 +; (9)Broadleaf Evergreen Shrub,
155.369 +; (16)Wheat
155.370 +
155.371 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
155.372 + area_bin(i) = area_bin@_FillValue
155.373 + end if
155.374 +;#############################################################
155.375 +
155.376 + delete (data)
155.377 +
155.378 +;---------------------
155.379 +; for data_mod and data_ob
155.380 +
155.381 + do n = 0,data_n-1
155.382 +
155.383 + t = -1
155.384 + do m = 0,nyear-1
155.385 + do k = 0,nmonth-1
155.386 +
155.387 + t = t + 1
155.388 +
155.389 + if (n.eq.0) then
155.390 + data = ndtooned(data_ob(m,k,:,:))
155.391 + end if
155.392 +
155.393 + if (n.eq.1) then
155.394 + data = ndtooned(data_mod(m,k,:,:))
155.395 + end if
155.396 +
155.397 +; Calculate average
155.398 +
155.399 + if (.not.any(ismissing(idx))) then
155.400 + yvalues(t,n,i) = avg(data(idx))
155.401 + else
155.402 + yvalues(t,n,i) = yvalues@_FillValue
155.403 + end if
155.404 +
155.405 +;#############################################################
155.406 +; using model biome class:
155.407 +; set the following 4 classes to _FillValue:
155.408 +; (3)Needleleaf Deciduous Boreal Tree,
155.409 +; (8)Broadleaf Deciduous Boreal Tree,
155.410 +; (9)Broadleaf Evergreen Shrub,
155.411 +; (16)Wheat
155.412 +
155.413 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
155.414 + yvalues(t,n,i) = yvalues@_FillValue
155.415 + end if
155.416 +;#############################################################
155.417 +
155.418 + end do
155.419 + end do
155.420 +
155.421 + delete(data)
155.422 + end do
155.423 +
155.424 + delete(idx)
155.425 + end do
155.426 +
155.427 + delete (base)
155.428 + delete (data_mod)
155.429 + delete (data_ob)
155.430 +
155.431 +;----------------------------------------------------------------
155.432 +; get area_good
155.433 +
155.434 + good = ind(.not.ismissing(area_bin))
155.435 +
155.436 + area_g = area_bin(good)
155.437 +
155.438 + n_biome = dimsizes(good)
155.439 +
155.440 +;----------------------------------------------------------------
155.441 +; data for tseries plot
155.442 +
155.443 + yvalues_g = new((/ntime,data_n,n_biome/),float)
155.444 +
155.445 + yvalues_g@units = "TgC/month"
155.446 +
155.447 +; change unit to Tg C/month
155.448 +; change unit from g to Tg (Tera gram)
155.449 + factor_unit = 1.e-12
155.450 +
155.451 + yvalues_g = yvalues(:,:,good) * conform(yvalues_g,area_g,2) * factor_unit
155.452 +
155.453 +;-------------------------------------------------------------------
155.454 +; general settings for line plot
155.455 +
155.456 + res = True
155.457 + res@xyDashPatterns = (/0,0/) ; make lines solid
155.458 + res@xyLineThicknesses = (/2.0,2.0/) ; make lines thicker
155.459 + res@xyLineColors = (/"blue","red"/) ; line color
155.460 +
155.461 + res@trXMinF = year_start
155.462 + res@trXMaxF = year_end + 1
155.463 +
155.464 + res@vpHeightF = 0.4 ; change aspect ratio of plot
155.465 +; res@vpWidthF = 0.8
155.466 + res@vpWidthF = 0.75
155.467 +
155.468 + res@tiMainFontHeightF = 0.025 ; size of title
155.469 +
155.470 + res@tmXBFormat = "f" ; not to add trailing zeros
155.471 +
155.472 +; res@gsnMaximize = True
155.473 +
155.474 +;----------------------------------------------
155.475 +; Add a boxed legend using the simple method
155.476 +
155.477 + res@pmLegendDisplayMode = "Always"
155.478 +; res@pmLegendWidthF = 0.1
155.479 + res@pmLegendWidthF = 0.08
155.480 + res@pmLegendHeightF = 0.06
155.481 + res@pmLegendOrthogonalPosF = -1.17
155.482 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
155.483 +; res@pmLegendOrthogonalPosF = -0.30 ;(downward)
155.484 +
155.485 +; res@pmLegendParallelPosF = 0.18
155.486 + res@pmLegendParallelPosF = 0.23 ;(rightward)
155.487 + res@pmLegendParallelPosF = 0.73 ;(rightward)
155.488 + res@pmLegendParallelPosF = 0.83 ;(rightward)
155.489 +
155.490 +; res@lgPerimOn = False
155.491 + res@lgLabelFontHeightF = 0.015
155.492 + res@xyExplicitLegendLabels = (/"observed",model_name/)
155.493 +
155.494 +;*******************************************************************
155.495 +; (A) time series plot: monthly ( 2 lines per plot)
155.496 +;*******************************************************************
155.497 +
155.498 +; x-axis in time series plot
155.499 +
155.500 + timeI = new((/ntime/),integer)
155.501 + timeF = new((/ntime/),float)
155.502 + timeI = ispan(1,ntime,1)
155.503 + timeF = year_start + (timeI-1)/12.
155.504 + timeF@long_name = "year"
155.505 +
155.506 + plot_data = new((/2,ntime/),float)
155.507 + plot_data@long_name = "TgC/month"
155.508 +
155.509 +;----------------------------------------------
155.510 +; time series : per biome
155.511 +
155.512 + do m = 0, n_biome-1
155.513 +
155.514 + plot_name = "monthly_biome_"+ m
155.515 +
155.516 + wks = gsn_open_wks (plot_type,plot_name)
155.517 +
155.518 + title = "Fire : "+ row_head(m)
155.519 + res@tiMainString = title
155.520 +
155.521 + plot_data(0,:) = yvalues_g(:,0,m)
155.522 + plot_data(1,:) = yvalues_g(:,1,m)
155.523 +
155.524 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
155.525 +
155.526 +; system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
155.527 +; "rm "+plot_name+"."+plot_type)
155.528 +
155.529 + clear (wks)
155.530 + delete (plot)
155.531 +
155.532 + end do
155.533 +
155.534 +;--------------------------------------------
155.535 +; time series: global
155.536 +
155.537 + plot_name = "monthly_global"
155.538 +
155.539 + wks = gsn_open_wks (plot_type,plot_name)
155.540 +
155.541 + title = "Fire : "+ row_head(n_biome)
155.542 + res@tiMainString = title
155.543 +
155.544 + do k = 0,ntime-1
155.545 + plot_data(0,k) = sum(yvalues_g(k,0,:))
155.546 + plot_data(1,k) = sum(yvalues_g(k,1,:))
155.547 + end do
155.548 +
155.549 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
155.550 +
155.551 +; system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
155.552 +; "rm "+plot_name+"."+plot_type)
155.553 +
155.554 + clear (wks)
155.555 + delete (plot)
155.556 +end
155.557 +
156.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
156.2 +++ b/fire/23.table+tseries.ncl Mon Jan 26 22:08:20 2009 -0500
156.3 @@ -0,0 +1,692 @@
156.4 +;********************************************************
156.5 +;using model biome vlass
156.6 +;
156.7 +; required command line input parameters:
156.8 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
156.9 +;
156.10 +; histogram normalized by rain and compute correleration
156.11 +;**************************************************************
156.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
156.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
156.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
156.15 +;**************************************************************
156.16 +procedure set_line(lines:string,nline:integer,newlines:string)
156.17 +begin
156.18 +; add line to ascci/html file
156.19 +
156.20 + nnewlines = dimsizes(newlines)
156.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
156.22 + print("set_line: bad index, not setting anything.")
156.23 + return
156.24 + end if
156.25 + lines(nline:nline+nnewlines-1) = newlines
156.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
156.27 + nline = nline + nnewlines
156.28 + return
156.29 +end
156.30 +;**************************************************************
156.31 +; Main code.
156.32 +begin
156.33 +
156.34 + plot_type = "ps"
156.35 + plot_type_new = "png"
156.36 +
156.37 +;---------------------------------------------------
156.38 +; model name and grid
156.39 +
156.40 + model_grid = "T42"
156.41 +
156.42 + model_name = "cn"
156.43 + model_name1 = "i01.06cn"
156.44 + model_name2 = "i01.10cn"
156.45 +
156.46 +;---------------------------------------------------
156.47 +; get biome data: model
156.48 +
156.49 + biome_name_mod = "Model PFT Class"
156.50 +
156.51 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
156.52 + film = "class_pft_"+model_grid+".nc"
156.53 + fm = addfile(dirm+film,"r")
156.54 +
156.55 + classmod = fm->CLASS_PFT
156.56 +
156.57 + delete (fm)
156.58 +
156.59 +; model data has 17 land-type classes
156.60 +
156.61 + nclass_mod = 17
156.62 +
156.63 +;--------------------------------------------------
156.64 +; get model data: landmask, landfrac and area
156.65 +
156.66 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
156.67 + film = "lnd_T42.nc"
156.68 + fm = addfile (dirm+film,"r")
156.69 +
156.70 + landmask = fm->landmask
156.71 + landfrac = fm->landfrac
156.72 + area = fm->area
156.73 +
156.74 + delete (fm)
156.75 +
156.76 +; change area from km**2 to m**2
156.77 + area = area * 1.e6
156.78 +
156.79 +;----------------------------------------------------
156.80 +; read data: time series, model
156.81 +
156.82 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
156.83 + film = model_name2 + "_Fire_C_1979-2004_monthly.nc"
156.84 + fm = addfile (dirm+film,"r")
156.85 +
156.86 + data_mod = fm->COL_FIRE_CLOSS(18:25,:,:,:)
156.87 +
156.88 + delete (fm)
156.89 +
156.90 +; Units for these variables are:
156.91 +; g C/m^2/s
156.92 +
156.93 +; change unit to g C/m^2/month
156.94 +
156.95 + nsec_per_month = 60*60*24*30
156.96 +
156.97 + data_mod = data_mod * nsec_per_month
156.98 +
156.99 + data_mod@unit = "gC/m2/month"
156.100 +;----------------------------------------------------
156.101 +; read data: time series, observed
156.102 +
156.103 + dirm = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
156.104 + film = "Fire_C_1997-2006_monthly_"+ model_grid+".nc"
156.105 + fm = addfile (dirm+film,"r")
156.106 +
156.107 + data_ob = fm->FIRE_C(0:7,:,:,:)
156.108 +
156.109 + delete (fm)
156.110 +
156.111 + ob_name = "GFEDv2"
156.112 +
156.113 +; Units for these variables are:
156.114 +; g C/m^2/month
156.115 +
156.116 +;---------------------------------------------------
156.117 +; take into account landfrac
156.118 +
156.119 + area = area * landfrac
156.120 + data_mod = data_mod * conform(data_mod, landfrac, (/2,3/))
156.121 + data_ob = data_ob * conform(data_ob, landfrac, (/2,3/))
156.122 +
156.123 + delete (landfrac)
156.124 +
156.125 +;-------------------------------------------------------------
156.126 +; html table1 data
156.127 +
156.128 +; column (not including header column)
156.129 +
156.130 + col_head = (/"Observed Fire_Flux (PgC/yr)" \
156.131 + ,"Model Fire_Flux (PgC/yr)" \
156.132 + ,"Correlation Coefficient" \
156.133 + ,"Ratio model/observed" \
156.134 + ,"M_score" \
156.135 + ,"Timeseries plot" \
156.136 + /)
156.137 +
156.138 + ncol = dimsizes(col_head)
156.139 +
156.140 +; row (not including header row)
156.141 +
156.142 +; using model biome class:
156.143 + row_head = (/"Not Vegetated" \
156.144 + ,"Needleleaf Evergreen Temperate Tree" \
156.145 + ,"Needleleaf Evergreen Boreal Tree" \
156.146 +; ,"Needleleaf Deciduous Boreal Tree" \
156.147 + ,"Broadleaf Evergreen Tropical Tree" \
156.148 + ,"Broadleaf Evergreen Temperate Tree" \
156.149 + ,"Broadleaf Deciduous Tropical Tree" \
156.150 + ,"Broadleaf Deciduous Temperate Tree" \
156.151 +; ,"Broadleaf Deciduous Boreal Tree" \
156.152 +; ,"Broadleaf Evergreen Shrub" \
156.153 + ,"Broadleaf Deciduous Temperate Shrub" \
156.154 + ,"Broadleaf Deciduous Boreal Shrub" \
156.155 + ,"C3 Arctic Grass" \
156.156 + ,"C3 Non-Arctic Grass" \
156.157 + ,"C4 Grass" \
156.158 + ,"Corn" \
156.159 +; ,"Wheat" \
156.160 + ,"All Biome" \
156.161 + /)
156.162 + nrow = dimsizes(row_head)
156.163 +
156.164 +; arrays to be passed to table.
156.165 + text = new ((/nrow, ncol/),string )
156.166 +
156.167 +;*****************************************************************
156.168 +; (A) get time-mean
156.169 +;*****************************************************************
156.170 +
156.171 + x = dim_avg_Wrap(data_mod(lat|:,lon|:,month|:,year|:))
156.172 + data_mod_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
156.173 + delete (x)
156.174 +
156.175 + x = dim_avg_Wrap( data_ob(lat|:,lon|:,month|:,year|:))
156.176 + data_ob_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
156.177 + delete (x)
156.178 +
156.179 +;----------------------------------------------------
156.180 +; compute correlation coef
156.181 +
156.182 + landmask_1d = ndtooned(landmask)
156.183 + data_mod_1d = ndtooned(data_mod_m)
156.184 + data_ob_1d = ndtooned(data_ob_m)
156.185 +
156.186 + good = ind(landmask_1d .gt. 0.)
156.187 +
156.188 + cc = esccr(data_mod_1d(good),data_ob_1d(good),0)
156.189 +
156.190 + delete (landmask_1d)
156.191 + delete (data_mod_1d)
156.192 + delete (data_ob_1d)
156.193 + delete (good)
156.194 +
156.195 +;----------------------------------------------------
156.196 +; compute M_global
156.197 +
156.198 + score_max = 1.
156.199 +
156.200 + Mscore1 = cc * cc * score_max
156.201 +
156.202 + M_global = sprintf("%.2f", Mscore1)
156.203 +
156.204 +;----------------------------------------------------
156.205 +; global res
156.206 +
156.207 + resg = True ; Use plot options
156.208 + resg@cnFillOn = True ; Turn on color fill
156.209 + resg@gsnSpreadColors = True ; use full colormap
156.210 + resg@cnLinesOn = False ; Turn off contourn lines
156.211 + resg@mpFillOn = False ; Turn off map fill
156.212 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
156.213 +
156.214 +;----------------------------------------------------
156.215 +; global contour: model vs ob
156.216 +
156.217 + plot_name = "global_model_vs_ob"
156.218 +
156.219 + wks = gsn_open_wks (plot_type,plot_name)
156.220 + gsn_define_colormap(wks,"gui_default")
156.221 +
156.222 + plot=new(3,graphic) ; create graphic array
156.223 +
156.224 + resg@gsnFrame = False ; Do not draw plot
156.225 + resg@gsnDraw = False ; Do not advance frame
156.226 +
156.227 +;----------------------
156.228 +; plot correlation coef
156.229 +
156.230 + gRes = True
156.231 + gRes@txFontHeightF = 0.02
156.232 + gRes@txAngleF = 90
156.233 +
156.234 + correlation_text = "(correlation coef = "+sprintf("%.2f", cc)+")"
156.235 +
156.236 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
156.237 +
156.238 +;-----------------------
156.239 +; plot ob
156.240 +
156.241 + data_ob_m = where(landmask .gt. 0., data_ob_m, data_ob_m@_FillValue)
156.242 +
156.243 + title = ob_name
156.244 + resg@tiMainString = title
156.245 +
156.246 + resg@cnMinLevelValF = 1.
156.247 + resg@cnMaxLevelValF = 10.
156.248 + resg@cnLevelSpacingF = 1.
156.249 +
156.250 + plot(0) = gsn_csm_contour_map_ce(wks,data_ob_m,resg)
156.251 +
156.252 +;-----------------------
156.253 +; plot model
156.254 +
156.255 + data_mod_m = where(landmask .gt. 0., data_mod_m, data_mod_m@_FillValue)
156.256 +
156.257 + title = "Model "+ model_name
156.258 + resg@tiMainString = title
156.259 +
156.260 + resg@cnMinLevelValF = 1.
156.261 + resg@cnMaxLevelValF = 10.
156.262 + resg@cnLevelSpacingF = 1.
156.263 +
156.264 + plot(1) = gsn_csm_contour_map_ce(wks,data_mod_m,resg)
156.265 +
156.266 +;-----------------------
156.267 +; plot model-ob
156.268 +
156.269 + resg@cnMinLevelValF = -8.
156.270 + resg@cnMaxLevelValF = 2.
156.271 + resg@cnLevelSpacingF = 1.
156.272 +
156.273 + zz = data_ob_m
156.274 + zz = data_mod_m - data_ob_m
156.275 + title = "Model_"+model_name+" - Observed"
156.276 + resg@tiMainString = title
156.277 +
156.278 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
156.279 +
156.280 +; plot panel
156.281 +
156.282 + pres = True ; panel plot mods desired
156.283 + pres@gsnMaximize = True ; fill the page
156.284 +
156.285 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
156.286 +
156.287 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
156.288 + "rm "+plot_name+"."+plot_type)
156.289 +
156.290 + clear (wks)
156.291 + delete (plot)
156.292 +
156.293 + delete (data_ob_m)
156.294 + delete (data_mod_m)
156.295 + delete (zz)
156.296 +
156.297 + resg@gsnFrame = True ; Do advance frame
156.298 + resg@gsnDraw = True ; Do draw plot
156.299 +
156.300 +;*******************************************************************
156.301 +; (B) Time series : per biome
156.302 +;*******************************************************************
156.303 +
156.304 + data_n = 2
156.305 +
156.306 + dsizes = dimsizes(data_mod)
156.307 + nyear = dsizes(0)
156.308 + nmonth = dsizes(1)
156.309 + ntime = nyear * nmonth
156.310 +
156.311 + year_start = 1997
156.312 + year_end = 2004
156.313 +
156.314 +;-------------------------------------------
156.315 +; Calculate "nice" bins for binning the data
156.316 +
156.317 +; using model biome class
156.318 + nclass = nclass_mod
156.319 +
156.320 + range = fspan(0,nclass,nclass+1)
156.321 +
156.322 +; Use this range information to grab all the values in a
156.323 +; particular range, and then take an average.
156.324 +
156.325 + nx = dimsizes(range) - 1
156.326 +
156.327 +;-------------------------------------------
156.328 +; put data into bins
156.329 +
156.330 +; using observed biome class
156.331 +; base = ndtooned(classob)
156.332 +; using model biome class
156.333 + base = ndtooned(classmod)
156.334 +
156.335 +; output
156.336 +
156.337 + area_bin = new((/nx/),float)
156.338 + yvalues = new((/ntime,data_n,nx/),float)
156.339 +
156.340 +; Loop through each range, using base.
156.341 +
156.342 + do i=0,nx-1
156.343 +
156.344 + if (i.ne.(nx-1)) then
156.345 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
156.346 + else
156.347 + idx = ind(base.ge.range(i))
156.348 + end if
156.349 +;---------------------
156.350 +; for area
156.351 +
156.352 + data = ndtooned(area)
156.353 +
156.354 + if (.not.any(ismissing(idx))) then
156.355 + area_bin(i) = sum(data(idx))
156.356 + else
156.357 + area_bin(i) = area_bin@_FillValue
156.358 + end if
156.359 +
156.360 +;#############################################################
156.361 +; using model biome class:
156.362 +; set the following 4 classes to _FillValue:
156.363 +; (3)Needleleaf Deciduous Boreal Tree,
156.364 +; (8)Broadleaf Deciduous Boreal Tree,
156.365 +; (9)Broadleaf Evergreen Shrub,
156.366 +; (16)Wheat
156.367 +
156.368 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
156.369 + area_bin(i) = area_bin@_FillValue
156.370 + end if
156.371 +;#############################################################
156.372 +
156.373 + delete (data)
156.374 +
156.375 +;---------------------
156.376 +; for data_mod and data_ob
156.377 +
156.378 + do n = 0,data_n-1
156.379 +
156.380 + t = -1
156.381 + do m = 0,nyear-1
156.382 + do k = 0,nmonth-1
156.383 +
156.384 + t = t + 1
156.385 +
156.386 + if (n.eq.0) then
156.387 + data = ndtooned(data_ob(m,k,:,:))
156.388 + end if
156.389 +
156.390 + if (n.eq.1) then
156.391 + data = ndtooned(data_mod(m,k,:,:))
156.392 + end if
156.393 +
156.394 +; Calculate average
156.395 +
156.396 + if (.not.any(ismissing(idx))) then
156.397 + yvalues(t,n,i) = avg(data(idx))
156.398 + else
156.399 + yvalues(t,n,i) = yvalues@_FillValue
156.400 + end if
156.401 +
156.402 +;#############################################################
156.403 +; using model biome class:
156.404 +; set the following 4 classes to _FillValue:
156.405 +; (3)Needleleaf Deciduous Boreal Tree,
156.406 +; (8)Broadleaf Deciduous Boreal Tree,
156.407 +; (9)Broadleaf Evergreen Shrub,
156.408 +; (16)Wheat
156.409 +
156.410 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
156.411 + yvalues(t,n,i) = yvalues@_FillValue
156.412 + end if
156.413 +;#############################################################
156.414 +
156.415 + end do
156.416 + end do
156.417 +
156.418 + delete(data)
156.419 + end do
156.420 +
156.421 + delete(idx)
156.422 + end do
156.423 +
156.424 + delete (base)
156.425 + delete (data_mod)
156.426 + delete (data_ob)
156.427 +
156.428 +;----------------------------------------------------------------
156.429 +; get area_good
156.430 +
156.431 + good = ind(.not.ismissing(area_bin))
156.432 +
156.433 + area_g = area_bin(good)
156.434 +
156.435 + n_biome = dimsizes(good)
156.436 +
156.437 +;----------------------------------------------------------------
156.438 +; data for tseries plot
156.439 +
156.440 + yvalues_g = new((/ntime,data_n,n_biome/),float)
156.441 +
156.442 + yvalues_g@units = "TgC/month"
156.443 +
156.444 +; change unit to Tg C/month
156.445 +; change unit from g to Tg (Tera gram)
156.446 + factor_unit = 1.e-12
156.447 +
156.448 + yvalues_g = yvalues(:,:,good) * conform(yvalues_g,area_g,2) * factor_unit
156.449 +
156.450 + delete (good)
156.451 +
156.452 +;-------------------------------------------------------------------
156.453 +; general settings for line plot
156.454 +
156.455 + res = True
156.456 + res@xyDashPatterns = (/0,0/) ; make lines solid
156.457 + res@xyLineThicknesses = (/2.0,2.0/) ; make lines thicker
156.458 + res@xyLineColors = (/"blue","red"/) ; line color
156.459 +
156.460 + res@trXMinF = year_start
156.461 + res@trXMaxF = year_end + 1
156.462 +
156.463 + res@vpHeightF = 0.4 ; change aspect ratio of plot
156.464 +; res@vpWidthF = 0.8
156.465 + res@vpWidthF = 0.75
156.466 +
156.467 + res@tiMainFontHeightF = 0.025 ; size of title
156.468 +
156.469 + res@tmXBFormat = "f" ; not to add trailing zeros
156.470 +
156.471 +; res@gsnMaximize = True
156.472 +
156.473 +;----------------------------------------------
156.474 +; Add a boxed legend using the simple method
156.475 +
156.476 + res@pmLegendDisplayMode = "Always"
156.477 +; res@pmLegendWidthF = 0.1
156.478 + res@pmLegendWidthF = 0.08
156.479 + res@pmLegendHeightF = 0.06
156.480 + res@pmLegendOrthogonalPosF = -1.17
156.481 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
156.482 +; res@pmLegendOrthogonalPosF = -0.30 ;(downward)
156.483 +
156.484 +; res@pmLegendParallelPosF = 0.18
156.485 + res@pmLegendParallelPosF = 0.23 ;(rightward)
156.486 + res@pmLegendParallelPosF = 0.73 ;(rightward)
156.487 + res@pmLegendParallelPosF = 0.83 ;(rightward)
156.488 +
156.489 +; res@lgPerimOn = False
156.490 + res@lgLabelFontHeightF = 0.015
156.491 + res@xyExplicitLegendLabels = (/"observed",model_name/)
156.492 +
156.493 +;*******************************************************************
156.494 +; (A) time series plot: monthly ( 2 lines per plot)
156.495 +;*******************************************************************
156.496 +
156.497 +; x-axis in time series plot
156.498 +
156.499 + timeI = new((/ntime/),integer)
156.500 + timeF = new((/ntime/),float)
156.501 + timeI = ispan(1,ntime,1)
156.502 + timeF = year_start + (timeI-1)/12.
156.503 + timeF@long_name = "year"
156.504 +
156.505 + plot_data = new((/2,ntime/),float)
156.506 + plot_data@long_name = "TgC/month"
156.507 +
156.508 +;----------------------------------------------
156.509 +; time series plot : per biome
156.510 +
156.511 + do m = 0, n_biome-1
156.512 +
156.513 + plot_name = "monthly_biome_"+ m
156.514 +
156.515 + wks = gsn_open_wks (plot_type,plot_name)
156.516 +
156.517 + title = "Fire : "+ row_head(m)
156.518 + res@tiMainString = title
156.519 +
156.520 + plot_data(0,:) = yvalues_g(:,0,m)
156.521 + plot_data(1,:) = yvalues_g(:,1,m)
156.522 +
156.523 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
156.524 +
156.525 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
156.526 + "rm "+plot_name+"."+plot_type)
156.527 +
156.528 + clear (wks)
156.529 + delete (plot)
156.530 +
156.531 + end do
156.532 +
156.533 +;------------------------------------------
156.534 +; data for table : per biome
156.535 +
156.536 +; unit change from TgC/month to PgC/month
156.537 + unit_factor = 1.e-3
156.538 +
156.539 + score_max = 1.
156.540 +
156.541 + tmp_ob = new((/ntime/),float)
156.542 + tmp_mod = new((/ntime/),float)
156.543 +
156.544 + total_ob = new((/n_biome/),float)
156.545 + total_mod = new((/n_biome/),float)
156.546 + Mscore2 = new((/n_biome/),float)
156.547 +
156.548 + do m = 0, n_biome-1
156.549 +
156.550 + tmp_ob = yvalues_g(:,0,m)
156.551 + tmp_mod = yvalues_g(:,1,m)
156.552 +
156.553 + total_ob(m) = avg(month_to_annual(tmp_ob, 0)) * unit_factor
156.554 + total_mod(m) = avg(month_to_annual(tmp_mod,0)) * unit_factor
156.555 +
156.556 + cc = esccr(tmp_mod,tmp_ob,0)
156.557 +
156.558 + ratio = total_mod(m)/total_ob(m)
156.559 +
156.560 + good = ind(tmp_ob .ne. 0. .and. tmp_mod .ne. 0.)
156.561 +
156.562 + bias = sum( abs( tmp_mod(good)-tmp_ob(good) )/( abs(tmp_mod(good))+abs(tmp_ob(good)) ) )
156.563 + Mscore2(m) = (1.- (bias/dimsizes(good)))*score_max
156.564 +
156.565 + delete (good)
156.566 +
156.567 + text(m,0) = sprintf("%.2f",total_ob(m))
156.568 + text(m,1) = sprintf("%.2f",total_mod(m))
156.569 + text(m,2) = sprintf("%.2f",cc)
156.570 + text(m,3) = sprintf("%.2f",ratio)
156.571 + text(m,4) = sprintf("%.2f",Mscore2(m))
156.572 + text(m,5) = "<a href=./monthly_biome_"+m+".png>model_vs_ob</a>"
156.573 + end do
156.574 +
156.575 + delete (tmp_ob)
156.576 + delete (tmp_mod)
156.577 +
156.578 +;--------------------------------------------
156.579 +; time series plot: all biome
156.580 +
156.581 + plot_name = "monthly_global"
156.582 +
156.583 + wks = gsn_open_wks (plot_type,plot_name)
156.584 +
156.585 + title = "Fire : "+ row_head(n_biome)
156.586 + res@tiMainString = title
156.587 +
156.588 + do k = 0,ntime-1
156.589 + plot_data(0,k) = sum(yvalues_g(k,0,:))
156.590 + plot_data(1,k) = sum(yvalues_g(k,1,:))
156.591 + end do
156.592 +
156.593 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
156.594 +
156.595 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
156.596 + "rm "+plot_name+"."+plot_type)
156.597 +
156.598 + clear (wks)
156.599 + delete (plot)
156.600 +
156.601 +;------------------------------------------
156.602 +; data for table : global
156.603 +
156.604 + tmp_ob = ndtooned(yvalues_g(:,0,:))
156.605 + tmp_mod = ndtooned(yvalues_g(:,1,:))
156.606 +
156.607 + cc = esccr(tmp_mod,tmp_ob,0)
156.608 +
156.609 + ratio = sum(total_mod)/sum(total_ob)
156.610 +
156.611 + text(nrow-1,0) = sprintf("%.2f",sum(total_ob))
156.612 + text(nrow-1,1) = sprintf("%.2f",sum(total_mod))
156.613 + text(nrow-1,2) = sprintf("%.2f",cc)
156.614 + text(nrow-1,3) = sprintf("%.2f",ratio)
156.615 + text(nrow-1,4) = sprintf("%.2f",avg(Mscore2))
156.616 + text(nrow-1,5) = "<a href=./monthly_global.png>model_vs_ob</a>"
156.617 +
156.618 +;**************************************************
156.619 +; create html table
156.620 +;**************************************************
156.621 +
156.622 + header_text = "<H1>Fire Emission (1997-2004): Model "+model_name+"</H1>"
156.623 +
156.624 + header = (/"<HTML>" \
156.625 + ,"<HEAD>" \
156.626 + ,"<TITLE>CLAMP metrics</TITLE>" \
156.627 + ,"</HEAD>" \
156.628 + ,header_text \
156.629 + /)
156.630 + footer = "</HTML>"
156.631 +
156.632 + table_header = (/ \
156.633 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
156.634 + ,"<tr>" \
156.635 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
156.636 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
156.637 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
156.638 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
156.639 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
156.640 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
156.641 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
156.642 + ,"</tr>" \
156.643 + /)
156.644 + table_footer = "</table>"
156.645 + row_header = "<tr>"
156.646 + row_footer = "</tr>"
156.647 +
156.648 + lines = new(50000,string)
156.649 + nline = 0
156.650 +
156.651 + set_line(lines,nline,header)
156.652 + set_line(lines,nline,table_header)
156.653 +;-----------------------------------------------
156.654 +;row of table
156.655 +
156.656 + do n = 0,nrow-1
156.657 + set_line(lines,nline,row_header)
156.658 +
156.659 + txt0 = row_head(n)
156.660 + txt1 = text(n,0)
156.661 + txt2 = text(n,1)
156.662 + txt3 = text(n,2)
156.663 + txt4 = text(n,3)
156.664 + txt5 = text(n,4)
156.665 + txt6 = text(n,5)
156.666 +
156.667 + set_line(lines,nline,"<th>"+txt0+"</th>")
156.668 + set_line(lines,nline,"<th>"+txt1+"</th>")
156.669 + set_line(lines,nline,"<th>"+txt2+"</th>")
156.670 + set_line(lines,nline,"<th>"+txt3+"</th>")
156.671 + set_line(lines,nline,"<th>"+txt4+"</th>")
156.672 + set_line(lines,nline,"<th>"+txt5+"</th>")
156.673 + set_line(lines,nline,"<th>"+txt6+"</th>")
156.674 +
156.675 + set_line(lines,nline,row_footer)
156.676 + end do
156.677 +;-----------------------------------------------
156.678 + set_line(lines,nline,table_footer)
156.679 + set_line(lines,nline,footer)
156.680 +
156.681 +; Now write to an HTML file.
156.682 +
156.683 + output_html = "table_fire.html"
156.684 +
156.685 + idx = ind(.not.ismissing(lines))
156.686 + if(.not.any(ismissing(idx))) then
156.687 + asciiwrite(output_html,lines(idx))
156.688 + else
156.689 + print ("error?")
156.690 + end if
156.691 +
156.692 + delete (idx)
156.693 +
156.694 +end
156.695 +
157.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
157.2 +++ b/fire/24.table+tseries.ncl Mon Jan 26 22:08:20 2009 -0500
157.3 @@ -0,0 +1,717 @@
157.4 +;********************************************************
157.5 +; landfrac applied to area only.
157.6 +; using model biome class
157.7 +;
157.8 +; required command line input parameters:
157.9 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
157.10 +;
157.11 +; histogram normalized by rain and compute correleration
157.12 +;**************************************************************
157.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
157.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
157.15 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
157.16 +;**************************************************************
157.17 +procedure set_line(lines:string,nline:integer,newlines:string)
157.18 +begin
157.19 +; add line to ascci/html file
157.20 +
157.21 + nnewlines = dimsizes(newlines)
157.22 + if(nline+nnewlines-1.ge.dimsizes(lines))
157.23 + print("set_line: bad index, not setting anything.")
157.24 + return
157.25 + end if
157.26 + lines(nline:nline+nnewlines-1) = newlines
157.27 +; print ("lines = " + lines(nline:nline+nnewlines-1))
157.28 + nline = nline + nnewlines
157.29 + return
157.30 +end
157.31 +;**************************************************************
157.32 +; Main code.
157.33 +begin
157.34 +
157.35 + plot_type = "ps"
157.36 + plot_type_new = "png"
157.37 +
157.38 +;---------------------------------------------------
157.39 +; model name and grid
157.40 +
157.41 + model_grid = "T42"
157.42 +
157.43 + model_name = "cn"
157.44 + model_name1 = "i01.06cn"
157.45 + model_name2 = "i01.10cn"
157.46 +
157.47 +;---------------------------------------------------
157.48 +; get biome data: model
157.49 +
157.50 + biome_name_mod = "Model PFT Class"
157.51 +
157.52 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
157.53 + film = "class_pft_"+model_grid+".nc"
157.54 + fm = addfile(dirm+film,"r")
157.55 +
157.56 + classmod = fm->CLASS_PFT
157.57 +
157.58 + delete (fm)
157.59 +
157.60 +; model data has 17 land-type classes
157.61 +
157.62 + nclass_mod = 17
157.63 +
157.64 +;--------------------------------------------------
157.65 +; get model data: landmask, landfrac and area
157.66 +
157.67 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
157.68 + film = "lnd_T42.nc"
157.69 + fm = addfile (dirm+film,"r")
157.70 +
157.71 + landmask = fm->landmask
157.72 + landfrac = fm->landfrac
157.73 + area = fm->area
157.74 +
157.75 + delete (fm)
157.76 +
157.77 +; change area from km**2 to m**2
157.78 + area = area * 1.e6
157.79 +
157.80 +;---------------------------------------------------
157.81 +; take into account landfrac
157.82 +
157.83 + area = area * landfrac
157.84 +
157.85 +;----------------------------------------------------
157.86 +; read data: time series, model
157.87 +
157.88 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
157.89 + film = model_name2 + "_Fire_C_1979-2004_monthly.nc"
157.90 + fm = addfile (dirm+film,"r")
157.91 +
157.92 + data_mod = fm->COL_FIRE_CLOSS(18:25,:,:,:)
157.93 +
157.94 + delete (fm)
157.95 +
157.96 +; Units for these variables are:
157.97 +; g C/m^2/s
157.98 +
157.99 +; change unit to g C/m^2/month
157.100 +
157.101 + nsec_per_month = 60*60*24*30
157.102 +
157.103 + data_mod = data_mod * nsec_per_month
157.104 +
157.105 + data_mod@unit = "gC/m2/month"
157.106 +;----------------------------------------------------
157.107 +; read data: time series, observed
157.108 +
157.109 + dirm = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
157.110 + film = "Fire_C_1997-2006_monthly_"+ model_grid+".nc"
157.111 + fm = addfile (dirm+film,"r")
157.112 +
157.113 + data_ob = fm->FIRE_C(0:7,:,:,:)
157.114 +
157.115 + delete (fm)
157.116 +
157.117 + ob_name = "GFEDv2"
157.118 +
157.119 +; Units for these variables are:
157.120 +; g C/m^2/month
157.121 +
157.122 +;-------------------------------------------------------------
157.123 +; html table1 data
157.124 +
157.125 +; column (not including header column)
157.126 +
157.127 + col_head = (/"Observed Fire_Flux (PgC/yr)" \
157.128 + ,"Model Fire_Flux (PgC/yr)" \
157.129 + ,"Correlation Coefficient" \
157.130 + ,"Ratio model/observed" \
157.131 + ,"M_score" \
157.132 + ,"Timeseries plot" \
157.133 + /)
157.134 +
157.135 + ncol = dimsizes(col_head)
157.136 +
157.137 +; row (not including header row)
157.138 +
157.139 +; using model biome class:
157.140 + row_head = (/"Not Vegetated" \
157.141 + ,"Needleleaf Evergreen Temperate Tree" \
157.142 + ,"Needleleaf Evergreen Boreal Tree" \
157.143 +; ,"Needleleaf Deciduous Boreal Tree" \
157.144 + ,"Broadleaf Evergreen Tropical Tree" \
157.145 + ,"Broadleaf Evergreen Temperate Tree" \
157.146 + ,"Broadleaf Deciduous Tropical Tree" \
157.147 + ,"Broadleaf Deciduous Temperate Tree" \
157.148 +; ,"Broadleaf Deciduous Boreal Tree" \
157.149 +; ,"Broadleaf Evergreen Shrub" \
157.150 + ,"Broadleaf Deciduous Temperate Shrub" \
157.151 + ,"Broadleaf Deciduous Boreal Shrub" \
157.152 + ,"C3 Arctic Grass" \
157.153 + ,"C3 Non-Arctic Grass" \
157.154 + ,"C4 Grass" \
157.155 + ,"Corn" \
157.156 +; ,"Wheat" \
157.157 + ,"All Biome" \
157.158 + /)
157.159 + nrow = dimsizes(row_head)
157.160 +
157.161 +; arrays to be passed to table.
157.162 + text = new ((/nrow, ncol/),string )
157.163 +
157.164 +;*****************************************************************
157.165 +; (A) get time-mean
157.166 +;*****************************************************************
157.167 +
157.168 + x = dim_avg_Wrap(data_mod(lat|:,lon|:,month|:,year|:))
157.169 + data_mod_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
157.170 + delete (x)
157.171 +
157.172 + x = dim_avg_Wrap( data_ob(lat|:,lon|:,month|:,year|:))
157.173 + data_ob_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
157.174 + delete (x)
157.175 +
157.176 +;----------------------------------------------------
157.177 +; compute correlation coef: space
157.178 +
157.179 + landmask_1d = ndtooned(landmask)
157.180 + data_mod_1d = ndtooned(data_mod_m)
157.181 + data_ob_1d = ndtooned(data_ob_m )
157.182 + area_1d = ndtooned(area)
157.183 + landfrac_1d = ndtooned(landfrac)
157.184 +
157.185 + good = ind(landmask_1d .gt. 0.)
157.186 +
157.187 + global_mod = sum(data_mod_1d(good)*area_1d(good)) * 1.e-15 * 12.
157.188 + global_ob = sum(data_ob_1d(good) *area_1d(good)) * 1.e-15 * 12.
157.189 + print (global_mod)
157.190 + print (global_ob)
157.191 +
157.192 + global_area= sum(area_1d)
157.193 + global_land= sum(area_1d(good))
157.194 + print (global_area)
157.195 + print (global_land)
157.196 +
157.197 + cc_space = esccr(data_mod_1d(good)*landfrac_1d(good),data_ob_1d(good)*landfrac_1d(good),0)
157.198 +
157.199 + delete (landmask_1d)
157.200 + delete (landfrac_1d)
157.201 +; delete (area_1d)
157.202 + delete (data_mod_1d)
157.203 + delete (data_ob_1d)
157.204 + delete (good)
157.205 +
157.206 +;----------------------------------------------------
157.207 +; compute M_global
157.208 +
157.209 + score_max = 1.
157.210 +
157.211 + Mscore1 = cc_space * cc_space * score_max
157.212 +
157.213 + M_global = sprintf("%.2f", Mscore1)
157.214 +
157.215 +;----------------------------------------------------
157.216 +; global res
157.217 +
157.218 + resg = True ; Use plot options
157.219 + resg@cnFillOn = True ; Turn on color fill
157.220 + resg@gsnSpreadColors = True ; use full colormap
157.221 + resg@cnLinesOn = False ; Turn off contourn lines
157.222 + resg@mpFillOn = False ; Turn off map fill
157.223 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
157.224 +
157.225 +;----------------------------------------------------
157.226 +; global contour: model vs ob
157.227 +
157.228 + plot_name = "global_model_vs_ob"
157.229 +
157.230 + wks = gsn_open_wks (plot_type,plot_name)
157.231 + gsn_define_colormap(wks,"gui_default")
157.232 +
157.233 + plot=new(3,graphic) ; create graphic array
157.234 +
157.235 + resg@gsnFrame = False ; Do not draw plot
157.236 + resg@gsnDraw = False ; Do not advance frame
157.237 +
157.238 +;----------------------
157.239 +; plot correlation coef
157.240 +
157.241 + gRes = True
157.242 + gRes@txFontHeightF = 0.02
157.243 + gRes@txAngleF = 90
157.244 +
157.245 + correlation_text = "(correlation coef = "+sprintf("%.2f", cc_space)+")"
157.246 +
157.247 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
157.248 +
157.249 +;-----------------------
157.250 +; plot ob
157.251 +
157.252 + data_ob_m = where(landmask .gt. 0., data_ob_m, data_ob_m@_FillValue)
157.253 +
157.254 + title = ob_name
157.255 + resg@tiMainString = title
157.256 +
157.257 + resg@cnMinLevelValF = 1.
157.258 + resg@cnMaxLevelValF = 10.
157.259 + resg@cnLevelSpacingF = 1.
157.260 +
157.261 + plot(0) = gsn_csm_contour_map_ce(wks,data_ob_m,resg)
157.262 +
157.263 +;-----------------------
157.264 +; plot model
157.265 +
157.266 + data_mod_m = where(landmask .gt. 0., data_mod_m, data_mod_m@_FillValue)
157.267 +
157.268 + title = "Model "+ model_name
157.269 + resg@tiMainString = title
157.270 +
157.271 + resg@cnMinLevelValF = 1.
157.272 + resg@cnMaxLevelValF = 10.
157.273 + resg@cnLevelSpacingF = 1.
157.274 +
157.275 + plot(1) = gsn_csm_contour_map_ce(wks,data_mod_m,resg)
157.276 +
157.277 +;-----------------------
157.278 +; plot model-ob
157.279 +
157.280 + resg@cnMinLevelValF = -8.
157.281 + resg@cnMaxLevelValF = 2.
157.282 + resg@cnLevelSpacingF = 1.
157.283 +
157.284 + zz = data_ob_m
157.285 + zz = data_mod_m - data_ob_m
157.286 + title = "Model_"+model_name+" - Observed"
157.287 + resg@tiMainString = title
157.288 +
157.289 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
157.290 +
157.291 +; plot panel
157.292 +
157.293 + pres = True ; panel plot mods desired
157.294 + pres@gsnMaximize = True ; fill the page
157.295 +
157.296 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
157.297 +
157.298 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
157.299 + "rm "+plot_name+"."+plot_type)
157.300 +
157.301 + clear (wks)
157.302 + delete (plot)
157.303 +
157.304 + delete (data_ob_m)
157.305 + delete (data_mod_m)
157.306 + delete (zz)
157.307 +
157.308 + resg@gsnFrame = True ; Do advance frame
157.309 + resg@gsnDraw = True ; Do draw plot
157.310 +
157.311 +;*******************************************************************
157.312 +; (B) Time series : per biome
157.313 +;*******************************************************************
157.314 +
157.315 + data_n = 2
157.316 +
157.317 + dsizes = dimsizes(data_mod)
157.318 + nyear = dsizes(0)
157.319 + nmonth = dsizes(1)
157.320 + ntime = nyear * nmonth
157.321 +
157.322 + year_start = 1997
157.323 + year_end = 2004
157.324 +
157.325 +;-------------------------------------------
157.326 +; Calculate "nice" bins for binning the data
157.327 +
157.328 +; using model biome class
157.329 + nclass = nclass_mod
157.330 +
157.331 + range = fspan(0,nclass,nclass+1)
157.332 +
157.333 +; Use this range information to grab all the values in a
157.334 +; particular range, and then take an average.
157.335 +
157.336 + nx = dimsizes(range) - 1
157.337 +
157.338 +;-------------------------------------------
157.339 +; put data into bins
157.340 +
157.341 +; using observed biome class
157.342 +; base = ndtooned(classob)
157.343 +; using model biome class
157.344 + base = ndtooned(classmod)
157.345 +
157.346 +; output
157.347 +
157.348 + area_bin = new((/nx/),float)
157.349 + yvalues = new((/ntime,data_n,nx/),float)
157.350 +
157.351 +; Loop through each range, using base.
157.352 +
157.353 + do i=0,nx-1
157.354 +
157.355 + if (i.ne.(nx-1)) then
157.356 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
157.357 + else
157.358 + idx = ind(base.ge.range(i))
157.359 + end if
157.360 +;---------------------
157.361 +; for area
157.362 +
157.363 + if (.not.any(ismissing(idx))) then
157.364 + area_bin(i) = sum(area_1d(idx))
157.365 + else
157.366 + area_bin(i) = area_bin@_FillValue
157.367 + end if
157.368 +
157.369 +;#############################################################
157.370 +; using model biome class:
157.371 +; set the following 4 classes to _FillValue:
157.372 +; (3)Needleleaf Deciduous Boreal Tree,
157.373 +; (8)Broadleaf Deciduous Boreal Tree,
157.374 +; (9)Broadleaf Evergreen Shrub,
157.375 +; (16)Wheat
157.376 +
157.377 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
157.378 + area_bin(i) = area_bin@_FillValue
157.379 + end if
157.380 +;#############################################################
157.381 +
157.382 +;---------------------
157.383 +; for data_mod and data_ob
157.384 +
157.385 + do n = 0,data_n-1
157.386 +
157.387 + t = -1
157.388 + do m = 0,nyear-1
157.389 + do k = 0,nmonth-1
157.390 +
157.391 + t = t + 1
157.392 +
157.393 + if (n.eq.0) then
157.394 + data = ndtooned(data_ob(m,k,:,:))
157.395 + end if
157.396 +
157.397 + if (n.eq.1) then
157.398 + data = ndtooned(data_mod(m,k,:,:))
157.399 + end if
157.400 +
157.401 +; Calculate average
157.402 +
157.403 + if (.not.any(ismissing(idx))) then
157.404 + yvalues(t,n,i) = sum(data(idx)*area_1d(idx))
157.405 + else
157.406 + yvalues(t,n,i) = yvalues@_FillValue
157.407 + end if
157.408 +
157.409 +;#############################################################
157.410 +; using model biome class:
157.411 +; set the following 4 classes to _FillValue:
157.412 +; (3)Needleleaf Deciduous Boreal Tree,
157.413 +; (8)Broadleaf Deciduous Boreal Tree,
157.414 +; (9)Broadleaf Evergreen Shrub,
157.415 +; (16)Wheat
157.416 +
157.417 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
157.418 + yvalues(t,n,i) = yvalues@_FillValue
157.419 + end if
157.420 +;#############################################################
157.421 +
157.422 + end do
157.423 + end do
157.424 +
157.425 + delete(data)
157.426 + end do
157.427 +
157.428 + delete(idx)
157.429 + end do
157.430 +
157.431 + delete (base)
157.432 + delete (data_mod)
157.433 + delete (data_ob)
157.434 +
157.435 + global_bin = sum(area_bin)
157.436 + print (global_bin)
157.437 +
157.438 +;----------------------------------------------------------------
157.439 +; get area_good
157.440 +
157.441 + good = ind(.not.ismissing(area_bin))
157.442 +
157.443 + area_g = area_bin(good)
157.444 +
157.445 + n_biome = dimsizes(good)
157.446 +
157.447 + global_good = sum(area_g)
157.448 + print (global_good)
157.449 +
157.450 +;----------------------------------------------------------------
157.451 +; data for tseries plot
157.452 +
157.453 + yvalues_g = new((/ntime,data_n,n_biome/),float)
157.454 +
157.455 + yvalues_g@units = "TgC/month"
157.456 +
157.457 +; change unit to Tg C/month
157.458 +; change unit from g to Tg (Tera gram)
157.459 + factor_unit = 1.e-12
157.460 +
157.461 + yvalues_g = yvalues(:,:,good) * factor_unit
157.462 +
157.463 + delete (good)
157.464 +
157.465 +;-------------------------------------------------------------------
157.466 +; general settings for line plot
157.467 +
157.468 + res = True
157.469 + res@xyDashPatterns = (/0,0/) ; make lines solid
157.470 + res@xyLineThicknesses = (/2.0,2.0/) ; make lines thicker
157.471 + res@xyLineColors = (/"blue","red"/) ; line color
157.472 +
157.473 + res@trXMinF = year_start
157.474 + res@trXMaxF = year_end + 1
157.475 +
157.476 + res@vpHeightF = 0.4 ; change aspect ratio of plot
157.477 +; res@vpWidthF = 0.8
157.478 + res@vpWidthF = 0.75
157.479 +
157.480 + res@tiMainFontHeightF = 0.025 ; size of title
157.481 +
157.482 + res@tmXBFormat = "f" ; not to add trailing zeros
157.483 +
157.484 +; res@gsnMaximize = True
157.485 +
157.486 +;----------------------------------------------
157.487 +; Add a boxed legend using the simple method
157.488 +
157.489 + res@pmLegendDisplayMode = "Always"
157.490 +; res@pmLegendWidthF = 0.1
157.491 + res@pmLegendWidthF = 0.08
157.492 + res@pmLegendHeightF = 0.06
157.493 + res@pmLegendOrthogonalPosF = -1.17
157.494 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
157.495 +; res@pmLegendOrthogonalPosF = -0.30 ;(downward)
157.496 +
157.497 +; res@pmLegendParallelPosF = 0.18
157.498 + res@pmLegendParallelPosF = 0.23 ;(rightward)
157.499 + res@pmLegendParallelPosF = 0.73 ;(rightward)
157.500 + res@pmLegendParallelPosF = 0.83 ;(rightward)
157.501 +
157.502 +; res@lgPerimOn = False
157.503 + res@lgLabelFontHeightF = 0.015
157.504 + res@xyExplicitLegendLabels = (/"observed",model_name/)
157.505 +
157.506 +;*******************************************************************
157.507 +; (A) time series plot: monthly ( 2 lines per plot)
157.508 +;*******************************************************************
157.509 +
157.510 +; x-axis in time series plot
157.511 +
157.512 + timeI = new((/ntime/),integer)
157.513 + timeF = new((/ntime/),float)
157.514 + timeI = ispan(1,ntime,1)
157.515 + timeF = year_start + (timeI-1)/12.
157.516 + timeF@long_name = "year"
157.517 +
157.518 + plot_data = new((/2,ntime/),float)
157.519 + plot_data@long_name = "TgC/month"
157.520 +
157.521 +;----------------------------------------------
157.522 +; time series plot : per biome
157.523 +
157.524 + do m = 0, n_biome-1
157.525 +
157.526 + plot_name = "monthly_biome_"+ m
157.527 +
157.528 + wks = gsn_open_wks (plot_type,plot_name)
157.529 +
157.530 + title = "Fire : "+ row_head(m)
157.531 + res@tiMainString = title
157.532 +
157.533 + plot_data(0,:) = yvalues_g(:,0,m)
157.534 + plot_data(1,:) = yvalues_g(:,1,m)
157.535 +
157.536 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
157.537 +
157.538 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
157.539 + "rm "+plot_name+"."+plot_type)
157.540 +
157.541 + clear (wks)
157.542 + delete (plot)
157.543 +
157.544 + end do
157.545 +
157.546 +;------------------------------------------
157.547 +; data for table : per biome
157.548 +
157.549 +; unit change from TgC/month to PgC/month
157.550 + unit_factor = 1.e-3
157.551 +
157.552 + score_max = 1.
157.553 +
157.554 + tmp_ob = new((/ntime/),float)
157.555 + tmp_mod = new((/ntime/),float)
157.556 +
157.557 + total_ob = new((/n_biome/),float)
157.558 + total_mod = new((/n_biome/),float)
157.559 + Mscore2 = new((/n_biome/),float)
157.560 +
157.561 + do m = 0, n_biome-1
157.562 +
157.563 + tmp_ob = yvalues_g(:,0,m)
157.564 + tmp_mod = yvalues_g(:,1,m)
157.565 +
157.566 + total_ob(m) = avg(month_to_annual(tmp_ob, 0)) * unit_factor
157.567 + total_mod(m) = avg(month_to_annual(tmp_mod,0)) * unit_factor
157.568 +
157.569 + cc_time = esccr(tmp_mod,tmp_ob,0)
157.570 +
157.571 + ratio = total_mod(m)/total_ob(m)
157.572 +
157.573 + good = ind(tmp_ob .ne. 0. .and. tmp_mod .ne. 0.)
157.574 +
157.575 + bias = sum( abs( tmp_mod(good)-tmp_ob(good) )/( abs(tmp_mod(good))+abs(tmp_ob(good)) ) )
157.576 + Mscore2(m) = (1.- (bias/dimsizes(good)))*score_max
157.577 +
157.578 + delete (good)
157.579 +
157.580 + text(m,0) = sprintf("%.2f",total_ob(m))
157.581 + text(m,1) = sprintf("%.2f",total_mod(m))
157.582 + text(m,2) = sprintf("%.2f",cc_time)
157.583 + text(m,3) = sprintf("%.2f",ratio)
157.584 + text(m,4) = sprintf("%.2f",Mscore2(m))
157.585 + text(m,5) = "<a href=./monthly_biome_"+m+".png>model_vs_ob</a>"
157.586 + end do
157.587 +
157.588 + delete (tmp_ob)
157.589 + delete (tmp_mod)
157.590 +
157.591 +;--------------------------------------------
157.592 +; time series plot: all biome
157.593 +
157.594 + plot_name = "monthly_global"
157.595 +
157.596 + wks = gsn_open_wks (plot_type,plot_name)
157.597 +
157.598 + title = "Fire : "+ row_head(n_biome)
157.599 + res@tiMainString = title
157.600 +
157.601 + do k = 0,ntime-1
157.602 + plot_data(0,k) = sum(yvalues_g(k,0,:))
157.603 + plot_data(1,k) = sum(yvalues_g(k,1,:))
157.604 + end do
157.605 +
157.606 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
157.607 +
157.608 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
157.609 + "rm "+plot_name+"."+plot_type)
157.610 +
157.611 + clear (wks)
157.612 + delete (plot)
157.613 +
157.614 +;------------------------------------------
157.615 +; data for table : global
157.616 +
157.617 + score_max = 1.
157.618 +
157.619 + tmp_ob = ndtooned(yvalues_g(:,0,:))
157.620 + tmp_mod = ndtooned(yvalues_g(:,1,:))
157.621 +
157.622 + cc_time = esccr(tmp_mod,tmp_ob,0)
157.623 +
157.624 + ratio = sum(total_mod)/sum(total_ob)
157.625 +
157.626 + good = ind(tmp_ob .ne. 0. .and. tmp_mod .ne. 0.)
157.627 +
157.628 + bias = sum( abs( tmp_mod(good)-tmp_ob(good) )/( abs(tmp_mod(good))+abs(tmp_ob(good)) ) )
157.629 + Mscore3 = (1.- (bias/dimsizes(good)))*score_max
157.630 +
157.631 + print (Mscore3)
157.632 +
157.633 + delete (good)
157.634 +
157.635 + text(nrow-1,0) = sprintf("%.2f",sum(total_ob))
157.636 + text(nrow-1,1) = sprintf("%.2f",sum(total_mod))
157.637 + text(nrow-1,2) = sprintf("%.2f",cc_time)
157.638 + text(nrow-1,3) = sprintf("%.2f",ratio)
157.639 +; text(nrow-1,4) = sprintf("%.2f",avg(Mscore2))
157.640 + text(nrow-1,4) = sprintf("%.2f", Mscore3)
157.641 + text(nrow-1,5) = "<a href=./monthly_global.png>model_vs_ob</a>"
157.642 +
157.643 +;**************************************************
157.644 +; create html table
157.645 +;**************************************************
157.646 +
157.647 + header_text = "<H1>Fire Emission (1997-2004): Model "+model_name+"</H1>"
157.648 +
157.649 + header = (/"<HTML>" \
157.650 + ,"<HEAD>" \
157.651 + ,"<TITLE>CLAMP metrics</TITLE>" \
157.652 + ,"</HEAD>" \
157.653 + ,header_text \
157.654 + /)
157.655 + footer = "</HTML>"
157.656 +
157.657 + table_header = (/ \
157.658 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
157.659 + ,"<tr>" \
157.660 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
157.661 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
157.662 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
157.663 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
157.664 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
157.665 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
157.666 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
157.667 + ,"</tr>" \
157.668 + /)
157.669 + table_footer = "</table>"
157.670 + row_header = "<tr>"
157.671 + row_footer = "</tr>"
157.672 +
157.673 + lines = new(50000,string)
157.674 + nline = 0
157.675 +
157.676 + set_line(lines,nline,header)
157.677 + set_line(lines,nline,table_header)
157.678 +;-----------------------------------------------
157.679 +;row of table
157.680 +
157.681 + do n = 0,nrow-1
157.682 + set_line(lines,nline,row_header)
157.683 +
157.684 + txt0 = row_head(n)
157.685 + txt1 = text(n,0)
157.686 + txt2 = text(n,1)
157.687 + txt3 = text(n,2)
157.688 + txt4 = text(n,3)
157.689 + txt5 = text(n,4)
157.690 + txt6 = text(n,5)
157.691 +
157.692 + set_line(lines,nline,"<th>"+txt0+"</th>")
157.693 + set_line(lines,nline,"<th>"+txt1+"</th>")
157.694 + set_line(lines,nline,"<th>"+txt2+"</th>")
157.695 + set_line(lines,nline,"<th>"+txt3+"</th>")
157.696 + set_line(lines,nline,"<th>"+txt4+"</th>")
157.697 + set_line(lines,nline,"<th>"+txt5+"</th>")
157.698 + set_line(lines,nline,"<th>"+txt6+"</th>")
157.699 +
157.700 + set_line(lines,nline,row_footer)
157.701 + end do
157.702 +;-----------------------------------------------
157.703 + set_line(lines,nline,table_footer)
157.704 + set_line(lines,nline,footer)
157.705 +
157.706 +; Now write to an HTML file.
157.707 +
157.708 + output_html = "table_fire.html"
157.709 +
157.710 + idx = ind(.not.ismissing(lines))
157.711 + if(.not.any(ismissing(idx))) then
157.712 + asciiwrite(output_html,lines(idx))
157.713 + else
157.714 + print ("error?")
157.715 + end if
157.716 +
157.717 + delete (idx)
157.718 +
157.719 +end
157.720 +
158.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
158.2 +++ b/fire/24x.table+tseries.ncl Mon Jan 26 22:08:20 2009 -0500
158.3 @@ -0,0 +1,784 @@
158.4 +;********************************************************
158.5 +; using observed biome class
158.6 +; landfrac applied to area only.
158.7 +;
158.8 +; required command line input parameters:
158.9 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
158.10 +;
158.11 +; histogram normalized by rain and compute correleration
158.12 +;**************************************************************
158.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
158.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
158.15 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
158.16 +;**************************************************************
158.17 +procedure set_line(lines:string,nline:integer,newlines:string)
158.18 +begin
158.19 +; add line to ascci/html file
158.20 +
158.21 + nnewlines = dimsizes(newlines)
158.22 + if(nline+nnewlines-1.ge.dimsizes(lines))
158.23 + print("set_line: bad index, not setting anything.")
158.24 + return
158.25 + end if
158.26 + lines(nline:nline+nnewlines-1) = newlines
158.27 +; print ("lines = " + lines(nline:nline+nnewlines-1))
158.28 + nline = nline + nnewlines
158.29 + return
158.30 +end
158.31 +;**************************************************************
158.32 +; Main code.
158.33 +begin
158.34 +
158.35 + plot_type = "ps"
158.36 + plot_type_new = "png"
158.37 +
158.38 +;---------------------------------------------------
158.39 +; model name and grid
158.40 +
158.41 + model_grid = "T42"
158.42 +
158.43 + model_name = "cn"
158.44 + model_name1 = "i01.06cn"
158.45 + model_name2 = "i01.10cn"
158.46 +
158.47 +;------------------------------------------------
158.48 +; read biome data: observed
158.49 +
158.50 + biome_name_ob = "MODIS LandCover"
158.51 +
158.52 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
158.53 + filo = "land_class_"+model_grid+".nc"
158.54 +
158.55 + fo = addfile(diro+filo,"r")
158.56 +
158.57 + classob = tofloat(fo->LAND_CLASS)
158.58 +
158.59 + delete (fo)
158.60 +
158.61 +; observed data has 20 land-type classes
158.62 +
158.63 + nclass_ob = 20
158.64 +
158.65 +;---------------------------------------------------
158.66 +; get biome data: model
158.67 +
158.68 + biome_name_mod = "Model PFT Class"
158.69 +
158.70 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
158.71 + film = "class_pft_"+model_grid+".nc"
158.72 + fm = addfile(dirm+film,"r")
158.73 +
158.74 + classmod = fm->CLASS_PFT
158.75 +
158.76 + delete (fm)
158.77 +
158.78 +; model data has 17 land-type classes
158.79 +
158.80 + nclass_mod = 17
158.81 +
158.82 +;--------------------------------------------------
158.83 +; get model data: landmask, landfrac and area
158.84 +
158.85 + dirm = "/fis/cgd/cseg/people/jeff/surface_data/"
158.86 + film = "lnd_T42.nc"
158.87 + fm = addfile (dirm+film,"r")
158.88 +
158.89 + landmask = fm->landmask
158.90 + landfrac = fm->landfrac
158.91 + area = fm->area
158.92 +
158.93 + delete (fm)
158.94 +
158.95 +; change area from km**2 to m**2
158.96 + area = area * 1.e6
158.97 +
158.98 +;---------------------------------------------------
158.99 +; take into account landfrac
158.100 +
158.101 + area = area * landfrac
158.102 +
158.103 +;----------------------------------------------------
158.104 +; read data: time series, model
158.105 +
158.106 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
158.107 + film = model_name2 + "_Fire_C_1979-2004_monthly.nc"
158.108 + fm = addfile (dirm+film,"r")
158.109 +
158.110 + data_mod = fm->COL_FIRE_CLOSS(18:25,:,:,:)
158.111 +
158.112 + delete (fm)
158.113 +
158.114 +; Units for these variables are:
158.115 +; g C/m^2/s
158.116 +
158.117 +; change unit to g C/m^2/month
158.118 +
158.119 + nsec_per_month = 60*60*24*30
158.120 +
158.121 + data_mod = data_mod * nsec_per_month
158.122 +
158.123 + data_mod@unit = "gC/m2/month"
158.124 +;----------------------------------------------------
158.125 +; read data: time series, observed
158.126 +
158.127 + dirm = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
158.128 + film = "Fire_C_1997-2006_monthly_"+ model_grid+".nc"
158.129 + fm = addfile (dirm+film,"r")
158.130 +
158.131 + data_ob = fm->FIRE_C(0:7,:,:,:)
158.132 +
158.133 + delete (fm)
158.134 +
158.135 + ob_name = "GFEDv2"
158.136 +
158.137 +; Units for these variables are:
158.138 +; g C/m^2/month
158.139 +
158.140 +;-------------------------------------------------------------
158.141 +; html table1 data
158.142 +
158.143 +; column (not including header column)
158.144 +
158.145 + col_head = (/"Observed Fire_Flux (PgC/yr)" \
158.146 + ,"Model Fire_Flux (PgC/yr)" \
158.147 + ,"Correlation Coefficient" \
158.148 + ,"Ratio model/observed" \
158.149 + ,"M_score" \
158.150 + ,"Timeseries plot" \
158.151 + /)
158.152 +
158.153 + ncol = dimsizes(col_head)
158.154 +
158.155 +; row (not including header row)
158.156 +
158.157 +;----------------------------------------------------
158.158 +; using observed biome class:
158.159 + row_head = (/"Evergreen Needleleaf Forests" \
158.160 + ,"Evergreen Broadleaf Forests" \
158.161 + ,"Deciduous Needleleaf Forest" \
158.162 + ,"Deciduous Broadleaf Forests" \
158.163 + ,"Mixed Forests" \
158.164 + ,"Closed Bushlands" \
158.165 + ,"Open Bushlands" \
158.166 + ,"Woody Savannas (S. Hem.)" \
158.167 + ,"Savannas (S. Hem.)" \
158.168 + ,"Grasslands" \
158.169 + ,"Permanent Wetlands" \
158.170 + ,"Croplands" \
158.171 + ,"Cropland/Natural Vegetation Mosaic" \
158.172 + ,"Barren or Sparsely Vegetated" \
158.173 + ,"Woody Savannas (N. Hem.)" \
158.174 + ,"Savannas (N. Hem.)" \
158.175 + ,"All Biome" \
158.176 + /)
158.177 +
158.178 +
158.179 +; using model biome class:
158.180 +; row_head = (/"Not Vegetated" \
158.181 +; ,"Needleleaf Evergreen Temperate Tree" \
158.182 +; ,"Needleleaf Evergreen Boreal Tree" \
158.183 +;; ,"Needleleaf Deciduous Boreal Tree" \
158.184 +; ,"Broadleaf Evergreen Tropical Tree" \
158.185 +; ,"Broadleaf Evergreen Temperate Tree" \
158.186 +; ,"Broadleaf Deciduous Tropical Tree" \
158.187 +; ,"Broadleaf Deciduous Temperate Tree" \
158.188 +;; ,"Broadleaf Deciduous Boreal Tree" \
158.189 +;; ,"Broadleaf Evergreen Shrub" \
158.190 +; ,"Broadleaf Deciduous Temperate Shrub" \
158.191 +; ,"Broadleaf Deciduous Boreal Shrub" \
158.192 +; ,"C3 Arctic Grass" \
158.193 +; ,"C3 Non-Arctic Grass" \
158.194 +; ,"C4 Grass" \
158.195 +; ,"Corn" \
158.196 +;; ,"Wheat" \
158.197 +; ,"All Biome" \
158.198 +; /)
158.199 + nrow = dimsizes(row_head)
158.200 +
158.201 +; arrays to be passed to table.
158.202 + text = new ((/nrow, ncol/),string )
158.203 +
158.204 +;*****************************************************************
158.205 +; (A) get time-mean
158.206 +;*****************************************************************
158.207 +
158.208 + x = dim_avg_Wrap(data_mod(lat|:,lon|:,month|:,year|:))
158.209 + data_mod_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
158.210 + delete (x)
158.211 +
158.212 + x = dim_avg_Wrap( data_ob(lat|:,lon|:,month|:,year|:))
158.213 + data_ob_m = dim_avg_Wrap( x(lat|:,lon|:,month|:))
158.214 + delete (x)
158.215 +
158.216 +;----------------------------------------------------
158.217 +; compute correlation coef: space
158.218 +
158.219 + landmask_1d = ndtooned(landmask)
158.220 + data_mod_1d = ndtooned(data_mod_m)
158.221 + data_ob_1d = ndtooned(data_ob_m )
158.222 + area_1d = ndtooned(area)
158.223 + landfrac_1d = ndtooned(landfrac)
158.224 +
158.225 + good = ind(landmask_1d .gt. 0.)
158.226 +
158.227 + global_mod = sum(data_mod_1d(good)*area_1d(good)) * 1.e-15 * 12.
158.228 + global_ob = sum(data_ob_1d(good) *area_1d(good)) * 1.e-15 * 12.
158.229 +
158.230 + print (global_mod)
158.231 + print (global_ob)
158.232 +
158.233 + global_area= sum(area_1d)
158.234 + global_land= sum(area_1d(good))
158.235 + print (global_area)
158.236 + print (global_land)
158.237 +
158.238 + cc_space = esccr(data_mod_1d(good)*landfrac_1d(good),data_ob_1d(good)*landfrac_1d(good),0)
158.239 +
158.240 + delete (landmask_1d)
158.241 + delete (landfrac_1d)
158.242 +; delete (area_1d)
158.243 + delete (data_mod_1d)
158.244 + delete (data_ob_1d)
158.245 + delete (good)
158.246 +
158.247 +;----------------------------------------------------
158.248 +; compute M_global
158.249 +
158.250 + score_max = 1.
158.251 +
158.252 + Mscore1 = cc_space * cc_space * score_max
158.253 +
158.254 + M_global = sprintf("%.2f", Mscore1)
158.255 +
158.256 +;----------------------------------------------------
158.257 +; global res
158.258 +
158.259 + resg = True ; Use plot options
158.260 + resg@cnFillOn = True ; Turn on color fill
158.261 + resg@gsnSpreadColors = True ; use full colormap
158.262 + resg@cnLinesOn = False ; Turn off contourn lines
158.263 + resg@mpFillOn = False ; Turn off map fill
158.264 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
158.265 +
158.266 +;----------------------------------------------------
158.267 +; global contour: model vs ob
158.268 +
158.269 + plot_name = "global_model_vs_ob"
158.270 +
158.271 + wks = gsn_open_wks (plot_type,plot_name)
158.272 + gsn_define_colormap(wks,"gui_default")
158.273 +
158.274 + plot=new(3,graphic) ; create graphic array
158.275 +
158.276 + resg@gsnFrame = False ; Do not draw plot
158.277 + resg@gsnDraw = False ; Do not advance frame
158.278 +
158.279 +;----------------------
158.280 +; plot correlation coef
158.281 +
158.282 + gRes = True
158.283 + gRes@txFontHeightF = 0.02
158.284 + gRes@txAngleF = 90
158.285 +
158.286 + correlation_text = "(correlation coef = "+sprintf("%.2f", cc_space)+")"
158.287 +
158.288 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
158.289 +
158.290 +;-----------------------
158.291 +; plot ob
158.292 +
158.293 + data_ob_m = where(landmask .gt. 0., data_ob_m, data_ob_m@_FillValue)
158.294 +
158.295 + title = ob_name
158.296 + resg@tiMainString = title
158.297 +
158.298 + resg@cnMinLevelValF = 1.
158.299 + resg@cnMaxLevelValF = 10.
158.300 + resg@cnLevelSpacingF = 1.
158.301 +
158.302 + plot(0) = gsn_csm_contour_map_ce(wks,data_ob_m,resg)
158.303 +
158.304 +;-----------------------
158.305 +; plot model
158.306 +
158.307 + data_mod_m = where(landmask .gt. 0., data_mod_m, data_mod_m@_FillValue)
158.308 +
158.309 + title = "Model "+ model_name
158.310 + resg@tiMainString = title
158.311 +
158.312 + resg@cnMinLevelValF = 1.
158.313 + resg@cnMaxLevelValF = 10.
158.314 + resg@cnLevelSpacingF = 1.
158.315 +
158.316 + plot(1) = gsn_csm_contour_map_ce(wks,data_mod_m,resg)
158.317 +
158.318 +;-----------------------
158.319 +; plot model-ob
158.320 +
158.321 + resg@cnMinLevelValF = -8.
158.322 + resg@cnMaxLevelValF = 2.
158.323 + resg@cnLevelSpacingF = 1.
158.324 +
158.325 + zz = data_ob_m
158.326 + zz = data_mod_m - data_ob_m
158.327 + title = "Model_"+model_name+" - Observed"
158.328 + resg@tiMainString = title
158.329 +
158.330 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
158.331 +
158.332 +; plot panel
158.333 +
158.334 + pres = True ; panel plot mods desired
158.335 + pres@gsnMaximize = True ; fill the page
158.336 +
158.337 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
158.338 +
158.339 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
158.340 + "rm "+plot_name+"."+plot_type)
158.341 +
158.342 + clear (wks)
158.343 + delete (plot)
158.344 +
158.345 + delete (data_ob_m)
158.346 + delete (data_mod_m)
158.347 + delete (zz)
158.348 +
158.349 + resg@gsnFrame = True ; Do advance frame
158.350 + resg@gsnDraw = True ; Do draw plot
158.351 +
158.352 +;*******************************************************************
158.353 +; (B) Time series : per biome
158.354 +;*******************************************************************
158.355 +
158.356 + data_n = 2
158.357 +
158.358 + dsizes = dimsizes(data_mod)
158.359 + nyear = dsizes(0)
158.360 + nmonth = dsizes(1)
158.361 + ntime = nyear * nmonth
158.362 +
158.363 + year_start = 1997
158.364 + year_end = 2004
158.365 +
158.366 +;-------------------------------------------
158.367 +; Calculate "nice" bins for binning the data
158.368 +
158.369 +; using ob biome class
158.370 + nclass = nclass_ob
158.371 +; using model biome class
158.372 +; nclass = nclass_mod
158.373 +
158.374 + range = fspan(0,nclass,nclass+1)
158.375 +
158.376 +; Use this range information to grab all the values in a
158.377 +; particular range, and then take an average.
158.378 +
158.379 + nx = dimsizes(range) - 1
158.380 +
158.381 +;-------------------------------------------
158.382 +; put data into bins
158.383 +
158.384 +; using observed biome class
158.385 + base = ndtooned(classob)
158.386 +; using model biome class
158.387 +; base = ndtooned(classmod)
158.388 +
158.389 +; output
158.390 +
158.391 + area_bin = new((/nx/),float)
158.392 + yvalues = new((/ntime,data_n,nx/),float)
158.393 +
158.394 +; Loop through each range, using base.
158.395 +
158.396 + do i=0,nx-1
158.397 +
158.398 + if (i.ne.(nx-1)) then
158.399 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
158.400 + else
158.401 + idx = ind(base.ge.range(i))
158.402 + end if
158.403 +;---------------------
158.404 +; for area
158.405 +
158.406 + if (.not.any(ismissing(idx))) then
158.407 + area_bin(i) = sum(area_1d(idx))
158.408 + else
158.409 + area_bin(i) = area_bin@_FillValue
158.410 + end if
158.411 +
158.412 +;#############################################################
158.413 +;using observed biome class:
158.414 +; set the following 4 classes to _FillValue:
158.415 +; Water Bodies(0), Urban and Build-Up(13),
158.416 +; Permenant Snow and Ice(15), Unclassified(17)
158.417 +
158.418 + if (i.eq.0 .or. i.eq.13 .or. i.eq.15 .or. i.eq.17) then
158.419 + area_bin(i) = yvalues@_FillValue
158.420 + end if
158.421 +;#############################################################
158.422 +
158.423 +
158.424 +;#############################################################
158.425 +; using model biome class:
158.426 +; set the following 4 classes to _FillValue:
158.427 +; (3)Needleleaf Deciduous Boreal Tree,
158.428 +; (8)Broadleaf Deciduous Boreal Tree,
158.429 +; (9)Broadleaf Evergreen Shrub,
158.430 +; (16)Wheat
158.431 +
158.432 +; if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
158.433 +; area_bin(i) = area_bin@_FillValue
158.434 +; end if
158.435 +;#############################################################
158.436 +
158.437 +;---------------------
158.438 +; for data_mod and data_ob
158.439 +
158.440 + do n = 0,data_n-1
158.441 +
158.442 + t = -1
158.443 + do m = 0,nyear-1
158.444 + do k = 0,nmonth-1
158.445 +
158.446 + t = t + 1
158.447 +
158.448 + if (n.eq.0) then
158.449 + data = ndtooned(data_ob(m,k,:,:))
158.450 + end if
158.451 +
158.452 + if (n.eq.1) then
158.453 + data = ndtooned(data_mod(m,k,:,:))
158.454 + end if
158.455 +
158.456 +; Calculate average
158.457 +
158.458 + if (.not.any(ismissing(idx))) then
158.459 + yvalues(t,n,i) = sum(data(idx)*area_1d(idx))
158.460 + else
158.461 + yvalues(t,n,i) = yvalues@_FillValue
158.462 + end if
158.463 +
158.464 +;#############################################################
158.465 +;using observed biome class:
158.466 +; set the following 4 classes to _FillValue:
158.467 +; Water Bodies(0), Urban and Build-Up(13),
158.468 +; Permenant Snow and Ice(15), Unclassified(17)
158.469 +
158.470 + if (i.eq.0 .or. i.eq.13 .or. i.eq.15 .or. i.eq.17) then
158.471 + yvalues(t,n,i) = yvalues@_FillValue
158.472 + end if
158.473 +;#############################################################
158.474 +
158.475 +
158.476 +;#############################################################
158.477 +; using model biome class:
158.478 +; set the following 4 classes to _FillValue:
158.479 +; (3)Needleleaf Deciduous Boreal Tree,
158.480 +; (8)Broadleaf Deciduous Boreal Tree,
158.481 +; (9)Broadleaf Evergreen Shrub,
158.482 +; (16)Wheat
158.483 +
158.484 +; if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
158.485 +; yvalues(t,n,i) = yvalues@_FillValue
158.486 +; end if
158.487 +;#############################################################
158.488 +
158.489 + end do
158.490 + end do
158.491 +
158.492 + delete(data)
158.493 + end do
158.494 +
158.495 + delete(idx)
158.496 + end do
158.497 +
158.498 + delete (base)
158.499 + delete (data_mod)
158.500 + delete (data_ob)
158.501 +
158.502 + global_bin = sum(area_bin)
158.503 + print (global_bin)
158.504 +
158.505 +;----------------------------------------------------------------
158.506 +; get area_good
158.507 +
158.508 + good = ind(.not.ismissing(area_bin))
158.509 +
158.510 + area_g = area_bin(good)
158.511 +
158.512 + n_biome = dimsizes(good)
158.513 +
158.514 + global_good = sum(area_g)
158.515 + print (global_good)
158.516 +
158.517 +;----------------------------------------------------------------
158.518 +; data for tseries plot
158.519 +
158.520 + yvalues_g = new((/ntime,data_n,n_biome/),float)
158.521 +
158.522 + yvalues_g@units = "TgC/month"
158.523 +
158.524 +; change unit to Tg C/month
158.525 +; change unit from g to Tg (Tera gram)
158.526 + factor_unit = 1.e-12
158.527 +
158.528 + yvalues_g = yvalues(:,:,good) * factor_unit
158.529 +
158.530 + delete (good)
158.531 +
158.532 +;-------------------------------------------------------------------
158.533 +; general settings for line plot
158.534 +
158.535 + res = True
158.536 + res@xyDashPatterns = (/0,0/) ; make lines solid
158.537 + res@xyLineThicknesses = (/2.0,2.0/) ; make lines thicker
158.538 + res@xyLineColors = (/"blue","red"/) ; line color
158.539 +
158.540 + res@trXMinF = year_start
158.541 + res@trXMaxF = year_end + 1
158.542 +
158.543 + res@vpHeightF = 0.4 ; change aspect ratio of plot
158.544 +; res@vpWidthF = 0.8
158.545 + res@vpWidthF = 0.75
158.546 +
158.547 + res@tiMainFontHeightF = 0.025 ; size of title
158.548 +
158.549 + res@tmXBFormat = "f" ; not to add trailing zeros
158.550 +
158.551 +; res@gsnMaximize = True
158.552 +
158.553 +;----------------------------------------------
158.554 +; Add a boxed legend using the simple method
158.555 +
158.556 + res@pmLegendDisplayMode = "Always"
158.557 +; res@pmLegendWidthF = 0.1
158.558 + res@pmLegendWidthF = 0.08
158.559 + res@pmLegendHeightF = 0.06
158.560 + res@pmLegendOrthogonalPosF = -1.17
158.561 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
158.562 +; res@pmLegendOrthogonalPosF = -0.30 ;(downward)
158.563 +
158.564 +; res@pmLegendParallelPosF = 0.18
158.565 + res@pmLegendParallelPosF = 0.23 ;(rightward)
158.566 + res@pmLegendParallelPosF = 0.73 ;(rightward)
158.567 + res@pmLegendParallelPosF = 0.83 ;(rightward)
158.568 +
158.569 +; res@lgPerimOn = False
158.570 + res@lgLabelFontHeightF = 0.015
158.571 + res@xyExplicitLegendLabels = (/"observed",model_name/)
158.572 +
158.573 +;*******************************************************************
158.574 +; (A) time series plot: monthly ( 2 lines per plot)
158.575 +;*******************************************************************
158.576 +
158.577 +; x-axis in time series plot
158.578 +
158.579 + timeI = new((/ntime/),integer)
158.580 + timeF = new((/ntime/),float)
158.581 + timeI = ispan(1,ntime,1)
158.582 + timeF = year_start + (timeI-1)/12.
158.583 + timeF@long_name = "year"
158.584 +
158.585 + plot_data = new((/2,ntime/),float)
158.586 + plot_data@long_name = "TgC/month"
158.587 +
158.588 +;----------------------------------------------
158.589 +; time series plot : per biome
158.590 +
158.591 + do m = 0, n_biome-1
158.592 +
158.593 + plot_name = "monthly_biome_"+ m
158.594 +
158.595 + wks = gsn_open_wks (plot_type,plot_name)
158.596 +
158.597 + title = "Fire : "+ row_head(m)
158.598 + res@tiMainString = title
158.599 +
158.600 + plot_data(0,:) = yvalues_g(:,0,m)
158.601 + plot_data(1,:) = yvalues_g(:,1,m)
158.602 +
158.603 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
158.604 +
158.605 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
158.606 + "rm "+plot_name+"."+plot_type)
158.607 +
158.608 + clear (wks)
158.609 + delete (plot)
158.610 +
158.611 + end do
158.612 +
158.613 +;------------------------------------------
158.614 +; data for table : per biome
158.615 +
158.616 +; unit change from TgC/month to PgC/month
158.617 + unit_factor = 1.e-3
158.618 +
158.619 + score_max = 1.
158.620 +
158.621 + tmp_ob = new((/ntime/),float)
158.622 + tmp_mod = new((/ntime/),float)
158.623 +
158.624 + total_ob = new((/n_biome/),float)
158.625 + total_mod = new((/n_biome/),float)
158.626 + Mscore2 = new((/n_biome/),float)
158.627 +
158.628 + do m = 0, n_biome-1
158.629 +
158.630 + tmp_ob = yvalues_g(:,0,m)
158.631 + tmp_mod = yvalues_g(:,1,m)
158.632 +
158.633 + total_ob(m) = avg(month_to_annual(tmp_ob, 0)) * unit_factor
158.634 + total_mod(m) = avg(month_to_annual(tmp_mod,0)) * unit_factor
158.635 +
158.636 + cc_time = esccr(tmp_mod,tmp_ob,0)
158.637 +
158.638 + ratio = total_mod(m)/total_ob(m)
158.639 +
158.640 + good = ind(tmp_ob .ne. 0. .and. tmp_mod .ne. 0.)
158.641 +
158.642 + bias = sum( abs( tmp_mod(good)-tmp_ob(good) )/( abs(tmp_mod(good))+abs(tmp_ob(good)) ) )
158.643 + Mscore2(m) = (1.- (bias/dimsizes(good)))*score_max
158.644 +
158.645 + delete (good)
158.646 +
158.647 + text(m,0) = sprintf("%.2f",total_ob(m))
158.648 + text(m,1) = sprintf("%.2f",total_mod(m))
158.649 + text(m,2) = sprintf("%.2f",cc_time)
158.650 + text(m,3) = sprintf("%.2f",ratio)
158.651 + text(m,4) = sprintf("%.2f",Mscore2(m))
158.652 + text(m,5) = "<a href=./monthly_biome_"+m+".png>model_vs_ob</a>"
158.653 + end do
158.654 +
158.655 + delete (tmp_ob)
158.656 + delete (tmp_mod)
158.657 +
158.658 +;--------------------------------------------
158.659 +; time series plot: all biome
158.660 +
158.661 + plot_name = "monthly_global"
158.662 +
158.663 + wks = gsn_open_wks (plot_type,plot_name)
158.664 +
158.665 + title = "Fire : "+ row_head(n_biome)
158.666 + res@tiMainString = title
158.667 +
158.668 + do k = 0,ntime-1
158.669 + plot_data(0,k) = sum(yvalues_g(k,0,:))
158.670 + plot_data(1,k) = sum(yvalues_g(k,1,:))
158.671 + end do
158.672 +
158.673 + plot = gsn_csm_xy(wks,timeF,plot_data,res)
158.674 +
158.675 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
158.676 + "rm "+plot_name+"."+plot_type)
158.677 +
158.678 + clear (wks)
158.679 + delete (plot)
158.680 +
158.681 +;------------------------------------------
158.682 +; data for table : global
158.683 +
158.684 + score_max = 1.
158.685 +
158.686 + tmp_ob = ndtooned(yvalues_g(:,0,:))
158.687 + tmp_mod = ndtooned(yvalues_g(:,1,:))
158.688 +
158.689 + cc_time = esccr(tmp_mod,tmp_ob,0)
158.690 +
158.691 + ratio = sum(total_mod)/sum(total_ob)
158.692 +
158.693 + good = ind(tmp_ob .ne. 0. .and. tmp_mod .ne. 0.)
158.694 +
158.695 + bias = sum( abs( tmp_mod(good)-tmp_ob(good) )/( abs(tmp_mod(good))+abs(tmp_ob(good)) ) )
158.696 + Mscore3 = (1.- (bias/dimsizes(good)))*score_max
158.697 +
158.698 + print (Mscore3)
158.699 +
158.700 + delete (good)
158.701 +
158.702 + text(nrow-1,0) = sprintf("%.2f",sum(total_ob))
158.703 + text(nrow-1,1) = sprintf("%.2f",sum(total_mod))
158.704 + text(nrow-1,2) = sprintf("%.2f",cc_time)
158.705 + text(nrow-1,3) = sprintf("%.2f",ratio)
158.706 +; text(nrow-1,4) = sprintf("%.2f",avg(Mscore2))
158.707 + text(nrow-1,4) = sprintf("%.2f", Mscore3)
158.708 + text(nrow-1,5) = "<a href=./monthly_global.png>model_vs_ob</a>"
158.709 +
158.710 +;**************************************************
158.711 +; create html table
158.712 +;**************************************************
158.713 +
158.714 + header_text = "<H1>Fire Emission (1997-2004): Model "+model_name+"</H1>"
158.715 +
158.716 + header = (/"<HTML>" \
158.717 + ,"<HEAD>" \
158.718 + ,"<TITLE>CLAMP metrics</TITLE>" \
158.719 + ,"</HEAD>" \
158.720 + ,header_text \
158.721 + /)
158.722 + footer = "</HTML>"
158.723 +
158.724 + table_header = (/ \
158.725 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
158.726 + ,"<tr>" \
158.727 + ," <th bgcolor=DDDDDD >Biome Type</th>" \
158.728 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
158.729 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
158.730 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
158.731 + ," <th bgcolor=DDDDDD >"+col_head(3)+"</th>" \
158.732 + ," <th bgcolor=DDDDDD >"+col_head(4)+"</th>" \
158.733 + ," <th bgcolor=DDDDDD >"+col_head(5)+"</th>" \
158.734 + ,"</tr>" \
158.735 + /)
158.736 + table_footer = "</table>"
158.737 + row_header = "<tr>"
158.738 + row_footer = "</tr>"
158.739 +
158.740 + lines = new(50000,string)
158.741 + nline = 0
158.742 +
158.743 + set_line(lines,nline,header)
158.744 + set_line(lines,nline,table_header)
158.745 +;-----------------------------------------------
158.746 +;row of table
158.747 +
158.748 + do n = 0,nrow-1
158.749 + set_line(lines,nline,row_header)
158.750 +
158.751 + txt0 = row_head(n)
158.752 + txt1 = text(n,0)
158.753 + txt2 = text(n,1)
158.754 + txt3 = text(n,2)
158.755 + txt4 = text(n,3)
158.756 + txt5 = text(n,4)
158.757 + txt6 = text(n,5)
158.758 +
158.759 + set_line(lines,nline,"<th>"+txt0+"</th>")
158.760 + set_line(lines,nline,"<th>"+txt1+"</th>")
158.761 + set_line(lines,nline,"<th>"+txt2+"</th>")
158.762 + set_line(lines,nline,"<th>"+txt3+"</th>")
158.763 + set_line(lines,nline,"<th>"+txt4+"</th>")
158.764 + set_line(lines,nline,"<th>"+txt5+"</th>")
158.765 + set_line(lines,nline,"<th>"+txt6+"</th>")
158.766 +
158.767 + set_line(lines,nline,row_footer)
158.768 + end do
158.769 +;-----------------------------------------------
158.770 + set_line(lines,nline,table_footer)
158.771 + set_line(lines,nline,footer)
158.772 +
158.773 +; Now write to an HTML file.
158.774 +
158.775 + output_html = "table_fire.html"
158.776 +
158.777 + idx = ind(.not.ismissing(lines))
158.778 + if(.not.any(ismissing(idx))) then
158.779 + asciiwrite(output_html,lines(idx))
158.780 + else
158.781 + print ("error?")
158.782 + end if
158.783 +
158.784 + delete (idx)
158.785 +
158.786 +end
158.787 +
159.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
159.2 +++ b/fire/note.1 Mon Jan 26 22:08:20 2009 -0500
159.3 @@ -0,0 +1,6 @@
159.4 +observed data in /fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/
159.5 + Fire_C_1997-2006_monthly_T42.nc
159.6 +
159.7 +model data in /fis/cgd/cseg/people/jeff/clamp_data/model
159.8 + i01.10cn_Fire_C_1979-2004_monthly.nc
159.9 + i01.10casa_Fire_C_1979-2004_monthly.nc
159.10 \ No newline at end of file
160.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
160.2 +++ b/lai/01.read.land_class.ascii.ncl Mon Jan 26 22:08:20 2009 -0500
160.3 @@ -0,0 +1,55 @@
160.4 +;************************************************
160.5 +; Read ascii, Write nc
160.6 +; output: lat: N->S lon: -180W->180E
160.7 +;************************************************
160.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
160.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
160.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
160.11 +;************************************************
160.12 +begin
160.13 +;---------------------------------------------------
160.14 +; final data
160.15 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
160.16 + filo = "land_class_0.25deg.nc"
160.17 + c = addfile(diro+filo,"c")
160.18 +; filedimdef(c,"time",-1,True)
160.19 +
160.20 + nlat = 180*4
160.21 + nlon = 360*4
160.22 +
160.23 + t = new((/nlat,nlon/),integer)
160.24 + lon = new((/nlon/),float)
160.25 + lat = new((/nlat/),float)
160.26 +;---------------------------------------------------
160.27 +; input data
160.28 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/modis_landcover_qdeg/"
160.29 + fili = "modis_landcover_class_qd.asc"
160.30 + b = diri+fili
160.31 +
160.32 + lat = latGlobeFo(nlat, "lat", "latitude", "degrees_north")
160.33 + lat = (/ lat(::-1) /) ; make N->S
160.34 + lon = lonGlobeFo(nlon, "lon", "longitude", "degrees_east")
160.35 + lon = (/ lon - 180. /) ; subtract 180 from all values
160.36 + lon&lon = lon ; update coordinates
160.37 + lat&lat = lat ; update coordinates
160.38 +
160.39 +;=============================
160.40 +; name dimensions of t and assign coordinate variables
160.41 +;============================
160.42 + t!0 = "lat"
160.43 + t!1 = "lon"
160.44 + t&lat = lat
160.45 + t&lon = lon
160.46 + t@long_name = "landcover class"
160.47 + t@units = ""
160.48 + t@_FillValue= -9999
160.49 + t@missing_value= -9999
160.50 +
160.51 + t = asciiread(b,(/nlat,nlon/),"integer")
160.52 +
160.53 + c->LAND_CLASS = t
160.54 + c->lat = lat
160.55 + c->lon = lon
160.56 +
160.57 + print (min(t) + "/" + max(t))
160.58 +end
161.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
161.2 +++ b/lai/01.read.land_class.split.ncl Mon Jan 26 22:08:20 2009 -0500
161.3 @@ -0,0 +1,67 @@
161.4 +;************************************************
161.5 +; Read ascii, Write nc
161.6 +; output: lat: N->S lon: -180W->180E
161.7 +; class 8 split into class 8 = woody savanna (S. Hem.)
161.8 +; 18 = woody savanna (N. Hem.)
161.9 +; class 8 split into class 9 = savanna (S. Hem.)
161.10 +; 19 = savanna (N. Hem.)
161.11 +;************************************************
161.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
161.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
161.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
161.15 +;************************************************
161.16 +begin
161.17 +;---------------------------------------------------
161.18 +; final data
161.19 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
161.20 + filo = "land_class_0.25deg_new.nc"
161.21 + c = addfile(diro+filo,"c")
161.22 +; filedimdef(c,"time",-1,True)
161.23 +
161.24 + nlat = 180*4
161.25 + nlon = 360*4
161.26 +
161.27 + t = new((/nlat,nlon/),integer)
161.28 + lon = new((/nlon/),float)
161.29 + lat = new((/nlat/),float)
161.30 +;---------------------------------------------------
161.31 +; input data
161.32 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/modis_landcover_qdeg/"
161.33 + fili = "modis_landcover_class_qd.asc"
161.34 + b = diri+fili
161.35 +
161.36 + lat = latGlobeFo(nlat, "lat", "latitude", "degrees_north")
161.37 + lat = (/ lat(::-1) /) ; make N->S
161.38 + lon = lonGlobeFo(nlon, "lon", "longitude", "degrees_east")
161.39 + lon = (/ lon - 180. /) ; subtract 180 from all values
161.40 + lon&lon = lon ; update coordinates
161.41 + lat&lat = lat ; update coordinates
161.42 +
161.43 +;=============================
161.44 +; name dimensions of t and assign coordinate variables
161.45 +;============================
161.46 + t!0 = "lat"
161.47 + t!1 = "lon"
161.48 + t&lat = lat
161.49 + t&lon = lon
161.50 + t@long_name = "landcover class"
161.51 + t@units = ""
161.52 + t@_FillValue= -9999
161.53 + t@missing_value= -9999
161.54 +
161.55 + t = asciiread(b,(/nlat,nlon/),"integer")
161.56 +
161.57 + nlat = dimsizes(lat)
161.58 + ny2 = nlat/2
161.59 +
161.60 + do j = 0,ny2-1
161.61 + t(j,:) = where((t(j,:) .eq. 8),18,t(j,:))
161.62 + t(j,:) = where((t(j,:) .eq. 9),19,t(j,:))
161.63 + end do
161.64 +
161.65 + c->LAND_CLASS = t
161.66 + c->lat = lat
161.67 + c->lon = lon
161.68 +
161.69 + print (min(t) + "/" + max(t))
161.70 +end
162.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
162.2 +++ b/lai/02.read_byte_LAI.ncl Mon Jan 26 22:08:20 2009 -0500
162.3 @@ -0,0 +1,40 @@
162.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
162.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
162.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
162.7 +
162.8 +begin
162.9 + nlat = 3600
162.10 + mlon = 7200
162.11 +
162.12 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
162.13 + fili = "MOD15A2_GEO_2000001.nc"
162.14 + a = addfile(diri+fili,"r")
162.15 +
162.16 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/"
162.17 + filo = "LAI_2000001_3.nc"
162.18 + c = addfile(diro+filo,"c")
162.19 +
162.20 + y = a->Lai_0_05deg
162.21 +
162.22 + y@_FillValue = inttobyte(253)
162.23 + y@_FillValue = inttobyte(255)
162.24 +
162.25 + x = byte2flt(y)
162.26 +
162.27 +; x@_FillValue = -17281 ; orig fill
162.28 + x@_FillValue = 1.e+36 ; new fill
162.29 +
162.30 + lat = latGlobeFo(nlat, "lat", "latitude", "degrees_north")
162.31 + lat = (/ lat(::-1) /) ; make N->S
162.32 + lon = lonGlobeFo(mlon, "lon", "longitude", "degrees_east")
162.33 + lon = (/ lon - 180. /) ; subtract 180 from all values
162.34 + lon&lon = lon ; update coordinates
162.35 +
162.36 + x!0 = "lat"
162.37 + x!1 = "lon"
162.38 + x&lat= lat
162.39 + x&lon= lon
162.40 +
162.41 + c->LAI = x
162.42 +end
162.43 +
163.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
163.2 +++ b/lai/02.read_byte_LAI.ncl.x Mon Jan 26 22:08:20 2009 -0500
163.3 @@ -0,0 +1,54 @@
163.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
163.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
163.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
163.7 +
163.8 +begin
163.9 + nlat = 3600
163.10 + mlon = 7200
163.11 +
163.12 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
163.13 + fili = "MOD15A2_GEO_2000001.nc"
163.14 + a = addfile(diri+fili,"r")
163.15 +
163.16 + y = a->Lai_0_05deg ; byte
163.17 + y@_FillValue = inttobyte(253)
163.18 + y@_FillValue = inttobyte(255)
163.19 +
163.20 + x = byte2flt(y)
163.21 +
163.22 + x@_FillValue = 1.e+36 ; new fill
163.23 +
163.24 + lat = latGlobeFo(nlat, "lat", "latitude", "degrees_north")
163.25 + lat = (/ lat(::-1) /) ; make N->S
163.26 + lon = lonGlobeFo(mlon, "lon", "longitude", "degrees_east")
163.27 + lon = (/ lon - 180. /) ; subtract 180 from all values
163.28 + lon&lon = lon ; update coordinates
163.29 +
163.30 + x!0 = "lat"
163.31 + x!1 = "lon"
163.32 + x&lat= lat
163.33 + x&lon= lon
163.34 +
163.35 + y!0 = "lat"
163.36 + y!1 = "lon"
163.37 + y&lat= lat
163.38 + y&lon= lon
163.39 +
163.40 + iy = new (dimsizes(y), "integer", -999)
163.41 + iy = y
163.42 +
163.43 + iy!0 = "lat"
163.44 + iy!1 = "lon"
163.45 + iy&lat= lat
163.46 + iy&lon= lon
163.47 +
163.48 + print(y(:,{130})+" "+ iy(:,{130})+" "+x(:,{130}))
163.49 +
163.50 +
163.51 +
163.52 +; diro = "/fis/cgd/cseg/people/jeff/clamp_data/"
163.53 +; filo = "LAI_2000001_2.nc"
163.54 +; c = addfile(diro+filo,"c")
163.55 +; c->LAI = x
163.56 +end
163.57 +
164.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
164.2 +++ b/lai/02.read_byte_LAI.note Mon Jan 26 22:08:20 2009 -0500
164.3 @@ -0,0 +1,3 @@
164.4 +on tempest, convert to netcdf
164.5 +> ncl_convert2nc *.hdf
164.6 +
164.7 \ No newline at end of file
165.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
165.2 +++ b/lai/02.read_lai_avg.ncl Mon Jan 26 22:08:20 2009 -0500
165.3 @@ -0,0 +1,91 @@
165.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
165.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
165.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
165.7 +
165.8 +begin
165.9 +;----------------------------------------------------------
165.10 + year = "2004"
165.11 +
165.12 + nlat = 3600
165.13 + mlon = 7200
165.14 + month_in_year = 12
165.15 +;----------------------------------------------------------
165.16 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
165.17 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/"
165.18 + filo = "MOD15A2_LAI_" + year + "_monthly.nc"
165.19 + c = addfile(diro+filo,"c")
165.20 + filedimdef(c,"time",-1,True)
165.21 +
165.22 + day = (/"001","009","017","025","033","041","049","057","065","073", \
165.23 + "081","089","097","105","113","121","129","137","145","153", \
165.24 + "161","169","177","185","193","201","209","217","225","233", \
165.25 + "241","249","257","265","273","281","289","297","305","313", \
165.26 + "321","329","337","345","353","361"/)
165.27 +
165.28 + file_index_L = (/0,3,7 ,11,15,18,22,26,30,34,38,41/)
165.29 + file_index_R = (/3,7,11,14,18,22,26,30,34,37,41,45/)
165.30 + scale_L = (/8,1,5,6,8,1,3,4,5,7,8,2/)
165.31 + scale_R = (/7,3,2,8,7,5,4,3,1,8,6,5/)
165.32 +
165.33 +; dayI = stringtointeger(day)
165.34 +; print (dayI)
165.35 +
165.36 + x = new((/12,nlat,mlon/),float)
165.37 + x = 0.
165.38 + x@_FillValue = 1.e+36
165.39 +
165.40 + do m = 0,month_in_year-1
165.41 + nday = 0 ; number of day in a month
165.42 + do n = file_index_L(m),file_index_R(m)
165.43 + fili = "MOD15A2_GEO_" + year + day(n) + ".hdf"
165.44 + print (fili)
165.45 + a = addfile(diri+fili,"r")
165.46 + y = a->Lai_0_05deg
165.47 +
165.48 + y@_FillValue = inttobyte(253) ; special missing value?
165.49 + y@_FillValue = inttobyte(255) ; missing value
165.50 +
165.51 + z = byte2flt(y)
165.52 +
165.53 + z@_FillValue = 1.e+36
165.54 +
165.55 +; weighted by day, data is 8-day average
165.56 + scale = 8
165.57 + if (n .eq. file_index_L(m)) then
165.58 + scale = scale_L(m)
165.59 + end if
165.60 + if (n .eq. file_index_R(m)) then
165.61 + scale = scale_R(m)
165.62 + end if
165.63 +
165.64 + nday = nday + scale
165.65 +
165.66 + x(m,:,:) = where(ismissing(z),1.e+36,x(m,:,:)+z(:,:)*scale)
165.67 +
165.68 + delete (a)
165.69 + delete (y)
165.70 + delete (z)
165.71 + end do
165.72 + x(m,:,:) = where(ismissing(x(m,:,:)),1.e+36,x(m,:,:)/nday)
165.73 + print (nday)
165.74 + print (min(x) + "/" + max(x))
165.75 + end do
165.76 +
165.77 + lat = latGlobeFo(nlat, "lat", "latitude", "degrees_north")
165.78 + lat = (/ lat(::-1) /) ; make N->S
165.79 + lon = lonGlobeFo(mlon, "lon", "longitude", "degrees_east")
165.80 + lon = (/ lon - 180. /) ; subtract 180 from all values
165.81 + lon&lon = lon ; update coordinates
165.82 +
165.83 + x!0 = "time"
165.84 + x!1 = "lat"
165.85 + x!2 = "lon"
165.86 + x&time= ispan(1,month_in_year,1)
165.87 + x&lat= lat
165.88 + x&lon= lon
165.89 + x@units = "none"
165.90 + x@long_name = "Leaf Area Index"
165.91 +
165.92 + c->LAI = x
165.93 +end
165.94 +
166.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
166.2 +++ b/lai/022.lai_ensemble.ncl Mon Jan 26 22:08:20 2009 -0500
166.3 @@ -0,0 +1,50 @@
166.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
166.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
166.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
166.7 +
166.8 +begin
166.9 +;----------------------------------------------------------
166.10 + year_start = 2000
166.11 + year_end = 2005
166.12 +;----------------------------------------------------------
166.13 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
166.14 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/"
166.15 + filo1 = "LAI_"+year_start+"-"+year_end+"_ensemble_T42.nc"
166.16 + filo2 = "LAI_"+year_start+"-"+year_end+"_mean_T42.nc"
166.17 + c = addfile(diro+filo1,"c")
166.18 + d = addfile(diro+filo2,"c")
166.19 +
166.20 + nyear = year_end - year_start + 1
166.21 +
166.22 + do n = year_start,year_end
166.23 +
166.24 +; fili = "LAI_" + n + "_monthly.nc"
166.25 + fili = "LAI_" + n + "_monthly_T42.nc"
166.26 + print (fili)
166.27 +
166.28 + a = addfile(diri+fili,"r")
166.29 + x = a->LAI
166.30 +
166.31 + if (n .eq. year_start) then
166.32 + y = x
166.33 + printVarSummary (x)
166.34 + else
166.35 + y = y + x
166.36 + end if
166.37 +
166.38 + delete (a)
166.39 + delete (x)
166.40 + delete (fili)
166.41 + end do
166.42 +
166.43 + y = y/nyear
166.44 + printVarSummary (y)
166.45 +
166.46 + c->LAI = y
166.47 +
166.48 + z = dim_avg_Wrap(y(lat|:,lon|:,time|:))
166.49 + printVarSummary (z)
166.50 +
166.51 + d->LAI = z
166.52 +end
166.53 +
167.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
167.2 +++ b/lai/022.lai_ensemble.ncl.x Mon Jan 26 22:08:20 2009 -0500
167.3 @@ -0,0 +1,45 @@
167.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
167.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
167.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
167.7 +
167.8 +begin
167.9 +;----------------------------------------------------------
167.10 + year_start = 2000
167.11 + year_end = 2005
167.12 +;----------------------------------------------------------
167.13 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
167.14 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/"
167.15 + filo1 = "LAI_"+year_start+"-"+year_end+"_ensemble.nc"
167.16 + filo2 = "LAI_"+year_start+"-"+year_end+"_mean.nc"
167.17 + c = addfile(diro+filo1,"c")
167.18 + d = addfile(diro+filo2,"c")
167.19 +
167.20 + nyear = year_end - year_start + 1
167.21 +
167.22 + files = new((/nyear/),"string")
167.23 +
167.24 + do n = year_start,year_end
167.25 + i = n - year_start
167.26 + files(i)= diri + "LAI_" + n + "_monthly.nc"
167.27 + end do
167.28 +; print (files)
167.29 +
167.30 + file_list = addfiles(files,"r")
167.31 + ListSetType(file_list,"join")
167.32 + x = addfiles_GetVar(file_list, files, "LAI")
167.33 + print (files)
167.34 +
167.35 + x!0 = "case"
167.36 + x!1 = "time"
167.37 + x!2 = "lat"
167.38 + x!3 = "lon"
167.39 +
167.40 + y = dim_avg(x(time|:,lat|:,lon|:,case|:))
167.41 + print (files)
167.42 + c->LAI = y
167.43 + print (files)
167.44 +
167.45 + z = dim_avg(y(lat|:,lon|:,time|:))
167.46 + d->LAI = z
167.47 +end
167.48 +
168.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
168.2 +++ b/lai/03.2.ncl Mon Jan 26 22:08:20 2009 -0500
168.3 @@ -0,0 +1,132 @@
168.4 +; ***********************************************
168.5 +; interpolate into model grids (T31)
168.6 +; ***********************************************
168.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
168.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
168.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
168.10 +;************************************************
168.11 +begin
168.12 +
168.13 + year = 2001
168.14 +
168.15 +;************************************************
168.16 +; output data
168.17 +;************************************************
168.18 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
168.19 + filo = "LAI_" + year + "_monthly_1.9.nc"
168.20 +
168.21 + c = addfile(diro+filo,"c")
168.22 + filedimdef(c,"time",-1,True)
168.23 +
168.24 +;************************************************
168.25 +; read in observed data
168.26 +;************************************************
168.27 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
168.28 + fili = "LAI_" + year + "_monthly.nc"
168.29 +
168.30 + g = addfile (diri+fili,"r")
168.31 + bi = g->LAI
168.32 + xi = g->lon
168.33 + yi = g->lat
168.34 +
168.35 +;************************************************
168.36 +; change into 0-360E, 90S-90N
168.37 +;************************************************
168.38 +
168.39 + yi = (/ yi(::-1) /)
168.40 + bi = (/ bi(:,::-1,:) /)
168.41 + printVarSummary(bi)
168.42 +
168.43 + b2 = bi
168.44 + x2 = xi
168.45 +
168.46 + nx = dimsizes(xi)
168.47 + do i= 0,nx-1
168.48 + if (i .lt. 3600) then
168.49 + p = i + 3600
168.50 + xi(p) = x2(i) + 360.
168.51 + else
168.52 + p = i - 3600
168.53 + xi(p) = x2(i)
168.54 + end if
168.55 + bi(:,:,p)= b2(:,:,i)
168.56 + end do
168.57 +
168.58 + bi&lat = yi
168.59 + bi&lon = xi
168.60 +
168.61 +;print (xi)
168.62 +;print (yi)
168.63 +
168.64 +;************************************************
168.65 +; read in model data
168.66 +;************************************************
168.67 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
168.68 + fili2 = "newcn05_ncep_1i_MONS_climo_lnd.nc"
168.69 + f = addfile (diri2+fili2,"r")
168.70 +
168.71 + lon = f->lon
168.72 + lat = f->lat
168.73 + nlon = dimsizes(lon)
168.74 + nlat = dimsizes(lat)
168.75 +
168.76 +; print (xi)
168.77 +; print (yi)
168.78 +; print (xo)
168.79 +; print (yo)
168.80 +
168.81 + bo = new((/12,nlat,nlon/),float)
168.82 +
168.83 + do m = 0,11
168.84 + do j=0,nlat-1
168.85 + if (j.eq.0 .or. j.eq.nlat-1) then
168.86 + if (j.eq.0) then
168.87 + LATS = -90.
168.88 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
168.89 + end if
168.90 + if (j.eq.nlat-1) then
168.91 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
168.92 + LATN = 90.
168.93 + end if
168.94 + else
168.95 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
168.96 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
168.97 + end if
168.98 +
168.99 + do i=0,nlon-1
168.100 + if (i.eq.0 .or. i.eq.nlon-1) then
168.101 + if (i.eq.0) then
168.102 + LONL = 0.
168.103 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
168.104 + end if
168.105 + if (i.eq.nlon-1) then
168.106 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
168.107 + LONR = 360.
168.108 + end if
168.109 + else
168.110 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
168.111 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
168.112 + end if
168.113 +
168.114 +;print (LATS)
168.115 +;print (LATN)
168.116 +;print (LONL)
168.117 +;print (LONR)
168.118 +
168.119 + bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))
168.120 + end do
168.121 + end do
168.122 + end do
168.123 +
168.124 + bo!0 = "time"
168.125 + bo!1 = "lat"
168.126 + bo!2 = "lon"
168.127 + bo&time= bi&time
168.128 + bo&lat = lat
168.129 + bo&lon = lon
168.130 + bo@units = bi@units
168.131 + bo@long_name = bi@long_name
168.132 + bo@_FillValue = bi@_FillValue
168.133 +
168.134 + c->LAI = bo
168.135 +end
168.136 \ No newline at end of file
169.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
169.2 +++ b/lai/03.3.ncl Mon Jan 26 22:08:20 2009 -0500
169.3 @@ -0,0 +1,132 @@
169.4 +; ***********************************************
169.5 +; interpolate into model grids (T31)
169.6 +; ***********************************************
169.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
169.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
169.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
169.10 +;************************************************
169.11 +begin
169.12 +
169.13 + year = 2002
169.14 +
169.15 +;************************************************
169.16 +; output data
169.17 +;************************************************
169.18 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
169.19 + filo = "LAI_" + year + "_monthly_1.9.nc"
169.20 +
169.21 + c = addfile(diro+filo,"c")
169.22 + filedimdef(c,"time",-1,True)
169.23 +
169.24 +;************************************************
169.25 +; read in observed data
169.26 +;************************************************
169.27 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
169.28 + fili = "LAI_" + year + "_monthly.nc"
169.29 +
169.30 + g = addfile (diri+fili,"r")
169.31 + bi = g->LAI
169.32 + xi = g->lon
169.33 + yi = g->lat
169.34 +
169.35 +;************************************************
169.36 +; change into 0-360E, 90S-90N
169.37 +;************************************************
169.38 +
169.39 + yi = (/ yi(::-1) /)
169.40 + bi = (/ bi(:,::-1,:) /)
169.41 + printVarSummary(bi)
169.42 +
169.43 + b2 = bi
169.44 + x2 = xi
169.45 +
169.46 + nx = dimsizes(xi)
169.47 + do i= 0,nx-1
169.48 + if (i .lt. 3600) then
169.49 + p = i + 3600
169.50 + xi(p) = x2(i) + 360.
169.51 + else
169.52 + p = i - 3600
169.53 + xi(p) = x2(i)
169.54 + end if
169.55 + bi(:,:,p)= b2(:,:,i)
169.56 + end do
169.57 +
169.58 + bi&lat = yi
169.59 + bi&lon = xi
169.60 +
169.61 +;print (xi)
169.62 +;print (yi)
169.63 +
169.64 +;************************************************
169.65 +; read in model data
169.66 +;************************************************
169.67 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
169.68 + fili2 = "newcn05_ncep_1i_MONS_climo_lnd.nc"
169.69 + f = addfile (diri2+fili2,"r")
169.70 +
169.71 + lon = f->lon
169.72 + lat = f->lat
169.73 + nlon = dimsizes(lon)
169.74 + nlat = dimsizes(lat)
169.75 +
169.76 +; print (xi)
169.77 +; print (yi)
169.78 +; print (xo)
169.79 +; print (yo)
169.80 +
169.81 + bo = new((/12,nlat,nlon/),float)
169.82 +
169.83 + do m = 0,11
169.84 + do j=0,nlat-1
169.85 + if (j.eq.0 .or. j.eq.nlat-1) then
169.86 + if (j.eq.0) then
169.87 + LATS = -90.
169.88 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
169.89 + end if
169.90 + if (j.eq.nlat-1) then
169.91 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
169.92 + LATN = 90.
169.93 + end if
169.94 + else
169.95 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
169.96 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
169.97 + end if
169.98 +
169.99 + do i=0,nlon-1
169.100 + if (i.eq.0 .or. i.eq.nlon-1) then
169.101 + if (i.eq.0) then
169.102 + LONL = 0.
169.103 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
169.104 + end if
169.105 + if (i.eq.nlon-1) then
169.106 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
169.107 + LONR = 360.
169.108 + end if
169.109 + else
169.110 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
169.111 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
169.112 + end if
169.113 +
169.114 +;print (LATS)
169.115 +;print (LATN)
169.116 +;print (LONL)
169.117 +;print (LONR)
169.118 +
169.119 + bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))
169.120 + end do
169.121 + end do
169.122 + end do
169.123 +
169.124 + bo!0 = "time"
169.125 + bo!1 = "lat"
169.126 + bo!2 = "lon"
169.127 + bo&time= bi&time
169.128 + bo&lat = lat
169.129 + bo&lon = lon
169.130 + bo@units = bi@units
169.131 + bo@long_name = bi@long_name
169.132 + bo@_FillValue = bi@_FillValue
169.133 +
169.134 + c->LAI = bo
169.135 +end
169.136 \ No newline at end of file
170.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
170.2 +++ b/lai/03.4.ncl Mon Jan 26 22:08:20 2009 -0500
170.3 @@ -0,0 +1,132 @@
170.4 +; ***********************************************
170.5 +; interpolate into model grids (T31)
170.6 +; ***********************************************
170.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
170.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
170.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
170.10 +;************************************************
170.11 +begin
170.12 +
170.13 + year = 2003
170.14 +
170.15 +;************************************************
170.16 +; output data
170.17 +;************************************************
170.18 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
170.19 + filo = "LAI_" + year + "_monthly_1.9.nc"
170.20 +
170.21 + c = addfile(diro+filo,"c")
170.22 + filedimdef(c,"time",-1,True)
170.23 +
170.24 +;************************************************
170.25 +; read in observed data
170.26 +;************************************************
170.27 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
170.28 + fili = "LAI_" + year + "_monthly.nc"
170.29 +
170.30 + g = addfile (diri+fili,"r")
170.31 + bi = g->LAI
170.32 + xi = g->lon
170.33 + yi = g->lat
170.34 +
170.35 +;************************************************
170.36 +; change into 0-360E, 90S-90N
170.37 +;************************************************
170.38 +
170.39 + yi = (/ yi(::-1) /)
170.40 + bi = (/ bi(:,::-1,:) /)
170.41 + printVarSummary(bi)
170.42 +
170.43 + b2 = bi
170.44 + x2 = xi
170.45 +
170.46 + nx = dimsizes(xi)
170.47 + do i= 0,nx-1
170.48 + if (i .lt. 3600) then
170.49 + p = i + 3600
170.50 + xi(p) = x2(i) + 360.
170.51 + else
170.52 + p = i - 3600
170.53 + xi(p) = x2(i)
170.54 + end if
170.55 + bi(:,:,p)= b2(:,:,i)
170.56 + end do
170.57 +
170.58 + bi&lat = yi
170.59 + bi&lon = xi
170.60 +
170.61 +;print (xi)
170.62 +;print (yi)
170.63 +
170.64 +;************************************************
170.65 +; read in model data
170.66 +;************************************************
170.67 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
170.68 + fili2 = "newcn05_ncep_1i_MONS_climo_lnd.nc"
170.69 + f = addfile (diri2+fili2,"r")
170.70 +
170.71 + lon = f->lon
170.72 + lat = f->lat
170.73 + nlon = dimsizes(lon)
170.74 + nlat = dimsizes(lat)
170.75 +
170.76 +; print (xi)
170.77 +; print (yi)
170.78 +; print (xo)
170.79 +; print (yo)
170.80 +
170.81 + bo = new((/12,nlat,nlon/),float)
170.82 +
170.83 + do m = 0,11
170.84 + do j=0,nlat-1
170.85 + if (j.eq.0 .or. j.eq.nlat-1) then
170.86 + if (j.eq.0) then
170.87 + LATS = -90.
170.88 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
170.89 + end if
170.90 + if (j.eq.nlat-1) then
170.91 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
170.92 + LATN = 90.
170.93 + end if
170.94 + else
170.95 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
170.96 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
170.97 + end if
170.98 +
170.99 + do i=0,nlon-1
170.100 + if (i.eq.0 .or. i.eq.nlon-1) then
170.101 + if (i.eq.0) then
170.102 + LONL = 0.
170.103 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
170.104 + end if
170.105 + if (i.eq.nlon-1) then
170.106 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
170.107 + LONR = 360.
170.108 + end if
170.109 + else
170.110 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
170.111 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
170.112 + end if
170.113 +
170.114 +;print (LATS)
170.115 +;print (LATN)
170.116 +;print (LONL)
170.117 +;print (LONR)
170.118 +
170.119 + bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))
170.120 + end do
170.121 + end do
170.122 + end do
170.123 +
170.124 + bo!0 = "time"
170.125 + bo!1 = "lat"
170.126 + bo!2 = "lon"
170.127 + bo&time= bi&time
170.128 + bo&lat = lat
170.129 + bo&lon = lon
170.130 + bo@units = bi@units
170.131 + bo@long_name = bi@long_name
170.132 + bo@_FillValue = bi@_FillValue
170.133 +
170.134 + c->LAI = bo
170.135 +end
170.136 \ No newline at end of file
171.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
171.2 +++ b/lai/03.5.ncl Mon Jan 26 22:08:20 2009 -0500
171.3 @@ -0,0 +1,132 @@
171.4 +; ***********************************************
171.5 +; interpolate into model grids (T31)
171.6 +; ***********************************************
171.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
171.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
171.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
171.10 +;************************************************
171.11 +begin
171.12 +
171.13 + year = 2004
171.14 +
171.15 +;************************************************
171.16 +; output data
171.17 +;************************************************
171.18 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
171.19 + filo = "LAI_" + year + "_monthly_1.9.nc"
171.20 +
171.21 + c = addfile(diro+filo,"c")
171.22 + filedimdef(c,"time",-1,True)
171.23 +
171.24 +;************************************************
171.25 +; read in observed data
171.26 +;************************************************
171.27 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
171.28 + fili = "LAI_" + year + "_monthly.nc"
171.29 +
171.30 + g = addfile (diri+fili,"r")
171.31 + bi = g->LAI
171.32 + xi = g->lon
171.33 + yi = g->lat
171.34 +
171.35 +;************************************************
171.36 +; change into 0-360E, 90S-90N
171.37 +;************************************************
171.38 +
171.39 + yi = (/ yi(::-1) /)
171.40 + bi = (/ bi(:,::-1,:) /)
171.41 + printVarSummary(bi)
171.42 +
171.43 + b2 = bi
171.44 + x2 = xi
171.45 +
171.46 + nx = dimsizes(xi)
171.47 + do i= 0,nx-1
171.48 + if (i .lt. 3600) then
171.49 + p = i + 3600
171.50 + xi(p) = x2(i) + 360.
171.51 + else
171.52 + p = i - 3600
171.53 + xi(p) = x2(i)
171.54 + end if
171.55 + bi(:,:,p)= b2(:,:,i)
171.56 + end do
171.57 +
171.58 + bi&lat = yi
171.59 + bi&lon = xi
171.60 +
171.61 +;print (xi)
171.62 +;print (yi)
171.63 +
171.64 +;************************************************
171.65 +; read in model data
171.66 +;************************************************
171.67 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
171.68 + fili2 = "newcn05_ncep_1i_MONS_climo_lnd.nc"
171.69 + f = addfile (diri2+fili2,"r")
171.70 +
171.71 + lon = f->lon
171.72 + lat = f->lat
171.73 + nlon = dimsizes(lon)
171.74 + nlat = dimsizes(lat)
171.75 +
171.76 +; print (xi)
171.77 +; print (yi)
171.78 +; print (xo)
171.79 +; print (yo)
171.80 +
171.81 + bo = new((/12,nlat,nlon/),float)
171.82 +
171.83 + do m = 0,11
171.84 + do j=0,nlat-1
171.85 + if (j.eq.0 .or. j.eq.nlat-1) then
171.86 + if (j.eq.0) then
171.87 + LATS = -90.
171.88 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
171.89 + end if
171.90 + if (j.eq.nlat-1) then
171.91 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
171.92 + LATN = 90.
171.93 + end if
171.94 + else
171.95 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
171.96 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
171.97 + end if
171.98 +
171.99 + do i=0,nlon-1
171.100 + if (i.eq.0 .or. i.eq.nlon-1) then
171.101 + if (i.eq.0) then
171.102 + LONL = 0.
171.103 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
171.104 + end if
171.105 + if (i.eq.nlon-1) then
171.106 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
171.107 + LONR = 360.
171.108 + end if
171.109 + else
171.110 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
171.111 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
171.112 + end if
171.113 +
171.114 +;print (LATS)
171.115 +;print (LATN)
171.116 +;print (LONL)
171.117 +;print (LONR)
171.118 +
171.119 + bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))
171.120 + end do
171.121 + end do
171.122 + end do
171.123 +
171.124 + bo!0 = "time"
171.125 + bo!1 = "lat"
171.126 + bo!2 = "lon"
171.127 + bo&time= bi&time
171.128 + bo&lat = lat
171.129 + bo&lon = lon
171.130 + bo@units = bi@units
171.131 + bo@long_name = bi@long_name
171.132 + bo@_FillValue = bi@_FillValue
171.133 +
171.134 + c->LAI = bo
171.135 +end
171.136 \ No newline at end of file
172.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
172.2 +++ b/lai/03.6.ncl Mon Jan 26 22:08:20 2009 -0500
172.3 @@ -0,0 +1,132 @@
172.4 +; ***********************************************
172.5 +; interpolate into model grids (T31)
172.6 +; ***********************************************
172.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
172.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
172.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
172.10 +;************************************************
172.11 +begin
172.12 +
172.13 + year = 2005
172.14 +
172.15 +;************************************************
172.16 +; output data
172.17 +;************************************************
172.18 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
172.19 + filo = "LAI_" + year + "_monthly_1.9.nc"
172.20 +
172.21 + c = addfile(diro+filo,"c")
172.22 + filedimdef(c,"time",-1,True)
172.23 +
172.24 +;************************************************
172.25 +; read in observed data
172.26 +;************************************************
172.27 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
172.28 + fili = "LAI_" + year + "_monthly.nc"
172.29 +
172.30 + g = addfile (diri+fili,"r")
172.31 + bi = g->LAI
172.32 + xi = g->lon
172.33 + yi = g->lat
172.34 +
172.35 +;************************************************
172.36 +; change into 0-360E, 90S-90N
172.37 +;************************************************
172.38 +
172.39 + yi = (/ yi(::-1) /)
172.40 + bi = (/ bi(:,::-1,:) /)
172.41 + printVarSummary(bi)
172.42 +
172.43 + b2 = bi
172.44 + x2 = xi
172.45 +
172.46 + nx = dimsizes(xi)
172.47 + do i= 0,nx-1
172.48 + if (i .lt. 3600) then
172.49 + p = i + 3600
172.50 + xi(p) = x2(i) + 360.
172.51 + else
172.52 + p = i - 3600
172.53 + xi(p) = x2(i)
172.54 + end if
172.55 + bi(:,:,p)= b2(:,:,i)
172.56 + end do
172.57 +
172.58 + bi&lat = yi
172.59 + bi&lon = xi
172.60 +
172.61 +;print (xi)
172.62 +;print (yi)
172.63 +
172.64 +;************************************************
172.65 +; read in model data
172.66 +;************************************************
172.67 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
172.68 + fili2 = "newcn05_ncep_1i_MONS_climo_lnd.nc"
172.69 + f = addfile (diri2+fili2,"r")
172.70 +
172.71 + lon = f->lon
172.72 + lat = f->lat
172.73 + nlon = dimsizes(lon)
172.74 + nlat = dimsizes(lat)
172.75 +
172.76 +; print (xi)
172.77 +; print (yi)
172.78 +; print (xo)
172.79 +; print (yo)
172.80 +
172.81 + bo = new((/12,nlat,nlon/),float)
172.82 +
172.83 + do m = 0,11
172.84 + do j=0,nlat-1
172.85 + if (j.eq.0 .or. j.eq.nlat-1) then
172.86 + if (j.eq.0) then
172.87 + LATS = -90.
172.88 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
172.89 + end if
172.90 + if (j.eq.nlat-1) then
172.91 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
172.92 + LATN = 90.
172.93 + end if
172.94 + else
172.95 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
172.96 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
172.97 + end if
172.98 +
172.99 + do i=0,nlon-1
172.100 + if (i.eq.0 .or. i.eq.nlon-1) then
172.101 + if (i.eq.0) then
172.102 + LONL = 0.
172.103 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
172.104 + end if
172.105 + if (i.eq.nlon-1) then
172.106 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
172.107 + LONR = 360.
172.108 + end if
172.109 + else
172.110 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
172.111 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
172.112 + end if
172.113 +
172.114 +;print (LATS)
172.115 +;print (LATN)
172.116 +;print (LONL)
172.117 +;print (LONR)
172.118 +
172.119 + bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))
172.120 + end do
172.121 + end do
172.122 + end do
172.123 +
172.124 + bo!0 = "time"
172.125 + bo!1 = "lat"
172.126 + bo!2 = "lon"
172.127 + bo&time= bi&time
172.128 + bo&lat = lat
172.129 + bo&lon = lon
172.130 + bo@units = bi@units
172.131 + bo@long_name = bi@long_name
172.132 + bo@_FillValue = bi@_FillValue
172.133 +
172.134 + c->LAI = bo
172.135 +end
172.136 \ No newline at end of file
173.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
173.2 +++ b/lai/03.lai_ob_to_0.25deg.ncl Mon Jan 26 22:08:20 2009 -0500
173.3 @@ -0,0 +1,154 @@
173.4 +; ***********************************************
173.5 +; interpolate into model grids (T31)
173.6 +; ***********************************************
173.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
173.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
173.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
173.10 +;************************************************
173.11 +begin
173.12 +
173.13 + year = 2000
173.14 +
173.15 +;************************************************
173.16 +; output data
173.17 +;************************************************
173.18 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
173.19 +; filo = "LAI_" + year + "_monthly_0.25deg.nc"
173.20 + filo = "LAI_2000-2005_mean_0.25deg.nc"
173.21 +; filo = "LAI_2000-2005_ensemble_0.25deg.nc"
173.22 + c = addfile(diro+filo,"c")
173.23 + filedimdef(c,"time",-1,True)
173.24 +
173.25 +;************************************************
173.26 +; read in observed data
173.27 +;************************************************
173.28 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
173.29 +; fili = "LAI_" + year + "_monthly.nc"
173.30 + fili = "LAI_2000-2005_mean_0.05deg.nc"
173.31 +; fili = "LAI_2000-2005_ensemble_0.05deg.nc"
173.32 + g = addfile (diri+fili,"r")
173.33 + bi = g->LAI
173.34 + xi = g->lon
173.35 + yi = g->lat
173.36 +
173.37 +;************************************************
173.38 +; change into 0-360E, 90S-90N
173.39 +; Observed NPP*scale_factor
173.40 +;************************************************
173.41 +
173.42 + yi = (/ yi(::-1) /)
173.43 + bi = (/ bi(:,::-1,:) /)
173.44 + printVarSummary(bi)
173.45 +
173.46 + b2 = bi
173.47 + x2 = xi
173.48 +
173.49 + nx = dimsizes(xi)
173.50 + do i= 0,nx-1
173.51 + if (i .lt. 3600) then
173.52 + p = i + 3600
173.53 + xi(p) = x2(i) + 360.
173.54 + else
173.55 + p = i - 3600
173.56 + xi(p) = x2(i)
173.57 + end if
173.58 + bi(:,:,p)= b2(:,:,i)
173.59 + end do
173.60 +
173.61 + bi&lat = yi
173.62 + bi&lon = xi
173.63 +
173.64 +;print (xi)
173.65 +;print (yi)
173.66 +;exit
173.67 +
173.68 +;************************************************
173.69 +; create 0.25deg lat and lon
173.70 +;************************************************
173.71 + nlon = 360*4
173.72 + nlat = 180*4
173.73 +
173.74 + lat = latGlobeFo(nlat, "lat", "latitude", "degrees_north") ; S->N
173.75 +; lat = (/ lat(::-1) /) ; N->S
173.76 + lat&lat = lat
173.77 + lon = lonGlobeFo(nlon, "lon", "longitude", "degrees_east") ; 0->360
173.78 +; lon = (/ lon - 180. /) ; subtract 180 from all values ; 180W-180E
173.79 + lon&lon = lon ; update coordinates
173.80 +
173.81 +; print (lon)
173.82 +; print (lat)
173.83 +
173.84 +; rad = 4.*atan(1.)/180.
173.85 +; clat = lat
173.86 +; clat = cos(lat*rad)
173.87 +; clat@long_name = "cos(latitude)"
173.88 +; delete(clat@units)
173.89 +; printVarSummary(clat)
173.90 +
173.91 +;bo = new((/12,nlat,nlon/),float)
173.92 + bo = new((/1,nlat,nlon/),float)
173.93 +
173.94 +;do m = 0,11
173.95 + do m = 0,0
173.96 + do j=0,nlat-1
173.97 + if (j.eq.0 .or. j.eq.nlat-1) then
173.98 + if (j.eq.0) then
173.99 + LATS = -90.
173.100 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
173.101 + end if
173.102 + if (j.eq.nlat-1) then
173.103 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
173.104 + LATN = 90.
173.105 + end if
173.106 + else
173.107 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
173.108 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
173.109 + end if
173.110 +
173.111 +; CLAT = clat({LATS:LATN}) ; do once for *slight* efficiency
173.112 +; TEMP = bi(:,{LATS:LATN},:) ; 2D [lat,lon]
173.113 +
173.114 + do i=0,nlon-1
173.115 + if (i.eq.0 .or. i.eq.nlon-1) then
173.116 + if (i.eq.0) then
173.117 + LONL = 0.
173.118 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
173.119 + end if
173.120 + if (i.eq.nlon-1) then
173.121 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
173.122 + LONR = 360.
173.123 + end if
173.124 + else
173.125 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
173.126 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
173.127 + end if
173.128 +
173.129 +;print (LATS)
173.130 +;print (LATN)
173.131 +;print (LONL)
173.132 +;print (LONR)
173.133 +
173.134 + bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))
173.135 +; bo(m,j,i) = wgt_areaave(TEMP(m,{LONL:LONR}), CLAT, 1.0, 0)
173.136 + end do
173.137 +
173.138 +; delete(CLAT)
173.139 +; delete(TEMP)
173.140 + end do
173.141 + end do
173.142 +
173.143 + bo!0 = "time"
173.144 + bo!1 = "lat"
173.145 + bo!2 = "lon"
173.146 + bo&time= bi&time
173.147 +; bo&time= 1
173.148 + bo&lat = lat
173.149 + bo&lon = lon
173.150 +; bo@units = bi@units
173.151 +; bo@long_name = bi@long_name
173.152 + bo@units = "none"
173.153 + bo@long_name = "Leaf Area Index"
173.154 + bo@_FillValue = bi@_FillValue
173.155 +
173.156 + c->LAI = bo
173.157 +end
173.158 \ No newline at end of file
174.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
174.2 +++ b/lai/03.lai_ob_to_0.25deg.ncl.0 Mon Jan 26 22:08:20 2009 -0500
174.3 @@ -0,0 +1,157 @@
174.4 +; ***********************************************
174.5 +; interpolate into 0.25degree
174.6 +; no change in lat and lon, to be in consistent with
174.7 +; land class data
174.8 +; ***********************************************
174.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
174.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
174.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
174.12 +;************************************************
174.13 +begin
174.14 +
174.15 + year = 2003
174.16 +
174.17 +;************************************************
174.18 +; output data
174.19 +;************************************************
174.20 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
174.21 + filo = "LAI_2000-2005_mean_0.25.nc"
174.22 + c = addfile(diro+filo,"c")
174.23 + filedimdef(c,"time",-1,True)
174.24 +
174.25 +;************************************************
174.26 +; read in observed data
174.27 +;************************************************
174.28 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
174.29 +; fili = "LAI_2000-2005_mean_0.05deg.nc"
174.30 + fili = "LAI_2000-2005_ensemble_0.05deg.nc"
174.31 + g = addfile (diri+fili,"r")
174.32 + bi = g->LAI
174.33 + xi = g->lon
174.34 + yi = g->lat
174.35 +
174.36 +;************************************************
174.37 +; change into 0-360E, 90S-90N
174.38 +; Observed NPP*scale_factor
174.39 +;************************************************
174.40 +
174.41 + yi = (/ yi(::-1) /)
174.42 + bi = (/ bi(:,::-1,:) /)
174.43 + printVarSummary(bi)
174.44 +
174.45 + b2 = bi
174.46 + x2 = xi
174.47 +
174.48 + nx = dimsizes(xi)
174.49 + do i= 0,nx-1
174.50 + if (i .lt. 3600) then
174.51 + p = i + 3600
174.52 + xi(p) = x2(i) + 360.
174.53 + else
174.54 + p = i - 3600
174.55 + xi(p) = x2(i)
174.56 + end if
174.57 + bi(:,:,p)= b2(:,:,i)
174.58 + end do
174.59 +
174.60 + bi&lat = yi
174.61 + bi&lon = xi
174.62 +
174.63 +;print (xi)
174.64 +;print (yi)
174.65 +;exit
174.66 +
174.67 +;************************************************
174.68 +; read in model data
174.69 +;************************************************
174.70 +;fili2 = "i01.03cn_1545-1569_ANN_climo.nc"
174.71 + fili2 = ""
174.72 + f = addfile (diri+fili2,"r")
174.73 +
174.74 + lon = f->lon
174.75 + lat = f->lat
174.76 + nlon = dimsizes(lon)
174.77 + nlat = dimsizes(lat)
174.78 +
174.79 +; print (xi)
174.80 +; print (yi)
174.81 +; print (xo)
174.82 +; print (yo)
174.83 +
174.84 +;(A)
174.85 +;bo = linint2_Wrap(xi,yi,bi,True,xo,yo,0)
174.86 +
174.87 +;(B)
174.88 +
174.89 +; rad = 4.*atan(1.)/180.
174.90 +; clat = lat
174.91 +; clat = cos(lat*rad)
174.92 +; clat@long_name = "cos(latitude)"
174.93 +; delete(clat@units)
174.94 +; printVarSummary(clat)
174.95 +
174.96 + bo = new((/12,nlat,nlon/),float)
174.97 +;bo = new((/1,nlat,nlon/),float)
174.98 + do m = 0,11
174.99 + do j=0,nlat-1
174.100 + if (j.eq.0 .or. j.eq.nlat-1) then
174.101 + if (j.eq.0) then
174.102 + LATS = -90.
174.103 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
174.104 + end if
174.105 + if (j.eq.nlat-1) then
174.106 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
174.107 + LATN = 90.
174.108 + end if
174.109 + else
174.110 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
174.111 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
174.112 + end if
174.113 +
174.114 +; CLAT = clat({LATS:LATN}) ; do once for *slight* efficiency
174.115 +; TEMP = bi(:,{LATS:LATN},:) ; 2D [lat,lon]
174.116 +
174.117 + do i=0,nlon-1
174.118 + if (i.eq.0 .or. i.eq.nlon-1) then
174.119 + if (i.eq.0) then
174.120 + LONL = 0.
174.121 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
174.122 + end if
174.123 + if (i.eq.nlon-1) then
174.124 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
174.125 + LONR = 360.
174.126 + end if
174.127 + else
174.128 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
174.129 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
174.130 + end if
174.131 +
174.132 +;print (LATS)
174.133 +;print (LATN)
174.134 +;print (LONL)
174.135 +;print (LONR)
174.136 +; bo(:,j,i) = avg(bi(:,{LATS:LATN},{LONL:LONR}))
174.137 + bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))
174.138 +; bo(:,j,i) = wgt_areaave(TEMP(:,{LONL:LONR}), CLAT, 1.0, 0)
174.139 + end do
174.140 +
174.141 +; delete(CLAT)
174.142 +; delete(TEMP)
174.143 + end do
174.144 + end do
174.145 +
174.146 + bo!0 = "time"
174.147 + bo!1 = "lat"
174.148 + bo!2 = "lon"
174.149 + bo&time= bi&time
174.150 +; bo&time= 1
174.151 + bo&lat = lat
174.152 + bo&lon = lon
174.153 +; bo@units = bi@units
174.154 +; bo@long_name = bi@long_name
174.155 + bo@units = "none"
174.156 + bo@long_name = "Leaf Area Index"
174.157 + bo@_FillValue = bi@_FillValue
174.158 +
174.159 + c->LAI = bo
174.160 +end
174.161 \ No newline at end of file
175.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
175.2 +++ b/lai/03.lai_ob_to_1.9.ncl Mon Jan 26 22:08:20 2009 -0500
175.3 @@ -0,0 +1,132 @@
175.4 +; ***********************************************
175.5 +; interpolate into model grids (T31)
175.6 +; ***********************************************
175.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
175.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
175.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
175.10 +;************************************************
175.11 +begin
175.12 +
175.13 + year = 2000
175.14 +
175.15 +;************************************************
175.16 +; output data
175.17 +;************************************************
175.18 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
175.19 + filo = "LAI_" + year + "_monthly_1.9.nc"
175.20 +
175.21 + c = addfile(diro+filo,"c")
175.22 + filedimdef(c,"time",-1,True)
175.23 +
175.24 +;************************************************
175.25 +; read in observed data
175.26 +;************************************************
175.27 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
175.28 + fili = "LAI_" + year + "_monthly.nc"
175.29 +
175.30 + g = addfile (diri+fili,"r")
175.31 + bi = g->LAI
175.32 + xi = g->lon
175.33 + yi = g->lat
175.34 +
175.35 +;************************************************
175.36 +; change into 0-360E, 90S-90N
175.37 +;************************************************
175.38 +
175.39 + yi = (/ yi(::-1) /)
175.40 + bi = (/ bi(:,::-1,:) /)
175.41 + printVarSummary(bi)
175.42 +
175.43 + b2 = bi
175.44 + x2 = xi
175.45 +
175.46 + nx = dimsizes(xi)
175.47 + do i= 0,nx-1
175.48 + if (i .lt. 3600) then
175.49 + p = i + 3600
175.50 + xi(p) = x2(i) + 360.
175.51 + else
175.52 + p = i - 3600
175.53 + xi(p) = x2(i)
175.54 + end if
175.55 + bi(:,:,p)= b2(:,:,i)
175.56 + end do
175.57 +
175.58 + bi&lat = yi
175.59 + bi&lon = xi
175.60 +
175.61 +;print (xi)
175.62 +;print (yi)
175.63 +
175.64 +;************************************************
175.65 +; read in model data
175.66 +;************************************************
175.67 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
175.68 + fili2 = "newcn05_ncep_1i_MONS_climo_lnd.nc"
175.69 + f = addfile (diri2+fili2,"r")
175.70 +
175.71 + lon = f->lon
175.72 + lat = f->lat
175.73 + nlon = dimsizes(lon)
175.74 + nlat = dimsizes(lat)
175.75 +
175.76 +; print (xi)
175.77 +; print (yi)
175.78 +; print (xo)
175.79 +; print (yo)
175.80 +
175.81 + bo = new((/12,nlat,nlon/),float)
175.82 +
175.83 + do m = 0,11
175.84 + do j=0,nlat-1
175.85 + if (j.eq.0 .or. j.eq.nlat-1) then
175.86 + if (j.eq.0) then
175.87 + LATS = -90.
175.88 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
175.89 + end if
175.90 + if (j.eq.nlat-1) then
175.91 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
175.92 + LATN = 90.
175.93 + end if
175.94 + else
175.95 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
175.96 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
175.97 + end if
175.98 +
175.99 + do i=0,nlon-1
175.100 + if (i.eq.0 .or. i.eq.nlon-1) then
175.101 + if (i.eq.0) then
175.102 + LONL = 0.
175.103 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
175.104 + end if
175.105 + if (i.eq.nlon-1) then
175.106 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
175.107 + LONR = 360.
175.108 + end if
175.109 + else
175.110 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
175.111 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
175.112 + end if
175.113 +
175.114 +;print (LATS)
175.115 +;print (LATN)
175.116 +;print (LONL)
175.117 +;print (LONR)
175.118 +
175.119 + bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))
175.120 + end do
175.121 + end do
175.122 + end do
175.123 +
175.124 + bo!0 = "time"
175.125 + bo!1 = "lat"
175.126 + bo!2 = "lon"
175.127 + bo&time= bi&time
175.128 + bo&lat = lat
175.129 + bo&lon = lon
175.130 + bo@units = bi@units
175.131 + bo@long_name = bi@long_name
175.132 + bo@_FillValue = bi@_FillValue
175.133 +
175.134 + c->LAI = bo
175.135 +end
175.136 \ No newline at end of file
176.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
176.2 +++ b/lai/03.lai_ob_to_T31.ncl Mon Jan 26 22:08:20 2009 -0500
176.3 @@ -0,0 +1,133 @@
176.4 +; ***********************************************
176.5 +; interpolate into model grids (T31)
176.6 +; ***********************************************
176.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
176.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
176.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
176.10 +;************************************************
176.11 +begin
176.12 +
176.13 + year = 2000
176.14 +
176.15 +;************************************************
176.16 +; output data
176.17 +;************************************************
176.18 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
176.19 + filo = "LAI_" + year + "_monthly_T31.nc"
176.20 +
176.21 + c = addfile(diro+filo,"c")
176.22 + filedimdef(c,"time",-1,True)
176.23 +
176.24 +;************************************************
176.25 +; read in observed data
176.26 +;************************************************
176.27 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
176.28 + fili = "LAI_" + year + "_monthly.nc"
176.29 +
176.30 + g = addfile (diri+fili,"r")
176.31 + bi = g->LAI
176.32 + xi = g->lon
176.33 + yi = g->lat
176.34 +
176.35 +;************************************************
176.36 +; change into 0-360E, 90S-90N
176.37 +; Observed NPP*scale_factor
176.38 +;************************************************
176.39 +
176.40 + yi = (/ yi(::-1) /)
176.41 + bi = (/ bi(:,::-1,:) /)
176.42 + printVarSummary(bi)
176.43 +
176.44 + b2 = bi
176.45 + x2 = xi
176.46 +
176.47 + nx = dimsizes(xi)
176.48 + do i= 0,nx-1
176.49 + if (i .lt. 3600) then
176.50 + p = i + 3600
176.51 + xi(p) = x2(i) + 360.
176.52 + else
176.53 + p = i - 3600
176.54 + xi(p) = x2(i)
176.55 + end if
176.56 + bi(:,:,p)= b2(:,:,i)
176.57 + end do
176.58 +
176.59 + bi&lat = yi
176.60 + bi&lon = xi
176.61 +
176.62 +;print (xi)
176.63 +;print (yi)
176.64 +
176.65 +;************************************************
176.66 +; read in model data
176.67 +;************************************************
176.68 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
176.69 + fili2 = "b30.061n_1995-2004_MONS_climo_lnd.nc"
176.70 + f = addfile (diri2+fili2,"r")
176.71 +
176.72 + lon = f->lon
176.73 + lat = f->lat
176.74 + nlon = dimsizes(lon)
176.75 + nlat = dimsizes(lat)
176.76 +
176.77 +; print (xi)
176.78 +; print (yi)
176.79 +; print (xo)
176.80 +; print (yo)
176.81 +
176.82 + bo = new((/12,nlat,nlon/),float)
176.83 +
176.84 + do m = 0,11
176.85 + do j=0,nlat-1
176.86 + if (j.eq.0 .or. j.eq.nlat-1) then
176.87 + if (j.eq.0) then
176.88 + LATS = -90.
176.89 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
176.90 + end if
176.91 + if (j.eq.nlat-1) then
176.92 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
176.93 + LATN = 90.
176.94 + end if
176.95 + else
176.96 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
176.97 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
176.98 + end if
176.99 +
176.100 + do i=0,nlon-1
176.101 + if (i.eq.0 .or. i.eq.nlon-1) then
176.102 + if (i.eq.0) then
176.103 + LONL = 0.
176.104 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
176.105 + end if
176.106 + if (i.eq.nlon-1) then
176.107 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
176.108 + LONR = 360.
176.109 + end if
176.110 + else
176.111 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
176.112 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
176.113 + end if
176.114 +
176.115 +;print (LATS)
176.116 +;print (LATN)
176.117 +;print (LONL)
176.118 +;print (LONR)
176.119 +
176.120 + bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))
176.121 + end do
176.122 + end do
176.123 + end do
176.124 +
176.125 + bo!0 = "time"
176.126 + bo!1 = "lat"
176.127 + bo!2 = "lon"
176.128 + bo&time= bi&time
176.129 + bo&lat = lat
176.130 + bo&lon = lon
176.131 + bo@units = bi@units
176.132 + bo@long_name = bi@long_name
176.133 + bo@_FillValue = bi@_FillValue
176.134 +
176.135 + c->LAI = bo
176.136 +end
176.137 \ No newline at end of file
177.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
177.2 +++ b/lai/03.lai_ob_to_T31.ncl.x Mon Jan 26 22:08:20 2009 -0500
177.3 @@ -0,0 +1,128 @@
177.4 +; ***********************************************
177.5 +; interpolate into model grids (T31)
177.6 +; ***********************************************
177.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
177.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
177.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
177.10 +;************************************************
177.11 +begin
177.12 +
177.13 +;************************************************
177.14 +; output data
177.15 +;************************************************
177.16 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
177.17 + filo = "LAI_2000-2005_ensemble_T31.nc"
177.18 + c = addfile(diro+filo,"c")
177.19 + filedimdef(c,"time",-1,True)
177.20 +
177.21 +;************************************************
177.22 +; read in observed data
177.23 +;************************************************
177.24 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
177.25 + fili = "LAI_2000-2005_ensemble_0.05deg.nc"
177.26 + g = addfile (diri+fili,"r")
177.27 + bi = g->LAI
177.28 + xi = g->lon
177.29 + yi = g->lat
177.30 +
177.31 +;************************************************
177.32 +; change into 0-360E, 90S-90N
177.33 +;************************************************
177.34 +
177.35 + yi = (/ yi(::-1) /)
177.36 + bi = (/ bi(:,::-1,:) /)
177.37 + printVarSummary(bi)
177.38 +
177.39 + b2 = bi
177.40 + x2 = xi
177.41 +
177.42 + nx = dimsizes(xi)
177.43 + do i= 0,nx-1
177.44 + if (i .lt. 3600) then
177.45 + p = i + 3600
177.46 + xi(p) = x2(i) + 360.
177.47 + else
177.48 + p = i - 3600
177.49 + xi(p) = x2(i)
177.50 + end if
177.51 + bi(:,:,p)= b2(:,:,i)
177.52 + end do
177.53 +
177.54 + bi&lat = yi
177.55 + bi&lon = xi
177.56 +
177.57 +;print (xi)
177.58 +;print (yi)
177.59 +;************************************************
177.60 +; read in model data
177.61 +;************************************************
177.62 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
177.63 + fili2 = "b30.061n_1995-2004_MONS_climo_lnd.nc"
177.64 + f = addfile (diri2+fili2,"r")
177.65 +
177.66 + lon = f->lon
177.67 + lat = f->lat
177.68 + nlon = dimsizes(lon)
177.69 + nlat = dimsizes(lat)
177.70 +
177.71 +; print (xi)
177.72 +; print (yi)
177.73 +; print (xo)
177.74 +; print (yo)
177.75 +
177.76 + bo = new((/12,nlat,nlon/),float)
177.77 +
177.78 + do m = 0,11
177.79 + do j=0,nlat-1
177.80 + if (j.eq.0 .or. j.eq.nlat-1) then
177.81 + if (j.eq.0) then
177.82 + LATS = -90.
177.83 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
177.84 + end if
177.85 + if (j.eq.nlat-1) then
177.86 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
177.87 + LATN = 90.
177.88 + end if
177.89 + else
177.90 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
177.91 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
177.92 + end if
177.93 +
177.94 + do i=0,nlon-1
177.95 + if (i.eq.0 .or. i.eq.nlon-1) then
177.96 + if (i.eq.0) then
177.97 + LONL = 0.
177.98 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
177.99 + end if
177.100 + if (i.eq.nlon-1) then
177.101 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
177.102 + LONR = 360.
177.103 + end if
177.104 + else
177.105 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
177.106 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
177.107 + end if
177.108 +
177.109 +;print (LATS)
177.110 +;print (LATN)
177.111 +;print (LONL)
177.112 +;print (LONR)
177.113 + bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))
177.114 + end do
177.115 + end do
177.116 + end do
177.117 +
177.118 + bo!0 = "time"
177.119 + bo!1 = "lat"
177.120 + bo!2 = "lon"
177.121 + bo&time= bi&time
177.122 + bo&lat = lat
177.123 + bo&lon = lon
177.124 + bo@units = bi@units
177.125 + bo@long_name = bi@long_name
177.126 + bo@_FillValue = bi@_FillValue
177.127 +; bo@units = "none"
177.128 +; bo@long_name = "Leaf Area Index"
177.129 +
177.130 + c->LAI = bo
177.131 +end
177.132 \ No newline at end of file
178.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
178.2 +++ b/lai/03.lai_ob_to_T42.ncl Mon Jan 26 22:08:20 2009 -0500
178.3 @@ -0,0 +1,158 @@
178.4 +; ***********************************************
178.5 +; interpolate into model grids (T31)
178.6 +; ***********************************************
178.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
178.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
178.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
178.10 +;************************************************
178.11 +begin
178.12 +
178.13 + year = 2003
178.14 +
178.15 +;************************************************
178.16 +; output data
178.17 +;************************************************
178.18 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/"
178.19 +; filo = "LAI_" + year + "_monthly_T42.nc"
178.20 +; filo = "LAI_2000-2005_mean_T42.nc"
178.21 + filo = "LAI_2000-2005_ensemble_T42.nc"
178.22 + c = addfile(diro+filo,"c")
178.23 + filedimdef(c,"time",-1,True)
178.24 +
178.25 +;************************************************
178.26 +; read in observed data
178.27 +;************************************************
178.28 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
178.29 +; fili = "LAI_" + year + "_monthly.nc"
178.30 +; fili = "LAI_2000-2005_mean_0.05deg.nc"
178.31 + fili = "LAI_2000-2005_ensemble_0.05deg.nc"
178.32 + g = addfile (diri+fili,"r")
178.33 + bi = g->LAI
178.34 + xi = g->lon
178.35 + yi = g->lat
178.36 +
178.37 +;************************************************
178.38 +; change into 0-360E, 90S-90N
178.39 +; Observed NPP*scale_factor
178.40 +;************************************************
178.41 +
178.42 + yi = (/ yi(::-1) /)
178.43 + bi = (/ bi(:,::-1,:) /)
178.44 + printVarSummary(bi)
178.45 +
178.46 + b2 = bi
178.47 + x2 = xi
178.48 +
178.49 + nx = dimsizes(xi)
178.50 + do i= 0,nx-1
178.51 + if (i .lt. 3600) then
178.52 + p = i + 3600
178.53 + xi(p) = x2(i) + 360.
178.54 + else
178.55 + p = i - 3600
178.56 + xi(p) = x2(i)
178.57 + end if
178.58 + bi(:,:,p)= b2(:,:,i)
178.59 + end do
178.60 +
178.61 + bi&lat = yi
178.62 + bi&lon = xi
178.63 +
178.64 +;print (xi)
178.65 +;print (yi)
178.66 +;exit
178.67 +
178.68 +;************************************************
178.69 +; read in model data
178.70 +;************************************************
178.71 +;fili2 = "i01.04casa_1605-1629_ANN_climo.nc"
178.72 + fili2 = "i01.03cn_1545-1569_ANN_climo.nc"
178.73 + f = addfile (diri+fili2,"r")
178.74 +
178.75 + lon = f->lon
178.76 + lat = f->lat
178.77 + nlon = dimsizes(lon)
178.78 + nlat = dimsizes(lat)
178.79 +
178.80 +; print (xi)
178.81 +; print (yi)
178.82 +; print (xo)
178.83 +; print (yo)
178.84 +
178.85 +;(A)
178.86 +;bo = linint2_Wrap(xi,yi,bi,True,xo,yo,0)
178.87 +
178.88 +;(B)
178.89 +
178.90 +; rad = 4.*atan(1.)/180.
178.91 +; clat = lat
178.92 +; clat = cos(lat*rad)
178.93 +; clat@long_name = "cos(latitude)"
178.94 +; delete(clat@units)
178.95 +; printVarSummary(clat)
178.96 +
178.97 + bo = new((/12,nlat,nlon/),float)
178.98 +;bo = new((/1,nlat,nlon/),float)
178.99 + do m = 0,11
178.100 + do j=0,nlat-1
178.101 + if (j.eq.0 .or. j.eq.nlat-1) then
178.102 + if (j.eq.0) then
178.103 + LATS = -90.
178.104 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
178.105 + end if
178.106 + if (j.eq.nlat-1) then
178.107 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
178.108 + LATN = 90.
178.109 + end if
178.110 + else
178.111 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
178.112 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
178.113 + end if
178.114 +
178.115 +; CLAT = clat({LATS:LATN}) ; do once for *slight* efficiency
178.116 +; TEMP = bi(:,{LATS:LATN},:) ; 2D [lat,lon]
178.117 +
178.118 + do i=0,nlon-1
178.119 + if (i.eq.0 .or. i.eq.nlon-1) then
178.120 + if (i.eq.0) then
178.121 + LONL = 0.
178.122 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
178.123 + end if
178.124 + if (i.eq.nlon-1) then
178.125 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
178.126 + LONR = 360.
178.127 + end if
178.128 + else
178.129 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
178.130 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
178.131 + end if
178.132 +
178.133 +;print (LATS)
178.134 +;print (LATN)
178.135 +;print (LONL)
178.136 +;print (LONR)
178.137 +; bo(:,j,i) = avg(bi(:,{LATS:LATN},{LONL:LONR}))
178.138 + bo(m,j,i) = avg(bi(m,{LATS:LATN},{LONL:LONR}))
178.139 +; bo(:,j,i) = wgt_areaave(TEMP(:,{LONL:LONR}), CLAT, 1.0, 0)
178.140 + end do
178.141 +
178.142 +; delete(CLAT)
178.143 +; delete(TEMP)
178.144 + end do
178.145 + end do
178.146 +
178.147 + bo!0 = "time"
178.148 + bo!1 = "lat"
178.149 + bo!2 = "lon"
178.150 + bo&time= bi&time
178.151 +; bo&time= 1
178.152 + bo&lat = lat
178.153 + bo&lon = lon
178.154 +; bo@units = bi@units
178.155 +; bo@long_name = bi@long_name
178.156 + bo@units = "none"
178.157 + bo@long_name = "Leaf Area Index"
178.158 + bo@_FillValue = bi@_FillValue
178.159 +
178.160 + c->LAI = bo
178.161 +end
178.162 \ No newline at end of file
179.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
179.2 +++ b/lai/03.land_class_to_1.9.ncl Mon Jan 26 22:08:20 2009 -0500
179.3 @@ -0,0 +1,139 @@
179.4 +; ***********************************************
179.5 +; interpolate into model grids (T42)
179.6 +; output: lat: S->N lon: 0->360
179.7 +; input : lat: N->S lon: -180->180
179.8 +; ***********************************************
179.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
179.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
179.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
179.12 +;************************************************
179.13 +begin
179.14 +
179.15 + nclass = 20
179.16 +
179.17 +;************************************************
179.18 +; output data
179.19 +;************************************************
179.20 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
179.21 + filo = "land_class_1.9.nc"
179.22 + c = addfile(diro+filo,"c")
179.23 +
179.24 +;************************************************
179.25 +; read in observed data
179.26 +;************************************************
179.27 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
179.28 + fili = "land_class_0.25deg_new.nc"
179.29 + g = addfile (diri+fili,"r")
179.30 + bi = g->LAND_CLASS
179.31 + xi = g->lon
179.32 + yi = g->lat
179.33 +
179.34 +;************************************************
179.35 +; change into 0-360E, 90S-90N
179.36 +;************************************************
179.37 +
179.38 + yi = (/ yi(::-1) /)
179.39 + bi = (/ bi(::-1,:) /)
179.40 + printVarSummary(bi)
179.41 +
179.42 + b2 = bi
179.43 + x2 = xi
179.44 +
179.45 + nx = dimsizes(xi)
179.46 + nx2 = nx/2
179.47 +
179.48 + do i= 0,nx-1
179.49 + if (i .lt. nx2) then
179.50 + p = i + nx2
179.51 + xi(p) = x2(i) + 360.
179.52 + else
179.53 + p = i - nx2
179.54 + xi(p) = x2(i)
179.55 + end if
179.56 + bi(:,p)= b2(:,i)
179.57 + end do
179.58 +
179.59 + bi&lat = yi
179.60 + bi&lon = xi
179.61 +
179.62 + print (xi)
179.63 + print (yi)
179.64 +;exit
179.65 +
179.66 +;************************************************
179.67 +; read in model data
179.68 +;************************************************
179.69 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
179.70 + fili2 = "newcn05_ncep_1i_MONS_climo_lnd.nc"
179.71 + f = addfile (diri2+fili2,"r")
179.72 +
179.73 + lon = f->lon
179.74 + lat = f->lat
179.75 + nlon = dimsizes(lon)
179.76 + nlat = dimsizes(lat)
179.77 +
179.78 +; print (xi)
179.79 +; print (yi)
179.80 +; print (xo)
179.81 +; print (yo)
179.82 +
179.83 + bo = new((/nlat,nlon/),integer)
179.84 + count = new((/nclass/),integer)
179.85 +
179.86 + do j=0,nlat-1
179.87 + if (j.eq.0 .or. j.eq.nlat-1) then
179.88 + if (j.eq.0) then
179.89 + LATS = -90.
179.90 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
179.91 + end if
179.92 + if (j.eq.nlat-1) then
179.93 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
179.94 + LATN = 90.
179.95 + end if
179.96 + else
179.97 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
179.98 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
179.99 + end if
179.100 +
179.101 + do i=0,nlon-1
179.102 + if (i.eq.0 .or. i.eq.nlon-1) then
179.103 + if (i.eq.0) then
179.104 + LONL = 0.
179.105 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
179.106 + end if
179.107 + if (i.eq.nlon-1) then
179.108 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
179.109 + LONR = 360.
179.110 + end if
179.111 + else
179.112 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
179.113 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
179.114 + end if
179.115 +
179.116 +;print (LATS)
179.117 +;print (LATN)
179.118 +;print (LONL)
179.119 +;print (LONR)
179.120 +
179.121 + count = 0
179.122 +
179.123 + do n = 0,nclass-1
179.124 + count(n) = num (bi({LATS:LATN},{LONL:LONR}).eq.n)
179.125 + end do
179.126 +
179.127 + bo(j,i) = maxind(count)
179.128 + end do
179.129 + end do
179.130 +
179.131 + bo!0 = "lat"
179.132 + bo!1 = "lon"
179.133 + bo&lat = lat
179.134 + bo&lon = lon
179.135 + bo@units = bi@units
179.136 + bo@long_name = bi@long_name
179.137 + bo@_FillValue = bi@_FillValue
179.138 +
179.139 + print (min(bo) + "/" + max(bo))
179.140 +
179.141 + c->LAND_CLASS = bo
179.142 +end
179.143 \ No newline at end of file
180.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
180.2 +++ b/lai/03.land_class_to_T31.ncl Mon Jan 26 22:08:20 2009 -0500
180.3 @@ -0,0 +1,139 @@
180.4 +; ***********************************************
180.5 +; interpolate into model grids (T42)
180.6 +; output: lat: S->N lon: 0->360
180.7 +; input : lat: N->S lon: -180->180
180.8 +; ***********************************************
180.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
180.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
180.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
180.12 +;************************************************
180.13 +begin
180.14 +
180.15 + nclass = 20
180.16 +
180.17 +;************************************************
180.18 +; output data
180.19 +;************************************************
180.20 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
180.21 + filo = "land_class_T31.nc"
180.22 + c = addfile(diro+filo,"c")
180.23 +
180.24 +;************************************************
180.25 +; read in observed data
180.26 +;************************************************
180.27 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
180.28 + fili = "land_class_0.25deg_new.nc"
180.29 + g = addfile (diri+fili,"r")
180.30 + bi = g->LAND_CLASS
180.31 + xi = g->lon
180.32 + yi = g->lat
180.33 +
180.34 +;************************************************
180.35 +; change into 0-360E, 90S-90N
180.36 +;************************************************
180.37 +
180.38 + yi = (/ yi(::-1) /)
180.39 + bi = (/ bi(::-1,:) /)
180.40 + printVarSummary(bi)
180.41 +
180.42 + b2 = bi
180.43 + x2 = xi
180.44 +
180.45 + nx = dimsizes(xi)
180.46 + nx2 = nx/2
180.47 +
180.48 + do i= 0,nx-1
180.49 + if (i .lt. nx2) then
180.50 + p = i + nx2
180.51 + xi(p) = x2(i) + 360.
180.52 + else
180.53 + p = i - nx2
180.54 + xi(p) = x2(i)
180.55 + end if
180.56 + bi(:,p)= b2(:,i)
180.57 + end do
180.58 +
180.59 + bi&lat = yi
180.60 + bi&lon = xi
180.61 +
180.62 + print (xi)
180.63 + print (yi)
180.64 +;exit
180.65 +
180.66 +;************************************************
180.67 +; read in model data
180.68 +;************************************************
180.69 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
180.70 + fili2 = "b30.061n_1995-2004_ANN_climo_lnd.nc"
180.71 + f = addfile (diri2+fili2,"r")
180.72 +
180.73 + lon = f->lon
180.74 + lat = f->lat
180.75 + nlon = dimsizes(lon)
180.76 + nlat = dimsizes(lat)
180.77 +
180.78 +; print (xi)
180.79 +; print (yi)
180.80 +; print (xo)
180.81 +; print (yo)
180.82 +
180.83 + bo = new((/nlat,nlon/),integer)
180.84 + count = new((/nclass/),integer)
180.85 +
180.86 + do j=0,nlat-1
180.87 + if (j.eq.0 .or. j.eq.nlat-1) then
180.88 + if (j.eq.0) then
180.89 + LATS = -90.
180.90 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
180.91 + end if
180.92 + if (j.eq.nlat-1) then
180.93 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
180.94 + LATN = 90.
180.95 + end if
180.96 + else
180.97 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
180.98 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
180.99 + end if
180.100 +
180.101 + do i=0,nlon-1
180.102 + if (i.eq.0 .or. i.eq.nlon-1) then
180.103 + if (i.eq.0) then
180.104 + LONL = 0.
180.105 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
180.106 + end if
180.107 + if (i.eq.nlon-1) then
180.108 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
180.109 + LONR = 360.
180.110 + end if
180.111 + else
180.112 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
180.113 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
180.114 + end if
180.115 +
180.116 +;print (LATS)
180.117 +;print (LATN)
180.118 +;print (LONL)
180.119 +;print (LONR)
180.120 +
180.121 + count = 0
180.122 +
180.123 + do n = 0,nclass-1
180.124 + count(n) = num (bi({LATS:LATN},{LONL:LONR}).eq.n)
180.125 + end do
180.126 +
180.127 + bo(j,i) = maxind(count)
180.128 + end do
180.129 + end do
180.130 +
180.131 + bo!0 = "lat"
180.132 + bo!1 = "lon"
180.133 + bo&lat = lat
180.134 + bo&lon = lon
180.135 + bo@units = bi@units
180.136 + bo@long_name = bi@long_name
180.137 + bo@_FillValue = bi@_FillValue
180.138 +
180.139 + print (min(bo) + "/" + max(bo))
180.140 +
180.141 + c->LAND_CLASS = bo
180.142 +end
180.143 \ No newline at end of file
181.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
181.2 +++ b/lai/03.land_class_to_T42.ncl Mon Jan 26 22:08:20 2009 -0500
181.3 @@ -0,0 +1,141 @@
181.4 +; ***********************************************
181.5 +; interpolate into model grids (T42)
181.6 +; output: lat: S->N lon: 0->360
181.7 +; input : lat: N->S lon: -180->180
181.8 +; ***********************************************
181.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
181.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
181.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
181.12 +;************************************************
181.13 +begin
181.14 +
181.15 + nclass = 20
181.16 +
181.17 +;************************************************
181.18 +; output data
181.19 +;************************************************
181.20 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
181.21 +; filo = "land_class_T42.nc"
181.22 + filo = "land_class_T42_new.nc"
181.23 + c = addfile(diro+filo,"c")
181.24 +
181.25 +;************************************************
181.26 +; read in observed data
181.27 +;************************************************
181.28 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
181.29 + fili = "land_class_0.25deg.nc"
181.30 + fili = "land_class_0.25deg_new.nc"
181.31 + g = addfile (diri+fili,"r")
181.32 + bi = g->LAND_CLASS
181.33 + xi = g->lon
181.34 + yi = g->lat
181.35 +
181.36 +;************************************************
181.37 +; change into 0-360E, 90S-90N
181.38 +;************************************************
181.39 +
181.40 + yi = (/ yi(::-1) /)
181.41 + bi = (/ bi(::-1,:) /)
181.42 + printVarSummary(bi)
181.43 +
181.44 + b2 = bi
181.45 + x2 = xi
181.46 +
181.47 + nx = dimsizes(xi)
181.48 + nx2 = nx/2
181.49 +
181.50 + do i= 0,nx-1
181.51 + if (i .lt. nx2) then
181.52 + p = i + nx2
181.53 + xi(p) = x2(i) + 360.
181.54 + else
181.55 + p = i - nx2
181.56 + xi(p) = x2(i)
181.57 + end if
181.58 + bi(:,p)= b2(:,i)
181.59 + end do
181.60 +
181.61 + bi&lat = yi
181.62 + bi&lon = xi
181.63 +
181.64 + print (xi)
181.65 + print (yi)
181.66 +;exit
181.67 +
181.68 +;************************************************
181.69 +; read in model data
181.70 +;************************************************
181.71 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
181.72 + fili2 = "i01.03cn_1545-1569_ANN_climo.nc"
181.73 + f = addfile (diri2+fili2,"r")
181.74 +
181.75 + lon = f->lon
181.76 + lat = f->lat
181.77 + nlon = dimsizes(lon)
181.78 + nlat = dimsizes(lat)
181.79 +
181.80 +; print (xi)
181.81 +; print (yi)
181.82 +; print (xo)
181.83 +; print (yo)
181.84 +
181.85 + bo = new((/nlat,nlon/),integer)
181.86 + count = new((/nclass/),integer)
181.87 +
181.88 + do j=0,nlat-1
181.89 + if (j.eq.0 .or. j.eq.nlat-1) then
181.90 + if (j.eq.0) then
181.91 + LATS = -90.
181.92 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
181.93 + end if
181.94 + if (j.eq.nlat-1) then
181.95 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
181.96 + LATN = 90.
181.97 + end if
181.98 + else
181.99 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
181.100 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
181.101 + end if
181.102 +
181.103 + do i=0,nlon-1
181.104 + if (i.eq.0 .or. i.eq.nlon-1) then
181.105 + if (i.eq.0) then
181.106 + LONL = 0.
181.107 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
181.108 + end if
181.109 + if (i.eq.nlon-1) then
181.110 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
181.111 + LONR = 360.
181.112 + end if
181.113 + else
181.114 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
181.115 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
181.116 + end if
181.117 +
181.118 +;print (LATS)
181.119 +;print (LATN)
181.120 +;print (LONL)
181.121 +;print (LONR)
181.122 +
181.123 + count = 0
181.124 +
181.125 + do n = 0,nclass-1
181.126 + count(n) = num (bi({LATS:LATN},{LONL:LONR}).eq.n)
181.127 + end do
181.128 +
181.129 + bo(j,i) = maxind(count)
181.130 + end do
181.131 + end do
181.132 +
181.133 + bo!0 = "lat"
181.134 + bo!1 = "lon"
181.135 + bo&lat = lat
181.136 + bo&lon = lon
181.137 + bo@units = bi@units
181.138 + bo@long_name = bi@long_name
181.139 + bo@_FillValue = bi@_FillValue
181.140 +
181.141 + print (min(bo) + "/" + max(bo))
181.142 +
181.143 + c->LAND_CLASS = bo
181.144 +end
181.145 \ No newline at end of file
182.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
182.2 +++ b/lai/04.lai_ensemble.ncl Mon Jan 26 22:08:20 2009 -0500
182.3 @@ -0,0 +1,43 @@
182.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
182.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
182.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
182.7 +
182.8 +begin
182.9 +;----------------------------------------------------------
182.10 + year_start = 2000
182.11 + year_end = 2005
182.12 +;----------------------------------------------------------
182.13 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
182.14 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/"
182.15 + filo1 = "MOD15A2_LAI_"+year_start+"-"+year_end+"_ensemble.nc"
182.16 + filo2 = "MOD15A2_LAI_"+year_start+"-"+year_end+"_mean.nc"
182.17 + c = addfile(diro+filo1,"c")
182.18 + d = addfile(diro+filo2,"c")
182.19 +
182.20 + nyear = year_end - year_start + 1
182.21 +
182.22 + files = new((/nyear/),"string")
182.23 +
182.24 + do n = year_start,year_end
182.25 + i = n - year_start
182.26 +; files(i)= diri + "MOD15A2_LAI_" + n + "_monthly.nc"
182.27 + files(i)= diri + "MOD15A2_LAI_" + n + "_monthly_T42.nc"
182.28 + end do
182.29 + print (files)
182.30 +
182.31 + file_list = addfiles(files,"r")
182.32 + ListSetType(file_list,"join")
182.33 + x = addfiles_GetVar(file_list, files, "LAI")
182.34 + printVarSummary (x)
182.35 +
182.36 + y = dim_avg_Wrap(x(time|:,lat|:,lon|:,case|:))
182.37 + printVarSummary (y)
182.38 +
182.39 + c->LAI = y
182.40 +
182.41 + z = dim_avg_Wrap(y(lat|:,lon|:,time|:))
182.42 + printVarSummary (z)
182.43 +
182.44 + d->LAI = z
182.45 +end
182.46 +
183.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
183.2 +++ b/lai/04.lai_ensemble_1.9.ncl Mon Jan 26 22:08:20 2009 -0500
183.3 @@ -0,0 +1,46 @@
183.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
183.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
183.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
183.7 +
183.8 +begin
183.9 +;----------------------------------------------------------
183.10 + year_start = 2000
183.11 + year_end = 2005
183.12 +;----------------------------------------------------------
183.13 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
183.14 +
183.15 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
183.16 + filo1 = "LAI_"+year_start+"-"+year_end+"_MONS_1.9.nc"
183.17 + filo2 = "LAI_"+year_start+"-"+year_end+"_ANN_1.9.nc"
183.18 + c = addfile(diro+filo1,"c")
183.19 + d = addfile(diro+filo2,"c")
183.20 +
183.21 + nyear = year_end - year_start + 1
183.22 +
183.23 + files = new((/nyear/),"string")
183.24 +
183.25 + do n = year_start,year_end
183.26 + i = n - year_start
183.27 + files(i)= diri + "LAI_" + n + "_monthly_1.9.nc"
183.28 + end do
183.29 + print (files)
183.30 +
183.31 + file_list = addfiles(files,"r")
183.32 + ListSetType(file_list,"join")
183.33 + x = addfiles_GetVar(file_list, files, "LAI")
183.34 + printVarSummary (x)
183.35 + x@_FillValue = 1.e+36
183.36 +
183.37 + y = dim_avg_Wrap(x(time|:,lat|:,lon|:,case|:))
183.38 + printVarSummary (y)
183.39 + y@_FillValue = 1.e+36
183.40 +
183.41 + c->LAI = y
183.42 +
183.43 + z = dim_avg_Wrap(y(lat|:,lon|:,time|:))
183.44 + printVarSummary (z)
183.45 + z@_FillValue = 1.e+36
183.46 +
183.47 + d->LAI = z
183.48 +end
183.49 +
184.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
184.2 +++ b/lai/04.lai_ensemble_T31.ncl Mon Jan 26 22:08:20 2009 -0500
184.3 @@ -0,0 +1,46 @@
184.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
184.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
184.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
184.7 +
184.8 +begin
184.9 +;----------------------------------------------------------
184.10 + year_start = 2000
184.11 + year_end = 2005
184.12 +;----------------------------------------------------------
184.13 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
184.14 +
184.15 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
184.16 + filo1 = "LAI_"+year_start+"-"+year_end+"_MONS_T31_3.nc"
184.17 + filo2 = "LAI_"+year_start+"-"+year_end+"_ANN_T31_3.nc"
184.18 + c = addfile(diro+filo1,"c")
184.19 + d = addfile(diro+filo2,"c")
184.20 +
184.21 + nyear = year_end - year_start + 1
184.22 +
184.23 + files = new((/nyear/),"string")
184.24 +
184.25 + do n = year_start,year_end
184.26 + i = n - year_start
184.27 + files(i)= diri + "LAI_" + n + "_monthly_T31.nc"
184.28 + end do
184.29 + print (files)
184.30 +
184.31 + file_list = addfiles(files,"r")
184.32 + ListSetType(file_list,"join")
184.33 + x = addfiles_GetVar(file_list, files, "LAI")
184.34 + printVarSummary (x)
184.35 + x@_FillValue = 1.e+36
184.36 +
184.37 + y = dim_avg_Wrap(x(time|:,lat|:,lon|:,case|:))
184.38 + printVarSummary (y)
184.39 + y@_FillValue = 1.e+36
184.40 +
184.41 + c->LAI = y
184.42 +
184.43 + z = dim_avg_Wrap(y(lat|:,lon|:,time|:))
184.44 + printVarSummary (z)
184.45 + z@_FillValue = 1.e+36
184.46 +
184.47 + d->LAI = z
184.48 +end
184.49 +
185.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
185.2 +++ b/lai/04.lai_ensemble_T42.ncl Mon Jan 26 22:08:20 2009 -0500
185.3 @@ -0,0 +1,45 @@
185.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
185.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
185.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
185.7 +
185.8 +begin
185.9 +;----------------------------------------------------------
185.10 + year_start = 2000
185.11 + year_end = 2005
185.12 +;----------------------------------------------------------
185.13 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
185.14 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/"
185.15 +; filo1 = "LAI_"+year_start+"-"+year_end+"_ensemble.nc"
185.16 +; filo2 = "LAI_"+year_start+"-"+year_end+"_mean.nc"
185.17 + filo1 = "LAI_"+year_start+"-"+year_end+"_ensemble_T42.nc"
185.18 + filo2 = "LAI_"+year_start+"-"+year_end+"_mean_T42.nc"
185.19 + c = addfile(diro+filo1,"c")
185.20 + d = addfile(diro+filo2,"c")
185.21 +
185.22 + nyear = year_end - year_start + 1
185.23 +
185.24 + files = new((/nyear/),"string")
185.25 +
185.26 + do n = year_start,year_end
185.27 + i = n - year_start
185.28 +; files(i)= diri + "LAI_" + n + "_monthly.nc"
185.29 + files(i)= diri + "LAI_" + n + "_monthly_T42.nc"
185.30 + end do
185.31 + print (files)
185.32 +
185.33 + file_list = addfiles(files,"r")
185.34 + ListSetType(file_list,"join")
185.35 + x = addfiles_GetVar(file_list, files, "LAI")
185.36 + printVarSummary (x)
185.37 +
185.38 + y = dim_avg_Wrap(x(time|:,lat|:,lon|:,case|:))
185.39 + printVarSummary (y)
185.40 +
185.41 + c->LAI = y
185.42 +
185.43 + z = dim_avg_Wrap(y(lat|:,lon|:,time|:))
185.44 + printVarSummary (z)
185.45 +
185.46 + d->LAI = z
185.47 +end
185.48 +
186.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
186.2 +++ b/lai/04.lai_ensemble_T42.ncl.x Mon Jan 26 22:08:20 2009 -0500
186.3 @@ -0,0 +1,82 @@
186.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
186.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
186.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
186.7 +
186.8 +begin
186.9 +;----------------------------------------------------------
186.10 + year_start = 2000
186.11 + year_end = 2005
186.12 +;----------------------------------------------------------
186.13 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
186.14 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/"
186.15 + filo1 = "MOD15A2_LAI_"+year_start+"-"+year_end+"_ensemble.nc"
186.16 + filo2 = "MOD15A2_LAI_"+year_start+"-"+year_end+"_mean.nc"
186.17 + c = addfile(diro+filo1,"c")
186.18 + d = addfile(diro+filo2,"c")
186.19 +
186.20 + nyear = year_end - year_start + 1
186.21 +
186.22 + files = new((/nyear/),"string")
186.23 +
186.24 + do n = year_start,year_end
186.25 + i = n - year_start
186.26 +; files(i)= diri + "MOD15A2_LAI_" + n + "_monthly.nc"
186.27 + files(i)= diri + "MOD15A2_LAI_" + n + "_monthly_T42.nc"
186.28 + end do
186.29 + print (files)
186.30 +
186.31 + file_list = addfiles(files,"r")
186.32 + ListSetType(file_list,"join")
186.33 + x = addfiles_GetVar(file_list, files, "LAI")
186.34 + printVarSummary (x)
186.35 +
186.36 + y = addfiles_GetVar(file_list, files, "time")
186.37 + time = y(0,:)
186.38 + delete(time@case)
186.39 + delete(y)
186.40 + printVarSummary (time)
186.41 +
186.42 + y = addfiles_GetVar(file_list, files, "lat")
186.43 + lat = y(0,:)
186.44 + delete(lat@case)
186.45 + delete(y)
186.46 + printVarSummary (lat)
186.47 +
186.48 + y = addfiles_GetVar(file_list, files, "lon")
186.49 + lon = y(0,:)
186.50 + delete(lon@case)
186.51 + delete(y)
186.52 + printVarSummary (lon)
186.53 +
186.54 + x!0 = "case"
186.55 + x!1 = "time"
186.56 + x!2 = "lat"
186.57 + x!3 = "lon"
186.58 +
186.59 + y = dim_avg(x(time|:,lat|:,lon|:,case|:))
186.60 +
186.61 + y!0 = "time"
186.62 + y!1 = "lat"
186.63 + y!2 = "lon"
186.64 + y&time = time
186.65 + y&lat = lat
186.66 + y&lon = lon
186.67 + y@units = "none"
186.68 + y@long_name = "Leaf Area Index"
186.69 + printVarSummary (y)
186.70 +
186.71 + c->LAI = y
186.72 +
186.73 + z = dim_avg(y(lat|:,lon|:,time|:))
186.74 +
186.75 + z!0 = "lat"
186.76 + z!1 = "lon"
186.77 + z&lat = lat
186.78 + z&lon = lon
186.79 + z@units = "none"
186.80 + z@long_name = "Leaf Area Index"
186.81 + printVarSummary (z)
186.82 +
186.83 + d->LAI = z
186.84 +end
186.85 +
187.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
187.2 +++ b/lai/24.histogram+bias_mean.ncl Mon Jan 26 22:08:20 2009 -0500
187.3 @@ -0,0 +1,293 @@
187.4 +;********************************************************
187.5 +; histogram normalized by rain and compute correleration
187.6 +;********************************************************
187.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
187.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
187.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
187.10 +
187.11 +procedure pminmax(data:numeric,name:string)
187.12 +begin
187.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
187.14 + if(isatt(data,"units")) then
187.15 + print (name + " units = " + data@units)
187.16 + end if
187.17 +end
187.18 +
187.19 +;
187.20 +; Main code.
187.21 +;
187.22 +begin
187.23 +
187.24 +;nclass = 18
187.25 + nclass = 20
187.26 +
187.27 +;************************************************
187.28 +; read in data: observed
187.29 +;************************************************
187.30 + diri1 = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
187.31 +;fili1 = "land_class_T42.nc"
187.32 + fili1 = "land_class_T42_new.nc"
187.33 + fili2 = "LAI_2000-2005_mean_T42.nc"
187.34 + data_file_ob1 = addfile(diri1+fili1,"r")
187.35 + data_file_ob2 = addfile(diri1+fili2,"r")
187.36 +
187.37 + RAIN1 = tofloat(data_file_ob1->LAND_CLASS)
187.38 + NPP1 = data_file_ob2->LAI
187.39 +;************************************************
187.40 +; read in data: model
187.41 +;************************************************
187.42 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
187.43 +;fili3 = "i01.03cn_1545-1569_ANN_climo.nc"
187.44 + fili3 = "i01.04casa_1605-1629_ANN_climo.nc"
187.45 + data_file_model = addfile(diri2+fili3,"r")
187.46 +
187.47 + NPP2 = data_file_model->TLAI
187.48 +;************************************************
187.49 +; print min/max and unit
187.50 +;************************************************
187.51 + pminmax(RAIN1,"RAIN1")
187.52 + pminmax(NPP1,"NPP1")
187.53 + pminmax(NPP2,"NPP2")
187.54 +
187.55 + RAIN1_1D = ndtooned(RAIN1)
187.56 + NPP1_1D = ndtooned(NPP1)
187.57 + NPP2_1D = ndtooned(NPP2)
187.58 +;
187.59 +; Calculate some "nice" bins for binning the data in equally spaced
187.60 +; ranges.
187.61 +;
187.62 +
187.63 +; nbins = nclass + 1 ; Number of bins to use.
187.64 +; nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,False)
187.65 +; nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
187.66 +; range = fspan(nicevals(0),nicevals(1),nvals)
187.67 +
187.68 + nclassn = nclass + 1
187.69 + range = fspan(0,nclassn-1,nclassn)
187.70 +
187.71 +; print (nicevals)
187.72 +; print (nvals)
187.73 + print (range)
187.74 +; exit
187.75 +
187.76 +;
187.77 +; Use this range information to grab all the values in a
187.78 +; particular range, and then take an average.
187.79 +;
187.80 + nr = dimsizes(range)
187.81 + nx = nr-1
187.82 + xvalues = new((/2,nx/),typeof(RAIN1_1D))
187.83 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
187.84 + dx = xvalues(0,1) - xvalues(0,0) ; range width
187.85 + dx4 = dx/4 ; 1/4 of the range
187.86 + xvalues(1,:) = xvalues(0,:) - dx/5.
187.87 + yvalues = new((/2,nx/),typeof(RAIN1_1D))
187.88 + mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
187.89 + mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
187.90 +
187.91 + do nd=0,1
187.92 +;
187.93 +; See if we are doing model or observational data.
187.94 +;
187.95 + if(nd.eq.0) then
187.96 + data = RAIN1_1D
187.97 + npp_data = NPP1_1D
187.98 + else
187.99 + data = RAIN1_1D
187.100 + npp_data = NPP2_1D
187.101 + end if
187.102 +;
187.103 +; Loop through each range and check for values.
187.104 +;
187.105 + do i=0,nr-2
187.106 + if (i.ne.(nr-2)) then
187.107 + print("")
187.108 + print("In range ["+range(i)+","+range(i+1)+")")
187.109 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
187.110 + else
187.111 + print("")
187.112 + print("In range ["+range(i)+",)")
187.113 + idx = ind(range(i).le.data)
187.114 + end if
187.115 +;
187.116 +; Calculate average, and get min and max.
187.117 +;
187.118 + if(.not.any(ismissing(idx))) then
187.119 + yvalues(nd,i) = avg(npp_data(idx))
187.120 + mn_yvalues(nd,i) = min(npp_data(idx))
187.121 + mx_yvalues(nd,i) = max(npp_data(idx))
187.122 + count = dimsizes(idx)
187.123 + else
187.124 + count = 0
187.125 + yvalues(nd,i) = yvalues@_FillValue
187.126 + mn_yvalues(nd,i) = yvalues@_FillValue
187.127 + mx_yvalues(nd,i) = yvalues@_FillValue
187.128 + end if
187.129 +;
187.130 +; Print out information.
187.131 +;
187.132 + print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
187.133 + print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
187.134 +
187.135 +;
187.136 +; Clean up for next time in loop.
187.137 +;
187.138 + delete(idx)
187.139 + end do
187.140 + delete(data)
187.141 + delete(npp_data)
187.142 + end do
187.143 +
187.144 +;
187.145 +; Start the graphics.
187.146 +;
187.147 + wks = gsn_open_wks("ps","xy")
187.148 +
187.149 + res = True
187.150 + res@gsnMaximize = True
187.151 + res@gsnDraw = False
187.152 + res@gsnFrame = False
187.153 + res@xyMarkLineMode = "Markers"
187.154 + res@xyMarkerSizeF = 0.014
187.155 + res@xyMarker = 16
187.156 + res@xyMarkerColors = (/"Brown","Blue"/)
187.157 +; res@trYMinF = min(mn_yvalues) - 10.
187.158 +; res@trYMaxF = max(mx_yvalues) + 10.
187.159 + res@trYMinF = min(mn_yvalues) - 2
187.160 + res@trYMaxF = max(mx_yvalues) + 4
187.161 +
187.162 +; res@tiMainString = "Observed vs i01.03cn"
187.163 + res@tiMainString = "Observed vs i01.04casa"
187.164 +
187.165 + res@tiYAxisString = "Mean LAI (Leaf Area Index)"
187.166 + res@tiXAxisString = "Land Cover Type"
187.167 +;
187.168 +; Add a boxed legend using the more simple method, which won't have
187.169 +; vertical lines going through the markers.
187.170 +;
187.171 + res@pmLegendDisplayMode = "Always"
187.172 +; res@pmLegendWidthF = 0.1
187.173 + res@pmLegendWidthF = 0.08
187.174 + res@pmLegendHeightF = 0.05
187.175 + res@pmLegendOrthogonalPosF = -1.17
187.176 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
187.177 +; res@pmLegendParallelPosF = 0.18
187.178 + res@pmLegendParallelPosF = 0.23 ;(rightward)
187.179 +
187.180 +; res@lgPerimOn = False
187.181 + res@lgLabelFontHeightF = 0.015
187.182 +; res@xyExplicitLegendLabels = (/"observed","model_i01.03cn"/)
187.183 + res@xyExplicitLegendLabels = (/"observed","model_i01.04casa"/)
187.184 +
187.185 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
187.186 +
187.187 + max_bar = new((/2,nx/),graphic)
187.188 + min_bar = new((/2,nx/),graphic)
187.189 + max_cap = new((/2,nx/),graphic)
187.190 + min_cap = new((/2,nx/),graphic)
187.191 +
187.192 + lnres = True
187.193 +
187.194 + line_colors = (/"brown","blue"/)
187.195 + do nd=0,1
187.196 + lnres@gsLineColor = line_colors(nd)
187.197 + do i=0,nx-1
187.198 +
187.199 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
187.200 + .not.ismissing(mx_yvalues(nd,i))) then
187.201 +;
187.202 +; Attach the vertical bar, both above and below the marker.
187.203 +;
187.204 + x1 = xvalues(nd,i)
187.205 + y1 = yvalues(nd,i)
187.206 + y2 = mn_yvalues(nd,i)
187.207 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
187.208 +
187.209 + y2 = mx_yvalues(nd,i)
187.210 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
187.211 +;
187.212 +; Attach the horizontal cap line, both above and below the marker.
187.213 +;
187.214 + x1 = xvalues(nd,i) - dx4
187.215 + x2 = xvalues(nd,i) + dx4
187.216 + y1 = mn_yvalues(nd,i)
187.217 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
187.218 +
187.219 + y1 = mx_yvalues(nd,i)
187.220 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
187.221 + end if
187.222 + end do
187.223 + end do
187.224 +
187.225 +;
187.226 +; Here's how to do the legend by hand.
187.227 +;
187.228 +; mkres = True ; Marker resources
187.229 +; txres = True ; Text resources
187.230 +; mkres@gsMarkerIndex = 16
187.231 +; mkres@gsMarkerSizeF = 0.02
187.232 +; txres@txFontHeightF = 0.02
187.233 +; txres@txJust = "CenterLeft"
187.234 +;
187.235 +; Change these values if you want to move the marker legend location.
187.236 +; These values are in the same data space as the plot.
187.237 +;
187.238 +; xlg1_cen = 0.2
187.239 +; ylg1_cen = 900.
187.240 +
187.241 +; xlg2_cen = 0.2
187.242 +; ylg2_cen = 760.
187.243 +
187.244 +; mkres@gsMarkerColor = "brown"
187.245 +; lnres@gsLineColor = "brown"
187.246 +
187.247 +; lg_mark_legend1 = gsn_add_polymarker(wks,xy,xlg1_cen,ylg1_cen,mkres)
187.248 +; lg_line_legend1 = gsn_add_polyline(wks,xy,(/xlg1_cen,xlg1_cen/), \
187.249 +; (/ylg1_cen-60,ylg1_cen+60/),lnres)
187.250 +; lg_cap_legend11 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
187.251 +; (/ylg1_cen-60,ylg1_cen-60/),lnres)
187.252 +; lg_cap_legend12 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
187.253 +; (/ylg1_cen+60,ylg1_cen+60/),lnres)
187.254 +
187.255 +; tx_legend1 = gsn_add_text(wks,xy,"observed",xlg1_cen+0.15,ylg1_cen,txres)
187.256 +
187.257 +; mkres@gsMarkerColor = "blue"
187.258 +; lnres@gsLineColor = "blue"
187.259 +
187.260 +; lg_mark_legend2 = gsn_add_polymarker(wks,xy,xlg2_cen,ylg2_cen,mkres)
187.261 +; lg_line_legend2 = gsn_add_polyline(wks,xy,(/xlg2_cen,xlg2_cen/), \
187.262 +; (/ylg2_cen-60,ylg2_cen+60/),lnres)
187.263 +; lg_cap_legend21 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
187.264 +; (/ylg2_cen-60,ylg2_cen-60/),lnres)
187.265 +; lg_cap_legend22 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
187.266 +; (/ylg2_cen+60,ylg2_cen+60/),lnres)
187.267 +; tx_legend2 = gsn_add_text(wks,xy,"model_i01.03cn",xlg2_cen+0.15,ylg2_cen,txres)
187.268 +
187.269 + draw(xy)
187.270 + frame(wks)
187.271 + system("convert xy.ps xy.png")
187.272 +
187.273 + u = yvalues(0,:)
187.274 + v = yvalues(1,:)
187.275 +
187.276 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
187.277 + uu = u(good)
187.278 + vv = v(good)
187.279 + nz = dimsizes(uu)
187.280 + print (nz)
187.281 +
187.282 + ccr = esccr(uu,vv,0)
187.283 + print (ccr)
187.284 +
187.285 +;old eq
187.286 +;bias = sum(((vv-uu)/uu)^2)
187.287 +;M = (1.- sqrt(bias/nz))*5.
187.288 +
187.289 +;new eq
187.290 + bias = sum(abs(vv-uu)/(vv+uu))
187.291 + M = (1.- (bias/nz))*5.
187.292 + print (bias)
187.293 + print (M)
187.294 +
187.295 +end
187.296 +
188.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
188.2 +++ b/lai/25.histogram+bias_max.ncl Mon Jan 26 22:08:20 2009 -0500
188.3 @@ -0,0 +1,340 @@
188.4 +;********************************************************
188.5 +; histogram normalized by rain and compute correleration
188.6 +;********************************************************
188.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
188.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
188.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
188.10 +
188.11 +procedure pminmax(data:numeric,name:string)
188.12 +begin
188.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
188.14 + if(isatt(data,"units")) then
188.15 + print (name + " units = " + data@units)
188.16 + end if
188.17 +end
188.18 +
188.19 +;
188.20 +; Main code.
188.21 +;
188.22 +begin
188.23 +
188.24 +;nclass = 18
188.25 + nclass = 20
188.26 +
188.27 +;************************************************
188.28 +; read in data: observed
188.29 +;************************************************
188.30 + diri1 = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
188.31 +;fili1 = "land_class_T42.nc"
188.32 + fili1 = "land_class_T42_new.nc"
188.33 + fili2 = "LAI_2000-2005_ensemble_T42.nc"
188.34 + data_file_ob1 = addfile(diri1+fili1,"r")
188.35 + data_file_ob2 = addfile(diri1+fili2,"r")
188.36 +
188.37 + RAIN1 = tofloat(data_file_ob1->LAND_CLASS)
188.38 +
188.39 + z = data_file_ob2->LAI
188.40 + y = z(0,:,:)
188.41 + y@long_name = "Leaf Area Index Max"
188.42 + s = z(:,0,0)
188.43 +
188.44 + dsizes_z = dimsizes(z)
188.45 + ntime = dsizes_z(0)
188.46 + nlat = dsizes_z(1)
188.47 + nlon = dsizes_z(2)
188.48 +
188.49 + do j = 0,nlat-1
188.50 + do i = 0,nlon-1
188.51 + s = z(:,j,i)
188.52 + y(j,i) = max(s)
188.53 + end do
188.54 + end do
188.55 +
188.56 + print (min(y)+"/"+max(y))
188.57 +
188.58 + NPP1 = y
188.59 +
188.60 + delete (z)
188.61 + delete (s)
188.62 + delete (y)
188.63 +;************************************************
188.64 +; read in data: model
188.65 +;************************************************
188.66 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
188.67 + fili3 = "i01.03cn_1545-1569_MONS_climo.nc"
188.68 +;fili3 = "i01.04casa_1605-1629_MONS_climo.nc"
188.69 + data_file_model = addfile(diri2+fili3,"r")
188.70 +
188.71 + z = data_file_model->TLAI
188.72 + y = z(0,:,:)
188.73 + y@long_name = "Leaf Area Index Max"
188.74 + s = z(:,0,0)
188.75 +
188.76 + dsizes_z = dimsizes(z)
188.77 + ntime = dsizes_z(0)
188.78 + nlat = dsizes_z(1)
188.79 + nlon = dsizes_z(2)
188.80 +
188.81 + do j = 0,nlat-1
188.82 + do i = 0,nlon-1
188.83 + s = z(:,j,i)
188.84 + y(j,i) = max(s)
188.85 + end do
188.86 + end do
188.87 +
188.88 + print (min(y)+"/"+max(y))
188.89 +
188.90 + NPP2 = y
188.91 +
188.92 + delete (z)
188.93 + delete (s)
188.94 + delete (y)
188.95 +;************************************************
188.96 +; print min/max and unit
188.97 +;************************************************
188.98 + pminmax(RAIN1,"RAIN1")
188.99 + pminmax(NPP1,"NPP1")
188.100 + pminmax(NPP2,"NPP2")
188.101 +
188.102 + RAIN1_1D = ndtooned(RAIN1)
188.103 + NPP1_1D = ndtooned(NPP1)
188.104 + NPP2_1D = ndtooned(NPP2)
188.105 +;
188.106 +; Calculate some "nice" bins for binning the data in equally spaced
188.107 +; ranges.
188.108 +;
188.109 +
188.110 +; nbins = nclass + 1 ; Number of bins to use.
188.111 +; nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,False)
188.112 +; nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
188.113 +; range = fspan(nicevals(0),nicevals(1),nvals)
188.114 +
188.115 + nclass = nclass + 1
188.116 + range = fspan(0,nclass-1,nclass)
188.117 +
188.118 +; print (nicevals)
188.119 +; print (nvals)
188.120 + print (range)
188.121 +; exit
188.122 +
188.123 +;
188.124 +; Use this range information to grab all the values in a
188.125 +; particular range, and then take an average.
188.126 +;
188.127 + nr = dimsizes(range)
188.128 + nx = nr-1
188.129 + xvalues = new((/2,nx/),typeof(RAIN1_1D))
188.130 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
188.131 + dx = xvalues(0,1) - xvalues(0,0) ; range width
188.132 + dx4 = dx/4 ; 1/4 of the range
188.133 + xvalues(1,:) = xvalues(0,:) - dx/5.
188.134 + yvalues = new((/2,nx/),typeof(RAIN1_1D))
188.135 + mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
188.136 + mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
188.137 +
188.138 + do nd=0,1
188.139 +;
188.140 +; See if we are doing model or observational data.
188.141 +;
188.142 + if(nd.eq.0) then
188.143 + data = RAIN1_1D
188.144 + npp_data = NPP1_1D
188.145 + else
188.146 + data = RAIN1_1D
188.147 + npp_data = NPP2_1D
188.148 + end if
188.149 +;
188.150 +; Loop through each range and check for values.
188.151 +;
188.152 + do i=0,nr-2
188.153 + if (i.ne.(nr-2)) then
188.154 + print("")
188.155 + print("In range ["+range(i)+","+range(i+1)+")")
188.156 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
188.157 + else
188.158 + print("")
188.159 + print("In range ["+range(i)+",)")
188.160 + idx = ind(range(i).le.data)
188.161 + end if
188.162 +;
188.163 +; Calculate average, and get min and max.
188.164 +;
188.165 + if(.not.any(ismissing(idx))) then
188.166 + yvalues(nd,i) = avg(npp_data(idx))
188.167 + mn_yvalues(nd,i) = min(npp_data(idx))
188.168 + mx_yvalues(nd,i) = max(npp_data(idx))
188.169 + count = dimsizes(idx)
188.170 + else
188.171 + count = 0
188.172 + yvalues(nd,i) = yvalues@_FillValue
188.173 + mn_yvalues(nd,i) = yvalues@_FillValue
188.174 + mx_yvalues(nd,i) = yvalues@_FillValue
188.175 + end if
188.176 +;
188.177 +; Print out information.
188.178 +;
188.179 + print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
188.180 + print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
188.181 +
188.182 +;
188.183 +; Clean up for next time in loop.
188.184 +;
188.185 + delete(idx)
188.186 + end do
188.187 + delete(data)
188.188 + delete(npp_data)
188.189 + end do
188.190 +
188.191 +;
188.192 +; Start the graphics.
188.193 +;
188.194 + wks = gsn_open_wks("ps","xy")
188.195 +
188.196 + res = True
188.197 + res@gsnMaximize = True
188.198 + res@gsnDraw = False
188.199 + res@gsnFrame = False
188.200 + res@xyMarkLineMode = "Markers"
188.201 + res@xyMarkerSizeF = 0.014
188.202 + res@xyMarker = 16
188.203 + res@xyMarkerColors = (/"Brown","Blue"/)
188.204 +; res@trYMinF = min(mn_yvalues) - 10.
188.205 +; res@trYMaxF = max(mx_yvalues) + 10.
188.206 + res@trYMinF = min(mn_yvalues) - 2
188.207 + res@trYMaxF = max(mx_yvalues) + 4
188.208 +
188.209 + res@tiMainString = "Observed vs i01.03cn"
188.210 +; res@tiMainString = "Observed vs i01.04casa"
188.211 +
188.212 + res@tiYAxisString = "Max LAI (Leaf Area Index)"
188.213 + res@tiXAxisString = "Land Cover Type"
188.214 +;
188.215 +; Add a boxed legend using the more simple method, which won't have
188.216 +; vertical lines going through the markers.
188.217 +;
188.218 + res@pmLegendDisplayMode = "Always"
188.219 +; res@pmLegendWidthF = 0.1
188.220 + res@pmLegendWidthF = 0.08
188.221 + res@pmLegendHeightF = 0.05
188.222 + res@pmLegendOrthogonalPosF = -1.17
188.223 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
188.224 +; res@pmLegendParallelPosF = 0.18
188.225 + res@pmLegendParallelPosF = 0.23 ;(rightward)
188.226 +
188.227 +; res@lgPerimOn = False
188.228 + res@lgLabelFontHeightF = 0.015
188.229 + res@xyExplicitLegendLabels = (/"observed","model_i01.03cn"/)
188.230 +; res@xyExplicitLegendLabels = (/"observed","model_i01.04casa"/)
188.231 +
188.232 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
188.233 +
188.234 + max_bar = new((/2,nx/),graphic)
188.235 + min_bar = new((/2,nx/),graphic)
188.236 + max_cap = new((/2,nx/),graphic)
188.237 + min_cap = new((/2,nx/),graphic)
188.238 +
188.239 + lnres = True
188.240 +
188.241 + line_colors = (/"brown","blue"/)
188.242 + do nd=0,1
188.243 + lnres@gsLineColor = line_colors(nd)
188.244 + do i=0,nx-1
188.245 +
188.246 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
188.247 + .not.ismissing(mx_yvalues(nd,i))) then
188.248 +;
188.249 +; Attach the vertical bar, both above and below the marker.
188.250 +;
188.251 + x1 = xvalues(nd,i)
188.252 + y1 = yvalues(nd,i)
188.253 + y2 = mn_yvalues(nd,i)
188.254 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
188.255 +
188.256 + y2 = mx_yvalues(nd,i)
188.257 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
188.258 +;
188.259 +; Attach the horizontal cap line, both above and below the marker.
188.260 +;
188.261 + x1 = xvalues(nd,i) - dx4
188.262 + x2 = xvalues(nd,i) + dx4
188.263 + y1 = mn_yvalues(nd,i)
188.264 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
188.265 +
188.266 + y1 = mx_yvalues(nd,i)
188.267 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
188.268 + end if
188.269 + end do
188.270 + end do
188.271 +
188.272 +;
188.273 +; Here's how to do the legend by hand.
188.274 +;
188.275 +; mkres = True ; Marker resources
188.276 +; txres = True ; Text resources
188.277 +; mkres@gsMarkerIndex = 16
188.278 +; mkres@gsMarkerSizeF = 0.02
188.279 +; txres@txFontHeightF = 0.02
188.280 +; txres@txJust = "CenterLeft"
188.281 +;
188.282 +; Change these values if you want to move the marker legend location.
188.283 +; These values are in the same data space as the plot.
188.284 +;
188.285 +; xlg1_cen = 0.2
188.286 +; ylg1_cen = 900.
188.287 +
188.288 +; xlg2_cen = 0.2
188.289 +; ylg2_cen = 760.
188.290 +
188.291 +; mkres@gsMarkerColor = "brown"
188.292 +; lnres@gsLineColor = "brown"
188.293 +
188.294 +; lg_mark_legend1 = gsn_add_polymarker(wks,xy,xlg1_cen,ylg1_cen,mkres)
188.295 +; lg_line_legend1 = gsn_add_polyline(wks,xy,(/xlg1_cen,xlg1_cen/), \
188.296 +; (/ylg1_cen-60,ylg1_cen+60/),lnres)
188.297 +; lg_cap_legend11 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
188.298 +; (/ylg1_cen-60,ylg1_cen-60/),lnres)
188.299 +; lg_cap_legend12 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
188.300 +; (/ylg1_cen+60,ylg1_cen+60/),lnres)
188.301 +
188.302 +; tx_legend1 = gsn_add_text(wks,xy,"observed",xlg1_cen+0.15,ylg1_cen,txres)
188.303 +
188.304 +; mkres@gsMarkerColor = "blue"
188.305 +; lnres@gsLineColor = "blue"
188.306 +
188.307 +; lg_mark_legend2 = gsn_add_polymarker(wks,xy,xlg2_cen,ylg2_cen,mkres)
188.308 +; lg_line_legend2 = gsn_add_polyline(wks,xy,(/xlg2_cen,xlg2_cen/), \
188.309 +; (/ylg2_cen-60,ylg2_cen+60/),lnres)
188.310 +; lg_cap_legend21 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
188.311 +; (/ylg2_cen-60,ylg2_cen-60/),lnres)
188.312 +; lg_cap_legend22 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
188.313 +; (/ylg2_cen+60,ylg2_cen+60/),lnres)
188.314 +; tx_legend2 = gsn_add_text(wks,xy,"model_i01.03cn",xlg2_cen+0.15,ylg2_cen,txres)
188.315 +
188.316 + draw(xy)
188.317 + frame(wks)
188.318 + system("convert xy.ps xy.png")
188.319 +
188.320 + u = yvalues(0,:)
188.321 + v = yvalues(1,:)
188.322 +
188.323 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
188.324 + uu = u(good)
188.325 + vv = v(good)
188.326 + nz = dimsizes(uu)
188.327 + print (nz)
188.328 +
188.329 + ccr = esccr(uu,vv,0)
188.330 + print (ccr)
188.331 +
188.332 +;old eq
188.333 +;bias = sum(((vv-uu)/uu)^2)
188.334 +;M = (1.- sqrt(bias/nz))*5.
188.335 +
188.336 +;new eq
188.337 + bias = sum(abs(vv-uu)/(vv+uu))
188.338 + M = (1.- (bias/nz))*5.
188.339 + print (bias)
188.340 + print (M)
188.341 +
188.342 +end
188.343 +
189.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
189.2 +++ b/lai/26.histogram+bias_phase.ncl Mon Jan 26 22:08:20 2009 -0500
189.3 @@ -0,0 +1,341 @@
189.4 +;********************************************************
189.5 +; histogram normalized by rain and compute correleration
189.6 +;********************************************************
189.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
189.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
189.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
189.10 +
189.11 +procedure pminmax(data:numeric,name:string)
189.12 +begin
189.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
189.14 + if(isatt(data,"units")) then
189.15 + print (name + " units = " + data@units)
189.16 + end if
189.17 +end
189.18 +
189.19 +;
189.20 +; Main code.
189.21 +;
189.22 +begin
189.23 +
189.24 +;nclass = 18
189.25 + nclass = 20
189.26 +
189.27 +;************************************************
189.28 +; read in data: observed
189.29 +;************************************************
189.30 + diri1 = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
189.31 +;fili1 = "land_class_T42.nc"
189.32 + fili1 = "land_class_T42_new.nc"
189.33 + fili2 = "LAI_2000-2005_ensemble_T42.nc"
189.34 + data_file_ob1 = addfile(diri1+fili1,"r")
189.35 + data_file_ob2 = addfile(diri1+fili2,"r")
189.36 +
189.37 + RAIN1 = tofloat(data_file_ob1->LAND_CLASS)
189.38 +
189.39 + z = data_file_ob2->LAI
189.40 + y = z(0,:,:)
189.41 + y@long_name = "Leaf Area Index Max Month"
189.42 + s = z(:,0,0)
189.43 +
189.44 + dsizes_z = dimsizes(z)
189.45 + ntime = dsizes_z(0)
189.46 + nlat = dsizes_z(1)
189.47 + nlon = dsizes_z(2)
189.48 +
189.49 + do j = 0,nlat-1
189.50 + do i = 0,nlon-1
189.51 + s = z(:,j,i)
189.52 + y(j,i) = maxind(s) + 1
189.53 + end do
189.54 + end do
189.55 +
189.56 + print (min(y)+"/"+max(y))
189.57 +
189.58 + NPP1 = y
189.59 +
189.60 + delete (z)
189.61 + delete (s)
189.62 + delete (y)
189.63 +;************************************************
189.64 +; read in data: model
189.65 +;************************************************
189.66 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
189.67 +;fili3 = "i01.03cn_1545-1569_MONS_climo.nc"
189.68 + fili3 = "i01.04casa_1605-1629_MONS_climo.nc"
189.69 + data_file_model = addfile(diri2+fili3,"r")
189.70 +
189.71 + z = data_file_model->TLAI
189.72 + y = z(0,:,:)
189.73 + y@long_name = "Leaf Area Index Max Month"
189.74 + s = z(:,0,0)
189.75 +
189.76 + dsizes_z = dimsizes(z)
189.77 + ntime = dsizes_z(0)
189.78 + nlat = dsizes_z(1)
189.79 + nlon = dsizes_z(2)
189.80 +
189.81 + do j = 0,nlat-1
189.82 + do i = 0,nlon-1
189.83 + s = z(:,j,i)
189.84 + y(j,i) = maxind(s) + 1
189.85 + end do
189.86 + end do
189.87 +
189.88 + print (min(y)+"/"+max(y))
189.89 +
189.90 + NPP2 = y
189.91 +
189.92 + delete (z)
189.93 + delete (s)
189.94 + delete (y)
189.95 +;************************************************
189.96 +; print min/max and unit
189.97 +;************************************************
189.98 + pminmax(RAIN1,"RAIN1")
189.99 + pminmax(NPP1,"NPP1")
189.100 + pminmax(NPP2,"NPP2")
189.101 +
189.102 + RAIN1_1D = ndtooned(RAIN1)
189.103 + NPP1_1D = ndtooned(NPP1)
189.104 + NPP2_1D = ndtooned(NPP2)
189.105 +;
189.106 +; Calculate some "nice" bins for binning the data in equally spaced
189.107 +; ranges.
189.108 +;
189.109 +
189.110 +; nbins = nclass + 1 ; Number of bins to use.
189.111 +; nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,False)
189.112 +; nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
189.113 +; range = fspan(nicevals(0),nicevals(1),nvals)
189.114 +
189.115 + nclass = nclass + 1
189.116 + range = fspan(0,nclass-1,nclass)
189.117 +
189.118 +; print (nicevals)
189.119 +; print (nvals)
189.120 + print (range)
189.121 +; exit
189.122 +
189.123 +;
189.124 +; Use this range information to grab all the values in a
189.125 +; particular range, and then take an average.
189.126 +;
189.127 + nr = dimsizes(range)
189.128 + nx = nr-1
189.129 + xvalues = new((/2,nx/),typeof(RAIN1_1D))
189.130 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
189.131 + dx = xvalues(0,1) - xvalues(0,0) ; range width
189.132 + dx4 = dx/4 ; 1/4 of the range
189.133 + xvalues(1,:) = xvalues(0,:) - dx/5.
189.134 + yvalues = new((/2,nx/),typeof(RAIN1_1D))
189.135 + mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
189.136 + mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
189.137 +
189.138 + do nd=0,1
189.139 +;
189.140 +; See if we are doing model or observational data.
189.141 +;
189.142 + if(nd.eq.0) then
189.143 + data = RAIN1_1D
189.144 + npp_data = NPP1_1D
189.145 + else
189.146 + data = RAIN1_1D
189.147 + npp_data = NPP2_1D
189.148 + end if
189.149 +;
189.150 +; Loop through each range and check for values.
189.151 +;
189.152 + do i=0,nr-2
189.153 + if (i.ne.(nr-2)) then
189.154 + print("")
189.155 + print("In range ["+range(i)+","+range(i+1)+")")
189.156 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
189.157 + else
189.158 + print("")
189.159 + print("In range ["+range(i)+",)")
189.160 + idx = ind(range(i).le.data)
189.161 + end if
189.162 +;
189.163 +; Calculate average, and get min and max.
189.164 +;
189.165 + if(.not.any(ismissing(idx))) then
189.166 + yvalues(nd,i) = avg(npp_data(idx))
189.167 + mn_yvalues(nd,i) = min(npp_data(idx))
189.168 + mx_yvalues(nd,i) = max(npp_data(idx))
189.169 + count = dimsizes(idx)
189.170 + else
189.171 + count = 0
189.172 + yvalues(nd,i) = yvalues@_FillValue
189.173 + mn_yvalues(nd,i) = yvalues@_FillValue
189.174 + mx_yvalues(nd,i) = yvalues@_FillValue
189.175 + end if
189.176 +;
189.177 +; Print out information.
189.178 +;
189.179 + print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
189.180 + print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
189.181 +
189.182 +;
189.183 +; Clean up for next time in loop.
189.184 +;
189.185 + delete(idx)
189.186 + end do
189.187 + delete(data)
189.188 + delete(npp_data)
189.189 + end do
189.190 +
189.191 +;
189.192 +; Start the graphics.
189.193 +;
189.194 + wks = gsn_open_wks("ps","xy")
189.195 +
189.196 + res = True
189.197 + res@gsnMaximize = True
189.198 + res@gsnDraw = False
189.199 + res@gsnFrame = False
189.200 + res@xyMarkLineMode = "Markers"
189.201 + res@xyMarkerSizeF = 0.014
189.202 + res@xyMarker = 16
189.203 + res@xyMarkerColors = (/"Brown","Blue"/)
189.204 +; res@trYMinF = min(mn_yvalues) - 10.
189.205 +; res@trYMaxF = max(mx_yvalues) + 10.
189.206 + res@trYMinF = min(mn_yvalues) - 2
189.207 + res@trYMaxF = max(mx_yvalues) + 4
189.208 +
189.209 +; res@tiMainString = "Observed vs i01.03cn"
189.210 + res@tiMainString = "Observed vs i01.04casa"
189.211 +
189.212 + res@tiYAxisString = "Max LAI (Leaf Area Index) Month"
189.213 + res@tiXAxisString = "Land Cover Type"
189.214 +;
189.215 +; Add a boxed legend using the more simple method, which won't have
189.216 +; vertical lines going through the markers.
189.217 +;
189.218 + res@pmLegendDisplayMode = "Always"
189.219 +; res@pmLegendWidthF = 0.1
189.220 + res@pmLegendWidthF = 0.08
189.221 + res@pmLegendHeightF = 0.05
189.222 + res@pmLegendOrthogonalPosF = -1.17
189.223 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
189.224 +; res@pmLegendParallelPosF = 0.18
189.225 + res@pmLegendParallelPosF = 0.23 ;(rightward)
189.226 +
189.227 +; res@lgPerimOn = False
189.228 + res@lgLabelFontHeightF = 0.015
189.229 +; res@xyExplicitLegendLabels = (/"observed","model_i01.03cn"/)
189.230 + res@xyExplicitLegendLabels = (/"observed","model_i01.04casa"/)
189.231 +
189.232 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
189.233 +
189.234 + max_bar = new((/2,nx/),graphic)
189.235 + min_bar = new((/2,nx/),graphic)
189.236 + max_cap = new((/2,nx/),graphic)
189.237 + min_cap = new((/2,nx/),graphic)
189.238 +
189.239 + lnres = True
189.240 +
189.241 + line_colors = (/"brown","blue"/)
189.242 + do nd=0,1
189.243 + lnres@gsLineColor = line_colors(nd)
189.244 + do i=0,nx-1
189.245 +
189.246 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
189.247 + .not.ismissing(mx_yvalues(nd,i))) then
189.248 +;
189.249 +; Attach the vertical bar, both above and below the marker.
189.250 +;
189.251 + x1 = xvalues(nd,i)
189.252 + y1 = yvalues(nd,i)
189.253 + y2 = mn_yvalues(nd,i)
189.254 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
189.255 +
189.256 + y2 = mx_yvalues(nd,i)
189.257 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
189.258 +;
189.259 +; Attach the horizontal cap line, both above and below the marker.
189.260 +;
189.261 + x1 = xvalues(nd,i) - dx4
189.262 + x2 = xvalues(nd,i) + dx4
189.263 + y1 = mn_yvalues(nd,i)
189.264 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
189.265 +
189.266 + y1 = mx_yvalues(nd,i)
189.267 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
189.268 + end if
189.269 + end do
189.270 + end do
189.271 +
189.272 +;
189.273 +; Here's how to do the legend by hand.
189.274 +;
189.275 +; mkres = True ; Marker resources
189.276 +; txres = True ; Text resources
189.277 +; mkres@gsMarkerIndex = 16
189.278 +; mkres@gsMarkerSizeF = 0.02
189.279 +; txres@txFontHeightF = 0.02
189.280 +; txres@txJust = "CenterLeft"
189.281 +;
189.282 +; Change these values if you want to move the marker legend location.
189.283 +; These values are in the same data space as the plot.
189.284 +;
189.285 +; xlg1_cen = 0.2
189.286 +; ylg1_cen = 900.
189.287 +
189.288 +; xlg2_cen = 0.2
189.289 +; ylg2_cen = 760.
189.290 +
189.291 +; mkres@gsMarkerColor = "brown"
189.292 +; lnres@gsLineColor = "brown"
189.293 +
189.294 +; lg_mark_legend1 = gsn_add_polymarker(wks,xy,xlg1_cen,ylg1_cen,mkres)
189.295 +; lg_line_legend1 = gsn_add_polyline(wks,xy,(/xlg1_cen,xlg1_cen/), \
189.296 +; (/ylg1_cen-60,ylg1_cen+60/),lnres)
189.297 +; lg_cap_legend11 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
189.298 +; (/ylg1_cen-60,ylg1_cen-60/),lnres)
189.299 +; lg_cap_legend12 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
189.300 +; (/ylg1_cen+60,ylg1_cen+60/),lnres)
189.301 +
189.302 +; tx_legend1 = gsn_add_text(wks,xy,"observed",xlg1_cen+0.15,ylg1_cen,txres)
189.303 +
189.304 +; mkres@gsMarkerColor = "blue"
189.305 +; lnres@gsLineColor = "blue"
189.306 +
189.307 +; lg_mark_legend2 = gsn_add_polymarker(wks,xy,xlg2_cen,ylg2_cen,mkres)
189.308 +; lg_line_legend2 = gsn_add_polyline(wks,xy,(/xlg2_cen,xlg2_cen/), \
189.309 +; (/ylg2_cen-60,ylg2_cen+60/),lnres)
189.310 +; lg_cap_legend21 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
189.311 +; (/ylg2_cen-60,ylg2_cen-60/),lnres)
189.312 +; lg_cap_legend22 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
189.313 +; (/ylg2_cen+60,ylg2_cen+60/),lnres)
189.314 +; tx_legend2 = gsn_add_text(wks,xy,"model_i01.03cn",xlg2_cen+0.15,ylg2_cen,txres)
189.315 +
189.316 + draw(xy)
189.317 + frame(wks)
189.318 + system("convert xy.ps xy.png")
189.319 +
189.320 + u = yvalues(0,:)
189.321 + v = yvalues(1,:)
189.322 +
189.323 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
189.324 + uu = u(good)
189.325 + vv = v(good)
189.326 + nz = dimsizes(uu)
189.327 + print (nz)
189.328 +
189.329 + ccr = esccr(uu,vv,0)
189.330 + print (ccr)
189.331 +
189.332 +;old eq
189.333 +;bias = sum(((vv-uu)/uu)^2)
189.334 +;M = (1.- sqrt(bias/nz))*5.
189.335 +
189.336 +;new eq
189.337 + bias = abs(avg(vv)-avg(uu))
189.338 + bias = where((bias.gt. 6.),12.-bias,bias)
189.339 + M = ((6. - bias)/6.)*5.
189.340 + print (bias)
189.341 + print (M)
189.342 +
189.343 +end
189.344 +
190.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
190.2 +++ b/lai/27.histogram+bias_grow.ncl Mon Jan 26 22:08:20 2009 -0500
190.3 @@ -0,0 +1,347 @@
190.4 +;********************************************************
190.5 +; histogram normalized by rain and compute correleration
190.6 +;********************************************************
190.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
190.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
190.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
190.10 +
190.11 +procedure pminmax(data:numeric,name:string)
190.12 +begin
190.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
190.14 + if(isatt(data,"units")) then
190.15 + print (name + " units = " + data@units)
190.16 + end if
190.17 +end
190.18 +
190.19 +;
190.20 +; Main code.
190.21 +;
190.22 +begin
190.23 +
190.24 +;nclass = 18
190.25 + nclass = 20
190.26 + day_of_data = (/31,28,31,30,31,30,31,31,30,31,30,31/)
190.27 +
190.28 +;************************************************
190.29 +; read in data: observed
190.30 +;************************************************
190.31 + diri1 = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
190.32 +;fili1 = "land_class_T42.nc"
190.33 + fili1 = "land_class_T42_new.nc"
190.34 + fili2 = "LAI_2000-2005_ensemble_T42.nc"
190.35 + data_file_ob1 = addfile(diri1+fili1,"r")
190.36 + data_file_ob2 = addfile(diri1+fili2,"r")
190.37 +
190.38 + RAIN1 = tofloat(data_file_ob1->LAND_CLASS)
190.39 +
190.40 + z = data_file_ob2->LAI
190.41 + y = z(0,:,:)
190.42 + y@long_name = "Days of Growing Season"
190.43 +
190.44 + dsizes_z = dimsizes(z)
190.45 + ntime = dsizes_z(0)
190.46 + nlat = dsizes_z(1)
190.47 + nlon = dsizes_z(2)
190.48 +
190.49 + do j = 0,nlat-1
190.50 + do i = 0,nlon-1
190.51 + nday = 0.
190.52 + do k = 0,ntime-1
190.53 + if (.not. ismissing(z(k,j,i)) .and. z(k,j,i) .gt. 1.0) then
190.54 + nday = nday + day_of_data(k)
190.55 + end if
190.56 + end do
190.57 + y(j,i) = nday
190.58 + end do
190.59 + end do
190.60 +
190.61 + print (min(y)+"/"+max(y))
190.62 +
190.63 + NPP1 = y
190.64 +
190.65 + delete (z)
190.66 + delete (y)
190.67 +;************************************************
190.68 +; read in data: model
190.69 +;************************************************
190.70 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
190.71 +;fili3 = "i01.03cn_1545-1569_MONS_climo.nc"
190.72 + fili3 = "i01.04casa_1605-1629_MONS_climo.nc"
190.73 + data_file_model = addfile(diri2+fili3,"r")
190.74 +
190.75 + z = data_file_model->TLAI
190.76 + y = z(0,:,:)
190.77 + y@long_name = "Days of Growing Season"
190.78 +
190.79 + dsizes_z = dimsizes(z)
190.80 + ntime = dsizes_z(0)
190.81 + nlat = dsizes_z(1)
190.82 + nlon = dsizes_z(2)
190.83 +
190.84 + do j = 0,nlat-1
190.85 + do i = 0,nlon-1
190.86 + nday = 0.
190.87 + do k = 0,ntime-1
190.88 + if (.not. ismissing(z(k,j,i)) .and. z(k,j,i) .gt. 1.0) then
190.89 + nday = nday + day_of_data(k)
190.90 + end if
190.91 + end do
190.92 + y(j,i) = nday
190.93 + end do
190.94 + end do
190.95 +
190.96 + print (min(y)+"/"+max(y))
190.97 +
190.98 + NPP2 = y
190.99 +
190.100 + delete (z)
190.101 + delete (y)
190.102 +;************************************************
190.103 +; print min/max and unit
190.104 +;************************************************
190.105 + pminmax(RAIN1,"RAIN1")
190.106 + pminmax(NPP1,"NPP1")
190.107 + pminmax(NPP2,"NPP2")
190.108 +
190.109 + RAIN1_1D = ndtooned(RAIN1)
190.110 + NPP1_1D = ndtooned(NPP1)
190.111 + NPP2_1D = ndtooned(NPP2)
190.112 +;
190.113 +; Calculate some "nice" bins for binning the data in equally spaced
190.114 +; ranges.
190.115 +;
190.116 +
190.117 +; nbins = nclass + 1 ; Number of bins to use.
190.118 +; nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,False)
190.119 +; nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
190.120 +; range = fspan(nicevals(0),nicevals(1),nvals)
190.121 +
190.122 + nclass = nclass + 1
190.123 + range = fspan(0,nclass-1,nclass)
190.124 +
190.125 +; print (nicevals)
190.126 +; print (nvals)
190.127 + print (range)
190.128 +; exit
190.129 +
190.130 +;
190.131 +; Use this range information to grab all the values in a
190.132 +; particular range, and then take an average.
190.133 +;
190.134 + nr = dimsizes(range)
190.135 + nx = nr-1
190.136 + xvalues = new((/2,nx/),typeof(RAIN1_1D))
190.137 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
190.138 + dx = xvalues(0,1) - xvalues(0,0) ; range width
190.139 + dx4 = dx/4 ; 1/4 of the range
190.140 + xvalues(1,:) = xvalues(0,:) - dx/5.
190.141 + yvalues = new((/2,nx/),typeof(RAIN1_1D))
190.142 + mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
190.143 + mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
190.144 +
190.145 + do nd=0,1
190.146 +;
190.147 +; See if we are doing model or observational data.
190.148 +;
190.149 + if(nd.eq.0) then
190.150 + data = RAIN1_1D
190.151 + npp_data = NPP1_1D
190.152 + else
190.153 + data = RAIN1_1D
190.154 + npp_data = NPP2_1D
190.155 + end if
190.156 +;
190.157 +; Loop through each range and check for values.
190.158 +;
190.159 + do i=0,nr-2
190.160 + if (i.ne.(nr-2)) then
190.161 + print("")
190.162 + print("In range ["+range(i)+","+range(i+1)+")")
190.163 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
190.164 + else
190.165 + print("")
190.166 + print("In range ["+range(i)+",)")
190.167 + idx = ind(range(i).le.data)
190.168 + end if
190.169 +;
190.170 +; Calculate average, and get min and max.
190.171 +;
190.172 + if(.not.any(ismissing(idx))) then
190.173 + yvalues(nd,i) = avg(npp_data(idx))
190.174 + mn_yvalues(nd,i) = min(npp_data(idx))
190.175 + mx_yvalues(nd,i) = max(npp_data(idx))
190.176 + count = dimsizes(idx)
190.177 + else
190.178 + count = 0
190.179 + yvalues(nd,i) = yvalues@_FillValue
190.180 + mn_yvalues(nd,i) = yvalues@_FillValue
190.181 + mx_yvalues(nd,i) = yvalues@_FillValue
190.182 + end if
190.183 +;
190.184 +; Print out information.
190.185 +;
190.186 + print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
190.187 + print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
190.188 +
190.189 +;
190.190 +; Clean up for next time in loop.
190.191 +;
190.192 + delete(idx)
190.193 + end do
190.194 + delete(data)
190.195 + delete(npp_data)
190.196 + end do
190.197 +
190.198 +;
190.199 +; Start the graphics.
190.200 +;
190.201 + wks = gsn_open_wks("ps","xy")
190.202 +
190.203 + res = True
190.204 + res@gsnMaximize = True
190.205 + res@gsnDraw = False
190.206 + res@gsnFrame = False
190.207 + res@xyMarkLineMode = "Markers"
190.208 + res@xyMarkerSizeF = 0.014
190.209 + res@xyMarker = 16
190.210 + res@xyMarkerColors = (/"Brown","Blue"/)
190.211 +; res@trYMinF = min(mn_yvalues) - 10.
190.212 +; res@trYMaxF = max(mx_yvalues) + 10.
190.213 + res@trYMinF = min(mn_yvalues) - 20.
190.214 + res@trYMaxF = max(mx_yvalues) + 100.
190.215 +
190.216 +; res@tiMainString = "Observed vs i01.03cn"
190.217 + res@tiMainString = "Observed vs i01.04casa"
190.218 +
190.219 + res@tiYAxisString = "Days of Growing season"
190.220 + res@tiXAxisString = "Land Cover Type"
190.221 +;
190.222 +; Add a boxed legend using the more simple method, which won't have
190.223 +; vertical lines going through the markers.
190.224 +;
190.225 + res@pmLegendDisplayMode = "Always"
190.226 +; res@pmLegendWidthF = 0.1
190.227 + res@pmLegendWidthF = 0.08
190.228 + res@pmLegendHeightF = 0.05
190.229 + res@pmLegendOrthogonalPosF = -1.17
190.230 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
190.231 +; res@pmLegendParallelPosF = 0.18
190.232 + res@pmLegendParallelPosF = 0.23 ;(rightward)
190.233 +
190.234 +; res@lgPerimOn = False
190.235 + res@lgLabelFontHeightF = 0.015
190.236 +; res@xyExplicitLegendLabels = (/"observed","model_i01.03cn"/)
190.237 + res@xyExplicitLegendLabels = (/"observed","model_i01.04casa"/)
190.238 +
190.239 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
190.240 +
190.241 + max_bar = new((/2,nx/),graphic)
190.242 + min_bar = new((/2,nx/),graphic)
190.243 + max_cap = new((/2,nx/),graphic)
190.244 + min_cap = new((/2,nx/),graphic)
190.245 +
190.246 + lnres = True
190.247 +
190.248 + line_colors = (/"brown","blue"/)
190.249 + do nd=0,1
190.250 + lnres@gsLineColor = line_colors(nd)
190.251 + do i=0,nx-1
190.252 +
190.253 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
190.254 + .not.ismissing(mx_yvalues(nd,i))) then
190.255 +;
190.256 +; Attach the vertical bar, both above and below the marker.
190.257 +;
190.258 + x1 = xvalues(nd,i)
190.259 + y1 = yvalues(nd,i)
190.260 + y2 = mn_yvalues(nd,i)
190.261 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
190.262 +
190.263 + y2 = mx_yvalues(nd,i)
190.264 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
190.265 +;
190.266 +; Attach the horizontal cap line, both above and below the marker.
190.267 +;
190.268 + x1 = xvalues(nd,i) - dx4
190.269 + x2 = xvalues(nd,i) + dx4
190.270 + y1 = mn_yvalues(nd,i)
190.271 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
190.272 +
190.273 + y1 = mx_yvalues(nd,i)
190.274 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
190.275 + end if
190.276 + end do
190.277 + end do
190.278 +
190.279 +;
190.280 +; Here's how to do the legend by hand.
190.281 +;
190.282 +; mkres = True ; Marker resources
190.283 +; txres = True ; Text resources
190.284 +; mkres@gsMarkerIndex = 16
190.285 +; mkres@gsMarkerSizeF = 0.02
190.286 +; txres@txFontHeightF = 0.02
190.287 +; txres@txJust = "CenterLeft"
190.288 +;
190.289 +; Change these values if you want to move the marker legend location.
190.290 +; These values are in the same data space as the plot.
190.291 +;
190.292 +; xlg1_cen = 0.2
190.293 +; ylg1_cen = 900.
190.294 +
190.295 +; xlg2_cen = 0.2
190.296 +; ylg2_cen = 760.
190.297 +
190.298 +; mkres@gsMarkerColor = "brown"
190.299 +; lnres@gsLineColor = "brown"
190.300 +
190.301 +; lg_mark_legend1 = gsn_add_polymarker(wks,xy,xlg1_cen,ylg1_cen,mkres)
190.302 +; lg_line_legend1 = gsn_add_polyline(wks,xy,(/xlg1_cen,xlg1_cen/), \
190.303 +; (/ylg1_cen-60,ylg1_cen+60/),lnres)
190.304 +; lg_cap_legend11 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
190.305 +; (/ylg1_cen-60,ylg1_cen-60/),lnres)
190.306 +; lg_cap_legend12 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
190.307 +; (/ylg1_cen+60,ylg1_cen+60/),lnres)
190.308 +
190.309 +; tx_legend1 = gsn_add_text(wks,xy,"observed",xlg1_cen+0.15,ylg1_cen,txres)
190.310 +
190.311 +; mkres@gsMarkerColor = "blue"
190.312 +; lnres@gsLineColor = "blue"
190.313 +
190.314 +; lg_mark_legend2 = gsn_add_polymarker(wks,xy,xlg2_cen,ylg2_cen,mkres)
190.315 +; lg_line_legend2 = gsn_add_polyline(wks,xy,(/xlg2_cen,xlg2_cen/), \
190.316 +; (/ylg2_cen-60,ylg2_cen+60/),lnres)
190.317 +; lg_cap_legend21 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
190.318 +; (/ylg2_cen-60,ylg2_cen-60/),lnres)
190.319 +; lg_cap_legend22 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
190.320 +; (/ylg2_cen+60,ylg2_cen+60/),lnres)
190.321 +; tx_legend2 = gsn_add_text(wks,xy,"model_i01.03cn",xlg2_cen+0.15,ylg2_cen,txres)
190.322 +
190.323 + draw(xy)
190.324 + frame(wks)
190.325 + system("convert xy.ps xy.png")
190.326 +
190.327 + u = yvalues(0,:)
190.328 + v = yvalues(1,:)
190.329 +
190.330 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
190.331 + uu = u(good)
190.332 + vv = v(good)
190.333 + nz = dimsizes(uu)
190.334 + print (nz)
190.335 +
190.336 + ccr = esccr(uu,vv,0)
190.337 + print (ccr)
190.338 +;old eq
190.339 +;bias = sum(((vv-uu)/uu)^2)
190.340 +;M = (1.- sqrt(bias/nz))*5.
190.341 +
190.342 +;new eq
190.343 + bias = sum(abs(vv-uu)/(vv+uu))
190.344 + M = (1.- (bias/nz))*5.
190.345 +
190.346 + print (bias)
190.347 + print (M)
190.348 +
190.349 +end
190.350 +
191.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
191.2 +++ b/lai/31.contour_model.ncl Mon Jan 26 22:08:20 2009 -0500
191.3 @@ -0,0 +1,47 @@
191.4 +;*************************************************
191.5 +; ce_1.ncl
191.6 +;************************************************
191.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
191.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
191.9 +;************************************************
191.10 +begin
191.11 +;************************************************
191.12 +; read in model data
191.13 +;************************************************
191.14 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
191.15 + fili = "i01.03cn_1545-1569_ANN_climo.nc"
191.16 +; fili = "i01.04casa_1605-1629_ANN_climo.nc"
191.17 +
191.18 + g = addfile(diri+fili,"r")
191.19 + x = g->TLAI
191.20 + print (max(x))
191.21 + print (min(x))
191.22 +
191.23 +;************************************************
191.24 +; create default plot
191.25 +;************************************************
191.26 +
191.27 + wks = gsn_open_wks("ps","xy") ; open a ps file
191.28 +; gsn_define_colormap(wks,"wgne15") ; choose colormap
191.29 + gsn_define_colormap(wks,"gui_default") ; choose colormap
191.30 +
191.31 + res = True ; Use plot options
191.32 + res@cnFillOn = True ; Turn on color fill
191.33 + res@gsnSpreadColors = True ; use full colormap
191.34 +; res@cnFillMode = "RasterFill" ; Turn on raster color
191.35 +; res@lbLabelAutoStride = True
191.36 + res@cnLinesOn = False ; Turn off contourn lines
191.37 + res@mpFillOn = False ; Turn off map fill
191.38 +; res@tiMainString = "Observed MODIS MOD 15A2"
191.39 + res@tiMainString = "Model i01.03cn"
191.40 +; res@tiMainString = "Model i01.04casa"
191.41 +
191.42 + res@gsnSpreadColors = True ; use full colormap
191.43 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
191.44 + res@cnMinLevelValF = 0. ; Min level
191.45 + res@cnMaxLevelValF = 10. ; Max level
191.46 + res@cnLevelSpacingF = 1. ; interval
191.47 +
191.48 + plot = gsn_csm_contour_map_ce(wks,x(0,:,:),res) ; for model
191.49 + system("convert xy.ps xy.png")
191.50 +end
191.51 \ No newline at end of file
192.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
192.2 +++ b/lai/31.contour_ob_grow.ncl Mon Jan 26 22:08:20 2009 -0500
192.3 @@ -0,0 +1,81 @@
192.4 +;*************************************************
192.5 +; ce_1.ncl
192.6 +;************************************************
192.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
192.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
192.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
192.10 +;************************************************
192.11 +begin
192.12 +;************************************************
192.13 +; read in observed data
192.14 +;************************************************
192.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
192.16 + fili = "LAI_2000-2005_ensemble_T42.nc"
192.17 + f = addfile(diri+fili,"r")
192.18 +
192.19 + z = f->LAI
192.20 + y = z(0,:,:)
192.21 + y@long_name = "Days of Growing Season"
192.22 +
192.23 + dsizes_z = dimsizes(z)
192.24 + ntime = dsizes_z(0)
192.25 + nlat = dsizes_z(1)
192.26 + nlon = dsizes_z(2)
192.27 +
192.28 + day_of_data = (/31,28,31,30,31,30,31,31,30,31,30,31/)
192.29 +
192.30 + do j = 0,nlat-1
192.31 + do i = 0,nlon-1
192.32 + nday = 0.
192.33 + do k = 0,ntime-1
192.34 + if (.not. ismissing(z(k,j,i)) .and. z(k,j,i) .gt. 1.0) then
192.35 + nday = nday + day_of_data(k)
192.36 + end if
192.37 + end do
192.38 + y(j,i) = nday
192.39 + end do
192.40 + end do
192.41 +
192.42 + print (min(y)+"/"+max(y))
192.43 +
192.44 +;************************************************
192.45 +; read in model data
192.46 +;************************************************
192.47 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
192.48 + fili2 = "i01.03cn_1545-1569_ANN_climo.nc"
192.49 + g = addfile(diri2+fili2,"r")
192.50 + x = g->TLAI
192.51 +
192.52 + delta = 0.000001
192.53 + x0 = x(0,:,:)
192.54 + y = where(ismissing(y).and.(ismissing(x0).or.(x0.lt.delta)),y@_FillValue,y)
192.55 +;************************************************
192.56 +; create default plot
192.57 +;************************************************
192.58 +
192.59 + wks = gsn_open_wks("ps","xy") ; open a ps file
192.60 + gsn_define_colormap(wks,"gui_default") ; choose colormap
192.61 +
192.62 + res = True ; Use plot options
192.63 + res@cnFillOn = True ; Turn on color fill
192.64 + res@gsnSpreadColors = True ; use full colormap
192.65 +; res@cnFillMode = "RasterFill" ; Turn on raster color
192.66 +; res@lbLabelAutoStride = True
192.67 + res@cnLinesOn = False ; Turn off contourn lines
192.68 + res@mpFillOn = False ; Turn off map fill
192.69 + res@tiMainString = "MODIS MOD 15A2 2000-2005"
192.70 +
192.71 + res@gsnSpreadColors = True ; use full colormap
192.72 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
192.73 + res@cnMinLevelValF = 0. ; Min level
192.74 + res@cnMaxLevelValF = 390. ; Max level
192.75 + res@cnLevelSpacingF = 30. ; interval
192.76 +
192.77 +; pres = True ; panel plot mods desired
192.78 +; pres@gsnMaximize = True ; fill the page
192.79 +
192.80 + plot = gsn_csm_contour_map_ce(wks,y,res) ; for observed
192.81 +
192.82 +; gsn_panel(wks,plot,(/1,1/),pres) ; create panel plot
192.83 + system("convert xy.ps xy.png")
192.84 +end
192.85 \ No newline at end of file
193.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
193.2 +++ b/lai/31.contour_ob_lai_max.ncl.1 Mon Jan 26 22:08:20 2009 -0500
193.3 @@ -0,0 +1,95 @@
193.4 +;*************************************************
193.5 +; ce_1.ncl
193.6 +;************************************************
193.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
193.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
193.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
193.10 +;************************************************
193.11 +begin
193.12 +;************************************************
193.13 +; read in observed data
193.14 +;************************************************
193.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
193.16 +; fili = "LAI_2000-2005_ensemble_T42.nc"
193.17 + fili = "2000-2005_ensemble_T42.nc"
193.18 + f = addfile(diri+fili,"r")
193.19 +
193.20 + z = f->LAI
193.21 + y = z(0,:,:)
193.22 + y@long_name = "Leaf Area Index Max"
193.23 + p = z(0,:,:)
193.24 + p@long_name = "Leaf Area Index Max Month"
193.25 + s = z(:,0,0)
193.26 +; printVarSummary(s)
193.27 +
193.28 + dsizes_z = dimsizes(z)
193.29 + ntime = dsizes_z(0)
193.30 + nlat = dsizes_z(1)
193.31 + nlon = dsizes_z(2)
193.32 +
193.33 + do j = 0,nlat-1
193.34 + do i = 0,nlon-1
193.35 + s = z(:,j,i)
193.36 + y(j,i) = max(s)
193.37 + p(j,i) = maxind(s)+ 1
193.38 +
193.39 +; iMax = ind(s.eq.y(j,i)) + 1 ; may be multiple max
193.40 +; if (.not.ismissing(iMax(0))) then
193.41 +; p(j,i) = iMax(0) ; no meta data
193.42 +; end if
193.43 +; delete(iMax)
193.44 +
193.45 + end do
193.46 + end do
193.47 +
193.48 +; printVarSummary(p)
193.49 + print (min(y)+"/"+max(y))
193.50 + print (min(p)+"/"+max(p))
193.51 +exit
193.52 +;************************************************
193.53 +; read in model data
193.54 +;************************************************
193.55 + fili2 = "i01.03cn_1545-1569_ANN_climo.nc"
193.56 + g = addfile(diri+fili2,"r")
193.57 + x = g->TLAI
193.58 +
193.59 + delta = 0.00000000001
193.60 + x0 = x(0,:,:)
193.61 + y = where(ismissing(y).and.(ismissing(x0).or.(x0.lt.delta)),0.,y)
193.62 +;************************************************
193.63 +; create default plot
193.64 +;************************************************
193.65 +
193.66 +; setvalues NhlGetWorkspaceObjectId()
193.67 +; "wsMaximumSize" : 199999999
193.68 +; end setvalues
193.69 +
193.70 + wks = gsn_open_wks("ps","xy") ; open a ps file
193.71 +; gsn_define_colormap(wks,"wgne15") ; choose colormap
193.72 + gsn_define_colormap(wks,"gui_default") ; choose colormap
193.73 +
193.74 + res = True ; Use plot options
193.75 + res@cnFillOn = True ; Turn on color fill
193.76 + res@gsnSpreadColors = True ; use full colormap
193.77 +; res@cnFillMode = "RasterFill" ; Turn on raster color
193.78 +; res@lbLabelAutoStride = True
193.79 + res@cnLinesOn = False ; Turn off contourn lines
193.80 + res@mpFillOn = False ; Turn off map fill
193.81 + res@tiMainString = "MODIS MOD 15A2 2000-2005"
193.82 +
193.83 + res@gsnSpreadColors = True ; use full colormap
193.84 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
193.85 + res@cnMinLevelValF = 0. ; Min level
193.86 + res@cnMaxLevelValF = 12. ; Max level
193.87 + res@cnLevelSpacingF = 1. ; interval
193.88 +
193.89 +; pres = True ; panel plot mods desired
193.90 +; pres@gsnMaximize = True ; fill the page
193.91 +
193.92 + plot = gsn_csm_contour_map_ce(wks,y,res) ; for observed
193.93 +
193.94 + plot = gsn_csm_contour_map_ce(wks,p,res) ; for observed
193.95 +
193.96 +; gsn_panel(wks,plot,(/1,1/),pres) ; create panel plot
193.97 + system("convert xy.ps xy.png")
193.98 +end
193.99 \ No newline at end of file
194.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
194.2 +++ b/lai/31.contour_ob_max.ncl Mon Jan 26 22:08:20 2009 -0500
194.3 @@ -0,0 +1,98 @@
194.4 +;*************************************************
194.5 +; ce_1.ncl
194.6 +;************************************************
194.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
194.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
194.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
194.10 +;************************************************
194.11 +begin
194.12 +;************************************************
194.13 +; read in observed data
194.14 +;************************************************
194.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
194.16 + fili = "LAI_2000-2005_ensemble_T42.nc"
194.17 +; fili = "LAI_2000_monthly_T42.nc"
194.18 + f = addfile(diri+fili,"r")
194.19 +
194.20 + z = f->LAI
194.21 + y = z(0,:,:)
194.22 + y@long_name = "Leaf Area Index Max"
194.23 + p = z(0,:,:)
194.24 + p@long_name = "Leaf Area Index Max Month"
194.25 + s = z(:,0,0)
194.26 +; printVarSummary(s)
194.27 +
194.28 + dsizes_z = dimsizes(z)
194.29 + ntime = dsizes_z(0)
194.30 + nlat = dsizes_z(1)
194.31 + nlon = dsizes_z(2)
194.32 +
194.33 + do j = 0,nlat-1
194.34 + do i = 0,nlon-1
194.35 + s = z(:,j,i)
194.36 + y(j,i) = max(s)
194.37 + p(j,i) = maxind(s)+ 1
194.38 +
194.39 +; iMax = ind(s.eq.y(j,i)) + 1 ; may be multiple max
194.40 +; if (.not.ismissing(iMax(0))) then
194.41 +; p(j,i) = iMax(0) ; no meta data
194.42 +; end if
194.43 +; delete(iMax)
194.44 +
194.45 + end do
194.46 + end do
194.47 +
194.48 +; printVarSummary(p)
194.49 + print (min(y)+"/"+max(y))
194.50 + print (min(p)+"/"+max(p))
194.51 +
194.52 +;************************************************
194.53 +; read in model data
194.54 +;************************************************
194.55 + fili2 = "i01.03cn_1545-1569_ANN_climo.nc"
194.56 + g = addfile(diri+fili2,"r")
194.57 + x = g->TLAI
194.58 +
194.59 + delta = 0.00000000001
194.60 + x0 = x(0,:,:)
194.61 + y = where(ismissing(y).and.(ismissing(x0).or.(x0.lt.delta)),0.,y)
194.62 +;************************************************
194.63 +; create default plot
194.64 +;************************************************
194.65 +
194.66 +; setvalues NhlGetWorkspaceObjectId()
194.67 +; "wsMaximumSize" : 199999999
194.68 +; end setvalues
194.69 +
194.70 + wks = gsn_open_wks("ps","xy") ; open a ps file
194.71 +; gsn_define_colormap(wks,"wgne15") ; choose colormap
194.72 + gsn_define_colormap(wks,"gui_default") ; choose colormap
194.73 +
194.74 + res = True ; Use plot options
194.75 + res@cnFillOn = True ; Turn on color fill
194.76 + res@gsnSpreadColors = True ; use full colormap
194.77 +; res@cnFillMode = "RasterFill" ; Turn on raster color
194.78 +; res@lbLabelAutoStride = True
194.79 + res@cnLinesOn = False ; Turn off contourn lines
194.80 + res@mpFillOn = False ; Turn off map fill
194.81 + res@tiMainString = "MODIS MOD 15A2 2000-2005"
194.82 +
194.83 + res@gsnSpreadColors = True ; use full colormap
194.84 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
194.85 + res@cnMinLevelValF = 0. ; Min level
194.86 + res@cnMaxLevelValF = 10. ; Max level
194.87 + res@cnLevelSpacingF = 1. ; interval
194.88 +
194.89 +; pres = True ; panel plot mods desired
194.90 +; pres@gsnMaximize = True ; fill the page
194.91 +
194.92 + plot = gsn_csm_contour_map_ce(wks,y,res) ; for observed
194.93 +
194.94 + res@cnMinLevelValF = 1. ; Min level
194.95 + res@cnMaxLevelValF = 12. ; Max level
194.96 + res@cnLevelSpacingF = 1. ; interval
194.97 + plot = gsn_csm_contour_map_ce(wks,p,res) ; for observed
194.98 +
194.99 +; gsn_panel(wks,plot,(/1,1/),pres) ; create panel plot
194.100 + system("convert xy.ps xy.png")
194.101 +end
194.102 \ No newline at end of file
195.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
195.2 +++ b/lai/31.contour_ob_mean.ncl Mon Jan 26 22:08:20 2009 -0500
195.3 @@ -0,0 +1,65 @@
195.4 +;*************************************************
195.5 +; ce_1.ncl
195.6 +;************************************************
195.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
195.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
195.9 +;************************************************
195.10 +begin
195.11 +;************************************************
195.12 +; read in observed data
195.13 +;************************************************
195.14 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
195.15 + fili = "LAI_2000-2005_mean_T42.nc"
195.16 + f = addfile(diri+fili,"r")
195.17 +
195.18 + y = f->LAI
195.19 + printVarSummary(y)
195.20 +
195.21 + print (min(y)+"/"+max(y))
195.22 +
195.23 +;************************************************
195.24 +; read in model data
195.25 +;************************************************
195.26 + fili2 = "i01.03cn_1545-1569_ANN_climo.nc"
195.27 + g = addfile(diri+fili2,"r")
195.28 + x = g->LAISUN
195.29 +
195.30 + delta = 0.0000001
195.31 + x0 = x(0,:,:)
195.32 + y = where(ismissing(y).and.(ismissing(x0).or.(x0.lt.delta)),0.,y)
195.33 +; y = where((y.gt.1000.),1.e+36,y)
195.34 + printVarSummary(y)
195.35 + print (min(y)+"/"+max(y))
195.36 +;************************************************
195.37 +; create default plot
195.38 +;************************************************
195.39 +
195.40 +; setvalues NhlGetWorkspaceObjectId()
195.41 +; "wsMaximumSize" : 199999999
195.42 +; end setvalues
195.43 +
195.44 + wks = gsn_open_wks("ps","xy") ; open a ps file
195.45 +; gsn_define_colormap(wks,"wgne15") ; choose colormap
195.46 + gsn_define_colormap(wks,"gui_default") ; choose colormap
195.47 +
195.48 + res = True ; Use plot options
195.49 + res@cnFillOn = True ; Turn on color fill
195.50 + res@gsnSpreadColors = True ; use full colormap
195.51 +; res@cnFillMode = "RasterFill" ; Turn on raster color
195.52 +; res@lbLabelAutoStride = True
195.53 + res@cnLinesOn = False ; Turn off contourn lines
195.54 + res@mpFillOn = False ; Turn off map fill
195.55 + res@tiMainString = "MODIS MOD 15A2 2000-2005"
195.56 +
195.57 + res@gsnSpreadColors = True ; use full colormap
195.58 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
195.59 + res@cnMinLevelValF = 0. ; Min level
195.60 + res@cnMaxLevelValF = 10. ; Max level
195.61 + res@cnLevelSpacingF = 1. ; interval
195.62 + pres = True ; panel plot mods desired
195.63 + pres@gsnMaximize = True ; fill the page
195.64 +
195.65 + plot = gsn_csm_contour_map_ce(wks,y,res) ; for observed
195.66 + gsn_panel(wks,plot,(/1,1/),pres) ; create panel plot
195.67 + system("convert xy.ps xy.png")
195.68 +end
195.69 \ No newline at end of file
196.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
196.2 +++ b/lai/32.contour_diff.ncl Mon Jan 26 22:08:20 2009 -0500
196.3 @@ -0,0 +1,87 @@
196.4 +;*************************************************
196.5 +; ce_1.ncl
196.6 +;************************************************
196.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
196.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
196.9 +;************************************************
196.10 +begin
196.11 +;************************************************
196.12 +; read in observed data
196.13 +;************************************************
196.14 + f = addfile ("Npp_T42_mean.nc","r")
196.15 + y = f->NPP
196.16 +;************************************************
196.17 +; read in model data
196.18 +;************************************************
196.19 + g = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
196.20 +;g = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
196.21 + x = g->NPP
196.22 +
196.23 + nsec_per_year = 86400.*365.
196.24 + x = x * nsec_per_year
196.25 +
196.26 + x@units = "gC/m^2/year"
196.27 +;************************************************
196.28 +;fill ob missing grid the same as model
196.29 +;************************************************
196.30 + delta = 0.00001
196.31 + x0 = x(0,:,:)
196.32 + y = where(ismissing(y).and.(ismissing(x0).or.(x0.lt.delta)),0.,y)
196.33 +
196.34 + y@units = "gC/m^2/year"
196.35 +;************************************************
196.36 +;model - observed
196.37 +;************************************************
196.38 + z = x
196.39 + z = x(0,:,:) - y(:,:)
196.40 +;************************************************
196.41 +; create 3 plots
196.42 +;************************************************
196.43 + wks = gsn_open_wks("ps","xy") ; open a ps file
196.44 + gsn_define_colormap(wks,"gui_default") ; choose colormap
196.45 +
196.46 + res = True ; Use plot options
196.47 + res@cnFillOn = True ; Turn on color fill
196.48 + res@gsnSpreadColors = True ; use full colormap
196.49 +; res@cnFillMode = "RasterFill" ; Turn on raster color
196.50 +; res@lbLabelAutoStride = True
196.51 + res@cnLinesOn = False ; Turn off contourn lines
196.52 + res@mpFillOn = False ; Turn off map fill
196.53 + res@tiMainString = "Observed MODIS MOD 17"
196.54 +
196.55 + res@gsnSpreadColors = True ; use full colormap
196.56 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
196.57 + res@cnMinLevelValF = 0. ; Min level
196.58 + res@cnMaxLevelValF = 2200. ; Max level
196.59 + res@cnLevelSpacingF = 200. ; interval
196.60 +
196.61 + res@gsnFrame = False ; Do not draw plot
196.62 + res@gsnDraw = False ; Do not advance frame
196.63 +
196.64 + plot=new(3,graphic) ; create graphic array
196.65 +
196.66 + plot(0) = gsn_csm_contour_map_ce(wks,y,res) ; for observed
196.67 +
196.68 + res@tiMainString = "Model i01.03cn"
196.69 +; res@tiMainString = "Model i01.04casa"
196.70 + plot(1) = gsn_csm_contour_map_ce(wks,x(0,:,:),res) ; for model
196.71 +
196.72 + res@cnMinLevelValF = -500 ; Min level
196.73 + res@cnMaxLevelValF = 500. ; Max level
196.74 + res@cnLevelSpacingF = 50. ; interval
196.75 + res@tiMainString = "(Model i01.03cn) - (observed)"
196.76 +; res@tiMainString = "(Model i01.04casa) - (observed)"
196.77 + plot(2) = gsn_csm_contour_map_ce(wks,z(0,:,:),res) ; for model - ob
196.78 +
196.79 +;***********************************************
196.80 +; create panel plot
196.81 +;***********************************************
196.82 + pres = True ; panel plot mods desired
196.83 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
196.84 + ; indiv. plots in panel
196.85 + pres@gsnMaximize = True ; fill the page
196.86 +
196.87 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
196.88 +
196.89 + system("convert xy.ps xy.png")
196.90 +end
196.91 \ No newline at end of file
197.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
197.2 +++ b/lai/32.contour_land_class.ncl Mon Jan 26 22:08:20 2009 -0500
197.3 @@ -0,0 +1,54 @@
197.4 +;*************************************************
197.5 +; ce_1.ncl
197.6 +;************************************************
197.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
197.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
197.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
197.10 +;************************************************
197.11 +begin
197.12 +;************************************************
197.13 +; read in observed data
197.14 +;************************************************
197.15 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
197.16 +; fili = "land_class_0.25deg.nc"
197.17 + fili = "land_class_T42_new.nc"
197.18 + f = addfile(diri+fili,"r")
197.19 + print (f)
197.20 +
197.21 +; y = f->LAND_CLASS(::10,::10) ; for 0.25deg
197.22 +; y = (/ y(::-1,:) /) ; for 0.25deg
197.23 +
197.24 + y = f->LAND_CLASS
197.25 + printVarSummary(y)
197.26 +
197.27 + y = where(y.eq.0,y@_FillValue,y)
197.28 +
197.29 + printVarSummary(y)
197.30 + print (min(y)+"/"+max(y))
197.31 +;************************************************
197.32 +; create default plot
197.33 +;************************************************
197.34 + wks = gsn_open_wks("ps","xy") ; open a ps file
197.35 + gsn_define_colormap(wks,"gui_default") ; choose colormap
197.36 +
197.37 + res = True ; Use plot options
197.38 + res@cnFillOn = True ; Turn on color fill
197.39 + res@gsnSpreadColors = True ; use full colormap
197.40 +; res@cnFillMode = "RasterFill" ; Turn on raster color
197.41 +; res@lbLabelAutoStride = True
197.42 + res@cnLinesOn = False ; Turn off contourn lines
197.43 + res@mpFillOn = False ; Turn off map fill
197.44 + res@tiMainString = "MODIS LAND CLASS T42"
197.45 +
197.46 + res@gsnSpreadColors = True ; use full colormap
197.47 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
197.48 + res@cnMinLevelValF = 1. ; Min level
197.49 + res@cnMaxLevelValF = 19. ; Max level
197.50 + res@cnLevelSpacingF = 1. ; interval
197.51 + pres = True ; panel plot mods desired
197.52 + pres@gsnMaximize = True ; fill the page
197.53 +
197.54 + plot = gsn_csm_contour_map_ce(wks,y,res) ; for observed
197.55 + gsn_panel(wks,plot,(/1,1/),pres) ; create panel plot
197.56 + system("convert xy.ps xy.png")
197.57 +end
197.58 \ No newline at end of file
198.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
198.2 +++ b/lai/33.contour_diff_grow.ncl Mon Jan 26 22:08:20 2009 -0500
198.3 @@ -0,0 +1,128 @@
198.4 +;*************************************************
198.5 +; 3 plots, model - ob
198.6 +;************************************************
198.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
198.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
198.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
198.10 +;************************************************
198.11 +begin
198.12 +
198.13 + day_of_data = (/31,28,31,30,31,30,31,31,30,31,30,31/)
198.14 +
198.15 +;************************************************
198.16 +; read in observed data
198.17 +;************************************************
198.18 + diri1 = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
198.19 + fili1 = "LAI_2000-2005_ensemble_T42.nc"
198.20 + f = addfile(diri1+fili1,"r")
198.21 +
198.22 + z = f->LAI
198.23 + y = z(0,:,:)
198.24 + y@long_name = "Days of Growing Season"
198.25 +
198.26 + dsizes_z = dimsizes(z)
198.27 + ntime = dsizes_z(0)
198.28 + nlat = dsizes_z(1)
198.29 + nlon = dsizes_z(2)
198.30 +
198.31 + do j = 0,nlat-1
198.32 + do i = 0,nlon-1
198.33 + nday = 0.
198.34 + do k = 0,ntime-1
198.35 + if (.not. ismissing(z(k,j,i)) .and. z(k,j,i) .gt. 1.0) then
198.36 + nday = nday + day_of_data(k)
198.37 + end if
198.38 + end do
198.39 + if (nday .ne. 0.) then
198.40 + y(j,i) = nday
198.41 + end if
198.42 + end do
198.43 + end do
198.44 +
198.45 +; printVarSummary(y)
198.46 + print (min(y)+"/"+max(y))
198.47 +
198.48 + delete (z)
198.49 +;************************************************
198.50 +; read in data: model
198.51 +;************************************************
198.52 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
198.53 +;fili3 = "i01.03cn_1545-1569_MONS_climo.nc"
198.54 + fili3 = "i01.04casa_1605-1629_MONS_climo.nc"
198.55 + data_file_model = addfile(diri2+fili3,"r")
198.56 +
198.57 + z = data_file_model->TLAI
198.58 + x = z(0,:,:)
198.59 + x@long_name = "Days of Growing Season"
198.60 +
198.61 + dsizes_z = dimsizes(z)
198.62 + ntime = dsizes_z(0)
198.63 + nlat = dsizes_z(1)
198.64 + nlon = dsizes_z(2)
198.65 +
198.66 + do j = 0,nlat-1
198.67 + do i = 0,nlon-1
198.68 + nday = 0.
198.69 + do k = 0,ntime-1
198.70 + if (.not. ismissing(z(k,j,i)) .and. z(k,j,i) .gt. 1.0) then
198.71 + nday = nday + day_of_data(k)
198.72 + end if
198.73 + end do
198.74 + if (nday .ne. 0.) then
198.75 + x(j,i) = nday
198.76 + end if
198.77 + end do
198.78 + end do
198.79 +
198.80 + print (min(x)+"/"+max(x))
198.81 +
198.82 + d = x
198.83 + d = x - y
198.84 + print (min(d)+"/"+max(d))
198.85 +
198.86 + delete (z)
198.87 +
198.88 + delta = 0.000001
198.89 + y = where(ismissing(y).and.(ismissing(x).or.(x.lt.delta)),0.,y)
198.90 +;************************************************
198.91 +; create default plot
198.92 +;************************************************
198.93 + wks = gsn_open_wks("ps","xy") ; open a ps file
198.94 + gsn_define_colormap(wks,"gui_default") ; choose colormap
198.95 +
198.96 + res = True ; Use plot options
198.97 + res@cnFillOn = True ; Turn on color fill
198.98 + res@gsnSpreadColors = True ; use full colormap
198.99 +; res@cnFillMode = "RasterFill" ; Turn on raster color
198.100 +; res@lbLabelAutoStride = True
198.101 + res@cnLinesOn = False ; Turn off contourn lines
198.102 + res@mpFillOn = False ; Turn off map fill
198.103 +
198.104 + res@gsnSpreadColors = True ; use full colormap
198.105 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
198.106 + res@cnMinLevelValF = 0. ; Min level
198.107 + res@cnMaxLevelValF = 365. ; Max level
198.108 + res@cnLevelSpacingF = 30. ; interval
198.109 +
198.110 + pres = True ; panel plot mods desired
198.111 + pres@gsnMaximize = True ; fill the page
198.112 +
198.113 + plot=new(3,graphic) ; create graphic array
198.114 +
198.115 + res@tiMainString = "MODIS MOD 15A2 2000-2005"
198.116 + plot(0) = gsn_csm_contour_map_ce(wks,y,res)
198.117 +
198.118 +; res@tiMainString = "Model i01.03cn"
198.119 + res@tiMainString = "Model i01.04casa"
198.120 + plot(1) = gsn_csm_contour_map_ce(wks,x,res)
198.121 +
198.122 +; res@tiMainString = "(Model i01.03cn) - (Observed)"
198.123 + res@tiMainString = "(Model i01.04casa) - (Observed)"
198.124 + res@cnMinLevelValF = -120. ; Min level
198.125 + res@cnMaxLevelValF = 120. ; Max level
198.126 + res@cnLevelSpacingF = 20. ; interval
198.127 + plot(2) = gsn_csm_contour_map_ce(wks,d,res) ; for observed
198.128 +
198.129 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
198.130 + system("convert xy.ps xy.png")
198.131 +end
198.132 \ No newline at end of file
199.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
199.2 +++ b/lai/33.contour_diff_max.ncl Mon Jan 26 22:08:20 2009 -0500
199.3 @@ -0,0 +1,114 @@
199.4 +;*************************************************
199.5 +; 3 plots, model - ob
199.6 +;************************************************
199.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
199.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
199.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
199.10 +;************************************************
199.11 +begin
199.12 +;************************************************
199.13 +; read in observed data
199.14 +;************************************************
199.15 + diri1 = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
199.16 + fili1 = "LAI_2000-2005_ensemble_T42.nc"
199.17 + f = addfile(diri1+fili1,"r")
199.18 +
199.19 + z = f->LAI
199.20 + y = z(0,:,:)
199.21 + y@long_name = "Leaf Area Index Max"
199.22 + s = z(:,0,0)
199.23 +
199.24 + dsizes_z = dimsizes(z)
199.25 + ntime = dsizes_z(0)
199.26 + nlat = dsizes_z(1)
199.27 + nlon = dsizes_z(2)
199.28 +
199.29 + do j = 0,nlat-1
199.30 + do i = 0,nlon-1
199.31 + s = z(:,j,i)
199.32 + y(j,i) = max(s)
199.33 + end do
199.34 + end do
199.35 +
199.36 +; printVarSummary(y)
199.37 + print (min(y)+"/"+max(y))
199.38 +
199.39 + delete (s)
199.40 + delete (z)
199.41 +;************************************************
199.42 +; read in data: model
199.43 +;************************************************
199.44 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
199.45 +;fili3 = "i01.03cn_1545-1569_MONS_climo.nc"
199.46 + fili3 = "i01.04casa_1605-1629_MONS_climo.nc"
199.47 + data_file_model = addfile(diri2+fili3,"r")
199.48 +
199.49 + z = data_file_model->TLAI
199.50 + x = z(0,:,:)
199.51 + x@long_name = "Leaf Area Index Max"
199.52 + s = z(:,0,0)
199.53 +
199.54 + dsizes_z = dimsizes(z)
199.55 + ntime = dsizes_z(0)
199.56 + nlat = dsizes_z(1)
199.57 + nlon = dsizes_z(2)
199.58 +
199.59 + do j = 0,nlat-1
199.60 + do i = 0,nlon-1
199.61 + s = z(:,j,i)
199.62 + x(j,i) = max(s)
199.63 + end do
199.64 + end do
199.65 +
199.66 + print (min(x)+"/"+max(x))
199.67 + d = x
199.68 + d = x - y
199.69 + print (min(d)+"/"+max(d))
199.70 +
199.71 + delete (z)
199.72 + delete (s)
199.73 +
199.74 + delta = 0.000001
199.75 + y = where(ismissing(y).and.(ismissing(x).or.(x.lt.delta)),0.,y)
199.76 +;************************************************
199.77 +; create default plot
199.78 +;************************************************
199.79 + wks = gsn_open_wks("ps","xy") ; open a ps file
199.80 + gsn_define_colormap(wks,"gui_default") ; choose colormap
199.81 +
199.82 + res = True ; Use plot options
199.83 + res@cnFillOn = True ; Turn on color fill
199.84 + res@gsnSpreadColors = True ; use full colormap
199.85 +; res@cnFillMode = "RasterFill" ; Turn on raster color
199.86 +; res@lbLabelAutoStride = True
199.87 + res@cnLinesOn = False ; Turn off contourn lines
199.88 + res@mpFillOn = False ; Turn off map fill
199.89 +
199.90 + res@gsnSpreadColors = True ; use full colormap
199.91 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
199.92 + res@cnMinLevelValF = 0. ; Min level
199.93 + res@cnMaxLevelValF = 10. ; Max level
199.94 + res@cnLevelSpacingF = 1. ; interval
199.95 +
199.96 + pres = True ; panel plot mods desired
199.97 + pres@gsnMaximize = True ; fill the page
199.98 +
199.99 + plot=new(3,graphic) ; create graphic array
199.100 +
199.101 + res@tiMainString = "MODIS MOD 15A2 2000-2005"
199.102 + plot(0) = gsn_csm_contour_map_ce(wks,y,res)
199.103 +
199.104 +; res@tiMainString = "Model i01.03cn"
199.105 + res@tiMainString = "Model i01.04casa"
199.106 + plot(1) = gsn_csm_contour_map_ce(wks,x,res)
199.107 +
199.108 +; res@tiMainString = "(Model i01.03cn) - (Observed)"
199.109 + res@tiMainString = "(Model i01.04casa) - (Observed)"
199.110 + res@cnMinLevelValF = -6. ; Min level
199.111 + res@cnMaxLevelValF = 6. ; Max level
199.112 + res@cnLevelSpacingF = 1. ; interval
199.113 + plot(2) = gsn_csm_contour_map_ce(wks,d,res) ; for observed
199.114 +
199.115 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
199.116 + system("convert xy.ps xy.png")
199.117 +end
199.118 \ No newline at end of file
200.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
200.2 +++ b/lai/33.contour_diff_mean.ncl Mon Jan 26 22:08:20 2009 -0500
200.3 @@ -0,0 +1,114 @@
200.4 +;*************************************************
200.5 +; 3 plots, model - ob
200.6 +;************************************************
200.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
200.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
200.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
200.10 +;************************************************
200.11 +begin
200.12 +;************************************************
200.13 +; read in observed data
200.14 +;************************************************
200.15 + diri1 = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
200.16 + fili1 = "LAI_2000-2005_ensemble_T42.nc"
200.17 + f = addfile(diri1+fili1,"r")
200.18 +
200.19 + z = f->LAI
200.20 + y = z(0,:,:)
200.21 + y@long_name = "Leaf Area Index Mean"
200.22 + s = z(:,0,0)
200.23 +
200.24 + dsizes_z = dimsizes(z)
200.25 + ntime = dsizes_z(0)
200.26 + nlat = dsizes_z(1)
200.27 + nlon = dsizes_z(2)
200.28 +
200.29 + do j = 0,nlat-1
200.30 + do i = 0,nlon-1
200.31 + s = z(:,j,i)
200.32 + y(j,i) = avg(s)
200.33 + end do
200.34 + end do
200.35 +
200.36 +; printVarSummary(y)
200.37 + print (min(y)+"/"+max(y))
200.38 +
200.39 + delete (s)
200.40 + delete (z)
200.41 +;************************************************
200.42 +; read in data: model
200.43 +;************************************************
200.44 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
200.45 + fili3 = "i01.03cn_1545-1569_MONS_climo.nc"
200.46 +;fili3 = "i01.04casa_1605-1629_MONS_climo.nc"
200.47 + data_file_model = addfile(diri2+fili3,"r")
200.48 +
200.49 + z = data_file_model->TLAI
200.50 + x = z(0,:,:)
200.51 + x@long_name = "Leaf Area Index Mean"
200.52 + s = z(:,0,0)
200.53 +
200.54 + dsizes_z = dimsizes(z)
200.55 + ntime = dsizes_z(0)
200.56 + nlat = dsizes_z(1)
200.57 + nlon = dsizes_z(2)
200.58 +
200.59 + do j = 0,nlat-1
200.60 + do i = 0,nlon-1
200.61 + s = z(:,j,i)
200.62 + x(j,i) = avg(s)
200.63 + end do
200.64 + end do
200.65 +
200.66 + print (min(x)+"/"+max(x))
200.67 + d = x
200.68 + d = x - y
200.69 + print (min(d)+"/"+max(d))
200.70 +
200.71 + delete (z)
200.72 + delete (s)
200.73 +
200.74 + delta = 0.000001
200.75 + y = where(ismissing(y).and.(ismissing(x).or.(x.lt.delta)),0.,y)
200.76 +;************************************************
200.77 +; create default plot
200.78 +;************************************************
200.79 + wks = gsn_open_wks("ps","xy") ; open a ps file
200.80 + gsn_define_colormap(wks,"gui_default") ; choose colormap
200.81 +
200.82 + res = True ; Use plot options
200.83 + res@cnFillOn = True ; Turn on color fill
200.84 + res@gsnSpreadColors = True ; use full colormap
200.85 +; res@cnFillMode = "RasterFill" ; Turn on raster color
200.86 +; res@lbLabelAutoStride = True
200.87 + res@cnLinesOn = False ; Turn off contourn lines
200.88 + res@mpFillOn = False ; Turn off map fill
200.89 +
200.90 + res@gsnSpreadColors = True ; use full colormap
200.91 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
200.92 + res@cnMinLevelValF = 0. ; Min level
200.93 + res@cnMaxLevelValF = 6. ; Max level
200.94 + res@cnLevelSpacingF = 0.5 ; interval
200.95 +
200.96 + pres = True ; panel plot mods desired
200.97 + pres@gsnMaximize = True ; fill the page
200.98 +
200.99 + plot=new(3,graphic) ; create graphic array
200.100 +
200.101 + res@tiMainString = "MODIS MOD 15A2 2000-2005"
200.102 + plot(0) = gsn_csm_contour_map_ce(wks,y,res)
200.103 +
200.104 + res@tiMainString = "Model i01.03cn"
200.105 +; res@tiMainString = "Model i01.04casa"
200.106 + plot(1) = gsn_csm_contour_map_ce(wks,x,res)
200.107 +
200.108 + res@tiMainString = "(Model i01.03cn) - (Observed)"
200.109 +; res@tiMainString = "(Model i01.04casa) - (Observed)"
200.110 + res@cnMinLevelValF = -2. ; Min level
200.111 + res@cnMaxLevelValF = 2. ; Max level
200.112 + res@cnLevelSpacingF = 0.4 ; interval
200.113 + plot(2) = gsn_csm_contour_map_ce(wks,d,res) ; for observed
200.114 +
200.115 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
200.116 + system("convert xy.ps xy.png")
200.117 +end
200.118 \ No newline at end of file
201.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
201.2 +++ b/lai/33.contour_diff_phase.ncl Mon Jan 26 22:08:20 2009 -0500
201.3 @@ -0,0 +1,116 @@
201.4 +;*************************************************
201.5 +; 3 plots, model - ob
201.6 +;************************************************
201.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
201.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
201.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
201.10 +;************************************************
201.11 +begin
201.12 +;************************************************
201.13 +; read in observed data
201.14 +;************************************************
201.15 + diri1 = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
201.16 + fili1 = "LAI_2000-2005_ensemble_T42.nc"
201.17 + f = addfile(diri1+fili1,"r")
201.18 +
201.19 + z = f->LAI
201.20 + y = z(0,:,:)
201.21 + y@long_name = "Month of Leaf Area Index Max"
201.22 + s = z(:,0,0)
201.23 +
201.24 + dsizes_z = dimsizes(z)
201.25 + ntime = dsizes_z(0)
201.26 + nlat = dsizes_z(1)
201.27 + nlon = dsizes_z(2)
201.28 +
201.29 + do j = 0,nlat-1
201.30 + do i = 0,nlon-1
201.31 + s = z(:,j,i)
201.32 + y(j,i) = maxind(s) + 1
201.33 + end do
201.34 + end do
201.35 +
201.36 +; printVarSummary(y)
201.37 + print (min(y)+"/"+max(y))
201.38 +
201.39 + delete (s)
201.40 + delete (z)
201.41 +;************************************************
201.42 +; read in data: model
201.43 +;************************************************
201.44 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
201.45 + fili3 = "i01.03cn_1545-1569_MONS_climo.nc"
201.46 +;fili3 = "i01.04casa_1605-1629_MONS_climo.nc"
201.47 + data_file_model = addfile(diri2+fili3,"r")
201.48 +
201.49 + z = data_file_model->TLAI
201.50 + x = z(0,:,:)
201.51 + x@long_name = "Month of Leaf Area Index Max"
201.52 + s = z(:,0,0)
201.53 +
201.54 + dsizes_z = dimsizes(z)
201.55 + ntime = dsizes_z(0)
201.56 + nlat = dsizes_z(1)
201.57 + nlon = dsizes_z(2)
201.58 +
201.59 + do j = 0,nlat-1
201.60 + do i = 0,nlon-1
201.61 + s = z(:,j,i)
201.62 + x(j,i) = maxind(s) + 1
201.63 + end do
201.64 + end do
201.65 +
201.66 + print (min(x)+"/"+max(x))
201.67 + d = x
201.68 + d = x - y
201.69 + d = where((d .gt. 6.),12.-d,d)
201.70 + d = where((d .lt. -6.),-12.-d,d)
201.71 + print (min(d)+"/"+max(d))
201.72 +
201.73 + delete (z)
201.74 + delete (s)
201.75 +
201.76 + delta = 0.000001
201.77 + y = where(ismissing(y).and.(ismissing(x).or.(x.lt.delta)),0.,y)
201.78 +;************************************************
201.79 +; create default plot
201.80 +;************************************************
201.81 + wks = gsn_open_wks("ps","xy") ; open a ps file
201.82 + gsn_define_colormap(wks,"gui_default") ; choose colormap
201.83 +
201.84 + res = True ; Use plot options
201.85 + res@cnFillOn = True ; Turn on color fill
201.86 + res@gsnSpreadColors = True ; use full colormap
201.87 +; res@cnFillMode = "RasterFill" ; Turn on raster color
201.88 +; res@lbLabelAutoStride = True
201.89 + res@cnLinesOn = False ; Turn off contourn lines
201.90 + res@mpFillOn = False ; Turn off map fill
201.91 +
201.92 + res@gsnSpreadColors = True ; use full colormap
201.93 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
201.94 + res@cnMinLevelValF = 1. ; Min level
201.95 + res@cnMaxLevelValF = 12. ; Max level
201.96 + res@cnLevelSpacingF = 1. ; interval
201.97 +
201.98 + pres = True ; panel plot mods desired
201.99 + pres@gsnMaximize = True ; fill the page
201.100 +
201.101 + plot=new(3,graphic) ; create graphic array
201.102 +
201.103 + res@tiMainString = "MODIS MOD 15A2 2000-2005"
201.104 + plot(0) = gsn_csm_contour_map_ce(wks,y,res)
201.105 +
201.106 + res@tiMainString = "Model i01.03cn"
201.107 +; res@tiMainString = "Model i01.04casa"
201.108 + plot(1) = gsn_csm_contour_map_ce(wks,x,res)
201.109 +
201.110 + res@tiMainString = "(Model i01.03cn) - (Observed)"
201.111 +; res@tiMainString = "(Model i01.04casa) - (Observed)"
201.112 + res@cnMinLevelValF = -6. ; Min level
201.113 + res@cnMaxLevelValF = 6. ; Max level
201.114 + res@cnLevelSpacingF = 1. ; interval
201.115 + plot(2) = gsn_csm_contour_map_ce(wks,d,res) ; for observed
201.116 +
201.117 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
201.118 + system("convert xy.ps xy.png")
201.119 +end
201.120 \ No newline at end of file
202.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
202.2 +++ b/lai/41.table_mean.ncl Mon Jan 26 22:08:20 2009 -0500
202.3 @@ -0,0 +1,166 @@
202.4 +;********************************************************
202.5 +; histogram normalized by rain and compute correleration
202.6 +;********************************************************
202.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
202.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
202.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
202.10 +
202.11 +procedure pminmax(data:numeric,name:string)
202.12 +begin
202.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
202.14 + if(isatt(data,"units")) then
202.15 + print (name + " units = " + data@units)
202.16 + end if
202.17 +end
202.18 +
202.19 +;
202.20 +; Main code.
202.21 +;
202.22 +begin
202.23 +
202.24 +;nclass = 18
202.25 + nclass = 20
202.26 +
202.27 +;************************************************
202.28 +; read in data: observed
202.29 +;************************************************
202.30 + diri1 = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
202.31 +;fili1 = "land_class_T42.nc"
202.32 + fili1 = "land_class_T42_new.nc"
202.33 + fili2 = "LAI_2000-2005_mean_T42.nc"
202.34 + data_file_ob1 = addfile(diri1+fili1,"r")
202.35 + data_file_ob2 = addfile(diri1+fili2,"r")
202.36 +
202.37 + RAIN1 = tofloat(data_file_ob1->LAND_CLASS)
202.38 + NPP1 = data_file_ob2->LAI
202.39 +;************************************************
202.40 +; read in data: model
202.41 +;************************************************
202.42 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
202.43 +;fili3 = "i01.03cn_1545-1569_ANN_climo.nc"
202.44 + fili3 = "i01.04casa_1605-1629_ANN_climo.nc"
202.45 + data_file_model = addfile(diri2+fili3,"r")
202.46 +
202.47 + NPP2 = data_file_model->TLAI
202.48 +;************************************************
202.49 +; print min/max and unit
202.50 +;************************************************
202.51 + pminmax(RAIN1,"RAIN1")
202.52 + pminmax(NPP1,"NPP1")
202.53 + pminmax(NPP2,"NPP2")
202.54 +
202.55 + RAIN1_1D = ndtooned(RAIN1)
202.56 + NPP1_1D = ndtooned(NPP1)
202.57 + NPP2_1D = ndtooned(NPP2)
202.58 +;
202.59 +; Calculate some "nice" bins for binning the data in equally spaced
202.60 +; ranges.
202.61 +;
202.62 +
202.63 +; nbins = nclass + 1 ; Number of bins to use.
202.64 +; nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,False)
202.65 +; nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
202.66 +; range = fspan(nicevals(0),nicevals(1),nvals)
202.67 +
202.68 + nclassn = nclass + 1
202.69 + range = fspan(0,nclassn-1,nclassn)
202.70 +
202.71 +; print (nicevals)
202.72 +; print (nvals)
202.73 + print (range)
202.74 +; exit
202.75 +
202.76 +;
202.77 +; Use this range information to grab all the values in a
202.78 +; particular range, and then take an average.
202.79 +;
202.80 + nr = dimsizes(range)
202.81 + nx = nr-1
202.82 + xvalues = new((/2,nx/),typeof(RAIN1_1D))
202.83 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
202.84 + dx = xvalues(0,1) - xvalues(0,0) ; range width
202.85 + dx4 = dx/4 ; 1/4 of the range
202.86 + xvalues(1,:) = xvalues(0,:) - dx/5.
202.87 + yvalues = new((/2,nx/),typeof(RAIN1_1D))
202.88 + mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
202.89 + mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
202.90 +
202.91 + do nd=0,1
202.92 +;
202.93 +; See if we are doing model or observational data.
202.94 +;
202.95 + if(nd.eq.0) then
202.96 + data = RAIN1_1D
202.97 + npp_data = NPP1_1D
202.98 + else
202.99 + data = RAIN1_1D
202.100 + npp_data = NPP2_1D
202.101 + end if
202.102 +;
202.103 +; Loop through each range and check for values.
202.104 +;
202.105 + do i=0,nr-2
202.106 + if (i.ne.(nr-2)) then
202.107 + print("")
202.108 + print("In range ["+range(i)+","+range(i+1)+")")
202.109 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
202.110 + else
202.111 + print("")
202.112 + print("In range ["+range(i)+",)")
202.113 + idx = ind(range(i).le.data)
202.114 + end if
202.115 +;
202.116 +; Calculate average, and get min and max.
202.117 +;
202.118 + if(.not.any(ismissing(idx))) then
202.119 + yvalues(nd,i) = avg(npp_data(idx))
202.120 + mn_yvalues(nd,i) = min(npp_data(idx))
202.121 + mx_yvalues(nd,i) = max(npp_data(idx))
202.122 + count = dimsizes(idx)
202.123 + else
202.124 + count = 0
202.125 + yvalues(nd,i) = yvalues@_FillValue
202.126 + mn_yvalues(nd,i) = yvalues@_FillValue
202.127 + mx_yvalues(nd,i) = yvalues@_FillValue
202.128 + end if
202.129 +;
202.130 +; Print out information.
202.131 +;
202.132 + print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
202.133 + print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
202.134 +
202.135 +;
202.136 +; Clean up for next time in loop.
202.137 +;
202.138 + delete(idx)
202.139 + end do
202.140 + delete(data)
202.141 + delete(npp_data)
202.142 + end do
202.143 +
202.144 +;
202.145 +; Start the graphics.
202.146 +;
202.147 +
202.148 + u = yvalues(0,:)
202.149 + v = yvalues(1,:)
202.150 + print (u)
202.151 + print (v)
202.152 +
202.153 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
202.154 + uu = u(good)
202.155 + vv = v(good)
202.156 + nz = dimsizes(uu)
202.157 + print (nz)
202.158 +
202.159 + ccr = esccr(uu,vv,0)
202.160 + print (ccr)
202.161 +
202.162 +;new eq
202.163 + bias = sum(abs(vv-uu)/(vv+uu))
202.164 + M = (1.- (bias/nz))*5.
202.165 + print (bias)
202.166 + print (M)
202.167 +
202.168 +end
202.169 +
203.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
203.2 +++ b/lai/99.all.ncl Mon Jan 26 22:08:20 2009 -0500
203.3 @@ -0,0 +1,1739 @@
203.4 +;********************************************************
203.5 +; histogram normalized by rain and compute correleration
203.6 +;********************************************************
203.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
203.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
203.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
203.10 +
203.11 +procedure pminmax(data:numeric,name:string)
203.12 +begin
203.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
203.14 + if(isatt(data,"units")) then
203.15 + print (name + " units = " + data@units)
203.16 + end if
203.17 +end
203.18 +
203.19 +; Main code.
203.20 +begin
203.21 +
203.22 + nclass = 20
203.23 +
203.24 + plot_type = "ps"
203.25 + plot_type_new = "png"
203.26 +
203.27 +;************************************************
203.28 +; read in data: model
203.29 +;************************************************
203.30 +;film = "b30.061n_1995-2004_MONS_climo_lnd.nc"
203.31 +;model_name = "b30.061n"
203.32 +;model_grid = "T31"
203.33 +
203.34 +;film = "newcn05_ncep_1i_MONS_climo_lnd.nc"
203.35 +;model_name = "newcn"
203.36 +;model_grid = "1.9"
203.37 +
203.38 +;film = "i01.06cn_1798-2004_MONS_climo.nc"
203.39 +;model_name = "06cn"
203.40 +;model_grid = "T42"
203.41 +
203.42 +;film = "i01.06casa_1798-2004_MONS_climo.nc"
203.43 +;model_name = "06casa"
203.44 +;model_grid = "T42"
203.45 +
203.46 + film = "i01.10cn_1948-2004_MONS_climo.nc"
203.47 + model_name = "10cn"
203.48 + model_grid = "T42"
203.49 +
203.50 +;film = "i01.10casa_1948-2004_MONS_climo.nc"
203.51 +;model_name = "10casa"
203.52 +;model_grid = "T42"
203.53 +
203.54 + html_name = "table.html." + model_name
203.55 + html_new = html_name +".new"
203.56 + system("sed s#model_name#"+model_name+"# "+html_name+" > "+html_new+";"+ \
203.57 + "mv -f "+html_new+" "+html_name)
203.58 +;------------------------------------------------
203.59 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
203.60 + fm = addfile(dirm+film,"r")
203.61 +
203.62 + laimod = fm->TLAI
203.63 +
203.64 +;************************************************
203.65 +; read in data: observed
203.66 +;************************************************
203.67 +
203.68 + ob_name = "MODIS MOD 15A2 2000-2005"
203.69 +
203.70 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
203.71 + filo1 = "land_class_"+model_grid+".nc"
203.72 + filo2 = "LAI_2000-2005_MONS_"+model_grid+".nc"
203.73 +
203.74 + fo1 = addfile(diro+filo1,"r")
203.75 + fo2 = addfile(diro+filo2,"r")
203.76 +
203.77 + classob = tofloat(fo1->LAND_CLASS)
203.78 + laiob = fo2->LAI
203.79 +
203.80 +;*******************************************************************
203.81 +; for plotting table
203.82 +;*******************************************************************
203.83 +; table header name
203.84 + table_header_name = "LAI"
203.85 +
203.86 +; column (not including header column)
203.87 +
203.88 + col_header1 = (/"Mean","Max","Phase","Growth"/)
203.89 + col_header2 = (/"ob","model","M" \
203.90 + ,"ob","model","M" \
203.91 + ,"ob","model","M" \
203.92 + ,"ob","model","M" \
203.93 + /)
203.94 +
203.95 + ncol1 = dimsizes(col_header1)
203.96 + ncol2 = dimsizes(col_header2)
203.97 + ncol = ncol2
203.98 +
203.99 +; row (not including header row)
203.100 + row_header = (/"Water Bodies" \
203.101 + ,"Evergreen Needleleaf Forests" \
203.102 + ,"Evergreen Broadleaf Forests" \
203.103 + ,"Deciduous Needleleaf Forest" \
203.104 + ,"Deciduous Broadleaf Forests" \
203.105 + ,"Mixed Forests" \
203.106 + ,"Closed Bushlands" \
203.107 + ,"Open Bushlands" \
203.108 + ,"Woody Savannas (S. Hem.)" \
203.109 + ,"Savannas (S. Hem.)" \
203.110 + ,"Grasslands" \
203.111 + ,"Permanent Wetlands" \
203.112 + ,"Croplands" \
203.113 + ,"Urban and Built-Up" \
203.114 + ,"Cropland/Natural Vegetation Mosaic" \
203.115 + ,"Permanent Snow and Ice" \
203.116 + ,"Barren or Sparsely Vegetated" \
203.117 + ,"Unclassified" \
203.118 + ,"Woody Savannas (N. Hem.)" \
203.119 + ,"Savannas (N. Hem.)" \
203.120 + ,"All biome average" \
203.121 + /)
203.122 + nrow = dimsizes(row_header)
203.123 +
203.124 +; arrays to be passed to table.
203.125 + value = new ((/nrow, ncol/),string )
203.126 +
203.127 + table_length = 0.995
203.128 +
203.129 +; Table header
203.130 + ncr1 = (/1,1/) ; 1 row, 1 column
203.131 + xx1 = (/0.005,0.25/) ; Start and end X
203.132 + yy1 = (/0.900,0.995/) ; Start and end Y
203.133 + text1 = table_header_name
203.134 + res1 = True
203.135 + res1@txFontHeightF = 0.03
203.136 + res1@gsFillColor = "CornFlowerBlue"
203.137 +
203.138 +; Column header (equally space in x2)
203.139 + ncr21 = (/1,ncol1/) ; 1 rows, 4 columns
203.140 + xx21 = (/xx1(1),0.995/) ; start from end of x1
203.141 + yy21 = (/0.9475,0.995/) ; half of y1
203.142 + text21 = col_header1
203.143 + res21 = True
203.144 + res21@txFontHeightF = 0.015
203.145 + res21@gsFillColor = "Gray"
203.146 +
203.147 + ncr22 = (/1,ncol2/) ; 1 rows, 12 columns
203.148 + xx22 = xx21 ; start from end of x1
203.149 + yy22 = (/0.900,0.9475/) ; half of y1
203.150 + text22 = col_header2
203.151 + res22 = True
203.152 + res22@txFontHeightF = 0.015
203.153 + res22@gsFillColor = "Gray"
203.154 +
203.155 +; Row header (equally space in y2)
203.156 + ncr3 = (/nrow,1/) ; 20 rows, 1 columns
203.157 + xx3 = xx1 ; same as x1
203.158 + yy3 = (/1.0-table_length,0.900/) ; end at start of y1
203.159 + text3 = row_header
203.160 + res3 = True
203.161 + res3@txFontHeightF = 0.01
203.162 + res3@gsFillColor = "Gray"
203.163 +
203.164 +; Main table body
203.165 + ncr4 = (/nrow,ncol/) ; 5 rows, 5 columns
203.166 + xx4 = xx21 ; Start and end x
203.167 + yy4 = yy3 ; Start and end Y
203.168 + text4 = new((/nrow,ncol/),string)
203.169 +
203.170 + color_fill4 = new((/nrow,ncol/),string)
203.171 + color_fill4 = "white"
203.172 + color_fill4(nrow-1,:) = "CornFlowerBlue"
203.173 +
203.174 + res4 = True ; Set up resource list
203.175 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
203.176 + res4@txFontHeightF = 0.015
203.177 + res4@gsFillColor = color_fill4
203.178 +
203.179 + delete (color_fill4)
203.180 +
203.181 +;************************************************
203.182 +; plot global land class: observed
203.183 +;************************************************
203.184 +;global res
203.185 +
203.186 + resg = True ; Use plot options
203.187 + resg@cnFillOn = True ; Turn on color fill
203.188 + resg@gsnSpreadColors = True ; use full colormap
203.189 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
203.190 +; resg@lbLabelAutoStride = True
203.191 + resg@cnLinesOn = False ; Turn off contourn lines
203.192 + resg@mpFillOn = False ; Turn off map fill
203.193 +
203.194 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
203.195 + resg@cnMinLevelValF = 1. ; Min level
203.196 + resg@cnMaxLevelValF = 19. ; Max level
203.197 + resg@cnLevelSpacingF = 1. ; interval
203.198 +
203.199 +;global contour ob
203.200 + classob@_FillValue = 1.e+36
203.201 + classob = where(classob.eq.0,classob@_FillValue,classob)
203.202 +
203.203 + plot_name = "global_class_ob"
203.204 + title = ob_name
203.205 + resg@tiMainString = title
203.206 +
203.207 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
203.208 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.209 +
203.210 + plot = gsn_csm_contour_map_ce(wks,classob,resg)
203.211 + frame(wks)
203.212 +
203.213 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.214 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
203.215 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
203.216 + "rm "+plot_name+"."+plot_type)
203.217 +
203.218 + clear (wks)
203.219 +;*******************************************************************
203.220 +; Calculate "nice" bins for binning the data in equally spaced ranges
203.221 +;********************************************************************
203.222 + nclassn = nclass + 1
203.223 + range = fspan(0,nclassn-1,nclassn)
203.224 +; print (range)
203.225 +
203.226 +; Use this range information to grab all the values in a
203.227 +; particular range, and then take an average.
203.228 +
203.229 + nr = dimsizes(range)
203.230 + nx = nr-1
203.231 + xvalues = new((/2,nx/),float)
203.232 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
203.233 + dx = xvalues(0,1) - xvalues(0,0) ; range width
203.234 + dx4 = dx/4 ; 1/4 of the range
203.235 + xvalues(1,:) = xvalues(0,:) - dx/5.
203.236 +;-----------------------------------------------------------------
203.237 +;(A) mean
203.238 +;--------------------------------------------------------------------
203.239 +; get data
203.240 +
203.241 + laiob_mean = dim_avg_Wrap(laiob(lat|:,lon|:,time|:))
203.242 + laimod_mean = dim_avg_Wrap(laimod(lat|:,lon|:,time|:))
203.243 +
203.244 + DATA11_1D = ndtooned(classob)
203.245 + DATA12_1D = ndtooned(laiob_mean)
203.246 + DATA22_1D = ndtooned(laimod_mean)
203.247 +
203.248 + yvalues = new((/2,nx/),float)
203.249 + mn_yvalues = new((/2,nx/),float)
203.250 + mx_yvalues = new((/2,nx/),float)
203.251 +
203.252 + do nd=0,1
203.253 +
203.254 +; See if we are doing model or observational data.
203.255 +
203.256 + if(nd.eq.0) then
203.257 + data_ob = DATA11_1D
203.258 + data_mod = DATA12_1D
203.259 + else
203.260 + data_ob = DATA11_1D
203.261 + data_mod = DATA22_1D
203.262 + end if
203.263 +
203.264 +; Loop through each range and check for values.
203.265 +
203.266 + do i=0,nr-2
203.267 + if (i.ne.(nr-2)) then
203.268 +; print("")
203.269 +; print("In range ["+range(i)+","+range(i+1)+")")
203.270 + idx = ind((data_ob.ge.range(i)).and.(data_ob.lt.range(i+1)))
203.271 + else
203.272 +; print("")
203.273 +; print("In range ["+range(i)+",)")
203.274 + idx = ind(data_ob.ge.range(i))
203.275 + end if
203.276 +
203.277 +; Calculate average, and get min and max.
203.278 +
203.279 + if(.not.any(ismissing(idx))) then
203.280 + yvalues(nd,i) = avg(data_mod(idx))
203.281 + mn_yvalues(nd,i) = min(data_mod(idx))
203.282 + mx_yvalues(nd,i) = max(data_mod(idx))
203.283 + count = dimsizes(idx)
203.284 + else
203.285 + count = 0
203.286 + yvalues(nd,i) = yvalues@_FillValue
203.287 + mn_yvalues(nd,i) = yvalues@_FillValue
203.288 + mx_yvalues(nd,i) = yvalues@_FillValue
203.289 + end if
203.290 +
203.291 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
203.292 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
203.293 +
203.294 +; Clean up for next time in loop.
203.295 +
203.296 + delete(idx)
203.297 + end do
203.298 + delete(data_ob)
203.299 + delete(data_mod)
203.300 + end do
203.301 +;-----------------------------------------------------------------
203.302 +; compute correlation coef and M score
203.303 +
203.304 + u = yvalues(0,:)
203.305 + v = yvalues(1,:)
203.306 +
203.307 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
203.308 + uu = u(good)
203.309 + vv = v(good)
203.310 +
203.311 + ccrMean = esccr(uu,vv,0)
203.312 +; print (ccrMean)
203.313 +
203.314 +; new eq
203.315 + bias = sum(abs(vv-uu)/(vv+uu))
203.316 + Mmean = (1.- (bias/dimsizes(uu)))*5.
203.317 +
203.318 + M_lai_mean = sprintf("%.2f", Mmean)
203.319 + system("sed s#M_lai_mean#"+M_lai_mean+"# "+html_name+" > "+html_new+";"+ \
203.320 + "mv -f "+html_new+" "+html_name)
203.321 + print (M_lai_mean)
203.322 +
203.323 + do i=0,nrow-2
203.324 + text4(i,0) = sprintf("%5.2f",u(i))
203.325 + text4(i,1) = sprintf("%5.2f",v(i))
203.326 + text4(i,2) = "-"
203.327 + end do
203.328 + text4(nrow-1,0) = sprintf("%5.2f",avg(u))
203.329 + text4(nrow-1,1) = sprintf("%5.2f",avg(v))
203.330 + text4(nrow-1,2) = sprintf("%5.2f",Mmean)
203.331 +
203.332 + delete (u)
203.333 + delete (v)
203.334 + delete (uu)
203.335 + delete (vv)
203.336 +;--------------------------------------------------------------------
203.337 +; histogram res
203.338 +
203.339 + resm = True
203.340 + resm@gsnMaximize = True
203.341 + resm@gsnDraw = False
203.342 + resm@gsnFrame = False
203.343 + resm@xyMarkLineMode = "Markers"
203.344 + resm@xyMarkerSizeF = 0.014
203.345 + resm@xyMarker = 16
203.346 + resm@xyMarkerColors = (/"Brown","Blue"/)
203.347 +; resm@trYMinF = min(mn_yvalues) - 10.
203.348 +; resm@trYMaxF = max(mx_yvalues) + 10.
203.349 + resm@trYMinF = min(mn_yvalues) - 2
203.350 + resm@trYMaxF = max(mx_yvalues) + 4
203.351 +
203.352 + resm@tiYAxisString = "Mean LAI (Leaf Area Index)"
203.353 + resm@tiXAxisString = "Land Cover Type"
203.354 +
203.355 + max_bar = new((/2,nx/),graphic)
203.356 + min_bar = new((/2,nx/),graphic)
203.357 + max_cap = new((/2,nx/),graphic)
203.358 + min_cap = new((/2,nx/),graphic)
203.359 +
203.360 + lnres = True
203.361 + line_colors = (/"brown","blue"/)
203.362 +;------------------------------------------------------------------
203.363 +; Start the graphics.
203.364 +
203.365 + plot_name = "histogram_mean"
203.366 + title = model_name + " vs Observed"
203.367 + resm@tiMainString = title
203.368 +
203.369 + wks = gsn_open_wks (plot_type,plot_name)
203.370 +;-----------------------------
203.371 +; Add a boxed legend using the more simple method
203.372 +
203.373 + resm@pmLegendDisplayMode = "Always"
203.374 +; resm@pmLegendWidthF = 0.1
203.375 + resm@pmLegendWidthF = 0.08
203.376 + resm@pmLegendHeightF = 0.05
203.377 + resm@pmLegendOrthogonalPosF = -1.17
203.378 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
203.379 +; resm@pmLegendParallelPosF = 0.18
203.380 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
203.381 +
203.382 +; resm@lgPerimOn = False
203.383 + resm@lgLabelFontHeightF = 0.015
203.384 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
203.385 +;-----------------------------
203.386 + tRes = True
203.387 + tRes@txFontHeightF = 0.025
203.388 +
203.389 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMean)+")"
203.390 +
203.391 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
203.392 +
203.393 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
203.394 +;-------------------------------
203.395 +;Attach the vertical bar and the horizontal cap line
203.396 +
203.397 + do nd=0,1
203.398 + lnres@gsLineColor = line_colors(nd)
203.399 + do i=0,nx-1
203.400 +
203.401 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
203.402 + .not.ismissing(mx_yvalues(nd,i))) then
203.403 +
203.404 +; Attach the vertical bar, both above and below the marker.
203.405 +
203.406 + x1 = xvalues(nd,i)
203.407 + y1 = yvalues(nd,i)
203.408 + y2 = mn_yvalues(nd,i)
203.409 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
203.410 +
203.411 + y2 = mx_yvalues(nd,i)
203.412 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
203.413 +
203.414 +; Attach the horizontal cap line, both above and below the marker.
203.415 +
203.416 + x1 = xvalues(nd,i) - dx4
203.417 + x2 = xvalues(nd,i) + dx4
203.418 + y1 = mn_yvalues(nd,i)
203.419 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
203.420 +
203.421 + y1 = mx_yvalues(nd,i)
203.422 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
203.423 + end if
203.424 + end do
203.425 + end do
203.426 +
203.427 + draw(xy)
203.428 + frame(wks)
203.429 +
203.430 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.431 + "rm "+plot_name+"."+plot_type)
203.432 +
203.433 + clear (wks)
203.434 +
203.435 + delete (DATA11_1D)
203.436 + delete (DATA12_1D)
203.437 + delete (DATA22_1D)
203.438 +;delete (range)
203.439 +;delete (xvalues)
203.440 + delete (yvalues)
203.441 + delete (mn_yvalues)
203.442 + delete (mx_yvalues)
203.443 + delete (good)
203.444 + delete (max_bar)
203.445 + delete (min_bar)
203.446 + delete (max_cap)
203.447 + delete (min_cap)
203.448 +;-----------------------------------------------------------------
203.449 +;global res
203.450 +
203.451 + resg = True ; Use plot options
203.452 + resg@cnFillOn = True ; Turn on color fill
203.453 + resg@gsnSpreadColors = True ; use full colormap
203.454 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
203.455 +; resg@lbLabelAutoStride = True
203.456 + resg@cnLinesOn = False ; Turn off contourn lines
203.457 + resg@mpFillOn = False ; Turn off map fill
203.458 +
203.459 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
203.460 + resg@cnMinLevelValF = 0. ; Min level
203.461 + resg@cnMaxLevelValF = 10. ; Max level
203.462 + resg@cnLevelSpacingF = 1. ; interval
203.463 +
203.464 +;global contour ob
203.465 +
203.466 + delta = 0.00001
203.467 + laiob_mean = where(ismissing(laiob_mean).and.(ismissing(laimod_mean).or.(laimod_mean.lt.delta)),0.,laiob_mean)
203.468 +
203.469 + plot_name = "global_mean_ob"
203.470 + title = ob_name
203.471 + resg@tiMainString = title
203.472 +
203.473 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
203.474 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.475 +
203.476 + plot = gsn_csm_contour_map_ce(wks,laiob_mean,resg)
203.477 + frame(wks)
203.478 +
203.479 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.480 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
203.481 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
203.482 + "rm "+plot_name+"."+plot_type)
203.483 +
203.484 + clear (wks)
203.485 +;------------------------------------------------------------------------
203.486 +;global contour model
203.487 +
203.488 + plot_name = "global_mean_model"
203.489 + title = "Model " + model_name
203.490 + resg@tiMainString = title
203.491 +
203.492 + wks = gsn_open_wks (plot_type,plot_name)
203.493 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.494 +
203.495 + plot = gsn_csm_contour_map_ce(wks,laimod_mean,resg)
203.496 + frame(wks)
203.497 +
203.498 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.499 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
203.500 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
203.501 + "rm "+plot_name+"."+plot_type)
203.502 +
203.503 + clear (wks)
203.504 +;-----------------------------------------------------------------
203.505 +;(B) max
203.506 +;--------------------------------------------------------------------
203.507 +; get data
203.508 +
203.509 +; observed
203.510 + laiob_max = laiob(0,:,:)
203.511 + s = laiob(:,0,0)
203.512 + laiob_max@long_name = "Leaf Area Index Max"
203.513 +
203.514 + dsizes_z = dimsizes(laiob)
203.515 + nlat = dsizes_z(1)
203.516 + nlon = dsizes_z(2)
203.517 +
203.518 + do j = 0,nlat-1
203.519 + do i = 0,nlon-1
203.520 + s = laiob(:,j,i)
203.521 + laiob_max(j,i) = max(s)
203.522 + end do
203.523 + end do
203.524 +
203.525 +; print (min(y)+"/"+max(y))
203.526 + delete (s)
203.527 + delete (dsizes_z)
203.528 +;-------------------------
203.529 +; model
203.530 + laimod_max = laimod(0,:,:)
203.531 + s = laimod(:,0,0)
203.532 + laimod_max@long_name = "Leaf Area Index Max"
203.533 +
203.534 + dsizes_z = dimsizes(laimod)
203.535 + nlat = dsizes_z(1)
203.536 + nlon = dsizes_z(2)
203.537 +
203.538 + do j = 0,nlat-1
203.539 + do i = 0,nlon-1
203.540 + s = laimod(:,j,i)
203.541 + laimod_max(j,i) = max(s)
203.542 + end do
203.543 + end do
203.544 +
203.545 +; print (min(laimod_max)+"/"+max(laimod_max))
203.546 + delete (s)
203.547 + delete (dsizes_z)
203.548 +;------------------------
203.549 + DATA11_1D = ndtooned(classob)
203.550 + DATA12_1D = ndtooned(laiob_max)
203.551 + DATA22_1D = ndtooned(laimod_max)
203.552 +
203.553 + yvalues = new((/2,nx/),float)
203.554 + mn_yvalues = new((/2,nx/),float)
203.555 + mx_yvalues = new((/2,nx/),float)
203.556 +
203.557 + do nd=0,1
203.558 +
203.559 +; See if we are doing model or observational data.
203.560 +
203.561 + if(nd.eq.0) then
203.562 + data_ob = DATA11_1D
203.563 + data_mod = DATA12_1D
203.564 + else
203.565 + data_ob = DATA11_1D
203.566 + data_mod = DATA22_1D
203.567 + end if
203.568 +
203.569 +; Loop through each range and check for values.
203.570 +
203.571 + do i=0,nr-2
203.572 + if (i.ne.(nr-2)) then
203.573 +; print("")
203.574 +; print("In range ["+range(i)+","+range(i+1)+")")
203.575 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
203.576 + else
203.577 +; print("")
203.578 +; print("In range ["+range(i)+",)")
203.579 + idx = ind(range(i).le.data_ob)
203.580 + end if
203.581 +
203.582 +; Calculate average, and get min and max.
203.583 +
203.584 + if(.not.any(ismissing(idx))) then
203.585 + yvalues(nd,i) = avg(data_mod(idx))
203.586 + mn_yvalues(nd,i) = min(data_mod(idx))
203.587 + mx_yvalues(nd,i) = max(data_mod(idx))
203.588 + count = dimsizes(idx)
203.589 + else
203.590 + count = 0
203.591 + yvalues(nd,i) = yvalues@_FillValue
203.592 + mn_yvalues(nd,i) = yvalues@_FillValue
203.593 + mx_yvalues(nd,i) = yvalues@_FillValue
203.594 + end if
203.595 +
203.596 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
203.597 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
203.598 +
203.599 +; Clean up for next time in loop.
203.600 +
203.601 + delete(idx)
203.602 + end do
203.603 + delete(data_ob)
203.604 + delete(data_mod)
203.605 + end do
203.606 +;-----------------------------------------------------------------
203.607 +; compute correlation coef and M score
203.608 +
203.609 + u = yvalues(0,:)
203.610 + v = yvalues(1,:)
203.611 +
203.612 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
203.613 + uu = u(good)
203.614 + vv = v(good)
203.615 +
203.616 + ccrMax = esccr(uu,vv,0)
203.617 +; print (ccrMax)
203.618 +
203.619 +; new eq
203.620 + bias = sum(abs(vv-uu)/(vv+uu))
203.621 + Mmax = (1.- (bias/dimsizes(uu)))*5.
203.622 +
203.623 + M_lai_max = sprintf("%.2f", Mmax)
203.624 + system("sed s#M_lai_max#"+M_lai_max+"# "+html_name+" > "+html_new+";"+ \
203.625 + "mv -f "+html_new+" "+html_name)
203.626 + print (M_lai_max)
203.627 +
203.628 + do i=0,nrow-2
203.629 + text4(i,3) = sprintf("%5.2f",u(i))
203.630 + text4(i,4) = sprintf("%5.2f",v(i))
203.631 + text4(i,5) = "-"
203.632 + end do
203.633 + text4(nrow-1,3) = sprintf("%5.2f",avg(u))
203.634 + text4(nrow-1,4) = sprintf("%5.2f",avg(v))
203.635 + text4(nrow-1,5) = sprintf("%5.2f",Mmax)
203.636 +
203.637 + delete (u)
203.638 + delete (v)
203.639 + delete (uu)
203.640 + delete (vv)
203.641 +;--------------------------------------------------------------------
203.642 +; histogram res
203.643 +
203.644 + resm = True
203.645 + resm@gsnMaximize = True
203.646 + resm@gsnDraw = False
203.647 + resm@gsnFrame = False
203.648 + resm@xyMarkLineMode = "Markers"
203.649 + resm@xyMarkerSizeF = 0.014
203.650 + resm@xyMarker = 16
203.651 + resm@xyMarkerColors = (/"Brown","Blue"/)
203.652 +; resm@trYMinF = min(mn_yvalues) - 10.
203.653 +; resm@trYMaxF = max(mx_yvalues) + 10.
203.654 + resm@trYMinF = min(mn_yvalues) - 2
203.655 + resm@trYMaxF = max(mx_yvalues) + 4
203.656 +
203.657 + resm@tiYAxisString = "Max LAI (Leaf Area Index)"
203.658 + resm@tiXAxisString = "Land Cover Type"
203.659 +
203.660 + max_bar = new((/2,nx/),graphic)
203.661 + min_bar = new((/2,nx/),graphic)
203.662 + max_cap = new((/2,nx/),graphic)
203.663 + min_cap = new((/2,nx/),graphic)
203.664 +
203.665 + lnres = True
203.666 + line_colors = (/"brown","blue"/)
203.667 +;------------------------------------------------------------------
203.668 +; Start the graphics.
203.669 +
203.670 + plot_name = "histogram_max"
203.671 + title = model_name + " vs Observed"
203.672 + resm@tiMainString = title
203.673 +
203.674 + wks = gsn_open_wks (plot_type,plot_name)
203.675 +;-----------------------------
203.676 +; Add a boxed legend using the more simple method
203.677 +
203.678 + resm@pmLegendDisplayMode = "Always"
203.679 +; resm@pmLegendWidthF = 0.1
203.680 + resm@pmLegendWidthF = 0.08
203.681 + resm@pmLegendHeightF = 0.05
203.682 + resm@pmLegendOrthogonalPosF = -1.17
203.683 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
203.684 +; resm@pmLegendParallelPosF = 0.18
203.685 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
203.686 +
203.687 +; resm@lgPerimOn = False
203.688 + resm@lgLabelFontHeightF = 0.015
203.689 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
203.690 +;-----------------------------
203.691 + tRes = True
203.692 + tRes@txFontHeightF = 0.025
203.693 +
203.694 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMax)+")"
203.695 +
203.696 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
203.697 +
203.698 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
203.699 +;-------------------------------
203.700 +;Attach the vertical bar and the horizontal cap line
203.701 +
203.702 + do nd=0,1
203.703 + lnres@gsLineColor = line_colors(nd)
203.704 + do i=0,nx-1
203.705 +
203.706 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
203.707 + .not.ismissing(mx_yvalues(nd,i))) then
203.708 +
203.709 +; Attach the vertical bar, both above and below the marker.
203.710 +
203.711 + x1 = xvalues(nd,i)
203.712 + y1 = yvalues(nd,i)
203.713 + y2 = mn_yvalues(nd,i)
203.714 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
203.715 +
203.716 + y2 = mx_yvalues(nd,i)
203.717 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
203.718 +
203.719 +; Attach the horizontal cap line, both above and below the marker.
203.720 +
203.721 + x1 = xvalues(nd,i) - dx4
203.722 + x2 = xvalues(nd,i) + dx4
203.723 + y1 = mn_yvalues(nd,i)
203.724 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
203.725 +
203.726 + y1 = mx_yvalues(nd,i)
203.727 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
203.728 + end if
203.729 + end do
203.730 + end do
203.731 +
203.732 + draw(xy)
203.733 + frame(wks)
203.734 +
203.735 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.736 + "rm "+plot_name+"."+plot_type)
203.737 +
203.738 + clear (wks)
203.739 +
203.740 + delete (DATA11_1D)
203.741 + delete (DATA12_1D)
203.742 + delete (DATA22_1D)
203.743 +;delete (range)
203.744 +;delete (xvalues)
203.745 + delete (yvalues)
203.746 + delete (mn_yvalues)
203.747 + delete (mx_yvalues)
203.748 + delete (good)
203.749 + delete (max_bar)
203.750 + delete (min_bar)
203.751 + delete (max_cap)
203.752 + delete (min_cap)
203.753 +;-----------------------------------------------------------------
203.754 +;global res
203.755 +
203.756 + resg = True ; Use plot options
203.757 + resg@cnFillOn = True ; Turn on color fill
203.758 + resg@gsnSpreadColors = True ; use full colormap
203.759 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
203.760 +; resg@lbLabelAutoStride = True
203.761 + resg@cnLinesOn = False ; Turn off contourn lines
203.762 + resg@mpFillOn = False ; Turn off map fill
203.763 +
203.764 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
203.765 + resg@cnMinLevelValF = 0. ; Min level
203.766 + resg@cnMaxLevelValF = 10. ; Max level
203.767 + resg@cnLevelSpacingF = 1. ; interval
203.768 +
203.769 +;global contour ob
203.770 +
203.771 + delta = 0.00001
203.772 + laiob_max = where(ismissing(laiob_max).and.(ismissing(laimod_max).or.(laimod_max.lt.delta)),0.,laiob_max)
203.773 +
203.774 + plot_name = "global_max_ob"
203.775 + title = ob_name
203.776 + resg@tiMainString = title
203.777 +
203.778 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
203.779 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.780 +
203.781 + plot_max = gsn_csm_contour_map_ce(wks,laiob_max,resg)
203.782 + frame(wks)
203.783 +
203.784 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.785 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
203.786 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
203.787 + "rm "+plot_name+"."+plot_type)
203.788 +
203.789 + clear (wks)
203.790 +;------------------------------------------------------------------------
203.791 +;global contour model
203.792 +
203.793 + plot_name = "global_max_model"
203.794 + title = "Model " + model_name
203.795 + resg@tiMainString = title
203.796 +
203.797 + wks = gsn_open_wks (plot_type,plot_name)
203.798 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.799 +
203.800 + plot_max = gsn_csm_contour_map_ce(wks,laimod_max,resg)
203.801 + frame(wks)
203.802 +
203.803 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.804 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
203.805 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
203.806 + "rm "+plot_name+"."+plot_type)
203.807 +
203.808 + clear (wks)
203.809 +;------------------------------------------------------------------------
203.810 +;(C) phase
203.811 +;--------------------------------------------------------------------
203.812 +; get data
203.813 +
203.814 +; observed
203.815 + laiob_phase = laiob(0,:,:)
203.816 + s = laiob(:,0,0)
203.817 + laiob_phase@long_name = "Leaf Area Index Max Month"
203.818 +
203.819 + dsizes_z = dimsizes(laiob)
203.820 + nlat = dsizes_z(1)
203.821 + nlon = dsizes_z(2)
203.822 +
203.823 + do j = 0,nlat-1
203.824 + do i = 0,nlon-1
203.825 + s = laiob(:,j,i)
203.826 + laiob_phase(j,i) = maxind(s) + 1
203.827 + end do
203.828 + end do
203.829 +
203.830 +; print (min(laiob_phase)+"/"+max(laiob_phase))
203.831 + delete (s)
203.832 + delete (dsizes_z)
203.833 +;-------------------------
203.834 +; model
203.835 + laimod_phase = laimod(0,:,:)
203.836 + s = laimod(:,0,0)
203.837 + laimod_phase@long_name = "Leaf Area Index Max Month"
203.838 +
203.839 + dsizes_z = dimsizes(laimod)
203.840 + nlat = dsizes_z(1)
203.841 + nlon = dsizes_z(2)
203.842 +
203.843 + do j = 0,nlat-1
203.844 + do i = 0,nlon-1
203.845 + s = laimod(:,j,i)
203.846 + laimod_phase(j,i) = maxind(s) + 1
203.847 + end do
203.848 + end do
203.849 +
203.850 +; print (min(laimod_phase)+"/"+max(laimod_phase))
203.851 + delete (s)
203.852 + delete (dsizes_z)
203.853 +;------------------------
203.854 + DATA11_1D = ndtooned(classob)
203.855 + DATA12_1D = ndtooned(laiob_phase)
203.856 + DATA22_1D = ndtooned(laimod_phase)
203.857 +
203.858 + yvalues = new((/2,nx/),float)
203.859 + mn_yvalues = new((/2,nx/),float)
203.860 + mx_yvalues = new((/2,nx/),float)
203.861 +
203.862 + do nd=0,1
203.863 +
203.864 +; See if we are doing model or observational data.
203.865 +
203.866 + if(nd.eq.0) then
203.867 + data_ob = DATA11_1D
203.868 + data_mod = DATA12_1D
203.869 + else
203.870 + data_ob = DATA11_1D
203.871 + data_mod = DATA22_1D
203.872 + end if
203.873 +
203.874 +; Loop through each range and check for values.
203.875 +
203.876 + do i=0,nr-2
203.877 + if (i.ne.(nr-2)) then
203.878 +; print("")
203.879 +; print("In range ["+range(i)+","+range(i+1)+")")
203.880 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
203.881 + else
203.882 +; print("")
203.883 +; print("In range ["+range(i)+",)")
203.884 + idx = ind(range(i).le.data_ob)
203.885 + end if
203.886 +
203.887 +; Calculate average, and get min and max.
203.888 +
203.889 + if(.not.any(ismissing(idx))) then
203.890 + yvalues(nd,i) = avg(data_mod(idx))
203.891 + mn_yvalues(nd,i) = min(data_mod(idx))
203.892 + mx_yvalues(nd,i) = max(data_mod(idx))
203.893 + count = dimsizes(idx)
203.894 + else
203.895 + count = 0
203.896 + yvalues(nd,i) = yvalues@_FillValue
203.897 + mn_yvalues(nd,i) = yvalues@_FillValue
203.898 + mx_yvalues(nd,i) = yvalues@_FillValue
203.899 + end if
203.900 +
203.901 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
203.902 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
203.903 +
203.904 +; Clean up for next time in loop.
203.905 +
203.906 + delete(idx)
203.907 + end do
203.908 + delete(data_ob)
203.909 + delete(data_mod)
203.910 + end do
203.911 +;-----------------------------------------------------------------
203.912 +; compute correlation coef and M score
203.913 +
203.914 + u = yvalues(0,:)
203.915 + v = yvalues(1,:)
203.916 +
203.917 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
203.918 + uu = u(good)
203.919 + vv = v(good)
203.920 +
203.921 + ccrPhase = esccr(uu,vv,0)
203.922 +; print (ccrPhase)
203.923 +
203.924 +; old eq
203.925 +; bias = abs(avg(vv)-avg(uu))
203.926 +; new eq
203.927 + bias = avg(abs(vv-uu))
203.928 +
203.929 + bias = where((bias.gt. 6.),12.-bias,bias)
203.930 + Mphase = ((6. - bias)/6.)*5.
203.931 +
203.932 + M_lai_phase = sprintf("%.2f", Mphase)
203.933 + system("sed s#M_lai_phase#"+M_lai_phase+"# "+html_name+" > "+html_new+";"+ \
203.934 + "mv -f "+html_new+" "+html_name)
203.935 + print (M_lai_phase)
203.936 +
203.937 + do i=0,nrow-2
203.938 + text4(i,6) = sprintf("%5.2f",u(i))
203.939 + text4(i,7) = sprintf("%5.2f",v(i))
203.940 + text4(i,8) = "-"
203.941 + end do
203.942 + text4(nrow-1,6) = sprintf("%5.2f",avg(u))
203.943 + text4(nrow-1,7) = sprintf("%5.2f",avg(v))
203.944 + text4(nrow-1,8) = sprintf("%5.2f",Mphase)
203.945 +
203.946 + delete (u)
203.947 + delete (v)
203.948 + delete (uu)
203.949 + delete (vv)
203.950 +;--------------------------------------------------------------------
203.951 +; histogram res
203.952 +
203.953 + resm = True
203.954 + resm@gsnMaximize = True
203.955 + resm@gsnDraw = False
203.956 + resm@gsnFrame = False
203.957 + resm@xyMarkLineMode = "Markers"
203.958 + resm@xyMarkerSizeF = 0.014
203.959 + resm@xyMarker = 16
203.960 + resm@xyMarkerColors = (/"Brown","Blue"/)
203.961 +; resm@trYMinF = min(mn_yvalues) - 10.
203.962 +; resm@trYMaxF = max(mx_yvalues) + 10.
203.963 + resm@trYMinF = min(mn_yvalues) - 2
203.964 + resm@trYMaxF = max(mx_yvalues) + 4
203.965 +
203.966 + resm@tiYAxisString = "Max LAI (Leaf Area Index) Month"
203.967 + resm@tiXAxisString = "Land Cover Type"
203.968 +
203.969 + max_bar = new((/2,nx/),graphic)
203.970 + min_bar = new((/2,nx/),graphic)
203.971 + max_cap = new((/2,nx/),graphic)
203.972 + min_cap = new((/2,nx/),graphic)
203.973 +
203.974 + lnres = True
203.975 + line_colors = (/"brown","blue"/)
203.976 +;------------------------------------------------------------------
203.977 +; Start the graphics.
203.978 +
203.979 + plot_name = "histogram_phase"
203.980 + title = model_name + " vs Observed"
203.981 + resm@tiMainString = title
203.982 +
203.983 + wks = gsn_open_wks (plot_type,plot_name)
203.984 +;-----------------------------
203.985 +; Add a boxed legend using the more simple method
203.986 +
203.987 + resm@pmLegendDisplayMode = "Always"
203.988 +; resm@pmLegendWidthF = 0.1
203.989 + resm@pmLegendWidthF = 0.08
203.990 + resm@pmLegendHeightF = 0.05
203.991 + resm@pmLegendOrthogonalPosF = -1.17
203.992 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
203.993 +; resm@pmLegendParallelPosF = 0.18
203.994 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
203.995 +
203.996 +; resm@lgPerimOn = False
203.997 + resm@lgLabelFontHeightF = 0.015
203.998 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
203.999 +;-----------------------------
203.1000 + tRes = True
203.1001 + tRes@txFontHeightF = 0.025
203.1002 +
203.1003 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrPhase)+")"
203.1004 +
203.1005 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
203.1006 +
203.1007 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
203.1008 +;-------------------------------
203.1009 +;Attach the vertical bar and the horizontal cap line
203.1010 +
203.1011 + do nd=0,1
203.1012 + lnres@gsLineColor = line_colors(nd)
203.1013 + do i=0,nx-1
203.1014 +
203.1015 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
203.1016 + .not.ismissing(mx_yvalues(nd,i))) then
203.1017 +
203.1018 +; Attach the vertical bar, both above and below the marker.
203.1019 +
203.1020 + x1 = xvalues(nd,i)
203.1021 + y1 = yvalues(nd,i)
203.1022 + y2 = mn_yvalues(nd,i)
203.1023 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
203.1024 +
203.1025 + y2 = mx_yvalues(nd,i)
203.1026 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
203.1027 +
203.1028 +; Attach the horizontal cap line, both above and below the marker.
203.1029 +
203.1030 + x1 = xvalues(nd,i) - dx4
203.1031 + x2 = xvalues(nd,i) + dx4
203.1032 + y1 = mn_yvalues(nd,i)
203.1033 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
203.1034 +
203.1035 + y1 = mx_yvalues(nd,i)
203.1036 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
203.1037 + end if
203.1038 + end do
203.1039 + end do
203.1040 +
203.1041 + draw(xy)
203.1042 + frame(wks)
203.1043 +
203.1044 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.1045 + "rm "+plot_name+"."+plot_type)
203.1046 +
203.1047 + clear (wks)
203.1048 +
203.1049 + delete (DATA11_1D)
203.1050 + delete (DATA12_1D)
203.1051 + delete (DATA22_1D)
203.1052 +;delete (range)
203.1053 +;delete (xvalues)
203.1054 + delete (yvalues)
203.1055 + delete (mn_yvalues)
203.1056 + delete (mx_yvalues)
203.1057 + delete (good)
203.1058 + delete (max_bar)
203.1059 + delete (min_bar)
203.1060 + delete (max_cap)
203.1061 + delete (min_cap)
203.1062 +;-----------------------------------------------------------------
203.1063 +;global res
203.1064 +
203.1065 + resg = True ; Use plot options
203.1066 + resg@cnFillOn = True ; Turn on color fill
203.1067 + resg@gsnSpreadColors = True ; use full colormap
203.1068 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
203.1069 +; resg@lbLabelAutoStride = True
203.1070 + resg@cnLinesOn = False ; Turn off contourn lines
203.1071 + resg@mpFillOn = False ; Turn off map fill
203.1072 +
203.1073 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
203.1074 + resg@cnMinLevelValF = 1. ; Min level
203.1075 + resg@cnMaxLevelValF = 12. ; Max level
203.1076 + resg@cnLevelSpacingF = 1. ; interval
203.1077 +
203.1078 +;global contour ob
203.1079 +
203.1080 + delta = 0.00001
203.1081 + laiob_phase = where(ismissing(laiob_phase).and.(ismissing(laimod_phase).or.(laimod_phase.lt.delta)),0.,laiob_phase)
203.1082 +
203.1083 + plot_name = "global_phase_ob"
203.1084 + title = ob_name
203.1085 + resg@tiMainString = title
203.1086 +
203.1087 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
203.1088 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.1089 +
203.1090 + plot = gsn_csm_contour_map_ce(wks,laiob_phase,resg)
203.1091 + frame(wks)
203.1092 +
203.1093 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.1094 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
203.1095 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
203.1096 + "rm "+plot_name+"."+plot_type)
203.1097 +
203.1098 + clear (wks)
203.1099 +;------------------------------------------------------------------------
203.1100 +;global contour model
203.1101 +
203.1102 + plot_name = "global_phase_model"
203.1103 + title = "Model " + model_name
203.1104 + resg@tiMainString = title
203.1105 +
203.1106 + wks = gsn_open_wks (plot_type,plot_name)
203.1107 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.1108 +
203.1109 + delete (plot)
203.1110 + plot = gsn_csm_contour_map_ce(wks,laimod_phase,resg)
203.1111 + frame(wks)
203.1112 +
203.1113 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.1114 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
203.1115 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
203.1116 + "rm "+plot_name+"."+plot_type)
203.1117 +
203.1118 + clear (wks)
203.1119 +;-----------------------------------------------------------------
203.1120 +;(D) grow day
203.1121 +;--------------------------------------------------------------------
203.1122 +; get data
203.1123 +
203.1124 + day_of_data = (/31,28,31,30,31,30,31,31,30,31,30,31/)
203.1125 +
203.1126 +; observed
203.1127 + laiob_grow = laiob(0,:,:)
203.1128 + laiob_grow@long_name = "Days of Growing Season"
203.1129 +
203.1130 + dsizes_z = dimsizes(laiob)
203.1131 + ntime = dsizes_z(0)
203.1132 + nlat = dsizes_z(1)
203.1133 + nlon = dsizes_z(2)
203.1134 +
203.1135 + do j = 0,nlat-1
203.1136 + do i = 0,nlon-1
203.1137 + nday = 0.
203.1138 + do k = 0,ntime-1
203.1139 + if (.not. ismissing(laiob(k,j,i)) .and. laiob(k,j,i) .gt. 1.0) then
203.1140 + nday = nday + day_of_data(k)
203.1141 + end if
203.1142 + end do
203.1143 +
203.1144 + laiob_grow(j,i) = nday
203.1145 + end do
203.1146 + end do
203.1147 +
203.1148 +; print (min(laiob_grow)+"/"+max(laiob_grow))
203.1149 +;-------------------------
203.1150 +; model
203.1151 + laimod_grow = laimod(0,:,:)
203.1152 + laimod_grow@long_name = "Days of Growing Season"
203.1153 +
203.1154 + dsizes_z = dimsizes(laimod)
203.1155 + ntime = dsizes_z(0)
203.1156 + nlat = dsizes_z(1)
203.1157 + nlon = dsizes_z(2)
203.1158 +
203.1159 + do j = 0,nlat-1
203.1160 + do i = 0,nlon-1
203.1161 + nday = 0.
203.1162 + do k = 0,ntime-1
203.1163 + if (.not. ismissing(laimod(k,j,i)) .and. laimod(k,j,i) .gt. 1.0) then
203.1164 + nday = nday + day_of_data(k)
203.1165 + end if
203.1166 + end do
203.1167 +
203.1168 + laimod_grow(j,i) = nday
203.1169 + end do
203.1170 + end do
203.1171 +
203.1172 +; print (min(laimod_grow)+"/"+max(laimod_grow))
203.1173 +;------------------------
203.1174 + DATA11_1D = ndtooned(classob)
203.1175 + DATA12_1D = ndtooned(laiob_grow)
203.1176 + DATA22_1D = ndtooned(laimod_grow)
203.1177 +
203.1178 + yvalues = new((/2,nx/),float)
203.1179 + mn_yvalues = new((/2,nx/),float)
203.1180 + mx_yvalues = new((/2,nx/),float)
203.1181 +
203.1182 + do nd=0,1
203.1183 +
203.1184 +; See if we are doing model or observational data.
203.1185 +
203.1186 + if(nd.eq.0) then
203.1187 + data_ob = DATA11_1D
203.1188 + data_mod = DATA12_1D
203.1189 + else
203.1190 + data_ob = DATA11_1D
203.1191 + data_mod = DATA22_1D
203.1192 + end if
203.1193 +
203.1194 +; Loop through each range and check for values.
203.1195 +
203.1196 + do i=0,nr-2
203.1197 + if (i.ne.(nr-2)) then
203.1198 +; print("")
203.1199 +; print("In range ["+range(i)+","+range(i+1)+")")
203.1200 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
203.1201 + else
203.1202 +; print("")
203.1203 +; print("In range ["+range(i)+",)")
203.1204 + idx = ind(range(i).le.data_ob)
203.1205 + end if
203.1206 +
203.1207 +; Calculate average, and get min and max.
203.1208 +
203.1209 + if(.not.any(ismissing(idx))) then
203.1210 + yvalues(nd,i) = avg(data_mod(idx))
203.1211 + mn_yvalues(nd,i) = min(data_mod(idx))
203.1212 + mx_yvalues(nd,i) = max(data_mod(idx))
203.1213 + count = dimsizes(idx)
203.1214 + else
203.1215 + count = 0
203.1216 + yvalues(nd,i) = yvalues@_FillValue
203.1217 + mn_yvalues(nd,i) = yvalues@_FillValue
203.1218 + mx_yvalues(nd,i) = yvalues@_FillValue
203.1219 + end if
203.1220 +
203.1221 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
203.1222 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
203.1223 +
203.1224 +; Clean up for next time in loop.
203.1225 +
203.1226 + delete(idx)
203.1227 + end do
203.1228 + delete(data_ob)
203.1229 + delete(data_mod)
203.1230 + end do
203.1231 +;-----------------------------------------------------------------
203.1232 +; compute correlation coef and M score
203.1233 +
203.1234 + u = yvalues(0,:)
203.1235 + v = yvalues(1,:)
203.1236 +
203.1237 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
203.1238 + uu = u(good)
203.1239 + vv = v(good)
203.1240 +
203.1241 + ccrGrow = esccr(uu,vv,0)
203.1242 +; print (ccrGrow)
203.1243 +
203.1244 +; new eq
203.1245 + bias = sum(abs(vv-uu)/(vv+uu))
203.1246 + Mgrow = (1.- (bias/dimsizes(uu)))*5.
203.1247 +
203.1248 + M_lai_grow = sprintf("%.2f", Mgrow)
203.1249 + system("sed s#M_lai_grow#"+M_lai_grow+"# "+html_name+" > "+html_new+";"+ \
203.1250 + "mv -f "+html_new+" "+html_name)
203.1251 + print (M_lai_grow)
203.1252 +
203.1253 + do i=0,nrow-2
203.1254 + text4(i,9) = sprintf("%5.2f",u(i))
203.1255 + text4(i,10) = sprintf("%5.2f",v(i))
203.1256 + text4(i,11) = "-"
203.1257 + end do
203.1258 + text4(nrow-1,9) = sprintf("%5.2f",avg(u))
203.1259 + text4(nrow-1,10) = sprintf("%5.2f",avg(v))
203.1260 + text4(nrow-1,11) = sprintf("%5.2f",Mgrow)
203.1261 +
203.1262 + delete (u)
203.1263 + delete (v)
203.1264 + delete (uu)
203.1265 + delete (vv)
203.1266 +;--------------------------------------------------------------------
203.1267 +; histogram res
203.1268 +
203.1269 + resm = True
203.1270 + resm@gsnMaximize = True
203.1271 + resm@gsnDraw = False
203.1272 + resm@gsnFrame = False
203.1273 + resm@xyMarkLineMode = "Markers"
203.1274 + resm@xyMarkerSizeF = 0.014
203.1275 + resm@xyMarker = 16
203.1276 + resm@xyMarkerColors = (/"Brown","Blue"/)
203.1277 +; resm@trYMinF = min(mn_yvalues) - 10.
203.1278 +; resm@trYMaxF = max(mx_yvalues) + 10.
203.1279 + resm@trYMinF = min(mn_yvalues) - 2
203.1280 + resm@trYMaxF = max(mx_yvalues) + 4
203.1281 +
203.1282 + resm@tiYAxisString = "Days of Growing season"
203.1283 + resm@tiXAxisString = "Land Cover Type"
203.1284 +
203.1285 + max_bar = new((/2,nx/),graphic)
203.1286 + min_bar = new((/2,nx/),graphic)
203.1287 + max_cap = new((/2,nx/),graphic)
203.1288 + min_cap = new((/2,nx/),graphic)
203.1289 +
203.1290 + lnres = True
203.1291 + line_colors = (/"brown","blue"/)
203.1292 +;------------------------------------------------------------------
203.1293 +; Start the graphics.
203.1294 +
203.1295 + plot_name = "histogram_grow"
203.1296 + title = model_name + " vs Observed"
203.1297 + resm@tiMainString = title
203.1298 +
203.1299 + wks = gsn_open_wks (plot_type,plot_name)
203.1300 +;-----------------------------
203.1301 +; Add a boxed legend using the more simple method
203.1302 +
203.1303 + resm@pmLegendDisplayMode = "Always"
203.1304 +; resm@pmLegendWidthF = 0.1
203.1305 + resm@pmLegendWidthF = 0.08
203.1306 + resm@pmLegendHeightF = 0.05
203.1307 + resm@pmLegendOrthogonalPosF = -1.17
203.1308 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
203.1309 +; resm@pmLegendParallelPosF = 0.18
203.1310 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
203.1311 +
203.1312 +; resm@lgPerimOn = False
203.1313 + resm@lgLabelFontHeightF = 0.015
203.1314 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
203.1315 +;-----------------------------
203.1316 + tRes = True
203.1317 + tRes@txFontHeightF = 0.025
203.1318 +
203.1319 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrGrow)+")"
203.1320 +
203.1321 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
203.1322 +
203.1323 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
203.1324 +;-------------------------------
203.1325 +;Attach the vertical bar and the horizontal cap line
203.1326 +
203.1327 + do nd=0,1
203.1328 + lnres@gsLineColor = line_colors(nd)
203.1329 + do i=0,nx-1
203.1330 +
203.1331 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
203.1332 + .not.ismissing(mx_yvalues(nd,i))) then
203.1333 +
203.1334 +; Attach the vertical bar, both above and below the marker.
203.1335 +
203.1336 + x1 = xvalues(nd,i)
203.1337 + y1 = yvalues(nd,i)
203.1338 + y2 = mn_yvalues(nd,i)
203.1339 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
203.1340 +
203.1341 + y2 = mx_yvalues(nd,i)
203.1342 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
203.1343 +
203.1344 +; Attach the horizontal cap line, both above and below the marker.
203.1345 +
203.1346 + x1 = xvalues(nd,i) - dx4
203.1347 + x2 = xvalues(nd,i) + dx4
203.1348 + y1 = mn_yvalues(nd,i)
203.1349 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
203.1350 +
203.1351 + y1 = mx_yvalues(nd,i)
203.1352 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
203.1353 + end if
203.1354 + end do
203.1355 + end do
203.1356 +
203.1357 + draw(xy)
203.1358 + frame(wks)
203.1359 +
203.1360 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.1361 + "rm "+plot_name+"."+plot_type)
203.1362 +
203.1363 + clear (wks)
203.1364 +
203.1365 + delete (DATA11_1D)
203.1366 + delete (DATA12_1D)
203.1367 + delete (DATA22_1D)
203.1368 +;delete (range)
203.1369 +;delete (xvalues)
203.1370 + delete (yvalues)
203.1371 + delete (mn_yvalues)
203.1372 + delete (mx_yvalues)
203.1373 + delete (good)
203.1374 + delete (max_bar)
203.1375 + delete (min_bar)
203.1376 + delete (max_cap)
203.1377 + delete (min_cap)
203.1378 +;-----------------------------------------------------------------
203.1379 +;global res
203.1380 +
203.1381 + resg = True ; Use plot options
203.1382 + resg@cnFillOn = True ; Turn on color fill
203.1383 + resg@gsnSpreadColors = True ; use full colormap
203.1384 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
203.1385 +; resg@lbLabelAutoStride = True
203.1386 + resg@cnLinesOn = False ; Turn off contourn lines
203.1387 + resg@mpFillOn = False ; Turn off map fill
203.1388 +
203.1389 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
203.1390 + resg@cnMinLevelValF = 60. ; Min level
203.1391 + resg@cnMaxLevelValF = 360. ; Max level
203.1392 + resg@cnLevelSpacingF = 20. ; interval
203.1393 +
203.1394 +;global contour ob
203.1395 +
203.1396 + laiob_grow@_FillValue = 1.e+36
203.1397 + laiob_grow = where(laiob_grow .lt. 10.,laiob_grow@_FillValue,laiob_grow)
203.1398 +
203.1399 + plot_name = "global_grow_ob"
203.1400 + title = ob_name
203.1401 + resg@tiMainString = title
203.1402 +
203.1403 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
203.1404 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.1405 +
203.1406 + plot = gsn_csm_contour_map_ce(wks,laiob_grow,resg)
203.1407 + frame(wks)
203.1408 +
203.1409 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.1410 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
203.1411 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
203.1412 + "rm "+plot_name+"."+plot_type)
203.1413 +
203.1414 + clear (wks)
203.1415 +;------------------------------------------------------------------------
203.1416 +;global contour model
203.1417 +
203.1418 + laimod_grow@_FillValue = 1.e+36
203.1419 + laimod_grow = where(laimod_grow .lt. 10.,laimod_grow@_FillValue,laimod_grow)
203.1420 +
203.1421 + plot_name = "global_grow_model"
203.1422 + title = "Model " + model_name
203.1423 + resg@tiMainString = title
203.1424 +
203.1425 + wks = gsn_open_wks (plot_type,plot_name)
203.1426 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.1427 +
203.1428 + delete (plot)
203.1429 + plot = gsn_csm_contour_map_ce(wks,laimod_grow,resg)
203.1430 + frame(wks)
203.1431 +
203.1432 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.1433 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
203.1434 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
203.1435 + "rm "+plot_name+"."+plot_type)
203.1436 +
203.1437 + clear (wks)
203.1438 +;------------------------------------------------------------------------
203.1439 +;global contour model vs ob
203.1440 +
203.1441 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
203.1442 + resg@cnMinLevelValF = 0. ; Min level
203.1443 + resg@cnMaxLevelValF = 10. ; Max level
203.1444 + resg@cnLevelSpacingF = 1. ; interval
203.1445 +
203.1446 + plot_name = "global_mean_model_vs_ob"
203.1447 +
203.1448 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
203.1449 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.1450 +
203.1451 + delete (plot)
203.1452 + plot=new(3,graphic) ; create graphic array
203.1453 +
203.1454 + resg@gsnFrame = False ; Do not draw plot
203.1455 + resg@gsnDraw = False ; Do not advance frame
203.1456 +
203.1457 +; plot correlation coef
203.1458 +
203.1459 + gRes = True
203.1460 + gRes@txFontHeightF = 0.02
203.1461 + gRes@txAngleF = 90
203.1462 +
203.1463 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMean)+")"
203.1464 +
203.1465 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
203.1466 +;--------------------------------------------------------------------
203.1467 +
203.1468 +;(a) ob
203.1469 +
203.1470 + title = ob_name
203.1471 + resg@tiMainString = title
203.1472 +
203.1473 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_mean,resg)
203.1474 +
203.1475 +;(b) model
203.1476 +
203.1477 + title = "Model "+ model_name
203.1478 + resg@tiMainString = title
203.1479 +
203.1480 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_mean,resg)
203.1481 +
203.1482 +;(c) model-ob
203.1483 +
203.1484 + zz = laimod_mean
203.1485 + zz = laimod_mean - laiob_mean
203.1486 + title = "Model_"+model_name+" - Observed"
203.1487 + resg@tiMainString = title
203.1488 +
203.1489 + resg@cnMinLevelValF = -2. ; Min level
203.1490 + resg@cnMaxLevelValF = 2. ; Max level
203.1491 + resg@cnLevelSpacingF = 0.4 ; interval
203.1492 +
203.1493 +
203.1494 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
203.1495 +
203.1496 + pres = True ; panel plot mods desired
203.1497 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
203.1498 + ; indiv. plots in panel
203.1499 + pres@gsnMaximize = True ; fill the page
203.1500 +
203.1501 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
203.1502 +
203.1503 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.1504 + "rm "+plot_name+"."+plot_type)
203.1505 +
203.1506 + clear (wks)
203.1507 + delete (plot)
203.1508 +;-----------------------------------------------------------------
203.1509 +;global contour model vs ob
203.1510 +
203.1511 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
203.1512 + resg@cnMinLevelValF = 0. ; Min level
203.1513 + resg@cnMaxLevelValF = 10. ; Max level
203.1514 + resg@cnLevelSpacingF = 1. ; interval
203.1515 +
203.1516 + plot_name = "global_max_model_vs_ob"
203.1517 +
203.1518 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
203.1519 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.1520 +
203.1521 +; delete(plot)
203.1522 + plot=new(3,graphic) ; create graphic array
203.1523 +
203.1524 + resg@gsnFrame = False ; Do not draw plot
203.1525 + resg@gsnDraw = False ; Do not advance frame
203.1526 +
203.1527 +; plot correlation coef
203.1528 +
203.1529 + gRes = True
203.1530 + gRes@txFontHeightF = 0.02
203.1531 + gRes@txAngleF = 90
203.1532 +
203.1533 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMax)+")"
203.1534 +
203.1535 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
203.1536 +;--------------------------------------------------------------------
203.1537 +;(a) ob
203.1538 +
203.1539 + title = ob_name
203.1540 + resg@tiMainString = title
203.1541 +
203.1542 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_max,resg)
203.1543 +
203.1544 +;(b) model
203.1545 +
203.1546 + title = "Model "+ model_name
203.1547 + resg@tiMainString = title
203.1548 +
203.1549 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_max,resg)
203.1550 +
203.1551 +;(c) model-ob
203.1552 +
203.1553 + delete (zz)
203.1554 + zz = laimod_max
203.1555 + zz = laimod_max - laiob_max
203.1556 + title = "Model_"+model_name+" - Observed"
203.1557 + resg@tiMainString = title
203.1558 +
203.1559 + resg@cnMinLevelValF = -6. ; Min level
203.1560 + resg@cnMaxLevelValF = 6. ; Max level
203.1561 + resg@cnLevelSpacingF = 1. ; interval
203.1562 +
203.1563 +
203.1564 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
203.1565 +
203.1566 + pres = True ; panel plot mods desired
203.1567 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
203.1568 + ; indiv. plots in panel
203.1569 + pres@gsnMaximize = True ; fill the page
203.1570 +
203.1571 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
203.1572 +
203.1573 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.1574 + "rm "+plot_name+"."+plot_type)
203.1575 +
203.1576 + clear (wks)
203.1577 + delete (plot)
203.1578 +;-----------------------------------------------------------------
203.1579 +;global contour model vs ob
203.1580 +
203.1581 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
203.1582 + resg@cnMinLevelValF = 1. ; Min level
203.1583 + resg@cnMaxLevelValF = 12. ; Max level
203.1584 + resg@cnLevelSpacingF = 1. ; interval
203.1585 +
203.1586 + plot_name = "global_phase_model_vs_ob"
203.1587 +
203.1588 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
203.1589 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.1590 +
203.1591 +; delete (plot)
203.1592 + plot=new(3,graphic) ; create graphic array
203.1593 +
203.1594 + resg@gsnFrame = False ; Do not draw plot
203.1595 + resg@gsnDraw = False ; Do not advance frame
203.1596 +
203.1597 +; plot correlation coef
203.1598 +
203.1599 + gRes = True
203.1600 + gRes@txFontHeightF = 0.02
203.1601 + gRes@txAngleF = 90
203.1602 +
203.1603 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrPhase)+")"
203.1604 +
203.1605 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
203.1606 +;--------------------------------------------------------------------
203.1607 +;(a) ob
203.1608 +
203.1609 + title = ob_name
203.1610 + resg@tiMainString = title
203.1611 +
203.1612 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_phase,resg)
203.1613 +
203.1614 +;(b) model
203.1615 +
203.1616 + title = "Model "+ model_name
203.1617 + resg@tiMainString = title
203.1618 +
203.1619 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_phase,resg)
203.1620 +
203.1621 +;(c) model-ob
203.1622 +
203.1623 + delete (zz)
203.1624 + zz = laimod_phase
203.1625 + zz = laimod_phase - laiob_phase
203.1626 + title = "Model_"+model_name+" - Observed"
203.1627 + resg@tiMainString = title
203.1628 +
203.1629 + resg@cnMinLevelValF = -6. ; Min level
203.1630 + resg@cnMaxLevelValF = 6. ; Max level
203.1631 + resg@cnLevelSpacingF = 1. ; interval
203.1632 +
203.1633 +
203.1634 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
203.1635 +
203.1636 + pres = True ; panel plot mods desired
203.1637 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
203.1638 + ; indiv. plots in panel
203.1639 + pres@gsnMaximize = True ; fill the page
203.1640 +
203.1641 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
203.1642 +
203.1643 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.1644 + "rm "+plot_name+"."+plot_type)
203.1645 +
203.1646 + clear (wks)
203.1647 + delete (plot)
203.1648 +;------------------------------------------------------------------
203.1649 +;global contour model vs ob
203.1650 +
203.1651 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
203.1652 + resg@cnMinLevelValF = 60. ; Min level
203.1653 + resg@cnMaxLevelValF = 360. ; Max level
203.1654 + resg@cnLevelSpacingF = 20. ; interval
203.1655 +
203.1656 + plot_name = "global_grow_model_vs_ob"
203.1657 +
203.1658 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
203.1659 + gsn_define_colormap(wks,"gui_default") ; choose colormap
203.1660 +
203.1661 +; delete (plot)
203.1662 + plot=new(3,graphic) ; create graphic array
203.1663 +
203.1664 + resg@gsnFrame = False ; Do not draw plot
203.1665 + resg@gsnDraw = False ; Do not advance frame
203.1666 +
203.1667 +; plot correlation coef
203.1668 +
203.1669 + gRes = True
203.1670 + gRes@txFontHeightF = 0.02
203.1671 + gRes@txAngleF = 90
203.1672 +
203.1673 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrGrow)+")"
203.1674 +
203.1675 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
203.1676 +;--------------------------------------------------------------------
203.1677 +;(a) ob
203.1678 +
203.1679 + title = ob_name
203.1680 + resg@tiMainString = title
203.1681 +
203.1682 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_grow,resg)
203.1683 +
203.1684 +;(b) model
203.1685 +
203.1686 + title = "Model "+ model_name
203.1687 + resg@tiMainString = title
203.1688 +
203.1689 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_grow,resg)
203.1690 +
203.1691 +;(c) model-ob
203.1692 +
203.1693 + delete (zz)
203.1694 + zz = laimod_grow
203.1695 + zz = laimod_grow - laiob_grow
203.1696 + title = "Model_"+model_name+" - Observed"
203.1697 + resg@tiMainString = title
203.1698 +
203.1699 + resg@cnMinLevelValF = -100. ; Min level
203.1700 + resg@cnMaxLevelValF = 100. ; Max level
203.1701 + resg@cnLevelSpacingF = 20. ; interval
203.1702 +
203.1703 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
203.1704 +
203.1705 + pres = True ; panel plot mods desired
203.1706 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
203.1707 + ; indiv. plots in panel
203.1708 + pres@gsnMaximize = True ; fill the page
203.1709 +
203.1710 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
203.1711 +
203.1712 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.1713 + "rm "+plot_name+"."+plot_type)
203.1714 +
203.1715 + clear (wks)
203.1716 + delete (plot)
203.1717 +;**************************************************
203.1718 +; plot lai table
203.1719 +;**************************************************
203.1720 +
203.1721 + plot_name = "table_lai"
203.1722 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
203.1723 +
203.1724 + gsn_table(wks,ncr1,xx1,yy1,text1,res1)
203.1725 + gsn_table(wks,ncr21,xx21,yy21,text21,res21)
203.1726 + gsn_table(wks,ncr22,xx22,yy22,text22,res22)
203.1727 + gsn_table(wks,ncr3,xx3,yy3,text3,res3)
203.1728 + gsn_table(wks,ncr4,xx4,yy4,text4,res4)
203.1729 +
203.1730 + frame(wks)
203.1731 +
203.1732 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
203.1733 + "rm "+plot_name+"."+plot_type)
203.1734 +;-------------------------------------------------------------------
203.1735 + temp_name = "lai." + model_name
203.1736 + system("mkdir -p " + temp_name+";"+ \
203.1737 + "cp "+ html_name + " " +temp_name+"/table.html"+";"+ \
203.1738 + "mv *.png " + temp_name +";"+ \
203.1739 + "tar cf "+ temp_name +".tar " + temp_name)
203.1740 +;-------------------------------------------------------------------
203.1741 +end
203.1742 +
204.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
204.2 +++ b/lai/99.all.ncl.0 Mon Jan 26 22:08:20 2009 -0500
204.3 @@ -0,0 +1,1747 @@
204.4 +;********************************************************
204.5 +; histogram normalized by rain and compute correleration
204.6 +;********************************************************
204.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
204.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
204.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
204.10 +
204.11 +procedure pminmax(data:numeric,name:string)
204.12 +begin
204.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
204.14 + if(isatt(data,"units")) then
204.15 + print (name + " units = " + data@units)
204.16 + end if
204.17 +end
204.18 +
204.19 +; Main code.
204.20 +begin
204.21 +
204.22 + nclass = 20
204.23 +
204.24 + plot_type = "ps"
204.25 + plot_type_new = "png"
204.26 +
204.27 +;************************************************
204.28 +; read in data: model
204.29 +;************************************************
204.30 +;film = "b30.061n_1995-2004_MONS_climo_lnd.nc"
204.31 +;model_name = "b30.061n"
204.32 +;model_grid = "T31"
204.33 +
204.34 +;film = "newcn05_ncep_1i_MONS_climo_lnd.nc"
204.35 +;model_name = "newcn"
204.36 +;model_grid = "1.9"
204.37 +
204.38 +;film = "i01.06cn_1798-2004_MONS_climo.nc"
204.39 +;model_name = "06cn"
204.40 +;model_grid = "T42"
204.41 +
204.42 +;film = "i01.06casa_1798-2004_MONS_climo.nc"
204.43 +;model_name = "06casa"
204.44 +;model_grid = "T42"
204.45 +
204.46 +;film = "i01.10cn_1948-2004_MONS_climo.nc"
204.47 +;model_name = "10cn"
204.48 +;model_grid = "T42"
204.49 +
204.50 + film = "i01.10casa_1948-2004_MONS_climo.nc"
204.51 + model_name = "10casa"
204.52 + model_grid = "T42"
204.53 +;------------------------------------------------
204.54 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
204.55 + fm = addfile(dirm+film,"r")
204.56 +
204.57 + laimod = fm->TLAI
204.58 +
204.59 +;************************************************
204.60 +; read in data: observed
204.61 +;************************************************
204.62 +
204.63 + ob_name = "MODIS MOD 15A2 2000-2005"
204.64 +
204.65 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
204.66 + filo1 = "land_class_"+model_grid+".nc"
204.67 + filo2 = "LAI_2000-2005_MONS_"+model_grid+".nc"
204.68 +
204.69 + fo1 = addfile(diro+filo1,"r")
204.70 + fo2 = addfile(diro+filo2,"r")
204.71 +
204.72 + classob = tofloat(fo1->LAND_CLASS)
204.73 + laiob = fo2->LAI
204.74 +
204.75 +;*******************************************************************
204.76 +; for plotting table
204.77 +;*******************************************************************
204.78 +; table header name
204.79 + table_header_name = "LAI"
204.80 +
204.81 +; column (not including header column)
204.82 +
204.83 + col_header1 = (/"Mean","Max","Phase","Growth"/)
204.84 + col_header2 = (/"ob","model","M" \
204.85 + ,"ob","model","M" \
204.86 + ,"ob","model","M" \
204.87 + ,"ob","model","M" \
204.88 + /)
204.89 +
204.90 + ncol1 = dimsizes(col_header1)
204.91 + ncol2 = dimsizes(col_header2)
204.92 + ncol = ncol2
204.93 +
204.94 +; row (not including header row)
204.95 + row_header = (/"Water Bodies" \
204.96 + ,"Evergreen Needleleaf Forests" \
204.97 + ,"Evergreen Broadleaf Forests" \
204.98 + ,"Deciduous Needleleaf Forest" \
204.99 + ,"Deciduous Broadleaf Forests" \
204.100 + ,"Mixed Forests" \
204.101 + ,"Closed Bushlands" \
204.102 + ,"Open Bushlands" \
204.103 + ,"Woody Savannas (S. Hem.)" \
204.104 + ,"Savannas (S. Hem.)" \
204.105 + ,"Grasslands" \
204.106 + ,"Permanent Wetlands" \
204.107 + ,"Croplands" \
204.108 + ,"Urban and Built-Up" \
204.109 + ,"Cropland/Natural Vegetation Mosaic" \
204.110 + ,"Permanent Snow and Ice" \
204.111 + ,"Barren or Sparsely Vegetated" \
204.112 + ,"Unclassified" \
204.113 + ,"Woody Savannas (N. Hem.)" \
204.114 + ,"Savannas (N. Hem.)" \
204.115 + ,"All biome average" \
204.116 + /)
204.117 + nrow = dimsizes(row_header)
204.118 +
204.119 +; arrays to be passed to table.
204.120 + value = new ((/nrow, ncol/),string )
204.121 +
204.122 + table_length = 0.995
204.123 +
204.124 +; Table header
204.125 + ncr1 = (/1,1/) ; 1 row, 1 column
204.126 + xx1 = (/0.005,0.25/) ; Start and end X
204.127 + yy1 = (/0.900,0.995/) ; Start and end Y
204.128 + text1 = table_header_name
204.129 + res1 = True
204.130 + res1@txFontHeightF = 0.03
204.131 + res1@gsFillColor = "CornFlowerBlue"
204.132 +
204.133 +; Column header (equally space in x2)
204.134 + ncr21 = (/1,ncol1/) ; 1 rows, 4 columns
204.135 + xx21 = (/xx1(1),0.995/) ; start from end of x1
204.136 + yy21 = (/0.9475,0.995/) ; half of y1
204.137 + text21 = col_header1
204.138 + res21 = True
204.139 + res21@txFontHeightF = 0.015
204.140 + res21@gsFillColor = "Gray"
204.141 +
204.142 + ncr22 = (/1,ncol2/) ; 1 rows, 12 columns
204.143 + xx22 = xx21 ; start from end of x1
204.144 + yy22 = (/0.900,0.9475/) ; half of y1
204.145 + text22 = col_header2
204.146 + res22 = True
204.147 + res22@txFontHeightF = 0.015
204.148 + res22@gsFillColor = "Gray"
204.149 +
204.150 +; Row header (equally space in y2)
204.151 + ncr3 = (/nrow,1/) ; 20 rows, 1 columns
204.152 + xx3 = xx1 ; same as x1
204.153 + yy3 = (/1.0-table_length,0.900/) ; end at start of y1
204.154 + text3 = row_header
204.155 + res3 = True
204.156 + res3@txFontHeightF = 0.01
204.157 + res3@gsFillColor = "Gray"
204.158 +
204.159 +; Main table body
204.160 + ncr4 = (/nrow,ncol/) ; 5 rows, 5 columns
204.161 + xx4 = xx21 ; Start and end x
204.162 + yy4 = yy3 ; Start and end Y
204.163 + text4 = new((/nrow,ncol/),string)
204.164 +
204.165 + color_fill4 = new((/nrow,ncol/),string)
204.166 + color_fill4 = "white"
204.167 + color_fill4(nrow-1,:) = "CornFlowerBlue"
204.168 +
204.169 + res4 = True ; Set up resource list
204.170 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
204.171 + res4@txFontHeightF = 0.015
204.172 + res4@gsFillColor = color_fill4
204.173 +
204.174 + delete (color_fill4)
204.175 +
204.176 +;************************************************
204.177 +; plot global land class: observed
204.178 +;************************************************
204.179 +;global res
204.180 +
204.181 + resg = True ; Use plot options
204.182 + resg@cnFillOn = True ; Turn on color fill
204.183 + resg@gsnSpreadColors = True ; use full colormap
204.184 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
204.185 +; resg@lbLabelAutoStride = True
204.186 + resg@cnLinesOn = False ; Turn off contourn lines
204.187 + resg@mpFillOn = False ; Turn off map fill
204.188 +
204.189 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
204.190 + resg@cnMinLevelValF = 1. ; Min level
204.191 + resg@cnMaxLevelValF = 19. ; Max level
204.192 + resg@cnLevelSpacingF = 1. ; interval
204.193 +
204.194 +;global contour ob
204.195 + classob@_FillValue = 1.e+36
204.196 + classob = where(classob.eq.0,classob@_FillValue,classob)
204.197 +
204.198 + plot_name = "global_class_ob"
204.199 + title = ob_name
204.200 + resg@tiMainString = title
204.201 +
204.202 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
204.203 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.204 +
204.205 + plot = gsn_csm_contour_map_ce(wks,classob,resg)
204.206 + frame(wks)
204.207 +
204.208 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.209 + system("rm "+plot_name+"."+plot_type)
204.210 + system("rm "+plot_name+"-1."+plot_type_new)
204.211 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.212 +
204.213 + clear (wks)
204.214 +;*******************************************************************
204.215 +; Calculate "nice" bins for binning the data in equally spaced ranges
204.216 +;********************************************************************
204.217 + nclassn = nclass + 1
204.218 + range = fspan(0,nclassn-1,nclassn)
204.219 +; print (range)
204.220 +
204.221 +; Use this range information to grab all the values in a
204.222 +; particular range, and then take an average.
204.223 +
204.224 + nr = dimsizes(range)
204.225 + nx = nr-1
204.226 + xvalues = new((/2,nx/),float)
204.227 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
204.228 + dx = xvalues(0,1) - xvalues(0,0) ; range width
204.229 + dx4 = dx/4 ; 1/4 of the range
204.230 + xvalues(1,:) = xvalues(0,:) - dx/5.
204.231 +;-----------------------------------------------------------------
204.232 +;(A) mean
204.233 +;--------------------------------------------------------------------
204.234 +; get data
204.235 +
204.236 + laiob_mean = dim_avg_Wrap(laiob(lat|:,lon|:,time|:))
204.237 + laimod_mean = dim_avg_Wrap(laimod(lat|:,lon|:,time|:))
204.238 +
204.239 + DATA11_1D = ndtooned(classob)
204.240 + DATA12_1D = ndtooned(laiob_mean)
204.241 + DATA22_1D = ndtooned(laimod_mean)
204.242 +
204.243 + yvalues = new((/2,nx/),float)
204.244 + mn_yvalues = new((/2,nx/),float)
204.245 + mx_yvalues = new((/2,nx/),float)
204.246 +
204.247 + do nd=0,1
204.248 +
204.249 +; See if we are doing model or observational data.
204.250 +
204.251 + if(nd.eq.0) then
204.252 + data_ob = DATA11_1D
204.253 + data_mod = DATA12_1D
204.254 + else
204.255 + data_ob = DATA11_1D
204.256 + data_mod = DATA22_1D
204.257 + end if
204.258 +
204.259 +; Loop through each range and check for values.
204.260 +
204.261 + do i=0,nr-2
204.262 + if (i.ne.(nr-2)) then
204.263 +; print("")
204.264 +; print("In range ["+range(i)+","+range(i+1)+")")
204.265 + idx = ind((data_ob.ge.range(i)).and.(data_ob.lt.range(i+1)))
204.266 + else
204.267 +; print("")
204.268 +; print("In range ["+range(i)+",)")
204.269 + idx = ind(data_ob.ge.range(i))
204.270 + end if
204.271 +
204.272 +; Calculate average, and get min and max.
204.273 +
204.274 + if(.not.any(ismissing(idx))) then
204.275 + yvalues(nd,i) = avg(data_mod(idx))
204.276 + mn_yvalues(nd,i) = min(data_mod(idx))
204.277 + mx_yvalues(nd,i) = max(data_mod(idx))
204.278 + count = dimsizes(idx)
204.279 + else
204.280 + count = 0
204.281 + yvalues(nd,i) = yvalues@_FillValue
204.282 + mn_yvalues(nd,i) = yvalues@_FillValue
204.283 + mx_yvalues(nd,i) = yvalues@_FillValue
204.284 + end if
204.285 +
204.286 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
204.287 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
204.288 +
204.289 +; Clean up for next time in loop.
204.290 +
204.291 + delete(idx)
204.292 + end do
204.293 + delete(data_ob)
204.294 + delete(data_mod)
204.295 + end do
204.296 +;-----------------------------------------------------------------
204.297 +; compute correlation coef and M score
204.298 +
204.299 + u = yvalues(0,:)
204.300 + v = yvalues(1,:)
204.301 +
204.302 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
204.303 + uu = u(good)
204.304 + vv = v(good)
204.305 +
204.306 + ccrMean = esccr(uu,vv,0)
204.307 +; print (ccrMean)
204.308 +
204.309 +; new eq
204.310 + bias = sum(abs(vv-uu)/(vv+uu))
204.311 + Mmean = (1.- (bias/dimsizes(uu)))*5.
204.312 +
204.313 + print (Mmean)
204.314 +
204.315 + do i=0,nrow-2
204.316 + text4(i,0) = sprintf("%5.2f",u(i))
204.317 + text4(i,1) = sprintf("%5.2f",v(i))
204.318 + text4(i,2) = "-"
204.319 + end do
204.320 + text4(nrow-1,0) = sprintf("%5.2f",avg(u))
204.321 + text4(nrow-1,1) = sprintf("%5.2f",avg(v))
204.322 + text4(nrow-1,2) = sprintf("%5.2f",Mmean)
204.323 +
204.324 + delete (u)
204.325 + delete (v)
204.326 + delete (uu)
204.327 + delete (vv)
204.328 +;--------------------------------------------------------------------
204.329 +; histogram res
204.330 +
204.331 + resm = True
204.332 + resm@gsnMaximize = True
204.333 + resm@gsnDraw = False
204.334 + resm@gsnFrame = False
204.335 + resm@xyMarkLineMode = "Markers"
204.336 + resm@xyMarkerSizeF = 0.014
204.337 + resm@xyMarker = 16
204.338 + resm@xyMarkerColors = (/"Brown","Blue"/)
204.339 +; resm@trYMinF = min(mn_yvalues) - 10.
204.340 +; resm@trYMaxF = max(mx_yvalues) + 10.
204.341 + resm@trYMinF = min(mn_yvalues) - 2
204.342 + resm@trYMaxF = max(mx_yvalues) + 4
204.343 +
204.344 + resm@tiYAxisString = "Mean LAI (Leaf Area Index)"
204.345 + resm@tiXAxisString = "Land Cover Type"
204.346 +
204.347 + max_bar = new((/2,nx/),graphic)
204.348 + min_bar = new((/2,nx/),graphic)
204.349 + max_cap = new((/2,nx/),graphic)
204.350 + min_cap = new((/2,nx/),graphic)
204.351 +
204.352 + lnres = True
204.353 + line_colors = (/"brown","blue"/)
204.354 +;------------------------------------------------------------------
204.355 +; Start the graphics.
204.356 +
204.357 + plot_name = "histogram_mean"
204.358 + title = model_name + " vs Observed"
204.359 + resm@tiMainString = title
204.360 +
204.361 + wks = gsn_open_wks (plot_type,plot_name)
204.362 +;-----------------------------
204.363 +; Add a boxed legend using the more simple method
204.364 +
204.365 + resm@pmLegendDisplayMode = "Always"
204.366 +; resm@pmLegendWidthF = 0.1
204.367 + resm@pmLegendWidthF = 0.08
204.368 + resm@pmLegendHeightF = 0.05
204.369 + resm@pmLegendOrthogonalPosF = -1.17
204.370 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
204.371 +; resm@pmLegendParallelPosF = 0.18
204.372 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
204.373 +
204.374 +; resm@lgPerimOn = False
204.375 + resm@lgLabelFontHeightF = 0.015
204.376 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
204.377 +;-----------------------------
204.378 + tRes = True
204.379 + tRes@txFontHeightF = 0.025
204.380 +
204.381 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMean)+")"
204.382 +
204.383 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
204.384 +
204.385 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
204.386 +;-------------------------------
204.387 +;Attach the vertical bar and the horizontal cap line
204.388 +
204.389 + do nd=0,1
204.390 + lnres@gsLineColor = line_colors(nd)
204.391 + do i=0,nx-1
204.392 +
204.393 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
204.394 + .not.ismissing(mx_yvalues(nd,i))) then
204.395 +
204.396 +; Attach the vertical bar, both above and below the marker.
204.397 +
204.398 + x1 = xvalues(nd,i)
204.399 + y1 = yvalues(nd,i)
204.400 + y2 = mn_yvalues(nd,i)
204.401 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
204.402 +
204.403 + y2 = mx_yvalues(nd,i)
204.404 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
204.405 +
204.406 +; Attach the horizontal cap line, both above and below the marker.
204.407 +
204.408 + x1 = xvalues(nd,i) - dx4
204.409 + x2 = xvalues(nd,i) + dx4
204.410 + y1 = mn_yvalues(nd,i)
204.411 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
204.412 +
204.413 + y1 = mx_yvalues(nd,i)
204.414 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
204.415 + end if
204.416 + end do
204.417 + end do
204.418 +
204.419 + draw(xy)
204.420 + frame(wks)
204.421 +
204.422 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.423 + system("rm "+plot_name+"."+plot_type)
204.424 +; system("rm "+plot_name+"-1."+plot_type_new)
204.425 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.426 +
204.427 + clear (wks)
204.428 +
204.429 + delete (DATA11_1D)
204.430 + delete (DATA12_1D)
204.431 + delete (DATA22_1D)
204.432 +;delete (range)
204.433 +;delete (xvalues)
204.434 + delete (yvalues)
204.435 + delete (mn_yvalues)
204.436 + delete (mx_yvalues)
204.437 + delete (good)
204.438 + delete (max_bar)
204.439 + delete (min_bar)
204.440 + delete (max_cap)
204.441 + delete (min_cap)
204.442 +;-----------------------------------------------------------------
204.443 +;global res
204.444 +
204.445 + resg = True ; Use plot options
204.446 + resg@cnFillOn = True ; Turn on color fill
204.447 + resg@gsnSpreadColors = True ; use full colormap
204.448 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
204.449 +; resg@lbLabelAutoStride = True
204.450 + resg@cnLinesOn = False ; Turn off contourn lines
204.451 + resg@mpFillOn = False ; Turn off map fill
204.452 +
204.453 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
204.454 + resg@cnMinLevelValF = 0. ; Min level
204.455 + resg@cnMaxLevelValF = 10. ; Max level
204.456 + resg@cnLevelSpacingF = 1. ; interval
204.457 +
204.458 +;global contour ob
204.459 +
204.460 + delta = 0.00001
204.461 + laiob_mean = where(ismissing(laiob_mean).and.(ismissing(laimod_mean).or.(laimod_mean.lt.delta)),0.,laiob_mean)
204.462 +
204.463 + plot_name = "global_mean_ob"
204.464 + title = ob_name
204.465 + resg@tiMainString = title
204.466 +
204.467 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
204.468 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.469 +
204.470 + plot = gsn_csm_contour_map_ce(wks,laiob_mean,resg)
204.471 + frame(wks)
204.472 +
204.473 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.474 + system("rm "+plot_name+"."+plot_type)
204.475 + system("rm "+plot_name+"-1."+plot_type_new)
204.476 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.477 +
204.478 + clear (wks)
204.479 +;------------------------------------------------------------------------
204.480 +;global contour model
204.481 +
204.482 + plot_name = "global_mean_model"
204.483 + title = "Model " + model_name
204.484 + resg@tiMainString = title
204.485 +
204.486 + wks = gsn_open_wks (plot_type,plot_name)
204.487 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.488 +
204.489 + plot = gsn_csm_contour_map_ce(wks,laimod_mean,resg)
204.490 + frame(wks)
204.491 +
204.492 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.493 + system("rm "+plot_name+"."+plot_type)
204.494 + system("rm "+plot_name+"-1."+plot_type_new)
204.495 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.496 +
204.497 + clear (wks)
204.498 +;-----------------------------------------------------------------
204.499 +;(B) max
204.500 +;--------------------------------------------------------------------
204.501 +; get data
204.502 +
204.503 +; observed
204.504 + laiob_max = laiob(0,:,:)
204.505 + s = laiob(:,0,0)
204.506 + laiob_max@long_name = "Leaf Area Index Max"
204.507 +
204.508 + dsizes_z = dimsizes(laiob)
204.509 + nlat = dsizes_z(1)
204.510 + nlon = dsizes_z(2)
204.511 +
204.512 + do j = 0,nlat-1
204.513 + do i = 0,nlon-1
204.514 + s = laiob(:,j,i)
204.515 + laiob_max(j,i) = max(s)
204.516 + end do
204.517 + end do
204.518 +
204.519 +; print (min(y)+"/"+max(y))
204.520 + delete (s)
204.521 + delete (dsizes_z)
204.522 +;-------------------------
204.523 +; model
204.524 + laimod_max = laimod(0,:,:)
204.525 + s = laimod(:,0,0)
204.526 + laimod_max@long_name = "Leaf Area Index Max"
204.527 +
204.528 + dsizes_z = dimsizes(laimod)
204.529 + nlat = dsizes_z(1)
204.530 + nlon = dsizes_z(2)
204.531 +
204.532 + do j = 0,nlat-1
204.533 + do i = 0,nlon-1
204.534 + s = laimod(:,j,i)
204.535 + laimod_max(j,i) = max(s)
204.536 + end do
204.537 + end do
204.538 +
204.539 +; print (min(laimod_max)+"/"+max(laimod_max))
204.540 + delete (s)
204.541 + delete (dsizes_z)
204.542 +;------------------------
204.543 + DATA11_1D = ndtooned(classob)
204.544 + DATA12_1D = ndtooned(laiob_max)
204.545 + DATA22_1D = ndtooned(laimod_max)
204.546 +
204.547 + yvalues = new((/2,nx/),float)
204.548 + mn_yvalues = new((/2,nx/),float)
204.549 + mx_yvalues = new((/2,nx/),float)
204.550 +
204.551 + do nd=0,1
204.552 +
204.553 +; See if we are doing model or observational data.
204.554 +
204.555 + if(nd.eq.0) then
204.556 + data_ob = DATA11_1D
204.557 + data_mod = DATA12_1D
204.558 + else
204.559 + data_ob = DATA11_1D
204.560 + data_mod = DATA22_1D
204.561 + end if
204.562 +
204.563 +; Loop through each range and check for values.
204.564 +
204.565 + do i=0,nr-2
204.566 + if (i.ne.(nr-2)) then
204.567 +; print("")
204.568 +; print("In range ["+range(i)+","+range(i+1)+")")
204.569 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
204.570 + else
204.571 +; print("")
204.572 +; print("In range ["+range(i)+",)")
204.573 + idx = ind(range(i).le.data_ob)
204.574 + end if
204.575 +
204.576 +; Calculate average, and get min and max.
204.577 +
204.578 + if(.not.any(ismissing(idx))) then
204.579 + yvalues(nd,i) = avg(data_mod(idx))
204.580 + mn_yvalues(nd,i) = min(data_mod(idx))
204.581 + mx_yvalues(nd,i) = max(data_mod(idx))
204.582 + count = dimsizes(idx)
204.583 + else
204.584 + count = 0
204.585 + yvalues(nd,i) = yvalues@_FillValue
204.586 + mn_yvalues(nd,i) = yvalues@_FillValue
204.587 + mx_yvalues(nd,i) = yvalues@_FillValue
204.588 + end if
204.589 +
204.590 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
204.591 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
204.592 +
204.593 +; Clean up for next time in loop.
204.594 +
204.595 + delete(idx)
204.596 + end do
204.597 + delete(data_ob)
204.598 + delete(data_mod)
204.599 + end do
204.600 +;-----------------------------------------------------------------
204.601 +; compute correlation coef and M score
204.602 +
204.603 + u = yvalues(0,:)
204.604 + v = yvalues(1,:)
204.605 +
204.606 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
204.607 + uu = u(good)
204.608 + vv = v(good)
204.609 +
204.610 + ccrMax = esccr(uu,vv,0)
204.611 +; print (ccrMax)
204.612 +
204.613 +; new eq
204.614 + bias = sum(abs(vv-uu)/(vv+uu))
204.615 + Mmax = (1.- (bias/dimsizes(uu)))*5.
204.616 +
204.617 + print (Mmax)
204.618 +
204.619 + do i=0,nrow-2
204.620 + text4(i,3) = sprintf("%5.2f",u(i))
204.621 + text4(i,4) = sprintf("%5.2f",v(i))
204.622 + text4(i,5) = "-"
204.623 + end do
204.624 + text4(nrow-1,3) = sprintf("%5.2f",avg(u))
204.625 + text4(nrow-1,4) = sprintf("%5.2f",avg(v))
204.626 + text4(nrow-1,5) = sprintf("%5.2f",Mmax)
204.627 +
204.628 + delete (u)
204.629 + delete (v)
204.630 + delete (uu)
204.631 + delete (vv)
204.632 +;--------------------------------------------------------------------
204.633 +; histogram res
204.634 +
204.635 + resm = True
204.636 + resm@gsnMaximize = True
204.637 + resm@gsnDraw = False
204.638 + resm@gsnFrame = False
204.639 + resm@xyMarkLineMode = "Markers"
204.640 + resm@xyMarkerSizeF = 0.014
204.641 + resm@xyMarker = 16
204.642 + resm@xyMarkerColors = (/"Brown","Blue"/)
204.643 +; resm@trYMinF = min(mn_yvalues) - 10.
204.644 +; resm@trYMaxF = max(mx_yvalues) + 10.
204.645 + resm@trYMinF = min(mn_yvalues) - 2
204.646 + resm@trYMaxF = max(mx_yvalues) + 4
204.647 +
204.648 + resm@tiYAxisString = "Max LAI (Leaf Area Index)"
204.649 + resm@tiXAxisString = "Land Cover Type"
204.650 +
204.651 + max_bar = new((/2,nx/),graphic)
204.652 + min_bar = new((/2,nx/),graphic)
204.653 + max_cap = new((/2,nx/),graphic)
204.654 + min_cap = new((/2,nx/),graphic)
204.655 +
204.656 + lnres = True
204.657 + line_colors = (/"brown","blue"/)
204.658 +;------------------------------------------------------------------
204.659 +; Start the graphics.
204.660 +
204.661 + plot_name = "histogram_max"
204.662 + title = model_name + " vs Observed"
204.663 + resm@tiMainString = title
204.664 +
204.665 + wks = gsn_open_wks (plot_type,plot_name)
204.666 +;-----------------------------
204.667 +; Add a boxed legend using the more simple method
204.668 +
204.669 + resm@pmLegendDisplayMode = "Always"
204.670 +; resm@pmLegendWidthF = 0.1
204.671 + resm@pmLegendWidthF = 0.08
204.672 + resm@pmLegendHeightF = 0.05
204.673 + resm@pmLegendOrthogonalPosF = -1.17
204.674 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
204.675 +; resm@pmLegendParallelPosF = 0.18
204.676 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
204.677 +
204.678 +; resm@lgPerimOn = False
204.679 + resm@lgLabelFontHeightF = 0.015
204.680 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
204.681 +;-----------------------------
204.682 + tRes = True
204.683 + tRes@txFontHeightF = 0.025
204.684 +
204.685 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMax)+")"
204.686 +
204.687 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
204.688 +
204.689 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
204.690 +;-------------------------------
204.691 +;Attach the vertical bar and the horizontal cap line
204.692 +
204.693 + do nd=0,1
204.694 + lnres@gsLineColor = line_colors(nd)
204.695 + do i=0,nx-1
204.696 +
204.697 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
204.698 + .not.ismissing(mx_yvalues(nd,i))) then
204.699 +
204.700 +; Attach the vertical bar, both above and below the marker.
204.701 +
204.702 + x1 = xvalues(nd,i)
204.703 + y1 = yvalues(nd,i)
204.704 + y2 = mn_yvalues(nd,i)
204.705 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
204.706 +
204.707 + y2 = mx_yvalues(nd,i)
204.708 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
204.709 +
204.710 +; Attach the horizontal cap line, both above and below the marker.
204.711 +
204.712 + x1 = xvalues(nd,i) - dx4
204.713 + x2 = xvalues(nd,i) + dx4
204.714 + y1 = mn_yvalues(nd,i)
204.715 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
204.716 +
204.717 + y1 = mx_yvalues(nd,i)
204.718 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
204.719 + end if
204.720 + end do
204.721 + end do
204.722 +
204.723 + draw(xy)
204.724 + frame(wks)
204.725 +
204.726 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.727 + system("rm "+plot_name+"."+plot_type)
204.728 +; system("rm "+plot_name+"-1."+plot_type_new)
204.729 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.730 +
204.731 + clear (wks)
204.732 +
204.733 + delete (DATA11_1D)
204.734 + delete (DATA12_1D)
204.735 + delete (DATA22_1D)
204.736 +;delete (range)
204.737 +;delete (xvalues)
204.738 + delete (yvalues)
204.739 + delete (mn_yvalues)
204.740 + delete (mx_yvalues)
204.741 + delete (good)
204.742 + delete (max_bar)
204.743 + delete (min_bar)
204.744 + delete (max_cap)
204.745 + delete (min_cap)
204.746 +;-----------------------------------------------------------------
204.747 +;global res
204.748 +
204.749 + resg = True ; Use plot options
204.750 + resg@cnFillOn = True ; Turn on color fill
204.751 + resg@gsnSpreadColors = True ; use full colormap
204.752 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
204.753 +; resg@lbLabelAutoStride = True
204.754 + resg@cnLinesOn = False ; Turn off contourn lines
204.755 + resg@mpFillOn = False ; Turn off map fill
204.756 +
204.757 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
204.758 + resg@cnMinLevelValF = 0. ; Min level
204.759 + resg@cnMaxLevelValF = 10. ; Max level
204.760 + resg@cnLevelSpacingF = 1. ; interval
204.761 +
204.762 +;global contour ob
204.763 +
204.764 + delta = 0.00001
204.765 + laiob_max = where(ismissing(laiob_max).and.(ismissing(laimod_max).or.(laimod_max.lt.delta)),0.,laiob_max)
204.766 +
204.767 + plot_name = "global_max_ob"
204.768 + title = ob_name
204.769 + resg@tiMainString = title
204.770 +
204.771 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
204.772 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.773 +
204.774 + plot_max = gsn_csm_contour_map_ce(wks,laiob_max,resg)
204.775 + frame(wks)
204.776 +
204.777 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.778 + system("rm "+plot_name+"."+plot_type)
204.779 + system("rm "+plot_name+"-1."+plot_type_new)
204.780 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.781 +
204.782 + clear (wks)
204.783 +;------------------------------------------------------------------------
204.784 +;global contour model
204.785 +
204.786 + plot_name = "global_max_model"
204.787 + title = "Model " + model_name
204.788 + resg@tiMainString = title
204.789 +
204.790 + wks = gsn_open_wks (plot_type,plot_name)
204.791 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.792 +
204.793 + plot_max = gsn_csm_contour_map_ce(wks,laimod_max,resg)
204.794 + frame(wks)
204.795 +
204.796 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.797 + system("rm "+plot_name+"."+plot_type)
204.798 + system("rm "+plot_name+"-1."+plot_type_new)
204.799 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.800 +
204.801 + clear (wks)
204.802 +;------------------------------------------------------------------------
204.803 +;(C) phase
204.804 +;--------------------------------------------------------------------
204.805 +; get data
204.806 +
204.807 +; observed
204.808 + laiob_phase = laiob(0,:,:)
204.809 + s = laiob(:,0,0)
204.810 + laiob_phase@long_name = "Leaf Area Index Max Month"
204.811 +
204.812 + dsizes_z = dimsizes(laiob)
204.813 + nlat = dsizes_z(1)
204.814 + nlon = dsizes_z(2)
204.815 +
204.816 + do j = 0,nlat-1
204.817 + do i = 0,nlon-1
204.818 + s = laiob(:,j,i)
204.819 + laiob_phase(j,i) = maxind(s) + 1
204.820 + end do
204.821 + end do
204.822 +
204.823 +; print (min(laiob_phase)+"/"+max(laiob_phase))
204.824 + delete (s)
204.825 + delete (dsizes_z)
204.826 +;-------------------------
204.827 +; model
204.828 + laimod_phase = laimod(0,:,:)
204.829 + s = laimod(:,0,0)
204.830 + laimod_phase@long_name = "Leaf Area Index Max Month"
204.831 +
204.832 + dsizes_z = dimsizes(laimod)
204.833 + nlat = dsizes_z(1)
204.834 + nlon = dsizes_z(2)
204.835 +
204.836 + do j = 0,nlat-1
204.837 + do i = 0,nlon-1
204.838 + s = laimod(:,j,i)
204.839 + laimod_phase(j,i) = maxind(s) + 1
204.840 + end do
204.841 + end do
204.842 +
204.843 +; print (min(laimod_phase)+"/"+max(laimod_phase))
204.844 + delete (s)
204.845 + delete (dsizes_z)
204.846 +;------------------------
204.847 + DATA11_1D = ndtooned(classob)
204.848 + DATA12_1D = ndtooned(laiob_phase)
204.849 + DATA22_1D = ndtooned(laimod_phase)
204.850 +
204.851 + yvalues = new((/2,nx/),float)
204.852 + mn_yvalues = new((/2,nx/),float)
204.853 + mx_yvalues = new((/2,nx/),float)
204.854 +
204.855 + do nd=0,1
204.856 +
204.857 +; See if we are doing model or observational data.
204.858 +
204.859 + if(nd.eq.0) then
204.860 + data_ob = DATA11_1D
204.861 + data_mod = DATA12_1D
204.862 + else
204.863 + data_ob = DATA11_1D
204.864 + data_mod = DATA22_1D
204.865 + end if
204.866 +
204.867 +; Loop through each range and check for values.
204.868 +
204.869 + do i=0,nr-2
204.870 + if (i.ne.(nr-2)) then
204.871 +; print("")
204.872 +; print("In range ["+range(i)+","+range(i+1)+")")
204.873 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
204.874 + else
204.875 +; print("")
204.876 +; print("In range ["+range(i)+",)")
204.877 + idx = ind(range(i).le.data_ob)
204.878 + end if
204.879 +
204.880 +; Calculate average, and get min and max.
204.881 +
204.882 + if(.not.any(ismissing(idx))) then
204.883 + yvalues(nd,i) = avg(data_mod(idx))
204.884 + mn_yvalues(nd,i) = min(data_mod(idx))
204.885 + mx_yvalues(nd,i) = max(data_mod(idx))
204.886 + count = dimsizes(idx)
204.887 + else
204.888 + count = 0
204.889 + yvalues(nd,i) = yvalues@_FillValue
204.890 + mn_yvalues(nd,i) = yvalues@_FillValue
204.891 + mx_yvalues(nd,i) = yvalues@_FillValue
204.892 + end if
204.893 +
204.894 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
204.895 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
204.896 +
204.897 +; Clean up for next time in loop.
204.898 +
204.899 + delete(idx)
204.900 + end do
204.901 + delete(data_ob)
204.902 + delete(data_mod)
204.903 + end do
204.904 +;-----------------------------------------------------------------
204.905 +; compute correlation coef and M score
204.906 +
204.907 + u = yvalues(0,:)
204.908 + v = yvalues(1,:)
204.909 +
204.910 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
204.911 + uu = u(good)
204.912 + vv = v(good)
204.913 +
204.914 + ccrPhase = esccr(uu,vv,0)
204.915 +; print (ccrPhase)
204.916 +
204.917 +; old eq
204.918 +; bias = abs(avg(vv)-avg(uu))
204.919 +; new eq
204.920 + bias = avg(abs(vv-uu))
204.921 +
204.922 + bias = where((bias.gt. 6.),12.-bias,bias)
204.923 + Mphase = ((6. - bias)/6.)*5.
204.924 +
204.925 + print (Mphase)
204.926 +
204.927 + do i=0,nrow-2
204.928 + text4(i,6) = sprintf("%5.2f",u(i))
204.929 + text4(i,7) = sprintf("%5.2f",v(i))
204.930 + text4(i,8) = "-"
204.931 + end do
204.932 + text4(nrow-1,6) = sprintf("%5.2f",avg(u))
204.933 + text4(nrow-1,7) = sprintf("%5.2f",avg(v))
204.934 + text4(nrow-1,8) = sprintf("%5.2f",Mphase)
204.935 +
204.936 + delete (u)
204.937 + delete (v)
204.938 + delete (uu)
204.939 + delete (vv)
204.940 +;--------------------------------------------------------------------
204.941 +; histogram res
204.942 +
204.943 + resm = True
204.944 + resm@gsnMaximize = True
204.945 + resm@gsnDraw = False
204.946 + resm@gsnFrame = False
204.947 + resm@xyMarkLineMode = "Markers"
204.948 + resm@xyMarkerSizeF = 0.014
204.949 + resm@xyMarker = 16
204.950 + resm@xyMarkerColors = (/"Brown","Blue"/)
204.951 +; resm@trYMinF = min(mn_yvalues) - 10.
204.952 +; resm@trYMaxF = max(mx_yvalues) + 10.
204.953 + resm@trYMinF = min(mn_yvalues) - 2
204.954 + resm@trYMaxF = max(mx_yvalues) + 4
204.955 +
204.956 + resm@tiYAxisString = "Max LAI (Leaf Area Index) Month"
204.957 + resm@tiXAxisString = "Land Cover Type"
204.958 +
204.959 + max_bar = new((/2,nx/),graphic)
204.960 + min_bar = new((/2,nx/),graphic)
204.961 + max_cap = new((/2,nx/),graphic)
204.962 + min_cap = new((/2,nx/),graphic)
204.963 +
204.964 + lnres = True
204.965 + line_colors = (/"brown","blue"/)
204.966 +;------------------------------------------------------------------
204.967 +; Start the graphics.
204.968 +
204.969 + plot_name = "histogram_phase"
204.970 + title = model_name + " vs Observed"
204.971 + resm@tiMainString = title
204.972 +
204.973 + wks = gsn_open_wks (plot_type,plot_name)
204.974 +;-----------------------------
204.975 +; Add a boxed legend using the more simple method
204.976 +
204.977 + resm@pmLegendDisplayMode = "Always"
204.978 +; resm@pmLegendWidthF = 0.1
204.979 + resm@pmLegendWidthF = 0.08
204.980 + resm@pmLegendHeightF = 0.05
204.981 + resm@pmLegendOrthogonalPosF = -1.17
204.982 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
204.983 +; resm@pmLegendParallelPosF = 0.18
204.984 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
204.985 +
204.986 +; resm@lgPerimOn = False
204.987 + resm@lgLabelFontHeightF = 0.015
204.988 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
204.989 +;-----------------------------
204.990 + tRes = True
204.991 + tRes@txFontHeightF = 0.025
204.992 +
204.993 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrPhase)+")"
204.994 +
204.995 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
204.996 +
204.997 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
204.998 +;-------------------------------
204.999 +;Attach the vertical bar and the horizontal cap line
204.1000 +
204.1001 + do nd=0,1
204.1002 + lnres@gsLineColor = line_colors(nd)
204.1003 + do i=0,nx-1
204.1004 +
204.1005 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
204.1006 + .not.ismissing(mx_yvalues(nd,i))) then
204.1007 +
204.1008 +; Attach the vertical bar, both above and below the marker.
204.1009 +
204.1010 + x1 = xvalues(nd,i)
204.1011 + y1 = yvalues(nd,i)
204.1012 + y2 = mn_yvalues(nd,i)
204.1013 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
204.1014 +
204.1015 + y2 = mx_yvalues(nd,i)
204.1016 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
204.1017 +
204.1018 +; Attach the horizontal cap line, both above and below the marker.
204.1019 +
204.1020 + x1 = xvalues(nd,i) - dx4
204.1021 + x2 = xvalues(nd,i) + dx4
204.1022 + y1 = mn_yvalues(nd,i)
204.1023 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
204.1024 +
204.1025 + y1 = mx_yvalues(nd,i)
204.1026 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
204.1027 + end if
204.1028 + end do
204.1029 + end do
204.1030 +
204.1031 + draw(xy)
204.1032 + frame(wks)
204.1033 +
204.1034 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.1035 + system("rm "+plot_name+"."+plot_type)
204.1036 +; system("rm "+plot_name+"-1."+plot_type_new)
204.1037 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.1038 +
204.1039 + clear (wks)
204.1040 +
204.1041 + delete (DATA11_1D)
204.1042 + delete (DATA12_1D)
204.1043 + delete (DATA22_1D)
204.1044 +;delete (range)
204.1045 +;delete (xvalues)
204.1046 + delete (yvalues)
204.1047 + delete (mn_yvalues)
204.1048 + delete (mx_yvalues)
204.1049 + delete (good)
204.1050 + delete (max_bar)
204.1051 + delete (min_bar)
204.1052 + delete (max_cap)
204.1053 + delete (min_cap)
204.1054 +;-----------------------------------------------------------------
204.1055 +;global res
204.1056 +
204.1057 + resg = True ; Use plot options
204.1058 + resg@cnFillOn = True ; Turn on color fill
204.1059 + resg@gsnSpreadColors = True ; use full colormap
204.1060 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
204.1061 +; resg@lbLabelAutoStride = True
204.1062 + resg@cnLinesOn = False ; Turn off contourn lines
204.1063 + resg@mpFillOn = False ; Turn off map fill
204.1064 +
204.1065 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
204.1066 + resg@cnMinLevelValF = 1. ; Min level
204.1067 + resg@cnMaxLevelValF = 12. ; Max level
204.1068 + resg@cnLevelSpacingF = 1. ; interval
204.1069 +
204.1070 +;global contour ob
204.1071 +
204.1072 + delta = 0.00001
204.1073 + laiob_phase = where(ismissing(laiob_phase).and.(ismissing(laimod_phase).or.(laimod_phase.lt.delta)),0.,laiob_phase)
204.1074 +
204.1075 + plot_name = "global_phase_ob"
204.1076 + title = ob_name
204.1077 + resg@tiMainString = title
204.1078 +
204.1079 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
204.1080 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.1081 +
204.1082 + plot = gsn_csm_contour_map_ce(wks,laiob_phase,resg)
204.1083 + frame(wks)
204.1084 +
204.1085 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.1086 + system("rm "+plot_name+"."+plot_type)
204.1087 + system("rm "+plot_name+"-1."+plot_type_new)
204.1088 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.1089 +
204.1090 + clear (wks)
204.1091 +;------------------------------------------------------------------------
204.1092 +;global contour model
204.1093 +
204.1094 + plot_name = "global_phase_model"
204.1095 + title = "Model " + model_name
204.1096 + resg@tiMainString = title
204.1097 +
204.1098 + wks = gsn_open_wks (plot_type,plot_name)
204.1099 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.1100 +
204.1101 + delete (plot)
204.1102 + plot = gsn_csm_contour_map_ce(wks,laimod_phase,resg)
204.1103 + frame(wks)
204.1104 +
204.1105 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.1106 + system("rm "+plot_name+"."+plot_type)
204.1107 + system("rm "+plot_name+"-1."+plot_type_new)
204.1108 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.1109 +
204.1110 + clear (wks)
204.1111 +;-----------------------------------------------------------------
204.1112 +;(D) grow day
204.1113 +;--------------------------------------------------------------------
204.1114 +; get data
204.1115 +
204.1116 + day_of_data = (/31,28,31,30,31,30,31,31,30,31,30,31/)
204.1117 +
204.1118 +; observed
204.1119 + laiob_grow = laiob(0,:,:)
204.1120 + laiob_grow@long_name = "Days of Growing Season"
204.1121 +
204.1122 + dsizes_z = dimsizes(laiob)
204.1123 + ntime = dsizes_z(0)
204.1124 + nlat = dsizes_z(1)
204.1125 + nlon = dsizes_z(2)
204.1126 +
204.1127 + do j = 0,nlat-1
204.1128 + do i = 0,nlon-1
204.1129 + nday = 0.
204.1130 + do k = 0,ntime-1
204.1131 + if (.not. ismissing(laiob(k,j,i)) .and. laiob(k,j,i) .gt. 1.0) then
204.1132 + nday = nday + day_of_data(k)
204.1133 + end if
204.1134 + end do
204.1135 +
204.1136 + laiob_grow(j,i) = nday
204.1137 + end do
204.1138 + end do
204.1139 +
204.1140 +; print (min(laiob_grow)+"/"+max(laiob_grow))
204.1141 +;-------------------------
204.1142 +; model
204.1143 + laimod_grow = laimod(0,:,:)
204.1144 + laimod_grow@long_name = "Days of Growing Season"
204.1145 +
204.1146 + dsizes_z = dimsizes(laimod)
204.1147 + ntime = dsizes_z(0)
204.1148 + nlat = dsizes_z(1)
204.1149 + nlon = dsizes_z(2)
204.1150 +
204.1151 + do j = 0,nlat-1
204.1152 + do i = 0,nlon-1
204.1153 + nday = 0.
204.1154 + do k = 0,ntime-1
204.1155 + if (.not. ismissing(laimod(k,j,i)) .and. laimod(k,j,i) .gt. 1.0) then
204.1156 + nday = nday + day_of_data(k)
204.1157 + end if
204.1158 + end do
204.1159 +
204.1160 + laimod_grow(j,i) = nday
204.1161 + end do
204.1162 + end do
204.1163 +
204.1164 +; print (min(laimod_grow)+"/"+max(laimod_grow))
204.1165 +;------------------------
204.1166 + DATA11_1D = ndtooned(classob)
204.1167 + DATA12_1D = ndtooned(laiob_grow)
204.1168 + DATA22_1D = ndtooned(laimod_grow)
204.1169 +
204.1170 + yvalues = new((/2,nx/),float)
204.1171 + mn_yvalues = new((/2,nx/),float)
204.1172 + mx_yvalues = new((/2,nx/),float)
204.1173 +
204.1174 + do nd=0,1
204.1175 +
204.1176 +; See if we are doing model or observational data.
204.1177 +
204.1178 + if(nd.eq.0) then
204.1179 + data_ob = DATA11_1D
204.1180 + data_mod = DATA12_1D
204.1181 + else
204.1182 + data_ob = DATA11_1D
204.1183 + data_mod = DATA22_1D
204.1184 + end if
204.1185 +
204.1186 +; Loop through each range and check for values.
204.1187 +
204.1188 + do i=0,nr-2
204.1189 + if (i.ne.(nr-2)) then
204.1190 +; print("")
204.1191 +; print("In range ["+range(i)+","+range(i+1)+")")
204.1192 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
204.1193 + else
204.1194 +; print("")
204.1195 +; print("In range ["+range(i)+",)")
204.1196 + idx = ind(range(i).le.data_ob)
204.1197 + end if
204.1198 +
204.1199 +; Calculate average, and get min and max.
204.1200 +
204.1201 + if(.not.any(ismissing(idx))) then
204.1202 + yvalues(nd,i) = avg(data_mod(idx))
204.1203 + mn_yvalues(nd,i) = min(data_mod(idx))
204.1204 + mx_yvalues(nd,i) = max(data_mod(idx))
204.1205 + count = dimsizes(idx)
204.1206 + else
204.1207 + count = 0
204.1208 + yvalues(nd,i) = yvalues@_FillValue
204.1209 + mn_yvalues(nd,i) = yvalues@_FillValue
204.1210 + mx_yvalues(nd,i) = yvalues@_FillValue
204.1211 + end if
204.1212 +
204.1213 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
204.1214 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
204.1215 +
204.1216 +; Clean up for next time in loop.
204.1217 +
204.1218 + delete(idx)
204.1219 + end do
204.1220 + delete(data_ob)
204.1221 + delete(data_mod)
204.1222 + end do
204.1223 +;-----------------------------------------------------------------
204.1224 +; compute correlation coef and M score
204.1225 +
204.1226 + u = yvalues(0,:)
204.1227 + v = yvalues(1,:)
204.1228 +
204.1229 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
204.1230 + uu = u(good)
204.1231 + vv = v(good)
204.1232 +
204.1233 + ccrGrow = esccr(uu,vv,0)
204.1234 +; print (ccrGrow)
204.1235 +
204.1236 +; new eq
204.1237 + bias = sum(abs(vv-uu)/(vv+uu))
204.1238 + Mgrow = (1.- (bias/dimsizes(uu)))*5.
204.1239 +
204.1240 + print (Mgrow)
204.1241 +
204.1242 + do i=0,nrow-2
204.1243 + text4(i,9) = sprintf("%5.2f",u(i))
204.1244 + text4(i,10) = sprintf("%5.2f",v(i))
204.1245 + text4(i,11) = "-"
204.1246 + end do
204.1247 + text4(nrow-1,9) = sprintf("%5.2f",avg(u))
204.1248 + text4(nrow-1,10) = sprintf("%5.2f",avg(v))
204.1249 + text4(nrow-1,11) = sprintf("%5.2f",Mgrow)
204.1250 +
204.1251 + delete (u)
204.1252 + delete (v)
204.1253 + delete (uu)
204.1254 + delete (vv)
204.1255 +;--------------------------------------------------------------------
204.1256 +; histogram res
204.1257 +
204.1258 + resm = True
204.1259 + resm@gsnMaximize = True
204.1260 + resm@gsnDraw = False
204.1261 + resm@gsnFrame = False
204.1262 + resm@xyMarkLineMode = "Markers"
204.1263 + resm@xyMarkerSizeF = 0.014
204.1264 + resm@xyMarker = 16
204.1265 + resm@xyMarkerColors = (/"Brown","Blue"/)
204.1266 +; resm@trYMinF = min(mn_yvalues) - 10.
204.1267 +; resm@trYMaxF = max(mx_yvalues) + 10.
204.1268 + resm@trYMinF = min(mn_yvalues) - 2
204.1269 + resm@trYMaxF = max(mx_yvalues) + 4
204.1270 +
204.1271 + resm@tiYAxisString = "Days of Growing season"
204.1272 + resm@tiXAxisString = "Land Cover Type"
204.1273 +
204.1274 + max_bar = new((/2,nx/),graphic)
204.1275 + min_bar = new((/2,nx/),graphic)
204.1276 + max_cap = new((/2,nx/),graphic)
204.1277 + min_cap = new((/2,nx/),graphic)
204.1278 +
204.1279 + lnres = True
204.1280 + line_colors = (/"brown","blue"/)
204.1281 +;------------------------------------------------------------------
204.1282 +; Start the graphics.
204.1283 +
204.1284 + plot_name = "histogram_grow"
204.1285 + title = model_name + " vs Observed"
204.1286 + resm@tiMainString = title
204.1287 +
204.1288 + wks = gsn_open_wks (plot_type,plot_name)
204.1289 +;-----------------------------
204.1290 +; Add a boxed legend using the more simple method
204.1291 +
204.1292 + resm@pmLegendDisplayMode = "Always"
204.1293 +; resm@pmLegendWidthF = 0.1
204.1294 + resm@pmLegendWidthF = 0.08
204.1295 + resm@pmLegendHeightF = 0.05
204.1296 + resm@pmLegendOrthogonalPosF = -1.17
204.1297 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
204.1298 +; resm@pmLegendParallelPosF = 0.18
204.1299 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
204.1300 +
204.1301 +; resm@lgPerimOn = False
204.1302 + resm@lgLabelFontHeightF = 0.015
204.1303 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
204.1304 +;-----------------------------
204.1305 + tRes = True
204.1306 + tRes@txFontHeightF = 0.025
204.1307 +
204.1308 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrGrow)+")"
204.1309 +
204.1310 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
204.1311 +
204.1312 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
204.1313 +;-------------------------------
204.1314 +;Attach the vertical bar and the horizontal cap line
204.1315 +
204.1316 + do nd=0,1
204.1317 + lnres@gsLineColor = line_colors(nd)
204.1318 + do i=0,nx-1
204.1319 +
204.1320 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
204.1321 + .not.ismissing(mx_yvalues(nd,i))) then
204.1322 +
204.1323 +; Attach the vertical bar, both above and below the marker.
204.1324 +
204.1325 + x1 = xvalues(nd,i)
204.1326 + y1 = yvalues(nd,i)
204.1327 + y2 = mn_yvalues(nd,i)
204.1328 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
204.1329 +
204.1330 + y2 = mx_yvalues(nd,i)
204.1331 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
204.1332 +
204.1333 +; Attach the horizontal cap line, both above and below the marker.
204.1334 +
204.1335 + x1 = xvalues(nd,i) - dx4
204.1336 + x2 = xvalues(nd,i) + dx4
204.1337 + y1 = mn_yvalues(nd,i)
204.1338 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
204.1339 +
204.1340 + y1 = mx_yvalues(nd,i)
204.1341 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
204.1342 + end if
204.1343 + end do
204.1344 + end do
204.1345 +
204.1346 + draw(xy)
204.1347 + frame(wks)
204.1348 +
204.1349 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.1350 + system("rm "+plot_name+"."+plot_type)
204.1351 +; system("rm "+plot_name+"-1."+plot_type_new)
204.1352 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.1353 +
204.1354 + clear (wks)
204.1355 +
204.1356 + delete (DATA11_1D)
204.1357 + delete (DATA12_1D)
204.1358 + delete (DATA22_1D)
204.1359 +;delete (range)
204.1360 +;delete (xvalues)
204.1361 + delete (yvalues)
204.1362 + delete (mn_yvalues)
204.1363 + delete (mx_yvalues)
204.1364 + delete (good)
204.1365 + delete (max_bar)
204.1366 + delete (min_bar)
204.1367 + delete (max_cap)
204.1368 + delete (min_cap)
204.1369 +;-----------------------------------------------------------------
204.1370 +;global res
204.1371 +
204.1372 + resg = True ; Use plot options
204.1373 + resg@cnFillOn = True ; Turn on color fill
204.1374 + resg@gsnSpreadColors = True ; use full colormap
204.1375 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
204.1376 +; resg@lbLabelAutoStride = True
204.1377 + resg@cnLinesOn = False ; Turn off contourn lines
204.1378 + resg@mpFillOn = False ; Turn off map fill
204.1379 +
204.1380 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
204.1381 + resg@cnMinLevelValF = 60. ; Min level
204.1382 + resg@cnMaxLevelValF = 360. ; Max level
204.1383 + resg@cnLevelSpacingF = 20. ; interval
204.1384 +
204.1385 +;global contour ob
204.1386 +
204.1387 + laiob_grow@_FillValue = 1.e+36
204.1388 + laiob_grow = where(laiob_grow .lt. 10.,laiob_grow@_FillValue,laiob_grow)
204.1389 +
204.1390 + plot_name = "global_grow_ob"
204.1391 + title = ob_name
204.1392 + resg@tiMainString = title
204.1393 +
204.1394 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
204.1395 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.1396 +
204.1397 + plot = gsn_csm_contour_map_ce(wks,laiob_grow,resg)
204.1398 + frame(wks)
204.1399 +
204.1400 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.1401 + system("rm "+plot_name+"."+plot_type)
204.1402 + system("rm "+plot_name+"-1."+plot_type_new)
204.1403 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.1404 +
204.1405 + clear (wks)
204.1406 +;------------------------------------------------------------------------
204.1407 +;global contour model
204.1408 +
204.1409 + laimod_grow@_FillValue = 1.e+36
204.1410 + laimod_grow = where(laimod_grow .lt. 10.,laimod_grow@_FillValue,laimod_grow)
204.1411 +
204.1412 + plot_name = "global_grow_model"
204.1413 + title = "Model " + model_name
204.1414 + resg@tiMainString = title
204.1415 +
204.1416 + wks = gsn_open_wks (plot_type,plot_name)
204.1417 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.1418 +
204.1419 + delete (plot)
204.1420 + plot = gsn_csm_contour_map_ce(wks,laimod_grow,resg)
204.1421 + frame(wks)
204.1422 +
204.1423 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.1424 + system("rm "+plot_name+"."+plot_type)
204.1425 + system("rm "+plot_name+"-1."+plot_type_new)
204.1426 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.1427 +
204.1428 + clear (wks)
204.1429 +;------------------------------------------------------------------------
204.1430 +;global contour model vs ob
204.1431 +
204.1432 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
204.1433 + resg@cnMinLevelValF = 0. ; Min level
204.1434 + resg@cnMaxLevelValF = 10. ; Max level
204.1435 + resg@cnLevelSpacingF = 1. ; interval
204.1436 +
204.1437 + plot_name = "global_mean_model_vs_ob"
204.1438 +
204.1439 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
204.1440 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.1441 +
204.1442 + delete (plot)
204.1443 + plot=new(3,graphic) ; create graphic array
204.1444 +
204.1445 + resg@gsnFrame = False ; Do not draw plot
204.1446 + resg@gsnDraw = False ; Do not advance frame
204.1447 +
204.1448 +; plot correlation coef
204.1449 +
204.1450 + gRes = True
204.1451 + gRes@txFontHeightF = 0.02
204.1452 + gRes@txAngleF = 90
204.1453 +
204.1454 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMean)+")"
204.1455 +
204.1456 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
204.1457 +;--------------------------------------------------------------------
204.1458 +
204.1459 +;(a) ob
204.1460 +
204.1461 + title = ob_name
204.1462 + resg@tiMainString = title
204.1463 +
204.1464 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_mean,resg)
204.1465 +
204.1466 +;(b) model
204.1467 +
204.1468 + title = "Model "+ model_name
204.1469 + resg@tiMainString = title
204.1470 +
204.1471 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_mean,resg)
204.1472 +
204.1473 +;(c) model-ob
204.1474 +
204.1475 + zz = laimod_mean
204.1476 + zz = laimod_mean - laiob_mean
204.1477 + title = "Model_"+model_name+" - Observed"
204.1478 + resg@tiMainString = title
204.1479 +
204.1480 + resg@cnMinLevelValF = -2. ; Min level
204.1481 + resg@cnMaxLevelValF = 2. ; Max level
204.1482 + resg@cnLevelSpacingF = 0.4 ; interval
204.1483 +
204.1484 +
204.1485 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
204.1486 +
204.1487 + pres = True ; panel plot mods desired
204.1488 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
204.1489 + ; indiv. plots in panel
204.1490 + pres@gsnMaximize = True ; fill the page
204.1491 +
204.1492 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
204.1493 +
204.1494 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.1495 + system("rm "+plot_name+"."+plot_type)
204.1496 +; system("rm "+plot_name+"-1."+plot_type_new)
204.1497 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.1498 +
204.1499 + frame (wks)
204.1500 + clear (wks)
204.1501 +
204.1502 + delete (plot)
204.1503 +;-----------------------------------------------------------------
204.1504 +;global contour model vs ob
204.1505 +
204.1506 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
204.1507 + resg@cnMinLevelValF = 0. ; Min level
204.1508 + resg@cnMaxLevelValF = 10. ; Max level
204.1509 + resg@cnLevelSpacingF = 1. ; interval
204.1510 +
204.1511 + plot_name = "global_max_model_vs_ob"
204.1512 +
204.1513 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
204.1514 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.1515 +
204.1516 +; delete(plot)
204.1517 + plot=new(3,graphic) ; create graphic array
204.1518 +
204.1519 + resg@gsnFrame = False ; Do not draw plot
204.1520 + resg@gsnDraw = False ; Do not advance frame
204.1521 +
204.1522 +; plot correlation coef
204.1523 +
204.1524 + gRes = True
204.1525 + gRes@txFontHeightF = 0.02
204.1526 + gRes@txAngleF = 90
204.1527 +
204.1528 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMax)+")"
204.1529 +
204.1530 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
204.1531 +;--------------------------------------------------------------------
204.1532 +;(a) ob
204.1533 +
204.1534 + title = ob_name
204.1535 + resg@tiMainString = title
204.1536 +
204.1537 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_max,resg)
204.1538 +
204.1539 +;(b) model
204.1540 +
204.1541 + title = "Model "+ model_name
204.1542 + resg@tiMainString = title
204.1543 +
204.1544 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_max,resg)
204.1545 +
204.1546 +;(c) model-ob
204.1547 +
204.1548 + delete (zz)
204.1549 + zz = laimod_max
204.1550 + zz = laimod_max - laiob_max
204.1551 + title = "Model_"+model_name+" - Observed"
204.1552 + resg@tiMainString = title
204.1553 +
204.1554 + resg@cnMinLevelValF = -6. ; Min level
204.1555 + resg@cnMaxLevelValF = 6. ; Max level
204.1556 + resg@cnLevelSpacingF = 1. ; interval
204.1557 +
204.1558 +
204.1559 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
204.1560 +
204.1561 + pres = True ; panel plot mods desired
204.1562 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
204.1563 + ; indiv. plots in panel
204.1564 + pres@gsnMaximize = True ; fill the page
204.1565 +
204.1566 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
204.1567 +
204.1568 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.1569 + system("rm "+plot_name+"."+plot_type)
204.1570 +; system("rm "+plot_name+"-1."+plot_type_new)
204.1571 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.1572 +
204.1573 + frame (wks)
204.1574 + clear (wks)
204.1575 +
204.1576 + delete (plot)
204.1577 +;-----------------------------------------------------------------
204.1578 +;global contour model vs ob
204.1579 +
204.1580 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
204.1581 + resg@cnMinLevelValF = 1. ; Min level
204.1582 + resg@cnMaxLevelValF = 12. ; Max level
204.1583 + resg@cnLevelSpacingF = 1. ; interval
204.1584 +
204.1585 + plot_name = "global_phase_model_vs_ob"
204.1586 +
204.1587 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
204.1588 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.1589 +
204.1590 +; delete (plot)
204.1591 + plot=new(3,graphic) ; create graphic array
204.1592 +
204.1593 + resg@gsnFrame = False ; Do not draw plot
204.1594 + resg@gsnDraw = False ; Do not advance frame
204.1595 +
204.1596 +; plot correlation coef
204.1597 +
204.1598 + gRes = True
204.1599 + gRes@txFontHeightF = 0.02
204.1600 + gRes@txAngleF = 90
204.1601 +
204.1602 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrPhase)+")"
204.1603 +
204.1604 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
204.1605 +;--------------------------------------------------------------------
204.1606 +;(a) ob
204.1607 +
204.1608 + title = ob_name
204.1609 + resg@tiMainString = title
204.1610 +
204.1611 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_phase,resg)
204.1612 +
204.1613 +;(b) model
204.1614 +
204.1615 + title = "Model "+ model_name
204.1616 + resg@tiMainString = title
204.1617 +
204.1618 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_phase,resg)
204.1619 +
204.1620 +;(c) model-ob
204.1621 +
204.1622 + delete (zz)
204.1623 + zz = laimod_phase
204.1624 + zz = laimod_phase - laiob_phase
204.1625 + title = "Model_"+model_name+" - Observed"
204.1626 + resg@tiMainString = title
204.1627 +
204.1628 + resg@cnMinLevelValF = -6. ; Min level
204.1629 + resg@cnMaxLevelValF = 6. ; Max level
204.1630 + resg@cnLevelSpacingF = 1. ; interval
204.1631 +
204.1632 +
204.1633 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
204.1634 +
204.1635 +; pres = True ; panel plot mods desired
204.1636 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
204.1637 + ; indiv. plots in panel
204.1638 +; pres@gsnMaximize = True ; fill the page
204.1639 +
204.1640 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
204.1641 +
204.1642 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.1643 + system("rm "+plot_name+"."+plot_type)
204.1644 +; system("rm "+plot_name+"-1."+plot_type_new)
204.1645 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.1646 +
204.1647 + frame (wks)
204.1648 + clear (wks)
204.1649 +
204.1650 + delete (plot)
204.1651 +;------------------------------------------------------------------
204.1652 +;global contour model vs ob
204.1653 +
204.1654 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
204.1655 + resg@cnMinLevelValF = 60. ; Min level
204.1656 + resg@cnMaxLevelValF = 360. ; Max level
204.1657 + resg@cnLevelSpacingF = 20. ; interval
204.1658 +
204.1659 + plot_name = "global_grow_model_vs_ob"
204.1660 +
204.1661 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
204.1662 + gsn_define_colormap(wks,"gui_default") ; choose colormap
204.1663 +
204.1664 +; delete (plot)
204.1665 + plot=new(3,graphic) ; create graphic array
204.1666 +
204.1667 + resg@gsnFrame = False ; Do not draw plot
204.1668 + resg@gsnDraw = False ; Do not advance frame
204.1669 +
204.1670 +; plot correlation coef
204.1671 +
204.1672 + gRes = True
204.1673 + gRes@txFontHeightF = 0.02
204.1674 + gRes@txAngleF = 90
204.1675 +
204.1676 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrGrow)+")"
204.1677 +
204.1678 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
204.1679 +;--------------------------------------------------------------------
204.1680 +;(a) ob
204.1681 +
204.1682 + title = ob_name
204.1683 + resg@tiMainString = title
204.1684 +
204.1685 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_grow,resg)
204.1686 +
204.1687 +;(b) model
204.1688 +
204.1689 + title = "Model "+ model_name
204.1690 + resg@tiMainString = title
204.1691 +
204.1692 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_grow,resg)
204.1693 +
204.1694 +;(c) model-ob
204.1695 +
204.1696 + delete (zz)
204.1697 + zz = laimod_grow
204.1698 + zz = laimod_grow - laiob_grow
204.1699 + title = "Model_"+model_name+" - Observed"
204.1700 + resg@tiMainString = title
204.1701 +
204.1702 + resg@cnMinLevelValF = -100. ; Min level
204.1703 + resg@cnMaxLevelValF = 100. ; Max level
204.1704 + resg@cnLevelSpacingF = 20. ; interval
204.1705 +
204.1706 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
204.1707 +
204.1708 + pres = True ; panel plot mods desired
204.1709 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
204.1710 + ; indiv. plots in panel
204.1711 + pres@gsnMaximize = True ; fill the page
204.1712 +
204.1713 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
204.1714 +
204.1715 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.1716 + system("rm "+plot_name+"."+plot_type)
204.1717 +; system("rm "+plot_name+"-1."+plot_type_new)
204.1718 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.1719 +
204.1720 + frame (wks)
204.1721 + clear (wks)
204.1722 +
204.1723 + delete (plot)
204.1724 +;**************************************************
204.1725 +; plot lai table
204.1726 +;**************************************************
204.1727 +
204.1728 + plot_name = "table_lai"
204.1729 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
204.1730 +
204.1731 + gsn_table(wks,ncr1,xx1,yy1,text1,res1)
204.1732 + gsn_table(wks,ncr21,xx21,yy21,text21,res21)
204.1733 + gsn_table(wks,ncr22,xx22,yy22,text22,res22)
204.1734 + gsn_table(wks,ncr3,xx3,yy3,text3,res3)
204.1735 + gsn_table(wks,ncr4,xx4,yy4,text4,res4)
204.1736 +
204.1737 + frame(wks)
204.1738 +
204.1739 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
204.1740 +; system("rm "+plot_name+"."+plot_type)
204.1741 +; system("rm "+plot_name+"-1."+plot_type_new)
204.1742 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
204.1743 +;-------------------------------------------------------------------
204.1744 + temp_name = "temp." + model_name
204.1745 + system("mkdir -p " + temp_name)
204.1746 + system("mv *.png " + temp_name)
204.1747 + system("tar cf "+ temp_name +".tar " + temp_name)
204.1748 +;-------------------------------------------------------------------
204.1749 +end
204.1750 +
205.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
205.2 +++ b/lai/99.all.ncl.1 Mon Jan 26 22:08:20 2009 -0500
205.3 @@ -0,0 +1,1763 @@
205.4 +;********************************************************
205.5 +; histogram normalized by rain and compute correleration
205.6 +;********************************************************
205.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
205.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
205.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
205.10 +
205.11 +procedure pminmax(data:numeric,name:string)
205.12 +begin
205.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
205.14 + if(isatt(data,"units")) then
205.15 + print (name + " units = " + data@units)
205.16 + end if
205.17 +end
205.18 +
205.19 +; Main code.
205.20 +begin
205.21 +
205.22 + nclass = 20
205.23 +
205.24 + plot_type = "ps"
205.25 + plot_type_new = "png"
205.26 +
205.27 +;************************************************
205.28 +; read in data: model
205.29 +;************************************************
205.30 +;film = "b30.061n_1995-2004_MONS_climo_lnd.nc"
205.31 +;model_name = "b30.061n"
205.32 +;model_grid = "T31"
205.33 +
205.34 +;film = "newcn05_ncep_1i_MONS_climo_lnd.nc"
205.35 +;model_name = "newcn"
205.36 +;model_grid = "1.9"
205.37 +
205.38 +;film = "i01.06cn_1798-2004_MONS_climo.nc"
205.39 +;model_name = "06cn"
205.40 +;model_grid = "T42"
205.41 +
205.42 +;film = "i01.06casa_1798-2004_MONS_climo.nc"
205.43 +;model_name = "06casa"
205.44 +;model_grid = "T42"
205.45 +
205.46 + film = "i01.10cn_1948-2004_MONS_climo.nc"
205.47 + model_name = "10cn"
205.48 + model_grid = "T42"
205.49 +
205.50 +;film = "i01.10casa_1948-2004_MONS_climo.nc"
205.51 +;model_name = "10casa"
205.52 +;model_grid = "T42"
205.53 +
205.54 + system("sed s#model_name#"+model_name+"# table.html > table.html.new")
205.55 + system("mv -f table.html.new table.html")
205.56 +;------------------------------------------------
205.57 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
205.58 + fm = addfile(dirm+film,"r")
205.59 +
205.60 + laimod = fm->TLAI
205.61 +
205.62 +;************************************************
205.63 +; read in data: observed
205.64 +;************************************************
205.65 +
205.66 + ob_name = "MODIS MOD 15A2 2000-2005"
205.67 +
205.68 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
205.69 + filo1 = "land_class_"+model_grid+".nc"
205.70 + filo2 = "LAI_2000-2005_MONS_"+model_grid+".nc"
205.71 +
205.72 + fo1 = addfile(diro+filo1,"r")
205.73 + fo2 = addfile(diro+filo2,"r")
205.74 +
205.75 + classob = tofloat(fo1->LAND_CLASS)
205.76 + laiob = fo2->LAI
205.77 +
205.78 +;*******************************************************************
205.79 +; for plotting table
205.80 +;*******************************************************************
205.81 +; table header name
205.82 + table_header_name = "LAI"
205.83 +
205.84 +; column (not including header column)
205.85 +
205.86 + col_header1 = (/"Mean","Max","Phase","Growth"/)
205.87 + col_header2 = (/"ob","model","M" \
205.88 + ,"ob","model","M" \
205.89 + ,"ob","model","M" \
205.90 + ,"ob","model","M" \
205.91 + /)
205.92 +
205.93 + ncol1 = dimsizes(col_header1)
205.94 + ncol2 = dimsizes(col_header2)
205.95 + ncol = ncol2
205.96 +
205.97 +; row (not including header row)
205.98 + row_header = (/"Water Bodies" \
205.99 + ,"Evergreen Needleleaf Forests" \
205.100 + ,"Evergreen Broadleaf Forests" \
205.101 + ,"Deciduous Needleleaf Forest" \
205.102 + ,"Deciduous Broadleaf Forests" \
205.103 + ,"Mixed Forests" \
205.104 + ,"Closed Bushlands" \
205.105 + ,"Open Bushlands" \
205.106 + ,"Woody Savannas (S. Hem.)" \
205.107 + ,"Savannas (S. Hem.)" \
205.108 + ,"Grasslands" \
205.109 + ,"Permanent Wetlands" \
205.110 + ,"Croplands" \
205.111 + ,"Urban and Built-Up" \
205.112 + ,"Cropland/Natural Vegetation Mosaic" \
205.113 + ,"Permanent Snow and Ice" \
205.114 + ,"Barren or Sparsely Vegetated" \
205.115 + ,"Unclassified" \
205.116 + ,"Woody Savannas (N. Hem.)" \
205.117 + ,"Savannas (N. Hem.)" \
205.118 + ,"All biome average" \
205.119 + /)
205.120 + nrow = dimsizes(row_header)
205.121 +
205.122 +; arrays to be passed to table.
205.123 + value = new ((/nrow, ncol/),string )
205.124 +
205.125 + table_length = 0.995
205.126 +
205.127 +; Table header
205.128 + ncr1 = (/1,1/) ; 1 row, 1 column
205.129 + xx1 = (/0.005,0.25/) ; Start and end X
205.130 + yy1 = (/0.900,0.995/) ; Start and end Y
205.131 + text1 = table_header_name
205.132 + res1 = True
205.133 + res1@txFontHeightF = 0.03
205.134 + res1@gsFillColor = "CornFlowerBlue"
205.135 +
205.136 +; Column header (equally space in x2)
205.137 + ncr21 = (/1,ncol1/) ; 1 rows, 4 columns
205.138 + xx21 = (/xx1(1),0.995/) ; start from end of x1
205.139 + yy21 = (/0.9475,0.995/) ; half of y1
205.140 + text21 = col_header1
205.141 + res21 = True
205.142 + res21@txFontHeightF = 0.015
205.143 + res21@gsFillColor = "Gray"
205.144 +
205.145 + ncr22 = (/1,ncol2/) ; 1 rows, 12 columns
205.146 + xx22 = xx21 ; start from end of x1
205.147 + yy22 = (/0.900,0.9475/) ; half of y1
205.148 + text22 = col_header2
205.149 + res22 = True
205.150 + res22@txFontHeightF = 0.015
205.151 + res22@gsFillColor = "Gray"
205.152 +
205.153 +; Row header (equally space in y2)
205.154 + ncr3 = (/nrow,1/) ; 20 rows, 1 columns
205.155 + xx3 = xx1 ; same as x1
205.156 + yy3 = (/1.0-table_length,0.900/) ; end at start of y1
205.157 + text3 = row_header
205.158 + res3 = True
205.159 + res3@txFontHeightF = 0.01
205.160 + res3@gsFillColor = "Gray"
205.161 +
205.162 +; Main table body
205.163 + ncr4 = (/nrow,ncol/) ; 5 rows, 5 columns
205.164 + xx4 = xx21 ; Start and end x
205.165 + yy4 = yy3 ; Start and end Y
205.166 + text4 = new((/nrow,ncol/),string)
205.167 +
205.168 + color_fill4 = new((/nrow,ncol/),string)
205.169 + color_fill4 = "white"
205.170 + color_fill4(nrow-1,:) = "CornFlowerBlue"
205.171 +
205.172 + res4 = True ; Set up resource list
205.173 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
205.174 + res4@txFontHeightF = 0.015
205.175 + res4@gsFillColor = color_fill4
205.176 +
205.177 + delete (color_fill4)
205.178 +
205.179 +;************************************************
205.180 +; plot global land class: observed
205.181 +;************************************************
205.182 +;global res
205.183 +
205.184 + resg = True ; Use plot options
205.185 + resg@cnFillOn = True ; Turn on color fill
205.186 + resg@gsnSpreadColors = True ; use full colormap
205.187 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
205.188 +; resg@lbLabelAutoStride = True
205.189 + resg@cnLinesOn = False ; Turn off contourn lines
205.190 + resg@mpFillOn = False ; Turn off map fill
205.191 +
205.192 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
205.193 + resg@cnMinLevelValF = 1. ; Min level
205.194 + resg@cnMaxLevelValF = 19. ; Max level
205.195 + resg@cnLevelSpacingF = 1. ; interval
205.196 +
205.197 +;global contour ob
205.198 + classob@_FillValue = 1.e+36
205.199 + classob = where(classob.eq.0,classob@_FillValue,classob)
205.200 +
205.201 + plot_name = "global_class_ob"
205.202 + title = ob_name
205.203 + resg@tiMainString = title
205.204 +
205.205 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
205.206 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.207 +
205.208 + plot = gsn_csm_contour_map_ce(wks,classob,resg)
205.209 + frame(wks)
205.210 +
205.211 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.212 + system("rm "+plot_name+"."+plot_type)
205.213 + system("rm "+plot_name+"-1."+plot_type_new)
205.214 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.215 +
205.216 + clear (wks)
205.217 +;*******************************************************************
205.218 +; Calculate "nice" bins for binning the data in equally spaced ranges
205.219 +;********************************************************************
205.220 + nclassn = nclass + 1
205.221 + range = fspan(0,nclassn-1,nclassn)
205.222 +; print (range)
205.223 +
205.224 +; Use this range information to grab all the values in a
205.225 +; particular range, and then take an average.
205.226 +
205.227 + nr = dimsizes(range)
205.228 + nx = nr-1
205.229 + xvalues = new((/2,nx/),float)
205.230 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
205.231 + dx = xvalues(0,1) - xvalues(0,0) ; range width
205.232 + dx4 = dx/4 ; 1/4 of the range
205.233 + xvalues(1,:) = xvalues(0,:) - dx/5.
205.234 +;-----------------------------------------------------------------
205.235 +;(A) mean
205.236 +;--------------------------------------------------------------------
205.237 +; get data
205.238 +
205.239 + laiob_mean = dim_avg_Wrap(laiob(lat|:,lon|:,time|:))
205.240 + laimod_mean = dim_avg_Wrap(laimod(lat|:,lon|:,time|:))
205.241 +
205.242 + DATA11_1D = ndtooned(classob)
205.243 + DATA12_1D = ndtooned(laiob_mean)
205.244 + DATA22_1D = ndtooned(laimod_mean)
205.245 +
205.246 + yvalues = new((/2,nx/),float)
205.247 + mn_yvalues = new((/2,nx/),float)
205.248 + mx_yvalues = new((/2,nx/),float)
205.249 +
205.250 + do nd=0,1
205.251 +
205.252 +; See if we are doing model or observational data.
205.253 +
205.254 + if(nd.eq.0) then
205.255 + data_ob = DATA11_1D
205.256 + data_mod = DATA12_1D
205.257 + else
205.258 + data_ob = DATA11_1D
205.259 + data_mod = DATA22_1D
205.260 + end if
205.261 +
205.262 +; Loop through each range and check for values.
205.263 +
205.264 + do i=0,nr-2
205.265 + if (i.ne.(nr-2)) then
205.266 +; print("")
205.267 +; print("In range ["+range(i)+","+range(i+1)+")")
205.268 + idx = ind((data_ob.ge.range(i)).and.(data_ob.lt.range(i+1)))
205.269 + else
205.270 +; print("")
205.271 +; print("In range ["+range(i)+",)")
205.272 + idx = ind(data_ob.ge.range(i))
205.273 + end if
205.274 +
205.275 +; Calculate average, and get min and max.
205.276 +
205.277 + if(.not.any(ismissing(idx))) then
205.278 + yvalues(nd,i) = avg(data_mod(idx))
205.279 + mn_yvalues(nd,i) = min(data_mod(idx))
205.280 + mx_yvalues(nd,i) = max(data_mod(idx))
205.281 + count = dimsizes(idx)
205.282 + else
205.283 + count = 0
205.284 + yvalues(nd,i) = yvalues@_FillValue
205.285 + mn_yvalues(nd,i) = yvalues@_FillValue
205.286 + mx_yvalues(nd,i) = yvalues@_FillValue
205.287 + end if
205.288 +
205.289 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
205.290 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
205.291 +
205.292 +; Clean up for next time in loop.
205.293 +
205.294 + delete(idx)
205.295 + end do
205.296 + delete(data_ob)
205.297 + delete(data_mod)
205.298 + end do
205.299 +;-----------------------------------------------------------------
205.300 +; compute correlation coef and M score
205.301 +
205.302 + u = yvalues(0,:)
205.303 + v = yvalues(1,:)
205.304 +
205.305 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
205.306 + uu = u(good)
205.307 + vv = v(good)
205.308 +
205.309 + ccrMean = esccr(uu,vv,0)
205.310 +; print (ccrMean)
205.311 +
205.312 +; new eq
205.313 + bias = sum(abs(vv-uu)/(vv+uu))
205.314 + Mmean = (1.- (bias/dimsizes(uu)))*5.
205.315 +
205.316 + M_lai_mean = sprintf("%.2f", Mmean)
205.317 + system("sed s#M_lai_mean#"+M_lai_mean+"# table.html > table.html.new")
205.318 + system("mv -f table.html.new table.html")
205.319 + print (M_lai_mean)
205.320 +
205.321 + do i=0,nrow-2
205.322 + text4(i,0) = sprintf("%5.2f",u(i))
205.323 + text4(i,1) = sprintf("%5.2f",v(i))
205.324 + text4(i,2) = "-"
205.325 + end do
205.326 + text4(nrow-1,0) = sprintf("%5.2f",avg(u))
205.327 + text4(nrow-1,1) = sprintf("%5.2f",avg(v))
205.328 + text4(nrow-1,2) = sprintf("%5.2f",Mmean)
205.329 +
205.330 + delete (u)
205.331 + delete (v)
205.332 + delete (uu)
205.333 + delete (vv)
205.334 +;--------------------------------------------------------------------
205.335 +; histogram res
205.336 +
205.337 + resm = True
205.338 + resm@gsnMaximize = True
205.339 + resm@gsnDraw = False
205.340 + resm@gsnFrame = False
205.341 + resm@xyMarkLineMode = "Markers"
205.342 + resm@xyMarkerSizeF = 0.014
205.343 + resm@xyMarker = 16
205.344 + resm@xyMarkerColors = (/"Brown","Blue"/)
205.345 +; resm@trYMinF = min(mn_yvalues) - 10.
205.346 +; resm@trYMaxF = max(mx_yvalues) + 10.
205.347 + resm@trYMinF = min(mn_yvalues) - 2
205.348 + resm@trYMaxF = max(mx_yvalues) + 4
205.349 +
205.350 + resm@tiYAxisString = "Mean LAI (Leaf Area Index)"
205.351 + resm@tiXAxisString = "Land Cover Type"
205.352 +
205.353 + max_bar = new((/2,nx/),graphic)
205.354 + min_bar = new((/2,nx/),graphic)
205.355 + max_cap = new((/2,nx/),graphic)
205.356 + min_cap = new((/2,nx/),graphic)
205.357 +
205.358 + lnres = True
205.359 + line_colors = (/"brown","blue"/)
205.360 +;------------------------------------------------------------------
205.361 +; Start the graphics.
205.362 +
205.363 + plot_name = "histogram_mean"
205.364 + title = model_name + " vs Observed"
205.365 + resm@tiMainString = title
205.366 +
205.367 + wks = gsn_open_wks (plot_type,plot_name)
205.368 +;-----------------------------
205.369 +; Add a boxed legend using the more simple method
205.370 +
205.371 + resm@pmLegendDisplayMode = "Always"
205.372 +; resm@pmLegendWidthF = 0.1
205.373 + resm@pmLegendWidthF = 0.08
205.374 + resm@pmLegendHeightF = 0.05
205.375 + resm@pmLegendOrthogonalPosF = -1.17
205.376 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
205.377 +; resm@pmLegendParallelPosF = 0.18
205.378 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
205.379 +
205.380 +; resm@lgPerimOn = False
205.381 + resm@lgLabelFontHeightF = 0.015
205.382 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
205.383 +;-----------------------------
205.384 + tRes = True
205.385 + tRes@txFontHeightF = 0.025
205.386 +
205.387 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMean)+")"
205.388 +
205.389 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
205.390 +
205.391 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
205.392 +;-------------------------------
205.393 +;Attach the vertical bar and the horizontal cap line
205.394 +
205.395 + do nd=0,1
205.396 + lnres@gsLineColor = line_colors(nd)
205.397 + do i=0,nx-1
205.398 +
205.399 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
205.400 + .not.ismissing(mx_yvalues(nd,i))) then
205.401 +
205.402 +; Attach the vertical bar, both above and below the marker.
205.403 +
205.404 + x1 = xvalues(nd,i)
205.405 + y1 = yvalues(nd,i)
205.406 + y2 = mn_yvalues(nd,i)
205.407 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
205.408 +
205.409 + y2 = mx_yvalues(nd,i)
205.410 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
205.411 +
205.412 +; Attach the horizontal cap line, both above and below the marker.
205.413 +
205.414 + x1 = xvalues(nd,i) - dx4
205.415 + x2 = xvalues(nd,i) + dx4
205.416 + y1 = mn_yvalues(nd,i)
205.417 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
205.418 +
205.419 + y1 = mx_yvalues(nd,i)
205.420 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
205.421 + end if
205.422 + end do
205.423 + end do
205.424 +
205.425 + draw(xy)
205.426 + frame(wks)
205.427 +
205.428 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.429 + system("rm "+plot_name+"."+plot_type)
205.430 +; system("rm "+plot_name+"-1."+plot_type_new)
205.431 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.432 +
205.433 + clear (wks)
205.434 +
205.435 + delete (DATA11_1D)
205.436 + delete (DATA12_1D)
205.437 + delete (DATA22_1D)
205.438 +;delete (range)
205.439 +;delete (xvalues)
205.440 + delete (yvalues)
205.441 + delete (mn_yvalues)
205.442 + delete (mx_yvalues)
205.443 + delete (good)
205.444 + delete (max_bar)
205.445 + delete (min_bar)
205.446 + delete (max_cap)
205.447 + delete (min_cap)
205.448 +;-----------------------------------------------------------------
205.449 +;global res
205.450 +
205.451 + resg = True ; Use plot options
205.452 + resg@cnFillOn = True ; Turn on color fill
205.453 + resg@gsnSpreadColors = True ; use full colormap
205.454 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
205.455 +; resg@lbLabelAutoStride = True
205.456 + resg@cnLinesOn = False ; Turn off contourn lines
205.457 + resg@mpFillOn = False ; Turn off map fill
205.458 +
205.459 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
205.460 + resg@cnMinLevelValF = 0. ; Min level
205.461 + resg@cnMaxLevelValF = 10. ; Max level
205.462 + resg@cnLevelSpacingF = 1. ; interval
205.463 +
205.464 +;global contour ob
205.465 +
205.466 + delta = 0.00001
205.467 + laiob_mean = where(ismissing(laiob_mean).and.(ismissing(laimod_mean).or.(laimod_mean.lt.delta)),0.,laiob_mean)
205.468 +
205.469 + plot_name = "global_mean_ob"
205.470 + title = ob_name
205.471 + resg@tiMainString = title
205.472 +
205.473 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
205.474 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.475 +
205.476 + plot = gsn_csm_contour_map_ce(wks,laiob_mean,resg)
205.477 + frame(wks)
205.478 +
205.479 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.480 + system("rm "+plot_name+"."+plot_type)
205.481 + system("rm "+plot_name+"-1."+plot_type_new)
205.482 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.483 +
205.484 + clear (wks)
205.485 +;------------------------------------------------------------------------
205.486 +;global contour model
205.487 +
205.488 + plot_name = "global_mean_model"
205.489 + title = "Model " + model_name
205.490 + resg@tiMainString = title
205.491 +
205.492 + wks = gsn_open_wks (plot_type,plot_name)
205.493 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.494 +
205.495 + plot = gsn_csm_contour_map_ce(wks,laimod_mean,resg)
205.496 + frame(wks)
205.497 +
205.498 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.499 + system("rm "+plot_name+"."+plot_type)
205.500 + system("rm "+plot_name+"-1."+plot_type_new)
205.501 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.502 +
205.503 + clear (wks)
205.504 +;-----------------------------------------------------------------
205.505 +;(B) max
205.506 +;--------------------------------------------------------------------
205.507 +; get data
205.508 +
205.509 +; observed
205.510 + laiob_max = laiob(0,:,:)
205.511 + s = laiob(:,0,0)
205.512 + laiob_max@long_name = "Leaf Area Index Max"
205.513 +
205.514 + dsizes_z = dimsizes(laiob)
205.515 + nlat = dsizes_z(1)
205.516 + nlon = dsizes_z(2)
205.517 +
205.518 + do j = 0,nlat-1
205.519 + do i = 0,nlon-1
205.520 + s = laiob(:,j,i)
205.521 + laiob_max(j,i) = max(s)
205.522 + end do
205.523 + end do
205.524 +
205.525 +; print (min(y)+"/"+max(y))
205.526 + delete (s)
205.527 + delete (dsizes_z)
205.528 +;-------------------------
205.529 +; model
205.530 + laimod_max = laimod(0,:,:)
205.531 + s = laimod(:,0,0)
205.532 + laimod_max@long_name = "Leaf Area Index Max"
205.533 +
205.534 + dsizes_z = dimsizes(laimod)
205.535 + nlat = dsizes_z(1)
205.536 + nlon = dsizes_z(2)
205.537 +
205.538 + do j = 0,nlat-1
205.539 + do i = 0,nlon-1
205.540 + s = laimod(:,j,i)
205.541 + laimod_max(j,i) = max(s)
205.542 + end do
205.543 + end do
205.544 +
205.545 +; print (min(laimod_max)+"/"+max(laimod_max))
205.546 + delete (s)
205.547 + delete (dsizes_z)
205.548 +;------------------------
205.549 + DATA11_1D = ndtooned(classob)
205.550 + DATA12_1D = ndtooned(laiob_max)
205.551 + DATA22_1D = ndtooned(laimod_max)
205.552 +
205.553 + yvalues = new((/2,nx/),float)
205.554 + mn_yvalues = new((/2,nx/),float)
205.555 + mx_yvalues = new((/2,nx/),float)
205.556 +
205.557 + do nd=0,1
205.558 +
205.559 +; See if we are doing model or observational data.
205.560 +
205.561 + if(nd.eq.0) then
205.562 + data_ob = DATA11_1D
205.563 + data_mod = DATA12_1D
205.564 + else
205.565 + data_ob = DATA11_1D
205.566 + data_mod = DATA22_1D
205.567 + end if
205.568 +
205.569 +; Loop through each range and check for values.
205.570 +
205.571 + do i=0,nr-2
205.572 + if (i.ne.(nr-2)) then
205.573 +; print("")
205.574 +; print("In range ["+range(i)+","+range(i+1)+")")
205.575 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
205.576 + else
205.577 +; print("")
205.578 +; print("In range ["+range(i)+",)")
205.579 + idx = ind(range(i).le.data_ob)
205.580 + end if
205.581 +
205.582 +; Calculate average, and get min and max.
205.583 +
205.584 + if(.not.any(ismissing(idx))) then
205.585 + yvalues(nd,i) = avg(data_mod(idx))
205.586 + mn_yvalues(nd,i) = min(data_mod(idx))
205.587 + mx_yvalues(nd,i) = max(data_mod(idx))
205.588 + count = dimsizes(idx)
205.589 + else
205.590 + count = 0
205.591 + yvalues(nd,i) = yvalues@_FillValue
205.592 + mn_yvalues(nd,i) = yvalues@_FillValue
205.593 + mx_yvalues(nd,i) = yvalues@_FillValue
205.594 + end if
205.595 +
205.596 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
205.597 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
205.598 +
205.599 +; Clean up for next time in loop.
205.600 +
205.601 + delete(idx)
205.602 + end do
205.603 + delete(data_ob)
205.604 + delete(data_mod)
205.605 + end do
205.606 +;-----------------------------------------------------------------
205.607 +; compute correlation coef and M score
205.608 +
205.609 + u = yvalues(0,:)
205.610 + v = yvalues(1,:)
205.611 +
205.612 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
205.613 + uu = u(good)
205.614 + vv = v(good)
205.615 +
205.616 + ccrMax = esccr(uu,vv,0)
205.617 +; print (ccrMax)
205.618 +
205.619 +; new eq
205.620 + bias = sum(abs(vv-uu)/(vv+uu))
205.621 + Mmax = (1.- (bias/dimsizes(uu)))*5.
205.622 +
205.623 + M_lai_max = sprintf("%.2f", Mmax)
205.624 + system("sed s#M_lai_max#"+M_lai_max+"# table.html > table.html.new")
205.625 + system("mv -f table.html.new table.html")
205.626 + print (M_lai_max)
205.627 +
205.628 + do i=0,nrow-2
205.629 + text4(i,3) = sprintf("%5.2f",u(i))
205.630 + text4(i,4) = sprintf("%5.2f",v(i))
205.631 + text4(i,5) = "-"
205.632 + end do
205.633 + text4(nrow-1,3) = sprintf("%5.2f",avg(u))
205.634 + text4(nrow-1,4) = sprintf("%5.2f",avg(v))
205.635 + text4(nrow-1,5) = sprintf("%5.2f",Mmax)
205.636 +
205.637 + delete (u)
205.638 + delete (v)
205.639 + delete (uu)
205.640 + delete (vv)
205.641 +;--------------------------------------------------------------------
205.642 +; histogram res
205.643 +
205.644 + resm = True
205.645 + resm@gsnMaximize = True
205.646 + resm@gsnDraw = False
205.647 + resm@gsnFrame = False
205.648 + resm@xyMarkLineMode = "Markers"
205.649 + resm@xyMarkerSizeF = 0.014
205.650 + resm@xyMarker = 16
205.651 + resm@xyMarkerColors = (/"Brown","Blue"/)
205.652 +; resm@trYMinF = min(mn_yvalues) - 10.
205.653 +; resm@trYMaxF = max(mx_yvalues) + 10.
205.654 + resm@trYMinF = min(mn_yvalues) - 2
205.655 + resm@trYMaxF = max(mx_yvalues) + 4
205.656 +
205.657 + resm@tiYAxisString = "Max LAI (Leaf Area Index)"
205.658 + resm@tiXAxisString = "Land Cover Type"
205.659 +
205.660 + max_bar = new((/2,nx/),graphic)
205.661 + min_bar = new((/2,nx/),graphic)
205.662 + max_cap = new((/2,nx/),graphic)
205.663 + min_cap = new((/2,nx/),graphic)
205.664 +
205.665 + lnres = True
205.666 + line_colors = (/"brown","blue"/)
205.667 +;------------------------------------------------------------------
205.668 +; Start the graphics.
205.669 +
205.670 + plot_name = "histogram_max"
205.671 + title = model_name + " vs Observed"
205.672 + resm@tiMainString = title
205.673 +
205.674 + wks = gsn_open_wks (plot_type,plot_name)
205.675 +;-----------------------------
205.676 +; Add a boxed legend using the more simple method
205.677 +
205.678 + resm@pmLegendDisplayMode = "Always"
205.679 +; resm@pmLegendWidthF = 0.1
205.680 + resm@pmLegendWidthF = 0.08
205.681 + resm@pmLegendHeightF = 0.05
205.682 + resm@pmLegendOrthogonalPosF = -1.17
205.683 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
205.684 +; resm@pmLegendParallelPosF = 0.18
205.685 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
205.686 +
205.687 +; resm@lgPerimOn = False
205.688 + resm@lgLabelFontHeightF = 0.015
205.689 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
205.690 +;-----------------------------
205.691 + tRes = True
205.692 + tRes@txFontHeightF = 0.025
205.693 +
205.694 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMax)+")"
205.695 +
205.696 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
205.697 +
205.698 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
205.699 +;-------------------------------
205.700 +;Attach the vertical bar and the horizontal cap line
205.701 +
205.702 + do nd=0,1
205.703 + lnres@gsLineColor = line_colors(nd)
205.704 + do i=0,nx-1
205.705 +
205.706 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
205.707 + .not.ismissing(mx_yvalues(nd,i))) then
205.708 +
205.709 +; Attach the vertical bar, both above and below the marker.
205.710 +
205.711 + x1 = xvalues(nd,i)
205.712 + y1 = yvalues(nd,i)
205.713 + y2 = mn_yvalues(nd,i)
205.714 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
205.715 +
205.716 + y2 = mx_yvalues(nd,i)
205.717 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
205.718 +
205.719 +; Attach the horizontal cap line, both above and below the marker.
205.720 +
205.721 + x1 = xvalues(nd,i) - dx4
205.722 + x2 = xvalues(nd,i) + dx4
205.723 + y1 = mn_yvalues(nd,i)
205.724 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
205.725 +
205.726 + y1 = mx_yvalues(nd,i)
205.727 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
205.728 + end if
205.729 + end do
205.730 + end do
205.731 +
205.732 + draw(xy)
205.733 + frame(wks)
205.734 +
205.735 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.736 + system("rm "+plot_name+"."+plot_type)
205.737 +; system("rm "+plot_name+"-1."+plot_type_new)
205.738 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.739 +
205.740 + clear (wks)
205.741 +
205.742 + delete (DATA11_1D)
205.743 + delete (DATA12_1D)
205.744 + delete (DATA22_1D)
205.745 +;delete (range)
205.746 +;delete (xvalues)
205.747 + delete (yvalues)
205.748 + delete (mn_yvalues)
205.749 + delete (mx_yvalues)
205.750 + delete (good)
205.751 + delete (max_bar)
205.752 + delete (min_bar)
205.753 + delete (max_cap)
205.754 + delete (min_cap)
205.755 +;-----------------------------------------------------------------
205.756 +;global res
205.757 +
205.758 + resg = True ; Use plot options
205.759 + resg@cnFillOn = True ; Turn on color fill
205.760 + resg@gsnSpreadColors = True ; use full colormap
205.761 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
205.762 +; resg@lbLabelAutoStride = True
205.763 + resg@cnLinesOn = False ; Turn off contourn lines
205.764 + resg@mpFillOn = False ; Turn off map fill
205.765 +
205.766 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
205.767 + resg@cnMinLevelValF = 0. ; Min level
205.768 + resg@cnMaxLevelValF = 10. ; Max level
205.769 + resg@cnLevelSpacingF = 1. ; interval
205.770 +
205.771 +;global contour ob
205.772 +
205.773 + delta = 0.00001
205.774 + laiob_max = where(ismissing(laiob_max).and.(ismissing(laimod_max).or.(laimod_max.lt.delta)),0.,laiob_max)
205.775 +
205.776 + plot_name = "global_max_ob"
205.777 + title = ob_name
205.778 + resg@tiMainString = title
205.779 +
205.780 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
205.781 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.782 +
205.783 + plot_max = gsn_csm_contour_map_ce(wks,laiob_max,resg)
205.784 + frame(wks)
205.785 +
205.786 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.787 + system("rm "+plot_name+"."+plot_type)
205.788 + system("rm "+plot_name+"-1."+plot_type_new)
205.789 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.790 +
205.791 + clear (wks)
205.792 +;------------------------------------------------------------------------
205.793 +;global contour model
205.794 +
205.795 + plot_name = "global_max_model"
205.796 + title = "Model " + model_name
205.797 + resg@tiMainString = title
205.798 +
205.799 + wks = gsn_open_wks (plot_type,plot_name)
205.800 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.801 +
205.802 + plot_max = gsn_csm_contour_map_ce(wks,laimod_max,resg)
205.803 + frame(wks)
205.804 +
205.805 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.806 + system("rm "+plot_name+"."+plot_type)
205.807 + system("rm "+plot_name+"-1."+plot_type_new)
205.808 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.809 +
205.810 + clear (wks)
205.811 +;------------------------------------------------------------------------
205.812 +;(C) phase
205.813 +;--------------------------------------------------------------------
205.814 +; get data
205.815 +
205.816 +; observed
205.817 + laiob_phase = laiob(0,:,:)
205.818 + s = laiob(:,0,0)
205.819 + laiob_phase@long_name = "Leaf Area Index Max Month"
205.820 +
205.821 + dsizes_z = dimsizes(laiob)
205.822 + nlat = dsizes_z(1)
205.823 + nlon = dsizes_z(2)
205.824 +
205.825 + do j = 0,nlat-1
205.826 + do i = 0,nlon-1
205.827 + s = laiob(:,j,i)
205.828 + laiob_phase(j,i) = maxind(s) + 1
205.829 + end do
205.830 + end do
205.831 +
205.832 +; print (min(laiob_phase)+"/"+max(laiob_phase))
205.833 + delete (s)
205.834 + delete (dsizes_z)
205.835 +;-------------------------
205.836 +; model
205.837 + laimod_phase = laimod(0,:,:)
205.838 + s = laimod(:,0,0)
205.839 + laimod_phase@long_name = "Leaf Area Index Max Month"
205.840 +
205.841 + dsizes_z = dimsizes(laimod)
205.842 + nlat = dsizes_z(1)
205.843 + nlon = dsizes_z(2)
205.844 +
205.845 + do j = 0,nlat-1
205.846 + do i = 0,nlon-1
205.847 + s = laimod(:,j,i)
205.848 + laimod_phase(j,i) = maxind(s) + 1
205.849 + end do
205.850 + end do
205.851 +
205.852 +; print (min(laimod_phase)+"/"+max(laimod_phase))
205.853 + delete (s)
205.854 + delete (dsizes_z)
205.855 +;------------------------
205.856 + DATA11_1D = ndtooned(classob)
205.857 + DATA12_1D = ndtooned(laiob_phase)
205.858 + DATA22_1D = ndtooned(laimod_phase)
205.859 +
205.860 + yvalues = new((/2,nx/),float)
205.861 + mn_yvalues = new((/2,nx/),float)
205.862 + mx_yvalues = new((/2,nx/),float)
205.863 +
205.864 + do nd=0,1
205.865 +
205.866 +; See if we are doing model or observational data.
205.867 +
205.868 + if(nd.eq.0) then
205.869 + data_ob = DATA11_1D
205.870 + data_mod = DATA12_1D
205.871 + else
205.872 + data_ob = DATA11_1D
205.873 + data_mod = DATA22_1D
205.874 + end if
205.875 +
205.876 +; Loop through each range and check for values.
205.877 +
205.878 + do i=0,nr-2
205.879 + if (i.ne.(nr-2)) then
205.880 +; print("")
205.881 +; print("In range ["+range(i)+","+range(i+1)+")")
205.882 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
205.883 + else
205.884 +; print("")
205.885 +; print("In range ["+range(i)+",)")
205.886 + idx = ind(range(i).le.data_ob)
205.887 + end if
205.888 +
205.889 +; Calculate average, and get min and max.
205.890 +
205.891 + if(.not.any(ismissing(idx))) then
205.892 + yvalues(nd,i) = avg(data_mod(idx))
205.893 + mn_yvalues(nd,i) = min(data_mod(idx))
205.894 + mx_yvalues(nd,i) = max(data_mod(idx))
205.895 + count = dimsizes(idx)
205.896 + else
205.897 + count = 0
205.898 + yvalues(nd,i) = yvalues@_FillValue
205.899 + mn_yvalues(nd,i) = yvalues@_FillValue
205.900 + mx_yvalues(nd,i) = yvalues@_FillValue
205.901 + end if
205.902 +
205.903 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
205.904 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
205.905 +
205.906 +; Clean up for next time in loop.
205.907 +
205.908 + delete(idx)
205.909 + end do
205.910 + delete(data_ob)
205.911 + delete(data_mod)
205.912 + end do
205.913 +;-----------------------------------------------------------------
205.914 +; compute correlation coef and M score
205.915 +
205.916 + u = yvalues(0,:)
205.917 + v = yvalues(1,:)
205.918 +
205.919 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
205.920 + uu = u(good)
205.921 + vv = v(good)
205.922 +
205.923 + ccrPhase = esccr(uu,vv,0)
205.924 +; print (ccrPhase)
205.925 +
205.926 +; old eq
205.927 +; bias = abs(avg(vv)-avg(uu))
205.928 +; new eq
205.929 + bias = avg(abs(vv-uu))
205.930 +
205.931 + bias = where((bias.gt. 6.),12.-bias,bias)
205.932 + Mphase = ((6. - bias)/6.)*5.
205.933 +
205.934 + M_lai_phase = sprintf("%.2f", Mphase)
205.935 + system("sed s#M_lai_phase#"+M_lai_phase+"# table.html > table.html.new")
205.936 + system("mv -f table.html.new table.html")
205.937 + print (M_lai_phase)
205.938 +
205.939 + do i=0,nrow-2
205.940 + text4(i,6) = sprintf("%5.2f",u(i))
205.941 + text4(i,7) = sprintf("%5.2f",v(i))
205.942 + text4(i,8) = "-"
205.943 + end do
205.944 + text4(nrow-1,6) = sprintf("%5.2f",avg(u))
205.945 + text4(nrow-1,7) = sprintf("%5.2f",avg(v))
205.946 + text4(nrow-1,8) = sprintf("%5.2f",Mphase)
205.947 +
205.948 + delete (u)
205.949 + delete (v)
205.950 + delete (uu)
205.951 + delete (vv)
205.952 +;--------------------------------------------------------------------
205.953 +; histogram res
205.954 +
205.955 + resm = True
205.956 + resm@gsnMaximize = True
205.957 + resm@gsnDraw = False
205.958 + resm@gsnFrame = False
205.959 + resm@xyMarkLineMode = "Markers"
205.960 + resm@xyMarkerSizeF = 0.014
205.961 + resm@xyMarker = 16
205.962 + resm@xyMarkerColors = (/"Brown","Blue"/)
205.963 +; resm@trYMinF = min(mn_yvalues) - 10.
205.964 +; resm@trYMaxF = max(mx_yvalues) + 10.
205.965 + resm@trYMinF = min(mn_yvalues) - 2
205.966 + resm@trYMaxF = max(mx_yvalues) + 4
205.967 +
205.968 + resm@tiYAxisString = "Max LAI (Leaf Area Index) Month"
205.969 + resm@tiXAxisString = "Land Cover Type"
205.970 +
205.971 + max_bar = new((/2,nx/),graphic)
205.972 + min_bar = new((/2,nx/),graphic)
205.973 + max_cap = new((/2,nx/),graphic)
205.974 + min_cap = new((/2,nx/),graphic)
205.975 +
205.976 + lnres = True
205.977 + line_colors = (/"brown","blue"/)
205.978 +;------------------------------------------------------------------
205.979 +; Start the graphics.
205.980 +
205.981 + plot_name = "histogram_phase"
205.982 + title = model_name + " vs Observed"
205.983 + resm@tiMainString = title
205.984 +
205.985 + wks = gsn_open_wks (plot_type,plot_name)
205.986 +;-----------------------------
205.987 +; Add a boxed legend using the more simple method
205.988 +
205.989 + resm@pmLegendDisplayMode = "Always"
205.990 +; resm@pmLegendWidthF = 0.1
205.991 + resm@pmLegendWidthF = 0.08
205.992 + resm@pmLegendHeightF = 0.05
205.993 + resm@pmLegendOrthogonalPosF = -1.17
205.994 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
205.995 +; resm@pmLegendParallelPosF = 0.18
205.996 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
205.997 +
205.998 +; resm@lgPerimOn = False
205.999 + resm@lgLabelFontHeightF = 0.015
205.1000 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
205.1001 +;-----------------------------
205.1002 + tRes = True
205.1003 + tRes@txFontHeightF = 0.025
205.1004 +
205.1005 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrPhase)+")"
205.1006 +
205.1007 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
205.1008 +
205.1009 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
205.1010 +;-------------------------------
205.1011 +;Attach the vertical bar and the horizontal cap line
205.1012 +
205.1013 + do nd=0,1
205.1014 + lnres@gsLineColor = line_colors(nd)
205.1015 + do i=0,nx-1
205.1016 +
205.1017 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
205.1018 + .not.ismissing(mx_yvalues(nd,i))) then
205.1019 +
205.1020 +; Attach the vertical bar, both above and below the marker.
205.1021 +
205.1022 + x1 = xvalues(nd,i)
205.1023 + y1 = yvalues(nd,i)
205.1024 + y2 = mn_yvalues(nd,i)
205.1025 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
205.1026 +
205.1027 + y2 = mx_yvalues(nd,i)
205.1028 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
205.1029 +
205.1030 +; Attach the horizontal cap line, both above and below the marker.
205.1031 +
205.1032 + x1 = xvalues(nd,i) - dx4
205.1033 + x2 = xvalues(nd,i) + dx4
205.1034 + y1 = mn_yvalues(nd,i)
205.1035 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
205.1036 +
205.1037 + y1 = mx_yvalues(nd,i)
205.1038 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
205.1039 + end if
205.1040 + end do
205.1041 + end do
205.1042 +
205.1043 + draw(xy)
205.1044 + frame(wks)
205.1045 +
205.1046 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.1047 + system("rm "+plot_name+"."+plot_type)
205.1048 +; system("rm "+plot_name+"-1."+plot_type_new)
205.1049 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.1050 +
205.1051 + clear (wks)
205.1052 +
205.1053 + delete (DATA11_1D)
205.1054 + delete (DATA12_1D)
205.1055 + delete (DATA22_1D)
205.1056 +;delete (range)
205.1057 +;delete (xvalues)
205.1058 + delete (yvalues)
205.1059 + delete (mn_yvalues)
205.1060 + delete (mx_yvalues)
205.1061 + delete (good)
205.1062 + delete (max_bar)
205.1063 + delete (min_bar)
205.1064 + delete (max_cap)
205.1065 + delete (min_cap)
205.1066 +;-----------------------------------------------------------------
205.1067 +;global res
205.1068 +
205.1069 + resg = True ; Use plot options
205.1070 + resg@cnFillOn = True ; Turn on color fill
205.1071 + resg@gsnSpreadColors = True ; use full colormap
205.1072 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
205.1073 +; resg@lbLabelAutoStride = True
205.1074 + resg@cnLinesOn = False ; Turn off contourn lines
205.1075 + resg@mpFillOn = False ; Turn off map fill
205.1076 +
205.1077 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
205.1078 + resg@cnMinLevelValF = 1. ; Min level
205.1079 + resg@cnMaxLevelValF = 12. ; Max level
205.1080 + resg@cnLevelSpacingF = 1. ; interval
205.1081 +
205.1082 +;global contour ob
205.1083 +
205.1084 + delta = 0.00001
205.1085 + laiob_phase = where(ismissing(laiob_phase).and.(ismissing(laimod_phase).or.(laimod_phase.lt.delta)),0.,laiob_phase)
205.1086 +
205.1087 + plot_name = "global_phase_ob"
205.1088 + title = ob_name
205.1089 + resg@tiMainString = title
205.1090 +
205.1091 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
205.1092 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.1093 +
205.1094 + plot = gsn_csm_contour_map_ce(wks,laiob_phase,resg)
205.1095 + frame(wks)
205.1096 +
205.1097 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.1098 + system("rm "+plot_name+"."+plot_type)
205.1099 + system("rm "+plot_name+"-1."+plot_type_new)
205.1100 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.1101 +
205.1102 + clear (wks)
205.1103 +;------------------------------------------------------------------------
205.1104 +;global contour model
205.1105 +
205.1106 + plot_name = "global_phase_model"
205.1107 + title = "Model " + model_name
205.1108 + resg@tiMainString = title
205.1109 +
205.1110 + wks = gsn_open_wks (plot_type,plot_name)
205.1111 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.1112 +
205.1113 + delete (plot)
205.1114 + plot = gsn_csm_contour_map_ce(wks,laimod_phase,resg)
205.1115 + frame(wks)
205.1116 +
205.1117 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.1118 + system("rm "+plot_name+"."+plot_type)
205.1119 + system("rm "+plot_name+"-1."+plot_type_new)
205.1120 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.1121 +
205.1122 + clear (wks)
205.1123 +;-----------------------------------------------------------------
205.1124 +;(D) grow day
205.1125 +;--------------------------------------------------------------------
205.1126 +; get data
205.1127 +
205.1128 + day_of_data = (/31,28,31,30,31,30,31,31,30,31,30,31/)
205.1129 +
205.1130 +; observed
205.1131 + laiob_grow = laiob(0,:,:)
205.1132 + laiob_grow@long_name = "Days of Growing Season"
205.1133 +
205.1134 + dsizes_z = dimsizes(laiob)
205.1135 + ntime = dsizes_z(0)
205.1136 + nlat = dsizes_z(1)
205.1137 + nlon = dsizes_z(2)
205.1138 +
205.1139 + do j = 0,nlat-1
205.1140 + do i = 0,nlon-1
205.1141 + nday = 0.
205.1142 + do k = 0,ntime-1
205.1143 + if (.not. ismissing(laiob(k,j,i)) .and. laiob(k,j,i) .gt. 1.0) then
205.1144 + nday = nday + day_of_data(k)
205.1145 + end if
205.1146 + end do
205.1147 +
205.1148 + laiob_grow(j,i) = nday
205.1149 + end do
205.1150 + end do
205.1151 +
205.1152 +; print (min(laiob_grow)+"/"+max(laiob_grow))
205.1153 +;-------------------------
205.1154 +; model
205.1155 + laimod_grow = laimod(0,:,:)
205.1156 + laimod_grow@long_name = "Days of Growing Season"
205.1157 +
205.1158 + dsizes_z = dimsizes(laimod)
205.1159 + ntime = dsizes_z(0)
205.1160 + nlat = dsizes_z(1)
205.1161 + nlon = dsizes_z(2)
205.1162 +
205.1163 + do j = 0,nlat-1
205.1164 + do i = 0,nlon-1
205.1165 + nday = 0.
205.1166 + do k = 0,ntime-1
205.1167 + if (.not. ismissing(laimod(k,j,i)) .and. laimod(k,j,i) .gt. 1.0) then
205.1168 + nday = nday + day_of_data(k)
205.1169 + end if
205.1170 + end do
205.1171 +
205.1172 + laimod_grow(j,i) = nday
205.1173 + end do
205.1174 + end do
205.1175 +
205.1176 +; print (min(laimod_grow)+"/"+max(laimod_grow))
205.1177 +;------------------------
205.1178 + DATA11_1D = ndtooned(classob)
205.1179 + DATA12_1D = ndtooned(laiob_grow)
205.1180 + DATA22_1D = ndtooned(laimod_grow)
205.1181 +
205.1182 + yvalues = new((/2,nx/),float)
205.1183 + mn_yvalues = new((/2,nx/),float)
205.1184 + mx_yvalues = new((/2,nx/),float)
205.1185 +
205.1186 + do nd=0,1
205.1187 +
205.1188 +; See if we are doing model or observational data.
205.1189 +
205.1190 + if(nd.eq.0) then
205.1191 + data_ob = DATA11_1D
205.1192 + data_mod = DATA12_1D
205.1193 + else
205.1194 + data_ob = DATA11_1D
205.1195 + data_mod = DATA22_1D
205.1196 + end if
205.1197 +
205.1198 +; Loop through each range and check for values.
205.1199 +
205.1200 + do i=0,nr-2
205.1201 + if (i.ne.(nr-2)) then
205.1202 +; print("")
205.1203 +; print("In range ["+range(i)+","+range(i+1)+")")
205.1204 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
205.1205 + else
205.1206 +; print("")
205.1207 +; print("In range ["+range(i)+",)")
205.1208 + idx = ind(range(i).le.data_ob)
205.1209 + end if
205.1210 +
205.1211 +; Calculate average, and get min and max.
205.1212 +
205.1213 + if(.not.any(ismissing(idx))) then
205.1214 + yvalues(nd,i) = avg(data_mod(idx))
205.1215 + mn_yvalues(nd,i) = min(data_mod(idx))
205.1216 + mx_yvalues(nd,i) = max(data_mod(idx))
205.1217 + count = dimsizes(idx)
205.1218 + else
205.1219 + count = 0
205.1220 + yvalues(nd,i) = yvalues@_FillValue
205.1221 + mn_yvalues(nd,i) = yvalues@_FillValue
205.1222 + mx_yvalues(nd,i) = yvalues@_FillValue
205.1223 + end if
205.1224 +
205.1225 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
205.1226 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
205.1227 +
205.1228 +; Clean up for next time in loop.
205.1229 +
205.1230 + delete(idx)
205.1231 + end do
205.1232 + delete(data_ob)
205.1233 + delete(data_mod)
205.1234 + end do
205.1235 +;-----------------------------------------------------------------
205.1236 +; compute correlation coef and M score
205.1237 +
205.1238 + u = yvalues(0,:)
205.1239 + v = yvalues(1,:)
205.1240 +
205.1241 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
205.1242 + uu = u(good)
205.1243 + vv = v(good)
205.1244 +
205.1245 + ccrGrow = esccr(uu,vv,0)
205.1246 +; print (ccrGrow)
205.1247 +
205.1248 +; new eq
205.1249 + bias = sum(abs(vv-uu)/(vv+uu))
205.1250 + Mgrow = (1.- (bias/dimsizes(uu)))*5.
205.1251 +
205.1252 + M_lai_grow = sprintf("%.2f", Mgrow)
205.1253 + system("sed s#M_lai_grow#"+M_lai_grow+"# table.html > table.html.new")
205.1254 + system("mv -f table.html.new table.html")
205.1255 + print (M_lai_grow)
205.1256 +
205.1257 + do i=0,nrow-2
205.1258 + text4(i,9) = sprintf("%5.2f",u(i))
205.1259 + text4(i,10) = sprintf("%5.2f",v(i))
205.1260 + text4(i,11) = "-"
205.1261 + end do
205.1262 + text4(nrow-1,9) = sprintf("%5.2f",avg(u))
205.1263 + text4(nrow-1,10) = sprintf("%5.2f",avg(v))
205.1264 + text4(nrow-1,11) = sprintf("%5.2f",Mgrow)
205.1265 +
205.1266 + delete (u)
205.1267 + delete (v)
205.1268 + delete (uu)
205.1269 + delete (vv)
205.1270 +;--------------------------------------------------------------------
205.1271 +; histogram res
205.1272 +
205.1273 + resm = True
205.1274 + resm@gsnMaximize = True
205.1275 + resm@gsnDraw = False
205.1276 + resm@gsnFrame = False
205.1277 + resm@xyMarkLineMode = "Markers"
205.1278 + resm@xyMarkerSizeF = 0.014
205.1279 + resm@xyMarker = 16
205.1280 + resm@xyMarkerColors = (/"Brown","Blue"/)
205.1281 +; resm@trYMinF = min(mn_yvalues) - 10.
205.1282 +; resm@trYMaxF = max(mx_yvalues) + 10.
205.1283 + resm@trYMinF = min(mn_yvalues) - 2
205.1284 + resm@trYMaxF = max(mx_yvalues) + 4
205.1285 +
205.1286 + resm@tiYAxisString = "Days of Growing season"
205.1287 + resm@tiXAxisString = "Land Cover Type"
205.1288 +
205.1289 + max_bar = new((/2,nx/),graphic)
205.1290 + min_bar = new((/2,nx/),graphic)
205.1291 + max_cap = new((/2,nx/),graphic)
205.1292 + min_cap = new((/2,nx/),graphic)
205.1293 +
205.1294 + lnres = True
205.1295 + line_colors = (/"brown","blue"/)
205.1296 +;------------------------------------------------------------------
205.1297 +; Start the graphics.
205.1298 +
205.1299 + plot_name = "histogram_grow"
205.1300 + title = model_name + " vs Observed"
205.1301 + resm@tiMainString = title
205.1302 +
205.1303 + wks = gsn_open_wks (plot_type,plot_name)
205.1304 +;-----------------------------
205.1305 +; Add a boxed legend using the more simple method
205.1306 +
205.1307 + resm@pmLegendDisplayMode = "Always"
205.1308 +; resm@pmLegendWidthF = 0.1
205.1309 + resm@pmLegendWidthF = 0.08
205.1310 + resm@pmLegendHeightF = 0.05
205.1311 + resm@pmLegendOrthogonalPosF = -1.17
205.1312 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
205.1313 +; resm@pmLegendParallelPosF = 0.18
205.1314 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
205.1315 +
205.1316 +; resm@lgPerimOn = False
205.1317 + resm@lgLabelFontHeightF = 0.015
205.1318 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
205.1319 +;-----------------------------
205.1320 + tRes = True
205.1321 + tRes@txFontHeightF = 0.025
205.1322 +
205.1323 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrGrow)+")"
205.1324 +
205.1325 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
205.1326 +
205.1327 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
205.1328 +;-------------------------------
205.1329 +;Attach the vertical bar and the horizontal cap line
205.1330 +
205.1331 + do nd=0,1
205.1332 + lnres@gsLineColor = line_colors(nd)
205.1333 + do i=0,nx-1
205.1334 +
205.1335 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
205.1336 + .not.ismissing(mx_yvalues(nd,i))) then
205.1337 +
205.1338 +; Attach the vertical bar, both above and below the marker.
205.1339 +
205.1340 + x1 = xvalues(nd,i)
205.1341 + y1 = yvalues(nd,i)
205.1342 + y2 = mn_yvalues(nd,i)
205.1343 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
205.1344 +
205.1345 + y2 = mx_yvalues(nd,i)
205.1346 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
205.1347 +
205.1348 +; Attach the horizontal cap line, both above and below the marker.
205.1349 +
205.1350 + x1 = xvalues(nd,i) - dx4
205.1351 + x2 = xvalues(nd,i) + dx4
205.1352 + y1 = mn_yvalues(nd,i)
205.1353 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
205.1354 +
205.1355 + y1 = mx_yvalues(nd,i)
205.1356 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
205.1357 + end if
205.1358 + end do
205.1359 + end do
205.1360 +
205.1361 + draw(xy)
205.1362 + frame(wks)
205.1363 +
205.1364 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.1365 + system("rm "+plot_name+"."+plot_type)
205.1366 +; system("rm "+plot_name+"-1."+plot_type_new)
205.1367 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.1368 +
205.1369 + clear (wks)
205.1370 +
205.1371 + delete (DATA11_1D)
205.1372 + delete (DATA12_1D)
205.1373 + delete (DATA22_1D)
205.1374 +;delete (range)
205.1375 +;delete (xvalues)
205.1376 + delete (yvalues)
205.1377 + delete (mn_yvalues)
205.1378 + delete (mx_yvalues)
205.1379 + delete (good)
205.1380 + delete (max_bar)
205.1381 + delete (min_bar)
205.1382 + delete (max_cap)
205.1383 + delete (min_cap)
205.1384 +;-----------------------------------------------------------------
205.1385 +;global res
205.1386 +
205.1387 + resg = True ; Use plot options
205.1388 + resg@cnFillOn = True ; Turn on color fill
205.1389 + resg@gsnSpreadColors = True ; use full colormap
205.1390 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
205.1391 +; resg@lbLabelAutoStride = True
205.1392 + resg@cnLinesOn = False ; Turn off contourn lines
205.1393 + resg@mpFillOn = False ; Turn off map fill
205.1394 +
205.1395 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
205.1396 + resg@cnMinLevelValF = 60. ; Min level
205.1397 + resg@cnMaxLevelValF = 360. ; Max level
205.1398 + resg@cnLevelSpacingF = 20. ; interval
205.1399 +
205.1400 +;global contour ob
205.1401 +
205.1402 + laiob_grow@_FillValue = 1.e+36
205.1403 + laiob_grow = where(laiob_grow .lt. 10.,laiob_grow@_FillValue,laiob_grow)
205.1404 +
205.1405 + plot_name = "global_grow_ob"
205.1406 + title = ob_name
205.1407 + resg@tiMainString = title
205.1408 +
205.1409 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
205.1410 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.1411 +
205.1412 + plot = gsn_csm_contour_map_ce(wks,laiob_grow,resg)
205.1413 + frame(wks)
205.1414 +
205.1415 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.1416 + system("rm "+plot_name+"."+plot_type)
205.1417 + system("rm "+plot_name+"-1."+plot_type_new)
205.1418 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.1419 +
205.1420 + clear (wks)
205.1421 +;------------------------------------------------------------------------
205.1422 +;global contour model
205.1423 +
205.1424 + laimod_grow@_FillValue = 1.e+36
205.1425 + laimod_grow = where(laimod_grow .lt. 10.,laimod_grow@_FillValue,laimod_grow)
205.1426 +
205.1427 + plot_name = "global_grow_model"
205.1428 + title = "Model " + model_name
205.1429 + resg@tiMainString = title
205.1430 +
205.1431 + wks = gsn_open_wks (plot_type,plot_name)
205.1432 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.1433 +
205.1434 + delete (plot)
205.1435 + plot = gsn_csm_contour_map_ce(wks,laimod_grow,resg)
205.1436 + frame(wks)
205.1437 +
205.1438 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.1439 + system("rm "+plot_name+"."+plot_type)
205.1440 + system("rm "+plot_name+"-1."+plot_type_new)
205.1441 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.1442 +
205.1443 + clear (wks)
205.1444 +;------------------------------------------------------------------------
205.1445 +;global contour model vs ob
205.1446 +
205.1447 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
205.1448 + resg@cnMinLevelValF = 0. ; Min level
205.1449 + resg@cnMaxLevelValF = 10. ; Max level
205.1450 + resg@cnLevelSpacingF = 1. ; interval
205.1451 +
205.1452 + plot_name = "global_mean_model_vs_ob"
205.1453 +
205.1454 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
205.1455 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.1456 +
205.1457 + delete (plot)
205.1458 + plot=new(3,graphic) ; create graphic array
205.1459 +
205.1460 + resg@gsnFrame = False ; Do not draw plot
205.1461 + resg@gsnDraw = False ; Do not advance frame
205.1462 +
205.1463 +; plot correlation coef
205.1464 +
205.1465 + gRes = True
205.1466 + gRes@txFontHeightF = 0.02
205.1467 + gRes@txAngleF = 90
205.1468 +
205.1469 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMean)+")"
205.1470 +
205.1471 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
205.1472 +;--------------------------------------------------------------------
205.1473 +
205.1474 +;(a) ob
205.1475 +
205.1476 + title = ob_name
205.1477 + resg@tiMainString = title
205.1478 +
205.1479 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_mean,resg)
205.1480 +
205.1481 +;(b) model
205.1482 +
205.1483 + title = "Model "+ model_name
205.1484 + resg@tiMainString = title
205.1485 +
205.1486 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_mean,resg)
205.1487 +
205.1488 +;(c) model-ob
205.1489 +
205.1490 + zz = laimod_mean
205.1491 + zz = laimod_mean - laiob_mean
205.1492 + title = "Model_"+model_name+" - Observed"
205.1493 + resg@tiMainString = title
205.1494 +
205.1495 + resg@cnMinLevelValF = -2. ; Min level
205.1496 + resg@cnMaxLevelValF = 2. ; Max level
205.1497 + resg@cnLevelSpacingF = 0.4 ; interval
205.1498 +
205.1499 +
205.1500 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
205.1501 +
205.1502 + pres = True ; panel plot mods desired
205.1503 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
205.1504 + ; indiv. plots in panel
205.1505 + pres@gsnMaximize = True ; fill the page
205.1506 +
205.1507 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
205.1508 +
205.1509 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.1510 + system("rm "+plot_name+"."+plot_type)
205.1511 +; system("rm "+plot_name+"-1."+plot_type_new)
205.1512 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.1513 +
205.1514 + frame (wks)
205.1515 + clear (wks)
205.1516 +
205.1517 + delete (plot)
205.1518 +;-----------------------------------------------------------------
205.1519 +;global contour model vs ob
205.1520 +
205.1521 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
205.1522 + resg@cnMinLevelValF = 0. ; Min level
205.1523 + resg@cnMaxLevelValF = 10. ; Max level
205.1524 + resg@cnLevelSpacingF = 1. ; interval
205.1525 +
205.1526 + plot_name = "global_max_model_vs_ob"
205.1527 +
205.1528 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
205.1529 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.1530 +
205.1531 +; delete(plot)
205.1532 + plot=new(3,graphic) ; create graphic array
205.1533 +
205.1534 + resg@gsnFrame = False ; Do not draw plot
205.1535 + resg@gsnDraw = False ; Do not advance frame
205.1536 +
205.1537 +; plot correlation coef
205.1538 +
205.1539 + gRes = True
205.1540 + gRes@txFontHeightF = 0.02
205.1541 + gRes@txAngleF = 90
205.1542 +
205.1543 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMax)+")"
205.1544 +
205.1545 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
205.1546 +;--------------------------------------------------------------------
205.1547 +;(a) ob
205.1548 +
205.1549 + title = ob_name
205.1550 + resg@tiMainString = title
205.1551 +
205.1552 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_max,resg)
205.1553 +
205.1554 +;(b) model
205.1555 +
205.1556 + title = "Model "+ model_name
205.1557 + resg@tiMainString = title
205.1558 +
205.1559 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_max,resg)
205.1560 +
205.1561 +;(c) model-ob
205.1562 +
205.1563 + delete (zz)
205.1564 + zz = laimod_max
205.1565 + zz = laimod_max - laiob_max
205.1566 + title = "Model_"+model_name+" - Observed"
205.1567 + resg@tiMainString = title
205.1568 +
205.1569 + resg@cnMinLevelValF = -6. ; Min level
205.1570 + resg@cnMaxLevelValF = 6. ; Max level
205.1571 + resg@cnLevelSpacingF = 1. ; interval
205.1572 +
205.1573 +
205.1574 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
205.1575 +
205.1576 + pres = True ; panel plot mods desired
205.1577 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
205.1578 + ; indiv. plots in panel
205.1579 + pres@gsnMaximize = True ; fill the page
205.1580 +
205.1581 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
205.1582 +
205.1583 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.1584 + system("rm "+plot_name+"."+plot_type)
205.1585 +; system("rm "+plot_name+"-1."+plot_type_new)
205.1586 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.1587 +
205.1588 + frame (wks)
205.1589 + clear (wks)
205.1590 +
205.1591 + delete (plot)
205.1592 +;-----------------------------------------------------------------
205.1593 +;global contour model vs ob
205.1594 +
205.1595 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
205.1596 + resg@cnMinLevelValF = 1. ; Min level
205.1597 + resg@cnMaxLevelValF = 12. ; Max level
205.1598 + resg@cnLevelSpacingF = 1. ; interval
205.1599 +
205.1600 + plot_name = "global_phase_model_vs_ob"
205.1601 +
205.1602 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
205.1603 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.1604 +
205.1605 +; delete (plot)
205.1606 + plot=new(3,graphic) ; create graphic array
205.1607 +
205.1608 + resg@gsnFrame = False ; Do not draw plot
205.1609 + resg@gsnDraw = False ; Do not advance frame
205.1610 +
205.1611 +; plot correlation coef
205.1612 +
205.1613 + gRes = True
205.1614 + gRes@txFontHeightF = 0.02
205.1615 + gRes@txAngleF = 90
205.1616 +
205.1617 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrPhase)+")"
205.1618 +
205.1619 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
205.1620 +;--------------------------------------------------------------------
205.1621 +;(a) ob
205.1622 +
205.1623 + title = ob_name
205.1624 + resg@tiMainString = title
205.1625 +
205.1626 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_phase,resg)
205.1627 +
205.1628 +;(b) model
205.1629 +
205.1630 + title = "Model "+ model_name
205.1631 + resg@tiMainString = title
205.1632 +
205.1633 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_phase,resg)
205.1634 +
205.1635 +;(c) model-ob
205.1636 +
205.1637 + delete (zz)
205.1638 + zz = laimod_phase
205.1639 + zz = laimod_phase - laiob_phase
205.1640 + title = "Model_"+model_name+" - Observed"
205.1641 + resg@tiMainString = title
205.1642 +
205.1643 + resg@cnMinLevelValF = -6. ; Min level
205.1644 + resg@cnMaxLevelValF = 6. ; Max level
205.1645 + resg@cnLevelSpacingF = 1. ; interval
205.1646 +
205.1647 +
205.1648 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
205.1649 +
205.1650 +; pres = True ; panel plot mods desired
205.1651 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
205.1652 + ; indiv. plots in panel
205.1653 +; pres@gsnMaximize = True ; fill the page
205.1654 +
205.1655 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
205.1656 +
205.1657 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.1658 + system("rm "+plot_name+"."+plot_type)
205.1659 +; system("rm "+plot_name+"-1."+plot_type_new)
205.1660 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.1661 +
205.1662 + frame (wks)
205.1663 + clear (wks)
205.1664 +
205.1665 + delete (plot)
205.1666 +;------------------------------------------------------------------
205.1667 +;global contour model vs ob
205.1668 +
205.1669 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
205.1670 + resg@cnMinLevelValF = 60. ; Min level
205.1671 + resg@cnMaxLevelValF = 360. ; Max level
205.1672 + resg@cnLevelSpacingF = 20. ; interval
205.1673 +
205.1674 + plot_name = "global_grow_model_vs_ob"
205.1675 +
205.1676 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
205.1677 + gsn_define_colormap(wks,"gui_default") ; choose colormap
205.1678 +
205.1679 +; delete (plot)
205.1680 + plot=new(3,graphic) ; create graphic array
205.1681 +
205.1682 + resg@gsnFrame = False ; Do not draw plot
205.1683 + resg@gsnDraw = False ; Do not advance frame
205.1684 +
205.1685 +; plot correlation coef
205.1686 +
205.1687 + gRes = True
205.1688 + gRes@txFontHeightF = 0.02
205.1689 + gRes@txAngleF = 90
205.1690 +
205.1691 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrGrow)+")"
205.1692 +
205.1693 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
205.1694 +;--------------------------------------------------------------------
205.1695 +;(a) ob
205.1696 +
205.1697 + title = ob_name
205.1698 + resg@tiMainString = title
205.1699 +
205.1700 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_grow,resg)
205.1701 +
205.1702 +;(b) model
205.1703 +
205.1704 + title = "Model "+ model_name
205.1705 + resg@tiMainString = title
205.1706 +
205.1707 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_grow,resg)
205.1708 +
205.1709 +;(c) model-ob
205.1710 +
205.1711 + delete (zz)
205.1712 + zz = laimod_grow
205.1713 + zz = laimod_grow - laiob_grow
205.1714 + title = "Model_"+model_name+" - Observed"
205.1715 + resg@tiMainString = title
205.1716 +
205.1717 + resg@cnMinLevelValF = -100. ; Min level
205.1718 + resg@cnMaxLevelValF = 100. ; Max level
205.1719 + resg@cnLevelSpacingF = 20. ; interval
205.1720 +
205.1721 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
205.1722 +
205.1723 + pres = True ; panel plot mods desired
205.1724 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
205.1725 + ; indiv. plots in panel
205.1726 + pres@gsnMaximize = True ; fill the page
205.1727 +
205.1728 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
205.1729 +
205.1730 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.1731 + system("rm "+plot_name+"."+plot_type)
205.1732 +; system("rm "+plot_name+"-1."+plot_type_new)
205.1733 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.1734 +
205.1735 + frame (wks)
205.1736 + clear (wks)
205.1737 +
205.1738 + delete (plot)
205.1739 +;**************************************************
205.1740 +; plot lai table
205.1741 +;**************************************************
205.1742 +
205.1743 + plot_name = "table_lai"
205.1744 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
205.1745 +
205.1746 + gsn_table(wks,ncr1,xx1,yy1,text1,res1)
205.1747 + gsn_table(wks,ncr21,xx21,yy21,text21,res21)
205.1748 + gsn_table(wks,ncr22,xx22,yy22,text22,res22)
205.1749 + gsn_table(wks,ncr3,xx3,yy3,text3,res3)
205.1750 + gsn_table(wks,ncr4,xx4,yy4,text4,res4)
205.1751 +
205.1752 + frame(wks)
205.1753 +
205.1754 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
205.1755 +; system("rm "+plot_name+"."+plot_type)
205.1756 +; system("rm "+plot_name+"-1."+plot_type_new)
205.1757 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
205.1758 +;-------------------------------------------------------------------
205.1759 + temp_name = "lai." + model_name
205.1760 + system("mkdir -p " + temp_name)
205.1761 + system("cp table.html " + temp_name)
205.1762 + system("mv *.png " + temp_name)
205.1763 + system("tar cf "+ temp_name +".tar " + temp_name)
205.1764 +;-------------------------------------------------------------------
205.1765 +end
205.1766 +
206.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
206.2 +++ b/lai/99.all.ncl.new Mon Jan 26 22:08:20 2009 -0500
206.3 @@ -0,0 +1,735 @@
206.4 +;*************************************************************
206.5 +; remove histogram plots.
206.6 +;
206.7 +; required command line input parameters:
206.8 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
206.9 +;
206.10 +; histogram normalized by rain and compute correleration
206.11 +;**************************************************************
206.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
206.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
206.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
206.15 +;**************************************************************
206.16 +procedure set_line(lines:string,nline:integer,newlines:string)
206.17 +begin
206.18 +; add line to ascci/html file
206.19 +
206.20 + nnewlines = dimsizes(newlines)
206.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
206.22 + print("set_line: bad index, not setting anything.")
206.23 + return
206.24 + end if
206.25 + lines(nline:nline+nnewlines-1) = newlines
206.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
206.27 + nline = nline + nnewlines
206.28 + return
206.29 +end
206.30 +;**************************************************************
206.31 +; Main code.
206.32 +begin
206.33 +
206.34 + plot_type = "ps"
206.35 + plot_type_new = "png"
206.36 +
206.37 +;************************************************
206.38 +; read data: model
206.39 +;************************************************
206.40 +
206.41 +;film = "b30.061n_1995-2004_MONS_climo_lnd.nc"
206.42 +;model_name = "b30.061n"
206.43 +;model_grid = "T31"
206.44 +
206.45 +;film = "newcn05_ncep_1i_MONS_climo_lnd.nc"
206.46 +;model_name = "newcn"
206.47 +;model_grid = "1.9"
206.48 +
206.49 +;film = "i01.06cn_1798-2004_MONS_climo.nc"
206.50 +;model_name = "06cn"
206.51 +;model_grid = "T42"
206.52 +
206.53 +;film = "i01.06casa_1798-2004_MONS_climo.nc"
206.54 +;model_name = "06casa"
206.55 +;model_grid = "T42"
206.56 +
206.57 + film = "i01.10cn_1948-2004_MONS_climo.nc"
206.58 + model_name = "10cn"
206.59 + model_grid = "T42"
206.60 +
206.61 +;film = "i01.10casa_1948-2004_MONS_climo.nc"
206.62 +;model_name = "10casa"
206.63 +;model_grid = "T42"
206.64 +
206.65 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
206.66 + fm = addfile(dirm+film,"r")
206.67 +
206.68 + laimod = fm->TLAI
206.69 +
206.70 +;************************************************
206.71 +; read data: observed
206.72 +;************************************************
206.73 +
206.74 + ob_name = "MODIS MOD 15A2 2000-2005"
206.75 +
206.76 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
206.77 + filo1 = "land_class_"+model_grid+".nc"
206.78 + filo2 = "LAI_2000-2005_MONS_"+model_grid+".nc"
206.79 +
206.80 + fo1 = addfile(diro+filo1,"r")
206.81 + fo2 = addfile(diro+filo2,"r")
206.82 +
206.83 + classob = tofloat(fo1->LAND_CLASS)
206.84 + laiob = fo2->LAI
206.85 +
206.86 +; input observed data has 20 land-type classes
206.87 + nclass = 20
206.88 +
206.89 +;************************************************
206.90 +; global res
206.91 +;************************************************
206.92 + resg = True ; Use plot options
206.93 + resg@cnFillOn = True ; Turn on color fill
206.94 + resg@gsnSpreadColors = True ; use full colormap
206.95 + resg@cnLinesOn = False ; Turn off contourn lines
206.96 + resg@mpFillOn = False ; Turn off map fill
206.97 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
206.98 +
206.99 +;************************************************
206.100 +; plot global land class: observed
206.101 +;************************************************
206.102 +
206.103 + resg@cnMinLevelValF = 1. ; Min level
206.104 + resg@cnMaxLevelValF = 19. ; Max level
206.105 + resg@cnLevelSpacingF = 1. ; interval
206.106 +
206.107 +; global contour ob
206.108 + classob@_FillValue = 1.e+36
206.109 + classob = where(classob.eq.0,classob@_FillValue,classob)
206.110 +
206.111 + plot_name = "global_class_ob"
206.112 + title = ob_name
206.113 + resg@tiMainString = title
206.114 +
206.115 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
206.116 + gsn_define_colormap(wks,"gui_default") ; choose colormap
206.117 +
206.118 + plot = gsn_csm_contour_map_ce(wks,classob,resg)
206.119 + frame(wks)
206.120 +
206.121 + clear (wks)
206.122 +
206.123 +;*******************************************************************
206.124 +; for html table : all 4 components (Mean, Max, Phase, Growth)
206.125 +;*******************************************************************
206.126 +
206.127 +; column (not including header column)
206.128 +
206.129 + component = (/"Mean","Max","Phase","Growth"/)
206.130 + col_head2 = (/"observed",model_name,"M_score" \
206.131 + ,"observed",model_name,"M_score" \
206.132 + ,"observed",model_name,"M_score" \
206.133 + ,"observed",model_name,"M_score" \
206.134 + /)
206.135 +
206.136 + n_comp = dimsizes(component)
206.137 + ncol = dimsizes(col_head2)
206.138 +
206.139 +; row (not including header row)
206.140 + row_head = (/"Evergreen Needleleaf Forests" \
206.141 + ,"Evergreen Broadleaf Forests" \
206.142 + ,"Deciduous Needleleaf Forest" \
206.143 + ,"Deciduous Broadleaf Forests" \
206.144 + ,"Mixed Forests" \
206.145 + ,"Closed Bushlands" \
206.146 + ,"Open Bushlands" \
206.147 + ,"Woody Savannas (S. Hem.)" \
206.148 + ,"Savannas (S. Hem.)" \
206.149 + ,"Grasslands" \
206.150 + ,"Permanent Wetlands" \
206.151 + ,"Croplands" \
206.152 + ,"Cropland/Natural Vegetation Mosaic" \
206.153 + ,"Barren or Sparsely Vegetated" \
206.154 + ,"Woody Savannas (N. Hem.)" \
206.155 + ,"Savannas (N. Hem.)" \
206.156 + ,"All Biome" \
206.157 + /)
206.158 + nrow = dimsizes(row_head)
206.159 +
206.160 +; arrays to be passed to table.
206.161 + text4 = new ((/nrow, ncol/),string )
206.162 +
206.163 +; M_comp
206.164 + M_comp = (/"M_lai_mean","M_lai_max","M_lai_phase","M_lai_grow"/)
206.165 +
206.166 +; total M_score
206.167 + M_total = 0.
206.168 +
206.169 +;********************************************************************
206.170 +; use land-type class to bin the data in equally spaced ranges
206.171 +;********************************************************************
206.172 +
206.173 + nclassn = nclass + 1
206.174 + range = fspan(0,nclassn-1,nclassn)
206.175 +; print (range)
206.176 +
206.177 +; Use this range information to grab all the values in a
206.178 +; particular range, and then take an average.
206.179 +
206.180 + nr = dimsizes(range)
206.181 + nx = nr-1
206.182 + xvalues = new((/2,nx/),float)
206.183 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
206.184 + dx = xvalues(0,1) - xvalues(0,0) ; range width
206.185 + dx4 = dx/4 ; 1/4 of the range
206.186 + xvalues(1,:) = xvalues(0,:) - dx/5.
206.187 +
206.188 +;************************************************************************
206.189 +; go through all components
206.190 +;************************************************************************
206.191 +
206.192 + do n = 0,n_comp-1
206.193 +
206.194 +;===================
206.195 +; get data:
206.196 +;===================
206.197 +; (A) Mean
206.198 +
206.199 + if (n .eq. 0) then
206.200 + data_ob = dim_avg_Wrap(laiob (lat|:,lon|:,time|:))
206.201 + data_mod = dim_avg_Wrap(laimod(lat|:,lon|:,time|:))
206.202 + end if
206.203 +
206.204 +; (B) Max
206.205 +
206.206 + if (n .eq. 1) then
206.207 +
206.208 +; observed
206.209 + data_ob = laiob(0,:,:)
206.210 + s = laiob(:,0,0)
206.211 + data_ob@long_name = "Leaf Area Index Max"
206.212 +
206.213 + dsizes_z = dimsizes(laiob)
206.214 + nlat = dsizes_z(1)
206.215 + nlon = dsizes_z(2)
206.216 +
206.217 + do j = 0,nlat-1
206.218 + do i = 0,nlon-1
206.219 + s = laiob(:,j,i)
206.220 + data_ob(j,i) = max(s)
206.221 + end do
206.222 + end do
206.223 +
206.224 + delete (s)
206.225 + delete (dsizes_z)
206.226 +
206.227 +; model
206.228 + data_mod = laimod(0,:,:)
206.229 + s = laimod(:,0,0)
206.230 + data_mod@long_name = "Leaf Area Index Max"
206.231 +
206.232 + dsizes_z = dimsizes(laimod)
206.233 + nlat = dsizes_z(1)
206.234 + nlon = dsizes_z(2)
206.235 +
206.236 + do j = 0,nlat-1
206.237 + do i = 0,nlon-1
206.238 + s = laimod(:,j,i)
206.239 + data_mod(j,i) = max(s)
206.240 + end do
206.241 + end do
206.242 +
206.243 + delete (s)
206.244 + delete (dsizes_z)
206.245 + end if
206.246 +
206.247 +; (C) phase
206.248 +
206.249 + if (n .eq. 2) then
206.250 +
206.251 +; observed
206.252 + data_ob = laiob(0,:,:)
206.253 + s = laiob(:,0,0)
206.254 + data_ob@long_name = "Leaf Area Index Max Month"
206.255 +
206.256 + dsizes_z = dimsizes(laiob)
206.257 + nlat = dsizes_z(1)
206.258 + nlon = dsizes_z(2)
206.259 +
206.260 + do j = 0,nlat-1
206.261 + do i = 0,nlon-1
206.262 + s = laiob(:,j,i)
206.263 + data_ob(j,i) = maxind(s) + 1
206.264 + end do
206.265 + end do
206.266 +
206.267 + delete (s)
206.268 + delete (dsizes_z)
206.269 +
206.270 +; model
206.271 + data_mod = laimod(0,:,:)
206.272 + s = laimod(:,0,0)
206.273 + data_mod@long_name = "Leaf Area Index Max Month"
206.274 +
206.275 + dsizes_z = dimsizes(laimod)
206.276 + nlat = dsizes_z(1)
206.277 + nlon = dsizes_z(2)
206.278 +
206.279 + do j = 0,nlat-1
206.280 + do i = 0,nlon-1
206.281 + s = laimod(:,j,i)
206.282 + data_mod(j,i) = maxind(s) + 1
206.283 + end do
206.284 + end do
206.285 +
206.286 + delete (s)
206.287 + delete (dsizes_z)
206.288 + end if
206.289 +
206.290 +; (D) grow day
206.291 +
206.292 + if (n .eq. 3) then
206.293 +
206.294 + day_of_data = (/31,28,31,30,31,30,31,31,30,31,30,31/)
206.295 +
206.296 +; observed
206.297 + data_ob = laiob(0,:,:)
206.298 + data_ob@long_name = "Days of Growing Season"
206.299 +
206.300 + dsizes_z = dimsizes(laiob)
206.301 + ntime = dsizes_z(0)
206.302 + nlat = dsizes_z(1)
206.303 + nlon = dsizes_z(2)
206.304 +
206.305 + do j = 0,nlat-1
206.306 + do i = 0,nlon-1
206.307 + nday = 0.
206.308 + do k = 0,ntime-1
206.309 + if (.not. ismissing(laiob(k,j,i)) .and. laiob(k,j,i) .gt. 1.0) then
206.310 + nday = nday + day_of_data(k)
206.311 + end if
206.312 + end do
206.313 +
206.314 + data_ob(j,i) = nday
206.315 + end do
206.316 + end do
206.317 +
206.318 + delete (dsizes_z)
206.319 +
206.320 +; model
206.321 + data_mod = laimod(0,:,:)
206.322 + data_mod@long_name = "Days of Growing Season"
206.323 +
206.324 + dsizes_z = dimsizes(laimod)
206.325 + ntime = dsizes_z(0)
206.326 + nlat = dsizes_z(1)
206.327 + nlon = dsizes_z(2)
206.328 +
206.329 + do j = 0,nlat-1
206.330 + do i = 0,nlon-1
206.331 + nday = 0.
206.332 + do k = 0,ntime-1
206.333 + if (.not. ismissing(laimod(k,j,i)) .and. laimod(k,j,i) .gt. 1.0) then
206.334 + nday = nday + day_of_data(k)
206.335 + end if
206.336 + end do
206.337 +
206.338 + data_mod(j,i) = nday
206.339 + end do
206.340 + end do
206.341 +
206.342 + delete (dsizes_z)
206.343 + end if
206.344 +
206.345 +;==============================
206.346 +; put data into bins
206.347 +;==============================
206.348 +
206.349 + base_1D = ndtooned(classob)
206.350 + data1_1D = ndtooned(data_ob)
206.351 + data2_1D = ndtooned(data_mod)
206.352 +
206.353 +; output for data in bins
206.354 +
206.355 + yvalues = new((/2,nx/),float)
206.356 + count = new((/2,nx/),float)
206.357 +
206.358 +; put data into bins
206.359 +
206.360 + do nd=0,1
206.361 +
206.362 +; See if we are doing data1 (nd=0) or data2 (nd=1).
206.363 +
206.364 + base = base_1D
206.365 +
206.366 + if(nd.eq.0) then
206.367 + data = data1_1D
206.368 + else
206.369 + data = data2_1D
206.370 + end if
206.371 +
206.372 +; Loop through each range, using base.
206.373 +
206.374 + do i=0,nr-2
206.375 + if (i.ne.(nr-2)) then
206.376 +; print("")
206.377 +; print("In range ["+range(i)+","+range(i+1)+")")
206.378 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
206.379 + else
206.380 +; print("")
206.381 +; print("In range ["+range(i)+",)")
206.382 + idx = ind(base.ge.range(i))
206.383 + end if
206.384 +
206.385 +; Calculate average
206.386 +
206.387 + if(.not.any(ismissing(idx))) then
206.388 + yvalues(nd,i) = avg(data(idx))
206.389 + count(nd,i) = dimsizes(idx)
206.390 + else
206.391 + yvalues(nd,i) = yvalues@_FillValue
206.392 + count(nd,i) = 0
206.393 + end if
206.394 +
206.395 +;#############################################################
206.396 +; set the following 4 classes to _FillValue:
206.397 +; Water Bodies(0), Urban and Build-Up(13),
206.398 +; Permenant Snow and Ice(15), Unclassified(17)
206.399 +
206.400 + if (i.eq.0 .or. i.eq.13 .or. i.eq.15 .or. i.eq.17) then
206.401 + yvalues(nd,i) = yvalues@_FillValue
206.402 + count(nd,i) = 0
206.403 + end if
206.404 +;#############################################################
206.405 +
206.406 +; print(nd + ": " + count(nd,i) + " points, avg = " + yvalues(nd,i))
206.407 +
206.408 +; Clean up for next time in loop.
206.409 +
206.410 + delete(idx)
206.411 + end do
206.412 +
206.413 + delete(data)
206.414 + end do
206.415 +
206.416 + delete (base)
206.417 + delete (base_1D)
206.418 + delete (data1_1D)
206.419 + delete (data2_1D)
206.420 +
206.421 +;=====================================
206.422 +; compute correlation coef and M score
206.423 +;=====================================
206.424 +
206.425 + u = yvalues(0,:)
206.426 + v = yvalues(1,:)
206.427 +
206.428 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
206.429 + uu = u(good)
206.430 + vv = v(good)
206.431 +
206.432 +; compute correlation coef
206.433 + cc = esccr(uu,vv,0)
206.434 +
206.435 + if (n .eq. 2) then
206.436 + bias = avg(abs(vv-uu))
206.437 + bias = where((bias.gt. 6.),12.-bias,bias)
206.438 + Mscore = ((6. - bias)/6.)*5.
206.439 + M_score = sprintf("%.2f", Mscore)
206.440 + else
206.441 + bias = sum(abs(vv-uu)/abs(vv+uu))
206.442 + Mscore = (1.- (bias/dimsizes(uu)))*5.
206.443 + M_score = sprintf("%.2f", Mscore)
206.444 + end if
206.445 +
206.446 +; compute M_total
206.447 +
206.448 + M_total = M_total + Mscore
206.449 +
206.450 +;==================
206.451 +; output M_score
206.452 +;==================
206.453 +
206.454 + print (Mscore)
206.455 +;=======================
206.456 +; output to html table
206.457 +;=======================
206.458 +
206.459 + nn = n*3
206.460 +
206.461 + do i=0,nrow-2
206.462 + text4(i,nn) = sprintf("%.2f",u(i))
206.463 + text4(i,nn+1) = sprintf("%.2f",v(i))
206.464 + text4(i,nn+2) = "-"
206.465 + end do
206.466 + text4(nrow-1,nn) = sprintf("%.2f",avg(u))
206.467 + text4(nrow-1,nn+1) = sprintf("%.2f",avg(v))
206.468 + text4(nrow-1,nn+2) = M_score
206.469 +
206.470 + delete (u)
206.471 + delete (v)
206.472 + delete (uu)
206.473 + delete (vv)
206.474 + delete (yvalues)
206.475 + delete (good)
206.476 +
206.477 +;========================================
206.478 +; global res changes for each component
206.479 +;========================================
206.480 + delta = 0.00001
206.481 +
206.482 + if (n .eq. 0) then
206.483 + resg@cnMinLevelValF = 0.
206.484 + resg@cnMaxLevelValF = 10.
206.485 + resg@cnLevelSpacingF = 1.
206.486 +
206.487 + data_ob = where(ismissing(data_ob).and.(ismissing(data_mod).or.(data_mod.lt.delta)),0.,data_ob)
206.488 + end if
206.489 +
206.490 + if (n .eq. 1) then
206.491 + resg@cnMinLevelValF = 0.
206.492 + resg@cnMaxLevelValF = 10.
206.493 + resg@cnLevelSpacingF = 1.
206.494 +
206.495 + data_ob = where(ismissing(data_ob).and.(ismissing(data_mod).or.(data_mod.lt.delta)),0.,data_ob)
206.496 + end if
206.497 +
206.498 + if (n .eq. 2) then
206.499 + resg@cnMinLevelValF = 1.
206.500 + resg@cnMaxLevelValF = 12.
206.501 + resg@cnLevelSpacingF = 1.
206.502 +
206.503 + data_ob = where(ismissing(data_ob).and.(ismissing(data_mod).or.(data_mod.lt.delta)),0.,data_ob)
206.504 + end if
206.505 +
206.506 + if (n .eq. 3) then
206.507 + resg@cnMinLevelValF = 60.
206.508 + resg@cnMaxLevelValF = 360.
206.509 + resg@cnLevelSpacingF = 20.
206.510 +
206.511 + data_ob@_FillValue = 1.e+36
206.512 + data_ob = where(data_ob .lt. 10.,data_ob@_FillValue,data_ob)
206.513 +
206.514 + data_mod@_FillValue = 1.e+36
206.515 + data_mod = where(data_mod .lt. 10.,data_mod@_FillValue,data_mod)
206.516 + end if
206.517 +
206.518 +;=========================
206.519 +; global contour : ob
206.520 +;=========================
206.521 +
206.522 + plot_name = "global_"+component(n)+"_ob"
206.523 + title = ob_name
206.524 + resg@tiMainString = title
206.525 +
206.526 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
206.527 + gsn_define_colormap(wks,"gui_default") ; choose colormap
206.528 +
206.529 + plot = gsn_csm_contour_map_ce(wks,data_ob,resg)
206.530 + frame(wks)
206.531 +
206.532 + clear (wks)
206.533 + delete (plot)
206.534 +
206.535 +;============================
206.536 +; global contour : model
206.537 +;============================
206.538 +
206.539 + plot_name = "global_"+component(n)+"_model"
206.540 + title = "Model " + model_name
206.541 + resg@tiMainString = title
206.542 +
206.543 + wks = gsn_open_wks (plot_type,plot_name)
206.544 + gsn_define_colormap(wks,"gui_default")
206.545 +
206.546 + plot = gsn_csm_contour_map_ce(wks,data_mod,resg)
206.547 + frame(wks)
206.548 +
206.549 + clear (wks)
206.550 + delete (plot)
206.551 +
206.552 +;================================
206.553 +; global contour: model vs ob
206.554 +;================================
206.555 +
206.556 + plot_name = "global_"+component(n)+"_model_vs_ob"
206.557 +
206.558 + wks = gsn_open_wks (plot_type,plot_name)
206.559 + gsn_define_colormap(wks,"gui_default")
206.560 +
206.561 + plot=new(3,graphic) ; create graphic array
206.562 +
206.563 + resg@gsnFrame = False ; Do not draw plot
206.564 + resg@gsnDraw = False ; Do not advance frame
206.565 +
206.566 +; plot correlation coef
206.567 +
206.568 + gRes = True
206.569 + gRes@txFontHeightF = 0.02
206.570 + gRes@txAngleF = 90
206.571 +
206.572 + correlation_text = "(correlation coef = "+sprintf("%.2f", cc)+")"
206.573 +
206.574 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
206.575 +
206.576 +; plot ob
206.577 +
206.578 + title = ob_name
206.579 + resg@tiMainString = title
206.580 +
206.581 + plot(0) = gsn_csm_contour_map_ce(wks,data_ob,resg)
206.582 +
206.583 +; plot model
206.584 +
206.585 + title = "Model "+ model_name
206.586 + resg@tiMainString = title
206.587 +
206.588 + plot(1) = gsn_csm_contour_map_ce(wks,data_mod,resg)
206.589 +
206.590 +; plot model-ob
206.591 +
206.592 + if (n .eq. 0) then
206.593 + resg@cnMinLevelValF = -2.
206.594 + resg@cnMaxLevelValF = 2.
206.595 + resg@cnLevelSpacingF = 0.4
206.596 + end if
206.597 +
206.598 + if (n .eq. 1) then
206.599 + resg@cnMinLevelValF = -6.
206.600 + resg@cnMaxLevelValF = 6.
206.601 + resg@cnLevelSpacingF = 1.
206.602 + end if
206.603 +
206.604 + if (n .eq. 2) then
206.605 + resg@cnMinLevelValF = -6.
206.606 + resg@cnMaxLevelValF = 6.
206.607 + resg@cnLevelSpacingF = 1.
206.608 + end if
206.609 +
206.610 + if (n .eq. 3) then
206.611 + resg@cnMinLevelValF = -100.
206.612 + resg@cnMaxLevelValF = 100.
206.613 + resg@cnLevelSpacingF = 20.
206.614 + end if
206.615 +
206.616 + zz = data_mod
206.617 + zz = data_mod - data_ob
206.618 + title = "Model_"+model_name+" - Observed"
206.619 + resg@tiMainString = title
206.620 +
206.621 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
206.622 +
206.623 +; plot panel
206.624 +
206.625 + pres = True ; panel plot mods desired
206.626 + pres@gsnMaximize = True ; fill the page
206.627 +
206.628 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
206.629 +
206.630 + clear (wks)
206.631 + delete (plot)
206.632 +
206.633 + end do
206.634 +;**************************************************
206.635 +; html table
206.636 +;**************************************************
206.637 + output_html = "table_model_vs_ob.html"
206.638 +
206.639 + header_text = "<H1>LAI: Model "+model_name+" vs Observed</H1>"
206.640 +
206.641 + header = (/"<HTML>" \
206.642 + ,"<HEAD>" \
206.643 + ,"<TITLE>CLAMP metrics</TITLE>" \
206.644 + ,"</HEAD>" \
206.645 + ,header_text \
206.646 + /)
206.647 + footer = "</HTML>"
206.648 +
206.649 + table_header = (/ \
206.650 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
206.651 + ,"<tr>" \
206.652 + ," <th bgcolor=DDDDDD rowspan=2>Biome Class</th>" \
206.653 + ," <th bgcolor=DDDDDD colspan=3>"+component(0)+"</th>" \
206.654 + ," <th bgcolor=DDDDDD colspan=3>"+component(1)+"</th>" \
206.655 + ," <th bgcolor=DDDDDD colspan=3>"+component(2)+"</th>" \
206.656 + ," <th bgcolor=DDDDDD colspan=3>"+component(3)+"</th>" \
206.657 + ,"</tr>" \
206.658 + ,"<tr>" \
206.659 + ," <th bgcolor=DDDDDD >observed</th>" \
206.660 + ," <th bgcolor=DDDDDD >"+model_name+"</th>" \
206.661 + ," <th bgcolor=DDDDDD >M_score</th>" \
206.662 + ," <th bgcolor=DDDDDD >observed</th>" \
206.663 + ," <th bgcolor=DDDDDD >"+model_name+"</th>" \
206.664 + ," <th bgcolor=DDDDDD >M_score</th>" \
206.665 + ," <th bgcolor=DDDDDD >observed</th>" \
206.666 + ," <th bgcolor=DDDDDD >"+model_name+"</th>" \
206.667 + ," <th bgcolor=DDDDDD >M_score</th>" \
206.668 + ," <th bgcolor=DDDDDD >observed</th>" \
206.669 + ," <th bgcolor=DDDDDD >"+model_name+"</th>" \
206.670 + ," <th bgcolor=DDDDDD >M_score</th>" \
206.671 + ,"</tr>" \
206.672 + /)
206.673 + table_footer = "</table>"
206.674 + row_header = "<tr>"
206.675 + row_footer = "</tr>"
206.676 +
206.677 + lines = new(50000,string)
206.678 + nline = 0
206.679 +
206.680 + set_line(lines,nline,header)
206.681 + set_line(lines,nline,table_header)
206.682 +;-----------------------------------------------
206.683 +;row of table
206.684 +
206.685 + do n = 0,nrow-1
206.686 + set_line(lines,nline,row_header)
206.687 +
206.688 + txt1 = row_head(n)
206.689 + txt2 = text4(n,0)
206.690 + txt3 = text4(n,1)
206.691 + txt4 = text4(n,2)
206.692 + txt5 = text4(n,3)
206.693 + txt6 = text4(n,4)
206.694 + txt7 = text4(n,5)
206.695 + txt8 = text4(n,6)
206.696 + txt9 = text4(n,7)
206.697 + txt10 = text4(n,8)
206.698 + txt11 = text4(n,9)
206.699 + txt12 = text4(n,10)
206.700 + txt13 = text4(n,11)
206.701 +
206.702 + set_line(lines,nline,"<th>"+txt1+"</th>")
206.703 + set_line(lines,nline,"<th>"+txt2+"</th>")
206.704 + set_line(lines,nline,"<th>"+txt3+"</th>")
206.705 + set_line(lines,nline,"<th>"+txt4+"</th>")
206.706 + set_line(lines,nline,"<th>"+txt5+"</th>")
206.707 + set_line(lines,nline,"<th>"+txt6+"</th>")
206.708 + set_line(lines,nline,"<th>"+txt7+"</th>")
206.709 + set_line(lines,nline,"<th>"+txt8+"</th>")
206.710 + set_line(lines,nline,"<th>"+txt9+"</th>")
206.711 + set_line(lines,nline,"<th>"+txt10+"</th>")
206.712 + set_line(lines,nline,"<th>"+txt11+"</th>")
206.713 + set_line(lines,nline,"<th>"+txt12+"</th>")
206.714 + set_line(lines,nline,"<th>"+txt13+"</th>")
206.715 +
206.716 + set_line(lines,nline,row_footer)
206.717 + end do
206.718 +;-----------------------------------------------
206.719 + set_line(lines,nline,table_footer)
206.720 + set_line(lines,nline,footer)
206.721 +
206.722 +; Now write to an HTML file.
206.723 + idx = ind(.not.ismissing(lines))
206.724 + if(.not.any(ismissing(idx))) then
206.725 + asciiwrite(output_html,lines(idx))
206.726 + else
206.727 + print ("error?")
206.728 + end if
206.729 +
206.730 +;***************************************************************************
206.731 +; write total score to file
206.732 +;***************************************************************************
206.733 +
206.734 + asciiwrite("M_save.lai", M_total)
206.735 +
206.736 +;***************************************************************************
206.737 +end
206.738 +
207.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
207.2 +++ b/lai/99.ncl Mon Jan 26 22:08:20 2009 -0500
207.3 @@ -0,0 +1,1185 @@
207.4 +;********************************************************
207.5 +; histogram normalized by rain and compute correleration
207.6 +;********************************************************
207.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
207.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
207.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
207.10 +
207.11 +procedure pminmax(data:numeric,name:string)
207.12 +begin
207.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
207.14 + if(isatt(data,"units")) then
207.15 + print (name + " units = " + data@units)
207.16 + end if
207.17 +end
207.18 +
207.19 +; Main code.
207.20 +begin
207.21 +
207.22 +;nclass = 18
207.23 + nclass = 20
207.24 +
207.25 + plot_type = "ps"
207.26 + plot_type_new = "png"
207.27 +
207.28 +;************************************************
207.29 +; read in data: model
207.30 +;************************************************
207.31 +
207.32 + model_name = "b30.061n"
207.33 + model_grid = "T31"
207.34 +
207.35 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
207.36 + film = "b30.061n_1995-2004_MONS_climo_lnd.nc"
207.37 +;film = "i01.03cn_1545-1569_MONS_climo.nc"
207.38 + fm = addfile(dirm+film,"r")
207.39 +
207.40 + laimod = fm->TLAI
207.41 +
207.42 +;************************************************
207.43 +; read in data: observed
207.44 +;************************************************
207.45 +
207.46 + ob_name = "MODIS MOD 15A2 2000-2005"
207.47 +
207.48 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
207.49 + filo1 = "land_class_"+model_grid+".nc"
207.50 + filo2 = "LAI_2000-2005_MONS_"+model_grid+".nc"
207.51 +
207.52 + fo1 = addfile(diro+filo1,"r")
207.53 + fo2 = addfile(diro+filo2,"r")
207.54 +
207.55 + classob = tofloat(fo1->LAND_CLASS)
207.56 + laiob = fo2->LAI
207.57 +;*******************************************************************
207.58 +; Calculate "nice" bins for binning the data in equally spaced ranges
207.59 +;********************************************************************
207.60 + nclassn = nclass + 1
207.61 + range = fspan(0,nclassn-1,nclassn)
207.62 +; print (range)
207.63 +
207.64 +; Use this range information to grab all the values in a
207.65 +; particular range, and then take an average.
207.66 +
207.67 + nr = dimsizes(range)
207.68 + nx = nr-1
207.69 + xvalues = new((/2,nx/),float)
207.70 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
207.71 + dx = xvalues(0,1) - xvalues(0,0) ; range width
207.72 + dx4 = dx/4 ; 1/4 of the range
207.73 + xvalues(1,:) = xvalues(0,:) - dx/5.
207.74 +;-----------------------------------------------------------------
207.75 +
207.76 +;-----------------------------------------------------------------
207.77 +;(B) max
207.78 +;--------------------------------------------------------------------
207.79 +; get data
207.80 +
207.81 +; observed
207.82 + laiob_max = laiob(0,:,:)
207.83 + s = laiob(:,0,0)
207.84 + laiob_max@long_name = "Leaf Area Index Max"
207.85 +
207.86 + dsizes_z = dimsizes(laiob)
207.87 + nlat = dsizes_z(1)
207.88 + nlon = dsizes_z(2)
207.89 +
207.90 + do j = 0,nlat-1
207.91 + do i = 0,nlon-1
207.92 + s = laiob(:,j,i)
207.93 + laiob_max(j,i) = max(s)
207.94 + end do
207.95 + end do
207.96 +
207.97 +; print (min(y)+"/"+max(y))
207.98 + delete (s)
207.99 + delete (dsizes_z)
207.100 +;-------------------------
207.101 +; model
207.102 + laimod_max = laimod(0,:,:)
207.103 + s = laimod(:,0,0)
207.104 + laimod_max@long_name = "Leaf Area Index Max"
207.105 +
207.106 + dsizes_z = dimsizes(laimod)
207.107 + nlat = dsizes_z(1)
207.108 + nlon = dsizes_z(2)
207.109 +
207.110 + do j = 0,nlat-1
207.111 + do i = 0,nlon-1
207.112 + s = laimod(:,j,i)
207.113 + laimod_max(j,i) = max(s)
207.114 + end do
207.115 + end do
207.116 +
207.117 +; print (min(laimod_max)+"/"+max(laimod_max))
207.118 + delete (s)
207.119 + delete (dsizes_z)
207.120 +;------------------------
207.121 + DATA11_1D = ndtooned(classob)
207.122 + DATA12_1D = ndtooned(laiob_max)
207.123 + DATA22_1D = ndtooned(laimod_max)
207.124 +
207.125 + yvalues = new((/2,nx/),float)
207.126 + mn_yvalues = new((/2,nx/),float)
207.127 + mx_yvalues = new((/2,nx/),float)
207.128 +
207.129 + do nd=0,1
207.130 +
207.131 +; See if we are doing model or observational data.
207.132 +
207.133 + if(nd.eq.0) then
207.134 + data_ob = DATA11_1D
207.135 + data_mod = DATA12_1D
207.136 + else
207.137 + data_ob = DATA11_1D
207.138 + data_mod = DATA22_1D
207.139 + end if
207.140 +
207.141 +; Loop through each range and check for values.
207.142 +
207.143 + do i=0,nr-2
207.144 + if (i.ne.(nr-2)) then
207.145 +; print("")
207.146 +; print("In range ["+range(i)+","+range(i+1)+")")
207.147 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
207.148 + else
207.149 +; print("")
207.150 +; print("In range ["+range(i)+",)")
207.151 + idx = ind(range(i).le.data_ob)
207.152 + end if
207.153 +
207.154 +; Calculate average, and get min and max.
207.155 +
207.156 + if(.not.any(ismissing(idx))) then
207.157 + yvalues(nd,i) = avg(data_mod(idx))
207.158 + mn_yvalues(nd,i) = min(data_mod(idx))
207.159 + mx_yvalues(nd,i) = max(data_mod(idx))
207.160 + count = dimsizes(idx)
207.161 + else
207.162 + count = 0
207.163 + yvalues(nd,i) = yvalues@_FillValue
207.164 + mn_yvalues(nd,i) = yvalues@_FillValue
207.165 + mx_yvalues(nd,i) = yvalues@_FillValue
207.166 + end if
207.167 +
207.168 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
207.169 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
207.170 +
207.171 +; Clean up for next time in loop.
207.172 +
207.173 + delete(idx)
207.174 + end do
207.175 + delete(data_ob)
207.176 + delete(data_mod)
207.177 + end do
207.178 +;-----------------------------------------------------------------
207.179 +; compute correlation coef and M score
207.180 +
207.181 + u = yvalues(0,:)
207.182 + v = yvalues(1,:)
207.183 +
207.184 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
207.185 + uu = u(good)
207.186 + vv = v(good)
207.187 +
207.188 + ccrMax = esccr(uu,vv,0)
207.189 +; print (ccrMax)
207.190 +
207.191 +; new eq
207.192 + bias = sum(abs(vv-uu)/(vv+uu))
207.193 + Mmax = (1.- (bias/dimsizes(uu)))*5.
207.194 +
207.195 + print (Mmax)
207.196 +
207.197 + delete (u)
207.198 + delete (v)
207.199 + delete (uu)
207.200 + delete (vv)
207.201 +;--------------------------------------------------------------------
207.202 +; histogram res
207.203 +
207.204 + resm = True
207.205 + resm@gsnMaximize = True
207.206 + resm@gsnDraw = False
207.207 + resm@gsnFrame = False
207.208 + resm@xyMarkLineMode = "Markers"
207.209 + resm@xyMarkerSizeF = 0.014
207.210 + resm@xyMarker = 16
207.211 + resm@xyMarkerColors = (/"Brown","Blue"/)
207.212 +; resm@trYMinF = min(mn_yvalues) - 10.
207.213 +; resm@trYMaxF = max(mx_yvalues) + 10.
207.214 + resm@trYMinF = min(mn_yvalues) - 2
207.215 + resm@trYMaxF = max(mx_yvalues) + 4
207.216 +
207.217 + resm@tiYAxisString = "Max LAI (Leaf Area Index)"
207.218 + resm@tiXAxisString = "Land Cover Type"
207.219 +
207.220 + max_bar = new((/2,nx/),graphic)
207.221 + min_bar = new((/2,nx/),graphic)
207.222 + max_cap = new((/2,nx/),graphic)
207.223 + min_cap = new((/2,nx/),graphic)
207.224 +
207.225 + lnres = True
207.226 + line_colors = (/"brown","blue"/)
207.227 +;------------------------------------------------------------------
207.228 +; Start the graphics.
207.229 +
207.230 + plot_name = "histogram_max"
207.231 + title = model_name + " vs Observed"
207.232 + resm@tiMainString = title
207.233 +
207.234 + wks = gsn_open_wks (plot_type,plot_name)
207.235 +;-----------------------------
207.236 +; Add a boxed legend using the more simple method
207.237 +
207.238 + resm@pmLegendDisplayMode = "Always"
207.239 +; resm@pmLegendWidthF = 0.1
207.240 + resm@pmLegendWidthF = 0.08
207.241 + resm@pmLegendHeightF = 0.05
207.242 + resm@pmLegendOrthogonalPosF = -1.17
207.243 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
207.244 +; resm@pmLegendParallelPosF = 0.18
207.245 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
207.246 +
207.247 +; resm@lgPerimOn = False
207.248 + resm@lgLabelFontHeightF = 0.015
207.249 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
207.250 +;-----------------------------
207.251 + tRes = True
207.252 + tRes@txFontHeightF = 0.025
207.253 +
207.254 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMax)+")"
207.255 +
207.256 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
207.257 +
207.258 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
207.259 +;-------------------------------
207.260 +;Attach the vertical bar and the horizontal cap line
207.261 +
207.262 + do nd=0,1
207.263 + lnres@gsLineColor = line_colors(nd)
207.264 + do i=0,nx-1
207.265 +
207.266 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
207.267 + .not.ismissing(mx_yvalues(nd,i))) then
207.268 +
207.269 +; Attach the vertical bar, both above and below the marker.
207.270 +
207.271 + x1 = xvalues(nd,i)
207.272 + y1 = yvalues(nd,i)
207.273 + y2 = mn_yvalues(nd,i)
207.274 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
207.275 +
207.276 + y2 = mx_yvalues(nd,i)
207.277 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
207.278 +
207.279 +; Attach the horizontal cap line, both above and below the marker.
207.280 +
207.281 + x1 = xvalues(nd,i) - dx4
207.282 + x2 = xvalues(nd,i) + dx4
207.283 + y1 = mn_yvalues(nd,i)
207.284 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
207.285 +
207.286 + y1 = mx_yvalues(nd,i)
207.287 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
207.288 + end if
207.289 + end do
207.290 + end do
207.291 +
207.292 + draw(xy)
207.293 + frame(wks)
207.294 +
207.295 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.296 +; system("rm "+plot_name+"."+plot_type)
207.297 +; system("rm "+plot_name+"-1."+plot_type_new)
207.298 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.299 +
207.300 + clear (wks)
207.301 +
207.302 + delete (DATA11_1D)
207.303 + delete (DATA12_1D)
207.304 + delete (DATA22_1D)
207.305 +;delete (range)
207.306 +;delete (xvalues)
207.307 + delete (yvalues)
207.308 + delete (mn_yvalues)
207.309 + delete (mx_yvalues)
207.310 + delete (good)
207.311 + delete (max_bar)
207.312 + delete (min_bar)
207.313 + delete (max_cap)
207.314 + delete (min_cap)
207.315 +;-----------------------------------------------------------------
207.316 +;global res
207.317 +
207.318 + resg = True ; Use plot options
207.319 + resg@cnFillOn = True ; Turn on color fill
207.320 + resg@gsnSpreadColors = True ; use full colormap
207.321 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
207.322 +; resg@lbLabelAutoStride = True
207.323 + resg@cnLinesOn = False ; Turn off contourn lines
207.324 + resg@mpFillOn = False ; Turn off map fill
207.325 +
207.326 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
207.327 + resg@cnMinLevelValF = 0. ; Min level
207.328 + resg@cnMaxLevelValF = 10. ; Max level
207.329 + resg@cnLevelSpacingF = 1. ; interval
207.330 +
207.331 +;global contour ob
207.332 +
207.333 + delta = 0.00001
207.334 + laiob_max = where(ismissing(laiob_max).and.(ismissing(laimod_max).or.(laimod_max.lt.delta)),0.,laiob_max)
207.335 +
207.336 + plot_name = "global_max_ob"
207.337 + title = ob_name
207.338 + resg@tiMainString = title
207.339 +
207.340 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
207.341 + gsn_define_colormap(wks,"gui_default") ; choose colormap
207.342 +
207.343 + plot = gsn_csm_contour_map_ce(wks,laiob_max,resg)
207.344 + frame(wks)
207.345 +
207.346 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.347 +; system("rm "+plot_name+"."+plot_type)
207.348 +; system("rm "+plot_name+"-1."+plot_type_new)
207.349 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.350 +
207.351 + clear (wks)
207.352 +;------------------------------------------------------------------------
207.353 +;global contour model
207.354 +
207.355 + plot_name = "global_max_model"
207.356 + title = "Model " + model_name
207.357 + resg@tiMainString = title
207.358 +
207.359 + wks = gsn_open_wks (plot_type,plot_name)
207.360 + gsn_define_colormap(wks,"gui_default") ; choose colormap
207.361 +
207.362 + delete (plot)
207.363 + plot = gsn_csm_contour_map_ce(wks,laimod_max,resg)
207.364 + frame(wks)
207.365 +
207.366 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.367 +; system("rm "+plot_name+"."+plot_type)
207.368 +; system("rm "+plot_name+"-1."+plot_type_new)
207.369 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.370 +
207.371 + clear (wks)
207.372 +;------------------------------------------------------------------------
207.373 +;global contour model vs ob
207.374 +
207.375 + plot_name = "global_max_model_vs_ob"
207.376 +
207.377 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
207.378 + gsn_define_colormap(wks,"gui_default") ; choose colormap
207.379 +
207.380 + delete (plot)
207.381 + plot=new(3,graphic) ; create graphic array
207.382 +
207.383 + resg@gsnFrame = False ; Do not draw plot
207.384 + resg@gsnDraw = False ; Do not advance frame
207.385 +
207.386 +; plot correlation coef
207.387 +
207.388 + gRes = True
207.389 + gRes@txFontHeightF = 0.02
207.390 + gRes@txAngleF = 90
207.391 +
207.392 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMax)+")"
207.393 +
207.394 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
207.395 +;--------------------------------------------------------------------
207.396 +
207.397 +;(a) ob
207.398 +
207.399 + title = ob_name
207.400 + resg@tiMainString = title
207.401 +
207.402 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_max,resg)
207.403 +
207.404 +;(b) model
207.405 +
207.406 + title = "Model "+ model_name
207.407 + resg@tiMainString = title
207.408 +
207.409 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_max,resg)
207.410 +
207.411 +;(c) model-ob
207.412 +
207.413 + zz = laimod_max
207.414 + zz = laimod_max - laiob_max
207.415 + title = "Model_"+model_name+" - Observed"
207.416 + resg@tiMainString = title
207.417 +
207.418 + resg@cnMinLevelValF = -6. ; Min level
207.419 + resg@cnMaxLevelValF = 6. ; Max level
207.420 + resg@cnLevelSpacingF = 1. ; interval
207.421 +
207.422 +
207.423 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
207.424 +
207.425 + pres = True ; panel plot mods desired
207.426 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
207.427 + ; indiv. plots in panel
207.428 + pres@gsnMaximize = True ; fill the page
207.429 +
207.430 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
207.431 +
207.432 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.433 +; system("rm "+plot_name+"."+plot_type)
207.434 +; system("rm "+plot_name+"-1."+plot_type_new)
207.435 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.436 +
207.437 + frame (wks)
207.438 + clear (wks)
207.439 +
207.440 + delete (plot)
207.441 +;-----------------------------------------------------------------
207.442 +;(C) phase
207.443 +;--------------------------------------------------------------------
207.444 +; get data
207.445 +
207.446 +; observed
207.447 + laiob_phase = laiob(0,:,:)
207.448 + s = laiob(:,0,0)
207.449 + laiob_phase@long_name = "Leaf Area Index Max Month"
207.450 +
207.451 + dsizes_z = dimsizes(laiob)
207.452 + nlat = dsizes_z(1)
207.453 + nlon = dsizes_z(2)
207.454 +
207.455 + do j = 0,nlat-1
207.456 + do i = 0,nlon-1
207.457 + s = laiob(:,j,i)
207.458 + laiob_phase(j,i) = maxind(s) + 1
207.459 + end do
207.460 + end do
207.461 +
207.462 +; print (min(laiob_phase)+"/"+max(laiob_phase))
207.463 + delete (s)
207.464 + delete (dsizes_z)
207.465 +;-------------------------
207.466 +; model
207.467 + laimod_phase = laimod(0,:,:)
207.468 + s = laimod(:,0,0)
207.469 + laimod_phase@long_name = "Leaf Area Index Max Month"
207.470 +
207.471 + dsizes_z = dimsizes(laimod)
207.472 + nlat = dsizes_z(1)
207.473 + nlon = dsizes_z(2)
207.474 +
207.475 + do j = 0,nlat-1
207.476 + do i = 0,nlon-1
207.477 + s = laimod(:,j,i)
207.478 + laimod_phase(j,i) = maxind(s) + 1
207.479 + end do
207.480 + end do
207.481 +
207.482 +; print (min(laimod_phase)+"/"+max(laimod_phase))
207.483 + delete (s)
207.484 + delete (dsizes_z)
207.485 +;------------------------
207.486 + DATA11_1D = ndtooned(classob)
207.487 + DATA12_1D = ndtooned(laiob_phase)
207.488 + DATA22_1D = ndtooned(laimod_phase)
207.489 +
207.490 + yvalues = new((/2,nx/),float)
207.491 + mn_yvalues = new((/2,nx/),float)
207.492 + mx_yvalues = new((/2,nx/),float)
207.493 +
207.494 + do nd=0,1
207.495 +
207.496 +; See if we are doing model or observational data.
207.497 +
207.498 + if(nd.eq.0) then
207.499 + data_ob = DATA11_1D
207.500 + data_mod = DATA12_1D
207.501 + else
207.502 + data_ob = DATA11_1D
207.503 + data_mod = DATA22_1D
207.504 + end if
207.505 +
207.506 +; Loop through each range and check for values.
207.507 +
207.508 + do i=0,nr-2
207.509 + if (i.ne.(nr-2)) then
207.510 +; print("")
207.511 +; print("In range ["+range(i)+","+range(i+1)+")")
207.512 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
207.513 + else
207.514 +; print("")
207.515 +; print("In range ["+range(i)+",)")
207.516 + idx = ind(range(i).le.data_ob)
207.517 + end if
207.518 +
207.519 +; Calculate average, and get min and max.
207.520 +
207.521 + if(.not.any(ismissing(idx))) then
207.522 + yvalues(nd,i) = avg(data_mod(idx))
207.523 + mn_yvalues(nd,i) = min(data_mod(idx))
207.524 + mx_yvalues(nd,i) = max(data_mod(idx))
207.525 + count = dimsizes(idx)
207.526 + else
207.527 + count = 0
207.528 + yvalues(nd,i) = yvalues@_FillValue
207.529 + mn_yvalues(nd,i) = yvalues@_FillValue
207.530 + mx_yvalues(nd,i) = yvalues@_FillValue
207.531 + end if
207.532 +
207.533 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
207.534 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
207.535 +
207.536 +; Clean up for next time in loop.
207.537 +
207.538 + delete(idx)
207.539 + end do
207.540 + delete(data_ob)
207.541 + delete(data_mod)
207.542 + end do
207.543 +;-----------------------------------------------------------------
207.544 +; compute correlation coef and M score
207.545 +
207.546 + u = yvalues(0,:)
207.547 + v = yvalues(1,:)
207.548 +
207.549 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
207.550 + uu = u(good)
207.551 + vv = v(good)
207.552 +
207.553 + ccrPhase = esccr(uu,vv,0)
207.554 +; print (ccrPhase)
207.555 +
207.556 +; old eq
207.557 +; bias = abs(avg(vv)-avg(uu))
207.558 +; new eq
207.559 + bias = avg(abs(vv-uu))
207.560 +
207.561 + bias = where((bias.gt. 6.),12.-bias,bias)
207.562 + Mphase = ((6. - bias)/6.)*5.
207.563 +
207.564 + print (Mphase)
207.565 +
207.566 + delete (u)
207.567 + delete (v)
207.568 + delete (uu)
207.569 + delete (vv)
207.570 +;--------------------------------------------------------------------
207.571 +; histogram res
207.572 +
207.573 + resm = True
207.574 + resm@gsnMaximize = True
207.575 + resm@gsnDraw = False
207.576 + resm@gsnFrame = False
207.577 + resm@xyMarkLineMode = "Markers"
207.578 + resm@xyMarkerSizeF = 0.014
207.579 + resm@xyMarker = 16
207.580 + resm@xyMarkerColors = (/"Brown","Blue"/)
207.581 +; resm@trYMinF = min(mn_yvalues) - 10.
207.582 +; resm@trYMaxF = max(mx_yvalues) + 10.
207.583 + resm@trYMinF = min(mn_yvalues) - 2
207.584 + resm@trYMaxF = max(mx_yvalues) + 4
207.585 +
207.586 + resm@tiYAxisString = "Max LAI (Leaf Area Index) Month"
207.587 + resm@tiXAxisString = "Land Cover Type"
207.588 +
207.589 + max_bar = new((/2,nx/),graphic)
207.590 + min_bar = new((/2,nx/),graphic)
207.591 + max_cap = new((/2,nx/),graphic)
207.592 + min_cap = new((/2,nx/),graphic)
207.593 +
207.594 + lnres = True
207.595 + line_colors = (/"brown","blue"/)
207.596 +;------------------------------------------------------------------
207.597 +; Start the graphics.
207.598 +
207.599 + plot_name = "histogram_phase"
207.600 + title = model_name + " vs Observed"
207.601 + resm@tiMainString = title
207.602 +
207.603 + wks = gsn_open_wks (plot_type,plot_name)
207.604 +;-----------------------------
207.605 +; Add a boxed legend using the more simple method
207.606 +
207.607 + resm@pmLegendDisplayMode = "Always"
207.608 +; resm@pmLegendWidthF = 0.1
207.609 + resm@pmLegendWidthF = 0.08
207.610 + resm@pmLegendHeightF = 0.05
207.611 + resm@pmLegendOrthogonalPosF = -1.17
207.612 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
207.613 +; resm@pmLegendParallelPosF = 0.18
207.614 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
207.615 +
207.616 +; resm@lgPerimOn = False
207.617 + resm@lgLabelFontHeightF = 0.015
207.618 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
207.619 +;-----------------------------
207.620 + tRes = True
207.621 + tRes@txFontHeightF = 0.025
207.622 +
207.623 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrPhase)+")"
207.624 +
207.625 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
207.626 +
207.627 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
207.628 +;-------------------------------
207.629 +;Attach the vertical bar and the horizontal cap line
207.630 +
207.631 + do nd=0,1
207.632 + lnres@gsLineColor = line_colors(nd)
207.633 + do i=0,nx-1
207.634 +
207.635 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
207.636 + .not.ismissing(mx_yvalues(nd,i))) then
207.637 +
207.638 +; Attach the vertical bar, both above and below the marker.
207.639 +
207.640 + x1 = xvalues(nd,i)
207.641 + y1 = yvalues(nd,i)
207.642 + y2 = mn_yvalues(nd,i)
207.643 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
207.644 +
207.645 + y2 = mx_yvalues(nd,i)
207.646 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
207.647 +
207.648 +; Attach the horizontal cap line, both above and below the marker.
207.649 +
207.650 + x1 = xvalues(nd,i) - dx4
207.651 + x2 = xvalues(nd,i) + dx4
207.652 + y1 = mn_yvalues(nd,i)
207.653 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
207.654 +
207.655 + y1 = mx_yvalues(nd,i)
207.656 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
207.657 + end if
207.658 + end do
207.659 + end do
207.660 +
207.661 + draw(xy)
207.662 + frame(wks)
207.663 +
207.664 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.665 +; system("rm "+plot_name+"."+plot_type)
207.666 +; system("rm "+plot_name+"-1."+plot_type_new)
207.667 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.668 +
207.669 + clear (wks)
207.670 +
207.671 + delete (DATA11_1D)
207.672 + delete (DATA12_1D)
207.673 + delete (DATA22_1D)
207.674 +;delete (range)
207.675 +;delete (xvalues)
207.676 + delete (yvalues)
207.677 + delete (mn_yvalues)
207.678 + delete (mx_yvalues)
207.679 + delete (good)
207.680 + delete (max_bar)
207.681 + delete (min_bar)
207.682 + delete (max_cap)
207.683 + delete (min_cap)
207.684 +;-----------------------------------------------------------------
207.685 +;global res
207.686 +
207.687 + resg = True ; Use plot options
207.688 + resg@cnFillOn = True ; Turn on color fill
207.689 + resg@gsnSpreadColors = True ; use full colormap
207.690 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
207.691 +; resg@lbLabelAutoStride = True
207.692 + resg@cnLinesOn = False ; Turn off contourn lines
207.693 + resg@mpFillOn = False ; Turn off map fill
207.694 +
207.695 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
207.696 + resg@cnMinLevelValF = 1. ; Min level
207.697 + resg@cnMaxLevelValF = 12. ; Max level
207.698 + resg@cnLevelSpacingF = 1. ; interval
207.699 +
207.700 +;global contour ob
207.701 +
207.702 + delta = 0.00001
207.703 + laiob_phase = where(ismissing(laiob_phase).and.(ismissing(laimod_phase).or.(laimod_phase.lt.delta)),0.,laiob_phase)
207.704 +
207.705 + plot_name = "global_phase_ob"
207.706 + title = ob_name
207.707 + resg@tiMainString = title
207.708 +
207.709 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
207.710 + gsn_define_colormap(wks,"gui_default") ; choose colormap
207.711 +
207.712 + plot = gsn_csm_contour_map_ce(wks,laiob_phase,resg)
207.713 + frame(wks)
207.714 +
207.715 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.716 +; system("rm "+plot_name+"."+plot_type)
207.717 +; system("rm "+plot_name+"-1."+plot_type_new)
207.718 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.719 +
207.720 + clear (wks)
207.721 +;------------------------------------------------------------------------
207.722 +;global contour model
207.723 +
207.724 + plot_name = "global_phase_model"
207.725 + title = "Model " + model_name
207.726 + resg@tiMainString = title
207.727 +
207.728 + wks = gsn_open_wks (plot_type,plot_name)
207.729 + gsn_define_colormap(wks,"gui_default") ; choose colormap
207.730 +
207.731 + delete (plot)
207.732 + plot = gsn_csm_contour_map_ce(wks,laimod_phase,resg)
207.733 + frame(wks)
207.734 +
207.735 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.736 +; system("rm "+plot_name+"."+plot_type)
207.737 +; system("rm "+plot_name+"-1."+plot_type_new)
207.738 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.739 +
207.740 + clear (wks)
207.741 +;------------------------------------------------------------------------
207.742 +;global contour model vs ob
207.743 +
207.744 + plot_name = "global_phase_model_vs_ob"
207.745 +
207.746 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
207.747 + gsn_define_colormap(wks,"gui_default") ; choose colormap
207.748 +
207.749 + delete (plot)
207.750 + plot=new(3,graphic) ; create graphic array
207.751 +
207.752 + resg@gsnFrame = False ; Do not draw plot
207.753 + resg@gsnDraw = False ; Do not advance frame
207.754 +
207.755 +; plot correlation coef
207.756 +
207.757 + gRes = True
207.758 + gRes@txFontHeightF = 0.02
207.759 + gRes@txAngleF = 90
207.760 +
207.761 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrPhase)+")"
207.762 +
207.763 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
207.764 +;--------------------------------------------------------------------
207.765 +
207.766 +;(a) ob
207.767 +
207.768 + title = ob_name
207.769 + resg@tiMainString = title
207.770 +
207.771 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_phase,resg)
207.772 +
207.773 +;(b) model
207.774 +
207.775 + title = "Model "+ model_name
207.776 + resg@tiMainString = title
207.777 +
207.778 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_phase,resg)
207.779 +
207.780 +;(c) model-ob
207.781 +
207.782 + delete (zz)
207.783 + zz = laimod_phase
207.784 + zz = laimod_phase - laiob_phase
207.785 + title = "Model_"+model_name+" - Observed"
207.786 + resg@tiMainString = title
207.787 +
207.788 + resg@cnMinLevelValF = -6. ; Min level
207.789 + resg@cnMaxLevelValF = 6. ; Max level
207.790 + resg@cnLevelSpacingF = 1. ; interval
207.791 +
207.792 +
207.793 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
207.794 +
207.795 +; pres = True ; panel plot mods desired
207.796 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
207.797 + ; indiv. plots in panel
207.798 +; pres@gsnMaximize = True ; fill the page
207.799 +
207.800 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
207.801 +
207.802 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.803 +; system("rm "+plot_name+"."+plot_type)
207.804 +; system("rm "+plot_name+"-1."+plot_type_new)
207.805 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.806 +
207.807 + frame (wks)
207.808 + clear (wks)
207.809 +
207.810 + delete (plot)
207.811 +;-----------------------------------------------------------------
207.812 +;(D) grow day
207.813 +;--------------------------------------------------------------------
207.814 +; get data
207.815 +
207.816 + day_of_data = (/31,28,31,30,31,30,31,31,30,31,30,31/)
207.817 +
207.818 +; observed
207.819 + laiob_grow = laiob(0,:,:)
207.820 + laiob_grow@long_name = "Days of Growing Season"
207.821 +
207.822 + dsizes_z = dimsizes(laiob)
207.823 + ntime = dsizes_z(0)
207.824 + nlat = dsizes_z(1)
207.825 + nlon = dsizes_z(2)
207.826 +
207.827 + do j = 0,nlat-1
207.828 + do i = 0,nlon-1
207.829 + nday = 0.
207.830 + do k = 0,ntime-1
207.831 + if (.not. ismissing(laiob(k,j,i)) .and. laiob(k,j,i) .gt. 1.0) then
207.832 + nday = nday + day_of_data(k)
207.833 + end if
207.834 + end do
207.835 +
207.836 + laiob_grow(j,i) = nday
207.837 + end do
207.838 + end do
207.839 +
207.840 +; print (min(laiob_grow)+"/"+max(laiob_grow))
207.841 +;-------------------------
207.842 +; model
207.843 + laimod_grow = laimod(0,:,:)
207.844 + laimod_grow@long_name = "Days of Growing Season"
207.845 +
207.846 + dsizes_z = dimsizes(laimod)
207.847 + ntime = dsizes_z(0)
207.848 + nlat = dsizes_z(1)
207.849 + nlon = dsizes_z(2)
207.850 +
207.851 + do j = 0,nlat-1
207.852 + do i = 0,nlon-1
207.853 + nday = 0.
207.854 + do k = 0,ntime-1
207.855 + if (.not. ismissing(laimod(k,j,i)) .and. laimod(k,j,i) .gt. 1.0) then
207.856 + nday = nday + day_of_data(k)
207.857 + end if
207.858 + end do
207.859 +
207.860 + laimod_grow(j,i) = nday
207.861 + end do
207.862 + end do
207.863 +
207.864 +; print (min(laimod_grow)+"/"+max(laimod_grow))
207.865 +;------------------------
207.866 + DATA11_1D = ndtooned(classob)
207.867 + DATA12_1D = ndtooned(laiob_grow)
207.868 + DATA22_1D = ndtooned(laimod_grow)
207.869 +
207.870 + yvalues = new((/2,nx/),float)
207.871 + mn_yvalues = new((/2,nx/),float)
207.872 + mx_yvalues = new((/2,nx/),float)
207.873 +
207.874 + do nd=0,1
207.875 +
207.876 +; See if we are doing model or observational data.
207.877 +
207.878 + if(nd.eq.0) then
207.879 + data_ob = DATA11_1D
207.880 + data_mod = DATA12_1D
207.881 + else
207.882 + data_ob = DATA11_1D
207.883 + data_mod = DATA22_1D
207.884 + end if
207.885 +
207.886 +; Loop through each range and check for values.
207.887 +
207.888 + do i=0,nr-2
207.889 + if (i.ne.(nr-2)) then
207.890 +; print("")
207.891 +; print("In range ["+range(i)+","+range(i+1)+")")
207.892 + idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
207.893 + else
207.894 +; print("")
207.895 +; print("In range ["+range(i)+",)")
207.896 + idx = ind(range(i).le.data_ob)
207.897 + end if
207.898 +
207.899 +; Calculate average, and get min and max.
207.900 +
207.901 + if(.not.any(ismissing(idx))) then
207.902 + yvalues(nd,i) = avg(data_mod(idx))
207.903 + mn_yvalues(nd,i) = min(data_mod(idx))
207.904 + mx_yvalues(nd,i) = max(data_mod(idx))
207.905 + count = dimsizes(idx)
207.906 + else
207.907 + count = 0
207.908 + yvalues(nd,i) = yvalues@_FillValue
207.909 + mn_yvalues(nd,i) = yvalues@_FillValue
207.910 + mx_yvalues(nd,i) = yvalues@_FillValue
207.911 + end if
207.912 +
207.913 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
207.914 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
207.915 +
207.916 +; Clean up for next time in loop.
207.917 +
207.918 + delete(idx)
207.919 + end do
207.920 + delete(data_ob)
207.921 + delete(data_mod)
207.922 + end do
207.923 +;-----------------------------------------------------------------
207.924 +; compute correlation coef and M score
207.925 +
207.926 + u = yvalues(0,:)
207.927 + v = yvalues(1,:)
207.928 +
207.929 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
207.930 + uu = u(good)
207.931 + vv = v(good)
207.932 +
207.933 + ccrGrow = esccr(uu,vv,0)
207.934 +; print (ccrGrow)
207.935 +
207.936 +; new eq
207.937 + bias = sum(abs(vv-uu)/(vv+uu))
207.938 + Mgrow = (1.- (bias/dimsizes(uu)))*5.
207.939 +
207.940 + print (Mgrow)
207.941 +
207.942 + delete (u)
207.943 + delete (v)
207.944 + delete (uu)
207.945 + delete (vv)
207.946 +;--------------------------------------------------------------------
207.947 +; histogram res
207.948 +
207.949 + resm = True
207.950 + resm@gsnMaximize = True
207.951 + resm@gsnDraw = False
207.952 + resm@gsnFrame = False
207.953 + resm@xyMarkLineMode = "Markers"
207.954 + resm@xyMarkerSizeF = 0.014
207.955 + resm@xyMarker = 16
207.956 + resm@xyMarkerColors = (/"Brown","Blue"/)
207.957 +; resm@trYMinF = min(mn_yvalues) - 10.
207.958 +; resm@trYMaxF = max(mx_yvalues) + 10.
207.959 + resm@trYMinF = min(mn_yvalues) - 2
207.960 + resm@trYMaxF = max(mx_yvalues) + 4
207.961 +
207.962 + resm@tiYAxisString = "Days of Growing season"
207.963 + resm@tiXAxisString = "Land Cover Type"
207.964 +
207.965 + max_bar = new((/2,nx/),graphic)
207.966 + min_bar = new((/2,nx/),graphic)
207.967 + max_cap = new((/2,nx/),graphic)
207.968 + min_cap = new((/2,nx/),graphic)
207.969 +
207.970 + lnres = True
207.971 + line_colors = (/"brown","blue"/)
207.972 +;------------------------------------------------------------------
207.973 +; Start the graphics.
207.974 +
207.975 + plot_name = "histogram_grow"
207.976 + title = model_name + " vs Observed"
207.977 + resm@tiMainString = title
207.978 +
207.979 + wks = gsn_open_wks (plot_type,plot_name)
207.980 +;-----------------------------
207.981 +; Add a boxed legend using the more simple method
207.982 +
207.983 + resm@pmLegendDisplayMode = "Always"
207.984 +; resm@pmLegendWidthF = 0.1
207.985 + resm@pmLegendWidthF = 0.08
207.986 + resm@pmLegendHeightF = 0.05
207.987 + resm@pmLegendOrthogonalPosF = -1.17
207.988 +; resm@pmLegendOrthogonalPosF = -1.00 ;(downward)
207.989 +; resm@pmLegendParallelPosF = 0.18
207.990 + resm@pmLegendParallelPosF = 0.88 ;(rightward)
207.991 +
207.992 +; resm@lgPerimOn = False
207.993 + resm@lgLabelFontHeightF = 0.015
207.994 + resm@xyExplicitLegendLabels = (/"observed",model_name/)
207.995 +;-----------------------------
207.996 + tRes = True
207.997 + tRes@txFontHeightF = 0.025
207.998 +
207.999 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrGrow)+")"
207.1000 +
207.1001 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
207.1002 +
207.1003 + xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
207.1004 +;-------------------------------
207.1005 +;Attach the vertical bar and the horizontal cap line
207.1006 +
207.1007 + do nd=0,1
207.1008 + lnres@gsLineColor = line_colors(nd)
207.1009 + do i=0,nx-1
207.1010 +
207.1011 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
207.1012 + .not.ismissing(mx_yvalues(nd,i))) then
207.1013 +
207.1014 +; Attach the vertical bar, both above and below the marker.
207.1015 +
207.1016 + x1 = xvalues(nd,i)
207.1017 + y1 = yvalues(nd,i)
207.1018 + y2 = mn_yvalues(nd,i)
207.1019 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
207.1020 +
207.1021 + y2 = mx_yvalues(nd,i)
207.1022 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
207.1023 +
207.1024 +; Attach the horizontal cap line, both above and below the marker.
207.1025 +
207.1026 + x1 = xvalues(nd,i) - dx4
207.1027 + x2 = xvalues(nd,i) + dx4
207.1028 + y1 = mn_yvalues(nd,i)
207.1029 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
207.1030 +
207.1031 + y1 = mx_yvalues(nd,i)
207.1032 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
207.1033 + end if
207.1034 + end do
207.1035 + end do
207.1036 +
207.1037 + draw(xy)
207.1038 + frame(wks)
207.1039 +
207.1040 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.1041 +; system("rm "+plot_name+"."+plot_type)
207.1042 +; system("rm "+plot_name+"-1."+plot_type_new)
207.1043 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.1044 +
207.1045 + clear (wks)
207.1046 +
207.1047 + delete (DATA11_1D)
207.1048 + delete (DATA12_1D)
207.1049 + delete (DATA22_1D)
207.1050 +;delete (range)
207.1051 +;delete (xvalues)
207.1052 + delete (yvalues)
207.1053 + delete (mn_yvalues)
207.1054 + delete (mx_yvalues)
207.1055 + delete (good)
207.1056 + delete (max_bar)
207.1057 + delete (min_bar)
207.1058 + delete (max_cap)
207.1059 + delete (min_cap)
207.1060 +;-----------------------------------------------------------------
207.1061 +;global res
207.1062 +
207.1063 + resg = True ; Use plot options
207.1064 + resg@cnFillOn = True ; Turn on color fill
207.1065 + resg@gsnSpreadColors = True ; use full colormap
207.1066 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
207.1067 +; resg@lbLabelAutoStride = True
207.1068 + resg@cnLinesOn = False ; Turn off contourn lines
207.1069 + resg@mpFillOn = False ; Turn off map fill
207.1070 +
207.1071 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
207.1072 + resg@cnMinLevelValF = 0. ; Min level
207.1073 + resg@cnMaxLevelValF = 360. ; Max level
207.1074 + resg@cnLevelSpacingF = 30. ; interval
207.1075 +
207.1076 +;global contour ob
207.1077 +
207.1078 + delta = 0.00001
207.1079 + laiob_grow = where(ismissing(laiob_grow).and.(ismissing(laimod_grow).or.(laimod_grow.lt.delta)),0.,laiob_grow)
207.1080 +
207.1081 + plot_name = "global_grow_ob"
207.1082 + title = ob_name
207.1083 + resg@tiMainString = title
207.1084 +
207.1085 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
207.1086 + gsn_define_colormap(wks,"gui_default") ; choose colormap
207.1087 +
207.1088 + plot = gsn_csm_contour_map_ce(wks,laiob_grow,resg)
207.1089 + frame(wks)
207.1090 +
207.1091 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.1092 +; system("rm "+plot_name+"."+plot_type)
207.1093 +; system("rm "+plot_name+"-1."+plot_type_new)
207.1094 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.1095 +
207.1096 + clear (wks)
207.1097 +;------------------------------------------------------------------------
207.1098 +;global contour model
207.1099 +
207.1100 + plot_name = "global_grow_model"
207.1101 + title = "Model " + model_name
207.1102 + resg@tiMainString = title
207.1103 +
207.1104 + wks = gsn_open_wks (plot_type,plot_name)
207.1105 + gsn_define_colormap(wks,"gui_default") ; choose colormap
207.1106 +
207.1107 + delete (plot)
207.1108 + plot = gsn_csm_contour_map_ce(wks,laimod_grow,resg)
207.1109 + frame(wks)
207.1110 +
207.1111 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.1112 +; system("rm "+plot_name+"."+plot_type)
207.1113 +; system("rm "+plot_name+"-1."+plot_type_new)
207.1114 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.1115 +
207.1116 + clear (wks)
207.1117 +;------------------------------------------------------------------------
207.1118 +;global contour model vs ob
207.1119 +
207.1120 + plot_name = "global_grow_model_vs_ob"
207.1121 +
207.1122 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
207.1123 + gsn_define_colormap(wks,"gui_default") ; choose colormap
207.1124 +
207.1125 + delete (plot)
207.1126 + plot=new(3,graphic) ; create graphic array
207.1127 +
207.1128 + resg@gsnFrame = False ; Do not draw plot
207.1129 + resg@gsnDraw = False ; Do not advance frame
207.1130 +
207.1131 +; plot correlation coef
207.1132 +
207.1133 + gRes = True
207.1134 + gRes@txFontHeightF = 0.02
207.1135 + gRes@txAngleF = 90
207.1136 +
207.1137 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrGrow)+")"
207.1138 +
207.1139 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
207.1140 +;--------------------------------------------------------------------
207.1141 +
207.1142 +;(a) ob
207.1143 +
207.1144 + title = ob_name
207.1145 + resg@tiMainString = title
207.1146 +
207.1147 + plot(0) = gsn_csm_contour_map_ce(wks,laiob_grow,resg)
207.1148 +
207.1149 +;(b) model
207.1150 +
207.1151 + title = "Model "+ model_name
207.1152 + resg@tiMainString = title
207.1153 +
207.1154 + plot(1) = gsn_csm_contour_map_ce(wks,laimod_grow,resg)
207.1155 +
207.1156 +;(c) model-ob
207.1157 +
207.1158 + delete (zz)
207.1159 + zz = laimod_grow
207.1160 + zz = laimod_grow - laiob_grow
207.1161 + title = "Model_"+model_name+" - Observed"
207.1162 + resg@tiMainString = title
207.1163 +
207.1164 + resg@cnMinLevelValF = -120. ; Min level
207.1165 + resg@cnMaxLevelValF = 120. ; Max level
207.1166 + resg@cnLevelSpacingF = 20. ; interval
207.1167 +
207.1168 +
207.1169 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
207.1170 +
207.1171 + pres = True ; panel plot mods desired
207.1172 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
207.1173 + ; indiv. plots in panel
207.1174 + pres@gsnMaximize = True ; fill the page
207.1175 +
207.1176 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
207.1177 +
207.1178 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
207.1179 +; system("rm "+plot_name+"."+plot_type)
207.1180 +; system("rm "+plot_name+"-1."+plot_type_new)
207.1181 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
207.1182 +
207.1183 + frame (wks)
207.1184 + clear (wks)
207.1185 +
207.1186 + delete (plot)
207.1187 +end
207.1188 +
208.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
208.2 +++ b/list.clamp_data Mon Jan 26 22:08:20 2009 -0500
208.3 @@ -0,0 +1,2 @@
208.4 +biomass fluxnet model soil_carbon
208.5 +co2 lai npp
209.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
209.2 +++ b/list.data Mon Jan 26 22:08:20 2009 -0500
209.3 @@ -0,0 +1,2 @@
209.4 +biomass fluxnet model soil_carbon
209.5 +co2 lai npp
210.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
210.2 +++ b/list.data.model Mon Jan 26 22:08:20 2009 -0500
210.3 @@ -0,0 +1,35 @@
210.4 +T42.clamp.surface-data.060412.nc i01.10casa_1994-2004_ANN_climo.nc
210.5 +b30.061m_401_425_ANN_climo_atm.nc i01.10casa_1994-2004_MONS_climo.nc
210.6 +b30.061m_401_425_MONS_climo_atm.nc i01.10casa_1996-2003_ANN_climo.nc
210.7 +b30.061n_1995-2004_ANN_climo_atm.nc i01.10casa_1996-2003_MONS_climo.nc
210.8 +b30.061n_1995-2004_ANN_climo_lnd.nc i01.10casa_1997-2003_ANN_climo.nc
210.9 +b30.061n_1995-2004_MONS_climo_atm.nc i01.10casa_1997-2003_MONS_climo.nc
210.10 +b30.061n_1995-2004_MONS_climo_lnd.nc i01.10casa_1998-2003_ANN_climo.nc
210.11 +f02.03casa_1876-1900_ANN_climo.nc i01.10casa_1998-2003_MONS_climo.nc
210.12 +f02.03casa_1876-1900_ANN_climo_atm.nc i01.10casa_1999-2004_ANN_climo.nc
210.13 +f02.03casa_1876-1900_MONS_climo.nc i01.10casa_1999-2004_MONS_climo.nc
210.14 +f02.03casa_1876-1900_MONS_climo_atm.nc i01.10casa_2000-2003_ANN_climo.nc
210.15 +f02.03cn_1901-1925_ANN_climo.nc i01.10casa_2000-2003_MONS_climo.nc
210.16 +f02.03cn_1901-1925_ANN_climo_atm.nc i01.10casa_2002-2004_ANN_climo.nc
210.17 +f02.03cn_1901-1925_MONS_climo.nc i01.10casa_2002-2004_MONS_climo.nc
210.18 +f02.03cn_1901-1925_MONS_climo_atm.nc i01.10cn_1948-2004_ANN_climo.nc
210.19 +i01.03cn_1545-1569_ANN_climo.nc i01.10cn_1948-2004_MONS_climo.nc
210.20 +i01.03cn_1545-1569_MONS_climo.nc i01.10cn_1990-2004_ANN_climo.nc
210.21 +i01.04casa_1605-1629_ANN_climo.nc i01.10cn_1990-2004_MONS_climo.nc
210.22 +i01.04casa_1605-1629_MONS_climo.nc i01.10cn_1994-2004_ANN_climo.nc
210.23 +i01.06casa_1798-2004_ANN_climo.nc i01.10cn_1994-2004_MONS_climo.nc
210.24 +i01.06casa_1798-2004_MONS_climo.nc i01.10cn_1996-2003_ANN_climo.nc
210.25 +i01.06casa_1980-2004_ANN_climo.nc i01.10cn_1996-2003_MONS_climo.nc
210.26 +i01.06casa_1980-2004_MONS_climo.nc i01.10cn_1997-2003_ANN_climo.nc
210.27 +i01.06cn_1798-2004_ANN_climo.nc i01.10cn_1997-2003_MONS_climo.nc
210.28 +i01.06cn_1798-2004_MONS_climo.nc i01.10cn_1998-2003_ANN_climo.nc
210.29 +i01.06cn_1980-2004_ANN_climo.nc i01.10cn_1998-2003_MONS_climo.nc
210.30 +i01.06cn_1980-2004_MONS_climo.nc i01.10cn_1999-2004_ANN_climo.nc
210.31 +i01.07casa_1990-2004_ANN_climo.nc i01.10cn_1999-2004_MONS_climo.nc
210.32 +i01.07casa_1990-2004_MONS_climo.nc i01.10cn_2000-2003_ANN_climo.nc
210.33 +i01.07cn_1990-2004_ANN_climo.nc i01.10cn_2000-2003_MONS_climo.nc
210.34 +i01.07cn_1990-2004_MONS_climo.nc i01.10cn_2002-2004_ANN_climo.nc
210.35 +i01.10casa_1948-2004_ANN_climo.nc i01.10cn_2002-2004_MONS_climo.nc
210.36 +i01.10casa_1948-2004_MONS_climo.nc newcn05_ncep_1i_ANN_climo_lnd.nc
210.37 +i01.10casa_1990-2004_ANN_climo.nc newcn05_ncep_1i_MONS_climo_lnd.nc
210.38 +i01.10casa_1990-2004_MONS_climo.nc surf_co2.clamp.T42.20070208.nc
211.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
211.2 +++ b/list.fluxnet Mon Jan 26 22:08:20 2009 -0500
211.3 @@ -0,0 +1,4 @@
211.4 +BOREAS_NSA_OBS Hyytiala_boreal Lethbridge
211.5 +BOREAS_NSA_OBS_boreal Kaamanen Lethbridge_c3
211.6 +CastelPorziano Kaamanen_c3 Tharandt
211.7 +Hyytiala LBA_Tapajos_KM67 Vielsalm
212.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
212.2 +++ b/npp/01.read_81.ncl.x Mon Jan 26 22:08:20 2009 -0500
212.3 @@ -0,0 +1,271 @@
212.4 +;----------------------------------------------------------------------
212.5 +; This example reads an ASCII file that is formatted a specific way, and
212.6 +; writes out the results to a netCDF file.
212.7 +;
212.8 +; The first line in the ASCII file must be a header, with each field
212.9 +; separated by a single character delimiter (like a ","). The rest of
212.10 +; the file must be such that each row contains all fields, each
212.11 +; separated by the designated delimiter.
212.12 +;
212.13 +; The fields can be integer, float, double, or string.
212.14 +;----------------------------------------------------------------------
212.15 +
212.16 +;----------------------------------------------------------------------
212.17 +; This function returns the index locations of the given delimiter
212.18 +; in a row or several rows of strings.
212.19 +;----------------------------------------------------------------------
212.20 +function delim_indices(strings,nfields,delimiter)
212.21 +local cstrings, cdelim
212.22 +begin
212.23 + nrows = dimsizes(strings)
212.24 +;
212.25 +; Handle special case if we only have one string. Make sure it
212.26 +; is put into a 2D array.
212.27 +;
212.28 + if(nrows.eq.1) then
212.29 + cstrings = new((/1,strlen(strings)+1/),character)
212.30 + end if
212.31 +
212.32 + cstrings = stringtochar(strings) ; Convert to characters.
212.33 + cdelim = stringtochar(delimiter) ; Convert delimiter to character.
212.34 +;
212.35 +; Som error checking here. Make sure delimiter is one character.
212.36 +;
212.37 + nc = dimsizes(cdelim)
212.38 + rank = dimsizes(nc)
212.39 + if(rank.ne.1.or.(rank.eq.1.and.nc.ne.2)) then
212.40 + print("delim_indices: fatal: the delimiter you've selected")
212.41 + print("must be a single character. Can't continue.")
212.42 + exit
212.43 + end if
212.44 +
212.45 +;
212.46 +; Create array to hold indices of delimiter locations, and then loop
212.47 +; through each row and find all the delimiters. Make sure each row has
212.48 +; the correct number of delimiters.
212.49 +;
212.50 + ndelims = nfields-1
212.51 + cindices = new((/nrows,ndelims/),integer)
212.52 + do i = 0, nrows-1
212.53 + ii = ind(cstrings(i,:).eq.cdelim(0))
212.54 +;
212.55 +; Make sure there were delimiters on this row. If not, we just quit.
212.56 +; This could probably be modified to do this more gracefully.
212.57 +;
212.58 + if(any(ismissing(ii))) then
212.59 + print("delim_indices: fatal: I didn't find any delimiters")
212.60 + print("('" + delimiter + "') on row " + i + ". Can't continue.")
212.61 + exit
212.62 + end if
212.63 + if(dimsizes(ii).ne.ndelims) then
212.64 + print("delim_indices: fatal: I expected to find " + ndelims)
212.65 + print("delimiters on row " + i + ". Instead, I found " + dimsizes(ii) + ".")
212.66 + print("Can't continue.")
212.67 + exit
212.68 + end if
212.69 +
212.70 + cindices(i,:) = ii
212.71 +
212.72 + delete(ii) ; For next time through loop
212.73 + end do
212.74 +
212.75 + return(cindices)
212.76 +end
212.77 +
212.78 +;----------------------------------------------------------------------
212.79 +; This function reads in a particular field from a string array,
212.80 +; given the field number to read (fields start at 1 and go to nfield),
212.81 +; and the indices of the delimiters.
212.82 +;
212.83 +; It returns either an integer, float, double, or a string,
212.84 +; depending on the input flag "return_type".
212.85 +;----------------------------------------------------------------------
212.86 +function read_field(strings,ifield,indices,return_type)
212.87 +local nstring, cstrings, nf, tmp_str
212.88 +begin
212.89 + nrows = dimsizes(strings)
212.90 +;
212.91 +; Handle special case if we only have one string. Make sure it
212.92 +; is put into a 2D array.
212.93 +;
212.94 + if(nrows.eq.1) then
212.95 + cstrings = new((/1,strlen(strings)+1/),character)
212.96 + end if
212.97 +
212.98 + cstrings = stringtochar(strings)
212.99 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
212.100 +
212.101 +;
212.102 +; Error checking. Make sure user has entered a valid field.
212.103 +;
212.104 + if(ifield.le.0.or.ifield.gt.nf) then
212.105 + print("read_field: fatal: you've selected a field that is")
212.106 + print("out-of-range of the number of fields that you have (" + nf + ").")
212.107 + exit
212.108 + end if
212.109 +
212.110 +;
212.111 +; Set up array to return.
212.112 +;
212.113 + return_array = new(nrows,return_type)
212.114 +
212.115 + do i = 0,nrows-1
212.116 +;
212.117 +; Special case of first field in row.
212.118 +;
212.119 + if(ifield.eq.1) then
212.120 + ibeg = 0
212.121 + iend = indices(i,ifield-1)-1
212.122 + else
212.123 +;
212.124 +; Special case of first field in row.
212.125 +;
212.126 + if(ifield.eq.nf) then
212.127 + ibeg = indices(i,ifield-2)+1
212.128 + iend = dimsizes(cstrings(i,:))-1
212.129 +;
212.130 +; Any field between first and last field.
212.131 +;
212.132 + else
212.133 + ibeg = indices(i,ifield-2)+1
212.134 + iend = indices(i,ifield-1)-1
212.135 + end if
212.136 + end if
212.137 +;
212.138 +; Here's the code that pulls off the correct string, and converts it
212.139 +; to float if desired.
212.140 +;
212.141 + if(return_type.eq."integer") then
212.142 + return_array(i) = stringtointeger(chartostring(cstrings(i,ibeg:iend)))
212.143 + end if
212.144 + if(return_type.eq."float") then
212.145 + return_array(i) = stringtofloat(chartostring(cstrings(i,ibeg:iend)))
212.146 + end if
212.147 + if(return_type.eq."double") then
212.148 + return_array(i) = stringtodouble(chartostring(cstrings(i,ibeg:iend)))
212.149 + end if
212.150 + if(return_type.eq."string") then
212.151 + return_array(i) = chartostring(cstrings(i,ibeg:iend))
212.152 + end if
212.153 + end do
212.154 +
212.155 + return(return_array)
212.156 +end
212.157 +
212.158 +;----------------------------------------------------------------------
212.159 +; Main code.
212.160 +;----------------------------------------------------------------------
212.161 +begin
212.162 +;
212.163 +; Set up defaults here. We have to hard-code the field types,
212.164 +; because we can't really tell otherwise.
212.165 +
212.166 + filename = "data.81" ; ASCII" file to read.
212.167 + cdf_file = filename + ".nc" ; netCDF file to write.
212.168 + nfields = 22 ; # of fields
212.169 + delimiter = "," ; field delimiter
212.170 +;
212.171 +; In this case, fields #6-#8 are strings, fields #2, #3, and #11
212.172 +; are float, and the rest of the fields are integers.
212.173 +;
212.174 + var_types = new(nfields,string)
212.175 + var_types = "integer" ; Most are ints.
212.176 + var_types(5:7) = "string" ; corresponds to fields 6-8
212.177 + var_types(1:2) = "float"
212.178 + var_types(10) = "float"
212.179 +
212.180 + if(isfilepresent(cdf_file))
212.181 + print("Warning: '" + cdf_file + "' exists. Will remove it.")
212.182 + system("/bin/rm " + cdf_file)
212.183 + end if
212.184 +
212.185 +;
212.186 +; Read in data as strings. This will create a string array that has the
212.187 +; same number of strings as there are rows in the file. We will then need
212.188 +; to parse each string later.
212.189 +;
212.190 + read_data = asciiread(filename,-1,"string")
212.191 + header = read_data(0) ; Header. Use for variable names.
212.192 + data = read_data(1:) ; Get rid of first line which is a header.
212.193 + nrows = dimsizes(data) ; Number of rows.
212.194 +
212.195 +;
212.196 +; Read in locations of delimiters in each string row.
212.197 +;
212.198 + hindices = delim_indices(header,nfields,delimiter) ; header row
212.199 + dindices = delim_indices(data,nfields,delimiter) ; rest of file
212.200 +
212.201 +;
212.202 +; Read in the field names which will become variable names on
212.203 +; the netCDF file.
212.204 +;
212.205 + var_names = new(nfields,string)
212.206 +
212.207 + do i=0,nfields-1
212.208 + var_names(i) = read_field(header,i+1,hindices,"string")
212.209 + end do
212.210 +;
212.211 +; Write out this netCDF file efficiently so it will be faster.
212.212 +; Try to predefine everything before you write to it.
212.213 +;
212.214 + f = addfile(cdf_file,"c")
212.215 + setfileoption(f,"DefineMode",True) ; Enter predefine phase.
212.216 +
212.217 +;
212.218 +; Write global attributes to file. It's okay to do this before
212.219 +; predefining the file's variables. We are still in "define" mode.
212.220 +;
212.221 + fAtt = True
212.222 + fAtt@description = "Data read in from '" + filename + "' ASCII file."
212.223 + fAtt@creation_date = systemfunc ("date")
212.224 + fileattdef( f, fAtt )
212.225 +
212.226 +;
212.227 +; Write dimension name. There's only one here.
212.228 +;
212.229 + filedimdef(f,"nvalues",-1,True)
212.230 +
212.231 +;
212.232 +; Define each variable on the file, giving it the dimension name
212.233 +; we just created above.
212.234 +;
212.235 +; Don't deal with variables that are of type string.
212.236 +;
212.237 + do i=0,nfields-1
212.238 + if(var_types(i).ne."string") then
212.239 + filevardef(f, var_names(i), var_types(i), "nvalues")
212.240 + end if
212.241 + end do
212.242 +
212.243 +;
212.244 +; Loop through each field, read the values for that field, print
212.245 +; information about the variable, and then write it to the netCDF
212.246 +; file.
212.247 +;
212.248 + do i=0,nfields-1
212.249 + ifield = i+1 ; Fields start at #1, not #0.
212.250 +;
212.251 +; You can't write strings to a netCDF file, so skip the string fields.
212.252 +;
212.253 + if(var_types(i).ne."string") then
212.254 + tmp_data = read_field(data,ifield,dindices,var_types(i))
212.255 +;
212.256 +; Print some info about the variable.
212.257 +;
212.258 + print("")
212.259 + print("Writing variable " + var_names(i) + " (field #" + ifield + ").")
212.260 + print("Type is " + var_types(i) + ", min/max = " + min(tmp_data) + \
212.261 + "/" + max(tmp_data))
212.262 +
212.263 + if(any(ismissing(tmp_data))) then
212.264 + print("This variable does contain missing values.")
212.265 + else
212.266 + print("This variable doesn't contain missing values.")
212.267 + end if
212.268 +
212.269 + f->$var_names(i)$ = tmp_data ; Write to netCDF file.
212.270 +
212.271 + delete(tmp_data) ; Delete for next round.
212.272 + end if
212.273 + end do
212.274 +end
213.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
213.2 +++ b/npp/01.read_81.ncl.y Mon Jan 26 22:08:20 2009 -0500
213.3 @@ -0,0 +1,406 @@
213.4 +;----------------------------------------------------------------------
213.5 +; This example reads an ASCII file that is formatted a specific way, and
213.6 +; writes out the results to a netCDF file.
213.7 +;
213.8 +; The first line in the ASCII file must be a header, with each field
213.9 +; separated by a single character delimiter (like a ","). The rest of
213.10 +; the file must be such that each row contains all fields, each
213.11 +; separated by the designated delimiter.
213.12 +;
213.13 +; The fields can be integer, float, double, character, or string.
213.14 +; String fields cannot be written to a netCDF file. They have to
213.15 +; be read in as character arrays and written out that way.
213.16 +;----------------------------------------------------------------------
213.17 +
213.18 +;----------------------------------------------------------------------
213.19 +; This function returns the index locations of the given delimiter
213.20 +; in a row or several rows of strings.
213.21 +;----------------------------------------------------------------------
213.22 +function delim_indices(strings,nfields,delimiter)
213.23 +local cstrings, cdelim
213.24 +begin
213.25 + nrows = dimsizes(strings)
213.26 +;
213.27 +; Handle special case if we only have one string. Make sure it
213.28 +; is put into a 2D array.
213.29 +;
213.30 + if(nrows.eq.1) then
213.31 + cstrings = new((/1,strlen(strings)+1/),character)
213.32 + end if
213.33 +
213.34 + cstrings = stringtochar(strings) ; Convert to characters.
213.35 + cdelim = stringtochar(delimiter) ; Convert delimiter to character.
213.36 +;
213.37 +; Som error checking here. Make sure delimiter is one character.
213.38 +;
213.39 + nc = dimsizes(cdelim)
213.40 + rank = dimsizes(nc)
213.41 + if(rank.ne.1.or.(rank.eq.1.and.nc.ne.2)) then
213.42 + print("delim_indices: fatal: the delimiter you've selected")
213.43 + print("must be a single character. Can't continue.")
213.44 + exit
213.45 + end if
213.46 +
213.47 +;
213.48 +; Create array to hold indices of delimiter locations, and then loop
213.49 +; through each row and find all the delimiters. Make sure each row has
213.50 +; the correct number of delimiters.
213.51 +;
213.52 + ndelims = nfields-1
213.53 + cindices = new((/nrows,ndelims/),integer)
213.54 + do i = 0, nrows-1
213.55 + ii = ind(cstrings(i,:).eq.cdelim(0))
213.56 +;
213.57 +; Make sure there were delimiters on this row. If not, we just quit.
213.58 +; This could probably be modified to do this more gracefully.
213.59 +;
213.60 + if(any(ismissing(ii))) then
213.61 + print("delim_indices: fatal: I didn't find any delimiters")
213.62 + print("('" + delimiter + "') on row " + i + ". Can't continue.")
213.63 + exit
213.64 + end if
213.65 + if(dimsizes(ii).ne.ndelims) then
213.66 + print("delim_indices: fatal: I expected to find " + ndelims)
213.67 + print("delimiters on row " + i + ". Instead, I found " + dimsizes(ii) + ".")
213.68 + print("Can't continue.")
213.69 + exit
213.70 + end if
213.71 +
213.72 + cindices(i,:) = ii
213.73 +
213.74 + delete(ii) ; For next time through loop
213.75 + end do
213.76 +
213.77 + return(cindices)
213.78 +end
213.79 +
213.80 +;----------------------------------------------------------------------
213.81 +; This function reads in a particular field from a string array,
213.82 +; given the field number to read (fields start at #1 and go to #nfield),
213.83 +; and the indices of the delimiters.
213.84 +;
213.85 +; It returns either an integer, float, double, character, or a string,
213.86 +; depending on the input flag "return_type".
213.87 +;----------------------------------------------------------------------
213.88 +function read_field(strings,ifield,indices,return_type)
213.89 +local nstring, cstrings, nf, tmp_str
213.90 +begin
213.91 + nrows = dimsizes(strings)
213.92 +;
213.93 +; Handle special case if we only have one string. Make sure it
213.94 +; is put into a 2D array.
213.95 +;
213.96 + if(nrows.eq.1) then
213.97 + cstrings = new((/1,strlen(strings)+1/),character)
213.98 + end if
213.99 +
213.100 + cstrings = stringtochar(strings)
213.101 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
213.102 +
213.103 +;
213.104 +; Error checking. Make sure user has entered a valid field.
213.105 +;
213.106 + if(ifield.le.0.or.ifield.gt.nf) then
213.107 + print("read_field: fatal: you've selected a field that is")
213.108 + print("out-of-range of the number of fields that you have (" + nf + ").")
213.109 + exit
213.110 + end if
213.111 +
213.112 +;
213.113 +; Set up array to return. For string, int, float, or double arrays,
213.114 +; we don't have to do anything special. For character arrays,
213.115 +; however, we do.
213.116 +;
213.117 + if(return_type.ne."character") then
213.118 + return_array = new(nrows,return_type)
213.119 + else
213.120 +;
213.121 +; We don't know what the biggest character array is at this point, so
213.122 +; make it bigger than necessary, and then resize later as necessary.
213.123 +;
213.124 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
213.125 +
213.126 + max_len = 0 ; Use to keep track of max lengths of strings.
213.127 + end if
213.128 +
213.129 + do i = 0,nrows-1
213.130 +;
213.131 +; Special case of first field in row.
213.132 +;
213.133 + if(ifield.eq.1) then
213.134 + ibeg = 0
213.135 + iend = indices(i,ifield-1)-1
213.136 + else
213.137 +;
213.138 +; Special case of first field in row.
213.139 +;
213.140 + if(ifield.eq.nf) then
213.141 + ibeg = indices(i,ifield-2)+1
213.142 + iend = dimsizes(cstrings(i,:))-1
213.143 +;
213.144 +; Any field between first and last field.
213.145 +;
213.146 + else
213.147 + ibeg = indices(i,ifield-2)+1
213.148 + iend = indices(i,ifield-1)-1
213.149 + end if
213.150 + end if
213.151 +;
213.152 +; Here's the code that pulls off the correct string, and converts it
213.153 +; to float if desired.
213.154 +;
213.155 + if(return_type.eq."integer") then
213.156 + return_array(i) = stringtointeger(chartostring(cstrings(i,ibeg:iend)))
213.157 + end if
213.158 + if(return_type.eq."float") then
213.159 + return_array(i) = stringtofloat(chartostring(cstrings(i,ibeg:iend)))
213.160 + end if
213.161 + if(return_type.eq."double") then
213.162 + return_array(i) = stringtodouble(chartostring(cstrings(i,ibeg:iend)))
213.163 + end if
213.164 + if(return_type.eq."string") then
213.165 + return_array(i) = chartostring(cstrings(i,ibeg:iend))
213.166 + end if
213.167 + if(return_type.eq."character") then
213.168 + if( (iend-ibeg) .gt. max_len) then
213.169 + max_len = iend-ibeg
213.170 + end if
213.171 + tmp_return_array(i,0:iend-ibeg) = cstrings(i,ibeg:iend)
213.172 + end if
213.173 + end do
213.174 +
213.175 + if(return_type.eq."character") then
213.176 + return_array = new((/nrows,max_len/),"character")
213.177 + return_array = tmp_return_array(:,0:max_len-1)
213.178 + end if
213.179 +
213.180 + return(return_array)
213.181 +end
213.182 +
213.183 +
213.184 +;----------------------------------------------------------------------
213.185 +; This function reads in string fields only to get the maximum string
213.186 +; length.
213.187 +;----------------------------------------------------------------------
213.188 +function get_maxlen(strings,ifield,indices)
213.189 +local nstring, cstrings, nf, tmp_str
213.190 +begin
213.191 + nrows = dimsizes(strings)
213.192 +;
213.193 +; Handle special case if we only have one string. Make sure it
213.194 +; is put into a 2D array.
213.195 +;
213.196 + if(nrows.eq.1) then
213.197 + cstrings = new((/1,strlen(strings)+1/),character)
213.198 + end if
213.199 +
213.200 + cstrings = stringtochar(strings)
213.201 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
213.202 +
213.203 +;
213.204 +; Error checking. Make sure user has entered a valid field.
213.205 +;
213.206 + if(ifield.le.0.or.ifield.gt.nf) then
213.207 + print("read_field: fatal: you've selected a field that is")
213.208 + print("out-of-range of the number of fields that you have (" + nf + ").")
213.209 + exit
213.210 + end if
213.211 +;
213.212 +; We don't know what the biggest character array is at this point, so
213.213 +; make it bigger than necessary, and then resize later as necessary.
213.214 +;
213.215 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
213.216 +
213.217 + max_len = 0 ; Use to keep track of max lengths of strings.
213.218 +
213.219 + do i = 0,nrows-1
213.220 +;
213.221 +; Special case of first field in row.
213.222 +;
213.223 + if(ifield.eq.1) then
213.224 + ibeg = 0
213.225 + iend = indices(i,ifield-1)-1
213.226 + else
213.227 +;
213.228 +; Special case of first field in row.
213.229 +;
213.230 + if(ifield.eq.nf) then
213.231 + ibeg = indices(i,ifield-2)+1
213.232 + iend = dimsizes(cstrings(i,:))-1
213.233 +;
213.234 +; Any field between first and last field.
213.235 +;
213.236 + else
213.237 + ibeg = indices(i,ifield-2)+1
213.238 + iend = indices(i,ifield-1)-1
213.239 + end if
213.240 + end if
213.241 + if( (iend-ibeg) .gt. max_len) then
213.242 + max_len = iend-ibeg
213.243 + end if
213.244 + end do
213.245 +
213.246 + return(max_len)
213.247 +end
213.248 +
213.249 +;----------------------------------------------------------------------
213.250 +; Main code.
213.251 +;----------------------------------------------------------------------
213.252 +begin
213.253 +;
213.254 +; Set up defaults here. We are hard-coding the field types here.
213.255 +; You can set up this script to try to determine the field types
213.256 +; automatically, but this is a bit tedious. Maybe later.
213.257 +;
213.258 + filename = "data.81" ; ASCII" file to read.
213.259 + cdf_file = filename + ".nc" ; netCDF file to write.
213.260 + nfields = 22 ; # of fields
213.261 + delimiter = "," ; field delimiter
213.262 +;
213.263 +; In this case, fields #6-#8 are strings, fields #2, #3, and #11
213.264 +; are float, and the rest of the fields are integers.
213.265 +;
213.266 + var_types = new(nfields,string)
213.267 + var_strlens = new(nfields,integer) ; var to hold strlens, just in case.
213.268 +
213.269 + var_types = "integer" ; Most are ints.
213.270 + var_types(5:7) = "character" ; Corresponds to fields 6-8.
213.271 + var_types(1:2) = "float"
213.272 + var_types(10) = "float"
213.273 +
213.274 + if(isfilepresent(cdf_file))
213.275 + print("Warning: '" + cdf_file + "' exists. Will remove it.")
213.276 + system("/bin/rm " + cdf_file)
213.277 + end if
213.278 +
213.279 +;
213.280 +; Read in data as strings. This will create a string array that has the
213.281 +; same number of strings as there are rows in the file. We will then need
213.282 +; to parse each string later.
213.283 +;
213.284 + read_data = asciiread(filename,-1,"string")
213.285 + header = read_data(0) ; Header. Use for variable names.
213.286 + data = read_data(1:) ; Get rid of first line which is a header.
213.287 + nrows = dimsizes(data) ; Number of rows.
213.288 +
213.289 +;
213.290 +; Read in locations of delimiters in each string row.
213.291 +;
213.292 + hindices = delim_indices(header,nfields,delimiter) ; header row
213.293 + dindices = delim_indices(data,nfields,delimiter) ; rest of file
213.294 +
213.295 +;
213.296 +; Read in the field names which will become variable names on
213.297 +; the netCDF file.
213.298 +;
213.299 + var_names = new(nfields,string)
213.300 +
213.301 + do i=0,nfields-1
213.302 + var_names(i) = read_field(header,i+1,hindices,"string")
213.303 + end do
213.304 +
213.305 +;
213.306 +; Write out this netCDF file efficiently so it will be faster.
213.307 +; Try to predefine everything before you write to it.
213.308 +;
213.309 + f = addfile(cdf_file,"c")
213.310 + setfileoption(f,"DefineMode",True) ; Enter predefine phase.
213.311 +
213.312 +;
213.313 +; Write global attributes to file. It's okay to do this before
213.314 +; predefining the file's variables. We are still in "define" mode.
213.315 +;
213.316 + fAtt = True
213.317 + fAtt@description = "Data read in from " + filename + " ASCII file."
213.318 + fAtt@creation_date = systemfunc ("date")
213.319 + fileattdef( f, fAtt )
213.320 +
213.321 +;
213.322 +; Write dimension names to file. If there are no character variables,
213.323 +; then there's only one dimension name ("nvalues").
213.324 +;
213.325 +; Otherwise, we need to write a dimension name for every character
213.326 +; variable, which will indicate the maximum string length for that
213.327 +; variable.
213.328 +;
213.329 + indc = ind(var_types.eq."character")
213.330 + if(.not.any(ismissing(indc))) then
213.331 +;
213.332 +; We have to treat the character arrays special here. We need to
213.333 +; know their sizes so we can write the maximum size of each char
213.334 +; array to the netCDF file as a dimension name. This means we
213.335 +; need to read in the character variables once to get the string
213.336 +; lengths, then we'll read them again later to get the actual values.
213.337 +;
213.338 + do i=0,dimsizes(indc)-1
213.339 + var_strlens(indc(i)) = get_maxlen(data,indc(i)+1,dindices)
213.340 + end do
213.341 +
213.342 + ndims = dimsizes(indc) + 1
213.343 + dimNames = new(ndims,string)
213.344 + dimSizes = new(ndims,integer)
213.345 + dimUnlim = new(ndims,logical)
213.346 +
213.347 + dimUnlim = False
213.348 + dimUnlim(0) = True
213.349 + dimNames(0) = "nvalues"
213.350 + dimNames(1:ndims-1) = var_names(indc) + "_StrLen"
213.351 + dimSizes(0) = -1
213.352 + dimSizes(1:ndims-1) = var_strlens(indc)
213.353 + filedimdef(f,dimNames,dimSizes,dimUnlim)
213.354 + else
213.355 +;
213.356 +; No character variables, so just write the one dimension name.
213.357 +;
213.358 + filedimdef(f,"nvalues",-1,True)
213.359 + end if
213.360 +
213.361 +;
213.362 +; Define each variable on the file.
213.363 +;
213.364 +; Don't deal with variables that are of type string.
213.365 +;
213.366 + do i=0,nfields-1
213.367 + if(var_types(i).ne."string") then
213.368 + if(var_types(i).ne."character") then
213.369 + filevardef(f, var_names(i), var_types(i), "nvalues")
213.370 + else
213.371 + filevardef(f, var_names(i), var_types(i), \
213.372 + (/"nvalues",var_names(i)+"_StrLen"/))
213.373 + end if
213.374 + end if
213.375 + end do
213.376 +
213.377 +;
213.378 +; Loop through each field, read the values for that field, print
213.379 +; information about the variable, and then write it to the netCDF
213.380 +; file.
213.381 +;
213.382 + do i=0,nfields-1
213.383 + ifield = i+1 ; Fields start at #1, not #0.
213.384 +;
213.385 +; Note: you can't write strings to a netCDF file, so these have
213.386 +; to be written out as character arrays.
213.387 +;
213.388 + tmp_data = read_field(data,ifield,dindices,var_types(i))
213.389 +;
213.390 +; Print some info about the variable.
213.391 +;
213.392 + print("")
213.393 + print("Writing variable '" + var_names(i) + "' (field #" + ifield + ").")
213.394 + print("Type is " + var_types(i) + ".")
213.395 + if(var_types(i).ne."string".and.var_types(i).ne."character") then
213.396 + print("min/max = " + min(tmp_data) + "/" + max(tmp_data))
213.397 + end if
213.398 +
213.399 + if(any(ismissing(tmp_data))) then
213.400 + print("This variable does contain missing values.")
213.401 + else
213.402 + print("This variable doesn't contain missing values.")
213.403 + end if
213.404 +
213.405 + f->$var_names(i)$ = tmp_data ; Write to netCDF file.
213.406 +
213.407 + delete(tmp_data) ; Delete for next round.
213.408 + end do
213.409 +end
214.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
214.2 +++ b/npp/01.read_ascii_81.ncl Mon Jan 26 22:08:20 2009 -0500
214.3 @@ -0,0 +1,406 @@
214.4 +;----------------------------------------------------------------------
214.5 +; This example reads an ASCII file that is formatted a specific way, and
214.6 +; writes out the results to a netCDF file.
214.7 +;
214.8 +; The first line in the ASCII file must be a header, with each field
214.9 +; separated by a single character delimiter (like a ","). The rest of
214.10 +; the file must be such that each row contains all fields, each
214.11 +; separated by the designated delimiter.
214.12 +;
214.13 +; The fields can be integer, float, double, character, or string.
214.14 +; String fields cannot be written to a netCDF file. They have to
214.15 +; be read in as character arrays and written out that way.
214.16 +;----------------------------------------------------------------------
214.17 +
214.18 +;----------------------------------------------------------------------
214.19 +; This function returns the index locations of the given delimiter
214.20 +; in a row or several rows of strings.
214.21 +;----------------------------------------------------------------------
214.22 +function delim_indices(strings,nfields,delimiter)
214.23 +local cstrings, cdelim
214.24 +begin
214.25 + nrows = dimsizes(strings)
214.26 +;
214.27 +; Handle special case if we only have one string. Make sure it
214.28 +; is put into a 2D array.
214.29 +;
214.30 + if(nrows.eq.1) then
214.31 + cstrings = new((/1,strlen(strings)+1/),character)
214.32 + end if
214.33 +
214.34 + cstrings = stringtochar(strings) ; Convert to characters.
214.35 + cdelim = stringtochar(delimiter) ; Convert delimiter to character.
214.36 +;
214.37 +; Som error checking here. Make sure delimiter is one character.
214.38 +;
214.39 + nc = dimsizes(cdelim)
214.40 + rank = dimsizes(nc)
214.41 + if(rank.ne.1.or.(rank.eq.1.and.nc.ne.2)) then
214.42 + print("delim_indices: fatal: the delimiter you've selected")
214.43 + print("must be a single character. Can't continue.")
214.44 + exit
214.45 + end if
214.46 +
214.47 +;
214.48 +; Create array to hold indices of delimiter locations, and then loop
214.49 +; through each row and find all the delimiters. Make sure each row has
214.50 +; the correct number of delimiters.
214.51 +;
214.52 + ndelims = nfields-1
214.53 + cindices = new((/nrows,ndelims/),integer)
214.54 + do i = 0, nrows-1
214.55 + ii = ind(cstrings(i,:).eq.cdelim(0))
214.56 +;
214.57 +; Make sure there were delimiters on this row. If not, we just quit.
214.58 +; This could probably be modified to do this more gracefully.
214.59 +;
214.60 + if(any(ismissing(ii))) then
214.61 + print("delim_indices: fatal: I didn't find any delimiters")
214.62 + print("('" + delimiter + "') on row " + i + ". Can't continue.")
214.63 + exit
214.64 + end if
214.65 + if(dimsizes(ii).ne.ndelims) then
214.66 + print("delim_indices: fatal: I expected to find " + ndelims)
214.67 + print("delimiters on row " + i + ". Instead, I found " + dimsizes(ii) + ".")
214.68 + print("Can't continue.")
214.69 + exit
214.70 + end if
214.71 +
214.72 + cindices(i,:) = ii
214.73 +
214.74 + delete(ii) ; For next time through loop
214.75 + end do
214.76 +
214.77 + return(cindices)
214.78 +end
214.79 +
214.80 +;----------------------------------------------------------------------
214.81 +; This function reads in a particular field from a string array,
214.82 +; given the field number to read (fields start at #1 and go to #nfield),
214.83 +; and the indices of the delimiters.
214.84 +;
214.85 +; It returns either an integer, float, double, character, or a string,
214.86 +; depending on the input flag "return_type".
214.87 +;----------------------------------------------------------------------
214.88 +function read_field(strings,ifield,indices,return_type)
214.89 +local nstring, cstrings, nf, tmp_str
214.90 +begin
214.91 + nrows = dimsizes(strings)
214.92 +;
214.93 +; Handle special case if we only have one string. Make sure it
214.94 +; is put into a 2D array.
214.95 +;
214.96 + if(nrows.eq.1) then
214.97 + cstrings = new((/1,strlen(strings)+1/),character)
214.98 + end if
214.99 +
214.100 + cstrings = stringtochar(strings)
214.101 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
214.102 +
214.103 +;
214.104 +; Error checking. Make sure user has entered a valid field.
214.105 +;
214.106 + if(ifield.le.0.or.ifield.gt.nf) then
214.107 + print("read_field: fatal: you've selected a field that is")
214.108 + print("out-of-range of the number of fields that you have (" + nf + ").")
214.109 + exit
214.110 + end if
214.111 +
214.112 +;
214.113 +; Set up array to return. For string, int, float, or double arrays,
214.114 +; we don't have to do anything special. For character arrays,
214.115 +; however, we do.
214.116 +;
214.117 + if(return_type.ne."character") then
214.118 + return_array = new(nrows,return_type)
214.119 + else
214.120 +;
214.121 +; We don't know what the biggest character array is at this point, so
214.122 +; make it bigger than necessary, and then resize later as necessary.
214.123 +;
214.124 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
214.125 +
214.126 + max_len = 0 ; Use to keep track of max lengths of strings.
214.127 + end if
214.128 +
214.129 + do i = 0,nrows-1
214.130 +;
214.131 +; Special case of first field in row.
214.132 +;
214.133 + if(ifield.eq.1) then
214.134 + ibeg = 0
214.135 + iend = indices(i,ifield-1)-1
214.136 + else
214.137 +;
214.138 +; Special case of first field in row.
214.139 +;
214.140 + if(ifield.eq.nf) then
214.141 + ibeg = indices(i,ifield-2)+1
214.142 + iend = dimsizes(cstrings(i,:))-1
214.143 +;
214.144 +; Any field between first and last field.
214.145 +;
214.146 + else
214.147 + ibeg = indices(i,ifield-2)+1
214.148 + iend = indices(i,ifield-1)-1
214.149 + end if
214.150 + end if
214.151 +;
214.152 +; Here's the code that pulls off the correct string, and converts it
214.153 +; to float if desired.
214.154 +;
214.155 + if(return_type.eq."integer") then
214.156 + return_array(i) = stringtointeger(chartostring(cstrings(i,ibeg:iend)))
214.157 + end if
214.158 + if(return_type.eq."float") then
214.159 + return_array(i) = stringtofloat(chartostring(cstrings(i,ibeg:iend)))
214.160 + end if
214.161 + if(return_type.eq."double") then
214.162 + return_array(i) = stringtodouble(chartostring(cstrings(i,ibeg:iend)))
214.163 + end if
214.164 + if(return_type.eq."string") then
214.165 + return_array(i) = chartostring(cstrings(i,ibeg:iend))
214.166 + end if
214.167 + if(return_type.eq."character") then
214.168 + if( (iend-ibeg+1) .gt. max_len) then
214.169 + max_len = iend-ibeg+1
214.170 + end if
214.171 + tmp_return_array(i,0:iend-ibeg) = cstrings(i,ibeg:iend)
214.172 + end if
214.173 + end do
214.174 +
214.175 + if(return_type.eq."character") then
214.176 + return_array = new((/nrows,max_len/),"character")
214.177 + return_array = tmp_return_array(:,0:max_len-1)
214.178 + end if
214.179 +
214.180 + return(return_array)
214.181 +end
214.182 +
214.183 +
214.184 +;----------------------------------------------------------------------
214.185 +; This function reads in string fields only to get the maximum string
214.186 +; length.
214.187 +;----------------------------------------------------------------------
214.188 +function get_maxlen(strings,ifield,indices)
214.189 +local nstring, cstrings, nf, tmp_str
214.190 +begin
214.191 + nrows = dimsizes(strings)
214.192 +;
214.193 +; Handle special case if we only have one string. Make sure it
214.194 +; is put into a 2D array.
214.195 +;
214.196 + if(nrows.eq.1) then
214.197 + cstrings = new((/1,strlen(strings)+1/),character)
214.198 + end if
214.199 +
214.200 + cstrings = stringtochar(strings)
214.201 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
214.202 +
214.203 +;
214.204 +; Error checking. Make sure user has entered a valid field.
214.205 +;
214.206 + if(ifield.le.0.or.ifield.gt.nf) then
214.207 + print("read_field: fatal: you've selected a field that is")
214.208 + print("out-of-range of the number of fields that you have (" + nf + ").")
214.209 + exit
214.210 + end if
214.211 +;
214.212 +; We don't know what the biggest character array is at this point, so
214.213 +; make it bigger than necessary, and then resize later as necessary.
214.214 +;
214.215 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
214.216 +
214.217 + max_len = 0 ; Use to keep track of max lengths of strings.
214.218 +
214.219 + do i = 0,nrows-1
214.220 +;
214.221 +; Special case of first field in row.
214.222 +;
214.223 + if(ifield.eq.1) then
214.224 + ibeg = 0
214.225 + iend = indices(i,ifield-1)-1
214.226 + else
214.227 +;
214.228 +; Special case of first field in row.
214.229 +;
214.230 + if(ifield.eq.nf) then
214.231 + ibeg = indices(i,ifield-2)+1
214.232 + iend = dimsizes(cstrings(i,:))-1
214.233 +;
214.234 +; Any field between first and last field.
214.235 +;
214.236 + else
214.237 + ibeg = indices(i,ifield-2)+1
214.238 + iend = indices(i,ifield-1)-1
214.239 + end if
214.240 + end if
214.241 + if( (iend-ibeg+1) .gt. max_len) then
214.242 + max_len = iend-ibeg+1
214.243 + end if
214.244 + end do
214.245 +
214.246 + return(max_len)
214.247 +end
214.248 +
214.249 +;----------------------------------------------------------------------
214.250 +; Main code.
214.251 +;----------------------------------------------------------------------
214.252 +begin
214.253 +;
214.254 +; Set up defaults here. We are hard-coding the field types here.
214.255 +; You can set up this script to try to determine the field types
214.256 +; automatically, but this is a bit tedious. Maybe later.
214.257 +;
214.258 + filename = "data.81" ; ASCII" file to read.
214.259 + cdf_file = filename + ".nc" ; netCDF file to write.
214.260 + nfields = 22 ; # of fields
214.261 + delimiter = "," ; field delimiter
214.262 +;
214.263 +; In this case, fields #6-#8 are strings, fields #2, #3, and #11
214.264 +; are float, and the rest of the fields are integers.
214.265 +;
214.266 + var_types = new(nfields,string)
214.267 + var_strlens = new(nfields,integer) ; var to hold strlens, just in case.
214.268 +
214.269 + var_types = "integer" ; Most are ints.
214.270 + var_types(5:7) = "character" ; Corresponds to fields 6-8.
214.271 + var_types(1:2) = "float"
214.272 + var_types(10) = "float"
214.273 +
214.274 + if(isfilepresent(cdf_file))
214.275 + print("Warning: '" + cdf_file + "' exists. Will remove it.")
214.276 + system("/bin/rm " + cdf_file)
214.277 + end if
214.278 +
214.279 +;
214.280 +; Read in data as strings. This will create a string array that has the
214.281 +; same number of strings as there are rows in the file. We will then need
214.282 +; to parse each string later.
214.283 +;
214.284 + read_data = asciiread(filename,-1,"string")
214.285 + header = read_data(0) ; Header. Use for variable names.
214.286 + data = read_data(1:) ; Get rid of first line which is a header.
214.287 + nrows = dimsizes(data) ; Number of rows.
214.288 +
214.289 +;
214.290 +; Read in locations of delimiters in each string row.
214.291 +;
214.292 + hindices = delim_indices(header,nfields,delimiter) ; header row
214.293 + dindices = delim_indices(data,nfields,delimiter) ; rest of file
214.294 +
214.295 +;
214.296 +; Read in the field names which will become variable names on
214.297 +; the netCDF file.
214.298 +;
214.299 + var_names = new(nfields,string)
214.300 +
214.301 + do i=0,nfields-1
214.302 + var_names(i) = read_field(header,i+1,hindices,"string")
214.303 + end do
214.304 +
214.305 +;
214.306 +; Write out this netCDF file efficiently so it will be faster.
214.307 +; Try to predefine everything before you write to it.
214.308 +;
214.309 + f = addfile(cdf_file,"c")
214.310 + setfileoption(f,"DefineMode",True) ; Enter predefine phase.
214.311 +
214.312 +;
214.313 +; Write global attributes to file. It's okay to do this before
214.314 +; predefining the file's variables. We are still in "define" mode.
214.315 +;
214.316 + fAtt = True
214.317 + fAtt@description = "Data read in from " + filename + " ASCII file."
214.318 + fAtt@creation_date = systemfunc ("date")
214.319 + fileattdef( f, fAtt )
214.320 +
214.321 +;
214.322 +; Write dimension names to file. If there are no character variables,
214.323 +; then there's only one dimension name ("nvalues").
214.324 +;
214.325 +; Otherwise, we need to write a dimension name for every character
214.326 +; variable, which will indicate the maximum string length for that
214.327 +; variable.
214.328 +;
214.329 + indc = ind(var_types.eq."character")
214.330 + if(.not.any(ismissing(indc))) then
214.331 +;
214.332 +; We have to treat the character arrays special here. We need to
214.333 +; know their sizes so we can write the maximum size of each char
214.334 +; array to the netCDF file as a dimension name. This means we
214.335 +; need to read in the character variables once to get the string
214.336 +; lengths, then we'll read them again later to get the actual values.
214.337 +;
214.338 + do i=0,dimsizes(indc)-1
214.339 + var_strlens(indc(i)) = get_maxlen(data,indc(i)+1,dindices)
214.340 + end do
214.341 +
214.342 + ndims = dimsizes(indc) + 1
214.343 + dimNames = new(ndims,string)
214.344 + dimSizes = new(ndims,integer)
214.345 + dimUnlim = new(ndims,logical)
214.346 +
214.347 + dimUnlim = False
214.348 + dimUnlim(0) = True
214.349 + dimNames(0) = "nvalues"
214.350 + dimNames(1:ndims-1) = var_names(indc) + "_StrLen"
214.351 + dimSizes(0) = -1
214.352 + dimSizes(1:ndims-1) = var_strlens(indc)
214.353 + filedimdef(f,dimNames,dimSizes,dimUnlim)
214.354 + else
214.355 +;
214.356 +; No character variables, so just write the one dimension name.
214.357 +;
214.358 + filedimdef(f,"nvalues",-1,True)
214.359 + end if
214.360 +
214.361 +;
214.362 +; Define each variable on the file.
214.363 +;
214.364 +; Don't deal with variables that are of type string.
214.365 +;
214.366 + do i=0,nfields-1
214.367 + if(var_types(i).ne."string") then
214.368 + if(var_types(i).ne."character") then
214.369 + filevardef(f, var_names(i), var_types(i), "nvalues")
214.370 + else
214.371 + filevardef(f, var_names(i), var_types(i), \
214.372 + (/"nvalues",var_names(i)+"_StrLen"/))
214.373 + end if
214.374 + end if
214.375 + end do
214.376 +
214.377 +;
214.378 +; Loop through each field, read the values for that field, print
214.379 +; information about the variable, and then write it to the netCDF
214.380 +; file.
214.381 +;
214.382 + do i=0,nfields-1
214.383 + ifield = i+1 ; Fields start at #1, not #0.
214.384 +;
214.385 +; Note: you can't write strings to a netCDF file, so these have
214.386 +; to be written out as character arrays.
214.387 +;
214.388 + tmp_data = read_field(data,ifield,dindices,var_types(i))
214.389 +;
214.390 +; Print some info about the variable.
214.391 +;
214.392 + print("")
214.393 + print("Writing variable '" + var_names(i) + "' (field #" + ifield + ").")
214.394 + print("Type is " + var_types(i) + ".")
214.395 + if(var_types(i).ne."string".and.var_types(i).ne."character") then
214.396 + print("min/max = " + min(tmp_data) + "/" + max(tmp_data))
214.397 + end if
214.398 +
214.399 + if(any(ismissing(tmp_data))) then
214.400 + print("This variable does contain missing values.")
214.401 + else
214.402 + print("This variable doesn't contain missing values.")
214.403 + end if
214.404 +
214.405 + f->$var_names(i)$ = tmp_data ; Write to netCDF file.
214.406 +
214.407 + delete(tmp_data) ; Delete for next round.
214.408 + end do
214.409 +end
215.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
215.2 +++ b/npp/01.read_ascii_933.ncl Mon Jan 26 22:08:20 2009 -0500
215.3 @@ -0,0 +1,406 @@
215.4 +;----------------------------------------------------------------------
215.5 +; This example reads an ASCII file that is formatted a specific way, and
215.6 +; writes out the results to a netCDF file.
215.7 +;
215.8 +; The first line in the ASCII file must be a header, with each field
215.9 +; separated by a single character delimiter (like a ","). The rest of
215.10 +; the file must be such that each row contains all fields, each
215.11 +; separated by the designated delimiter.
215.12 +;
215.13 +; The fields can be integer, float, double, character, or string.
215.14 +; String fields cannot be written to a netCDF file. They have to
215.15 +; be read in as character arrays and written out that way.
215.16 +;----------------------------------------------------------------------
215.17 +
215.18 +;----------------------------------------------------------------------
215.19 +; This function returns the index locations of the given delimiter
215.20 +; in a row or several rows of strings.
215.21 +;----------------------------------------------------------------------
215.22 +function delim_indices(strings,nfields,delimiter)
215.23 +local cstrings, cdelim
215.24 +begin
215.25 + nrows = dimsizes(strings)
215.26 +;
215.27 +; Handle special case if we only have one string. Make sure it
215.28 +; is put into a 2D array.
215.29 +;
215.30 + if(nrows.eq.1) then
215.31 + cstrings = new((/1,strlen(strings)+1/),character)
215.32 + end if
215.33 +
215.34 + cstrings = stringtochar(strings) ; Convert to characters.
215.35 + cdelim = stringtochar(delimiter) ; Convert delimiter to character.
215.36 +;
215.37 +; Som error checking here. Make sure delimiter is one character.
215.38 +;
215.39 + nc = dimsizes(cdelim)
215.40 + rank = dimsizes(nc)
215.41 + if(rank.ne.1.or.(rank.eq.1.and.nc.ne.2)) then
215.42 + print("delim_indices: fatal: the delimiter you've selected")
215.43 + print("must be a single character. Can't continue.")
215.44 + exit
215.45 + end if
215.46 +
215.47 +;
215.48 +; Create array to hold indices of delimiter locations, and then loop
215.49 +; through each row and find all the delimiters. Make sure each row has
215.50 +; the correct number of delimiters.
215.51 +;
215.52 + ndelims = nfields-1
215.53 + cindices = new((/nrows,ndelims/),integer)
215.54 + do i = 0, nrows-1
215.55 + ii = ind(cstrings(i,:).eq.cdelim(0))
215.56 +;
215.57 +; Make sure there were delimiters on this row. If not, we just quit.
215.58 +; This could probably be modified to do this more gracefully.
215.59 +;
215.60 + if(any(ismissing(ii))) then
215.61 + print("delim_indices: fatal: I didn't find any delimiters")
215.62 + print("('" + delimiter + "') on row " + i + ". Can't continue.")
215.63 + exit
215.64 + end if
215.65 + if(dimsizes(ii).ne.ndelims) then
215.66 + print("delim_indices: fatal: I expected to find " + ndelims)
215.67 + print("delimiters on row " + i + ". Instead, I found " + dimsizes(ii) + ".")
215.68 + print("Can't continue.")
215.69 + exit
215.70 + end if
215.71 +
215.72 + cindices(i,:) = ii
215.73 +
215.74 + delete(ii) ; For next time through loop
215.75 + end do
215.76 +
215.77 + return(cindices)
215.78 +end
215.79 +
215.80 +;----------------------------------------------------------------------
215.81 +; This function reads in a particular field from a string array,
215.82 +; given the field number to read (fields start at #1 and go to #nfield),
215.83 +; and the indices of the delimiters.
215.84 +;
215.85 +; It returns either an integer, float, double, character, or a string,
215.86 +; depending on the input flag "return_type".
215.87 +;----------------------------------------------------------------------
215.88 +function read_field(strings,ifield,indices,return_type)
215.89 +local nstring, cstrings, nf, tmp_str
215.90 +begin
215.91 + nrows = dimsizes(strings)
215.92 +;
215.93 +; Handle special case if we only have one string. Make sure it
215.94 +; is put into a 2D array.
215.95 +;
215.96 + if(nrows.eq.1) then
215.97 + cstrings = new((/1,strlen(strings)+1/),character)
215.98 + end if
215.99 +
215.100 + cstrings = stringtochar(strings)
215.101 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
215.102 +
215.103 +;
215.104 +; Error checking. Make sure user has entered a valid field.
215.105 +;
215.106 + if(ifield.le.0.or.ifield.gt.nf) then
215.107 + print("read_field: fatal: you've selected a field that is")
215.108 + print("out-of-range of the number of fields that you have (" + nf + ").")
215.109 + exit
215.110 + end if
215.111 +
215.112 +;
215.113 +; Set up array to return. For string, int, float, or double arrays,
215.114 +; we don't have to do anything special. For character arrays,
215.115 +; however, we do.
215.116 +;
215.117 + if(return_type.ne."character") then
215.118 + return_array = new(nrows,return_type)
215.119 + else
215.120 +;
215.121 +; We don't know what the biggest character array is at this point, so
215.122 +; make it bigger than necessary, and then resize later as necessary.
215.123 +;
215.124 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
215.125 +
215.126 + max_len = 0 ; Use to keep track of max lengths of strings.
215.127 + end if
215.128 +
215.129 + do i = 0,nrows-1
215.130 +;
215.131 +; Special case of first field in row.
215.132 +;
215.133 + if(ifield.eq.1) then
215.134 + ibeg = 0
215.135 + iend = indices(i,ifield-1)-1
215.136 + else
215.137 +;
215.138 +; Special case of first field in row.
215.139 +;
215.140 + if(ifield.eq.nf) then
215.141 + ibeg = indices(i,ifield-2)+1
215.142 + iend = dimsizes(cstrings(i,:))-1
215.143 +;
215.144 +; Any field between first and last field.
215.145 +;
215.146 + else
215.147 + ibeg = indices(i,ifield-2)+1
215.148 + iend = indices(i,ifield-1)-1
215.149 + end if
215.150 + end if
215.151 +;
215.152 +; Here's the code that pulls off the correct string, and converts it
215.153 +; to float if desired.
215.154 +;
215.155 + if(return_type.eq."integer") then
215.156 + return_array(i) = stringtointeger(chartostring(cstrings(i,ibeg:iend)))
215.157 + end if
215.158 + if(return_type.eq."float") then
215.159 + return_array(i) = stringtofloat(chartostring(cstrings(i,ibeg:iend)))
215.160 + end if
215.161 + if(return_type.eq."double") then
215.162 + return_array(i) = stringtodouble(chartostring(cstrings(i,ibeg:iend)))
215.163 + end if
215.164 + if(return_type.eq."string") then
215.165 + return_array(i) = chartostring(cstrings(i,ibeg:iend))
215.166 + end if
215.167 + if(return_type.eq."character") then
215.168 + if( (iend-ibeg+1) .gt. max_len) then
215.169 + max_len = iend-ibeg+1
215.170 + end if
215.171 + tmp_return_array(i,0:iend-ibeg) = cstrings(i,ibeg:iend)
215.172 + end if
215.173 + end do
215.174 +
215.175 + if(return_type.eq."character") then
215.176 + return_array = new((/nrows,max_len/),"character")
215.177 + return_array = tmp_return_array(:,0:max_len-1)
215.178 + end if
215.179 +
215.180 + return(return_array)
215.181 +end
215.182 +
215.183 +
215.184 +;----------------------------------------------------------------------
215.185 +; This function reads in string fields only to get the maximum string
215.186 +; length.
215.187 +;----------------------------------------------------------------------
215.188 +function get_maxlen(strings,ifield,indices)
215.189 +local nstring, cstrings, nf, tmp_str
215.190 +begin
215.191 + nrows = dimsizes(strings)
215.192 +;
215.193 +; Handle special case if we only have one string. Make sure it
215.194 +; is put into a 2D array.
215.195 +;
215.196 + if(nrows.eq.1) then
215.197 + cstrings = new((/1,strlen(strings)+1/),character)
215.198 + end if
215.199 +
215.200 + cstrings = stringtochar(strings)
215.201 + nf = dimsizes(indices(0,:))+1 ; indices is nrows x (nfields-1)
215.202 +
215.203 +;
215.204 +; Error checking. Make sure user has entered a valid field.
215.205 +;
215.206 + if(ifield.le.0.or.ifield.gt.nf) then
215.207 + print("read_field: fatal: you've selected a field that is")
215.208 + print("out-of-range of the number of fields that you have (" + nf + ").")
215.209 + exit
215.210 + end if
215.211 +;
215.212 +; We don't know what the biggest character array is at this point, so
215.213 +; make it bigger than necessary, and then resize later as necessary.
215.214 +;
215.215 + tmp_return_array = new((/nrows,dimsizes(cstrings(0,:))/),"character")
215.216 +
215.217 + max_len = 0 ; Use to keep track of max lengths of strings.
215.218 +
215.219 + do i = 0,nrows-1
215.220 +;
215.221 +; Special case of first field in row.
215.222 +;
215.223 + if(ifield.eq.1) then
215.224 + ibeg = 0
215.225 + iend = indices(i,ifield-1)-1
215.226 + else
215.227 +;
215.228 +; Special case of first field in row.
215.229 +;
215.230 + if(ifield.eq.nf) then
215.231 + ibeg = indices(i,ifield-2)+1
215.232 + iend = dimsizes(cstrings(i,:))-1
215.233 +;
215.234 +; Any field between first and last field.
215.235 +;
215.236 + else
215.237 + ibeg = indices(i,ifield-2)+1
215.238 + iend = indices(i,ifield-1)-1
215.239 + end if
215.240 + end if
215.241 + if( (iend-ibeg+1) .gt. max_len) then
215.242 + max_len = iend-ibeg+1
215.243 + end if
215.244 + end do
215.245 +
215.246 + return(max_len)
215.247 +end
215.248 +
215.249 +;----------------------------------------------------------------------
215.250 +; Main code.
215.251 +;----------------------------------------------------------------------
215.252 +begin
215.253 +;
215.254 +; Set up defaults here. We are hard-coding the field types here.
215.255 +; You can set up this script to try to determine the field types
215.256 +; automatically, but this is a bit tedious. Maybe later.
215.257 +;
215.258 + filename = "data.933" ; ASCII" file to read.
215.259 + cdf_file = filename + ".nc" ; netCDF file to write.
215.260 + nfields = 45 ; # of fields
215.261 + delimiter = "," ; field delimiter
215.262 +;
215.263 +; In this case, fields #6-#8 are strings, fields #2, #3, and #11
215.264 +; are float, and the rest of the fields are integers.
215.265 +;
215.266 + var_types = new(nfields,string)
215.267 + var_strlens = new(nfields,integer) ; var to hold strlens, just in case.
215.268 +
215.269 + var_types = "integer" ; Most are ints.
215.270 + var_types(5:7) = "character" ; Corresponds to fields 6-8.
215.271 + var_types(1:2) = "float"
215.272 + var_types(10) = "float"
215.273 +
215.274 + if(isfilepresent(cdf_file))
215.275 + print("Warning: '" + cdf_file + "' exists. Will remove it.")
215.276 + system("/bin/rm " + cdf_file)
215.277 + end if
215.278 +
215.279 +;
215.280 +; Read in data as strings. This will create a string array that has the
215.281 +; same number of strings as there are rows in the file. We will then need
215.282 +; to parse each string later.
215.283 +;
215.284 + read_data = asciiread(filename,-1,"string")
215.285 + header = read_data(0) ; Header. Use for variable names.
215.286 + data = read_data(1:) ; Get rid of first line which is a header.
215.287 + nrows = dimsizes(data) ; Number of rows.
215.288 +
215.289 +;
215.290 +; Read in locations of delimiters in each string row.
215.291 +;
215.292 + hindices = delim_indices(header,nfields,delimiter) ; header row
215.293 + dindices = delim_indices(data,nfields,delimiter) ; rest of file
215.294 +
215.295 +;
215.296 +; Read in the field names which will become variable names on
215.297 +; the netCDF file.
215.298 +;
215.299 + var_names = new(nfields,string)
215.300 +
215.301 + do i=0,nfields-1
215.302 + var_names(i) = read_field(header,i+1,hindices,"string")
215.303 + end do
215.304 +
215.305 +;
215.306 +; Write out this netCDF file efficiently so it will be faster.
215.307 +; Try to predefine everything before you write to it.
215.308 +;
215.309 + f = addfile(cdf_file,"c")
215.310 + setfileoption(f,"DefineMode",True) ; Enter predefine phase.
215.311 +
215.312 +;
215.313 +; Write global attributes to file. It's okay to do this before
215.314 +; predefining the file's variables. We are still in "define" mode.
215.315 +;
215.316 + fAtt = True
215.317 + fAtt@description = "Data read in from " + filename + " ASCII file."
215.318 + fAtt@creation_date = systemfunc ("date")
215.319 + fileattdef( f, fAtt )
215.320 +
215.321 +;
215.322 +; Write dimension names to file. If there are no character variables,
215.323 +; then there's only one dimension name ("nvalues").
215.324 +;
215.325 +; Otherwise, we need to write a dimension name for every character
215.326 +; variable, which will indicate the maximum string length for that
215.327 +; variable.
215.328 +;
215.329 + indc = ind(var_types.eq."character")
215.330 + if(.not.any(ismissing(indc))) then
215.331 +;
215.332 +; We have to treat the character arrays special here. We need to
215.333 +; know their sizes so we can write the maximum size of each char
215.334 +; array to the netCDF file as a dimension name. This means we
215.335 +; need to read in the character variables once to get the string
215.336 +; lengths, then we'll read them again later to get the actual values.
215.337 +;
215.338 + do i=0,dimsizes(indc)-1
215.339 + var_strlens(indc(i)) = get_maxlen(data,indc(i)+1,dindices)
215.340 + end do
215.341 +
215.342 + ndims = dimsizes(indc) + 1
215.343 + dimNames = new(ndims,string)
215.344 + dimSizes = new(ndims,integer)
215.345 + dimUnlim = new(ndims,logical)
215.346 +
215.347 + dimUnlim = False
215.348 + dimUnlim(0) = True
215.349 + dimNames(0) = "nvalues"
215.350 + dimNames(1:ndims-1) = var_names(indc) + "_StrLen"
215.351 + dimSizes(0) = -1
215.352 + dimSizes(1:ndims-1) = var_strlens(indc)
215.353 + filedimdef(f,dimNames,dimSizes,dimUnlim)
215.354 + else
215.355 +;
215.356 +; No character variables, so just write the one dimension name.
215.357 +;
215.358 + filedimdef(f,"nvalues",-1,True)
215.359 + end if
215.360 +
215.361 +;
215.362 +; Define each variable on the file.
215.363 +;
215.364 +; Don't deal with variables that are of type string.
215.365 +;
215.366 + do i=0,nfields-1
215.367 + if(var_types(i).ne."string") then
215.368 + if(var_types(i).ne."character") then
215.369 + filevardef(f, var_names(i), var_types(i), "nvalues")
215.370 + else
215.371 + filevardef(f, var_names(i), var_types(i), \
215.372 + (/"nvalues",var_names(i)+"_StrLen"/))
215.373 + end if
215.374 + end if
215.375 + end do
215.376 +
215.377 +;
215.378 +; Loop through each field, read the values for that field, print
215.379 +; information about the variable, and then write it to the netCDF
215.380 +; file.
215.381 +;
215.382 + do i=0,nfields-1
215.383 + ifield = i+1 ; Fields start at #1, not #0.
215.384 +;
215.385 +; Note: you can't write strings to a netCDF file, so these have
215.386 +; to be written out as character arrays.
215.387 +;
215.388 + tmp_data = read_field(data,ifield,dindices,var_types(i))
215.389 +;
215.390 +; Print some info about the variable.
215.391 +;
215.392 + print("")
215.393 + print("Writing variable '" + var_names(i) + "' (field #" + ifield + ").")
215.394 + print("Type is " + var_types(i) + ".")
215.395 + if(var_types(i).ne."string".and.var_types(i).ne."character") then
215.396 + print("min/max = " + min(tmp_data) + "/" + max(tmp_data))
215.397 + end if
215.398 +
215.399 + if(any(ismissing(tmp_data))) then
215.400 + print("This variable does contain missing values.")
215.401 + else
215.402 + print("This variable doesn't contain missing values.")
215.403 + end if
215.404 +
215.405 + f->$var_names(i)$ = tmp_data ; Write to netCDF file.
215.406 +
215.407 + delete(tmp_data) ; Delete for next round.
215.408 + end do
215.409 +end
216.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
216.2 +++ b/npp/02.read.ascii.ncl.x Mon Jan 26 22:08:20 2009 -0500
216.3 @@ -0,0 +1,83 @@
216.4 +;************************************************
216.5 +; Read ascii, Write nc
216.6 +;************************************************
216.7 +;load "/fs/cgd/data0/shea/nclGSUN/gsn_code.ncl"
216.8 +;load "/fs/cgd/data0/shea/nclGSUN/gsn_csm.ncl"
216.9 +;load "/fs/cgd/data0/shea/nclGSUN/shea_util.ncl"
216.10 +;************************************************
216.11 +begin
216.12 +;---------------------------------------------------
216.13 +; final data
216.14 + c = addfile("Npp_0.05deg_mean4.nc","c")
216.15 + filedimdef(c,"time",-1,True)
216.16 +
216.17 + nlat = 180*20
216.18 + nlon = 360*20
216.19 +
216.20 +;---------------------------------------------------
216.21 +; input data
216.22 + b = "Npp_0.05deg_mean.ASCII2"
216.23 +
216.24 + t = new((/1,nlat,nlon/),float)
216.25 + lon = new((/nlon/),float)
216.26 + lat = new((/nlat/),float)
216.27 + time = new((/1/),integer)
216.28 +
216.29 +; sam result
216.30 +; lon = fspan(-180.,179.95,nlon)
216.31 +; lat = fspan(-90. , 89.95,nlat)
216.32 +
216.33 + do i = 0,nlon-1
216.34 + lon(i) = -180. + i*(360./nlon)
216.35 + end do
216.36 +
216.37 + do j = 0,nlat-1
216.38 + lat(j) = -90. + j*(180./nlat)
216.39 + end do
216.40 +
216.41 + time = 1
216.42 +
216.43 +; print (lon)
216.44 +; print (lat)
216.45 +; print (time)
216.46 +;=============================
216.47 + ; create lat and long coordinate variables
216.48 + ;============================
216.49 + lon!0 = "lon"
216.50 + lon@long_name = "lon"
216.51 + lon@units = "degrees-east"
216.52 + lon&lon = lon
216.53 +
216.54 + lat!0 = "lat"
216.55 + lat@long_name = "lat"
216.56 + lat@units = "degrees_north"
216.57 + lat&lat = lat
216.58 + ;=============================
216.59 + ; name dimensions of t and assign coordinate variables
216.60 + ;============================
216.61 + t!0 = "time"
216.62 + t!1 = "lat"
216.63 + t!2 = "lon"
216.64 + t&time = time
216.65 + t&lat = lat
216.66 + t&lon = lon
216.67 + t@long_name = "net primary production"
216.68 + t@units = "gC/m^2/year"
216.69 + t@_FillValue= 1.e+36
216.70 + t@missing_value= 1.e+36
216.71 +
216.72 + t(0,:,:) = asciiread(b,(/nlat,nlon/),"float")
216.73 +
216.74 + c->NPP = t
216.75 + c->lat = lat
216.76 + c->lon = lon
216.77 + c->time = time
216.78 +
216.79 + do i = 0,nlon-1
216.80 + do j = 0,nlat-1
216.81 + if (t(0,j,i) .gt. 0.) then
216.82 + print (t(0,j,i))
216.83 + end if
216.84 + end do
216.85 + end do
216.86 +end
217.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
217.2 +++ b/npp/02.read_binary.f90.x Mon Jan 26 22:08:20 2009 -0500
217.3 @@ -0,0 +1,14 @@
217.4 +program to_read_int
217.5 +integer, parameter :: nlat = 180 * 20, nlon = 360 * 20, &
217.6 + recl = 2*nlat*nlon
217.7 +integer(2), dimension(nlat,nlon) :: data
217.8 +open(11,file='Npp_0.05deg_mean.int16',form='unformatted',&
217.9 + access='direct',recl=recl)
217.10 +read(11,rec=1)data
217.11 +close(11)
217.12 +do i = 1, nlon
217.13 + do j = 1, nlat
217.14 + write(*,*)data(j,i)
217.15 + end do
217.16 +enddo
217.17 +end
218.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
218.2 +++ b/npp/02.read_binary_0.05deg.ncl Mon Jan 26 22:08:20 2009 -0500
218.3 @@ -0,0 +1,79 @@
218.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
218.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
218.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
218.7 +
218.8 +begin
218.9 + nlat = 3600
218.10 + mlon = 7200
218.11 +
218.12 + diri = "/fis/cgd/cseg/people/jeff/clamp/"
218.13 + fili = "Npp_0.05deg_mean.int16"
218.14 +
218.15 + diro = "/fis/cgd/cseg/people/jeff/clamp/"
218.16 + filo = "Npp_0.05deg_mean_3.nc"
218.17 + c = addfile(diro+filo,"c")
218.18 +
218.19 +; I think (a) the file is "little endian"; read into short
218.20 +; (b) the _FillValue is 32700
218.21 +
218.22 + setfileoption("bin","ReadByteOrder","LittleEndian")
218.23 + xShort= fbindirread(diri+fili,0, (/nlat,mlon/), "short")
218.24 + xShort@_FillValue= inttoshort(32700)
218.25 +
218.26 +;;xShort@scale_factor = ?????
218.27 +;;xShort@add_offset = ?????
218.28 +
218.29 + x = short2flt( xShort )
218.30 +
218.31 +;;print(xShort(:,1800)+" "+x(:,1800)) ; look at the values
218.32 + delete(xShort)
218.33 +
218.34 + x@long_name = "net primary production"
218.35 + x@units = "gC/m^2/year"
218.36 +; x@_FillValue = -17281 ; orig fill
218.37 + x@_FillValue = 1e20 ; new fill
218.38 +
218.39 + lat = latGlobeFo(nlat, "lat", "latitude", "degrees_north")
218.40 + lat = (/ lat(::-1) /) ; make N->S
218.41 + lon = lonGlobeFo(mlon, "lon", "longitude", "degrees_east")
218.42 + lon = (/ lon - 180. /) ; subtract 180 from all values
218.43 + lon&lon = lon ; update coordinates
218.44 +
218.45 + x!0 = "lat"
218.46 + x!1 = "lon"
218.47 + x&lat= lat
218.48 + x&lon= lon
218.49 +
218.50 + c->NPP = x
218.51 +
218.52 + exit
218.53 +
218.54 +;************************************************
218.55 +; create default plot
218.56 +;************************************************
218.57 +
218.58 + setvalues NhlGetWorkspaceObjectId()
218.59 + "wsMaximumSize" : 199999999
218.60 + end setvalues
218.61 +
218.62 + wks = gsn_open_wks("ps","Npp_rdBinPlt") ; open a ps file
218.63 + ;gsn_define_colormap(wks,"wgne15") ; choose colormap
218.64 +
218.65 + res = True ; Use plot options
218.66 + res@cnFillOn = True ; Turn on color fill
218.67 + res@cnFillMode = "RasterFill" ; Turn on raster color
218.68 + res@lbLabelAutoStride = True
218.69 + res@cnLinesOn = False ; Turn off contourn lines
218.70 + ;res@gsnSpreadColors = True ; use full colormap
218.71 + res@mpFillOn = False ; Turn off map fill
218.72 +
218.73 + ;res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
218.74 + ;res@cnMinLevelValF = ; Min level
218.75 + ;res@cnMaxLevelValF = ; Max level
218.76 + ;res@cnLevelSpacingF = ; interval
218.77 + res@tiMainString = fili
218.78 +
218.79 + plot = gsn_csm_contour_map_ce(wks,x,res)
218.80 +
218.81 +end
218.82 +
219.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
219.2 +++ b/npp/02.read_binary_Npp.ncl.0 Mon Jan 26 22:08:20 2009 -0500
219.3 @@ -0,0 +1,94 @@
219.4 +;************************************************
219.5 +; Read ascii, Write nc
219.6 +;************************************************
219.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
219.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
219.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
219.10 +;************************************************
219.11 +begin
219.12 +;---------------------------------------------------
219.13 +; final data
219.14 + c = addfile("Npp_0.05deg_mean_2.nc","c")
219.15 + filedimdef(c,"time",-1,True)
219.16 +
219.17 + nlat = 180*20
219.18 + nlon = 360*20
219.19 +
219.20 +;---------------------------------------------------
219.21 +; input data
219.22 + b = "Npp_0.05deg_mean.int16"
219.23 +
219.24 + x = new((/nlat*nlon/),float)
219.25 + t = new((/1,nlat,nlon/),float)
219.26 + lon = new((/nlon/),float)
219.27 + lat = new((/nlat/),float)
219.28 + time = new((/1/),integer)
219.29 +
219.30 +; sam result
219.31 +; lon = fspan(-180.,179.95,nlon)
219.32 +; lat = fspan(-90. , 89.95,nlat)
219.33 +
219.34 + do i = 0,nlon-1
219.35 + lon(i) = -180. + i*(360./nlon)
219.36 + end do
219.37 +
219.38 + do j = 0,nlat-1
219.39 + lat(j) = -90. + j*(180./nlat)
219.40 + end do
219.41 +
219.42 + time = 1
219.43 +
219.44 +; print (lon)
219.45 +; print (lat)
219.46 +; print (time)
219.47 +;=============================
219.48 + ; create lat and long coordinate variables
219.49 + ;============================
219.50 + lon!0 = "lon"
219.51 + lon@long_name = "lon"
219.52 + lon@units = "degrees-east"
219.53 + lon&lon = lon
219.54 +
219.55 + lat!0 = "lat"
219.56 + lat@long_name = "lat"
219.57 + lat@units = "degrees_north"
219.58 + lat&lat = lat
219.59 + ;=============================
219.60 + ; name dimensions of t and assign coordinate variables
219.61 + ;============================
219.62 + t!0 = "time"
219.63 + t!1 = "lat"
219.64 + t!2 = "lon"
219.65 + t&time = time
219.66 + t&lat = lat
219.67 + t&lon = lon
219.68 + t@long_name = "net primary production"
219.69 + t@units = "gC/m^2/year"
219.70 + t@_FillValue= 1.e+36
219.71 + t@missing_value= 1.e+36
219.72 +
219.73 +; t = fbinrecread(b,0,(/nlat,nlon/),"float")
219.74 +
219.75 + do j = 0,nlat-1
219.76 +print (j)
219.77 + do i = 0,nlon-1
219.78 + nrec = j*nlon + i
219.79 + x(nrec) = fbindirread(b,nrec,1,"float")
219.80 + end do
219.81 + end do
219.82 +print (lat)
219.83 + t = onedtond(x,(/nlat,nlon/))
219.84 +
219.85 + c->NPP = t
219.86 + c->lat = lat
219.87 + c->lon = lon
219.88 + c->time = time
219.89 +
219.90 +; do i = 0,nlon-1
219.91 +; do j = 0,nlat-1
219.92 +; if (t(0,j,i) .gt. 0.) then
219.93 +; print (t(0,j,i))
219.94 +; end if
219.95 +; end do
219.96 +; end do
219.97 +end
220.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
220.2 +++ b/npp/02.read_uint16_ASCII.c.x Mon Jan 26 22:08:20 2009 -0500
220.3 @@ -0,0 +1,90 @@
220.4 +/* purpose: conversion of binary data with little-endian to ASCII
220.5 + Sep. 8, 2006 by Maosheng Zhao */
220.6 +
220.7 +/* I also accounts for the possible different CPU on different platforms,
220.8 + and therefore, it should work on different machines without problem */
220.9 +
220.10 +#include<stdio.h>
220.11 +#define COLS 7200
220.12 +#define ROWS 3600
220.13 +#define DATA_TYPE unsigned short
220.14 +
220.15 +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
220.16 +#define IN_FILE_NAME "Npp_0.05deg_mean.int16"
220.17 +#define OUT_FILE_NAME "Npp_0.05deg_mean.ASCII2"
220.18 +/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
220.19 +int main()
220.20 +{
220.21 + /* definiation of variables will be used */
220.22 + FILE *in_f, *out_f;
220.23 + static DATA_TYPE data_in[ROWS][COLS];
220.24 + int i,j;
220.25 +
220.26 + /* the follow definition is for determination the type of CPU */
220.27 + int is_big_endian=0;
220.28 + short one=1;
220.29 + char *cp;
220.30 +
220.31 + /* define a buffer pointer to swap bytes if it is big-endian CPU */
220.32 + char temp_char[sizeof(DATA_TYPE)];
220.33 + DATA_TYPE *buffer_data;
220.34 + int m;
220.35 +
220.36 + /*################################################################*/
220.37 + /* main program starts */
220.38 + /* open the data file and read all the data */
220.39 + in_f = fopen(IN_FILE_NAME,"rb");
220.40 + if(in_f == NULL)
220.41 + {
220.42 + printf("cannot open %s, exit...\n",IN_FILE_NAME);
220.43 + exit(0);
220.44 + }
220.45 + else /* reading the data */
220.46 + {
220.47 + /* tell the type of CPU */
220.48 + cp = (char*)&one;
220.49 + if(*cp == 0)
220.50 + is_big_endian = 1; /* yes, this is a big-endian CPU */
220.51 + else
220.52 + is_big_endian = 0; /* this is a little-endian CPU */
220.53 +
220.54 + if(is_big_endian == 0)
220.55 + {
220.56 + printf("This is a little-endian CPU, no need to swap bytes\n");
220.57 + printf("reading data now, please waiting for...\n");
220.58 + fread(data_in,sizeof(DATA_TYPE),COLS*ROWS,in_f);
220.59 + }
220.60 + else
220.61 + {
220.62 + printf("This is a big-endian CPU, which needs to swap bytes\n");
220.63 + printf("reading data now, please waiting for...\n");
220.64 + for(i=0;i<ROWS;i++)
220.65 + for(j=0;j<COLS;j++)
220.66 + {
220.67 + for(m=0;m<sizeof(DATA_TYPE);m++)
220.68 + fread(&temp_char[sizeof(DATA_TYPE)-1-m],1,1,in_f);
220.69 +
220.70 + /* swap the byte order */
220.71 + buffer_data = (DATA_TYPE*)temp_char;
220.72 + data_in[i][j] = *buffer_data;
220.73 + } /* end of nested loops for i and j */
220.74 + }
220.75 + }
220.76 +
220.77 + /* close the input file */
220.78 + fclose(in_f);
220.79 +
220.80 +
220.81 + /* write the ASCII to a new file */
220.82 + out_f = fopen(OUT_FILE_NAME,"w");
220.83 + printf("Please waiting for writing data to %s\n",OUT_FILE_NAME);
220.84 + for(i=0;i<ROWS;i++)
220.85 + for(j=0;j<COLS;j++)
220.86 + fprintf(out_f,"%6d\n",data_in[i][j]);
220.87 +
220.88 + fclose(out_f);
220.89 +
220.90 + printf("Finished conversion of binary to ASCII\n");
220.91 +
220.92 + return(0);
220.93 +}
221.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
221.2 +++ b/npp/03.0.05deg_to_1.9.ncl Mon Jan 26 22:08:20 2009 -0500
221.3 @@ -0,0 +1,123 @@
221.4 +; ***********************************************
221.5 +; interpolate into model grids (1.9x2.5)
221.6 +; ***********************************************
221.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
221.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
221.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
221.10 +;************************************************
221.11 +begin
221.12 +;************************************************
221.13 +; output data
221.14 +;************************************************
221.15 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
221.16 + filo = "Npp_1.9_mean.nc"
221.17 + c = addfile(diro+filo,"c")
221.18 +
221.19 +;************************************************
221.20 +; read in observed data
221.21 +;************************************************
221.22 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
221.23 + fili = "Npp_0.05deg_mean.nc"
221.24 + g = addfile (diri+fili,"r")
221.25 + bi = g->NPP
221.26 + xi = g->lon
221.27 + yi = g->lat
221.28 +
221.29 +;************************************************
221.30 +; change into 0-360E, 90S-90N
221.31 +; Observed NPP*scale_factor
221.32 +;************************************************
221.33 +
221.34 + scale_factor = 0.1
221.35 +
221.36 + yi = (/ yi(::-1) /)
221.37 + bi = (/ bi(::-1,:) /)
221.38 + b2 = bi
221.39 + x2 = xi
221.40 +
221.41 + nx = dimsizes(xi)
221.42 + do i= 0,nx-1
221.43 + if (i .lt. 3600) then
221.44 + p = i + 3600
221.45 + xi(p) = x2(i) + 360.
221.46 + else
221.47 + p = i - 3600
221.48 + xi(p) = x2(i)
221.49 + end if
221.50 + bi(:,p)= b2(:,i) * scale_factor
221.51 + end do
221.52 +
221.53 + bi&lat = yi
221.54 + bi&lon = xi
221.55 +
221.56 +;print (xi)
221.57 +;print (yi)
221.58 +;************************************************
221.59 +; read in model data
221.60 +;************************************************
221.61 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
221.62 + fili2 = "newcn05_ncep_1i_MONS_climo_lnd.nc"
221.63 + f = addfile (diri2+fili2,"r")
221.64 +
221.65 + lon = f->lon
221.66 + lat = f->lat
221.67 + nlon = dimsizes(lon)
221.68 + nlat = dimsizes(lat)
221.69 +
221.70 +; print (xi)
221.71 +; print (yi)
221.72 +; print (xo)
221.73 +; print (yo)
221.74 +
221.75 + bo = new((/nlat,nlon/),float)
221.76 +
221.77 + do j=0,nlat-1
221.78 + if (j.eq.0 .or. j.eq.nlat-1) then
221.79 + if (j.eq.0) then
221.80 + LATS = -90.
221.81 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
221.82 + end if
221.83 + if (j.eq.nlat-1) then
221.84 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
221.85 + LATN = 90.
221.86 + end if
221.87 + else
221.88 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
221.89 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
221.90 + end if
221.91 +
221.92 + do i=0,nlon-1
221.93 + if (i.eq.0 .or. i.eq.nlon-1) then
221.94 + if (i.eq.0) then
221.95 + LONL = 0.
221.96 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
221.97 + end if
221.98 + if (i.eq.nlon-1) then
221.99 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
221.100 + LONR = 360.
221.101 + end if
221.102 + else
221.103 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
221.104 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
221.105 + end if
221.106 +
221.107 +;print (LATS)
221.108 +;print (LATN)
221.109 +;print (LONL)
221.110 +;print (LONR)
221.111 +
221.112 + bo(j,i) = avg(bi({LATS:LATN},{LONL:LONR}))
221.113 + end do
221.114 + end do
221.115 +
221.116 + bo!0 = "lat"
221.117 + bo!1 = "lon"
221.118 + bo&lat = lat
221.119 + bo&lon = lon
221.120 + bo@units = bi@units
221.121 + bo@long_name = bi@long_name
221.122 +; bo@_FillValue = bi@_FillValue
221.123 + bo@_FillValue = 1.e+36
221.124 +
221.125 + c->NPP = bo
221.126 +end
221.127 \ No newline at end of file
222.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
222.2 +++ b/npp/03.0.05deg_to_T31.ncl Mon Jan 26 22:08:20 2009 -0500
222.3 @@ -0,0 +1,142 @@
222.4 +; ***********************************************
222.5 +; interpolate into model grids (T31)
222.6 +; ***********************************************
222.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
222.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
222.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
222.10 +;************************************************
222.11 +begin
222.12 +;************************************************
222.13 +; output data
222.14 +;************************************************
222.15 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
222.16 + filo = "Npp_T31_mean.nc"
222.17 + c = addfile(diro+filo,"c")
222.18 +
222.19 +;************************************************
222.20 +; read in observed data
222.21 +;************************************************
222.22 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
222.23 + fili = "Npp_0.05deg_mean.nc"
222.24 + g = addfile (diri+fili,"r")
222.25 + bi = g->NPP
222.26 + xi = g->lon
222.27 + yi = g->lat
222.28 +
222.29 +;************************************************
222.30 +; change into 0-360E, 90S-90N
222.31 +; Observed NPP*scale_factor
222.32 +;************************************************
222.33 +
222.34 + scale_factor = 0.1
222.35 +
222.36 + yi = (/ yi(::-1) /)
222.37 + bi = (/ bi(::-1,:) /)
222.38 + b2 = bi
222.39 + x2 = xi
222.40 +
222.41 + nx = dimsizes(xi)
222.42 + do i= 0,nx-1
222.43 + if (i .lt. 3600) then
222.44 + p = i + 3600
222.45 + xi(p) = x2(i) + 360.
222.46 + else
222.47 + p = i - 3600
222.48 + xi(p) = x2(i)
222.49 + end if
222.50 + bi(:,p)= b2(:,i) * scale_factor
222.51 + end do
222.52 +
222.53 + bi&lat = yi
222.54 + bi&lon = xi
222.55 +
222.56 +;print (xi)
222.57 +;print (yi)
222.58 +;exit
222.59 +
222.60 +;************************************************
222.61 +; read in model data
222.62 +;************************************************
222.63 + diri2 = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
222.64 + fili2 = "b30.061n_1995-2004_ANN_climo_lnd.nc"
222.65 + f = addfile (diri2+fili2,"r")
222.66 +
222.67 + lon = f->lon
222.68 + lat = f->lat
222.69 + nlon = dimsizes(lon)
222.70 + nlat = dimsizes(lat)
222.71 +
222.72 +; print (xi)
222.73 +; print (yi)
222.74 +; print (xo)
222.75 +; print (yo)
222.76 +
222.77 +;(A)
222.78 +;bo = linint2_Wrap(xi,yi,bi,True,xo,yo,0)
222.79 +
222.80 +;(B)
222.81 +
222.82 + rad = 4.*atan(1.)/180.
222.83 + clat = lat
222.84 + clat = cos(lat*rad)
222.85 + clat@long_name = "cos(latitude)"
222.86 + delete(clat@units)
222.87 + printVarSummary(clat)
222.88 +
222.89 + bo = new((/nlat,nlon/),float)
222.90 + do j=0,nlat-1
222.91 + if (j.eq.0 .or. j.eq.nlat-1) then
222.92 + if (j.eq.0) then
222.93 + LATS = -90.
222.94 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
222.95 + end if
222.96 + if (j.eq.nlat-1) then
222.97 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
222.98 + LATN = 90.
222.99 + end if
222.100 + else
222.101 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
222.102 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
222.103 + end if
222.104 +
222.105 +; CLAT = clat({LATS:LATN}) ; do once for *slight* efficiency
222.106 +; TEMP = bi({LATS:LATN},:) ; 2D [lat,lon]
222.107 +
222.108 + do i=0,nlon-1
222.109 + if (i.eq.0 .or. i.eq.nlon-1) then
222.110 + if (i.eq.0) then
222.111 + LONL = 0.
222.112 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
222.113 + end if
222.114 + if (i.eq.nlon-1) then
222.115 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
222.116 + LONR = 360.
222.117 + end if
222.118 + else
222.119 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
222.120 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
222.121 + end if
222.122 +
222.123 +;print (LATS)
222.124 +;print (LATN)
222.125 +;print (LONL)
222.126 +;print (LONR)
222.127 + bo(j,i) = avg(bi({LATS:LATN},{LONL:LONR}))
222.128 +; bo(j,i) = wgt_areaave(TEMP(:,{LONL:LONR}), CLAT, 1.0, 0)
222.129 + end do
222.130 +
222.131 +; delete(CLAT)
222.132 +; delete(TEMP)
222.133 + end do
222.134 +
222.135 + bo!0 = "lat"
222.136 + bo!1 = "lon"
222.137 + bo&lat = lat
222.138 + bo&lon = lon
222.139 + bo@units = bi@units
222.140 + bo@long_name = bi@long_name
222.141 +; bo@_FillValue = bi@_FillValue
222.142 + bo@_FillValue = 1.e+36
222.143 +
222.144 + c->NPP = bo
222.145 +end
222.146 \ No newline at end of file
223.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
223.2 +++ b/npp/03.0.05deg_to_T42.ncl Mon Jan 26 22:08:20 2009 -0500
223.3 @@ -0,0 +1,142 @@
223.4 +; ***********************************************
223.5 +; interpolate into model grids (T31)
223.6 +; ***********************************************
223.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
223.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
223.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
223.10 +;************************************************
223.11 +begin
223.12 +;************************************************
223.13 +; output data
223.14 +;************************************************
223.15 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/"
223.16 + filo = "Npp_T42_mean.nc"
223.17 + c = addfile(diro+filo,"c")
223.18 +
223.19 +;************************************************
223.20 +; read in observed data
223.21 +;************************************************
223.22 + diri = "/fis/cgd/cseg/people/jeff/clamp_data/"
223.23 + fili = "Npp_0.05deg_mean.nc"
223.24 + g = addfile (diri+fili,"r")
223.25 + bi = g->NPP
223.26 + xi = g->lon
223.27 + yi = g->lat
223.28 +
223.29 +;************************************************
223.30 +; change into 0-360E, 90S-90N
223.31 +; Observed NPP*scale_factor
223.32 +;************************************************
223.33 +
223.34 + scale_factor = 0.1
223.35 +
223.36 + yi = (/ yi(::-1) /)
223.37 + bi = (/ bi(::-1,:) /)
223.38 + b2 = bi
223.39 + x2 = xi
223.40 +
223.41 + nx = dimsizes(xi)
223.42 + do i= 0,nx-1
223.43 + if (i .lt. 3600) then
223.44 + p = i + 3600
223.45 + xi(p) = x2(i) + 360.
223.46 + else
223.47 + p = i - 3600
223.48 + xi(p) = x2(i)
223.49 + end if
223.50 + bi(:,p)= b2(:,i) * scale_factor
223.51 + end do
223.52 +
223.53 + bi&lat = yi
223.54 + bi&lon = xi
223.55 +
223.56 +;print (xi)
223.57 +;print (yi)
223.58 +;exit
223.59 +
223.60 +;************************************************
223.61 +; read in model data
223.62 +;************************************************
223.63 +;fili2 = "i01.04casa_1605-1629_ANN_climo.nc"
223.64 + fili2 = "i01.03cn_1545-1569_ANN_climo.nc"
223.65 + f = addfile (diri+fili2,"r")
223.66 +
223.67 + lon = f->lon
223.68 + lat = f->lat
223.69 + nlon = dimsizes(lon)
223.70 + nlat = dimsizes(lat)
223.71 +
223.72 +; print (xi)
223.73 +; print (yi)
223.74 +; print (xo)
223.75 +; print (yo)
223.76 +
223.77 +;(A)
223.78 +;bo = linint2_Wrap(xi,yi,bi,True,xo,yo,0)
223.79 +
223.80 +;(B)
223.81 +
223.82 + rad = 4.*atan(1.)/180.
223.83 + clat = lat
223.84 + clat = cos(lat*rad)
223.85 + clat@long_name = "cos(latitude)"
223.86 + delete(clat@units)
223.87 + printVarSummary(clat)
223.88 +
223.89 + bo = new((/nlat,nlon/),float)
223.90 + do j=0,nlat-1
223.91 + if (j.eq.0 .or. j.eq.nlat-1) then
223.92 + if (j.eq.0) then
223.93 + LATS = -90.
223.94 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
223.95 + end if
223.96 + if (j.eq.nlat-1) then
223.97 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
223.98 + LATN = 90.
223.99 + end if
223.100 + else
223.101 + LATS = lat(j)-0.5*(lat(j)-lat(j-1))
223.102 + LATN = lat(j)+0.5*(lat(j+1)-lat(j))
223.103 + end if
223.104 +
223.105 +; CLAT = clat({LATS:LATN}) ; do once for *slight* efficiency
223.106 +; TEMP = bi({LATS:LATN},:) ; 2D [lat,lon]
223.107 +
223.108 + do i=0,nlon-1
223.109 + if (i.eq.0 .or. i.eq.nlon-1) then
223.110 + if (i.eq.0) then
223.111 + LONL = 0.
223.112 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
223.113 + end if
223.114 + if (i.eq.nlon-1) then
223.115 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
223.116 + LONR = 360.
223.117 + end if
223.118 + else
223.119 + LONL = lon(i)-0.5*(lon(i)-lon(i-1))
223.120 + LONR = lon(i)+0.5*(lon(i+1)-lon(i))
223.121 + end if
223.122 +
223.123 +;print (LATS)
223.124 +;print (LATN)
223.125 +;print (LONL)
223.126 +;print (LONR)
223.127 + bo(j,i) = avg(bi({LATS:LATN},{LONL:LONR}))
223.128 +; bo(j,i) = wgt_areaave(TEMP(:,{LONL:LONR}), CLAT, 1.0, 0)
223.129 + end do
223.130 +
223.131 +; delete(CLAT)
223.132 +; delete(TEMP)
223.133 + end do
223.134 +
223.135 + bo!0 = "lat"
223.136 + bo!1 = "lon"
223.137 + bo&lat = lat
223.138 + bo&lon = lon
223.139 + bo@units = bi@units
223.140 + bo@long_name = bi@long_name
223.141 +; bo@_FillValue = bi@_FillValue
223.142 + bo@_FillValue = 1.e+36
223.143 +
223.144 + c->NPP = bo
223.145 +end
223.146 \ No newline at end of file
224.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
224.2 +++ b/npp/03.0.05deg_to_T42.ncl.0 Mon Jan 26 22:08:20 2009 -0500
224.3 @@ -0,0 +1,77 @@
224.4 +; ***********************************************
224.5 +; interpolate into model grids (T31)
224.6 +; ***********************************************
224.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
224.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
224.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
224.10 +;************************************************
224.11 +begin
224.12 +;************************************************
224.13 +; output data
224.14 +;************************************************
224.15 + diro = "/fis/cgd/cseg/people/jeff/clamp/"
224.16 + filo = "Npp_T31_mean.nc"
224.17 + c = addfile(diro+filo,"c")
224.18 +
224.19 +;************************************************
224.20 +; read in observed data
224.21 +;************************************************
224.22 + g = addfile ("Npp_0.05deg_mean.nc","r")
224.23 + bi = g->NPP
224.24 + xi = g->lon
224.25 + yi = g->lat
224.26 +
224.27 +;************************************************
224.28 +; change into 0-360E, 90S-90N
224.29 +; Observed NPP*scale_factor
224.30 +;************************************************
224.31 +
224.32 + scale_factor = 0.1
224.33 +
224.34 + yi = (/ yi(::-1) /)
224.35 + bi = (/ bi(::-1,:) /)
224.36 + b2 = bi
224.37 + x2 = xi
224.38 +
224.39 + nx = dimsizes(xi)
224.40 + do i= 0,nx-1
224.41 + if (i .lt. 3600) then
224.42 + p = i + 3600
224.43 + xi(p) = x2(i) + 360.
224.44 + else
224.45 + p = i - 3600
224.46 + xi(p) = x2(i)
224.47 + end if
224.48 + bi(:,p)= b2(:,i) * scale_factor
224.49 + end do
224.50 +
224.51 +;print (xi)
224.52 +;print (yi)
224.53 +;exit
224.54 +
224.55 +;************************************************
224.56 +; read in model data
224.57 +;************************************************
224.58 + f = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
224.59 +;f = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
224.60 +
224.61 + xo = f->lon
224.62 + yo = f->lat
224.63 +
224.64 +; print (xi)
224.65 +; print (yi)
224.66 +; print (xo)
224.67 +; print (yo)
224.68 +
224.69 + bo = linint2_Wrap(xi,yi,bi,True,xo,yo,0)
224.70 +
224.71 + bo!0 = "lat"
224.72 + bo!1 = "lon"
224.73 + bo&lat = yo
224.74 + bo&lon = xo
224.75 + bo@units = bi@units
224.76 + bo@long_name = bi@long_name
224.77 + bo@_FillValue = bi@_FillValue
224.78 +
224.79 + c->NPP = bo
224.80 +end
224.81 \ No newline at end of file
225.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
225.2 +++ b/npp/11.scatter.ncl Mon Jan 26 22:08:20 2009 -0500
225.3 @@ -0,0 +1,53 @@
225.4 +; ***********************************************
225.5 +; xy_4.ncl
225.6 +; ***********************************************
225.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
225.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
225.9 +;************************************************
225.10 +begin
225.11 +;************************************************
225.12 +; read in data
225.13 +;************************************************
225.14 +;f = addfile ("data.81.nc","r")
225.15 + f = addfile ("data.933.nc","r")
225.16 + x = f->SITE_ID ; get t data
225.17 +;y = f->PREC_ANN ; get t data
225.18 + y = f->TNPP_C ; get t data
225.19 +
225.20 + x@long_name = "SITE_ID"
225.21 +;y@long_name = "PREC_ANN"
225.22 + y@long_name = "TNPP_C"
225.23 +
225.24 +;************************************************
225.25 +; plotting parameters
225.26 +;************************************************
225.27 + wks = gsn_open_wks ("png","xy") ; open workstation
225.28 +
225.29 + res = True ; plot mods desired
225.30 +;res@tiMainString = "Observed 81 sites" ; add title
225.31 + res@tiMainString = "Observed 933 sites" ; add title
225.32 + res@xyMarkLineModes = "Markers" ; choose which have markers
225.33 + res@xyMarkers = 16 ; choose type of marker
225.34 + res@xyMarkerColor = "red" ; Marker color
225.35 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
225.36 +
225.37 + res@tmLabelAutoStride = True ; nice tick mark labels
225.38 +
225.39 +;plot = gsn_csm_xy (wks,t&nvalues,t(:),res) ; create plot
225.40 + plot = gsn_csm_xy (wks,x,y,res) ; create plot
225.41 +
225.42 +;************************************************
225.43 +; now create our own markers using NhlNewMarker
225.44 +; available since ncl version 4.2.0.a030
225.45 +;************************************************
225.46 +; this example will create filled squares. You will have to play with
225.47 +; the numbers a but to get the size and shape you desire. On the
225.48 +; documentation page for NhlNewMarker, there is a table of values for
225.49 +; the current marker set, to give you an idea of where to start.
225.50 +
225.51 +; res@xyMarkerColor = "blue"
225.52 +; res@tiMainString = "Make your own marker"
225.53 +; res@xyMarkers = NhlNewMarker(wks, "^", 19, 0.0, 0.0, 1.3125, 1.5, 0.0)
225.54 +; plot = gsn_csm_xy (wks,x,y,res)
225.55 +
225.56 +end
226.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
226.2 +++ b/npp/12.scatter.linint2_points.ncl Mon Jan 26 22:08:20 2009 -0500
226.3 @@ -0,0 +1,76 @@
226.4 +; ***********************************************
226.5 +; xy_4.ncl
226.6 +; ***********************************************
226.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
226.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
226.9 +;************************************************
226.10 +begin
226.11 +;************************************************
226.12 +; read in data
226.13 +;************************************************
226.14 + g = addfile ("data.81.nc","r")
226.15 +;g = addfile ("data.933.nc","r")
226.16 + a = g->SITE_ID ; get ob data
226.17 + xo = g->LONG_DD ; get ob data
226.18 + yo = g->LAT_DD ; get ob data
226.19 +
226.20 + print (xo)
226.21 + nx = dimsizes(xo)
226.22 + do i= 0,nx-1
226.23 + if (xo(i) .lt. 0.) then
226.24 + xo(i) = xo(i)+ 360.
226.25 + end if
226.26 + end do
226.27 + print (xo)
226.28 +
226.29 + a@long_name = "SITE_ID"
226.30 +
226.31 +;f = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
226.32 + f = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
226.33 + b = f->NPP ; get model data
226.34 + xi = f->lon ; get model data
226.35 + yi = f->lat ; get model data
226.36 +
226.37 + sec_to_year = 86400.*365.
226.38 +
226.39 + bo = linint2_points(xi,yi,b,True,xo,yo,0) * sec_to_year
226.40 + print (bo)
226.41 +
226.42 + bo@long_name = "NPP (gC/m2/year)"
226.43 +
226.44 +;************************************************
226.45 +; plotting parameters
226.46 +;************************************************
226.47 +;wks = gsn_open_wks ("ps","xy") ; open workstation
226.48 + wks = gsn_open_wks ("png","xy")
226.49 +
226.50 + res = True ; plot mods desired
226.51 +;res@tiMainString = "Model i01.03cn 81 sites" ; add title
226.52 +;res@tiMainString = "Model i01.03cn 933 sites" ; add title
226.53 + res@tiMainString = "Model i01.04casa 81 sites" ; add title
226.54 +;res@tiMainString = "Model i01.04casa 933 sites" ; add title
226.55 + res@xyMarkLineModes = "Markers" ; choose which have markers
226.56 + res@xyMarkers = 16 ; choose type of marker
226.57 + res@xyMarkerColor = "red" ; Marker color
226.58 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
226.59 +
226.60 + res@tmLabelAutoStride = True ; nice tick mark labels
226.61 +
226.62 +;plot = gsn_csm_xy (wks,t&nvalues,t(:),res) ; create plot
226.63 + plot = gsn_csm_xy (wks,a,bo,res) ; create plot
226.64 +
226.65 +;************************************************
226.66 +; now create our own markers using NhlNewMarker
226.67 +; available since ncl version 4.2.0.a030
226.68 +;************************************************
226.69 +; this example will create filled squares. You will have to play with
226.70 +; the numbers a but to get the size and shape you desire. On the
226.71 +; documentation page for NhlNewMarker, there is a table of values for
226.72 +; the current marker set, to give you an idea of where to start.
226.73 +
226.74 +; res@xyMarkerColor = "blue"
226.75 +; res@tiMainString = "Make your own marker"
226.76 +; res@xyMarkers = NhlNewMarker(wks, "^", 19, 0.0, 0.0, 1.3125, 1.5, 0.0)
226.77 +; plot = gsn_csm_xy (wks,a,bo,res)
226.78 +
226.79 +end
227.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
227.2 +++ b/npp/13.scatter.model-ob.ncl Mon Jan 26 22:08:20 2009 -0500
227.3 @@ -0,0 +1,87 @@
227.4 +; ***********************************************
227.5 +; xy_4.ncl
227.6 +; ***********************************************
227.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
227.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
227.9 +;************************************************
227.10 +begin
227.11 +;************************************************
227.12 +; read in data: observed
227.13 +;************************************************
227.14 +;g = addfile ("data.81.nc","r")
227.15 + g = addfile ("data.933.nc","r")
227.16 + a = g->TNPP_C
227.17 +;a = g->ANPP_C
227.18 +;a = g->BNPP_C
227.19 + xo = g->LONG_DD
227.20 + yo = g->LAT_DD
227.21 +
227.22 + a@long_name = "TNPP_C (gC/m2/year)"
227.23 +;a@long_name = "ANPP_C (gC/m2/year)"
227.24 +;a@long_name = "BNPP_C (gC/m2/year)"
227.25 +
227.26 +;print (xo)
227.27 + nx = dimsizes(xo)
227.28 + do i= 0,nx-1
227.29 + if (xo(i) .lt. 0.) then
227.30 + xo(i) = xo(i)+ 360.
227.31 + end if
227.32 + end do
227.33 +;print (xo)
227.34 +
227.35 +;************************************************
227.36 +; read in data: model
227.37 +;************************************************
227.38 + f = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
227.39 +;f = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
227.40 +
227.41 + b = f->NPP
227.42 +;b = f->AGNPP
227.43 +;b = f->BGNPP
227.44 + xi = f->lon
227.45 + yi = f->lat
227.46 +
227.47 + sec_to_year = 86400.*365.
227.48 +
227.49 + bo = linint2_points(xi,yi,b,True,xo,yo,0) * sec_to_year
227.50 +;print (bo)
227.51 +
227.52 + bo@long_name = "NPP (gC/m2/year)"
227.53 +;bo@long_name = "AGNPP (gC/m2/year)"
227.54 +;bo@long_name = "BGNPP (gC/m2/year)"
227.55 +
227.56 +;************************************************
227.57 +; plotting parameters
227.58 +;************************************************
227.59 +;wks = gsn_open_wks ("ps","xy") ; open workstation
227.60 + wks = gsn_open_wks ("png","xy")
227.61 +
227.62 + res = True ; plot mods desired
227.63 +;res@tiMainString = "Model_i01.03cn vs Observed 81" ; add title
227.64 + res@tiMainString = "Model_i01.03cn vs Observed 933" ; add title
227.65 +;res@tiMainString = "Model_i01.04casa vs Observed 81" ; add title
227.66 +;res@tiMainString = "Model_i01.04casa vs Observed 933" ; add title
227.67 + res@xyMarkLineModes = "Markers" ; choose which have markers
227.68 + res@xyMarkers = 16 ; choose type of marker
227.69 + res@xyMarkerColor = "red" ; Marker color
227.70 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
227.71 +
227.72 + res@tmLabelAutoStride = True ; nice tick mark labels
227.73 +
227.74 + plot = gsn_csm_xy (wks,a,bo,res) ; create plot
227.75 +
227.76 +;************************************************
227.77 +; now create our own markers using NhlNewMarker
227.78 +; available since ncl version 4.2.0.a030
227.79 +;************************************************
227.80 +; this example will create filled squares. You will have to play with
227.81 +; the numbers a but to get the size and shape you desire. On the
227.82 +; documentation page for NhlNewMarker, there is a table of values for
227.83 +; the current marker set, to give you an idea of where to start.
227.84 +
227.85 +; res@xyMarkerColor = "blue"
227.86 +; res@tiMainString = "Make your own marker"
227.87 +; res@xyMarkers = NhlNewMarker(wks, "^", 19, 0.0, 0.0, 1.3125, 1.5, 0.0)
227.88 +; plot = gsn_csm_xy (wks,a,bo,res)
227.89 +
227.90 +end
228.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
228.2 +++ b/npp/14.scatter_bias.ncl Mon Jan 26 22:08:20 2009 -0500
228.3 @@ -0,0 +1,57 @@
228.4 +; ***********************************************
228.5 +; xy_4.ncl
228.6 +; ***********************************************
228.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
228.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
228.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
228.10 +;************************************************
228.11 +begin
228.12 +;************************************************
228.13 +; read in data
228.14 +;************************************************
228.15 + g = addfile ("data.81.nc","r")
228.16 +;g = addfile ("data.933.nc","r")
228.17 + c = g->TNPP_C
228.18 +;c = g->ANPP_C
228.19 +;c = g->BNPP_C
228.20 + xo = g->LONG_DD
228.21 + yo = g->LAT_DD
228.22 +
228.23 +;print (c)
228.24 +
228.25 + nx = dimsizes(xo)
228.26 + do i= 0,nx-1
228.27 + if (xo(i) .lt. 0.) then
228.28 + xo(i) = xo(i)+ 360.
228.29 + end if
228.30 + end do
228.31 +;print (xo)
228.32 +
228.33 + f = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
228.34 +;f = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
228.35 + b = f->NPP
228.36 +;b = f->AGNPP
228.37 +;b = f->BGNPP
228.38 + xi = f->lon
228.39 + yi = f->lat
228.40 +
228.41 + sec_to_year = 86400.*365.
228.42 +
228.43 + bo = linint2_points(xi,yi,b,True,xo,yo,0) * sec_to_year
228.44 +;print (bo)
228.45 +
228.46 + ccr = esccr(bo,c,0)
228.47 + print (ccr)
228.48 +
228.49 +;old eq
228.50 +;bias = sum(((bo(0,:)-c(:))/c(:))^2)
228.51 +;M = (1. - sqrt(bias/nx))*5.
228.52 +
228.53 +;new eq
228.54 + bias = sum(abs(bo(0,:)-c(:))/(bo(0,:)+c(:)))
228.55 + M = (1. - (bias/nx))*5.
228.56 +
228.57 + print (bias)
228.58 + print (M)
228.59 +
228.60 +end
229.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
229.2 +++ b/npp/15.scatter_bias.ncl Mon Jan 26 22:08:20 2009 -0500
229.3 @@ -0,0 +1,285 @@
229.4 +; ***********************************************
229.5 +; combine all scatter
229.6 +; ***********************************************
229.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
229.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
229.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
229.10 +;************************************************
229.11 +begin
229.12 +
229.13 + plot_type = "ps"
229.14 + plot_type_new = "png"
229.15 +
229.16 +;************************************************
229.17 +; read in ob data
229.18 +;************************************************
229.19 +
229.20 +;(A) plot ob scatter_81
229.21 +
229.22 + dir81 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
229.23 + fil81 = "data.81.nc"
229.24 + f81 = addfile (dir81+fil81,"r")
229.25 +
229.26 + x81 = f81->SITE_ID
229.27 + y81 = f81->TNPP_C
229.28 + xo81 = f81->LONG_DD
229.29 + yo81 = f81->LAT_DD
229.30 +
229.31 + x81@long_name = "SITE_ID"
229.32 + y81@long_name = "NPP (gC/m2/year)"
229.33 +
229.34 + plot_name = "scatter_ob_81"
229.35 + title = "Observed 81 sites"
229.36 +
229.37 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
229.38 + res = True ; plot mods desired
229.39 + res@tiMainString = title ; add title
229.40 + res@xyMarkLineModes = "Markers" ; choose which have markers
229.41 + res@xyMarkers = 16 ; choose type of marker
229.42 + res@xyMarkerColor = "red" ; Marker color
229.43 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
229.44 + res@tmLabelAutoStride = True ; nice tick mark labels
229.45 +
229.46 + plot = gsn_csm_xy (wks,x81,y81,res) ; create plot
229.47 + frame(wks)
229.48 +
229.49 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
229.50 + system("rm "+plot_name+"."+plot_type)
229.51 + system("rm "+plot_name+"-1."+plot_type_new)
229.52 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
229.53 +
229.54 + clear (wks)
229.55 +
229.56 +;(B) plot ob scatter_933
229.57 +
229.58 + dir933 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
229.59 + fil933 = "data.933.nc"
229.60 + f933 = addfile (dir933+fil933,"r")
229.61 +
229.62 + x933 = f933->SITE_ID
229.63 + y933 = f933->TNPP_C
229.64 + xo933 = f933->LONG_DD
229.65 + yo933 = f933->LAT_DD
229.66 +
229.67 + x933@long_name = "SITE_ID"
229.68 + y933@long_name = "NPP (gC/m2/year)"
229.69 +
229.70 + plot_name = "scatter_ob_933"
229.71 + title = "Observed 933 sites"
229.72 +
229.73 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
229.74 + res = True ; plot mods desired
229.75 + res@tiMainString = title ; add title
229.76 + res@xyMarkLineModes = "Markers" ; choose which have markers
229.77 + res@xyMarkers = 16 ; choose type of marker
229.78 + res@xyMarkerColor = "red" ; Marker color
229.79 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
229.80 + res@tmLabelAutoStride = True ; nice tick mark labels
229.81 +
229.82 + plot = gsn_csm_xy (wks,x933,y933,res) ; create plot
229.83 + frame(wks)
229.84 +
229.85 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
229.86 + system("rm "+plot_name+"."+plot_type)
229.87 + system("rm "+plot_name+"-1."+plot_type_new)
229.88 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
229.89 +
229.90 + clear (wks)
229.91 +;************************************************
229.92 +; read in model data
229.93 +;************************************************
229.94 +
229.95 +;(C) plot model scatter_81
229.96 +
229.97 + model_name = "b30.061n"
229.98 +
229.99 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
229.100 + film = "b30.061n_1995-2004_ANN_climo_lnd.nc"
229.101 + fm = addfile (dirm+film,"r")
229.102 +
229.103 + ymod = fm->NPP
229.104 + xm = fm->lon
229.105 + ym = fm->lat
229.106 +
229.107 + nx = dimsizes(xo81)
229.108 + do i= 0,nx-1
229.109 + if (xo81(i) .lt. 0.) then
229.110 + xo81(i) = xo81(i)+ 360.
229.111 + end if
229.112 + end do
229.113 + print (xo81)
229.114 +
229.115 + sec_to_year = 86400.*365.
229.116 +
229.117 + ymod81 = linint2_points(xm,ym,ymod(0,:,:),True,xo81,yo81,0) * sec_to_year
229.118 + xmod81 = x81
229.119 +
229.120 + ymod81@long_name = "NPP (gC/m2/year)"
229.121 + xmod81@long_name = "SITE_ID"
229.122 +print (ymod81)
229.123 +print (xmod81)
229.124 +
229.125 + plot_name = "scatter_model_81"
229.126 + title = "Model "+ model_name +" 81 sites"
229.127 +
229.128 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
229.129 + res = True ; plot mods desired
229.130 + res@tiMainString = title ; add title
229.131 + res@xyMarkLineModes = "Markers" ; choose which have markers
229.132 + res@xyMarkers = 16 ; choose type of marker
229.133 + res@xyMarkerColor = "red" ; Marker color
229.134 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
229.135 + res@tmLabelAutoStride = True ; nice tick mark labels
229.136 +
229.137 + plot = gsn_csm_xy (wks,xmod81,ymod81,res) ; create plot
229.138 + frame(wks)
229.139 +
229.140 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
229.141 + system("rm "+plot_name+"."+plot_type)
229.142 + system("rm "+plot_name+"-1."+plot_type_new)
229.143 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
229.144 +
229.145 + clear (wks)
229.146 +
229.147 +;(D) plot model scatter_933
229.148 +
229.149 + model_name = "b30.061n"
229.150 +
229.151 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
229.152 + film = "b30.061n_1995-2004_ANN_climo_lnd.nc"
229.153 + fm = addfile (dirm+film,"r")
229.154 +
229.155 + ymod = fm->NPP
229.156 + xm = fm->lon
229.157 + ym = fm->lat
229.158 +
229.159 + nx = dimsizes(xo933)
229.160 + do i= 0,nx-1
229.161 + if (xo933(i) .lt. 0.) then
229.162 + xo933(i) = xo933(i)+ 360.
229.163 + end if
229.164 + end do
229.165 + print (xo933)
229.166 +
229.167 + sec_to_year = 86400.*365.
229.168 +
229.169 + ymod933 = linint2_points(xm,ym,ymod(0,:,:),True,xo933,yo933,0) * sec_to_year
229.170 + xmod933 = x933
229.171 +
229.172 + ymod933@long_name = "NPP (gC/m2/year)"
229.173 + xmod933@long_name = "SITE_ID"
229.174 +;print (ymod933)
229.175 +;print (xmod933)
229.176 +
229.177 + plot_name = "scatter_model_933"
229.178 + title = "Model "+ model_name +" 933 sites"
229.179 +
229.180 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
229.181 + res = True ; plot mods desired
229.182 + res@tiMainString = title ; add title
229.183 + res@xyMarkLineModes = "Markers" ; choose which have markers
229.184 + res@xyMarkers = 16 ; choose type of marker
229.185 + res@xyMarkerColor = "red" ; Marker color
229.186 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
229.187 + res@tmLabelAutoStride = True ; nice tick mark labels
229.188 +
229.189 + plot = gsn_csm_xy (wks,xmod933,ymod933,res) ; create plot
229.190 + frame(wks)
229.191 +
229.192 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
229.193 + system("rm "+plot_name+"."+plot_type)
229.194 + system("rm "+plot_name+"-1."+plot_type_new)
229.195 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
229.196 +
229.197 + clear (wks)
229.198 +
229.199 +;(E) scatter model vs ob 81
229.200 +
229.201 + ymod81@long_name = "NPP (gC/m2/year)"
229.202 + y81@long_name = "NPP (gC/m2/year)"
229.203 +;print (ymod81)
229.204 +;print (y81)
229.205 +
229.206 + plot_name = "scatter_model_vs_ob_81"
229.207 + title = model_name +" vs ob 81 sites"
229.208 +
229.209 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
229.210 + res = True ; plot mods desired
229.211 + res@tiMainString = title ; add title
229.212 + res@xyMarkLineModes = "Markers" ; choose which have markers
229.213 + res@xyMarkers = 16 ; choose type of marker
229.214 + res@xyMarkerColor = "red" ; Marker color
229.215 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
229.216 + res@tmLabelAutoStride = True ; nice tick mark labels
229.217 +;-------------------------------
229.218 +;compute correlation coef. and M
229.219 + ccr81 = esccr(ymod81,y81,0)
229.220 + print (ccr81)
229.221 +
229.222 +;new eq
229.223 + bias = sum(abs(ymod81-y81)/(ymod81+y81))
229.224 + M81 = (1. - (bias/dimsizes(y81)))*5.
229.225 + print (M81)
229.226 +
229.227 + tRes = True
229.228 + tRes@txFontHeightF = 0.025
229.229 +
229.230 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81)+")"
229.231 +
229.232 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
229.233 +;--------------------------------
229.234 + plot = gsn_csm_xy (wks,y81,ymod81,res) ; create plot
229.235 + frame(wks)
229.236 +
229.237 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
229.238 + system("rm "+plot_name+"."+plot_type)
229.239 + system("rm "+plot_name+"-1."+plot_type_new)
229.240 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
229.241 +
229.242 + clear (wks)
229.243 +
229.244 +;(F) scatter model vs ob 933
229.245 +
229.246 + ymod933@long_name = "NPP (gC/m2/year)"
229.247 + y933@long_name = "NPP (gC/m2/year)"
229.248 +;print (ymod33)
229.249 +;print (y933)
229.250 +
229.251 + plot_name = "scatter_model_vs_ob_933"
229.252 + title = model_name +" vs ob 933 sites"
229.253 +
229.254 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
229.255 + res = True ; plot mods desired
229.256 + res@tiMainString = title ; add title
229.257 + res@xyMarkLineModes = "Markers" ; choose which have markers
229.258 + res@xyMarkers = 16 ; choose type of marker
229.259 + res@xyMarkerColor = "red" ; Marker color
229.260 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
229.261 + res@tmLabelAutoStride = True ; nice tick mark labels
229.262 +;-------------------------------
229.263 +;compute correlation coef. and M
229.264 + ccr933 = esccr(ymod933,y933,0)
229.265 + print (ccr933)
229.266 +
229.267 +;new eq
229.268 + bias = sum(abs(ymod933-y933)/(ymod933+y933))
229.269 + M933 = (1. - (bias/dimsizes(y933)))*5.
229.270 + print (M933)
229.271 +
229.272 + tRes = True
229.273 + tRes@txFontHeightF = 0.025
229.274 +
229.275 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933)+")"
229.276 +
229.277 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
229.278 +;--------------------------------
229.279 + plot = gsn_csm_xy (wks,y933,ymod933,res) ; create plot
229.280 + frame(wks)
229.281 +
229.282 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
229.283 + system("rm "+plot_name+"."+plot_type)
229.284 + system("rm "+plot_name+"-1."+plot_type_new)
229.285 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
229.286 +
229.287 + clear (wks)
229.288 +end
230.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
230.2 +++ b/npp/16.scatter_bias.ncl Mon Jan 26 22:08:20 2009 -0500
230.3 @@ -0,0 +1,840 @@
230.4 +; ***********************************************
230.5 +; combine all scatter
230.6 +; ***********************************************
230.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
230.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
230.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
230.10 +;************************************************
230.11 +procedure pminmax(data:numeric,name:string)
230.12 +begin
230.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
230.14 + if(isatt(data,"units")) then
230.15 + print (name + " units = " + data@units)
230.16 + end if
230.17 +end
230.18 +
230.19 +; Main code.
230.20 +begin
230.21 +
230.22 + plot_type = "ps"
230.23 + plot_type_new = "png"
230.24 +
230.25 +;************************************************
230.26 +; read in ob data
230.27 +;************************************************
230.28 + dir81 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
230.29 + fil81 = "data.81.nc"
230.30 + f81 = addfile (dir81+fil81,"r")
230.31 +
230.32 + id81 = f81->SITE_ID
230.33 + npp81 = f81->TNPP_C
230.34 + rain81 = tofloat(f81->PREC_ANN)
230.35 + x81 = f81->LONG_DD
230.36 + y81 = f81->LAT_DD
230.37 +
230.38 + id81@long_name = "SITE_ID"
230.39 + npp81@long_name = "NPP (gC/m2/year)"
230.40 +
230.41 +;change longitude from (-180,180) to (0,360)
230.42 +;for model data interpolation
230.43 +
230.44 + do i= 0,dimsizes(x81)-1
230.45 + if (x81(i) .lt. 0.) then
230.46 + x81(i) = x81(i)+ 360.
230.47 + end if
230.48 + end do
230.49 +;print (x81)
230.50 +;-------------------------------------
230.51 + dir933 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
230.52 + fil933 = "data.933.nc"
230.53 + f933 = addfile (dir933+fil933,"r")
230.54 +
230.55 + id933 = f933->SITE_ID
230.56 + npp933 = f933->TNPP_C
230.57 + rain933 = f933->PREC
230.58 + x933 = f933->LONG_DD
230.59 + y933 = f933->LAT_DD
230.60 +
230.61 + id933@long_name = "SITE_ID"
230.62 + npp933@long_name = "NPP (gC/m2/year)"
230.63 +
230.64 +;change longitude from (-180,180) to (0,360)
230.65 +;for model data interpolation
230.66 +
230.67 + do i= 0,dimsizes(x933)-1
230.68 + if (x933(i) .lt. 0.) then
230.69 + x933(i) = x933(i)+ 360.
230.70 + end if
230.71 + end do
230.72 +;print (x933)
230.73 +;************************************************
230.74 +; read in model data
230.75 +;************************************************
230.76 + model_name = "b30.061n"
230.77 +
230.78 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
230.79 + film = "b30.061n_1995-2004_ANN_climo_lnd.nc"
230.80 + fm = addfile (dirm+film,"r")
230.81 +
230.82 + nppmod = fm->NPP
230.83 + rainmod = fm->RAIN
230.84 + xm = fm->lon
230.85 + ym = fm->lat
230.86 +
230.87 + nppmod81 =linint2_points(xm,ym,nppmod(0,:,:),True,x81,y81,0)
230.88 +
230.89 + nppmod933 =linint2_points(xm,ym,nppmod(0,:,:),True,x933,y933,0)
230.90 +
230.91 + rainmod81 =linint2_points(xm,ym,rainmod(0,:,:),True,x81,y81,0)
230.92 +
230.93 + rainmod933=linint2_points(xm,ym,rainmod(0,:,:),True,x933,y933,0)
230.94 +
230.95 +;************************************************
230.96 +; Units for these four variables are:
230.97 +;
230.98 +; rain81 : mm/year
230.99 +; rainmod : mm/s
230.100 +; npp81 : g C/m^2/year
230.101 +; nppmod81: g C/m^2/s
230.102 +;
230.103 +; We want to convert these to "m/year" and "g C/m^2/year".
230.104 +;
230.105 + nsec_per_year = 60*60*24*365
230.106 +
230.107 + rain81 = rain81 / 1000.
230.108 + rainmod81 = (rainmod81/ 1000.) * nsec_per_year
230.109 + nppmod81 = nppmod81 * nsec_per_year
230.110 +
230.111 + rain933 = rain933 / 1000.
230.112 + rainmod933 = (rainmod933/ 1000.) * nsec_per_year
230.113 + nppmod933 = nppmod933 * nsec_per_year
230.114 +
230.115 + npp81@units = "gC/m^2/yr"
230.116 + nppmod81@units = "gC/m^2/yr"
230.117 + npp933@units = "gC/m^2/yr"
230.118 + nppmod933@units = "gC/m^2/yr"
230.119 + rain81@units = "m/yr"
230.120 + rainmod81@units = "m/yr"
230.121 + rain933@units = "m/yr"
230.122 + rainmod933@units = "m/yr"
230.123 +
230.124 + npp81@long_name = "NPP (gC/m2/year)"
230.125 + npp933@long_name = "NPP (gC/m2/year)"
230.126 + nppmod81@long_name = "NPP (gC/m2/year)"
230.127 + nppmod933@long_name = "NPP (gC/m2/year)"
230.128 + rain81@long_name = "PREC (m/year)"
230.129 + rain933@long_name = "PREC (m/year)"
230.130 + rainmod81@long_name = "PREC (m/year)"
230.131 + rainmod933@long_name = "PREC (m/year)"
230.132 +
230.133 +;(A) plot scatter ob 81
230.134 +
230.135 + plot_name = "scatter_ob_81"
230.136 + title = "Observed 81 sites"
230.137 +
230.138 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
230.139 + res = True ; plot mods desired
230.140 + res@tiMainString = title ; add title
230.141 + res@xyMarkLineModes = "Markers" ; choose which have markers
230.142 + res@xyMarkers = 16 ; choose type of marker
230.143 + res@xyMarkerColor = "red" ; Marker color
230.144 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
230.145 + res@tmLabelAutoStride = True ; nice tick mark labels
230.146 +
230.147 + plot = gsn_csm_xy (wks,id81,npp81,res) ; create plot
230.148 + frame(wks)
230.149 +
230.150 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
230.151 + system("rm "+plot_name+"."+plot_type)
230.152 + system("rm "+plot_name+"-1."+plot_type_new)
230.153 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
230.154 +
230.155 + clear (wks)
230.156 +
230.157 +;(B) plot scatter ob 933
230.158 +
230.159 + plot_name = "scatter_ob_933"
230.160 + title = "Observed 933 sites"
230.161 +
230.162 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
230.163 + res = True ; plot mods desired
230.164 + res@tiMainString = title ; add title
230.165 + res@xyMarkLineModes = "Markers" ; choose which have markers
230.166 + res@xyMarkers = 16 ; choose type of marker
230.167 + res@xyMarkerColor = "red" ; Marker color
230.168 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
230.169 + res@tmLabelAutoStride = True ; nice tick mark labels
230.170 +
230.171 + plot = gsn_csm_xy (wks,id933,npp933,res) ; create plot
230.172 + frame(wks)
230.173 +
230.174 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
230.175 + system("rm "+plot_name+"."+plot_type)
230.176 + system("rm "+plot_name+"-1."+plot_type_new)
230.177 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
230.178 +
230.179 + clear (wks)
230.180 +
230.181 +;(C) plot scatter model 81
230.182 +
230.183 + plot_name = "scatter_model_81"
230.184 + title = "Model "+ model_name +" 81 sites"
230.185 +
230.186 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
230.187 + res = True ; plot mods desired
230.188 + res@tiMainString = title ; add title
230.189 + res@xyMarkLineModes = "Markers" ; choose which have markers
230.190 + res@xyMarkers = 16 ; choose type of marker
230.191 + res@xyMarkerColor = "red" ; Marker color
230.192 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
230.193 + res@tmLabelAutoStride = True ; nice tick mark labels
230.194 +
230.195 + plot = gsn_csm_xy (wks,id81,nppmod81,res) ; create plot
230.196 + frame(wks)
230.197 +
230.198 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
230.199 + system("rm "+plot_name+"."+plot_type)
230.200 + system("rm "+plot_name+"-1."+plot_type_new)
230.201 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
230.202 +
230.203 + clear (wks)
230.204 +
230.205 +;(D) plot scatter model 933
230.206 +
230.207 + plot_name = "scatter_model_933"
230.208 + title = "Model "+ model_name +" 933 sites"
230.209 +
230.210 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
230.211 + res = True ; plot mods desired
230.212 + res@tiMainString = title ; add title
230.213 + res@xyMarkLineModes = "Markers" ; choose which have markers
230.214 + res@xyMarkers = 16 ; choose type of marker
230.215 + res@xyMarkerColor = "red" ; Marker color
230.216 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
230.217 + res@tmLabelAutoStride = True ; nice tick mark labels
230.218 +
230.219 + plot = gsn_csm_xy (wks,id933,nppmod933,res) ; create plot
230.220 + frame(wks)
230.221 +
230.222 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
230.223 + system("rm "+plot_name+"."+plot_type)
230.224 + system("rm "+plot_name+"-1."+plot_type_new)
230.225 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
230.226 +
230.227 + clear (wks)
230.228 +
230.229 +;(E) scatter model vs ob 81
230.230 +
230.231 + plot_name = "scatter_model_vs_ob_81"
230.232 + title = model_name +" vs ob 81 sites"
230.233 +
230.234 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
230.235 + res = True ; plot mods desired
230.236 + res@tiMainString = title ; add title
230.237 + res@xyMarkLineModes = "Markers" ; choose which have markers
230.238 + res@xyMarkers = 16 ; choose type of marker
230.239 + res@xyMarkerColor = "red" ; Marker color
230.240 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
230.241 + res@tmLabelAutoStride = True ; nice tick mark labels
230.242 +;-------------------------------
230.243 +;compute correlation coef. and M
230.244 + ccr81 = esccr(nppmod81,npp81,0)
230.245 + print (ccr81)
230.246 +
230.247 +;new eq
230.248 + bias = sum(abs(nppmod81-npp81)/(nppmod81+npp81))
230.249 + M81 = (1. - (bias/dimsizes(y81)))*5.
230.250 + print (M81)
230.251 +
230.252 + tRes = True
230.253 + tRes@txFontHeightF = 0.025
230.254 +
230.255 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81)+")"
230.256 +
230.257 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
230.258 +;--------------------------------
230.259 + plot = gsn_csm_xy (wks,npp81,nppmod81,res) ; create plot
230.260 + frame(wks)
230.261 +
230.262 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
230.263 + system("rm "+plot_name+"."+plot_type)
230.264 + system("rm "+plot_name+"-1."+plot_type_new)
230.265 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
230.266 +
230.267 + clear (wks)
230.268 +
230.269 +;(F) scatter model vs ob 933
230.270 +
230.271 + plot_name = "scatter_model_vs_ob_933"
230.272 + title = model_name +" vs ob 933 sites"
230.273 +
230.274 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
230.275 + res = True ; plot mods desired
230.276 + res@tiMainString = title ; add title
230.277 + res@xyMarkLineModes = "Markers" ; choose which have markers
230.278 + res@xyMarkers = 16 ; choose type of marker
230.279 + res@xyMarkerColor = "red" ; Marker color
230.280 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
230.281 + res@tmLabelAutoStride = True ; nice tick mark labels
230.282 +;-------------------------------
230.283 +;compute correlation coef. and M
230.284 + ccr933 = esccr(nppmod933,npp933,0)
230.285 + print (ccr933)
230.286 +
230.287 +;new eq
230.288 + bias = sum(abs(nppmod933-npp933)/(nppmod933+npp933))
230.289 + M933 = (1. - (bias/dimsizes(y933)))*5.
230.290 + print (M933)
230.291 +
230.292 + tRes = True
230.293 + tRes@txFontHeightF = 0.025
230.294 +
230.295 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933)+")"
230.296 +
230.297 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
230.298 +;--------------------------------
230.299 + plot = gsn_csm_xy (wks,npp933,nppmod933,res) ; create plot
230.300 + frame(wks)
230.301 +
230.302 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
230.303 + system("rm "+plot_name+"."+plot_type)
230.304 + system("rm "+plot_name+"-1."+plot_type_new)
230.305 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
230.306 +
230.307 + clear (wks)
230.308 +;**************************************************************************
230.309 +;(G) histogram 81
230.310 +
230.311 +;--------------------------------------------------------------------
230.312 +;get data
230.313 +
230.314 + RAIN1_1D = ndtooned(rain81)
230.315 + RAIN2_1D = ndtooned(rainmod81)
230.316 + NPP1_1D = ndtooned(npp81)
230.317 + NPP2_1D = ndtooned(nppmod81)
230.318 +;
230.319 +; Calculate some "nice" bins for binning the data in equally spaced
230.320 +; ranges.
230.321 +;
230.322 + nbins = 15 ; Number of bins to use.
230.323 +
230.324 + nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
230.325 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
230.326 + range = fspan(nicevals(0),nicevals(1),nvals)
230.327 +;
230.328 +; Use this range information to grab all the values in a
230.329 +; particular range, and then take an average.
230.330 +;
230.331 + nr = dimsizes(range)
230.332 + nx = nr-1
230.333 + xvalues = new((/2,nx/),typeof(RAIN1_1D))
230.334 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
230.335 + dx = xvalues(0,1) - xvalues(0,0) ; range width
230.336 + dx4 = dx/4 ; 1/4 of the range
230.337 + xvalues(1,:) = xvalues(0,:) - dx/5.
230.338 + yvalues = new((/2,nx/),typeof(RAIN1_1D))
230.339 + mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
230.340 + mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
230.341 +
230.342 + do nd=0,1
230.343 +;
230.344 +; See if we are doing model or observational data.
230.345 +;
230.346 + if(nd.eq.0) then
230.347 + data = RAIN1_1D
230.348 + npp_data = NPP1_1D
230.349 + else
230.350 + data = RAIN2_1D
230.351 + npp_data = NPP2_1D
230.352 + end if
230.353 +;
230.354 +; Loop through each range and check for values.
230.355 +;
230.356 + do i=0,nr-2
230.357 + if (i.ne.(nr-2)) then
230.358 +; print("")
230.359 +; print("In range ["+range(i)+","+range(i+1)+")")
230.360 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
230.361 + else
230.362 +; print("")
230.363 +; print("In range ["+range(i)+",)")
230.364 + idx = ind(range(i).le.data)
230.365 + end if
230.366 +;
230.367 +; Calculate average, and get min and max.
230.368 +;
230.369 + if(.not.any(ismissing(idx))) then
230.370 + yvalues(nd,i) = avg(npp_data(idx))
230.371 + mn_yvalues(nd,i) = min(npp_data(idx))
230.372 + mx_yvalues(nd,i) = max(npp_data(idx))
230.373 + count = dimsizes(idx)
230.374 + else
230.375 + count = 0
230.376 + yvalues(nd,i) = yvalues@_FillValue
230.377 + mn_yvalues(nd,i) = yvalues@_FillValue
230.378 + mx_yvalues(nd,i) = yvalues@_FillValue
230.379 + end if
230.380 +;
230.381 +; Print out information.
230.382 +;
230.383 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
230.384 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
230.385 +
230.386 +;
230.387 +; Clean up for next time in loop.
230.388 +;
230.389 + delete(idx)
230.390 + end do
230.391 + delete(data)
230.392 + delete(npp_data)
230.393 + end do
230.394 +;----------------------------------------
230.395 +;compute correlation coeff and M score
230.396 + u = yvalues(0,:)
230.397 + v = yvalues(1,:)
230.398 +
230.399 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
230.400 + uu = u(good)
230.401 + vv = v(good)
230.402 +
230.403 + ccr81h = esccr(uu,vv,0)
230.404 + print (ccr81h)
230.405 +
230.406 +;new eq
230.407 + bias = sum(abs(vv-uu)/(vv+uu))
230.408 + M81h = (1.- (bias/dimsizes(uu)))*5.
230.409 + print (M81h)
230.410 +
230.411 + delete (u)
230.412 + delete (v)
230.413 + delete (uu)
230.414 + delete (vv)
230.415 +;----------------------------------------------------------------------
230.416 +; histogram res
230.417 +
230.418 + res = True
230.419 + res@gsnMaximize = True
230.420 + res@gsnDraw = False
230.421 + res@gsnFrame = False
230.422 + res@xyMarkLineMode = "Markers"
230.423 + res@xyMarkerSizeF = 0.014
230.424 + res@xyMarker = 16
230.425 + res@xyMarkerColors = (/"Brown","Blue"/)
230.426 + res@trYMinF = min(mn_yvalues) - 10.
230.427 + res@trYMaxF = max(mx_yvalues) + 10.
230.428 +
230.429 + res@tiYAxisString = "NPP (g C/m2/year)"
230.430 + res@tiXAxisString = "Precipitation (m/year)"
230.431 +
230.432 + max_bar = new((/2,nx/),graphic)
230.433 + min_bar = new((/2,nx/),graphic)
230.434 + max_cap = new((/2,nx/),graphic)
230.435 + min_cap = new((/2,nx/),graphic)
230.436 +
230.437 + lnres = True
230.438 + line_colors = (/"brown","blue"/)
230.439 +;=================================================================
230.440 +; histogram ob 81 site only
230.441 +;
230.442 + plot_name = "histogram_ob_81"
230.443 + title = "Observed 81 site"
230.444 + res@tiMainString = title
230.445 +
230.446 + wks = gsn_open_wks (plot_type,plot_name)
230.447 +
230.448 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),res)
230.449 +
230.450 +;-------------------------------
230.451 +;Attach the vertical bar and the horizontal cap line
230.452 +
230.453 + do nd=0,0
230.454 + lnres@gsLineColor = line_colors(nd)
230.455 + do i=0,nx-1
230.456 +
230.457 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
230.458 + .not.ismissing(mx_yvalues(nd,i))) then
230.459 +;
230.460 +; Attach the vertical bar, both above and below the marker.
230.461 +;
230.462 + x1 = xvalues(nd,i)
230.463 + y1 = yvalues(nd,i)
230.464 + y2 = mn_yvalues(nd,i)
230.465 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
230.466 +
230.467 + y2 = mx_yvalues(nd,i)
230.468 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
230.469 +;
230.470 +; Attach the horizontal cap line, both above and below the marker.
230.471 +;
230.472 + x1 = xvalues(nd,i) - dx4
230.473 + x2 = xvalues(nd,i) + dx4
230.474 + y1 = mn_yvalues(nd,i)
230.475 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
230.476 +
230.477 + y1 = mx_yvalues(nd,i)
230.478 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
230.479 + end if
230.480 + end do
230.481 + end do
230.482 +
230.483 + draw(xy)
230.484 + frame(wks)
230.485 +
230.486 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
230.487 +; system("rm "+plot_name+"."+plot_type)
230.488 +; system("rm "+plot_name+"-1."+plot_type_new)
230.489 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
230.490 +
230.491 + clear (wks)
230.492 +;===========================================================================
230.493 +; histogram model vs ob 81 site
230.494 +
230.495 + plot_name = "histogram_mod-ob_81"
230.496 + title = model_name+ " vs Observed 81 site"
230.497 + res@tiMainString = title
230.498 +
230.499 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
230.500 +
230.501 +;-----------------------------
230.502 +; Add a boxed legend using the more simple method, which won't have
230.503 +; vertical lines going through the markers.
230.504 +
230.505 + res@pmLegendDisplayMode = "Always"
230.506 +; res@pmLegendWidthF = 0.1
230.507 + res@pmLegendWidthF = 0.08
230.508 + res@pmLegendHeightF = 0.05
230.509 + res@pmLegendOrthogonalPosF = -1.17
230.510 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
230.511 +; res@pmLegendParallelPosF = 0.18
230.512 + res@pmLegendParallelPosF = 0.23 ;(rightward)
230.513 +
230.514 +; res@lgPerimOn = False
230.515 + res@lgLabelFontHeightF = 0.015
230.516 + res@xyExplicitLegendLabels = (/"observed",model_name/)
230.517 +;-----------------------------
230.518 + tRes = True
230.519 + tRes@txFontHeightF = 0.025
230.520 +
230.521 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81h)+")"
230.522 +
230.523 + gsn_text_ndc(wks,correlation_text,0.5,0.8,tRes)
230.524 +
230.525 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
230.526 +;-------------------------------
230.527 +;Attach the vertical bar and the horizontal cap line
230.528 +
230.529 + do nd=0,1
230.530 + lnres@gsLineColor = line_colors(nd)
230.531 + do i=0,nx-1
230.532 +
230.533 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
230.534 + .not.ismissing(mx_yvalues(nd,i))) then
230.535 +;
230.536 +; Attach the vertical bar, both above and below the marker.
230.537 +;
230.538 + x1 = xvalues(nd,i)
230.539 + y1 = yvalues(nd,i)
230.540 + y2 = mn_yvalues(nd,i)
230.541 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
230.542 +
230.543 + y2 = mx_yvalues(nd,i)
230.544 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
230.545 +;
230.546 +; Attach the horizontal cap line, both above and below the marker.
230.547 +;
230.548 + x1 = xvalues(nd,i) - dx4
230.549 + x2 = xvalues(nd,i) + dx4
230.550 + y1 = mn_yvalues(nd,i)
230.551 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
230.552 +
230.553 + y1 = mx_yvalues(nd,i)
230.554 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
230.555 + end if
230.556 + end do
230.557 + end do
230.558 + draw(xy)
230.559 + frame(wks)
230.560 +
230.561 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
230.562 +;system("rm "+plot_name+"."+plot_type)
230.563 +;system("rm "+plot_name+"-1."+plot_type_new)
230.564 +;system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
230.565 +
230.566 + clear (wks)
230.567 +
230.568 + delete (RAIN1_1D)
230.569 + delete (RAIN2_1D)
230.570 + delete (NPP1_1D)
230.571 + delete (NPP2_1D)
230.572 + delete (range)
230.573 + delete (xvalues)
230.574 + delete (yvalues)
230.575 + delete (mn_yvalues)
230.576 + delete (mx_yvalues)
230.577 + delete (good)
230.578 + delete (max_bar)
230.579 + delete (min_bar)
230.580 + delete (max_cap)
230.581 + delete (min_cap)
230.582 +;**************************************************************************
230.583 +;(H) histogram 933
230.584 +
230.585 +;--------------------------------------------------------------------
230.586 +;get data
230.587 +
230.588 + RAIN1_1D = ndtooned(rain933)
230.589 + RAIN2_1D = ndtooned(rainmod933)
230.590 + NPP1_1D = ndtooned(npp933)
230.591 + NPP2_1D = ndtooned(nppmod933)
230.592 +;
230.593 +; Calculate some "nice" bins for binning the data in equally spaced
230.594 +; ranges.
230.595 +;
230.596 + nbins = 15 ; Number of bins to use.
230.597 +
230.598 + nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
230.599 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
230.600 + range = fspan(nicevals(0),nicevals(1),nvals)
230.601 +;
230.602 +; Use this range information to grab all the values in a
230.603 +; particular range, and then take an average.
230.604 +;
230.605 + nr = dimsizes(range)
230.606 + nx = nr-1
230.607 + xvalues = new((/2,nx/),typeof(RAIN1_1D))
230.608 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
230.609 + dx = xvalues(0,1) - xvalues(0,0) ; range width
230.610 + dx4 = dx/4 ; 1/4 of the range
230.611 + xvalues(1,:) = xvalues(0,:) - dx/5.
230.612 + yvalues = new((/2,nx/),typeof(RAIN1_1D))
230.613 + mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
230.614 + mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
230.615 +
230.616 + do nd=0,1
230.617 +;
230.618 +; See if we are doing model or observational data.
230.619 +;
230.620 + if(nd.eq.0) then
230.621 + data = RAIN1_1D
230.622 + npp_data = NPP1_1D
230.623 + else
230.624 + data = RAIN2_1D
230.625 + npp_data = NPP2_1D
230.626 + end if
230.627 +;
230.628 +; Loop through each range and check for values.
230.629 +;
230.630 + do i=0,nr-2
230.631 + if (i.ne.(nr-2)) then
230.632 +; print("")
230.633 +; print("In range ["+range(i)+","+range(i+1)+")")
230.634 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
230.635 + else
230.636 +; print("")
230.637 +; print("In range ["+range(i)+",)")
230.638 + idx = ind(range(i).le.data)
230.639 + end if
230.640 +;
230.641 +; Calculate average, and get min and max.
230.642 +;
230.643 + if(.not.any(ismissing(idx))) then
230.644 + yvalues(nd,i) = avg(npp_data(idx))
230.645 + mn_yvalues(nd,i) = min(npp_data(idx))
230.646 + mx_yvalues(nd,i) = max(npp_data(idx))
230.647 + count = dimsizes(idx)
230.648 + else
230.649 + count = 0
230.650 + yvalues(nd,i) = yvalues@_FillValue
230.651 + mn_yvalues(nd,i) = yvalues@_FillValue
230.652 + mx_yvalues(nd,i) = yvalues@_FillValue
230.653 + end if
230.654 +;
230.655 +; Print out information.
230.656 +;
230.657 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
230.658 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
230.659 +
230.660 +;
230.661 +; Clean up for next time in loop.
230.662 +;
230.663 + delete(idx)
230.664 + end do
230.665 + delete(data)
230.666 + delete(npp_data)
230.667 + end do
230.668 +;----------------------------------------
230.669 +;compute correlation coeff and M score
230.670 + u = yvalues(0,:)
230.671 + v = yvalues(1,:)
230.672 +
230.673 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
230.674 + uu = u(good)
230.675 + vv = v(good)
230.676 +
230.677 + ccr933h = esccr(uu,vv,0)
230.678 + print (ccr933h)
230.679 +
230.680 +;new eq
230.681 + bias = sum(abs(vv-uu)/(vv+uu))
230.682 + M933h = (1.- (bias/dimsizes(uu)))*5.
230.683 + print (M933h)
230.684 +
230.685 + delete (u)
230.686 + delete (v)
230.687 + delete (uu)
230.688 + delete (vv)
230.689 +;----------------------------------------------------------------------
230.690 +; histogram res
230.691 +
230.692 + res = True
230.693 + res@gsnMaximize = True
230.694 + res@gsnDraw = False
230.695 + res@gsnFrame = False
230.696 + res@xyMarkLineMode = "Markers"
230.697 + res@xyMarkerSizeF = 0.014
230.698 + res@xyMarker = 16
230.699 + res@xyMarkerColors = (/"Brown","Blue"/)
230.700 + res@trYMinF = min(mn_yvalues) - 10.
230.701 + res@trYMaxF = max(mx_yvalues) + 10.
230.702 +
230.703 + res@tiYAxisString = "NPP (g C/m2/year)"
230.704 + res@tiXAxisString = "Precipitation (m/year)"
230.705 +
230.706 + max_bar = new((/2,nx/),graphic)
230.707 + min_bar = new((/2,nx/),graphic)
230.708 + max_cap = new((/2,nx/),graphic)
230.709 + min_cap = new((/2,nx/),graphic)
230.710 +
230.711 + lnres = True
230.712 + line_colors = (/"brown","blue"/)
230.713 +;=================================================================
230.714 +; histogram ob 933 site only
230.715 +;
230.716 + plot_name = "histogram_ob_933"
230.717 + title = "Observed 933 site"
230.718 + res@tiMainString = title
230.719 +
230.720 + wks = gsn_open_wks (plot_type,plot_name)
230.721 +
230.722 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),res)
230.723 +
230.724 +;-------------------------------
230.725 +;Attach the vertical bar and the horizontal cap line
230.726 +
230.727 + do nd=0,0
230.728 + lnres@gsLineColor = line_colors(nd)
230.729 + do i=0,nx-1
230.730 +
230.731 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
230.732 + .not.ismissing(mx_yvalues(nd,i))) then
230.733 +;
230.734 +; Attach the vertical bar, both above and below the marker.
230.735 +;
230.736 + x1 = xvalues(nd,i)
230.737 + y1 = yvalues(nd,i)
230.738 + y2 = mn_yvalues(nd,i)
230.739 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
230.740 +
230.741 + y2 = mx_yvalues(nd,i)
230.742 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
230.743 +;
230.744 +; Attach the horizontal cap line, both above and below the marker.
230.745 +;
230.746 + x1 = xvalues(nd,i) - dx4
230.747 + x2 = xvalues(nd,i) + dx4
230.748 + y1 = mn_yvalues(nd,i)
230.749 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
230.750 +
230.751 + y1 = mx_yvalues(nd,i)
230.752 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
230.753 + end if
230.754 + end do
230.755 + end do
230.756 +
230.757 + draw(xy)
230.758 + frame(wks)
230.759 +
230.760 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
230.761 +; system("rm "+plot_name+"."+plot_type)
230.762 +; system("rm "+plot_name+"-1."+plot_type_new)
230.763 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
230.764 +
230.765 + clear (wks)
230.766 +;===========================================================================
230.767 +; histogram model vs ob 933 site
230.768 +
230.769 + plot_name = "histogram_mod-ob_933"
230.770 + title = model_name+ " vs Observed 933 site"
230.771 + res@tiMainString = title
230.772 +
230.773 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
230.774 +
230.775 +;-----------------------------
230.776 +; Add a boxed legend using the more simple method, which won't have
230.777 +; vertical lines going through the markers.
230.778 +
230.779 + res@pmLegendDisplayMode = "Always"
230.780 +; res@pmLegendWidthF = 0.1
230.781 + res@pmLegendWidthF = 0.08
230.782 + res@pmLegendHeightF = 0.05
230.783 + res@pmLegendOrthogonalPosF = -1.17
230.784 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
230.785 +; res@pmLegendParallelPosF = 0.18
230.786 + res@pmLegendParallelPosF = 0.23 ;(rightward)
230.787 +
230.788 +; res@lgPerimOn = False
230.789 + res@lgLabelFontHeightF = 0.015
230.790 + res@xyExplicitLegendLabels = (/"observed",model_name/)
230.791 +;-----------------------------
230.792 + tRes = True
230.793 + tRes@txFontHeightF = 0.025
230.794 +
230.795 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933h)+")"
230.796 +
230.797 + gsn_text_ndc(wks,correlation_text,0.5,0.8,tRes)
230.798 +
230.799 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
230.800 +;-------------------------------
230.801 +;Attach the vertical bar and the horizontal cap line
230.802 +
230.803 + do nd=0,1
230.804 + lnres@gsLineColor = line_colors(nd)
230.805 + do i=0,nx-1
230.806 +
230.807 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
230.808 + .not.ismissing(mx_yvalues(nd,i))) then
230.809 +;
230.810 +; Attach the vertical bar, both above and below the marker.
230.811 +;
230.812 + x1 = xvalues(nd,i)
230.813 + y1 = yvalues(nd,i)
230.814 + y2 = mn_yvalues(nd,i)
230.815 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
230.816 +
230.817 + y2 = mx_yvalues(nd,i)
230.818 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
230.819 +;
230.820 +; Attach the horizontal cap line, both above and below the marker.
230.821 +;
230.822 + x1 = xvalues(nd,i) - dx4
230.823 + x2 = xvalues(nd,i) + dx4
230.824 + y1 = mn_yvalues(nd,i)
230.825 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
230.826 +
230.827 + y1 = mx_yvalues(nd,i)
230.828 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
230.829 + end if
230.830 + end do
230.831 + end do
230.832 + draw(xy)
230.833 + frame(wks)
230.834 +
230.835 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
230.836 +;system("rm "+plot_name+"."+plot_type)
230.837 +;system("rm "+plot_name+"-1."+plot_type_new)
230.838 +;system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
230.839 +
230.840 + clear (wks)
230.841 +;------------------------------------------------------------------------
230.842 +
230.843 +end
231.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
231.2 +++ b/npp/17.scatter_bias.ncl Mon Jan 26 22:08:20 2009 -0500
231.3 @@ -0,0 +1,972 @@
231.4 +; ***********************************************
231.5 +; combine all scatter and all histogram
231.6 +; ***********************************************
231.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
231.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
231.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
231.10 +;************************************************
231.11 +procedure pminmax(data:numeric,name:string)
231.12 +begin
231.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
231.14 + if(isatt(data,"units")) then
231.15 + print (name + " units = " + data@units)
231.16 + end if
231.17 +end
231.18 +
231.19 +; Main code.
231.20 +begin
231.21 +
231.22 + plot_type = "ps"
231.23 + plot_type_new = "png"
231.24 +
231.25 +;************************************************
231.26 +; read in ob data
231.27 +;************************************************
231.28 +;(1)
231.29 + dir81 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
231.30 + fil81 = "data.81.nc"
231.31 + f81 = addfile (dir81+fil81,"r")
231.32 +
231.33 + id81 = f81->SITE_ID
231.34 + npp81 = f81->TNPP_C
231.35 + rain81 = tofloat(f81->PREC_ANN)
231.36 + x81 = f81->LONG_DD
231.37 + y81 = f81->LAT_DD
231.38 +
231.39 + id81@long_name = "SITE_ID"
231.40 +
231.41 +;change longitude from (-180,180) to (0,360)
231.42 +;for model data interpolation
231.43 +
231.44 + do i= 0,dimsizes(x81)-1
231.45 + if (x81(i) .lt. 0.) then
231.46 + x81(i) = x81(i)+ 360.
231.47 + end if
231.48 + end do
231.49 +;print (x81)
231.50 +;-------------------------------------
231.51 +;(2)
231.52 + dir933 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
231.53 + fil933 = "data.933.nc"
231.54 + f933 = addfile (dir933+fil933,"r")
231.55 +
231.56 + id933 = f933->SITE_ID
231.57 + npp933 = f933->TNPP_C
231.58 + rain933 = f933->PREC
231.59 + x933 = f933->LONG_DD
231.60 + y933 = f933->LAT_DD
231.61 +
231.62 + id933@long_name = "SITE_ID"
231.63 +
231.64 +;change longitude from (-180,180) to (0,360)
231.65 +;for model data interpolation
231.66 +
231.67 + do i= 0,dimsizes(x933)-1
231.68 + if (x933(i) .lt. 0.) then
231.69 + x933(i) = x933(i)+ 360.
231.70 + end if
231.71 + end do
231.72 +;print (x933)
231.73 +;----------------------------------------
231.74 +;(3)
231.75 + dirglobe = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
231.76 + filglobe = "Npp_T31_mean.nc"
231.77 + fglobe = addfile (dirglobe+filglobe,"r")
231.78 +
231.79 + nppglobe = fglobe->NPP
231.80 +
231.81 +;************************************************
231.82 +; read in model data
231.83 +;************************************************
231.84 + model_name = "b30.061n"
231.85 +
231.86 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
231.87 + film = "b30.061n_1995-2004_ANN_climo_lnd.nc"
231.88 + fm = addfile (dirm+film,"r")
231.89 +
231.90 + nppmod0 = fm->NPP
231.91 + rainmod0 = fm->RAIN
231.92 + xm = fm->lon
231.93 + ym = fm->lat
231.94 +
231.95 + nppmod = nppmod0(0,:,:)
231.96 + rainmod = rainmod0(0,:,:)
231.97 + delete (nppmod0)
231.98 + delete (rainmod0)
231.99 +
231.100 + nppmod81 =linint2_points(xm,ym,nppmod,True,x81,y81,0)
231.101 +
231.102 + nppmod933 =linint2_points(xm,ym,nppmod,True,x933,y933,0)
231.103 +
231.104 + rainmod81 =linint2_points(xm,ym,rainmod,True,x81,y81,0)
231.105 +
231.106 + rainmod933=linint2_points(xm,ym,rainmod,True,x933,y933,0)
231.107 +
231.108 +;************************************************
231.109 +; Units for these variables are:
231.110 +;
231.111 +; rain81 : mm/year
231.112 +; rainmod : mm/s
231.113 +; npp81 : g C/m^2/year
231.114 +; nppmod81: g C/m^2/s
231.115 +; nppglobe: g C/m^2/year
231.116 +;
231.117 +; We want to convert these to "m/year" and "g C/m^2/year".
231.118 +;
231.119 + nsec_per_year = 60*60*24*365
231.120 +
231.121 + rain81 = rain81 / 1000.
231.122 + rainmod81 = (rainmod81/ 1000.) * nsec_per_year
231.123 + nppmod81 = nppmod81 * nsec_per_year
231.124 +
231.125 + rain933 = rain933 / 1000.
231.126 + rainmod933 = (rainmod933/ 1000.) * nsec_per_year
231.127 + nppmod933 = nppmod933 * nsec_per_year
231.128 +
231.129 + nppmod = nppmod * nsec_per_year
231.130 +
231.131 + npp81@units = "gC/m^2/yr"
231.132 + nppmod81@units = "gC/m^2/yr"
231.133 + npp933@units = "gC/m^2/yr"
231.134 + nppmod933@units = "gC/m^2/yr"
231.135 + nppmod@units = "gC/m^2/yr"
231.136 + nppglobe@units = "gC/m^2/yr"
231.137 + rain81@units = "m/yr"
231.138 + rainmod81@units = "m/yr"
231.139 + rain933@units = "m/yr"
231.140 + rainmod933@units = "m/yr"
231.141 +
231.142 + npp81@long_name = "NPP (gC/m2/year)"
231.143 + npp933@long_name = "NPP (gC/m2/year)"
231.144 + nppmod81@long_name = "NPP (gC/m2/year)"
231.145 + nppmod933@long_name = "NPP (gC/m2/year)"
231.146 + nppmod@long_name = "NPP (gC/m2/year)"
231.147 + nppglobe@long_name = "NPP (gC/m2/year)"
231.148 + rain81@long_name = "PREC (m/year)"
231.149 + rain933@long_name = "PREC (m/year)"
231.150 + rainmod81@long_name = "PREC (m/year)"
231.151 + rainmod933@long_name = "PREC (m/year)"
231.152 +
231.153 +;(A) plot scatter ob 81
231.154 +
231.155 + plot_name = "scatter_ob_81"
231.156 + title = "Observed 81 sites"
231.157 +
231.158 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
231.159 + res = True ; plot mods desired
231.160 + res@tiMainString = title ; add title
231.161 + res@xyMarkLineModes = "Markers" ; choose which have markers
231.162 + res@xyMarkers = 16 ; choose type of marker
231.163 + res@xyMarkerColor = "red" ; Marker color
231.164 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
231.165 + res@tmLabelAutoStride = True ; nice tick mark labels
231.166 +
231.167 + plot = gsn_csm_xy (wks,id81,npp81,res) ; create plot
231.168 + frame(wks)
231.169 +
231.170 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.171 + system("rm "+plot_name+"."+plot_type)
231.172 + system("rm "+plot_name+"-1."+plot_type_new)
231.173 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.174 +
231.175 + clear (wks)
231.176 +
231.177 +;(B) plot scatter ob 933
231.178 +
231.179 + plot_name = "scatter_ob_933"
231.180 + title = "Observed 933 sites"
231.181 +
231.182 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
231.183 + res = True ; plot mods desired
231.184 + res@tiMainString = title ; add title
231.185 + res@xyMarkLineModes = "Markers" ; choose which have markers
231.186 + res@xyMarkers = 16 ; choose type of marker
231.187 + res@xyMarkerColor = "red" ; Marker color
231.188 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
231.189 + res@tmLabelAutoStride = True ; nice tick mark labels
231.190 +
231.191 + plot = gsn_csm_xy (wks,id933,npp933,res) ; create plot
231.192 + frame(wks)
231.193 +
231.194 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.195 + system("rm "+plot_name+"."+plot_type)
231.196 + system("rm "+plot_name+"-1."+plot_type_new)
231.197 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.198 +
231.199 + clear (wks)
231.200 +
231.201 +;(C) plot scatter model 81
231.202 +
231.203 + plot_name = "scatter_model_81"
231.204 + title = "Model "+ model_name +" 81 sites"
231.205 +
231.206 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
231.207 + res = True ; plot mods desired
231.208 + res@tiMainString = title ; add title
231.209 + res@xyMarkLineModes = "Markers" ; choose which have markers
231.210 + res@xyMarkers = 16 ; choose type of marker
231.211 + res@xyMarkerColor = "red" ; Marker color
231.212 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
231.213 + res@tmLabelAutoStride = True ; nice tick mark labels
231.214 +
231.215 + plot = gsn_csm_xy (wks,id81,nppmod81,res) ; create plot
231.216 + frame(wks)
231.217 +
231.218 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.219 + system("rm "+plot_name+"."+plot_type)
231.220 + system("rm "+plot_name+"-1."+plot_type_new)
231.221 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.222 +
231.223 + clear (wks)
231.224 +
231.225 +;(D) plot scatter model 933
231.226 +
231.227 + plot_name = "scatter_model_933"
231.228 + title = "Model "+ model_name +" 933 sites"
231.229 +
231.230 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
231.231 + res = True ; plot mods desired
231.232 + res@tiMainString = title ; add title
231.233 + res@xyMarkLineModes = "Markers" ; choose which have markers
231.234 + res@xyMarkers = 16 ; choose type of marker
231.235 + res@xyMarkerColor = "red" ; Marker color
231.236 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
231.237 + res@tmLabelAutoStride = True ; nice tick mark labels
231.238 +
231.239 + plot = gsn_csm_xy (wks,id933,nppmod933,res) ; create plot
231.240 + frame(wks)
231.241 +
231.242 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.243 + system("rm "+plot_name+"."+plot_type)
231.244 + system("rm "+plot_name+"-1."+plot_type_new)
231.245 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.246 +
231.247 + clear (wks)
231.248 +
231.249 +;(E) scatter model vs ob 81
231.250 +
231.251 + plot_name = "scatter_model_vs_ob_81"
231.252 + title = model_name +" vs ob 81 sites"
231.253 +
231.254 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
231.255 + res = True ; plot mods desired
231.256 + res@tiMainString = title ; add title
231.257 + res@xyMarkLineModes = "Markers" ; choose which have markers
231.258 + res@xyMarkers = 16 ; choose type of marker
231.259 + res@xyMarkerColor = "red" ; Marker color
231.260 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
231.261 + res@tmLabelAutoStride = True ; nice tick mark labels
231.262 +;-------------------------------
231.263 +;compute correlation coef. and M
231.264 + ccr81 = esccr(nppmod81,npp81,0)
231.265 + print (ccr81)
231.266 +
231.267 +;new eq
231.268 + bias = sum(abs(nppmod81-npp81)/(nppmod81+npp81))
231.269 + M81 = (1. - (bias/dimsizes(y81)))*5.
231.270 + print (M81)
231.271 +
231.272 + tRes = True
231.273 + tRes@txFontHeightF = 0.025
231.274 +
231.275 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81)+")"
231.276 +
231.277 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
231.278 +;--------------------------------
231.279 + plot = gsn_csm_xy (wks,npp81,nppmod81,res) ; create plot
231.280 + frame(wks)
231.281 +
231.282 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.283 + system("rm "+plot_name+"."+plot_type)
231.284 + system("rm "+plot_name+"-1."+plot_type_new)
231.285 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.286 +
231.287 + clear (wks)
231.288 +
231.289 +;(F) scatter model vs ob 933
231.290 +
231.291 + plot_name = "scatter_model_vs_ob_933"
231.292 + title = model_name +" vs ob 933 sites"
231.293 +
231.294 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
231.295 + res = True ; plot mods desired
231.296 + res@tiMainString = title ; add title
231.297 + res@xyMarkLineModes = "Markers" ; choose which have markers
231.298 + res@xyMarkers = 16 ; choose type of marker
231.299 + res@xyMarkerColor = "red" ; Marker color
231.300 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
231.301 + res@tmLabelAutoStride = True ; nice tick mark labels
231.302 +;-------------------------------
231.303 +;compute correlation coef. and M
231.304 + ccr933 = esccr(nppmod933,npp933,0)
231.305 + print (ccr933)
231.306 +
231.307 +;new eq
231.308 + bias = sum(abs(nppmod933-npp933)/(nppmod933+npp933))
231.309 + M933 = (1. - (bias/dimsizes(y933)))*5.
231.310 + print (M933)
231.311 +
231.312 + tRes = True
231.313 + tRes@txFontHeightF = 0.025
231.314 +
231.315 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933)+")"
231.316 +
231.317 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
231.318 +;--------------------------------
231.319 + plot = gsn_csm_xy (wks,npp933,nppmod933,res) ; create plot
231.320 + frame(wks)
231.321 +
231.322 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.323 + system("rm "+plot_name+"."+plot_type)
231.324 + system("rm "+plot_name+"-1."+plot_type_new)
231.325 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.326 +
231.327 + clear (wks)
231.328 +;**************************************************************************
231.329 +;(G) histogram 81
231.330 +
231.331 +;--------------------------------------------------------------------
231.332 +;get data
231.333 +
231.334 + RAIN1_1D = ndtooned(rain81)
231.335 + RAIN2_1D = ndtooned(rainmod81)
231.336 + NPP1_1D = ndtooned(npp81)
231.337 + NPP2_1D = ndtooned(nppmod81)
231.338 +;
231.339 +; Calculate some "nice" bins for binning the data in equally spaced
231.340 +; ranges.
231.341 +;
231.342 + nbins = 15 ; Number of bins to use.
231.343 +
231.344 + nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
231.345 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
231.346 + range = fspan(nicevals(0),nicevals(1),nvals)
231.347 +;
231.348 +; Use this range information to grab all the values in a
231.349 +; particular range, and then take an average.
231.350 +;
231.351 + nr = dimsizes(range)
231.352 + nx = nr-1
231.353 + xvalues = new((/2,nx/),typeof(RAIN1_1D))
231.354 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
231.355 + dx = xvalues(0,1) - xvalues(0,0) ; range width
231.356 + dx4 = dx/4 ; 1/4 of the range
231.357 + xvalues(1,:) = xvalues(0,:) - dx/5.
231.358 + yvalues = new((/2,nx/),typeof(RAIN1_1D))
231.359 + mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
231.360 + mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
231.361 +
231.362 + do nd=0,1
231.363 +;
231.364 +; See if we are doing model or observational data.
231.365 +;
231.366 + if(nd.eq.0) then
231.367 + data = RAIN1_1D
231.368 + npp_data = NPP1_1D
231.369 + else
231.370 + data = RAIN2_1D
231.371 + npp_data = NPP2_1D
231.372 + end if
231.373 +;
231.374 +; Loop through each range and check for values.
231.375 +;
231.376 + do i=0,nr-2
231.377 + if (i.ne.(nr-2)) then
231.378 +; print("")
231.379 +; print("In range ["+range(i)+","+range(i+1)+")")
231.380 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
231.381 + else
231.382 +; print("")
231.383 +; print("In range ["+range(i)+",)")
231.384 + idx = ind(range(i).le.data)
231.385 + end if
231.386 +;
231.387 +; Calculate average, and get min and max.
231.388 +;
231.389 + if(.not.any(ismissing(idx))) then
231.390 + yvalues(nd,i) = avg(npp_data(idx))
231.391 + mn_yvalues(nd,i) = min(npp_data(idx))
231.392 + mx_yvalues(nd,i) = max(npp_data(idx))
231.393 + count = dimsizes(idx)
231.394 + else
231.395 + count = 0
231.396 + yvalues(nd,i) = yvalues@_FillValue
231.397 + mn_yvalues(nd,i) = yvalues@_FillValue
231.398 + mx_yvalues(nd,i) = yvalues@_FillValue
231.399 + end if
231.400 +;
231.401 +; Print out information.
231.402 +;
231.403 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
231.404 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
231.405 +
231.406 +;
231.407 +; Clean up for next time in loop.
231.408 +;
231.409 + delete(idx)
231.410 + end do
231.411 + delete(data)
231.412 + delete(npp_data)
231.413 + end do
231.414 +;----------------------------------------
231.415 +;compute correlation coeff and M score
231.416 + u = yvalues(0,:)
231.417 + v = yvalues(1,:)
231.418 +
231.419 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
231.420 + uu = u(good)
231.421 + vv = v(good)
231.422 +
231.423 + ccr81h = esccr(uu,vv,0)
231.424 + print (ccr81h)
231.425 +
231.426 +;new eq
231.427 + bias = sum(abs(vv-uu)/(vv+uu))
231.428 + M81h = (1.- (bias/dimsizes(uu)))*5.
231.429 + print (M81h)
231.430 +
231.431 + delete (u)
231.432 + delete (v)
231.433 + delete (uu)
231.434 + delete (vv)
231.435 +;----------------------------------------------------------------------
231.436 +; histogram res
231.437 +
231.438 + res = True
231.439 + res@gsnMaximize = True
231.440 + res@gsnDraw = False
231.441 + res@gsnFrame = False
231.442 + res@xyMarkLineMode = "Markers"
231.443 + res@xyMarkerSizeF = 0.014
231.444 + res@xyMarker = 16
231.445 + res@xyMarkerColors = (/"Brown","Blue"/)
231.446 + res@trYMinF = min(mn_yvalues) - 10.
231.447 + res@trYMaxF = max(mx_yvalues) + 10.
231.448 +
231.449 + res@tiYAxisString = "NPP (g C/m2/year)"
231.450 + res@tiXAxisString = "Precipitation (m/year)"
231.451 +
231.452 + max_bar = new((/2,nx/),graphic)
231.453 + min_bar = new((/2,nx/),graphic)
231.454 + max_cap = new((/2,nx/),graphic)
231.455 + min_cap = new((/2,nx/),graphic)
231.456 +
231.457 + lnres = True
231.458 + line_colors = (/"brown","blue"/)
231.459 +;=================================================================
231.460 +; histogram ob 81 site only
231.461 +;
231.462 + plot_name = "histogram_ob_81"
231.463 + title = "Observed 81 site"
231.464 + res@tiMainString = title
231.465 +
231.466 + wks = gsn_open_wks (plot_type,plot_name)
231.467 +
231.468 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),res)
231.469 +
231.470 +;-------------------------------
231.471 +;Attach the vertical bar and the horizontal cap line
231.472 +
231.473 + do nd=0,0
231.474 + lnres@gsLineColor = line_colors(nd)
231.475 + do i=0,nx-1
231.476 +
231.477 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
231.478 + .not.ismissing(mx_yvalues(nd,i))) then
231.479 +;
231.480 +; Attach the vertical bar, both above and below the marker.
231.481 +;
231.482 + x1 = xvalues(nd,i)
231.483 + y1 = yvalues(nd,i)
231.484 + y2 = mn_yvalues(nd,i)
231.485 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
231.486 +
231.487 + y2 = mx_yvalues(nd,i)
231.488 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
231.489 +;
231.490 +; Attach the horizontal cap line, both above and below the marker.
231.491 +;
231.492 + x1 = xvalues(nd,i) - dx4
231.493 + x2 = xvalues(nd,i) + dx4
231.494 + y1 = mn_yvalues(nd,i)
231.495 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
231.496 +
231.497 + y1 = mx_yvalues(nd,i)
231.498 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
231.499 + end if
231.500 + end do
231.501 + end do
231.502 +
231.503 + draw(xy)
231.504 + frame(wks)
231.505 +
231.506 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.507 +; system("rm "+plot_name+"."+plot_type)
231.508 +; system("rm "+plot_name+"-1."+plot_type_new)
231.509 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.510 +
231.511 + clear (wks)
231.512 +;===========================================================================
231.513 +; histogram model vs ob 81 site
231.514 +
231.515 + plot_name = "histogram_mod-ob_81"
231.516 + title = model_name+ " vs Observed 81 site"
231.517 + res@tiMainString = title
231.518 +
231.519 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
231.520 +
231.521 +;-----------------------------
231.522 +; Add a boxed legend using the more simple method, which won't have
231.523 +; vertical lines going through the markers.
231.524 +
231.525 + res@pmLegendDisplayMode = "Always"
231.526 +; res@pmLegendWidthF = 0.1
231.527 + res@pmLegendWidthF = 0.08
231.528 + res@pmLegendHeightF = 0.05
231.529 + res@pmLegendOrthogonalPosF = -1.17
231.530 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
231.531 +; res@pmLegendParallelPosF = 0.18
231.532 + res@pmLegendParallelPosF = 0.23 ;(rightward)
231.533 +
231.534 +; res@lgPerimOn = False
231.535 + res@lgLabelFontHeightF = 0.015
231.536 + res@xyExplicitLegendLabels = (/"observed",model_name/)
231.537 +;-----------------------------
231.538 + tRes = True
231.539 + tRes@txFontHeightF = 0.025
231.540 +
231.541 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81h)+")"
231.542 +
231.543 + gsn_text_ndc(wks,correlation_text,0.5,0.8,tRes)
231.544 +
231.545 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
231.546 +;-------------------------------
231.547 +;Attach the vertical bar and the horizontal cap line
231.548 +
231.549 + do nd=0,1
231.550 + lnres@gsLineColor = line_colors(nd)
231.551 + do i=0,nx-1
231.552 +
231.553 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
231.554 + .not.ismissing(mx_yvalues(nd,i))) then
231.555 +;
231.556 +; Attach the vertical bar, both above and below the marker.
231.557 +;
231.558 + x1 = xvalues(nd,i)
231.559 + y1 = yvalues(nd,i)
231.560 + y2 = mn_yvalues(nd,i)
231.561 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
231.562 +
231.563 + y2 = mx_yvalues(nd,i)
231.564 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
231.565 +;
231.566 +; Attach the horizontal cap line, both above and below the marker.
231.567 +;
231.568 + x1 = xvalues(nd,i) - dx4
231.569 + x2 = xvalues(nd,i) + dx4
231.570 + y1 = mn_yvalues(nd,i)
231.571 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
231.572 +
231.573 + y1 = mx_yvalues(nd,i)
231.574 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
231.575 + end if
231.576 + end do
231.577 + end do
231.578 + draw(xy)
231.579 + frame(wks)
231.580 +
231.581 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.582 +;system("rm "+plot_name+"."+plot_type)
231.583 +;system("rm "+plot_name+"-1."+plot_type_new)
231.584 +;system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.585 +
231.586 + clear (wks)
231.587 +
231.588 + delete (RAIN1_1D)
231.589 + delete (RAIN2_1D)
231.590 + delete (NPP1_1D)
231.591 + delete (NPP2_1D)
231.592 + delete (range)
231.593 + delete (xvalues)
231.594 + delete (yvalues)
231.595 + delete (mn_yvalues)
231.596 + delete (mx_yvalues)
231.597 + delete (good)
231.598 + delete (max_bar)
231.599 + delete (min_bar)
231.600 + delete (max_cap)
231.601 + delete (min_cap)
231.602 +;**************************************************************************
231.603 +;(H) histogram 933
231.604 +
231.605 +;--------------------------------------------------------------------
231.606 +;get data
231.607 +
231.608 + RAIN1_1D = ndtooned(rain933)
231.609 + RAIN2_1D = ndtooned(rainmod933)
231.610 + NPP1_1D = ndtooned(npp933)
231.611 + NPP2_1D = ndtooned(nppmod933)
231.612 +;
231.613 +; Calculate some "nice" bins for binning the data in equally spaced
231.614 +; ranges.
231.615 +;
231.616 + nbins = 15 ; Number of bins to use.
231.617 +
231.618 + nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
231.619 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
231.620 + range = fspan(nicevals(0),nicevals(1),nvals)
231.621 +;
231.622 +; Use this range information to grab all the values in a
231.623 +; particular range, and then take an average.
231.624 +;
231.625 + nr = dimsizes(range)
231.626 + nx = nr-1
231.627 + xvalues = new((/2,nx/),typeof(RAIN1_1D))
231.628 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
231.629 + dx = xvalues(0,1) - xvalues(0,0) ; range width
231.630 + dx4 = dx/4 ; 1/4 of the range
231.631 + xvalues(1,:) = xvalues(0,:) - dx/5.
231.632 + yvalues = new((/2,nx/),typeof(RAIN1_1D))
231.633 + mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
231.634 + mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
231.635 +
231.636 + do nd=0,1
231.637 +;
231.638 +; See if we are doing model or observational data.
231.639 +;
231.640 + if(nd.eq.0) then
231.641 + data = RAIN1_1D
231.642 + npp_data = NPP1_1D
231.643 + else
231.644 + data = RAIN2_1D
231.645 + npp_data = NPP2_1D
231.646 + end if
231.647 +;
231.648 +; Loop through each range and check for values.
231.649 +;
231.650 + do i=0,nr-2
231.651 + if (i.ne.(nr-2)) then
231.652 +; print("")
231.653 +; print("In range ["+range(i)+","+range(i+1)+")")
231.654 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
231.655 + else
231.656 +; print("")
231.657 +; print("In range ["+range(i)+",)")
231.658 + idx = ind(range(i).le.data)
231.659 + end if
231.660 +;
231.661 +; Calculate average, and get min and max.
231.662 +;
231.663 + if(.not.any(ismissing(idx))) then
231.664 + yvalues(nd,i) = avg(npp_data(idx))
231.665 + mn_yvalues(nd,i) = min(npp_data(idx))
231.666 + mx_yvalues(nd,i) = max(npp_data(idx))
231.667 + count = dimsizes(idx)
231.668 + else
231.669 + count = 0
231.670 + yvalues(nd,i) = yvalues@_FillValue
231.671 + mn_yvalues(nd,i) = yvalues@_FillValue
231.672 + mx_yvalues(nd,i) = yvalues@_FillValue
231.673 + end if
231.674 +;
231.675 +; Print out information.
231.676 +;
231.677 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
231.678 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
231.679 +
231.680 +;
231.681 +; Clean up for next time in loop.
231.682 +;
231.683 + delete(idx)
231.684 + end do
231.685 + delete(data)
231.686 + delete(npp_data)
231.687 + end do
231.688 +;----------------------------------------
231.689 +;compute correlation coeff and M score
231.690 + u = yvalues(0,:)
231.691 + v = yvalues(1,:)
231.692 +
231.693 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
231.694 + uu = u(good)
231.695 + vv = v(good)
231.696 +
231.697 + ccr933h = esccr(uu,vv,0)
231.698 + print (ccr933h)
231.699 +
231.700 +;new eq
231.701 + bias = sum(abs(vv-uu)/(vv+uu))
231.702 + M933h = (1.- (bias/dimsizes(uu)))*5.
231.703 + print (M933h)
231.704 +
231.705 + delete (u)
231.706 + delete (v)
231.707 + delete (uu)
231.708 + delete (vv)
231.709 +;----------------------------------------------------------------------
231.710 +; histogram res
231.711 +
231.712 + res = True
231.713 + res@gsnMaximize = True
231.714 + res@gsnDraw = False
231.715 + res@gsnFrame = False
231.716 + res@xyMarkLineMode = "Markers"
231.717 + res@xyMarkerSizeF = 0.014
231.718 + res@xyMarker = 16
231.719 + res@xyMarkerColors = (/"Brown","Blue"/)
231.720 + res@trYMinF = min(mn_yvalues) - 10.
231.721 + res@trYMaxF = max(mx_yvalues) + 10.
231.722 +
231.723 + res@tiYAxisString = "NPP (g C/m2/year)"
231.724 + res@tiXAxisString = "Precipitation (m/year)"
231.725 +
231.726 + max_bar = new((/2,nx/),graphic)
231.727 + min_bar = new((/2,nx/),graphic)
231.728 + max_cap = new((/2,nx/),graphic)
231.729 + min_cap = new((/2,nx/),graphic)
231.730 +
231.731 + lnres = True
231.732 + line_colors = (/"brown","blue"/)
231.733 +;=================================================================
231.734 +; histogram ob 933 site only
231.735 +;
231.736 + plot_name = "histogram_ob_933"
231.737 + title = "Observed 933 site"
231.738 + res@tiMainString = title
231.739 +
231.740 + wks = gsn_open_wks (plot_type,plot_name)
231.741 +
231.742 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),res)
231.743 +
231.744 +;-------------------------------
231.745 +;Attach the vertical bar and the horizontal cap line
231.746 +
231.747 + do nd=0,0
231.748 + lnres@gsLineColor = line_colors(nd)
231.749 + do i=0,nx-1
231.750 +
231.751 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
231.752 + .not.ismissing(mx_yvalues(nd,i))) then
231.753 +;
231.754 +; Attach the vertical bar, both above and below the marker.
231.755 +;
231.756 + x1 = xvalues(nd,i)
231.757 + y1 = yvalues(nd,i)
231.758 + y2 = mn_yvalues(nd,i)
231.759 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
231.760 +
231.761 + y2 = mx_yvalues(nd,i)
231.762 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
231.763 +;
231.764 +; Attach the horizontal cap line, both above and below the marker.
231.765 +;
231.766 + x1 = xvalues(nd,i) - dx4
231.767 + x2 = xvalues(nd,i) + dx4
231.768 + y1 = mn_yvalues(nd,i)
231.769 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
231.770 +
231.771 + y1 = mx_yvalues(nd,i)
231.772 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
231.773 + end if
231.774 + end do
231.775 + end do
231.776 +
231.777 + draw(xy)
231.778 + frame(wks)
231.779 +
231.780 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.781 +; system("rm "+plot_name+"."+plot_type)
231.782 +; system("rm "+plot_name+"-1."+plot_type_new)
231.783 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.784 +
231.785 + clear (wks)
231.786 +;===========================================================================
231.787 +; histogram model vs ob 933 site
231.788 +
231.789 + plot_name = "histogram_mod-ob_933"
231.790 + title = model_name+ " vs Observed 933 site"
231.791 + res@tiMainString = title
231.792 +
231.793 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
231.794 +
231.795 +;-----------------------------
231.796 +; Add a boxed legend using the more simple method, which won't have
231.797 +; vertical lines going through the markers.
231.798 +
231.799 + res@pmLegendDisplayMode = "Always"
231.800 +; res@pmLegendWidthF = 0.1
231.801 + res@pmLegendWidthF = 0.08
231.802 + res@pmLegendHeightF = 0.05
231.803 + res@pmLegendOrthogonalPosF = -1.17
231.804 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
231.805 +; res@pmLegendParallelPosF = 0.18
231.806 + res@pmLegendParallelPosF = 0.23 ;(rightward)
231.807 +
231.808 +; res@lgPerimOn = False
231.809 + res@lgLabelFontHeightF = 0.015
231.810 + res@xyExplicitLegendLabels = (/"observed",model_name/)
231.811 +;-----------------------------
231.812 + tRes = True
231.813 + tRes@txFontHeightF = 0.025
231.814 +
231.815 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933h)+")"
231.816 +
231.817 + gsn_text_ndc(wks,correlation_text,0.5,0.8,tRes)
231.818 +
231.819 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
231.820 +;-------------------------------
231.821 +;Attach the vertical bar and the horizontal cap line
231.822 +
231.823 + do nd=0,1
231.824 + lnres@gsLineColor = line_colors(nd)
231.825 + do i=0,nx-1
231.826 +
231.827 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
231.828 + .not.ismissing(mx_yvalues(nd,i))) then
231.829 +;
231.830 +; Attach the vertical bar, both above and below the marker.
231.831 +;
231.832 + x1 = xvalues(nd,i)
231.833 + y1 = yvalues(nd,i)
231.834 + y2 = mn_yvalues(nd,i)
231.835 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
231.836 +
231.837 + y2 = mx_yvalues(nd,i)
231.838 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
231.839 +;
231.840 +; Attach the horizontal cap line, both above and below the marker.
231.841 +;
231.842 + x1 = xvalues(nd,i) - dx4
231.843 + x2 = xvalues(nd,i) + dx4
231.844 + y1 = mn_yvalues(nd,i)
231.845 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
231.846 +
231.847 + y1 = mx_yvalues(nd,i)
231.848 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
231.849 + end if
231.850 + end do
231.851 + end do
231.852 + draw(xy)
231.853 + frame(wks)
231.854 +
231.855 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.856 +; system("rm "+plot_name+"."+plot_type)
231.857 +; system("rm "+plot_name+"-1."+plot_type_new)
231.858 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.859 +
231.860 + clear (wks)
231.861 +;------------------------------------------------------------------------
231.862 +;global contour
231.863 +
231.864 +;res
231.865 + resw = True ; Use plot options
231.866 + resw@cnFillOn = True ; Turn on color fill
231.867 + resw@gsnSpreadColors = True ; use full colormap
231.868 +; resw@cnFillMode = "RasterFill" ; Turn on raster color
231.869 +; resw@lbLabelAutoStride = True
231.870 + resw@cnLinesOn = False ; Turn off contourn lines
231.871 + resw@mpFillOn = False ; Turn off map fill
231.872 +
231.873 + resw@gsnSpreadColors = True ; use full colormap
231.874 + resw@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
231.875 + resw@cnMinLevelValF = 0. ; Min level
231.876 + resw@cnMaxLevelValF = 2200. ; Max level
231.877 + resw@cnLevelSpacingF = 200. ; interval
231.878 +;------------------------------------------------------------------------
231.879 +;global contour ob
231.880 +
231.881 + delta = 0.00000000001
231.882 + nppglobe = where(ismissing(nppglobe).and.(ismissing(nppmod).or.(nppmod.lt.delta)),0.,nppglobe)
231.883 +
231.884 + plot_name = "global_ob"
231.885 + title = "Observed MODIS MOD 17"
231.886 + resw@tiMainString = title
231.887 +
231.888 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
231.889 + gsn_define_colormap(wks,"gui_default") ; choose colormap
231.890 +
231.891 +
231.892 + plot = gsn_csm_contour_map_ce(wks,nppglobe,resw)
231.893 + frame(wks)
231.894 +
231.895 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.896 + system("rm "+plot_name+"."+plot_type)
231.897 + system("rm "+plot_name+"-1."+plot_type_new)
231.898 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.899 +
231.900 + clear (wks)
231.901 +;------------------------------------------------------------------------
231.902 +;global contour model
231.903 +
231.904 + plot_name = "global_model"
231.905 + title = "Model "+ model_name
231.906 + resw@tiMainString = title
231.907 +
231.908 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
231.909 + gsn_define_colormap(wks,"gui_default") ; choose colormap
231.910 +
231.911 + plot = gsn_csm_contour_map_ce(wks,nppmod,resw)
231.912 + frame(wks)
231.913 +
231.914 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.915 + system("rm "+plot_name+"."+plot_type)
231.916 + system("rm "+plot_name+"-1."+plot_type_new)
231.917 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.918 +
231.919 + clear (wks)
231.920 +;------------------------------------------------------------------------
231.921 +;global contour model vs ob
231.922 +
231.923 + plot_name = "global_model_vs_ob"
231.924 +
231.925 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
231.926 + gsn_define_colormap(wks,"gui_default") ; choose colormap
231.927 +
231.928 + delete (plot)
231.929 + plot=new(3,graphic) ; create graphic array
231.930 +
231.931 + resw@gsnFrame = False ; Do not draw plot
231.932 + resw@gsnDraw = False ; Do not advance frame
231.933 +
231.934 +;(a) ob
231.935 +
231.936 + title = "Observed MODIS MOD 17"
231.937 + resw@tiMainString = title
231.938 +
231.939 + plot(0) = gsn_csm_contour_map_ce(wks,nppglobe,resw) ; for observed
231.940 +
231.941 +;(b) model
231.942 +
231.943 + title = "Model "+ model_name
231.944 + resw@tiMainString = title
231.945 +
231.946 + plot(1) = gsn_csm_contour_map_ce(wks,nppmod,resw) ; for model
231.947 +
231.948 +;(c) model-ob
231.949 +
231.950 + zz = nppmod
231.951 + zz = nppmod - nppglobe
231.952 + title = "Model_"+model_name+" - Observed"
231.953 +
231.954 + resw@cnMinLevelValF = -500 ; Min level
231.955 + resw@cnMaxLevelValF = 500. ; Max level
231.956 + resw@cnLevelSpacingF = 50. ; interval
231.957 + resw@tiMainString = title
231.958 +
231.959 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resw)
231.960 +
231.961 + pres = True ; panel plot mods desired
231.962 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
231.963 + ; indiv. plots in panel
231.964 + pres@gsnMaximize = True ; fill the page
231.965 +
231.966 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
231.967 +
231.968 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
231.969 + system("rm "+plot_name+"."+plot_type)
231.970 +; system("rm "+plot_name+"-1."+plot_type_new)
231.971 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
231.972 +
231.973 + frame (wks)
231.974 + clear (wks)
231.975 +end
232.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
232.2 +++ b/npp/18.scatter_bias.ncl Mon Jan 26 22:08:20 2009 -0500
232.3 @@ -0,0 +1,1096 @@
232.4 +; ****************************************************
232.5 +; combine scatter, histogram, global and zonal plots
232.6 +; ****************************************************
232.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
232.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
232.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
232.10 +;************************************************
232.11 +procedure pminmax(data:numeric,name:string)
232.12 +begin
232.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
232.14 + if(isatt(data,"units")) then
232.15 + print (name + " units = " + data@units)
232.16 + end if
232.17 +end
232.18 +
232.19 +; Main code.
232.20 +begin
232.21 +
232.22 + plot_type = "ps"
232.23 + plot_type_new = "png"
232.24 +
232.25 +;************************************************
232.26 +; read in ob data
232.27 +;************************************************
232.28 +;(1)
232.29 + dir81 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
232.30 + fil81 = "data.81.nc"
232.31 + f81 = addfile (dir81+fil81,"r")
232.32 +
232.33 + id81 = f81->SITE_ID
232.34 + npp81 = f81->TNPP_C
232.35 + rain81 = tofloat(f81->PREC_ANN)
232.36 + x81 = f81->LONG_DD
232.37 + y81 = f81->LAT_DD
232.38 +
232.39 + id81@long_name = "SITE_ID"
232.40 +
232.41 +;change longitude from (-180,180) to (0,360)
232.42 +;for model data interpolation
232.43 +
232.44 + do i= 0,dimsizes(x81)-1
232.45 + if (x81(i) .lt. 0.) then
232.46 + x81(i) = x81(i)+ 360.
232.47 + end if
232.48 + end do
232.49 +;print (x81)
232.50 +;-------------------------------------
232.51 +;(2)
232.52 + dir933 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
232.53 + fil933 = "data.933.nc"
232.54 + f933 = addfile (dir933+fil933,"r")
232.55 +
232.56 + id933 = f933->SITE_ID
232.57 + npp933 = f933->TNPP_C
232.58 + rain933 = f933->PREC
232.59 + x933 = f933->LONG_DD
232.60 + y933 = f933->LAT_DD
232.61 +
232.62 + id933@long_name = "SITE_ID"
232.63 +
232.64 +;change longitude from (-180,180) to (0,360)
232.65 +;for model data interpolation
232.66 +
232.67 + do i= 0,dimsizes(x933)-1
232.68 + if (x933(i) .lt. 0.) then
232.69 + x933(i) = x933(i)+ 360.
232.70 + end if
232.71 + end do
232.72 +;print (x933)
232.73 +;----------------------------------------
232.74 +;(3)
232.75 + dirglobe = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
232.76 + filglobe = "Npp_T31_mean.nc"
232.77 + fglobe = addfile (dirglobe+filglobe,"r")
232.78 +
232.79 + nppglobe0 = fglobe->NPP
232.80 + nppglobe = nppglobe0
232.81 +;************************************************
232.82 +; read in model data
232.83 +;************************************************
232.84 + model_name = "b30.061n"
232.85 +
232.86 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
232.87 + film = "b30.061n_1995-2004_ANN_climo_lnd.nc"
232.88 + fm = addfile (dirm+film,"r")
232.89 +
232.90 + nppmod0 = fm->NPP
232.91 + rainmod0 = fm->RAIN
232.92 + xm = fm->lon
232.93 + ym = fm->lat
232.94 +
232.95 + nppmod = nppmod0(0,:,:)
232.96 + rainmod = rainmod0(0,:,:)
232.97 + delete (nppmod0)
232.98 + delete (rainmod0)
232.99 +
232.100 + nppmod81 =linint2_points(xm,ym,nppmod,True,x81,y81,0)
232.101 +
232.102 + nppmod933 =linint2_points(xm,ym,nppmod,True,x933,y933,0)
232.103 +
232.104 + rainmod81 =linint2_points(xm,ym,rainmod,True,x81,y81,0)
232.105 +
232.106 + rainmod933=linint2_points(xm,ym,rainmod,True,x933,y933,0)
232.107 +
232.108 +;************************************************
232.109 +; Units for these variables are:
232.110 +;
232.111 +; rain81 : mm/year
232.112 +; rainmod : mm/s
232.113 +; npp81 : g C/m^2/year
232.114 +; nppmod81: g C/m^2/s
232.115 +; nppglobe: g C/m^2/year
232.116 +;
232.117 +; We want to convert these to "m/year" and "g C/m^2/year".
232.118 +;
232.119 + nsec_per_year = 60*60*24*365
232.120 +
232.121 + rain81 = rain81 / 1000.
232.122 + rainmod81 = (rainmod81/ 1000.) * nsec_per_year
232.123 + nppmod81 = nppmod81 * nsec_per_year
232.124 +
232.125 + rain933 = rain933 / 1000.
232.126 + rainmod933 = (rainmod933/ 1000.) * nsec_per_year
232.127 + nppmod933 = nppmod933 * nsec_per_year
232.128 +
232.129 + nppmod = nppmod * nsec_per_year
232.130 +
232.131 + npp81@units = "gC/m^2/yr"
232.132 + nppmod81@units = "gC/m^2/yr"
232.133 + npp933@units = "gC/m^2/yr"
232.134 + nppmod933@units = "gC/m^2/yr"
232.135 + nppmod@units = "gC/m^2/yr"
232.136 + nppglobe@units = "gC/m^2/yr"
232.137 + rain81@units = "m/yr"
232.138 + rainmod81@units = "m/yr"
232.139 + rain933@units = "m/yr"
232.140 + rainmod933@units = "m/yr"
232.141 +
232.142 + npp81@long_name = "NPP (gC/m2/year)"
232.143 + npp933@long_name = "NPP (gC/m2/year)"
232.144 + nppmod81@long_name = "NPP (gC/m2/year)"
232.145 + nppmod933@long_name = "NPP (gC/m2/year)"
232.146 + nppmod@long_name = "NPP (gC/m2/year)"
232.147 + nppglobe@long_name = "NPP (gC/m2/year)"
232.148 + rain81@long_name = "PREC (m/year)"
232.149 + rain933@long_name = "PREC (m/year)"
232.150 + rainmod81@long_name = "PREC (m/year)"
232.151 + rainmod933@long_name = "PREC (m/year)"
232.152 +
232.153 +;(A) plot scatter ob 81
232.154 +
232.155 + plot_name = "scatter_ob_81"
232.156 + title = "Observed 81 sites"
232.157 +
232.158 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.159 + res = True ; plot mods desired
232.160 + res@tiMainString = title ; add title
232.161 + res@xyMarkLineModes = "Markers" ; choose which have markers
232.162 + res@xyMarkers = 16 ; choose type of marker
232.163 + res@xyMarkerColor = "red" ; Marker color
232.164 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
232.165 + res@tmLabelAutoStride = True ; nice tick mark labels
232.166 +
232.167 + plot = gsn_csm_xy (wks,id81,npp81,res) ; create plot
232.168 + frame(wks)
232.169 +
232.170 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.171 + system("rm "+plot_name+"."+plot_type)
232.172 + system("rm "+plot_name+"-1."+plot_type_new)
232.173 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.174 +
232.175 + clear (wks)
232.176 +
232.177 +;(B) plot scatter ob 933
232.178 +
232.179 + plot_name = "scatter_ob_933"
232.180 + title = "Observed 933 sites"
232.181 +
232.182 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.183 + res = True ; plot mods desired
232.184 + res@tiMainString = title ; add title
232.185 + res@xyMarkLineModes = "Markers" ; choose which have markers
232.186 + res@xyMarkers = 16 ; choose type of marker
232.187 + res@xyMarkerColor = "red" ; Marker color
232.188 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
232.189 + res@tmLabelAutoStride = True ; nice tick mark labels
232.190 +
232.191 + plot = gsn_csm_xy (wks,id933,npp933,res) ; create plot
232.192 + frame(wks)
232.193 +
232.194 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.195 + system("rm "+plot_name+"."+plot_type)
232.196 + system("rm "+plot_name+"-1."+plot_type_new)
232.197 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.198 +
232.199 + clear (wks)
232.200 +
232.201 +;(C) plot scatter model 81
232.202 +
232.203 + plot_name = "scatter_model_81"
232.204 + title = "Model "+ model_name +" 81 sites"
232.205 +
232.206 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.207 + res = True ; plot mods desired
232.208 + res@tiMainString = title ; add title
232.209 + res@xyMarkLineModes = "Markers" ; choose which have markers
232.210 + res@xyMarkers = 16 ; choose type of marker
232.211 + res@xyMarkerColor = "red" ; Marker color
232.212 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
232.213 + res@tmLabelAutoStride = True ; nice tick mark labels
232.214 +
232.215 + plot = gsn_csm_xy (wks,id81,nppmod81,res) ; create plot
232.216 + frame(wks)
232.217 +
232.218 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.219 + system("rm "+plot_name+"."+plot_type)
232.220 + system("rm "+plot_name+"-1."+plot_type_new)
232.221 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.222 +
232.223 + clear (wks)
232.224 +
232.225 +;(D) plot scatter model 933
232.226 +
232.227 + plot_name = "scatter_model_933"
232.228 + title = "Model "+ model_name +" 933 sites"
232.229 +
232.230 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.231 + res = True ; plot mods desired
232.232 + res@tiMainString = title ; add title
232.233 + res@xyMarkLineModes = "Markers" ; choose which have markers
232.234 + res@xyMarkers = 16 ; choose type of marker
232.235 + res@xyMarkerColor = "red" ; Marker color
232.236 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
232.237 + res@tmLabelAutoStride = True ; nice tick mark labels
232.238 +
232.239 + plot = gsn_csm_xy (wks,id933,nppmod933,res) ; create plot
232.240 + frame(wks)
232.241 +
232.242 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.243 + system("rm "+plot_name+"."+plot_type)
232.244 + system("rm "+plot_name+"-1."+plot_type_new)
232.245 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.246 +
232.247 + clear (wks)
232.248 +
232.249 +;(E) scatter model vs ob 81
232.250 +
232.251 + plot_name = "scatter_model_vs_ob_81"
232.252 + title = model_name +" vs ob 81 sites"
232.253 +
232.254 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.255 + res = True ; plot mods desired
232.256 + res@tiMainString = title ; add title
232.257 + res@xyMarkLineModes = "Markers" ; choose which have markers
232.258 + res@xyMarkers = 16 ; choose type of marker
232.259 + res@xyMarkerColor = "red" ; Marker color
232.260 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
232.261 + res@tmLabelAutoStride = True ; nice tick mark labels
232.262 +;-------------------------------
232.263 +;compute correlation coef. and M
232.264 + ccr81 = esccr(nppmod81,npp81,0)
232.265 + print (ccr81)
232.266 +
232.267 +;new eq
232.268 + bias = sum(abs(nppmod81-npp81)/(nppmod81+npp81))
232.269 + M81 = (1. - (bias/dimsizes(y81)))*5.
232.270 + print (M81)
232.271 +
232.272 + tRes = True
232.273 + tRes@txFontHeightF = 0.025
232.274 +
232.275 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81)+")"
232.276 +
232.277 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
232.278 +;--------------------------------
232.279 + plot = gsn_csm_xy (wks,npp81,nppmod81,res) ; create plot
232.280 + frame(wks)
232.281 +
232.282 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.283 + system("rm "+plot_name+"."+plot_type)
232.284 + system("rm "+plot_name+"-1."+plot_type_new)
232.285 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.286 +
232.287 + clear (wks)
232.288 +
232.289 +;(F) scatter model vs ob 933
232.290 +
232.291 + plot_name = "scatter_model_vs_ob_933"
232.292 + title = model_name +" vs ob 933 sites"
232.293 +
232.294 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.295 + res = True ; plot mods desired
232.296 + res@tiMainString = title ; add title
232.297 + res@xyMarkLineModes = "Markers" ; choose which have markers
232.298 + res@xyMarkers = 16 ; choose type of marker
232.299 + res@xyMarkerColor = "red" ; Marker color
232.300 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
232.301 + res@tmLabelAutoStride = True ; nice tick mark labels
232.302 +;-------------------------------
232.303 +;compute correlation coef. and M
232.304 + ccr933 = esccr(nppmod933,npp933,0)
232.305 + print (ccr933)
232.306 +
232.307 +;new eq
232.308 + bias = sum(abs(nppmod933-npp933)/(nppmod933+npp933))
232.309 + M933 = (1. - (bias/dimsizes(y933)))*5.
232.310 + print (M933)
232.311 +
232.312 + tRes = True
232.313 + tRes@txFontHeightF = 0.025
232.314 +
232.315 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933)+")"
232.316 +
232.317 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
232.318 +;--------------------------------
232.319 + plot = gsn_csm_xy (wks,npp933,nppmod933,res) ; create plot
232.320 + frame(wks)
232.321 +
232.322 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.323 + system("rm "+plot_name+"."+plot_type)
232.324 + system("rm "+plot_name+"-1."+plot_type_new)
232.325 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.326 +
232.327 + clear (wks)
232.328 +;**************************************************************************
232.329 +;(G) histogram 81
232.330 +
232.331 +;--------------------------------------------------------------------
232.332 +;get data
232.333 +
232.334 + RAIN1_1D = ndtooned(rain81)
232.335 + RAIN2_1D = ndtooned(rainmod81)
232.336 + NPP1_1D = ndtooned(npp81)
232.337 + NPP2_1D = ndtooned(nppmod81)
232.338 +
232.339 +; Calculaee "nice" bins for binning the data in equally spaced ranges.
232.340 +
232.341 + nbins = 15 ; Number of bins to use.
232.342 +
232.343 + nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
232.344 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
232.345 + range = fspan(nicevals(0),nicevals(1),nvals)
232.346 +
232.347 +; Use this range information to grab all the values in a
232.348 +; particular range, and then take an average.
232.349 +
232.350 + nr = dimsizes(range)
232.351 + nx = nr-1
232.352 + xvalues = new((/2,nx/),typeof(RAIN1_1D))
232.353 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
232.354 + dx = xvalues(0,1) - xvalues(0,0) ; range width
232.355 + dx4 = dx/4 ; 1/4 of the range
232.356 + xvalues(1,:) = xvalues(0,:) - dx/5.
232.357 + yvalues = new((/2,nx/),typeof(RAIN1_1D))
232.358 + mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
232.359 + mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
232.360 +
232.361 + do nd=0,1
232.362 +
232.363 +; See if we are doing model or observational data.
232.364 +
232.365 + if(nd.eq.0) then
232.366 + data = RAIN1_1D
232.367 + npp_data = NPP1_1D
232.368 + else
232.369 + data = RAIN2_1D
232.370 + npp_data = NPP2_1D
232.371 + end if
232.372 +
232.373 +; Loop through each range and check for values.
232.374 +
232.375 + do i=0,nr-2
232.376 + if (i.ne.(nr-2)) then
232.377 +; print("")
232.378 +; print("In range ["+range(i)+","+range(i+1)+")")
232.379 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
232.380 + else
232.381 +; print("")
232.382 +; print("In range ["+range(i)+",)")
232.383 + idx = ind(range(i).le.data)
232.384 + end if
232.385 +
232.386 +; Calculate average, and get min and max.
232.387 +
232.388 + if(.not.any(ismissing(idx))) then
232.389 + yvalues(nd,i) = avg(npp_data(idx))
232.390 + mn_yvalues(nd,i) = min(npp_data(idx))
232.391 + mx_yvalues(nd,i) = max(npp_data(idx))
232.392 + count = dimsizes(idx)
232.393 + else
232.394 + count = 0
232.395 + yvalues(nd,i) = yvalues@_FillValue
232.396 + mn_yvalues(nd,i) = yvalues@_FillValue
232.397 + mx_yvalues(nd,i) = yvalues@_FillValue
232.398 + end if
232.399 +
232.400 +; Print out information.
232.401 +
232.402 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
232.403 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
232.404 +
232.405 +
232.406 +; Clean up for next time in loop.
232.407 +
232.408 + delete(idx)
232.409 + end do
232.410 + delete(data)
232.411 + delete(npp_data)
232.412 + end do
232.413 +;----------------------------------------
232.414 +;compute correlation coeff and M score
232.415 +
232.416 + u = yvalues(0,:)
232.417 + v = yvalues(1,:)
232.418 +
232.419 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
232.420 + uu = u(good)
232.421 + vv = v(good)
232.422 +
232.423 + ccr81h = esccr(uu,vv,0)
232.424 + print (ccr81h)
232.425 +
232.426 +;new eq
232.427 + bias = sum(abs(vv-uu)/(vv+uu))
232.428 + M81h = (1.- (bias/dimsizes(uu)))*5.
232.429 + print (M81h)
232.430 +
232.431 + delete (u)
232.432 + delete (v)
232.433 + delete (uu)
232.434 + delete (vv)
232.435 +;----------------------------------------------------------------------
232.436 +; histogram res
232.437 +
232.438 + resh = True
232.439 + resh@gsnMaximize = True
232.440 + resh@gsnDraw = False
232.441 + resh@gsnFrame = False
232.442 + resh@xyMarkLineMode = "Markers"
232.443 + resh@xyMarkerSizeF = 0.014
232.444 + resh@xyMarker = 16
232.445 + resh@xyMarkerColors = (/"Brown","Blue"/)
232.446 + resh@trYMinF = min(mn_yvalues) - 10.
232.447 + resh@trYMaxF = max(mx_yvalues) + 10.
232.448 +
232.449 + resh@tiYAxisString = "NPP (g C/m2/year)"
232.450 + resh@tiXAxisString = "Precipitation (m/year)"
232.451 +
232.452 + max_bar = new((/2,nx/),graphic)
232.453 + min_bar = new((/2,nx/),graphic)
232.454 + max_cap = new((/2,nx/),graphic)
232.455 + min_cap = new((/2,nx/),graphic)
232.456 +
232.457 + lnres = True
232.458 + line_colors = (/"brown","blue"/)
232.459 +;=================================================================
232.460 +; histogram ob 81 site only
232.461 +;
232.462 + plot_name = "histogram_ob_81"
232.463 + title = "Observed 81 site"
232.464 + resh@tiMainString = title
232.465 +
232.466 + wks = gsn_open_wks (plot_type,plot_name)
232.467 +
232.468 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
232.469 +
232.470 +;-------------------------------
232.471 +;Attach the vertical bar and the horizontal cap line
232.472 +
232.473 + do nd=0,0
232.474 + lnres@gsLineColor = line_colors(nd)
232.475 + do i=0,nx-1
232.476 +
232.477 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
232.478 + .not.ismissing(mx_yvalues(nd,i))) then
232.479 +;
232.480 +; Attach the vertical bar, both above and below the marker.
232.481 +;
232.482 + x1 = xvalues(nd,i)
232.483 + y1 = yvalues(nd,i)
232.484 + y2 = mn_yvalues(nd,i)
232.485 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
232.486 +
232.487 + y2 = mx_yvalues(nd,i)
232.488 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
232.489 +;
232.490 +; Attach the horizontal cap line, both above and below the marker.
232.491 +;
232.492 + x1 = xvalues(nd,i) - dx4
232.493 + x2 = xvalues(nd,i) + dx4
232.494 + y1 = mn_yvalues(nd,i)
232.495 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
232.496 +
232.497 + y1 = mx_yvalues(nd,i)
232.498 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
232.499 + end if
232.500 + end do
232.501 + end do
232.502 +
232.503 + draw(xy)
232.504 + frame(wks)
232.505 +
232.506 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.507 + system("rm "+plot_name+"."+plot_type)
232.508 +; system("rm "+plot_name+"-1."+plot_type_new)
232.509 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.510 +
232.511 + clear (wks)
232.512 +;===========================================================================
232.513 +; histogram model vs ob 81 site
232.514 +
232.515 + plot_name = "histogram_mod-ob_81"
232.516 + title = model_name+ " vs Observed 81 site"
232.517 + resh@tiMainString = title
232.518 +
232.519 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.520 +
232.521 +;-----------------------------
232.522 +; Add a boxed legend using the more simple method, which won't have
232.523 +; vertical lines going through the markers.
232.524 +
232.525 + resh@pmLegendDisplayMode = "Always"
232.526 +; resh@pmLegendWidthF = 0.1
232.527 + resh@pmLegendWidthF = 0.08
232.528 + resh@pmLegendHeightF = 0.05
232.529 + resh@pmLegendOrthogonalPosF = -1.17
232.530 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
232.531 +; resh@pmLegendParallelPosF = 0.18
232.532 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
232.533 +
232.534 +; resh@lgPerimOn = False
232.535 + resh@lgLabelFontHeightF = 0.015
232.536 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
232.537 +;-----------------------------
232.538 + tRes = True
232.539 + tRes@txFontHeightF = 0.025
232.540 +
232.541 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81h)+")"
232.542 +
232.543 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
232.544 +
232.545 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
232.546 +;-------------------------------
232.547 +;Attach the vertical bar and the horizontal cap line
232.548 +
232.549 + do nd=0,1
232.550 + lnres@gsLineColor = line_colors(nd)
232.551 + do i=0,nx-1
232.552 +
232.553 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
232.554 + .not.ismissing(mx_yvalues(nd,i))) then
232.555 +;
232.556 +; Attach the vertical bar, both above and below the marker.
232.557 +;
232.558 + x1 = xvalues(nd,i)
232.559 + y1 = yvalues(nd,i)
232.560 + y2 = mn_yvalues(nd,i)
232.561 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
232.562 +
232.563 + y2 = mx_yvalues(nd,i)
232.564 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
232.565 +;
232.566 +; Attach the horizontal cap line, both above and below the marker.
232.567 +;
232.568 + x1 = xvalues(nd,i) - dx4
232.569 + x2 = xvalues(nd,i) + dx4
232.570 + y1 = mn_yvalues(nd,i)
232.571 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
232.572 +
232.573 + y1 = mx_yvalues(nd,i)
232.574 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
232.575 + end if
232.576 + end do
232.577 + end do
232.578 + draw(xy)
232.579 + frame(wks)
232.580 +
232.581 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.582 + system("rm "+plot_name+"."+plot_type)
232.583 +; system("rm "+plot_name+"-1."+plot_type_new)
232.584 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.585 +
232.586 + clear (wks)
232.587 +
232.588 + delete (RAIN1_1D)
232.589 + delete (RAIN2_1D)
232.590 + delete (NPP1_1D)
232.591 + delete (NPP2_1D)
232.592 + delete (range)
232.593 + delete (xvalues)
232.594 + delete (yvalues)
232.595 + delete (mn_yvalues)
232.596 + delete (mx_yvalues)
232.597 + delete (good)
232.598 + delete (max_bar)
232.599 + delete (min_bar)
232.600 + delete (max_cap)
232.601 + delete (min_cap)
232.602 +;**************************************************************************
232.603 +;(H) histogram 933
232.604 +
232.605 +;--------------------------------------------------------------------
232.606 +;get data
232.607 +
232.608 + RAIN1_1D = ndtooned(rain933)
232.609 + RAIN2_1D = ndtooned(rainmod933)
232.610 + NPP1_1D = ndtooned(npp933)
232.611 + NPP2_1D = ndtooned(nppmod933)
232.612 +
232.613 +; Calculate "nice" bins for binning the data in equally spaced ranges.
232.614 +
232.615 + nbins = 15 ; Number of bins to use.
232.616 +
232.617 + nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
232.618 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
232.619 + range = fspan(nicevals(0),nicevals(1),nvals)
232.620 +
232.621 +; Use this range information to grab all the values in a
232.622 +; particular range, and then take an average.
232.623 +
232.624 + nr = dimsizes(range)
232.625 + nx = nr-1
232.626 + xvalues = new((/2,nx/),typeof(RAIN1_1D))
232.627 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
232.628 + dx = xvalues(0,1) - xvalues(0,0) ; range width
232.629 + dx4 = dx/4 ; 1/4 of the range
232.630 + xvalues(1,:) = xvalues(0,:) - dx/5.
232.631 + yvalues = new((/2,nx/),typeof(RAIN1_1D))
232.632 + mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
232.633 + mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
232.634 +
232.635 + do nd=0,1
232.636 +
232.637 +; See if we are doing model or observational data.
232.638 +
232.639 + if(nd.eq.0) then
232.640 + data = RAIN1_1D
232.641 + npp_data = NPP1_1D
232.642 + else
232.643 + data = RAIN2_1D
232.644 + npp_data = NPP2_1D
232.645 + end if
232.646 +
232.647 +; Loop through each range and check for values.
232.648 +
232.649 + do i=0,nr-2
232.650 + if (i.ne.(nr-2)) then
232.651 +; print("")
232.652 +; print("In range ["+range(i)+","+range(i+1)+")")
232.653 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
232.654 + else
232.655 +; print("")
232.656 +; print("In range ["+range(i)+",)")
232.657 + idx = ind(range(i).le.data)
232.658 + end if
232.659 +
232.660 +; Calculate average, and get min and max.
232.661 +
232.662 + if(.not.any(ismissing(idx))) then
232.663 + yvalues(nd,i) = avg(npp_data(idx))
232.664 + mn_yvalues(nd,i) = min(npp_data(idx))
232.665 + mx_yvalues(nd,i) = max(npp_data(idx))
232.666 + count = dimsizes(idx)
232.667 + else
232.668 + count = 0
232.669 + yvalues(nd,i) = yvalues@_FillValue
232.670 + mn_yvalues(nd,i) = yvalues@_FillValue
232.671 + mx_yvalues(nd,i) = yvalues@_FillValue
232.672 + end if
232.673 +
232.674 +; Print out information.
232.675 +
232.676 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
232.677 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
232.678 +
232.679 +; Clean up for next time in loop.
232.680 +
232.681 + delete(idx)
232.682 + end do
232.683 + delete(data)
232.684 + delete(npp_data)
232.685 + end do
232.686 +;----------------------------------------
232.687 +;compute correlation coeff and M score
232.688 +
232.689 + u = yvalues(0,:)
232.690 + v = yvalues(1,:)
232.691 +
232.692 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
232.693 + uu = u(good)
232.694 + vv = v(good)
232.695 +
232.696 + ccr933h = esccr(uu,vv,0)
232.697 + print (ccr933h)
232.698 +
232.699 +;new eq
232.700 + bias = sum(abs(vv-uu)/(vv+uu))
232.701 + M933h = (1.- (bias/dimsizes(uu)))*5.
232.702 + print (M933h)
232.703 +
232.704 + delete (u)
232.705 + delete (v)
232.706 + delete (uu)
232.707 + delete (vv)
232.708 +;----------------------------------------------------------------------
232.709 +; histogram res
232.710 +
232.711 + delete (resh)
232.712 + resh = True
232.713 + resh@gsnMaximize = True
232.714 + resh@gsnDraw = False
232.715 + resh@gsnFrame = False
232.716 + resh@xyMarkLineMode = "Markers"
232.717 + resh@xyMarkerSizeF = 0.014
232.718 + resh@xyMarker = 16
232.719 + resh@xyMarkerColors = (/"Brown","Blue"/)
232.720 + resh@trYMinF = min(mn_yvalues) - 10.
232.721 + resh@trYMaxF = max(mx_yvalues) + 10.
232.722 +
232.723 + resh@tiYAxisString = "NPP (g C/m2/year)"
232.724 + resh@tiXAxisString = "Precipitation (m/year)"
232.725 +
232.726 + max_bar = new((/2,nx/),graphic)
232.727 + min_bar = new((/2,nx/),graphic)
232.728 + max_cap = new((/2,nx/),graphic)
232.729 + min_cap = new((/2,nx/),graphic)
232.730 +
232.731 + lnres = True
232.732 + line_colors = (/"brown","blue"/)
232.733 +;=================================================================
232.734 +; histogram ob 933 site only
232.735 +
232.736 + plot_name = "histogram_ob_933"
232.737 + title = "Observed 933 site"
232.738 + resh@tiMainString = title
232.739 +
232.740 + wks = gsn_open_wks (plot_type,plot_name)
232.741 +
232.742 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
232.743 +
232.744 +;-------------------------------
232.745 +;Attach the vertical bar and the horizontal cap line
232.746 +
232.747 + do nd=0,0
232.748 + lnres@gsLineColor = line_colors(nd)
232.749 + do i=0,nx-1
232.750 +
232.751 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
232.752 + .not.ismissing(mx_yvalues(nd,i))) then
232.753 +
232.754 +; Attach the vertical bar, both above and below the marker.
232.755 +
232.756 + x1 = xvalues(nd,i)
232.757 + y1 = yvalues(nd,i)
232.758 + y2 = mn_yvalues(nd,i)
232.759 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
232.760 +
232.761 + y2 = mx_yvalues(nd,i)
232.762 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
232.763 +
232.764 +; Attach the horizontal cap line, both above and below the marker.
232.765 +
232.766 + x1 = xvalues(nd,i) - dx4
232.767 + x2 = xvalues(nd,i) + dx4
232.768 + y1 = mn_yvalues(nd,i)
232.769 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
232.770 +
232.771 + y1 = mx_yvalues(nd,i)
232.772 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
232.773 + end if
232.774 + end do
232.775 + end do
232.776 +
232.777 + draw(xy)
232.778 + frame(wks)
232.779 +
232.780 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.781 + system("rm "+plot_name+"."+plot_type)
232.782 +; system("rm "+plot_name+"-1."+plot_type_new)
232.783 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.784 +
232.785 + delete (xy)
232.786 + clear (wks)
232.787 +
232.788 +;===========================================================================
232.789 +; histogram model vs ob 933 site
232.790 +
232.791 + plot_name = "histogram_mod-ob_933"
232.792 + title = model_name+ " vs Observed 933 site"
232.793 + resh@tiMainString = title
232.794 +
232.795 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.796 +
232.797 +;-----------------------------
232.798 +; Add a boxed legend using the more simple method, which won't have
232.799 +; vertical lines going through the markers.
232.800 +
232.801 + resh@pmLegendDisplayMode = "Always"
232.802 +; resh@pmLegendWidthF = 0.1
232.803 + resh@pmLegendWidthF = 0.08
232.804 + resh@pmLegendHeightF = 0.05
232.805 + resh@pmLegendOrthogonalPosF = -1.17
232.806 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
232.807 +; resh@pmLegendParallelPosF = 0.18
232.808 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
232.809 +
232.810 +; resh@lgPerimOn = False
232.811 + resh@lgLabelFontHeightF = 0.015
232.812 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
232.813 +;-----------------------------
232.814 + tRes = True
232.815 + tRes@txFontHeightF = 0.025
232.816 +
232.817 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933h)+")"
232.818 +
232.819 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
232.820 +
232.821 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
232.822 +;-------------------------------
232.823 +;Attach the vertical bar and the horizontal cap line
232.824 +
232.825 + do nd=0,1
232.826 + lnres@gsLineColor = line_colors(nd)
232.827 + do i=0,nx-1
232.828 +
232.829 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
232.830 + .not.ismissing(mx_yvalues(nd,i))) then
232.831 +;
232.832 +; Attach the vertical bar, both above and below the marker.
232.833 +;
232.834 + x1 = xvalues(nd,i)
232.835 + y1 = yvalues(nd,i)
232.836 + y2 = mn_yvalues(nd,i)
232.837 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
232.838 +
232.839 + y2 = mx_yvalues(nd,i)
232.840 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
232.841 +;
232.842 +; Attach the horizontal cap line, both above and below the marker.
232.843 +;
232.844 + x1 = xvalues(nd,i) - dx4
232.845 + x2 = xvalues(nd,i) + dx4
232.846 + y1 = mn_yvalues(nd,i)
232.847 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
232.848 +
232.849 + y1 = mx_yvalues(nd,i)
232.850 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
232.851 + end if
232.852 + end do
232.853 + end do
232.854 + draw(xy)
232.855 + frame(wks)
232.856 +
232.857 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.858 + system("rm "+plot_name+"."+plot_type)
232.859 +; system("rm "+plot_name+"-1."+plot_type_new)
232.860 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.861 +
232.862 + delete (xy)
232.863 + clear (wks)
232.864 +;------------------------------------------------------------------------
232.865 +; global contour
232.866 +
232.867 +;res
232.868 + resg = True ; Use plot options
232.869 + resg@cnFillOn = True ; Turn on color fill
232.870 + resg@gsnSpreadColors = True ; use full colormap
232.871 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
232.872 +; resg@lbLabelAutoStride = True
232.873 + resg@cnLinesOn = False ; Turn off contourn lines
232.874 + resg@mpFillOn = False ; Turn off map fill
232.875 +
232.876 + resg@gsnSpreadColors = True ; use full colormap
232.877 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
232.878 + resg@cnMinLevelValF = 0. ; Min level
232.879 + resg@cnMaxLevelValF = 2200. ; Max level
232.880 + resg@cnLevelSpacingF = 200. ; interval
232.881 +;------------------------------------------------------------------------
232.882 +;global contour ob
232.883 +
232.884 + delta = 0.00000000001
232.885 + nppglobe = where(ismissing(nppglobe).and.(ismissing(nppmod).or.(nppmod.lt.delta)),0.,nppglobe)
232.886 +
232.887 + plot_name = "global_ob"
232.888 + title = "Observed MODIS MOD 17"
232.889 + resg@tiMainString = title
232.890 +
232.891 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.892 + gsn_define_colormap(wks,"gui_default") ; choose colormap
232.893 +
232.894 + plot = gsn_csm_contour_map_ce(wks,nppglobe,resg)
232.895 + frame(wks)
232.896 +
232.897 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.898 + system("rm "+plot_name+"."+plot_type)
232.899 + system("rm "+plot_name+"-1."+plot_type_new)
232.900 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.901 +
232.902 + clear (wks)
232.903 +;------------------------------------------------------------------------
232.904 +;global contour model
232.905 +
232.906 + plot_name = "global_model"
232.907 + title = "Model "+ model_name
232.908 + resg@tiMainString = title
232.909 +
232.910 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.911 + gsn_define_colormap(wks,"gui_default") ; choose colormap
232.912 +
232.913 + plot = gsn_csm_contour_map_ce(wks,nppmod,resg)
232.914 + frame(wks)
232.915 +
232.916 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.917 + system("rm "+plot_name+"."+plot_type)
232.918 + system("rm "+plot_name+"-1."+plot_type_new)
232.919 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.920 +
232.921 + clear (wks)
232.922 +;------------------------------------------------------------------------
232.923 +;global contour model vs ob
232.924 +
232.925 + plot_name = "global_model_vs_ob"
232.926 +
232.927 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.928 + gsn_define_colormap(wks,"gui_default") ; choose colormap
232.929 +
232.930 + delete (plot)
232.931 + plot=new(3,graphic) ; create graphic array
232.932 +
232.933 + resg@gsnFrame = False ; Do not draw plot
232.934 + resg@gsnDraw = False ; Do not advance frame
232.935 +
232.936 +;(d) compute correlation coef and M score
232.937 +
232.938 + uu1 = ndtooned(nppmod)
232.939 + vv1 = ndtooned(nppglobe)
232.940 +
232.941 + delete (good)
232.942 + good = ind(.not.ismissing(uu1) .and. .not.ismissing(vv1))
232.943 +
232.944 + ug = uu1(good)
232.945 + vg = vv1(good)
232.946 +
232.947 + ccrG = esccr(ug,vg,0)
232.948 + print (ccrG)
232.949 +
232.950 + MG = (ccrG*ccrG)* 5.0
232.951 + print (MG)
232.952 +
232.953 +; plot correlation coef
232.954 +
232.955 + gRes = True
232.956 + gRes@txFontHeightF = 0.02
232.957 + gRes@txAngleF = 90
232.958 +
232.959 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrG)+")"
232.960 +
232.961 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
232.962 +;--------------------------------------------------------------------
232.963 +
232.964 +;(a) ob
232.965 +
232.966 + title = "Observed MODIS MOD 17"
232.967 + resg@tiMainString = title
232.968 +
232.969 + plot(0) = gsn_csm_contour_map_ce(wks,nppglobe,resg)
232.970 +
232.971 +;(b) model
232.972 +
232.973 + title = "Model "+ model_name
232.974 + resg@tiMainString = title
232.975 +
232.976 + plot(1) = gsn_csm_contour_map_ce(wks,nppmod,resg)
232.977 +
232.978 +;(c) model-ob
232.979 +
232.980 + zz = nppmod
232.981 + zz = nppmod - nppglobe
232.982 + title = "Model_"+model_name+" - Observed"
232.983 +
232.984 + resg@cnMinLevelValF = -500 ; Min level
232.985 + resg@cnMaxLevelValF = 500. ; Max level
232.986 + resg@cnLevelSpacingF = 50. ; interval
232.987 + resg@tiMainString = title
232.988 +
232.989 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
232.990 +
232.991 + pres = True ; panel plot mods desired
232.992 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
232.993 + ; indiv. plots in panel
232.994 + pres@gsnMaximize = True ; fill the page
232.995 +
232.996 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
232.997 +
232.998 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.999 +; system("rm "+plot_name+"."+plot_type)
232.1000 +; system("rm "+plot_name+"-1."+plot_type_new)
232.1001 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.1002 +
232.1003 + frame (wks)
232.1004 + clear (wks)
232.1005 +
232.1006 + delete (plot)
232.1007 +;---------------------------------------------------------------------
232.1008 +; zonal line plot ob
232.1009 +
232.1010 + resz = True
232.1011 +
232.1012 + vv = zonalAve(nppglobe)
232.1013 + vv@long_name = nppglobe@long_name
232.1014 +
232.1015 + plot_name = "zonal_ob"
232.1016 + title = "Observed MODIS MOD 17"
232.1017 + resz@tiMainString = title
232.1018 +
232.1019 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.1020 +
232.1021 + plot = gsn_csm_xy (wks,ym,vv,resz)
232.1022 + frame(wks)
232.1023 +
232.1024 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.1025 + system("rm "+plot_name+"."+plot_type)
232.1026 + system("rm "+plot_name+"-1."+plot_type_new)
232.1027 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.1028 +
232.1029 + clear (wks)
232.1030 +;---------------------------------------------------------------------
232.1031 +; zonal line plot model vs ob
232.1032 +
232.1033 + s = new ((/2,dimsizes(ym)/), float)
232.1034 +
232.1035 + s(0,:) = zonalAve(nppglobe)
232.1036 + s(1,:) = zonalAve(nppmod)
232.1037 +
232.1038 + s@long_name = nppglobe@long_name
232.1039 +;-------------------------------------------
232.1040 +;(d) compute correlation coef and M score
232.1041 +
232.1042 + ccrZ = esccr(s(1,:), s(0,:),0)
232.1043 + print (ccrZ)
232.1044 +
232.1045 + MZ = (ccrZ*ccrZ)* 5.0
232.1046 + print (MZ)
232.1047 +;-------------------------------------------
232.1048 + plot_name = "zonal_model_vs_ob"
232.1049 + title = "Zonal Average"
232.1050 + resz@tiMainString = title
232.1051 +
232.1052 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
232.1053 +
232.1054 +; resz@vpHeightF = 0.4 ; change aspect ratio of plot
232.1055 +; resz@vpWidthF = 0.7
232.1056 +
232.1057 + resz@xyMonoLineColor = "False" ; want colored lines
232.1058 + resz@xyLineColors = (/"black","red"/) ; colors chosen
232.1059 +; resz@xyLineThicknesses = (/3.,3./) ; line thicknesses
232.1060 + resz@xyLineThicknesses = (/2.,2./) ; line thicknesses
232.1061 + resz@xyDashPatterns = (/0.,0./) ; make all lines solid
232.1062 +
232.1063 + resz@tiYAxisString = s@long_name ; add a axis title
232.1064 + resz@txFontHeightF = 0.0195 ; change title font heights
232.1065 +
232.1066 +; Legent
232.1067 + resz@pmLegendDisplayMode = "Always" ; turn on legend
232.1068 + resz@pmLegendSide = "Top" ; Change location of
232.1069 +; resz@pmLegendParallelPosF = .45 ; move units right
232.1070 + resz@pmLegendParallelPosF = .82 ; move units right
232.1071 + resz@pmLegendOrthogonalPosF = -0.4 ; move units down
232.1072 +
232.1073 + resz@pmLegendWidthF = 0.10 ; Change width and
232.1074 + resz@pmLegendHeightF = 0.10 ; height of legend.
232.1075 + resz@lgLabelFontHeightF = .02 ; change font height
232.1076 +; resz@lgTitleOn = True ; turn on legend title
232.1077 +; resz@lgTitleString = "Example" ; create legend title
232.1078 +; resz@lgTitleFontHeightF = .025 ; font of legend title
232.1079 + resz@xyExplicitLegendLabels = (/"Observed",model_name/) ; explicit labels
232.1080 +;--------------------------------------------------------------------
232.1081 + zRes = True
232.1082 + zRes@txFontHeightF = 0.025
232.1083 +
232.1084 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrZ)+")"
232.1085 +
232.1086 + gsn_text_ndc(wks,correlation_text,0.50,0.77,zRes)
232.1087 +;--------------------------------------------------------------------
232.1088 +
232.1089 + plot = gsn_csm_xy (wks,ym,s,resz) ; create plot
232.1090 +
232.1091 + frame(wks) ; advance frame
232.1092 +
232.1093 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
232.1094 + system("rm "+plot_name+"."+plot_type)
232.1095 + system("rm "+plot_name+"-1."+plot_type_new)
232.1096 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
232.1097 +
232.1098 + clear (wks)
232.1099 +end
233.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
233.2 +++ b/npp/21.histogram.ncl Mon Jan 26 22:08:20 2009 -0500
233.3 @@ -0,0 +1,209 @@
233.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
233.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
233.6 +
233.7 +procedure pminmax(data:numeric,name:string)
233.8 +begin
233.9 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
233.10 + if(isatt(data,"units")) then
233.11 + print (name + " units = " + data@units)
233.12 + end if
233.13 +end
233.14 +
233.15 +;
233.16 +; Main code.
233.17 +;
233.18 +begin
233.19 + data_types = (/ "Obs", "Model" /)
233.20 + data_names = (/ "data.81.nc", "i01.03cn_1545-1569_ANN_climo.nc" /)
233.21 +; data_names = (/ "data.81.nc", "i01.04casa_1605-1629_ANN_climo.nc" /)
233.22 + filevar_names = (/ (/"PREC_ANN","TNPP_C"/), (/"RAIN","NPP"/) /)
233.23 + ndata_types = dimsizes(data_types)
233.24 +
233.25 + data_file_obs = addfile(data_names(0),"r") ; Open obs file
233.26 + data_file_mod = addfile(data_names(1),"r") ; Open model file
233.27 +
233.28 +;
233.29 +; Read four variables from files.
233.30 +;
233.31 + PREC_ANN = tofloat(data_file_obs->PREC_ANN)
233.32 + TNPP_C = data_file_obs->TNPP_C
233.33 + RAIN = data_file_mod->RAIN
233.34 + NPP = data_file_mod->NPP
233.35 +;
233.36 +; Units for these four variables are:
233.37 +;
233.38 +; PREC_ANN : mm/year
233.39 +; TNPP_C : g C/m^2/year
233.40 +; RAIN : mm/s
233.41 +; NPP : g C/m^2/s
233.42 +;
233.43 +; We want to convert these to "m/year" and "g C/m^2/year".
233.44 +;
233.45 + nsec_per_year = 60*60*24*365 ; # seconds per year
233.46 +
233.47 +; Do the necessary conversions.
233.48 + PREC_ANN = PREC_ANN / 1000.
233.49 + RAIN = (RAIN / 1000.) * nsec_per_year
233.50 + NPP = NPP * nsec_per_year
233.51 +
233.52 +; Redo the units.
233.53 + PREC_ANN@units = "m/yr"
233.54 + RAIN@units = "m/yr"
233.55 + NPP@units = "gC/m^2/yr"
233.56 + TNPP_C@units = "gC/m^2/yr"
233.57 +
233.58 + pminmax(PREC_ANN,"PREC_ANN")
233.59 + pminmax(TNPP_C,"TNPP_C")
233.60 + pminmax(RAIN,"RAIN")
233.61 + pminmax(NPP,"NPP")
233.62 +
233.63 + RAIN_1D = ndtooned(RAIN)
233.64 + NPP_1D = ndtooned(NPP)
233.65 + PREC_ANN_1D = ndtooned(PREC_ANN)
233.66 + TNPP_C_1D = ndtooned(TNPP_C)
233.67 +
233.68 +;
233.69 +; Calculate some "nice" bins for binning the data in equally spaced
233.70 +; ranges.
233.71 +;
233.72 + nbins = 15 ; Number of bins to use.
233.73 +
233.74 + nicevals = nice_mnmxintvl(min(RAIN_1D),max(RAIN_1D),nbins,True)
233.75 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
233.76 + range = fspan(nicevals(0),nicevals(1),nvals)
233.77 +;
233.78 +; Use this range information to grab all the values in a
233.79 +; particular range, and then take an average.
233.80 +;
233.81 + nr = dimsizes(range)
233.82 + nx = nr-1
233.83 + xvalues = new((/2,nx/),typeof(RAIN_1D))
233.84 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
233.85 + dx = xvalues(0,1) - xvalues(0,0) ; range width
233.86 + dx4 = dx/4 ; 1/4 of the range
233.87 + xvalues(1,:) = xvalues(0,:) - dx/5.
233.88 + yvalues = new((/2,nx/),typeof(RAIN_1D))
233.89 + mn_yvalues = new((/2,nx/),typeof(RAIN_1D))
233.90 + mx_yvalues = new((/2,nx/),typeof(RAIN_1D))
233.91 +
233.92 + do nd=0,1
233.93 +;
233.94 +; See if we are doing model or observational data.
233.95 +;
233.96 + if(nd.eq.0) then
233.97 + data = PREC_ANN_1D
233.98 + npp_data = TNPP_C_1D
233.99 + else
233.100 + data = RAIN_1D
233.101 + npp_data = NPP_1D
233.102 + end if
233.103 +;
233.104 +; Loop through each range and check for values.
233.105 +;
233.106 + do i=0,nr-2
233.107 + if (i.ne.(nr-2)) then
233.108 + print("")
233.109 + print("In range ["+range(i)+","+range(i+1)+")")
233.110 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
233.111 + else
233.112 + print("")
233.113 + print("In range ["+range(i)+",)")
233.114 + idx = ind(range(i).le.data)
233.115 + end if
233.116 +;
233.117 +; Calculate average, and get min and max.
233.118 +;
233.119 + if(.not.any(ismissing(idx))) then
233.120 + yvalues(nd,i) = avg(npp_data(idx))
233.121 + mn_yvalues(nd,i) = min(npp_data(idx))
233.122 + mx_yvalues(nd,i) = max(npp_data(idx))
233.123 + count = dimsizes(idx)
233.124 + else
233.125 + count = 0
233.126 + yvalues(nd,i) = yvalues@_FillValue
233.127 + mn_yvalues(nd,i) = yvalues@_FillValue
233.128 + mx_yvalues(nd,i) = yvalues@_FillValue
233.129 + end if
233.130 +;
233.131 +; Print out information.
233.132 +;
233.133 + print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
233.134 + print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
233.135 +
233.136 +;
233.137 +; Clean up for next time in loop.
233.138 +;
233.139 + delete(idx)
233.140 + end do
233.141 + delete(data)
233.142 + delete(npp_data)
233.143 + end do
233.144 +
233.145 + xvalues@long_name = "Mean Annual precipitation (m/year)"
233.146 + yvalues@long_name = "NPP (g C/m2/year)"
233.147 +
233.148 +;
233.149 +; Start the graphics.
233.150 +;
233.151 +; wks = gsn_open_wks("x11","npp")
233.152 + wks = gsn_open_wks("png","npp")
233.153 +
233.154 + res = True
233.155 + res@tiMainString = "Observed vs i01.03cn"
233.156 +; res@tiMainString = "Observed vs i01.04casa"
233.157 + res@gsnMaximize = False
233.158 + res@gsnDraw = False
233.159 + res@gsnFrame = False
233.160 + res@xyMarkLineMode = "Markers"
233.161 + res@xyMarkerSizeF = 0.014
233.162 + res@xyMarker = 16
233.163 +; res@xyMarkerColors = (/"Gray25","Gray50"/)
233.164 + res@xyMarkerColors = (/"brown","blue"/)
233.165 + res@trYMinF = min(mn_yvalues) - 10.
233.166 + res@trYMaxF = max(mx_yvalues) + 10.
233.167 +
233.168 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
233.169 +
233.170 + max_bar = new((/2,nx/),graphic)
233.171 + min_bar = new((/2,nx/),graphic)
233.172 + max_cap = new((/2,nx/),graphic)
233.173 + min_cap = new((/2,nx/),graphic)
233.174 +
233.175 + lnres = True
233.176 +
233.177 + line_colors = (/"brown","blue"/)
233.178 + do nd=0,1
233.179 + lnres@gsLineColor = line_colors(nd)
233.180 + do i=0,nx-1
233.181 +
233.182 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
233.183 + .not.ismissing(mx_yvalues(nd,i))) then
233.184 +;
233.185 +; Attach the vertical bar, both above and below the marker.
233.186 +;
233.187 + x1 = xvalues(nd,i)
233.188 + y1 = yvalues(nd,i)
233.189 + y2 = mn_yvalues(nd,i)
233.190 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
233.191 +
233.192 + y2 = mx_yvalues(nd,i)
233.193 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
233.194 +;
233.195 +; Attach the horizontal cap line, both above and below the marker.
233.196 +;
233.197 + x1 = xvalues(nd,i) - dx4
233.198 + x2 = xvalues(nd,i) + dx4
233.199 + y1 = mn_yvalues(nd,i)
233.200 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
233.201 +
233.202 + y1 = mx_yvalues(nd,i)
233.203 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
233.204 + end if
233.205 + end do
233.206 + end do
233.207 +
233.208 + draw(xy)
233.209 + frame(wks)
233.210 +
233.211 +end
233.212 +
234.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
234.2 +++ b/npp/22.histogram.ncl Mon Jan 26 22:08:20 2009 -0500
234.3 @@ -0,0 +1,238 @@
234.4 +
234.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
234.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
234.7 +
234.8 +procedure pminmax(data:numeric,name:string)
234.9 +begin
234.10 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
234.11 + if(isatt(data,"units")) then
234.12 + print (name + " units = " + data@units)
234.13 + end if
234.14 +end
234.15 +
234.16 +;
234.17 +; Main code.
234.18 +;
234.19 +begin
234.20 + data_types = (/ "Obs", "Model" /)
234.21 + data_names = (/ "data.81.nc", "i01.03cn_1545-1569_ANN_climo.nc" /)
234.22 +; data_names = (/ "data.81.nc", "i01.04casa_1605-1629_ANN_climo.nc" /)
234.23 +; filevar_names = (/ (/"PREC_ANN","TNPP_C"/), (/"RAIN","NPP"/) /)
234.24 + filevar_names = (/ (/"PREC_ANN","ANPP_C"/), (/"RAIN","AGNPP"/) /)
234.25 + ndata_types = dimsizes(data_types)
234.26 +
234.27 + data_file_obs = addfile(data_names(0),"r") ; Open obs file
234.28 + data_file_mod = addfile(data_names(1),"r") ; Open model file
234.29 +
234.30 +;************************************************
234.31 +; read in data: observed
234.32 +;************************************************
234.33 + PREC_ANN = tofloat(data_file_obs->PREC_ANN)
234.34 + TNPP_C = data_file_obs->TNPP_C
234.35 + xo = data_file_obs->LONG_DD
234.36 + yo = data_file_obs->LAT_DD
234.37 +
234.38 +; change longitude from (-180,180) to (0,360)
234.39 +;print (xo)
234.40 + nx = dimsizes(xo)
234.41 + do i= 0,nx-1
234.42 + if (xo(i) .lt. 0.) then
234.43 + xo(i) = xo(i)+ 360.
234.44 + end if
234.45 + end do
234.46 +;print (xo)
234.47 +
234.48 +;************************************************
234.49 +; read in data: model
234.50 +;************************************************
234.51 + ai = data_file_mod->RAIN
234.52 + bi = data_file_mod->NPP
234.53 + xi = data_file_mod->lon
234.54 + yi = data_file_mod->lat
234.55 +
234.56 +;************************************************
234.57 +; interpolate from model grid to observed grid
234.58 +;************************************************
234.59 + RAIN = linint2_points(xi,yi,ai,True,xo,yo,0)
234.60 + NPP = linint2_points(xi,yi,bi,True,xo,yo,0)
234.61 +
234.62 +;************************************************
234.63 +; convert unit
234.64 +;************************************************
234.65 +; Units for these four variables are:
234.66 +;
234.67 +; PREC_ANN : mm/year
234.68 +; TNPP_C : g C/m^2/year
234.69 +; RAIN : mm/s
234.70 +; NPP : g C/m^2/s
234.71 +;
234.72 +; We want to convert these to "m/year" and "g C/m^2/year".
234.73 +;
234.74 + nsec_per_year = 60*60*24*365 ; # seconds per year
234.75 +
234.76 +; Do the necessary conversions.
234.77 + PREC_ANN = PREC_ANN / 1000.
234.78 + RAIN = (RAIN / 1000.) * nsec_per_year
234.79 + NPP = NPP * nsec_per_year
234.80 +
234.81 +; Redo the units.
234.82 + PREC_ANN@units = "m/yr"
234.83 + RAIN@units = "m/yr"
234.84 + NPP@units = "gC/m^2/yr"
234.85 + TNPP_C@units = "gC/m^2/yr"
234.86 +
234.87 +;************************************************
234.88 + pminmax(PREC_ANN,"PREC_ANN")
234.89 + pminmax(TNPP_C,"TNPP_C")
234.90 + pminmax(RAIN,"RAIN")
234.91 + pminmax(NPP,"NPP")
234.92 +
234.93 + RAIN_1D = ndtooned(RAIN)
234.94 + NPP_1D = ndtooned(NPP)
234.95 + PREC_ANN_1D = ndtooned(PREC_ANN)
234.96 + TNPP_C_1D = ndtooned(TNPP_C)
234.97 +
234.98 +;
234.99 +; Calculate some "nice" bins for binning the data in equally spaced
234.100 +; ranges.
234.101 +;
234.102 + nbins = 15 ; Number of bins to use.
234.103 +
234.104 + nicevals = nice_mnmxintvl(min(RAIN_1D),max(RAIN_1D),nbins,True)
234.105 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
234.106 + range = fspan(nicevals(0),nicevals(1),nvals)
234.107 +;
234.108 +; Use this range information to grab all the values in a
234.109 +; particular range, and then take an average.
234.110 +;
234.111 + nr = dimsizes(range)
234.112 + nx = nr-1
234.113 + xvalues = new((/2,nx/),typeof(RAIN_1D))
234.114 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
234.115 + dx = xvalues(0,1) - xvalues(0,0) ; range width
234.116 + dx4 = dx/4 ; 1/4 of the range
234.117 + xvalues(1,:) = xvalues(0,:) - dx/5.
234.118 + yvalues = new((/2,nx/),typeof(RAIN_1D))
234.119 + mn_yvalues = new((/2,nx/),typeof(RAIN_1D))
234.120 + mx_yvalues = new((/2,nx/),typeof(RAIN_1D))
234.121 +
234.122 + do nd=0,1
234.123 +;
234.124 +; See if we are doing model or observational data.
234.125 +;
234.126 + if(nd.eq.0) then
234.127 + data = PREC_ANN_1D
234.128 + npp_data = TNPP_C_1D
234.129 + else
234.130 + data = RAIN_1D
234.131 + npp_data = NPP_1D
234.132 + end if
234.133 +;
234.134 +; Loop through each range and check for values.
234.135 +;
234.136 + do i=0,nr-2
234.137 + if (i.ne.(nr-2)) then
234.138 + print("")
234.139 + print("In range ["+range(i)+","+range(i+1)+")")
234.140 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
234.141 + else
234.142 + print("")
234.143 + print("In range ["+range(i)+",)")
234.144 + idx = ind(range(i).le.data)
234.145 + end if
234.146 +;
234.147 +; Calculate average, and get min and max.
234.148 +;
234.149 + if(.not.any(ismissing(idx))) then
234.150 + yvalues(nd,i) = avg(npp_data(idx))
234.151 + mn_yvalues(nd,i) = min(npp_data(idx))
234.152 + mx_yvalues(nd,i) = max(npp_data(idx))
234.153 + count = dimsizes(idx)
234.154 + else
234.155 + count = 0
234.156 + yvalues(nd,i) = yvalues@_FillValue
234.157 + mn_yvalues(nd,i) = yvalues@_FillValue
234.158 + mx_yvalues(nd,i) = yvalues@_FillValue
234.159 + end if
234.160 +;
234.161 +; Print out information.
234.162 +;
234.163 + print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
234.164 + print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
234.165 +
234.166 +;
234.167 +; Clean up for next time in loop.
234.168 +;
234.169 + delete(idx)
234.170 + end do
234.171 + delete(data)
234.172 + delete(npp_data)
234.173 + end do
234.174 +
234.175 + xvalues@long_name = "Mean Annual precipitation (m/year)"
234.176 + yvalues@long_name = "NPP (g C/m2/year)"
234.177 +
234.178 +;
234.179 +; Start the graphics.
234.180 +;
234.181 + wks = gsn_open_wks("png","npp")
234.182 +
234.183 + res = True
234.184 + res@gsnMaximize = False
234.185 + res@gsnDraw = False
234.186 + res@gsnFrame = False
234.187 + res@xyMarkLineMode = "Markers"
234.188 + res@xyMarkerSizeF = 0.014
234.189 + res@xyMarker = 16
234.190 +; res@xyMarkerColors = (/"Gray25","Gray50"/)
234.191 + res@xyMarkerColors = (/"brown","blue"/)
234.192 + res@trYMinF = min(mn_yvalues) - 10.
234.193 + res@trYMaxF = max(mx_yvalues) + 10.
234.194 +; res@tiMainString = "Observed vs i01.03cn_81site"
234.195 + res@tiMainString = "Observed vs i01.04casa_81site"
234.196 +
234.197 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
234.198 +
234.199 + max_bar = new((/2,nx/),graphic)
234.200 + min_bar = new((/2,nx/),graphic)
234.201 + max_cap = new((/2,nx/),graphic)
234.202 + min_cap = new((/2,nx/),graphic)
234.203 +
234.204 + lnres = True
234.205 +
234.206 + line_colors = (/"brown","blue"/)
234.207 + do nd=0,1
234.208 + lnres@gsLineColor = line_colors(nd)
234.209 + do i=0,nx-1
234.210 +
234.211 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
234.212 + .not.ismissing(mx_yvalues(nd,i))) then
234.213 +;
234.214 +; Attach the vertical bar, both above and below the marker.
234.215 +;
234.216 + x1 = xvalues(nd,i)
234.217 + y1 = yvalues(nd,i)
234.218 + y2 = mn_yvalues(nd,i)
234.219 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
234.220 +
234.221 + y2 = mx_yvalues(nd,i)
234.222 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
234.223 +;
234.224 +; Attach the horizontal cap line, both above and below the marker.
234.225 +;
234.226 + x1 = xvalues(nd,i) - dx4
234.227 + x2 = xvalues(nd,i) + dx4
234.228 + y1 = mn_yvalues(nd,i)
234.229 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
234.230 +
234.231 + y1 = mx_yvalues(nd,i)
234.232 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
234.233 + end if
234.234 + end do
234.235 + end do
234.236 +
234.237 + draw(xy)
234.238 + frame(wks)
234.239 +
234.240 +end
234.241 +
235.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
235.2 +++ b/npp/23.histogram.ncl Mon Jan 26 22:08:20 2009 -0500
235.3 @@ -0,0 +1,307 @@
235.4 +;********************************************************
235.5 +; histogram normalized by rain
235.6 +;********************************************************
235.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
235.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
235.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
235.10 +
235.11 +procedure pminmax(data:numeric,name:string)
235.12 +begin
235.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
235.14 + if(isatt(data,"units")) then
235.15 + print (name + " units = " + data@units)
235.16 + end if
235.17 +end
235.18 +
235.19 +;
235.20 +; Main code.
235.21 +;
235.22 +begin
235.23 + data_types = (/ "Obs", "Model" /)
235.24 +; data_names = (/ "data.81.nc" , "i01.03cn_1545-1569_ANN_climo.nc" /)
235.25 +; data_names = (/ "data.933.nc", "i01.03cn_1545-1569_ANN_climo.nc" /)
235.26 +; data_names = (/ "data.81.nc" , "i01.04casa_1605-1629_ANN_climo.nc" /)
235.27 + data_names = (/ "data.933.nc", "i01.04casa_1605-1629_ANN_climo.nc" /)
235.28 + filevar_names = (/ (/"PREC_ANN","TNPP_C"/), (/"RAIN","NPP"/) /)
235.29 + ndata_types = dimsizes(data_types)
235.30 +
235.31 + data_file_obs = addfile(data_names(0),"r") ; Open obs file
235.32 + data_file_mod = addfile(data_names(1),"r") ; Open model file
235.33 +
235.34 +;************************************************
235.35 +; read in data: observed
235.36 +;************************************************
235.37 +;RAIN1 = tofloat(data_file_obs->PREC_ANN) ; for data.81
235.38 + RAIN1 = data_file_obs->PREC ; for data.933
235.39 + NPP1 = data_file_obs->TNPP_C
235.40 + xo = data_file_obs->LONG_DD
235.41 + yo = data_file_obs->LAT_DD
235.42 +
235.43 +; change longitude from (-180,180) to (0,360)
235.44 + print (xo)
235.45 + nx = dimsizes(xo)
235.46 + do i= 0,nx-1
235.47 + if (xo(i) .lt. 0.) then
235.48 + xo(i) = xo(i)+ 360.
235.49 + end if
235.50 + end do
235.51 + print (xo)
235.52 +
235.53 +;************************************************
235.54 +; read in data: model
235.55 +;************************************************
235.56 + ai = data_file_mod->RAIN
235.57 + bi = data_file_mod->NPP
235.58 + xi = data_file_mod->lon
235.59 + yi = data_file_mod->lat
235.60 +
235.61 +;************************************************
235.62 +; interpolate from model grid to observed grid
235.63 +;************************************************
235.64 + RAIN2 = linint2_points(xi,yi,ai,True,xo,yo,0)
235.65 + NPP2 = linint2_points(xi,yi,bi,True,xo,yo,0)
235.66 +
235.67 +;************************************************
235.68 +; convert unit
235.69 +;************************************************
235.70 +; Units for these four variables are:
235.71 +;
235.72 +; RAIN1 : mm/year
235.73 +; RAIN2 : mm/s
235.74 +; NPP1 : g C/m^2/year
235.75 +; NPP2 : g C/m^2/s
235.76 +;
235.77 +; We want to convert these to "m/year" and "g C/m^2/year".
235.78 +;
235.79 + nsec_per_year = 60*60*24*365 ; # seconds per year
235.80 +
235.81 +; Do the necessary conversions.
235.82 + RAIN1 = RAIN1 / 1000.
235.83 + RAIN2 = (RAIN2/ 1000.) * nsec_per_year
235.84 + NPP2 = NPP2 * nsec_per_year
235.85 +
235.86 +; Redo the units.
235.87 + RAIN1@units = "m/yr"
235.88 + RAIN2@units = "m/yr"
235.89 + NPP1@units = "gC/m^2/yr"
235.90 + NPP2@units = "gC/m^2/yr"
235.91 +
235.92 +;************************************************
235.93 +; print min/max and unit
235.94 +;************************************************
235.95 + pminmax(RAIN1,"RAIN1")
235.96 + pminmax(RAIN2,"RAIN2")
235.97 + pminmax(NPP1,"NPP1")
235.98 + pminmax(NPP2,"NPP2")
235.99 +
235.100 + RAIN1_1D = ndtooned(RAIN1)
235.101 + RAIN2_1D = ndtooned(RAIN2)
235.102 + NPP1_1D = ndtooned(NPP1)
235.103 + NPP2_1D = ndtooned(NPP2)
235.104 +;
235.105 +; Calculate some "nice" bins for binning the data in equally spaced
235.106 +; ranges.
235.107 +;
235.108 + nbins = 15 ; Number of bins to use.
235.109 +
235.110 + nicevals = nice_mnmxintvl(min(RAIN2_1D),max(RAIN2_1D),nbins,True)
235.111 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
235.112 + range = fspan(nicevals(0),nicevals(1),nvals)
235.113 +;
235.114 +; Use this range information to grab all the values in a
235.115 +; particular range, and then take an average.
235.116 +;
235.117 + nr = dimsizes(range)
235.118 + nx = nr-1
235.119 + xvalues = new((/2,nx/),typeof(RAIN2_1D))
235.120 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
235.121 + dx = xvalues(0,1) - xvalues(0,0) ; range width
235.122 + dx4 = dx/4 ; 1/4 of the range
235.123 + xvalues(1,:) = xvalues(0,:) - dx/5.
235.124 + yvalues = new((/2,nx/),typeof(RAIN2_1D))
235.125 + mn_yvalues = new((/2,nx/),typeof(RAIN2_1D))
235.126 + mx_yvalues = new((/2,nx/),typeof(RAIN2_1D))
235.127 +
235.128 + do nd=0,1
235.129 +;
235.130 +; See if we are doing model or observational data.
235.131 +;
235.132 + if(nd.eq.0) then
235.133 + data = RAIN1_1D
235.134 + npp_data = NPP1_1D
235.135 + else
235.136 + data = RAIN2_1D
235.137 + npp_data = NPP2_1D
235.138 + end if
235.139 +;
235.140 +; Loop through each range and check for values.
235.141 +;
235.142 + do i=0,nr-2
235.143 + if (i.ne.(nr-2)) then
235.144 +; print("")
235.145 +; print("In range ["+range(i)+","+range(i+1)+")")
235.146 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
235.147 + else
235.148 +; print("")
235.149 +; print("In range ["+range(i)+",)")
235.150 + idx = ind(range(i).le.data)
235.151 + end if
235.152 +;
235.153 +; Calculate average, and get min and max.
235.154 +;
235.155 + if(.not.any(ismissing(idx))) then
235.156 + yvalues(nd,i) = avg(npp_data(idx))
235.157 + mn_yvalues(nd,i) = min(npp_data(idx))
235.158 + mx_yvalues(nd,i) = max(npp_data(idx))
235.159 + count = dimsizes(idx)
235.160 + else
235.161 + count = 0
235.162 + yvalues(nd,i) = yvalues@_FillValue
235.163 + mn_yvalues(nd,i) = yvalues@_FillValue
235.164 + mx_yvalues(nd,i) = yvalues@_FillValue
235.165 + end if
235.166 +;
235.167 +; Print out information.
235.168 +;
235.169 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
235.170 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
235.171 +
235.172 +;
235.173 +; Clean up for next time in loop.
235.174 +;
235.175 + delete(idx)
235.176 + end do
235.177 + delete(data)
235.178 + delete(npp_data)
235.179 + end do
235.180 +
235.181 +;
235.182 +; Start the graphics.
235.183 +;
235.184 + wks = gsn_open_wks("png","npp")
235.185 +
235.186 + res = True
235.187 + res@gsnMaximize = True
235.188 + res@gsnDraw = False
235.189 + res@gsnFrame = False
235.190 + res@xyMarkLineMode = "Markers"
235.191 + res@xyMarkerSizeF = 0.014
235.192 + res@xyMarker = 16
235.193 + res@xyMarkerColors = (/"Brown","Blue"/)
235.194 + res@trYMinF = min(mn_yvalues) - 10.
235.195 + res@trYMaxF = max(mx_yvalues) + 10.
235.196 +
235.197 +; res@tiMainString = "Observerd vs i01.03cn 81site"
235.198 +; res@tiMainString = "Observerd vs i01.03cn 933site"
235.199 +; res@tiMainString = "Observerd vs i01.04casa_81site"
235.200 + res@tiMainString = "Observerd vs i01.04casa 933site"
235.201 + res@tiYAxisString = "NPP (g C/m2/year)"
235.202 + res@tiXAxisString = "Precipitation (m/year)"
235.203 +
235.204 +;
235.205 +; Add a boxed legend using the more simple method, which won't have
235.206 +; vertical lines going through the markers.
235.207 +;
235.208 + res@pmLegendDisplayMode = "Always"
235.209 +; res@pmLegendWidthF = 0.1
235.210 + res@pmLegendWidthF = 0.08
235.211 + res@pmLegendHeightF = 0.05
235.212 + res@pmLegendOrthogonalPosF = -1.17
235.213 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
235.214 +; res@pmLegendParallelPosF = 0.18
235.215 + res@pmLegendParallelPosF = 0.23 ;(rightward)
235.216 +
235.217 +; res@lgPerimOn = False
235.218 + res@lgLabelFontHeightF = 0.015
235.219 +; res@xyExplicitLegendLabels = (/"observed","model_i01.03cn"/)
235.220 + res@xyExplicitLegendLabels = (/"observed","model_i01.04casa"/)
235.221 +
235.222 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
235.223 +
235.224 + max_bar = new((/2,nx/),graphic)
235.225 + min_bar = new((/2,nx/),graphic)
235.226 + max_cap = new((/2,nx/),graphic)
235.227 + min_cap = new((/2,nx/),graphic)
235.228 +
235.229 + lnres = True
235.230 +
235.231 + line_colors = (/"brown","blue"/)
235.232 + do nd=0,1
235.233 + lnres@gsLineColor = line_colors(nd)
235.234 + do i=0,nx-1
235.235 +
235.236 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
235.237 + .not.ismissing(mx_yvalues(nd,i))) then
235.238 +;
235.239 +; Attach the vertical bar, both above and below the marker.
235.240 +;
235.241 + x1 = xvalues(nd,i)
235.242 + y1 = yvalues(nd,i)
235.243 + y2 = mn_yvalues(nd,i)
235.244 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
235.245 +
235.246 + y2 = mx_yvalues(nd,i)
235.247 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
235.248 +;
235.249 +; Attach the horizontal cap line, both above and below the marker.
235.250 +;
235.251 + x1 = xvalues(nd,i) - dx4
235.252 + x2 = xvalues(nd,i) + dx4
235.253 + y1 = mn_yvalues(nd,i)
235.254 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
235.255 +
235.256 + y1 = mx_yvalues(nd,i)
235.257 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
235.258 + end if
235.259 + end do
235.260 + end do
235.261 +
235.262 +;
235.263 +; Here's how to do the legend by hand.
235.264 +;
235.265 +; mkres = True ; Marker resources
235.266 +; txres = True ; Text resources
235.267 +; mkres@gsMarkerIndex = 16
235.268 +; mkres@gsMarkerSizeF = 0.02
235.269 +; txres@txFontHeightF = 0.02
235.270 +; txres@txJust = "CenterLeft"
235.271 +;
235.272 +; Change these values if you want to move the marker legend location.
235.273 +; These values are in the same data space as the plot.
235.274 +;
235.275 +; xlg1_cen = 0.2
235.276 +; ylg1_cen = 900.
235.277 +
235.278 +; xlg2_cen = 0.2
235.279 +; ylg2_cen = 760.
235.280 +
235.281 +; mkres@gsMarkerColor = "brown"
235.282 +; lnres@gsLineColor = "brown"
235.283 +
235.284 +; lg_mark_legend1 = gsn_add_polymarker(wks,xy,xlg1_cen,ylg1_cen,mkres)
235.285 +; lg_line_legend1 = gsn_add_polyline(wks,xy,(/xlg1_cen,xlg1_cen/), \
235.286 +; (/ylg1_cen-60,ylg1_cen+60/),lnres)
235.287 +; lg_cap_legend11 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
235.288 +; (/ylg1_cen-60,ylg1_cen-60/),lnres)
235.289 +; lg_cap_legend12 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
235.290 +; (/ylg1_cen+60,ylg1_cen+60/),lnres)
235.291 +
235.292 +; tx_legend1 = gsn_add_text(wks,xy,"observed",xlg1_cen+0.15,ylg1_cen,txres)
235.293 +
235.294 +; mkres@gsMarkerColor = "blue"
235.295 +; lnres@gsLineColor = "blue"
235.296 +
235.297 +; lg_mark_legend2 = gsn_add_polymarker(wks,xy,xlg2_cen,ylg2_cen,mkres)
235.298 +; lg_line_legend2 = gsn_add_polyline(wks,xy,(/xlg2_cen,xlg2_cen/), \
235.299 +; (/ylg2_cen-60,ylg2_cen+60/),lnres)
235.300 +; lg_cap_legend21 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
235.301 +; (/ylg2_cen-60,ylg2_cen-60/),lnres)
235.302 +; lg_cap_legend22 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
235.303 +; (/ylg2_cen+60,ylg2_cen+60/),lnres)
235.304 +; tx_legend2 = gsn_add_text(wks,xy,"model_i01.03cn",xlg2_cen+0.15,ylg2_cen,txres)
235.305 +
235.306 + draw(xy)
235.307 + frame(wks)
235.308 +
235.309 +end
235.310 +
236.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
236.2 +++ b/npp/24.histogram+bias.ncl Mon Jan 26 22:08:20 2009 -0500
236.3 @@ -0,0 +1,329 @@
236.4 +;********************************************************
236.5 +; histogram normalized by rain and compute correleration
236.6 +;********************************************************
236.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
236.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
236.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
236.10 +
236.11 +procedure pminmax(data:numeric,name:string)
236.12 +begin
236.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
236.14 + if(isatt(data,"units")) then
236.15 + print (name + " units = " + data@units)
236.16 + end if
236.17 +end
236.18 +
236.19 +;
236.20 +; Main code.
236.21 +;
236.22 +begin
236.23 + data_types = (/ "Obs", "Model" /)
236.24 + data_names = (/ "data.81.nc" , "i01.03cn_1545-1569_ANN_climo.nc" /)
236.25 +; data_names = (/ "data.933.nc", "i01.03cn_1545-1569_ANN_climo.nc" /)
236.26 +; data_names = (/ "data.81.nc" , "i01.04casa_1605-1629_ANN_climo.nc" /)
236.27 +; data_names = (/ "data.933.nc", "i01.04casa_1605-1629_ANN_climo.nc" /)
236.28 + filevar_names = (/ (/"PREC_ANN","TNPP_C"/), (/"RAIN","NPP"/) /)
236.29 + ndata_types = dimsizes(data_types)
236.30 +
236.31 + data_file_obs = addfile(data_names(0),"r") ; Open obs file
236.32 + data_file_mod = addfile(data_names(1),"r") ; Open model file
236.33 +
236.34 +;************************************************
236.35 +; read in data: observed
236.36 +;************************************************
236.37 + RAIN1 = tofloat(data_file_obs->PREC_ANN) ; for data.81
236.38 +;RAIN1 = data_file_obs->PREC ; for data.933
236.39 + NPP1 = data_file_obs->TNPP_C
236.40 + xo = data_file_obs->LONG_DD
236.41 + yo = data_file_obs->LAT_DD
236.42 +
236.43 +; change longitude from (-180,180) to (0,360)
236.44 + print (xo)
236.45 + nx = dimsizes(xo)
236.46 + do i= 0,nx-1
236.47 + if (xo(i) .lt. 0.) then
236.48 + xo(i) = xo(i)+ 360.
236.49 + end if
236.50 + end do
236.51 + print (xo)
236.52 +
236.53 +;************************************************
236.54 +; read in data: model
236.55 +;************************************************
236.56 + ai = data_file_mod->RAIN
236.57 + bi = data_file_mod->NPP
236.58 + xi = data_file_mod->lon
236.59 + yi = data_file_mod->lat
236.60 +
236.61 +;************************************************
236.62 +; interpolate from model grid to observed grid
236.63 +;************************************************
236.64 + RAIN2 = linint2_points(xi,yi,ai,True,xo,yo,0)
236.65 + NPP2 = linint2_points(xi,yi,bi,True,xo,yo,0)
236.66 +
236.67 +;************************************************
236.68 +; convert unit
236.69 +;************************************************
236.70 +; Units for these four variables are:
236.71 +;
236.72 +; RAIN1 : mm/year
236.73 +; RAIN2 : mm/s
236.74 +; NPP1 : g C/m^2/year
236.75 +; NPP2 : g C/m^2/s
236.76 +;
236.77 +; We want to convert these to "m/year" and "g C/m^2/year".
236.78 +;
236.79 + nsec_per_year = 60*60*24*365 ; # seconds per year
236.80 +
236.81 +; Do the necessary conversions.
236.82 + RAIN1 = RAIN1 / 1000.
236.83 + RAIN2 = (RAIN2/ 1000.) * nsec_per_year
236.84 + NPP2 = NPP2 * nsec_per_year
236.85 +
236.86 +; Redo the units.
236.87 + RAIN1@units = "m/yr"
236.88 + RAIN2@units = "m/yr"
236.89 + NPP1@units = "gC/m^2/yr"
236.90 + NPP2@units = "gC/m^2/yr"
236.91 +
236.92 +;************************************************
236.93 +; print min/max and unit
236.94 +;************************************************
236.95 + pminmax(RAIN1,"RAIN1")
236.96 + pminmax(RAIN2,"RAIN2")
236.97 + pminmax(NPP1,"NPP1")
236.98 + pminmax(NPP2,"NPP2")
236.99 +
236.100 + RAIN1_1D = ndtooned(RAIN1)
236.101 + RAIN2_1D = ndtooned(RAIN2)
236.102 + NPP1_1D = ndtooned(NPP1)
236.103 + NPP2_1D = ndtooned(NPP2)
236.104 +;
236.105 +; Calculate some "nice" bins for binning the data in equally spaced
236.106 +; ranges.
236.107 +;
236.108 + nbins = 15 ; Number of bins to use.
236.109 +
236.110 + nicevals = nice_mnmxintvl(min(RAIN2_1D),max(RAIN2_1D),nbins,True)
236.111 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
236.112 + range = fspan(nicevals(0),nicevals(1),nvals)
236.113 +;
236.114 +; Use this range information to grab all the values in a
236.115 +; particular range, and then take an average.
236.116 +;
236.117 + nr = dimsizes(range)
236.118 + nx = nr-1
236.119 + xvalues = new((/2,nx/),typeof(RAIN2_1D))
236.120 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
236.121 + dx = xvalues(0,1) - xvalues(0,0) ; range width
236.122 + dx4 = dx/4 ; 1/4 of the range
236.123 + xvalues(1,:) = xvalues(0,:) - dx/5.
236.124 + yvalues = new((/2,nx/),typeof(RAIN2_1D))
236.125 + mn_yvalues = new((/2,nx/),typeof(RAIN2_1D))
236.126 + mx_yvalues = new((/2,nx/),typeof(RAIN2_1D))
236.127 +
236.128 + do nd=0,1
236.129 +;
236.130 +; See if we are doing model or observational data.
236.131 +;
236.132 + if(nd.eq.0) then
236.133 + data = RAIN1_1D
236.134 + npp_data = NPP1_1D
236.135 + else
236.136 + data = RAIN2_1D
236.137 + npp_data = NPP2_1D
236.138 + end if
236.139 +;
236.140 +; Loop through each range and check for values.
236.141 +;
236.142 + do i=0,nr-2
236.143 + if (i.ne.(nr-2)) then
236.144 +; print("")
236.145 +; print("In range ["+range(i)+","+range(i+1)+")")
236.146 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
236.147 + else
236.148 +; print("")
236.149 +; print("In range ["+range(i)+",)")
236.150 + idx = ind(range(i).le.data)
236.151 + end if
236.152 +;
236.153 +; Calculate average, and get min and max.
236.154 +;
236.155 + if(.not.any(ismissing(idx))) then
236.156 + yvalues(nd,i) = avg(npp_data(idx))
236.157 + mn_yvalues(nd,i) = min(npp_data(idx))
236.158 + mx_yvalues(nd,i) = max(npp_data(idx))
236.159 + count = dimsizes(idx)
236.160 + else
236.161 + count = 0
236.162 + yvalues(nd,i) = yvalues@_FillValue
236.163 + mn_yvalues(nd,i) = yvalues@_FillValue
236.164 + mx_yvalues(nd,i) = yvalues@_FillValue
236.165 + end if
236.166 +;
236.167 +; Print out information.
236.168 +;
236.169 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
236.170 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
236.171 +
236.172 +;
236.173 +; Clean up for next time in loop.
236.174 +;
236.175 + delete(idx)
236.176 + end do
236.177 + delete(data)
236.178 + delete(npp_data)
236.179 + end do
236.180 +
236.181 +;
236.182 +; Start the graphics.
236.183 +;
236.184 + wks = gsn_open_wks("png","xy")
236.185 +
236.186 + res = True
236.187 + res@gsnMaximize = True
236.188 + res@gsnDraw = False
236.189 + res@gsnFrame = False
236.190 + res@xyMarkLineMode = "Markers"
236.191 + res@xyMarkerSizeF = 0.014
236.192 + res@xyMarker = 16
236.193 + res@xyMarkerColors = (/"Brown","Blue"/)
236.194 + res@trYMinF = min(mn_yvalues) - 10.
236.195 + res@trYMaxF = max(mx_yvalues) + 10.
236.196 +
236.197 +; res@tiMainString = "Observed vs i01.03cn 81 site"
236.198 +; res@tiMainString = "Observed vs i01.03cn 933 site"
236.199 + res@tiMainString = "Observed vs i01.04casa 81 site"
236.200 +; res@tiMainString = "Observed vs i01.04casa 933 site"
236.201 + res@tiYAxisString = "NPP (g C/m2/year)"
236.202 + res@tiXAxisString = "Precipitation (m/year)"
236.203 +
236.204 +;
236.205 +; Add a boxed legend using the more simple method, which won't have
236.206 +; vertical lines going through the markers.
236.207 +;
236.208 + res@pmLegendDisplayMode = "Always"
236.209 +; res@pmLegendWidthF = 0.1
236.210 + res@pmLegendWidthF = 0.08
236.211 + res@pmLegendHeightF = 0.05
236.212 + res@pmLegendOrthogonalPosF = -1.17
236.213 +; res@pmLegendOrthogonalPosF = -1.00 ;(downward)
236.214 +; res@pmLegendParallelPosF = 0.18
236.215 + res@pmLegendParallelPosF = 0.23 ;(rightward)
236.216 +
236.217 +; res@lgPerimOn = False
236.218 + res@lgLabelFontHeightF = 0.015
236.219 +; res@xyExplicitLegendLabels = (/"observed","model_i01.03cn"/)
236.220 + res@xyExplicitLegendLabels = (/"observed","model_i01.04casa"/)
236.221 +
236.222 + xy = gsn_csm_xy(wks,xvalues,yvalues,res)
236.223 +
236.224 + max_bar = new((/2,nx/),graphic)
236.225 + min_bar = new((/2,nx/),graphic)
236.226 + max_cap = new((/2,nx/),graphic)
236.227 + min_cap = new((/2,nx/),graphic)
236.228 +
236.229 + lnres = True
236.230 +
236.231 + line_colors = (/"brown","blue"/)
236.232 + do nd=0,1
236.233 + lnres@gsLineColor = line_colors(nd)
236.234 + do i=0,nx-1
236.235 +
236.236 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
236.237 + .not.ismissing(mx_yvalues(nd,i))) then
236.238 +;
236.239 +; Attach the vertical bar, both above and below the marker.
236.240 +;
236.241 + x1 = xvalues(nd,i)
236.242 + y1 = yvalues(nd,i)
236.243 + y2 = mn_yvalues(nd,i)
236.244 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
236.245 +
236.246 + y2 = mx_yvalues(nd,i)
236.247 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
236.248 +;
236.249 +; Attach the horizontal cap line, both above and below the marker.
236.250 +;
236.251 + x1 = xvalues(nd,i) - dx4
236.252 + x2 = xvalues(nd,i) + dx4
236.253 + y1 = mn_yvalues(nd,i)
236.254 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
236.255 +
236.256 + y1 = mx_yvalues(nd,i)
236.257 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
236.258 + end if
236.259 + end do
236.260 + end do
236.261 +
236.262 +;
236.263 +; Here's how to do the legend by hand.
236.264 +;
236.265 +; mkres = True ; Marker resources
236.266 +; txres = True ; Text resources
236.267 +; mkres@gsMarkerIndex = 16
236.268 +; mkres@gsMarkerSizeF = 0.02
236.269 +; txres@txFontHeightF = 0.02
236.270 +; txres@txJust = "CenterLeft"
236.271 +;
236.272 +; Change these values if you want to move the marker legend location.
236.273 +; These values are in the same data space as the plot.
236.274 +;
236.275 +; xlg1_cen = 0.2
236.276 +; ylg1_cen = 900.
236.277 +
236.278 +; xlg2_cen = 0.2
236.279 +; ylg2_cen = 760.
236.280 +
236.281 +; mkres@gsMarkerColor = "brown"
236.282 +; lnres@gsLineColor = "brown"
236.283 +
236.284 +; lg_mark_legend1 = gsn_add_polymarker(wks,xy,xlg1_cen,ylg1_cen,mkres)
236.285 +; lg_line_legend1 = gsn_add_polyline(wks,xy,(/xlg1_cen,xlg1_cen/), \
236.286 +; (/ylg1_cen-60,ylg1_cen+60/),lnres)
236.287 +; lg_cap_legend11 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
236.288 +; (/ylg1_cen-60,ylg1_cen-60/),lnres)
236.289 +; lg_cap_legend12 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
236.290 +; (/ylg1_cen+60,ylg1_cen+60/),lnres)
236.291 +
236.292 +; tx_legend1 = gsn_add_text(wks,xy,"observed",xlg1_cen+0.15,ylg1_cen,txres)
236.293 +
236.294 +; mkres@gsMarkerColor = "blue"
236.295 +; lnres@gsLineColor = "blue"
236.296 +
236.297 +; lg_mark_legend2 = gsn_add_polymarker(wks,xy,xlg2_cen,ylg2_cen,mkres)
236.298 +; lg_line_legend2 = gsn_add_polyline(wks,xy,(/xlg2_cen,xlg2_cen/), \
236.299 +; (/ylg2_cen-60,ylg2_cen+60/),lnres)
236.300 +; lg_cap_legend21 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
236.301 +; (/ylg2_cen-60,ylg2_cen-60/),lnres)
236.302 +; lg_cap_legend22 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
236.303 +; (/ylg2_cen+60,ylg2_cen+60/),lnres)
236.304 +; tx_legend2 = gsn_add_text(wks,xy,"model_i01.03cn",xlg2_cen+0.15,ylg2_cen,txres)
236.305 +
236.306 + draw(xy)
236.307 + frame(wks)
236.308 +
236.309 + u = yvalues(0,:)
236.310 + v = yvalues(1,:)
236.311 +
236.312 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
236.313 + uu = u(good)
236.314 + vv = v(good)
236.315 + nz = dimsizes(uu)
236.316 + print (nz)
236.317 +
236.318 + ccr = esccr(uu,vv,0)
236.319 + print (ccr)
236.320 +
236.321 +;old eq
236.322 +;bias = sum(((vv-uu)/uu)^2)
236.323 +;M = (1.- sqrt(bias/nz))*5.
236.324 +
236.325 +;new eq
236.326 + bias = sum(abs(vv-uu)/(vv+uu))
236.327 + M = (1.- (bias/nz))*5.
236.328 + print (bias)
236.329 + print (M)
236.330 +
236.331 +end
236.332 +
237.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
237.2 +++ b/npp/24.histogram_ob.ncl Mon Jan 26 22:08:20 2009 -0500
237.3 @@ -0,0 +1,306 @@
237.4 +;********************************************************
237.5 +; histogram normalized by rain and compute correleration
237.6 +;********************************************************
237.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
237.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
237.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
237.10 +
237.11 +procedure pminmax(data:numeric,name:string)
237.12 +begin
237.13 + print ("min/max " + name + " = " + min(data) + "/" + max(data))
237.14 + if(isatt(data,"units")) then
237.15 + print (name + " units = " + data@units)
237.16 + end if
237.17 +end
237.18 +
237.19 +;
237.20 +; Main code.
237.21 +;
237.22 +begin
237.23 + data_types = (/ "Obs", "Model" /)
237.24 + data_names = (/ "data.81.nc" , "i01.03cn_1545-1569_ANN_climo.nc" /)
237.25 +; data_names = (/ "data.933.nc", "i01.03cn_1545-1569_ANN_climo.nc" /)
237.26 +; data_names = (/ "data.81.nc" , "i01.04casa_1605-1629_ANN_climo.nc" /)
237.27 +; data_names = (/ "data.933.nc", "i01.04casa_1605-1629_ANN_climo.nc" /)
237.28 + filevar_names = (/ (/"PREC_ANN","TNPP_C"/), (/"RAIN","NPP"/) /)
237.29 + ndata_types = dimsizes(data_types)
237.30 +
237.31 + data_file_obs = addfile(data_names(0),"r") ; Open obs file
237.32 + data_file_mod = addfile(data_names(1),"r") ; Open model file
237.33 +
237.34 +;************************************************
237.35 +; read in data: observed
237.36 +;************************************************
237.37 + RAIN1 = tofloat(data_file_obs->PREC_ANN) ; for data.81
237.38 +;RAIN1 = data_file_obs->PREC ; for data.933
237.39 + NPP1 = data_file_obs->TNPP_C
237.40 + xo = data_file_obs->LONG_DD
237.41 + yo = data_file_obs->LAT_DD
237.42 +
237.43 +; change longitude from (-180,180) to (0,360)
237.44 + print (xo)
237.45 + nx = dimsizes(xo)
237.46 + do i= 0,nx-1
237.47 + if (xo(i) .lt. 0.) then
237.48 + xo(i) = xo(i)+ 360.
237.49 + end if
237.50 + end do
237.51 + print (xo)
237.52 +
237.53 +;************************************************
237.54 +; read in data: model
237.55 +;************************************************
237.56 + ai = data_file_mod->RAIN
237.57 + bi = data_file_mod->NPP
237.58 + xi = data_file_mod->lon
237.59 + yi = data_file_mod->lat
237.60 +
237.61 +;************************************************
237.62 +; interpolate from model grid to observed grid
237.63 +;************************************************
237.64 + RAIN2 = linint2_points(xi,yi,ai,True,xo,yo,0)
237.65 + NPP2 = linint2_points(xi,yi,bi,True,xo,yo,0)
237.66 +
237.67 +;************************************************
237.68 +; convert unit
237.69 +;************************************************
237.70 +; Units for these four variables are:
237.71 +;
237.72 +; RAIN1 : mm/year
237.73 +; RAIN2 : mm/s
237.74 +; NPP1 : g C/m^2/year
237.75 +; NPP2 : g C/m^2/s
237.76 +;
237.77 +; We want to convert these to "m/year" and "g C/m^2/year".
237.78 +;
237.79 + nsec_per_year = 60*60*24*365 ; # seconds per year
237.80 +
237.81 +; Do the necessary conversions.
237.82 + RAIN1 = RAIN1 / 1000.
237.83 + RAIN2 = (RAIN2/ 1000.) * nsec_per_year
237.84 + NPP2 = NPP2 * nsec_per_year
237.85 +
237.86 +; Redo the units.
237.87 + RAIN1@units = "m/yr"
237.88 + RAIN2@units = "m/yr"
237.89 + NPP1@units = "gC/m^2/yr"
237.90 + NPP2@units = "gC/m^2/yr"
237.91 +
237.92 +;************************************************
237.93 +; print min/max and unit
237.94 +;************************************************
237.95 + pminmax(RAIN1,"RAIN1")
237.96 + pminmax(RAIN2,"RAIN2")
237.97 + pminmax(NPP1,"NPP1")
237.98 + pminmax(NPP2,"NPP2")
237.99 +
237.100 + RAIN1_1D = ndtooned(RAIN1)
237.101 + RAIN2_1D = ndtooned(RAIN2)
237.102 + NPP1_1D = ndtooned(NPP1)
237.103 + NPP2_1D = ndtooned(NPP2)
237.104 +;
237.105 +; Calculate some "nice" bins for binning the data in equally spaced
237.106 +; ranges.
237.107 +;
237.108 + nbins = 15 ; Number of bins to use.
237.109 +
237.110 + nicevals = nice_mnmxintvl(min(RAIN2_1D),max(RAIN2_1D),nbins,True)
237.111 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
237.112 + range = fspan(nicevals(0),nicevals(1),nvals)
237.113 +;
237.114 +; Use this range information to grab all the values in a
237.115 +; particular range, and then take an average.
237.116 +;
237.117 + nr = dimsizes(range)
237.118 + nx = nr-1
237.119 + xvalues = new((/2,nx/),typeof(RAIN2_1D))
237.120 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
237.121 + dx = xvalues(0,1) - xvalues(0,0) ; range width
237.122 + dx4 = dx/4 ; 1/4 of the range
237.123 + xvalues(1,:) = xvalues(0,:) - dx/5.
237.124 + yvalues = new((/2,nx/),typeof(RAIN2_1D))
237.125 + mn_yvalues = new((/2,nx/),typeof(RAIN2_1D))
237.126 + mx_yvalues = new((/2,nx/),typeof(RAIN2_1D))
237.127 +
237.128 + do nd=0,1
237.129 +;
237.130 +; See if we are doing model or observational data.
237.131 +;
237.132 + if(nd.eq.0) then
237.133 + data = RAIN1_1D
237.134 + npp_data = NPP1_1D
237.135 + else
237.136 + data = RAIN2_1D
237.137 + npp_data = NPP2_1D
237.138 + end if
237.139 +;
237.140 +; Loop through each range and check for values.
237.141 +;
237.142 + do i=0,nr-2
237.143 + if (i.ne.(nr-2)) then
237.144 +; print("")
237.145 +; print("In range ["+range(i)+","+range(i+1)+")")
237.146 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
237.147 + else
237.148 +; print("")
237.149 +; print("In range ["+range(i)+",)")
237.150 + idx = ind(range(i).le.data)
237.151 + end if
237.152 +;
237.153 +; Calculate average, and get min and max.
237.154 +;
237.155 + if(.not.any(ismissing(idx))) then
237.156 + yvalues(nd,i) = avg(npp_data(idx))
237.157 + mn_yvalues(nd,i) = min(npp_data(idx))
237.158 + mx_yvalues(nd,i) = max(npp_data(idx))
237.159 + count = dimsizes(idx)
237.160 + else
237.161 + count = 0
237.162 + yvalues(nd,i) = yvalues@_FillValue
237.163 + mn_yvalues(nd,i) = yvalues@_FillValue
237.164 + mx_yvalues(nd,i) = yvalues@_FillValue
237.165 + end if
237.166 +;
237.167 +; Print out information.
237.168 +;
237.169 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
237.170 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
237.171 +
237.172 +;
237.173 +; Clean up for next time in loop.
237.174 +;
237.175 + delete(idx)
237.176 + end do
237.177 + delete(data)
237.178 + delete(npp_data)
237.179 + end do
237.180 +
237.181 +;
237.182 +; Start the graphics.
237.183 +;
237.184 + wks = gsn_open_wks("png","hist")
237.185 +
237.186 + res = True
237.187 + res@gsnMaximize = True
237.188 + res@gsnDraw = False
237.189 + res@gsnFrame = False
237.190 + res@xyMarkLineMode = "Markers"
237.191 + res@xyMarkerSizeF = 0.014
237.192 + res@xyMarker = 16
237.193 + res@xyMarkerColors = (/"Brown","Blue"/)
237.194 + res@trYMinF = min(mn_yvalues) - 10.
237.195 + res@trYMaxF = max(mx_yvalues) + 10.
237.196 +
237.197 + res@tiMainString = "Observed 81 sites"
237.198 +; res@tiMainString = "Observed 933 sites"
237.199 + res@tiYAxisString = "NPP (g C/m2/year)"
237.200 + res@tiXAxisString = "Precipitation (m/year)"
237.201 +
237.202 +;
237.203 +; Add a boxed legend using the more simple method, which won't have
237.204 +; vertical lines going through the markers.
237.205 +;
237.206 +; res@pmLegendDisplayMode = "Always"
237.207 +;;res@pmLegendWidthF = 0.1
237.208 +; res@pmLegendWidthF = 0.08
237.209 +; res@pmLegendHeightF = 0.05
237.210 +; res@pmLegendOrthogonalPosF = -1.17
237.211 +;;res@pmLegendOrthogonalPosF = -1.00 ;(downward)
237.212 +;;res@pmLegendParallelPosF = 0.18
237.213 +; res@pmLegendParallelPosF = 0.23 ;(rightward)
237.214 +
237.215 +; res@lgPerimOn = False
237.216 +; res@lgLabelFontHeightF = 0.015
237.217 +; res@xyExplicitLegendLabels = (/"observed","model_i01.03cn"/)
237.218 +;;res@xyExplicitLegendLabels = (/"observed","model_i01.04casa"/)
237.219 +
237.220 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),res)
237.221 +
237.222 + max_bar = new((/2,nx/),graphic)
237.223 + min_bar = new((/2,nx/),graphic)
237.224 + max_cap = new((/2,nx/),graphic)
237.225 + min_cap = new((/2,nx/),graphic)
237.226 +
237.227 + lnres = True
237.228 +
237.229 + line_colors = (/"brown","blue"/)
237.230 +; do nd=0,1
237.231 + do nd=0,0
237.232 + lnres@gsLineColor = line_colors(nd)
237.233 + do i=0,nx-1
237.234 +
237.235 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
237.236 + .not.ismissing(mx_yvalues(nd,i))) then
237.237 +;
237.238 +; Attach the vertical bar, both above and below the marker.
237.239 +;
237.240 + x1 = xvalues(nd,i)
237.241 + y1 = yvalues(nd,i)
237.242 + y2 = mn_yvalues(nd,i)
237.243 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
237.244 +
237.245 + y2 = mx_yvalues(nd,i)
237.246 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
237.247 +;
237.248 +; Attach the horizontal cap line, both above and below the marker.
237.249 +;
237.250 + x1 = xvalues(nd,i) - dx4
237.251 + x2 = xvalues(nd,i) + dx4
237.252 + y1 = mn_yvalues(nd,i)
237.253 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
237.254 +
237.255 + y1 = mx_yvalues(nd,i)
237.256 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
237.257 + end if
237.258 + end do
237.259 + end do
237.260 +
237.261 +;
237.262 +; Here's how to do the legend by hand.
237.263 +;
237.264 +; mkres = True ; Marker resources
237.265 +; txres = True ; Text resources
237.266 +; mkres@gsMarkerIndex = 16
237.267 +; mkres@gsMarkerSizeF = 0.02
237.268 +; txres@txFontHeightF = 0.02
237.269 +; txres@txJust = "CenterLeft"
237.270 +;
237.271 +; Change these values if you want to move the marker legend location.
237.272 +; These values are in the same data space as the plot.
237.273 +;
237.274 +; xlg1_cen = 0.2
237.275 +; ylg1_cen = 900.
237.276 +
237.277 +; xlg2_cen = 0.2
237.278 +; ylg2_cen = 760.
237.279 +
237.280 +; mkres@gsMarkerColor = "brown"
237.281 +; lnres@gsLineColor = "brown"
237.282 +
237.283 +; lg_mark_legend1 = gsn_add_polymarker(wks,xy,xlg1_cen,ylg1_cen,mkres)
237.284 +; lg_line_legend1 = gsn_add_polyline(wks,xy,(/xlg1_cen,xlg1_cen/), \
237.285 +; (/ylg1_cen-60,ylg1_cen+60/),lnres)
237.286 +; lg_cap_legend11 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
237.287 +; (/ylg1_cen-60,ylg1_cen-60/),lnres)
237.288 +; lg_cap_legend12 = gsn_add_polyline(wks,xy,(/xlg1_cen-0.1,xlg1_cen+0.1/), \
237.289 +; (/ylg1_cen+60,ylg1_cen+60/),lnres)
237.290 +
237.291 +; tx_legend1 = gsn_add_text(wks,xy,"observed",xlg1_cen+0.15,ylg1_cen,txres)
237.292 +
237.293 +; mkres@gsMarkerColor = "blue"
237.294 +; lnres@gsLineColor = "blue"
237.295 +
237.296 +; lg_mark_legend2 = gsn_add_polymarker(wks,xy,xlg2_cen,ylg2_cen,mkres)
237.297 +; lg_line_legend2 = gsn_add_polyline(wks,xy,(/xlg2_cen,xlg2_cen/), \
237.298 +; (/ylg2_cen-60,ylg2_cen+60/),lnres)
237.299 +; lg_cap_legend21 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
237.300 +; (/ylg2_cen-60,ylg2_cen-60/),lnres)
237.301 +; lg_cap_legend22 = gsn_add_polyline(wks,xy,(/xlg2_cen-0.1,xlg2_cen+0.1/), \
237.302 +; (/ylg2_cen+60,ylg2_cen+60/),lnres)
237.303 +; tx_legend2 = gsn_add_text(wks,xy,"model_i01.03cn",xlg2_cen+0.15,ylg2_cen,txres)
237.304 +
237.305 + draw(xy)
237.306 + frame(wks)
237.307 +
237.308 +end
237.309 +
238.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
238.2 +++ b/npp/31.contour_model.ncl Mon Jan 26 22:08:20 2009 -0500
238.3 @@ -0,0 +1,65 @@
238.4 +;*************************************************
238.5 +; ce_1.ncl
238.6 +;************************************************
238.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
238.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
238.9 +;************************************************
238.10 +begin
238.11 +;************************************************
238.12 +; read in netCDF file
238.13 +;************************************************
238.14 +; fili = "Npp_0.05deg_mean.nc"
238.15 + fili = "Npp_T42_mean.nc"
238.16 +; fili = "i01.03cn_1545-1569_ANN_climo.nc"
238.17 +; fili = "i01.04casa_1605-1629_ANN_climo.nc"
238.18 +
238.19 + a = addfile(fili,"r")
238.20 +
238.21 +;************************************************
238.22 +; read in data
238.23 +;************************************************
238.24 +; x = a->NPP(::10,::10) ; for observed 0.05deg
238.25 + x = a->NPP
238.26 +
238.27 + nsec_per_year = 60*60*24*365
238.28 +
238.29 +;scale_factor = nsec_per_year ; for model
238.30 + scale_factor = 1. ; for observed T42
238.31 +;scale_factor = 0.1 ; for observed 0.05deg
238.32 +
238.33 + x = x * scale_factor
238.34 +
238.35 + x@units = "gC/m^2/year"
238.36 +;************************************************
238.37 +; create default plot
238.38 +;************************************************
238.39 +
238.40 +; setvalues NhlGetWorkspaceObjectId()
238.41 +; "wsMaximumSize" : 199999999
238.42 +; end setvalues
238.43 +
238.44 + wks = gsn_open_wks("png","xy") ; open a ps file
238.45 +; gsn_define_colormap(wks,"wgne15") ; choose colormap
238.46 + gsn_define_colormap(wks,"gui_default") ; choose colormap
238.47 +
238.48 + res = True ; Use plot options
238.49 + res@cnFillOn = True ; Turn on color fill
238.50 + res@gsnSpreadColors = True ; use full colormap
238.51 +; res@cnFillMode = "RasterFill" ; Turn on raster color
238.52 +; res@lbLabelAutoStride = True
238.53 + res@cnLinesOn = False ; Turn off contourn lines
238.54 + res@mpFillOn = False ; Turn off map fill
238.55 + res@tiMainString = "Observed MODIS MOD 17"
238.56 +; res@tiMainString = "Model i01.03cn"
238.57 +; res@tiMainString = "Model i01.04casa"
238.58 +
238.59 + res@gsnSpreadColors = True ; use full colormap
238.60 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
238.61 + res@cnMinLevelValF = 0. ; Min level
238.62 + res@cnMaxLevelValF = 2200. ; Max level
238.63 + res@cnLevelSpacingF = 200. ; interval
238.64 +
238.65 + plot = gsn_csm_contour_map_ce(wks,x,res) ; for observed
238.66 +; plot = gsn_csm_contour_map_ce(wks,x(0,:,:),res) ; for model
238.67 +
238.68 +end
238.69 \ No newline at end of file
239.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
239.2 +++ b/npp/31.contour_ob.ncl Mon Jan 26 22:08:20 2009 -0500
239.3 @@ -0,0 +1,58 @@
239.4 +;*************************************************
239.5 +; ce_1.ncl
239.6 +;************************************************
239.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
239.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
239.9 +;************************************************
239.10 +begin
239.11 +;************************************************
239.12 +; read in observed data
239.13 +;************************************************
239.14 +;f = addfile ("Npp_0.05deg_mean.nc","r")
239.15 +;y = f->NPP(::10,::10) ; for observed 0.05deg
239.16 + f = addfile ("Npp_T42_mean.nc","r")
239.17 + y = f->NPP
239.18 +;************************************************
239.19 +; read in model data
239.20 +;************************************************
239.21 + g = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
239.22 +;g = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
239.23 + x = g->NPP
239.24 +
239.25 + delta = 0.00000000001
239.26 + x0 = x(0,:,:)
239.27 + y = where(ismissing(y).and.(ismissing(x0).or.(x0.lt.delta)),0.,y)
239.28 +
239.29 + y@units = "gC/m^2/year"
239.30 +;************************************************
239.31 +; create default plot
239.32 +;************************************************
239.33 +
239.34 +; setvalues NhlGetWorkspaceObjectId()
239.35 +; "wsMaximumSize" : 199999999
239.36 +; end setvalues
239.37 +
239.38 + wks = gsn_open_wks("png","xy") ; open a ps file
239.39 +; gsn_define_colormap(wks,"wgne15") ; choose colormap
239.40 + gsn_define_colormap(wks,"gui_default") ; choose colormap
239.41 +
239.42 + res = True ; Use plot options
239.43 + res@cnFillOn = True ; Turn on color fill
239.44 + res@gsnSpreadColors = True ; use full colormap
239.45 +; res@cnFillMode = "RasterFill" ; Turn on raster color
239.46 +; res@lbLabelAutoStride = True
239.47 + res@cnLinesOn = False ; Turn off contourn lines
239.48 + res@mpFillOn = False ; Turn off map fill
239.49 + res@tiMainString = "Observed MODIS MOD 17"
239.50 +; res@tiMainString = "Model i01.03cn"
239.51 +; res@tiMainString = "Model i01.04casa"
239.52 +
239.53 + res@gsnSpreadColors = True ; use full colormap
239.54 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
239.55 + res@cnMinLevelValF = 0. ; Min level
239.56 + res@cnMaxLevelValF = 2200. ; Max level
239.57 + res@cnLevelSpacingF = 200. ; interval
239.58 +
239.59 + plot = gsn_csm_contour_map_ce(wks,y,res) ; for observed
239.60 +
239.61 +end
239.62 \ No newline at end of file
240.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
240.2 +++ b/npp/32.contour_diff.ncl Mon Jan 26 22:08:20 2009 -0500
240.3 @@ -0,0 +1,87 @@
240.4 +;*************************************************
240.5 +; ce_1.ncl
240.6 +;************************************************
240.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
240.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
240.9 +;************************************************
240.10 +begin
240.11 +;************************************************
240.12 +; read in observed data
240.13 +;************************************************
240.14 + f = addfile ("Npp_T42_mean.nc","r")
240.15 + y = f->NPP
240.16 +;************************************************
240.17 +; read in model data
240.18 +;************************************************
240.19 + g = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
240.20 +;g = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
240.21 + x = g->NPP
240.22 +
240.23 + nsec_per_year = 86400.*365.
240.24 + x = x * nsec_per_year
240.25 +
240.26 + x@units = "gC/m^2/year"
240.27 +;************************************************
240.28 +;fill ob missing grid the same as model
240.29 +;************************************************
240.30 + delta = 0.00001
240.31 + x0 = x(0,:,:)
240.32 + y = where(ismissing(y).and.(ismissing(x0).or.(x0.lt.delta)),0.,y)
240.33 +
240.34 + y@units = "gC/m^2/year"
240.35 +;************************************************
240.36 +;model - observed
240.37 +;************************************************
240.38 + z = x
240.39 + z = x(0,:,:) - y(:,:)
240.40 +;************************************************
240.41 +; create 3 plots
240.42 +;************************************************
240.43 + wks = gsn_open_wks("ps","xy") ; open a ps file
240.44 + gsn_define_colormap(wks,"gui_default") ; choose colormap
240.45 +
240.46 + res = True ; Use plot options
240.47 + res@cnFillOn = True ; Turn on color fill
240.48 + res@gsnSpreadColors = True ; use full colormap
240.49 +; res@cnFillMode = "RasterFill" ; Turn on raster color
240.50 +; res@lbLabelAutoStride = True
240.51 + res@cnLinesOn = False ; Turn off contourn lines
240.52 + res@mpFillOn = False ; Turn off map fill
240.53 + res@tiMainString = "Observed MODIS MOD 17"
240.54 +
240.55 + res@gsnSpreadColors = True ; use full colormap
240.56 + res@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
240.57 + res@cnMinLevelValF = 0. ; Min level
240.58 + res@cnMaxLevelValF = 2200. ; Max level
240.59 + res@cnLevelSpacingF = 200. ; interval
240.60 +
240.61 + res@gsnFrame = False ; Do not draw plot
240.62 + res@gsnDraw = False ; Do not advance frame
240.63 +
240.64 + plot=new(3,graphic) ; create graphic array
240.65 +
240.66 + plot(0) = gsn_csm_contour_map_ce(wks,y,res) ; for observed
240.67 +
240.68 + res@tiMainString = "Model i01.03cn"
240.69 +; res@tiMainString = "Model i01.04casa"
240.70 + plot(1) = gsn_csm_contour_map_ce(wks,x(0,:,:),res) ; for model
240.71 +
240.72 + res@cnMinLevelValF = -500 ; Min level
240.73 + res@cnMaxLevelValF = 500. ; Max level
240.74 + res@cnLevelSpacingF = 50. ; interval
240.75 + res@tiMainString = "(Model i01.03cn) - (observed)"
240.76 +; res@tiMainString = "(Model i01.04casa) - (observed)"
240.77 + plot(2) = gsn_csm_contour_map_ce(wks,z(0,:,:),res) ; for model - ob
240.78 +
240.79 +;***********************************************
240.80 +; create panel plot
240.81 +;***********************************************
240.82 + pres = True ; panel plot mods desired
240.83 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
240.84 + ; indiv. plots in panel
240.85 + pres@gsnMaximize = True ; fill the page
240.86 +
240.87 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
240.88 +
240.89 + system("convert xy.ps xy.png")
240.90 +end
240.91 \ No newline at end of file
241.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
241.2 +++ b/npp/41.correlation.ncl Mon Jan 26 22:08:20 2009 -0500
241.3 @@ -0,0 +1,49 @@
241.4 +; ***********************************************
241.5 +; xy_4.ncl
241.6 +; ***********************************************
241.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
241.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
241.9 +;************************************************
241.10 +begin
241.11 +;************************************************
241.12 +; read in data
241.13 +;************************************************
241.14 + g = addfile ("data.81.nc","r")
241.15 + a = g->SITE_ID
241.16 + xo = g->LONG_DD
241.17 + yo = g->LAT_DD
241.18 +;c = g->TNPP_C
241.19 +;c = g->ANPP_C
241.20 + c = g->BNPP_C
241.21 +
241.22 + print (xo)
241.23 + nx = dimsizes(xo)
241.24 + do i= 0,nx-1
241.25 + if (xo(i) .lt. 0.) then
241.26 + xo(i) = xo(i)+ 360.
241.27 + end if
241.28 + end do
241.29 + print (xo)
241.30 +
241.31 + a@long_name = "SITE_ID"
241.32 +
241.33 + f = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
241.34 +;f = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
241.35 +;b = f->NPP
241.36 +;b = f->AGNPP
241.37 + b = f->BGNPP
241.38 + xi = f->lon
241.39 + yi = f->lat
241.40 +
241.41 + sec_to_year = 86400.*365.
241.42 +
241.43 + bo = linint2_points(xi,yi,b,True,xo,yo,0) * sec_to_year
241.44 +;print (bo)
241.45 +
241.46 + bo@long_name = "NPP (gC/m2/year)"
241.47 +
241.48 + ccr = esccr(bo,c,0)
241.49 +
241.50 + print (ccr)
241.51 +
241.52 +end
242.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
242.2 +++ b/npp/41.correlation_zonal.ncl Mon Jan 26 22:08:20 2009 -0500
242.3 @@ -0,0 +1,31 @@
242.4 +; ***********************************************
242.5 +; xy_4.ncl
242.6 +; ***********************************************
242.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
242.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
242.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
242.10 +;************************************************
242.11 +begin
242.12 +;************************************************
242.13 +; read in data
242.14 +;************************************************
242.15 + g = addfile ("Npp_T31_mean.nc","r")
242.16 + c = g->NPP
242.17 + u = zonalAve(c)
242.18 +
242.19 +;f = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
242.20 + f = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
242.21 + b = f->NPP
242.22 +
242.23 + sec_to_year = 86400.*365.
242.24 +
242.25 + b = b * sec_to_year
242.26 + v = zonalAve(b)
242.27 +
242.28 + b@long_name = "NPP (gC/m2/year)"
242.29 +
242.30 + ccr = esccr(u,v(0,:),0)
242.31 +
242.32 + print (ccr)
242.33 +
242.34 +end
243.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
243.2 +++ b/npp/42.bias_global.nc Mon Jan 26 22:08:20 2009 -0500
243.3 @@ -0,0 +1,43 @@
243.4 +; ***********************************************
243.5 +; xy_4.ncl
243.6 +; ***********************************************
243.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
243.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
243.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
243.10 +;************************************************
243.11 +begin
243.12 +;************************************************
243.13 +; read in data
243.14 +;************************************************
243.15 + g = addfile ("Npp_T42_mean.nc","r")
243.16 + c = g->NPP
243.17 + u = ndtooned(c)
243.18 +
243.19 +;f = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
243.20 + f = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
243.21 + b = f->NPP
243.22 + v = ndtooned(b)
243.23 +
243.24 + sec_to_year = 86400.*365.
243.25 + v = v * sec_to_year
243.26 +
243.27 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
243.28 + uu = u(good)
243.29 + nx = dimsizes(uu)
243.30 +;print (nx)
243.31 +
243.32 + do i = 0,nx-1
243.33 + if (uu(i) .lt. 1.) then
243.34 + uu(i) =10.
243.35 + end if
243.36 + end do
243.37 +
243.38 + ccr = esccr(uu,v(good),0)
243.39 + print (ccr)
243.40 +;print (uu)
243.41 + bias = sum(((v(good)-uu)/uu)^2)
243.42 + print (bias)
243.43 + M = 1.- sqrt(bias/nx)
243.44 + print (M)
243.45 +
243.46 +end
244.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
244.2 +++ b/npp/42.bias_normalized.ncl Mon Jan 26 22:08:20 2009 -0500
244.3 @@ -0,0 +1,60 @@
244.4 +; ***********************************************
244.5 +; xy_4.ncl
244.6 +; ***********************************************
244.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
244.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
244.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
244.10 +;************************************************
244.11 +begin
244.12 +;************************************************
244.13 +; read in data
244.14 +;************************************************
244.15 + g = addfile ("data.81.nc","r")
244.16 + a = g->SITE_ID
244.17 + xo = g->LONG_DD
244.18 + yo = g->LAT_DD
244.19 + c = g->TNPP_C
244.20 +;c = g->ANPP_C
244.21 +;c = g->BNPP_C
244.22 + cp = g->PREC_ANN
244.23 + do i= 0,dimsizes(cp)-1
244.24 + if (ismissing(cp(i))) then
244.25 + cp (i) = 100
244.26 + end if
244.27 + end do
244.28 + d = int2flt(c)/int2flt(cp)
244.29 + print (d)
244.30 +
244.31 + nx = dimsizes(xo)
244.32 + do i= 0,nx-1
244.33 + if (xo(i) .lt. 0.) then
244.34 + xo(i) = xo(i)+ 360.
244.35 + end if
244.36 + end do
244.37 +;print (xo)
244.38 +
244.39 + f = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
244.40 +;f = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
244.41 + b = f->NPP
244.42 +;b = f->AGNPP
244.43 +;b = f->BGNPP
244.44 + xi = f->lon
244.45 + yi = f->lat
244.46 + bp = f->RAIN
244.47 +
244.48 + sec_to_year = 86400.*365.
244.49 +
244.50 + bo = linint2_points(xi,yi,b,True,xo,yo,0) * sec_to_year
244.51 +;print (bo)
244.52 + bq = linint2_points(xi,yi,bp,True,xo,yo,0) * sec_to_year
244.53 +
244.54 + bo = bo/bq
244.55 +
244.56 + ccr = esccr(bo,d,0)
244.57 + print (ccr)
244.58 + bias = sum(((bo(0,:)-d(:))/d(:))^2)
244.59 + print (bias)
244.60 + M = 1. - sqrt(bias/nx)
244.61 + print (M)
244.62 +
244.63 +end
245.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
245.2 +++ b/npp/42.bias_zonal.nc Mon Jan 26 22:08:20 2009 -0500
245.3 @@ -0,0 +1,42 @@
245.4 +; ***********************************************
245.5 +; xy_4.ncl
245.6 +; ***********************************************
245.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
245.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
245.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
245.10 +;************************************************
245.11 +begin
245.12 +;************************************************
245.13 +; read in observed data
245.14 +;************************************************
245.15 + f = addfile ("Npp_T42_mean.nc","r")
245.16 + y = f->NPP
245.17 +;************************************************
245.18 +; read in model data
245.19 +;************************************************
245.20 + g = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
245.21 +;g = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
245.22 + x = g->NPP
245.23 +
245.24 + delta = 0.00000000001
245.25 + x0 = x(0,:,:)
245.26 + y = where(ismissing(y).and.(ismissing(x0).or.(x0.lt.delta)),0.,y)
245.27 +
245.28 + p = zonalAve(y)
245.29 +
245.30 + sec_to_year = 86400.*365.
245.31 + x0 = x0 * sec_to_year
245.32 + q = zonalAve(x0)
245.33 +
245.34 + good = ind(p .ne. 0.)
245.35 + u = p(good)
245.36 + v = q(good)
245.37 +
245.38 + ccr = esccr(u,v,0)
245.39 + print (ccr)
245.40 + bias = sum(((v-u)/u)^2)
245.41 + print (bias)
245.42 + M = 1.- sqrt(bias/dimsizes(u))
245.43 + print (M)
245.44 +
245.45 +end
246.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
246.2 +++ b/npp/51.zonavg.ncl Mon Jan 26 22:08:20 2009 -0500
246.3 @@ -0,0 +1,32 @@
246.4 +; ***********************************************
246.5 +; xy_1.ncl
246.6 +; ***********************************************
246.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
246.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
246.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
246.10 +;************************************************
246.11 +begin
246.12 +;************************************************
246.13 +; read in data
246.14 +;************************************************
246.15 +;f = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
246.16 + f = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
246.17 + u = f->NPP
246.18 + v = zonalAve(u)
246.19 +
246.20 + nsec_per_year = 60*60*24*365
246.21 +
246.22 + v = v * nsec_per_year
246.23 +
246.24 + v@long_name = "NPP (gC/m2/year)"
246.25 +;************************************************
246.26 +; plotting parameters
246.27 +;************************************************
246.28 + wks = gsn_open_wks ("png","xy")
246.29 +
246.30 + res = True
246.31 +;res@tiMainString = "Model i01.03cn"
246.32 + res@tiMainString = "Model i01.04casa"
246.33 +
246.34 + plot = gsn_csm_xy (wks,v&lat,v(0,:),res)
246.35 +end
246.36 \ No newline at end of file
247.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
247.2 +++ b/npp/51.zonavg_ob.ncl Mon Jan 26 22:08:20 2009 -0500
247.3 @@ -0,0 +1,26 @@
247.4 +; ***********************************************
247.5 +; xy_1.ncl
247.6 +; ***********************************************
247.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
247.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
247.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
247.10 +;************************************************
247.11 +begin
247.12 +;************************************************
247.13 +; read in data
247.14 +;************************************************
247.15 + f = addfile ("Npp_T31_mean.nc","r")
247.16 + u = f->NPP
247.17 + v = zonalAve(u)
247.18 +
247.19 + v@long_name = "NPP (gC/m2/year)"
247.20 +;************************************************
247.21 +; plotting parameters
247.22 +;************************************************
247.23 + wks = gsn_open_wks ("png","xy")
247.24 +
247.25 + res = True
247.26 + res@tiMainString = "Observed"
247.27 +
247.28 + plot = gsn_csm_xy (wks,v&lat,v,res)
247.29 +end
247.30 \ No newline at end of file
248.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
248.2 +++ b/npp/51.zonavg_ob2.ncl Mon Jan 26 22:08:20 2009 -0500
248.3 @@ -0,0 +1,49 @@
248.4 +; ***********************************************
248.5 +; xy_1.ncl
248.6 +; ***********************************************
248.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
248.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
248.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
248.10 +;************************************************
248.11 +begin
248.12 +;************************************************
248.13 +; read in data
248.14 +;************************************************
248.15 + f = addfile ("Npp_T42_mean.nc","r")
248.16 + u = f->NPP
248.17 +;************************************************
248.18 +; read in model data
248.19 +;************************************************
248.20 + g = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
248.21 + x = g->NPP
248.22 + lat = g->lat
248.23 + lon = g->lon
248.24 +
248.25 + delta = 0.00000000001
248.26 + x0 = x(0,:,:)
248.27 + u = where(ismissing(u).and.(ismissing(x0).or.(x0.lt.delta)),0.,u)
248.28 +
248.29 +; do j = 0,dimsizes(lat)-1
248.30 +; do i = 0,dimsizes(lon)-1
248.31 +; print(u(j,i))
248.32 +; print(x(0,j,i))
248.33 +; if (ismissing(u(j,i)) .and. (ismissing(x(0,j,i)).or. \
248.34 +; x(0,j,i) .lt. 0.00000000001)) then
248.35 +; u(j,i) = 0.
248.36 +; end if
248.37 +; end do
248.38 +; end do
248.39 +
248.40 + v = zonalAve(u)
248.41 +
248.42 + v@long_name = "NPP (gC/m2/year)"
248.43 +;************************************************
248.44 +; plotting parameters
248.45 +;************************************************
248.46 + wks = gsn_open_wks ("png","xy")
248.47 +
248.48 + res = True
248.49 + res@tiMainString = "Observed MODIS MOD 17"
248.50 +
248.51 + plot = gsn_csm_xy (wks,v&lat,v,res)
248.52 +end
248.53 \ No newline at end of file
249.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
249.2 +++ b/npp/52.zonavg_to_T31.ncl Mon Jan 26 22:08:20 2009 -0500
249.3 @@ -0,0 +1,62 @@
249.4 +; ***********************************************
249.5 +; zonal average plot
249.6 +; ***********************************************
249.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
249.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
249.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
249.10 +;************************************************
249.11 +begin
249.12 +;************************************************
249.13 +; read in observed data
249.14 +;************************************************
249.15 + g = addfile ("Npp_0.05deg_mean.nc","r")
249.16 + bi = g->NPP
249.17 + xi = g->lon
249.18 + yi = g->lat
249.19 + yi = (/ yi(::-1) /)
249.20 + bi = (/ bi(::-1,:) /)
249.21 + b2 = bi
249.22 + x2 = xi
249.23 +
249.24 + nx = dimsizes(xi)
249.25 + do i= 0,nx-1
249.26 + if (i .lt. 3600) then
249.27 + p = i + 3600
249.28 + xi(p) = x2(i) + 360.
249.29 + else
249.30 + p = i - 3600
249.31 + xi(p) = x2(i)
249.32 + end if
249.33 + bi(:,p)= b2(:,i)
249.34 + end do
249.35 +;print (xi)
249.36 +;print (yi)
249.37 +;exit
249.38 +
249.39 + f = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
249.40 +;f = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
249.41 +
249.42 + xo = f->lon
249.43 + yo = f->lat
249.44 +
249.45 + print (xi)
249.46 + print (yi)
249.47 + print (xo)
249.48 + print (yo)
249.49 +
249.50 + bo = linint2_Wrap(xi,yi,bi,True,xo,yo,0)
249.51 +
249.52 + v = zonalAve(bo)
249.53 +
249.54 + v@long_name = "NPP (gC/m2/year)"
249.55 +
249.56 +;************************************************
249.57 +; plotting parameters
249.58 +;************************************************
249.59 + wks = gsn_open_wks ("png","xy") ; open workstation
249.60 +
249.61 + res = True ; plot mods desired
249.62 + res@tiMainString = "Observed T31" ; add title
249.63 +
249.64 + plot = gsn_csm_xy (wks,v&lat,v,res)
249.65 +end
250.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
250.2 +++ b/npp/53.zonavg_3line.ncl Mon Jan 26 22:08:20 2009 -0500
250.3 @@ -0,0 +1,125 @@
250.4 +; ***********************************************
250.5 +; zonal average plot
250.6 +; ***********************************************
250.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
250.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
250.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
250.10 +;************************************************
250.11 +begin
250.12 +
250.13 +;************************************************
250.14 +; read in observed data
250.15 +;************************************************
250.16 +
250.17 + a = addfile ("Npp_T42_mean.nc","r")
250.18 + b = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
250.19 + c = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
250.20 +
250.21 + ta = a->NPP
250.22 + tb = b->NPP
250.23 + tc = c->NPP
250.24 +
250.25 + lon = a->lon
250.26 + lat = a->lat
250.27 + nlon = dimsizes(lon)
250.28 + nlat = dimsizes(lat)
250.29 +
250.30 + s = new ((/3,nlat/), float)
250.31 +
250.32 +;************************************************
250.33 +; set value to 0. at missing point of observed
250.34 +;************************************************
250.35 + delta = 0.00000000001
250.36 + x0 = tb(0,:,:)
250.37 + ta = where(ismissing(ta).and.(ismissing(x0).or.(x0.lt.delta)),0.,ta)
250.38 +
250.39 + s(0,:) = zonalAve(ta(:,:))
250.40 + delete (ta)
250.41 +
250.42 +;************************************************
250.43 +; for model data
250.44 +;************************************************
250.45 + scale_factor = 86400.*365.
250.46 +
250.47 + s(1,:) = zonalAve(tb(0,:,:)) * scale_factor
250.48 + delete (tb)
250.49 +
250.50 + s(2,:) = zonalAve(tc(0,:,:)) * scale_factor
250.51 + delete (tc)
250.52 +
250.53 + s@long_name = "NPP (gC/m2/year)"
250.54 +
250.55 +;*****************************************************
250.56 +; create plot
250.57 +;*****************************************************
250.58 + wks = gsn_open_wks("png","xy") ; create plot
250.59 + i = NhlNewColor(wks,1.0,0.71,0.76) ; add color to colormap
250.60 + j = NhlNewColor(wks,0.64,0.71,0.8) ; ditto
250.61 +
250.62 + res = True ; plot mods desired
250.63 + res@gsnDraw = False ; don't draw yet
250.64 + res@gsnFrame = False ; don't advance frame yet
250.65 +
250.66 +; res@vpHeightF = 0.4 ; change aspect ratio of plot
250.67 +; res@vpWidthF = 0.7
250.68 +
250.69 +; res@trXMinF = 1890 ; set x-axis minimum
250.70 +
250.71 + res@xyMonoLineColor = "False" ; want colored lines
250.72 + res@xyLineColors = (/"Red","Blue","Black"/) ; colors chosen
250.73 +; res@xyLineThicknesses = (/3.,3.,4./) ; line thicknesses
250.74 + res@xyLineThicknesses = (/2.,2.,2./) ; line thicknesses
250.75 + res@xyDashPatterns = (/0.,0.,0./) ; make all lines solid
250.76 +
250.77 + res@tiMainString = "Zoanl Average"
250.78 + res@tiYAxisString = "NPP (gC/m2/year)" ; add a axis title
250.79 + res@txFontHeightF = 0.0195 ; change title font heights
250.80 +
250.81 + plot = gsn_csm_xy (wks,lat,s,res) ; create plot
250.82 +
250.83 +; plot = fill_xy2(wks,plot(0),time,mnmx(2,:),mnmx(3,:),(/0.64,0.71,0.8/),\
250.84 +; (/0.64,0.71,0.8/))
250.85 +; plot = fill_xy2(wks,plot(0),time,mnmx(0,:),mnmx(1,:),(/1.0,0.71,0.76/),\
250.86 +; (/1.0,0.71,0.76/))
250.87 +;*****************************************************
250.88 +; Manually create legend
250.89 +;*****************************************************
250.90 + res_text = True ; text mods desired
250.91 + res_text@txFontHeightF = 0.015 ; change text size
250.92 + res_text@txJust = "CenterLeft" ; text justification
250.93 +
250.94 + res_lines = True ; polyline mods desired
250.95 + res_lines@gsLineDashPattern = 0. ; solid line
250.96 + res_lines@gsLineThicknessF = 5. ; line thicker
250.97 + res_lines@gsLineColor = "red" ; line color
250.98 + xx = (/-85.,-75./)
250.99 + yy = (/1400.,1400./)
250.100 + gsn_polyline(wks,plot,xx,yy,res_lines) ; add polyline
250.101 + gsn_text(wks,plot,"Observed",-70.,1400.,res_text); add text
250.102 +
250.103 + yy = (/1500.,1500./)
250.104 + res_lines@gsLineColor = "blue" ; change to blue
250.105 + gsn_polyline(wks,plot,xx,yy,res_lines) ; add polyline
250.106 + gsn_text(wks,plot,"Model i01.03cn",-70.,1500.,res_text) ; add text
250.107 +
250.108 + yy = (/1600.,1600./)
250.109 + res_lines@gsLineColor = "black" ; change to black
250.110 + gsn_polyline(wks,plot,xx,yy,res_lines) ; add poly line
250.111 + gsn_text(wks,plot,"Model i01.04casa",-70.,1600.,res_text) ; add text
250.112 +;*****************************************************
250.113 +; Manually create titles
250.114 +;*****************************************************
250.115 +; res_text@txJust = "CenterCenter" ; change justification
250.116 +; res_text@txFontHeightF = 0.03 ; change font size
250.117 +; gsn_text_ndc(wks,"Parallel Climate Model Ensembles",0.55,0.90,res_text)
250.118 +
250.119 +; res_text@txFontHeightF = 0.02 ; change font size
250.120 +; gsn_text_ndc(wks,"Global Temperature Anomalies",0.55,0.86,res_text)
250.121 +
250.122 +; res_text@txFontHeightF = 0.015 ; change font size
250.123 +; gsn_text_ndc(wks,"from 1890-1919 average",0.55,0.83,res_text)
250.124 +
250.125 + draw(plot)
250.126 + frame(wks) ; advance frame
250.127 +
250.128 +end
251.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
251.2 +++ b/npp/99.all.ncl Mon Jan 26 22:08:20 2009 -0500
251.3 @@ -0,0 +1,1358 @@
251.4 +;*****************************************************
251.5 +; combine scatter, histogram, global and zonal plots
251.6 +; compute all correlation coef and M score
251.7 +; add 1-to-1 line in scatter plots
251.8 +;*****************************************************
251.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
251.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
251.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
251.12 +;****************************************************************************
251.13 +procedure set_line(lines:string,nline:integer,newlines:string)
251.14 +begin
251.15 +; add line to ascci/html file
251.16 +
251.17 + nnewlines = dimsizes(newlines)
251.18 + if(nline+nnewlines-1.ge.dimsizes(lines))
251.19 + print("set_line: bad index, not setting anything.")
251.20 + return
251.21 + end if
251.22 + lines(nline:nline+nnewlines-1) = newlines
251.23 +; print ("lines = " + lines(nline:nline+nnewlines-1))
251.24 + nline = nline + nnewlines
251.25 + return
251.26 +end
251.27 +;****************************************************************************
251.28 +procedure get_bin(RAIN1_1D[*]:numeric, NPP1_1D[*]:numeric \
251.29 + ,RAIN2_1D[*]:numeric, NPP2_1D[*]:numeric \
251.30 + ,xvalues[*][*]:numeric, yvalues[*][*]:numeric \
251.31 + ,mn_yvalues[*][*]:numeric, mx_yvalues[*][*]:numeric \
251.32 + ,dx4[1]:numeric \
251.33 + )
251.34 +begin
251.35 +; Calculaee "nice" bins for binning the data in equally spaced ranges.
251.36 +; input : RAIN1_1D, RAIN2_1D, NPP1_1D, NPP2_1D
251.37 +; output: xvalues, yvalues, mn_yvalues, mx_yvalues,dx4
251.38 +
251.39 + nbins = 15 ; Number of bins to use.
251.40 +
251.41 + nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
251.42 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
251.43 + range = fspan(nicevals(0),nicevals(1),nvals)
251.44 +
251.45 +; Use this range information to grab all the values in a
251.46 +; particular range, and then take an average.
251.47 +
251.48 + nr = dimsizes(range)
251.49 + nx = nr-1
251.50 +; print (nx)
251.51 +
251.52 +; xvalues = new((/2,nx/),typeof(RAIN1_1D))
251.53 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
251.54 + dx = xvalues(0,1) - xvalues(0,0) ; range width
251.55 + dx4 = dx/4 ; 1/4 of the range
251.56 + xvalues(1,:) = xvalues(0,:) - dx/5.
251.57 +; yvalues = new((/2,nx/),typeof(RAIN1_1D))
251.58 +; mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
251.59 +; mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
251.60 +
251.61 + do nd=0,1
251.62 +
251.63 +; See if we are doing model or observational data.
251.64 +
251.65 + if(nd.eq.0) then
251.66 + data = RAIN1_1D
251.67 + npp_data = NPP1_1D
251.68 + else
251.69 + data = RAIN2_1D
251.70 + npp_data = NPP2_1D
251.71 + end if
251.72 +
251.73 +; Loop through each range and check for values.
251.74 +
251.75 + do i=0,nr-2
251.76 + if (i.ne.(nr-2)) then
251.77 +; print("")
251.78 +; print("In range ["+range(i)+","+range(i+1)+")")
251.79 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
251.80 + else
251.81 +; print("")
251.82 +; print("In range ["+range(i)+",)")
251.83 + idx = ind(range(i).le.data)
251.84 + end if
251.85 +
251.86 +; Calculate average, and get min and max.
251.87 +
251.88 + if(.not.any(ismissing(idx))) then
251.89 + yvalues(nd,i) = avg(npp_data(idx))
251.90 + mn_yvalues(nd,i) = min(npp_data(idx))
251.91 + mx_yvalues(nd,i) = max(npp_data(idx))
251.92 + count = dimsizes(idx)
251.93 + else
251.94 + count = 0
251.95 + yvalues(nd,i) = yvalues@_FillValue
251.96 + mn_yvalues(nd,i) = yvalues@_FillValue
251.97 + mx_yvalues(nd,i) = yvalues@_FillValue
251.98 + end if
251.99 +
251.100 +; Print out information.
251.101 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
251.102 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
251.103 +
251.104 +; Clean up for next time in loop.
251.105 +
251.106 + delete(idx)
251.107 + end do
251.108 + delete(data)
251.109 + delete(npp_data)
251.110 + end do
251.111 +end
251.112 +;****************************************************************************
251.113 +; Main code.
251.114 +;****************************************************************************
251.115 +begin
251.116 +
251.117 + plot_type = "ps"
251.118 + plot_type_new = "png"
251.119 +
251.120 +;************************************************
251.121 +; read model data
251.122 +;************************************************
251.123 +
251.124 +;film = "i01.06cn_1798-2004_ANN_climo.nc"
251.125 +;model_name = "06cn"
251.126 +;model_grid = "T42"
251.127 +
251.128 +;film = "i01.06casa_1798-2004_ANN_climo.nc"
251.129 +;model_name = "06casa"
251.130 +;model_grid = "T42"
251.131 +
251.132 +;film = "i01.10casa_1948-2004_ANN_climo.nc"
251.133 +;model_name = "10casa"
251.134 +;model_grid = "T42"
251.135 +
251.136 + film = "i01.10cn_1948-2004_ANN_climo.nc"
251.137 + model_name = "10cn"
251.138 + model_grid = "T42"
251.139 +
251.140 + html_name = "table.html." + model_name
251.141 + html_new = html_name +".new"
251.142 + system("sed s#model_name#"+model_name+"# "+html_name+" > "+html_new+";"+ \
251.143 + "mv -f "+html_new+" "+html_name)
251.144 +;--------------------------------------------------
251.145 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
251.146 + fm = addfile (dirm+film,"r")
251.147 +
251.148 + nppmod0 = fm->NPP
251.149 + rainmod0 = fm->RAIN
251.150 + xm = fm->lon
251.151 + ym = fm->lat
251.152 +
251.153 +;************************************************
251.154 +; read ob data
251.155 +;************************************************
251.156 +
251.157 +;(1) data at 81 sites
251.158 + dir81 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
251.159 + fil81 = "data.81.nc"
251.160 + f81 = addfile (dir81+fil81,"r")
251.161 +
251.162 + id81 = f81->SITE_ID
251.163 + npp81 = f81->TNPP_C
251.164 + rain81 = tofloat(f81->PREC_ANN)
251.165 + x81 = f81->LONG_DD
251.166 + y81 = f81->LAT_DD
251.167 +
251.168 + id81@long_name = "SITE_ID"
251.169 +
251.170 +;change longitude from (-180,180) to (0,360)
251.171 +;for model data interpolation
251.172 +
251.173 + do i= 0,dimsizes(x81)-1
251.174 + if (x81(i) .lt. 0.) then
251.175 + x81(i) = x81(i)+ 360.
251.176 + end if
251.177 + end do
251.178 +;print (x81)
251.179 +;-------------------------------------
251.180 +;(2) data at 933 sites
251.181 + dir933 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
251.182 + fil933 = "data.933.nc"
251.183 + f933 = addfile (dir933+fil933,"r")
251.184 +
251.185 + id933 = f933->SITE_ID
251.186 + npp933 = f933->TNPP_C
251.187 + rain933 = f933->PREC
251.188 + x933 = f933->LONG_DD
251.189 + y933 = f933->LAT_DD
251.190 +
251.191 + id933@long_name = "SITE_ID"
251.192 +
251.193 +;change longitude from (-180,180) to (0,360)
251.194 +;for model data interpolation
251.195 +
251.196 + do i= 0,dimsizes(x933)-1
251.197 + if (x933(i) .lt. 0.) then
251.198 + x933(i) = x933(i)+ 360.
251.199 + end if
251.200 + end do
251.201 +;print (x933)
251.202 +;----------------------------------------
251.203 +;(3) global data, interpolated into model grid
251.204 + dirglobe = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
251.205 + filglobe = "Npp_"+model_grid+"_mean.nc"
251.206 + fglobe = addfile (dirglobe+filglobe,"r")
251.207 +
251.208 + nppglobe0 = fglobe->NPP
251.209 + nppglobe = nppglobe0
251.210 +
251.211 +;***********************************************************************
251.212 +; interpolate model data into ob sites
251.213 +;***********************************************************************
251.214 +
251.215 + nppmod = nppmod0(0,:,:)
251.216 + rainmod = rainmod0(0,:,:)
251.217 + delete (nppmod0)
251.218 + delete (rainmod0)
251.219 +
251.220 + nppmod81 =linint2_points(xm,ym,nppmod,True,x81,y81,0)
251.221 +
251.222 + nppmod933 =linint2_points(xm,ym,nppmod,True,x933,y933,0)
251.223 +
251.224 + rainmod81 =linint2_points(xm,ym,rainmod,True,x81,y81,0)
251.225 +
251.226 + rainmod933=linint2_points(xm,ym,rainmod,True,x933,y933,0)
251.227 +
251.228 +;**********************************************************
251.229 +; unified units
251.230 +;**********************************************************
251.231 +; Units for these variables are:
251.232 +;
251.233 +; rain81 : mm/year
251.234 +; rainmod : mm/s
251.235 +; npp81 : g C/m^2/year
251.236 +; nppmod81: g C/m^2/s
251.237 +; nppglobe: g C/m^2/year
251.238 +;
251.239 +; We want to convert these to "m/year" and "g C/m^2/year".
251.240 +
251.241 + nsec_per_year = 60*60*24*365
251.242 +
251.243 + rain81 = rain81 / 1000.
251.244 + rainmod81 = (rainmod81/ 1000.) * nsec_per_year
251.245 + nppmod81 = nppmod81 * nsec_per_year
251.246 +
251.247 + rain933 = rain933 / 1000.
251.248 + rainmod933 = (rainmod933/ 1000.) * nsec_per_year
251.249 + nppmod933 = nppmod933 * nsec_per_year
251.250 +
251.251 + nppmod = nppmod * nsec_per_year
251.252 +
251.253 + npp81@units = "gC/m^2/yr"
251.254 + nppmod81@units = "gC/m^2/yr"
251.255 + npp933@units = "gC/m^2/yr"
251.256 + nppmod933@units = "gC/m^2/yr"
251.257 + nppmod@units = "gC/m^2/yr"
251.258 + nppglobe@units = "gC/m^2/yr"
251.259 + rain81@units = "m/yr"
251.260 + rainmod81@units = "m/yr"
251.261 + rain933@units = "m/yr"
251.262 + rainmod933@units = "m/yr"
251.263 +
251.264 + npp81@long_name = "NPP (gC/m2/year)"
251.265 + npp933@long_name = "NPP (gC/m2/year)"
251.266 + nppmod81@long_name = "NPP (gC/m2/year)"
251.267 + nppmod933@long_name = "NPP (gC/m2/year)"
251.268 + nppmod@long_name = "NPP (gC/m2/year)"
251.269 + nppglobe@long_name = "NPP (gC/m2/year)"
251.270 + rain81@long_name = "PREC (m/year)"
251.271 + rain933@long_name = "PREC (m/year)"
251.272 + rainmod81@long_name = "PREC (m/year)"
251.273 + rainmod933@long_name = "PREC (m/year)"
251.274 +
251.275 +;*******************************************************************
251.276 +;(A)-1 html table of site81 -- observed
251.277 +;*******************************************************************
251.278 + output_html = "table_site81_ob.html"
251.279 +
251.280 + header = (/"<HTML>" \
251.281 + ,"<HEAD>" \
251.282 + ,"<TITLE>CLAMP metrics</TITLE>" \
251.283 + ,"</HEAD>" \
251.284 + ,"<H1>Observation at 81 sites</H1>" \
251.285 + /)
251.286 + footer = "</HTML>"
251.287 +
251.288 + table_header = (/ \
251.289 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
251.290 + ,"<tr>" \
251.291 + ," <th bgcolor=DDDDDD >Site ID</th>" \
251.292 + ," <th bgcolor=DDDDDD >Latitude</th>" \
251.293 + ," <th bgcolor=DDDDDD >Longitude</th>" \
251.294 + ," <th bgcolor=DDDDDD >NPP(gC/m2.year)</th>" \
251.295 + ," <th bgcolor=DDDDDD >RAIN(m/year)</th>" \
251.296 + ,"</tr>" \
251.297 + /)
251.298 + table_footer = "</table>"
251.299 + row_header = "<tr>"
251.300 + row_footer = "</tr>"
251.301 +
251.302 + lines = new(50000,string)
251.303 + nline = 0
251.304 +
251.305 + set_line(lines,nline,header)
251.306 + set_line(lines,nline,table_header)
251.307 +;-----------------------------------------------
251.308 +;row of table
251.309 +
251.310 + nrow = dimsizes(id81)
251.311 + do n = 0,nrow-1
251.312 + set_line(lines,nline,row_header)
251.313 +
251.314 + txt1 = sprintf("%5.0f", id81(n))
251.315 + txt2 = sprintf("%5.2f", y81(n))
251.316 + txt3 = sprintf("%5.2f", x81(n))
251.317 + txt4 = sprintf("%5.2f", npp81(n))
251.318 + txt5 = sprintf("%5.2f", rain81(n))
251.319 +
251.320 + set_line(lines,nline,"<th>"+txt1+"</th>")
251.321 + set_line(lines,nline,"<th>"+txt2+"</th>")
251.322 + set_line(lines,nline,"<th>"+txt3+"</th>")
251.323 + set_line(lines,nline,"<th>"+txt4+"</th>")
251.324 + set_line(lines,nline,"<th>"+txt5+"</th>")
251.325 +
251.326 + set_line(lines,nline,row_footer)
251.327 + end do
251.328 +;-----------------------------------------------
251.329 + set_line(lines,nline,table_footer)
251.330 + set_line(lines,nline,footer)
251.331 +
251.332 +; Now write to an HTML file.
251.333 + idx = ind(.not.ismissing(lines))
251.334 + if(.not.any(ismissing(idx))) then
251.335 + asciiwrite(output_html,lines(idx))
251.336 + else
251.337 + print ("error?")
251.338 + end if
251.339 +;*******************************************************************
251.340 +;(A)-2 html table of site933 -- observed
251.341 +;*******************************************************************
251.342 + output_html = "table_site933_ob.html"
251.343 +
251.344 + header = (/"<HTML>" \
251.345 + ,"<HEAD>" \
251.346 + ,"<TITLE>CLAMP metrics</TITLE>" \
251.347 + ,"</HEAD>" \
251.348 + ,"<H1>Observation at 933 sites</H1>" \
251.349 + /)
251.350 + footer = "</HTML>"
251.351 +
251.352 + table_header = (/ \
251.353 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
251.354 + ,"<tr>" \
251.355 + ," <th bgcolor=DDDDDD >Site ID</th>" \
251.356 + ," <th bgcolor=DDDDDD >Latitude</th>" \
251.357 + ," <th bgcolor=DDDDDD >Longitude</th>" \
251.358 + ," <th bgcolor=DDDDDD >NPP(gC/m2.year)</th>" \
251.359 + ," <th bgcolor=DDDDDD >RAIN(m/year)</th>" \
251.360 + ,"</tr>" \
251.361 + /)
251.362 + table_footer = "</table>"
251.363 + row_header = "<tr>"
251.364 + row_footer = "</tr>"
251.365 +
251.366 + delete (lines)
251.367 + lines = new(50000,string)
251.368 + nline = 0
251.369 +
251.370 + set_line(lines,nline,header)
251.371 + set_line(lines,nline,table_header)
251.372 +;-----------------------------------------------
251.373 +;row of table
251.374 +
251.375 + nrow = dimsizes(id933)
251.376 + do n = 0,nrow-1
251.377 + set_line(lines,nline,row_header)
251.378 +
251.379 + txt1 = sprintf("%5.0f", id933(n))
251.380 + txt2 = sprintf("%5.2f", y933(n))
251.381 + txt3 = sprintf("%5.2f", x933(n))
251.382 + txt4 = sprintf("%5.2f", npp933(n))
251.383 + txt5 = sprintf("%5.2f", rain933(n))
251.384 +
251.385 + set_line(lines,nline,"<th>"+txt1+"</th>")
251.386 + set_line(lines,nline,"<th>"+txt2+"</th>")
251.387 + set_line(lines,nline,"<th>"+txt3+"</th>")
251.388 + set_line(lines,nline,"<th>"+txt4+"</th>")
251.389 + set_line(lines,nline,"<th>"+txt5+"</th>")
251.390 +
251.391 + set_line(lines,nline,row_footer)
251.392 + end do
251.393 +;-----------------------------------------------
251.394 + set_line(lines,nline,table_footer)
251.395 + set_line(lines,nline,footer)
251.396 +
251.397 +; Now write to an HTML file.
251.398 + delete (idx)
251.399 + idx = ind(.not.ismissing(lines))
251.400 + if(.not.any(ismissing(idx))) then
251.401 + asciiwrite(output_html,lines(idx))
251.402 + else
251.403 + print ("error?")
251.404 + end if
251.405 +;*******************************************************************
251.406 +;(A)-3 html table of site81 -- model vs ob
251.407 +;*******************************************************************
251.408 + output_html = "table_site81_model_vs_ob.html"
251.409 +
251.410 + header_text = "<H1>Model "+model_name+" vs Observed at 81 sites</H1>"
251.411 +
251.412 + header = (/"<HTML>" \
251.413 + ,"<HEAD>" \
251.414 + ,"<TITLE>CLAMP metrics</TITLE>" \
251.415 + ,"</HEAD>" \
251.416 + ,header_text \
251.417 + /)
251.418 + footer = "</HTML>"
251.419 +
251.420 + delete (table_header)
251.421 + table_header_text = " <th bgcolor=DDDDDD >"+model_name+"</th>"
251.422 + table_header = (/ \
251.423 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
251.424 + ,"<tr>" \
251.425 + ," <th bgcolor=DDDDDD rowspan=2>Site ID</th>" \
251.426 + ," <th bgcolor=DDDDDD rowspan=2>Latitude</th>" \
251.427 + ," <th bgcolor=DDDDDD rowspan=2>Longitude</th>" \
251.428 + ," <th bgcolor=DDDDDD colspan=2>NPP(gC/m2.year)</th>" \
251.429 + ," <th bgcolor=DDDDDD colspan=2>RAIN(m/year)</th>" \
251.430 + ,"</tr>" \
251.431 + ,"<tr>" \
251.432 + ," <th bgcolor=DDDDDD >observed</th>" \
251.433 + , table_header_text \
251.434 + ," <th bgcolor=DDDDDD >observed</th>" \
251.435 + , table_header_text \
251.436 + ,"</tr>" \
251.437 + /)
251.438 + table_footer = "</table>"
251.439 + row_header = "<tr>"
251.440 + row_footer = "</tr>"
251.441 +
251.442 + delete (lines)
251.443 + lines = new(50000,string)
251.444 + nline = 0
251.445 +
251.446 + set_line(lines,nline,header)
251.447 + set_line(lines,nline,table_header)
251.448 +;-----------------------------------------------
251.449 +;row of table
251.450 +
251.451 + nrow = dimsizes(id81)
251.452 + do n = 0,nrow-1
251.453 + set_line(lines,nline,row_header)
251.454 +
251.455 + txt1 = sprintf("%5.0f", id81(n))
251.456 + txt2 = sprintf("%5.2f", y81(n))
251.457 + txt3 = sprintf("%5.2f", x81(n))
251.458 + txt4 = sprintf("%5.2f", npp81(n))
251.459 + txt5 = sprintf("%5.2f", nppmod81(n))
251.460 + txt6 = sprintf("%5.2f", rain81(n))
251.461 + txt7 = sprintf("%5.2f", rainmod81(n))
251.462 +
251.463 + set_line(lines,nline,"<th>"+txt1+"</th>")
251.464 + set_line(lines,nline,"<th>"+txt2+"</th>")
251.465 + set_line(lines,nline,"<th>"+txt3+"</th>")
251.466 + set_line(lines,nline,"<th>"+txt4+"</th>")
251.467 + set_line(lines,nline,"<th>"+txt5+"</th>")
251.468 + set_line(lines,nline,"<th>"+txt6+"</th>")
251.469 + set_line(lines,nline,"<th>"+txt7+"</th>")
251.470 +
251.471 + set_line(lines,nline,row_footer)
251.472 + end do
251.473 +;-----------------------------------------------
251.474 + set_line(lines,nline,table_footer)
251.475 + set_line(lines,nline,footer)
251.476 +
251.477 +; Now write to an HTML file.
251.478 + delete (idx)
251.479 + idx = ind(.not.ismissing(lines))
251.480 + if(.not.any(ismissing(idx))) then
251.481 + asciiwrite(output_html,lines(idx))
251.482 + else
251.483 + print ("error?")
251.484 + end if
251.485 +
251.486 +;*******************************************************************
251.487 +;(A)-4 html table of site933 -- model vs ob
251.488 +;*******************************************************************
251.489 + output_html = "table_site933_model_vs_ob.html"
251.490 +
251.491 + header_text = "<H1>Model "+model_name+" vs Observed at 933 sites</H1>"
251.492 +
251.493 + header = (/"<HTML>" \
251.494 + ,"<HEAD>" \
251.495 + ,"<TITLE>CLAMP metrics</TITLE>" \
251.496 + ,"</HEAD>" \
251.497 + ,header_text \
251.498 + /)
251.499 + footer = "</HTML>"
251.500 +
251.501 + delete (table_header)
251.502 + table_header_text = " <th bgcolor=DDDDDD >"+model_name+"</th>"
251.503 + table_header = (/ \
251.504 + "<table border=1 cellspacing=0 cellpadding=3 width=100%>" \
251.505 + ,"<tr>" \
251.506 + ," <th bgcolor=DDDDDD rowspan=2>Site ID</th>" \
251.507 + ," <th bgcolor=DDDDDD rowspan=2>Latitude</th>" \
251.508 + ," <th bgcolor=DDDDDD rowspan=2>Longitude</th>" \
251.509 + ," <th bgcolor=DDDDDD colspan=2>NPP(gC/m2.year)</th>" \
251.510 + ," <th bgcolor=DDDDDD colspan=2>RAIN(m/year)</th>" \
251.511 + ,"</tr>" \
251.512 + ,"<tr>" \
251.513 + ," <th bgcolor=DDDDDD >observed</th>" \
251.514 + , table_header_text \
251.515 + ," <th bgcolor=DDDDDD >observed</th>" \
251.516 + , table_header_text \
251.517 + ,"</tr>" \
251.518 + /)
251.519 + table_footer = "</table>"
251.520 + row_header = "<tr>"
251.521 + row_footer = "</tr>"
251.522 +
251.523 + delete (lines)
251.524 + lines = new(50000,string)
251.525 + nline = 0
251.526 +
251.527 + set_line(lines,nline,header)
251.528 + set_line(lines,nline,table_header)
251.529 +;-----------------------------------------------
251.530 +;row of table
251.531 +
251.532 + nrow = dimsizes(id933)
251.533 + do n = 0,nrow-1
251.534 + set_line(lines,nline,row_header)
251.535 +
251.536 + txt1 = sprintf("%5.0f", id933(n))
251.537 + txt2 = sprintf("%5.2f", y933(n))
251.538 + txt3 = sprintf("%5.2f", x933(n))
251.539 + txt4 = sprintf("%5.2f", npp933(n))
251.540 + txt5 = sprintf("%5.2f", nppmod933(n))
251.541 + txt6 = sprintf("%5.2f", rain933(n))
251.542 + txt7 = sprintf("%5.2f", rainmod933(n))
251.543 +
251.544 + set_line(lines,nline,"<th>"+txt1+"</th>")
251.545 + set_line(lines,nline,"<th>"+txt2+"</th>")
251.546 + set_line(lines,nline,"<th>"+txt3+"</th>")
251.547 + set_line(lines,nline,"<th>"+txt4+"</th>")
251.548 + set_line(lines,nline,"<th>"+txt5+"</th>")
251.549 + set_line(lines,nline,"<th>"+txt6+"</th>")
251.550 + set_line(lines,nline,"<th>"+txt7+"</th>")
251.551 +
251.552 + set_line(lines,nline,row_footer)
251.553 + end do
251.554 +;-----------------------------------------------
251.555 + set_line(lines,nline,table_footer)
251.556 + set_line(lines,nline,footer)
251.557 +
251.558 +; Now write to an HTML file.
251.559 + delete (idx)
251.560 + idx = ind(.not.ismissing(lines))
251.561 + if(.not.any(ismissing(idx))) then
251.562 + asciiwrite(output_html,lines(idx))
251.563 + else
251.564 + print ("error?")
251.565 + end if
251.566 +;***************************************************************************
251.567 +;(A)-5 scatter plot, model vs ob 81
251.568 +;***************************************************************************
251.569 +
251.570 + plot_name = "scatter_model_vs_ob_81"
251.571 + title = model_name +" vs ob 81 sites"
251.572 +
251.573 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
251.574 + res = True ; plot mods desired
251.575 + res@tiMainString = title ; add title
251.576 + res@xyMarkLineModes = "Markers" ; choose which have markers
251.577 + res@xyMarkers = 16 ; choose type of marker
251.578 + res@xyMarkerColor = "red" ; Marker color
251.579 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
251.580 + res@tmLabelAutoStride = True ; nice tick mark labels
251.581 +
251.582 + res@gsnDraw = False
251.583 + res@gsnFrame = False ; don't advance frame yet
251.584 +;-------------------------------
251.585 +;compute correlation coef. and M
251.586 + ccr81 = esccr(nppmod81,npp81,0)
251.587 +;print (ccr81)
251.588 +
251.589 +;new eq
251.590 + bias = sum(abs(nppmod81-npp81)/(abs(nppmod81)+abs(npp81)))
251.591 + M81 = (1. - (bias/dimsizes(y81)))*5.
251.592 +
251.593 + M_npp_S81 = sprintf("%.2f", M81)
251.594 + system("sed s#M_npp_S81#"+M_npp_S81+"# "+html_name+" > "+html_new+";"+ \
251.595 + "mv -f "+html_new+" "+html_name)
251.596 + print (M_npp_S81)
251.597 +
251.598 + tRes = True
251.599 + tRes@txFontHeightF = 0.025
251.600 +
251.601 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81)+")"
251.602 +
251.603 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
251.604 +;--------------------------------
251.605 + plot = gsn_csm_xy (wks,npp81,nppmod81,res) ; create plot
251.606 +;-------------------------------
251.607 +; add polyline
251.608 +
251.609 + dum=gsn_add_polyline(wks,plot,(/0,1200/),(/0,1200/),False)
251.610 +;-------------------------------
251.611 + draw (plot)
251.612 + frame(wks)
251.613 + clear (wks)
251.614 + delete (dum)
251.615 +
251.616 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
251.617 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
251.618 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
251.619 + "rm "+plot_name+"."+plot_type)
251.620 +;***************************************************************************
251.621 +;(A)-6 scatter plot, model vs ob 933
251.622 +;***************************************************************************
251.623 +
251.624 + plot_name = "scatter_model_vs_ob_933"
251.625 + title = model_name +" vs ob 933 sites"
251.626 +
251.627 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
251.628 + res = True ; plot mods desired
251.629 + res@tiMainString = title ; add title
251.630 + res@xyMarkLineModes = "Markers" ; choose which have markers
251.631 + res@xyMarkers = 16 ; choose type of marker
251.632 + res@xyMarkerColor = "red" ; Marker color
251.633 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
251.634 + res@tmLabelAutoStride = True ; nice tick mark labels
251.635 +
251.636 + res@gsnDraw = False
251.637 + res@gsnFrame = False ; don't advance frame yet
251.638 +;-------------------------------
251.639 +;compute correlation coef. and M
251.640 + ccr933 = esccr(nppmod933,npp933,0)
251.641 +;print (ccr933)
251.642 +
251.643 +;new eq
251.644 + bias = sum(abs(nppmod933-npp933)/(abs(nppmod933)+abs(npp933)))
251.645 + M933 = (1. - (bias/dimsizes(y933)))*5.
251.646 +
251.647 + M_npp_S933 = sprintf("%.2f", M933)
251.648 + system("sed s#M_npp_S933#"+M_npp_S933+"# "+html_name+" > "+html_new+";"+ \
251.649 + "mv -f "+html_new+" "+html_name)
251.650 + print (M_npp_S933)
251.651 +
251.652 + tRes = True
251.653 + tRes@txFontHeightF = 0.025
251.654 +
251.655 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933)+")"
251.656 +
251.657 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
251.658 +;--------------------------------
251.659 + plot = gsn_csm_xy (wks,npp933,nppmod933,res) ; create plot
251.660 +;-------------------------------
251.661 +; add polyline
251.662 +
251.663 + dum=gsn_add_polyline(wks,plot,(/0,1500/),(/0,1500/),False)
251.664 +;-------------------------------
251.665 + draw (plot)
251.666 + frame(wks)
251.667 + clear (wks)
251.668 + delete (dum)
251.669 +
251.670 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
251.671 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
251.672 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
251.673 + "rm "+plot_name+"."+plot_type)
251.674 +;**************************************************************************
251.675 +;(B) histogram 81
251.676 +;**************************************************************************
251.677 +;get data
251.678 + RAIN1_1D = ndtooned(rain81)
251.679 + RAIN2_1D = ndtooned(rainmod81)
251.680 + NPP1_1D = ndtooned(npp81)
251.681 + NPP2_1D = ndtooned(nppmod81)
251.682 +
251.683 +; number of bin
251.684 + nx = 8
251.685 +
251.686 + xvalues = new((/2,nx/),float)
251.687 + yvalues = new((/2,nx/),float)
251.688 + mn_yvalues = new((/2,nx/),float)
251.689 + mx_yvalues = new((/2,nx/),float)
251.690 + dx4 = new((/1/),float)
251.691 +
251.692 + get_bin(RAIN1_1D, NPP1_1D, RAIN2_1D, NPP2_1D \
251.693 + ,xvalues,yvalues,mn_yvalues,mx_yvalues,dx4)
251.694 +
251.695 +;----------------------------------------
251.696 +;compute correlation coeff and M score
251.697 +
251.698 + u = yvalues(0,:)
251.699 + v = yvalues(1,:)
251.700 +
251.701 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
251.702 + uu = u(good)
251.703 + vv = v(good)
251.704 +
251.705 + ccr81h = esccr(uu,vv,0)
251.706 +;print (ccr81h)
251.707 +
251.708 +;new eq
251.709 + bias = sum(abs(vv-uu)/(abs(vv)+abs(uu)))
251.710 + M81h = (1.- (bias/dimsizes(uu)))*5.
251.711 +
251.712 + M_npp_H81 = sprintf("%.2f", M81h)
251.713 + system("sed s#M_npp_H81#"+M_npp_H81+"# "+html_name+" > "+html_new+";"+ \
251.714 + "mv -f "+html_new+" "+html_name)
251.715 + print (M_npp_H81)
251.716 +
251.717 + delete (u)
251.718 + delete (v)
251.719 + delete (uu)
251.720 + delete (vv)
251.721 +;----------------------------------------------------------------------
251.722 +; histogram res
251.723 + resh = True
251.724 + resh@gsnMaximize = True
251.725 + resh@gsnDraw = False
251.726 + resh@gsnFrame = False
251.727 + resh@xyMarkLineMode = "Markers"
251.728 + resh@xyMarkerSizeF = 0.014
251.729 + resh@xyMarker = 16
251.730 + resh@xyMarkerColors = (/"Brown","Blue"/)
251.731 + resh@trYMinF = min(mn_yvalues) - 10.
251.732 + resh@trYMaxF = max(mx_yvalues) + 10.
251.733 +
251.734 + resh@tiYAxisString = "NPP (g C/m2/year)"
251.735 + resh@tiXAxisString = "Precipitation (m/year)"
251.736 +
251.737 + max_bar = new((/2,nx/),graphic)
251.738 + min_bar = new((/2,nx/),graphic)
251.739 + max_cap = new((/2,nx/),graphic)
251.740 + min_cap = new((/2,nx/),graphic)
251.741 +
251.742 + lnres = True
251.743 + line_colors = (/"brown","blue"/)
251.744 +
251.745 +;**************************************************************************
251.746 +;(B)-1 histogram plot, ob 81 site
251.747 +;**************************************************************************
251.748 +
251.749 + plot_name = "histogram_ob_81"
251.750 + title = "Observed 81 site"
251.751 + resh@tiMainString = title
251.752 +
251.753 + wks = gsn_open_wks (plot_type,plot_name)
251.754 +
251.755 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
251.756 +
251.757 +;-------------------------------
251.758 +;Attach the vertical bar and the horizontal cap line
251.759 +
251.760 + do nd=0,0
251.761 + lnres@gsLineColor = line_colors(nd)
251.762 + do i=0,nx-1
251.763 +
251.764 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
251.765 + .not.ismissing(mx_yvalues(nd,i))) then
251.766 +;
251.767 +; Attach the vertical bar, both above and below the marker.
251.768 +;
251.769 + x1 = xvalues(nd,i)
251.770 + y1 = yvalues(nd,i)
251.771 + y2 = mn_yvalues(nd,i)
251.772 + plx = (/x1,x1/)
251.773 + ply = (/y1,y2/)
251.774 + min_bar(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
251.775 +
251.776 + y2 = mx_yvalues(nd,i)
251.777 + plx = (/x1,x1/)
251.778 + ply = (/y1,y2/)
251.779 + max_bar(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
251.780 +;
251.781 +; Attach the horizontal cap line, both above and below the marker.
251.782 +;
251.783 + x1 = xvalues(nd,i) - dx4
251.784 + x2 = xvalues(nd,i) + dx4
251.785 + y1 = mn_yvalues(nd,i)
251.786 + plx = (/x1,x2/)
251.787 + ply = (/y1,y1/)
251.788 + min_cap(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
251.789 +
251.790 + y1 = mx_yvalues(nd,i)
251.791 + plx = (/x1,x2/)
251.792 + ply = (/y1,y1/)
251.793 + max_cap(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
251.794 + end if
251.795 + end do
251.796 + end do
251.797 +
251.798 + draw(xy)
251.799 + frame(wks)
251.800 + clear (wks)
251.801 +
251.802 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
251.803 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
251.804 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
251.805 + "rm "+plot_name+"."+plot_type)
251.806 +;****************************************************************************
251.807 +;(B)-2 histogram plot, model vs ob 81 site
251.808 +;****************************************************************************
251.809 +
251.810 + plot_name = "histogram_model_vs_ob_81"
251.811 + title = model_name+ " vs Observed 81 site"
251.812 + resh@tiMainString = title
251.813 +
251.814 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
251.815 +
251.816 +;-----------------------------
251.817 +; Add a boxed legend using the more simple method, which won't have
251.818 +; vertical lines going through the markers.
251.819 +
251.820 + resh@pmLegendDisplayMode = "Always"
251.821 +; resh@pmLegendWidthF = 0.1
251.822 + resh@pmLegendWidthF = 0.08
251.823 + resh@pmLegendHeightF = 0.05
251.824 + resh@pmLegendOrthogonalPosF = -1.17
251.825 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
251.826 +; resh@pmLegendParallelPosF = 0.18
251.827 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
251.828 +
251.829 +; resh@lgPerimOn = False
251.830 + resh@lgLabelFontHeightF = 0.015
251.831 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
251.832 +;-----------------------------
251.833 + tRes = True
251.834 + tRes@txFontHeightF = 0.025
251.835 +
251.836 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81h)+")"
251.837 +
251.838 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
251.839 +
251.840 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
251.841 +;-------------------------------
251.842 +;Attach the vertical bar and the horizontal cap line
251.843 +
251.844 + do nd=0,1
251.845 + lnres@gsLineColor = line_colors(nd)
251.846 + do i=0,nx-1
251.847 +
251.848 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
251.849 + .not.ismissing(mx_yvalues(nd,i))) then
251.850 +;
251.851 +; Attach the vertical bar, both above and below the marker.
251.852 +;
251.853 + x1 = xvalues(nd,i)
251.854 + y1 = yvalues(nd,i)
251.855 + y2 = mn_yvalues(nd,i)
251.856 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
251.857 +
251.858 + y2 = mx_yvalues(nd,i)
251.859 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
251.860 +;
251.861 +; Attach the horizontal cap line, both above and below the marker.
251.862 +;
251.863 + x1 = xvalues(nd,i) - dx4
251.864 + x2 = xvalues(nd,i) + dx4
251.865 + y1 = mn_yvalues(nd,i)
251.866 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
251.867 +
251.868 + y1 = mx_yvalues(nd,i)
251.869 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
251.870 + end if
251.871 + end do
251.872 + end do
251.873 +
251.874 + draw(xy)
251.875 + frame(wks)
251.876 + clear(wks)
251.877 +
251.878 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
251.879 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
251.880 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
251.881 + "rm "+plot_name+"."+plot_type)
251.882 +
251.883 + delete (RAIN1_1D)
251.884 + delete (RAIN2_1D)
251.885 + delete (NPP1_1D)
251.886 + delete (NPP2_1D)
251.887 +;delete (range)
251.888 + delete (xvalues)
251.889 + delete (yvalues)
251.890 + delete (mn_yvalues)
251.891 + delete (mx_yvalues)
251.892 + delete (good)
251.893 + delete (max_bar)
251.894 + delete (min_bar)
251.895 + delete (max_cap)
251.896 + delete (min_cap)
251.897 +
251.898 +;**************************************************************************
251.899 +;(B) histogram 933
251.900 +;**************************************************************************
251.901 +
251.902 +; get data
251.903 + RAIN1_1D = ndtooned(rain933)
251.904 + RAIN2_1D = ndtooned(rainmod933)
251.905 + NPP1_1D = ndtooned(npp933)
251.906 + NPP2_1D = ndtooned(nppmod933)
251.907 +
251.908 +; number of bin
251.909 + nx = 10
251.910 +
251.911 + xvalues = new((/2,nx/),float)
251.912 + yvalues = new((/2,nx/),float)
251.913 + mn_yvalues = new((/2,nx/),float)
251.914 + mx_yvalues = new((/2,nx/),float)
251.915 + dx4 = new((/1/),float)
251.916 +
251.917 + get_bin(RAIN1_1D, NPP1_1D, RAIN2_1D, NPP2_1D \
251.918 + ,xvalues,yvalues,mn_yvalues,mx_yvalues,dx4)
251.919 +
251.920 +;----------------------------------------
251.921 +;compute correlation coeff and M score
251.922 +
251.923 + u = yvalues(0,:)
251.924 + v = yvalues(1,:)
251.925 +
251.926 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
251.927 + uu = u(good)
251.928 + vv = v(good)
251.929 +
251.930 + ccr933h = esccr(uu,vv,0)
251.931 +;print (ccr933h)
251.932 +
251.933 +;new eq
251.934 + bias = sum(abs(vv-uu)/(abs(vv)+abs(uu)))
251.935 + M933h = (1.- (bias/dimsizes(uu)))*5.
251.936 +
251.937 + M_npp_H933 = sprintf("%.2f", M933h)
251.938 + system("sed s#M_npp_H933#"+M_npp_H933+"# "+html_name+" > "+html_new+";"+ \
251.939 + "mv -f "+html_new+" "+html_name)
251.940 + print (M_npp_H933)
251.941 +
251.942 + delete (u)
251.943 + delete (v)
251.944 + delete (uu)
251.945 + delete (vv)
251.946 +;----------------------------------------------------------------------
251.947 +; histogram res
251.948 + delete (resh)
251.949 + resh = True
251.950 + resh@gsnMaximize = True
251.951 + resh@gsnDraw = False
251.952 + resh@gsnFrame = False
251.953 + resh@xyMarkLineMode = "Markers"
251.954 + resh@xyMarkerSizeF = 0.014
251.955 + resh@xyMarker = 16
251.956 + resh@xyMarkerColors = (/"Brown","Blue"/)
251.957 + resh@trYMinF = min(mn_yvalues) - 10.
251.958 + resh@trYMaxF = max(mx_yvalues) + 10.
251.959 +
251.960 + resh@tiYAxisString = "NPP (g C/m2/year)"
251.961 + resh@tiXAxisString = "Precipitation (m/year)"
251.962 +
251.963 + max_bar = new((/2,nx/),graphic)
251.964 + min_bar = new((/2,nx/),graphic)
251.965 + max_cap = new((/2,nx/),graphic)
251.966 + min_cap = new((/2,nx/),graphic)
251.967 +
251.968 + lnres = True
251.969 + line_colors = (/"brown","blue"/)
251.970 +
251.971 +;**************************************************************************
251.972 +;(B)-3 histogram plot, ob 933 site
251.973 +;**************************************************************************
251.974 +
251.975 + plot_name = "histogram_ob_933"
251.976 + title = "Observed 933 site"
251.977 + resh@tiMainString = title
251.978 +
251.979 + wks = gsn_open_wks (plot_type,plot_name)
251.980 +
251.981 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
251.982 +
251.983 +;-------------------------------
251.984 +;Attach the vertical bar and the horizontal cap line
251.985 +
251.986 + do nd=0,0
251.987 + lnres@gsLineColor = line_colors(nd)
251.988 + do i=0,nx-1
251.989 +
251.990 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
251.991 + .not.ismissing(mx_yvalues(nd,i))) then
251.992 +
251.993 +; Attach the vertical bar, both above and below the marker.
251.994 +
251.995 + x1 = xvalues(nd,i)
251.996 + y1 = yvalues(nd,i)
251.997 + y2 = mn_yvalues(nd,i)
251.998 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
251.999 +
251.1000 + y2 = mx_yvalues(nd,i)
251.1001 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
251.1002 +
251.1003 +; Attach the horizontal cap line, both above and below the marker.
251.1004 +
251.1005 + x1 = xvalues(nd,i) - dx4
251.1006 + x2 = xvalues(nd,i) + dx4
251.1007 + y1 = mn_yvalues(nd,i)
251.1008 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
251.1009 +
251.1010 + y1 = mx_yvalues(nd,i)
251.1011 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
251.1012 + end if
251.1013 + end do
251.1014 + end do
251.1015 +
251.1016 + draw(xy)
251.1017 + frame(wks)
251.1018 + delete (xy)
251.1019 + clear (wks)
251.1020 +
251.1021 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
251.1022 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
251.1023 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
251.1024 + "rm "+plot_name+"."+plot_type)
251.1025 +;****************************************************************************
251.1026 +;(B)-4 histogram plot, model vs ob 933 site
251.1027 +;****************************************************************************
251.1028 +
251.1029 + plot_name = "histogram_model_vs_ob_933"
251.1030 + title = model_name+ " vs Observed 933 site"
251.1031 + resh@tiMainString = title
251.1032 +
251.1033 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
251.1034 +
251.1035 +;-----------------------------
251.1036 +; Add a boxed legend using the more simple method, which won't have
251.1037 +; vertical lines going through the markers.
251.1038 +
251.1039 + resh@pmLegendDisplayMode = "Always"
251.1040 +; resh@pmLegendWidthF = 0.1
251.1041 + resh@pmLegendWidthF = 0.08
251.1042 + resh@pmLegendHeightF = 0.05
251.1043 + resh@pmLegendOrthogonalPosF = -1.17
251.1044 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
251.1045 +; resh@pmLegendParallelPosF = 0.18
251.1046 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
251.1047 +
251.1048 +; resh@lgPerimOn = False
251.1049 + resh@lgLabelFontHeightF = 0.015
251.1050 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
251.1051 +;-----------------------------
251.1052 + tRes = True
251.1053 + tRes@txFontHeightF = 0.025
251.1054 +
251.1055 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933h)+")"
251.1056 +
251.1057 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
251.1058 +
251.1059 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
251.1060 +;-------------------------------
251.1061 +;Attach the vertical bar and the horizontal cap line
251.1062 +
251.1063 + do nd=0,1
251.1064 + lnres@gsLineColor = line_colors(nd)
251.1065 + do i=0,nx-1
251.1066 +
251.1067 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
251.1068 + .not.ismissing(mx_yvalues(nd,i))) then
251.1069 +;
251.1070 +; Attach the vertical bar, both above and below the marker.
251.1071 +;
251.1072 + x1 = xvalues(nd,i)
251.1073 + y1 = yvalues(nd,i)
251.1074 + y2 = mn_yvalues(nd,i)
251.1075 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
251.1076 +
251.1077 + y2 = mx_yvalues(nd,i)
251.1078 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
251.1079 +;
251.1080 +; Attach the horizontal cap line, both above and below the marker.
251.1081 +;
251.1082 + x1 = xvalues(nd,i) - dx4
251.1083 + x2 = xvalues(nd,i) + dx4
251.1084 + y1 = mn_yvalues(nd,i)
251.1085 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
251.1086 +
251.1087 + y1 = mx_yvalues(nd,i)
251.1088 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
251.1089 + end if
251.1090 + end do
251.1091 + end do
251.1092 +
251.1093 + draw(xy)
251.1094 + frame(wks)
251.1095 + delete(xy)
251.1096 + clear(wks)
251.1097 +
251.1098 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
251.1099 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
251.1100 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
251.1101 + "rm "+plot_name+"."+plot_type)
251.1102 +;***************************************************************************
251.1103 +;(C) global contour
251.1104 +;***************************************************************************
251.1105 +
251.1106 +;res
251.1107 + resg = True ; Use plot options
251.1108 + resg@cnFillOn = True ; Turn on color fill
251.1109 + resg@gsnSpreadColors = True ; use full colormap
251.1110 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
251.1111 +; resg@lbLabelAutoStride = True
251.1112 + resg@cnLinesOn = False ; Turn off contourn lines
251.1113 + resg@mpFillOn = False ; Turn off map fill
251.1114 +
251.1115 + resg@gsnSpreadColors = True ; use full colormap
251.1116 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
251.1117 + resg@cnMinLevelValF = 0. ; Min level
251.1118 + resg@cnMaxLevelValF = 2200. ; Max level
251.1119 + resg@cnLevelSpacingF = 200. ; interval
251.1120 +
251.1121 +;****************************************************************************
251.1122 +;(C)-1 global contour plot, ob
251.1123 +;****************************************************************************
251.1124 +
251.1125 + delta = 0.00000000001
251.1126 + nppglobe = where(ismissing(nppglobe).and.(ismissing(nppmod).or.(nppmod.lt.delta)),0.,nppglobe)
251.1127 +
251.1128 + plot_name = "global_ob"
251.1129 + title = "Observed MODIS MOD 17"
251.1130 + resg@tiMainString = title
251.1131 +
251.1132 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
251.1133 + gsn_define_colormap(wks,"gui_default") ; choose colormap
251.1134 +
251.1135 + plot = gsn_csm_contour_map_ce(wks,nppglobe,resg)
251.1136 +
251.1137 + frame(wks)
251.1138 + clear (wks)
251.1139 +
251.1140 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
251.1141 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
251.1142 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
251.1143 + "rm "+plot_name+"."+plot_type)
251.1144 +;****************************************************************************
251.1145 +;(C)-2 global contour plot, model
251.1146 +;****************************************************************************
251.1147 +
251.1148 + plot_name = "global_model"
251.1149 + title = "Model "+ model_name
251.1150 + resg@tiMainString = title
251.1151 +
251.1152 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
251.1153 + gsn_define_colormap(wks,"gui_default") ; choose colormap
251.1154 +
251.1155 + plot = gsn_csm_contour_map_ce(wks,nppmod,resg)
251.1156 +
251.1157 + frame(wks)
251.1158 + clear (wks)
251.1159 +
251.1160 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
251.1161 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
251.1162 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
251.1163 + "rm "+plot_name+"."+plot_type)
251.1164 +;****************************************************************************
251.1165 +;(C)-3 global contour plot, model vs ob
251.1166 +;****************************************************************************
251.1167 +
251.1168 + plot_name = "global_model_vs_ob"
251.1169 +
251.1170 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
251.1171 + gsn_define_colormap(wks,"gui_default") ; choose colormap
251.1172 +
251.1173 + delete (plot)
251.1174 + plot=new(3,graphic) ; create graphic array
251.1175 +
251.1176 + resg@gsnFrame = False ; Do not draw plot
251.1177 + resg@gsnDraw = False ; Do not advance frame
251.1178 +
251.1179 +; compute correlation coef and M score
251.1180 +
251.1181 + uu1 = ndtooned(nppmod)
251.1182 + vv1 = ndtooned(nppglobe)
251.1183 +
251.1184 + delete (good)
251.1185 + good = ind(.not.ismissing(uu1) .and. .not.ismissing(vv1))
251.1186 +
251.1187 + ug = uu1(good)
251.1188 + vg = vv1(good)
251.1189 +
251.1190 + ccrG = esccr(ug,vg,0)
251.1191 +; print (ccrG)
251.1192 +
251.1193 + MG = (ccrG*ccrG)* 5.0
251.1194 +
251.1195 + M_npp_G = sprintf("%.2f", MG)
251.1196 + system("sed s#M_npp_G#"+M_npp_G+"# "+html_name+" > "+html_new+";"+ \
251.1197 + "mv -f "+html_new+" "+html_name)
251.1198 + print (M_npp_G)
251.1199 +
251.1200 +; plot correlation coef
251.1201 +
251.1202 + gRes = True
251.1203 + gRes@txFontHeightF = 0.02
251.1204 + gRes@txAngleF = 90
251.1205 +
251.1206 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrG)+")"
251.1207 +
251.1208 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
251.1209 +;--------------------------------------------------------------------
251.1210 +;(a) ob
251.1211 +
251.1212 + title = "Observed MODIS MOD 17"
251.1213 + resg@tiMainString = title
251.1214 +
251.1215 + plot(0) = gsn_csm_contour_map_ce(wks,nppglobe,resg)
251.1216 +
251.1217 +;(b) model
251.1218 +
251.1219 + title = "Model "+ model_name
251.1220 + resg@tiMainString = title
251.1221 +
251.1222 + plot(1) = gsn_csm_contour_map_ce(wks,nppmod,resg)
251.1223 +
251.1224 +;(c) model-ob
251.1225 +
251.1226 + zz = nppmod
251.1227 + zz = nppmod - nppglobe
251.1228 + title = "Model_"+model_name+" - Observed"
251.1229 +
251.1230 + resg@cnMinLevelValF = -500 ; Min level
251.1231 + resg@cnMaxLevelValF = 500. ; Max level
251.1232 + resg@cnLevelSpacingF = 50. ; interval
251.1233 + resg@tiMainString = title
251.1234 +
251.1235 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
251.1236 +
251.1237 + pres = True ; panel plot mods desired
251.1238 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
251.1239 + ; indiv. plots in panel
251.1240 + pres@gsnMaximize = True ; fill the page
251.1241 +
251.1242 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
251.1243 +
251.1244 + frame (wks)
251.1245 + clear (wks)
251.1246 + delete (plot)
251.1247 +
251.1248 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
251.1249 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
251.1250 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
251.1251 + "rm "+plot_name+"."+plot_type)
251.1252 +;***************************************************************************
251.1253 +;(D)-1 zonal line plot, ob
251.1254 +;***************************************************************************
251.1255 +
251.1256 + vv = zonalAve(nppglobe)
251.1257 + vv@long_name = nppglobe@long_name
251.1258 +
251.1259 + plot_name = "zonal_ob"
251.1260 + title = "Observed MODIS MOD 17"
251.1261 +
251.1262 + resz = True
251.1263 + resz@tiMainString = title
251.1264 +
251.1265 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
251.1266 +
251.1267 + plot = gsn_csm_xy (wks,ym,vv,resz)
251.1268 +
251.1269 + frame(wks)
251.1270 + clear (wks)
251.1271 +
251.1272 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
251.1273 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
251.1274 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
251.1275 + "rm "+plot_name+"."+plot_type)
251.1276 +;****************************************************************************
251.1277 +;(D)-2 zonal line plot, model vs ob
251.1278 +;****************************************************************************
251.1279 +
251.1280 + s = new ((/2,dimsizes(ym)/), float)
251.1281 +
251.1282 + s(0,:) = zonalAve(nppglobe)
251.1283 + s(1,:) = zonalAve(nppmod)
251.1284 +
251.1285 + s@long_name = nppglobe@long_name
251.1286 +;-------------------------------------------
251.1287 +; compute correlation coef and M score
251.1288 +
251.1289 + ccrZ = esccr(s(1,:), s(0,:),0)
251.1290 +; print (ccrZ)
251.1291 +
251.1292 + MZ = (ccrZ*ccrZ)* 5.0
251.1293 +
251.1294 + M_npp_Z = sprintf("%.2f", MZ)
251.1295 + system("sed s#M_npp_Z#"+M_npp_Z+"# "+html_name+" > "+html_new+";"+ \
251.1296 + "mv -f "+html_new+" "+html_name)
251.1297 + print (M_npp_Z)
251.1298 +;-------------------------------------------
251.1299 + plot_name = "zonal_model_vs_ob"
251.1300 + title = "Zonal Average"
251.1301 + resz@tiMainString = title
251.1302 +
251.1303 + wks = gsn_open_wks (plot_type,plot_name)
251.1304 +
251.1305 +; resz@vpHeightF = 0.4 ; change aspect ratio of plot
251.1306 +; resz@vpWidthF = 0.7
251.1307 +
251.1308 + resz@xyMonoLineColor = "False" ; want colored lines
251.1309 + resz@xyLineColors = (/"black","red"/) ; colors chosen
251.1310 +; resz@xyLineThicknesses = (/3.,3./) ; line thicknesses
251.1311 + resz@xyLineThicknesses = (/2.,2./) ; line thicknesses
251.1312 + resz@xyDashPatterns = (/0.,0./) ; make all lines solid
251.1313 +
251.1314 + resz@tiYAxisString = s@long_name ; add a axis title
251.1315 + resz@txFontHeightF = 0.0195 ; change title font heights
251.1316 +
251.1317 +; Legent
251.1318 + resz@pmLegendDisplayMode = "Always" ; turn on legend
251.1319 + resz@pmLegendSide = "Top" ; Change location of
251.1320 +; resz@pmLegendParallelPosF = .45 ; move units right
251.1321 + resz@pmLegendParallelPosF = .82 ; move units right
251.1322 + resz@pmLegendOrthogonalPosF = -0.4 ; move units down
251.1323 +
251.1324 + resz@pmLegendWidthF = 0.10 ; Change width and
251.1325 + resz@pmLegendHeightF = 0.10 ; height of legend.
251.1326 + resz@lgLabelFontHeightF = .02 ; change font height
251.1327 +; resz@lgTitleOn = True ; turn on legend title
251.1328 +; resz@lgTitleString = "Example" ; create legend title
251.1329 +; resz@lgTitleFontHeightF = .025 ; font of legend title
251.1330 + resz@xyExplicitLegendLabels = (/"Observed",model_name/) ; explicit labels
251.1331 +;--------------------------------------------------------------------
251.1332 + zRes = True
251.1333 + zRes@txFontHeightF = 0.025
251.1334 +
251.1335 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrZ)+")"
251.1336 +
251.1337 + gsn_text_ndc(wks,correlation_text,0.50,0.77,zRes)
251.1338 +;--------------------------------------------------------------------
251.1339 +
251.1340 + plot = gsn_csm_xy (wks,ym,s,resz)
251.1341 +
251.1342 + frame(wks)
251.1343 + clear (wks)
251.1344 +
251.1345 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
251.1346 + "mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new+";"+ \
251.1347 + "rm "+plot_name+"-*."+plot_type_new+";"+ \
251.1348 + "rm "+plot_name+"."+plot_type)
251.1349 +;***************************************************************************
251.1350 +; tar up output plots
251.1351 +;***************************************************************************
251.1352 +
251.1353 + temp_name = "npp." + model_name
251.1354 + system("mkdir -p " + temp_name+";"+ \
251.1355 + "cp "+ html_name + " " +temp_name+"/table.html"+";"+ \
251.1356 + "mv table_*.html " + temp_name +";"+ \
251.1357 + "mv *.png " + temp_name +";"+ \
251.1358 + "tar cf "+ temp_name +".tar " + temp_name)
251.1359 +;***************************************************************************
251.1360 +end
251.1361 +
252.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
252.2 +++ b/npp/99.all.ncl.0 Mon Jan 26 22:08:20 2009 -0500
252.3 @@ -0,0 +1,1683 @@
252.4 +; ****************************************************
252.5 +; combine scatter, histogram, global and zonal plots
252.6 +; compute all correlation coef and M score
252.7 +; add 1-to-1 line in scatter plots
252.8 +; ****************************************************
252.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
252.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
252.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
252.12 +;************************************************
252.13 +procedure get_bin(RAIN1_1D[*]:numeric, NPP1_1D[*]:numeric \
252.14 + ,RAIN2_1D[*]:numeric, NPP2_1D[*]:numeric \
252.15 + ,xvalues[*][*]:numeric, yvalues[*][*]:numeric \
252.16 + ,mn_yvalues[*][*]:numeric, mx_yvalues[*][*]:numeric \
252.17 + ,dx4[1]:numeric \
252.18 + )
252.19 +begin
252.20 +; Calculaee "nice" bins for binning the data in equally spaced ranges.
252.21 +; input : RAIN1_1D, RAIN2_1D, NPP1_1D, NPP2_1D
252.22 +; output: xvalues, yvalues, mn_yvalues, mx_yvalues,dx4
252.23 +
252.24 + nbins = 15 ; Number of bins to use.
252.25 +
252.26 + nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
252.27 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
252.28 + range = fspan(nicevals(0),nicevals(1),nvals)
252.29 +
252.30 +; Use this range information to grab all the values in a
252.31 +; particular range, and then take an average.
252.32 +
252.33 + nr = dimsizes(range)
252.34 + nx = nr-1
252.35 +; print (nx)
252.36 +
252.37 +; xvalues = new((/2,nx/),typeof(RAIN1_1D))
252.38 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
252.39 + dx = xvalues(0,1) - xvalues(0,0) ; range width
252.40 + dx4 = dx/4 ; 1/4 of the range
252.41 + xvalues(1,:) = xvalues(0,:) - dx/5.
252.42 +; yvalues = new((/2,nx/),typeof(RAIN1_1D))
252.43 +; mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
252.44 +; mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
252.45 +
252.46 + do nd=0,1
252.47 +
252.48 +; See if we are doing model or observational data.
252.49 +
252.50 + if(nd.eq.0) then
252.51 + data = RAIN1_1D
252.52 + npp_data = NPP1_1D
252.53 + else
252.54 + data = RAIN2_1D
252.55 + npp_data = NPP2_1D
252.56 + end if
252.57 +
252.58 +; Loop through each range and check for values.
252.59 +
252.60 + do i=0,nr-2
252.61 + if (i.ne.(nr-2)) then
252.62 +; print("")
252.63 +; print("In range ["+range(i)+","+range(i+1)+")")
252.64 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
252.65 + else
252.66 +; print("")
252.67 +; print("In range ["+range(i)+",)")
252.68 + idx = ind(range(i).le.data)
252.69 + end if
252.70 +
252.71 +; Calculate average, and get min and max.
252.72 +
252.73 + if(.not.any(ismissing(idx))) then
252.74 + yvalues(nd,i) = avg(npp_data(idx))
252.75 + mn_yvalues(nd,i) = min(npp_data(idx))
252.76 + mx_yvalues(nd,i) = max(npp_data(idx))
252.77 + count = dimsizes(idx)
252.78 + else
252.79 + count = 0
252.80 + yvalues(nd,i) = yvalues@_FillValue
252.81 + mn_yvalues(nd,i) = yvalues@_FillValue
252.82 + mx_yvalues(nd,i) = yvalues@_FillValue
252.83 + end if
252.84 +
252.85 +; Print out information.
252.86 +
252.87 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
252.88 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
252.89 +
252.90 +
252.91 +; Clean up for next time in loop.
252.92 +
252.93 + delete(idx)
252.94 + end do
252.95 + delete(data)
252.96 + delete(npp_data)
252.97 + end do
252.98 +end
252.99 +
252.100 +; Main code.
252.101 +begin
252.102 +
252.103 + plot_type = "ps"
252.104 + plot_type_new = "png"
252.105 +;************************************************
252.106 +; read in model data
252.107 +;************************************************
252.108 +;film = "i01.06cn_1798-2004_ANN_climo.nc"
252.109 +;model_name = "06cn"
252.110 +;model_grid = "T42"
252.111 +
252.112 +;film = "i01.06casa_1798-2004_ANN_climo.nc"
252.113 +;model_name = "06casa"
252.114 +;model_grid = "T42"
252.115 +
252.116 + film = "i01.10casa_1948-2004_ANN_climo.nc"
252.117 + model_name = "10casa"
252.118 + model_grid = "T42"
252.119 +
252.120 +;film = "i01.10cn_1948-2004_ANN_climo.nc"
252.121 +;model_name = "10cn"
252.122 +;model_grid = "T42"
252.123 +;--------------------------------------------------
252.124 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
252.125 + fm = addfile (dirm+film,"r")
252.126 +
252.127 + nppmod0 = fm->NPP
252.128 + rainmod0 = fm->RAIN
252.129 + xm = fm->lon
252.130 + ym = fm->lat
252.131 +
252.132 +;************************************************
252.133 +; read in ob data
252.134 +;************************************************
252.135 +;(1)
252.136 + dir81 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
252.137 + fil81 = "data.81.nc"
252.138 + f81 = addfile (dir81+fil81,"r")
252.139 +
252.140 + id81 = f81->SITE_ID
252.141 + npp81 = f81->TNPP_C
252.142 + rain81 = tofloat(f81->PREC_ANN)
252.143 + x81 = f81->LONG_DD
252.144 + y81 = f81->LAT_DD
252.145 +
252.146 + id81@long_name = "SITE_ID"
252.147 +
252.148 +;change longitude from (-180,180) to (0,360)
252.149 +;for model data interpolation
252.150 +
252.151 + do i= 0,dimsizes(x81)-1
252.152 + if (x81(i) .lt. 0.) then
252.153 + x81(i) = x81(i)+ 360.
252.154 + end if
252.155 + end do
252.156 +;print (x81)
252.157 +;-------------------------------------
252.158 +;(2)
252.159 + dir933 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
252.160 + fil933 = "data.933.nc"
252.161 + f933 = addfile (dir933+fil933,"r")
252.162 +
252.163 + id933 = f933->SITE_ID
252.164 + npp933 = f933->TNPP_C
252.165 + rain933 = f933->PREC
252.166 + x933 = f933->LONG_DD
252.167 + y933 = f933->LAT_DD
252.168 +
252.169 + id933@long_name = "SITE_ID"
252.170 +
252.171 +;change longitude from (-180,180) to (0,360)
252.172 +;for model data interpolation
252.173 +
252.174 + do i= 0,dimsizes(x933)-1
252.175 + if (x933(i) .lt. 0.) then
252.176 + x933(i) = x933(i)+ 360.
252.177 + end if
252.178 + end do
252.179 +;print (x933)
252.180 +;----------------------------------------
252.181 +;(3)
252.182 + dirglobe = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
252.183 + filglobe = "Npp_"+model_grid+"_mean.nc"
252.184 + fglobe = addfile (dirglobe+filglobe,"r")
252.185 +
252.186 + nppglobe0 = fglobe->NPP
252.187 + nppglobe = nppglobe0
252.188 +;***********************************************************************
252.189 +; interpolate model data
252.190 +;***********************************************************************
252.191 + nppmod = nppmod0(0,:,:)
252.192 + rainmod = rainmod0(0,:,:)
252.193 + delete (nppmod0)
252.194 + delete (rainmod0)
252.195 +
252.196 + nppmod81 =linint2_points(xm,ym,nppmod,True,x81,y81,0)
252.197 +
252.198 + nppmod933 =linint2_points(xm,ym,nppmod,True,x933,y933,0)
252.199 +
252.200 + rainmod81 =linint2_points(xm,ym,rainmod,True,x81,y81,0)
252.201 +
252.202 + rainmod933=linint2_points(xm,ym,rainmod,True,x933,y933,0)
252.203 +
252.204 +;************************************************
252.205 +; Units for these variables are:
252.206 +;
252.207 +; rain81 : mm/year
252.208 +; rainmod : mm/s
252.209 +; npp81 : g C/m^2/year
252.210 +; nppmod81: g C/m^2/s
252.211 +; nppglobe: g C/m^2/year
252.212 +;
252.213 +; We want to convert these to "m/year" and "g C/m^2/year".
252.214 +;
252.215 + nsec_per_year = 60*60*24*365
252.216 +
252.217 + rain81 = rain81 / 1000.
252.218 + rainmod81 = (rainmod81/ 1000.) * nsec_per_year
252.219 + nppmod81 = nppmod81 * nsec_per_year
252.220 +
252.221 + rain933 = rain933 / 1000.
252.222 + rainmod933 = (rainmod933/ 1000.) * nsec_per_year
252.223 + nppmod933 = nppmod933 * nsec_per_year
252.224 +
252.225 + nppmod = nppmod * nsec_per_year
252.226 +
252.227 + npp81@units = "gC/m^2/yr"
252.228 + nppmod81@units = "gC/m^2/yr"
252.229 + npp933@units = "gC/m^2/yr"
252.230 + nppmod933@units = "gC/m^2/yr"
252.231 + nppmod@units = "gC/m^2/yr"
252.232 + nppglobe@units = "gC/m^2/yr"
252.233 + rain81@units = "m/yr"
252.234 + rainmod81@units = "m/yr"
252.235 + rain933@units = "m/yr"
252.236 + rainmod933@units = "m/yr"
252.237 +
252.238 + npp81@long_name = "NPP (gC/m2/year)"
252.239 + npp933@long_name = "NPP (gC/m2/year)"
252.240 + nppmod81@long_name = "NPP (gC/m2/year)"
252.241 + nppmod933@long_name = "NPP (gC/m2/year)"
252.242 + nppmod@long_name = "NPP (gC/m2/year)"
252.243 + nppglobe@long_name = "NPP (gC/m2/year)"
252.244 + rain81@long_name = "PREC (m/year)"
252.245 + rain933@long_name = "PREC (m/year)"
252.246 + rainmod81@long_name = "PREC (m/year)"
252.247 + rainmod933@long_name = "PREC (m/year)"
252.248 +
252.249 +;(A)-1 plot scatter ob 81
252.250 +
252.251 +;plot_name = "scatter_ob_81"
252.252 +;title = "Observed 81 sites"
252.253 +
252.254 +;wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.255 +;res = True ; plot mods desired
252.256 +;res@tiMainString = title ; add title
252.257 +;res@xyMarkLineModes = "Markers" ; choose which have markers
252.258 +;res@xyMarkers = 16 ; choose type of marker
252.259 +;res@xyMarkerColor = "red" ; Marker color
252.260 +;res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
252.261 +;res@tmLabelAutoStride = True ; nice tick mark labels
252.262 +
252.263 +;plot = gsn_csm_xy (wks,id81,npp81,res) ; create plot
252.264 +;frame(wks)
252.265 +
252.266 +;system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.267 +;system("rm "+plot_name+"."+plot_type)
252.268 +;system("rm "+plot_name+"-1."+plot_type_new)
252.269 +;system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.270 +
252.271 +;clear (wks)
252.272 +;*******************************************************************
252.273 +;(A)-2 for table of site(1) (the first 41 sites)
252.274 +;*******************************************************************
252.275 +
252.276 + table_length = 0.95
252.277 +
252.278 +; table header name
252.279 + table_header_name = "Site ID"
252.280 +
252.281 +; column (not including header column)
252.282 + col_header = (/"Latitude","Longitude","NPP (gC/m2/year)","RAIN (m/year)"/)
252.283 + ncol = dimsizes(col_header)
252.284 +
252.285 +; row (not including header row)
252.286 + nrow = 41
252.287 + row_header = new ((/nrow/),string )
252.288 + row_header(0:nrow-1) = id81(0:nrow-1)
252.289 +
252.290 +; Table header
252.291 + ncr1 = (/1,1/) ; 1 row, 1 column
252.292 + x1 = (/0.005,0.15/) ; Start and end X
252.293 + y1 = (/0.900,0.95/) ; Start and end Y
252.294 + text1 = table_header_name
252.295 + res1 = True
252.296 + res1@txFontHeightF = 0.015
252.297 + res1@gsFillColor = "CornFlowerBlue"
252.298 +
252.299 +; Column header (equally space in x2)
252.300 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
252.301 + x2 = (/x1(1),0.995/) ; start from end of x1
252.302 + y2 = y1 ; same as y1
252.303 + text2 = col_header
252.304 + res2 = True
252.305 + res2@txFontHeightF = 0.015
252.306 + res2@gsFillColor = "Gray"
252.307 +
252.308 +; Row header (equally space in y2)
252.309 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
252.310 + x3 = x1 ; same as x1
252.311 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
252.312 + text3 = row_header
252.313 + res3 = True
252.314 + res3@txFontHeightF = 0.010
252.315 + res3@gsFillColor = "Gray"
252.316 +
252.317 +; Main table body
252.318 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
252.319 + x4 = x2 ; Start and end x
252.320 + y4 = y3 ; Start and end Y
252.321 + text4 = new((/nrow,ncol/),string)
252.322 +
252.323 + color_fill4 = new((/nrow,ncol/),string)
252.324 + color_fill4 = "white"
252.325 +; color_fill4(:,ncol-1) = "grey"
252.326 +; color_fill4(nrow-1,:) = "green"
252.327 +
252.328 + res4 = True ; Set up resource list
252.329 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
252.330 + res4@txFontHeightF = 0.015
252.331 + res4@gsFillColor = color_fill4
252.332 +
252.333 + delete (color_fill4)
252.334 +;-------------------------------------------------------------------
252.335 +; for table value
252.336 +
252.337 + do n = 0,nrow-1
252.338 + text4(n,0) = sprintf("%5.2f", y81(n))
252.339 + text4(n,1) = sprintf("%5.2f", x81(n))
252.340 + text4(n,2) = sprintf("%5.2f", npp81(n))
252.341 + text4(n,3) = sprintf("%5.2f", rain81(n))
252.342 + end do
252.343 +;---------------------------------------------------------------------------
252.344 +
252.345 + plot_name = "table_site81_ob1"
252.346 +
252.347 + wks = gsn_open_wks (plot_type,plot_name)
252.348 +;------------------------------------------
252.349 +; for table title
252.350 +
252.351 + gRes = True
252.352 + gRes@txFontHeightF = 0.02
252.353 +; gRes@txAngleF = 90
252.354 +
252.355 + title_text = "Observation at 81 Sites (1)"
252.356 +
252.357 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
252.358 +;------------------------------------------
252.359 +
252.360 + gsn_table(wks,ncr1,x1,y1,text1,res1)
252.361 + gsn_table(wks,ncr2,x2,y2,text2,res2)
252.362 + gsn_table(wks,ncr3,x3,y3,text3,res3)
252.363 + gsn_table(wks,ncr4,x4,y4,text4,res4)
252.364 +
252.365 + frame(wks)
252.366 + clear (wks)
252.367 +
252.368 + delete (row_header)
252.369 + delete (res3)
252.370 + delete (ncr3)
252.371 + delete (text3)
252.372 + delete (res4)
252.373 + delete (ncr4)
252.374 + delete (text4)
252.375 +
252.376 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.377 + system("rm "+plot_name+"."+plot_type)
252.378 + system("rm "+plot_name+"-1."+plot_type_new)
252.379 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.380 +
252.381 +;*******************************************************************
252.382 +;(A)-3 for table of site(2) (the second 40 sites)
252.383 +;*******************************************************************
252.384 +
252.385 + table_length = 0.95
252.386 +
252.387 +; table header name
252.388 + table_header_name = "Site ID"
252.389 +
252.390 +; column (not including header column)
252.391 + col_header = (/"Latitude","Longitude","NPP (gC/m2/year)","RAIN (m/year)"/)
252.392 + ncol = dimsizes(col_header)
252.393 +
252.394 +; row (not including header row)
252.395 + nrow = 40
252.396 + row_header = new ((/nrow/),string )
252.397 + row_header(0:nrow-1) = id81(41:41+nrow-1)
252.398 +
252.399 +; Table header
252.400 + ncr1 = (/1,1/) ; 1 row, 1 column
252.401 + x1 = (/0.005,0.15/) ; Start and end X
252.402 + y1 = (/0.900,0.95/) ; Start and end Y
252.403 + text1 = table_header_name
252.404 + res1 = True
252.405 + res1@txFontHeightF = 0.015
252.406 + res1@gsFillColor = "CornFlowerBlue"
252.407 +
252.408 +; Column header (equally space in x2)
252.409 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
252.410 + x2 = (/x1(1),0.995/) ; start from end of x1
252.411 + y2 = y1 ; same as y1
252.412 + text2 = col_header
252.413 + res2 = True
252.414 + res2@txFontHeightF = 0.015
252.415 + res2@gsFillColor = "Gray"
252.416 +
252.417 +; Row header (equally space in y2)
252.418 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
252.419 + x3 = x1 ; same as x1
252.420 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
252.421 + text3 = row_header
252.422 + res3 = True
252.423 + res3@txFontHeightF = 0.010
252.424 + res3@gsFillColor = "Gray"
252.425 +
252.426 +; Main table body
252.427 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
252.428 + x4 = x2 ; Start and end x
252.429 + y4 = y3 ; Start and end Y
252.430 + text4 = new((/nrow,ncol/),string)
252.431 +
252.432 + color_fill4 = new((/nrow,ncol/),string)
252.433 + color_fill4 = "white"
252.434 +; color_fill4(:,ncol-1) = "grey"
252.435 +; color_fill4(nrow-1,:) = "green"
252.436 +
252.437 + res4 = True ; Set up resource list
252.438 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
252.439 + res4@txFontHeightF = 0.015
252.440 + res4@gsFillColor = color_fill4
252.441 +
252.442 + delete (color_fill4)
252.443 +;-------------------------------------------------------------------
252.444 +; for table value
252.445 +
252.446 + do n = 0,nrow-1
252.447 + text4(n,0) = sprintf("%5.2f", y81(n+41))
252.448 + text4(n,1) = sprintf("%5.2f", x81(n+41))
252.449 + text4(n,2) = sprintf("%5.2f", npp81(n+41))
252.450 + text4(n,3) = sprintf("%5.2f", rain81(n+41))
252.451 + end do
252.452 +;---------------------------------------------------------------------------
252.453 +
252.454 + plot_name = "table_site81_ob2"
252.455 +
252.456 + wks = gsn_open_wks (plot_type,plot_name)
252.457 +;------------------------------------------
252.458 +; for table title
252.459 +
252.460 + gRes = True
252.461 + gRes@txFontHeightF = 0.02
252.462 +; gRes@txAngleF = 90
252.463 +
252.464 + title_text = "Observation at 81 Sites (2)"
252.465 +
252.466 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
252.467 +;------------------------------------------
252.468 +
252.469 + gsn_table(wks,ncr1,x1,y1,text1,res1)
252.470 + gsn_table(wks,ncr2,x2,y2,text2,res2)
252.471 + gsn_table(wks,ncr3,x3,y3,text3,res3)
252.472 + gsn_table(wks,ncr4,x4,y4,text4,res4)
252.473 +
252.474 + frame(wks)
252.475 + clear (wks)
252.476 +
252.477 + delete (row_header)
252.478 + delete (res3)
252.479 + delete (ncr3)
252.480 + delete (text3)
252.481 + delete (res4)
252.482 + delete (ncr4)
252.483 + delete (text4)
252.484 +
252.485 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.486 + system("rm "+plot_name+"."+plot_type)
252.487 + system("rm "+plot_name+"-1."+plot_type_new)
252.488 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.489 +;**************************************************************************
252.490 +;(A)-4 plot scatter ob 933
252.491 +
252.492 + plot_name = "scatter_ob_933"
252.493 + title = "Observed 933 sites"
252.494 +
252.495 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.496 + res = True ; plot mods desired
252.497 + res@tiMainString = title ; add title
252.498 + res@xyMarkLineModes = "Markers" ; choose which have markers
252.499 + res@xyMarkers = 16 ; choose type of marker
252.500 + res@xyMarkerColor = "red" ; Marker color
252.501 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
252.502 + res@tmLabelAutoStride = True ; nice tick mark labels
252.503 +
252.504 + plot = gsn_csm_xy (wks,id933,npp933,res) ; create plot
252.505 + frame(wks)
252.506 +
252.507 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.508 + system("rm "+plot_name+"."+plot_type)
252.509 + system("rm "+plot_name+"-1."+plot_type_new)
252.510 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.511 +
252.512 + clear (wks)
252.513 +
252.514 +;(A)-5 plot scatter model 81
252.515 +
252.516 +;plot_name = "scatter_model_81"
252.517 +;title = "Model "+ model_name +" 81 sites"
252.518 +
252.519 +;wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.520 +;res = True ; plot mods desired
252.521 +;res@tiMainString = title ; add title
252.522 +;res@xyMarkLineModes = "Markers" ; choose which have markers
252.523 +;res@xyMarkers = 16 ; choose type of marker
252.524 +;res@xyMarkerColor = "red" ; Marker color
252.525 +;res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
252.526 +;res@tmLabelAutoStride = True ; nice tick mark labels
252.527 +
252.528 +;plot = gsn_csm_xy (wks,id81,nppmod81,res) ; create plot
252.529 +;frame(wks)
252.530 +
252.531 +;system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.532 +;system("rm "+plot_name+"."+plot_type)
252.533 +;system("rm "+plot_name+"-1."+plot_type_new)
252.534 +;system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.535 +
252.536 +;clear (wks)
252.537 +
252.538 +;(A)-6 plot scatter model 933
252.539 +
252.540 + plot_name = "scatter_model_933"
252.541 + title = "Model "+ model_name +" 933 sites"
252.542 +
252.543 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.544 + res = True ; plot mods desired
252.545 + res@tiMainString = title ; add title
252.546 + res@xyMarkLineModes = "Markers" ; choose which have markers
252.547 + res@xyMarkers = 16 ; choose type of marker
252.548 + res@xyMarkerColor = "red" ; Marker color
252.549 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
252.550 + res@tmLabelAutoStride = True ; nice tick mark labels
252.551 +
252.552 + plot = gsn_csm_xy (wks,id933,nppmod933,res) ; create plot
252.553 + frame(wks)
252.554 +
252.555 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.556 + system("rm "+plot_name+"."+plot_type)
252.557 + system("rm "+plot_name+"-1."+plot_type_new)
252.558 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.559 +
252.560 + clear (wks)
252.561 +
252.562 +;(A)-7 scatter model vs ob 81
252.563 +
252.564 + plot_name = "scatter_model_vs_ob_81"
252.565 + title = model_name +" vs ob 81 sites"
252.566 +
252.567 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.568 + res = True ; plot mods desired
252.569 + res@tiMainString = title ; add title
252.570 + res@xyMarkLineModes = "Markers" ; choose which have markers
252.571 + res@xyMarkers = 16 ; choose type of marker
252.572 + res@xyMarkerColor = "red" ; Marker color
252.573 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
252.574 + res@tmLabelAutoStride = True ; nice tick mark labels
252.575 +
252.576 + res@gsnDraw = False
252.577 + res@gsnFrame = False ; don't advance frame yet
252.578 +;-------------------------------
252.579 +;compute correlation coef. and M
252.580 + ccr81 = esccr(nppmod81,npp81,0)
252.581 +;print (ccr81)
252.582 +
252.583 +;new eq
252.584 + bias = sum(abs(nppmod81-npp81)/(abs(nppmod81)+abs(npp81)))
252.585 + M81 = (1. - (bias/dimsizes(y81)))*5.
252.586 + print (M81)
252.587 +
252.588 + tRes = True
252.589 + tRes@txFontHeightF = 0.025
252.590 +
252.591 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81)+")"
252.592 +
252.593 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
252.594 +;--------------------------------
252.595 + plot = gsn_csm_xy (wks,npp81,nppmod81,res) ; create plot
252.596 +;-------------------------------
252.597 +; add polyline
252.598 +
252.599 + dum=gsn_add_polyline(wks,plot,(/0,1200/),(/0,1200/),False)
252.600 +;-------------------------------
252.601 + draw (plot)
252.602 + frame(wks)
252.603 +
252.604 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.605 + system("rm "+plot_name+"."+plot_type)
252.606 +;system("rm "+plot_name+"-1."+plot_type_new)
252.607 +;system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.608 +
252.609 + clear (wks)
252.610 + delete (dum)
252.611 +
252.612 +;(A)-8 scatter model vs ob 933
252.613 +
252.614 + plot_name = "scatter_model_vs_ob_933"
252.615 + title = model_name +" vs ob 933 sites"
252.616 +
252.617 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.618 + res = True ; plot mods desired
252.619 + res@tiMainString = title ; add title
252.620 + res@xyMarkLineModes = "Markers" ; choose which have markers
252.621 + res@xyMarkers = 16 ; choose type of marker
252.622 + res@xyMarkerColor = "red" ; Marker color
252.623 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
252.624 + res@tmLabelAutoStride = True ; nice tick mark labels
252.625 +
252.626 + res@gsnDraw = False
252.627 + res@gsnFrame = False ; don't advance frame yet
252.628 +;-------------------------------
252.629 +;compute correlation coef. and M
252.630 + ccr933 = esccr(nppmod933,npp933,0)
252.631 +;print (ccr933)
252.632 +
252.633 +;new eq
252.634 + bias = sum(abs(nppmod933-npp933)/(abs(nppmod933)+abs(npp933)))
252.635 + M933 = (1. - (bias/dimsizes(y933)))*5.
252.636 + print (M933)
252.637 +
252.638 + tRes = True
252.639 + tRes@txFontHeightF = 0.025
252.640 +
252.641 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933)+")"
252.642 +
252.643 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
252.644 +;--------------------------------
252.645 + plot = gsn_csm_xy (wks,npp933,nppmod933,res) ; create plot
252.646 +;-------------------------------
252.647 +; add polyline
252.648 +
252.649 + dum=gsn_add_polyline(wks,plot,(/0,1500/),(/0,1500/),False)
252.650 +;-------------------------------
252.651 + draw (plot)
252.652 + frame(wks)
252.653 +
252.654 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.655 + system("rm "+plot_name+"."+plot_type)
252.656 +;system("rm "+plot_name+"-1."+plot_type_new)
252.657 +;system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.658 +
252.659 + clear (wks)
252.660 + delete (dum)
252.661 +
252.662 +;*******************************************************************
252.663 +;(A)-9 for table of site(1) (the first 41 sites), model vs ob
252.664 +;*******************************************************************
252.665 +
252.666 + table_length = 0.95
252.667 +
252.668 +; table header name
252.669 + table_header_name = "Site ID"
252.670 +
252.671 +; row (not including header row)
252.672 + nrow = 41
252.673 + row_header = new ((/nrow/),string )
252.674 + row_header(0:nrow-1) = id81(0:nrow-1)
252.675 +
252.676 +; Table header
252.677 + ncr1 = (/1,1/) ; 1 row, 1 column
252.678 + x1 = (/0.005,0.15/) ; Start and end X
252.679 + y1 = (/0.85 ,0.95/) ; Start and end Y
252.680 + text1 = table_header_name
252.681 + res1 = True
252.682 + res1@txFontHeightF = 0.015
252.683 + res1@gsFillColor = "CornFlowerBlue"
252.684 +
252.685 +; Column header1 (equally space in x2)
252.686 +
252.687 + delete (col_header)
252.688 + delete (ncr2)
252.689 + delete (text2)
252.690 +
252.691 + col_header = (/"Latitude","Longitude"/)
252.692 + ncol = dimsizes(col_header)
252.693 +
252.694 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
252.695 + x2 = (/x1(1),0.35/) ; start from end of x1
252.696 + y2 = y1 ; same as y1
252.697 + text2 = col_header
252.698 + res2 = True
252.699 + res2@txFontHeightF = 0.015
252.700 + res2@gsFillColor = "Gray"
252.701 +
252.702 +; Column header2 (equally space in x2)
252.703 +
252.704 + col_header1 = (/"NPP (gC/m2/year)","RAIN (m/year)"/)
252.705 + col_header2 = (/"ob",model_name \
252.706 + ,"ob",model_name \
252.707 + /)
252.708 +
252.709 + ncol1 = dimsizes(col_header1)
252.710 + ncol2 = dimsizes(col_header2)
252.711 +
252.712 + ncr21 = (/1,ncol1/) ; 1 rows, 4 columns
252.713 + x21 = (/x2(1),0.995/) ; start from end of x2
252.714 + yhalf = (y1(0)+y1(1))*0.5
252.715 + y21 = (/yhalf,y1(1)/) ; top half of y1
252.716 + text21 = col_header1
252.717 + res21 = True
252.718 + res21@txFontHeightF = 0.015
252.719 + res21@gsFillColor = "Gray"
252.720 +
252.721 + ncr22 = (/1,ncol2/) ; 1 rows, 12 columns
252.722 + x22 = x21 ; start from end of x1
252.723 + y22 = (/y1(0),yhalf/) ; bottom half of y1
252.724 + text22 = col_header2
252.725 + res22 = True
252.726 + res22@txFontHeightF = 0.015
252.727 + res22@gsFillColor = "Gray"
252.728 +
252.729 +; Row header (equally space in y2)
252.730 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
252.731 + x3 = x1 ; same as x1
252.732 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
252.733 + text3 = row_header
252.734 + res3 = True
252.735 + res3@txFontHeightF = 0.010
252.736 + res3@gsFillColor = "Gray"
252.737 +
252.738 +; Main table body-1
252.739 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
252.740 + x4 = x2 ; Start and end x
252.741 + y4 = y3 ; Start and end Y
252.742 + text4 = new((/nrow,ncol/),string)
252.743 +
252.744 + color_fill4 = new((/nrow,ncol/),string)
252.745 + color_fill4 = "white"
252.746 +; color_fill4(:,ncol-1) = "grey"
252.747 +; color_fill4(nrow-1,:) = "green"
252.748 +
252.749 + res4 = True ; Set up resource list
252.750 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
252.751 + res4@txFontHeightF = 0.015
252.752 + res4@gsFillColor = color_fill4
252.753 +
252.754 + delete (color_fill4)
252.755 +
252.756 +; Main table body-2
252.757 + ncr42 = (/nrow,ncol2/) ; nrow rows, ncol columns
252.758 + x42 = x21 ; Start and end x
252.759 + y42 = y3 ; Start and end Y
252.760 + text42 = new((/nrow,ncol2/),string)
252.761 +
252.762 + color_fill42 = new((/nrow,ncol2/),string)
252.763 + color_fill42 = "white"
252.764 +; color_fill42(:,ncol-1) = "grey"
252.765 +; color_fill42(nrow-1,:) = "green"
252.766 +
252.767 + res42 = True ; Set up resource list
252.768 +; res42@gsnDebug = True ; Useful to print NDC row,col values used.
252.769 + res42@txFontHeightF = 0.015
252.770 + res42@gsFillColor = color_fill42
252.771 +
252.772 + delete (color_fill42)
252.773 +;-------------------------------------------------------------------
252.774 +; for table value
252.775 +
252.776 + do n = 0,nrow-1
252.777 + text4(n,0) = sprintf("%5.2f", y81(n))
252.778 + text4(n,1) = sprintf("%5.2f", x81(n))
252.779 + end do
252.780 +
252.781 + do n = 0,nrow-1
252.782 + text42(n,0) = sprintf("%5.2f", npp81(n))
252.783 + text42(n,1) = sprintf("%5.2f", nppmod81(n))
252.784 + text42(n,2) = sprintf("%5.2f", rain81(n))
252.785 + text42(n,3) = sprintf("%5.2f", rainmod81(n))
252.786 + end do
252.787 +;---------------------------------------------------------------------------
252.788 +
252.789 + plot_name = "table_site81_model_vs_ob1"
252.790 +
252.791 + wks = gsn_open_wks (plot_type,plot_name)
252.792 +;------------------------------------------
252.793 +; for table title
252.794 +
252.795 + gRes = True
252.796 + gRes@txFontHeightF = 0.02
252.797 +; gRes@txAngleF = 90
252.798 +
252.799 + title_text = "Model vs Observation at 81 Sites (1)"
252.800 +
252.801 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
252.802 +;------------------------------------------
252.803 +
252.804 + gsn_table(wks,ncr1,x1,y1,text1,res1)
252.805 + gsn_table(wks,ncr2,x2,y2,text2,res2)
252.806 + gsn_table(wks,ncr21,x21,y21,text21,res21)
252.807 + gsn_table(wks,ncr22,x22,y22,text22,res22)
252.808 + gsn_table(wks,ncr3,x3,y3,text3,res3)
252.809 + gsn_table(wks,ncr4,x4,y4,text4,res4)
252.810 + gsn_table(wks,ncr42,x42,y42,text42,res42)
252.811 +
252.812 + frame(wks)
252.813 + clear (wks)
252.814 +
252.815 + delete (col_header)
252.816 + delete (row_header)
252.817 + delete (res1)
252.818 + delete (ncr1)
252.819 + delete (text1)
252.820 + delete (res2)
252.821 + delete (ncr2)
252.822 + delete (text2)
252.823 + delete (res21)
252.824 + delete (ncr21)
252.825 + delete (text21)
252.826 + delete (res22)
252.827 + delete (ncr22)
252.828 + delete (text22)
252.829 + delete (res3)
252.830 + delete (ncr3)
252.831 + delete (text3)
252.832 + delete (res4)
252.833 + delete (ncr4)
252.834 + delete (text4)
252.835 + delete (res42)
252.836 + delete (ncr42)
252.837 + delete (text42)
252.838 +
252.839 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.840 + system("rm "+plot_name+"."+plot_type)
252.841 + system("rm "+plot_name+"-1."+plot_type_new)
252.842 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.843 +
252.844 +;*******************************************************************
252.845 +;(A)-10 for table of site(2) (the last 40 sites), model vs ob
252.846 +;*******************************************************************
252.847 +
252.848 + table_length = 0.95
252.849 +
252.850 +; table header name
252.851 + table_header_name = "Site ID"
252.852 +
252.853 +; row (not including header row)
252.854 + nrow = 40
252.855 + row_header = new ((/nrow/),string )
252.856 + row_header(0:nrow-1) = id81(41:41+nrow-1)
252.857 +
252.858 +; Table header
252.859 + ncr1 = (/1,1/) ; 1 row, 1 column
252.860 + x1 = (/0.005,0.15/) ; Start and end X
252.861 + y1 = (/0.85 ,0.95/) ; Start and end Y
252.862 + text1 = table_header_name
252.863 + res1 = True
252.864 + res1@txFontHeightF = 0.015
252.865 + res1@gsFillColor = "CornFlowerBlue"
252.866 +
252.867 +; Column header1 (equally space in x2)
252.868 +
252.869 + col_header = (/"Latitude","Longitude"/)
252.870 + ncol = dimsizes(col_header)
252.871 +
252.872 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
252.873 + x2 = (/x1(1),0.35/) ; start from end of x1
252.874 + y2 = y1 ; same as y1
252.875 + text2 = col_header
252.876 + res2 = True
252.877 + res2@txFontHeightF = 0.015
252.878 + res2@gsFillColor = "Gray"
252.879 +
252.880 +; Column header2 (equally space in x2)
252.881 +
252.882 +; col_header1 = (/"NPP (gC/m2/year)","RAIN (m/year)"/)
252.883 + col_header2 = (/"ob",model_name \
252.884 + ,"ob",model_name \
252.885 + /)
252.886 +
252.887 + ncol1 = dimsizes(col_header1)
252.888 + ncol2 = dimsizes(col_header2)
252.889 +
252.890 + ncr21 = (/1,ncol1/) ; 1 rows, 4 columns
252.891 + x21 = (/x2(1),0.995/) ; start from end of x2
252.892 + yhalf = (y1(0)+y1(1))*0.5
252.893 + y21 = (/yhalf,y1(1)/) ; top half of y1
252.894 + text21 = col_header1
252.895 + res21 = True
252.896 + res21@txFontHeightF = 0.015
252.897 + res21@gsFillColor = "Gray"
252.898 +
252.899 + ncr22 = (/1,ncol2/) ; 1 rows, 12 columns
252.900 + x22 = x21 ; start from end of x1
252.901 + y22 = (/y1(0),yhalf/) ; bottom half of y1
252.902 + text22 = col_header2
252.903 + res22 = True
252.904 + res22@txFontHeightF = 0.015
252.905 + res22@gsFillColor = "Gray"
252.906 +
252.907 +; Row header (equally space in y2)
252.908 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
252.909 + x3 = x1 ; same as x1
252.910 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
252.911 + text3 = row_header
252.912 + res3 = True
252.913 + res3@txFontHeightF = 0.010
252.914 + res3@gsFillColor = "Gray"
252.915 +
252.916 +; Main table body-1
252.917 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
252.918 + x4 = x2 ; Start and end x
252.919 + y4 = y3 ; Start and end Y
252.920 + text4 = new((/nrow,ncol/),string)
252.921 +
252.922 + color_fill4 = new((/nrow,ncol/),string)
252.923 + color_fill4 = "white"
252.924 +; color_fill4(:,ncol-1) = "grey"
252.925 +; color_fill4(nrow-1,:) = "green"
252.926 +
252.927 + res4 = True ; Set up resource list
252.928 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
252.929 + res4@txFontHeightF = 0.015
252.930 + res4@gsFillColor = color_fill4
252.931 +
252.932 + delete (color_fill4)
252.933 +
252.934 +; Main table body-2
252.935 + ncr42 = (/nrow,ncol2/) ; nrow rows, ncol columns
252.936 + x42 = x21 ; Start and end x
252.937 + y42 = y3 ; Start and end Y
252.938 + text42 = new((/nrow,ncol2/),string)
252.939 +
252.940 + color_fill42 = new((/nrow,ncol2/),string)
252.941 + color_fill42 = "white"
252.942 +; color_fill42(:,ncol-1) = "grey"
252.943 +; color_fill42(nrow-1,:) = "green"
252.944 +
252.945 + res42 = True ; Set up resource list
252.946 +; res42@gsnDebug = True ; Useful to print NDC row,col values used.
252.947 + res42@txFontHeightF = 0.015
252.948 + res42@gsFillColor = color_fill42
252.949 +
252.950 + delete (color_fill42)
252.951 +;-------------------------------------------------------------------
252.952 +; for table value
252.953 +
252.954 + do n = 0,nrow-1
252.955 + text4(n,0) = sprintf("%5.2f", y81(n+41))
252.956 + text4(n,1) = sprintf("%5.2f", x81(n+41))
252.957 + end do
252.958 +
252.959 + do n = 0,nrow-1
252.960 + text42(n,0) = sprintf("%5.2f", npp81(n+41))
252.961 + text42(n,1) = sprintf("%5.2f", nppmod81(n+41))
252.962 + text42(n,2) = sprintf("%5.2f", rain81(n+41))
252.963 + text42(n,3) = sprintf("%5.2f", rainmod81(n+41))
252.964 + end do
252.965 +;---------------------------------------------------------------------------
252.966 +
252.967 + plot_name = "table_site81_model_vs_ob2"
252.968 +
252.969 + wks = gsn_open_wks (plot_type,plot_name)
252.970 +;------------------------------------------
252.971 +; for table title
252.972 +
252.973 + gRes = True
252.974 + gRes@txFontHeightF = 0.02
252.975 +; gRes@txAngleF = 90
252.976 +
252.977 + title_text = "Model vs Observation at 81 Sites (2)"
252.978 +
252.979 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
252.980 +;------------------------------------------
252.981 +
252.982 + gsn_table(wks,ncr1,x1,y1,text1,res1)
252.983 + gsn_table(wks,ncr2,x2,y2,text2,res2)
252.984 + gsn_table(wks,ncr21,x21,y21,text21,res21)
252.985 + gsn_table(wks,ncr22,x22,y22,text22,res22)
252.986 + gsn_table(wks,ncr3,x3,y3,text3,res3)
252.987 + gsn_table(wks,ncr4,x4,y4,text4,res4)
252.988 + gsn_table(wks,ncr42,x42,y42,text42,res42)
252.989 +
252.990 + frame(wks)
252.991 + clear (wks)
252.992 +
252.993 + delete (col_header)
252.994 + delete (row_header)
252.995 + delete (res1)
252.996 + delete (ncr1)
252.997 + delete (text1)
252.998 + delete (res2)
252.999 + delete (ncr2)
252.1000 + delete (text2)
252.1001 + delete (res21)
252.1002 + delete (ncr21)
252.1003 + delete (text21)
252.1004 + delete (res22)
252.1005 + delete (ncr22)
252.1006 + delete (text22)
252.1007 + delete (res3)
252.1008 + delete (ncr3)
252.1009 + delete (text3)
252.1010 + delete (res4)
252.1011 + delete (ncr4)
252.1012 + delete (text4)
252.1013 + delete (res42)
252.1014 + delete (ncr42)
252.1015 + delete (text42)
252.1016 +
252.1017 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.1018 + system("rm "+plot_name+"."+plot_type)
252.1019 + system("rm "+plot_name+"-1."+plot_type_new)
252.1020 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.1021 +
252.1022 +;**************************************************************************
252.1023 +;(B) histogram 81
252.1024 +;***********************************************************************-
252.1025 +;get data
252.1026 +
252.1027 + RAIN1_1D = ndtooned(rain81)
252.1028 + RAIN2_1D = ndtooned(rainmod81)
252.1029 + NPP1_1D = ndtooned(npp81)
252.1030 + NPP2_1D = ndtooned(nppmod81)
252.1031 +
252.1032 + nx = 8
252.1033 +
252.1034 + xvalues = new((/2,nx/),float)
252.1035 + yvalues = new((/2,nx/),float)
252.1036 + mn_yvalues = new((/2,nx/),float)
252.1037 + mx_yvalues = new((/2,nx/),float)
252.1038 + dx4 = new((/1/),float)
252.1039 +
252.1040 + get_bin(RAIN1_1D, NPP1_1D, RAIN2_1D, NPP2_1D \
252.1041 + ,xvalues,yvalues,mn_yvalues,mx_yvalues,dx4)
252.1042 +
252.1043 +;----------------------------------------
252.1044 +;compute correlation coeff and M score
252.1045 +
252.1046 + u = yvalues(0,:)
252.1047 + v = yvalues(1,:)
252.1048 +
252.1049 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
252.1050 + uu = u(good)
252.1051 + vv = v(good)
252.1052 +
252.1053 + ccr81h = esccr(uu,vv,0)
252.1054 +;print (ccr81h)
252.1055 +
252.1056 +;new eq
252.1057 + bias = sum(abs(vv-uu)/(abs(vv)+abs(uu)))
252.1058 + M81h = (1.- (bias/dimsizes(uu)))*5.
252.1059 + print (M81h)
252.1060 +
252.1061 + delete (u)
252.1062 + delete (v)
252.1063 + delete (uu)
252.1064 + delete (vv)
252.1065 +;----------------------------------------------------------------------
252.1066 +; histogram res
252.1067 +
252.1068 + resh = True
252.1069 + resh@gsnMaximize = True
252.1070 + resh@gsnDraw = False
252.1071 + resh@gsnFrame = False
252.1072 + resh@xyMarkLineMode = "Markers"
252.1073 + resh@xyMarkerSizeF = 0.014
252.1074 + resh@xyMarker = 16
252.1075 + resh@xyMarkerColors = (/"Brown","Blue"/)
252.1076 + resh@trYMinF = min(mn_yvalues) - 10.
252.1077 + resh@trYMaxF = max(mx_yvalues) + 10.
252.1078 +
252.1079 + resh@tiYAxisString = "NPP (g C/m2/year)"
252.1080 + resh@tiXAxisString = "Precipitation (m/year)"
252.1081 +
252.1082 + max_bar = new((/2,nx/),graphic)
252.1083 + min_bar = new((/2,nx/),graphic)
252.1084 + max_cap = new((/2,nx/),graphic)
252.1085 + min_cap = new((/2,nx/),graphic)
252.1086 +
252.1087 + lnres = True
252.1088 + line_colors = (/"brown","blue"/)
252.1089 +;=================================================================
252.1090 +;(B)-1 histogram ob 81 site only
252.1091 +;
252.1092 + plot_name = "histogram_ob_81"
252.1093 + title = "Observed 81 site"
252.1094 + resh@tiMainString = title
252.1095 +
252.1096 + wks = gsn_open_wks (plot_type,plot_name)
252.1097 +
252.1098 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
252.1099 +
252.1100 +;-------------------------------
252.1101 +;Attach the vertical bar and the horizontal cap line
252.1102 +
252.1103 + delete (x1)
252.1104 + delete (x2)
252.1105 + delete (y1)
252.1106 + delete (y2)
252.1107 +
252.1108 + do nd=0,0
252.1109 + lnres@gsLineColor = line_colors(nd)
252.1110 + do i=0,nx-1
252.1111 +
252.1112 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
252.1113 + .not.ismissing(mx_yvalues(nd,i))) then
252.1114 +;
252.1115 +; Attach the vertical bar, both above and below the marker.
252.1116 +;
252.1117 + x1 = xvalues(nd,i)
252.1118 + y1 = yvalues(nd,i)
252.1119 + y2 = mn_yvalues(nd,i)
252.1120 + plx = (/x1,x1/)
252.1121 + ply = (/y1,y2/)
252.1122 + min_bar(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
252.1123 +
252.1124 + y2 = mx_yvalues(nd,i)
252.1125 + plx = (/x1,x1/)
252.1126 + ply = (/y1,y2/)
252.1127 + max_bar(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
252.1128 +;
252.1129 +; Attach the horizontal cap line, both above and below the marker.
252.1130 +;
252.1131 + x1 = xvalues(nd,i) - dx4
252.1132 + x2 = xvalues(nd,i) + dx4
252.1133 + y1 = mn_yvalues(nd,i)
252.1134 + plx = (/x1,x2/)
252.1135 + ply = (/y1,y1/)
252.1136 + min_cap(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
252.1137 +
252.1138 + y1 = mx_yvalues(nd,i)
252.1139 + plx = (/x1,x2/)
252.1140 + ply = (/y1,y1/)
252.1141 + max_cap(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
252.1142 + end if
252.1143 + end do
252.1144 + end do
252.1145 +
252.1146 + draw(xy)
252.1147 + frame(wks)
252.1148 +
252.1149 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.1150 + system("rm "+plot_name+"."+plot_type)
252.1151 +; system("rm "+plot_name+"-1."+plot_type_new)
252.1152 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.1153 +
252.1154 + clear (wks)
252.1155 +;===========================================================================
252.1156 +;(B)-2 histogram model vs ob 81 site
252.1157 +
252.1158 + plot_name = "histogram_mod-ob_81"
252.1159 + title = model_name+ " vs Observed 81 site"
252.1160 + resh@tiMainString = title
252.1161 +
252.1162 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.1163 +
252.1164 +;-----------------------------
252.1165 +; Add a boxed legend using the more simple method, which won't have
252.1166 +; vertical lines going through the markers.
252.1167 +
252.1168 + resh@pmLegendDisplayMode = "Always"
252.1169 +; resh@pmLegendWidthF = 0.1
252.1170 + resh@pmLegendWidthF = 0.08
252.1171 + resh@pmLegendHeightF = 0.05
252.1172 + resh@pmLegendOrthogonalPosF = -1.17
252.1173 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
252.1174 +; resh@pmLegendParallelPosF = 0.18
252.1175 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
252.1176 +
252.1177 +; resh@lgPerimOn = False
252.1178 + resh@lgLabelFontHeightF = 0.015
252.1179 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
252.1180 +;-----------------------------
252.1181 + tRes = True
252.1182 + tRes@txFontHeightF = 0.025
252.1183 +
252.1184 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81h)+")"
252.1185 +
252.1186 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
252.1187 +
252.1188 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
252.1189 +;-------------------------------
252.1190 +;Attach the vertical bar and the horizontal cap line
252.1191 +
252.1192 + do nd=0,1
252.1193 + lnres@gsLineColor = line_colors(nd)
252.1194 + do i=0,nx-1
252.1195 +
252.1196 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
252.1197 + .not.ismissing(mx_yvalues(nd,i))) then
252.1198 +;
252.1199 +; Attach the vertical bar, both above and below the marker.
252.1200 +;
252.1201 + x1 = xvalues(nd,i)
252.1202 + y1 = yvalues(nd,i)
252.1203 + y2 = mn_yvalues(nd,i)
252.1204 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
252.1205 +
252.1206 + y2 = mx_yvalues(nd,i)
252.1207 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
252.1208 +;
252.1209 +; Attach the horizontal cap line, both above and below the marker.
252.1210 +;
252.1211 + x1 = xvalues(nd,i) - dx4
252.1212 + x2 = xvalues(nd,i) + dx4
252.1213 + y1 = mn_yvalues(nd,i)
252.1214 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
252.1215 +
252.1216 + y1 = mx_yvalues(nd,i)
252.1217 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
252.1218 + end if
252.1219 + end do
252.1220 + end do
252.1221 + draw(xy)
252.1222 + frame(wks)
252.1223 +
252.1224 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.1225 + system("rm "+plot_name+"."+plot_type)
252.1226 +; system("rm "+plot_name+"-1."+plot_type_new)
252.1227 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.1228 +
252.1229 + clear (wks)
252.1230 +
252.1231 + delete (RAIN1_1D)
252.1232 + delete (RAIN2_1D)
252.1233 + delete (NPP1_1D)
252.1234 + delete (NPP2_1D)
252.1235 +;delete (range)
252.1236 + delete (xvalues)
252.1237 + delete (yvalues)
252.1238 + delete (mn_yvalues)
252.1239 + delete (mx_yvalues)
252.1240 + delete (good)
252.1241 + delete (max_bar)
252.1242 + delete (min_bar)
252.1243 + delete (max_cap)
252.1244 + delete (min_cap)
252.1245 +;**************************************************************************
252.1246 +;(B) histogram 933
252.1247 +
252.1248 +;--------------------------------------------------------------------
252.1249 +;get data
252.1250 +
252.1251 + RAIN1_1D = ndtooned(rain933)
252.1252 + RAIN2_1D = ndtooned(rainmod933)
252.1253 + NPP1_1D = ndtooned(npp933)
252.1254 + NPP2_1D = ndtooned(nppmod933)
252.1255 +
252.1256 + nx = 10
252.1257 + xvalues = new((/2,nx/),float)
252.1258 + yvalues = new((/2,nx/),float)
252.1259 + mn_yvalues = new((/2,nx/),float)
252.1260 + mx_yvalues = new((/2,nx/),float)
252.1261 + dx4 = new((/1/),float)
252.1262 +
252.1263 + get_bin(RAIN1_1D, NPP1_1D, RAIN2_1D, NPP2_1D \
252.1264 + ,xvalues,yvalues,mn_yvalues,mx_yvalues,dx4)
252.1265 +
252.1266 +;----------------------------------------
252.1267 +;compute correlation coeff and M score
252.1268 +
252.1269 + u = yvalues(0,:)
252.1270 + v = yvalues(1,:)
252.1271 +
252.1272 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
252.1273 + uu = u(good)
252.1274 + vv = v(good)
252.1275 +
252.1276 + ccr933h = esccr(uu,vv,0)
252.1277 +;print (ccr933h)
252.1278 +
252.1279 +;new eq
252.1280 + bias = sum(abs(vv-uu)/(abs(vv)+abs(uu)))
252.1281 + M933h = (1.- (bias/dimsizes(uu)))*5.
252.1282 + print (M933h)
252.1283 +
252.1284 + delete (u)
252.1285 + delete (v)
252.1286 + delete (uu)
252.1287 + delete (vv)
252.1288 +;----------------------------------------------------------------------
252.1289 +; histogram res
252.1290 +
252.1291 + delete (resh)
252.1292 + resh = True
252.1293 + resh@gsnMaximize = True
252.1294 + resh@gsnDraw = False
252.1295 + resh@gsnFrame = False
252.1296 + resh@xyMarkLineMode = "Markers"
252.1297 + resh@xyMarkerSizeF = 0.014
252.1298 + resh@xyMarker = 16
252.1299 + resh@xyMarkerColors = (/"Brown","Blue"/)
252.1300 + resh@trYMinF = min(mn_yvalues) - 10.
252.1301 + resh@trYMaxF = max(mx_yvalues) + 10.
252.1302 +
252.1303 + resh@tiYAxisString = "NPP (g C/m2/year)"
252.1304 + resh@tiXAxisString = "Precipitation (m/year)"
252.1305 +
252.1306 + max_bar = new((/2,nx/),graphic)
252.1307 + min_bar = new((/2,nx/),graphic)
252.1308 + max_cap = new((/2,nx/),graphic)
252.1309 + min_cap = new((/2,nx/),graphic)
252.1310 +
252.1311 + lnres = True
252.1312 + line_colors = (/"brown","blue"/)
252.1313 +;=================================================================
252.1314 +;(B)-3 histogram ob 933 site only
252.1315 +
252.1316 + plot_name = "histogram_ob_933"
252.1317 + title = "Observed 933 site"
252.1318 + resh@tiMainString = title
252.1319 +
252.1320 + wks = gsn_open_wks (plot_type,plot_name)
252.1321 +
252.1322 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
252.1323 +
252.1324 +;-------------------------------
252.1325 +;Attach the vertical bar and the horizontal cap line
252.1326 +
252.1327 + do nd=0,0
252.1328 + lnres@gsLineColor = line_colors(nd)
252.1329 + do i=0,nx-1
252.1330 +
252.1331 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
252.1332 + .not.ismissing(mx_yvalues(nd,i))) then
252.1333 +
252.1334 +; Attach the vertical bar, both above and below the marker.
252.1335 +
252.1336 + x1 = xvalues(nd,i)
252.1337 + y1 = yvalues(nd,i)
252.1338 + y2 = mn_yvalues(nd,i)
252.1339 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
252.1340 +
252.1341 + y2 = mx_yvalues(nd,i)
252.1342 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
252.1343 +
252.1344 +; Attach the horizontal cap line, both above and below the marker.
252.1345 +
252.1346 + x1 = xvalues(nd,i) - dx4
252.1347 + x2 = xvalues(nd,i) + dx4
252.1348 + y1 = mn_yvalues(nd,i)
252.1349 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
252.1350 +
252.1351 + y1 = mx_yvalues(nd,i)
252.1352 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
252.1353 + end if
252.1354 + end do
252.1355 + end do
252.1356 +
252.1357 + draw(xy)
252.1358 + frame(wks)
252.1359 +
252.1360 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.1361 + system("rm "+plot_name+"."+plot_type)
252.1362 +; system("rm "+plot_name+"-1."+plot_type_new)
252.1363 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.1364 +
252.1365 + delete (xy)
252.1366 + clear (wks)
252.1367 +
252.1368 +;===========================================================================
252.1369 +;(B)-4 histogram model vs ob 933 site
252.1370 +
252.1371 + plot_name = "histogram_mod-ob_933"
252.1372 + title = model_name+ " vs Observed 933 site"
252.1373 + resh@tiMainString = title
252.1374 +
252.1375 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.1376 +
252.1377 +;-----------------------------
252.1378 +; Add a boxed legend using the more simple method, which won't have
252.1379 +; vertical lines going through the markers.
252.1380 +
252.1381 + resh@pmLegendDisplayMode = "Always"
252.1382 +; resh@pmLegendWidthF = 0.1
252.1383 + resh@pmLegendWidthF = 0.08
252.1384 + resh@pmLegendHeightF = 0.05
252.1385 + resh@pmLegendOrthogonalPosF = -1.17
252.1386 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
252.1387 +; resh@pmLegendParallelPosF = 0.18
252.1388 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
252.1389 +
252.1390 +; resh@lgPerimOn = False
252.1391 + resh@lgLabelFontHeightF = 0.015
252.1392 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
252.1393 +;-----------------------------
252.1394 + tRes = True
252.1395 + tRes@txFontHeightF = 0.025
252.1396 +
252.1397 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933h)+")"
252.1398 +
252.1399 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
252.1400 +
252.1401 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
252.1402 +;-------------------------------
252.1403 +;Attach the vertical bar and the horizontal cap line
252.1404 +
252.1405 + do nd=0,1
252.1406 + lnres@gsLineColor = line_colors(nd)
252.1407 + do i=0,nx-1
252.1408 +
252.1409 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
252.1410 + .not.ismissing(mx_yvalues(nd,i))) then
252.1411 +;
252.1412 +; Attach the vertical bar, both above and below the marker.
252.1413 +;
252.1414 + x1 = xvalues(nd,i)
252.1415 + y1 = yvalues(nd,i)
252.1416 + y2 = mn_yvalues(nd,i)
252.1417 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
252.1418 +
252.1419 + y2 = mx_yvalues(nd,i)
252.1420 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
252.1421 +;
252.1422 +; Attach the horizontal cap line, both above and below the marker.
252.1423 +;
252.1424 + x1 = xvalues(nd,i) - dx4
252.1425 + x2 = xvalues(nd,i) + dx4
252.1426 + y1 = mn_yvalues(nd,i)
252.1427 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
252.1428 +
252.1429 + y1 = mx_yvalues(nd,i)
252.1430 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
252.1431 + end if
252.1432 + end do
252.1433 + end do
252.1434 + draw(xy)
252.1435 + frame(wks)
252.1436 +
252.1437 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.1438 + system("rm "+plot_name+"."+plot_type)
252.1439 +; system("rm "+plot_name+"-1."+plot_type_new)
252.1440 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.1441 +
252.1442 + delete (xy)
252.1443 + clear (wks)
252.1444 +;***********************************************************************-
252.1445 +; global contour
252.1446 +
252.1447 +;res
252.1448 + resg = True ; Use plot options
252.1449 + resg@cnFillOn = True ; Turn on color fill
252.1450 + resg@gsnSpreadColors = True ; use full colormap
252.1451 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
252.1452 +; resg@lbLabelAutoStride = True
252.1453 + resg@cnLinesOn = False ; Turn off contourn lines
252.1454 + resg@mpFillOn = False ; Turn off map fill
252.1455 +
252.1456 + resg@gsnSpreadColors = True ; use full colormap
252.1457 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
252.1458 + resg@cnMinLevelValF = 0. ; Min level
252.1459 + resg@cnMaxLevelValF = 2200. ; Max level
252.1460 + resg@cnLevelSpacingF = 200. ; interval
252.1461 +;------------------------------------------------------------------------
252.1462 +;(C)-1 global contour ob
252.1463 +
252.1464 + delta = 0.00000000001
252.1465 + nppglobe = where(ismissing(nppglobe).and.(ismissing(nppmod).or.(nppmod.lt.delta)),0.,nppglobe)
252.1466 +
252.1467 + plot_name = "global_ob"
252.1468 + title = "Observed MODIS MOD 17"
252.1469 + resg@tiMainString = title
252.1470 +
252.1471 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.1472 + gsn_define_colormap(wks,"gui_default") ; choose colormap
252.1473 +
252.1474 + plot = gsn_csm_contour_map_ce(wks,nppglobe,resg)
252.1475 + frame(wks)
252.1476 +
252.1477 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.1478 + system("rm "+plot_name+"."+plot_type)
252.1479 + system("rm "+plot_name+"-1."+plot_type_new)
252.1480 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.1481 +
252.1482 + clear (wks)
252.1483 +;------------------------------------------------------------------------
252.1484 +;(C)-2 global contour model
252.1485 +
252.1486 + plot_name = "global_model"
252.1487 + title = "Model "+ model_name
252.1488 + resg@tiMainString = title
252.1489 +
252.1490 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.1491 + gsn_define_colormap(wks,"gui_default") ; choose colormap
252.1492 +
252.1493 + plot = gsn_csm_contour_map_ce(wks,nppmod,resg)
252.1494 + frame(wks)
252.1495 +
252.1496 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.1497 + system("rm "+plot_name+"."+plot_type)
252.1498 + system("rm "+plot_name+"-1."+plot_type_new)
252.1499 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.1500 +
252.1501 + clear (wks)
252.1502 +;------------------------------------------------------------------------
252.1503 +;(C)-3 global contour model vs ob
252.1504 +
252.1505 + plot_name = "global_model_vs_ob"
252.1506 +
252.1507 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.1508 + gsn_define_colormap(wks,"gui_default") ; choose colormap
252.1509 +
252.1510 + delete (plot)
252.1511 + plot=new(3,graphic) ; create graphic array
252.1512 +
252.1513 + resg@gsnFrame = False ; Do not draw plot
252.1514 + resg@gsnDraw = False ; Do not advance frame
252.1515 +
252.1516 +;(d) compute correlation coef and M score
252.1517 +
252.1518 + uu1 = ndtooned(nppmod)
252.1519 + vv1 = ndtooned(nppglobe)
252.1520 +
252.1521 + delete (good)
252.1522 + good = ind(.not.ismissing(uu1) .and. .not.ismissing(vv1))
252.1523 +
252.1524 + ug = uu1(good)
252.1525 + vg = vv1(good)
252.1526 +
252.1527 + ccrG = esccr(ug,vg,0)
252.1528 +; print (ccrG)
252.1529 +
252.1530 + MG = (ccrG*ccrG)* 5.0
252.1531 + print (MG)
252.1532 +
252.1533 +; plot correlation coef
252.1534 +
252.1535 + gRes = True
252.1536 + gRes@txFontHeightF = 0.02
252.1537 + gRes@txAngleF = 90
252.1538 +
252.1539 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrG)+")"
252.1540 +
252.1541 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
252.1542 +;--------------------------------------------------------------------
252.1543 +
252.1544 +;(a) ob
252.1545 +
252.1546 + title = "Observed MODIS MOD 17"
252.1547 + resg@tiMainString = title
252.1548 +
252.1549 + plot(0) = gsn_csm_contour_map_ce(wks,nppglobe,resg)
252.1550 +
252.1551 +;(b) model
252.1552 +
252.1553 + title = "Model "+ model_name
252.1554 + resg@tiMainString = title
252.1555 +
252.1556 + plot(1) = gsn_csm_contour_map_ce(wks,nppmod,resg)
252.1557 +
252.1558 +;(c) model-ob
252.1559 +
252.1560 + zz = nppmod
252.1561 + zz = nppmod - nppglobe
252.1562 + title = "Model_"+model_name+" - Observed"
252.1563 +
252.1564 + resg@cnMinLevelValF = -500 ; Min level
252.1565 + resg@cnMaxLevelValF = 500. ; Max level
252.1566 + resg@cnLevelSpacingF = 50. ; interval
252.1567 + resg@tiMainString = title
252.1568 +
252.1569 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
252.1570 +
252.1571 + pres = True ; panel plot mods desired
252.1572 + pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
252.1573 + ; indiv. plots in panel
252.1574 + pres@gsnMaximize = True ; fill the page
252.1575 +
252.1576 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
252.1577 +
252.1578 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.1579 + system("rm "+plot_name+"."+plot_type)
252.1580 +; system("rm "+plot_name+"-1."+plot_type_new)
252.1581 +; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.1582 +
252.1583 + frame (wks)
252.1584 + clear (wks)
252.1585 +
252.1586 + delete (plot)
252.1587 +;**********************************************************************
252.1588 +;(D)-1 zonal line plot ob
252.1589 +
252.1590 + resz = True
252.1591 +
252.1592 + vv = zonalAve(nppglobe)
252.1593 + vv@long_name = nppglobe@long_name
252.1594 +
252.1595 + plot_name = "zonal_ob"
252.1596 + title = "Observed MODIS MOD 17"
252.1597 + resz@tiMainString = title
252.1598 +
252.1599 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.1600 +
252.1601 + plot = gsn_csm_xy (wks,ym,vv,resz)
252.1602 + frame(wks)
252.1603 +
252.1604 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.1605 + system("rm "+plot_name+"."+plot_type)
252.1606 + system("rm "+plot_name+"-1."+plot_type_new)
252.1607 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.1608 +
252.1609 + clear (wks)
252.1610 +;---------------------------------------------------------------------
252.1611 +;(D)-2 zonal line plot model vs ob
252.1612 +
252.1613 + s = new ((/2,dimsizes(ym)/), float)
252.1614 +
252.1615 + s(0,:) = zonalAve(nppglobe)
252.1616 + s(1,:) = zonalAve(nppmod)
252.1617 +
252.1618 + s@long_name = nppglobe@long_name
252.1619 +;-------------------------------------------
252.1620 +;(d) compute correlation coef and M score
252.1621 +
252.1622 + ccrZ = esccr(s(1,:), s(0,:),0)
252.1623 +; print (ccrZ)
252.1624 +
252.1625 + MZ = (ccrZ*ccrZ)* 5.0
252.1626 + print (MZ)
252.1627 +;-------------------------------------------
252.1628 + plot_name = "zonal_model_vs_ob"
252.1629 + title = "Zonal Average"
252.1630 + resz@tiMainString = title
252.1631 +
252.1632 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
252.1633 +
252.1634 +; resz@vpHeightF = 0.4 ; change aspect ratio of plot
252.1635 +; resz@vpWidthF = 0.7
252.1636 +
252.1637 + resz@xyMonoLineColor = "False" ; want colored lines
252.1638 + resz@xyLineColors = (/"black","red"/) ; colors chosen
252.1639 +; resz@xyLineThicknesses = (/3.,3./) ; line thicknesses
252.1640 + resz@xyLineThicknesses = (/2.,2./) ; line thicknesses
252.1641 + resz@xyDashPatterns = (/0.,0./) ; make all lines solid
252.1642 +
252.1643 + resz@tiYAxisString = s@long_name ; add a axis title
252.1644 + resz@txFontHeightF = 0.0195 ; change title font heights
252.1645 +
252.1646 +; Legent
252.1647 + resz@pmLegendDisplayMode = "Always" ; turn on legend
252.1648 + resz@pmLegendSide = "Top" ; Change location of
252.1649 +; resz@pmLegendParallelPosF = .45 ; move units right
252.1650 + resz@pmLegendParallelPosF = .82 ; move units right
252.1651 + resz@pmLegendOrthogonalPosF = -0.4 ; move units down
252.1652 +
252.1653 + resz@pmLegendWidthF = 0.10 ; Change width and
252.1654 + resz@pmLegendHeightF = 0.10 ; height of legend.
252.1655 + resz@lgLabelFontHeightF = .02 ; change font height
252.1656 +; resz@lgTitleOn = True ; turn on legend title
252.1657 +; resz@lgTitleString = "Example" ; create legend title
252.1658 +; resz@lgTitleFontHeightF = .025 ; font of legend title
252.1659 + resz@xyExplicitLegendLabels = (/"Observed",model_name/) ; explicit labels
252.1660 +;--------------------------------------------------------------------
252.1661 + zRes = True
252.1662 + zRes@txFontHeightF = 0.025
252.1663 +
252.1664 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrZ)+")"
252.1665 +
252.1666 + gsn_text_ndc(wks,correlation_text,0.50,0.77,zRes)
252.1667 +;--------------------------------------------------------------------
252.1668 +
252.1669 + plot = gsn_csm_xy (wks,ym,s,resz) ; create plot
252.1670 +
252.1671 + frame(wks) ; advance frame
252.1672 +
252.1673 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
252.1674 + system("rm "+plot_name+"."+plot_type)
252.1675 + system("rm "+plot_name+"-1."+plot_type_new)
252.1676 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
252.1677 +
252.1678 + clear (wks)
252.1679 +;------------------------------------------------------------------------
252.1680 + temp_name = "temp." + model_name
252.1681 + system("mkdir -p " + temp_name)
252.1682 + system("mv *.png " + temp_name)
252.1683 + system("tar cf "+ temp_name +".tar " + temp_name)
252.1684 +;------------------------------------------------------------------------
252.1685 +end
252.1686 +
253.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
253.2 +++ b/npp/99.all.ncl.1 Mon Jan 26 22:08:20 2009 -0500
253.3 @@ -0,0 +1,1667 @@
253.4 +;*****************************************************
253.5 +; combine scatter, histogram, global and zonal plots
253.6 +; compute all correlation coef and M score
253.7 +; add 1-to-1 line in scatter plots
253.8 +;*****************************************************
253.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
253.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
253.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
253.12 +;*****************************************************
253.13 +procedure get_bin(RAIN1_1D[*]:numeric, NPP1_1D[*]:numeric \
253.14 + ,RAIN2_1D[*]:numeric, NPP2_1D[*]:numeric \
253.15 + ,xvalues[*][*]:numeric, yvalues[*][*]:numeric \
253.16 + ,mn_yvalues[*][*]:numeric, mx_yvalues[*][*]:numeric \
253.17 + ,dx4[1]:numeric \
253.18 + )
253.19 +begin
253.20 +; Calculaee "nice" bins for binning the data in equally spaced ranges.
253.21 +; input : RAIN1_1D, RAIN2_1D, NPP1_1D, NPP2_1D
253.22 +; output: xvalues, yvalues, mn_yvalues, mx_yvalues,dx4
253.23 +
253.24 + nbins = 15 ; Number of bins to use.
253.25 +
253.26 + nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
253.27 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
253.28 + range = fspan(nicevals(0),nicevals(1),nvals)
253.29 +
253.30 +; Use this range information to grab all the values in a
253.31 +; particular range, and then take an average.
253.32 +
253.33 + nr = dimsizes(range)
253.34 + nx = nr-1
253.35 +; print (nx)
253.36 +
253.37 +; xvalues = new((/2,nx/),typeof(RAIN1_1D))
253.38 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
253.39 + dx = xvalues(0,1) - xvalues(0,0) ; range width
253.40 + dx4 = dx/4 ; 1/4 of the range
253.41 + xvalues(1,:) = xvalues(0,:) - dx/5.
253.42 +; yvalues = new((/2,nx/),typeof(RAIN1_1D))
253.43 +; mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
253.44 +; mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
253.45 +
253.46 + do nd=0,1
253.47 +
253.48 +; See if we are doing model or observational data.
253.49 +
253.50 + if(nd.eq.0) then
253.51 + data = RAIN1_1D
253.52 + npp_data = NPP1_1D
253.53 + else
253.54 + data = RAIN2_1D
253.55 + npp_data = NPP2_1D
253.56 + end if
253.57 +
253.58 +; Loop through each range and check for values.
253.59 +
253.60 + do i=0,nr-2
253.61 + if (i.ne.(nr-2)) then
253.62 +; print("")
253.63 +; print("In range ["+range(i)+","+range(i+1)+")")
253.64 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
253.65 + else
253.66 +; print("")
253.67 +; print("In range ["+range(i)+",)")
253.68 + idx = ind(range(i).le.data)
253.69 + end if
253.70 +
253.71 +; Calculate average, and get min and max.
253.72 +
253.73 + if(.not.any(ismissing(idx))) then
253.74 + yvalues(nd,i) = avg(npp_data(idx))
253.75 + mn_yvalues(nd,i) = min(npp_data(idx))
253.76 + mx_yvalues(nd,i) = max(npp_data(idx))
253.77 + count = dimsizes(idx)
253.78 + else
253.79 + count = 0
253.80 + yvalues(nd,i) = yvalues@_FillValue
253.81 + mn_yvalues(nd,i) = yvalues@_FillValue
253.82 + mx_yvalues(nd,i) = yvalues@_FillValue
253.83 + end if
253.84 +
253.85 +; Print out information.
253.86 +
253.87 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
253.88 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
253.89 +
253.90 +
253.91 +; Clean up for next time in loop.
253.92 +
253.93 + delete(idx)
253.94 + end do
253.95 + delete(data)
253.96 + delete(npp_data)
253.97 + end do
253.98 +end
253.99 +;****************************************************************************
253.100 +; Main code.
253.101 +;****************************************************************************
253.102 +begin
253.103 +
253.104 + plot_type = "ps"
253.105 + plot_type_new = "png"
253.106 +
253.107 +;************************************************
253.108 +; read model data
253.109 +;************************************************
253.110 +
253.111 +;film = "i01.06cn_1798-2004_ANN_climo.nc"
253.112 +;model_name = "06cn"
253.113 +;model_grid = "T42"
253.114 +
253.115 +;film = "i01.06casa_1798-2004_ANN_climo.nc"
253.116 +;model_name = "06casa"
253.117 +;model_grid = "T42"
253.118 +
253.119 + film = "i01.10casa_1948-2004_ANN_climo.nc"
253.120 + model_name = "10casa"
253.121 + model_grid = "T42"
253.122 +
253.123 +;film = "i01.10cn_1948-2004_ANN_climo.nc"
253.124 +;model_name = "10cn"
253.125 +;model_grid = "T42"
253.126 +;--------------------------------------------------
253.127 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
253.128 + fm = addfile (dirm+film,"r")
253.129 +
253.130 + nppmod0 = fm->NPP
253.131 + rainmod0 = fm->RAIN
253.132 + xm = fm->lon
253.133 + ym = fm->lat
253.134 +
253.135 +;************************************************
253.136 +; read ob data
253.137 +;************************************************
253.138 +
253.139 +;(1) data at 81 sites
253.140 + dir81 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
253.141 + fil81 = "data.81.nc"
253.142 + f81 = addfile (dir81+fil81,"r")
253.143 +
253.144 + id81 = f81->SITE_ID
253.145 + npp81 = f81->TNPP_C
253.146 + rain81 = tofloat(f81->PREC_ANN)
253.147 + x81 = f81->LONG_DD
253.148 + y81 = f81->LAT_DD
253.149 +
253.150 + id81@long_name = "SITE_ID"
253.151 +
253.152 +;change longitude from (-180,180) to (0,360)
253.153 +;for model data interpolation
253.154 +
253.155 + do i= 0,dimsizes(x81)-1
253.156 + if (x81(i) .lt. 0.) then
253.157 + x81(i) = x81(i)+ 360.
253.158 + end if
253.159 + end do
253.160 +;print (x81)
253.161 +;-------------------------------------
253.162 +;(2) data at 933 sites
253.163 + dir933 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
253.164 + fil933 = "data.933.nc"
253.165 + f933 = addfile (dir933+fil933,"r")
253.166 +
253.167 + id933 = f933->SITE_ID
253.168 + npp933 = f933->TNPP_C
253.169 + rain933 = f933->PREC
253.170 + x933 = f933->LONG_DD
253.171 + y933 = f933->LAT_DD
253.172 +
253.173 + id933@long_name = "SITE_ID"
253.174 +
253.175 +;change longitude from (-180,180) to (0,360)
253.176 +;for model data interpolation
253.177 +
253.178 + do i= 0,dimsizes(x933)-1
253.179 + if (x933(i) .lt. 0.) then
253.180 + x933(i) = x933(i)+ 360.
253.181 + end if
253.182 + end do
253.183 +;print (x933)
253.184 +;----------------------------------------
253.185 +;(3) global data, interpolated into model grid
253.186 + dirglobe = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
253.187 + filglobe = "Npp_"+model_grid+"_mean.nc"
253.188 + fglobe = addfile (dirglobe+filglobe,"r")
253.189 +
253.190 + nppglobe0 = fglobe->NPP
253.191 + nppglobe = nppglobe0
253.192 +
253.193 +;***********************************************************************
253.194 +; interpolate model data into ob sites
253.195 +;***********************************************************************
253.196 +
253.197 + nppmod = nppmod0(0,:,:)
253.198 + rainmod = rainmod0(0,:,:)
253.199 + delete (nppmod0)
253.200 + delete (rainmod0)
253.201 +
253.202 + nppmod81 =linint2_points(xm,ym,nppmod,True,x81,y81,0)
253.203 +
253.204 + nppmod933 =linint2_points(xm,ym,nppmod,True,x933,y933,0)
253.205 +
253.206 + rainmod81 =linint2_points(xm,ym,rainmod,True,x81,y81,0)
253.207 +
253.208 + rainmod933=linint2_points(xm,ym,rainmod,True,x933,y933,0)
253.209 +
253.210 +;**********************************************************
253.211 +; unified units
253.212 +;**********************************************************
253.213 +; Units for these variables are:
253.214 +;
253.215 +; rain81 : mm/year
253.216 +; rainmod : mm/s
253.217 +; npp81 : g C/m^2/year
253.218 +; nppmod81: g C/m^2/s
253.219 +; nppglobe: g C/m^2/year
253.220 +;
253.221 +; We want to convert these to "m/year" and "g C/m^2/year".
253.222 +
253.223 + nsec_per_year = 60*60*24*365
253.224 +
253.225 + rain81 = rain81 / 1000.
253.226 + rainmod81 = (rainmod81/ 1000.) * nsec_per_year
253.227 + nppmod81 = nppmod81 * nsec_per_year
253.228 +
253.229 + rain933 = rain933 / 1000.
253.230 + rainmod933 = (rainmod933/ 1000.) * nsec_per_year
253.231 + nppmod933 = nppmod933 * nsec_per_year
253.232 +
253.233 + nppmod = nppmod * nsec_per_year
253.234 +
253.235 + npp81@units = "gC/m^2/yr"
253.236 + nppmod81@units = "gC/m^2/yr"
253.237 + npp933@units = "gC/m^2/yr"
253.238 + nppmod933@units = "gC/m^2/yr"
253.239 + nppmod@units = "gC/m^2/yr"
253.240 + nppglobe@units = "gC/m^2/yr"
253.241 + rain81@units = "m/yr"
253.242 + rainmod81@units = "m/yr"
253.243 + rain933@units = "m/yr"
253.244 + rainmod933@units = "m/yr"
253.245 +
253.246 + npp81@long_name = "NPP (gC/m2/year)"
253.247 + npp933@long_name = "NPP (gC/m2/year)"
253.248 + nppmod81@long_name = "NPP (gC/m2/year)"
253.249 + nppmod933@long_name = "NPP (gC/m2/year)"
253.250 + nppmod@long_name = "NPP (gC/m2/year)"
253.251 + nppglobe@long_name = "NPP (gC/m2/year)"
253.252 + rain81@long_name = "PREC (m/year)"
253.253 + rain933@long_name = "PREC (m/year)"
253.254 + rainmod81@long_name = "PREC (m/year)"
253.255 + rainmod933@long_name = "PREC (m/year)"
253.256 +
253.257 +;*******************************************************************
253.258 +;(A)-1 table of site81 (1) (the first 41 sites)
253.259 +;*******************************************************************
253.260 +
253.261 + table_length = 0.95
253.262 +
253.263 +; table header name
253.264 + table_header_name = "Site ID"
253.265 +
253.266 +; column (not including header column)
253.267 + col_header = (/"Latitude","Longitude","NPP (gC/m2/year)","RAIN (m/year)"/)
253.268 + ncol = dimsizes(col_header)
253.269 +
253.270 +; row (not including header row)
253.271 + nrow = 41
253.272 + row_header = new ((/nrow/),string )
253.273 + row_header(0:nrow-1) = id81(0:nrow-1)
253.274 +
253.275 +; Table header
253.276 + ncr1 = (/1,1/) ; 1 row, 1 column
253.277 + x1 = (/0.005,0.15/) ; Start and end X
253.278 + y1 = (/0.900,0.95/) ; Start and end Y
253.279 + text1 = table_header_name
253.280 + res1 = True
253.281 + res1@txFontHeightF = 0.015
253.282 + res1@gsFillColor = "CornFlowerBlue"
253.283 +
253.284 +; Column header (equally space in x2)
253.285 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
253.286 + x2 = (/x1(1),0.995/) ; start from end of x1
253.287 + y2 = y1 ; same as y1
253.288 + text2 = col_header
253.289 + res2 = True
253.290 + res2@txFontHeightF = 0.015
253.291 + res2@gsFillColor = "Gray"
253.292 +
253.293 +; Row header (equally space in y2)
253.294 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
253.295 + x3 = x1 ; same as x1
253.296 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
253.297 + text3 = row_header
253.298 + res3 = True
253.299 + res3@txFontHeightF = 0.010
253.300 + res3@gsFillColor = "Gray"
253.301 +
253.302 +; Main table body
253.303 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
253.304 + x4 = x2 ; Start and end x
253.305 + y4 = y3 ; Start and end Y
253.306 + text4 = new((/nrow,ncol/),string)
253.307 +
253.308 + color_fill4 = new((/nrow,ncol/),string)
253.309 + color_fill4 = "white"
253.310 +; color_fill4(:,ncol-1) = "grey"
253.311 +; color_fill4(nrow-1,:) = "green"
253.312 +
253.313 + res4 = True ; Set up resource list
253.314 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
253.315 + res4@txFontHeightF = 0.015
253.316 + res4@gsFillColor = color_fill4
253.317 +
253.318 + delete (color_fill4)
253.319 +;-------------------------------------------------------------------
253.320 +; for table value
253.321 +
253.322 + do n = 0,nrow-1
253.323 + text4(n,0) = sprintf("%5.2f", y81(n))
253.324 + text4(n,1) = sprintf("%5.2f", x81(n))
253.325 + text4(n,2) = sprintf("%5.2f", npp81(n))
253.326 + text4(n,3) = sprintf("%5.2f", rain81(n))
253.327 + end do
253.328 +;-------------------------------------------------------------------
253.329 +
253.330 + plot_name = "table_site81_ob1"
253.331 +
253.332 + wks = gsn_open_wks (plot_type,plot_name)
253.333 +;------------------------------------------
253.334 +; for table title
253.335 +
253.336 + gRes = True
253.337 + gRes@txFontHeightF = 0.02
253.338 +; gRes@txAngleF = 90
253.339 +
253.340 + title_text = "Observation at 81 Sites (1)"
253.341 +
253.342 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
253.343 +;------------------------------------------
253.344 +
253.345 + gsn_table(wks,ncr1,x1,y1,text1,res1)
253.346 + gsn_table(wks,ncr2,x2,y2,text2,res2)
253.347 + gsn_table(wks,ncr3,x3,y3,text3,res3)
253.348 + gsn_table(wks,ncr4,x4,y4,text4,res4)
253.349 +
253.350 + frame(wks)
253.351 + clear (wks)
253.352 +
253.353 + delete (row_header)
253.354 + delete (res3)
253.355 + delete (ncr3)
253.356 + delete (text3)
253.357 + delete (res4)
253.358 + delete (ncr4)
253.359 + delete (text4)
253.360 +
253.361 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.362 + system("rm "+plot_name+"."+plot_type)
253.363 + system("rm "+plot_name+"-1."+plot_type_new)
253.364 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.365 +
253.366 +;*******************************************************************
253.367 +;(A)-2 table of site81 (2) (the last 40 sites)
253.368 +;*******************************************************************
253.369 +
253.370 + table_length = 0.95
253.371 +
253.372 +; table header name
253.373 + table_header_name = "Site ID"
253.374 +
253.375 +; column (not including header column)
253.376 + col_header = (/"Latitude","Longitude","NPP (gC/m2/year)","RAIN (m/year)"/)
253.377 + ncol = dimsizes(col_header)
253.378 +
253.379 +; row (not including header row)
253.380 + nrow = 40
253.381 + row_header = new ((/nrow/),string )
253.382 + row_header(0:nrow-1) = id81(41:41+nrow-1)
253.383 +
253.384 +; Table header
253.385 + ncr1 = (/1,1/) ; 1 row, 1 column
253.386 + x1 = (/0.005,0.15/) ; Start and end X
253.387 + y1 = (/0.900,0.95/) ; Start and end Y
253.388 + text1 = table_header_name
253.389 + res1 = True
253.390 + res1@txFontHeightF = 0.015
253.391 + res1@gsFillColor = "CornFlowerBlue"
253.392 +
253.393 +; Column header (equally space in x2)
253.394 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
253.395 + x2 = (/x1(1),0.995/) ; start from end of x1
253.396 + y2 = y1 ; same as y1
253.397 + text2 = col_header
253.398 + res2 = True
253.399 + res2@txFontHeightF = 0.015
253.400 + res2@gsFillColor = "Gray"
253.401 +
253.402 +; Row header (equally space in y2)
253.403 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
253.404 + x3 = x1 ; same as x1
253.405 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
253.406 + text3 = row_header
253.407 + res3 = True
253.408 + res3@txFontHeightF = 0.010
253.409 + res3@gsFillColor = "Gray"
253.410 +
253.411 +; Main table body
253.412 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
253.413 + x4 = x2 ; Start and end x
253.414 + y4 = y3 ; Start and end Y
253.415 + text4 = new((/nrow,ncol/),string)
253.416 +
253.417 + color_fill4 = new((/nrow,ncol/),string)
253.418 + color_fill4 = "white"
253.419 +; color_fill4(:,ncol-1) = "grey"
253.420 +; color_fill4(nrow-1,:) = "green"
253.421 +
253.422 + res4 = True ; Set up resource list
253.423 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
253.424 + res4@txFontHeightF = 0.015
253.425 + res4@gsFillColor = color_fill4
253.426 +
253.427 + delete (color_fill4)
253.428 +;-------------------------------------------------------------------
253.429 +; for table value
253.430 +
253.431 + do n = 0,nrow-1
253.432 + text4(n,0) = sprintf("%5.2f", y81(n+41))
253.433 + text4(n,1) = sprintf("%5.2f", x81(n+41))
253.434 + text4(n,2) = sprintf("%5.2f", npp81(n+41))
253.435 + text4(n,3) = sprintf("%5.2f", rain81(n+41))
253.436 + end do
253.437 +;-------------------------------------------------------------------
253.438 +
253.439 + plot_name = "table_site81_ob2"
253.440 +
253.441 + wks = gsn_open_wks (plot_type,plot_name)
253.442 +;------------------------------------------
253.443 +; for table title
253.444 +
253.445 + gRes = True
253.446 + gRes@txFontHeightF = 0.02
253.447 +; gRes@txAngleF = 90
253.448 +
253.449 + title_text = "Observation at 81 Sites (2)"
253.450 +
253.451 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
253.452 +;------------------------------------------
253.453 +
253.454 + gsn_table(wks,ncr1,x1,y1,text1,res1)
253.455 + gsn_table(wks,ncr2,x2,y2,text2,res2)
253.456 + gsn_table(wks,ncr3,x3,y3,text3,res3)
253.457 + gsn_table(wks,ncr4,x4,y4,text4,res4)
253.458 +
253.459 + frame(wks)
253.460 + clear (wks)
253.461 +
253.462 + delete (row_header)
253.463 + delete (res3)
253.464 + delete (ncr3)
253.465 + delete (text3)
253.466 + delete (res4)
253.467 + delete (ncr4)
253.468 + delete (text4)
253.469 +
253.470 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.471 + system("rm "+plot_name+"."+plot_type)
253.472 + system("rm "+plot_name+"-1."+plot_type_new)
253.473 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.474 +
253.475 +;**************************************************************************
253.476 +;(A)-3 scatter plot, ob 933
253.477 +;**************************************************************************
253.478 +
253.479 + plot_name = "scatter_ob_933"
253.480 + title = "Observed 933 sites"
253.481 +
253.482 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
253.483 + res = True ; plot mods desired
253.484 + res@tiMainString = title ; add title
253.485 + res@xyMarkLineModes = "Markers" ; choose which have markers
253.486 + res@xyMarkers = 16 ; choose type of marker
253.487 + res@xyMarkerColor = "red" ; Marker color
253.488 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
253.489 + res@tmLabelAutoStride = True ; nice tick mark labels
253.490 +
253.491 + plot = gsn_csm_xy (wks,id933,npp933,res) ; create plot
253.492 + frame(wks)
253.493 + clear (wks)
253.494 +
253.495 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.496 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.497 + system("rm "+plot_name+"-*."+plot_type_new)
253.498 + system("rm "+plot_name+"."+plot_type)
253.499 +
253.500 +;**************************************************************************
253.501 +;(A)-4 scatter plot, model 933
253.502 +;**************************************************************************
253.503 +
253.504 + plot_name = "scatter_model_933"
253.505 + title = "Model "+ model_name +" 933 sites"
253.506 +
253.507 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
253.508 + res = True ; plot mods desired
253.509 + res@tiMainString = title ; add title
253.510 + res@xyMarkLineModes = "Markers" ; choose which have markers
253.511 + res@xyMarkers = 16 ; choose type of marker
253.512 + res@xyMarkerColor = "red" ; Marker color
253.513 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
253.514 + res@tmLabelAutoStride = True ; nice tick mark labels
253.515 +
253.516 + plot = gsn_csm_xy (wks,id933,nppmod933,res) ; create plot
253.517 + frame(wks)
253.518 + clear (wks)
253.519 +
253.520 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.521 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.522 + system("rm "+plot_name+"-*."+plot_type_new)
253.523 + system("rm "+plot_name+"."+plot_type)
253.524 +
253.525 +;***************************************************************************
253.526 +;(A)-5 scatter plot, model vs ob 81
253.527 +;***************************************************************************
253.528 +
253.529 + plot_name = "scatter_model_vs_ob_81"
253.530 + title = model_name +" vs ob 81 sites"
253.531 +
253.532 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
253.533 + res = True ; plot mods desired
253.534 + res@tiMainString = title ; add title
253.535 + res@xyMarkLineModes = "Markers" ; choose which have markers
253.536 + res@xyMarkers = 16 ; choose type of marker
253.537 + res@xyMarkerColor = "red" ; Marker color
253.538 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
253.539 + res@tmLabelAutoStride = True ; nice tick mark labels
253.540 +
253.541 + res@gsnDraw = False
253.542 + res@gsnFrame = False ; don't advance frame yet
253.543 +;-------------------------------
253.544 +;compute correlation coef. and M
253.545 + ccr81 = esccr(nppmod81,npp81,0)
253.546 +;print (ccr81)
253.547 +
253.548 +;new eq
253.549 + bias = sum(abs(nppmod81-npp81)/(abs(nppmod81)+abs(npp81)))
253.550 + M81 = (1. - (bias/dimsizes(y81)))*5.
253.551 + print (M81)
253.552 +
253.553 + tRes = True
253.554 + tRes@txFontHeightF = 0.025
253.555 +
253.556 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81)+")"
253.557 +
253.558 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
253.559 +;--------------------------------
253.560 + plot = gsn_csm_xy (wks,npp81,nppmod81,res) ; create plot
253.561 +;-------------------------------
253.562 +; add polyline
253.563 +
253.564 + dum=gsn_add_polyline(wks,plot,(/0,1200/),(/0,1200/),False)
253.565 +;-------------------------------
253.566 + draw (plot)
253.567 + frame(wks)
253.568 + clear (wks)
253.569 + delete (dum)
253.570 +
253.571 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.572 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.573 + system("rm "+plot_name+"-*."+plot_type_new)
253.574 + system("rm "+plot_name+"."+plot_type)
253.575 +
253.576 +;***************************************************************************
253.577 +;(A)-6 scatter plot, model vs ob 933
253.578 +;***************************************************************************
253.579 +
253.580 + plot_name = "scatter_model_vs_ob_933"
253.581 + title = model_name +" vs ob 933 sites"
253.582 +
253.583 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
253.584 + res = True ; plot mods desired
253.585 + res@tiMainString = title ; add title
253.586 + res@xyMarkLineModes = "Markers" ; choose which have markers
253.587 + res@xyMarkers = 16 ; choose type of marker
253.588 + res@xyMarkerColor = "red" ; Marker color
253.589 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
253.590 + res@tmLabelAutoStride = True ; nice tick mark labels
253.591 +
253.592 + res@gsnDraw = False
253.593 + res@gsnFrame = False ; don't advance frame yet
253.594 +;-------------------------------
253.595 +;compute correlation coef. and M
253.596 + ccr933 = esccr(nppmod933,npp933,0)
253.597 +;print (ccr933)
253.598 +
253.599 +;new eq
253.600 + bias = sum(abs(nppmod933-npp933)/(abs(nppmod933)+abs(npp933)))
253.601 + M933 = (1. - (bias/dimsizes(y933)))*5.
253.602 + print (M933)
253.603 +
253.604 + tRes = True
253.605 + tRes@txFontHeightF = 0.025
253.606 +
253.607 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933)+")"
253.608 +
253.609 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
253.610 +;--------------------------------
253.611 + plot = gsn_csm_xy (wks,npp933,nppmod933,res) ; create plot
253.612 +;-------------------------------
253.613 +; add polyline
253.614 +
253.615 + dum=gsn_add_polyline(wks,plot,(/0,1500/),(/0,1500/),False)
253.616 +;-------------------------------
253.617 + draw (plot)
253.618 + frame(wks)
253.619 + clear (wks)
253.620 + delete (dum)
253.621 +
253.622 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.623 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.624 + system("rm "+plot_name+"-*."+plot_type_new)
253.625 + system("rm "+plot_name+"."+plot_type)
253.626 +
253.627 +;*******************************************************************
253.628 +;(A)-7 table of site81 (1) (the first 41 sites), model vs ob
253.629 +;*******************************************************************
253.630 +
253.631 + table_length = 0.95
253.632 +
253.633 +; table header name
253.634 + table_header_name = "Site ID"
253.635 +
253.636 +; row (not including header row)
253.637 + nrow = 41
253.638 + row_header = new ((/nrow/),string )
253.639 + row_header(0:nrow-1) = id81(0:nrow-1)
253.640 +
253.641 +; Table header
253.642 + ncr1 = (/1,1/) ; 1 row, 1 column
253.643 + x1 = (/0.005,0.15/) ; Start and end X
253.644 + y1 = (/0.85 ,0.95/) ; Start and end Y
253.645 + text1 = table_header_name
253.646 + res1 = True
253.647 + res1@txFontHeightF = 0.015
253.648 + res1@gsFillColor = "CornFlowerBlue"
253.649 +
253.650 +; Column header1 (equally space in x2)
253.651 +
253.652 + delete (col_header)
253.653 + delete (ncr2)
253.654 + delete (text2)
253.655 +
253.656 + col_header = (/"Latitude","Longitude"/)
253.657 + ncol = dimsizes(col_header)
253.658 +
253.659 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
253.660 + x2 = (/x1(1),0.35/) ; start from end of x1
253.661 + y2 = y1 ; same as y1
253.662 + text2 = col_header
253.663 + res2 = True
253.664 + res2@txFontHeightF = 0.015
253.665 + res2@gsFillColor = "Gray"
253.666 +
253.667 +; Column header2 (equally space in x2)
253.668 +
253.669 + col_header1 = (/"NPP (gC/m2/year)","RAIN (m/year)"/)
253.670 + col_header2 = (/"ob",model_name \
253.671 + ,"ob",model_name \
253.672 + /)
253.673 +
253.674 + ncol1 = dimsizes(col_header1)
253.675 + ncol2 = dimsizes(col_header2)
253.676 +
253.677 + ncr21 = (/1,ncol1/) ; 1 rows, 4 columns
253.678 + x21 = (/x2(1),0.995/) ; start from end of x2
253.679 + yhalf = (y1(0)+y1(1))*0.5
253.680 + y21 = (/yhalf,y1(1)/) ; top half of y1
253.681 + text21 = col_header1
253.682 + res21 = True
253.683 + res21@txFontHeightF = 0.015
253.684 + res21@gsFillColor = "Gray"
253.685 +
253.686 + ncr22 = (/1,ncol2/) ; 1 rows, 12 columns
253.687 + x22 = x21 ; start from end of x1
253.688 + y22 = (/y1(0),yhalf/) ; bottom half of y1
253.689 + text22 = col_header2
253.690 + res22 = True
253.691 + res22@txFontHeightF = 0.015
253.692 + res22@gsFillColor = "Gray"
253.693 +
253.694 +; Row header (equally space in y2)
253.695 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
253.696 + x3 = x1 ; same as x1
253.697 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
253.698 + text3 = row_header
253.699 + res3 = True
253.700 + res3@txFontHeightF = 0.010
253.701 + res3@gsFillColor = "Gray"
253.702 +
253.703 +; Main table body-1
253.704 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
253.705 + x4 = x2 ; Start and end x
253.706 + y4 = y3 ; Start and end Y
253.707 + text4 = new((/nrow,ncol/),string)
253.708 +
253.709 + color_fill4 = new((/nrow,ncol/),string)
253.710 + color_fill4 = "white"
253.711 +; color_fill4(:,ncol-1) = "grey"
253.712 +; color_fill4(nrow-1,:) = "green"
253.713 +
253.714 + res4 = True ; Set up resource list
253.715 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
253.716 + res4@txFontHeightF = 0.015
253.717 + res4@gsFillColor = color_fill4
253.718 +
253.719 + delete (color_fill4)
253.720 +
253.721 +; Main table body-2
253.722 + ncr42 = (/nrow,ncol2/) ; nrow rows, ncol columns
253.723 + x42 = x21 ; Start and end x
253.724 + y42 = y3 ; Start and end Y
253.725 + text42 = new((/nrow,ncol2/),string)
253.726 +
253.727 + color_fill42 = new((/nrow,ncol2/),string)
253.728 + color_fill42 = "white"
253.729 +; color_fill42(:,ncol-1) = "grey"
253.730 +; color_fill42(nrow-1,:) = "green"
253.731 +
253.732 + res42 = True ; Set up resource list
253.733 +; res42@gsnDebug = True ; Useful to print NDC row,col values used.
253.734 + res42@txFontHeightF = 0.015
253.735 + res42@gsFillColor = color_fill42
253.736 +
253.737 + delete (color_fill42)
253.738 +;-------------------------------------------------------------------
253.739 +; for table value
253.740 +
253.741 + do n = 0,nrow-1
253.742 + text4(n,0) = sprintf("%5.2f", y81(n))
253.743 + text4(n,1) = sprintf("%5.2f", x81(n))
253.744 + end do
253.745 +
253.746 + do n = 0,nrow-1
253.747 + text42(n,0) = sprintf("%5.2f", npp81(n))
253.748 + text42(n,1) = sprintf("%5.2f", nppmod81(n))
253.749 + text42(n,2) = sprintf("%5.2f", rain81(n))
253.750 + text42(n,3) = sprintf("%5.2f", rainmod81(n))
253.751 + end do
253.752 +;---------------------------------------------------------------------------
253.753 +
253.754 + plot_name = "table_site81_model_vs_ob1"
253.755 +
253.756 + wks = gsn_open_wks (plot_type,plot_name)
253.757 +;------------------------------------------
253.758 +; for table title
253.759 +
253.760 + gRes = True
253.761 + gRes@txFontHeightF = 0.02
253.762 +; gRes@txAngleF = 90
253.763 +
253.764 + title_text = "Model vs Observation at 81 Sites (1)"
253.765 +
253.766 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
253.767 +;------------------------------------------
253.768 +
253.769 + gsn_table(wks,ncr1,x1,y1,text1,res1)
253.770 + gsn_table(wks,ncr2,x2,y2,text2,res2)
253.771 + gsn_table(wks,ncr21,x21,y21,text21,res21)
253.772 + gsn_table(wks,ncr22,x22,y22,text22,res22)
253.773 + gsn_table(wks,ncr3,x3,y3,text3,res3)
253.774 + gsn_table(wks,ncr4,x4,y4,text4,res4)
253.775 + gsn_table(wks,ncr42,x42,y42,text42,res42)
253.776 +
253.777 + frame(wks)
253.778 + clear (wks)
253.779 +
253.780 + delete (col_header)
253.781 + delete (row_header)
253.782 + delete (res1)
253.783 + delete (ncr1)
253.784 + delete (text1)
253.785 + delete (res2)
253.786 + delete (ncr2)
253.787 + delete (text2)
253.788 + delete (res21)
253.789 + delete (ncr21)
253.790 + delete (text21)
253.791 + delete (res22)
253.792 + delete (ncr22)
253.793 + delete (text22)
253.794 + delete (res3)
253.795 + delete (ncr3)
253.796 + delete (text3)
253.797 + delete (res4)
253.798 + delete (ncr4)
253.799 + delete (text4)
253.800 + delete (res42)
253.801 + delete (ncr42)
253.802 + delete (text42)
253.803 +
253.804 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.805 + system("rm "+plot_name+"."+plot_type)
253.806 + system("rm "+plot_name+"-1."+plot_type_new)
253.807 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.808 +
253.809 +;*******************************************************************
253.810 +;(A)-8 table of site81 (2) (the last 40 sites), model vs ob
253.811 +;*******************************************************************
253.812 +
253.813 + table_length = 0.95
253.814 +
253.815 +; table header name
253.816 + table_header_name = "Site ID"
253.817 +
253.818 +; row (not including header row)
253.819 + nrow = 40
253.820 + row_header = new ((/nrow/),string )
253.821 + row_header(0:nrow-1) = id81(41:41+nrow-1)
253.822 +
253.823 +; Table header
253.824 + ncr1 = (/1,1/) ; 1 row, 1 column
253.825 + x1 = (/0.005,0.15/) ; Start and end X
253.826 + y1 = (/0.85 ,0.95/) ; Start and end Y
253.827 + text1 = table_header_name
253.828 + res1 = True
253.829 + res1@txFontHeightF = 0.015
253.830 + res1@gsFillColor = "CornFlowerBlue"
253.831 +
253.832 +; Column header1 (equally space in x2)
253.833 +
253.834 + col_header = (/"Latitude","Longitude"/)
253.835 + ncol = dimsizes(col_header)
253.836 +
253.837 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
253.838 + x2 = (/x1(1),0.35/) ; start from end of x1
253.839 + y2 = y1 ; same as y1
253.840 + text2 = col_header
253.841 + res2 = True
253.842 + res2@txFontHeightF = 0.015
253.843 + res2@gsFillColor = "Gray"
253.844 +
253.845 +; Column header2 (equally space in x2)
253.846 +
253.847 +; col_header1 = (/"NPP (gC/m2/year)","RAIN (m/year)"/)
253.848 + col_header2 = (/"ob",model_name \
253.849 + ,"ob",model_name \
253.850 + /)
253.851 +
253.852 + ncol1 = dimsizes(col_header1)
253.853 + ncol2 = dimsizes(col_header2)
253.854 +
253.855 + ncr21 = (/1,ncol1/) ; 1 rows, 4 columns
253.856 + x21 = (/x2(1),0.995/) ; start from end of x2
253.857 + yhalf = (y1(0)+y1(1))*0.5
253.858 + y21 = (/yhalf,y1(1)/) ; top half of y1
253.859 + text21 = col_header1
253.860 + res21 = True
253.861 + res21@txFontHeightF = 0.015
253.862 + res21@gsFillColor = "Gray"
253.863 +
253.864 + ncr22 = (/1,ncol2/) ; 1 rows, 12 columns
253.865 + x22 = x21 ; start from end of x1
253.866 + y22 = (/y1(0),yhalf/) ; bottom half of y1
253.867 + text22 = col_header2
253.868 + res22 = True
253.869 + res22@txFontHeightF = 0.015
253.870 + res22@gsFillColor = "Gray"
253.871 +
253.872 +; Row header (equally space in y2)
253.873 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
253.874 + x3 = x1 ; same as x1
253.875 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
253.876 + text3 = row_header
253.877 + res3 = True
253.878 + res3@txFontHeightF = 0.010
253.879 + res3@gsFillColor = "Gray"
253.880 +
253.881 +; Main table body-1
253.882 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
253.883 + x4 = x2 ; Start and end x
253.884 + y4 = y3 ; Start and end Y
253.885 + text4 = new((/nrow,ncol/),string)
253.886 +
253.887 + color_fill4 = new((/nrow,ncol/),string)
253.888 + color_fill4 = "white"
253.889 +; color_fill4(:,ncol-1) = "grey"
253.890 +; color_fill4(nrow-1,:) = "green"
253.891 +
253.892 + res4 = True ; Set up resource list
253.893 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
253.894 + res4@txFontHeightF = 0.015
253.895 + res4@gsFillColor = color_fill4
253.896 +
253.897 + delete (color_fill4)
253.898 +
253.899 +; Main table body-2
253.900 + ncr42 = (/nrow,ncol2/) ; nrow rows, ncol columns
253.901 + x42 = x21 ; Start and end x
253.902 + y42 = y3 ; Start and end Y
253.903 + text42 = new((/nrow,ncol2/),string)
253.904 +
253.905 + color_fill42 = new((/nrow,ncol2/),string)
253.906 + color_fill42 = "white"
253.907 +; color_fill42(:,ncol-1) = "grey"
253.908 +; color_fill42(nrow-1,:) = "green"
253.909 +
253.910 + res42 = True ; Set up resource list
253.911 +; res42@gsnDebug = True ; Useful to print NDC row,col values used.
253.912 + res42@txFontHeightF = 0.015
253.913 + res42@gsFillColor = color_fill42
253.914 +
253.915 + delete (color_fill42)
253.916 +;-------------------------------------------------------------------
253.917 +; for table value
253.918 +
253.919 + do n = 0,nrow-1
253.920 + text4(n,0) = sprintf("%5.2f", y81(n+41))
253.921 + text4(n,1) = sprintf("%5.2f", x81(n+41))
253.922 + end do
253.923 +
253.924 + do n = 0,nrow-1
253.925 + text42(n,0) = sprintf("%5.2f", npp81(n+41))
253.926 + text42(n,1) = sprintf("%5.2f", nppmod81(n+41))
253.927 + text42(n,2) = sprintf("%5.2f", rain81(n+41))
253.928 + text42(n,3) = sprintf("%5.2f", rainmod81(n+41))
253.929 + end do
253.930 +;-------------------------------------------------------------------
253.931 +
253.932 + plot_name = "table_site81_model_vs_ob2"
253.933 +
253.934 + wks = gsn_open_wks (plot_type,plot_name)
253.935 +;------------------------------------------
253.936 +; for table title
253.937 +
253.938 + gRes = True
253.939 + gRes@txFontHeightF = 0.02
253.940 +; gRes@txAngleF = 90
253.941 +
253.942 + title_text = "Model vs Observation at 81 Sites (2)"
253.943 +
253.944 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
253.945 +;------------------------------------------
253.946 +
253.947 + gsn_table(wks,ncr1,x1,y1,text1,res1)
253.948 + gsn_table(wks,ncr2,x2,y2,text2,res2)
253.949 + gsn_table(wks,ncr21,x21,y21,text21,res21)
253.950 + gsn_table(wks,ncr22,x22,y22,text22,res22)
253.951 + gsn_table(wks,ncr3,x3,y3,text3,res3)
253.952 + gsn_table(wks,ncr4,x4,y4,text4,res4)
253.953 + gsn_table(wks,ncr42,x42,y42,text42,res42)
253.954 +
253.955 + frame(wks)
253.956 + clear (wks)
253.957 +
253.958 + delete (col_header)
253.959 + delete (row_header)
253.960 + delete (res1)
253.961 + delete (ncr1)
253.962 + delete (text1)
253.963 + delete (res2)
253.964 + delete (ncr2)
253.965 + delete (text2)
253.966 + delete (res21)
253.967 + delete (ncr21)
253.968 + delete (text21)
253.969 + delete (res22)
253.970 + delete (ncr22)
253.971 + delete (text22)
253.972 + delete (res3)
253.973 + delete (ncr3)
253.974 + delete (text3)
253.975 + delete (res4)
253.976 + delete (ncr4)
253.977 + delete (text4)
253.978 + delete (res42)
253.979 + delete (ncr42)
253.980 + delete (text42)
253.981 +
253.982 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.983 + system("rm "+plot_name+"."+plot_type)
253.984 + system("rm "+plot_name+"-1."+plot_type_new)
253.985 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.986 +
253.987 +;**************************************************************************
253.988 +;(B) histogram 81
253.989 +;**************************************************************************
253.990 +;get data
253.991 + RAIN1_1D = ndtooned(rain81)
253.992 + RAIN2_1D = ndtooned(rainmod81)
253.993 + NPP1_1D = ndtooned(npp81)
253.994 + NPP2_1D = ndtooned(nppmod81)
253.995 +
253.996 +; number of bin
253.997 + nx = 8
253.998 +
253.999 + xvalues = new((/2,nx/),float)
253.1000 + yvalues = new((/2,nx/),float)
253.1001 + mn_yvalues = new((/2,nx/),float)
253.1002 + mx_yvalues = new((/2,nx/),float)
253.1003 + dx4 = new((/1/),float)
253.1004 +
253.1005 + get_bin(RAIN1_1D, NPP1_1D, RAIN2_1D, NPP2_1D \
253.1006 + ,xvalues,yvalues,mn_yvalues,mx_yvalues,dx4)
253.1007 +
253.1008 +;----------------------------------------
253.1009 +;compute correlation coeff and M score
253.1010 +
253.1011 + u = yvalues(0,:)
253.1012 + v = yvalues(1,:)
253.1013 +
253.1014 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
253.1015 + uu = u(good)
253.1016 + vv = v(good)
253.1017 +
253.1018 + ccr81h = esccr(uu,vv,0)
253.1019 +;print (ccr81h)
253.1020 +
253.1021 +;new eq
253.1022 + bias = sum(abs(vv-uu)/(abs(vv)+abs(uu)))
253.1023 + M81h = (1.- (bias/dimsizes(uu)))*5.
253.1024 + print (M81h)
253.1025 +
253.1026 + delete (u)
253.1027 + delete (v)
253.1028 + delete (uu)
253.1029 + delete (vv)
253.1030 +;----------------------------------------------------------------------
253.1031 +; histogram res
253.1032 + resh = True
253.1033 + resh@gsnMaximize = True
253.1034 + resh@gsnDraw = False
253.1035 + resh@gsnFrame = False
253.1036 + resh@xyMarkLineMode = "Markers"
253.1037 + resh@xyMarkerSizeF = 0.014
253.1038 + resh@xyMarker = 16
253.1039 + resh@xyMarkerColors = (/"Brown","Blue"/)
253.1040 + resh@trYMinF = min(mn_yvalues) - 10.
253.1041 + resh@trYMaxF = max(mx_yvalues) + 10.
253.1042 +
253.1043 + resh@tiYAxisString = "NPP (g C/m2/year)"
253.1044 + resh@tiXAxisString = "Precipitation (m/year)"
253.1045 +
253.1046 + max_bar = new((/2,nx/),graphic)
253.1047 + min_bar = new((/2,nx/),graphic)
253.1048 + max_cap = new((/2,nx/),graphic)
253.1049 + min_cap = new((/2,nx/),graphic)
253.1050 +
253.1051 + lnres = True
253.1052 + line_colors = (/"brown","blue"/)
253.1053 +
253.1054 +;**************************************************************************
253.1055 +;(B)-1 histogram plot, ob 81 site
253.1056 +;**************************************************************************
253.1057 +
253.1058 + plot_name = "histogram_ob_81"
253.1059 + title = "Observed 81 site"
253.1060 + resh@tiMainString = title
253.1061 +
253.1062 + wks = gsn_open_wks (plot_type,plot_name)
253.1063 +
253.1064 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
253.1065 +
253.1066 +;-------------------------------
253.1067 +;Attach the vertical bar and the horizontal cap line
253.1068 +
253.1069 + delete (x1)
253.1070 + delete (x2)
253.1071 + delete (y1)
253.1072 + delete (y2)
253.1073 +
253.1074 + do nd=0,0
253.1075 + lnres@gsLineColor = line_colors(nd)
253.1076 + do i=0,nx-1
253.1077 +
253.1078 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
253.1079 + .not.ismissing(mx_yvalues(nd,i))) then
253.1080 +;
253.1081 +; Attach the vertical bar, both above and below the marker.
253.1082 +;
253.1083 + x1 = xvalues(nd,i)
253.1084 + y1 = yvalues(nd,i)
253.1085 + y2 = mn_yvalues(nd,i)
253.1086 + plx = (/x1,x1/)
253.1087 + ply = (/y1,y2/)
253.1088 + min_bar(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
253.1089 +
253.1090 + y2 = mx_yvalues(nd,i)
253.1091 + plx = (/x1,x1/)
253.1092 + ply = (/y1,y2/)
253.1093 + max_bar(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
253.1094 +;
253.1095 +; Attach the horizontal cap line, both above and below the marker.
253.1096 +;
253.1097 + x1 = xvalues(nd,i) - dx4
253.1098 + x2 = xvalues(nd,i) + dx4
253.1099 + y1 = mn_yvalues(nd,i)
253.1100 + plx = (/x1,x2/)
253.1101 + ply = (/y1,y1/)
253.1102 + min_cap(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
253.1103 +
253.1104 + y1 = mx_yvalues(nd,i)
253.1105 + plx = (/x1,x2/)
253.1106 + ply = (/y1,y1/)
253.1107 + max_cap(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
253.1108 + end if
253.1109 + end do
253.1110 + end do
253.1111 +
253.1112 + draw(xy)
253.1113 + frame(wks)
253.1114 + clear (wks)
253.1115 +
253.1116 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.1117 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.1118 + system("rm "+plot_name+"-*."+plot_type_new)
253.1119 + system("rm "+plot_name+"."+plot_type)
253.1120 +
253.1121 +;****************************************************************************
253.1122 +;(B)-2 histogram plot, model vs ob 81 site
253.1123 +;****************************************************************************
253.1124 +
253.1125 + plot_name = "histogram_model_vs_ob_81"
253.1126 + title = model_name+ " vs Observed 81 site"
253.1127 + resh@tiMainString = title
253.1128 +
253.1129 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
253.1130 +
253.1131 +;-----------------------------
253.1132 +; Add a boxed legend using the more simple method, which won't have
253.1133 +; vertical lines going through the markers.
253.1134 +
253.1135 + resh@pmLegendDisplayMode = "Always"
253.1136 +; resh@pmLegendWidthF = 0.1
253.1137 + resh@pmLegendWidthF = 0.08
253.1138 + resh@pmLegendHeightF = 0.05
253.1139 + resh@pmLegendOrthogonalPosF = -1.17
253.1140 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
253.1141 +; resh@pmLegendParallelPosF = 0.18
253.1142 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
253.1143 +
253.1144 +; resh@lgPerimOn = False
253.1145 + resh@lgLabelFontHeightF = 0.015
253.1146 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
253.1147 +;-----------------------------
253.1148 + tRes = True
253.1149 + tRes@txFontHeightF = 0.025
253.1150 +
253.1151 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81h)+")"
253.1152 +
253.1153 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
253.1154 +
253.1155 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
253.1156 +;-------------------------------
253.1157 +;Attach the vertical bar and the horizontal cap line
253.1158 +
253.1159 + do nd=0,1
253.1160 + lnres@gsLineColor = line_colors(nd)
253.1161 + do i=0,nx-1
253.1162 +
253.1163 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
253.1164 + .not.ismissing(mx_yvalues(nd,i))) then
253.1165 +;
253.1166 +; Attach the vertical bar, both above and below the marker.
253.1167 +;
253.1168 + x1 = xvalues(nd,i)
253.1169 + y1 = yvalues(nd,i)
253.1170 + y2 = mn_yvalues(nd,i)
253.1171 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
253.1172 +
253.1173 + y2 = mx_yvalues(nd,i)
253.1174 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
253.1175 +;
253.1176 +; Attach the horizontal cap line, both above and below the marker.
253.1177 +;
253.1178 + x1 = xvalues(nd,i) - dx4
253.1179 + x2 = xvalues(nd,i) + dx4
253.1180 + y1 = mn_yvalues(nd,i)
253.1181 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
253.1182 +
253.1183 + y1 = mx_yvalues(nd,i)
253.1184 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
253.1185 + end if
253.1186 + end do
253.1187 + end do
253.1188 +
253.1189 + draw(xy)
253.1190 + frame(wks)
253.1191 + clear(wks)
253.1192 +
253.1193 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.1194 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.1195 + system("rm "+plot_name+"-*."+plot_type_new)
253.1196 + system("rm "+plot_name+"."+plot_type)
253.1197 +
253.1198 + delete (RAIN1_1D)
253.1199 + delete (RAIN2_1D)
253.1200 + delete (NPP1_1D)
253.1201 + delete (NPP2_1D)
253.1202 +;delete (range)
253.1203 + delete (xvalues)
253.1204 + delete (yvalues)
253.1205 + delete (mn_yvalues)
253.1206 + delete (mx_yvalues)
253.1207 + delete (good)
253.1208 + delete (max_bar)
253.1209 + delete (min_bar)
253.1210 + delete (max_cap)
253.1211 + delete (min_cap)
253.1212 +
253.1213 +;**************************************************************************
253.1214 +;(B) histogram 933
253.1215 +;**************************************************************************
253.1216 +
253.1217 +; get data
253.1218 + RAIN1_1D = ndtooned(rain933)
253.1219 + RAIN2_1D = ndtooned(rainmod933)
253.1220 + NPP1_1D = ndtooned(npp933)
253.1221 + NPP2_1D = ndtooned(nppmod933)
253.1222 +
253.1223 +; number of bin
253.1224 + nx = 10
253.1225 +
253.1226 + xvalues = new((/2,nx/),float)
253.1227 + yvalues = new((/2,nx/),float)
253.1228 + mn_yvalues = new((/2,nx/),float)
253.1229 + mx_yvalues = new((/2,nx/),float)
253.1230 + dx4 = new((/1/),float)
253.1231 +
253.1232 + get_bin(RAIN1_1D, NPP1_1D, RAIN2_1D, NPP2_1D \
253.1233 + ,xvalues,yvalues,mn_yvalues,mx_yvalues,dx4)
253.1234 +
253.1235 +;----------------------------------------
253.1236 +;compute correlation coeff and M score
253.1237 +
253.1238 + u = yvalues(0,:)
253.1239 + v = yvalues(1,:)
253.1240 +
253.1241 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
253.1242 + uu = u(good)
253.1243 + vv = v(good)
253.1244 +
253.1245 + ccr933h = esccr(uu,vv,0)
253.1246 +;print (ccr933h)
253.1247 +
253.1248 +;new eq
253.1249 + bias = sum(abs(vv-uu)/(abs(vv)+abs(uu)))
253.1250 + M933h = (1.- (bias/dimsizes(uu)))*5.
253.1251 + print (M933h)
253.1252 +
253.1253 + delete (u)
253.1254 + delete (v)
253.1255 + delete (uu)
253.1256 + delete (vv)
253.1257 +;----------------------------------------------------------------------
253.1258 +; histogram res
253.1259 + delete (resh)
253.1260 + resh = True
253.1261 + resh@gsnMaximize = True
253.1262 + resh@gsnDraw = False
253.1263 + resh@gsnFrame = False
253.1264 + resh@xyMarkLineMode = "Markers"
253.1265 + resh@xyMarkerSizeF = 0.014
253.1266 + resh@xyMarker = 16
253.1267 + resh@xyMarkerColors = (/"Brown","Blue"/)
253.1268 + resh@trYMinF = min(mn_yvalues) - 10.
253.1269 + resh@trYMaxF = max(mx_yvalues) + 10.
253.1270 +
253.1271 + resh@tiYAxisString = "NPP (g C/m2/year)"
253.1272 + resh@tiXAxisString = "Precipitation (m/year)"
253.1273 +
253.1274 + max_bar = new((/2,nx/),graphic)
253.1275 + min_bar = new((/2,nx/),graphic)
253.1276 + max_cap = new((/2,nx/),graphic)
253.1277 + min_cap = new((/2,nx/),graphic)
253.1278 +
253.1279 + lnres = True
253.1280 + line_colors = (/"brown","blue"/)
253.1281 +
253.1282 +;**************************************************************************
253.1283 +;(B)-3 histogram plot, ob 933 site
253.1284 +;**************************************************************************
253.1285 +
253.1286 + plot_name = "histogram_ob_933"
253.1287 + title = "Observed 933 site"
253.1288 + resh@tiMainString = title
253.1289 +
253.1290 + wks = gsn_open_wks (plot_type,plot_name)
253.1291 +
253.1292 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
253.1293 +
253.1294 +;-------------------------------
253.1295 +;Attach the vertical bar and the horizontal cap line
253.1296 +
253.1297 + do nd=0,0
253.1298 + lnres@gsLineColor = line_colors(nd)
253.1299 + do i=0,nx-1
253.1300 +
253.1301 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
253.1302 + .not.ismissing(mx_yvalues(nd,i))) then
253.1303 +
253.1304 +; Attach the vertical bar, both above and below the marker.
253.1305 +
253.1306 + x1 = xvalues(nd,i)
253.1307 + y1 = yvalues(nd,i)
253.1308 + y2 = mn_yvalues(nd,i)
253.1309 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
253.1310 +
253.1311 + y2 = mx_yvalues(nd,i)
253.1312 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
253.1313 +
253.1314 +; Attach the horizontal cap line, both above and below the marker.
253.1315 +
253.1316 + x1 = xvalues(nd,i) - dx4
253.1317 + x2 = xvalues(nd,i) + dx4
253.1318 + y1 = mn_yvalues(nd,i)
253.1319 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
253.1320 +
253.1321 + y1 = mx_yvalues(nd,i)
253.1322 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
253.1323 + end if
253.1324 + end do
253.1325 + end do
253.1326 +
253.1327 + draw(xy)
253.1328 + frame(wks)
253.1329 + delete (xy)
253.1330 + clear (wks)
253.1331 +
253.1332 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.1333 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.1334 + system("rm "+plot_name+"-*."+plot_type_new)
253.1335 + system("rm "+plot_name+"."+plot_type)
253.1336 +
253.1337 +;****************************************************************************
253.1338 +;(B)-4 histogram plot, model vs ob 933 site
253.1339 +;****************************************************************************
253.1340 +
253.1341 + plot_name = "histogram_model_vs_ob_933"
253.1342 + title = model_name+ " vs Observed 933 site"
253.1343 + resh@tiMainString = title
253.1344 +
253.1345 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
253.1346 +
253.1347 +;-----------------------------
253.1348 +; Add a boxed legend using the more simple method, which won't have
253.1349 +; vertical lines going through the markers.
253.1350 +
253.1351 + resh@pmLegendDisplayMode = "Always"
253.1352 +; resh@pmLegendWidthF = 0.1
253.1353 + resh@pmLegendWidthF = 0.08
253.1354 + resh@pmLegendHeightF = 0.05
253.1355 + resh@pmLegendOrthogonalPosF = -1.17
253.1356 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
253.1357 +; resh@pmLegendParallelPosF = 0.18
253.1358 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
253.1359 +
253.1360 +; resh@lgPerimOn = False
253.1361 + resh@lgLabelFontHeightF = 0.015
253.1362 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
253.1363 +;-----------------------------
253.1364 + tRes = True
253.1365 + tRes@txFontHeightF = 0.025
253.1366 +
253.1367 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933h)+")"
253.1368 +
253.1369 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
253.1370 +
253.1371 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
253.1372 +;-------------------------------
253.1373 +;Attach the vertical bar and the horizontal cap line
253.1374 +
253.1375 + do nd=0,1
253.1376 + lnres@gsLineColor = line_colors(nd)
253.1377 + do i=0,nx-1
253.1378 +
253.1379 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
253.1380 + .not.ismissing(mx_yvalues(nd,i))) then
253.1381 +;
253.1382 +; Attach the vertical bar, both above and below the marker.
253.1383 +;
253.1384 + x1 = xvalues(nd,i)
253.1385 + y1 = yvalues(nd,i)
253.1386 + y2 = mn_yvalues(nd,i)
253.1387 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
253.1388 +
253.1389 + y2 = mx_yvalues(nd,i)
253.1390 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
253.1391 +;
253.1392 +; Attach the horizontal cap line, both above and below the marker.
253.1393 +;
253.1394 + x1 = xvalues(nd,i) - dx4
253.1395 + x2 = xvalues(nd,i) + dx4
253.1396 + y1 = mn_yvalues(nd,i)
253.1397 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
253.1398 +
253.1399 + y1 = mx_yvalues(nd,i)
253.1400 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
253.1401 + end if
253.1402 + end do
253.1403 + end do
253.1404 +
253.1405 + draw(xy)
253.1406 + frame(wks)
253.1407 + delete(xy)
253.1408 + clear(wks)
253.1409 +
253.1410 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.1411 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.1412 + system("rm "+plot_name+"-*."+plot_type_new)
253.1413 + system("rm "+plot_name+"."+plot_type)
253.1414 +
253.1415 +;***************************************************************************
253.1416 +;(C) global contour
253.1417 +;***************************************************************************
253.1418 +
253.1419 +;res
253.1420 + resg = True ; Use plot options
253.1421 + resg@cnFillOn = True ; Turn on color fill
253.1422 + resg@gsnSpreadColors = True ; use full colormap
253.1423 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
253.1424 +; resg@lbLabelAutoStride = True
253.1425 + resg@cnLinesOn = False ; Turn off contourn lines
253.1426 + resg@mpFillOn = False ; Turn off map fill
253.1427 +
253.1428 + resg@gsnSpreadColors = True ; use full colormap
253.1429 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
253.1430 + resg@cnMinLevelValF = 0. ; Min level
253.1431 + resg@cnMaxLevelValF = 2200. ; Max level
253.1432 + resg@cnLevelSpacingF = 200. ; interval
253.1433 +
253.1434 +;****************************************************************************
253.1435 +;(C)-1 global contour plot, ob
253.1436 +;****************************************************************************
253.1437 +
253.1438 + delta = 0.00000000001
253.1439 + nppglobe = where(ismissing(nppglobe).and.(ismissing(nppmod).or.(nppmod.lt.delta)),0.,nppglobe)
253.1440 +
253.1441 + plot_name = "global_ob"
253.1442 + title = "Observed MODIS MOD 17"
253.1443 + resg@tiMainString = title
253.1444 +
253.1445 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
253.1446 + gsn_define_colormap(wks,"gui_default") ; choose colormap
253.1447 +
253.1448 + plot = gsn_csm_contour_map_ce(wks,nppglobe,resg)
253.1449 +
253.1450 + frame(wks)
253.1451 + clear (wks)
253.1452 +
253.1453 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.1454 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.1455 + system("rm "+plot_name+"-*."+plot_type_new)
253.1456 + system("rm "+plot_name+"."+plot_type)
253.1457 +
253.1458 +;****************************************************************************
253.1459 +;(C)-2 global contour plot, model
253.1460 +;****************************************************************************
253.1461 +
253.1462 + plot_name = "global_model"
253.1463 + title = "Model "+ model_name
253.1464 + resg@tiMainString = title
253.1465 +
253.1466 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
253.1467 + gsn_define_colormap(wks,"gui_default") ; choose colormap
253.1468 +
253.1469 + plot = gsn_csm_contour_map_ce(wks,nppmod,resg)
253.1470 +
253.1471 + frame(wks)
253.1472 + clear (wks)
253.1473 +
253.1474 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.1475 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.1476 + system("rm "+plot_name+"-*."+plot_type_new)
253.1477 + system("rm "+plot_name+"."+plot_type)
253.1478 +
253.1479 +;****************************************************************************
253.1480 +;(C)-3 global contour plot, model vs ob
253.1481 +;****************************************************************************
253.1482 +
253.1483 + plot_name = "global_model_vs_ob"
253.1484 +
253.1485 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
253.1486 + gsn_define_colormap(wks,"gui_default") ; choose colormap
253.1487 +
253.1488 + delete (plot)
253.1489 + plot=new(3,graphic) ; create graphic array
253.1490 +
253.1491 + resg@gsnFrame = False ; Do not draw plot
253.1492 + resg@gsnDraw = False ; Do not advance frame
253.1493 +
253.1494 +; compute correlation coef and M score
253.1495 +
253.1496 + uu1 = ndtooned(nppmod)
253.1497 + vv1 = ndtooned(nppglobe)
253.1498 +
253.1499 + delete (good)
253.1500 + good = ind(.not.ismissing(uu1) .and. .not.ismissing(vv1))
253.1501 +
253.1502 + ug = uu1(good)
253.1503 + vg = vv1(good)
253.1504 +
253.1505 + ccrG = esccr(ug,vg,0)
253.1506 +; print (ccrG)
253.1507 +
253.1508 + MG = (ccrG*ccrG)* 5.0
253.1509 + print (MG)
253.1510 +
253.1511 +; plot correlation coef
253.1512 +
253.1513 + gRes = True
253.1514 + gRes@txFontHeightF = 0.02
253.1515 + gRes@txAngleF = 90
253.1516 +
253.1517 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrG)+")"
253.1518 +
253.1519 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
253.1520 +;--------------------------------------------------------------------
253.1521 +;(a) ob
253.1522 +
253.1523 + title = "Observed MODIS MOD 17"
253.1524 + resg@tiMainString = title
253.1525 +
253.1526 + plot(0) = gsn_csm_contour_map_ce(wks,nppglobe,resg)
253.1527 +
253.1528 +;(b) model
253.1529 +
253.1530 + title = "Model "+ model_name
253.1531 + resg@tiMainString = title
253.1532 +
253.1533 + plot(1) = gsn_csm_contour_map_ce(wks,nppmod,resg)
253.1534 +
253.1535 +;(c) model-ob
253.1536 +
253.1537 + zz = nppmod
253.1538 + zz = nppmod - nppglobe
253.1539 + title = "Model_"+model_name+" - Observed"
253.1540 +
253.1541 + resg@cnMinLevelValF = -500 ; Min level
253.1542 + resg@cnMaxLevelValF = 500. ; Max level
253.1543 + resg@cnLevelSpacingF = 50. ; interval
253.1544 + resg@tiMainString = title
253.1545 +
253.1546 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
253.1547 +
253.1548 + pres = True ; panel plot mods desired
253.1549 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
253.1550 + ; indiv. plots in panel
253.1551 + pres@gsnMaximize = True ; fill the page
253.1552 +
253.1553 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
253.1554 +
253.1555 + frame (wks)
253.1556 + clear (wks)
253.1557 + delete (plot)
253.1558 +
253.1559 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.1560 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.1561 + system("rm "+plot_name+"-*."+plot_type_new)
253.1562 + system("rm "+plot_name+"."+plot_type)
253.1563 +
253.1564 +;***************************************************************************
253.1565 +;(D)-1 zonal line plot, ob
253.1566 +;***************************************************************************
253.1567 +
253.1568 + vv = zonalAve(nppglobe)
253.1569 + vv@long_name = nppglobe@long_name
253.1570 +
253.1571 + plot_name = "zonal_ob"
253.1572 + title = "Observed MODIS MOD 17"
253.1573 +
253.1574 + resz = True
253.1575 + resz@tiMainString = title
253.1576 +
253.1577 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
253.1578 +
253.1579 + plot = gsn_csm_xy (wks,ym,vv,resz)
253.1580 +
253.1581 + frame(wks)
253.1582 + clear (wks)
253.1583 +
253.1584 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.1585 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.1586 + system("rm "+plot_name+"-*."+plot_type_new)
253.1587 + system("rm "+plot_name+"."+plot_type)
253.1588 +
253.1589 +;****************************************************************************
253.1590 +;(D)-2 zonal line plot, model vs ob
253.1591 +;****************************************************************************
253.1592 +
253.1593 + s = new ((/2,dimsizes(ym)/), float)
253.1594 +
253.1595 + s(0,:) = zonalAve(nppglobe)
253.1596 + s(1,:) = zonalAve(nppmod)
253.1597 +
253.1598 + s@long_name = nppglobe@long_name
253.1599 +;-------------------------------------------
253.1600 +; compute correlation coef and M score
253.1601 +
253.1602 + ccrZ = esccr(s(1,:), s(0,:),0)
253.1603 +; print (ccrZ)
253.1604 +
253.1605 + MZ = (ccrZ*ccrZ)* 5.0
253.1606 + print (MZ)
253.1607 +;-------------------------------------------
253.1608 + plot_name = "zonal_model_vs_ob"
253.1609 + title = "Zonal Average"
253.1610 + resz@tiMainString = title
253.1611 +
253.1612 + wks = gsn_open_wks (plot_type,plot_name)
253.1613 +
253.1614 +; resz@vpHeightF = 0.4 ; change aspect ratio of plot
253.1615 +; resz@vpWidthF = 0.7
253.1616 +
253.1617 + resz@xyMonoLineColor = "False" ; want colored lines
253.1618 + resz@xyLineColors = (/"black","red"/) ; colors chosen
253.1619 +; resz@xyLineThicknesses = (/3.,3./) ; line thicknesses
253.1620 + resz@xyLineThicknesses = (/2.,2./) ; line thicknesses
253.1621 + resz@xyDashPatterns = (/0.,0./) ; make all lines solid
253.1622 +
253.1623 + resz@tiYAxisString = s@long_name ; add a axis title
253.1624 + resz@txFontHeightF = 0.0195 ; change title font heights
253.1625 +
253.1626 +; Legent
253.1627 + resz@pmLegendDisplayMode = "Always" ; turn on legend
253.1628 + resz@pmLegendSide = "Top" ; Change location of
253.1629 +; resz@pmLegendParallelPosF = .45 ; move units right
253.1630 + resz@pmLegendParallelPosF = .82 ; move units right
253.1631 + resz@pmLegendOrthogonalPosF = -0.4 ; move units down
253.1632 +
253.1633 + resz@pmLegendWidthF = 0.10 ; Change width and
253.1634 + resz@pmLegendHeightF = 0.10 ; height of legend.
253.1635 + resz@lgLabelFontHeightF = .02 ; change font height
253.1636 +; resz@lgTitleOn = True ; turn on legend title
253.1637 +; resz@lgTitleString = "Example" ; create legend title
253.1638 +; resz@lgTitleFontHeightF = .025 ; font of legend title
253.1639 + resz@xyExplicitLegendLabels = (/"Observed",model_name/) ; explicit labels
253.1640 +;--------------------------------------------------------------------
253.1641 + zRes = True
253.1642 + zRes@txFontHeightF = 0.025
253.1643 +
253.1644 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrZ)+")"
253.1645 +
253.1646 + gsn_text_ndc(wks,correlation_text,0.50,0.77,zRes)
253.1647 +;--------------------------------------------------------------------
253.1648 +
253.1649 + plot = gsn_csm_xy (wks,ym,s,resz)
253.1650 +
253.1651 + frame(wks)
253.1652 + clear (wks)
253.1653 +
253.1654 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
253.1655 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
253.1656 + system("rm "+plot_name+"-*."+plot_type_new)
253.1657 + system("rm "+plot_name+"."+plot_type)
253.1658 +
253.1659 +;***************************************************************************
253.1660 +; tar up output plots
253.1661 +;***************************************************************************
253.1662 +
253.1663 + temp_name = "temp." + model_name
253.1664 + system("mkdir -p " + temp_name)
253.1665 + system("mv *.png " + temp_name)
253.1666 + system("tar cf "+ temp_name +".tar " + temp_name)
253.1667 +
253.1668 +;***************************************************************************
253.1669 +end
253.1670 +
254.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
254.2 +++ b/npp/99.all.ncl.2 Mon Jan 26 22:08:20 2009 -0500
254.3 @@ -0,0 +1,1695 @@
254.4 +;*****************************************************
254.5 +; combine scatter, histogram, global and zonal plots
254.6 +; compute all correlation coef and M score
254.7 +; add 1-to-1 line in scatter plots
254.8 +;*****************************************************
254.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
254.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
254.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
254.12 +;*****************************************************
254.13 +procedure get_bin(RAIN1_1D[*]:numeric, NPP1_1D[*]:numeric \
254.14 + ,RAIN2_1D[*]:numeric, NPP2_1D[*]:numeric \
254.15 + ,xvalues[*][*]:numeric, yvalues[*][*]:numeric \
254.16 + ,mn_yvalues[*][*]:numeric, mx_yvalues[*][*]:numeric \
254.17 + ,dx4[1]:numeric \
254.18 + )
254.19 +begin
254.20 +; Calculaee "nice" bins for binning the data in equally spaced ranges.
254.21 +; input : RAIN1_1D, RAIN2_1D, NPP1_1D, NPP2_1D
254.22 +; output: xvalues, yvalues, mn_yvalues, mx_yvalues,dx4
254.23 +
254.24 + nbins = 15 ; Number of bins to use.
254.25 +
254.26 + nicevals = nice_mnmxintvl(min(RAIN1_1D),max(RAIN1_1D),nbins,True)
254.27 + nvals = floattoint((nicevals(1) - nicevals(0))/nicevals(2) + 1)
254.28 + range = fspan(nicevals(0),nicevals(1),nvals)
254.29 +
254.30 +; Use this range information to grab all the values in a
254.31 +; particular range, and then take an average.
254.32 +
254.33 + nr = dimsizes(range)
254.34 + nx = nr-1
254.35 +; print (nx)
254.36 +
254.37 +; xvalues = new((/2,nx/),typeof(RAIN1_1D))
254.38 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
254.39 + dx = xvalues(0,1) - xvalues(0,0) ; range width
254.40 + dx4 = dx/4 ; 1/4 of the range
254.41 + xvalues(1,:) = xvalues(0,:) - dx/5.
254.42 +; yvalues = new((/2,nx/),typeof(RAIN1_1D))
254.43 +; mn_yvalues = new((/2,nx/),typeof(RAIN1_1D))
254.44 +; mx_yvalues = new((/2,nx/),typeof(RAIN1_1D))
254.45 +
254.46 + do nd=0,1
254.47 +
254.48 +; See if we are doing model or observational data.
254.49 +
254.50 + if(nd.eq.0) then
254.51 + data = RAIN1_1D
254.52 + npp_data = NPP1_1D
254.53 + else
254.54 + data = RAIN2_1D
254.55 + npp_data = NPP2_1D
254.56 + end if
254.57 +
254.58 +; Loop through each range and check for values.
254.59 +
254.60 + do i=0,nr-2
254.61 + if (i.ne.(nr-2)) then
254.62 +; print("")
254.63 +; print("In range ["+range(i)+","+range(i+1)+")")
254.64 + idx = ind((range(i).le.data).and.(data.lt.range(i+1)))
254.65 + else
254.66 +; print("")
254.67 +; print("In range ["+range(i)+",)")
254.68 + idx = ind(range(i).le.data)
254.69 + end if
254.70 +
254.71 +; Calculate average, and get min and max.
254.72 +
254.73 + if(.not.any(ismissing(idx))) then
254.74 + yvalues(nd,i) = avg(npp_data(idx))
254.75 + mn_yvalues(nd,i) = min(npp_data(idx))
254.76 + mx_yvalues(nd,i) = max(npp_data(idx))
254.77 + count = dimsizes(idx)
254.78 + else
254.79 + count = 0
254.80 + yvalues(nd,i) = yvalues@_FillValue
254.81 + mn_yvalues(nd,i) = yvalues@_FillValue
254.82 + mx_yvalues(nd,i) = yvalues@_FillValue
254.83 + end if
254.84 +
254.85 +; Print out information.
254.86 +; print(data_types(nd) + ": " + count + " points, avg = " + yvalues(nd,i))
254.87 +; print("Min/Max: " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
254.88 +
254.89 +; Clean up for next time in loop.
254.90 +
254.91 + delete(idx)
254.92 + end do
254.93 + delete(data)
254.94 + delete(npp_data)
254.95 + end do
254.96 +end
254.97 +;****************************************************************************
254.98 +; Main code.
254.99 +;****************************************************************************
254.100 +begin
254.101 +
254.102 + plot_type = "ps"
254.103 + plot_type_new = "png"
254.104 +
254.105 +;************************************************
254.106 +; read model data
254.107 +;************************************************
254.108 +
254.109 +;film = "i01.06cn_1798-2004_ANN_climo.nc"
254.110 +;model_name = "06cn"
254.111 +;model_grid = "T42"
254.112 +
254.113 +;film = "i01.06casa_1798-2004_ANN_climo.nc"
254.114 +;model_name = "06casa"
254.115 +;model_grid = "T42"
254.116 +
254.117 +;film = "i01.10casa_1948-2004_ANN_climo.nc"
254.118 +;model_name = "10casa"
254.119 +;model_grid = "T42"
254.120 +
254.121 + film = "i01.10cn_1948-2004_ANN_climo.nc"
254.122 + model_name = "10cn"
254.123 + model_grid = "T42"
254.124 +
254.125 + html_name = "table.html." + model_name
254.126 + html_new = html_name +".new"
254.127 + system("sed s#model_name#"+model_name+"# "+html_name+" > "+html_new)
254.128 + system("mv -f "+html_new+" "+html_name)
254.129 +;--------------------------------------------------
254.130 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
254.131 + fm = addfile (dirm+film,"r")
254.132 +
254.133 + nppmod0 = fm->NPP
254.134 + rainmod0 = fm->RAIN
254.135 + xm = fm->lon
254.136 + ym = fm->lat
254.137 +
254.138 +;************************************************
254.139 +; read ob data
254.140 +;************************************************
254.141 +
254.142 +;(1) data at 81 sites
254.143 + dir81 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
254.144 + fil81 = "data.81.nc"
254.145 + f81 = addfile (dir81+fil81,"r")
254.146 +
254.147 + id81 = f81->SITE_ID
254.148 + npp81 = f81->TNPP_C
254.149 + rain81 = tofloat(f81->PREC_ANN)
254.150 + x81 = f81->LONG_DD
254.151 + y81 = f81->LAT_DD
254.152 +
254.153 + id81@long_name = "SITE_ID"
254.154 +
254.155 +;change longitude from (-180,180) to (0,360)
254.156 +;for model data interpolation
254.157 +
254.158 + do i= 0,dimsizes(x81)-1
254.159 + if (x81(i) .lt. 0.) then
254.160 + x81(i) = x81(i)+ 360.
254.161 + end if
254.162 + end do
254.163 +;print (x81)
254.164 +;-------------------------------------
254.165 +;(2) data at 933 sites
254.166 + dir933 = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
254.167 + fil933 = "data.933.nc"
254.168 + f933 = addfile (dir933+fil933,"r")
254.169 +
254.170 + id933 = f933->SITE_ID
254.171 + npp933 = f933->TNPP_C
254.172 + rain933 = f933->PREC
254.173 + x933 = f933->LONG_DD
254.174 + y933 = f933->LAT_DD
254.175 +
254.176 + id933@long_name = "SITE_ID"
254.177 +
254.178 +;change longitude from (-180,180) to (0,360)
254.179 +;for model data interpolation
254.180 +
254.181 + do i= 0,dimsizes(x933)-1
254.182 + if (x933(i) .lt. 0.) then
254.183 + x933(i) = x933(i)+ 360.
254.184 + end if
254.185 + end do
254.186 +;print (x933)
254.187 +;----------------------------------------
254.188 +;(3) global data, interpolated into model grid
254.189 + dirglobe = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
254.190 + filglobe = "Npp_"+model_grid+"_mean.nc"
254.191 + fglobe = addfile (dirglobe+filglobe,"r")
254.192 +
254.193 + nppglobe0 = fglobe->NPP
254.194 + nppglobe = nppglobe0
254.195 +
254.196 +;***********************************************************************
254.197 +; interpolate model data into ob sites
254.198 +;***********************************************************************
254.199 +
254.200 + nppmod = nppmod0(0,:,:)
254.201 + rainmod = rainmod0(0,:,:)
254.202 + delete (nppmod0)
254.203 + delete (rainmod0)
254.204 +
254.205 + nppmod81 =linint2_points(xm,ym,nppmod,True,x81,y81,0)
254.206 +
254.207 + nppmod933 =linint2_points(xm,ym,nppmod,True,x933,y933,0)
254.208 +
254.209 + rainmod81 =linint2_points(xm,ym,rainmod,True,x81,y81,0)
254.210 +
254.211 + rainmod933=linint2_points(xm,ym,rainmod,True,x933,y933,0)
254.212 +
254.213 +;**********************************************************
254.214 +; unified units
254.215 +;**********************************************************
254.216 +; Units for these variables are:
254.217 +;
254.218 +; rain81 : mm/year
254.219 +; rainmod : mm/s
254.220 +; npp81 : g C/m^2/year
254.221 +; nppmod81: g C/m^2/s
254.222 +; nppglobe: g C/m^2/year
254.223 +;
254.224 +; We want to convert these to "m/year" and "g C/m^2/year".
254.225 +
254.226 + nsec_per_year = 60*60*24*365
254.227 +
254.228 + rain81 = rain81 / 1000.
254.229 + rainmod81 = (rainmod81/ 1000.) * nsec_per_year
254.230 + nppmod81 = nppmod81 * nsec_per_year
254.231 +
254.232 + rain933 = rain933 / 1000.
254.233 + rainmod933 = (rainmod933/ 1000.) * nsec_per_year
254.234 + nppmod933 = nppmod933 * nsec_per_year
254.235 +
254.236 + nppmod = nppmod * nsec_per_year
254.237 +
254.238 + npp81@units = "gC/m^2/yr"
254.239 + nppmod81@units = "gC/m^2/yr"
254.240 + npp933@units = "gC/m^2/yr"
254.241 + nppmod933@units = "gC/m^2/yr"
254.242 + nppmod@units = "gC/m^2/yr"
254.243 + nppglobe@units = "gC/m^2/yr"
254.244 + rain81@units = "m/yr"
254.245 + rainmod81@units = "m/yr"
254.246 + rain933@units = "m/yr"
254.247 + rainmod933@units = "m/yr"
254.248 +
254.249 + npp81@long_name = "NPP (gC/m2/year)"
254.250 + npp933@long_name = "NPP (gC/m2/year)"
254.251 + nppmod81@long_name = "NPP (gC/m2/year)"
254.252 + nppmod933@long_name = "NPP (gC/m2/year)"
254.253 + nppmod@long_name = "NPP (gC/m2/year)"
254.254 + nppglobe@long_name = "NPP (gC/m2/year)"
254.255 + rain81@long_name = "PREC (m/year)"
254.256 + rain933@long_name = "PREC (m/year)"
254.257 + rainmod81@long_name = "PREC (m/year)"
254.258 + rainmod933@long_name = "PREC (m/year)"
254.259 +
254.260 +;*******************************************************************
254.261 +;(A)-1 table of site81 (1) (the first 41 sites)
254.262 +;*******************************************************************
254.263 +
254.264 + table_length = 0.95
254.265 +
254.266 +; table header name
254.267 + table_header_name = "Site ID"
254.268 +
254.269 +; column (not including header column)
254.270 + col_header = (/"Latitude","Longitude","NPP (gC/m2/year)","RAIN (m/year)"/)
254.271 + ncol = dimsizes(col_header)
254.272 +
254.273 +; row (not including header row)
254.274 + nrow = 41
254.275 + row_header = new ((/nrow/),string )
254.276 + row_header(0:nrow-1) = id81(0:nrow-1)
254.277 +
254.278 +; Table header
254.279 + ncr1 = (/1,1/) ; 1 row, 1 column
254.280 + x1 = (/0.005,0.15/) ; Start and end X
254.281 + y1 = (/0.900,0.95/) ; Start and end Y
254.282 + text1 = table_header_name
254.283 + res1 = True
254.284 + res1@txFontHeightF = 0.015
254.285 + res1@gsFillColor = "CornFlowerBlue"
254.286 +
254.287 +; Column header (equally space in x2)
254.288 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
254.289 + x2 = (/x1(1),0.995/) ; start from end of x1
254.290 + y2 = y1 ; same as y1
254.291 + text2 = col_header
254.292 + res2 = True
254.293 + res2@txFontHeightF = 0.015
254.294 + res2@gsFillColor = "Gray"
254.295 +
254.296 +; Row header (equally space in y2)
254.297 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
254.298 + x3 = x1 ; same as x1
254.299 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
254.300 + text3 = row_header
254.301 + res3 = True
254.302 + res3@txFontHeightF = 0.010
254.303 + res3@gsFillColor = "Gray"
254.304 +
254.305 +; Main table body
254.306 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
254.307 + x4 = x2 ; Start and end x
254.308 + y4 = y3 ; Start and end Y
254.309 + text4 = new((/nrow,ncol/),string)
254.310 +
254.311 + color_fill4 = new((/nrow,ncol/),string)
254.312 + color_fill4 = "white"
254.313 +; color_fill4(:,ncol-1) = "grey"
254.314 +; color_fill4(nrow-1,:) = "green"
254.315 +
254.316 + res4 = True ; Set up resource list
254.317 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
254.318 + res4@txFontHeightF = 0.015
254.319 + res4@gsFillColor = color_fill4
254.320 +
254.321 + delete (color_fill4)
254.322 +;-------------------------------------------------------------------
254.323 +; for table value
254.324 +
254.325 + do n = 0,nrow-1
254.326 + text4(n,0) = sprintf("%5.2f", y81(n))
254.327 + text4(n,1) = sprintf("%5.2f", x81(n))
254.328 + text4(n,2) = sprintf("%5.2f", npp81(n))
254.329 + text4(n,3) = sprintf("%5.2f", rain81(n))
254.330 + end do
254.331 +;-------------------------------------------------------------------
254.332 +
254.333 + plot_name = "table_site81_ob1"
254.334 +
254.335 + wks = gsn_open_wks (plot_type,plot_name)
254.336 +;------------------------------------------
254.337 +; for table title
254.338 +
254.339 + gRes = True
254.340 + gRes@txFontHeightF = 0.02
254.341 +; gRes@txAngleF = 90
254.342 +
254.343 + title_text = "Observation at 81 Sites (1)"
254.344 +
254.345 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
254.346 +;------------------------------------------
254.347 +
254.348 + gsn_table(wks,ncr1,x1,y1,text1,res1)
254.349 + gsn_table(wks,ncr2,x2,y2,text2,res2)
254.350 + gsn_table(wks,ncr3,x3,y3,text3,res3)
254.351 + gsn_table(wks,ncr4,x4,y4,text4,res4)
254.352 +
254.353 + frame(wks)
254.354 + clear (wks)
254.355 +
254.356 + delete (row_header)
254.357 + delete (res3)
254.358 + delete (ncr3)
254.359 + delete (text3)
254.360 + delete (res4)
254.361 + delete (ncr4)
254.362 + delete (text4)
254.363 +
254.364 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.365 + system("rm "+plot_name+"."+plot_type)
254.366 + system("rm "+plot_name+"-1."+plot_type_new)
254.367 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.368 +
254.369 +;*******************************************************************
254.370 +;(A)-2 table of site81 (2) (the last 40 sites)
254.371 +;*******************************************************************
254.372 +
254.373 + table_length = 0.95
254.374 +
254.375 +; table header name
254.376 + table_header_name = "Site ID"
254.377 +
254.378 +; column (not including header column)
254.379 + col_header = (/"Latitude","Longitude","NPP (gC/m2/year)","RAIN (m/year)"/)
254.380 + ncol = dimsizes(col_header)
254.381 +
254.382 +; row (not including header row)
254.383 + nrow = 40
254.384 + row_header = new ((/nrow/),string )
254.385 + row_header(0:nrow-1) = id81(41:41+nrow-1)
254.386 +
254.387 +; Table header
254.388 + ncr1 = (/1,1/) ; 1 row, 1 column
254.389 + x1 = (/0.005,0.15/) ; Start and end X
254.390 + y1 = (/0.900,0.95/) ; Start and end Y
254.391 + text1 = table_header_name
254.392 + res1 = True
254.393 + res1@txFontHeightF = 0.015
254.394 + res1@gsFillColor = "CornFlowerBlue"
254.395 +
254.396 +; Column header (equally space in x2)
254.397 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
254.398 + x2 = (/x1(1),0.995/) ; start from end of x1
254.399 + y2 = y1 ; same as y1
254.400 + text2 = col_header
254.401 + res2 = True
254.402 + res2@txFontHeightF = 0.015
254.403 + res2@gsFillColor = "Gray"
254.404 +
254.405 +; Row header (equally space in y2)
254.406 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
254.407 + x3 = x1 ; same as x1
254.408 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
254.409 + text3 = row_header
254.410 + res3 = True
254.411 + res3@txFontHeightF = 0.010
254.412 + res3@gsFillColor = "Gray"
254.413 +
254.414 +; Main table body
254.415 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
254.416 + x4 = x2 ; Start and end x
254.417 + y4 = y3 ; Start and end Y
254.418 + text4 = new((/nrow,ncol/),string)
254.419 +
254.420 + color_fill4 = new((/nrow,ncol/),string)
254.421 + color_fill4 = "white"
254.422 +; color_fill4(:,ncol-1) = "grey"
254.423 +; color_fill4(nrow-1,:) = "green"
254.424 +
254.425 + res4 = True ; Set up resource list
254.426 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
254.427 + res4@txFontHeightF = 0.015
254.428 + res4@gsFillColor = color_fill4
254.429 +
254.430 + delete (color_fill4)
254.431 +;-------------------------------------------------------------------
254.432 +; for table value
254.433 +
254.434 + do n = 0,nrow-1
254.435 + text4(n,0) = sprintf("%5.2f", y81(n+41))
254.436 + text4(n,1) = sprintf("%5.2f", x81(n+41))
254.437 + text4(n,2) = sprintf("%5.2f", npp81(n+41))
254.438 + text4(n,3) = sprintf("%5.2f", rain81(n+41))
254.439 + end do
254.440 +;-------------------------------------------------------------------
254.441 +
254.442 + plot_name = "table_site81_ob2"
254.443 +
254.444 + wks = gsn_open_wks (plot_type,plot_name)
254.445 +;------------------------------------------
254.446 +; for table title
254.447 +
254.448 + gRes = True
254.449 + gRes@txFontHeightF = 0.02
254.450 +; gRes@txAngleF = 90
254.451 +
254.452 + title_text = "Observation at 81 Sites (2)"
254.453 +
254.454 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
254.455 +;------------------------------------------
254.456 +
254.457 + gsn_table(wks,ncr1,x1,y1,text1,res1)
254.458 + gsn_table(wks,ncr2,x2,y2,text2,res2)
254.459 + gsn_table(wks,ncr3,x3,y3,text3,res3)
254.460 + gsn_table(wks,ncr4,x4,y4,text4,res4)
254.461 +
254.462 + frame(wks)
254.463 + clear (wks)
254.464 +
254.465 + delete (row_header)
254.466 + delete (res3)
254.467 + delete (ncr3)
254.468 + delete (text3)
254.469 + delete (res4)
254.470 + delete (ncr4)
254.471 + delete (text4)
254.472 +
254.473 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.474 + system("rm "+plot_name+"."+plot_type)
254.475 + system("rm "+plot_name+"-1."+plot_type_new)
254.476 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.477 +
254.478 +;**************************************************************************
254.479 +;(A)-3 scatter plot, ob 933
254.480 +;**************************************************************************
254.481 +
254.482 + plot_name = "scatter_ob_933"
254.483 + title = "Observed 933 sites"
254.484 +
254.485 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
254.486 + res = True ; plot mods desired
254.487 + res@tiMainString = title ; add title
254.488 + res@xyMarkLineModes = "Markers" ; choose which have markers
254.489 + res@xyMarkers = 16 ; choose type of marker
254.490 + res@xyMarkerColor = "red" ; Marker color
254.491 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
254.492 + res@tmLabelAutoStride = True ; nice tick mark labels
254.493 +
254.494 + plot = gsn_csm_xy (wks,id933,npp933,res) ; create plot
254.495 + frame(wks)
254.496 + clear (wks)
254.497 +
254.498 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.499 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.500 + system("rm "+plot_name+"-*."+plot_type_new)
254.501 + system("rm "+plot_name+"."+plot_type)
254.502 +
254.503 +;**************************************************************************
254.504 +;(A)-4 scatter plot, model 933
254.505 +;**************************************************************************
254.506 +
254.507 + plot_name = "scatter_model_933"
254.508 + title = "Model "+ model_name +" 933 sites"
254.509 +
254.510 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
254.511 + res = True ; plot mods desired
254.512 + res@tiMainString = title ; add title
254.513 + res@xyMarkLineModes = "Markers" ; choose which have markers
254.514 + res@xyMarkers = 16 ; choose type of marker
254.515 + res@xyMarkerColor = "red" ; Marker color
254.516 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
254.517 + res@tmLabelAutoStride = True ; nice tick mark labels
254.518 +
254.519 + plot = gsn_csm_xy (wks,id933,nppmod933,res) ; create plot
254.520 + frame(wks)
254.521 + clear (wks)
254.522 +
254.523 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.524 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.525 + system("rm "+plot_name+"-*."+plot_type_new)
254.526 + system("rm "+plot_name+"."+plot_type)
254.527 +
254.528 +;***************************************************************************
254.529 +;(A)-5 scatter plot, model vs ob 81
254.530 +;***************************************************************************
254.531 +
254.532 + plot_name = "scatter_model_vs_ob_81"
254.533 + title = model_name +" vs ob 81 sites"
254.534 +
254.535 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
254.536 + res = True ; plot mods desired
254.537 + res@tiMainString = title ; add title
254.538 + res@xyMarkLineModes = "Markers" ; choose which have markers
254.539 + res@xyMarkers = 16 ; choose type of marker
254.540 + res@xyMarkerColor = "red" ; Marker color
254.541 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
254.542 + res@tmLabelAutoStride = True ; nice tick mark labels
254.543 +
254.544 + res@gsnDraw = False
254.545 + res@gsnFrame = False ; don't advance frame yet
254.546 +;-------------------------------
254.547 +;compute correlation coef. and M
254.548 + ccr81 = esccr(nppmod81,npp81,0)
254.549 +;print (ccr81)
254.550 +
254.551 +;new eq
254.552 + bias = sum(abs(nppmod81-npp81)/(abs(nppmod81)+abs(npp81)))
254.553 + M81 = (1. - (bias/dimsizes(y81)))*5.
254.554 +
254.555 + M_npp_S81 = sprintf("%.2f", M81)
254.556 + system("sed s#M_npp_S81#"+M_npp_S81+"# "+html_name+" > "+html_new)
254.557 + system("mv -f "+html_new+" "+html_name)
254.558 + print (M_npp_S81)
254.559 +
254.560 + tRes = True
254.561 + tRes@txFontHeightF = 0.025
254.562 +
254.563 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81)+")"
254.564 +
254.565 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
254.566 +;--------------------------------
254.567 + plot = gsn_csm_xy (wks,npp81,nppmod81,res) ; create plot
254.568 +;-------------------------------
254.569 +; add polyline
254.570 +
254.571 + dum=gsn_add_polyline(wks,plot,(/0,1200/),(/0,1200/),False)
254.572 +;-------------------------------
254.573 + draw (plot)
254.574 + frame(wks)
254.575 + clear (wks)
254.576 + delete (dum)
254.577 +
254.578 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.579 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.580 + system("rm "+plot_name+"-*."+plot_type_new)
254.581 + system("rm "+plot_name+"."+plot_type)
254.582 +
254.583 +;***************************************************************************
254.584 +;(A)-6 scatter plot, model vs ob 933
254.585 +;***************************************************************************
254.586 +
254.587 + plot_name = "scatter_model_vs_ob_933"
254.588 + title = model_name +" vs ob 933 sites"
254.589 +
254.590 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
254.591 + res = True ; plot mods desired
254.592 + res@tiMainString = title ; add title
254.593 + res@xyMarkLineModes = "Markers" ; choose which have markers
254.594 + res@xyMarkers = 16 ; choose type of marker
254.595 + res@xyMarkerColor = "red" ; Marker color
254.596 + res@xyMarkerSizeF = 0.01 ; Marker size (default 0.01)
254.597 + res@tmLabelAutoStride = True ; nice tick mark labels
254.598 +
254.599 + res@gsnDraw = False
254.600 + res@gsnFrame = False ; don't advance frame yet
254.601 +;-------------------------------
254.602 +;compute correlation coef. and M
254.603 + ccr933 = esccr(nppmod933,npp933,0)
254.604 +;print (ccr933)
254.605 +
254.606 +;new eq
254.607 + bias = sum(abs(nppmod933-npp933)/(abs(nppmod933)+abs(npp933)))
254.608 + M933 = (1. - (bias/dimsizes(y933)))*5.
254.609 +
254.610 + M_npp_S933 = sprintf("%.2f", M933)
254.611 + system("sed s#M_npp_S933#"+M_npp_S933+"# "+html_name+" > "+html_new)
254.612 + system("mv -f "+html_new+" "+html_name)
254.613 + print (M_npp_S933)
254.614 +
254.615 + tRes = True
254.616 + tRes@txFontHeightF = 0.025
254.617 +
254.618 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933)+")"
254.619 +
254.620 + gsn_text_ndc(wks,correlation_text,0.5,0.95,tRes)
254.621 +;--------------------------------
254.622 + plot = gsn_csm_xy (wks,npp933,nppmod933,res) ; create plot
254.623 +;-------------------------------
254.624 +; add polyline
254.625 +
254.626 + dum=gsn_add_polyline(wks,plot,(/0,1500/),(/0,1500/),False)
254.627 +;-------------------------------
254.628 + draw (plot)
254.629 + frame(wks)
254.630 + clear (wks)
254.631 + delete (dum)
254.632 +
254.633 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.634 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.635 + system("rm "+plot_name+"-*."+plot_type_new)
254.636 + system("rm "+plot_name+"."+plot_type)
254.637 +
254.638 +;*******************************************************************
254.639 +;(A)-7 table of site81 (1) (the first 41 sites), model vs ob
254.640 +;*******************************************************************
254.641 +
254.642 + table_length = 0.95
254.643 +
254.644 +; table header name
254.645 + table_header_name = "Site ID"
254.646 +
254.647 +; row (not including header row)
254.648 + nrow = 41
254.649 + row_header = new ((/nrow/),string )
254.650 + row_header(0:nrow-1) = id81(0:nrow-1)
254.651 +
254.652 +; Table header
254.653 + ncr1 = (/1,1/) ; 1 row, 1 column
254.654 + x1 = (/0.005,0.15/) ; Start and end X
254.655 + y1 = (/0.85 ,0.95/) ; Start and end Y
254.656 + text1 = table_header_name
254.657 + res1 = True
254.658 + res1@txFontHeightF = 0.015
254.659 + res1@gsFillColor = "CornFlowerBlue"
254.660 +
254.661 +; Column header1 (equally space in x2)
254.662 +
254.663 + delete (col_header)
254.664 + delete (ncr2)
254.665 + delete (text2)
254.666 +
254.667 + col_header = (/"Latitude","Longitude"/)
254.668 + ncol = dimsizes(col_header)
254.669 +
254.670 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
254.671 + x2 = (/x1(1),0.35/) ; start from end of x1
254.672 + y2 = y1 ; same as y1
254.673 + text2 = col_header
254.674 + res2 = True
254.675 + res2@txFontHeightF = 0.015
254.676 + res2@gsFillColor = "Gray"
254.677 +
254.678 +; Column header2 (equally space in x2)
254.679 +
254.680 + col_header1 = (/"NPP (gC/m2/year)","RAIN (m/year)"/)
254.681 + col_header2 = (/"ob",model_name \
254.682 + ,"ob",model_name \
254.683 + /)
254.684 +
254.685 + ncol1 = dimsizes(col_header1)
254.686 + ncol2 = dimsizes(col_header2)
254.687 +
254.688 + ncr21 = (/1,ncol1/) ; 1 rows, 4 columns
254.689 + x21 = (/x2(1),0.995/) ; start from end of x2
254.690 + yhalf = (y1(0)+y1(1))*0.5
254.691 + y21 = (/yhalf,y1(1)/) ; top half of y1
254.692 + text21 = col_header1
254.693 + res21 = True
254.694 + res21@txFontHeightF = 0.015
254.695 + res21@gsFillColor = "Gray"
254.696 +
254.697 + ncr22 = (/1,ncol2/) ; 1 rows, 12 columns
254.698 + x22 = x21 ; start from end of x1
254.699 + y22 = (/y1(0),yhalf/) ; bottom half of y1
254.700 + text22 = col_header2
254.701 + res22 = True
254.702 + res22@txFontHeightF = 0.015
254.703 + res22@gsFillColor = "Gray"
254.704 +
254.705 +; Row header (equally space in y2)
254.706 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
254.707 + x3 = x1 ; same as x1
254.708 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
254.709 + text3 = row_header
254.710 + res3 = True
254.711 + res3@txFontHeightF = 0.010
254.712 + res3@gsFillColor = "Gray"
254.713 +
254.714 +; Main table body-1
254.715 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
254.716 + x4 = x2 ; Start and end x
254.717 + y4 = y3 ; Start and end Y
254.718 + text4 = new((/nrow,ncol/),string)
254.719 +
254.720 + color_fill4 = new((/nrow,ncol/),string)
254.721 + color_fill4 = "white"
254.722 +; color_fill4(:,ncol-1) = "grey"
254.723 +; color_fill4(nrow-1,:) = "green"
254.724 +
254.725 + res4 = True ; Set up resource list
254.726 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
254.727 + res4@txFontHeightF = 0.015
254.728 + res4@gsFillColor = color_fill4
254.729 +
254.730 + delete (color_fill4)
254.731 +
254.732 +; Main table body-2
254.733 + ncr42 = (/nrow,ncol2/) ; nrow rows, ncol columns
254.734 + x42 = x21 ; Start and end x
254.735 + y42 = y3 ; Start and end Y
254.736 + text42 = new((/nrow,ncol2/),string)
254.737 +
254.738 + color_fill42 = new((/nrow,ncol2/),string)
254.739 + color_fill42 = "white"
254.740 +; color_fill42(:,ncol-1) = "grey"
254.741 +; color_fill42(nrow-1,:) = "green"
254.742 +
254.743 + res42 = True ; Set up resource list
254.744 +; res42@gsnDebug = True ; Useful to print NDC row,col values used.
254.745 + res42@txFontHeightF = 0.015
254.746 + res42@gsFillColor = color_fill42
254.747 +
254.748 + delete (color_fill42)
254.749 +;-------------------------------------------------------------------
254.750 +; for table value
254.751 +
254.752 + do n = 0,nrow-1
254.753 + text4(n,0) = sprintf("%5.2f", y81(n))
254.754 + text4(n,1) = sprintf("%5.2f", x81(n))
254.755 + end do
254.756 +
254.757 + do n = 0,nrow-1
254.758 + text42(n,0) = sprintf("%5.2f", npp81(n))
254.759 + text42(n,1) = sprintf("%5.2f", nppmod81(n))
254.760 + text42(n,2) = sprintf("%5.2f", rain81(n))
254.761 + text42(n,3) = sprintf("%5.2f", rainmod81(n))
254.762 + end do
254.763 +;---------------------------------------------------------------------------
254.764 +
254.765 + plot_name = "table_site81_model_vs_ob1"
254.766 +
254.767 + wks = gsn_open_wks (plot_type,plot_name)
254.768 +;------------------------------------------
254.769 +; for table title
254.770 +
254.771 + gRes = True
254.772 + gRes@txFontHeightF = 0.02
254.773 +; gRes@txAngleF = 90
254.774 +
254.775 + title_text = "Model vs Observation at 81 Sites (1)"
254.776 +
254.777 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
254.778 +;------------------------------------------
254.779 +
254.780 + gsn_table(wks,ncr1,x1,y1,text1,res1)
254.781 + gsn_table(wks,ncr2,x2,y2,text2,res2)
254.782 + gsn_table(wks,ncr21,x21,y21,text21,res21)
254.783 + gsn_table(wks,ncr22,x22,y22,text22,res22)
254.784 + gsn_table(wks,ncr3,x3,y3,text3,res3)
254.785 + gsn_table(wks,ncr4,x4,y4,text4,res4)
254.786 + gsn_table(wks,ncr42,x42,y42,text42,res42)
254.787 +
254.788 + frame(wks)
254.789 + clear (wks)
254.790 +
254.791 + delete (col_header)
254.792 + delete (row_header)
254.793 + delete (res1)
254.794 + delete (ncr1)
254.795 + delete (text1)
254.796 + delete (res2)
254.797 + delete (ncr2)
254.798 + delete (text2)
254.799 + delete (res21)
254.800 + delete (ncr21)
254.801 + delete (text21)
254.802 + delete (res22)
254.803 + delete (ncr22)
254.804 + delete (text22)
254.805 + delete (res3)
254.806 + delete (ncr3)
254.807 + delete (text3)
254.808 + delete (res4)
254.809 + delete (ncr4)
254.810 + delete (text4)
254.811 + delete (res42)
254.812 + delete (ncr42)
254.813 + delete (text42)
254.814 +
254.815 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.816 + system("rm "+plot_name+"."+plot_type)
254.817 + system("rm "+plot_name+"-1."+plot_type_new)
254.818 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.819 +
254.820 +;*******************************************************************
254.821 +;(A)-8 table of site81 (2) (the last 40 sites), model vs ob
254.822 +;*******************************************************************
254.823 +
254.824 + table_length = 0.95
254.825 +
254.826 +; table header name
254.827 + table_header_name = "Site ID"
254.828 +
254.829 +; row (not including header row)
254.830 + nrow = 40
254.831 + row_header = new ((/nrow/),string )
254.832 + row_header(0:nrow-1) = id81(41:41+nrow-1)
254.833 +
254.834 +; Table header
254.835 + ncr1 = (/1,1/) ; 1 row, 1 column
254.836 + x1 = (/0.005,0.15/) ; Start and end X
254.837 + y1 = (/0.85 ,0.95/) ; Start and end Y
254.838 + text1 = table_header_name
254.839 + res1 = True
254.840 + res1@txFontHeightF = 0.015
254.841 + res1@gsFillColor = "CornFlowerBlue"
254.842 +
254.843 +; Column header1 (equally space in x2)
254.844 +
254.845 + col_header = (/"Latitude","Longitude"/)
254.846 + ncol = dimsizes(col_header)
254.847 +
254.848 + ncr2 = (/1,ncol/) ; 1 rows, ncol columns
254.849 + x2 = (/x1(1),0.35/) ; start from end of x1
254.850 + y2 = y1 ; same as y1
254.851 + text2 = col_header
254.852 + res2 = True
254.853 + res2@txFontHeightF = 0.015
254.854 + res2@gsFillColor = "Gray"
254.855 +
254.856 +; Column header2 (equally space in x2)
254.857 +
254.858 +; col_header1 = (/"NPP (gC/m2/year)","RAIN (m/year)"/)
254.859 + col_header2 = (/"ob",model_name \
254.860 + ,"ob",model_name \
254.861 + /)
254.862 +
254.863 + ncol1 = dimsizes(col_header1)
254.864 + ncol2 = dimsizes(col_header2)
254.865 +
254.866 + ncr21 = (/1,ncol1/) ; 1 rows, 4 columns
254.867 + x21 = (/x2(1),0.995/) ; start from end of x2
254.868 + yhalf = (y1(0)+y1(1))*0.5
254.869 + y21 = (/yhalf,y1(1)/) ; top half of y1
254.870 + text21 = col_header1
254.871 + res21 = True
254.872 + res21@txFontHeightF = 0.015
254.873 + res21@gsFillColor = "Gray"
254.874 +
254.875 + ncr22 = (/1,ncol2/) ; 1 rows, 12 columns
254.876 + x22 = x21 ; start from end of x1
254.877 + y22 = (/y1(0),yhalf/) ; bottom half of y1
254.878 + text22 = col_header2
254.879 + res22 = True
254.880 + res22@txFontHeightF = 0.015
254.881 + res22@gsFillColor = "Gray"
254.882 +
254.883 +; Row header (equally space in y2)
254.884 + ncr3 = (/nrow,1/) ; nrow rows, 1 columns
254.885 + x3 = x1 ; same as x1
254.886 + y3 = (/1.0-table_length,y1(0)/) ; end at start of y1
254.887 + text3 = row_header
254.888 + res3 = True
254.889 + res3@txFontHeightF = 0.010
254.890 + res3@gsFillColor = "Gray"
254.891 +
254.892 +; Main table body-1
254.893 + ncr4 = (/nrow,ncol/) ; nrow rows, ncol columns
254.894 + x4 = x2 ; Start and end x
254.895 + y4 = y3 ; Start and end Y
254.896 + text4 = new((/nrow,ncol/),string)
254.897 +
254.898 + color_fill4 = new((/nrow,ncol/),string)
254.899 + color_fill4 = "white"
254.900 +; color_fill4(:,ncol-1) = "grey"
254.901 +; color_fill4(nrow-1,:) = "green"
254.902 +
254.903 + res4 = True ; Set up resource list
254.904 +; res4@gsnDebug = True ; Useful to print NDC row,col values used.
254.905 + res4@txFontHeightF = 0.015
254.906 + res4@gsFillColor = color_fill4
254.907 +
254.908 + delete (color_fill4)
254.909 +
254.910 +; Main table body-2
254.911 + ncr42 = (/nrow,ncol2/) ; nrow rows, ncol columns
254.912 + x42 = x21 ; Start and end x
254.913 + y42 = y3 ; Start and end Y
254.914 + text42 = new((/nrow,ncol2/),string)
254.915 +
254.916 + color_fill42 = new((/nrow,ncol2/),string)
254.917 + color_fill42 = "white"
254.918 +; color_fill42(:,ncol-1) = "grey"
254.919 +; color_fill42(nrow-1,:) = "green"
254.920 +
254.921 + res42 = True ; Set up resource list
254.922 +; res42@gsnDebug = True ; Useful to print NDC row,col values used.
254.923 + res42@txFontHeightF = 0.015
254.924 + res42@gsFillColor = color_fill42
254.925 +
254.926 + delete (color_fill42)
254.927 +;-------------------------------------------------------------------
254.928 +; for table value
254.929 +
254.930 + do n = 0,nrow-1
254.931 + text4(n,0) = sprintf("%5.2f", y81(n+41))
254.932 + text4(n,1) = sprintf("%5.2f", x81(n+41))
254.933 + end do
254.934 +
254.935 + do n = 0,nrow-1
254.936 + text42(n,0) = sprintf("%5.2f", npp81(n+41))
254.937 + text42(n,1) = sprintf("%5.2f", nppmod81(n+41))
254.938 + text42(n,2) = sprintf("%5.2f", rain81(n+41))
254.939 + text42(n,3) = sprintf("%5.2f", rainmod81(n+41))
254.940 + end do
254.941 +;-------------------------------------------------------------------
254.942 +
254.943 + plot_name = "table_site81_model_vs_ob2"
254.944 +
254.945 + wks = gsn_open_wks (plot_type,plot_name)
254.946 +;------------------------------------------
254.947 +; for table title
254.948 +
254.949 + gRes = True
254.950 + gRes@txFontHeightF = 0.02
254.951 +; gRes@txAngleF = 90
254.952 +
254.953 + title_text = "Model vs Observation at 81 Sites (2)"
254.954 +
254.955 + gsn_text_ndc(wks,title_text,0.50,0.975,gRes)
254.956 +;------------------------------------------
254.957 +
254.958 + gsn_table(wks,ncr1,x1,y1,text1,res1)
254.959 + gsn_table(wks,ncr2,x2,y2,text2,res2)
254.960 + gsn_table(wks,ncr21,x21,y21,text21,res21)
254.961 + gsn_table(wks,ncr22,x22,y22,text22,res22)
254.962 + gsn_table(wks,ncr3,x3,y3,text3,res3)
254.963 + gsn_table(wks,ncr4,x4,y4,text4,res4)
254.964 + gsn_table(wks,ncr42,x42,y42,text42,res42)
254.965 +
254.966 + frame(wks)
254.967 + clear (wks)
254.968 +
254.969 + delete (col_header)
254.970 + delete (row_header)
254.971 + delete (res1)
254.972 + delete (ncr1)
254.973 + delete (text1)
254.974 + delete (res2)
254.975 + delete (ncr2)
254.976 + delete (text2)
254.977 + delete (res21)
254.978 + delete (ncr21)
254.979 + delete (text21)
254.980 + delete (res22)
254.981 + delete (ncr22)
254.982 + delete (text22)
254.983 + delete (res3)
254.984 + delete (ncr3)
254.985 + delete (text3)
254.986 + delete (res4)
254.987 + delete (ncr4)
254.988 + delete (text4)
254.989 + delete (res42)
254.990 + delete (ncr42)
254.991 + delete (text42)
254.992 +
254.993 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.994 + system("rm "+plot_name+"."+plot_type)
254.995 + system("rm "+plot_name+"-1."+plot_type_new)
254.996 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.997 +
254.998 +;**************************************************************************
254.999 +;(B) histogram 81
254.1000 +;**************************************************************************
254.1001 +;get data
254.1002 + RAIN1_1D = ndtooned(rain81)
254.1003 + RAIN2_1D = ndtooned(rainmod81)
254.1004 + NPP1_1D = ndtooned(npp81)
254.1005 + NPP2_1D = ndtooned(nppmod81)
254.1006 +
254.1007 +; number of bin
254.1008 + nx = 8
254.1009 +
254.1010 + xvalues = new((/2,nx/),float)
254.1011 + yvalues = new((/2,nx/),float)
254.1012 + mn_yvalues = new((/2,nx/),float)
254.1013 + mx_yvalues = new((/2,nx/),float)
254.1014 + dx4 = new((/1/),float)
254.1015 +
254.1016 + get_bin(RAIN1_1D, NPP1_1D, RAIN2_1D, NPP2_1D \
254.1017 + ,xvalues,yvalues,mn_yvalues,mx_yvalues,dx4)
254.1018 +
254.1019 +;----------------------------------------
254.1020 +;compute correlation coeff and M score
254.1021 +
254.1022 + u = yvalues(0,:)
254.1023 + v = yvalues(1,:)
254.1024 +
254.1025 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
254.1026 + uu = u(good)
254.1027 + vv = v(good)
254.1028 +
254.1029 + ccr81h = esccr(uu,vv,0)
254.1030 +;print (ccr81h)
254.1031 +
254.1032 +;new eq
254.1033 + bias = sum(abs(vv-uu)/(abs(vv)+abs(uu)))
254.1034 + M81h = (1.- (bias/dimsizes(uu)))*5.
254.1035 +
254.1036 + M_npp_H81 = sprintf("%.2f", M81h)
254.1037 + system("sed s#M_npp_H81#"+M_npp_H81+"# "+html_name+" > "+html_new)
254.1038 + system("mv -f "+html_new+" "+html_name)
254.1039 + print (M_npp_H81)
254.1040 +
254.1041 + delete (u)
254.1042 + delete (v)
254.1043 + delete (uu)
254.1044 + delete (vv)
254.1045 +;----------------------------------------------------------------------
254.1046 +; histogram res
254.1047 + resh = True
254.1048 + resh@gsnMaximize = True
254.1049 + resh@gsnDraw = False
254.1050 + resh@gsnFrame = False
254.1051 + resh@xyMarkLineMode = "Markers"
254.1052 + resh@xyMarkerSizeF = 0.014
254.1053 + resh@xyMarker = 16
254.1054 + resh@xyMarkerColors = (/"Brown","Blue"/)
254.1055 + resh@trYMinF = min(mn_yvalues) - 10.
254.1056 + resh@trYMaxF = max(mx_yvalues) + 10.
254.1057 +
254.1058 + resh@tiYAxisString = "NPP (g C/m2/year)"
254.1059 + resh@tiXAxisString = "Precipitation (m/year)"
254.1060 +
254.1061 + max_bar = new((/2,nx/),graphic)
254.1062 + min_bar = new((/2,nx/),graphic)
254.1063 + max_cap = new((/2,nx/),graphic)
254.1064 + min_cap = new((/2,nx/),graphic)
254.1065 +
254.1066 + lnres = True
254.1067 + line_colors = (/"brown","blue"/)
254.1068 +
254.1069 +;**************************************************************************
254.1070 +;(B)-1 histogram plot, ob 81 site
254.1071 +;**************************************************************************
254.1072 +
254.1073 + plot_name = "histogram_ob_81"
254.1074 + title = "Observed 81 site"
254.1075 + resh@tiMainString = title
254.1076 +
254.1077 + wks = gsn_open_wks (plot_type,plot_name)
254.1078 +
254.1079 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
254.1080 +
254.1081 +;-------------------------------
254.1082 +;Attach the vertical bar and the horizontal cap line
254.1083 +
254.1084 + delete (x1)
254.1085 + delete (x2)
254.1086 + delete (y1)
254.1087 + delete (y2)
254.1088 +
254.1089 + do nd=0,0
254.1090 + lnres@gsLineColor = line_colors(nd)
254.1091 + do i=0,nx-1
254.1092 +
254.1093 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
254.1094 + .not.ismissing(mx_yvalues(nd,i))) then
254.1095 +;
254.1096 +; Attach the vertical bar, both above and below the marker.
254.1097 +;
254.1098 + x1 = xvalues(nd,i)
254.1099 + y1 = yvalues(nd,i)
254.1100 + y2 = mn_yvalues(nd,i)
254.1101 + plx = (/x1,x1/)
254.1102 + ply = (/y1,y2/)
254.1103 + min_bar(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
254.1104 +
254.1105 + y2 = mx_yvalues(nd,i)
254.1106 + plx = (/x1,x1/)
254.1107 + ply = (/y1,y2/)
254.1108 + max_bar(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
254.1109 +;
254.1110 +; Attach the horizontal cap line, both above and below the marker.
254.1111 +;
254.1112 + x1 = xvalues(nd,i) - dx4
254.1113 + x2 = xvalues(nd,i) + dx4
254.1114 + y1 = mn_yvalues(nd,i)
254.1115 + plx = (/x1,x2/)
254.1116 + ply = (/y1,y1/)
254.1117 + min_cap(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
254.1118 +
254.1119 + y1 = mx_yvalues(nd,i)
254.1120 + plx = (/x1,x2/)
254.1121 + ply = (/y1,y1/)
254.1122 + max_cap(nd,i) = gsn_add_polyline(wks,xy,plx,ply,lnres)
254.1123 + end if
254.1124 + end do
254.1125 + end do
254.1126 +
254.1127 + draw(xy)
254.1128 + frame(wks)
254.1129 + clear (wks)
254.1130 +
254.1131 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.1132 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.1133 + system("rm "+plot_name+"-*."+plot_type_new)
254.1134 + system("rm "+plot_name+"."+plot_type)
254.1135 +
254.1136 +;****************************************************************************
254.1137 +;(B)-2 histogram plot, model vs ob 81 site
254.1138 +;****************************************************************************
254.1139 +
254.1140 + plot_name = "histogram_model_vs_ob_81"
254.1141 + title = model_name+ " vs Observed 81 site"
254.1142 + resh@tiMainString = title
254.1143 +
254.1144 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
254.1145 +
254.1146 +;-----------------------------
254.1147 +; Add a boxed legend using the more simple method, which won't have
254.1148 +; vertical lines going through the markers.
254.1149 +
254.1150 + resh@pmLegendDisplayMode = "Always"
254.1151 +; resh@pmLegendWidthF = 0.1
254.1152 + resh@pmLegendWidthF = 0.08
254.1153 + resh@pmLegendHeightF = 0.05
254.1154 + resh@pmLegendOrthogonalPosF = -1.17
254.1155 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
254.1156 +; resh@pmLegendParallelPosF = 0.18
254.1157 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
254.1158 +
254.1159 +; resh@lgPerimOn = False
254.1160 + resh@lgLabelFontHeightF = 0.015
254.1161 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
254.1162 +;-----------------------------
254.1163 + tRes = True
254.1164 + tRes@txFontHeightF = 0.025
254.1165 +
254.1166 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr81h)+")"
254.1167 +
254.1168 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
254.1169 +
254.1170 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
254.1171 +;-------------------------------
254.1172 +;Attach the vertical bar and the horizontal cap line
254.1173 +
254.1174 + do nd=0,1
254.1175 + lnres@gsLineColor = line_colors(nd)
254.1176 + do i=0,nx-1
254.1177 +
254.1178 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
254.1179 + .not.ismissing(mx_yvalues(nd,i))) then
254.1180 +;
254.1181 +; Attach the vertical bar, both above and below the marker.
254.1182 +;
254.1183 + x1 = xvalues(nd,i)
254.1184 + y1 = yvalues(nd,i)
254.1185 + y2 = mn_yvalues(nd,i)
254.1186 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
254.1187 +
254.1188 + y2 = mx_yvalues(nd,i)
254.1189 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
254.1190 +;
254.1191 +; Attach the horizontal cap line, both above and below the marker.
254.1192 +;
254.1193 + x1 = xvalues(nd,i) - dx4
254.1194 + x2 = xvalues(nd,i) + dx4
254.1195 + y1 = mn_yvalues(nd,i)
254.1196 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
254.1197 +
254.1198 + y1 = mx_yvalues(nd,i)
254.1199 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
254.1200 + end if
254.1201 + end do
254.1202 + end do
254.1203 +
254.1204 + draw(xy)
254.1205 + frame(wks)
254.1206 + clear(wks)
254.1207 +
254.1208 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.1209 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.1210 + system("rm "+plot_name+"-*."+plot_type_new)
254.1211 + system("rm "+plot_name+"."+plot_type)
254.1212 +
254.1213 + delete (RAIN1_1D)
254.1214 + delete (RAIN2_1D)
254.1215 + delete (NPP1_1D)
254.1216 + delete (NPP2_1D)
254.1217 +;delete (range)
254.1218 + delete (xvalues)
254.1219 + delete (yvalues)
254.1220 + delete (mn_yvalues)
254.1221 + delete (mx_yvalues)
254.1222 + delete (good)
254.1223 + delete (max_bar)
254.1224 + delete (min_bar)
254.1225 + delete (max_cap)
254.1226 + delete (min_cap)
254.1227 +
254.1228 +;**************************************************************************
254.1229 +;(B) histogram 933
254.1230 +;**************************************************************************
254.1231 +
254.1232 +; get data
254.1233 + RAIN1_1D = ndtooned(rain933)
254.1234 + RAIN2_1D = ndtooned(rainmod933)
254.1235 + NPP1_1D = ndtooned(npp933)
254.1236 + NPP2_1D = ndtooned(nppmod933)
254.1237 +
254.1238 +; number of bin
254.1239 + nx = 10
254.1240 +
254.1241 + xvalues = new((/2,nx/),float)
254.1242 + yvalues = new((/2,nx/),float)
254.1243 + mn_yvalues = new((/2,nx/),float)
254.1244 + mx_yvalues = new((/2,nx/),float)
254.1245 + dx4 = new((/1/),float)
254.1246 +
254.1247 + get_bin(RAIN1_1D, NPP1_1D, RAIN2_1D, NPP2_1D \
254.1248 + ,xvalues,yvalues,mn_yvalues,mx_yvalues,dx4)
254.1249 +
254.1250 +;----------------------------------------
254.1251 +;compute correlation coeff and M score
254.1252 +
254.1253 + u = yvalues(0,:)
254.1254 + v = yvalues(1,:)
254.1255 +
254.1256 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
254.1257 + uu = u(good)
254.1258 + vv = v(good)
254.1259 +
254.1260 + ccr933h = esccr(uu,vv,0)
254.1261 +;print (ccr933h)
254.1262 +
254.1263 +;new eq
254.1264 + bias = sum(abs(vv-uu)/(abs(vv)+abs(uu)))
254.1265 + M933h = (1.- (bias/dimsizes(uu)))*5.
254.1266 +
254.1267 + M_npp_H933 = sprintf("%.2f", M933h)
254.1268 + system("sed s#M_npp_H933#"+M_npp_H933+"# "+html_name+" > "+html_new)
254.1269 + system("mv -f "+html_new+" "+html_name)
254.1270 + print (M_npp_H933)
254.1271 +
254.1272 + delete (u)
254.1273 + delete (v)
254.1274 + delete (uu)
254.1275 + delete (vv)
254.1276 +;----------------------------------------------------------------------
254.1277 +; histogram res
254.1278 + delete (resh)
254.1279 + resh = True
254.1280 + resh@gsnMaximize = True
254.1281 + resh@gsnDraw = False
254.1282 + resh@gsnFrame = False
254.1283 + resh@xyMarkLineMode = "Markers"
254.1284 + resh@xyMarkerSizeF = 0.014
254.1285 + resh@xyMarker = 16
254.1286 + resh@xyMarkerColors = (/"Brown","Blue"/)
254.1287 + resh@trYMinF = min(mn_yvalues) - 10.
254.1288 + resh@trYMaxF = max(mx_yvalues) + 10.
254.1289 +
254.1290 + resh@tiYAxisString = "NPP (g C/m2/year)"
254.1291 + resh@tiXAxisString = "Precipitation (m/year)"
254.1292 +
254.1293 + max_bar = new((/2,nx/),graphic)
254.1294 + min_bar = new((/2,nx/),graphic)
254.1295 + max_cap = new((/2,nx/),graphic)
254.1296 + min_cap = new((/2,nx/),graphic)
254.1297 +
254.1298 + lnres = True
254.1299 + line_colors = (/"brown","blue"/)
254.1300 +
254.1301 +;**************************************************************************
254.1302 +;(B)-3 histogram plot, ob 933 site
254.1303 +;**************************************************************************
254.1304 +
254.1305 + plot_name = "histogram_ob_933"
254.1306 + title = "Observed 933 site"
254.1307 + resh@tiMainString = title
254.1308 +
254.1309 + wks = gsn_open_wks (plot_type,plot_name)
254.1310 +
254.1311 + xy = gsn_csm_xy(wks,xvalues(0,:),yvalues(0,:),resh)
254.1312 +
254.1313 +;-------------------------------
254.1314 +;Attach the vertical bar and the horizontal cap line
254.1315 +
254.1316 + do nd=0,0
254.1317 + lnres@gsLineColor = line_colors(nd)
254.1318 + do i=0,nx-1
254.1319 +
254.1320 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
254.1321 + .not.ismissing(mx_yvalues(nd,i))) then
254.1322 +
254.1323 +; Attach the vertical bar, both above and below the marker.
254.1324 +
254.1325 + x1 = xvalues(nd,i)
254.1326 + y1 = yvalues(nd,i)
254.1327 + y2 = mn_yvalues(nd,i)
254.1328 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
254.1329 +
254.1330 + y2 = mx_yvalues(nd,i)
254.1331 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
254.1332 +
254.1333 +; Attach the horizontal cap line, both above and below the marker.
254.1334 +
254.1335 + x1 = xvalues(nd,i) - dx4
254.1336 + x2 = xvalues(nd,i) + dx4
254.1337 + y1 = mn_yvalues(nd,i)
254.1338 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
254.1339 +
254.1340 + y1 = mx_yvalues(nd,i)
254.1341 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
254.1342 + end if
254.1343 + end do
254.1344 + end do
254.1345 +
254.1346 + draw(xy)
254.1347 + frame(wks)
254.1348 + delete (xy)
254.1349 + clear (wks)
254.1350 +
254.1351 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.1352 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.1353 + system("rm "+plot_name+"-*."+plot_type_new)
254.1354 + system("rm "+plot_name+"."+plot_type)
254.1355 +
254.1356 +;****************************************************************************
254.1357 +;(B)-4 histogram plot, model vs ob 933 site
254.1358 +;****************************************************************************
254.1359 +
254.1360 + plot_name = "histogram_model_vs_ob_933"
254.1361 + title = model_name+ " vs Observed 933 site"
254.1362 + resh@tiMainString = title
254.1363 +
254.1364 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
254.1365 +
254.1366 +;-----------------------------
254.1367 +; Add a boxed legend using the more simple method, which won't have
254.1368 +; vertical lines going through the markers.
254.1369 +
254.1370 + resh@pmLegendDisplayMode = "Always"
254.1371 +; resh@pmLegendWidthF = 0.1
254.1372 + resh@pmLegendWidthF = 0.08
254.1373 + resh@pmLegendHeightF = 0.05
254.1374 + resh@pmLegendOrthogonalPosF = -1.17
254.1375 +; resh@pmLegendOrthogonalPosF = -1.00 ;(downward)
254.1376 +; resh@pmLegendParallelPosF = 0.18
254.1377 + resh@pmLegendParallelPosF = 0.88 ;(rightward)
254.1378 +
254.1379 +; resh@lgPerimOn = False
254.1380 + resh@lgLabelFontHeightF = 0.015
254.1381 + resh@xyExplicitLegendLabels = (/"observed",model_name/)
254.1382 +;-----------------------------
254.1383 + tRes = True
254.1384 + tRes@txFontHeightF = 0.025
254.1385 +
254.1386 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccr933h)+")"
254.1387 +
254.1388 + gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
254.1389 +
254.1390 + xy = gsn_csm_xy(wks,xvalues,yvalues,resh)
254.1391 +;-------------------------------
254.1392 +;Attach the vertical bar and the horizontal cap line
254.1393 +
254.1394 + do nd=0,1
254.1395 + lnres@gsLineColor = line_colors(nd)
254.1396 + do i=0,nx-1
254.1397 +
254.1398 + if(.not.ismissing(mn_yvalues(nd,i)).and. \
254.1399 + .not.ismissing(mx_yvalues(nd,i))) then
254.1400 +;
254.1401 +; Attach the vertical bar, both above and below the marker.
254.1402 +;
254.1403 + x1 = xvalues(nd,i)
254.1404 + y1 = yvalues(nd,i)
254.1405 + y2 = mn_yvalues(nd,i)
254.1406 + min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
254.1407 +
254.1408 + y2 = mx_yvalues(nd,i)
254.1409 + max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
254.1410 +;
254.1411 +; Attach the horizontal cap line, both above and below the marker.
254.1412 +;
254.1413 + x1 = xvalues(nd,i) - dx4
254.1414 + x2 = xvalues(nd,i) + dx4
254.1415 + y1 = mn_yvalues(nd,i)
254.1416 + min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
254.1417 +
254.1418 + y1 = mx_yvalues(nd,i)
254.1419 + max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
254.1420 + end if
254.1421 + end do
254.1422 + end do
254.1423 +
254.1424 + draw(xy)
254.1425 + frame(wks)
254.1426 + delete(xy)
254.1427 + clear(wks)
254.1428 +
254.1429 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.1430 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.1431 + system("rm "+plot_name+"-*."+plot_type_new)
254.1432 + system("rm "+plot_name+"."+plot_type)
254.1433 +
254.1434 +;***************************************************************************
254.1435 +;(C) global contour
254.1436 +;***************************************************************************
254.1437 +
254.1438 +;res
254.1439 + resg = True ; Use plot options
254.1440 + resg@cnFillOn = True ; Turn on color fill
254.1441 + resg@gsnSpreadColors = True ; use full colormap
254.1442 +; resg@cnFillMode = "RasterFill" ; Turn on raster color
254.1443 +; resg@lbLabelAutoStride = True
254.1444 + resg@cnLinesOn = False ; Turn off contourn lines
254.1445 + resg@mpFillOn = False ; Turn off map fill
254.1446 +
254.1447 + resg@gsnSpreadColors = True ; use full colormap
254.1448 + resg@cnLevelSelectionMode = "ManualLevels" ; Manual contour invtervals
254.1449 + resg@cnMinLevelValF = 0. ; Min level
254.1450 + resg@cnMaxLevelValF = 2200. ; Max level
254.1451 + resg@cnLevelSpacingF = 200. ; interval
254.1452 +
254.1453 +;****************************************************************************
254.1454 +;(C)-1 global contour plot, ob
254.1455 +;****************************************************************************
254.1456 +
254.1457 + delta = 0.00000000001
254.1458 + nppglobe = where(ismissing(nppglobe).and.(ismissing(nppmod).or.(nppmod.lt.delta)),0.,nppglobe)
254.1459 +
254.1460 + plot_name = "global_ob"
254.1461 + title = "Observed MODIS MOD 17"
254.1462 + resg@tiMainString = title
254.1463 +
254.1464 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
254.1465 + gsn_define_colormap(wks,"gui_default") ; choose colormap
254.1466 +
254.1467 + plot = gsn_csm_contour_map_ce(wks,nppglobe,resg)
254.1468 +
254.1469 + frame(wks)
254.1470 + clear (wks)
254.1471 +
254.1472 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.1473 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.1474 + system("rm "+plot_name+"-*."+plot_type_new)
254.1475 + system("rm "+plot_name+"."+plot_type)
254.1476 +
254.1477 +;****************************************************************************
254.1478 +;(C)-2 global contour plot, model
254.1479 +;****************************************************************************
254.1480 +
254.1481 + plot_name = "global_model"
254.1482 + title = "Model "+ model_name
254.1483 + resg@tiMainString = title
254.1484 +
254.1485 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
254.1486 + gsn_define_colormap(wks,"gui_default") ; choose colormap
254.1487 +
254.1488 + plot = gsn_csm_contour_map_ce(wks,nppmod,resg)
254.1489 +
254.1490 + frame(wks)
254.1491 + clear (wks)
254.1492 +
254.1493 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.1494 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.1495 + system("rm "+plot_name+"-*."+plot_type_new)
254.1496 + system("rm "+plot_name+"."+plot_type)
254.1497 +
254.1498 +;****************************************************************************
254.1499 +;(C)-3 global contour plot, model vs ob
254.1500 +;****************************************************************************
254.1501 +
254.1502 + plot_name = "global_model_vs_ob"
254.1503 +
254.1504 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
254.1505 + gsn_define_colormap(wks,"gui_default") ; choose colormap
254.1506 +
254.1507 + delete (plot)
254.1508 + plot=new(3,graphic) ; create graphic array
254.1509 +
254.1510 + resg@gsnFrame = False ; Do not draw plot
254.1511 + resg@gsnDraw = False ; Do not advance frame
254.1512 +
254.1513 +; compute correlation coef and M score
254.1514 +
254.1515 + uu1 = ndtooned(nppmod)
254.1516 + vv1 = ndtooned(nppglobe)
254.1517 +
254.1518 + delete (good)
254.1519 + good = ind(.not.ismissing(uu1) .and. .not.ismissing(vv1))
254.1520 +
254.1521 + ug = uu1(good)
254.1522 + vg = vv1(good)
254.1523 +
254.1524 + ccrG = esccr(ug,vg,0)
254.1525 +; print (ccrG)
254.1526 +
254.1527 + MG = (ccrG*ccrG)* 5.0
254.1528 +
254.1529 + M_npp_G = sprintf("%.2f", MG)
254.1530 + system("sed s#M_npp_G#"+M_npp_G+"# "+html_name+" > "+html_new)
254.1531 + system("mv -f "+html_new+" "+html_name)
254.1532 + print (M_npp_G)
254.1533 +
254.1534 +; plot correlation coef
254.1535 +
254.1536 + gRes = True
254.1537 + gRes@txFontHeightF = 0.02
254.1538 + gRes@txAngleF = 90
254.1539 +
254.1540 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrG)+")"
254.1541 +
254.1542 + gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
254.1543 +;--------------------------------------------------------------------
254.1544 +;(a) ob
254.1545 +
254.1546 + title = "Observed MODIS MOD 17"
254.1547 + resg@tiMainString = title
254.1548 +
254.1549 + plot(0) = gsn_csm_contour_map_ce(wks,nppglobe,resg)
254.1550 +
254.1551 +;(b) model
254.1552 +
254.1553 + title = "Model "+ model_name
254.1554 + resg@tiMainString = title
254.1555 +
254.1556 + plot(1) = gsn_csm_contour_map_ce(wks,nppmod,resg)
254.1557 +
254.1558 +;(c) model-ob
254.1559 +
254.1560 + zz = nppmod
254.1561 + zz = nppmod - nppglobe
254.1562 + title = "Model_"+model_name+" - Observed"
254.1563 +
254.1564 + resg@cnMinLevelValF = -500 ; Min level
254.1565 + resg@cnMaxLevelValF = 500. ; Max level
254.1566 + resg@cnLevelSpacingF = 50. ; interval
254.1567 + resg@tiMainString = title
254.1568 +
254.1569 + plot(2) = gsn_csm_contour_map_ce(wks,zz,resg)
254.1570 +
254.1571 + pres = True ; panel plot mods desired
254.1572 +; pres@gsnPanelYWhiteSpacePercent = 5 ; increase white space around
254.1573 + ; indiv. plots in panel
254.1574 + pres@gsnMaximize = True ; fill the page
254.1575 +
254.1576 + gsn_panel(wks,plot,(/3,1/),pres) ; create panel plot
254.1577 +
254.1578 + frame (wks)
254.1579 + clear (wks)
254.1580 + delete (plot)
254.1581 +
254.1582 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.1583 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.1584 + system("rm "+plot_name+"-*."+plot_type_new)
254.1585 + system("rm "+plot_name+"."+plot_type)
254.1586 +
254.1587 +;***************************************************************************
254.1588 +;(D)-1 zonal line plot, ob
254.1589 +;***************************************************************************
254.1590 +
254.1591 + vv = zonalAve(nppglobe)
254.1592 + vv@long_name = nppglobe@long_name
254.1593 +
254.1594 + plot_name = "zonal_ob"
254.1595 + title = "Observed MODIS MOD 17"
254.1596 +
254.1597 + resz = True
254.1598 + resz@tiMainString = title
254.1599 +
254.1600 + wks = gsn_open_wks (plot_type,plot_name) ; open workstation
254.1601 +
254.1602 + plot = gsn_csm_xy (wks,ym,vv,resz)
254.1603 +
254.1604 + frame(wks)
254.1605 + clear (wks)
254.1606 +
254.1607 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.1608 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.1609 + system("rm "+plot_name+"-*."+plot_type_new)
254.1610 + system("rm "+plot_name+"."+plot_type)
254.1611 +
254.1612 +;****************************************************************************
254.1613 +;(D)-2 zonal line plot, model vs ob
254.1614 +;****************************************************************************
254.1615 +
254.1616 + s = new ((/2,dimsizes(ym)/), float)
254.1617 +
254.1618 + s(0,:) = zonalAve(nppglobe)
254.1619 + s(1,:) = zonalAve(nppmod)
254.1620 +
254.1621 + s@long_name = nppglobe@long_name
254.1622 +;-------------------------------------------
254.1623 +; compute correlation coef and M score
254.1624 +
254.1625 + ccrZ = esccr(s(1,:), s(0,:),0)
254.1626 +; print (ccrZ)
254.1627 +
254.1628 + MZ = (ccrZ*ccrZ)* 5.0
254.1629 +
254.1630 + M_npp_Z = sprintf("%.2f", MZ)
254.1631 + system("sed s#M_npp_Z#"+M_npp_Z+"# "+html_name+" > "+html_new)
254.1632 + system("mv -f "+html_new+" "+html_name)
254.1633 + print (M_npp_Z)
254.1634 +;-------------------------------------------
254.1635 + plot_name = "zonal_model_vs_ob"
254.1636 + title = "Zonal Average"
254.1637 + resz@tiMainString = title
254.1638 +
254.1639 + wks = gsn_open_wks (plot_type,plot_name)
254.1640 +
254.1641 +; resz@vpHeightF = 0.4 ; change aspect ratio of plot
254.1642 +; resz@vpWidthF = 0.7
254.1643 +
254.1644 + resz@xyMonoLineColor = "False" ; want colored lines
254.1645 + resz@xyLineColors = (/"black","red"/) ; colors chosen
254.1646 +; resz@xyLineThicknesses = (/3.,3./) ; line thicknesses
254.1647 + resz@xyLineThicknesses = (/2.,2./) ; line thicknesses
254.1648 + resz@xyDashPatterns = (/0.,0./) ; make all lines solid
254.1649 +
254.1650 + resz@tiYAxisString = s@long_name ; add a axis title
254.1651 + resz@txFontHeightF = 0.0195 ; change title font heights
254.1652 +
254.1653 +; Legent
254.1654 + resz@pmLegendDisplayMode = "Always" ; turn on legend
254.1655 + resz@pmLegendSide = "Top" ; Change location of
254.1656 +; resz@pmLegendParallelPosF = .45 ; move units right
254.1657 + resz@pmLegendParallelPosF = .82 ; move units right
254.1658 + resz@pmLegendOrthogonalPosF = -0.4 ; move units down
254.1659 +
254.1660 + resz@pmLegendWidthF = 0.10 ; Change width and
254.1661 + resz@pmLegendHeightF = 0.10 ; height of legend.
254.1662 + resz@lgLabelFontHeightF = .02 ; change font height
254.1663 +; resz@lgTitleOn = True ; turn on legend title
254.1664 +; resz@lgTitleString = "Example" ; create legend title
254.1665 +; resz@lgTitleFontHeightF = .025 ; font of legend title
254.1666 + resz@xyExplicitLegendLabels = (/"Observed",model_name/) ; explicit labels
254.1667 +;--------------------------------------------------------------------
254.1668 + zRes = True
254.1669 + zRes@txFontHeightF = 0.025
254.1670 +
254.1671 + correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrZ)+")"
254.1672 +
254.1673 + gsn_text_ndc(wks,correlation_text,0.50,0.77,zRes)
254.1674 +;--------------------------------------------------------------------
254.1675 +
254.1676 + plot = gsn_csm_xy (wks,ym,s,resz)
254.1677 +
254.1678 + frame(wks)
254.1679 + clear (wks)
254.1680 +
254.1681 + system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
254.1682 + system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
254.1683 + system("rm "+plot_name+"-*."+plot_type_new)
254.1684 + system("rm "+plot_name+"."+plot_type)
254.1685 +
254.1686 +;***************************************************************************
254.1687 +; tar up output plots
254.1688 +;***************************************************************************
254.1689 +
254.1690 + temp_name = "npp." + model_name
254.1691 + system("mkdir -p " + temp_name)
254.1692 + system("cp "+ html_name + " " +temp_name+"/table.html")
254.1693 + system("mv *.png " + temp_name)
254.1694 + system("tar cf "+ temp_name +".tar " + temp_name)
254.1695 +
254.1696 +;***************************************************************************
254.1697 +end
254.1698 +
255.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
255.2 +++ b/npp/note.ob_read Mon Jan 26 22:08:20 2009 -0500
255.3 @@ -0,0 +1,7 @@
255.4 +(A) for station data
255.5 + 01.read_ascii_81.ncl
255.6 + 01.read_ascii_933.ncl
255.7 +
255.8 +(B) for global 0.05deg data
255.9 + 02.read_binary_0.05deg.ncl
255.10 + 03.0.05deg_to_T42.ncl
255.11 \ No newline at end of file
256.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
256.2 +++ b/npp/note.read-binary Mon Jan 26 22:08:20 2009 -0500
256.3 @@ -0,0 +1,6 @@
256.4 +f90 -64 read-binary.f90
256.5 +./a.out > asc.dat &
256.6 +
256.7 +wc -l asc.dat
256.8 +bc -l
256.9 +ls -tl | head
256.10 \ No newline at end of file
257.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
257.2 +++ b/soil_carbon/01.test.read.ncl Mon Jan 26 22:08:20 2009 -0500
257.3 @@ -0,0 +1,19 @@
257.4 +;************************************************
257.5 +; Read ascii, Write nc
257.6 +;************************************************
257.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
257.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
257.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
257.10 +;************************************************
257.11 +begin
257.12 +
257.13 + b = "zot005_45D2_seas.co2"
257.14 + ncol = 4
257.15 + data = readAsciiTable(b, ncol, "float", (/10,17/))
257.16 + print (data)
257.17 +
257.18 + ncol = 5
257.19 + data2 = readAsciiTable(b, ncol, "float", 16)
257.20 + print (data2)
257.21 +
257.22 +end
258.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
258.2 +++ b/taylor/01.ncl Mon Jan 26 22:08:20 2009 -0500
258.3 @@ -0,0 +1,57 @@
258.4 +;**********************************
258.5 +; taylor_3.ncl
258.6 +;**********************************
258.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
258.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
258.9 +load "./taylor_diagram.ncl"
258.10 +;**********************************
258.11 +begin
258.12 +;**********************************
258.13 +; Assume the following have already been computed:
258.14 +; _ratio are the ratio: Case_Variance/Reference_Variance
258.15 +; _cc are the cross correlation coef of Case to Reference
258.16 +;**********************************
258.17 +
258.18 +; Cases [Model]
258.19 + case = (/ "Case A", "Case B" /)
258.20 + nCase = dimsizes(case ) ; # of Cases [Cases]
258.21 +
258.22 +; variables compared
258.23 + var = (/ "SLP","Tsfc","Prc","Prc 30S-30N","LW","SW", "U300", "Guess" /)
258.24 + nVar = dimsizes(var) ; # of Variables
258.25 +
258.26 +; "Case A"
258.27 + CA_ratio = (/1.230, 0.988, 1.092, 1.172, 1.064, 0.966, 1.079, 0.781/)
258.28 + CA_cc = (/0.958, 0.973, 0.740, 0.743, 0.922, 0.982, 0.952, 0.433/)
258.29 +
258.30 +; "Case B"
258.31 + CB_ratio = (/1.129, 0.996, 1.016, 1.134, 1.023, 0.962, 1.048, 0.852 /)
258.32 + CB_cc = (/0.963, 0.975, 0.801, 0.814, 0.946, 0.984, 0.968, 0.647 /)
258.33 +
258.34 +; arrays to be passed to taylor plot
258.35 + ratio = new ((/nCase, nVar/),typeof(CA_cc) )
258.36 + cc = new ((/nCase, nVar/),typeof(CA_cc) )
258.37 +
258.38 + ratio(0,:) = CA_ratio
258.39 + ratio(1,:) = CB_ratio
258.40 +
258.41 + cc(0,:) = CA_cc
258.42 + cc(1,:) = CB_cc
258.43 +
258.44 +;**********************************
258.45 +; create plot
258.46 +;**********************************
258.47 +
258.48 + res = True ; default taylor diagram
258.49 +
258.50 + res@Markers = (/16, 16/) ; make all solid fill
258.51 + res@Colors = (/"red", "blue" /)
258.52 + res@varLabels = var
258.53 + res@caseLabels = case
258.54 +
258.55 + wks = gsn_open_wks("ps","taylor")
258.56 + plot = taylor_diagram(wks,ratio,cc,res)
258.57 +
258.58 + frame(wks)
258.59 +
258.60 +end
259.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
259.2 +++ b/taylor/taylor_diagram.ncl Mon Jan 26 22:08:20 2009 -0500
259.3 @@ -0,0 +1,478 @@
259.4 +function taylor_diagram (wks:graphic ,RATIO[*][*]:numeric, CC[*][*]:numeric \
259.5 + ,rOpts:logical)
259.6 +;--------------------------------------------------------------------
259.7 +; This version of taylor_diagram supports "paneling"
259.8 +; It requires NCL version 4.2.0.a034 because it uses "gsn_create_legend"
259.9 +;--------------------------------------------------------------------
259.10 +
259.11 +;
259.12 +; Generate a Taylor Diagram:
259.13 +; Generate Multiple Aspects of Model Performance in a Single Diagram
259.14 +; Taylor, K. E., J. Geophys. Res., 106, D7, 7183-7192, 2001
259.15 +;
259.16 +; An example:
259.17 +; http://www.grida.no/climate/ipcc_tar/wg1/fig8-4.htm
259.18 +;
259.19 +; This expects one or more datasets. The left dimension
259.20 +; is the number of datasets. The rightmost is the number of pts.
259.21 +;
259.22 +; Markers are at:
259.23 +; http://www.ncl.ucar.edu/Document/Graphics/Resources/gs.shtml
259.24 +;
259.25 +; By default, the function can handle up to 10 variable comparisons..
259.26 +; To expand ... modify the 'Colors' and 'Markers' attributes.
259.27 +; The user can change / add some default settings.
259.28 +;
259.29 +; The defaults that the user can modify:
259.30 +;
259.31 +; rOpts = True
259.32 +; ; 'made-up' resources
259.33 +; rOpts@Colors = (/ "blue" , "red", "green", "cyan", "black" \
259.34 +; , "torquoise", "brown", "yellow"/)
259.35 +; rOpts@Markers = (/ 2, 3, 6, 14, 9, 12, 7, 4/) ; Marker Indices
259.36 +; rOpts@markerTxOffset = 0.0175 ; offset for text above marker
259.37 +; rOpts@stnRad = (/ 1. /) ; (/ 0.50, 0.75, 1.5 /)
259.38 +; rOpts@centerDiffRMS = False ; True mean draw additional radii from REF
259.39 +; rOpts@caseLabelsFontHeightF = 0.05
259.40 +; rOpts@varLabelsFontHeightF = 0.013
259.41 +; rOpts@varLabelsYloc = 0.65
259.42 +; rOpts@legendWidth = 0.015
259.43 +; rOpts@legendHeight = 0.030*nCase
259.44 +; rOpts@taylorDraw = True
259.45 +; rOpts@taylorFrame = True
259.46 +;
259.47 +; ; standard NCL resources
259.48 +; rOpts@tiMainString = "Taylor" ; not using title makes plot bigger
259.49 +; rOpts@gsMarkerSizeF = 0.0085 ; marker size
259.50 +; rOpts@gsMarkerThicknessF = 1.0
259.51 +; rOpts@txFontHeightF = 0.0125 ; text size
259.52 +; rOpts@tiMainFontHeightF = 0.0225 ; tiMainString size
259.53 +;
259.54 +; It returns to the user a graphic object containing the
259.55 +; Taylor background and plotted x/y pts.
259.56 +; This graphic object contains a simple Taylor background appropriate
259.57 +; for standardized data and the markers for the datasets.
259.58 +; ==================================================================
259.59 +; This version allows paneling:
259.60 +; The 'cumbersome' "dum" variables were added by
259.61 +; Adam Phillips to allow paneling via "gsn_add_?".
259.62 +; ==================================================================
259.63 +begin
259.64 + dimR = dimsizes(RATIO)
259.65 + nCase = dimR(0) ; # of cases [models]
259.66 + nVar = dimR(1) ; # of variables
259.67 +
259.68 + ; x/y coordinates for plotting
259.69 + X = new ( (/nCase,nVar/) , typeof(RATIO) )
259.70 + Y = new ( (/nCase,nVar/) , typeof(RATIO) )
259.71 +
259.72 + do nc=0,nCase-1
259.73 + angle = acos( CC(nc,:) ) ; array operation
259.74 + X(nc,:) = RATIO(nc,:)*cos( angle )
259.75 + Y(nc,:) = RATIO(nc,:)*sin( angle )
259.76 + end do
259.77 +
259.78 + xyMin = 0.
259.79 + xyOne = 1.00
259.80 + xyMax = 1.65
259.81 + xyMax_Panel = xyMax+ 0.10 ; paneling purposes
259.82 +
259.83 + if (rOpts .and. isatt(rOpts,"txFontHeightF")) then
259.84 + FontHeightF = rOpts@txFontHeightF ; user wants to specify size
259.85 + else
259.86 + FontHeightF = 0.0175
259.87 + end if
259.88 +
259.89 +; ----------------------------------------------------------------
259.90 +; Part 1:
259.91 +; base plot: Based upon request of Mark Stevens
259.92 +; basic x-y and draw the 1.0 observed and the outer curve at 1.65
259.93 +; ----------------------------------------------------------------
259.94 +
259.95 + rxy = True
259.96 + rxy@gsnDraw = False
259.97 + rxy@gsnFrame = False
259.98 + rxy@vpHeightF = 0.65
259.99 + rxy@vpWidthF = 0.65
259.100 + rxy@tmYLBorderOn = False
259.101 + rxy@tmXBBorderOn = False
259.102 +
259.103 + rxy@tiYAxisString = "Standardized Deviations (Normalized)"
259.104 + rxy@tiYAxisFontHeightF= FontHeightF ; default=0.025
259.105 +
259.106 + rxy@tmXBMode = "Explicit"
259.107 + rxy@tmXBValues = (/0.0,0.25,0.50,0.75,1.00,1.25,1.5/) ; major tm
259.108 + ; default "OBS" or "REF"
259.109 + ;rxy@tmXBLabels = (/"0.00","0.25","0.50","0.75","REF" ,"1.25","1.50"/)
259.110 + rxy@tmXBLabels = (/" ","0.25","0.50","0.75","REF" ,"1.25","1.50"/)
259.111 + if (rOpts .and. isatt(rOpts,"OneX") ) then ; eg: rOpts@OneX="1.00"
259.112 + ;rxy@tmXBLabels = (/"0.00","0.25","0.50","0.75",rOpts@OneX,"1.25","1.50"/)
259.113 + rxy@tmXBLabels = (/" ","0.25","0.50","0.75",rOpts@OneX,"1.25","1.50"/)
259.114 + end if
259.115 +
259.116 + rxy@tmXBMajorLengthF = 0.015 ; default=0.02 for a vpHeightF=0.6
259.117 + rxy@tmXBLabelFontHeightF = FontHeightF
259.118 + rxy@tmXBMinorOn = False
259.119 + rxy@trXMaxF = xyMax_Panel
259.120 +
259.121 + rxy@tmYLMode = "Manual"
259.122 + rxy@tmYLMinorOn = False
259.123 + rxy@tmYLMajorLengthF = rxy@tmXBMajorLengthF
259.124 + rxy@tmYLLabelFontHeightF = FontHeightF
259.125 + rxy@tmYLMode = "Explicit"
259.126 + rxy@tmYLValues = (/0.0, .25,0.50, 0.75, 1.00, 1.25, 1.5/) ; major tm
259.127 + rxy@tmYLLabels = (/"0.00","0.25","0.50","0.75","1.00","1.25","1.50"/)
259.128 + ;rxy@tmYLLabels = (/" ","0.25","0.50","0.75","1.00","1.25","1.50"/)
259.129 + rxy@trYMaxF = xyMax_Panel
259.130 +
259.131 + rxy@tmYRBorderOn = False
259.132 + rxy@tmYROn = False ; Turn off right tick marks.
259.133 +
259.134 + rxy@tmXTBorderOn = False
259.135 + rxy@tmXTOn = False ; Turn off right tick marks.
259.136 +
259.137 + rxy@xyDashPatterns = (/ 0 /) ; line characteristics (dash,solid)
259.138 + rxy@xyLineThicknesses = (/ 2./) ; choose line thickness
259.139 +
259.140 + rxy@gsnFrame = False ; Don't advance the frame.
259.141 +
259.142 + ; create outer 'correlation axis'
259.143 + npts = 200 ; arbitrary
259.144 + xx = fspan(xyMin,xyMax,npts)
259.145 + yy = sqrt(xyMax^2 - xx^2 ) ; outer correlation line (xyMax)
259.146 +
259.147 + sLabels = (/"0.0","0.1","0.2","0.3","0.4","0.5","0.6" \ ; correlation labels
259.148 + ,"0.7","0.8","0.9","0.95","0.99","1.0" /); also, major tm
259.149 + cLabels = stringtofloat(sLabels)
259.150 + rad = 4.*atan(1.0)/180.
259.151 + angC = acos(cLabels)/rad ; angles: correlation labels
259.152 +
259.153 + if (rOpts .and. isatt(rOpts,"tiMainString")) then
259.154 + rxy@tiMainString = rOpts@tiMainString
259.155 + ;rxy@tiMainOffsetYF = 0.015 ; default 0.0
259.156 + if (isatt(rOpts,"tiMainFontHeightF")) then
259.157 + rxy@tiMainFontHeightF = rOpts@tiMainFontHeightF
259.158 + else
259.159 + rxy@tiMainFontHeightF = 0.0225 ; default 0.025
259.160 + end if
259.161 + end if
259.162 +;;if (rOpts .and. isatt(rOpts,"gsnCenterString")) then
259.163 +;; rxy@gsnCenterString = rOpts@gsnCenterString ; only gsn_csm_xy
259.164 +;;end if
259.165 +
259.166 + taylor = gsn_xy(wks,xx,yy,rxy) ; Create and draw XY plot.
259.167 +
259.168 + rsrRes = True
259.169 + rsrRes@gsLineThicknessF = rxy@xyLineThicknesses(0) ; line thickness
259.170 + rsrRes@gsLineDashPattern = 0 ; solid line pattern
259.171 + ; draw x and y to xyMax
259.172 + dum0 = gsn_add_polyline(wks,taylor,(/0., 0. /),(/0.,xyMax/), rsrRes)
259.173 + dum1 = gsn_add_polyline(wks,taylor,(/0.,xyMax/),(/0., 0. /), rsrRes)
259.174 +
259.175 + xx = fspan(xyMin, xyOne ,npts) ; draw 1.0 standard radius
259.176 + yy = sqrt(xyOne - xx^2)
259.177 + rsrRes@gsLineDashPattern = 1 ; dashed line pattern
259.178 + rsrRes@gsLineThicknessF = rxy@xyLineThicknesses(0) ; line thickness
259.179 + dum2 = gsn_add_polyline(wks,taylor,xx,yy, rsrRes)
259.180 + delete(xx)
259.181 + delete(yy)
259.182 +
259.183 + if (rOpts .and. isatt(rOpts,"stnRad") ) then
259.184 + rsrRes@gsLineThicknessF = 1 ; rxy@xyLineThicknesses(0)
259.185 + nStnRad = dimsizes(rOpts@stnRad)
259.186 +
259.187 + dum3 = new(nStnRad,graphic)
259.188 + do n=0,nStnRad-1
259.189 + rr = rOpts@stnRad(n)
259.190 + xx = fspan(xyMin, rr ,npts)
259.191 + yy = sqrt(rr^2 - xx^2)
259.192 + dum3(n) = gsn_add_polyline(wks,taylor,xx,yy, rsrRes)
259.193 + end do
259.194 + taylor@$unique_string("dum")$ = dum3
259.195 +
259.196 + delete(xx)
259.197 + delete(yy)
259.198 + end if
259.199 +
259.200 + getvalues taylor ; get style info from taylor
259.201 + "tmYLLabelFont" : tmYLLabelFont ; use for correlation axis
259.202 + "tmYLLabelFontHeightF" : tmYLLabelFontHeightF
259.203 + end getvalues
259.204 +
259.205 +; ----------------------------------------------------------------
259.206 +; Part 2:
259.207 +; Correlation labels
259.208 +; ----------------------------------------------------------------
259.209 + radC = xyMax ; for correlation labels
259.210 + xC = radC*cos(angC*rad)
259.211 + yC = radC*sin(angC*rad)
259.212 +; added to get some separation
259.213 + xC = xC + 0.020*cos(rad*angC)
259.214 + yC = yC + 0.060*sin(rad*angC)
259.215 +
259.216 + txRes = True ; text mods desired
259.217 + txRes@txFontHeightF = FontHeightF ; match YL
259.218 + txRes@tmYLLabelFont = tmYLLabelFont ; match YL
259.219 + txRes@txAngleF = -45.
259.220 + if (.not.isatt(rOpts,"drawCorLabel") .or. rOpts@drawCorLabel) then
259.221 + dum4 = gsn_add_text(wks,taylor,"Correlation",1.30,1.30,txRes)
259.222 + taylor@$unique_string("dum")$ = dum4
259.223 + end if
259.224 + txRes@txAngleF = 0.0
259.225 + txRes@txFontHeightF = FontHeightF*0.50 ; bit smaller
259.226 +
259.227 +;;dum0 = gsn_add_text(wks,taylor,"OBSERVED",1.00,0.075,txRes)
259.228 +
259.229 + plRes = True
259.230 + plRes@gsLineThicknessF = 2.
259.231 +
259.232 + txRes@txJust = "CenterLeft" ; Default="CenterCenter".
259.233 + txRes@txFontHeightF = FontHeightF ; match YL
259.234 + ;txRes@txBackgroundFillColor = "white"
259.235 +
259.236 + tmEnd = 0.975
259.237 + radTM = xyMax*tmEnd ; radius end: major TM
259.238 + xTM = new( 2 , "float")
259.239 + yTM = new( 2 , "float")
259.240 +
259.241 + dum5 = new(dimsizes(sLabels),graphic)
259.242 + dum6 = dum5
259.243 +
259.244 + do i=0,dimsizes(sLabels)-1 ; Loop to draw strings
259.245 + txRes@txAngleF = angC(i)
259.246 + dum5(i) = gsn_add_text(wks, taylor, sLabels(i),xC(i),yC(i),txRes) ; cor label
259.247 + xTM(0) = xyMax*cos(angC(i)*rad) ; major tickmarks at
259.248 + yTM(0) = xyMax*sin(angC(i)*rad) ; correlation labels
259.249 + xTM(1) = radTM*cos(angC(i)*rad)
259.250 + yTM(1) = radTM*sin(angC(i)*rad)
259.251 + dum6(i) = gsn_add_polyline(wks,taylor,xTM,yTM,plRes)
259.252 + end do
259.253 + ; minor tm locations
259.254 + mTM = (/0.05,0.15,0.25,0.35,0.45,0.55,0.65 \
259.255 + ,0.75,0.85,0.91,0.92,0.93,0.94,0.96,0.97,0.98 /)
259.256 + angmTM = acos(mTM)/rad ; angles: correlation labels
259.257 + radmTM = xyMax*(1.-(1.-tmEnd)*0.5) ; radius end: minor TM
259.258 +
259.259 + dum7 = new(dimsizes(mTM),graphic)
259.260 +
259.261 + do i=0,dimsizes(mTM)-1 ; manually add tm
259.262 + xTM(0) = xyMax*cos(angmTM(i)*rad) ; minor tickmarks
259.263 + yTM(0) = xyMax*sin(angmTM(i)*rad)
259.264 + xTM(1) = radmTM*cos(angmTM(i)*rad)
259.265 + yTM(1) = radmTM*sin(angmTM(i)*rad)
259.266 + dum7(i) = gsn_add_polyline(wks,taylor,xTM,yTM,plRes)
259.267 + end do
259.268 + ; added for Wanli
259.269 + if (rOpts .and. isatt(rOpts,"ccRays") ) then
259.270 + angRL = acos(rOpts@ccRays)/rad ; angles: radial lines
259.271 +
259.272 + rlRes = True
259.273 + rlRes@xyDashPattern = 4 ; line pattern
259.274 + rlRes@xyLineThicknessF = 1 ; choose line thickness
259.275 +
259.276 + dum8 = new(dimsizes(angRL),graphic)
259.277 + do i=0,dimsizes(angRL)-1
259.278 + xRL = xyMax*cos(angRL(i)*rad)
259.279 + yRL = xyMax*sin(angRL(i)*rad)
259.280 + dum8(i) = gsn_add_polyline(wks,taylor,(/0, xRL /),(/0, yRL /),rlRes)
259.281 + end do
259.282 + taylor@$unique_string("dum")$ = dum8
259.283 + end if
259.284 +
259.285 +; ----------------------------------------------------------------
259.286 +; Part 3:
259.287 +; Concentric about 1.0 on XB axis
259.288 +; I think this is correct. Still test mode.
259.289 +; ----------------------------------------------------------------
259.290 + if (rOpts .and. isatt(rOpts,"centerDiffRMS") \
259.291 + .and. rOpts@centerDiffRMS) then
259.292 + respl = True ; polyline mods desired
259.293 + respl@gsLineThicknessF = 1.0 ; line thickness
259.294 + respl@gsLineColor = "Black" ; line color
259.295 + respl@gsLineDashPattern = 2 ; short dash lines
259.296 +
259.297 + dx = 0.25
259.298 + ncon = 4 ; 0.75, 0.50, 0.25, 0.0
259.299 + npts = 100 ; arbitrary
259.300 + ang = fspan(180,360,npts)*rad
259.301 +
259.302 + dum9 = new(ncon,graphic)
259.303 +
259.304 + do n=1,ncon
259.305 + rr = n*dx ; radius from 1.0 [OBS] abscissa
259.306 + xx = 1. + rr*cos(ang)
259.307 + yy = fabs( rr*sin(ang) )
259.308 + if (n.le.2) then
259.309 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx,yy,respl)
259.310 + end if
259.311 + if (n.eq.3) then
259.312 + n3 = floattointeger( 0.77*npts )
259.313 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx(0:n3),yy(0:n3),respl)
259.314 + end if
259.315 + if (n.eq.4) then
259.316 + n4 = floattointeger( 0.61*npts )
259.317 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx(0:n4),yy(0:n4),respl)
259.318 + end if
259.319 + end do
259.320 + delete(ang)
259.321 + delete(xx)
259.322 + delete(yy)
259.323 + taylor@$unique_string("dum")$ = dum9
259.324 +
259.325 + end if
259.326 +; ---------------------------------------------------------------
259.327 +; Part 4:
259.328 +; generic resources that will be applied to all users data points
259.329 +; of course, these can be changed
259.330 +; http://www.ncl.ucar.edu/Document/Graphics/Resources/gs.shtml
259.331 +; ---------------------------------------------------------------
259.332 + if (rOpts .and. isatt(rOpts,"Markers")) then
259.333 + Markers = rOpts@Markers
259.334 + else
259.335 + Markers = (/ 4, 6, 8, 0, 9, 12, 7, 2, 11, 16/) ; Marker Indices
259.336 + end if
259.337 +
259.338 + if (rOpts .and. isatt(rOpts,"Colors")) then
259.339 + Colors = rOpts@Colors
259.340 + else
259.341 + Colors = (/ "red", "blue", "green", "cyan", "orange" \
259.342 + , "torquoise", "brown", "yellow", "purple", "black"/)
259.343 + end if
259.344 +
259.345 + if (rOpts .and. isatt(rOpts,"gsMarkerThicknessF")) then
259.346 + gsMarkerThicknessF = rOpts@gsMarkerThicknessF
259.347 + else
259.348 + gsMarkerThicknessF = 1.0
259.349 + end if
259.350 +
259.351 + if (rOpts .and. isatt(rOpts,"gsMarkerSizeF")) then
259.352 + gsMarkerSizeF = rOpts@gsMarkerSizeF
259.353 + else
259.354 + gsMarkerSizeF = 0.0085 ; Default: 0.007
259.355 + end if
259.356 +
259.357 + gsRes = True
259.358 + gsRes@gsMarkerThicknessF = gsMarkerThicknessF ; default=1.0
259.359 + gsRes@gsMarkerSizeF = gsMarkerSizeF ; Default: 0.007
259.360 +
259.361 + ptRes = True ; text options for points
259.362 + ptRes@txJust = "BottomCenter"; Default="CenterCenter".
259.363 + ptRes@txFontThicknessF = 1.2 ; default=1.00
259.364 + ptRes@txFontHeightF = 0.0125 ; default=0.05
259.365 + if (rOpts .and. isatt(rOpts,"txFontHeightF")) then
259.366 + ptRes@txFontHeightF = rOpts@txFontHeightF
259.367 + end if
259.368 +
259.369 + markerTxYOffset = 0.0175 ; default
259.370 + if (rOpts .and. isatt(rOpts,"markerTxYOffset")) then
259.371 + markerTxYOffset = rOpts@markerTxYOffset ; user defined offset
259.372 + end if
259.373 +
259.374 + dum10 = new((nCase*nVar),graphic)
259.375 + dum11 = dum10
259.376 +
259.377 + do n=0,nCase-1
259.378 + gsRes@gsMarkerIndex = Markers(n) ; marker style (+)
259.379 + gsRes@gsMarkerColor = Colors(n) ; marker color
259.380 + ptRes@txFontColor = gsRes@gsMarkerColor
259.381 + do i=0,nVar-1
259.382 + dum10(n*nVar+i) = gsn_add_polymarker(wks,taylor,X(n,i),Y(n,i),gsRes)
259.383 +; dum11(n*nVar+i) = gsn_add_text(wks,taylor,(i+1),X(n,i),Y(n,i)+markerTxYOffset,ptRes)
259.384 + end do
259.385 + end do
259.386 +
259.387 +; ---------------------------------------------------------------
259.388 +; Part 5: ; add case legend and variable labels
259.389 +; ---------------------------------------------------------------
259.390 +
259.391 + if (rOpts .and. isatt(rOpts,"caseLabels")) then
259.392 +
259.393 + if (isatt(rOpts,"caseLabelsFontHeightF")) then
259.394 + caseLabelsFontHeightF = rOpts@caseLabelsFontHeightF
259.395 + else
259.396 + caseLabelsFontHeightF = 0.05
259.397 + end if
259.398 +
259.399 + lgres = True
259.400 + lgres@lgMarkerColors = Colors ; colors of markers
259.401 + lgres@lgMarkerIndexes = Markers ; Markers
259.402 + lgres@lgMarkerSizeF = gsMarkerSizeF ; Marker size
259.403 + lgres@lgItemType = "Markers" ; draw markers only
259.404 + lgres@lgLabelFontHeightF = caseLabelsFontHeightF ; font height of legend case labels
259.405 +
259.406 + if (isatt(rOpts,"legendWidth")) then
259.407 + lgres@vpWidthF = rOpts@legendWidth
259.408 + else
259.409 + lgres@vpWidthF = 0.15 ; width of legend (NDC)
259.410 + end if
259.411 +
259.412 + if (isatt(rOpts,"legendHeight")) then
259.413 + lgres@vpHeightF = rOpts@legendHeight
259.414 + else
259.415 + lgres@vpHeightF = 0.030*nCase ; height of legend (NDC)
259.416 + end if
259.417 +
259.418 + lgres@lgPerimOn = False ; turn off perimeter
259.419 + nModel = dimsizes( rOpts@caseLabels )
259.420 + lbid = gsn_create_legend(wks,nModel,rOpts@caseLabels,lgres)
259.421 +
259.422 + amres = True
259.423 + amres@amParallelPosF = 0.35
259.424 + amres@amOrthogonalPosF = -0.35
259.425 + annoid1 = gsn_add_annotation(taylor,lbid,amres) ; add legend to plot
259.426 + end if
259.427 +
259.428 + if (rOpts .and. isatt(rOpts,"varLabels")) then
259.429 + nVar = dimsizes(rOpts@varLabels)
259.430 +
259.431 + if (isatt(rOpts,"varLabelsFontHeightF")) then
259.432 + varLabelsFontHeightF = rOpts@varLabelsFontHeightF
259.433 + else
259.434 + varLabelsFontHeightF = 0.013
259.435 + end if
259.436 +
259.437 + txres = True
259.438 + txres@txFontHeightF = varLabelsFontHeightF
259.439 + txres@txJust = "CenterLeft" ; justify to the center left
259.440 +
259.441 + ;delta_y = 0.02
259.442 + delta_y = 0.06
259.443 + if (rOpts .and. isatt(rOpts,"varLabelsYloc")) then
259.444 + ys = rOpts@varLabelsYloc ; user specified
259.445 + else
259.446 + ys = max( (/nVar*delta_y , 0.30/) )
259.447 + end if
259.448 +
259.449 +
259.450 + do i = 1,nVar
259.451 + if (i.eq.1) then
259.452 + dum12 = new(nVar,graphic)
259.453 + end if
259.454 +
259.455 + dum12(i-1) = gsn_add_text(wks,taylor,i+" - "+rOpts@varLabels(i-1), .125,ys,txres)
259.456 + ys = ys- delta_y
259.457 + end do
259.458 +
259.459 + taylor@$unique_string("dum")$ = dum12
259.460 + end if
259.461 +
259.462 + taylor@$unique_string("dum")$ = dum0 ; x-axis
259.463 + taylor@$unique_string("dum")$ = dum1 ; y-axis
259.464 + taylor@$unique_string("dum")$ = dum2 ; 1.0 std curve
259.465 + taylor@$unique_string("dum")$ = dum5 ; labels [COR]
259.466 + taylor@$unique_string("dum")$ = dum6 ; major tm [COR]
259.467 + taylor@$unique_string("dum")$ = dum7 ; minor tm
259.468 + taylor@$unique_string("dum")$ = dum10 ; markers
259.469 + taylor@$unique_string("dum")$ = dum11 ; text
259.470 +
259.471 + if (.not.isatt(rOpts,"taylorDraw") .or. \
259.472 + (isatt(rOpts,"taylorDraw") .and. rOpts@taylorDraw)) then
259.473 + draw(taylor)
259.474 + end if
259.475 + if (.not.isatt(rOpts,"taylorFrame") .or. \
259.476 + (isatt(rOpts,"taylorFrame") .and. rOpts@taylorFrame)) then
259.477 + frame(wks)
259.478 + end if
259.479 + return(taylor)
259.480 +end
259.481 +
260.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
260.2 +++ b/taylor/taylor_diagram.ncl.0 Mon Jan 26 22:08:20 2009 -0500
260.3 @@ -0,0 +1,478 @@
260.4 +function taylor_diagram (wks:graphic ,RATIO[*][*]:numeric, CC[*][*]:numeric \
260.5 + ,rOpts:logical)
260.6 +;--------------------------------------------------------------------
260.7 +; This version of taylor_diagram supports "paneling"
260.8 +; It requires NCL version 4.2.0.a034 because it uses "gsn_create_legend"
260.9 +;--------------------------------------------------------------------
260.10 +
260.11 +;
260.12 +; Generate a Taylor Diagram:
260.13 +; Generate Multiple Aspects of Model Performance in a Single Diagram
260.14 +; Taylor, K. E., J. Geophys. Res., 106, D7, 7183-7192, 2001
260.15 +;
260.16 +; An example:
260.17 +; http://www.grida.no/climate/ipcc_tar/wg1/fig8-4.htm
260.18 +;
260.19 +; This expects one or more datasets. The left dimension
260.20 +; is the number of datasets. The rightmost is the number of pts.
260.21 +;
260.22 +; Markers are at:
260.23 +; http://www.ncl.ucar.edu/Document/Graphics/Resources/gs.shtml
260.24 +;
260.25 +; By default, the function can handle up to 10 variable comparisons..
260.26 +; To expand ... modify the 'Colors' and 'Markers' attributes.
260.27 +; The user can change / add some default settings.
260.28 +;
260.29 +; The defaults that the user can modify:
260.30 +;
260.31 +; rOpts = True
260.32 +; ; 'made-up' resources
260.33 +; rOpts@Colors = (/ "blue" , "red", "green", "cyan", "black" \
260.34 +; , "torquoise", "brown", "yellow"/)
260.35 +; rOpts@Markers = (/ 2, 3, 6, 14, 9, 12, 7, 4/) ; Marker Indices
260.36 +; rOpts@markerTxOffset = 0.0175 ; offset for text above marker
260.37 +; rOpts@stnRad = (/ 1. /) ; (/ 0.50, 0.75, 1.5 /)
260.38 +; rOpts@centerDiffRMS = False ; True mean draw additional radii from REF
260.39 +; rOpts@caseLabelsFontHeightF = 0.05
260.40 +; rOpts@varLabelsFontHeightF = 0.013
260.41 +; rOpts@varLabelsYloc = 0.65
260.42 +; rOpts@legendWidth = 0.015
260.43 +; rOpts@legendHeight = 0.030*nCase
260.44 +; rOpts@taylorDraw = True
260.45 +; rOpts@taylorFrame = True
260.46 +;
260.47 +; ; standard NCL resources
260.48 +; rOpts@tiMainString = "Taylor" ; not using title makes plot bigger
260.49 +; rOpts@gsMarkerSizeF = 0.0085 ; marker size
260.50 +; rOpts@gsMarkerThicknessF = 1.0
260.51 +; rOpts@txFontHeightF = 0.0125 ; text size
260.52 +; rOpts@tiMainFontHeightF = 0.0225 ; tiMainString size
260.53 +;
260.54 +; It returns to the user a graphic object containing the
260.55 +; Taylor background and plotted x/y pts.
260.56 +; This graphic object contains a simple Taylor background appropriate
260.57 +; for standardized data and the markers for the datasets.
260.58 +; ==================================================================
260.59 +; This version allows paneling:
260.60 +; The 'cumbersome' "dum" variables were added by
260.61 +; Adam Phillips to allow paneling via "gsn_add_?".
260.62 +; ==================================================================
260.63 +begin
260.64 + dimR = dimsizes(RATIO)
260.65 + nCase = dimR(0) ; # of cases [models]
260.66 + nVar = dimR(1) ; # of variables
260.67 +
260.68 + ; x/y coordinates for plotting
260.69 + X = new ( (/nCase,nVar/) , typeof(RATIO) )
260.70 + Y = new ( (/nCase,nVar/) , typeof(RATIO) )
260.71 +
260.72 + do nc=0,nCase-1
260.73 + angle = acos( CC(nc,:) ) ; array operation
260.74 + X(nc,:) = RATIO(nc,:)*cos( angle )
260.75 + Y(nc,:) = RATIO(nc,:)*sin( angle )
260.76 + end do
260.77 +
260.78 + xyMin = 0.
260.79 + xyOne = 1.00
260.80 + xyMax = 1.65
260.81 + xyMax_Panel = xyMax+ 0.10 ; paneling purposes
260.82 +
260.83 + if (rOpts .and. isatt(rOpts,"txFontHeightF")) then
260.84 + FontHeightF = rOpts@txFontHeightF ; user wants to specify size
260.85 + else
260.86 + FontHeightF = 0.0175
260.87 + end if
260.88 +
260.89 +; ----------------------------------------------------------------
260.90 +; Part 1:
260.91 +; base plot: Based upon request of Mark Stevens
260.92 +; basic x-y and draw the 1.0 observed and the outer curve at 1.65
260.93 +; ----------------------------------------------------------------
260.94 +
260.95 + rxy = True
260.96 + rxy@gsnDraw = False
260.97 + rxy@gsnFrame = False
260.98 + rxy@vpHeightF = 0.65
260.99 + rxy@vpWidthF = 0.65
260.100 + rxy@tmYLBorderOn = False
260.101 + rxy@tmXBBorderOn = False
260.102 +
260.103 + rxy@tiYAxisString = "Standardized Deviations (Normalized)"
260.104 + rxy@tiYAxisFontHeightF= FontHeightF ; default=0.025
260.105 +
260.106 + rxy@tmXBMode = "Explicit"
260.107 + rxy@tmXBValues = (/0.0,0.25,0.50,0.75,1.00,1.25,1.5/) ; major tm
260.108 + ; default "OBS" or "REF"
260.109 + ;rxy@tmXBLabels = (/"0.00","0.25","0.50","0.75","REF" ,"1.25","1.50"/)
260.110 + rxy@tmXBLabels = (/" ","0.25","0.50","0.75","REF" ,"1.25","1.50"/)
260.111 + if (rOpts .and. isatt(rOpts,"OneX") ) then ; eg: rOpts@OneX="1.00"
260.112 + ;rxy@tmXBLabels = (/"0.00","0.25","0.50","0.75",rOpts@OneX,"1.25","1.50"/)
260.113 + rxy@tmXBLabels = (/" ","0.25","0.50","0.75",rOpts@OneX,"1.25","1.50"/)
260.114 + end if
260.115 +
260.116 + rxy@tmXBMajorLengthF = 0.015 ; default=0.02 for a vpHeightF=0.6
260.117 + rxy@tmXBLabelFontHeightF = FontHeightF
260.118 + rxy@tmXBMinorOn = False
260.119 + rxy@trXMaxF = xyMax_Panel
260.120 +
260.121 + rxy@tmYLMode = "Manual"
260.122 + rxy@tmYLMinorOn = False
260.123 + rxy@tmYLMajorLengthF = rxy@tmXBMajorLengthF
260.124 + rxy@tmYLLabelFontHeightF = FontHeightF
260.125 + rxy@tmYLMode = "Explicit"
260.126 + rxy@tmYLValues = (/0.0, .25,0.50, 0.75, 1.00, 1.25, 1.5/) ; major tm
260.127 + rxy@tmYLLabels = (/"0.00","0.25","0.50","0.75","1.00","1.25","1.50"/)
260.128 + ;rxy@tmYLLabels = (/" ","0.25","0.50","0.75","1.00","1.25","1.50"/)
260.129 + rxy@trYMaxF = xyMax_Panel
260.130 +
260.131 + rxy@tmYRBorderOn = False
260.132 + rxy@tmYROn = False ; Turn off right tick marks.
260.133 +
260.134 + rxy@tmXTBorderOn = False
260.135 + rxy@tmXTOn = False ; Turn off right tick marks.
260.136 +
260.137 + rxy@xyDashPatterns = (/ 0 /) ; line characteristics (dash,solid)
260.138 + rxy@xyLineThicknesses = (/ 2./) ; choose line thickness
260.139 +
260.140 + rxy@gsnFrame = False ; Don't advance the frame.
260.141 +
260.142 + ; create outer 'correlation axis'
260.143 + npts = 200 ; arbitrary
260.144 + xx = fspan(xyMin,xyMax,npts)
260.145 + yy = sqrt(xyMax^2 - xx^2 ) ; outer correlation line (xyMax)
260.146 +
260.147 + sLabels = (/"0.0","0.1","0.2","0.3","0.4","0.5","0.6" \ ; correlation labels
260.148 + ,"0.7","0.8","0.9","0.95","0.99","1.0" /); also, major tm
260.149 + cLabels = stringtofloat(sLabels)
260.150 + rad = 4.*atan(1.0)/180.
260.151 + angC = acos(cLabels)/rad ; angles: correlation labels
260.152 +
260.153 + if (rOpts .and. isatt(rOpts,"tiMainString")) then
260.154 + rxy@tiMainString = rOpts@tiMainString
260.155 + ;rxy@tiMainOffsetYF = 0.015 ; default 0.0
260.156 + if (isatt(rOpts,"tiMainFontHeightF")) then
260.157 + rxy@tiMainFontHeightF = rOpts@tiMainFontHeightF
260.158 + else
260.159 + rxy@tiMainFontHeightF = 0.0225 ; default 0.025
260.160 + end if
260.161 + end if
260.162 +;;if (rOpts .and. isatt(rOpts,"gsnCenterString")) then
260.163 +;; rxy@gsnCenterString = rOpts@gsnCenterString ; only gsn_csm_xy
260.164 +;;end if
260.165 +
260.166 + taylor = gsn_xy(wks,xx,yy,rxy) ; Create and draw XY plot.
260.167 +
260.168 + rsrRes = True
260.169 + rsrRes@gsLineThicknessF = rxy@xyLineThicknesses(0) ; line thickness
260.170 + rsrRes@gsLineDashPattern = 0 ; solid line pattern
260.171 + ; draw x and y to xyMax
260.172 + dum0 = gsn_add_polyline(wks,taylor,(/0., 0. /),(/0.,xyMax/), rsrRes)
260.173 + dum1 = gsn_add_polyline(wks,taylor,(/0.,xyMax/),(/0., 0. /), rsrRes)
260.174 +
260.175 + xx = fspan(xyMin, xyOne ,npts) ; draw 1.0 standard radius
260.176 + yy = sqrt(xyOne - xx^2)
260.177 + rsrRes@gsLineDashPattern = 1 ; dashed line pattern
260.178 + rsrRes@gsLineThicknessF = rxy@xyLineThicknesses(0) ; line thickness
260.179 + dum2 = gsn_add_polyline(wks,taylor,xx,yy, rsrRes)
260.180 + delete(xx)
260.181 + delete(yy)
260.182 +
260.183 + if (rOpts .and. isatt(rOpts,"stnRad") ) then
260.184 + rsrRes@gsLineThicknessF = 1 ; rxy@xyLineThicknesses(0)
260.185 + nStnRad = dimsizes(rOpts@stnRad)
260.186 +
260.187 + dum3 = new(nStnRad,graphic)
260.188 + do n=0,nStnRad-1
260.189 + rr = rOpts@stnRad(n)
260.190 + xx = fspan(xyMin, rr ,npts)
260.191 + yy = sqrt(rr^2 - xx^2)
260.192 + dum3(n) = gsn_add_polyline(wks,taylor,xx,yy, rsrRes)
260.193 + end do
260.194 + taylor@$unique_string("dum")$ = dum3
260.195 +
260.196 + delete(xx)
260.197 + delete(yy)
260.198 + end if
260.199 +
260.200 + getvalues taylor ; get style info from taylor
260.201 + "tmYLLabelFont" : tmYLLabelFont ; use for correlation axis
260.202 + "tmYLLabelFontHeightF" : tmYLLabelFontHeightF
260.203 + end getvalues
260.204 +
260.205 +; ----------------------------------------------------------------
260.206 +; Part 2:
260.207 +; Correlation labels
260.208 +; ----------------------------------------------------------------
260.209 + radC = xyMax ; for correlation labels
260.210 + xC = radC*cos(angC*rad)
260.211 + yC = radC*sin(angC*rad)
260.212 +; added to get some separation
260.213 + xC = xC + 0.020*cos(rad*angC)
260.214 + yC = yC + 0.060*sin(rad*angC)
260.215 +
260.216 + txRes = True ; text mods desired
260.217 + txRes@txFontHeightF = FontHeightF ; match YL
260.218 + txRes@tmYLLabelFont = tmYLLabelFont ; match YL
260.219 + txRes@txAngleF = -45.
260.220 + if (.not.isatt(rOpts,"drawCorLabel") .or. rOpts@drawCorLabel) then
260.221 + dum4 = gsn_add_text(wks,taylor,"Correlation",1.30,1.30,txRes)
260.222 + taylor@$unique_string("dum")$ = dum4
260.223 + end if
260.224 + txRes@txAngleF = 0.0
260.225 + txRes@txFontHeightF = FontHeightF*0.50 ; bit smaller
260.226 +
260.227 +;;dum0 = gsn_add_text(wks,taylor,"OBSERVED",1.00,0.075,txRes)
260.228 +
260.229 + plRes = True
260.230 + plRes@gsLineThicknessF = 2.
260.231 +
260.232 + txRes@txJust = "CenterLeft" ; Default="CenterCenter".
260.233 + txRes@txFontHeightF = FontHeightF ; match YL
260.234 + ;txRes@txBackgroundFillColor = "white"
260.235 +
260.236 + tmEnd = 0.975
260.237 + radTM = xyMax*tmEnd ; radius end: major TM
260.238 + xTM = new( 2 , "float")
260.239 + yTM = new( 2 , "float")
260.240 +
260.241 + dum5 = new(dimsizes(sLabels),graphic)
260.242 + dum6 = dum5
260.243 +
260.244 + do i=0,dimsizes(sLabels)-1 ; Loop to draw strings
260.245 + txRes@txAngleF = angC(i)
260.246 + dum5(i) = gsn_add_text(wks, taylor, sLabels(i),xC(i),yC(i),txRes) ; cor label
260.247 + xTM(0) = xyMax*cos(angC(i)*rad) ; major tickmarks at
260.248 + yTM(0) = xyMax*sin(angC(i)*rad) ; correlation labels
260.249 + xTM(1) = radTM*cos(angC(i)*rad)
260.250 + yTM(1) = radTM*sin(angC(i)*rad)
260.251 + dum6(i) = gsn_add_polyline(wks,taylor,xTM,yTM,plRes)
260.252 + end do
260.253 + ; minor tm locations
260.254 + mTM = (/0.05,0.15,0.25,0.35,0.45,0.55,0.65 \
260.255 + ,0.75,0.85,0.91,0.92,0.93,0.94,0.96,0.97,0.98 /)
260.256 + angmTM = acos(mTM)/rad ; angles: correlation labels
260.257 + radmTM = xyMax*(1.-(1.-tmEnd)*0.5) ; radius end: minor TM
260.258 +
260.259 + dum7 = new(dimsizes(mTM),graphic)
260.260 +
260.261 + do i=0,dimsizes(mTM)-1 ; manually add tm
260.262 + xTM(0) = xyMax*cos(angmTM(i)*rad) ; minor tickmarks
260.263 + yTM(0) = xyMax*sin(angmTM(i)*rad)
260.264 + xTM(1) = radmTM*cos(angmTM(i)*rad)
260.265 + yTM(1) = radmTM*sin(angmTM(i)*rad)
260.266 + dum7(i) = gsn_add_polyline(wks,taylor,xTM,yTM,plRes)
260.267 + end do
260.268 + ; added for Wanli
260.269 + if (rOpts .and. isatt(rOpts,"ccRays") ) then
260.270 + angRL = acos(rOpts@ccRays)/rad ; angles: radial lines
260.271 +
260.272 + rlRes = True
260.273 + rlRes@xyDashPattern = 4 ; line pattern
260.274 + rlRes@xyLineThicknessF = 1 ; choose line thickness
260.275 +
260.276 + dum8 = new(dimsizes(angRL),graphic)
260.277 + do i=0,dimsizes(angRL)-1
260.278 + xRL = xyMax*cos(angRL(i)*rad)
260.279 + yRL = xyMax*sin(angRL(i)*rad)
260.280 + dum8(i) = gsn_add_polyline(wks,taylor,(/0, xRL /),(/0, yRL /),rlRes)
260.281 + end do
260.282 + taylor@$unique_string("dum")$ = dum8
260.283 + end if
260.284 +
260.285 +; ----------------------------------------------------------------
260.286 +; Part 3:
260.287 +; Concentric about 1.0 on XB axis
260.288 +; I think this is correct. Still test mode.
260.289 +; ----------------------------------------------------------------
260.290 + if (rOpts .and. isatt(rOpts,"centerDiffRMS") \
260.291 + .and. rOpts@centerDiffRMS) then
260.292 + respl = True ; polyline mods desired
260.293 + respl@gsLineThicknessF = 1.0 ; line thickness
260.294 + respl@gsLineColor = "Black" ; line color
260.295 + respl@gsLineDashPattern = 2 ; short dash lines
260.296 +
260.297 + dx = 0.25
260.298 + ncon = 4 ; 0.75, 0.50, 0.25, 0.0
260.299 + npts = 100 ; arbitrary
260.300 + ang = fspan(180,360,npts)*rad
260.301 +
260.302 + dum9 = new(ncon,graphic)
260.303 +
260.304 + do n=1,ncon
260.305 + rr = n*dx ; radius from 1.0 [OBS] abscissa
260.306 + xx = 1. + rr*cos(ang)
260.307 + yy = fabs( rr*sin(ang) )
260.308 + if (n.le.2) then
260.309 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx,yy,respl)
260.310 + end if
260.311 + if (n.eq.3) then
260.312 + n3 = floattointeger( 0.77*npts )
260.313 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx(0:n3),yy(0:n3),respl)
260.314 + end if
260.315 + if (n.eq.4) then
260.316 + n4 = floattointeger( 0.61*npts )
260.317 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx(0:n4),yy(0:n4),respl)
260.318 + end if
260.319 + end do
260.320 + delete(ang)
260.321 + delete(xx)
260.322 + delete(yy)
260.323 + taylor@$unique_string("dum")$ = dum9
260.324 +
260.325 + end if
260.326 +; ---------------------------------------------------------------
260.327 +; Part 4:
260.328 +; generic resources that will be applied to all users data points
260.329 +; of course, these can be changed
260.330 +; http://www.ncl.ucar.edu/Document/Graphics/Resources/gs.shtml
260.331 +; ---------------------------------------------------------------
260.332 + if (rOpts .and. isatt(rOpts,"Markers")) then
260.333 + Markers = rOpts@Markers
260.334 + else
260.335 + Markers = (/ 4, 6, 8, 0, 9, 12, 7, 2, 11, 16/) ; Marker Indices
260.336 + end if
260.337 +
260.338 + if (rOpts .and. isatt(rOpts,"Colors")) then
260.339 + Colors = rOpts@Colors
260.340 + else
260.341 + Colors = (/ "red", "blue", "green", "cyan", "orange" \
260.342 + , "torquoise", "brown", "yellow", "purple", "black"/)
260.343 + end if
260.344 +
260.345 + if (rOpts .and. isatt(rOpts,"gsMarkerThicknessF")) then
260.346 + gsMarkerThicknessF = rOpts@gsMarkerThicknessF
260.347 + else
260.348 + gsMarkerThicknessF = 1.0
260.349 + end if
260.350 +
260.351 + if (rOpts .and. isatt(rOpts,"gsMarkerSizeF")) then
260.352 + gsMarkerSizeF = rOpts@gsMarkerSizeF
260.353 + else
260.354 + gsMarkerSizeF = 0.0085 ; Default: 0.007
260.355 + end if
260.356 +
260.357 + gsRes = True
260.358 + gsRes@gsMarkerThicknessF = gsMarkerThicknessF ; default=1.0
260.359 + gsRes@gsMarkerSizeF = gsMarkerSizeF ; Default: 0.007
260.360 +
260.361 + ptRes = True ; text options for points
260.362 + ptRes@txJust = "BottomCenter"; Default="CenterCenter".
260.363 + ptRes@txFontThicknessF = 1.2 ; default=1.00
260.364 + ptRes@txFontHeightF = 0.0125 ; default=0.05
260.365 + if (rOpts .and. isatt(rOpts,"txFontHeightF")) then
260.366 + ptRes@txFontHeightF = rOpts@txFontHeightF
260.367 + end if
260.368 +
260.369 + markerTxYOffset = 0.0175 ; default
260.370 + if (rOpts .and. isatt(rOpts,"markerTxYOffset")) then
260.371 + markerTxYOffset = rOpts@markerTxYOffset ; user defined offset
260.372 + end if
260.373 +
260.374 + dum10 = new((nCase*nVar),graphic)
260.375 + dum11 = dum10
260.376 +
260.377 + do n=0,nCase-1
260.378 + gsRes@gsMarkerIndex = Markers(n) ; marker style (+)
260.379 + gsRes@gsMarkerColor = Colors(n) ; marker color
260.380 + ptRes@txFontColor = gsRes@gsMarkerColor
260.381 + do i=0,nVar-1
260.382 + dum10(n*nVar+i) = gsn_add_polymarker(wks,taylor,X(n,i),Y(n,i),gsRes)
260.383 + dum11(n*nVar+i) = gsn_add_text(wks,taylor,(i+1),X(n,i),Y(n,i)+markerTxYOffset,ptRes)
260.384 + end do
260.385 + end do
260.386 +
260.387 +; ---------------------------------------------------------------
260.388 +; Part 5: ; add case legend and variable labels
260.389 +; ---------------------------------------------------------------
260.390 +
260.391 + if (rOpts .and. isatt(rOpts,"caseLabels")) then
260.392 +
260.393 + if (isatt(rOpts,"caseLabelsFontHeightF")) then
260.394 + caseLabelsFontHeightF = rOpts@caseLabelsFontHeightF
260.395 + else
260.396 + caseLabelsFontHeightF = 0.05
260.397 + end if
260.398 +
260.399 + lgres = True
260.400 + lgres@lgMarkerColors = Colors ; colors of markers
260.401 + lgres@lgMarkerIndexes = Markers ; Markers
260.402 + lgres@lgMarkerSizeF = gsMarkerSizeF ; Marker size
260.403 + lgres@lgItemType = "Markers" ; draw markers only
260.404 + lgres@lgLabelFontHeightF = caseLabelsFontHeightF ; font height of legend case labels
260.405 +
260.406 + if (isatt(rOpts,"legendWidth")) then
260.407 + lgres@vpWidthF = rOpts@legendWidth
260.408 + else
260.409 + lgres@vpWidthF = 0.15 ; width of legend (NDC)
260.410 + end if
260.411 +
260.412 + if (isatt(rOpts,"legendHeight")) then
260.413 + lgres@vpHeightF = rOpts@legendHeight
260.414 + else
260.415 + lgres@vpHeightF = 0.030*nCase ; height of legend (NDC)
260.416 + end if
260.417 +
260.418 + lgres@lgPerimOn = False ; turn off perimeter
260.419 + nModel = dimsizes( rOpts@caseLabels )
260.420 + lbid = gsn_create_legend(wks,nModel,rOpts@caseLabels,lgres)
260.421 +
260.422 + amres = True
260.423 + amres@amParallelPosF = 0.35
260.424 + amres@amOrthogonalPosF = -0.35
260.425 + annoid1 = gsn_add_annotation(taylor,lbid,amres) ; add legend to plot
260.426 + end if
260.427 +
260.428 + if (rOpts .and. isatt(rOpts,"varLabels")) then
260.429 + nVar = dimsizes(rOpts@varLabels)
260.430 +
260.431 + if (isatt(rOpts,"varLabelsFontHeightF")) then
260.432 + varLabelsFontHeightF = rOpts@varLabelsFontHeightF
260.433 + else
260.434 + varLabelsFontHeightF = 0.013
260.435 + end if
260.436 +
260.437 + txres = True
260.438 + txres@txFontHeightF = varLabelsFontHeightF
260.439 + txres@txJust = "CenterLeft" ; justify to the center left
260.440 +
260.441 + ;delta_y = 0.02
260.442 + delta_y = 0.06
260.443 + if (rOpts .and. isatt(rOpts,"varLabelsYloc")) then
260.444 + ys = rOpts@varLabelsYloc ; user specified
260.445 + else
260.446 + ys = max( (/nVar*delta_y , 0.30/) )
260.447 + end if
260.448 +
260.449 +
260.450 + do i = 1,nVar
260.451 + if (i.eq.1) then
260.452 + dum12 = new(nVar,graphic)
260.453 + end if
260.454 +
260.455 + dum12(i-1) = gsn_add_text(wks,taylor,i+" - "+rOpts@varLabels(i-1), .125,ys,txres)
260.456 + ys = ys- delta_y
260.457 + end do
260.458 +
260.459 + taylor@$unique_string("dum")$ = dum12
260.460 + end if
260.461 +
260.462 + taylor@$unique_string("dum")$ = dum0 ; x-axis
260.463 + taylor@$unique_string("dum")$ = dum1 ; y-axis
260.464 + taylor@$unique_string("dum")$ = dum2 ; 1.0 std curve
260.465 + taylor@$unique_string("dum")$ = dum5 ; labels [COR]
260.466 + taylor@$unique_string("dum")$ = dum6 ; major tm [COR]
260.467 + taylor@$unique_string("dum")$ = dum7 ; minor tm
260.468 + taylor@$unique_string("dum")$ = dum10 ; markers
260.469 + taylor@$unique_string("dum")$ = dum11 ; text
260.470 +
260.471 + if (.not.isatt(rOpts,"taylorDraw") .or. \
260.472 + (isatt(rOpts,"taylorDraw") .and. rOpts@taylorDraw)) then
260.473 + draw(taylor)
260.474 + end if
260.475 + if (.not.isatt(rOpts,"taylorFrame") .or. \
260.476 + (isatt(rOpts,"taylorFrame") .and. rOpts@taylorFrame)) then
260.477 + frame(wks)
260.478 + end if
260.479 + return(taylor)
260.480 +end
260.481 +
261.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
261.2 +++ b/taylor/taylor_diagram.ncl.1 Mon Jan 26 22:08:20 2009 -0500
261.3 @@ -0,0 +1,479 @@
261.4 +function taylor_diagram (wks:graphic ,RATIO[*][*]:numeric, CC[*][*]:numeric \
261.5 + ,rOpts:logical)
261.6 +;--------------------------------------------------------------------
261.7 +; This version of taylor_diagram supports "paneling"
261.8 +; It requires NCL version 4.2.0.a034 because it uses "gsn_create_legend"
261.9 +;--------------------------------------------------------------------
261.10 +
261.11 +;
261.12 +; Generate a Taylor Diagram:
261.13 +; Generate Multiple Aspects of Model Performance in a Single Diagram
261.14 +; Taylor, K. E., J. Geophys. Res., 106, D7, 7183-7192, 2001
261.15 +;
261.16 +; An example:
261.17 +; http://www.grida.no/climate/ipcc_tar/wg1/fig8-4.htm
261.18 +;
261.19 +; This expects one or more datasets. The left dimension
261.20 +; is the number of datasets. The rightmost is the number of pts.
261.21 +;
261.22 +; Markers are at:
261.23 +; http://www.ncl.ucar.edu/Document/Graphics/Resources/gs.shtml
261.24 +;
261.25 +; By default, the function can handle up to 10 variable comparisons..
261.26 +; To expand ... modify the 'Colors' and 'Markers' attributes.
261.27 +; The user can change / add some default settings.
261.28 +;
261.29 +; The defaults that the user can modify:
261.30 +;
261.31 +; rOpts = True
261.32 +; ; 'made-up' resources
261.33 +; rOpts@Colors = (/ "blue" , "red", "green", "cyan", "black" \
261.34 +; , "torquoise", "brown", "yellow"/)
261.35 +; rOpts@Markers = (/ 2, 3, 6, 14, 9, 12, 7, 4/) ; Marker Indices
261.36 +; rOpts@markerTxOffset = 0.0175 ; offset for text above marker
261.37 +; rOpts@stnRad = (/ 1. /) ; (/ 0.50, 0.75, 1.5 /)
261.38 +; rOpts@centerDiffRMS = False ; True mean draw additional radii from REF
261.39 +; rOpts@caseLabelsFontHeightF = 0.05
261.40 +; rOpts@varLabelsFontHeightF = 0.013
261.41 +; rOpts@varLabelsYloc = 0.65
261.42 +; rOpts@legendWidth = 0.015
261.43 +; rOpts@legendHeight = 0.030*nCase
261.44 +; rOpts@taylorDraw = True
261.45 +; rOpts@taylorFrame = True
261.46 +;
261.47 +; ; standard NCL resources
261.48 +; rOpts@tiMainString = "Taylor" ; not using title makes plot bigger
261.49 +; rOpts@gsMarkerSizeF = 0.0085 ; marker size
261.50 +; rOpts@gsMarkerThicknessF = 1.0
261.51 +; rOpts@txFontHeightF = 0.0125 ; text size
261.52 +; rOpts@tiMainFontHeightF = 0.0225 ; tiMainString size
261.53 +;
261.54 +; It returns to the user a graphic object containing the
261.55 +; Taylor background and plotted x/y pts.
261.56 +; This graphic object contains a simple Taylor background appropriate
261.57 +; for standardized data and the markers for the datasets.
261.58 +; ==================================================================
261.59 +; This version allows paneling:
261.60 +; The 'cumbersome' "dum" variables were added by
261.61 +; Adam Phillips to allow paneling via "gsn_add_?".
261.62 +; ==================================================================
261.63 +begin
261.64 + dimR = dimsizes(RATIO)
261.65 + nCase = dimR(0) ; # of cases [models]
261.66 + nVar = dimR(1) ; # of variables
261.67 +
261.68 + ; x/y coordinates for plotting
261.69 + X = new ( (/nCase,nVar/) , typeof(RATIO) )
261.70 + Y = new ( (/nCase,nVar/) , typeof(RATIO) )
261.71 +
261.72 + do nc=0,nCase-1
261.73 + angle = acos( CC(nc,:) ) ; array operation
261.74 + X(nc,:) = RATIO(nc,:)*cos( angle )
261.75 + Y(nc,:) = RATIO(nc,:)*sin( angle )
261.76 + end do
261.77 +
261.78 + xyMin = 0.
261.79 + xyOne = 1.00
261.80 + xyMax = 1.65
261.81 + xyMax_Panel = xyMax+ 0.10 ; paneling purposes
261.82 +
261.83 + if (rOpts .and. isatt(rOpts,"txFontHeightF")) then
261.84 + FontHeightF = rOpts@txFontHeightF ; user wants to specify size
261.85 + else
261.86 + FontHeightF = 0.0175
261.87 + end if
261.88 +
261.89 +; ----------------------------------------------------------------
261.90 +; Part 1:
261.91 +; base plot: Based upon request of Mark Stevens
261.92 +; basic x-y and draw the 1.0 observed and the outer curve at 1.65
261.93 +; ----------------------------------------------------------------
261.94 +
261.95 + rxy = True
261.96 + rxy@gsnDraw = False
261.97 + rxy@gsnFrame = False
261.98 + rxy@vpHeightF = 0.65
261.99 + rxy@vpWidthF = 0.65
261.100 + rxy@tmYLBorderOn = False
261.101 + rxy@tmXBBorderOn = False
261.102 +
261.103 +; rxy@tiYAxisString = "Standardized Deviations (Normalized)"
261.104 + rxy@tiYAxisString = "Standardized Deviations"
261.105 + rxy@tiYAxisFontHeightF= FontHeightF ; default=0.025
261.106 +
261.107 + rxy@tmXBMode = "Explicit"
261.108 + rxy@tmXBValues = (/0.0,0.25,0.50,0.75,1.00,1.25,1.5/) ; major tm
261.109 + ; default "OBS" or "REF"
261.110 + ;rxy@tmXBLabels = (/"0.00","0.25","0.50","0.75","REF" ,"1.25","1.50"/)
261.111 + rxy@tmXBLabels = (/" ","0.25","0.50","0.75","REF" ,"1.25","1.50"/)
261.112 + if (rOpts .and. isatt(rOpts,"OneX") ) then ; eg: rOpts@OneX="1.00"
261.113 + ;rxy@tmXBLabels = (/"0.00","0.25","0.50","0.75",rOpts@OneX,"1.25","1.50"/)
261.114 + rxy@tmXBLabels = (/" ","0.25","0.50","0.75",rOpts@OneX,"1.25","1.50"/)
261.115 + end if
261.116 +
261.117 + rxy@tmXBMajorLengthF = 0.015 ; default=0.02 for a vpHeightF=0.6
261.118 + rxy@tmXBLabelFontHeightF = FontHeightF
261.119 + rxy@tmXBMinorOn = False
261.120 + rxy@trXMaxF = xyMax_Panel
261.121 +
261.122 + rxy@tmYLMode = "Manual"
261.123 + rxy@tmYLMinorOn = False
261.124 + rxy@tmYLMajorLengthF = rxy@tmXBMajorLengthF
261.125 + rxy@tmYLLabelFontHeightF = FontHeightF
261.126 + rxy@tmYLMode = "Explicit"
261.127 + rxy@tmYLValues = (/0.0, .25,0.50, 0.75, 1.00, 1.25, 1.5/) ; major tm
261.128 + rxy@tmYLLabels = (/"0.00","0.25","0.50","0.75","1.00","1.25","1.50"/)
261.129 + ;rxy@tmYLLabels = (/" ","0.25","0.50","0.75","1.00","1.25","1.50"/)
261.130 + rxy@trYMaxF = xyMax_Panel
261.131 +
261.132 + rxy@tmYRBorderOn = False
261.133 + rxy@tmYROn = False ; Turn off right tick marks.
261.134 +
261.135 + rxy@tmXTBorderOn = False
261.136 + rxy@tmXTOn = False ; Turn off right tick marks.
261.137 +
261.138 + rxy@xyDashPatterns = (/ 0 /) ; line characteristics (dash,solid)
261.139 + rxy@xyLineThicknesses = (/ 2./) ; choose line thickness
261.140 +
261.141 + rxy@gsnFrame = False ; Don't advance the frame.
261.142 +
261.143 + ; create outer 'correlation axis'
261.144 + npts = 200 ; arbitrary
261.145 + xx = fspan(xyMin,xyMax,npts)
261.146 + yy = sqrt(xyMax^2 - xx^2 ) ; outer correlation line (xyMax)
261.147 +
261.148 + sLabels = (/"0.0","0.1","0.2","0.3","0.4","0.5","0.6" \ ; correlation labels
261.149 + ,"0.7","0.8","0.9","0.95","0.99","1.0" /); also, major tm
261.150 + cLabels = stringtofloat(sLabels)
261.151 + rad = 4.*atan(1.0)/180.
261.152 + angC = acos(cLabels)/rad ; angles: correlation labels
261.153 +
261.154 + if (rOpts .and. isatt(rOpts,"tiMainString")) then
261.155 + rxy@tiMainString = rOpts@tiMainString
261.156 + ;rxy@tiMainOffsetYF = 0.015 ; default 0.0
261.157 + if (isatt(rOpts,"tiMainFontHeightF")) then
261.158 + rxy@tiMainFontHeightF = rOpts@tiMainFontHeightF
261.159 + else
261.160 + rxy@tiMainFontHeightF = 0.0225 ; default 0.025
261.161 + end if
261.162 + end if
261.163 +;;if (rOpts .and. isatt(rOpts,"gsnCenterString")) then
261.164 +;; rxy@gsnCenterString = rOpts@gsnCenterString ; only gsn_csm_xy
261.165 +;;end if
261.166 +
261.167 + taylor = gsn_xy(wks,xx,yy,rxy) ; Create and draw XY plot.
261.168 +
261.169 + rsrRes = True
261.170 + rsrRes@gsLineThicknessF = rxy@xyLineThicknesses(0) ; line thickness
261.171 + rsrRes@gsLineDashPattern = 0 ; solid line pattern
261.172 + ; draw x and y to xyMax
261.173 + dum0 = gsn_add_polyline(wks,taylor,(/0., 0. /),(/0.,xyMax/), rsrRes)
261.174 + dum1 = gsn_add_polyline(wks,taylor,(/0.,xyMax/),(/0., 0. /), rsrRes)
261.175 +
261.176 + xx = fspan(xyMin, xyOne ,npts) ; draw 1.0 standard radius
261.177 + yy = sqrt(xyOne - xx^2)
261.178 + rsrRes@gsLineDashPattern = 1 ; dashed line pattern
261.179 + rsrRes@gsLineThicknessF = rxy@xyLineThicknesses(0) ; line thickness
261.180 + dum2 = gsn_add_polyline(wks,taylor,xx,yy, rsrRes)
261.181 + delete(xx)
261.182 + delete(yy)
261.183 +
261.184 + if (rOpts .and. isatt(rOpts,"stnRad") ) then
261.185 + rsrRes@gsLineThicknessF = 1 ; rxy@xyLineThicknesses(0)
261.186 + nStnRad = dimsizes(rOpts@stnRad)
261.187 +
261.188 + dum3 = new(nStnRad,graphic)
261.189 + do n=0,nStnRad-1
261.190 + rr = rOpts@stnRad(n)
261.191 + xx = fspan(xyMin, rr ,npts)
261.192 + yy = sqrt(rr^2 - xx^2)
261.193 + dum3(n) = gsn_add_polyline(wks,taylor,xx,yy, rsrRes)
261.194 + end do
261.195 + taylor@$unique_string("dum")$ = dum3
261.196 +
261.197 + delete(xx)
261.198 + delete(yy)
261.199 + end if
261.200 +
261.201 + getvalues taylor ; get style info from taylor
261.202 + "tmYLLabelFont" : tmYLLabelFont ; use for correlation axis
261.203 + "tmYLLabelFontHeightF" : tmYLLabelFontHeightF
261.204 + end getvalues
261.205 +
261.206 +; ----------------------------------------------------------------
261.207 +; Part 2:
261.208 +; Correlation labels
261.209 +; ----------------------------------------------------------------
261.210 + radC = xyMax ; for correlation labels
261.211 + xC = radC*cos(angC*rad)
261.212 + yC = radC*sin(angC*rad)
261.213 +; added to get some separation
261.214 + xC = xC + 0.020*cos(rad*angC)
261.215 + yC = yC + 0.060*sin(rad*angC)
261.216 +
261.217 + txRes = True ; text mods desired
261.218 + txRes@txFontHeightF = FontHeightF ; match YL
261.219 + txRes@tmYLLabelFont = tmYLLabelFont ; match YL
261.220 + txRes@txAngleF = -45.
261.221 + if (.not.isatt(rOpts,"drawCorLabel") .or. rOpts@drawCorLabel) then
261.222 + dum4 = gsn_add_text(wks,taylor,"Correlation",1.30,1.30,txRes)
261.223 + taylor@$unique_string("dum")$ = dum4
261.224 + end if
261.225 + txRes@txAngleF = 0.0
261.226 + txRes@txFontHeightF = FontHeightF*0.50 ; bit smaller
261.227 +
261.228 +;;dum0 = gsn_add_text(wks,taylor,"OBSERVED",1.00,0.075,txRes)
261.229 +
261.230 + plRes = True
261.231 + plRes@gsLineThicknessF = 2.
261.232 +
261.233 + txRes@txJust = "CenterLeft" ; Default="CenterCenter".
261.234 + txRes@txFontHeightF = FontHeightF ; match YL
261.235 + ;txRes@txBackgroundFillColor = "white"
261.236 +
261.237 + tmEnd = 0.975
261.238 + radTM = xyMax*tmEnd ; radius end: major TM
261.239 + xTM = new( 2 , "float")
261.240 + yTM = new( 2 , "float")
261.241 +
261.242 + dum5 = new(dimsizes(sLabels),graphic)
261.243 + dum6 = dum5
261.244 +
261.245 + do i=0,dimsizes(sLabels)-1 ; Loop to draw strings
261.246 + txRes@txAngleF = angC(i)
261.247 + dum5(i) = gsn_add_text(wks, taylor, sLabels(i),xC(i),yC(i),txRes) ; cor label
261.248 + xTM(0) = xyMax*cos(angC(i)*rad) ; major tickmarks at
261.249 + yTM(0) = xyMax*sin(angC(i)*rad) ; correlation labels
261.250 + xTM(1) = radTM*cos(angC(i)*rad)
261.251 + yTM(1) = radTM*sin(angC(i)*rad)
261.252 + dum6(i) = gsn_add_polyline(wks,taylor,xTM,yTM,plRes)
261.253 + end do
261.254 + ; minor tm locations
261.255 + mTM = (/0.05,0.15,0.25,0.35,0.45,0.55,0.65 \
261.256 + ,0.75,0.85,0.91,0.92,0.93,0.94,0.96,0.97,0.98 /)
261.257 + angmTM = acos(mTM)/rad ; angles: correlation labels
261.258 + radmTM = xyMax*(1.-(1.-tmEnd)*0.5) ; radius end: minor TM
261.259 +
261.260 + dum7 = new(dimsizes(mTM),graphic)
261.261 +
261.262 + do i=0,dimsizes(mTM)-1 ; manually add tm
261.263 + xTM(0) = xyMax*cos(angmTM(i)*rad) ; minor tickmarks
261.264 + yTM(0) = xyMax*sin(angmTM(i)*rad)
261.265 + xTM(1) = radmTM*cos(angmTM(i)*rad)
261.266 + yTM(1) = radmTM*sin(angmTM(i)*rad)
261.267 + dum7(i) = gsn_add_polyline(wks,taylor,xTM,yTM,plRes)
261.268 + end do
261.269 + ; added for Wanli
261.270 + if (rOpts .and. isatt(rOpts,"ccRays") ) then
261.271 + angRL = acos(rOpts@ccRays)/rad ; angles: radial lines
261.272 +
261.273 + rlRes = True
261.274 + rlRes@xyDashPattern = 4 ; line pattern
261.275 + rlRes@xyLineThicknessF = 1 ; choose line thickness
261.276 +
261.277 + dum8 = new(dimsizes(angRL),graphic)
261.278 + do i=0,dimsizes(angRL)-1
261.279 + xRL = xyMax*cos(angRL(i)*rad)
261.280 + yRL = xyMax*sin(angRL(i)*rad)
261.281 + dum8(i) = gsn_add_polyline(wks,taylor,(/0, xRL /),(/0, yRL /),rlRes)
261.282 + end do
261.283 + taylor@$unique_string("dum")$ = dum8
261.284 + end if
261.285 +
261.286 +; ----------------------------------------------------------------
261.287 +; Part 3:
261.288 +; Concentric about 1.0 on XB axis
261.289 +; I think this is correct. Still test mode.
261.290 +; ----------------------------------------------------------------
261.291 + if (rOpts .and. isatt(rOpts,"centerDiffRMS") \
261.292 + .and. rOpts@centerDiffRMS) then
261.293 + respl = True ; polyline mods desired
261.294 + respl@gsLineThicknessF = 1.0 ; line thickness
261.295 + respl@gsLineColor = "Black" ; line color
261.296 + respl@gsLineDashPattern = 2 ; short dash lines
261.297 +
261.298 + dx = 0.25
261.299 + ncon = 4 ; 0.75, 0.50, 0.25, 0.0
261.300 + npts = 100 ; arbitrary
261.301 + ang = fspan(180,360,npts)*rad
261.302 +
261.303 + dum9 = new(ncon,graphic)
261.304 +
261.305 + do n=1,ncon
261.306 + rr = n*dx ; radius from 1.0 [OBS] abscissa
261.307 + xx = 1. + rr*cos(ang)
261.308 + yy = fabs( rr*sin(ang) )
261.309 + if (n.le.2) then
261.310 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx,yy,respl)
261.311 + end if
261.312 + if (n.eq.3) then
261.313 + n3 = floattointeger( 0.77*npts )
261.314 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx(0:n3),yy(0:n3),respl)
261.315 + end if
261.316 + if (n.eq.4) then
261.317 + n4 = floattointeger( 0.61*npts )
261.318 + dum9(n-1) = gsn_add_polyline(wks,taylor,xx(0:n4),yy(0:n4),respl)
261.319 + end if
261.320 + end do
261.321 + delete(ang)
261.322 + delete(xx)
261.323 + delete(yy)
261.324 + taylor@$unique_string("dum")$ = dum9
261.325 +
261.326 + end if
261.327 +; ---------------------------------------------------------------
261.328 +; Part 4:
261.329 +; generic resources that will be applied to all users data points
261.330 +; of course, these can be changed
261.331 +; http://www.ncl.ucar.edu/Document/Graphics/Resources/gs.shtml
261.332 +; ---------------------------------------------------------------
261.333 + if (rOpts .and. isatt(rOpts,"Markers")) then
261.334 + Markers = rOpts@Markers
261.335 + else
261.336 + Markers = (/ 4, 6, 8, 0, 9, 12, 7, 2, 11, 16/) ; Marker Indices
261.337 + end if
261.338 +
261.339 + if (rOpts .and. isatt(rOpts,"Colors")) then
261.340 + Colors = rOpts@Colors
261.341 + else
261.342 + Colors = (/ "red", "blue", "green", "cyan", "orange" \
261.343 + , "torquoise", "brown", "yellow", "purple", "black"/)
261.344 + end if
261.345 +
261.346 + if (rOpts .and. isatt(rOpts,"gsMarkerThicknessF")) then
261.347 + gsMarkerThicknessF = rOpts@gsMarkerThicknessF
261.348 + else
261.349 + gsMarkerThicknessF = 1.0
261.350 + end if
261.351 +
261.352 + if (rOpts .and. isatt(rOpts,"gsMarkerSizeF")) then
261.353 + gsMarkerSizeF = rOpts@gsMarkerSizeF
261.354 + else
261.355 + gsMarkerSizeF = 0.0085 ; Default: 0.007
261.356 + end if
261.357 +
261.358 + gsRes = True
261.359 + gsRes@gsMarkerThicknessF = gsMarkerThicknessF ; default=1.0
261.360 + gsRes@gsMarkerSizeF = gsMarkerSizeF ; Default: 0.007
261.361 +
261.362 + ptRes = True ; text options for points
261.363 + ptRes@txJust = "BottomCenter"; Default="CenterCenter".
261.364 + ptRes@txFontThicknessF = 1.2 ; default=1.00
261.365 + ptRes@txFontHeightF = 0.0125 ; default=0.05
261.366 + if (rOpts .and. isatt(rOpts,"txFontHeightF")) then
261.367 + ptRes@txFontHeightF = rOpts@txFontHeightF
261.368 + end if
261.369 +
261.370 + markerTxYOffset = 0.0175 ; default
261.371 + if (rOpts .and. isatt(rOpts,"markerTxYOffset")) then
261.372 + markerTxYOffset = rOpts@markerTxYOffset ; user defined offset
261.373 + end if
261.374 +
261.375 + dum10 = new((nCase*nVar),graphic)
261.376 + dum11 = dum10
261.377 +
261.378 + do n=0,nCase-1
261.379 + gsRes@gsMarkerIndex = Markers(n) ; marker style (+)
261.380 + gsRes@gsMarkerColor = Colors(n) ; marker color
261.381 + ptRes@txFontColor = gsRes@gsMarkerColor
261.382 + do i=0,nVar-1
261.383 + dum10(n*nVar+i) = gsn_add_polymarker(wks,taylor,X(n,i),Y(n,i),gsRes)
261.384 + dum11(n*nVar+i) = gsn_add_text(wks,taylor,(i+1),X(n,i),Y(n,i)+markerTxYOffset,ptRes)
261.385 + end do
261.386 + end do
261.387 +
261.388 +; ---------------------------------------------------------------
261.389 +; Part 5: ; add case legend and variable labels
261.390 +; ---------------------------------------------------------------
261.391 +
261.392 + if (rOpts .and. isatt(rOpts,"caseLabels")) then
261.393 +
261.394 + if (isatt(rOpts,"caseLabelsFontHeightF")) then
261.395 + caseLabelsFontHeightF = rOpts@caseLabelsFontHeightF
261.396 + else
261.397 + caseLabelsFontHeightF = 0.05
261.398 + end if
261.399 +
261.400 + lgres = True
261.401 + lgres@lgMarkerColors = Colors ; colors of markers
261.402 + lgres@lgMarkerIndexes = Markers ; Markers
261.403 + lgres@lgMarkerSizeF = gsMarkerSizeF ; Marker size
261.404 + lgres@lgItemType = "Markers" ; draw markers only
261.405 + lgres@lgLabelFontHeightF = caseLabelsFontHeightF ; font height of legend case labels
261.406 +
261.407 + if (isatt(rOpts,"legendWidth")) then
261.408 + lgres@vpWidthF = rOpts@legendWidth
261.409 + else
261.410 + lgres@vpWidthF = 0.15 ; width of legend (NDC)
261.411 + end if
261.412 +
261.413 + if (isatt(rOpts,"legendHeight")) then
261.414 + lgres@vpHeightF = rOpts@legendHeight
261.415 + else
261.416 + lgres@vpHeightF = 0.030*nCase ; height of legend (NDC)
261.417 + end if
261.418 +
261.419 + lgres@lgPerimOn = False ; turn off perimeter
261.420 + nModel = dimsizes( rOpts@caseLabels )
261.421 + lbid = gsn_create_legend(wks,nModel,rOpts@caseLabels,lgres)
261.422 +
261.423 + amres = True
261.424 + amres@amParallelPosF = 0.35
261.425 + amres@amOrthogonalPosF = -0.35
261.426 + annoid1 = gsn_add_annotation(taylor,lbid,amres) ; add legend to plot
261.427 + end if
261.428 +
261.429 + if (rOpts .and. isatt(rOpts,"varLabels")) then
261.430 + nVar = dimsizes(rOpts@varLabels)
261.431 +
261.432 + if (isatt(rOpts,"varLabelsFontHeightF")) then
261.433 + varLabelsFontHeightF = rOpts@varLabelsFontHeightF
261.434 + else
261.435 + varLabelsFontHeightF = 0.013
261.436 + end if
261.437 +
261.438 + txres = True
261.439 + txres@txFontHeightF = varLabelsFontHeightF
261.440 + txres@txJust = "CenterLeft" ; justify to the center left
261.441 +
261.442 + ;delta_y = 0.02
261.443 + delta_y = 0.06
261.444 + if (rOpts .and. isatt(rOpts,"varLabelsYloc")) then
261.445 + ys = rOpts@varLabelsYloc ; user specified
261.446 + else
261.447 + ys = max( (/nVar*delta_y , 0.30/) )
261.448 + end if
261.449 +
261.450 +
261.451 + do i = 1,nVar
261.452 + if (i.eq.1) then
261.453 + dum12 = new(nVar,graphic)
261.454 + end if
261.455 +
261.456 + dum12(i-1) = gsn_add_text(wks,taylor,i+" - "+rOpts@varLabels(i-1), .125,ys,txres)
261.457 + ys = ys- delta_y
261.458 + end do
261.459 +
261.460 + taylor@$unique_string("dum")$ = dum12
261.461 + end if
261.462 +
261.463 + taylor@$unique_string("dum")$ = dum0 ; x-axis
261.464 + taylor@$unique_string("dum")$ = dum1 ; y-axis
261.465 + taylor@$unique_string("dum")$ = dum2 ; 1.0 std curve
261.466 + taylor@$unique_string("dum")$ = dum5 ; labels [COR]
261.467 + taylor@$unique_string("dum")$ = dum6 ; major tm [COR]
261.468 + taylor@$unique_string("dum")$ = dum7 ; minor tm
261.469 + taylor@$unique_string("dum")$ = dum10 ; markers
261.470 + taylor@$unique_string("dum")$ = dum11 ; text
261.471 +
261.472 + if (.not.isatt(rOpts,"taylorDraw") .or. \
261.473 + (isatt(rOpts,"taylorDraw") .and. rOpts@taylorDraw)) then
261.474 + draw(taylor)
261.475 + end if
261.476 + if (.not.isatt(rOpts,"taylorFrame") .or. \
261.477 + (isatt(rOpts,"taylorFrame") .and. rOpts@taylorFrame)) then
261.478 + frame(wks)
261.479 + end if
261.480 + return(taylor)
261.481 +end
261.482 +
262.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
262.2 +++ b/time_series/10.write_ameriflux_casa.ncl Mon Jan 26 22:08:20 2009 -0500
262.3 @@ -0,0 +1,167 @@
262.4 +;************************************************
262.5 +; Read ascii, Write nc
262.6 +; output: lat: N->S lon: -180W->180E
262.7 +;************************************************
262.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
262.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
262.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
262.11 +;************************************************
262.12 +begin
262.13 +
262.14 +; output
262.15 +
262.16 + model_name = "i01.10casa"
262.17 +
262.18 + diro = "/ptmp/jeff/"
262.19 + filo = model_name + "_ameriflux_1990-2004_monthly.nc"
262.20 + c = addfile(diro+filo,"c")
262.21 + filedimdef(c,"year",-1,True)
262.22 +
262.23 +; input data
262.24 +
262.25 + nlat = 64
262.26 + nlon = 128
262.27 +
262.28 + year_start = 1990
262.29 + year_end = 2004
262.30 +
262.31 + nyear = year_end - year_start + 1
262.32 + nmonth = 12
262.33 +
262.34 + data1 = new((/nyear,nmonth,nlat,nlon/),float)
262.35 + data2 = new((/nyear,nmonth,nlat,nlon/),float)
262.36 + data3 = new((/nyear,nmonth,nlat,nlon/),float)
262.37 + data4 = new((/nyear,nmonth,nlat,nlon/),float)
262.38 + data5 = new((/nyear,nmonth,nlat,nlon/),float)
262.39 + data6 = new((/nyear,nmonth,nlat,nlon/),float)
262.40 + data7 = new((/nyear,nmonth,nlat,nlon/),float)
262.41 + date = new((/nyear,nmonth/),integer)
262.42 +
262.43 +; name dimensions and assign coordinate variables
262.44 +
262.45 + data1!0 ="year"
262.46 + data1!1 ="month"
262.47 + data1!2 = "lat"
262.48 + data1!3 = "lon"
262.49 +
262.50 + data2!0 ="year"
262.51 + data2!1 ="month"
262.52 + data2!2 = "lat"
262.53 + data2!3 = "lon"
262.54 +
262.55 + data3!0 ="year"
262.56 + data3!1 ="month"
262.57 + data3!2 = "lat"
262.58 + data3!3 = "lon"
262.59 +
262.60 + data4!0 ="year"
262.61 + data4!1 ="month"
262.62 + data4!2 = "lat"
262.63 + data4!3 = "lon"
262.64 +
262.65 + data5!0 ="year"
262.66 + data5!1 ="month"
262.67 + data5!2 = "lat"
262.68 + data5!3 = "lon"
262.69 +
262.70 + data6!0 ="year"
262.71 + data6!1 ="month"
262.72 + data6!2 = "lat"
262.73 + data6!3 = "lon"
262.74 +
262.75 + data7!0 ="year"
262.76 + data7!1 ="month"
262.77 + data7!2 = "lat"
262.78 + data7!3 = "lon"
262.79 +
262.80 + date!0 ="year"
262.81 + date!1 ="month"
262.82 + date@long_name = "date: yyyymm"
262.83 +
262.84 +; input dir
262.85 + diri = "/ptmp/jeff/"+model_name+"/"
262.86 +
262.87 + do m = 0,nyear-1
262.88 + year = year_start + m
262.89 + do n = 0,nmonth-1
262.90 + nn = n+1
262.91 + date(m,n) = year*100 +nn
262.92 +
262.93 +; input file
262.94 + if (nn .ge. 10) then
262.95 + fili = model_name+".clm2.h0."+year+"-"+nn+".nc"
262.96 + else
262.97 + fili = model_name+".clm2.h0."+year+"-0"+nn+".nc"
262.98 + end if
262.99 +
262.100 + print (fili)
262.101 +
262.102 + g = addfile (diri+fili,"r")
262.103 +
262.104 + b = g->NEE
262.105 + data1(m,n,:,:) = (/b(0,:,:)/)
262.106 + data1@long_name = b@long_name
262.107 + data1@units = b@units
262.108 + data1@_FillValue = b@_FillValue
262.109 + delete (b)
262.110 +
262.111 + b = g->GPP
262.112 + data2(m,n,:,:) = (/b(0,:,:)/)
262.113 + data2@long_name = b@long_name
262.114 + data2@units = b@units
262.115 + data2@_FillValue = b@_FillValue
262.116 + delete (b)
262.117 +
262.118 + b = g->AR
262.119 + data3(m,n,:,:) = (/b(0,:,:)/)
262.120 + b = g->HR
262.121 + data3(m,n,:,:) = data3(m,n,:,:)+(/b(0,:,:)/)
262.122 + data3@long_name = "total ecosystem respiration, autotrophic + heterotrophic"
262.123 + data3@units = b@units
262.124 + data3@_FillValue = b@_FillValue
262.125 + delete (b)
262.126 +
262.127 + b = g->NETRAD
262.128 + data4(m,n,:,:) = (/b(0,:,:)/)
262.129 + data4@long_name = b@long_name
262.130 + data4@units = b@units
262.131 + data4@_FillValue = b@_FillValue
262.132 + delete (b)
262.133 +
262.134 + b = g->LATENT
262.135 + data5(m,n,:,:) = (/b(0,:,:)/)
262.136 + data5@long_name = b@long_name
262.137 + data5@units = b@units
262.138 + data5@_FillValue = b@_FillValue
262.139 + delete (b)
262.140 +
262.141 + b = g->FSH
262.142 + data6(m,n,:,:) = (/b(0,:,:)/)
262.143 + data6@long_name = b@long_name
262.144 + data6@units = b@units
262.145 + data6@_FillValue = b@_FillValue
262.146 + delete (b)
262.147 +
262.148 + b = g->FSDS
262.149 + data7(m,n,:,:) = (/b(0,:,:)/)
262.150 + data7@long_name = b@long_name
262.151 + data7@units = b@units
262.152 + data7@_FillValue = b@_FillValue
262.153 + delete (b)
262.154 +
262.155 + end do
262.156 + end do
262.157 +
262.158 + c->NEE = data1
262.159 + c->GPP = data2
262.160 + c->ER = data3
262.161 + c->NETRAD = data4
262.162 + c->LATENT = data5
262.163 + c->FSH = data6
262.164 + c->FSDS = data7
262.165 + c->date = date
262.166 + c->area = g->area
262.167 +
262.168 + print (date)
262.169 +
262.170 +end
263.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
263.2 +++ b/time_series/10.write_ameriflux_cn.ncl Mon Jan 26 22:08:20 2009 -0500
263.3 @@ -0,0 +1,165 @@
263.4 +;************************************************
263.5 +; Read ascii, Write nc
263.6 +; output: lat: N->S lon: -180W->180E
263.7 +;************************************************
263.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
263.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
263.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
263.11 +;************************************************
263.12 +begin
263.13 +
263.14 +; output
263.15 +
263.16 + model_name = "i01.10cn"
263.17 +
263.18 + diro = "/ptmp/jeff/"
263.19 + filo = model_name + "_ameriflux_1990-2004_monthly.nc"
263.20 + c = addfile(diro+filo,"c")
263.21 + filedimdef(c,"year",-1,True)
263.22 +
263.23 +; input data
263.24 +
263.25 + nlat = 64
263.26 + nlon = 128
263.27 +
263.28 + year_start = 1990
263.29 + year_end = 2004
263.30 +
263.31 + nyear = year_end - year_start + 1
263.32 + nmonth = 12
263.33 +
263.34 + data1 = new((/nyear,nmonth,nlat,nlon/),float)
263.35 + data2 = new((/nyear,nmonth,nlat,nlon/),float)
263.36 + data3 = new((/nyear,nmonth,nlat,nlon/),float)
263.37 + data4 = new((/nyear,nmonth,nlat,nlon/),float)
263.38 + data5 = new((/nyear,nmonth,nlat,nlon/),float)
263.39 + data6 = new((/nyear,nmonth,nlat,nlon/),float)
263.40 + data7 = new((/nyear,nmonth,nlat,nlon/),float)
263.41 + date = new((/nyear,nmonth/),integer)
263.42 +
263.43 +; name dimensions and assign coordinate variables
263.44 +
263.45 + data1!0 ="year"
263.46 + data1!1 ="month"
263.47 + data1!2 = "lat"
263.48 + data1!3 = "lon"
263.49 +
263.50 + data2!0 ="year"
263.51 + data2!1 ="month"
263.52 + data2!2 = "lat"
263.53 + data2!3 = "lon"
263.54 +
263.55 + data3!0 ="year"
263.56 + data3!1 ="month"
263.57 + data3!2 = "lat"
263.58 + data3!3 = "lon"
263.59 +
263.60 + data4!0 ="year"
263.61 + data4!1 ="month"
263.62 + data4!2 = "lat"
263.63 + data4!3 = "lon"
263.64 +
263.65 + data5!0 ="year"
263.66 + data5!1 ="month"
263.67 + data5!2 = "lat"
263.68 + data5!3 = "lon"
263.69 +
263.70 + data6!0 ="year"
263.71 + data6!1 ="month"
263.72 + data6!2 = "lat"
263.73 + data6!3 = "lon"
263.74 +
263.75 + data7!0 ="year"
263.76 + data7!1 ="month"
263.77 + data7!2 = "lat"
263.78 + data7!3 = "lon"
263.79 +
263.80 + date!0 ="year"
263.81 + date!1 ="month"
263.82 + date@long_name = "date: yyyymm"
263.83 +
263.84 +; input dir
263.85 + diri = "/ptmp/jeff/"+model_name+"/"
263.86 +
263.87 + do m = 0,nyear-1
263.88 + year = year_start + m
263.89 + do n = 0,nmonth-1
263.90 + nn = n+1
263.91 + date(m,n) = year*100 +nn
263.92 +
263.93 +; input file
263.94 + if (nn .ge. 10) then
263.95 + fili = model_name+".clm2.h0."+year+"-"+nn+".nc"
263.96 + else
263.97 + fili = model_name+".clm2.h0."+year+"-0"+nn+".nc"
263.98 + end if
263.99 +
263.100 + print (fili)
263.101 +
263.102 + g = addfile (diri+fili,"r")
263.103 +
263.104 + b = g->NEE
263.105 + data1(m,n,:,:) = (/b(0,:,:)/)
263.106 + data1@long_name = b@long_name
263.107 + data1@units = b@units
263.108 + data1@_FillValue = b@_FillValue
263.109 + delete (b)
263.110 +
263.111 + b = g->GPP
263.112 + data2(m,n,:,:) = (/b(0,:,:)/)
263.113 + data2@long_name = b@long_name
263.114 + data2@units = b@units
263.115 + data2@_FillValue = b@_FillValue
263.116 + delete (b)
263.117 +
263.118 + b = g->ER
263.119 + data3(m,n,:,:) = (/b(0,:,:)/)
263.120 + data3@long_name = b@long_name
263.121 + data3@units = b@units
263.122 + data3@_FillValue = b@_FillValue
263.123 + delete (b)
263.124 +
263.125 + b = g->NETRAD
263.126 + data4(m,n,:,:) = (/b(0,:,:)/)
263.127 + data4@long_name = b@long_name
263.128 + data4@units = b@units
263.129 + data4@_FillValue = b@_FillValue
263.130 + delete (b)
263.131 +
263.132 + b = g->LATENT
263.133 + data5(m,n,:,:) = (/b(0,:,:)/)
263.134 + data5@long_name = b@long_name
263.135 + data5@units = b@units
263.136 + data5@_FillValue = b@_FillValue
263.137 + delete (b)
263.138 +
263.139 + b = g->FSH
263.140 + data6(m,n,:,:) = (/b(0,:,:)/)
263.141 + data6@long_name = b@long_name
263.142 + data6@units = b@units
263.143 + data6@_FillValue = b@_FillValue
263.144 + delete (b)
263.145 +
263.146 + b = g->FSDS
263.147 + data7(m,n,:,:) = (/b(0,:,:)/)
263.148 + data7@long_name = b@long_name
263.149 + data7@units = b@units
263.150 + data7@_FillValue = b@_FillValue
263.151 + delete (b)
263.152 +
263.153 + end do
263.154 + end do
263.155 +
263.156 + c->NEE = data1
263.157 + c->GPP = data2
263.158 + c->ER = data3
263.159 + c->NETRAD = data4
263.160 + c->LATENT = data5
263.161 + c->FSH = data6
263.162 + c->FSDS = data7
263.163 + c->date = date
263.164 + c->area = g->area
263.165 +
263.166 + print (date)
263.167 +
263.168 +end
264.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
264.2 +++ b/time_series/20.write_fire_cn.ncl Mon Jan 26 22:08:20 2009 -0500
264.3 @@ -0,0 +1,104 @@
264.4 +;************************************************
264.5 +; output: lat: N->S lon: -180W->180E
264.6 +;************************************************
264.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
264.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
264.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
264.10 +;************************************************
264.11 +begin
264.12 +
264.13 +; output
264.14 +
264.15 + model_name = "i01.10cn"
264.16 +
264.17 + diro = "/ptmp/jeff/"
264.18 + filo = model_name + "_Fire_C_1979-2004_monthly.nc"
264.19 + c = addfile(diro+filo,"c")
264.20 + filedimdef(c,"year",-1,True)
264.21 +
264.22 +; input data
264.23 +
264.24 + nlat = 64
264.25 + nlon = 128
264.26 +
264.27 + year_start = 1979
264.28 + year_end = 2004
264.29 +
264.30 + nyear = year_end - year_start + 1
264.31 + nmonth = 12
264.32 +
264.33 + data1 = new((/nyear,nmonth,nlat,nlon/),float)
264.34 + data2 = new((/nyear,nmonth,nlat,nlon/),float)
264.35 + data3 = new((/nyear,nmonth,nlat,nlon/),float)
264.36 + date = new((/nyear,nmonth/),integer)
264.37 +
264.38 +; input dir
264.39 + diri = "/ptmp/jeff/"+model_name+"/"
264.40 +
264.41 + do m = 0,nyear-1
264.42 + year = year_start + m
264.43 + do n = 0,nmonth-1
264.44 + nn = n+1
264.45 + date(m,n) = year*100 +nn
264.46 +
264.47 +; input file
264.48 + if (nn .ge. 10) then
264.49 + fili = model_name+".clm2.h0."+year+"-"+nn+".nc"
264.50 + else
264.51 + fili = model_name+".clm2.h0."+year+"-0"+nn+".nc"
264.52 + end if
264.53 +
264.54 +; print (fili)
264.55 +
264.56 + g = addfile (diri+fili,"r")
264.57 +
264.58 + b1 = g->COL_FIRE_CLOSS
264.59 + data1(m,n,:,:) = (/b1(0,:,:)/)
264.60 +
264.61 + b2 = g->NPP
264.62 + data2(m,n,:,:) = (/b2(0,:,:)/)
264.63 +
264.64 + b3 = g->NEE
264.65 + data3(m,n,:,:) = (/b3(0,:,:)/)
264.66 + end do
264.67 + end do
264.68 +
264.69 +; name dimensions and assign coordinate variables
264.70 +
264.71 + data1!0 ="year"
264.72 + data1!1 ="month"
264.73 + data1!2 = "lat"
264.74 + data1!3 = "lon"
264.75 + data1@long_name = b1@long_name
264.76 + data1@units = b1@units
264.77 + data1@_FillValue = b1@_FillValue
264.78 +
264.79 + data2!0 ="year"
264.80 + data2!1 ="month"
264.81 + data2!2 = "lat"
264.82 + data2!3 = "lon"
264.83 + data2@long_name = b2@long_name
264.84 + data2@units = b2@units
264.85 + data2@_FillValue = b2@_FillValue
264.86 +
264.87 + data3!0 ="year"
264.88 + data3!1 ="month"
264.89 + data3!2 = "lat"
264.90 + data3!3 = "lon"
264.91 + data3@long_name = b3@long_name
264.92 + data3@units = b3@units
264.93 + data3@_FillValue = b3@_FillValue
264.94 +
264.95 + date!0 ="year"
264.96 + date!1 ="month"
264.97 + date@long_name = "date: yyyymm"
264.98 +
264.99 + c->COL_FIRE_CLOSS = data1
264.100 + c->NPP = data2
264.101 + c->NEE = data3
264.102 + c->date = date
264.103 + c->area = g->area
264.104 +
264.105 + print (date)
264.106 +
264.107 +end
265.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
265.2 +++ b/turnover/01.biome.ncl Mon Jan 26 22:08:20 2009 -0500
265.3 @@ -0,0 +1,294 @@
265.4 +;********************************************************
265.5 +; required command line input parameters:
265.6 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
265.7 +;
265.8 +; histogram normalized by rain and compute correleration
265.9 +;**************************************************************
265.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
265.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
265.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
265.13 +;**************************************************************
265.14 +procedure set_line(lines:string,nline:integer,newlines:string)
265.15 +begin
265.16 +; add line to ascci/html file
265.17 +
265.18 + nnewlines = dimsizes(newlines)
265.19 + if(nline+nnewlines-1.ge.dimsizes(lines))
265.20 + print("set_line: bad index, not setting anything.")
265.21 + return
265.22 + end if
265.23 + lines(nline:nline+nnewlines-1) = newlines
265.24 +; print ("lines = " + lines(nline:nline+nnewlines-1))
265.25 + nline = nline + nnewlines
265.26 + return
265.27 +end
265.28 +;**************************************************************
265.29 +; Main code.
265.30 +begin
265.31 +
265.32 + plot_type = "ps"
265.33 + plot_type_new = "png"
265.34 +
265.35 +;************************************************
265.36 +; read data: model
265.37 +;************************************************
265.38 +
265.39 + model_grid = "T42"
265.40 +
265.41 + model_name = "i01.06cn"
265.42 +;model_name = "i01.06casa"
265.43 +
265.44 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
265.45 + film = model_name + "_1980-2004_ANN_climo.nc"
265.46 +
265.47 + fm = addfile (dirm+film,"r")
265.48 +
265.49 + xm = fm->lon
265.50 + ym = fm->lat
265.51 +
265.52 + pool = fm->WOODC
265.53 + flux = fm->WOODC_ALLOC
265.54 +
265.55 +;Units for these variables are:
265.56 +;pool: g C/m^2
265.57 +;flux: g C/m^2/s
265.58 +
265.59 + nsec_per_year = 60*60*24*365
265.60 +
265.61 + flux = flux * nsec_per_year
265.62 +
265.63 +;************************************************
265.64 +; read data: observed-biome
265.65 +;************************************************
265.66 +
265.67 + ob_name = "MODIS MOD 15A2 2000-2005"
265.68 +
265.69 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
265.70 + filo = "land_class_"+model_grid+".nc"
265.71 +
265.72 + fo = addfile(diro+filo,"r")
265.73 +
265.74 + classob = tofloat(fo->LAND_CLASS)
265.75 +
265.76 + nclass = 20
265.77 +
265.78 +;*******************************************************************
265.79 +; Calculate "nice" bins for binning the data in equally spaced ranges
265.80 +;********************************************************************
265.81 +
265.82 + nclassn = nclass + 1
265.83 + range = fspan(0,nclassn-1,nclassn)
265.84 +; print (range)
265.85 +
265.86 +; Use this range information to grab all the values in a
265.87 +; particular range, and then take an average.
265.88 +
265.89 + nr = dimsizes(range)
265.90 + nx = nr-1
265.91 + xvalues = new((/2,nx/),float)
265.92 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
265.93 + dx = xvalues(0,1) - xvalues(0,0) ; range width
265.94 + dx4 = dx/4 ; 1/4 of the range
265.95 + xvalues(1,:) = xvalues(0,:) - dx/5.
265.96 +
265.97 +; get data
265.98 +
265.99 + base_1D = ndtooned(classob)
265.100 + data1_1D = ndtooned(pool)
265.101 + data2_1D = ndtooned(flux)
265.102 +
265.103 +; output
265.104 +
265.105 + yvalues = new((/2,nx/),float)
265.106 +
265.107 + do nd=0,1
265.108 +
265.109 +; See if we are doing data1 (nd=0) or data2 (nd=1).
265.110 +
265.111 + base = base_1D
265.112 +
265.113 + if(nd.eq.0) then
265.114 + data = data1_1D
265.115 + else
265.116 + data = data2_1D
265.117 + end if
265.118 +
265.119 +; Loop through each range, using base.
265.120 +
265.121 + do i=0,nr-2
265.122 + if (i.ne.(nr-2)) then
265.123 +; print("")
265.124 +; print("In range ["+range(i)+","+range(i+1)+")")
265.125 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
265.126 + else
265.127 +; print("")
265.128 +; print("In range ["+range(i)+",)")
265.129 + idx = ind(base.ge.range(i))
265.130 + end if
265.131 +
265.132 +; Calculate average
265.133 +
265.134 + if(.not.any(ismissing(idx))) then
265.135 + yvalues(nd,i) = avg(data(idx))
265.136 + count = dimsizes(idx)
265.137 + else
265.138 + yvalues(nd,i) = yvalues@_FillValue
265.139 + count = 0
265.140 + end if
265.141 +
265.142 +;#############################################################
265.143 +; set the following 4 classes to _FillValue:
265.144 +; Water Bodies(0), Urban and Build-Up(13),
265.145 +; Permenant Snow and Ice(15), Unclassified(17)
265.146 +
265.147 + if (i.eq.0 .or. i.eq.13 .or. i.eq.15 .or. i.eq.17) then
265.148 + yvalues(nd,i) = yvalues@_FillValue
265.149 + count = 0
265.150 + end if
265.151 +;#############################################################
265.152 +
265.153 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
265.154 +
265.155 +; Clean up for next time in loop.
265.156 +
265.157 + delete(idx)
265.158 + end do
265.159 +
265.160 + delete(data)
265.161 + end do
265.162 +
265.163 +;============================
265.164 +;compute turnover time
265.165 +;============================
265.166 +
265.167 + u = yvalues(0,:)
265.168 + v = yvalues(1,:)
265.169 +
265.170 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
265.171 +
265.172 + uu = u(good)
265.173 + vv = v(good)
265.174 +
265.175 + n_biome = dimsizes(uu)
265.176 +
265.177 + t_biome = new((/n_biome/),float)
265.178 +
265.179 + t_biome = uu/vv
265.180 +
265.181 + t_biome_avg = avg(t_biome)
265.182 +
265.183 +;print (t_biome)
265.184 +;print (t_biome_avg)
265.185 +
265.186 +;===========================
265.187 +; for html table - biome
265.188 +;===========================
265.189 +
265.190 + output_html = "table_biome.html"
265.191 +
265.192 +; column (not including header column)
265.193 +
265.194 + col_head = (/"WOOD Flux","WOOD Pool","WOOD Turnover Time"/)
265.195 +
265.196 + ncol = dimsizes(col_head)
265.197 +
265.198 +; row (not including header row)
265.199 +; 4 classes removed: Water Bodies, Urban and Build-Up,
265.200 +; Unclassified, Permanent Snow and Ice
265.201 +
265.202 + row_head = (/"Evergreen Needleleaf Forests" \
265.203 + ,"Evergreen Broadleaf Forests" \
265.204 + ,"Deciduous Needleleaf Forest" \
265.205 + ,"Deciduous Broadleaf Forests" \
265.206 + ,"Mixed Forests" \
265.207 + ,"Closed Bushlands" \
265.208 + ,"Open Bushlands" \
265.209 + ,"Woody Savannas (S. Hem.)" \
265.210 + ,"Savannas (S. Hem.)" \
265.211 + ,"Grasslands" \
265.212 + ,"Permanent Wetlands" \
265.213 + ,"Croplands" \
265.214 + ,"Cropland/Natural Vegetation Mosaic" \
265.215 + ,"Barren or Sparsely Vegetated" \
265.216 + ,"Woody Savannas (N. Hem.)" \
265.217 + ,"Savannas (N. Hem.)" \
265.218 + ,"All Biome" \
265.219 + /)
265.220 + nrow = dimsizes(row_head)
265.221 +
265.222 +; arrays to be passed to table.
265.223 + text4 = new ((/nrow, ncol/),string )
265.224 +
265.225 + do i=0,nrow-2
265.226 + text4(i,0) = sprintf("%.1f",vv(i))
265.227 + text4(i,1) = sprintf("%.1f",uu(i))
265.228 + text4(i,2) = sprintf("%.1f",t_biome(i))
265.229 + end do
265.230 + text4(nrow-1,0) = "-"
265.231 + text4(nrow-1,1) = "-"
265.232 + text4(nrow-1,2) = sprintf("%.1f",t_biome_avg)
265.233 +
265.234 +;**************************************************
265.235 +; html table
265.236 +;**************************************************
265.237 +
265.238 + header_text = "<H1>WOOD Turnover Time: Model "+model_name+"</H1>"
265.239 +
265.240 + header = (/"<HTML>" \
265.241 + ,"<HEAD>" \
265.242 + ,"<TITLE>CLAMP metrics</TITLE>" \
265.243 + ,"</HEAD>" \
265.244 + ,header_text \
265.245 + /)
265.246 + footer = "</HTML>"
265.247 +
265.248 + table_header = (/ \
265.249 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
265.250 + ,"<tr>" \
265.251 + ," <th bgcolor=DDDDDD >Biome Class</th>" \
265.252 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
265.253 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
265.254 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
265.255 + ,"</tr>" \
265.256 + /)
265.257 + table_footer = "</table>"
265.258 + row_header = "<tr>"
265.259 + row_footer = "</tr>"
265.260 +
265.261 + lines = new(50000,string)
265.262 + nline = 0
265.263 +
265.264 + set_line(lines,nline,header)
265.265 + set_line(lines,nline,table_header)
265.266 +;-----------------------------------------------
265.267 +;row of table
265.268 +
265.269 + do n = 0,nrow-1
265.270 + set_line(lines,nline,row_header)
265.271 +
265.272 + txt1 = row_head(n)
265.273 + txt2 = text4(n,0)
265.274 + txt3 = text4(n,1)
265.275 + txt4 = text4(n,2)
265.276 +
265.277 + set_line(lines,nline,"<th>"+txt1+"</th>")
265.278 + set_line(lines,nline,"<th>"+txt2+"</th>")
265.279 + set_line(lines,nline,"<th>"+txt3+"</th>")
265.280 + set_line(lines,nline,"<th>"+txt4+"</th>")
265.281 +
265.282 + set_line(lines,nline,row_footer)
265.283 + end do
265.284 +;-----------------------------------------------
265.285 + set_line(lines,nline,table_footer)
265.286 + set_line(lines,nline,footer)
265.287 +
265.288 +; Now write to an HTML file.
265.289 + idx = ind(.not.ismissing(lines))
265.290 + if(.not.any(ismissing(idx))) then
265.291 + asciiwrite(output_html,lines(idx))
265.292 + else
265.293 + print ("error?")
265.294 + end if
265.295 +
265.296 +end
265.297 +
266.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
266.2 +++ b/turnover/02.biome.ncl Mon Jan 26 22:08:20 2009 -0500
266.3 @@ -0,0 +1,303 @@
266.4 +;********************************************************
266.5 +; required command line input parameters:
266.6 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
266.7 +;
266.8 +; histogram normalized by rain and compute correleration
266.9 +;**************************************************************
266.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
266.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
266.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
266.13 +;**************************************************************
266.14 +procedure set_line(lines:string,nline:integer,newlines:string)
266.15 +begin
266.16 +; add line to ascci/html file
266.17 +
266.18 + nnewlines = dimsizes(newlines)
266.19 + if(nline+nnewlines-1.ge.dimsizes(lines))
266.20 + print("set_line: bad index, not setting anything.")
266.21 + return
266.22 + end if
266.23 + lines(nline:nline+nnewlines-1) = newlines
266.24 +; print ("lines = " + lines(nline:nline+nnewlines-1))
266.25 + nline = nline + nnewlines
266.26 + return
266.27 +end
266.28 +;**************************************************************
266.29 +; Main code.
266.30 +begin
266.31 +
266.32 + plot_type = "ps"
266.33 + plot_type_new = "png"
266.34 +
266.35 +;components
266.36 +
266.37 + component = (/"Leaf","Wood","Fine_Root","Litter","Coarse_Woody_Debris","Soil"/)
266.38 + n_comp = dimsizes(component)
266.39 +
266.40 + field_pool = (/"LEAFC","WOODC","FROOTC","LITTERC","CWDC","SOILC"/)
266.41 + field_flux = (/"LEAFC_ALLOC","WOODC_ALLOC","FROOTC_ALLOC","LITTERC_LOSS","CWDC_LOSS","SOILC_HR"/)
266.42 +
266.43 +;************************************************
266.44 +; read data: model
266.45 +;************************************************
266.46 +
266.47 + model_grid = "T42"
266.48 +
266.49 +;model_name = "i01.06cn"
266.50 + model_name = "i01.06casa"
266.51 +
266.52 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
266.53 + film = model_name + "_1980-2004_ANN_climo.nc"
266.54 +
266.55 + fm = addfile (dirm+film,"r")
266.56 +
266.57 + do k = 0,n_comp-1
266.58 +
266.59 + pool = fm->$field_pool(k)$
266.60 + flux = fm->$field_flux(k)$
266.61 +
266.62 +;Units for these variables are:
266.63 +;pool: g C/m^2
266.64 +;flux: g C/m^2/s
266.65 +
266.66 + nsec_per_year = 60*60*24*365
266.67 +
266.68 + flux = flux * nsec_per_year
266.69 +
266.70 +;************************************************
266.71 +; read data: observed-biome
266.72 +;************************************************
266.73 +
266.74 + ob_name = "MODIS MOD 15A2 2000-2005"
266.75 +
266.76 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
266.77 + filo = "land_class_"+model_grid+".nc"
266.78 +
266.79 + fo = addfile(diro+filo,"r")
266.80 +
266.81 + classob = tofloat(fo->LAND_CLASS)
266.82 +
266.83 + nclass = 20
266.84 +
266.85 +;*******************************************************************
266.86 +; Calculate "nice" bins for binning the data in equally spaced ranges
266.87 +;********************************************************************
266.88 +
266.89 + nclassn = nclass + 1
266.90 + range = fspan(0,nclassn-1,nclassn)
266.91 +; print (range)
266.92 +
266.93 +; Use this range information to grab all the values in a
266.94 +; particular range, and then take an average.
266.95 +
266.96 + nr = dimsizes(range)
266.97 + nx = nr-1
266.98 + xvalues = new((/2,nx/),float)
266.99 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
266.100 + dx = xvalues(0,1) - xvalues(0,0) ; range width
266.101 + dx4 = dx/4 ; 1/4 of the range
266.102 + xvalues(1,:) = xvalues(0,:) - dx/5.
266.103 +
266.104 +; get data
266.105 +
266.106 + base_1D = ndtooned(classob)
266.107 + data1_1D = ndtooned(pool)
266.108 + data2_1D = ndtooned(flux)
266.109 +
266.110 +; output
266.111 +
266.112 + yvalues = new((/2,nx/),float)
266.113 +
266.114 + do nd=0,1
266.115 +
266.116 +; See if we are doing data1 (nd=0) or data2 (nd=1).
266.117 +
266.118 + base = base_1D
266.119 +
266.120 + if(nd.eq.0) then
266.121 + data = data1_1D
266.122 + else
266.123 + data = data2_1D
266.124 + end if
266.125 +
266.126 +; Loop through each range, using base.
266.127 +
266.128 + do i=0,nr-2
266.129 + if (i.ne.(nr-2)) then
266.130 +; print("")
266.131 +; print("In range ["+range(i)+","+range(i+1)+")")
266.132 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
266.133 + else
266.134 +; print("")
266.135 +; print("In range ["+range(i)+",)")
266.136 + idx = ind(base.ge.range(i))
266.137 + end if
266.138 +
266.139 +; Calculate average
266.140 +
266.141 + if(.not.any(ismissing(idx))) then
266.142 + yvalues(nd,i) = avg(data(idx))
266.143 + count = dimsizes(idx)
266.144 + else
266.145 + yvalues(nd,i) = yvalues@_FillValue
266.146 + count = 0
266.147 + end if
266.148 +
266.149 +;#############################################################
266.150 +; set the following 4 classes to _FillValue:
266.151 +; Water Bodies(0), Urban and Build-Up(13),
266.152 +; Permenant Snow and Ice(15), Unclassified(17)
266.153 +
266.154 + if (i.eq.0 .or. i.eq.13 .or. i.eq.15 .or. i.eq.17) then
266.155 + yvalues(nd,i) = yvalues@_FillValue
266.156 + count = 0
266.157 + end if
266.158 +;#############################################################
266.159 +
266.160 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
266.161 +
266.162 +; Clean up for next time in loop.
266.163 +
266.164 + delete(idx)
266.165 + end do
266.166 +
266.167 + delete(data)
266.168 + end do
266.169 +
266.170 +;============================
266.171 +;compute turnover time
266.172 +;============================
266.173 +
266.174 + u = yvalues(0,:)
266.175 + v = yvalues(1,:)
266.176 +
266.177 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
266.178 +
266.179 + uu = u(good)
266.180 + vv = v(good)
266.181 +
266.182 + n_biome = dimsizes(uu)
266.183 +
266.184 + t_biome = new((/n_biome/),float)
266.185 +
266.186 + t_biome = uu/vv
266.187 +
266.188 + t_biome_avg = avg(t_biome)
266.189 +
266.190 +;print (t_biome)
266.191 +;print (t_biome_avg)
266.192 +
266.193 +;===========================
266.194 +; for html table - biome
266.195 +;===========================
266.196 +
266.197 + output_html = "table_"+component(k)+".html"
266.198 +
266.199 +; column (not including header column)
266.200 +
266.201 + col_head = (/component(k)+" Flux",component(k)+" Pool",component(k)+" Turnover Time"/)
266.202 +
266.203 + ncol = dimsizes(col_head)
266.204 +
266.205 +; row (not including header row)
266.206 +; 4 classes removed: Water Bodies, Urban and Build-Up,
266.207 +; Unclassified, Permanent Snow and Ice
266.208 +
266.209 + row_head = (/"Evergreen Needleleaf Forests" \
266.210 + ,"Evergreen Broadleaf Forests" \
266.211 + ,"Deciduous Needleleaf Forest" \
266.212 + ,"Deciduous Broadleaf Forests" \
266.213 + ,"Mixed Forests" \
266.214 + ,"Closed Bushlands" \
266.215 + ,"Open Bushlands" \
266.216 + ,"Woody Savannas (S. Hem.)" \
266.217 + ,"Savannas (S. Hem.)" \
266.218 + ,"Grasslands" \
266.219 + ,"Permanent Wetlands" \
266.220 + ,"Croplands" \
266.221 + ,"Cropland/Natural Vegetation Mosaic" \
266.222 + ,"Barren or Sparsely Vegetated" \
266.223 + ,"Woody Savannas (N. Hem.)" \
266.224 + ,"Savannas (N. Hem.)" \
266.225 + ,"All Biome" \
266.226 + /)
266.227 + nrow = dimsizes(row_head)
266.228 +
266.229 +; arrays to be passed to table.
266.230 + text4 = new ((/nrow, ncol/),string )
266.231 +
266.232 + do i=0,nrow-2
266.233 + text4(i,0) = sprintf("%.1f",vv(i))
266.234 + text4(i,1) = sprintf("%.1f",uu(i))
266.235 + text4(i,2) = sprintf("%.1f",t_biome(i))
266.236 + end do
266.237 + text4(nrow-1,0) = "-"
266.238 + text4(nrow-1,1) = "-"
266.239 + text4(nrow-1,2) = sprintf("%.1f",t_biome_avg)
266.240 +
266.241 +;**************************************************
266.242 +; html table
266.243 +;**************************************************
266.244 +
266.245 + header_text = "<H1>"+component(k)+" Turnover Time: Model "+model_name+"</H1>"
266.246 +
266.247 + header = (/"<HTML>" \
266.248 + ,"<HEAD>" \
266.249 + ,"<TITLE>CLAMP metrics</TITLE>" \
266.250 + ,"</HEAD>" \
266.251 + ,header_text \
266.252 + /)
266.253 + footer = "</HTML>"
266.254 +
266.255 + table_header = (/ \
266.256 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
266.257 + ,"<tr>" \
266.258 + ," <th bgcolor=DDDDDD >Biome Class</th>" \
266.259 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
266.260 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
266.261 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
266.262 + ,"</tr>" \
266.263 + /)
266.264 + table_footer = "</table>"
266.265 + row_header = "<tr>"
266.266 + row_footer = "</tr>"
266.267 +
266.268 + lines = new(50000,string)
266.269 + nline = 0
266.270 +
266.271 + set_line(lines,nline,header)
266.272 + set_line(lines,nline,table_header)
266.273 +;-----------------------------------------------
266.274 +;row of table
266.275 +
266.276 + do n = 0,nrow-1
266.277 + set_line(lines,nline,row_header)
266.278 +
266.279 + txt1 = row_head(n)
266.280 + txt2 = text4(n,0)
266.281 + txt3 = text4(n,1)
266.282 + txt4 = text4(n,2)
266.283 +
266.284 + set_line(lines,nline,"<th>"+txt1+"</th>")
266.285 + set_line(lines,nline,"<th>"+txt2+"</th>")
266.286 + set_line(lines,nline,"<th>"+txt3+"</th>")
266.287 + set_line(lines,nline,"<th>"+txt4+"</th>")
266.288 +
266.289 + set_line(lines,nline,row_footer)
266.290 + end do
266.291 +;-----------------------------------------------
266.292 + set_line(lines,nline,table_footer)
266.293 + set_line(lines,nline,footer)
266.294 +
266.295 +; Now write to an HTML file.
266.296 + idx = ind(.not.ismissing(lines))
266.297 + if(.not.any(ismissing(idx))) then
266.298 + asciiwrite(output_html,lines(idx))
266.299 + else
266.300 + print ("error?")
266.301 + end if
266.302 +
266.303 + delete (idx)
266.304 +end do
266.305 +end
266.306 +
267.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
267.2 +++ b/turnover/03.biome_model.ncl Mon Jan 26 22:08:20 2009 -0500
267.3 @@ -0,0 +1,404 @@
267.4 +;********************************************************
267.5 +;using model biome vlass
267.6 +;
267.7 +; required command line input parameters:
267.8 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
267.9 +;
267.10 +; histogram normalized by rain and compute correleration
267.11 +;**************************************************************
267.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
267.13 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
267.14 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
267.15 +;**************************************************************
267.16 +procedure set_line(lines:string,nline:integer,newlines:string)
267.17 +begin
267.18 +; add line to ascci/html file
267.19 +
267.20 + nnewlines = dimsizes(newlines)
267.21 + if(nline+nnewlines-1.ge.dimsizes(lines))
267.22 + print("set_line: bad index, not setting anything.")
267.23 + return
267.24 + end if
267.25 + lines(nline:nline+nnewlines-1) = newlines
267.26 +; print ("lines = " + lines(nline:nline+nnewlines-1))
267.27 + nline = nline + nnewlines
267.28 + return
267.29 +end
267.30 +;**************************************************************
267.31 +; Main code.
267.32 +begin
267.33 +
267.34 + plot_type = "ps"
267.35 + plot_type_new = "png"
267.36 +
267.37 +;components
267.38 +
267.39 + component = (/"Leaf","Wood","Fine_Root","Litter","Coarse_Woody_Debris","Soil"/)
267.40 + n_comp = dimsizes(component)
267.41 +
267.42 + field_pool = (/"LEAFC","WOODC","FROOTC","LITTERC","CWDC","SOILC"/)
267.43 + field_flux = (/"LEAFC_ALLOC","WOODC_ALLOC","FROOTC_ALLOC","LITTERC_LOSS","CWDC_LOSS","SOILC_HR"/)
267.44 +
267.45 +;************************************************
267.46 +; model name and grid
267.47 +;************************************************
267.48 +
267.49 + model_grid = "T42"
267.50 +
267.51 + model_name = "i01.06cn"
267.52 +;model_name = "i01.06casa"
267.53 +
267.54 +;************************************************
267.55 +; read data: ob
267.56 +;************************************************
267.57 +;------------------------------------------------
267.58 +; read biome data: observed
267.59 +
267.60 +; biome_name_ob = "MODIS LandCover"
267.61 +
267.62 +; diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
267.63 +; filo = "land_class_"+model_grid+".nc"
267.64 +
267.65 +; fo = addfile(diro+filo,"r")
267.66 +
267.67 +; classob = tofloat(fo->LAND_CLASS)
267.68 +
267.69 +; delete (fo)
267.70 +
267.71 +; observed data has 20 land-type classes
267.72 +
267.73 +; nclass_ob = 20
267.74 +
267.75 +;---------------------------------------------------
267.76 +; read biome data: model
267.77 +
267.78 + biome_name_mod = "Model PFT Class"
267.79 +
267.80 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
267.81 + film = "class_pft_"+model_grid+".nc"
267.82 +
267.83 + fm = addfile(dirm+film,"r")
267.84 +
267.85 + classmod = fm->CLASS_PFT
267.86 +
267.87 + delete (fm)
267.88 +
267.89 +; model data has 17 land-type classes
267.90 +
267.91 + nclass_mod = 17
267.92 +
267.93 +;---------------------------------------------------
267.94 +; read data: model, each component
267.95 +
267.96 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
267.97 + film = model_name + "_1980-2004_ANN_climo.nc"
267.98 +
267.99 + fm = addfile (dirm+film,"r")
267.100 +
267.101 + do k = 0,n_comp-1
267.102 +
267.103 + pool = fm->$field_pool(k)$
267.104 + flux = fm->$field_flux(k)$
267.105 +
267.106 +;Units for these variables are:
267.107 +;pool: g C/m^2
267.108 +;flux: g C/m^2/s
267.109 +
267.110 + nsec_per_year = 60*60*24*365
267.111 +
267.112 + flux = flux * nsec_per_year
267.113 +
267.114 +; casa only
267.115 +; all the plant pools (leaf, wood, and fine root) and
267.116 +; coarse woody debris (cwd) and litter pools for
267.117 +; CASA need to be divided by 1200. The soil flux
267.118 +; and turnover time are fine and do not need to be adjusted.
267.119 +
267.120 +; if (k .ne. n_comp-1) then
267.121 +; flux = flux/1200.
267.122 +; end if
267.123 +
267.124 +;*******************************************************************
267.125 +; Calculate "nice" bins for binning the data in equally spaced ranges
267.126 +;********************************************************************
267.127 +
267.128 +; using observed biome class
267.129 +; nclass = nclass_ob
267.130 +; using model biome class
267.131 + nclass = nclass_mod
267.132 +
267.133 + nclassn = nclass + 1
267.134 + range = fspan(0,nclassn-1,nclassn)
267.135 +; print (range)
267.136 +
267.137 +; Use this range information to grab all the values in a
267.138 +; particular range, and then take an average.
267.139 +
267.140 + nr = dimsizes(range)
267.141 + nx = nr-1
267.142 + xvalues = new((/2,nx/),float)
267.143 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
267.144 + dx = xvalues(0,1) - xvalues(0,0) ; range width
267.145 + dx4 = dx/4 ; 1/4 of the range
267.146 + xvalues(1,:) = xvalues(0,:) - dx/5.
267.147 +
267.148 +;==============================
267.149 +; put data into bins
267.150 +;==============================
267.151 +
267.152 +; using observed biome class
267.153 +; base_1D = ndtooned(classob)
267.154 +; using model biome class
267.155 + base_1D = ndtooned(classmod)
267.156 +
267.157 + data1_1D = ndtooned(pool)
267.158 + data2_1D = ndtooned(flux)
267.159 +
267.160 +; output
267.161 +
267.162 + yvalues = new((/2,nx/),float)
267.163 + count = new((/2,nx/),float)
267.164 +
267.165 + do nd=0,1
267.166 +
267.167 +; See if we are doing data1 (nd=0) or data2 (nd=1).
267.168 +
267.169 + base = base_1D
267.170 +
267.171 + if(nd.eq.0) then
267.172 + data = data1_1D
267.173 + else
267.174 + data = data2_1D
267.175 + end if
267.176 +
267.177 +; Loop through each range, using base.
267.178 +
267.179 + do i=0,nr-2
267.180 + if (i.ne.(nr-2)) then
267.181 +; print("")
267.182 +; print("In range ["+range(i)+","+range(i+1)+")")
267.183 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
267.184 + else
267.185 +; print("")
267.186 +; print("In range ["+range(i)+",)")
267.187 + idx = ind(base.ge.range(i))
267.188 + end if
267.189 +
267.190 +; Calculate average
267.191 +
267.192 + if(.not.any(ismissing(idx))) then
267.193 + yvalues(nd,i) = avg(data(idx))
267.194 + count(nd,i) = dimsizes(idx)
267.195 + else
267.196 + yvalues(nd,i) = yvalues@_FillValue
267.197 + count(nd,i) = 0
267.198 + end if
267.199 +
267.200 +;#############################################################
267.201 +;using observed biome class:
267.202 +; set the following 4 classes to _FillValue:
267.203 +; Water Bodies(0), Urban and Build-Up(13),
267.204 +; Permenant Snow and Ice(15), Unclassified(17)
267.205 +
267.206 +; if (i.eq.0 .or. i.eq.13 .or. i.eq.15 .or. i.eq.17) then
267.207 +; yvalues(nd,i) = yvalues@_FillValue
267.208 +; count(nd,i) = 0
267.209 +; end if
267.210 +;#############################################################
267.211 +
267.212 +;#############################################################
267.213 +;using model biome class:
267.214 +; set the following 4 classes to _FillValue:
267.215 +; (3)Needleleaf Deciduous Boreal Tree,
267.216 +; (8)Broadleaf Deciduous Boreal Tree,
267.217 +; (9)Broadleaf Evergreen Shrub,
267.218 +; (16)Wheat
267.219 +
267.220 + if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
267.221 + yvalues(nd,i) = yvalues@_FillValue
267.222 + count(nd,i) = 0
267.223 + end if
267.224 +;#############################################################
267.225 +
267.226 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
267.227 +
267.228 +; Clean up for next time in loop.
267.229 +
267.230 + delete(idx)
267.231 + end do
267.232 +
267.233 + delete(data)
267.234 + end do
267.235 +
267.236 +;============================
267.237 +;compute turnover time
267.238 +;============================
267.239 +
267.240 + u = yvalues(0,:)
267.241 + v = yvalues(1,:)
267.242 + u_count = count(0,:)
267.243 + v_count = count(1,:)
267.244 +
267.245 +;print (dimsizes(u))
267.246 +;print (dimsizes(v))
267.247 +
267.248 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
267.249 +
267.250 +;print (good)
267.251 +
267.252 + uu = u(good)
267.253 + vv = v(good)
267.254 +
267.255 +;print (dimsizes(uu))
267.256 +;print (dimsizes(vv))
267.257 +
267.258 + uu_count = u_count(good)
267.259 + vv_count = v_count(good)
267.260 +
267.261 + n_biome = dimsizes(uu)
267.262 + t_biome = new((/n_biome/),float)
267.263 +
267.264 + t_biome = uu/vv
267.265 +
267.266 +;t_biome_avg = avg(t_biome)
267.267 + t_biome_avg = sum(uu*uu_count)/sum(vv*vv_count)
267.268 +
267.269 +;print (t_biome)
267.270 +;print (t_biome_avg)
267.271 +
267.272 +;===========================
267.273 +; for html table - biome
267.274 +;===========================
267.275 +
267.276 + output_html = "table_"+component(k)+".html"
267.277 +
267.278 +; column (not including header column)
267.279 +
267.280 + col_head = (/component(k)+" Flux",component(k)+" Pool",component(k)+" Turnover Time"/)
267.281 +
267.282 + ncol = dimsizes(col_head)
267.283 +
267.284 +; row (not including header row)
267.285 +
267.286 +;----------------------------------------------------
267.287 +; using observed biome class:
267.288 +; row_head = (/"Evergreen Needleleaf Forests" \
267.289 +; ,"Evergreen Broadleaf Forests" \
267.290 +; ,"Deciduous Needleleaf Forest" \
267.291 +; ,"Deciduous Broadleaf Forests" \
267.292 +; ,"Mixed Forests" \
267.293 +; ,"Closed Bushlands" \
267.294 +; ,"Open Bushlands" \
267.295 +; ,"Woody Savannas (S. Hem.)" \
267.296 +; ,"Savannas (S. Hem.)" \
267.297 +; ,"Grasslands" \
267.298 +; ,"Permanent Wetlands" \
267.299 +; ,"Croplands" \
267.300 +; ,"Cropland/Natural Vegetation Mosaic" \
267.301 +; ,"Barren or Sparsely Vegetated" \
267.302 +; ,"Woody Savannas (N. Hem.)" \
267.303 +; ,"Savannas (N. Hem.)" \
267.304 +; ,"All Biome" \
267.305 +; /)
267.306 +
267.307 +;----------------------------------------------------
267.308 +; using model biome class:
267.309 + row_head = (/"Not Vegetated" \
267.310 + ,"Needleleaf Evergreen Temperate Tree" \
267.311 + ,"Needleleaf Evergreen Boreal Tree" \
267.312 +; ,"Needleleaf Deciduous Boreal Tree" \
267.313 + ,"Broadleaf Evergreen Tropical Tree" \
267.314 + ,"Broadleaf Evergreen Temperate Tree" \
267.315 + ,"Broadleaf Deciduous Tropical Tree" \
267.316 + ,"Broadleaf Deciduous Temperate Tree" \
267.317 +; ,"Broadleaf Deciduous Boreal Tree" \
267.318 +; ,"Broadleaf Evergreen Shrub" \
267.319 + ,"Broadleaf Deciduous Temperate Shrub" \
267.320 + ,"Broadleaf Deciduous Boreal Shrub" \
267.321 + ,"C3 Arctic Grass" \
267.322 + ,"C3 Non-Arctic Grass" \
267.323 + ,"C4 Grass" \
267.324 + ,"Corn" \
267.325 +; ,"Wheat" \
267.326 + ,"All Biome" \
267.327 + /)
267.328 + nrow = dimsizes(row_head)
267.329 +
267.330 +; arrays to be passed to table.
267.331 + text4 = new ((/nrow, ncol/),string )
267.332 +
267.333 + do i=0,nrow-2
267.334 + text4(i,0) = sprintf("%.1f",vv(i))
267.335 + text4(i,1) = sprintf("%.1f",uu(i))
267.336 + text4(i,2) = sprintf("%.2f",t_biome(i))
267.337 + end do
267.338 + text4(nrow-1,0) = "-"
267.339 + text4(nrow-1,1) = "-"
267.340 + text4(nrow-1,2) = sprintf("%.2f",t_biome_avg)
267.341 +
267.342 +;**************************************************
267.343 +; html table
267.344 +;**************************************************
267.345 +
267.346 + header_text = "<H1>"+component(k)+" Turnover Time: Model "+model_name+"</H1>"
267.347 +
267.348 + header = (/"<HTML>" \
267.349 + ,"<HEAD>" \
267.350 + ,"<TITLE>CLAMP metrics</TITLE>" \
267.351 + ,"</HEAD>" \
267.352 + ,header_text \
267.353 + /)
267.354 + footer = "</HTML>"
267.355 +
267.356 + table_header = (/ \
267.357 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
267.358 + ,"<tr>" \
267.359 + ," <th bgcolor=DDDDDD >Biome Class</th>" \
267.360 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
267.361 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
267.362 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
267.363 + ,"</tr>" \
267.364 + /)
267.365 + table_footer = "</table>"
267.366 + row_header = "<tr>"
267.367 + row_footer = "</tr>"
267.368 +
267.369 + lines = new(50000,string)
267.370 + nline = 0
267.371 +
267.372 + set_line(lines,nline,header)
267.373 + set_line(lines,nline,table_header)
267.374 +;-----------------------------------------------
267.375 +;row of table
267.376 +
267.377 + do n = 0,nrow-1
267.378 + set_line(lines,nline,row_header)
267.379 +
267.380 + txt1 = row_head(n)
267.381 + txt2 = text4(n,0)
267.382 + txt3 = text4(n,1)
267.383 + txt4 = text4(n,2)
267.384 +
267.385 + set_line(lines,nline,"<th>"+txt1+"</th>")
267.386 + set_line(lines,nline,"<th>"+txt2+"</th>")
267.387 + set_line(lines,nline,"<th>"+txt3+"</th>")
267.388 + set_line(lines,nline,"<th>"+txt4+"</th>")
267.389 +
267.390 + set_line(lines,nline,row_footer)
267.391 + end do
267.392 +;-----------------------------------------------
267.393 + set_line(lines,nline,table_footer)
267.394 + set_line(lines,nline,footer)
267.395 +
267.396 +; Now write to an HTML file.
267.397 + idx = ind(.not.ismissing(lines))
267.398 + if(.not.any(ismissing(idx))) then
267.399 + asciiwrite(output_html,lines(idx))
267.400 + else
267.401 + print ("error?")
267.402 + end if
267.403 +
267.404 + delete (idx)
267.405 +end do
267.406 +end
267.407 +
268.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
268.2 +++ b/turnover/03.biome_ob.ncl Mon Jan 26 22:08:20 2009 -0500
268.3 @@ -0,0 +1,317 @@
268.4 +;********************************************************
268.5 +; required command line input parameters:
268.6 +; ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
268.7 +;
268.8 +; histogram normalized by rain and compute correleration
268.9 +;**************************************************************
268.10 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
268.11 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
268.12 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
268.13 +;**************************************************************
268.14 +procedure set_line(lines:string,nline:integer,newlines:string)
268.15 +begin
268.16 +; add line to ascci/html file
268.17 +
268.18 + nnewlines = dimsizes(newlines)
268.19 + if(nline+nnewlines-1.ge.dimsizes(lines))
268.20 + print("set_line: bad index, not setting anything.")
268.21 + return
268.22 + end if
268.23 + lines(nline:nline+nnewlines-1) = newlines
268.24 +; print ("lines = " + lines(nline:nline+nnewlines-1))
268.25 + nline = nline + nnewlines
268.26 + return
268.27 +end
268.28 +;**************************************************************
268.29 +; Main code.
268.30 +begin
268.31 +
268.32 + plot_type = "ps"
268.33 + plot_type_new = "png"
268.34 +
268.35 +;components
268.36 +
268.37 + component = (/"Leaf","Wood","Fine_Root","Litter","Coarse_Woody_Debris","Soil"/)
268.38 + n_comp = dimsizes(component)
268.39 +
268.40 + field_pool = (/"LEAFC","WOODC","FROOTC","LITTERC","CWDC","SOILC"/)
268.41 + field_flux = (/"LEAFC_ALLOC","WOODC_ALLOC","FROOTC_ALLOC","LITTERC_LOSS","CWDC_LOSS","SOILC_HR"/)
268.42 +
268.43 +;************************************************
268.44 +; read data: model
268.45 +;************************************************
268.46 +
268.47 + model_grid = "T42"
268.48 +
268.49 +;model_name = "i01.06cn"
268.50 + model_name = "i01.06casa"
268.51 +
268.52 + dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
268.53 + film = model_name + "_1980-2004_ANN_climo.nc"
268.54 +
268.55 + fm = addfile (dirm+film,"r")
268.56 +
268.57 + do k = 0,n_comp-1
268.58 +
268.59 + pool = fm->$field_pool(k)$
268.60 + flux = fm->$field_flux(k)$
268.61 +
268.62 +;Units for these variables are:
268.63 +;pool: g C/m^2
268.64 +;flux: g C/m^2/s
268.65 +
268.66 + nsec_per_year = 60*60*24*365
268.67 +
268.68 + flux = flux * nsec_per_year
268.69 +
268.70 +; casa only
268.71 +; all the plant pools (leaf, wood, and fine root) and
268.72 +; coarse woody debris (cwd) and litter pools for
268.73 +; CASA need to be divided by 1200. The soil flux
268.74 +; and turnover time are fine and do not need to be adjusted.
268.75 +
268.76 + if (k .ne. n_comp-1) then
268.77 + flux = flux/1200.
268.78 + end if
268.79 +;************************************************
268.80 +; read data: observed-biome
268.81 +;************************************************
268.82 +
268.83 + ob_name = "MODIS MOD 15A2 2000-2005"
268.84 +
268.85 + diro = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
268.86 + filo = "land_class_"+model_grid+".nc"
268.87 +
268.88 + fo = addfile(diro+filo,"r")
268.89 +
268.90 + classob = tofloat(fo->LAND_CLASS)
268.91 +
268.92 + nclass = 20
268.93 +
268.94 +;*******************************************************************
268.95 +; Calculate "nice" bins for binning the data in equally spaced ranges
268.96 +;********************************************************************
268.97 +
268.98 + nclassn = nclass + 1
268.99 + range = fspan(0,nclassn-1,nclassn)
268.100 +; print (range)
268.101 +
268.102 +; Use this range information to grab all the values in a
268.103 +; particular range, and then take an average.
268.104 +
268.105 + nr = dimsizes(range)
268.106 + nx = nr-1
268.107 + xvalues = new((/2,nx/),float)
268.108 + xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
268.109 + dx = xvalues(0,1) - xvalues(0,0) ; range width
268.110 + dx4 = dx/4 ; 1/4 of the range
268.111 + xvalues(1,:) = xvalues(0,:) - dx/5.
268.112 +
268.113 +; get data
268.114 +
268.115 + base_1D = ndtooned(classob)
268.116 + data1_1D = ndtooned(pool)
268.117 + data2_1D = ndtooned(flux)
268.118 +
268.119 +; output
268.120 +
268.121 + yvalues = new((/2,nx/),float)
268.122 + count = new((/2,nx/),float)
268.123 +
268.124 + do nd=0,1
268.125 +
268.126 +; See if we are doing data1 (nd=0) or data2 (nd=1).
268.127 +
268.128 + base = base_1D
268.129 +
268.130 + if(nd.eq.0) then
268.131 + data = data1_1D
268.132 + else
268.133 + data = data2_1D
268.134 + end if
268.135 +
268.136 +; Loop through each range, using base.
268.137 +
268.138 + do i=0,nr-2
268.139 + if (i.ne.(nr-2)) then
268.140 +; print("")
268.141 +; print("In range ["+range(i)+","+range(i+1)+")")
268.142 + idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
268.143 + else
268.144 +; print("")
268.145 +; print("In range ["+range(i)+",)")
268.146 + idx = ind(base.ge.range(i))
268.147 + end if
268.148 +
268.149 +; Calculate average
268.150 +
268.151 + if(.not.any(ismissing(idx))) then
268.152 + yvalues(nd,i) = avg(data(idx))
268.153 + count(nd,i) = dimsizes(idx)
268.154 + else
268.155 + yvalues(nd,i) = yvalues@_FillValue
268.156 + count(nd,i) = 0
268.157 + end if
268.158 +
268.159 +;#############################################################
268.160 +; set the following 4 classes to _FillValue:
268.161 +; Water Bodies(0), Urban and Build-Up(13),
268.162 +; Permenant Snow and Ice(15), Unclassified(17)
268.163 +
268.164 + if (i.eq.0 .or. i.eq.13 .or. i.eq.15 .or. i.eq.17) then
268.165 + yvalues(nd,i) = yvalues@_FillValue
268.166 + count(nd,i) = 0
268.167 + end if
268.168 +;#############################################################
268.169 +
268.170 +; print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
268.171 +
268.172 +; Clean up for next time in loop.
268.173 +
268.174 + delete(idx)
268.175 + end do
268.176 +
268.177 + delete(data)
268.178 + end do
268.179 +
268.180 +;============================
268.181 +;compute turnover time
268.182 +;============================
268.183 +
268.184 + u = yvalues(0,:)
268.185 + v = yvalues(1,:)
268.186 + u_count = count(0,:)
268.187 + v_count = count(1,:)
268.188 +
268.189 + good = ind(.not.ismissing(u) .and. .not.ismissing(v))
268.190 +
268.191 + uu = u(good)
268.192 + vv = v(good)
268.193 + uu_count = u_count(good)
268.194 + vv_count = v_count(good)
268.195 +
268.196 + n_biome = dimsizes(uu)
268.197 + t_biome = new((/n_biome/),float)
268.198 +
268.199 + t_biome = uu/vv
268.200 +
268.201 +;t_biome_avg = avg(t_biome)
268.202 + t_biome_avg = sum(uu*uu_count)/sum(vv*vv_count)
268.203 +
268.204 +;print (t_biome)
268.205 +;print (t_biome_avg)
268.206 +
268.207 +;===========================
268.208 +; for html table - biome
268.209 +;===========================
268.210 +
268.211 + output_html = "table_"+component(k)+".html"
268.212 +
268.213 +; column (not including header column)
268.214 +
268.215 + col_head = (/component(k)+" Flux",component(k)+" Pool",component(k)+" Turnover Time"/)
268.216 +
268.217 + ncol = dimsizes(col_head)
268.218 +
268.219 +; row (not including header row)
268.220 +; 4 classes removed: Water Bodies, Urban and Build-Up,
268.221 +; Unclassified, Permanent Snow and Ice
268.222 +
268.223 + row_head = (/"Evergreen Needleleaf Forests" \
268.224 + ,"Evergreen Broadleaf Forests" \
268.225 + ,"Deciduous Needleleaf Forest" \
268.226 + ,"Deciduous Broadleaf Forests" \
268.227 + ,"Mixed Forests" \
268.228 + ,"Closed Bushlands" \
268.229 + ,"Open Bushlands" \
268.230 + ,"Woody Savannas (S. Hem.)" \
268.231 + ,"Savannas (S. Hem.)" \
268.232 + ,"Grasslands" \
268.233 + ,"Permanent Wetlands" \
268.234 + ,"Croplands" \
268.235 + ,"Cropland/Natural Vegetation Mosaic" \
268.236 + ,"Barren or Sparsely Vegetated" \
268.237 + ,"Woody Savannas (N. Hem.)" \
268.238 + ,"Savannas (N. Hem.)" \
268.239 + ,"All Biome" \
268.240 + /)
268.241 + nrow = dimsizes(row_head)
268.242 +
268.243 +; arrays to be passed to table.
268.244 + text4 = new ((/nrow, ncol/),string )
268.245 +
268.246 + do i=0,nrow-2
268.247 + text4(i,0) = sprintf("%.1f",vv(i))
268.248 + text4(i,1) = sprintf("%.1f",uu(i))
268.249 + text4(i,2) = sprintf("%.2f",t_biome(i))
268.250 + end do
268.251 + text4(nrow-1,0) = "-"
268.252 + text4(nrow-1,1) = "-"
268.253 + text4(nrow-1,2) = sprintf("%.2f",t_biome_avg)
268.254 +
268.255 +;**************************************************
268.256 +; html table
268.257 +;**************************************************
268.258 +
268.259 + header_text = "<H1>"+component(k)+" Turnover Time: Model "+model_name+"</H1>"
268.260 +
268.261 + header = (/"<HTML>" \
268.262 + ,"<HEAD>" \
268.263 + ,"<TITLE>CLAMP metrics</TITLE>" \
268.264 + ,"</HEAD>" \
268.265 + ,header_text \
268.266 + /)
268.267 + footer = "</HTML>"
268.268 +
268.269 + table_header = (/ \
268.270 + "<table border=1 cellspacing=0 cellpadding=3 width=60%>" \
268.271 + ,"<tr>" \
268.272 + ," <th bgcolor=DDDDDD >Biome Class</th>" \
268.273 + ," <th bgcolor=DDDDDD >"+col_head(0)+"</th>" \
268.274 + ," <th bgcolor=DDDDDD >"+col_head(1)+"</th>" \
268.275 + ," <th bgcolor=DDDDDD >"+col_head(2)+"</th>" \
268.276 + ,"</tr>" \
268.277 + /)
268.278 + table_footer = "</table>"
268.279 + row_header = "<tr>"
268.280 + row_footer = "</tr>"
268.281 +
268.282 + lines = new(50000,string)
268.283 + nline = 0
268.284 +
268.285 + set_line(lines,nline,header)
268.286 + set_line(lines,nline,table_header)
268.287 +;-----------------------------------------------
268.288 +;row of table
268.289 +
268.290 + do n = 0,nrow-1
268.291 + set_line(lines,nline,row_header)
268.292 +
268.293 + txt1 = row_head(n)
268.294 + txt2 = text4(n,0)
268.295 + txt3 = text4(n,1)
268.296 + txt4 = text4(n,2)
268.297 +
268.298 + set_line(lines,nline,"<th>"+txt1+"</th>")
268.299 + set_line(lines,nline,"<th>"+txt2+"</th>")
268.300 + set_line(lines,nline,"<th>"+txt3+"</th>")
268.301 + set_line(lines,nline,"<th>"+txt4+"</th>")
268.302 +
268.303 + set_line(lines,nline,row_footer)
268.304 + end do
268.305 +;-----------------------------------------------
268.306 + set_line(lines,nline,table_footer)
268.307 + set_line(lines,nline,footer)
268.308 +
268.309 +; Now write to an HTML file.
268.310 + idx = ind(.not.ismissing(lines))
268.311 + if(.not.any(ismissing(idx))) then
268.312 + asciiwrite(output_html,lines(idx))
268.313 + else
268.314 + print ("error?")
268.315 + end if
268.316 +
268.317 + delete (idx)
268.318 +end do
268.319 +end
268.320 +
269.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
269.2 +++ b/turnover/note.1 Mon Jan 26 22:08:20 2009 -0500
269.3 @@ -0,0 +1,9 @@
269.4 +Just wanted to follow up on your turnover time
269.5 +analysis for CLAMP. Forrest and I discussed the
269.6 +problem with the CASA fluxes. It looks like all
269.7 +the plant pools (leaf, wood, and fine root) and
269.8 +coarse woody debris (cwd) and litter pools for
269.9 +CASA need to be divided by 1200. The soil flux
269.10 +and turnover time are fine and do not need to be adjusted.
269.11 +
269.12 +Jim Randerson
269.13 \ No newline at end of file