npp/02.read_binary_0.05deg.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 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"  
     2 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"  
     3 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  
     4 
     5 begin
     6   nlat  = 3600
     7   mlon  = 7200
     8 
     9   diri  = "/fis/cgd/cseg/people/jeff/clamp/"
    10   fili  = "Npp_0.05deg_mean.int16"
    11 
    12   diro  = "/fis/cgd/cseg/people/jeff/clamp/"
    13   filo  = "Npp_0.05deg_mean_3.nc"
    14   c = addfile(diro+filo,"c")
    15 
    16 ; I think  (a) the file is "little endian"; read into short
    17 ;          (b) the _FillValue is 32700
    18 
    19   setfileoption("bin","ReadByteOrder","LittleEndian")
    20   xShort= fbindirread(diri+fili,0, (/nlat,mlon/), "short")
    21   xShort@_FillValue= inttoshort(32700)
    22 
    23 ;;xShort@scale_factor = ?????
    24 ;;xShort@add_offset   = ?????
    25 
    26   x     = short2flt( xShort )
    27 
    28 ;;print(xShort(:,1800)+"   "+x(:,1800))      ; look at the values
    29   delete(xShort)
    30 
    31   x@long_name  = "net primary production"
    32   x@units      = "gC/m^2/year"
    33 ; x@_FillValue = -17281                      ; orig fill    
    34   x@_FillValue =  1e20                       ; new fill
    35 
    36   lat  = latGlobeFo(nlat, "lat", "latitude", "degrees_north")
    37   lat  = (/ lat(::-1) /)                     ; make N->S
    38   lon  = lonGlobeFo(mlon, "lon", "longitude", "degrees_east")
    39   lon  = (/ lon - 180. /) ; subtract 180 from all values 
    40   lon&lon = lon           ; update coordinates
    41 
    42   x!0  = "lat"
    43   x!1  = "lon"
    44   x&lat=  lat
    45   x&lon=  lon
    46 
    47   c->NPP  = x
    48 
    49   exit
    50   
    51 ;************************************************
    52 ; create default plot
    53 ;************************************************
    54   
    55   setvalues NhlGetWorkspaceObjectId()
    56     "wsMaximumSize" : 199999999
    57   end setvalues
    58 
    59   wks = gsn_open_wks("ps","Npp_rdBinPlt")                  ; open a ps file
    60  ;gsn_define_colormap(wks,"wgne15")          ; choose colormap
    61 
    62   res                     = True             ; Use plot options
    63   res@cnFillOn            = True             ; Turn on color fill
    64   res@cnFillMode          = "RasterFill"     ; Turn on raster color
    65   res@lbLabelAutoStride   = True
    66   res@cnLinesOn           = False            ; Turn off contourn lines
    67  ;res@gsnSpreadColors     = True             ; use full colormap
    68   res@mpFillOn            = False            ; Turn off map fill
    69 
    70  ;res@cnLevelSelectionMode = "ManualLevels"    ; Manual contour invtervals
    71  ;res@cnMinLevelValF       =                   ; Min level
    72  ;res@cnMaxLevelValF       =                   ; Max level
    73  ;res@cnLevelSpacingF      =                   ; interval
    74   res@tiMainString         = fili
    75 
    76   plot = gsn_csm_contour_map_ce(wks,x,res)    
    77 
    78 end
    79