all/99.final.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
; landfrac applied to area only.
forrest@0
     3
; using model biome class
forrest@0
     4
;
forrest@0
     5
; required command line input parameters:
forrest@0
     6
;  ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
forrest@0
     7
;
forrest@0
     8
; histogram normalized by rain and compute correleration
forrest@0
     9
;**************************************************************
forrest@0
    10
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
forrest@0
    11
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
forrest@0
    12
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
forrest@0
    13
;**************************************************************
forrest@0
    14
procedure set_line(lines:string,nline:integer,newlines:string) 
forrest@0
    15
begin
forrest@0
    16
; add line to ascci/html file
forrest@0
    17
    
forrest@0
    18
  nnewlines = dimsizes(newlines)
forrest@0
    19
  if(nline+nnewlines-1.ge.dimsizes(lines))
forrest@0
    20
    print("set_line: bad index, not setting anything.") 
forrest@0
    21
    return
forrest@0
    22
  end if 
forrest@0
    23
  lines(nline:nline+nnewlines-1) = newlines
forrest@0
    24
;  print ("lines = " + lines(nline:nline+nnewlines-1))
forrest@0
    25
  nline = nline + nnewlines
forrest@0
    26
  return 
forrest@0
    27
end
forrest@0
    28
;**************************************************************
forrest@0
    29
; Main code.
forrest@0
    30
begin
forrest@0
    31
;--------------------------------------------------
forrest@0
    32
; edit table.html of current model for movel1_vs_model2
forrest@0
    33
forrest@0
    34
 if (isvar("compare")) then
forrest@0
    35
    html_name2 = compare+"/table.html"  
forrest@0
    36
    html_new2  = html_name2 +".new"
forrest@0
    37
 end if
forrest@0
    38
forrest@0
    39
;-------------------------------------
forrest@0
    40
; edit table.html for current model
forrest@0
    41
forrest@0
    42
 html_name = model_name+"/table.html"  
forrest@0
    43
 html_new  = html_name +".new"
forrest@0
    44
forrest@0
    45
;---------------------------------------------------
forrest@0
    46
; add total score and update metric table
forrest@0
    47
forrest@0
    48
  M_save = 0.
forrest@0
    49
forrest@0
    50
  if (isfilepresent("M_save.npp")) then
forrest@0
    51
     M_save = M_save + asciiread("M_save.npp",(/1/),"float")
forrest@0
    52
  end if
forrest@0
    53
forrest@0
    54
  if (isfilepresent("M_save.lai")) then
forrest@0
    55
     M_save = M_save + asciiread("M_save.lai",(/1/),"float")
forrest@0
    56
  end if 
forrest@0
    57
forrest@0
    58
  if (film3 .ne. "") then
forrest@0
    59
  if (isfilepresent("M_save.co2")) then
forrest@0
    60
     M_save = M_save + asciiread("M_save.co2",(/1/),"float")
forrest@0
    61
  end if
forrest@0
    62
  end if
forrest@0
    63
forrest@0
    64
  if (isfilepresent("M_save.biomass")) then
forrest@0
    65
     M_save = M_save + asciiread("M_save.biomass",(/1/),"float")
forrest@0
    66
  end if
forrest@0
    67
forrest@0
    68
  if (isfilepresent("M_save.fluxnet")) then
forrest@0
    69
     M_save = M_save + asciiread("M_save.fluxnet",(/1/),"float")
forrest@0
    70
  end if
forrest@0
    71
forrest@0
    72
  if (isfilepresent("M_save.beta")) then
forrest@0
    73
     M_save = M_save + asciiread("M_save.beta",(/1/),"float")
forrest@0
    74
  end if
forrest@0
    75
forrest@0
    76
  if (isfilepresent("M_save.fire")) then
forrest@0
    77
     M_save = M_save + asciiread("M_save.fire",(/1/),"float")
forrest@0
    78
  end if
forrest@0
    79
forrest@0
    80
  if (isfilepresent("M_save.ameriflux")) then
forrest@0
    81
     M_save = M_save + asciiread("M_save.ameriflux",(/1/),"float")
forrest@0
    82
  end if
forrest@0
    83
forrest@0
    84
  M_total = sprintf("%.2f", M_save)
forrest@0
    85
forrest@0
    86
  if (isvar("compare")) then
forrest@0
    87
     system("sed -e '1,/M_total/s/M_total/"+M_total+"/' "+html_name2+" > "+html_new2+";"+ \
forrest@0
    88
            "mv -f "+html_new2+" "+html_name2)
forrest@0
    89
  end if
forrest@0
    90
forrest@0
    91
  system("sed s#M_total#"+M_total+"# "+html_name+" > "+html_new+";"+ \
forrest@0
    92
         "mv -f "+html_new+" "+html_name+";"+ \
forrest@0
    93
         "rm M_save.*")
forrest@0
    94
end
forrest@0
    95