npp/02.read_binary_0.05deg.ncl
changeset 0 0c6405ab2ff4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/npp/02.read_binary_0.05deg.ncl	Mon Jan 26 22:08:20 2009 -0500
     1.3 @@ -0,0 +1,79 @@
     1.4 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"  
     1.5 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"  
     1.6 +load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  
     1.7 +
     1.8 +begin
     1.9 +  nlat  = 3600
    1.10 +  mlon  = 7200
    1.11 +
    1.12 +  diri  = "/fis/cgd/cseg/people/jeff/clamp/"
    1.13 +  fili  = "Npp_0.05deg_mean.int16"
    1.14 +
    1.15 +  diro  = "/fis/cgd/cseg/people/jeff/clamp/"
    1.16 +  filo  = "Npp_0.05deg_mean_3.nc"
    1.17 +  c = addfile(diro+filo,"c")
    1.18 +
    1.19 +; I think  (a) the file is "little endian"; read into short
    1.20 +;          (b) the _FillValue is 32700
    1.21 +
    1.22 +  setfileoption("bin","ReadByteOrder","LittleEndian")
    1.23 +  xShort= fbindirread(diri+fili,0, (/nlat,mlon/), "short")
    1.24 +  xShort@_FillValue= inttoshort(32700)
    1.25 +
    1.26 +;;xShort@scale_factor = ?????
    1.27 +;;xShort@add_offset   = ?????
    1.28 +
    1.29 +  x     = short2flt( xShort )
    1.30 +
    1.31 +;;print(xShort(:,1800)+"   "+x(:,1800))      ; look at the values
    1.32 +  delete(xShort)
    1.33 +
    1.34 +  x@long_name  = "net primary production"
    1.35 +  x@units      = "gC/m^2/year"
    1.36 +; x@_FillValue = -17281                      ; orig fill    
    1.37 +  x@_FillValue =  1e20                       ; new fill
    1.38 +
    1.39 +  lat  = latGlobeFo(nlat, "lat", "latitude", "degrees_north")
    1.40 +  lat  = (/ lat(::-1) /)                     ; make N->S
    1.41 +  lon  = lonGlobeFo(mlon, "lon", "longitude", "degrees_east")
    1.42 +  lon  = (/ lon - 180. /) ; subtract 180 from all values 
    1.43 +  lon&lon = lon           ; update coordinates
    1.44 +
    1.45 +  x!0  = "lat"
    1.46 +  x!1  = "lon"
    1.47 +  x&lat=  lat
    1.48 +  x&lon=  lon
    1.49 +
    1.50 +  c->NPP  = x
    1.51 +
    1.52 +  exit
    1.53 +  
    1.54 +;************************************************
    1.55 +; create default plot
    1.56 +;************************************************
    1.57 +  
    1.58 +  setvalues NhlGetWorkspaceObjectId()
    1.59 +    "wsMaximumSize" : 199999999
    1.60 +  end setvalues
    1.61 +
    1.62 +  wks = gsn_open_wks("ps","Npp_rdBinPlt")                  ; open a ps file
    1.63 + ;gsn_define_colormap(wks,"wgne15")          ; choose colormap
    1.64 +
    1.65 +  res                     = True             ; Use plot options
    1.66 +  res@cnFillOn            = True             ; Turn on color fill
    1.67 +  res@cnFillMode          = "RasterFill"     ; Turn on raster color
    1.68 +  res@lbLabelAutoStride   = True
    1.69 +  res@cnLinesOn           = False            ; Turn off contourn lines
    1.70 + ;res@gsnSpreadColors     = True             ; use full colormap
    1.71 +  res@mpFillOn            = False            ; Turn off map fill
    1.72 +
    1.73 + ;res@cnLevelSelectionMode = "ManualLevels"    ; Manual contour invtervals
    1.74 + ;res@cnMinLevelValF       =                   ; Min level
    1.75 + ;res@cnMaxLevelValF       =                   ; Max level
    1.76 + ;res@cnLevelSpacingF      =                   ; interval
    1.77 +  res@tiMainString         = fili
    1.78 +
    1.79 +  plot = gsn_csm_contour_map_ce(wks,x,res)    
    1.80 +
    1.81 +end
    1.82 +