The VCS model is defined by a trio of named attribute sets, designated the "Primary Objects" (also known as "Primary Elements"). These include: the data, which specifies what is to be displayed and are obtained from the "cdms", "cu", or Numeric modules; the graphics method, which specifies the display technique; and the picture template, which determines the appearance of each segment of the display.
A description of each primary object is warranted before showing their use and usefulness in VCS. See descriptions below.
A graphics method simply defines how data is to be displayed on the screen. Currently, there are eleven different graphics methods with more on the way. Each graphics method has its own unique set of attributes (or members) and functions. They also have a set of core attributes that are common in all graphics methods. The descriptions of the current set of graphics methods are as follows:
A picture template determines the location of each picture segment, the space to be allocated to it, and related properties relevant to its display. The description of the picture template is as follows:
A description of each secondary object is warranted before showing their use and usefulness in VCS. It is these secondary objects that defines the detailed specification of the primary objects' attributes. Currently, there are five secondary objects with more to follow.
The colormap object is used to specify, create, and modify colormaps. There are 256 colors and color indices, but only the first 240 color indices can be modified (indices 240 through 255 are reserved for VCS internal use). The description of the colormap object is as follows:
Note: VCS colormaps are objects, but they are not referenced like other secondary objects.
The fillarea objects allows the user to edit fillarea attributes, including fillarea interior style, style index, and color index. The description of the fillarea object is as follows:
The line object allows the editing of line type, width, and color index. The description of the line object is as follows:
The marker object allows the editing of the marker type, width, and color index. The description of the marker object is as follows:
Graphical displays often contain textual inscriptions, which provide further information. The text-table object attributes allow the generation of character strings on the VCS Canvas by defining the character font, precision, expansion, spacing, and color. The text-orientation object attributes allow the appearance of text character strings to be changed by defining the character height, up-angle, path, and horizontal and vertical alignment. The text-combined object is a combination of both text-table and text-orientation objects. The description of the text objects are as follows:
In Python, before one can start using a module they must first load it. To load the VCS module, like all other Python modules, either type:
If you use "import vcs", then you must prepend "vcs" to certain calls (e.g., "vcs.help()"). If you use "from vcs import *", then you must be aware of possible name clashes. That is, if two packages are imported using the form "from name import *" and both have a "help" function, then Python doesn't know which "help" function to call. For such cases, and indeed as an unspoken rule, it is best to use "import name" to avoid name clashing between packages.
To construct a VCS Canvas object type the following:
There can only be at most 8 VCS Canvas objects initialized at any given time. When a VCS Canvas object is initialized, the current template and graphics method will be displayed. For example:
"`Template' is currently set to P_default.
Graphics method 'Boxfill' is currently set to Gfb_default.'"
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.
import vcs # import the VCS module
import cdms # import CDMS for ingesting data
cdms.setAutoReshapeMode(`on') # needed by CDMS module if
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
v=vcs.init() # "v" is an instance of the VCS class
v.plot(data, variable=psl) # call "plot" function to display the CDMS
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
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
v=vcs.init() # "v" is an instance of the VCS
v.plot(a) # call "plot" function to display the Numeric
The plot function has many overriding keyword arguments that control textural and graphical output of the display. As shown above, the arguments necessary to plot data can be very simple. Below is a more complex plot() function showing the uses of array objects, template object, graphics method object, and key word arguments. Objects placed in brackets "[ ]" indicate optional entries into the plot function:
plot(array1, [array2 [, template [, graphics method [,key=value [, key=value [, ...]]]]]]),
where array1 and array2 are Numeric arrays or CU slabs; template represents a template object; graphics method represents a graphics method object (such as, boxfill or isofill); and key=value represents one variable attributes used to display textual information or to modify the plot's output. If no template is specified, then the default template will be used. If no graphics method is specified, then the default boxfill graphics method is used.
comment1 = string # Comment plotted above file_comment
comment2 = string # Comment plotted above comment1
comment3 = string # Comment plotted above comment2
comment4 = string # Comment plotted above comment3
file_comment = string # Comment (defaults to file.comment)
hms = string (hh:mm:ss) # Hour, minute, second
long_name = string # Descriptive variable name
missing_value= (same type as array) # Missing data value
#(defaults to var.getMissing())
name = string # Variable name (defaults to var.id)
time = cdtime # instance (relative or absolute),
# cdtime, reltime or abstime value
units = string # Variable units
ymd = string (yy/mm/dd) # Year, month, day
Dimension attribute keys (dimension length=n) are:
[x|y|z|t|w]array1 = NumPy array of length n # x or y Dimension values
[x|y|z|t|w]array2 = NumPy array of length n # x or y Dimension
[x|y]bounds = NumPy array of shape (n,2) # x or y Dimension
[x|y|z|t|w]name = string # x or y Dimension name
[x|y|z|t|w]units = string # x or y Dimension units
[x|y]weights = NumPy array of length n # x or y Dimension
[x|y|z|t|w]axis = CDMS axis object # x or y Axis
grid = CDMS grid object # Grid object (e.g.
variable = CDMS variable object # Variable object
[x|y]rev = 0|1 # if ==1, reverse the direction of
continents = 0,1,2,3,4,5,6,7,8,9,10,11 # if >=1, plot continental
# outlines (default: plot if x-axis is
# longitude, y-axis is latitude -or-
# xname is 'longitude' and yname is
# The continents-type values are integers
# ranging from 0 to 11, where:
# 1 signifies "Fine Continents"
# 2 signifies "Coarse Continents"
# 4 signifies "Political Borders"
# Values 6 through 11 signify the line
# through data_continent_other12.
Graphics Output in Background Mode:
bg = 0|1 # if==1, create images in the
# background (Don't display the
Note: More specific attributes take precedence over general attributes. In particular, specific attributes override variable object attributes; dimension attributes and arrays override axis objects, which override grid objects, which override variable objects.
For example, if both 'file_comment' and 'variable' keywords are specified, the value of 'file_comment' is used instead of the file comment in the parent of variable. Similarly, if both 'xaxis' and 'grid' keywords are specified, the value of 'xaxis' takes precedence over the x-axis of grid.
When using the plot() function, keep in mind that all keyword arguments must be last. Note that the order of the objects is not restrictive, just as long as they are before any keyword argument. See the two plot() function examples below.
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(`psl') # get the "psl" variable slab
v=vcs.init() # "v" is an instance of the VCS
t=x.createtemplate('new') # create a new template from the default
iso=x.createisofill(`new') # create a new isofill graphics method from
x.plot(s, t, iso, continents=0) # call "plot" function to display the CU
# newly created template "t" and isofill
# graphics method "iso" and turn
x.clear() # clear the VCS Canvas of all plots
x.plot(t,iso,s,continents=0) # shows that the order of the objects are irrelevant, but
There are other ways to plot data in VCS. These additional plotting routines utilizes the same parameter format as the plot() function. What makes these plotting functions unique are their direct association with the graphics methods. That is, each graphics method has its own plot function. For example, if the user wishes to plot data using the isofill graphics method, then the function isofill() can be used instead of the plot() function. If the isofill object is not specified then the default isofill graphics method will be used. The user can also pass down the name of the graphics method to be used. In some ways, the graphics method plot functions can be thought of as short cuts to plotting data.
Note, if a different graphics method object is specified and passed down to one of these alternate plot functions, then the alternate plot function will behave as the plot() function and plot the data in the specified graphics method format.
See table below for additional plot functions.
In some cases, there my be a need to check or verify an object in VCS. For these cases, you may want to use the query functions below.
Check for VCS graphics method objects:
Check for VCS secondary objects:
verifies if an object is one of the secondary objects: fillarea, line, marker, textcombined, textorientation, or texttable |
Check for VCS template objects:
The create functions allow the user to create VCS objects which can be modified directly to produce the desired results. Since the VCS "default" objects do allow modifications, it is best to either create a new VCS object or get an existing one. When a VCS object is created, it is stored in an internal table for later use and/or recall.
Create the following VCS objects:
The get functions are used to obtain VCS objects that exist in the object memory tables. The get function directly manipulates the object's attributes in memory. If the object is used to display data on a plot and is manipulated by the user, then the plot will be automatically updated.
Get the following VCS objects:
Unwanted VCS objects can be removed from internal memory with the use of the remove function. The remove function will identify the VCS object type and remove it from the appropriate object table.
allows the user to remove objects from the appropriate object list |
The show function is handy to list VCS objects tables.
The show function is used to list the VCS objects in memory:
Script commands define the actions that are necessary to preserve an interactive session as a script and to mimic that session in a non-interactive replay of the script. Many attributes are needed to create a graphical representation of a variable, e.g. attributes to identify the variable and to label the plotting axes. By use of VCS and Python scripts, most of these attributes can be manipulated to create the desired visual effect, and the resulting attributes can be saved for later use. VCS and Python scripts also allow the user to save a sequence of interactive operations for replay, and to recover from a system failure.
After creating and/or modifying a VCS object, the user can save the object in the initial.attributes file. The initial.attributes file contains many predefined attribute settings to aid the beginning user of VCS. The path to the file must be:
/$HOME/PCMDI_GRAPHICS/initial.attributes
where /$HOME denotes the user's home directory. (Note, when VCS is executed for the first time, a /PCMDI_GRAPHICS subdirectory will be created automatically if one has not already been created.) The user also can customize the initial.attributes file directly.
To re-save the initial.attributes file, use the function:
saves current VCS objects in the initial.attributes file, which is read initially at start-up |
To save VCS objects has Python scripts or VCS scripts, use the function:
To save the state of the system, use the function:
saves a sequence of interactive operations for replay; or to recover from a system failure |
To run a VCS script file, use the function: