npp/53.zonavg_3line.ncl
author Forrest Hoffman <forrest@climatemodeling.org>
Mon, 26 Jan 2009 22:08:20 -0500
changeset 0 0c6405ab2ff4
permissions -rw-r--r--
Initial commit of C-LAMP Diagnostics from Jeff Lee
forrest@0
     1
; ***********************************************
forrest@0
     2
; zonal average plot
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 observed data
forrest@0
    12
;************************************************
forrest@0
    13
 
forrest@0
    14
 a     = addfile ("Npp_T42_mean.nc","r")
forrest@0
    15
 b     = addfile ("i01.03cn_1545-1569_ANN_climo.nc","r")
forrest@0
    16
 c     = addfile ("i01.04casa_1605-1629_ANN_climo.nc","r")
forrest@0
    17
forrest@0
    18
 ta    = a->NPP
forrest@0
    19
 tb    = b->NPP
forrest@0
    20
 tc    = c->NPP
forrest@0
    21
   
forrest@0
    22
 lon   = a->lon 
forrest@0
    23
 lat   = a->lat
forrest@0
    24
 nlon  = dimsizes(lon)
forrest@0
    25
 nlat  = dimsizes(lat)
forrest@0
    26
forrest@0
    27
 s  = new ((/3,nlat/), float)
forrest@0
    28
forrest@0
    29
;************************************************
forrest@0
    30
; set value to 0. at missing point of observed
forrest@0
    31
;************************************************
forrest@0
    32
 delta = 0.00000000001
forrest@0
    33
 x0    = tb(0,:,:)
forrest@0
    34
 ta = where(ismissing(ta).and.(ismissing(x0).or.(x0.lt.delta)),0.,ta)
forrest@0
    35
forrest@0
    36
 s(0,:) = zonalAve(ta(:,:))
forrest@0
    37
 delete (ta)
forrest@0
    38
forrest@0
    39
;************************************************
forrest@0
    40
; for model data
forrest@0
    41
;************************************************
forrest@0
    42
 scale_factor = 86400.*365.
forrest@0
    43
forrest@0
    44
 s(1,:) = zonalAve(tb(0,:,:)) * scale_factor
forrest@0
    45
 delete (tb)     
forrest@0
    46
forrest@0
    47
 s(2,:) = zonalAve(tc(0,:,:)) * scale_factor     
forrest@0
    48
 delete (tc)     
forrest@0
    49
forrest@0
    50
 s@long_name = "NPP (gC/m2/year)"
forrest@0
    51
 
forrest@0
    52
;***************************************************** 
forrest@0
    53
; create plot
forrest@0
    54
;***************************************************** 
forrest@0
    55
  wks = gsn_open_wks("png","xy")              ; create plot
forrest@0
    56
  i   = NhlNewColor(wks,1.0,0.71,0.76)       ; add color to colormap
forrest@0
    57
  j   = NhlNewColor(wks,0.64,0.71,0.8)       ; ditto
forrest@0
    58
  
forrest@0
    59
  res                    = True              ; plot mods desired
forrest@0
    60
  res@gsnDraw            = False             ; don't draw yet
forrest@0
    61
  res@gsnFrame           = False             ; don't advance frame yet
forrest@0
    62
forrest@0
    63
; res@vpHeightF 	 = 0.4               ; change aspect ratio of plot
forrest@0
    64
; res@vpWidthF 	         = 0.7
forrest@0
    65
forrest@0
    66
; res@trXMinF	         = 1890              ; set x-axis minimum
forrest@0
    67
forrest@0
    68
  res@xyMonoLineColor    = "False"           ; want colored lines
forrest@0
    69
  res@xyLineColors       = (/"Red","Blue","Black"/) ; colors chosen
forrest@0
    70
; res@xyLineThicknesses	 = (/3.,3.,4./)      ; line thicknesses
forrest@0
    71
  res@xyLineThicknesses	 = (/2.,2.,2./)      ; line thicknesses
forrest@0
    72
  res@xyDashPatterns	 = (/0.,0.,0./)      ; make all lines solid
forrest@0
    73
forrest@0
    74
  res@tiMainString        = "Zoanl Average"
forrest@0
    75
  res@tiYAxisString	 = "NPP (gC/m2/year)"      ; add a axis title    
forrest@0
    76
  res@txFontHeightF	 = 0.0195            ; change title font heights
forrest@0
    77
  
forrest@0
    78
  plot  = gsn_csm_xy (wks,lat,s,res)       ; create plot
forrest@0
    79
forrest@0
    80
; plot  = fill_xy2(wks,plot(0),time,mnmx(2,:),mnmx(3,:),(/0.64,0.71,0.8/),\
forrest@0
    81
; (/0.64,0.71,0.8/))
forrest@0
    82
; plot  = fill_xy2(wks,plot(0),time,mnmx(0,:),mnmx(1,:),(/1.0,0.71,0.76/),\
forrest@0
    83
; (/1.0,0.71,0.76/))
forrest@0
    84
;*****************************************************   
forrest@0
    85
; Manually create legend
forrest@0
    86
;***************************************************** 
forrest@0
    87
  res_text                    = True                  ; text mods desired
forrest@0
    88
  res_text@txFontHeightF      = 0.015                 ; change text size
forrest@0
    89
  res_text@txJust             = "CenterLeft"          ; text justification
forrest@0
    90
forrest@0
    91
  res_lines                   = True                  ; polyline mods desired
forrest@0
    92
  res_lines@gsLineDashPattern = 0.                    ; solid line
forrest@0
    93
  res_lines@gsLineThicknessF  = 5.                    ; line thicker
forrest@0
    94
  res_lines@gsLineColor       = "red"                 ; line color
forrest@0
    95
  xx = (/-85.,-75./)
forrest@0
    96
  yy = (/1400.,1400./)
forrest@0
    97
  gsn_polyline(wks,plot,xx,yy,res_lines)              ; add polyline
forrest@0
    98
  gsn_text(wks,plot,"Observed",-70.,1400.,res_text); add text
forrest@0
    99
  
forrest@0
   100
  yy = (/1500.,1500./)
forrest@0
   101
  res_lines@gsLineColor       = "blue"                ; change to blue
forrest@0
   102
  gsn_polyline(wks,plot,xx,yy,res_lines)              ; add polyline
forrest@0
   103
  gsn_text(wks,plot,"Model i01.03cn",-70.,1500.,res_text)     ; add text
forrest@0
   104
  
forrest@0
   105
  yy = (/1600.,1600./)
forrest@0
   106
  res_lines@gsLineColor       = "black"               ; change to black
forrest@0
   107
  gsn_polyline(wks,plot,xx,yy,res_lines)              ; add poly line
forrest@0
   108
  gsn_text(wks,plot,"Model i01.04casa",-70.,1600.,res_text) ; add text
forrest@0
   109
;*****************************************************   
forrest@0
   110
; Manually create titles
forrest@0
   111
;*****************************************************   
forrest@0
   112
; res_text@txJust        = "CenterCenter"             ; change justification
forrest@0
   113
; res_text@txFontHeightF = 0.03                       ; change font size
forrest@0
   114
; gsn_text_ndc(wks,"Parallel Climate Model Ensembles",0.55,0.90,res_text)
forrest@0
   115
forrest@0
   116
; res_text@txFontHeightF = 0.02                       ; change font size
forrest@0
   117
; gsn_text_ndc(wks,"Global Temperature Anomalies",0.55,0.86,res_text)
forrest@0
   118
forrest@0
   119
; res_text@txFontHeightF = 0.015                      ; change font size
forrest@0
   120
; gsn_text_ndc(wks,"from 1890-1919 average",0.55,0.83,res_text)
forrest@0
   121
  
forrest@0
   122
  draw(plot)
forrest@0
   123
  frame(wks)                                            ; advance frame
forrest@0
   124
  
forrest@0
   125
end