Plotting in VCS
Goal: Learn about plotting in VCS.
There are several different ways to display data on the VCS Canvas.
The most basic way is to use the plot() function. The simple plot()
function command: plot(array1,[array2], [template object], [graphics_method object]). The examples below are showing how to plot a simple array using default values for everything else.
Plotting a CDMS Persistent Array
import vcs # import the VCS module
import cdms # import CDMS for ingesting data
cdms.setAutoReshapeMode(`on') # needed by CDMS module if data is reshaped
f=cdms.openDataset(`example.nc') # open file via the cdms module
psl=f.variables[`clt'] # get the "psl" variable
data=psl[...] # get the "psl" variable data (Note, data is now a Numeric array)
v=vcs.init() # "v" is an instance of the VCS class object (constructor)
v.plot(data, variable=psl) # call "plot" function to display the CDMS
# Persistent Array on the VCS Canvas using default settings
Plotting a CU Slab Array
import vcs # import the VCS module
import cu # import CU for ingesting data
f=cu.open(`example.nc') # open file via the cu module
s=f.getslab(`clt') # get the "psl" variable slab
v=vcs.init() # "v" is an instance of the VCS class object (constructor)
v.plot(s) # call "plot" function to display the CU "slab"
# array on the VCS Canvas using default settings
Plotting a Numeric Array
import vcs # import the VCS module
import Numeric # import Numeric for generating data
a=Numeric.array([[1,2,3],[4,5,6],[7,8,9] ]) # create a simple multidimensional array
v=vcs.init() # "v" is an instance of the VCS class object (constructor)
v.plot(a) # call "plot" function to display the Numeric "array"
# data on the VCS Canvas using default settings