npp/02.read_binary_Npp.ncl.0
changeset 0 0c6405ab2ff4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/npp/02.read_binary_Npp.ncl.0	Mon Jan 26 22:08:20 2009 -0500
     1.3 @@ -0,0 +1,94 @@
     1.4 +;************************************************
     1.5 +;    Read ascii, Write nc                         
     1.6 +;************************************************
     1.7 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"  
     1.8 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"  
     1.9 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"   
    1.10 +;************************************************
    1.11 +begin
    1.12 +;---------------------------------------------------
    1.13 +; final data                                    
    1.14 +  c = addfile("Npp_0.05deg_mean_2.nc","c")
    1.15 +  filedimdef(c,"time",-1,True) 
    1.16 +       
    1.17 +  nlat  = 180*20 
    1.18 +  nlon  = 360*20  
    1.19 + 
    1.20 +;---------------------------------------------------
    1.21 +; input data
    1.22 +  b = "Npp_0.05deg_mean.int16"                    
    1.23 +
    1.24 +  x        = new((/nlat*nlon/),float)   
    1.25 +  t        = new((/1,nlat,nlon/),float)
    1.26 +  lon      = new((/nlon/),float)
    1.27 +  lat      = new((/nlat/),float)
    1.28 +  time     = new((/1/),integer)
    1.29 +
    1.30 +; sam result
    1.31 +; lon = fspan(-180.,179.95,nlon)
    1.32 +; lat = fspan(-90. , 89.95,nlat)
    1.33 + 
    1.34 +  do i = 0,nlon-1
    1.35 +     lon(i) = -180. + i*(360./nlon)
    1.36 +  end do
    1.37 + 
    1.38 +  do j = 0,nlat-1
    1.39 +     lat(j) =  -90. + j*(180./nlat)
    1.40 +  end do
    1.41 + 
    1.42 +  time = 1
    1.43 +
    1.44 +; print (lon)
    1.45 +; print (lat)       
    1.46 +; print (time) 
    1.47 +;=============================
    1.48 +    ;  create lat and long coordinate variables
    1.49 +    ;============================                                         
    1.50 +     lon!0          = "lon"
    1.51 +     lon@long_name  = "lon"
    1.52 +     lon@units      = "degrees-east"
    1.53 +     lon&lon        = lon
    1.54 +
    1.55 +     lat!0          = "lat"
    1.56 +     lat@long_name  = "lat"
    1.57 +     lat@units      = "degrees_north"
    1.58 +     lat&lat        = lat
    1.59 +    ;=============================
    1.60 +    ;  name dimensions of t and assign coordinate variables
    1.61 +    ;============================
    1.62 +     t!0    = "time"  
    1.63 +     t!1    = "lat"
    1.64 +     t!2    = "lon"
    1.65 +     t&time = time
    1.66 +     t&lat  = lat
    1.67 +     t&lon  = lon
    1.68 +     t@long_name = "net primary production"
    1.69 +     t@units     = "gC/m^2/year"
    1.70 +     t@_FillValue= 1.e+36         
    1.71 +     t@missing_value= 1.e+36 
    1.72 +        
    1.73 +;  t = fbinrecread(b,0,(/nlat,nlon/),"float")
    1.74 +          
    1.75 +   do j = 0,nlat-1
    1.76 +print (j)
    1.77 +   do i = 0,nlon-1
    1.78 +      nrec = j*nlon + i
    1.79 +      x(nrec) = fbindirread(b,nrec,1,"float")
    1.80 +   end do
    1.81 +   end do
    1.82 +print (lat)
    1.83 +   t = onedtond(x,(/nlat,nlon/))
    1.84 +
    1.85 +  c->NPP  = t
    1.86 +  c->lat  = lat
    1.87 +  c->lon  = lon
    1.88 +  c->time = time
    1.89 +
    1.90 +;  do i = 0,nlon-1           
    1.91 +;  do j = 0,nlat-1                                                       
    1.92 +;  if (t(0,j,i) .gt. 0.) then
    1.93 +;     print (t(0,j,i))
    1.94 +;  end if
    1.95 +;  end do
    1.96 +;  end do
    1.97 +end