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