You are here: Home / Services / Data Analysis and Visualization / Visualization / Software / NCL / examples / source_code / DKRZ PyNGL example Hovmueller plot

DKRZ PyNGL example Hovmueller plot

This example demonstrates how to create a default black and white Hovmueller plot.

Example:

from __future__ import print_function
import numpy as np
import os, sys
import Ngl,Nio

#-- data path and file name
ncarg_root = os.environ.get('NCARG_ROOT')
diri  = ncarg_root + '/lib/ncarg/data/cdf/'
fname = 'chi200_ud_smooth.nc'

#-- open file and read variables
f     =  Nio.open_file(diri + fname,"r")    #-- open data file
chi   =  f.variables['CHI'][:,:]            #-- read variable CHI[time,lon]
lon   =  f.variables['lon'][:]
time  =  f.variables['time'][:]

scale =  1.0e6
chi   =  chi/scale

#-- create the plot
wks =  Ngl.open_wks('png','plot_hovmueller')
                                            #-- open workstation
#-- set resources
res                       =  Ngl.Resources
res.nglFrame              =  False
res.nglMaximize           =  True           #-- maximize plot output

res.tiMainString          = 'Default Hovmu~H-13V2F35~H~FV-2H3~ller' #-- title

res.sfXArray              =  lon            #-- scalar field x
res.sfYArray              =  time           #-- scalar field y
 
res.tiYAxisString         = 'elapsed time'
res.tmYLLabelFontHeightF  =  0.015

res.nglPointTickmarksOutward = True         #-- point tickmarks out

plot = Ngl.contour(wks,chi,res)             #-- draw contours

#-- advance the frame
Ngl.frame(wks)

#-- end
Ngl.end()

Result:

DKRZ NCL example Hovmueller plot w400

 

Document Actions