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

DKRZ NCL Workshop: map resolutions, projections and shapefiles

All map resolution, projection and shapefile exercises from the DKRZ NCL Workshop. Requirement: NCL version 6.2.0 and higher

 

1. Change map resolution:

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

;-- define the workstation (plot type and name)
  wks = gsn_open_wks("png","part_VI_map_resolution")
  
;-- set resources
  res                       =  True
  res@gsnMaximize           =  True            ;-- maximize plot output

  res@cnFillOn              =  True            ;-- turn on contour fill
  res@cnFillMode            = "RasterFill"     ;-- contour cell fill modes
  res@cnRasterSmoothingOn   =  True            ;-- contour smoothing on
  res@cnFillPalette         = "ncl_default"    ;-- choose a colormap
  res@cnLinesOn             =  False           ;-- turn off contour lines
  res@cnLineLabelsOn        =  False           ;-- turn off line labels
  res@cnLevelSelectionMode  = "ManualLevels"   ;-- set contour levels manually
  res@cnMinLevelValF        =  265.            ;-- minimum contour level
  res@cnMaxLevelValF        =  285.            ;-- maximum contour level
  res@cnLevelSpacingF       =  0.5             ;-- contour level spacing

  res@mpMinLonF             =   3.             ;-- min lon
  res@mpMaxLonF             =  20.             ;-- max lon
  res@mpMinLatF             =  53.             ;-- min lat
  res@mpMaxLatF             =  70.             ;-- max lat

  res@mpDataBaseVersion     = "MediumRes"      ;-- choose map data base version

  res@tiMainString          = "DKRZ NCL workshop: MediumRes resolution"   ;-- title string
  res@tiMainFontHeightF     =  0.02

  plot = gsn_csm_contour_map(wks, var, res)

end 

 

2. Change map projection:

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

;-- define the workstation (plot type and name)
  wks = gsn_open_wks("png","part_VI_map_projection")
  
;-- set resources
  res                       =  True
  res@gsnMaximize           =  True            ;-- maximize plot output

  res@mpProjection          = "Orthographic"   ;-- choose map projection
  res@mpCenterLonF          =  15              ;-- center plot on lon value
  res@mpCenterLatF          =  40              ;-- center plot on lat value
  res@mpGridAndLimbOn       =  True            ;-- draw grid and limb lines

  res@tiMainString          = "DKRZ NCL workshop: Orthographic projection"   ;-- title string
  res@tiMainFontHeightF     =  0.02

  plot = gsn_csm_contour_map(wks, var, res)

end 

 

3. Outline counties of Germany using a shapefile:

begin
;-- read data to display
   f    = addfile("$NCL_TUT/data/ECHAM5_OM_A1B_2001_0101-1001_2D.nc","r")
   var  = f->tsurf(0,:,:)

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

;-- set resources for the map
   res                     =  True
   res@gsnDraw             =  False           ;-- don't draw the plot
   res@gsnFrame            =  False           ;-- don't advance frame yet
   res@gsnMaximize         =  True            ;-- maximize plot in frame

   res@cnFillOn            =  True            ;-- turn on countour fill
   res@cnFillMode          = "RasterFill"     ;-- contour cell fill mode
   res@cnRasterSmoothingOn =  True            ;-- contour smoothing on
;   res@cnFillPalette       = "ncl_default"    ;-- choose a colormap
   res@cnLinesOn           =  False           ;-- don't draw contour lines
   res@cnLevelSelectionMode = "ManualLevels"  ;-- set manual contour levels
   res@cnMinLevelValF      =  270.0           ;-- minimum contour value
   res@cnMaxLevelValF      =  285.0           ;-- maximum contour value
   res@cnLevelSpacingF     =    0.5           ;-- contour value increment

;-- select coordinates for Germany
   res@mpFillOn            =  False           ;-- turn off map fill
   res@mpLimitMode         = "LatLon"         ;-- must be set to LatLon for Mercator sub-region selection
   res@mpMinLatF           =  45.             ;-- min lat
   res@mpMaxLatF           =  60.             ;-- max lat
   res@mpMinLonF           =  3.              ;-- min lon
   res@mpMaxLonF           =  20.             ;-- max lon

   res@mpOutlineOn         =  True            ;-- draw map outlines
   res@mpDataBaseVersion   = "MediumRes"      ;-- choose map resolution
   res@mpProjection        = "Mercator"       ;-- set map projection
   res@pmTickMarkDisplayMode = "Always"       ;-- draw tickmarks

   res@tiMainString        = "DKRZ NCL workshop: Shapefile"  ;-- draw title
   res@tiMainFontHeightF   =  0.015

;-- generate map, but don't draw it
   plot = gsn_csm_contour_map(wks,var,res)

;-- add polylines from the shapefile to the plot
   shp_filename = ("$NCL_TUT/data/Shapefiles/DEU_adm/DEU_adm1.shp")
   poly = gsn_add_shapefile_polylines(wks,plot,shp_filename,False)

;-- draw the plot and the attached shapefile outlines and advance the frame
   draw(plot)
   frame(wks)

end 

 

Artikelaktionen