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