2013-04-10

Getting hard-copy graphics from Starlink apps

Most of you will already know that the Starlink KAPPA package provides many tools for producing useful graphical output (linplot, display, contour, etc.), and for dividing up the plotting space into "pictures", each of which can hold a separate plot (picdef, picsel, etc.). Multiple plots can be stacked on top of each other, so for instance it is possible to overlay a contour plot on an image, or to overlay multiple line-plots. However, how easy it is to do this depends on the graphics device you are using.  Using "xwindows" is straight-forward, but relies on taking screen-shots for hardcopy, which for some purposes is not good enough. Using PostScript devices produces high quality hard-copy, but is awkward because each KAPPA command produces a separate PostScript file. The user then needs to combine all the individual PostScript files into a single PostScript file.

The current development Starlink system introduces some new features that make using PostScript much easier. If you use kappa:gdnames to list all available graphics devices, you will see some new entries:

   % kappa
% gdnames

The following graphics devices are available. The first column holds the GNS
names, and the second the equivalent PGPLOT names (in parentheses). Either
form can be used...

png (/PNG) Portable Network Graphics file
...
...
aps_p (/AVPS) Accumulating EPS, monochrome, portrait
aps_l (/APS) Accumulating EPS, monochrome, landscape
apscol_p (/AVCPS) Accumulating EPS, color, portrait
apscol_l (/ACPS) Accumulating EPS, color, landscape
...
...

These new "accumulating" devices produce a single Encapsulated PostScript file (pgplot.ps by default) by accumulating the PostScript output automatically from subsequent Starlink graphics commands - no need for you to merge them all together yourself into one file. For example:

   % gdset /acps
% okular pgplot.ps &
% gdclear
% picdef mode=array xpic=2 ypic=1 prefix=pic nooutline
% display $KAPPA_DIR/m31 \
          style="'colour=black,width=2,colour(ticks,border)=green'" \
          mode=perc percentiles=\[2,98\]
% contour $KAPPA_DIR/m31 style="'colour=red'" noclear mode=free \
          heights=\[9000,11000,13000\]
% picsel pic2
% linplot $KAPPA_DIR/m31'(,169)' \
          style="'colour=black,width=2,colour(curve)=red'"
% linplot $KAPPA_DIR/m31'(,180)' style="'+colour=blue'" noclear


produces a single PostScript file (pgplot.ps) containing the following two pictures:


But what is that "okular pgplot.ps &" command in there? Okular (see http://okular.kde.org/) is a PDF and PostScript viewer supplied with the KDE desktop in Fedora, etc. It automatically re-draw the display if the contents of the displayed file changes on disk. Combined this with these accumulating Postscript devices provides a scheme that is similar to the use of a traditional persistent X-window device, in that the display is automatically updated after each graphics operation completes. If you do not use KDE, your OS may provide an alternative PostScript viewer.

To use these new features, you will need to rsync /stardev from Hilo.

No comments: