Sie sind hier: Startseite / Services / Data Analysis and Visualization / Visualization / Software / NCL / source codes / PyNGL example map settings
Info
Alle Inhalte des Nutzerportal sind nur auf Englisch verfügbar.

PyNGL example map settings

The python script demonstrates how to create a simple map from the USA using PyNGL.

Software requirements:

  • Python 2.7.x
  • Numpy 1.9.2
  • PyNGL/PyNIO 1.5.0

 

Run the map example script:

python PyNGL_map_settings.py

 

Script PyNGL_map_settings.py:

'''
 DKRZ PyNGL Script: PyNGL_map_settings.py

 Description:	 plot a simple USA map
 
                 - show the use of map resources

 11.05.2015  meier-fleischer(at)dkrz.de
'''
import numpy
import sys,os
import Ngl, Nio

#-- open a workstation
wkres             =  Ngl.Resources()            #-- generate an resources object for workstation
wkres.wkWidth     =  1024                       #-- width of workstation
wkres.wkHeight    =  1024                       #-- height of workstation
wks_type          = "png"                       #-- output type of workstation
wks = Ngl.open_wks(wks_type,"Py_map_settings")  #-- open workstation

#-- set map resources
res                         =  Ngl.Resources()  #-- generate an res object for plot
res.nglMaximize             =  True             #-- maximize plot in frame
res.tiMainString            = "USA"             #-- title string

#-- map resources
res.mpDataSetName           = "Earth..4"        #-- set map data base version
res.mpDataBaseVersion       = "MediumRes"       #-- MediumRes = Ncarg4_1
res.mpGeophysicalLineThicknessF =  2.           #-- line thickness of coastal borders
res.mpFillOn                =  True             #-- turn on fill for map areas.
res.mpLandFillColor         = "LightGray"       #-- fill color land
res.mpOceanFillColor        = "lightblue"       #-- fill color ocean
res.mpInlandWaterFillColor  = "lightblue"       #-- fill color inland water
res.mpOutlineOn             =  True             #-- turn on map outlines
res.mpOutlineBoundarySets   = "national"        #-- "national"
res.mpOutlineSpecifiers     = "conterminous us : states" #-- plot state boundaries
res.mpGridLatSpacingF       =  5.               #-- grid spacing for latitude
res.mpGridLonSpacingF       =  5.               #-- grid spacing for longitude
res.mpGridLineDashPattern   =  7                #-- dash pattern for grid lines
res.mpLimitMode             = "LatLon"          #-- limit map via lat/lon
res.mpMinLatF               =   20.             #-- minimum latitude
res.mpMaxLatF               =   50.             #-- maximum latitude
res.mpMinLonF               = -130.             #-- minimum longitude
res.mpMaxLonF               =  -65.             #-- maximum longitude
   
res.pmTickMarkDisplayMode   = "Always"          #-- turn on map tickmarks

#-- draw the map
map = Ngl.map(wks,res)

#-- done
Ngl.end()

Plot result:

PyNGL map settings w400

 

 

 

Artikelaktionen