Title                  :XMAQNT
Keywords               :quantitative correction, PAP, PROZA, XPP
Computer               :Any with ANSI-C; tested on IBM-PC, Unix
Operating System       :Any
Programming Language   :ANSI-C
Hardware Requirements  :None
Author(s)              :Cameron Davidson
Correspondence Address :CSIRO, Division of Manuf. Technol., P.O Box 883
                       :Kenmore, 4069, Australia
                       : fax +61 7 212 4681
                       :email (Internet): cjd@cat.csiro.au
Compression Method     :ZIP -use 'unzip' or 'pkunzip -d' on MS-DOS, or
                       : 'unzip -a' on Unix.
Description:

    XMAQNT.DOC : V1.1 13-May-94
    This document is divided into the following sections:
        INTRODUCTION ( this section)
        Setup INSTRUCTIONS - Data files and directories
                           - Using MSDOS binaries
                           - Building from soure code
	PROGRAM DESCRIPTIONS
                           - Utility programs
                           - XMAQNT
        Energy and MAC database files
        STANDARDS

    XMAQNT is a software package for performing quantitative X-ray
    microanalysis. It is written entirely in ANSI C and should be
    compatible with most C compilers with little change.
    It has been built and tested on at least the following systems:

    Unix - gcc (GNU C Compiler v2.5.8) under SunOS 4.1.3 (Sun sparc)
    Unix (HP-UX) - Hewlett Packard C compiler on 730 and 735 machines
    Linux (free unix clone for PCs) using GCC 2.5.8
    MSDOS - using Microsoft C version 5.1 and
    MSDOS - using the free 32-bit GNU C compiler and dos extender
        (the DJGPP package)

    It provides:
    1. A program to perform PAP, PROZ-A or XPP quantitative corrections on
        X-ray intensity ratios.
    2. a library of basic atomic chemistry and X-ray related utility
        routines.
    3. use of databases for X-ray lines, edges and Mass Absorption
        coefficients, with the possibility of supporting multiple
        such databases.
    4. utility programs for creating, examining and editing these
        databases. 
    5. support for plotting the calculated Phi-Rho-Z curves. (This
        requires the user to obtain the free plotting package
        GNUPLOT - available for many different operating systems.)

References:
    Main correction routines:
       1. J-L Pouchou and F Pichoir, pp 31-75, in "Electron Probe Quantitation",
	 Ed Heinrich and Newbury, Plenum:NY 1991
       2. G F Bastin and H J M Heijligers, pp 145-161, ibid.
    Other routines:
       1. S J B Reed, Microbeam Analysis, p 109 (1990)
	Many Others; may be referenced in the routines in which they are used.

Compilation Procedure:
Linking Procedure:
    Available as source code and also in MS-DOS binary form, ready to run.
    There are three separate ZIP files which you can obtain. For an MS-DOS
    system you should get all three, otherwise only XMAQNT.ZIP is useful:

        XMAQNT.ZIP	- source code and ASCII source for data
        XMAQEXE.ZIP	- MS-DOS executables
        XMAQDAT.ZIP	- MS-DOS binary data files.

    Procedures for building from source code will vary slightly depending on
    which C compiler you have. Makefiles for several systems are supplied and
    are described in some detail below.

Test Data:
    Several test datafiles are supplied in the 'examples' directory
    of the zip file containing the source code. Their use is described
    below.

Acknowledgements:
    The main correction routines are derived from fortran routines
written by Mr X. Meng at Cambridge University Dept of Earth Sciences (now
at Dept of Materials Science).
All main algorithms are based on references above.
Not all situations discussed in those papers are coded; for example I
have not made the adjustments necessary for very low overvoltages.
The K/K fluorescence is based on Reed 1990, while other fluorescence
calculations are based on the earlier method of Reed.

    Many of the support functions were developed while I was working with
Link Analytical (now part of Oxford Instruments) and they draw to some extent
on the Fortran code in their AN10000 and eXL ZAF-4 product. I am grateful
to Dr P. Statham for permission to release that code.

    I thank Dr D. Cousens for access to the HP computer at Univ of
Queensland Centre of Micr. and Microanalysis and for data from the
JEOL 8800 probe for testing the code.

Bugs:
    I am certain to have introduced some errors either in transcription or
in writing my own code. Please let me know of any you find. If you try it
and can compare it with other correction programs I would like to know the
outcome, no matter whether the results agree or disagree.

Enhancements:
    If you would like to help improve the program then please get in touch
with me first - I or somebody else may have already done it or be working on
other code which affects your proposed changes.

Restrictions on use:
    This software may be used free of charge whether for commercial or
non-profit use. The source code supplied is in the public domain.

Warranty:
    This software comes with NO warranty of any sort, expressed or implied.

Contact:
    I am willing to answer questions (particularly if you find my
instructions confusing and can help improve them).
If there are questions regarding compilers and such then I would ask you
to try your local experts first since I have only used the ones described
below, and even with these local settings may vary.
    I can be contacted by e-mail on the Internet as:
cjd@cat.csiro.au

-------------- Setup INSTRUCTIONS ----------------

In this document filenames are sometimes written in upper case to make them
stand out. In MSDOS this does not matter. In Unix the filenames should
be treated as lower case. Under Unix the directory separator in a pathname
is always '/'. With the MSDOS programs here you can use '\' and '/'
equally well.

============== Data files and directories

The xmaqnt programs require a directory tree for necessary data files:
by default the data files are below a root directory:
"/usr/local/lib/xray" for unix systems, or
"C:\XRAY" for MS-DOS systems.
If these are not suitable then you can override the directory name on
an individual basis by setting an environment variable named XRAY_DATA.
For example, if you wish to use drive D: under MSDOS instead, then
you should put the line:
	set XRAY_DATA=D:\XRAY
in your autoexec.bat file.
If you are compiling from sources then you should edit the file xrdata.c
in the lib directory to reflect your desired default directory.

In the information below, XDD represents whatever is defined as the X-ray
data file root directory.
The data directory tree structure is as follows:
XDD/data    - Xray database directory. Contains
         xray2.dat - the binary lines and edges database
         mac_N.dat - a number of MAC database files.
                N = 0 for K alpha lines
                N = 1 for L alpha line, etc.
                N = 3 for K beta lines
XDD/stds    - all the  standards information
XDD/stds/comps    - a directory containing all the standard compositions
        for compound stds; each standard is specified in an individual
        file. The name of the standard used by XMAQNT is the name of
        the file, and so must conform to filename restrictions imposed
        by whatever operating system you use.
XDD/stds/pap0150    - directory containing precalculated stds factors
        for using PaP model at 15.0 kV. Each standard named in comps
        will have a file of the same name here (if used at 15kV with
        PAP). Additionally, factors for pure element stds are stored
        in files named e.g. "pureFe" for iron, "pureK" for potassium.
XDD/stds/pap0200/*  - ditto for PaP at 20 kV, thus you can have datasets
                to nearest 100V.
XDD/stds/xpp0150/*  - precalc. factors for XPP at 15.0 kV.
XDD/stds/prz0150/*  - precalc. factors for PROZ-A at 15.0 kV.
    The pap/xpp/prz stds files and directories are created as required
    by the software (well, mostly).

============== Using MSDOS binaries

Installing for MS-DOS systems:
	I will assume for the sake of illustration that the ZIP files are
on a floppy disc in drive A:.
	Choose a suitable directory in which to place the executable files,
typically somewhere in the path (total requirement up to 400kByte disc space,
although some programs may be removed if not required). For example, on my
system is a directory C:\BIN which contains programs from a number of
places no large enough to warrant directories of their own.
Change directory to the location you have decided to place the files and
extract the files:
	> CD C:\BIN
	> UNZIP A:XMAQEXE.ZIP   or  > PKUNZIP A:XMAQEXE.ZIP 

	Choose a suitable hard disc partition for the data file heirarchy:
there should be about 600kBytes free. The default built into the programs
extracted above is drive C:. The data files should be extracted into a
directory in the root directory of the selected disc partition:
	> C:
	> CD \
	> UNZIP A:XMAQDATA.ZIP   or PKUNZIP -d A:XMAQDATA.ZIP
Make sure you remember the '-d' if you use PKUNZIP since retaining the
directory structure is vital.
	Now go to the section describing the programs...

============== BUILDING FROM SOURCE CODE:

    Extracting source code from Zip-file...
Unix:	unzip   -a xmaqnt.zip
DOS	unzip      xmaqnt.zip
  or	pkunzip -d xmaqnt.zip
any other operating system, I do not know, but basically the text is stored
using MS-DOS style <CR><LF> line terminations. There are a few long
filenames (exceeding MS-DOS limits) but they are only required under
Unix.

    When the source code is unzipped you will have created a directory tree
starting with one named xmaqnt. Change to that directory.
It should contain the following files:
readme - this file, the same as xmaqnt.doc!
makef.xxx - makefiles for various systems on which I have built the software.
  Each is specific to a version of Make, but they are quite basic and should be
  useable with any half-decent Make. The DOS versions suffer the usual problems
  of command line length limitations and the thousand different ways of
  resolving it. If all else fails just make the response files by hand.
  Each subdirectory will also have makefiles with the same naming scheme.
    makef.c51 - for Microsoft C compiler V5.1 (I used a P.D. make; if you only
        have MS nmake, I think you need to rename to 'makefile'
        (I've not tried it)
    makeall.bat - MS-DOS batch file to perform the same as "make all" if the
        top-level makefiles do not work for you.
    makef.gcc - GCC for dos (DJGPP), used with GNU make for DOS.
        DMAKE nearly works, if you
        don't run the overall makefile from the top directory, but
        run the individual makefiles in the order specified below.
    makef.unix - general purpose make for Unix systems.
directories: the current directory should also contain 6 subdirectories:
    lib - the library source code
    xmaqnt - the main source code
    utils - a couple of utility programs for checking the data.
    mactbl - for constructing MAC database files; source code and source data
		files.
    xwt - for constructing the X-ray wavelength database file; source code
		and source data file.
    examples - some example standards files, as well as example input and
    	the output you should see from it.


How to compile it:

1. Choose your default data directory:

The xmaqnt programs require a directory tree for necessary data files:
by default the data files are below a root directory (XDD):
"/usr/local/lib/xray" for unix systems, or
"C:\XRAY" for MS-DOS systems.
If these are not suitable then you should edit the file xrdata.c in the
lib directory.

Before you start a build under MSDOS you should create the directories:
XDD,
XDD/data,
XDD/stds and
XDD/stds/comps.
The Unix makefile will do this for you.
[ On Unix systems they should be given read (and possibly execute) permissions
to the world. Whether any have write permission will depend how you see
to the world. Whether any have write permission will depend how you see
system security versus flexibility. There is some provision made in the
code for using group-IDs and/or running setGID, but it has not been tested
much (see xmaqnt/std_io.c if you are interested - or if you are building for
Unix and want to disable it). ]


2. Building the programs:

Rename the make-file most suited to your compiler to be "makefile".
You should not do this for lower levels, only for the top level
makefile. (Alternatively you can rename them all and then ALSO edit
the top makefile to reference the proper lower-level makefile)

    MS-DOS:
	If you have a system matching one of those already tested then you
	can probably proceed by executing "make all" in the current directory.
	This will attempt to:
	    1. build the library,
	    2. build the xmasterb program in xwt, and then run xmasterb to
	       build the actual database file.
	    3. build the MAC file utilities
	    4. build utility programs viewxray and viewfl,
	    5. build the xmaqnt program itself.
	Nothing is installed. The MAC database files are not built.

	3A. Building the programs the hard way.

	If the 'make all' failed, or if you did not want to try it, you should go to
	each of the directories in turn, check the makefile (same naming convention
	as described above) and possibly modify it for your own system, and try
	"make" or "make all". The lib must be built first, but the others can be
	built in any order.

	4. Install Lines and Edge database

	assuming you had the file linesmas.trs and succeeded in creating xray2.dat,
	You can install it in (copy it to) your xray data directory, keeping the
	name "xray2.dat".

	------------------------------------------------

    UNIX compilations.

		There is a file "makef.unix" in the top directory which needs to
	be edited to reflect your system. See the comments embedded in
	makef.unix to determine what needs to be changed.  You should not need
	to edit the file if you run GCC under Linux or under Solaris. 

	Once you have edited the definitions in makef.unix you can issue:
		make -f makef.unix all
	If all succeeded you can try
		make -f makef.unix installdata
			which will make directories and install data files
	and
		make -f makef.unix install
			which will install executables.
	If you need to be running as superuser to do the installation then you
	should set the INSTALL macro to be "install -o etc..." so that file
	ownership and access mode are set up correctly.

	If you need to fiddle around in specific subdirectories then
		make -f makef.unix makefiles
	will build suitable Makefiles in each subdirectory, based on your
	preferences in makef.unix.


------------------ PROGRAM DESCRIPTIONS ----------------------

The programs are written in C and so conform to the normal C input
specifications: where more than one data item is required on a
line they should be SEPARATED BY SPACES AND/OR TABS, use no commas.
Requests for chemical elements require the alphabetic symbol, one or
two characters, in any combination of upper and lower case.


====================== viewfl
	Allows you to view some of the parameters used in calculating
fluorecsence correction. (it was mainly written as a debugging aid).
Just run the program (it takes no arguments) and answer the questions.

====================== viewxray
	Like VIEWFL, this was originally written for debugging; the
consequences of this are apparent in the idiosyncratic user interface.
VIEWXRAY allows you to inspect the lines and edges database and the MAC
databases. You can examine one element or a range of elements, one
Xray line or a family of lines. By selecting various options on the command
line you can also select the modes of results display
command syntax:
	> viewxray  [option]
    where option is one or more of the following
    -ux         : set display units to x:
                 w = wavelength
                 l = L value
                 s = sin( theta )
    -rnn        : set rowland radius in mm (dflt 140)
    -dnn        : set the crystal 2-D spacing
    -xccc       : set the crystal 2-D spacing by name ccc:
                 lif, pet, tap, ldeb, ste...
    -zminyy     : set min atomic number to be yy, when printing ranges
    -zmaxyy     : set max atomic number to be yy, when printing ranges
		: (yy must be a number, not element symbol)
    -D          : debug on (may be repeated to increase debug)
If you want to display in sin( theta ) or L-value then you must specify a 2-D
spacing somehow. If you want to display in L-value then you must also specify
a Rowland circle radius (or accept 140mm as default).

Once you run the program you will be prompted for your what sort of information
you want, with the lines:

              ------- Give type of data required -
    lower case for a family of values and upper case for single value.
    l=line, e=edge, m=MAC from table, h=Heinrich86MAC, z=atomic num & wt :

If you reply with a blank line the program exits, otherwise select from
one of the following characters:
 Z  asks for an element symbol and prints atomic number and atomic weight.
 z  asks for start and stop elements for the range - give as element symbols.
 L  asks for element (symbol) and X-ray line and prints the result in the
    units selected on the command (default wavelength and keV). Only the
    'analytical' lines can be specified ( i.e. K/L/M Alpha or K/L/M Beta)
 l  asks for an element and X-ray line. Somewhere in the reply should be the
    '*' character to indicate range of results, thus:
      * ka       will display all K alpha lines for the previously selected
                 range of elements.
      Fe *       will display all lines for Fe
      Fe k*      will display all of the K family of lines which have values
                 in the database file. 
 e  asks for element and edge. Somewhere in the reply should be the
    '*' character to indicate range of results, thus:
      * k        will display all k edges for the specified range of elements
      fe *       will display all absorption edges for Fe.
      fe l*      will display the L family of absorption edges for Fe.
 E  asks for an element and edge and displays the result.
 M  asks for an element and X-ray line along with the absorber element and
     displays the MAC value from the data file. Only 'analytical' X-ray
     lines are valid.
 m  asks  for emitter element and line and absorber selection, of which one
     must be the '*' character, indicating selected range. E.g.:
      * ka Fe    will display a table of MACS for the K alpha lines of the
                 range of elements specified when absorbed by Fe.
      Fe ka *    will display a table of MACS for Fe K alpha in the selected
                 range of elements.
 h or H  will ask for element and energy and then calculate the MAC using the
      Heinrich 1986 formula.

	Prompt are written to stderr channel while tables are written to
standard output, therefore you can (MS-DOS and Unix) redirect the output
only into a file, e.g.:
	viewxray > xrtable
The prompt messages will still come to the screen but the results will be
writen to file xrtable.

====================== mactbld
	Simply asks which MAC table you wish to build and creates the
appropriate file, filled with values calculated from Heinrich 1986 and 1964.

====================== editmac
	Allows you to enter specific values for MACs in the working
database files (the ones in XDD/data)
You are prompted for the necessary data. Here is an annotated script
directly from a  run: ( lines beginning with -- are annotations)
 > editmac

		-- we can only edit the file for one type of analytical line
		-- at a time.
Give Xray line of emitter(s): ka

Give symbol of emitter  and symbol of absorbing elem: Si Ta

		-- the program prints out the current value and
		-- where it was derived from
Old MAC = 1697, source was Heinrich 1986
Source codes:
        8       User defined
        4       Henke and Ebisu
        3       Pouchou and Pichoir
        2       Heinrich 1964
        1       Heinrich 1986

		-- specify the new MAC and that it came from source 3 (P and P)
Give new MAC [and optional source code] : 1490 3
		-- keep answering until you have finished K alpha entries, then
		-- give a blank line to finish
Give symbol of emitter  and symbol of absorbing elem:

		-- until now changes have been kept in memory, do you want
		-- to write the changes to disc?
Save new data ? y


====================== xmasterb
	This program reads the file linesmas.trs and creates a binary version
named xray2.dat in the current directory. It takes no options. Once the data
file is created it is no longer required, unless you wish to modify the
input data file and re-run the conversion.


====================== XMAQNT

	XMAQNT takes options on the command line. If you type
"xmaqnt -h" you will see the following error message.

Syntax is : xmaqnt [ options ]
options are:
    -mxxx       : use correction model 'xxx'. Valid values are:
                  'pap'(dflt), 'prz', or 'xpp'
    -s name     : calculate for standard 'name' only
    -kvnn       : set accelerating voltage to nn kV(dflt 15)
    -ann        : set take-off angle to nn degrees (dflt 40)
    -r[-A|O]    : reverse process.(pure stds only)
                [-A : input Atoms] [-O : input oxide wt pct]
    -px : give plot of Phi(rho-Z) curves, 'x' specifies plotting option:
                g = gnuplot (results in file xx_prz.gp for element xx)
		[ -pg is the only plotting option currently supported ]
    -dnn        : set sample density to nn gm/cc (for plotting)
    -edixx      : estimate element xx by difference
    -eos        : estimate oxygen by stoichiometry
    -eod        : estimate oxygen by difference but assign by stoich. in output
    -vxx=nn     : override default valence for element xx with n               
    -imode      : set iteration mode, mode is
                h - hyperbolic only,    p - parabolic only
                pp - P and P hybrid(dflt)
    -V          : print version information and exit
    -D          : debug on (may be repeated to increase debug)
    file        : file name for input ( default input is keyboard
							(standard input))

Note that if you have a number of options which you always invoke then
you can put these into a file called "xmaqnt.opt" in the current directory
and the program will read them after parsing the command line. Thus if you
always wanted to use xpp and always worked at 25kv for a particular data set
your file xmaqnt.opt would contain:
-mxpp
-kv25
If you wish to permanently change defaults for
accelerating voltage, correction model, or detector take-off angle
then edit the file maqinit.c in directory xmaqnt and recompile.
Changing the default correction model involves changing 4 separate global
variable initialisation parameters (on 4 successive lines).


======= Input data format:

Data can be entered from a file or else from std input (keyboard).
If data is from std input then the user is prompted for data.
The list of all measured elements is entered first:
one element per line. On each line give:
chemical symbol, xray line, standard name 
a blank line terminates the element list.
All data should be SEPARATED BY SPACES AND/OR TABS, use no commas.
If standard name is omitted then a "pure" std is assumed.
If xray line is omitted the a pure std and a default line is assumed (either
Ka, La or Ma depending on atomic number - cutoffs are arbitrarily set to
z < 35,Br and z < 70,Lu)
Then come the data sets: any number of analyses may be added to the one input
file, but only the one element list is allowed. Lines beginning with "#" may be
included - the "#" is removed and the remainder of the line is used as a label
for printout of the next result.
Succeeding lines give the X-ray intensity ratio (unknown / standard) for the
elements in the same order as the element list, one element per line. Each
line may also have a second number which gives the estimated relative
std deviation of the intensity ratio (as a fraction of the input ratio value).
This number would normally be derived from counting statistics.
A blank line or end of file terminates the program.

I have developed a set of shell/awk scripts for processing data obtained on
a JEOL 8800 using JEOL software to collect the measurements. These can
be provided on request.

====== Output data format:

	when run in reverse or as a standards precalculation output
is like this:

Accel voltage = 15.0 kV, 40 degrees TOA.
 elem            wt pct   ZA(std)   F(std)   FST    rel intens(to pure)
  Al   K alpha 52.9261 5.55068e-04 1.000000   0.80176  0.42434
   O   K alpha 47.0739 3.18100e-04 1.002216   0.54829  0.25810

The ZA factor is the value calculated from the absorption-corrected Phi(rho-Z)
function (i.e. the emitted intensity),
it is the equivalent of the combined Z and A corrections in ZAF procedures.
F is the fluoresence factor. The values are NOT normalised
relative to the pure element, and so are not near 1. The last column is
the predicted relative intensity compared to pure material. The FST value
is the same but normalised for mass fraction (this is old Link Analytical
terminology). An FST of 1 means ZA.F = 1 relative to the pure element.

When run normally the output is like this (taken from the example file
qout.ox):


Sample:  first fake example

Accel voltage = 15.0 kV, 40 degrees TOA. 3 iterations
 elem  wt pct   wt % ox   atom %   FST  ZA(unk/std) F(unk/std) 3sd det.lim
   Al  42.5753  80.4428  31.8048  0.9933  0.989798   1.003550   0.0000
   Si   9.5166  20.3587   6.8297  0.7366  0.736558   1.000000   0.0000
    O  48.7087           61.3655 
Total 100.80  100.80 

Sample:  second example, with estimated std deviation

Accel voltage = 15.0 kV, 40 degrees TOA. 4 iterations
 elem  wt pct   wt % ox   atom %   FST  ZA(unk/std) F(unk/std) 3sd det.lim
   Al  32.1189  60.6864  23.8447  0.9877  0.979999   1.007826   2.8907
   Si  18.8764  40.3821  13.4628  0.7918  0.791809   1.000000   1.1326
    O  50.0731           62.6926 
Total 101.07  101.07 

Most values should be obvious. FST is as above. ZA(unk/std) is the ratio of
the ZA factor for the unknown to that for the specified standard.
F(unk/std) is the ratio of fluorescence corrections. The detection limit
is based on the weight percent value.

====== Plotting Phi(rho-Z) curves.

	This option requires the free plotting package GNUPLOT to provide a
plot, although you can still use this option to see the parameters
defining the shape of the curve (see example below).
If you do not have it you should obtain it by anonymous FTP from any of a large
number of sites around the world. Look for gnuplot* for source code, or
wgnupl* for DOS Windows 3.1 executables (or it might be wgpt* to avoid long
filenames); other executables may be available
as it has been ported to many operating systems (non-Windows versions are
also available for MS-DOS). It is not related to the GNU project and may or
may not be available in the same places.

	If you specify a density then the X-axis will be depth in micrometres,
otherwise the X-axis will be mass-depth.

Here is an example, where I generate the curve using Al2O3:
My command is:
	xmaqnt -r -A -pg
May input is:
	Al ka 2
	O ka 3
	{blank line}

The program runs and prints some data.
It also produces gnuplot command files for each element; the filename syntax
is {model}_{element}.gp so in this case we would get files named "pap_Al.gp"
and "pap_O.gp". The file pap_O.gp looks like this:

	rzfactor = 4.000000e+03
	Rm = 1.735992e-04
	Rc = 2.917518e-04
	Rx = 6.686397e-04
	a1 = -4.432025e+07
	b1 = 2.592308e+00
	a2 = 1.389420e+07
	chi=5.993151e+03
	set xrange [0:Rx*rzfactor]
	set xlabel "Depth (micrometres)"
	set ylabel "Phi(Rho-Z) - PaP"
	rz(x) = x / rzfactor
	papphi(x) = ( rz(x) < Rc ) ?  \
		a1 * ( rz(x) - Rm)**2 + b1  \
	 :	a2 * ( rz(x) - Rx ) ** 2
	papemphi(x) = papphi(x)*exp( -chi * rz(x) )
	plot papphi(x) title "generated",  \
		papemphi(x) title "emergent",  \
		papphi(x)-papemphi(x) title "absorbed"

To produce a plot, you run gnuplot and give the command "load 'pap_O.gp'".
The parameter names should be recognizable in terms of the original
publications defining the equations.
[ The '?' operator may need explaining to non-C programmers. Gnuplot
command language does not have an if-then-else construct except for the
"x = a ? b : c" syntax, which means
if ( a ) then x = b
         else x = c
In the example above it is used in the definition of the papphi function,
not just as a simple assignment.
I have tried to avoid variable name clashes between plot files for
different models, so you could do a series of commands like
	gnuplot > load "pap_O.gp"
	gnuplot > load "xpp_O.gp"
	gnuplot > plot papphi(x) title "P and P", xppphi(x) title "XPP"
To overlay and compare the curves generated by two (or more) models.
However because of name clashes you could not overlay two sets of curves
from the same correction model.

--------------- TESTING THE INSTALLATION -------------------

    1. Use the program VIEWXRAY to check the lines and edges as well as the
	MAC data.
    2. Check that there have been some sample standard files installed in
	directory XDD/stds/comps. If not then copy the sample stds
	composition files from examples/comps/*.
    3. Calculate stds factors... run
           xmaqnt -s al2o3
           xmaqnt -s quartz
    4. change current directory to examples (this is in the source distribution
	but not the MS-DOS binary zip files).
    There is a sample datafile "quantin" and two example output files
    "qout" and "qout.ox" which were obtained by running the program
    as specified below. The input data is arbitrary - resemblence to
    anything sensible is unintentional.
    Run the program with sample input datafile:
       xmaqnt quantin
    Compare the output with the file "qout".
    Then run it again, this time with Oxygen estimated by stoichiometry...
       xmaqnt -eos quantin
    Compare the output with the file "qout.ox".

------------------ Energy and MAC database sources ------------------------

The xray Lines and Edge database.

The program xmasterb in directory xwt reads Chuck Fiori's ascii EMMPDL
database file LINESMAS.TRS and converts to a binary format. You should obtain
the latest version and put a copy in the xwt directory. The binary datafile
which xmasterb will create is called xray2.dat (the number denotes the
revision number of the format).
If you wish to modify or add values in this database then you need to
edit the original ASCII source (LINESMAS.TRS), rerun xmasterb and
copy the new file XRAY2.DAT over the old one.

MAC database:

In directory mactbl you should have two executables: mactbld and editmac.
MACTBLD builds a MAC database file for one particular X-ray line for every
emitter element, for every absorber element. The initial database files
in XMAQDATA.ZIP contain the parameterised values from Heinrich 1986
where the line energy is less than 20keV and Heinrich 1964 where line energy
is greater than 20keV with selected modifications from Pouchou and Pichior.
The file is named "mac_n.dat" where 'n' is 0 for K alpha,
1 for L alpha, through to 5 for M beta.
Answer questions as asked when MACTBLD runs, in order to specify
which xray line to do. Specify -1 to make all data files (on a PC you may get
sick of waiting - on a HP700 it takes a few seconds!each). Then move the data
files to the XDD/data directory to make them accessible to the other
programs.

MAC database extensions:

To enter you own MAC values in particular cases run the program EDITMAC
which will ask you questions as you go along. There are several sets of data
files included here which contain input data for EDITMAC.
Those with names matching pap*.mac incorporate the recommended values of
Pouchou and Pichoir (from the Electron Probe Quantitation book);
those matching he_*.mac contain Henke and Ebisu values; while
those matching h_*.mac are Henke, Tanaka, et al.
Thus, file "pap_b_ka.mac" contain selected values for Boron K alpha in various
absorber elements from P and P. Run:
    editmac < pap_b_ka.mac
and repeat for any other data sets you wish to update. Only one value for any
given absorber and emitter is stored. Previous values are overwritten and lost.
NOTE: Editmac works directly on the data files in their official places as
defined by XRAY_DATA, and as used by all other programs. MACTBLD creates
files in the current directory - it does not touch the standard files.
You may specify an alternate MAC file by setting an environment variable
XRAY_MAC_PREFIX. Thus, if you say (on DOS):
set XRAY_MAC_PREFIX=HE
then all software would read/write data files HEMAC_n.DAT. You would need
to create these files youself; start by copying the basic MAC_n.DAT files.
The XRAY_MAC_PREFIX option should only be used for short term experiments, since
it can lead to confusion: precalculated standards data files may end up
with data using the wrong MACS. For long term use of more than one set of
MACs you should create an entire extra directory tree and use the XRAY_DATA
environment variable to select one or the other. you can just copy over
(or on Unix, you can link) the lines and edges database, and standards
compositions files.


-------------------- STANDARDS ----------------------------

Standards are a bit messy at the moment. Before they can be
used for an analysis you have to:
    1. define the composition (if not pure) (see description below for
        format of stds composition file - use any normal text editor)
    2. precalculate the std correction factors using the command
        xmaqnt [options] -s sio2               (e.g. for a defined std)
        or
        xmaqnt [options] -s pure        (for a pure std. )
	The precalculated stds factors will then be stored in files (in ASCII
	format) and become useable for full corrections. The files are shared by
	all users and are in locations described above with the directory
	structure.


Format of standard composition file:
Look at the examples given in examples/comps
The name of the file is how the standard is referenced in the software.
You should therefore choose an obvious name.
line 1, should begin with '#' and is followed by a verbose name for the
        std - say anything you like (80 chars max) (nothing is done
        with this name at the moment by any programs) but it must
        be present.
line 2, should contain the letters "atomic" if data input is in atomic ratios
        or "oxide" if the data expresses oxide wt percents,
        otherwise the data is interpreted as element weight percent
        You can also add the word "fraction", to express data as
        mass fraction, rather than percent.
line 3 to end of file, should specify an element, an X-ray line, and the
	concentration, in whatever units you specified.

---------------- CURRENT DEFICIENCIES -----------------------

1. The program should be able to calculate standards factors when they
   are required, and not require them to be done in advance.
2. The program should not need to be told an Xray line (this is a fault in
   the simplistic approach which I took to storing stds factors ahead of the
   time they are required).
3. The element valence for oxide calculations is assumed
   to be the default value, unless a modification is given in the command line,
   every time the file is read!
   There should perhaps be a way to specify valence in the input file.
   The use of xmaqnt.opt would be a partial solution.
4. It has not had enough use to find all the other problems.