lai/33.contour_diff_grow.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
; 3 plots, model - ob
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
  day_of_data = (/31,28,31,30,31,30,31,31,30,31,30,31/)
forrest@0
    11
forrest@0
    12
;************************************************
forrest@0
    13
; read in observed data
forrest@0
    14
;************************************************
forrest@0
    15
  diri1  = "/fis/cgd/cseg/people/jeff/clamp_data/lai/"
forrest@0
    16
  fili1  = "LAI_2000-2005_ensemble_T42.nc"
forrest@0
    17
  f     = addfile(diri1+fili1,"r")
forrest@0
    18
forrest@0
    19
  z     = f->LAI
forrest@0
    20
  y     = z(0,:,:)
forrest@0
    21
  y@long_name = "Days of Growing Season"
forrest@0
    22
 
forrest@0
    23
  dsizes_z = dimsizes(z)
forrest@0
    24
  ntime    = dsizes_z(0)
forrest@0
    25
  nlat     = dsizes_z(1)
forrest@0
    26
  nlon     = dsizes_z(2)
forrest@0
    27
  
forrest@0
    28
  do j = 0,nlat-1
forrest@0
    29
  do i = 0,nlon-1
forrest@0
    30
     nday = 0.
forrest@0
    31
     do k = 0,ntime-1
forrest@0
    32
        if (.not. ismissing(z(k,j,i)) .and. z(k,j,i) .gt. 1.0) then
forrest@0
    33
           nday = nday + day_of_data(k)
forrest@0
    34
        end if
forrest@0
    35
     end do
forrest@0
    36
     if (nday .ne. 0.) then
forrest@0
    37
        y(j,i) = nday
forrest@0
    38
     end if
forrest@0
    39
  end do
forrest@0
    40
  end do
forrest@0
    41
forrest@0
    42
; printVarSummary(y)
forrest@0
    43
  print (min(y)+"/"+max(y))
forrest@0
    44
forrest@0
    45
  delete (z)
forrest@0
    46
;************************************************
forrest@0
    47
; read in data: model       
forrest@0
    48
;************************************************
forrest@0
    49
 diri2  = "/fis/cgd/cseg/people/jeff/clamp_data/model/"
forrest@0
    50
;fili3  = "i01.03cn_1545-1569_MONS_climo.nc"
forrest@0
    51
 fili3  = "i01.04casa_1605-1629_MONS_climo.nc"
forrest@0
    52
 data_file_model = addfile(diri2+fili3,"r")
forrest@0
    53
forrest@0
    54
  z     = data_file_model->TLAI
forrest@0
    55
  x     = z(0,:,:)
forrest@0
    56
  x@long_name = "Days of Growing Season"  
forrest@0
    57
 
forrest@0
    58
  dsizes_z = dimsizes(z)
forrest@0
    59
  ntime    = dsizes_z(0)
forrest@0
    60
  nlat     = dsizes_z(1)
forrest@0
    61
  nlon     = dsizes_z(2)
forrest@0
    62
  
forrest@0
    63
  do j = 0,nlat-1
forrest@0
    64
  do i = 0,nlon-1
forrest@0
    65
     nday = 0.
forrest@0
    66
     do k = 0,ntime-1
forrest@0
    67
        if (.not. ismissing(z(k,j,i)) .and. z(k,j,i) .gt. 1.0) then
forrest@0
    68
           nday = nday + day_of_data(k)
forrest@0
    69
        end if
forrest@0
    70
     end do
forrest@0
    71
    if (nday .ne. 0.) then
forrest@0
    72
       x(j,i) = nday
forrest@0
    73
    end if
forrest@0
    74
  end do
forrest@0
    75
  end do
forrest@0
    76
forrest@0
    77
  print (min(x)+"/"+max(x))
forrest@0
    78
forrest@0
    79
  d = x              
forrest@0
    80
  d = x - y
forrest@0
    81
  print (min(d)+"/"+max(d))
forrest@0
    82
forrest@0
    83
  delete (z)
forrest@0
    84
forrest@0
    85
  delta = 0.000001
forrest@0
    86
  y = where(ismissing(y).and.(ismissing(x).or.(x.lt.delta)),0.,y)
forrest@0
    87
;************************************************
forrest@0
    88
; create default plot
forrest@0
    89
;************************************************
forrest@0
    90
  wks = gsn_open_wks("ps","xy")              ; open a ps file
forrest@0
    91
  gsn_define_colormap(wks,"gui_default")     ; choose colormap
forrest@0
    92
forrest@0
    93
  res                     = True             ; Use plot options
forrest@0
    94
  res@cnFillOn            = True             ; Turn on color fill
forrest@0
    95
  res@gsnSpreadColors     = True             ; use full colormap
forrest@0
    96
; res@cnFillMode          = "RasterFill"     ; Turn on raster color
forrest@0
    97
; res@lbLabelAutoStride   = True
forrest@0
    98
  res@cnLinesOn           = False            ; Turn off contourn lines
forrest@0
    99
  res@mpFillOn            = False            ; Turn off map fill
forrest@0
   100
forrest@0
   101
  res@gsnSpreadColors      = True            ; use full colormap
forrest@0
   102
  res@cnLevelSelectionMode = "ManualLevels"  ; Manual contour invtervals
forrest@0
   103
  res@cnMinLevelValF       = 0.              ; Min level
forrest@0
   104
  res@cnMaxLevelValF       = 365.             ; Max level
forrest@0
   105
  res@cnLevelSpacingF      = 30.              ; interval
forrest@0
   106
forrest@0
   107
  pres                     = True            ; panel plot mods desired
forrest@0
   108
  pres@gsnMaximize         = True            ; fill the page
forrest@0
   109
forrest@0
   110
  plot=new(3,graphic)                        ; create graphic array
forrest@0
   111
forrest@0
   112
  res@tiMainString        = "MODIS MOD 15A2 2000-2005"
forrest@0
   113
  plot(0) = gsn_csm_contour_map_ce(wks,y,res)   
forrest@0
   114
forrest@0
   115
; res@tiMainString        = "Model i01.03cn"
forrest@0
   116
  res@tiMainString        = "Model i01.04casa"
forrest@0
   117
  plot(1) = gsn_csm_contour_map_ce(wks,x,res)   
forrest@0
   118
 
forrest@0
   119
; res@tiMainString        = "(Model i01.03cn) - (Observed)"
forrest@0
   120
  res@tiMainString        = "(Model i01.04casa) - (Observed)"    
forrest@0
   121
  res@cnMinLevelValF       = -120.              ; Min level
forrest@0
   122
  res@cnMaxLevelValF       =  120.             ; Max level
forrest@0
   123
  res@cnLevelSpacingF      =  20.              ; interval
forrest@0
   124
  plot(2) = gsn_csm_contour_map_ce(wks,d,res)   ; for observed
forrest@0
   125
forrest@0
   126
  gsn_panel(wks,plot,(/3,1/),pres)           ; create panel plot
forrest@0
   127
  system("convert xy.ps xy.png")
forrest@0
   128
end