Sie sind hier: Startseite / Services / Data Analysis and Visualization / Visualization / Software / NCL / examples / source_code / DKRZ NCL Workshop: slices and overlays
Info
Alle Inhalte des Nutzerportal sind nur auf Englisch verfügbar.

DKRZ NCL Workshop: slices and overlays

All slices and overlay exercises from the DKRZ NCL Workshop. Requirement: NCL version 6.2.0 and higher

 

1. Simple slice plot:

begin
   f     = addfile("$NCL_TUT/data/ECHAM5_OM_A1B_2001_timestep1_3D.nc", "r")
   var   = f->t(0,:,{40},{0:60})     ;-- first time step, latitude=40N, longitude=0-60E.
   lon_t = f->lon({0:60})            ;-- longitude=0-60E
   lev_t = f->lev                    ;-- currently 17 levels

;-- define workstation
   wks = gsn_open_wks("png","part_IV_simple_slice")

;-- set resources
   res                          =  True
   res@tiMainString             = "Simple slice plot" ;-- draw title

   res@sfXArray                 =  lon_t              ;-- uses lon_t as plot x-axis
   res@sfYArray                 =  lev_t              ;-- uses lev_t in hPa as plot y-axis

;-- generate the plot
   plot = gsn_csm_contour(wks,var,res)

end 

 

2. Slice overlyed by countour lines:

begin
   f      = addfile("$NCL_TUT/data/ECHAM5_OM_A1B_2001_timestep1_3D.nc", "r")
   t      = f->t(0,:,{40},{0:60})          ;-- first time step, latitude=40N, longitude=0-60E.
   rhum   = f->rhumidity(0,:,{40},{0:60})  ;-- first time step, latitude=40N, longitude=0-60E.
   lon_t  = f->lon({0:60})                 ;-- longitude=0-60E
   lev_t  = f->lev/100                     ;-- currently 17 levels; convert to hPa units

   llabels = new(dimsizes(lev_t),string)
   llabels = lev_t

;-- define workstation
   wks = gsn_open_wks("png","part_IV_slice_rhumidity_overlay")
   gsn_define_colormap(wks,"WhiteBlue")               ;-- set the colormap to be used

;-- set resources
   res                          =  True
   res@gsnDraw                  =  False
   res@gsnFrame                 =  False
   res@gsnSpreadColors          =  True               ;-- use full colormap

   res@tiMainString = "Slice at latitude = 40~S~o~N~N~C~~Z70~contour lines: " + rhum@long_name

   res@cnFillOn                 =  True               ;-- turn on color fill
   res@cnLineLabelsOn           =  False              ;-- turns off contour line labels
   res@cnInfoLabelOn            =  False              ;-- turns off contour info label

   res@lbOrientation            = "vertical"          ;-- vertical label bar

   res@sfXArray                 =  lon_t              ;-- uses lon_t as plot x-axis
   res@sfYArray                 =  lev_t              ;-- uses lev_t in hPa as plot y-axis

;   res@gsnYAxisIrregular2Linear =  True               ;-- converts y-axis irregular to linear depth
   res@trYReverse               =  True               ;-- reverses y-axis
 
   res@tmXBTickSpacingF         =  10.                ;-- label x-axis every 10 degrees

   res@tmYLMode                 = "Explicit"          ;-- set y-axis labeling to explicit
   res@tmYLValues               =  lev_t              ;-- values for y-axis tickmarks
   res@tmYLLabels               =  llabels            ;-- set labels equal to values (type string)
;   res@tmYLLabelStride          =  5                  ;-- draw every 5th label

   res@tiXAxisString            =  f->lon@long_name   ;-- draw y-axis title
   res@tiYAxisString            =  f->lev@long_name + "  [hPa]"  ;-- draw y-axis title

;-------------------------------------------------------------------------------------
;-- generate plot1, but don't draw it yet
;-------------------------------------------------------------------------------------
   plot1 = gsn_csm_contour(wks,t,res)

;-- change resources for the overlayed plot
   res@cnFillOn                 =  False              ;-- turn off color fill
   res@cnLineLabelsOn           =  True               ;-- turns on contour line labels
   res@gsnLeftString            = ""                  ;-- don't draw left string

;-------------------------------------------------------------------------------------
;-- generate plot2, but don't draw it yet
;-------------------------------------------------------------------------------------
   plot2 = gsn_csm_contour(wks,rhum,res)

;-- overlay plot2 on plot1
   overlay(plot1, plot2)

;-- draw the plot and advance the frame
   draw(plot1)
   frame(wks)

end 

 

 

 

 

Artikelaktionen