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