\documentstyle [11pt]{article}
\textwidth=6.0in
\textheight=9.0in
\topmargin=-0.5in
\oddsidemargin=0.5in
\renewcommand{\baselinestretch}{1.5}
\begin{document}
 
\begin{center}
{\bf GRAFIT: A Generic 2D Field Data Plotting Package}\\
\vspace*{0.1in}
{\em Rong-Sheng Zhou, Robert L. Snyder}\\
New York State College of Ceramics\\
Alfred University\\
Alfred, NY 14802\\
\end{center}
 
\vspace*{0.5in}
\begin{center}
{\bf \underline{Abstract}}\\
\end{center}

A suite of FORTRAN-77 computer programs are described which provide
a comprehensive set of visualization techniques for 2D scientific
and engineering data (especially x-ray powder diffraction data) on 
a Tektronix-4100 command graphics terminal hosted to a Vax/VMS 
computer. On-line manipulation of the display and convenient high 
quality hardcopy output are provided. The package will also display
known x-ray powder patterns from the JCPD data base. 
Such a program package is useful in a scientific and engineering 
environment where large volume of 2D data are to be processed and 
visualized routinely.

\begin{center}
{\bf \underline{Introduction}}\\
\end{center}
 
{\bf GRAFIT} is a user-friendly, straightforward and yet sophisticated 
interactive 2D graphics package.  It is written in FORTRAN-77 and designed 
particularly for scientists to run on a Vax/VMS computer and display 
principally on a Tektronix-4100 graphics command language serial terminal 
(TEK4100 short for Tektronix-42xx,41xx). The primary motivation for 
developing GRAFIT was to be able to visualize, by exploiting the power 
of a virtual memory minicomputer, the large volume of x-ray powder 
diffraction data collected and reduced routinely on the Vaxes in our 
diffraction lab in an {\em efficient} as well as {\em flexible} way.
A Menu and form driven dialogue scheme is used to setup plots on any 
DEC VT100 compatible text terminal. Hardcopy output of publication 
quality is currently supported on Hewlett Packard HPGL series and HP7221 
series multi-pen plotters and PostScript printers such as a DEC LN03R 
laser printer.
Fig. 1 gives an example of profile graph produced from GRAFIT on a
DEC LN03R Scriptprinter.

\newpage 
\begin{center}
{\bf \underline{Procedure and Function}}\\
\end{center}

\begin{flushleft}
(1) {\em Data Input}
\end{flushleft}

Data input to GRAFIT is oriented to existing data file(s) which could 
be either created by an editor or by a computer program. Four ASCII 
and two binary file formats are supported by GRAFIT to cater for 
commonly used configurations of x,y pairs of data points and data sets. 
Y error bar input is supported. An ASCII file is free of data field 
formats with maximum field length of 40 characters. Binary formats 
provide storage economy and fast data access for large data sets.
A data file could contain more than one set of data. 
Input of known x-ray powder patterns in the JCPD data base (version ???) 
is via the pattern id number. A group of pattern numbers can be entered 
individually like a filename or collected in and entered from a single 
file. Given the name of a data file, GRAFIT will automatically parse 
its file format and content during data acquisition.

Run-time dynamic memory allocation is used for data storage.
This is implemented in terms of two user-specifiable run-time parameters,
i.e. max number of data sets and max number of data points per data set. 
Input of multiple data sets could be either from a single file or from 
multiple files. Plot setup however is oriented to individual data sets 
rather than to individual data files.

\begin{flushleft}
(2) {\em Dialogue Scheme and Auxiliary Utilities}
\end{flushleft}
 
Non-scroll menu and form driven dialogue is provided by GRAFIT on any
DEC VT100 compatible text terminal that supports the standard ANSI
escape and control sequences. Random-access setup of all plot parameters
is accomplished with a set of two letter mnemonics designated to a single
or group of related parameters succinctly laid out on a single VT screen. 
Complete on-line help on the mnemonics and parameter functions are easily 
accessible. A number of Vax/VMS-type auxiliary dialogue commands and 
function keys are implemented to provide additional utilities such as 
reading and writing associated files, spawning sub-process, and invoking
on-line data manipulation menu. The data manipulation menu consists of
such items as data sorting, smoothing and differentiation, polynomial 
regression, and mathematical function graphing which can essentially 
plot any $y=f(x)$ function simply by user keying its formula. 
 
By default, GRAFIT searches initially for a run file *.PAR (where *
designates the name of the data file to be plotted) in the users directory 
to set up the plot and keeps updating it every time the user exits from 
the setup menu. If the run file is not found, a set of program-internal 
default parameters are used to setup the plot initially. An auxiliary 
dialogue command SAVE will save the current setup into or READ will read 
from a different run file. The run file is written as a keyword-oriented 
ASCII file the user may edit, and it contains all the information necessary 
to re-generate the same plot. No additional file or command procedure need 
to be prepared or executed before running GRAFIT.

\begin{flushleft}
(3) {\em Screen Display}
\end{flushleft}

Automatic data scaling is provided together with manual scaling on linear, 
log10, and inverse linear types of axes. The inverse linear axis is 
tickmarked and annotated in {\em inverse linear scale}. Full tickmark 
control is supported over tickmark number, spacing, offset, direction 
and grid. Independent x,y-axis offset and rotation, multi-axis, 
multi-window and multi-quadrant plots are also supported.

A set of data points can be rendered with a variety of colors, line types,
centered marker symbols, line widths, region fills. In addition, the user 
also has control over their connectivity, sampling stride, x,y-offset and 
rescaling, cubic spline smooth, and region fill reference line.

CTRL/C interrupt is trapped by GRAFIT to allow user to abort an unwanted 
plot session and get back to the setup menu.
 
\begin{flushleft}
(4) {\em On-line Graphics Editing and Layout}
\end{flushleft}

On-line interactive graphics editing of the display and 2D layout are
implemented on a Tek4100 with segment graphics capability. The editing 
and layout session, when invoked upon a completed display, uses a set
of dialogue commands and function keys together with a crosshair cursor 
to edit the display. The session supports such editing features as 
coordinate and distance report, zoom, pan, rotate, hiding toggle, cursor 
position lettering and overlay of a variety of geometric patterns (e.g. 
line, arrowhead, symbol, circle, ellipse, polygon, bar, etc...).
The edited display is saved and can be sent for hardcopy.
 
\begin{flushleft}
(5) {\em Hardcopy output}
\end{flushleft}
 
GRAFIT was designed to link to a graphics library named TEKLIB which was
modeled after a set of Calcomp calls and further developed by the author 
over years to take advantage of modern computers and computer graphics 
devices. With Tek4100 commands as its primary graphics language,
TEKLIB also supports ReGIS graphics and ASCII character-set graphics.
Therefore GRAFIT can also be run on a non-Tek4100 terminal to obtain
a hardcopy. The principle of ``{\em What you see on screen is what you get 
on a hardcopy}'' is applied to GRAFIT. Parallel to the screen display, 
TEKLIB automatically writes a device independent meta-file in the users 
directory. The meta-file contains all the necessary information for 
reproducing the screen display on a hardcopy. When hardcopy is requested 
with a single key stroke to GRAFIT, TEKLIB presents the user with a 
hardcopy page setup menu which will allow for selection of hardcopy 
parameters such as number of copies and target hardcopy device. TEKLIB 
then releases GRAFIT by sending a job entry to a system batch queue to 
activate the target hardcopy device driver. The device driver reads the 
device-independent commands and data in the meta-file, converts them to 
device-specific graphics instructions, and then writes them to a scratch 
file. Upon completion of the above process, the scratch file is submitted 
for printing to a system print queue designated to the target hardcopy 
device. Such a hardcopy making scheme, although system-dependent, makes 
hardcopy simple and fast to a regular user. At the moment, hardcopy device 
drivers are provided for PostScript laser printers, Hewlett Packard HPGL 
series and HP7221 series pen plotters, and Present Technology 35mm color 
slide makers. It is a relatively easy task for a programmer to write 
additional hardcopy device drivers of local interest since the driver 
is a standalone program and all of its subroutine calls have been unified 
into a single main program.

In addition, hardcopy output can be redirected easily to a device
eavesdrop-configured to the on-line terminal or its printer port.

\begin{center}
{\bf \underline{Installation}}
\end{center}
 
Upon request with a blank tape and the instructions for writing the tape,
a copy of GRAFIT together with all subsidiary programs and installation
notes is available from the first author. Minimum virtual memory allocation 
by the current version of GRAFIT is 400 pages (512 bytes/page), which is 
less than the default working set size for a regular user on a multi-user 
Vax/VMS. A VMS Command Language Description(CLD) file with provision of 
VMS-type command parameters and qualifiers for running GRAFIT is also 
available to install GRAFIT into the DCL command table, so that GRAFIT 
can be invoked in either normal interactive mode or bypass mode for hardcopy 
shortcut. In the interactive mode, the user can define and execute
commands such as
\begin{small}
\begin{flushleft}
\hspace*{0.25in} \$ GGPLOT == ``GRAFIT/TERMINAL=REGIS''\\
\hspace*{0.25in} \$ GGPLOT FILE1.EXT,FILE2.EXT/ALLOCATE=(5,1000)/SETUP=COMMON.PAR
\end{flushleft}
\end{small}
while in the bypass mode, for example
\begin{small}
\begin{flushleft}
\hspace*{0.25in} \$ HARDCOPY == ``GRAFIT/HARDCOPY/DEVICE=HP7550''\\
\hspace*{0.25in} \$ HARDCOPY FILE1.EXT,FILE2.EXT/COPIES=5/PEN\_SPEED=5
\end{flushleft}
\end{small}
VMS specific system services have been utilized and built in TEKLIB. 
An effort is underway to port TEKLIB to the UNIX environment.\\\\\\
We would like to acknowledge James Walker at Alfred University
Computer Center for his professional help in the development of
the programs.
\end{document}
