class/03.class_T42_write.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
     1 ;*************************************************
     2 ; ce_1.ncl
     3 ;************************************************
     4 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"  
     5 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
     6 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  
     7 ;************************************************
     8 begin
     9 
    10 ; final output
    11 
    12   diro  = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
    13   filo =  "class_pft_T42.nc"
    14   c = addfile(diro+filo,"c")
    15  
    16 ; read model data
    17 
    18   diri  = "/fis/cgd/cseg/people/jeff/surface_data/"
    19   fili  = "T42.clamp.surface-data.060412.nc"
    20   f     = addfile(diri+fili,"r")
    21 
    22   y     = f->PCT_PFT
    23 ; printVarSummary(y)
    24 
    25 ; read model grid data
    26 
    27   diri  = "/fis/cgd/cseg/people/jeff/surface_data/"
    28   fili  = "lnd_T42.nc"   
    29   g = addfile(diri+fili,"r")
    30 
    31   landmask = g->landmask
    32   lat      = g->lat
    33   lon      = g->lon
    34 
    35   nlat = dimsizes(lat)
    36   nlon = dimsizes(lon)
    37 
    38   x = y(0,:,:)
    39 
    40   x!0   = "lat"
    41   x&lat = lat            
    42   x!1   = "lon"
    43   x&lon = lon
    44   x@_FillValue = 1.e36
    45   x@long_name  = "Model PFT Classes"  
    46   
    47   do j= 0,nlat-1
    48   do i= 0,nlon-1
    49      x(j,i) = maxind(y(:,j,i))      
    50   end do
    51   end do 
    52 
    53 ; print (x)  
    54 
    55   x = where(landmask .lt. 1.,x@_FillValue,x)
    56 
    57   c->CLASS_PFT = x
    58   c->lat       = lat 
    59   c->lon       = lon   
    60 
    61 end