class/02.class.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
;*************************************************
forrest@0
     2
; ce_1.ncl
forrest@0
     3
;************************************************
forrest@0
     4
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"  
forrest@0
     5
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
forrest@0
     6
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  
forrest@0
     7
;************************************************
forrest@0
     8
begin
forrest@0
     9
 
forrest@0
    10
;************************************************
forrest@0
    11
; read in model data
forrest@0
    12
;************************************************
forrest@0
    13
  diri  = "/fis/cgd/cseg/people/jeff/clamp/class/"
forrest@0
    14
  fili  = "T42.clamp.surface-data.060412.nc"
forrest@0
    15
  f     = addfile(diri+fili,"r")
forrest@0
    16
forrest@0
    17
  y     = f->PCT_PFT
forrest@0
    18
  printVarSummary(y)
forrest@0
    19
forrest@0
    20
  diri  = "/fis/cgd/cseg/people/jeff/surface_data/"
forrest@0
    21
  fili  = "lnd_T42.nc"   
forrest@0
    22
  g = addfile(diri+fili,"r")
forrest@0
    23
forrest@0
    24
  landmask = g->landmask
forrest@0
    25
  lat      = g->lat
forrest@0
    26
  lon      = g->lon
forrest@0
    27
forrest@0
    28
  nlat = dimsizes(lat)
forrest@0
    29
  nlon = dimsizes(lon)
forrest@0
    30
forrest@0
    31
  x = y(0,:,:)
forrest@0
    32
forrest@0
    33
  x!0   = "lat"
forrest@0
    34
  x&lat = lat            
forrest@0
    35
  x!1   = "lon"
forrest@0
    36
  x&lon = lon
forrest@0
    37
  x@_FillValue = 1.e36
forrest@0
    38
  x@long_name  = "Model PFT Classes"  
forrest@0
    39
  
forrest@0
    40
  do j= 0,nlat-1
forrest@0
    41
  do i= 0,nlon-1
forrest@0
    42
     x(j,i) = maxind(y(:,j,i))      
forrest@0
    43
  end do
forrest@0
    44
  end do 
forrest@0
    45
forrest@0
    46
; print (x)  
forrest@0
    47
forrest@0
    48
  x = where(landmask .lt. 1.,x@_FillValue,x)
forrest@0
    49
forrest@0
    50
;************************************************
forrest@0
    51
; create default plot
forrest@0
    52
;************************************************
forrest@0
    53
forrest@0
    54
  wks = gsn_open_wks("ps","class")              ; open a ps file
forrest@0
    55
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
    56
forrest@0
    57
  res                     = True             ; Use plot options
forrest@0
    58
  res@cnFillOn            = True             ; Turn on color fill
forrest@0
    59
  res@gsnSpreadColors     = True             ; use full colormap
forrest@0
    60
  res@cnLinesOn           = False            ; Turn off contourn lines
forrest@0
    61
  res@mpFillOn            = False            ; Turn off map fill
forrest@0
    62
  res@tiMainString        = "Class"
forrest@0
    63
forrest@0
    64
  res@gsnSpreadColors      = True            ; use full colormap
forrest@0
    65
  res@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
    66
  res@cnMinLevelValF       = 0.              ; Min level
forrest@0
    67
  res@cnMaxLevelValF       = 16.             ; Max level
forrest@0
    68
  res@cnLevelSpacingF      = 1.              ; interval
forrest@0
    69
forrest@0
    70
  plot = gsn_csm_contour_map_ce(wks,x,res)   
forrest@0
    71
forrest@0
    72
end