npp/03.0.05deg_to_1.9.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.
     1 ; ***********************************************
     2 ; interpolate into model grids (1.9x2.5)
     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 ; output data
    11 ;************************************************
    12   diro  = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
    13   filo  = "Npp_1.9_mean.nc"
    14   c = addfile(diro+filo,"c")
    15 
    16 ;************************************************
    17 ; read in observed data
    18 ;************************************************
    19   diri  = "/fis/cgd/cseg/people/jeff/clamp_data/npp/ob/"
    20   fili  = "Npp_0.05deg_mean.nc"
    21   g     = addfile (diri+fili,"r")
    22   bi    = g->NPP   
    23   xi    = g->lon 
    24   yi    = g->lat
    25 
    26 ;************************************************
    27 ; change into 0-360E, 90S-90N
    28 ; Observed NPP*scale_factor
    29 ;************************************************
    30 
    31  scale_factor = 0.1
    32  
    33  yi    = (/ yi(::-1) /)
    34  bi    =  (/ bi(::-1,:) /)
    35  b2    = bi
    36  x2    = xi   
    37  
    38  nx = dimsizes(xi)
    39  do i= 0,nx-1
    40     if (i .lt. 3600) then
    41        p = i + 3600
    42        xi(p) = x2(i) + 360.      
    43     else
    44        p = i - 3600
    45        xi(p) = x2(i)
    46     end if
    47     bi(:,p)= b2(:,i) * scale_factor
    48  end do
    49 
    50  bi&lat =  yi
    51  bi&lon =  xi
    52 
    53 ;print (xi)
    54 ;print (yi)
    55 ;************************************************
    56 ; read in model data
    57 ;************************************************
    58  diri2  = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
    59  fili2  = "newcn05_ncep_1i_MONS_climo_lnd.nc"
    60  f      = addfile (diri2+fili2,"r")
    61 
    62  lon    = f->lon     
    63  lat    = f->lat
    64  nlon   = dimsizes(lon)
    65  nlat   = dimsizes(lat)      
    66 
    67 ; print (xi)
    68 ; print (yi)
    69 ; print (xo)
    70 ; print (yo)
    71 
    72  bo = new((/nlat,nlon/),float)
    73 
    74     do j=0,nlat-1
    75        if (j.eq.0 .or. j.eq.nlat-1) then
    76           if (j.eq.0) then
    77              LATS = -90.          
    78              LATN = lat(j)+0.5*(lat(j+1)-lat(j))
    79           end if
    80           if (j.eq.nlat-1) then
    81              LATS = lat(j)-0.5*(lat(j)-lat(j-1))
    82              LATN = 90.                  
    83           end if
    84        else
    85           LATS = lat(j)-0.5*(lat(j)-lat(j-1))
    86           LATN = lat(j)+0.5*(lat(j+1)-lat(j))
    87        end if
    88   
    89       do i=0,nlon-1
    90        if (i.eq.0 .or. i.eq.nlon-1) then
    91           if (i.eq.0) then
    92              LONL = 0.          
    93              LONR = lon(i)+0.5*(lon(i+1)-lon(i))
    94           end if
    95           if (i.eq.nlon-1) then
    96              LONL = lon(i)-0.5*(lon(i)-lon(i-1))
    97              LONR = 360.                 
    98           end if
    99        else
   100           LONL = lon(i)-0.5*(lon(i)-lon(i-1))
   101           LONR = lon(i)+0.5*(lon(i+1)-lon(i))
   102        end if
   103 
   104 ;print (LATS)
   105 ;print (LATN)
   106 ;print (LONL)
   107 ;print (LONR)
   108 
   109          bo(j,i) = avg(bi({LATS:LATN},{LONL:LONR}))  
   110       end do 
   111     end do
   112 
   113   bo!0   = "lat"
   114   bo!1   = "lon"
   115   bo&lat =  lat
   116   bo&lon =  lon
   117   bo@units      = bi@units
   118   bo@long_name  = bi@long_name
   119 ; bo@_FillValue = bi@_FillValue
   120   bo@_FillValue = 1.e+36
   121 
   122   c->NPP  = bo
   123 end