lai/99.all.ncl.1
author Forrest Hoffman <forrest@climatemodeling.org>
Mon, 26 Jan 2009 22:08:20 -0500
changeset 0 0c6405ab2ff4
permissions -rw-r--r--
Initial commit of C-LAMP Diagnostics from Jeff Lee
forrest@0
     1
;********************************************************
forrest@0
     2
; histogram normalized by rain and compute correleration
forrest@0
     3
;********************************************************
forrest@0
     4
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl.test"
forrest@0
     5
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl.test"
forrest@0
     6
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
forrest@0
     7
forrest@0
     8
procedure pminmax(data:numeric,name:string)
forrest@0
     9
begin
forrest@0
    10
  print ("min/max " + name + " = " + min(data) + "/" + max(data))
forrest@0
    11
  if(isatt(data,"units")) then
forrest@0
    12
    print (name + " units = " + data@units)
forrest@0
    13
  end if
forrest@0
    14
end
forrest@0
    15
forrest@0
    16
; Main code.
forrest@0
    17
begin
forrest@0
    18
 
forrest@0
    19
 nclass = 20
forrest@0
    20
forrest@0
    21
 plot_type     = "ps"
forrest@0
    22
 plot_type_new = "png"
forrest@0
    23
forrest@0
    24
;************************************************
forrest@0
    25
; read in data: model       
forrest@0
    26
;************************************************
forrest@0
    27
;film  = "b30.061n_1995-2004_MONS_climo_lnd.nc"
forrest@0
    28
;model_name = "b30.061n"
forrest@0
    29
;model_grid = "T31"
forrest@0
    30
forrest@0
    31
;film  = "newcn05_ncep_1i_MONS_climo_lnd.nc"
forrest@0
    32
;model_name = "newcn"
forrest@0
    33
;model_grid = "1.9"
forrest@0
    34
forrest@0
    35
;film  = "i01.06cn_1798-2004_MONS_climo.nc"
forrest@0
    36
;model_name = "06cn"
forrest@0
    37
;model_grid = "T42"
forrest@0
    38
forrest@0
    39
;film  = "i01.06casa_1798-2004_MONS_climo.nc"
forrest@0
    40
;model_name = "06casa"
forrest@0
    41
;model_grid = "T42"
forrest@0
    42
forrest@0
    43
 film  = "i01.10cn_1948-2004_MONS_climo.nc"
forrest@0
    44
 model_name = "10cn"
forrest@0
    45
 model_grid = "T42"
forrest@0
    46
forrest@0
    47
;film  = "i01.10casa_1948-2004_MONS_climo.nc"
forrest@0
    48
;model_name = "10casa"
forrest@0
    49
;model_grid = "T42"
forrest@0
    50
forrest@0
    51
 system("sed s#model_name#"+model_name+"# table.html > table.html.new")
forrest@0
    52
 system("mv -f table.html.new table.html")
forrest@0
    53
;------------------------------------------------
forrest@0
    54
 dirm  = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
forrest@0
    55
 fm    = addfile(dirm+film,"r")
forrest@0
    56
      
forrest@0
    57
 laimod  = fm->TLAI
forrest@0
    58
      
forrest@0
    59
;************************************************
forrest@0
    60
; read in data: observed
forrest@0
    61
;************************************************
forrest@0
    62
forrest@0
    63
 ob_name = "MODIS MOD 15A2 2000-2005"
forrest@0
    64
forrest@0
    65
 diro  = "/fis/cgd/cseg/people/jeff/clamp_data/lai/ob/"
forrest@0
    66
 filo1  = "land_class_"+model_grid+".nc"
forrest@0
    67
 filo2  = "LAI_2000-2005_MONS_"+model_grid+".nc"
forrest@0
    68
forrest@0
    69
 fo1 = addfile(diro+filo1,"r")
forrest@0
    70
 fo2 = addfile(diro+filo2,"r")
forrest@0
    71
 
forrest@0
    72
 classob    = tofloat(fo1->LAND_CLASS)               
forrest@0
    73
 laiob      = fo2->LAI
forrest@0
    74
 
forrest@0
    75
;*******************************************************************
forrest@0
    76
; for plotting table
forrest@0
    77
;*******************************************************************
forrest@0
    78
; table header name
forrest@0
    79
  table_header_name = "LAI" 
forrest@0
    80
forrest@0
    81
; column (not including header column)
forrest@0
    82
forrest@0
    83
  col_header1 = (/"Mean","Max","Phase","Growth"/)
forrest@0
    84
  col_header2 = (/"ob","model","M" \
forrest@0
    85
                 ,"ob","model","M" \
forrest@0
    86
                 ,"ob","model","M" \
forrest@0
    87
                 ,"ob","model","M" \
forrest@0
    88
                 /)
forrest@0
    89
forrest@0
    90
  ncol1 = dimsizes(col_header1)
forrest@0
    91
  ncol2 = dimsizes(col_header2)
forrest@0
    92
  ncol  = ncol2 
forrest@0
    93
forrest@0
    94
; row (not including header row)
forrest@0
    95
  row_header = (/"Water Bodies" \
forrest@0
    96
                ,"Evergreen Needleleaf Forests" \
forrest@0
    97
                ,"Evergreen Broadleaf Forests" \
forrest@0
    98
                ,"Deciduous Needleleaf Forest" \
forrest@0
    99
                ,"Deciduous Broadleaf Forests" \
forrest@0
   100
                ,"Mixed Forests" \                      
forrest@0
   101
                ,"Closed Bushlands" \                   
forrest@0
   102
                ,"Open Bushlands" \                     
forrest@0
   103
                ,"Woody Savannas (S. Hem.)" \           
forrest@0
   104
                ,"Savannas (S. Hem.)" \                 
forrest@0
   105
                ,"Grasslands" \                         
forrest@0
   106
                ,"Permanent Wetlands" \                 
forrest@0
   107
                ,"Croplands" \                          
forrest@0
   108
                ,"Urban and Built-Up" \                 
forrest@0
   109
                ,"Cropland/Natural Vegetation Mosaic" \ 
forrest@0
   110
                ,"Permanent Snow and Ice" \             
forrest@0
   111
                ,"Barren or Sparsely Vegetated" \       
forrest@0
   112
                ,"Unclassified" \                       
forrest@0
   113
                ,"Woody Savannas (N. Hem.)" \           
forrest@0
   114
                ,"Savannas (N. Hem.)" \
forrest@0
   115
                ,"All biome average" \                
forrest@0
   116
                /)  
forrest@0
   117
  nrow = dimsizes(row_header)                  
forrest@0
   118
forrest@0
   119
; arrays to be passed to table. 
forrest@0
   120
  value = new ((/nrow, ncol/),string ) 
forrest@0
   121
forrest@0
   122
  table_length = 0.995 
forrest@0
   123
forrest@0
   124
; Table header
forrest@0
   125
  ncr1  = (/1,1/)               ; 1 row, 1 column
forrest@0
   126
  xx1    = (/0.005,0.25/)        ; Start and end X
forrest@0
   127
  yy1    = (/0.900,0.995/)       ; Start and end Y
forrest@0
   128
  text1 = table_header_name
forrest@0
   129
  res1               = True
forrest@0
   130
  res1@txFontHeightF = 0.03
forrest@0
   131
  res1@gsFillColor   = "CornFlowerBlue"
forrest@0
   132
forrest@0
   133
; Column header (equally space in x2)
forrest@0
   134
  ncr21  = (/1,ncol1/)            ; 1 rows, 4 columns
forrest@0
   135
  xx21    = (/xx1(1),0.995/)        ; start from end of x1
forrest@0
   136
  yy21    = (/0.9475,0.995/)        ; half of y1
forrest@0
   137
  text21 = col_header1
forrest@0
   138
  res21               = True
forrest@0
   139
  res21@txFontHeightF = 0.015
forrest@0
   140
  res21@gsFillColor   = "Gray"
forrest@0
   141
forrest@0
   142
  ncr22  = (/1,ncol2/)            ; 1 rows, 12 columns
forrest@0
   143
  xx22    = xx21                    ; start from end of x1
forrest@0
   144
  yy22    = (/0.900,0.9475/)       ; half of y1
forrest@0
   145
  text22 = col_header2
forrest@0
   146
  res22               = True
forrest@0
   147
  res22@txFontHeightF = 0.015
forrest@0
   148
  res22@gsFillColor   = "Gray"
forrest@0
   149
forrest@0
   150
; Row header (equally space in y2)
forrest@0
   151
  ncr3  = (/nrow,1/)              ; 20 rows, 1 columns
forrest@0
   152
  xx3    = xx1                      ; same as x1
forrest@0
   153
  yy3    = (/1.0-table_length,0.900/) ; end at start of y1
forrest@0
   154
  text3 = row_header
forrest@0
   155
  res3               = True
forrest@0
   156
  res3@txFontHeightF = 0.01
forrest@0
   157
  res3@gsFillColor   = "Gray"
forrest@0
   158
forrest@0
   159
; Main table body
forrest@0
   160
  ncr4  = (/nrow,ncol/) ; 5 rows, 5 columns
forrest@0
   161
  xx4    = xx21                      ; Start and end x
forrest@0
   162
  yy4    = yy3                      ; Start and end Y
forrest@0
   163
  text4 = new((/nrow,ncol/),string)
forrest@0
   164
forrest@0
   165
  color_fill4      = new((/nrow,ncol/),string)
forrest@0
   166
  color_fill4      = "white"
forrest@0
   167
  color_fill4(nrow-1,:) = "CornFlowerBlue"
forrest@0
   168
forrest@0
   169
  res4               = True       ; Set up resource list
forrest@0
   170
; res4@gsnDebug      = True       ; Useful to print NDC row,col values used.
forrest@0
   171
  res4@txFontHeightF = 0.015
forrest@0
   172
  res4@gsFillColor   = color_fill4
forrest@0
   173
forrest@0
   174
  delete (color_fill4)
forrest@0
   175
forrest@0
   176
;************************************************
forrest@0
   177
; plot global land class: observed
forrest@0
   178
;************************************************
forrest@0
   179
;global res
forrest@0
   180
forrest@0
   181
  resg                     = True             ; Use plot options
forrest@0
   182
  resg@cnFillOn            = True             ; Turn on color fill
forrest@0
   183
  resg@gsnSpreadColors     = True             ; use full colormap
forrest@0
   184
; resg@cnFillMode          = "RasterFill"     ; Turn on raster color
forrest@0
   185
; resg@lbLabelAutoStride   = True
forrest@0
   186
  resg@cnLinesOn           = False            ; Turn off contourn lines
forrest@0
   187
  resg@mpFillOn            = False            ; Turn off map fill
forrest@0
   188
forrest@0
   189
  resg@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
   190
  resg@cnMinLevelValF       = 1.              ; Min level
forrest@0
   191
  resg@cnMaxLevelValF       = 19.             ; Max level
forrest@0
   192
  resg@cnLevelSpacingF      = 1.              ; interval
forrest@0
   193
forrest@0
   194
;global contour ob
forrest@0
   195
  classob@_FillValue = 1.e+36
forrest@0
   196
  classob = where(classob.eq.0,classob@_FillValue,classob)
forrest@0
   197
  
forrest@0
   198
  plot_name = "global_class_ob"
forrest@0
   199
  title     = ob_name
forrest@0
   200
  resg@tiMainString  = title
forrest@0
   201
forrest@0
   202
  wks = gsn_open_wks (plot_type,plot_name)   ; open workstation
forrest@0
   203
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
   204
forrest@0
   205
  plot = gsn_csm_contour_map_ce(wks,classob,resg)   
forrest@0
   206
  frame(wks)
forrest@0
   207
forrest@0
   208
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
   209
  system("rm "+plot_name+"."+plot_type)
forrest@0
   210
  system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
   211
  system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
   212
forrest@0
   213
  clear (wks)
forrest@0
   214
;*******************************************************************
forrest@0
   215
; Calculate "nice" bins for binning the data in equally spaced ranges
forrest@0
   216
;********************************************************************
forrest@0
   217
  nclassn     = nclass + 1
forrest@0
   218
  range       = fspan(0,nclassn-1,nclassn)
forrest@0
   219
; print (range)
forrest@0
   220
forrest@0
   221
; Use this range information to grab all the values in a
forrest@0
   222
; particular range, and then take an average.
forrest@0
   223
forrest@0
   224
  nr           = dimsizes(range)
forrest@0
   225
  nx           = nr-1
forrest@0
   226
  xvalues      = new((/2,nx/),float)
forrest@0
   227
  xvalues(0,:) = range(0:nr-2) + (range(1:)-range(0:nr-2))/2.
forrest@0
   228
  dx           = xvalues(0,1) - xvalues(0,0)       ; range width
forrest@0
   229
  dx4          = dx/4                              ; 1/4 of the range
forrest@0
   230
  xvalues(1,:) = xvalues(0,:) - dx/5.
forrest@0
   231
;-----------------------------------------------------------------
forrest@0
   232
;(A) mean
forrest@0
   233
;--------------------------------------------------------------------
forrest@0
   234
; get data
forrest@0
   235
forrest@0
   236
  laiob_mean  = dim_avg_Wrap(laiob(lat|:,lon|:,time|:))
forrest@0
   237
  laimod_mean = dim_avg_Wrap(laimod(lat|:,lon|:,time|:))
forrest@0
   238
forrest@0
   239
  DATA11_1D = ndtooned(classob)
forrest@0
   240
  DATA12_1D = ndtooned(laiob_mean)
forrest@0
   241
  DATA22_1D = ndtooned(laimod_mean)
forrest@0
   242
forrest@0
   243
  yvalues      = new((/2,nx/),float)
forrest@0
   244
  mn_yvalues   = new((/2,nx/),float)
forrest@0
   245
  mx_yvalues   = new((/2,nx/),float)
forrest@0
   246
forrest@0
   247
  do nd=0,1
forrest@0
   248
forrest@0
   249
; See if we are doing model or observational data.
forrest@0
   250
forrest@0
   251
    if(nd.eq.0) then
forrest@0
   252
      data_ob  = DATA11_1D
forrest@0
   253
      data_mod = DATA12_1D
forrest@0
   254
    else
forrest@0
   255
      data_ob  = DATA11_1D
forrest@0
   256
      data_mod = DATA22_1D
forrest@0
   257
    end if
forrest@0
   258
forrest@0
   259
; Loop through each range and check for values.
forrest@0
   260
forrest@0
   261
    do i=0,nr-2
forrest@0
   262
      if (i.ne.(nr-2)) then
forrest@0
   263
;        print("")
forrest@0
   264
;        print("In range ["+range(i)+","+range(i+1)+")")
forrest@0
   265
         idx = ind((data_ob.ge.range(i)).and.(data_ob.lt.range(i+1)))
forrest@0
   266
      else
forrest@0
   267
;        print("")
forrest@0
   268
;        print("In range ["+range(i)+",)")
forrest@0
   269
         idx = ind(data_ob.ge.range(i))
forrest@0
   270
      end if
forrest@0
   271
forrest@0
   272
; Calculate average, and get min and max.
forrest@0
   273
forrest@0
   274
      if(.not.any(ismissing(idx))) then
forrest@0
   275
        yvalues(nd,i)    = avg(data_mod(idx))
forrest@0
   276
        mn_yvalues(nd,i) = min(data_mod(idx))
forrest@0
   277
        mx_yvalues(nd,i) = max(data_mod(idx))
forrest@0
   278
        count = dimsizes(idx)
forrest@0
   279
      else
forrest@0
   280
        count            = 0
forrest@0
   281
        yvalues(nd,i)    = yvalues@_FillValue
forrest@0
   282
        mn_yvalues(nd,i) = yvalues@_FillValue
forrest@0
   283
        mx_yvalues(nd,i) = yvalues@_FillValue
forrest@0
   284
      end if
forrest@0
   285
forrest@0
   286
;     print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
forrest@0
   287
;     print("Min/Max:  " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
forrest@0
   288
forrest@0
   289
; Clean up for next time in loop.
forrest@0
   290
forrest@0
   291
      delete(idx)
forrest@0
   292
    end do
forrest@0
   293
    delete(data_ob)
forrest@0
   294
    delete(data_mod)
forrest@0
   295
  end do
forrest@0
   296
;-----------------------------------------------------------------
forrest@0
   297
; compute correlation coef and M score
forrest@0
   298
forrest@0
   299
  u = yvalues(0,:)
forrest@0
   300
  v = yvalues(1,:)
forrest@0
   301
forrest@0
   302
  good = ind(.not.ismissing(u) .and. .not.ismissing(v))
forrest@0
   303
  uu = u(good)
forrest@0
   304
  vv = v(good)
forrest@0
   305
forrest@0
   306
  ccrMean = esccr(uu,vv,0)
forrest@0
   307
; print (ccrMean)
forrest@0
   308
forrest@0
   309
; new eq
forrest@0
   310
  bias  = sum(abs(vv-uu)/(vv+uu))
forrest@0
   311
  Mmean = (1.- (bias/dimsizes(uu)))*5.
forrest@0
   312
forrest@0
   313
  M_lai_mean = sprintf("%.2f", Mmean)
forrest@0
   314
  system("sed s#M_lai_mean#"+M_lai_mean+"# table.html > table.html.new")
forrest@0
   315
  system("mv -f table.html.new table.html")
forrest@0
   316
  print (M_lai_mean)
forrest@0
   317
forrest@0
   318
 do i=0,nrow-2
forrest@0
   319
  text4(i,0) = sprintf("%5.2f",u(i))
forrest@0
   320
  text4(i,1) = sprintf("%5.2f",v(i))
forrest@0
   321
  text4(i,2) = "-"
forrest@0
   322
 end do
forrest@0
   323
  text4(nrow-1,0) = sprintf("%5.2f",avg(u))
forrest@0
   324
  text4(nrow-1,1) = sprintf("%5.2f",avg(v))
forrest@0
   325
  text4(nrow-1,2) = sprintf("%5.2f",Mmean)
forrest@0
   326
forrest@0
   327
 delete (u)
forrest@0
   328
 delete (v)
forrest@0
   329
 delete (uu)
forrest@0
   330
 delete (vv)
forrest@0
   331
;--------------------------------------------------------------------
forrest@0
   332
; histogram res
forrest@0
   333
forrest@0
   334
  resm                = True
forrest@0
   335
  resm@gsnMaximize    = True
forrest@0
   336
  resm@gsnDraw        = False
forrest@0
   337
  resm@gsnFrame       = False
forrest@0
   338
  resm@xyMarkLineMode = "Markers"
forrest@0
   339
  resm@xyMarkerSizeF  = 0.014
forrest@0
   340
  resm@xyMarker       = 16
forrest@0
   341
  resm@xyMarkerColors = (/"Brown","Blue"/)
forrest@0
   342
; resm@trYMinF        = min(mn_yvalues) - 10.
forrest@0
   343
; resm@trYMaxF        = max(mx_yvalues) + 10.
forrest@0
   344
  resm@trYMinF        = min(mn_yvalues) - 2
forrest@0
   345
  resm@trYMaxF        = max(mx_yvalues) + 4
forrest@0
   346
forrest@0
   347
  resm@tiYAxisString  = "Mean LAI (Leaf Area Index)"
forrest@0
   348
  resm@tiXAxisString  = "Land Cover Type"
forrest@0
   349
forrest@0
   350
  max_bar = new((/2,nx/),graphic)
forrest@0
   351
  min_bar = new((/2,nx/),graphic)
forrest@0
   352
  max_cap = new((/2,nx/),graphic)
forrest@0
   353
  min_cap = new((/2,nx/),graphic)
forrest@0
   354
forrest@0
   355
  lnres = True
forrest@0
   356
  line_colors = (/"brown","blue"/)
forrest@0
   357
;------------------------------------------------------------------
forrest@0
   358
; Start the graphics.
forrest@0
   359
forrest@0
   360
  plot_name = "histogram_mean"
forrest@0
   361
  title     = model_name + " vs Observed"
forrest@0
   362
  resm@tiMainString  = title
forrest@0
   363
forrest@0
   364
  wks   = gsn_open_wks (plot_type,plot_name)
forrest@0
   365
;-----------------------------
forrest@0
   366
; Add a boxed legend using the more simple method
forrest@0
   367
forrest@0
   368
  resm@pmLegendDisplayMode    = "Always"
forrest@0
   369
; resm@pmLegendWidthF         = 0.1
forrest@0
   370
  resm@pmLegendWidthF         = 0.08
forrest@0
   371
  resm@pmLegendHeightF        = 0.05
forrest@0
   372
  resm@pmLegendOrthogonalPosF = -1.17
forrest@0
   373
; resm@pmLegendOrthogonalPosF = -1.00  ;(downward)
forrest@0
   374
; resm@pmLegendParallelPosF   =  0.18
forrest@0
   375
  resm@pmLegendParallelPosF   =  0.88  ;(rightward)
forrest@0
   376
forrest@0
   377
; resm@lgPerimOn              = False
forrest@0
   378
  resm@lgLabelFontHeightF     = 0.015
forrest@0
   379
  resm@xyExplicitLegendLabels = (/"observed",model_name/)
forrest@0
   380
;-----------------------------
forrest@0
   381
  tRes  = True
forrest@0
   382
  tRes@txFontHeightF = 0.025
forrest@0
   383
forrest@0
   384
  correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMean)+")"
forrest@0
   385
forrest@0
   386
  gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
forrest@0
   387
forrest@0
   388
  xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
forrest@0
   389
;-------------------------------
forrest@0
   390
;Attach the vertical bar and the horizontal cap line 
forrest@0
   391
forrest@0
   392
  do nd=0,1
forrest@0
   393
    lnres@gsLineColor = line_colors(nd)
forrest@0
   394
    do i=0,nx-1
forrest@0
   395
     
forrest@0
   396
      if(.not.ismissing(mn_yvalues(nd,i)).and. \
forrest@0
   397
         .not.ismissing(mx_yvalues(nd,i))) then
forrest@0
   398
forrest@0
   399
; Attach the vertical bar, both above and below the marker.
forrest@0
   400
forrest@0
   401
        x1 = xvalues(nd,i)
forrest@0
   402
        y1 = yvalues(nd,i)
forrest@0
   403
        y2 = mn_yvalues(nd,i)
forrest@0
   404
        min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
forrest@0
   405
forrest@0
   406
        y2 = mx_yvalues(nd,i)
forrest@0
   407
        max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
forrest@0
   408
forrest@0
   409
; Attach the horizontal cap line, both above and below the marker.
forrest@0
   410
forrest@0
   411
        x1 = xvalues(nd,i) - dx4
forrest@0
   412
        x2 = xvalues(nd,i) + dx4
forrest@0
   413
        y1 = mn_yvalues(nd,i)
forrest@0
   414
        min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
forrest@0
   415
forrest@0
   416
        y1 = mx_yvalues(nd,i)
forrest@0
   417
        max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
forrest@0
   418
      end if
forrest@0
   419
    end do
forrest@0
   420
  end do
forrest@0
   421
forrest@0
   422
  draw(xy)
forrest@0
   423
  frame(wks)
forrest@0
   424
forrest@0
   425
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
   426
  system("rm "+plot_name+"."+plot_type)
forrest@0
   427
; system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
   428
; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
   429
forrest@0
   430
  clear (wks)
forrest@0
   431
forrest@0
   432
 delete (DATA11_1D)
forrest@0
   433
 delete (DATA12_1D)
forrest@0
   434
 delete (DATA22_1D)
forrest@0
   435
;delete (range)
forrest@0
   436
;delete (xvalues) 
forrest@0
   437
 delete (yvalues)
forrest@0
   438
 delete (mn_yvalues)
forrest@0
   439
 delete (mx_yvalues)
forrest@0
   440
 delete (good)
forrest@0
   441
 delete (max_bar)
forrest@0
   442
 delete (min_bar)
forrest@0
   443
 delete (max_cap)
forrest@0
   444
 delete (min_cap)
forrest@0
   445
;----------------------------------------------------------------- 
forrest@0
   446
;global res
forrest@0
   447
forrest@0
   448
  resg                     = True             ; Use plot options
forrest@0
   449
  resg@cnFillOn            = True             ; Turn on color fill
forrest@0
   450
  resg@gsnSpreadColors     = True             ; use full colormap
forrest@0
   451
; resg@cnFillMode          = "RasterFill"     ; Turn on raster color
forrest@0
   452
; resg@lbLabelAutoStride   = True
forrest@0
   453
  resg@cnLinesOn           = False            ; Turn off contourn lines
forrest@0
   454
  resg@mpFillOn            = False            ; Turn off map fill
forrest@0
   455
forrest@0
   456
  resg@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
   457
  resg@cnMinLevelValF       = 0.              ; Min level
forrest@0
   458
  resg@cnMaxLevelValF       = 10.             ; Max level
forrest@0
   459
  resg@cnLevelSpacingF      = 1.              ; interval
forrest@0
   460
forrest@0
   461
;global contour ob
forrest@0
   462
forrest@0
   463
  delta = 0.00001
forrest@0
   464
  laiob_mean = where(ismissing(laiob_mean).and.(ismissing(laimod_mean).or.(laimod_mean.lt.delta)),0.,laiob_mean)
forrest@0
   465
  
forrest@0
   466
  plot_name = "global_mean_ob"
forrest@0
   467
  title     = ob_name
forrest@0
   468
  resg@tiMainString  = title
forrest@0
   469
forrest@0
   470
  wks = gsn_open_wks (plot_type,plot_name)   ; open workstation
forrest@0
   471
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
   472
forrest@0
   473
  plot = gsn_csm_contour_map_ce(wks,laiob_mean,resg)   
forrest@0
   474
  frame(wks)
forrest@0
   475
forrest@0
   476
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
   477
  system("rm "+plot_name+"."+plot_type)
forrest@0
   478
  system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
   479
  system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
   480
forrest@0
   481
  clear (wks)
forrest@0
   482
;------------------------------------------------------------------------
forrest@0
   483
;global contour model
forrest@0
   484
  
forrest@0
   485
  plot_name = "global_mean_model"
forrest@0
   486
  title     = "Model " + model_name
forrest@0
   487
  resg@tiMainString  = title
forrest@0
   488
forrest@0
   489
  wks = gsn_open_wks (plot_type,plot_name)
forrest@0
   490
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
   491
forrest@0
   492
  plot = gsn_csm_contour_map_ce(wks,laimod_mean,resg)   
forrest@0
   493
  frame(wks)
forrest@0
   494
forrest@0
   495
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
   496
  system("rm "+plot_name+"."+plot_type)
forrest@0
   497
  system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
   498
  system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
   499
forrest@0
   500
  clear (wks)
forrest@0
   501
;-----------------------------------------------------------------
forrest@0
   502
;(B) max
forrest@0
   503
;--------------------------------------------------------------------
forrest@0
   504
; get data
forrest@0
   505
forrest@0
   506
; observed
forrest@0
   507
  laiob_max = laiob(0,:,:)
forrest@0
   508
  s         = laiob(:,0,0)
forrest@0
   509
  laiob_max@long_name = "Leaf Area Index Max"
forrest@0
   510
 
forrest@0
   511
  dsizes_z = dimsizes(laiob)
forrest@0
   512
  nlat     = dsizes_z(1)
forrest@0
   513
  nlon     = dsizes_z(2)
forrest@0
   514
  
forrest@0
   515
  do j = 0,nlat-1
forrest@0
   516
  do i = 0,nlon-1
forrest@0
   517
     s = laiob(:,j,i) 
forrest@0
   518
     laiob_max(j,i) = max(s)
forrest@0
   519
  end do
forrest@0
   520
  end do
forrest@0
   521
forrest@0
   522
; print (min(y)+"/"+max(y))
forrest@0
   523
  delete (s)
forrest@0
   524
  delete (dsizes_z)          
forrest@0
   525
;-------------------------
forrest@0
   526
; model
forrest@0
   527
  laimod_max = laimod(0,:,:)
forrest@0
   528
  s          = laimod(:,0,0)
forrest@0
   529
  laimod_max@long_name = "Leaf Area Index Max"
forrest@0
   530
 
forrest@0
   531
  dsizes_z = dimsizes(laimod)
forrest@0
   532
  nlat     = dsizes_z(1)
forrest@0
   533
  nlon     = dsizes_z(2)
forrest@0
   534
  
forrest@0
   535
  do j = 0,nlat-1
forrest@0
   536
  do i = 0,nlon-1
forrest@0
   537
     s = laimod(:,j,i) 
forrest@0
   538
     laimod_max(j,i) = max(s)
forrest@0
   539
  end do
forrest@0
   540
  end do
forrest@0
   541
forrest@0
   542
; print (min(laimod_max)+"/"+max(laimod_max))
forrest@0
   543
  delete (s)
forrest@0
   544
  delete (dsizes_z)          
forrest@0
   545
;------------------------
forrest@0
   546
  DATA11_1D = ndtooned(classob)
forrest@0
   547
  DATA12_1D = ndtooned(laiob_max)
forrest@0
   548
  DATA22_1D = ndtooned(laimod_max)
forrest@0
   549
forrest@0
   550
  yvalues      = new((/2,nx/),float)
forrest@0
   551
  mn_yvalues   = new((/2,nx/),float)
forrest@0
   552
  mx_yvalues   = new((/2,nx/),float)
forrest@0
   553
forrest@0
   554
  do nd=0,1
forrest@0
   555
forrest@0
   556
; See if we are doing model or observational data.
forrest@0
   557
forrest@0
   558
    if(nd.eq.0) then
forrest@0
   559
      data_ob  = DATA11_1D
forrest@0
   560
      data_mod = DATA12_1D
forrest@0
   561
    else
forrest@0
   562
      data_ob  = DATA11_1D
forrest@0
   563
      data_mod = DATA22_1D
forrest@0
   564
    end if
forrest@0
   565
forrest@0
   566
; Loop through each range and check for values.
forrest@0
   567
forrest@0
   568
    do i=0,nr-2
forrest@0
   569
      if (i.ne.(nr-2)) then
forrest@0
   570
;        print("")
forrest@0
   571
;        print("In range ["+range(i)+","+range(i+1)+")")
forrest@0
   572
        idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
forrest@0
   573
      else
forrest@0
   574
;        print("")
forrest@0
   575
;        print("In range ["+range(i)+",)")
forrest@0
   576
        idx = ind(range(i).le.data_ob)
forrest@0
   577
      end if
forrest@0
   578
forrest@0
   579
; Calculate average, and get min and max.
forrest@0
   580
forrest@0
   581
      if(.not.any(ismissing(idx))) then
forrest@0
   582
        yvalues(nd,i)    = avg(data_mod(idx))
forrest@0
   583
        mn_yvalues(nd,i) = min(data_mod(idx))
forrest@0
   584
        mx_yvalues(nd,i) = max(data_mod(idx))
forrest@0
   585
        count = dimsizes(idx)
forrest@0
   586
      else
forrest@0
   587
        count            = 0
forrest@0
   588
        yvalues(nd,i)    = yvalues@_FillValue
forrest@0
   589
        mn_yvalues(nd,i) = yvalues@_FillValue
forrest@0
   590
        mx_yvalues(nd,i) = yvalues@_FillValue
forrest@0
   591
      end if
forrest@0
   592
forrest@0
   593
;     print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
forrest@0
   594
;     print("Min/Max:  " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
forrest@0
   595
forrest@0
   596
; Clean up for next time in loop.
forrest@0
   597
forrest@0
   598
      delete(idx)
forrest@0
   599
    end do
forrest@0
   600
    delete(data_ob)
forrest@0
   601
    delete(data_mod)
forrest@0
   602
  end do
forrest@0
   603
;-----------------------------------------------------------------
forrest@0
   604
; compute correlation coef and M score
forrest@0
   605
forrest@0
   606
  u = yvalues(0,:)
forrest@0
   607
  v = yvalues(1,:)
forrest@0
   608
forrest@0
   609
  good = ind(.not.ismissing(u) .and. .not.ismissing(v))
forrest@0
   610
  uu = u(good)
forrest@0
   611
  vv = v(good)
forrest@0
   612
forrest@0
   613
  ccrMax = esccr(uu,vv,0)
forrest@0
   614
; print (ccrMax)
forrest@0
   615
forrest@0
   616
; new eq
forrest@0
   617
  bias = sum(abs(vv-uu)/(vv+uu))
forrest@0
   618
  Mmax = (1.- (bias/dimsizes(uu)))*5.
forrest@0
   619
forrest@0
   620
  M_lai_max = sprintf("%.2f", Mmax)
forrest@0
   621
  system("sed s#M_lai_max#"+M_lai_max+"# table.html > table.html.new")
forrest@0
   622
  system("mv -f table.html.new table.html")
forrest@0
   623
  print (M_lai_max)
forrest@0
   624
forrest@0
   625
 do i=0,nrow-2
forrest@0
   626
  text4(i,3) = sprintf("%5.2f",u(i))
forrest@0
   627
  text4(i,4) = sprintf("%5.2f",v(i))
forrest@0
   628
  text4(i,5) = "-"
forrest@0
   629
 end do
forrest@0
   630
  text4(nrow-1,3) = sprintf("%5.2f",avg(u))
forrest@0
   631
  text4(nrow-1,4) = sprintf("%5.2f",avg(v))
forrest@0
   632
  text4(nrow-1,5) = sprintf("%5.2f",Mmax)
forrest@0
   633
forrest@0
   634
 delete (u)
forrest@0
   635
 delete (v)
forrest@0
   636
 delete (uu)
forrest@0
   637
 delete (vv)
forrest@0
   638
;--------------------------------------------------------------------
forrest@0
   639
; histogram res
forrest@0
   640
forrest@0
   641
  resm                = True
forrest@0
   642
  resm@gsnMaximize    = True
forrest@0
   643
  resm@gsnDraw        = False
forrest@0
   644
  resm@gsnFrame       = False
forrest@0
   645
  resm@xyMarkLineMode = "Markers"
forrest@0
   646
  resm@xyMarkerSizeF  = 0.014
forrest@0
   647
  resm@xyMarker       = 16
forrest@0
   648
  resm@xyMarkerColors = (/"Brown","Blue"/)
forrest@0
   649
; resm@trYMinF        = min(mn_yvalues) - 10.
forrest@0
   650
; resm@trYMaxF        = max(mx_yvalues) + 10.
forrest@0
   651
  resm@trYMinF        = min(mn_yvalues) - 2
forrest@0
   652
  resm@trYMaxF        = max(mx_yvalues) + 4
forrest@0
   653
forrest@0
   654
  resm@tiYAxisString  = "Max LAI (Leaf Area Index)"
forrest@0
   655
  resm@tiXAxisString  = "Land Cover Type"
forrest@0
   656
forrest@0
   657
  max_bar = new((/2,nx/),graphic)
forrest@0
   658
  min_bar = new((/2,nx/),graphic)
forrest@0
   659
  max_cap = new((/2,nx/),graphic)
forrest@0
   660
  min_cap = new((/2,nx/),graphic)
forrest@0
   661
forrest@0
   662
  lnres = True
forrest@0
   663
  line_colors = (/"brown","blue"/)
forrest@0
   664
;------------------------------------------------------------------
forrest@0
   665
; Start the graphics.
forrest@0
   666
forrest@0
   667
  plot_name = "histogram_max"
forrest@0
   668
  title     = model_name + " vs Observed"
forrest@0
   669
  resm@tiMainString  = title
forrest@0
   670
forrest@0
   671
  wks   = gsn_open_wks (plot_type,plot_name)
forrest@0
   672
;-----------------------------
forrest@0
   673
; Add a boxed legend using the more simple method
forrest@0
   674
forrest@0
   675
  resm@pmLegendDisplayMode    = "Always"
forrest@0
   676
; resm@pmLegendWidthF         = 0.1
forrest@0
   677
  resm@pmLegendWidthF         = 0.08
forrest@0
   678
  resm@pmLegendHeightF        = 0.05
forrest@0
   679
  resm@pmLegendOrthogonalPosF = -1.17
forrest@0
   680
; resm@pmLegendOrthogonalPosF = -1.00  ;(downward)
forrest@0
   681
; resm@pmLegendParallelPosF   =  0.18
forrest@0
   682
  resm@pmLegendParallelPosF   =  0.88  ;(rightward)
forrest@0
   683
forrest@0
   684
; resm@lgPerimOn              = False
forrest@0
   685
  resm@lgLabelFontHeightF     = 0.015
forrest@0
   686
  resm@xyExplicitLegendLabels = (/"observed",model_name/)
forrest@0
   687
;-----------------------------
forrest@0
   688
  tRes  = True
forrest@0
   689
  tRes@txFontHeightF = 0.025
forrest@0
   690
forrest@0
   691
  correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMax)+")"
forrest@0
   692
forrest@0
   693
  gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
forrest@0
   694
forrest@0
   695
  xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
forrest@0
   696
;-------------------------------
forrest@0
   697
;Attach the vertical bar and the horizontal cap line 
forrest@0
   698
forrest@0
   699
  do nd=0,1
forrest@0
   700
    lnres@gsLineColor = line_colors(nd)
forrest@0
   701
    do i=0,nx-1
forrest@0
   702
     
forrest@0
   703
      if(.not.ismissing(mn_yvalues(nd,i)).and. \
forrest@0
   704
         .not.ismissing(mx_yvalues(nd,i))) then
forrest@0
   705
forrest@0
   706
; Attach the vertical bar, both above and below the marker.
forrest@0
   707
forrest@0
   708
        x1 = xvalues(nd,i)
forrest@0
   709
        y1 = yvalues(nd,i)
forrest@0
   710
        y2 = mn_yvalues(nd,i)
forrest@0
   711
        min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
forrest@0
   712
forrest@0
   713
        y2 = mx_yvalues(nd,i)
forrest@0
   714
        max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
forrest@0
   715
forrest@0
   716
; Attach the horizontal cap line, both above and below the marker.
forrest@0
   717
forrest@0
   718
        x1 = xvalues(nd,i) - dx4
forrest@0
   719
        x2 = xvalues(nd,i) + dx4
forrest@0
   720
        y1 = mn_yvalues(nd,i)
forrest@0
   721
        min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
forrest@0
   722
forrest@0
   723
        y1 = mx_yvalues(nd,i)
forrest@0
   724
        max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
forrest@0
   725
      end if
forrest@0
   726
    end do
forrest@0
   727
  end do
forrest@0
   728
forrest@0
   729
  draw(xy)
forrest@0
   730
  frame(wks)
forrest@0
   731
forrest@0
   732
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
   733
  system("rm "+plot_name+"."+plot_type)
forrest@0
   734
; system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
   735
; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
   736
forrest@0
   737
  clear (wks)
forrest@0
   738
forrest@0
   739
 delete (DATA11_1D)
forrest@0
   740
 delete (DATA12_1D)
forrest@0
   741
 delete (DATA22_1D)
forrest@0
   742
;delete (range)
forrest@0
   743
;delete (xvalues) 
forrest@0
   744
 delete (yvalues)
forrest@0
   745
 delete (mn_yvalues)
forrest@0
   746
 delete (mx_yvalues)
forrest@0
   747
 delete (good)
forrest@0
   748
 delete (max_bar)
forrest@0
   749
 delete (min_bar)
forrest@0
   750
 delete (max_cap)
forrest@0
   751
 delete (min_cap)
forrest@0
   752
;----------------------------------------------------------------- 
forrest@0
   753
;global res
forrest@0
   754
forrest@0
   755
  resg                     = True             ; Use plot options
forrest@0
   756
  resg@cnFillOn            = True             ; Turn on color fill
forrest@0
   757
  resg@gsnSpreadColors     = True             ; use full colormap
forrest@0
   758
; resg@cnFillMode          = "RasterFill"     ; Turn on raster color
forrest@0
   759
; resg@lbLabelAutoStride   = True
forrest@0
   760
  resg@cnLinesOn           = False            ; Turn off contourn lines
forrest@0
   761
  resg@mpFillOn            = False            ; Turn off map fill
forrest@0
   762
forrest@0
   763
  resg@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
   764
  resg@cnMinLevelValF       = 0.              ; Min level
forrest@0
   765
  resg@cnMaxLevelValF       = 10.             ; Max level
forrest@0
   766
  resg@cnLevelSpacingF      = 1.              ; interval
forrest@0
   767
forrest@0
   768
;global contour ob
forrest@0
   769
forrest@0
   770
  delta = 0.00001
forrest@0
   771
  laiob_max = where(ismissing(laiob_max).and.(ismissing(laimod_max).or.(laimod_max.lt.delta)),0.,laiob_max)
forrest@0
   772
  
forrest@0
   773
  plot_name = "global_max_ob"
forrest@0
   774
  title     = ob_name
forrest@0
   775
  resg@tiMainString  = title
forrest@0
   776
forrest@0
   777
  wks = gsn_open_wks (plot_type,plot_name)   ; open workstation
forrest@0
   778
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
   779
forrest@0
   780
  plot_max = gsn_csm_contour_map_ce(wks,laiob_max,resg)   
forrest@0
   781
  frame(wks)
forrest@0
   782
forrest@0
   783
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
   784
  system("rm "+plot_name+"."+plot_type)
forrest@0
   785
  system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
   786
  system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
   787
forrest@0
   788
  clear (wks)
forrest@0
   789
;------------------------------------------------------------------------
forrest@0
   790
;global contour model
forrest@0
   791
  
forrest@0
   792
  plot_name = "global_max_model"
forrest@0
   793
  title     = "Model " + model_name
forrest@0
   794
  resg@tiMainString  = title
forrest@0
   795
forrest@0
   796
  wks = gsn_open_wks (plot_type,plot_name)
forrest@0
   797
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
   798
forrest@0
   799
  plot_max = gsn_csm_contour_map_ce(wks,laimod_max,resg)   
forrest@0
   800
  frame(wks)
forrest@0
   801
forrest@0
   802
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
   803
  system("rm "+plot_name+"."+plot_type)
forrest@0
   804
  system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
   805
  system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
   806
forrest@0
   807
  clear (wks)
forrest@0
   808
;------------------------------------------------------------------------
forrest@0
   809
;(C) phase
forrest@0
   810
;--------------------------------------------------------------------
forrest@0
   811
; get data
forrest@0
   812
forrest@0
   813
; observed
forrest@0
   814
  laiob_phase = laiob(0,:,:)
forrest@0
   815
  s           = laiob(:,0,0)
forrest@0
   816
  laiob_phase@long_name = "Leaf Area Index Max Month"
forrest@0
   817
 
forrest@0
   818
  dsizes_z = dimsizes(laiob)
forrest@0
   819
  nlat     = dsizes_z(1)
forrest@0
   820
  nlon     = dsizes_z(2)
forrest@0
   821
  
forrest@0
   822
  do j = 0,nlat-1
forrest@0
   823
  do i = 0,nlon-1
forrest@0
   824
     s = laiob(:,j,i) 
forrest@0
   825
     laiob_phase(j,i) = maxind(s) + 1
forrest@0
   826
  end do
forrest@0
   827
  end do
forrest@0
   828
forrest@0
   829
; print (min(laiob_phase)+"/"+max(laiob_phase))
forrest@0
   830
  delete (s)
forrest@0
   831
  delete (dsizes_z)          
forrest@0
   832
;-------------------------
forrest@0
   833
; model
forrest@0
   834
  laimod_phase = laimod(0,:,:)
forrest@0
   835
  s            = laimod(:,0,0)
forrest@0
   836
  laimod_phase@long_name = "Leaf Area Index Max Month"
forrest@0
   837
 
forrest@0
   838
  dsizes_z = dimsizes(laimod)
forrest@0
   839
  nlat     = dsizes_z(1)
forrest@0
   840
  nlon     = dsizes_z(2)
forrest@0
   841
  
forrest@0
   842
  do j = 0,nlat-1
forrest@0
   843
  do i = 0,nlon-1
forrest@0
   844
     s = laimod(:,j,i) 
forrest@0
   845
     laimod_phase(j,i) = maxind(s) + 1
forrest@0
   846
  end do
forrest@0
   847
  end do
forrest@0
   848
forrest@0
   849
; print (min(laimod_phase)+"/"+max(laimod_phase))
forrest@0
   850
  delete (s)
forrest@0
   851
  delete (dsizes_z)          
forrest@0
   852
;------------------------
forrest@0
   853
  DATA11_1D = ndtooned(classob)
forrest@0
   854
  DATA12_1D = ndtooned(laiob_phase)
forrest@0
   855
  DATA22_1D = ndtooned(laimod_phase)
forrest@0
   856
forrest@0
   857
  yvalues      = new((/2,nx/),float)
forrest@0
   858
  mn_yvalues   = new((/2,nx/),float)
forrest@0
   859
  mx_yvalues   = new((/2,nx/),float)
forrest@0
   860
forrest@0
   861
  do nd=0,1
forrest@0
   862
forrest@0
   863
; See if we are doing model or observational data.
forrest@0
   864
forrest@0
   865
    if(nd.eq.0) then
forrest@0
   866
      data_ob  = DATA11_1D
forrest@0
   867
      data_mod = DATA12_1D
forrest@0
   868
    else
forrest@0
   869
      data_ob  = DATA11_1D
forrest@0
   870
      data_mod = DATA22_1D
forrest@0
   871
    end if
forrest@0
   872
forrest@0
   873
; Loop through each range and check for values.
forrest@0
   874
forrest@0
   875
    do i=0,nr-2
forrest@0
   876
      if (i.ne.(nr-2)) then
forrest@0
   877
;        print("")
forrest@0
   878
;        print("In range ["+range(i)+","+range(i+1)+")")
forrest@0
   879
        idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
forrest@0
   880
      else
forrest@0
   881
;        print("")
forrest@0
   882
;        print("In range ["+range(i)+",)")
forrest@0
   883
        idx = ind(range(i).le.data_ob)
forrest@0
   884
      end if
forrest@0
   885
forrest@0
   886
; Calculate average, and get min and max.
forrest@0
   887
forrest@0
   888
      if(.not.any(ismissing(idx))) then
forrest@0
   889
        yvalues(nd,i)    = avg(data_mod(idx))
forrest@0
   890
        mn_yvalues(nd,i) = min(data_mod(idx))
forrest@0
   891
        mx_yvalues(nd,i) = max(data_mod(idx))
forrest@0
   892
        count = dimsizes(idx)
forrest@0
   893
      else
forrest@0
   894
        count            = 0
forrest@0
   895
        yvalues(nd,i)    = yvalues@_FillValue
forrest@0
   896
        mn_yvalues(nd,i) = yvalues@_FillValue
forrest@0
   897
        mx_yvalues(nd,i) = yvalues@_FillValue
forrest@0
   898
      end if
forrest@0
   899
forrest@0
   900
;     print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
forrest@0
   901
;     print("Min/Max:  " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
forrest@0
   902
forrest@0
   903
; Clean up for next time in loop.
forrest@0
   904
forrest@0
   905
      delete(idx)
forrest@0
   906
    end do
forrest@0
   907
    delete(data_ob)
forrest@0
   908
    delete(data_mod)
forrest@0
   909
  end do
forrest@0
   910
;-----------------------------------------------------------------
forrest@0
   911
; compute correlation coef and M score
forrest@0
   912
forrest@0
   913
  u = yvalues(0,:)
forrest@0
   914
  v = yvalues(1,:)
forrest@0
   915
forrest@0
   916
  good = ind(.not.ismissing(u) .and. .not.ismissing(v))
forrest@0
   917
  uu = u(good)
forrest@0
   918
  vv = v(good)
forrest@0
   919
forrest@0
   920
  ccrPhase = esccr(uu,vv,0)
forrest@0
   921
; print (ccrPhase)
forrest@0
   922
forrest@0
   923
; old eq
forrest@0
   924
; bias   = abs(avg(vv)-avg(uu))
forrest@0
   925
; new eq
forrest@0
   926
  bias   = avg(abs(vv-uu))
forrest@0
   927
forrest@0
   928
  bias   = where((bias.gt. 6.),12.-bias,bias)
forrest@0
   929
  Mphase = ((6. - bias)/6.)*5.
forrest@0
   930
forrest@0
   931
  M_lai_phase = sprintf("%.2f", Mphase)
forrest@0
   932
  system("sed s#M_lai_phase#"+M_lai_phase+"# table.html > table.html.new")
forrest@0
   933
  system("mv -f table.html.new table.html")
forrest@0
   934
  print (M_lai_phase)
forrest@0
   935
forrest@0
   936
 do i=0,nrow-2
forrest@0
   937
  text4(i,6) = sprintf("%5.2f",u(i))
forrest@0
   938
  text4(i,7) = sprintf("%5.2f",v(i))
forrest@0
   939
  text4(i,8) = "-"
forrest@0
   940
 end do
forrest@0
   941
  text4(nrow-1,6) = sprintf("%5.2f",avg(u))
forrest@0
   942
  text4(nrow-1,7) = sprintf("%5.2f",avg(v))
forrest@0
   943
  text4(nrow-1,8) = sprintf("%5.2f",Mphase)
forrest@0
   944
forrest@0
   945
 delete (u)
forrest@0
   946
 delete (v)
forrest@0
   947
 delete (uu)
forrest@0
   948
 delete (vv)
forrest@0
   949
;--------------------------------------------------------------------
forrest@0
   950
; histogram res
forrest@0
   951
forrest@0
   952
  resm                = True
forrest@0
   953
  resm@gsnMaximize    = True
forrest@0
   954
  resm@gsnDraw        = False
forrest@0
   955
  resm@gsnFrame       = False
forrest@0
   956
  resm@xyMarkLineMode = "Markers"
forrest@0
   957
  resm@xyMarkerSizeF  = 0.014
forrest@0
   958
  resm@xyMarker       = 16
forrest@0
   959
  resm@xyMarkerColors = (/"Brown","Blue"/)
forrest@0
   960
; resm@trYMinF        = min(mn_yvalues) - 10.
forrest@0
   961
; resm@trYMaxF        = max(mx_yvalues) + 10.
forrest@0
   962
  resm@trYMinF        = min(mn_yvalues) - 2
forrest@0
   963
  resm@trYMaxF        = max(mx_yvalues) + 4
forrest@0
   964
forrest@0
   965
  resm@tiYAxisString  = "Max LAI (Leaf Area Index) Month"
forrest@0
   966
  resm@tiXAxisString  = "Land Cover Type"
forrest@0
   967
forrest@0
   968
  max_bar = new((/2,nx/),graphic)
forrest@0
   969
  min_bar = new((/2,nx/),graphic)
forrest@0
   970
  max_cap = new((/2,nx/),graphic)
forrest@0
   971
  min_cap = new((/2,nx/),graphic)
forrest@0
   972
forrest@0
   973
  lnres = True
forrest@0
   974
  line_colors = (/"brown","blue"/)
forrest@0
   975
;------------------------------------------------------------------
forrest@0
   976
; Start the graphics.
forrest@0
   977
forrest@0
   978
  plot_name = "histogram_phase"
forrest@0
   979
  title     = model_name + " vs Observed"
forrest@0
   980
  resm@tiMainString  = title
forrest@0
   981
forrest@0
   982
  wks   = gsn_open_wks (plot_type,plot_name)
forrest@0
   983
;-----------------------------
forrest@0
   984
; Add a boxed legend using the more simple method
forrest@0
   985
forrest@0
   986
  resm@pmLegendDisplayMode    = "Always"
forrest@0
   987
; resm@pmLegendWidthF         = 0.1
forrest@0
   988
  resm@pmLegendWidthF         = 0.08
forrest@0
   989
  resm@pmLegendHeightF        = 0.05
forrest@0
   990
  resm@pmLegendOrthogonalPosF = -1.17
forrest@0
   991
; resm@pmLegendOrthogonalPosF = -1.00  ;(downward)
forrest@0
   992
; resm@pmLegendParallelPosF   =  0.18
forrest@0
   993
  resm@pmLegendParallelPosF   =  0.88  ;(rightward)
forrest@0
   994
forrest@0
   995
; resm@lgPerimOn              = False
forrest@0
   996
  resm@lgLabelFontHeightF     = 0.015
forrest@0
   997
  resm@xyExplicitLegendLabels = (/"observed",model_name/)
forrest@0
   998
;-----------------------------
forrest@0
   999
  tRes  = True
forrest@0
  1000
  tRes@txFontHeightF = 0.025
forrest@0
  1001
forrest@0
  1002
  correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrPhase)+")"
forrest@0
  1003
forrest@0
  1004
  gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
forrest@0
  1005
forrest@0
  1006
  xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
forrest@0
  1007
;-------------------------------
forrest@0
  1008
;Attach the vertical bar and the horizontal cap line 
forrest@0
  1009
forrest@0
  1010
  do nd=0,1
forrest@0
  1011
    lnres@gsLineColor = line_colors(nd)
forrest@0
  1012
    do i=0,nx-1
forrest@0
  1013
     
forrest@0
  1014
      if(.not.ismissing(mn_yvalues(nd,i)).and. \
forrest@0
  1015
         .not.ismissing(mx_yvalues(nd,i))) then
forrest@0
  1016
forrest@0
  1017
; Attach the vertical bar, both above and below the marker.
forrest@0
  1018
forrest@0
  1019
        x1 = xvalues(nd,i)
forrest@0
  1020
        y1 = yvalues(nd,i)
forrest@0
  1021
        y2 = mn_yvalues(nd,i)
forrest@0
  1022
        min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
forrest@0
  1023
forrest@0
  1024
        y2 = mx_yvalues(nd,i)
forrest@0
  1025
        max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
forrest@0
  1026
forrest@0
  1027
; Attach the horizontal cap line, both above and below the marker.
forrest@0
  1028
forrest@0
  1029
        x1 = xvalues(nd,i) - dx4
forrest@0
  1030
        x2 = xvalues(nd,i) + dx4
forrest@0
  1031
        y1 = mn_yvalues(nd,i)
forrest@0
  1032
        min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
forrest@0
  1033
forrest@0
  1034
        y1 = mx_yvalues(nd,i)
forrest@0
  1035
        max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
forrest@0
  1036
      end if
forrest@0
  1037
    end do
forrest@0
  1038
  end do
forrest@0
  1039
forrest@0
  1040
  draw(xy)
forrest@0
  1041
  frame(wks)
forrest@0
  1042
forrest@0
  1043
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
  1044
  system("rm "+plot_name+"."+plot_type)
forrest@0
  1045
; system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
  1046
; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
  1047
forrest@0
  1048
  clear (wks)
forrest@0
  1049
forrest@0
  1050
 delete (DATA11_1D)
forrest@0
  1051
 delete (DATA12_1D)
forrest@0
  1052
 delete (DATA22_1D)
forrest@0
  1053
;delete (range)
forrest@0
  1054
;delete (xvalues) 
forrest@0
  1055
 delete (yvalues)
forrest@0
  1056
 delete (mn_yvalues)
forrest@0
  1057
 delete (mx_yvalues)
forrest@0
  1058
 delete (good)
forrest@0
  1059
 delete (max_bar)
forrest@0
  1060
 delete (min_bar)
forrest@0
  1061
 delete (max_cap)
forrest@0
  1062
 delete (min_cap)
forrest@0
  1063
;----------------------------------------------------------------- 
forrest@0
  1064
;global res
forrest@0
  1065
forrest@0
  1066
  resg                     = True             ; Use plot options
forrest@0
  1067
  resg@cnFillOn            = True             ; Turn on color fill
forrest@0
  1068
  resg@gsnSpreadColors     = True             ; use full colormap
forrest@0
  1069
; resg@cnFillMode          = "RasterFill"     ; Turn on raster color
forrest@0
  1070
; resg@lbLabelAutoStride   = True
forrest@0
  1071
  resg@cnLinesOn           = False            ; Turn off contourn lines
forrest@0
  1072
  resg@mpFillOn            = False            ; Turn off map fill
forrest@0
  1073
forrest@0
  1074
  resg@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
  1075
  resg@cnMinLevelValF       = 1.              ; Min level
forrest@0
  1076
  resg@cnMaxLevelValF       = 12.             ; Max level
forrest@0
  1077
  resg@cnLevelSpacingF      = 1.              ; interval
forrest@0
  1078
forrest@0
  1079
;global contour ob
forrest@0
  1080
forrest@0
  1081
  delta = 0.00001
forrest@0
  1082
  laiob_phase = where(ismissing(laiob_phase).and.(ismissing(laimod_phase).or.(laimod_phase.lt.delta)),0.,laiob_phase)
forrest@0
  1083
  
forrest@0
  1084
  plot_name = "global_phase_ob"
forrest@0
  1085
  title     = ob_name
forrest@0
  1086
  resg@tiMainString  = title
forrest@0
  1087
forrest@0
  1088
  wks = gsn_open_wks (plot_type,plot_name)   ; open workstation
forrest@0
  1089
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
  1090
forrest@0
  1091
  plot = gsn_csm_contour_map_ce(wks,laiob_phase,resg)   
forrest@0
  1092
  frame(wks)
forrest@0
  1093
forrest@0
  1094
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
  1095
  system("rm "+plot_name+"."+plot_type)
forrest@0
  1096
  system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
  1097
  system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
  1098
forrest@0
  1099
  clear (wks)
forrest@0
  1100
;------------------------------------------------------------------------
forrest@0
  1101
;global contour model
forrest@0
  1102
  
forrest@0
  1103
  plot_name = "global_phase_model"
forrest@0
  1104
  title     = "Model " + model_name
forrest@0
  1105
  resg@tiMainString  = title
forrest@0
  1106
forrest@0
  1107
  wks = gsn_open_wks (plot_type,plot_name)
forrest@0
  1108
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
  1109
forrest@0
  1110
  delete (plot)
forrest@0
  1111
  plot = gsn_csm_contour_map_ce(wks,laimod_phase,resg)   
forrest@0
  1112
  frame(wks)
forrest@0
  1113
forrest@0
  1114
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
  1115
  system("rm "+plot_name+"."+plot_type)
forrest@0
  1116
  system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
  1117
  system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
  1118
forrest@0
  1119
  clear (wks)
forrest@0
  1120
;-----------------------------------------------------------------
forrest@0
  1121
;(D) grow day
forrest@0
  1122
;--------------------------------------------------------------------
forrest@0
  1123
; get data
forrest@0
  1124
forrest@0
  1125
  day_of_data = (/31,28,31,30,31,30,31,31,30,31,30,31/)
forrest@0
  1126
forrest@0
  1127
; observed
forrest@0
  1128
  laiob_grow = laiob(0,:,:)
forrest@0
  1129
  laiob_grow@long_name = "Days of Growing Season"
forrest@0
  1130
 
forrest@0
  1131
  dsizes_z = dimsizes(laiob)
forrest@0
  1132
  ntime    = dsizes_z(0)
forrest@0
  1133
  nlat     = dsizes_z(1)
forrest@0
  1134
  nlon     = dsizes_z(2)
forrest@0
  1135
  
forrest@0
  1136
  do j = 0,nlat-1
forrest@0
  1137
  do i = 0,nlon-1
forrest@0
  1138
     nday = 0.
forrest@0
  1139
     do k = 0,ntime-1
forrest@0
  1140
        if (.not. ismissing(laiob(k,j,i)) .and. laiob(k,j,i) .gt. 1.0) then
forrest@0
  1141
           nday = nday + day_of_data(k)
forrest@0
  1142
        end if
forrest@0
  1143
     end do
forrest@0
  1144
forrest@0
  1145
     laiob_grow(j,i) = nday
forrest@0
  1146
  end do
forrest@0
  1147
  end do
forrest@0
  1148
forrest@0
  1149
; print (min(laiob_grow)+"/"+max(laiob_grow))         
forrest@0
  1150
;-------------------------
forrest@0
  1151
; model
forrest@0
  1152
  laimod_grow = laimod(0,:,:)
forrest@0
  1153
  laimod_grow@long_name = "Days of Growing Season"
forrest@0
  1154
 
forrest@0
  1155
  dsizes_z = dimsizes(laimod)
forrest@0
  1156
  ntime    = dsizes_z(0)
forrest@0
  1157
  nlat     = dsizes_z(1)
forrest@0
  1158
  nlon     = dsizes_z(2)
forrest@0
  1159
  
forrest@0
  1160
  do j = 0,nlat-1
forrest@0
  1161
  do i = 0,nlon-1
forrest@0
  1162
     nday = 0.
forrest@0
  1163
     do k = 0,ntime-1
forrest@0
  1164
        if (.not. ismissing(laimod(k,j,i)) .and. laimod(k,j,i) .gt. 1.0) then
forrest@0
  1165
           nday = nday + day_of_data(k)
forrest@0
  1166
        end if
forrest@0
  1167
     end do
forrest@0
  1168
forrest@0
  1169
     laimod_grow(j,i) = nday
forrest@0
  1170
  end do
forrest@0
  1171
  end do
forrest@0
  1172
forrest@0
  1173
; print (min(laimod_grow)+"/"+max(laimod_grow))          
forrest@0
  1174
;------------------------
forrest@0
  1175
  DATA11_1D = ndtooned(classob)
forrest@0
  1176
  DATA12_1D = ndtooned(laiob_grow)
forrest@0
  1177
  DATA22_1D = ndtooned(laimod_grow)
forrest@0
  1178
forrest@0
  1179
  yvalues      = new((/2,nx/),float)
forrest@0
  1180
  mn_yvalues   = new((/2,nx/),float)
forrest@0
  1181
  mx_yvalues   = new((/2,nx/),float)
forrest@0
  1182
forrest@0
  1183
  do nd=0,1
forrest@0
  1184
forrest@0
  1185
; See if we are doing model or observational data.
forrest@0
  1186
forrest@0
  1187
    if(nd.eq.0) then
forrest@0
  1188
      data_ob  = DATA11_1D
forrest@0
  1189
      data_mod = DATA12_1D
forrest@0
  1190
    else
forrest@0
  1191
      data_ob  = DATA11_1D
forrest@0
  1192
      data_mod = DATA22_1D
forrest@0
  1193
    end if
forrest@0
  1194
forrest@0
  1195
; Loop through each range and check for values.
forrest@0
  1196
forrest@0
  1197
    do i=0,nr-2
forrest@0
  1198
      if (i.ne.(nr-2)) then
forrest@0
  1199
;        print("")
forrest@0
  1200
;        print("In range ["+range(i)+","+range(i+1)+")")
forrest@0
  1201
        idx = ind((range(i).le.data_ob).and.(data_ob.lt.range(i+1)))
forrest@0
  1202
      else
forrest@0
  1203
;        print("")
forrest@0
  1204
;        print("In range ["+range(i)+",)")
forrest@0
  1205
        idx = ind(range(i).le.data_ob)
forrest@0
  1206
      end if
forrest@0
  1207
forrest@0
  1208
; Calculate average, and get min and max.
forrest@0
  1209
forrest@0
  1210
      if(.not.any(ismissing(idx))) then
forrest@0
  1211
        yvalues(nd,i)    = avg(data_mod(idx))
forrest@0
  1212
        mn_yvalues(nd,i) = min(data_mod(idx))
forrest@0
  1213
        mx_yvalues(nd,i) = max(data_mod(idx))
forrest@0
  1214
        count = dimsizes(idx)
forrest@0
  1215
      else
forrest@0
  1216
        count            = 0
forrest@0
  1217
        yvalues(nd,i)    = yvalues@_FillValue
forrest@0
  1218
        mn_yvalues(nd,i) = yvalues@_FillValue
forrest@0
  1219
        mx_yvalues(nd,i) = yvalues@_FillValue
forrest@0
  1220
      end if
forrest@0
  1221
forrest@0
  1222
;     print(nd + ": " + count + " points, avg = " + yvalues(nd,i))
forrest@0
  1223
;     print("Min/Max:  " + mn_yvalues(nd,i) + "/" + mx_yvalues(nd,i))
forrest@0
  1224
forrest@0
  1225
; Clean up for next time in loop.
forrest@0
  1226
forrest@0
  1227
      delete(idx)
forrest@0
  1228
    end do
forrest@0
  1229
    delete(data_ob)
forrest@0
  1230
    delete(data_mod)
forrest@0
  1231
  end do
forrest@0
  1232
;-----------------------------------------------------------------
forrest@0
  1233
; compute correlation coef and M score
forrest@0
  1234
forrest@0
  1235
  u = yvalues(0,:)
forrest@0
  1236
  v = yvalues(1,:)
forrest@0
  1237
forrest@0
  1238
  good = ind(.not.ismissing(u) .and. .not.ismissing(v))
forrest@0
  1239
  uu = u(good)
forrest@0
  1240
  vv = v(good)
forrest@0
  1241
forrest@0
  1242
  ccrGrow = esccr(uu,vv,0)
forrest@0
  1243
; print (ccrGrow)
forrest@0
  1244
forrest@0
  1245
; new eq
forrest@0
  1246
  bias  = sum(abs(vv-uu)/(vv+uu))
forrest@0
  1247
  Mgrow = (1.- (bias/dimsizes(uu)))*5.
forrest@0
  1248
forrest@0
  1249
  M_lai_grow = sprintf("%.2f", Mgrow)
forrest@0
  1250
  system("sed s#M_lai_grow#"+M_lai_grow+"# table.html > table.html.new")
forrest@0
  1251
  system("mv -f table.html.new table.html")
forrest@0
  1252
  print (M_lai_grow)
forrest@0
  1253
forrest@0
  1254
 do i=0,nrow-2
forrest@0
  1255
  text4(i,9)  = sprintf("%5.2f",u(i))
forrest@0
  1256
  text4(i,10) = sprintf("%5.2f",v(i))
forrest@0
  1257
  text4(i,11) = "-"
forrest@0
  1258
 end do
forrest@0
  1259
  text4(nrow-1,9)  = sprintf("%5.2f",avg(u))
forrest@0
  1260
  text4(nrow-1,10) = sprintf("%5.2f",avg(v))
forrest@0
  1261
  text4(nrow-1,11) = sprintf("%5.2f",Mgrow)
forrest@0
  1262
forrest@0
  1263
 delete (u)
forrest@0
  1264
 delete (v)
forrest@0
  1265
 delete (uu)
forrest@0
  1266
 delete (vv)
forrest@0
  1267
;--------------------------------------------------------------------
forrest@0
  1268
; histogram res
forrest@0
  1269
forrest@0
  1270
  resm                = True
forrest@0
  1271
  resm@gsnMaximize    = True
forrest@0
  1272
  resm@gsnDraw        = False
forrest@0
  1273
  resm@gsnFrame       = False
forrest@0
  1274
  resm@xyMarkLineMode = "Markers"
forrest@0
  1275
  resm@xyMarkerSizeF  = 0.014
forrest@0
  1276
  resm@xyMarker       = 16
forrest@0
  1277
  resm@xyMarkerColors = (/"Brown","Blue"/)
forrest@0
  1278
; resm@trYMinF        = min(mn_yvalues) - 10.
forrest@0
  1279
; resm@trYMaxF        = max(mx_yvalues) + 10.
forrest@0
  1280
  resm@trYMinF        = min(mn_yvalues) - 2
forrest@0
  1281
  resm@trYMaxF        = max(mx_yvalues) + 4
forrest@0
  1282
forrest@0
  1283
  resm@tiYAxisString = "Days of Growing season"
forrest@0
  1284
  resm@tiXAxisString = "Land Cover Type"
forrest@0
  1285
forrest@0
  1286
  max_bar = new((/2,nx/),graphic)
forrest@0
  1287
  min_bar = new((/2,nx/),graphic)
forrest@0
  1288
  max_cap = new((/2,nx/),graphic)
forrest@0
  1289
  min_cap = new((/2,nx/),graphic)
forrest@0
  1290
forrest@0
  1291
  lnres = True
forrest@0
  1292
  line_colors = (/"brown","blue"/)
forrest@0
  1293
;------------------------------------------------------------------
forrest@0
  1294
; Start the graphics.
forrest@0
  1295
forrest@0
  1296
  plot_name = "histogram_grow"
forrest@0
  1297
  title     = model_name + " vs Observed"
forrest@0
  1298
  resm@tiMainString  = title
forrest@0
  1299
forrest@0
  1300
  wks   = gsn_open_wks (plot_type,plot_name)
forrest@0
  1301
;-----------------------------
forrest@0
  1302
; Add a boxed legend using the more simple method
forrest@0
  1303
forrest@0
  1304
  resm@pmLegendDisplayMode    = "Always"
forrest@0
  1305
; resm@pmLegendWidthF         = 0.1
forrest@0
  1306
  resm@pmLegendWidthF         = 0.08
forrest@0
  1307
  resm@pmLegendHeightF        = 0.05
forrest@0
  1308
  resm@pmLegendOrthogonalPosF = -1.17
forrest@0
  1309
; resm@pmLegendOrthogonalPosF = -1.00  ;(downward)
forrest@0
  1310
; resm@pmLegendParallelPosF   =  0.18
forrest@0
  1311
  resm@pmLegendParallelPosF   =  0.88  ;(rightward)
forrest@0
  1312
forrest@0
  1313
; resm@lgPerimOn              = False
forrest@0
  1314
  resm@lgLabelFontHeightF     = 0.015
forrest@0
  1315
  resm@xyExplicitLegendLabels = (/"observed",model_name/)
forrest@0
  1316
;-----------------------------
forrest@0
  1317
  tRes  = True
forrest@0
  1318
  tRes@txFontHeightF = 0.025
forrest@0
  1319
forrest@0
  1320
  correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrGrow)+")"
forrest@0
  1321
forrest@0
  1322
  gsn_text_ndc(wks,correlation_text,0.56,0.85,tRes)
forrest@0
  1323
forrest@0
  1324
  xy = gsn_csm_xy(wks,xvalues,yvalues,resm)
forrest@0
  1325
;-------------------------------
forrest@0
  1326
;Attach the vertical bar and the horizontal cap line 
forrest@0
  1327
forrest@0
  1328
  do nd=0,1
forrest@0
  1329
    lnres@gsLineColor = line_colors(nd)
forrest@0
  1330
    do i=0,nx-1
forrest@0
  1331
     
forrest@0
  1332
      if(.not.ismissing(mn_yvalues(nd,i)).and. \
forrest@0
  1333
         .not.ismissing(mx_yvalues(nd,i))) then
forrest@0
  1334
forrest@0
  1335
; Attach the vertical bar, both above and below the marker.
forrest@0
  1336
forrest@0
  1337
        x1 = xvalues(nd,i)
forrest@0
  1338
        y1 = yvalues(nd,i)
forrest@0
  1339
        y2 = mn_yvalues(nd,i)
forrest@0
  1340
        min_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
forrest@0
  1341
forrest@0
  1342
        y2 = mx_yvalues(nd,i)
forrest@0
  1343
        max_bar(nd,i) = gsn_add_polyline(wks,xy,(/x1,x1/),(/y1,y2/),lnres)
forrest@0
  1344
forrest@0
  1345
; Attach the horizontal cap line, both above and below the marker.
forrest@0
  1346
forrest@0
  1347
        x1 = xvalues(nd,i) - dx4
forrest@0
  1348
        x2 = xvalues(nd,i) + dx4
forrest@0
  1349
        y1 = mn_yvalues(nd,i)
forrest@0
  1350
        min_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
forrest@0
  1351
forrest@0
  1352
        y1 = mx_yvalues(nd,i)
forrest@0
  1353
        max_cap(nd,i) = gsn_add_polyline(wks,xy,(/x1,x2/),(/y1,y1/),lnres)
forrest@0
  1354
      end if
forrest@0
  1355
    end do
forrest@0
  1356
  end do
forrest@0
  1357
forrest@0
  1358
  draw(xy)
forrest@0
  1359
  frame(wks)
forrest@0
  1360
forrest@0
  1361
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
  1362
  system("rm "+plot_name+"."+plot_type)
forrest@0
  1363
; system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
  1364
; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
  1365
forrest@0
  1366
  clear (wks)
forrest@0
  1367
forrest@0
  1368
 delete (DATA11_1D)
forrest@0
  1369
 delete (DATA12_1D)
forrest@0
  1370
 delete (DATA22_1D)
forrest@0
  1371
;delete (range)
forrest@0
  1372
;delete (xvalues) 
forrest@0
  1373
 delete (yvalues)
forrest@0
  1374
 delete (mn_yvalues)
forrest@0
  1375
 delete (mx_yvalues)
forrest@0
  1376
 delete (good)
forrest@0
  1377
 delete (max_bar)
forrest@0
  1378
 delete (min_bar)
forrest@0
  1379
 delete (max_cap)
forrest@0
  1380
 delete (min_cap)
forrest@0
  1381
;----------------------------------------------------------------- 
forrest@0
  1382
;global res
forrest@0
  1383
forrest@0
  1384
  resg                     = True             ; Use plot options
forrest@0
  1385
  resg@cnFillOn            = True             ; Turn on color fill
forrest@0
  1386
  resg@gsnSpreadColors     = True             ; use full colormap
forrest@0
  1387
; resg@cnFillMode          = "RasterFill"     ; Turn on raster color
forrest@0
  1388
; resg@lbLabelAutoStride   = True
forrest@0
  1389
  resg@cnLinesOn           = False            ; Turn off contourn lines
forrest@0
  1390
  resg@mpFillOn            = False            ; Turn off map fill
forrest@0
  1391
forrest@0
  1392
  resg@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
  1393
  resg@cnMinLevelValF       = 60.             ; Min level
forrest@0
  1394
  resg@cnMaxLevelValF       = 360.            ; Max level
forrest@0
  1395
  resg@cnLevelSpacingF      = 20.             ; interval
forrest@0
  1396
forrest@0
  1397
;global contour ob
forrest@0
  1398
forrest@0
  1399
  laiob_grow@_FillValue = 1.e+36
forrest@0
  1400
  laiob_grow = where(laiob_grow .lt. 10.,laiob_grow@_FillValue,laiob_grow)
forrest@0
  1401
 
forrest@0
  1402
  plot_name = "global_grow_ob"
forrest@0
  1403
  title     = ob_name
forrest@0
  1404
  resg@tiMainString  = title
forrest@0
  1405
forrest@0
  1406
  wks = gsn_open_wks (plot_type,plot_name)   ; open workstation
forrest@0
  1407
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
  1408
forrest@0
  1409
  plot = gsn_csm_contour_map_ce(wks,laiob_grow,resg)   
forrest@0
  1410
  frame(wks)
forrest@0
  1411
forrest@0
  1412
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
  1413
  system("rm "+plot_name+"."+plot_type)
forrest@0
  1414
  system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
  1415
  system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
  1416
forrest@0
  1417
  clear (wks)
forrest@0
  1418
;------------------------------------------------------------------------
forrest@0
  1419
;global contour model
forrest@0
  1420
forrest@0
  1421
  laimod_grow@_FillValue = 1.e+36
forrest@0
  1422
  laimod_grow = where(laimod_grow .lt. 10.,laimod_grow@_FillValue,laimod_grow)
forrest@0
  1423
forrest@0
  1424
  plot_name = "global_grow_model"
forrest@0
  1425
  title     = "Model " + model_name
forrest@0
  1426
  resg@tiMainString  = title
forrest@0
  1427
forrest@0
  1428
  wks = gsn_open_wks (plot_type,plot_name)
forrest@0
  1429
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
  1430
forrest@0
  1431
  delete (plot)
forrest@0
  1432
  plot = gsn_csm_contour_map_ce(wks,laimod_grow,resg)   
forrest@0
  1433
  frame(wks)
forrest@0
  1434
forrest@0
  1435
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
  1436
  system("rm "+plot_name+"."+plot_type)
forrest@0
  1437
  system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
  1438
  system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
  1439
forrest@0
  1440
  clear (wks)
forrest@0
  1441
;------------------------------------------------------------------------
forrest@0
  1442
;global contour model vs ob
forrest@0
  1443
forrest@0
  1444
  resg@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
  1445
  resg@cnMinLevelValF       = 0.              ; Min level
forrest@0
  1446
  resg@cnMaxLevelValF       = 10.             ; Max level
forrest@0
  1447
  resg@cnLevelSpacingF      = 1.              ; interval
forrest@0
  1448
forrest@0
  1449
  plot_name = "global_mean_model_vs_ob"
forrest@0
  1450
forrest@0
  1451
  wks = gsn_open_wks (plot_type,plot_name)   ; open workstation
forrest@0
  1452
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
  1453
forrest@0
  1454
  delete (plot)
forrest@0
  1455
  plot=new(3,graphic)                        ; create graphic array
forrest@0
  1456
forrest@0
  1457
  resg@gsnFrame             = False          ; Do not draw plot 
forrest@0
  1458
  resg@gsnDraw              = False          ; Do not advance frame
forrest@0
  1459
forrest@0
  1460
; plot correlation coef
forrest@0
  1461
forrest@0
  1462
  gRes               = True
forrest@0
  1463
  gRes@txFontHeightF = 0.02
forrest@0
  1464
  gRes@txAngleF      = 90
forrest@0
  1465
forrest@0
  1466
  correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMean)+")"
forrest@0
  1467
forrest@0
  1468
  gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
forrest@0
  1469
;--------------------------------------------------------------------
forrest@0
  1470
  
forrest@0
  1471
;(a) ob
forrest@0
  1472
forrest@0
  1473
  title     = ob_name
forrest@0
  1474
  resg@tiMainString  = title
forrest@0
  1475
forrest@0
  1476
  plot(0) = gsn_csm_contour_map_ce(wks,laiob_mean,resg)       
forrest@0
  1477
forrest@0
  1478
;(b) model
forrest@0
  1479
forrest@0
  1480
  title     = "Model "+ model_name
forrest@0
  1481
  resg@tiMainString  = title
forrest@0
  1482
forrest@0
  1483
  plot(1) = gsn_csm_contour_map_ce(wks,laimod_mean,resg) 
forrest@0
  1484
forrest@0
  1485
;(c) model-ob
forrest@0
  1486
forrest@0
  1487
  zz = laimod_mean
forrest@0
  1488
  zz = laimod_mean - laiob_mean
forrest@0
  1489
  title = "Model_"+model_name+" - Observed"
forrest@0
  1490
  resg@tiMainString    = title
forrest@0
  1491
forrest@0
  1492
  resg@cnMinLevelValF  = -2.           ; Min level
forrest@0
  1493
  resg@cnMaxLevelValF  =  2.           ; Max level
forrest@0
  1494
  resg@cnLevelSpacingF =  0.4           ; interval
forrest@0
  1495
forrest@0
  1496
forrest@0
  1497
  plot(2) = gsn_csm_contour_map_ce(wks,zz,resg) 
forrest@0
  1498
forrest@0
  1499
  pres                            = True        ; panel plot mods desired
forrest@0
  1500
  pres@gsnPanelYWhiteSpacePercent = 5           ; increase white space around
forrest@0
  1501
                                                ; indiv. plots in panel
forrest@0
  1502
  pres@gsnMaximize                = True        ; fill the page
forrest@0
  1503
forrest@0
  1504
  gsn_panel(wks,plot,(/3,1/),pres)              ; create panel plot
forrest@0
  1505
forrest@0
  1506
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
  1507
  system("rm "+plot_name+"."+plot_type)
forrest@0
  1508
; system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
  1509
; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
  1510
forrest@0
  1511
  frame (wks)
forrest@0
  1512
  clear (wks)
forrest@0
  1513
forrest@0
  1514
  delete (plot)
forrest@0
  1515
;-----------------------------------------------------------------
forrest@0
  1516
;global contour model vs ob
forrest@0
  1517
forrest@0
  1518
  resg@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
  1519
  resg@cnMinLevelValF       = 0.              ; Min level
forrest@0
  1520
  resg@cnMaxLevelValF       = 10.             ; Max level
forrest@0
  1521
  resg@cnLevelSpacingF      = 1.              ; interval
forrest@0
  1522
forrest@0
  1523
  plot_name = "global_max_model_vs_ob"
forrest@0
  1524
forrest@0
  1525
  wks = gsn_open_wks (plot_type,plot_name)   ; open workstation
forrest@0
  1526
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
  1527
forrest@0
  1528
; delete(plot)
forrest@0
  1529
  plot=new(3,graphic)                        ; create graphic array
forrest@0
  1530
forrest@0
  1531
  resg@gsnFrame             = False          ; Do not draw plot 
forrest@0
  1532
  resg@gsnDraw              = False          ; Do not advance frame
forrest@0
  1533
forrest@0
  1534
; plot correlation coef
forrest@0
  1535
forrest@0
  1536
  gRes               = True
forrest@0
  1537
  gRes@txFontHeightF = 0.02
forrest@0
  1538
  gRes@txAngleF      = 90
forrest@0
  1539
forrest@0
  1540
  correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrMax)+")"
forrest@0
  1541
forrest@0
  1542
  gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
forrest@0
  1543
;--------------------------------------------------------------------  
forrest@0
  1544
;(a) ob
forrest@0
  1545
forrest@0
  1546
  title     = ob_name
forrest@0
  1547
  resg@tiMainString  = title
forrest@0
  1548
forrest@0
  1549
  plot(0) = gsn_csm_contour_map_ce(wks,laiob_max,resg)       
forrest@0
  1550
forrest@0
  1551
;(b) model
forrest@0
  1552
forrest@0
  1553
  title     = "Model "+ model_name
forrest@0
  1554
  resg@tiMainString  = title
forrest@0
  1555
forrest@0
  1556
  plot(1) = gsn_csm_contour_map_ce(wks,laimod_max,resg) 
forrest@0
  1557
forrest@0
  1558
;(c) model-ob
forrest@0
  1559
forrest@0
  1560
  delete (zz)
forrest@0
  1561
  zz = laimod_max
forrest@0
  1562
  zz = laimod_max - laiob_max
forrest@0
  1563
  title = "Model_"+model_name+" - Observed"
forrest@0
  1564
  resg@tiMainString    = title
forrest@0
  1565
forrest@0
  1566
  resg@cnMinLevelValF  = -6.           ; Min level
forrest@0
  1567
  resg@cnMaxLevelValF  =  6.           ; Max level
forrest@0
  1568
  resg@cnLevelSpacingF =  1.           ; interval
forrest@0
  1569
forrest@0
  1570
forrest@0
  1571
  plot(2) = gsn_csm_contour_map_ce(wks,zz,resg) 
forrest@0
  1572
forrest@0
  1573
  pres                            = True        ; panel plot mods desired
forrest@0
  1574
  pres@gsnPanelYWhiteSpacePercent = 5           ; increase white space around
forrest@0
  1575
                                                ; indiv. plots in panel
forrest@0
  1576
  pres@gsnMaximize                = True        ; fill the page
forrest@0
  1577
forrest@0
  1578
  gsn_panel(wks,plot,(/3,1/),pres)              ; create panel plot
forrest@0
  1579
forrest@0
  1580
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
  1581
  system("rm "+plot_name+"."+plot_type)
forrest@0
  1582
; system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
  1583
; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
  1584
forrest@0
  1585
  frame (wks)
forrest@0
  1586
  clear (wks)
forrest@0
  1587
forrest@0
  1588
  delete (plot)
forrest@0
  1589
;-----------------------------------------------------------------
forrest@0
  1590
;global contour model vs ob
forrest@0
  1591
forrest@0
  1592
  resg@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
  1593
  resg@cnMinLevelValF       = 1.              ; Min level
forrest@0
  1594
  resg@cnMaxLevelValF       = 12.             ; Max level
forrest@0
  1595
  resg@cnLevelSpacingF      = 1.              ; interval
forrest@0
  1596
forrest@0
  1597
  plot_name = "global_phase_model_vs_ob"
forrest@0
  1598
forrest@0
  1599
  wks = gsn_open_wks (plot_type,plot_name)   ; open workstation
forrest@0
  1600
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
  1601
forrest@0
  1602
; delete (plot)
forrest@0
  1603
  plot=new(3,graphic)                        ; create graphic array
forrest@0
  1604
forrest@0
  1605
  resg@gsnFrame             = False          ; Do not draw plot 
forrest@0
  1606
  resg@gsnDraw              = False          ; Do not advance frame
forrest@0
  1607
forrest@0
  1608
; plot correlation coef
forrest@0
  1609
forrest@0
  1610
  gRes               = True
forrest@0
  1611
  gRes@txFontHeightF = 0.02
forrest@0
  1612
  gRes@txAngleF      = 90
forrest@0
  1613
forrest@0
  1614
  correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrPhase)+")"
forrest@0
  1615
forrest@0
  1616
  gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
forrest@0
  1617
;--------------------------------------------------------------------  
forrest@0
  1618
;(a) ob
forrest@0
  1619
forrest@0
  1620
  title     = ob_name
forrest@0
  1621
  resg@tiMainString  = title
forrest@0
  1622
forrest@0
  1623
  plot(0) = gsn_csm_contour_map_ce(wks,laiob_phase,resg)       
forrest@0
  1624
forrest@0
  1625
;(b) model
forrest@0
  1626
forrest@0
  1627
  title     = "Model "+ model_name
forrest@0
  1628
  resg@tiMainString  = title
forrest@0
  1629
forrest@0
  1630
  plot(1) = gsn_csm_contour_map_ce(wks,laimod_phase,resg) 
forrest@0
  1631
forrest@0
  1632
;(c) model-ob
forrest@0
  1633
forrest@0
  1634
  delete (zz)
forrest@0
  1635
  zz = laimod_phase
forrest@0
  1636
  zz = laimod_phase - laiob_phase
forrest@0
  1637
  title = "Model_"+model_name+" - Observed"
forrest@0
  1638
  resg@tiMainString    = title
forrest@0
  1639
forrest@0
  1640
  resg@cnMinLevelValF  = -6.           ; Min level
forrest@0
  1641
  resg@cnMaxLevelValF  =  6.           ; Max level
forrest@0
  1642
  resg@cnLevelSpacingF =  1.           ; interval
forrest@0
  1643
forrest@0
  1644
forrest@0
  1645
  plot(2) = gsn_csm_contour_map_ce(wks,zz,resg) 
forrest@0
  1646
forrest@0
  1647
; pres                            = True        ; panel plot mods desired
forrest@0
  1648
; pres@gsnPanelYWhiteSpacePercent = 5           ; increase white space around
forrest@0
  1649
                                                ; indiv. plots in panel
forrest@0
  1650
; pres@gsnMaximize                = True        ; fill the page
forrest@0
  1651
forrest@0
  1652
  gsn_panel(wks,plot,(/3,1/),pres)              ; create panel plot
forrest@0
  1653
forrest@0
  1654
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
  1655
  system("rm "+plot_name+"."+plot_type)
forrest@0
  1656
; system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
  1657
; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
  1658
forrest@0
  1659
  frame (wks)
forrest@0
  1660
  clear (wks)
forrest@0
  1661
forrest@0
  1662
  delete (plot)  
forrest@0
  1663
;------------------------------------------------------------------
forrest@0
  1664
;global contour model vs ob
forrest@0
  1665
forrest@0
  1666
  resg@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
  1667
  resg@cnMinLevelValF       = 60.             ; Min level
forrest@0
  1668
  resg@cnMaxLevelValF       = 360.            ; Max level
forrest@0
  1669
  resg@cnLevelSpacingF      = 20.             ; interval
forrest@0
  1670
forrest@0
  1671
  plot_name = "global_grow_model_vs_ob"
forrest@0
  1672
forrest@0
  1673
  wks = gsn_open_wks (plot_type,plot_name)   ; open workstation
forrest@0
  1674
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
  1675
forrest@0
  1676
; delete (plot)
forrest@0
  1677
  plot=new(3,graphic)                        ; create graphic array
forrest@0
  1678
forrest@0
  1679
  resg@gsnFrame             = False          ; Do not draw plot 
forrest@0
  1680
  resg@gsnDraw              = False          ; Do not advance frame
forrest@0
  1681
forrest@0
  1682
; plot correlation coef
forrest@0
  1683
forrest@0
  1684
  gRes               = True
forrest@0
  1685
  gRes@txFontHeightF = 0.02
forrest@0
  1686
  gRes@txAngleF      = 90
forrest@0
  1687
forrest@0
  1688
  correlation_text = "(correlation coef = "+sprintf("%5.2f", ccrGrow)+")"
forrest@0
  1689
forrest@0
  1690
  gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
forrest@0
  1691
;-------------------------------------------------------------------- 
forrest@0
  1692
;(a) ob
forrest@0
  1693
forrest@0
  1694
  title     = ob_name
forrest@0
  1695
  resg@tiMainString  = title
forrest@0
  1696
forrest@0
  1697
  plot(0) = gsn_csm_contour_map_ce(wks,laiob_grow,resg)       
forrest@0
  1698
forrest@0
  1699
;(b) model
forrest@0
  1700
forrest@0
  1701
  title     = "Model "+ model_name
forrest@0
  1702
  resg@tiMainString  = title
forrest@0
  1703
forrest@0
  1704
  plot(1) = gsn_csm_contour_map_ce(wks,laimod_grow,resg) 
forrest@0
  1705
forrest@0
  1706
;(c) model-ob
forrest@0
  1707
forrest@0
  1708
  delete (zz)
forrest@0
  1709
  zz = laimod_grow
forrest@0
  1710
  zz = laimod_grow - laiob_grow
forrest@0
  1711
  title = "Model_"+model_name+" - Observed"
forrest@0
  1712
  resg@tiMainString    = title
forrest@0
  1713
forrest@0
  1714
  resg@cnMinLevelValF  = -100.           ; Min level
forrest@0
  1715
  resg@cnMaxLevelValF  =  100.           ; Max level
forrest@0
  1716
  resg@cnLevelSpacingF =  20.            ; interval
forrest@0
  1717
forrest@0
  1718
  plot(2) = gsn_csm_contour_map_ce(wks,zz,resg) 
forrest@0
  1719
forrest@0
  1720
  pres                            = True        ; panel plot mods desired
forrest@0
  1721
  pres@gsnPanelYWhiteSpacePercent = 5           ; increase white space around
forrest@0
  1722
                                                ; indiv. plots in panel
forrest@0
  1723
  pres@gsnMaximize                = True        ; fill the page
forrest@0
  1724
forrest@0
  1725
  gsn_panel(wks,plot,(/3,1/),pres)              ; create panel plot
forrest@0
  1726
forrest@0
  1727
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
  1728
  system("rm "+plot_name+"."+plot_type)
forrest@0
  1729
; system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
  1730
; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
  1731
forrest@0
  1732
  frame (wks)
forrest@0
  1733
  clear (wks)
forrest@0
  1734
forrest@0
  1735
  delete (plot)  
forrest@0
  1736
;**************************************************
forrest@0
  1737
; plot lai table
forrest@0
  1738
;**************************************************
forrest@0
  1739
forrest@0
  1740
  plot_name = "table_lai" 
forrest@0
  1741
  wks = gsn_open_wks (plot_type,plot_name)   ; open workstation
forrest@0
  1742
forrest@0
  1743
  gsn_table(wks,ncr1,xx1,yy1,text1,res1)
forrest@0
  1744
  gsn_table(wks,ncr21,xx21,yy21,text21,res21)
forrest@0
  1745
  gsn_table(wks,ncr22,xx22,yy22,text22,res22)
forrest@0
  1746
  gsn_table(wks,ncr3,xx3,yy3,text3,res3)
forrest@0
  1747
  gsn_table(wks,ncr4,xx4,yy4,text4,res4) 
forrest@0
  1748
forrest@0
  1749
  frame(wks)
forrest@0
  1750
forrest@0
  1751
  system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new)
forrest@0
  1752
; system("rm "+plot_name+"."+plot_type)
forrest@0
  1753
; system("rm "+plot_name+"-1."+plot_type_new)
forrest@0
  1754
; system("mv "+plot_name+"-0."+plot_type_new+" "+plot_name+"."+plot_type_new)
forrest@0
  1755
;-------------------------------------------------------------------
forrest@0
  1756
  temp_name = "lai." + model_name
forrest@0
  1757
  system("mkdir -p " + temp_name)
forrest@0
  1758
  system("cp table.html " + temp_name)
forrest@0
  1759
  system("mv *.png " + temp_name)
forrest@0
  1760
  system("tar cf "+ temp_name +".tar " + temp_name)
forrest@0
  1761
;------------------------------------------------------------------- 
forrest@0
  1762
end
forrest@0
  1763