fire/22.table+tseries.ncl
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
;using model biome vlass
forrest@0
     3
;
forrest@0
     4
; required command line input parameters:
forrest@0
     5
;  ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
forrest@0
     6
;
forrest@0
     7
; histogram normalized by rain and compute correleration
forrest@0
     8
;**************************************************************
forrest@0
     9
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
forrest@0
    10
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
forrest@0
    11
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
forrest@0
    12
;**************************************************************
forrest@0
    13
procedure set_line(lines:string,nline:integer,newlines:string) 
forrest@0
    14
begin
forrest@0
    15
; add line to ascci/html file
forrest@0
    16
    
forrest@0
    17
  nnewlines = dimsizes(newlines)
forrest@0
    18
  if(nline+nnewlines-1.ge.dimsizes(lines))
forrest@0
    19
    print("set_line: bad index, not setting anything.") 
forrest@0
    20
    return
forrest@0
    21
  end if 
forrest@0
    22
  lines(nline:nline+nnewlines-1) = newlines
forrest@0
    23
;  print ("lines = " + lines(nline:nline+nnewlines-1))
forrest@0
    24
  nline = nline + nnewlines
forrest@0
    25
  return 
forrest@0
    26
end
forrest@0
    27
;**************************************************************
forrest@0
    28
; Main code.
forrest@0
    29
begin
forrest@0
    30
 
forrest@0
    31
  plot_type     = "ps"
forrest@0
    32
  plot_type_new = "png"
forrest@0
    33
forrest@0
    34
;---------------------------------------------------
forrest@0
    35
; model name and grid       
forrest@0
    36
forrest@0
    37
  model_grid = "T42"
forrest@0
    38
forrest@0
    39
  model_name  = "cn"
forrest@0
    40
  model_name1 = "i01.06cn"
forrest@0
    41
  model_name2 = "i01.10cn"
forrest@0
    42
forrest@0
    43
;---------------------------------------------------
forrest@0
    44
; get biome data: model
forrest@0
    45
forrest@0
    46
  biome_name_mod = "Model PFT Class"
forrest@0
    47
forrest@0
    48
  dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
forrest@0
    49
  film = "class_pft_"+model_grid+".nc"
forrest@0
    50
  fm   = addfile(dirm+film,"r")
forrest@0
    51
 
forrest@0
    52
  classmod = fm->CLASS_PFT
forrest@0
    53
forrest@0
    54
  delete (fm)
forrest@0
    55
forrest@0
    56
; model data has 17 land-type classes
forrest@0
    57
forrest@0
    58
  nclass_mod = 17
forrest@0
    59
forrest@0
    60
;--------------------------------------------------
forrest@0
    61
; get model data: landmask, landfrac and area
forrest@0
    62
forrest@0
    63
  dirm = "/fis/cgd/cseg/people/jeff/surface_data/" 
forrest@0
    64
  film = "lnd_T42.nc"
forrest@0
    65
  fm   = addfile (dirm+film,"r")
forrest@0
    66
  
forrest@0
    67
  landmask = fm->landmask
forrest@0
    68
  landfrac = fm->landfrac
forrest@0
    69
  area     = fm->area
forrest@0
    70
forrest@0
    71
  delete (fm)
forrest@0
    72
forrest@0
    73
; change area from km**2 to m**2
forrest@0
    74
  area = area * 1.e6             
forrest@0
    75
forrest@0
    76
;----------------------------------------------------
forrest@0
    77
; read data: time series, model
forrest@0
    78
forrest@0
    79
 dirm = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
forrest@0
    80
 film = model_name2 + "_Fire_C_1979-2004_monthly.nc"
forrest@0
    81
 fm   = addfile (dirm+film,"r")
forrest@0
    82
forrest@0
    83
 data_mod = fm->COL_FIRE_CLOSS(18:25,:,:,:)
forrest@0
    84
forrest@0
    85
 delete (fm)
forrest@0
    86
forrest@0
    87
; Units for these variables are:
forrest@0
    88
; g C/m^2/s
forrest@0
    89
forrest@0
    90
; change unit to g C/m^2/month
forrest@0
    91
forrest@0
    92
  nsec_per_month = 60*60*24*30
forrest@0
    93
 
forrest@0
    94
  data_mod = data_mod * nsec_per_month 
forrest@0
    95
forrest@0
    96
  data_mod@unit = "gC/m2/month"
forrest@0
    97
;----------------------------------------------------
forrest@0
    98
; read data: time series, observed
forrest@0
    99
forrest@0
   100
 dirm = "/fis/cgd/cseg/people/jeff/fire_data/ob/GFEDv2_C/"
forrest@0
   101
 film = "Fire_C_1997-2006_monthly_"+ model_grid+".nc"
forrest@0
   102
 fm   = addfile (dirm+film,"r")
forrest@0
   103
forrest@0
   104
 data_ob = fm->FIRE_C(0:7,:,:,:)
forrest@0
   105
forrest@0
   106
 delete (fm)
forrest@0
   107
forrest@0
   108
 ob_name = "GFEDv2"
forrest@0
   109
forrest@0
   110
; Units for these variables are:
forrest@0
   111
; g C/m^2/month
forrest@0
   112
forrest@0
   113
;---------------------------------------------------
forrest@0
   114
; take into account landfrac
forrest@0
   115
forrest@0
   116
 area     = area * landfrac
forrest@0
   117
 data_mod = data_mod * conform(data_mod, landfrac, (/2,3/))
forrest@0
   118
 data_ob  = data_ob  * conform(data_ob,  landfrac, (/2,3/))
forrest@0
   119
forrest@0
   120
 delete (landfrac)
forrest@0
   121
forrest@0
   122
;-------------------------------------------------------------
forrest@0
   123
; html table1 data
forrest@0
   124
forrest@0
   125
; column (not including header column)
forrest@0
   126
forrest@0
   127
  col_head  = (/"Model Fire_Flux (PgC/yr)" \
forrest@0
   128
               ,"Observed Fire_Flux (PgC/yr)" \
forrest@0
   129
               ,"Correlation Coefficient" \
forrest@0
   130
               ,"Ratio model/observed" \
forrest@0
   131
               ,"M_score" \
forrest@0
   132
               ,"Timeseries plot" \
forrest@0
   133
               /)
forrest@0
   134
forrest@0
   135
  ncol = dimsizes(col_head)
forrest@0
   136
forrest@0
   137
; row (not including header row)                   
forrest@0
   138
forrest@0
   139
; using model biome class:  
forrest@0
   140
  row_head  = (/"Not Vegetated" \
forrest@0
   141
               ,"Needleleaf Evergreen Temperate Tree" \
forrest@0
   142
               ,"Needleleaf Evergreen Boreal Tree" \
forrest@0
   143
;              ,"Needleleaf Deciduous Boreal Tree" \
forrest@0
   144
               ,"Broadleaf Evergreen Tropical Tree" \
forrest@0
   145
               ,"Broadleaf Evergreen Temperate Tree" \
forrest@0
   146
               ,"Broadleaf Deciduous Tropical Tree" \
forrest@0
   147
               ,"Broadleaf Deciduous Temperate Tree" \
forrest@0
   148
;              ,"Broadleaf Deciduous Boreal Tree" \
forrest@0
   149
;              ,"Broadleaf Evergreen Shrub" \
forrest@0
   150
               ,"Broadleaf Deciduous Temperate Shrub" \
forrest@0
   151
               ,"Broadleaf Deciduous Boreal Shrub" \
forrest@0
   152
               ,"C3 Arctic Grass" \
forrest@0
   153
               ,"C3 Non-Arctic Grass" \
forrest@0
   154
               ,"C4 Grass" \
forrest@0
   155
               ,"Corn" \
forrest@0
   156
;              ,"Wheat" \                      
forrest@0
   157
               ,"All Biome" \                
forrest@0
   158
               /)  
forrest@0
   159
  nrow = dimsizes(row_head)                  
forrest@0
   160
forrest@0
   161
; arrays to be passed to table. 
forrest@0
   162
  text = new ((/nrow, ncol/),string ) 
forrest@0
   163
forrest@0
   164
;*****************************************************************
forrest@0
   165
; (A) get time-mean
forrest@0
   166
;*****************************************************************
forrest@0
   167
  
forrest@0
   168
  x          = dim_avg_Wrap(data_mod(lat|:,lon|:,month|:,year|:))
forrest@0
   169
  data_mod_m = dim_avg_Wrap(       x(lat|:,lon|:,month|:))
forrest@0
   170
  delete (x)
forrest@0
   171
forrest@0
   172
  x          = dim_avg_Wrap( data_ob(lat|:,lon|:,month|:,year|:))
forrest@0
   173
  data_ob_m  = dim_avg_Wrap(       x(lat|:,lon|:,month|:))
forrest@0
   174
  delete (x)
forrest@0
   175
forrest@0
   176
;----------------------------------------------------
forrest@0
   177
; compute correlation coef
forrest@0
   178
forrest@0
   179
  landmask_1d = ndtooned(landmask)
forrest@0
   180
  data_mod_1d = ndtooned(data_mod_m)
forrest@0
   181
  data_ob_1d  = ndtooned(data_ob_m)
forrest@0
   182
forrest@0
   183
  good = ind(landmask_1d .gt. 0.)
forrest@0
   184
; print (dimsizes(good))
forrest@0
   185
forrest@0
   186
  cc = esccr(data_mod_1d(good),data_ob_1d(good),0)
forrest@0
   187
; print (cc)
forrest@0
   188
forrest@0
   189
  delete (landmask_1d)
forrest@0
   190
  delete (data_mod_1d)
forrest@0
   191
  delete (data_ob_1d)
forrest@0
   192
  delete (good)
forrest@0
   193
forrest@0
   194
;----------------------------------------------------
forrest@0
   195
; compute M_global
forrest@0
   196
forrest@0
   197
  score_max = 1.
forrest@0
   198
forrest@0
   199
  Mscore = cc * cc * score_max
forrest@0
   200
forrest@0
   201
  M_global = sprintf("%.2f", Mscore)
forrest@0
   202
 
forrest@0
   203
;----------------------------------------------------
forrest@0
   204
; global res
forrest@0
   205
forrest@0
   206
  resg                      = True             ; Use plot options
forrest@0
   207
  resg@cnFillOn             = True             ; Turn on color fill
forrest@0
   208
  resg@gsnSpreadColors      = True             ; use full colormap
forrest@0
   209
  resg@cnLinesOn            = False            ; Turn off contourn lines
forrest@0
   210
  resg@mpFillOn             = False            ; Turn off map fill
forrest@0
   211
  resg@cnLevelSelectionMode = "ManualLevels"   ; Manual contour invtervals
forrest@0
   212
      
forrest@0
   213
;----------------------------------------------------
forrest@0
   214
; global contour: model vs ob
forrest@0
   215
forrest@0
   216
  plot_name = "global_model_vs_ob"
forrest@0
   217
forrest@0
   218
  wks = gsn_open_wks (plot_type,plot_name)   
forrest@0
   219
  gsn_define_colormap(wks,"gui_default")     
forrest@0
   220
forrest@0
   221
  plot=new(3,graphic)                        ; create graphic array
forrest@0
   222
forrest@0
   223
  resg@gsnFrame             = False          ; Do not draw plot 
forrest@0
   224
  resg@gsnDraw              = False          ; Do not advance frame
forrest@0
   225
forrest@0
   226
;----------------------
forrest@0
   227
; plot correlation coef
forrest@0
   228
forrest@0
   229
  gRes               = True
forrest@0
   230
  gRes@txFontHeightF = 0.02
forrest@0
   231
  gRes@txAngleF      = 90
forrest@0
   232
forrest@0
   233
  correlation_text = "(correlation coef = "+sprintf("%.2f", cc)+")"
forrest@0
   234
forrest@0
   235
  gsn_text_ndc(wks,correlation_text,0.20,0.50,gRes)
forrest@0
   236
forrest@0
   237
;-----------------------  
forrest@0
   238
; plot ob
forrest@0
   239
forrest@0
   240
  data_ob_m = where(landmask .gt. 0., data_ob_m, data_ob_m@_FillValue)
forrest@0
   241
forrest@0
   242
  title     = ob_name
forrest@0
   243
  resg@tiMainString  = title
forrest@0
   244
forrest@0
   245
  resg@cnMinLevelValF       = 1.             
forrest@0
   246
  resg@cnMaxLevelValF       = 10.             
forrest@0
   247
  resg@cnLevelSpacingF      = 1.
forrest@0
   248
forrest@0
   249
  plot(0) = gsn_csm_contour_map_ce(wks,data_ob_m,resg)       
forrest@0
   250
forrest@0
   251
;-----------------------
forrest@0
   252
; plot model
forrest@0
   253
forrest@0
   254
  data_mod_m = where(landmask .gt. 0., data_mod_m, data_mod_m@_FillValue)
forrest@0
   255
forrest@0
   256
  title     = "Model "+ model_name
forrest@0
   257
  resg@tiMainString  = title
forrest@0
   258
forrest@0
   259
  resg@cnMinLevelValF       = 1.             
forrest@0
   260
  resg@cnMaxLevelValF       = 10.             
forrest@0
   261
  resg@cnLevelSpacingF      = 1.
forrest@0
   262
forrest@0
   263
  plot(1) = gsn_csm_contour_map_ce(wks,data_mod_m,resg) 
forrest@0
   264
forrest@0
   265
;-----------------------
forrest@0
   266
; plot model-ob
forrest@0
   267
forrest@0
   268
     resg@cnMinLevelValF  = -8.           
forrest@0
   269
     resg@cnMaxLevelValF  =  2.            
forrest@0
   270
     resg@cnLevelSpacingF =  1.
forrest@0
   271
forrest@0
   272
  zz = data_ob_m
forrest@0
   273
  zz = data_mod_m - data_ob_m
forrest@0
   274
  title = "Model_"+model_name+" - Observed"
forrest@0
   275
  resg@tiMainString    = title
forrest@0
   276
forrest@0
   277
  plot(2) = gsn_csm_contour_map_ce(wks,zz,resg) 
forrest@0
   278
forrest@0
   279
; plot panel
forrest@0
   280
forrest@0
   281
  pres                            = True        ; panel plot mods desired
forrest@0
   282
  pres@gsnMaximize                = True        ; fill the page
forrest@0
   283
forrest@0
   284
  gsn_panel(wks,plot,(/3,1/),pres)              ; create panel plot
forrest@0
   285
forrest@0
   286
; system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
forrest@0
   287
;        "rm "+plot_name+"."+plot_type)
forrest@0
   288
forrest@0
   289
  clear (wks)
forrest@0
   290
  delete (plot)
forrest@0
   291
forrest@0
   292
  delete (data_ob_m)
forrest@0
   293
  delete (data_mod_m)
forrest@0
   294
  delete (zz)
forrest@0
   295
forrest@0
   296
  resg@gsnFrame             = True          ; Do advance frame 
forrest@0
   297
  resg@gsnDraw              = True          ; Do draw plot
forrest@0
   298
forrest@0
   299
;*******************************************************************
forrest@0
   300
; (B) Time series : per biome
forrest@0
   301
;*******************************************************************
forrest@0
   302
forrest@0
   303
 data_n = 2
forrest@0
   304
forrest@0
   305
 dsizes = dimsizes(data_mod)
forrest@0
   306
 nyear  = dsizes(0)
forrest@0
   307
 nmonth = dsizes(1)
forrest@0
   308
 ntime  = nyear * nmonth
forrest@0
   309
forrest@0
   310
 year_start = 1997
forrest@0
   311
 year_end   = 2004
forrest@0
   312
                
forrest@0
   313
;-------------------------------------------
forrest@0
   314
; Calculate "nice" bins for binning the data
forrest@0
   315
forrest@0
   316
; using model biome class
forrest@0
   317
  nclass = nclass_mod
forrest@0
   318
forrest@0
   319
  range  = fspan(0,nclass,nclass+1)
forrest@0
   320
forrest@0
   321
; print (range)
forrest@0
   322
; Use this range information to grab all the values in a
forrest@0
   323
; particular range, and then take an average.
forrest@0
   324
forrest@0
   325
  nx = dimsizes(range) - 1
forrest@0
   326
forrest@0
   327
;-------------------------------------------
forrest@0
   328
; put data into bins
forrest@0
   329
forrest@0
   330
; using observed biome class
forrest@0
   331
; base  = ndtooned(classob)
forrest@0
   332
; using model biome class
forrest@0
   333
  base  = ndtooned(classmod)
forrest@0
   334
forrest@0
   335
; output
forrest@0
   336
forrest@0
   337
  area_bin = new((/nx/),float)
forrest@0
   338
  yvalues  = new((/ntime,data_n,nx/),float)
forrest@0
   339
forrest@0
   340
; Loop through each range, using base.
forrest@0
   341
forrest@0
   342
  do i=0,nx-1
forrest@0
   343
forrest@0
   344
     if (i.ne.(nx-1)) then
forrest@0
   345
        idx = ind((base.ge.range(i)).and.(base.lt.range(i+1)))
forrest@0
   346
     else
forrest@0
   347
        idx = ind(base.ge.range(i))
forrest@0
   348
     end if
forrest@0
   349
;---------------------
forrest@0
   350
;    for area
forrest@0
   351
forrest@0
   352
     data = ndtooned(area)  
forrest@0
   353
forrest@0
   354
     if (.not.any(ismissing(idx))) then 
forrest@0
   355
        area_bin(i) = sum(data(idx))
forrest@0
   356
     else
forrest@0
   357
        area_bin(i) = area_bin@_FillValue
forrest@0
   358
     end if
forrest@0
   359
forrest@0
   360
;#############################################################
forrest@0
   361
; using model biome class:
forrest@0
   362
;     set the following 4 classes to _FillValue:
forrest@0
   363
;     (3)Needleleaf Deciduous Boreal Tree,
forrest@0
   364
;     (8)Broadleaf Deciduous Boreal Tree,
forrest@0
   365
;     (9)Broadleaf Evergreen Shrub,
forrest@0
   366
;     (16)Wheat
forrest@0
   367
forrest@0
   368
     if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
forrest@0
   369
        area_bin(i) = area_bin@_FillValue
forrest@0
   370
     end if
forrest@0
   371
;#############################################################  
forrest@0
   372
forrest@0
   373
  delete (data)
forrest@0
   374
forrest@0
   375
;---------------------
forrest@0
   376
; for data_mod and data_ob
forrest@0
   377
forrest@0
   378
  do n = 0,data_n-1
forrest@0
   379
forrest@0
   380
     t = -1
forrest@0
   381
     do m = 0,nyear-1
forrest@0
   382
     do k = 0,nmonth-1
forrest@0
   383
    
forrest@0
   384
        t = t + 1 
forrest@0
   385
forrest@0
   386
        if (n.eq.0) then
forrest@0
   387
           data = ndtooned(data_ob(m,k,:,:))
forrest@0
   388
        end if
forrest@0
   389
forrest@0
   390
        if (n.eq.1) then
forrest@0
   391
           data = ndtooned(data_mod(m,k,:,:))
forrest@0
   392
        end if
forrest@0
   393
forrest@0
   394
;       Calculate average
forrest@0
   395
 
forrest@0
   396
        if (.not.any(ismissing(idx))) then 
forrest@0
   397
           yvalues(t,n,i) = avg(data(idx))
forrest@0
   398
        else
forrest@0
   399
           yvalues(t,n,i) = yvalues@_FillValue
forrest@0
   400
        end if
forrest@0
   401
forrest@0
   402
;#############################################################
forrest@0
   403
; using model biome class:
forrest@0
   404
;     set the following 4 classes to _FillValue:
forrest@0
   405
;     (3)Needleleaf Deciduous Boreal Tree,
forrest@0
   406
;     (8)Broadleaf Deciduous Boreal Tree,
forrest@0
   407
;     (9)Broadleaf Evergreen Shrub,
forrest@0
   408
;     (16)Wheat
forrest@0
   409
forrest@0
   410
        if (i.eq.3 .or. i.eq.8 .or. i.eq.9 .or. i.eq.16) then
forrest@0
   411
           yvalues(t,n,i) = yvalues@_FillValue
forrest@0
   412
        end if
forrest@0
   413
;#############################################################  
forrest@0
   414
forrest@0
   415
     end do
forrest@0
   416
     end do
forrest@0
   417
forrest@0
   418
     delete(data)
forrest@0
   419
  end do 
forrest@0
   420
forrest@0
   421
    delete(idx)
forrest@0
   422
  end do
forrest@0
   423
forrest@0
   424
  delete (base)
forrest@0
   425
  delete (data_mod)
forrest@0
   426
  delete (data_ob)
forrest@0
   427
forrest@0
   428
;----------------------------------------------------------------
forrest@0
   429
; get area_good
forrest@0
   430
forrest@0
   431
  good = ind(.not.ismissing(area_bin))
forrest@0
   432
forrest@0
   433
  area_g = area_bin(good)  
forrest@0
   434
forrest@0
   435
  n_biome = dimsizes(good)
forrest@0
   436
forrest@0
   437
;----------------------------------------------------------------
forrest@0
   438
; data for tseries plot
forrest@0
   439
forrest@0
   440
  yvalues_g = new((/ntime,data_n,n_biome/),float)
forrest@0
   441
forrest@0
   442
  yvalues_g@units = "TgC/month"
forrest@0
   443
forrest@0
   444
; change unit to Tg C/month
forrest@0
   445
; change unit from g to Tg (Tera gram)
forrest@0
   446
  factor_unit = 1.e-12
forrest@0
   447
forrest@0
   448
  yvalues_g = yvalues(:,:,good) * conform(yvalues_g,area_g,2) * factor_unit
forrest@0
   449
forrest@0
   450
;-------------------------------------------------------------------
forrest@0
   451
; general settings for line plot
forrest@0
   452
forrest@0
   453
  res                   = True               
forrest@0
   454
  res@xyDashPatterns    = (/0,0/)          ; make lines solid
forrest@0
   455
  res@xyLineThicknesses = (/2.0,2.0/)      ; make lines thicker
forrest@0
   456
  res@xyLineColors      = (/"blue","red"/) ; line color
forrest@0
   457
forrest@0
   458
  res@trXMinF   = year_start
forrest@0
   459
  res@trXMaxF   = year_end + 1
forrest@0
   460
forrest@0
   461
  res@vpHeightF = 0.4                 ; change aspect ratio of plot
forrest@0
   462
; res@vpWidthF  = 0.8
forrest@0
   463
  res@vpWidthF  = 0.75   
forrest@0
   464
forrest@0
   465
  res@tiMainFontHeightF = 0.025       ; size of title 
forrest@0
   466
forrest@0
   467
  res@tmXBFormat  = "f"               ; not to add trailing zeros
forrest@0
   468
forrest@0
   469
; res@gsnMaximize = True
forrest@0
   470
forrest@0
   471
;----------------------------------------------
forrest@0
   472
; Add a boxed legend using the simple method
forrest@0
   473
forrest@0
   474
  res@pmLegendDisplayMode    = "Always"
forrest@0
   475
; res@pmLegendWidthF         = 0.1
forrest@0
   476
  res@pmLegendWidthF         = 0.08
forrest@0
   477
  res@pmLegendHeightF        = 0.06
forrest@0
   478
  res@pmLegendOrthogonalPosF = -1.17
forrest@0
   479
; res@pmLegendOrthogonalPosF = -1.00  ;(downward)
forrest@0
   480
; res@pmLegendOrthogonalPosF = -0.30  ;(downward)
forrest@0
   481
forrest@0
   482
; res@pmLegendParallelPosF   =  0.18
forrest@0
   483
  res@pmLegendParallelPosF   =  0.23  ;(rightward)
forrest@0
   484
  res@pmLegendParallelPosF   =  0.73  ;(rightward)
forrest@0
   485
  res@pmLegendParallelPosF   =  0.83  ;(rightward)
forrest@0
   486
forrest@0
   487
; res@lgPerimOn             = False
forrest@0
   488
  res@lgLabelFontHeightF     = 0.015
forrest@0
   489
  res@xyExplicitLegendLabels = (/"observed",model_name/)
forrest@0
   490
forrest@0
   491
;*******************************************************************
forrest@0
   492
; (A) time series plot: monthly ( 2 lines per plot)
forrest@0
   493
;*******************************************************************
forrest@0
   494
forrest@0
   495
; x-axis in time series plot
forrest@0
   496
forrest@0
   497
  timeI = new((/ntime/),integer)
forrest@0
   498
  timeF = new((/ntime/),float)
forrest@0
   499
  timeI = ispan(1,ntime,1)
forrest@0
   500
  timeF = year_start + (timeI-1)/12.
forrest@0
   501
  timeF@long_name = "year" 
forrest@0
   502
forrest@0
   503
  plot_data = new((/2,ntime/),float)
forrest@0
   504
  plot_data@long_name = "TgC/month"
forrest@0
   505
forrest@0
   506
;----------------------------------------------
forrest@0
   507
; time series : per biome
forrest@0
   508
 
forrest@0
   509
  do m = 0, n_biome-1
forrest@0
   510
forrest@0
   511
     plot_name = "monthly_biome_"+ m
forrest@0
   512
forrest@0
   513
     wks = gsn_open_wks (plot_type,plot_name)   
forrest@0
   514
forrest@0
   515
     title = "Fire : "+ row_head(m)
forrest@0
   516
     res@tiMainString = title
forrest@0
   517
forrest@0
   518
     plot_data(0,:) = yvalues_g(:,0,m)
forrest@0
   519
     plot_data(1,:) = yvalues_g(:,1,m)
forrest@0
   520
                                  
forrest@0
   521
     plot = gsn_csm_xy(wks,timeF,plot_data,res)
forrest@0
   522
forrest@0
   523
;    system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
forrest@0
   524
;          "rm "+plot_name+"."+plot_type)
forrest@0
   525
forrest@0
   526
     clear (wks)  
forrest@0
   527
     delete (plot)
forrest@0
   528
   
forrest@0
   529
  end do
forrest@0
   530
forrest@0
   531
;--------------------------------------------
forrest@0
   532
; time series: global
forrest@0
   533
forrest@0
   534
     plot_name = "monthly_global"
forrest@0
   535
forrest@0
   536
     wks = gsn_open_wks (plot_type,plot_name)   
forrest@0
   537
forrest@0
   538
     title = "Fire : "+ row_head(n_biome)
forrest@0
   539
     res@tiMainString = title
forrest@0
   540
forrest@0
   541
     do k = 0,ntime-1
forrest@0
   542
        plot_data(0,k) = sum(yvalues_g(k,0,:))
forrest@0
   543
        plot_data(1,k) = sum(yvalues_g(k,1,:))
forrest@0
   544
     end do
forrest@0
   545
                                  
forrest@0
   546
     plot = gsn_csm_xy(wks,timeF,plot_data,res)
forrest@0
   547
forrest@0
   548
;    system("convert "+plot_name+"."+plot_type+" "+plot_name+"."+plot_type_new+";"+ \
forrest@0
   549
;          "rm "+plot_name+"."+plot_type)
forrest@0
   550
forrest@0
   551
     clear (wks)  
forrest@0
   552
     delete (plot)
forrest@0
   553
end
forrest@0
   554