time_series/20.write_fire_cn.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
;    output: lat: N->S     lon: -180W->180E                         
forrest@0
     3
;************************************************
forrest@0
     4
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
forrest@0
     5
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
forrest@0
     6
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  
forrest@0
     7
;************************************************
forrest@0
     8
begin
forrest@0
     9
forrest@0
    10
; output
forrest@0
    11
forrest@0
    12
  model_name = "i01.10cn"
forrest@0
    13
  
forrest@0
    14
  diro  = "/ptmp/jeff/"
forrest@0
    15
  filo  = model_name + "_Fire_C_1979-2004_monthly.nc"
forrest@0
    16
  c = addfile(diro+filo,"c")
forrest@0
    17
  filedimdef(c,"year",-1,True) 
forrest@0
    18
forrest@0
    19
; input data
forrest@0
    20
forrest@0
    21
  nlat = 64
forrest@0
    22
  nlon = 128
forrest@0
    23
forrest@0
    24
  year_start = 1979
forrest@0
    25
  year_end   = 2004
forrest@0
    26
forrest@0
    27
  nyear  = year_end - year_start + 1
forrest@0
    28
  nmonth = 12
forrest@0
    29
  
forrest@0
    30
  data1  = new((/nyear,nmonth,nlat,nlon/),float)
forrest@0
    31
  data2  = new((/nyear,nmonth,nlat,nlon/),float)
forrest@0
    32
  data3  = new((/nyear,nmonth,nlat,nlon/),float)
forrest@0
    33
  date   = new((/nyear,nmonth/),integer)
forrest@0
    34
forrest@0
    35
; input dir
forrest@0
    36
  diri  = "/ptmp/jeff/"+model_name+"/"
forrest@0
    37
forrest@0
    38
  do m = 0,nyear-1
forrest@0
    39
     year = year_start + m
forrest@0
    40
  do n = 0,nmonth-1
forrest@0
    41
     nn = n+1
forrest@0
    42
     date(m,n) = year*100 +nn 
forrest@0
    43
     
forrest@0
    44
;    input file
forrest@0
    45
     if (nn .ge. 10) then
forrest@0
    46
        fili = model_name+".clm2.h0."+year+"-"+nn+".nc"
forrest@0
    47
     else
forrest@0
    48
        fili = model_name+".clm2.h0."+year+"-0"+nn+".nc"
forrest@0
    49
     end if
forrest@0
    50
forrest@0
    51
;    print (fili)
forrest@0
    52
forrest@0
    53
     g  = addfile (diri+fili,"r")
forrest@0
    54
forrest@0
    55
     b1 = g->COL_FIRE_CLOSS
forrest@0
    56
     data1(m,n,:,:) = (/b1(0,:,:)/)
forrest@0
    57
forrest@0
    58
     b2 = g->NPP
forrest@0
    59
     data2(m,n,:,:) = (/b2(0,:,:)/)
forrest@0
    60
forrest@0
    61
     b3 = g->NEE
forrest@0
    62
     data3(m,n,:,:) = (/b3(0,:,:)/)        
forrest@0
    63
  end do
forrest@0
    64
  end do
forrest@0
    65
forrest@0
    66
;  name dimensions and assign coordinate variables
forrest@0
    67
forrest@0
    68
  data1!0    ="year"
forrest@0
    69
  data1!1    ="month"
forrest@0
    70
  data1!2    = "lat"
forrest@0
    71
  data1!3    = "lon"
forrest@0
    72
  data1@long_name  = b1@long_name
forrest@0
    73
  data1@units      = b1@units
forrest@0
    74
  data1@_FillValue = b1@_FillValue
forrest@0
    75
forrest@0
    76
  data2!0    ="year"
forrest@0
    77
  data2!1    ="month"
forrest@0
    78
  data2!2    = "lat"
forrest@0
    79
  data2!3    = "lon"
forrest@0
    80
  data2@long_name  = b2@long_name
forrest@0
    81
  data2@units      = b2@units
forrest@0
    82
  data2@_FillValue = b2@_FillValue
forrest@0
    83
forrest@0
    84
  data3!0    ="year"
forrest@0
    85
  data3!1    ="month"
forrest@0
    86
  data3!2    = "lat"
forrest@0
    87
  data3!3    = "lon"
forrest@0
    88
  data3@long_name  = b3@long_name
forrest@0
    89
  data3@units      = b3@units
forrest@0
    90
  data3@_FillValue = b3@_FillValue
forrest@0
    91
forrest@0
    92
  date!0    ="year"
forrest@0
    93
  date!1    ="month"
forrest@0
    94
  date@long_name  = "date: yyyymm"
forrest@0
    95
         
forrest@0
    96
  c->COL_FIRE_CLOSS = data1
forrest@0
    97
  c->NPP            = data2
forrest@0
    98
  c->NEE            = data3
forrest@0
    99
  c->date           = date
forrest@0
   100
  c->area           = g->area
forrest@0
   101
forrest@0
   102
  print (date)
forrest@0
   103
forrest@0
   104
end