POW Scripting Guide
Because fv and POW are written in Tcl, they are inherently scriptable. So long as one knows the necessary data structures and function calls, everything POW does can be controlled by a user-created Tcl script running inside of POW. This, however, is a formidable task. Plus, POW's internal behavior and data are subject to change with each new release.
To make scripting possible, then, a simplified (and hence limited) script interface has been added to POW. It consists of a small set of commands which perform the basic operations of creating and modifying graphs. Future versions should contain more capabilities.
Operational Summary
There are several ways to access POW's scripting commands. The simplest is to write a Tcl script which uses the commands directly and then execute it within POW's powCmds namespace. As POW has no file capabilities nor command console of its own, this currently can be done only if implemented within an application containing POW, such as fv. (See fv's Scripting Guide for details on executing POW commands within fv.) This scripting method is useful for implementing macros which can perform certain common operations at the user's request, such as setting specific graph options.
Alternatively, POW can be scripted by other programs, allowing those programs to make use of POW's capabilities remotely. These programs, however, do not need to be written in Tcl so long as they can communicate with POW. Currently POW supports XPA on unix platforms and AppleScript on MacOS for communication:
The XPA messaging system (http://hea-www.harvard.edu/RD/xpa/) developed by the SAO/HEAD R&D group implements a method of communicating between two programs running on unix platforms. Communication occurs either through standalone programs (ie, xpaget and xpaset), a C subroutine library, or a Tcl extension. POW uses the Tcl extension to make its scripting commands available, but the calling program can use any of the XPA methods to access the commands. The XPA software is not distributed with POW or fv and must be obtained and built by the user.
AppleScript (http://www.apple.com/applescript), the English-like language on all Macintosh computers (circa MacOS 7.5 and up), can also be used to control POW remotely. (Actually, any program on the Mac can control POW through the use of Apple Events.) Using the do script command, Tcl code can be passed to POW. Due to how Tcl's do script command and POW's scripting commands are implemented, POW commands must be prefixed with the powCmds:: namespace specifier.
POW's scripting capabilities closely mimic the interface described in POW's Developer's Guide. In general, one first creates a data object from which either a curve or image is produced. One then creates a graph onto which a series of curves and/or images is placed. The graph size, position, and viewing region can then be modified as needed. Once plotted in a graph, curves and images can be displayed using different point shapes, line styles, or colormaps. In most cases, commands operate on the currently selected object (as appropriate).
Many scripting commands also can be used as inquiries. Inquiries and commands are implemented using the same syntax, differing only in that commands supply the necessary parameters to perform an action, whereas inquiries leave them off indicating POW should return the current settings. When used with XPA, inquiries must use the xpaget tool and commands the xpaset tool.
Command Summary
pDisp --> boolean --> Display Points?
pShape --> string --> Point shape (Cross, Diamond, Box,
Octagon, Triangle, "Inv. Triangle")
pSizeErr --> boolean --> Draw point the size of errorbars?
pSize --> integer --> Size of point
pFill --> boolean --> Fill in point, if an outline
pColor --> color --> Color of points (any color name
or #RRGGBB value)
lDisp --> boolean --> Display line?
lStyle --> dash --> Dash style of line (" " is solid,
"20" is 20-pixel dashes,
"15 10 4 10" is Dash-dot, etc)
lWidth --> integer --> Width of line
lStep --> boolean --> Draw line as histogram?
lBoxFill --> boolean --> Fill histogram boxes?
lColor --> color --> Color of line (any color name
or #RRGGBB value)
bgcolor --> color --> Color behind graph (any color
name or #RRGGBB value)
xmargin --> integer --> Intergraph spacing; affects
ymargin --> integer --> placement of new graphs
xdimdisp --> integer --> Screen dimensions of graph;
ydimdisp --> integer --> affects size of new graphs
FixedAspect --> boolean --> Force identical horizontal
and vertical scales for graph
(defaults to yes if any
images present)
xlabel --> string --> Label for X axis
ylabel --> string --> Label for Y axis
xunits --> string --> Optional unit value for X axis
yunits --> string --> Optional unit value for Y axis
titleString --> string --> Title for graph
titlePosition --> direction --> Position around graph to place
title... value is a string
containing the letters n, e,
w, s (for north, east, etc)
titleAnchor --> direction --> Position in title to place at
the titlePosition... value is
a string containing n, e, w, s.
xNumTicks --> integer --> Scaling parameter for number of
yNumTicks --> integer --> tick marks on each axis
(default, 3; not 1-to-1)
xTickScal --> string --> Scaling of tick marks along
yTickScal --> string --> each axis: "linear" or "log".
Graphs with WCS information
ignore this and use ra/dec.
xTickLength --> list --> Length of tick marks for each
yTickLength --> list --> axis on each side of graph.
Order is [lft rgt top bot]
(default: "10 10 10 10xLft yBtm xRgt yTop ?wcs|pixel?
pDisp --> boolean --> Display Points?
pShape --> string --> Point shape (Cross, Diamond, Box,
Octagon, Triangle, "Inv. Triangle")
pSizeErr --> boolean --> Draw point the size of errorbars?
pSize --> integer --> Size of point
pFill --> boolean --> Fill in point, if an outline
pColor --> color --> Color of points (any color name
or #RRGGBB value)
lDisp --> boolean --> Display line?
lStyle --> dash --> Dash style of line (" " is solid,
"20" is 20-pixel dashes,
"15 10 4 10" is Dash-dot, etc)
lWidth --> integer --> Width of line
lStep --> boolean --> Draw line as histogram?
lBoxFill --> boolean --> Fill histogram boxes?
lColor --> color --> Color of line (any color name
or #RRGGBB value)
bgcolor --> color --> Color behind graph (any color
name or #RRGGBB value)
xmargin --> integer --> Intergraph spacing; affects
ymargin --> integer --> placement of new graphs
xdimdisp --> integer --> Screen dimensions of graph;
ydimdisp --> integer --> affects size of new graphs
FixedAspect --> boolean --> Force identical horizontal
and vertical scales for graph
(defaults to yes if any
images present)
xlabel --> string --> Label for X axis
ylabel --> string --> Label for Y axis
xunits --> string --> Optional unit value for X axis
yunits --> string --> Optional unit value for Y axis
titleString --> string --> Title for graph
titlePosition --> direction --> Position around graph to place
title... value is a string
containing the letters n, e,
w, s (for north, east, etc)
titleAnchor --> direction --> Position in title to place at
the titlePosition... value is
a string containing n, e, w, s.
xNumTicks --> integer --> Scaling parameter for number of
yNumTicks --> integer --> tick marks on each axis
(default, 3; not 1-to-1)
xTickScal --> string --> Scaling of tick marks along
yTickScal --> string --> each axis: "linear" or "log".
Graphs with WCS information