ameriflux/07.missing_year.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
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
forrest@0
     3
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
forrest@0
     4
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
forrest@0
     5
;************************************************************
forrest@0
     6
forrest@0
     7
begin
forrest@0
     8
forrest@0
     9
  year_new = 2000
forrest@0
    10
  file_input  = "1999_L4_m.nc"
forrest@0
    11
  file_output = year_new+"_L4_m.nc"
forrest@0
    12
 
forrest@0
    13
  a = addfile(file_input,"r")
forrest@0
    14
  b = addfile(file_output,"c")
forrest@0
    15
;-------------------------------------------------------------------
forrest@0
    16
; Enter predefine phase.
forrest@0
    17
forrest@0
    18
; Write global attributes to file. It's okay to do this before 
forrest@0
    19
; predefining the file's variables. We are still in "define" mode.
forrest@0
    20
forrest@0
    21
  fAtt               = True
forrest@0
    22
  fAtt@description   = "Data read in from " + file_input 
forrest@0
    23
  fAtt@creation_date = systemfunc ("date")        
forrest@0
    24
  fileattdef( b, fAtt )        
forrest@0
    25
forrest@0
    26
  filedimdef( b,"year",-1,True)
forrest@0
    27
;-------------------------------------------------------------------
forrest@0
    28
  month_of_year = (/1,2,3,4,5,6,7,8,9,10,11,12/)
forrest@0
    29
 
forrest@0
    30
  Var = getfilevarnames(a)
forrest@0
    31
  nVar= dimsizes(Var)
forrest@0
    32
forrest@0
    33
; do n = 0,nVar-1
forrest@0
    34
;    print( (/Var(n)/))
forrest@0
    35
; end do
forrest@0
    36
 
forrest@0
    37
  do n = 0,nVar-1
forrest@0
    38
forrest@0
    39
     if (Var(n).ne."year" .and. Var(n).ne."Month" .and. Var(n).ne."n_days" .and. Var(n).ne."lat" .and. Var(n).ne."lon" ) then
forrest@0
    40
forrest@0
    41
        temp = a->$Var(n)$
forrest@0
    42
        temp(0,:) = -999.
forrest@0
    43
        b->$Var(n)$ = temp
forrest@0
    44
     else
forrest@0
    45
forrest@0
    46
     if (Var(n).eq."year") then
forrest@0
    47
        b->$Var(n)$ = year_new
forrest@0
    48
     end if
forrest@0
    49
forrest@0
    50
     if (Var(n).eq."Month") then
forrest@0
    51
        Month = a->$Var(n)$
forrest@0
    52
        Month(0,:)= month_of_year + year_new * 100   
forrest@0
    53
        b->$Var(n)$ = Month
forrest@0
    54
     end if
forrest@0
    55
forrest@0
    56
     if (Var(n).eq."n_days" .or. Var(n).eq."lat" .or. Var(n).eq."lon") then
forrest@0
    57
        b->$Var(n)$ = a->$Var(n)$
forrest@0
    58
     end if
forrest@0
    59
forrest@0
    60
     end if
forrest@0
    61
  end do
forrest@0
    62
 
forrest@0
    63
end