You are here: Home / News & Events / Workshops and Trainings / NCL Workshops / Beispiele und Aufgaben Teil II - Landkarten und Kontur Plots
Info
Our docs have moved to https://docs.dkrz.de This portal will be shutdown as soon the last content is migrated.

Beispiele und Aufgaben Teil II - Landkarten und Kontur Plots

NCL Skripte zur Erzeugung von Landkarten und Kontur Plots.

 

Landkarten

Einfache Landkarte:

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

  ;-- set resources
   res               =  True                ;-- create plot resource object
   res@tiMainString  = "Default Cylindrical-Equidistant projection"    ;-- draw a title on top of the plot

  ;-- create the plot
   plot = gsn_csm_map(wks, res)

end

 

Änderung der Kartenprojektion:

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

  ;-- set resources
   res                        =  True               ;-- create plot resource object

   res@mpProjection           = "Mollweide"         ;-- set projection
   res@mpGridAndLimbOn        =  True               ;-- turn on grid lines

   res@tiMainString           = "Mollweide Projection"  ;-- draw a title on top of the plot

  ;-- create the plot
   plot = gsn_csm_map(wks, res)

end

 

Kartenausschnitt:

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

  ;-- set resources
   res               =  True               ;-- create plot resource object

   res@tiMainString  = "Europe"            ;-- draw a title on top of the plot

   res@mpMinLonF     = -11
   res@mpMaxLonF     =  45
   res@mpMinLatF     =  34
   res@mpMaxLatF     =  72

  ;-- create the plot
   plot = gsn_csm_map(wks, res)

end

 

Kartenauflösung:

begin

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

;-- set resources
   res                        =  True                             ;-- create plot resource object   
   res@tiMainString           = "Ju~H-15V6F35~H~FV-6H3~tland"     ;-- draw a title on top of the plot

   res@mpMinLonF              =   8                               ;-- min longitude
   res@mpMaxLonF              =  13                               ;-- max longitude
   res@mpMinLatF              =  53                               ;-- min latitude
   res@mpMaxLatF              =  58                               ;-- max latitude

   res@mpDataBaseVersion      = "MediumRes"                       ;-- set map resolution
   res@mpGridAndLimbOn        =  True                             ;-- draw grid lines
   res@mpGridLineColor        = "blue"                            ;-- grid line color
   res@mpOutlineOn            =  True                             ;-- draw coastlines
   res@mpGridSpacingF         =  1                                ;-- grid line spacing
   res@mpGridLineThicknessF   =  1                                ;-- grid line thickness
   res@mpGridLineDashPattern  =  1                                ;-- grid line dash pattern

;-- create 1. plot
   plot = gsn_csm_map(wks, res)
   
;-- create 2. plot
   res@mpGridAndLimbDrawOrder = "PreDraw"                         ;-- draw first the grid then the map
   plot = gsn_csm_map(wks, res)
  
end

 

Kartenauflösung (Gitterlinien hinter der Karte):

begin

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

;-- set resources
   res                        =  True                             ;-- create plot resource object   
   res@tiMainString           = "Ju~H-15V6F35~H~FV-6H3~tland"     ;-- draw a title on top of the plot

   res@mpMinLonF              =   8                               ;-- min longitude
   res@mpMaxLonF              =  13                               ;-- max longitude
   res@mpMinLatF              =  53                               ;-- min latitude
   res@mpMaxLatF              =  58                               ;-- max latitude

   res@mpDataBaseVersion      = "MediumRes"                       ;-- set map resolution
   res@mpGridAndLimbOn        =  True                             ;-- draw grid lines
   res@mpGridLineColor        = "blue"                            ;-- grid line color
   res@mpOutlineOn            =  True                             ;-- draw coastlines
   res@mpGridSpacingF         =  1                                ;-- grid line spacing
   res@mpGridLineThicknessF   =  1                                ;-- grid line thickness
   res@mpGridLineDashPattern  =  1                                ;-- grid line dash pattern
   res@mpGridAndLimbDrawOrder  =  "PreDraw"                       ;-- draw grid lines first

;-- create 1. plot
   plot = gsn_csm_map(wks, res)
   
;-- create 2. plot
   res@mpGridAndLimbDrawOrder = "PreDraw"                         ;-- draw first the grid then the map
   plot = gsn_csm_map(wks, res)
  
end

 

Konturen

Kartenvoreinstellungen:

begin

  f = addfile("../../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")

  ;-- 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(wks, t, res)

end

 

Mit korrektem Seitenverhältnis:

begin

  f = addfile("../../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

 

Farbige Konturlinien:

begin

  f = addfile("../../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_line_col_map_2")

  ;-- 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

 

Farbige Konturflächen:

begin

  f = addfile("../../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_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

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

end

 

Kontureigenschaften festlegen:

begin

  f = addfile("../../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

 

Kontur Plot mit Gitterlinien:

begin
;-- read the data and define
   file1 = addfile("../../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")

;-- 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       = "grey30"         ;-- grid line color

   cmap = read_colormap_file("rainbow")         ;-- 188 colors
   res@cnFillPalette         =  cmap(2:181,:)   

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

   res@mpGridMaskMode        = "MaskLand"       ;-- mask grid over land

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

end

 

Für die Aufgabe:

part_II_Contour_fill_map.ncl

begin

  f = addfile("../../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_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

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

end

 

 

 

 

 

 

Document Actions