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

DKRZ NCL Workshop: contours

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

 

1. Simple contour plot:

begin

  f = addfile("$NCL_TUT/data/EH_OM_A1B_3Dvectors_t1-24.nc","r")
  t = f->t(0,0,:,:)

;-- open a workstation
   wks = gsn_open_wks("png", "part_II_contour_def_map")

;-- set resources
   res               =  True                ;-- create plot resource object
   res@tiMainString  = "Temperature t=1"    ;-- draw a title on top of the plot

;-- create the plot
   plot = gsn_csm_contour_map(wks, t, res)

end

 

2. Colored contour lines:

begin

  f = addfile("../../EH_OM_A1B_3Dvectors_t1-24.nc","r")
  t = f->t(0,0,:,:)

;-- open a workstation
   wks = gsn_open_wks("png", "part_II_contour_line_col_map")

;-- set resources
   res                     =  True                    ;-- create plot resource object
   res@tiMainString        = "Temperature t=1"        ;-- draw a title on top of the plot

  res@cnLineThicknessF     =  2                       ;-- make lines thicker
  res@cnMonoLineColor      =  False                   ;-- use multiple colors
  res@cnLineColors         =  toint(fspan(2,240,20))  ;-- define the colors
  res@cnLevelSpacingF      =  2                       ;-- contour level spacing
 
;-- create the plot
   plot = gsn_csm_contour_map(wks, t, res)

end 

 

3. Color fill contours:

begin

  f = addfile("$NCL_TUT/data/EH_OM_A1B_3Dvectors_t1-24.nc","r")
  t = f->t(0,0,:,:)

;-- open a workstation
   wks = gsn_open_wks("png", "part_II_contour_colormap_map")

;-- set resources
   res                       =  True                ;-- create plot resource object
   res@tiMainString          = "Temperature t=1"    ;-- draw a title on top of the plot
   res@cnFillOn              =  True                ;-- color fill between contour levels
   res@cnFillPalette         = "rainbow"            ;-- change the colormap

;-- create the plot
   plot = gsn_csm_contour_map(wks, t, res)

end

 

4. Contour line settings:

begin

  f = addfile("$NCL_TUT/data/EH_OM_A1B_3Dvectors_t1-24.nc","r")
  t = f->t(0,0,:,:)

;-- open a workstation
   wks = gsn_open_wks("png", "part_II_contour_fill_line_settings_map")

;-- set resources
   res                       =  True              ;-- create plot resource object
   res@tiMainString          = "Temperature t=1"  ;-- draw a title on top of the plot
   res@cnFillOn              =  True              ;-- color fill between contour levels
   res@cnLinesOn             =  False             ;-- don't draw contour lines
   res@cnLevelSelectionMode  = "ManualLevels"     ;-- set contour levels manually
   res@cnMinLevelValF        =  240.              ;-- minimum contour level
   res@cnMaxLevelValF        =  310.              ;-- maximum contour level
   res@cnLevelSpacingF       =  2                 ;-- contour level spacing

   res@lbLabelStride         =  5
   res@lbBoxMinorExtentF     =  0.15              ;-- decrease the height of the labelbar

;-- create the plot
   plot = gsn_csm_contour_map(wks, t, res)

end 

 

5. Contour plot with grid lines:

begin
;-- read the data and define
   file1 = addfile("$NCL_TUT/data/MITgcm_2007s-t1.nc","r")
   var   =  file1->SSS(0,0,:,:)

;-- define the workstation (plot type and name)
   wks = gsn_open_wks("png","part_II_contour_grid_lines_map")
   gsn_define_colormap(wks,"rainbow")          ;-- set colormap

;-- set resources
   res                       =  True
   res@tiMainString          = "Salinity at sea surface" ;-- draw a title on top of the plot
   res@cnFillOn              =  True            ;-- turn ofncontour fill
   res@cnLinesOn             =  False           ;-- turn off contour lines
   res@cnLineLabelsOn        =  False           ;-- turn off line labels
   res@cnLevelSelectionMode  = "ManualLevels"   ;-- set contour levels manually
   res@cnMinLevelValF        =   7.             ;-- minimum contour level
   res@cnMaxLevelValF        =  36.             ;-- maximum contour level
   res@cnLevelSpacingF       =   1              ;-- contour level spacing

   res@lbLabelStride         =  5               ;-- label every 5th values on labelbar
   res@lbBoxMinorExtentF     =  0.15            ;-- decrease the height of the labelbar

   res@mpMinLonF             =   3              ;-- min longitude
   res@mpMaxLonF             =  17              ;-- max longitude
   res@mpMinLatF             =  52              ;-- min latitude
   res@mpMaxLatF             =  65              ;-- max latitude
   res@mpGridAndLimbOn       =  True            ;-- plot grid lines

   res@mpGridSpacingF        =  1               ;-- grid line spacing 1 degree
   res@mpGridLineThicknessF  =  2.0             ;-- thicker grid lines
   res@mpGridLineColor       = "Gray30"         ;-- grid line color

   res@gsnSpreadColors       =  True            ;-- spread color map
   res@gsnSpreadColorStart   =  2               ;-- start color index 
   res@gsnSpreadColorEnd     = -6               ;-- end color index

;-- draw the contour map
   plot = gsn_csm_contour_map(wks, var, res)

   res@mpGridAndLimbOn       =  True            ;-- turn on lat/lon lines
   res@mpGridMaskMode        = "MaskLand"       ;-- mask grid over land

;-- draw a second contour map on seperate page
   plot = gsn_csm_contour_map(wks, var, res)

end 

 

Artikelaktionen