%Jim... this is the Latex file for the TAURUS reduction manual.
%Could you extract it as filename TAURUS_RED.TEX, to be consistent
%with what I say in the intro ? It'd be preferable to leave the
% style (i.e. things like the title page) as is, since that fits 
% in with the other WHT manuals.
%
%I've noted a few areas where you'll need to expand slightly
%on what's in here. Search for the character string 'JIM'
%Also, could you check my equations ! They were done from 
%memory, in the early hours, in parallel with UES commisioning......
% 
% I've added a new first section on general principles. I've also
% suggested you add a new second section giving a software interview,
% covering general issues such as the need to sort data, the need
% to use I*2, the availability of NDPROGS etc. Can you
% expand these headings ?  I'd suggest that its worth adding an 
% appendix listing the NDPROGS routines. WHat do you think ?
%
% I may be able to work on this again when I get back to RGO in 
% second half of July. On the other hand, if you can finish it 
% off to your satisfaction, feel free to send it to STARLINK.


%+
%                   +------------------------------------+
%      La Palma     |     William Herschel Telescope     |   Royal Greenwich
%   Software Group  | Roque de los Muchachos Observatory |     Observatory
%                   +------------------------------------+
%
% File    : TAURUS_RED.TEX
%
% Author  : Jim Lewis, Steve Unger                  Date : 26-Jun-1991
%
% Purpose : TeX source file for the TAURUS data reduction manual
%
%-----------------------------------------------------------------------------*
%
\documentstyle[twoside,bezier]{article}
\parskip 10pt
\parindent 0pt
%
%============= Definition of {asyoulikeit} page style ======================*
%
% Jonathan Burch        This is the terse form  -  expanded, formatted,
%  20-Jan-1989          commented version in TEX$LATEX:ASYOULIKEIT.FULL
%
\catcode`\@=11\def\ps@asyoulikeit{\def\@oddhead{\hbox{}\lp@innerhead
\lp@headfill\lp@middlehead\lp@headfill\lp@outerhead}\def\@evenhead
{\hbox{}\lp@outerhead\lp@headfill\lp@middlehead\lp@headfill\lp@innerhead}
\def\@oddfoot{\hbox{}\lp@innerfoot\lp@footfill\lp@middlefoot\lp@footfill
\lp@outerfoot}\def\@evenfoot{\hbox{}\lp@outerfoot\lp@footfill\lp@middlefoot
\lp@footfill\lp@innerfoot}\def\sectionmark##1{}\def\subsectionmark##1{}}
\def\lp@innerhead{}\def\lp@middlehead{}\def\lp@outerhead{}\def\lp@innerfoot{}
\def\lp@middlefoot{ {\thepage} }\def\lp@outerfoot{}\def\lp@headfill{\hfil}
\def\lp@footfill{\hfil}\newcommand{\lp@linefill}{\leaders\hrule height 0.55ex
depth -0.5ex\hfill}\newcommand{\innerhead}[1]{\def\lp@innerhead{#1}}
\newcommand{\middlehead}[1]{\def\lp@middlehead{#1}}\newcommand{\outerhead}[1]
{\def\lp@outerhead{#1}}\newcommand{\innerfoot}[1]{\def\lp@innerfoot{#1}}
\newcommand{\middlefoot}[1]{\def\lp@middlefoot{#1}}\newcommand{\outerfoot}[1]
{\def\lp@outerfoot{#1}}\newcommand{\lineheadfill}{\def\lp@headfill
{\lp@linefill}}\newcommand{\linefootfill}{\def\lp@footfill{\lp@linefill}}
\newcommand{\blankheadfill}{\def\lp@headfill{\hfill}}\newcommand
{\blankfootfill}{\def\lp@footfill{\hfill}}\newcommand{\documentnumber}[1]
{\def\lp@docno{#1}\outerhead{\lp@docno}}\def\lp@docno{}\def\@maketitle
{\newpage\null\vskip -14ex\hbox{}\hfill\lp@docno\vskip 13ex\begin{center}
{\LARGE\@title\par}\vskip 1.5em{\large\lineskip .5em\begin{tabular}[t]{c}
\@author\end{tabular}\par}\vskip 1em{\large\@date}\end{center}\par\vskip 3em}
\def\abstract{\if@twocolumn\section*{Abstract}\else\small\begin{center}
{\bf Abstract\vspace{-.5em}\vspace{0pt}}\end{center}\quotation\fi}\def
\endabstract{\if@twocolumn\else\endquotation\fi}\ps@asyoulikeit\catcode`\@=12
%
%=========== End of {asyoulikeit} page style definition ====================*

%============= Definition of \WHTlogo control sequence =====================*
%
%   Roger Wood          This is the terse form  -  expanded, formatted,
%  20-Apr-1989          commented version in ???
%
\newcommand{\WHTlogo}[1]{         \setlength{\unitlength}{#1mm}
\begin{picture}(8,10)(-4,0.7)     \put(-0.4,10.4){\line(1,0){0.8}}
\put(-0.4,10.1){\line(0,1){0.3}}  \put(+0.4,10.1){\line(0,1){0.3}}
\put(-0.4,9.2){\line(0,1){0.6}}   \put(+0.4,9.2){\line(0,1){0.6}}
\put(-0.3,8.9){\line(1,0){0.6}}   \put(-1.6,10.1){\line(1,0){3.2}}
\put(-1.6,9.8){\line(1,0){3.2}}   \put(-1.4,6.2){\line(1,3){1.2}}
\put(+1.4,6.2){\line(-1,3){1.2}}  \put(-1.2,6.2){\line(1,3){1.2}}
\put(+1.2,6.2){\line(-1,3){1.2}}  \put(-1.4,6.2){\line(0,1){3.6}}
\put(+1.4,6.2){\line(0,1){3.6}}   \put(-1.6,4.6){\line(0,1){5.5}}
\put(+1.6,4.6){\line(0,1){5.5}}   \put(-1.5,4.4){\line(-1,3){0.1}}
\put(+2.5,4.4){\line(1,3){0.1}}   \put(-0.25,7.0){\line(1,0){0.5}}
\put(-0.25,6.2){\line(0,1){0.8}}  \put(+0.25,6.2){\line(0,1){0.8}}
\put(-1.6,6.2 ){\line(1,0){3.2}}  \put(0.0,5.77){\circle{0.6}}
\put(-0.75,5.35){\line(1,0){1.5}} \put(-0.95,5.35){\line(-1,0){0.65}}
\put(+0.95,5.35){\line(1,0){0.65}}\put(-0.0,4.6){\line(-1,1){1.6}}
\put(+0.0,4.6){\line(1,1){1.6}}   \put(-0.1,4.5){\line(-1,1){1.5}}
\put(+0.1,4.5){\line(1,1){1.5}}   \put(-0.1,4.5){\line(1,0){0.2}}
\put(-0.4,4.8){\line(-1,0){1.0}}  \put(+0.4,4.8){\line(1,0){1.0}}
\put(-0.2,4.8){\line(1,0){0.4}}   \put(-1.4,4.6){\line(0,1){0.2}}
\put(+1.4,4.6){\line(0,1){0.2}}   \put(-0.2,4.6){\line(-1,0){1.4}}
\put(+0.2,4.6){\line(1,0){1.4}}   \put(-1.5,4.2){\line(0,1){1.15}}
\put(+1.5,4.2){\line(0,1){1.15}}  \put(-1.5,4.2){\line(1,0){3.0}}
\put(-1.0,3.9){\line(0,1){0.3}}   \put(+1.0,3.9){\line(0,1){0.3}}
\put(-1.0,3.9){\line(1,0){2.0}}   \put(-1.6,6.1){\line(-1,0){0.5}}
\put(+1.6,6.1){\line(1,0){0.5}}   \put(-1.6,5.4){\line(-1,0){0.5}}
\put(+1.6,5.4){\line(1,0){0.5}}   \put(-2.1,5.2){\line(0,1){0.9}}
\put(+2.1,5.2){\line(0,1){0.9}}   \put(-2.2,5.7){\line(-1,0){1.5}}
\put(+2.2,5.7){\line(1,0){1.5}}   \put(-2.2,5.5){\line(-1,0){1.5}}
\put(+2.2,5.5){\line(1,0){1.5}}   \put(-3.5,5.2){\line(0,1){0.5}}
\put(+3.5,5.2){\line(0,1){0.5}}   \put(-2.4,5.2){\line(0,1){0.5}}
\put(+2.4,5.2){\line(0,1){0.5}}   \put(-1.8,5.2){\line(-1,0){1.9}}
\put(+1.8,5.2){\line(1,0){1.9}}   \put(-3.7,4.9){\line(0,1){0.3}}
\put(+3.7,4.9){\line(0,1){0.3}}   \put(-1.8,4.0){\line(0,1){1.4}}
\put(+1.8,4.0){\line(0,1){1.4}}   \put(-2.5,3.9){\line(-6,5){1.2}}
\put(+2.5,3.9){\line(6,5){1.2}}   \put(-0.9,2.2){\line(-1,2){0.9}}
\put(+0.9,2.2){\line(1,2){0.9}}   \put(-2.2,2.2){\line(1,0){4.4}}
\put(-2.2,2.1){\line(0,1){0.1}}   \put(+2.2,2.1){\line(0,1){0.1}}
\put(-2.2,2.1){\line(1,0){4.4}}   \put(-1.7,1.5){\line(-1,3){0.8}}
\put(+1.7,1.5){\line(1,3){0.8}}   \put(-1.7,1.5){\line(1,0){3.4}}
\put(-1.7,1.0){\line(0,1){0.5}}   \put(+1.7,1.0){\line(0,1){0.5}}
\put(-1.7,1.0){\line(1,0){3.4}}
\end{picture} }
%
%=========== End of \WHTlogo control sequence definition ===================*


% Page layout definitions to suit A4 paper

\setcounter{secnumdepth}{3}        \setcounter{tocdepth}{3}
\setlength{\topmargin}{0mm}
\setlength{\textwidth}{160mm}      \setlength{\textheight}{220mm}
\setlength{\oddsidemargin}{0mm}    \setlength{\evensidemargin}{0mm}
%
% Local definitions
% -----------------
\newcommand{\eg}{{\it e.g.}}    
\newcommand{\etc}{{\it etc.}}
\newcommand{\ie}{{\it i.e.}}
\newcommand{\qv}{{\it q.v.}}
\newcommand{\viz}{{\it viz.}}
\newcommand{\degs}[1]{$#1^\circ$}                       % Degrees symbol
\newcommand{\mins}[1]{$#1^{\scriptsize\prime}$}         % Minutes symbol
\newcommand{\secs}[1]{$#1^{\scriptsize\prime\prime}$}   % Seconds symbol
\newcommand{\key}[1]{\fbox{\sc#1}}                      % Box for keys
\newcommand{\?}{\_\hspace{0.115em}}                     % Proper spacing for 
                                                        %   underscore
\newcommand{\hid}{\mbox{$^{\dag}$}}
\newcommand{\tc}{\mbox{$^{*}$}}

%----- Display example text (#1) in typewriter font

\newcommand{\example}[1]{\\ \smallskip\hspace{1in}{\tt #1}\hfil\\
                            \smallskip\noindent}

%----- Enclose text (#2) in ruled box of given thickness (#1)

\def\boxit#1#2{\vbox{\hrule height #1pt\hbox{\vrule width #1pt\hskip 5pt
                   \vbox{\vskip 5pt #2 \vskip 5pt}\hskip 5pt
                   \vrule width #1pt}\hrule height #1pt}}

%----- Display boxed warning text (#1)

\def\warning#1{\bigskip
               \setbox1=\vbox{\tolerance=5000\parfillskip=0pt
               \hsize=3in\noindent#1}
               \centerline{\boxit{1.0}{\box1}}
               \bigskip}

%----- Definitions to aid display of help text 
%         (modelled on \item and \itemitem)

\def\helpindent#1{\setbox2=\hbox to\parindent{{\it #1}\hfil}
                  \indent\llap{\box2}\ignorespaces}
\def\helpitem{\parindent=70pt\par\hang\helpindent}
\def\helpitemitem{\parindent=70pt\par\indent \hangindent2\parindent \helpindent}

%----- Tables and footnotes to tables
%
\newcommand{\spacerA}{\rule{0mm}{4mm}}
\newcommand{\spacerB}{\rule[-2mm]{0mm}{5mm}}
\footnotesep=5mm
\renewcommand{\footnoterule}{{\small Notes:}}
%
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%
\begin{document}
% 
% Title page
% ----------
%
\middlefoot{ }                               % No page number on title page
\begin{center}

{\large Roque de los Muchachos Observatory }

\vspace{1.0in}

{\LARGE \bf William Herschel Telescope}

\vspace{0.3in}

{\Huge \bf TAURUS DATA AND}

\vspace{0.1in}

{\Huge \bf HOW TO REDUCE IT}

\vspace{0.5in}

{\large Version 1.0}

\vspace{0.1in}

{\large 1991 June 26}

\vspace{0.5in}

{\Large Jim Lewis and Steve Unger}


\vspace{0.7in}

\WHTlogo{4}

\vfill

\parbox{3.2in}{\parindent=0pt \parfillskip=0pt \scriptsize
    The Isaac Newton Group of telescopes on La~Palma is owned by the UK
    Science and Engineering Research Council and operated by the Royal
    Greenwich Observatory for the SERC in partnership with the Organisatie
    voor Zuiver Wetenschappelijk Onderzoek (ZWO) of the Netherlands, the
    Irish National Board for Science and Technology and the Dublin
    Institute for Advanced Studies.} 
%
\end{center}
%
\cleardoublepage

\innerhead{{\Large\bf TAURUS data reduction}}   % Running inner head for
                                                %   whole manual

% Contents
% --------

\outerhead{{\large\bf CONTENTS}}             % Outer head for contents
\pagenumbering{roman}                        % Lower case roman page numbers
\middlefoot{\thepage}                        % Contents page numbers centred

\tableofcontents    
% \listoffigures    
% \listoftables  
\cleardoublepage


% Main text
% ---------

\middlefoot{ } \outerfoot{{\bf\thepage}}     % Body of manual has bolded page
                                             % numbers at outer edges

\pagenumbering{arabic}                       % Arabic page numbers hereafter

\section{Introduction: scope of the manual and documentation}
\label{Intro}
\outerhead{{\large\bf INTRODUCTION}}
\subsection{Scope of the manual}

This manual describes the use of the TAURUS data reduction package, TAUCAL.
Section~\ref{Intro} gives an overview of the manual, and indicates
other sources of help. Section~\ref{Principles} provides an overview of
the theory of TAURUS data reduction, and 
section~\ref{Software overview} gives an overview of various
software issues. Section~\ref{Phase calibration} describes
the phase calibration software in detail, and 
section~\ref{Profile analysis} describes the software for
profile analysis (i.e. velocity field mapping). Programme
details are summarised in the appendices.

\subsection{Obtaining copies of this manual} 

This manual has been prepared using {\LaTeX}. A copy of the current
source is held on the La~Palma VAX 8300 in directory {\tt
[MANUALS.WHT\?TAURUS]}, along with its associated rasterized file,
    {\tt .DVI-CAN}. New copies of the manual may be printed out using: 
%
\begin{list}{$\bullet$}{\setlength{\itemsep}{-0.5mm}\setlength{\topsep}{0mm}}
 \item  {\tt WHT\?GLASE [MANUALS.WHT\?TAURUS]TAURUS\?RED.DVI-CAN} or
 \item  {\tt INT\?GLASE [MANUALS.WHT\?TAURUS]TAURUS\?RED.DVI-CAN},
\end{list}
%
(to give output on the laser-printers in the WHT and INT buildings,
respectively). A copy is also held on the STARLINK VAXcluster at 
RGO Cambridge, in
the directory {\tt CAVAD::DISK\$USER1:[MANUALS.WHT\?TAURUS]}.

\subsection{Getting help}

The present manual is designed to be the main reference for the
use of the TAURUS reduction package, TAUCAL. The operation of the
TAURUS intrument at the William Herschel Telescope is described 
in the {\it TAURUS Users Manual} by Steve Unger. More 
specialised advice on TAURUS data reduction can be obtained from 
Jim Lewis (author of software) or Steve Unger (TAURUS project
scientist).

\vfill
\eject


\section{General principles}
\label{Principles}
\outerhead{{\large\bf PRINCIPLES}}

This section describes the basic principles of TAURUS
reduction using  the TAUCAL package. 

It is assumed that the reader is familiar with the basic
principles of Fabry-Perot interferometry. If not,
it would be advisable to read some of the references listed
 in section~\ref{Refs}.

\subsection{Basic equations}

This section gives the basic equations describing the transmission
of a Fabry-Perot etalon when placed in TAURUS. The aim is to
set the formal background, before discussing the reduction
process.  See references in section~\ref{Refs} for a more
detailoed discussion of this background.

The transmission of a Fabry-Perot etalon is given by 
equation~\ref{eq:FPtrans}:

\begin{equation}
T \propto \frac{1}{1 + 
  \frac{4N^2}{\pi^2} sin^2 (\frac{2 \pi \mu G cos \theta}{\lambda})}
\label{eq:FPtrans}
\end{equation}
\hspace*{10pt} T is the transmision of the etalon \\
\hspace*{10pt} N is the etalon finesse \\
\hspace*{10pt}  $\mu$ is the refractive index of air \\
\hspace*{10pt}  G is the gap between the two etalon plates \\
\hspace*{10pt}  $\theta$ is the angle of incidence of light on the etalon \\
\hspace*{10pt}  $\lambda$  is the wavelength \\

The transmission peaks at wavelengths given by equation~\ref{eq:FPpeaks} 
(the condition for constructive interference) :

\begin{equation}
       n  \lambda = 2 \mu G cos \theta \\
       \label{eq:FPpeaks}
\end{equation}
\hspace*{10pt} n is an integer, the order of interference \\
\hspace*{10pt}  $\lambda$  is the wavelength \\
\hspace*{10pt}  $\mu$ is the refractive index of air \\
\hspace*{10pt}  G is the gap between the two etalon plates \\
\hspace*{10pt}  $\theta$ is the angle of incidence of light on the etalon \\

The wavelength separation between adjacent transmission maxima (i.e.
the separation between successive interference orders) is referred
to as the free spectral range. The on-axis ($\theta=0$) free
spectral range is given by equation~\ref{eq:FPfsr}:

\begin{equation}
       FSR = \lambda^2 / 2  \mu G = \lambda / n \\
       \label{eq:FPfsr}
\end{equation}
\hspace*{10pt} FSR is the free spectral range \\
\hspace*{10pt}  $\lambda$  is the wavelength \\
\hspace*{10pt}  $\mu$ is the refractive index of air \\
\hspace*{10pt} G is the gap between the two etalon plates \\
\hspace*{10pt} n is an integer, the order of interference 

The way in which Fabry-Perot etalons are used in TAURUS is described
in detail elsewhere (see section~\ref{Refs}). Briefly, light is 
first collimated, then passed through a Fabry-Perot
etalon placed in the pupil, and finally reimaged onto a detector.
Under these circumstances,
the value of $\theta$ corresponding to a particular image point 
on the detector is given by equation~\ref{eq:FPimage} (using
the small angle approximation for $\theta$):

\begin{equation}
       \theta =  R / F_{cam}  
       \label{eq:FPimage}
\end{equation}
\hspace*{10pt}  $\theta$ is the angle of incidence of light on the etalon \\
\hspace*{10pt} R is the distance of the image point from the point 
                               (x$_0$,y$_0$) \\
\hspace*{10pt} (x$_0$,y$_0$) are the coordinates of the optical axis 
                   on the detector \\
\hspace*{10pt} F$_{cam}$ is the camera focal length 

\subsection{The need for phase calibration}

In normal operation of TAURUS, the order of interference is fixed 
by the use of an order
sorting interference filter. Under these circumstances, it can be 
seen from equations~\ref{eq:FPpeaks} and \ref{eq:FPimage} that at any given 
point on the detector (i.e. for a particular value of $\theta$), 
the wavelength transmitted is directly proportional to the etalon gap.
By varying the etalon gap, it is possible to change the wavelength
transmitted.  We can therefore obtain a spectrum for any particular point 
in the field by scanning the etalon gap, and measuring how the 
transmitted intensity varies as a function of the gap.

Of course, the aim is to do much more than obtain 
a spectrum of one point in the field. The principal advantage 
of TAURUS as compared to a slit spectrograph is that it is possible
to obtain spectra simultaneously at every point covered by the 
detector, by taking a series of images, each with a different
value of the etalon gap. These images are stacked together to
form a datacube.

The problem with such a datacube is that the transmitted wavelength
is not just a function of etalon gap, but is also a function of position
on the detector. Thus the raw TAURUS datacube does 
not have separable spatial and spectral axes, as should be the case for a 
calibrated spectral line datacube. It is necessary to rebin the
datacube, applying a shift to each spectrum so that all spectra
have the same wavelength calibration. This shift is referred to as
the {\bf phase shift}, the magnitude of the phase shift as a function
of position in the image is referred to as the {\bf phase map},
and the process of determining the phase map and rebinning the
datacube is referred to as {\bf phase calibration}.

\subsection{Functional form of the phase map}

From equations~\ref{eq:FPpeaks}, \ref{eq:FPimage} and \ref{eq:FPfsr}
the surfaces of constant wavelength in a TAURUS 
cube are defined by equation~\ref{eq:FPconstl}:

\begin{equation}
        G = \frac{\lambda^2}{2 \mu FSR} sec ( \frac{R}{F_{cam} } )  
    \label{eq:FPconstl}
\end{equation}
\hspace*{10pt} G is the gap between the two etalon plates \\
\hspace*{10pt} $\lambda$ is the wavelength \\
\hspace*{10pt}  $\mu$ is the refractive index of air \\
\hspace*{10pt} FSR is the free spectral range \\
\hspace*{10pt} R is the distance of the image point from the point 
                               (x$_0$,y$_0$) \\
\hspace*{10pt} (x$_0$,y$_0$) are the coordinates of the optical axis 
                   on the detector \\
\hspace*{10pt} F$_{cam}$ is the camera focal length 

In practice, when we scan the etalon gap, the gap and
the free spectral range are not
expressed in the same units as the wavelength, but in 
'miroprocessor units' (see later). We define a constant 
$a$ such that $G_m=aG$ and $FSR_m=aFSR$, and can then rewrite
equation~\ref{eq:FPconstl} as equation~\ref{eq:FPconstlm}:

\begin{equation}
        G_m = \frac{\lambda^2}{2 \mu a^2 FSR_m} sec ( \frac{R}{F_{cam} } )  
    \label{eq:FPconstlm}
\end{equation}

For small values of R/F$_{cam}$, sec(R/F$_{cam}$) can be expanded
as a Taylor series to show that  the surfaces of constant wavelength 
are parabaloids of revolution.
However, the surfaces of constant wavelength in a spectral line 
datacube are its planes. Thus each spectrum needs to be shifted
by an amount given in microprocessor units by 
equation~\ref{eq:FPconstlm}. 

This shift is the {\bf theoretical phase map}. In practice the actual phase
map may also include a small contribution from a {\bf residual phase map},
in order to account for effects such as field or detector distortion.

\subsection{Determination of the phase map}

From equation~\ref{eq:FPconstlm} it can be seen that in order to 
derive the theoretical phase map we need to know the following 
parameters: 

\begin{itemize}

\item Wavelength. This is determined accurately enough for
     present purposes by the order-sorting filter used. The
     question of accurate wavelength calibration is discussed
     separately below.

\item Camera focal length. This is a known optical property of the 
      system.

\item Pixel size. For a geometrically stable detector such as a CCD
     this is also simple. However, detectors  such as the
    IPCS, which are not geometrically stable, are more difficult.
    The normal procedure is to observe a pinhole mask. This is
    an aperture mask in which a number of holes have been drilled,
    on a regular grid. If we illuminate this pinhole mask, and
    take an image, we produce a set of reseau marks on the detector.
    These can be used to determine the detector pixel size, and
    can even be used to determine the way in which the pixel
    size varies across the detector.

\item The free spectral range and constant $a$. This is the difficult
     bit, and the way in which these parameters are derived 
     is described below.

\end{itemize}

It should be apparent from equation~\ref{eq:FPconstlm} that if we just 
look at 
one plane of the datacube (i.e. $G_m=constant$),
then the wavelength is constant on a line defined
by $R=constant$. In other words, the wavelength is constant on 
a ring of radius R centred on the optical axis. Thus if we 
illuminate the field with a monochromatic light source (e.g.
an arc lamp, plus an interference filter to select one arc line)
and take an image, we will see a ring centred on the
optical axis.

In order to derive the free spectral range and constant $a$,
what we do is obtain a datacube, with TAURUS illuminated
by a monochromatic light source. We then fit a ring
pattern to the data in each plane of the datacube, in
order to determine the centre of the ring pattern (the
optical axis) and the ring radius. We then plot 
sec(R/F$_{cam}$) as a function of G$_m$. This plot
is referred to as the Radius-versus-Frame (RVF) plot.

What we should see in this plot is a family of straight 
parallel lines,
one line for each order of interference observed. We then 
determine the gradient and intercept on the G$_m$ axis of 
each line. The difference between the intercepts of adjacent
orders is equal to the free spectral range. We can then derive
the constant $a$ from the gradient of the lines, using
equation~\ref{eq:FPconstlm} 

We can now derive the theoretical phase map for any wavelength. 
In order to determine the residual phase map, we derive
the theoretical phase map for a calibration cube, and
determine the difference between the observed and theoretical
phase surface.

\subsection{Flexure and etalon drifts}

The theoretical phase map can change as a function of time
for two reasons. Firstly, if the optical axis shifts
as a result of flexure. Secondly, if the etalon gap drifts.

We correct for these effects by taking a series of 2D exposures
through the night at the same nominal gap setting. It is then
possible to fit a ring pattern to each image. Changes in
the optical axis appear as a shift in the centre of the ring
pattern, and changes in the gap appear as a change of the
ring radius. The reduction software is used to analyse
the variation of ring centre and radius with time,
referred to as the RVT relationship.

\subsection{Phase correction}

We can now determine the theoretical phase map for any specifed
wavelength, corrected for effects of flexure and etalon drift.
We then add in the residual phase map, and are now ready
to correct the data. 

The rebinning of the datacube essentially
involves sliding each spectrum along by an amount specified in the 
phase map. The process is somewhat complicated by the fact that
the spectra are actually cyclic.   

JIM.. could you expand here.


\subsection{Wavelength calibration}

JIM... could you explain how this works

\subsection{Further reading \label{Refs}}

JIM... there are two recent textbooks specifically about FP interferometers.
One is by Vaughan, the other is by Hernandez.
There is also an article by Keith Taylor in the book by Roberts called
'Indirect imaging'.  Could you dig out the details and add them,
cos I can't find them here.

\subsubsection{Theory of Fabry-Perot interferometers}

Meaburn, J., 1976. {Detection and spectrometry of faint light},
          publ. Reidel.  

Atherton, P., 1988. in {\it Instrumentation for ground-based optical
   astronomy}, ed. L.B.Robinson, publ. Springer-Verlag, p.124.  


\subsubsection{TAURUS 1}

Taylor, K \& Atherton, P.D., 1980. {\it Mon.Not.R.astr.Soc.},
      {\bf 191}, 675. 

Atherton et al., 1982. {\it Mon.Not.R.astr.Soc.}, {\bf 201}, 661.

\subsubsection{TAURUS 2}

Unger et al., 1990. {\it Mon.Not.R.astr.Soc.}, {\bf 242}, 242.

Unger, S.W., 1991. {\it TAURUS users manual}, publ. RGO.

\vfill
\eject

\section{Software overview}
\label{Software overview}
\outerhead{{\large\bf SOFTWARE OVERVIEW}}

This section considers a number of general points concerned with
TAURUS data reduction using the TAUCAL package.

\subsection{FIGARO}
Note that FIGARO is environment. Give references.

\subsection{NDPROGS}
A number of routines, produced at RGO, for analysis of cubes 
in FIGARO. Reference SUNs for more info.

\subsection{Quotas}
What quotas are needed to reduce TAURUS data ?
VIRTUALPAGECNT etc.

\subsection{Sorting cubes}
Efficient access implies need to sort cubes. Use NDPROGS transpose

\subsection{Datatypes}
When to use I2, when to use R4

\subsection{Magic values}
Are they supported ?

\subsection{TAUCAL files}
Describe the idea of these here


\vfill
\eject
\section{Phase calibration software}
\label{Phase calibration}
\outerhead{{\large\bf PHASE CALIBRATION}}

\subsection{Introduction}

In this document the calibration procedure has been broken down to
6 steps:
\begin{enumerate}
  \item {\bf Creating a `TAUCAL' file --}
        This is a bookkeeping device which can be terribly useful.
        Basically, it gets really tiresome having to type things
        like wavelength, collimator focal length, etc repeatedly, and
        using this system cuts down on that sort of rubbish quite
        a lot.  It's also useful as a notebook for results.  Quite
        frequently results from one program are needed in another and
        storing these results in one `notebook' is a lot
        easier than having all sorts of ASCII files floating around
        with various names which you can never remember.  One can
        run the software without one of these as the TAUCAL system is
        designed such that if it can't get a certain bit of info from
        the TAUCAL file (for one reason or another) then the FIGARO
        parameter system takes over and asks you for it.
  \item {\bf Creating a new pixel grid --}
        What this procedure does is to map out the detector distortions.
        It then creates a grid of `pixel numbers' which later
        programs use instead of the indices to the data array.
        e.g. for data point DATA(100,200)  X = 99.5,  Y = 200.04, instead
        of X = 100, Y = 200.  You need a pin hole mask for this. Again,
        you can run without this as the programs will just use the
        indices (answer 'no' when they ask you if you want to use a grid).
  \item {\bf Do the RVF analysis --}
        This is the procedure which is used to calculate the free spectral
        range, the etalon gap and the coordinates of the optical axis from
        the calibration cube.
  \item {\bf Do the RVT analysis --}
        What this does is to try and take account of changes in the phase
        map as a function of time.  `Time' here is a fuzzy term as
        sometimes the crucial factor is not time, but rather whether the
        telescope has been moved.  What you need for this is a series of
        single calibration rings (preferably one before and one after each
        observation).
        The radii and centres of these rings are compared with those of
        the one ring of the cal cube which was taken with the same etalon
        spacing as the single rings.  It is possible to cope without this.
  \item {\bf Create a residual phase map --}
        Although the taking the IPCS distortions into account in (2) should
        take out any residual phase, this is probably a good thing to do
        as at large radii, the rings in the cal cubes can become pretty
        wimpy and radius estimates become correspondingly worse. You can
        leave it out though if you want.
  \item {\bf Create a final phase map and phase correct --}
        This is the final step where the actual phase map for each cube
        is calculated and the cube is phase corrected. The data will then
        be ready for profile fitting.
\end{enumerate}


Having got all that out of the way, here is an explanation of  each program
in more detail.  They will be addressed in the context of the 6 categories
mentioned above.  If you are still lost after this `explanation' try looking
at the prologue of the source files by doing {\bf \$HELP $<$program$>$ SOURCE}
or leafing through appendix~\ref{app:prog}.
Throughout this section the assumption will be made that you are using a
TAUCAL file.  Not using one doesn't change the way the programs work, but
you may then have to answer an awful lot of questions.

\subsection{Create a TAUCAL File}

\begin{description}
  \item[CALBASIC]  This creates the basic TAUCAL file.  When you run the
                   program you'll
                   get menus for telescope setup, etalon used and detector used.
                   Just type the appropriate numbers when asked. If your setup
                   doesn't correspond to any of those offered, then the files
                   to update are  *.std where * is SETUPS, DETECTOR or ETALONS.
                   The parameter CALOUT will be the name of your TAUCAL file.

  \item[CALRUN]  This lets you input all the information necessary for each
                 structure.  Information about each structure is stored by
                 its run number.  There are four different run types:

                 \begin{itemize}
                    \item CAL -- Calibration cubes
                    \item RING -- Single rings (for RVT)
                    \item OBS -- Observation cubes
                    \item MASK -- Pinhole matrix masks.
                 \end{itemize}

                 The first thing for which you are asked is a run type. Since
                 you can
                 enter information about more than one structure at a time, it's
                 best that you do, say, all the obs cubes at once or all the
                 ring
                 frames at once (that way you can take advantage of the default
                 settings for, say, the wavelength).

                 Once you have given the run type, you are asked for the number
                 of structures of this type and their run numbers.  The
                 following information is then needed for each run:
\medskip

\begin{table}[htb]
\caption{Information Required for Each Run Type}
\begin{center}
\begin{tabular}{|l|l|} \hline
{\em Type} & {\em Info needed}\\ \hline
CAL                     &image name\\
                        &mpu0 (see below)\\
                        &dmpu (see below)\\
                        &wavelength\\ \hline
MASK                    &image name\\ \hline
RING                    &image name\\
                        &wavelength\\ \hline
OBS                     &image name\\
                        &mpu0 (see below)\\
                        &dmpu (see below)\\
                        &wavelength (redshifted)\\ \hline
\end{tabular}
\end{center}
\end{table}

\medskip

                 MPU0 and DMPU are the Z axis zeropoint and increment in
                 microprocessor units (such that the value for the
                 first frame is MPU0).  These are useful as there will come a
                 time when the frames are not equally spaced in
                 the spectral direction.  Note that the software doesn't cope
                 yet with unequal spacing, but will in the future.  Whenever
                 you examine results in the spectral direction it is important
                 to remember that they will almost always be
                 in MPUs. So if, for example you do a 2-d plot of the residual
                 phase map later on and discover that there are many pixels
                 with residuals of 5 or so, this isn't so bad if DMPU is 15,
                 say.  Next thing to remember is that all wavelengths are
                 expressed in microns as is the mask distance parameter.  As
                 a matter of fact, most if not all physical distances are
                 expressed in microns, even the camera focal length, etc.

                 If you are interested in what is in the TAUCAL file, you can, of course,
                 always find out by doing {\bf \$exam taucal...}

\end{description}

\subsection{Create a Pixel Grid}

\begin{description}

  \item[FINDPKS] This routine finds the pinhole peaks on the matrix mask frame.  It uses a
                thresholding criterion for locating them and this is, of course, never
                fool-proof.  (e.g. it may miss some or it may include ghost images, etc).
                So, if you opt to display the frame then you can use the cursor to include
                any which it has missed or zap any which it shouldn't have included.  This
                might become tedious, so one always has to option of just starting over and
                using a different threshold as it doesn't take very long anyway.

                If you do display the frame, then the cursor routine gives you 5 options:

                \begin{description}
                  \item[A:] Add a point
                  \item[Q:] Quit
                  \item[R:] Redraw the frame
                  \item[Z:] Zap a point
                  \item[?:] Help menu
                \end{description}

                When you add a point it should come up in red as an open circle.  If you zap
                a point it should come up as a filled circle.  Type `Q' when you're satisfied with
                it all.

  \item[PEAKDISP] If for some reason or another you want to see the peaks again (e.g. to check that
                you haven't included any ghosts) use this program.

  \item[TMASK] This routine does the 2-d polynomial fit to the peaks' positions.  From the number
             of peaks it tells you what the maximum order it's willing to fit is. It calculates
             a rough rotation and then does a proper fit.  The file MASK.OUT is interesting
             because it gives the pixel sizes in both directions and the pixel ellipticities all
             as a function of position.  It's useful to check to see if the pixel sizes are on the
             same track as what you would expect.

  \item[SIZES] If you really want to look at a map of pixel sizes, you can generate one using
             this program.  It asks for the size of the map you want and for the axis you
             want to see.  The output is a 2-d image which you can display with the NDPROGS
             routine DEPICT or whatever you want.

  \item[GRID] This actually creates the new pixel grid.  This grid can be of any size, although
             one should worry about extrapolating the fits, of course.  The reason this size
             flexibility has been included is because there are times when some cubes
             cover the whole detector and others in the same observing run are
             a subset.  Thus, this was intended to do subsetting.  Basically you are asked if the
             map is to be of a different size in X,Y from the matrix file and if so, what size in
             each direction.  You are then asked if the new grid is to have the same physical
             centre as the matrix file. If not, then it asks where you want to centre the new
             grid.
\end{description}

\subsection{Do the RVF Analysis} \label{sec-rvf}

\begin{description}

  \item[PRERING] This is the program which gives the ring fitting program (RINGS) the initial
              estimate of the ring parameters.  The first thing to do is to run the NDPROGS
              routine MOVIE on
              the CAL cube to find out where each series of rings begins and ends.  Basically
              what happens here is that you are asked to show where the ring is on the frame
              for 2 rings for each series.  The program fits a circle to the points you have
              indicated.  The program then extracts data along a radius from the centre of
              the circle through each of your indicated points.  The data are added together and
              averaged and a gaussian is fitted to it.  This gives a better estimate of the
              width.  Then the program writes out a file of what it thinks is a best guess for
              the parameters of each ring.  In doing so it uses the following rules:
\begin{displaymath}
                        R^2 = AZ + B
\end{displaymath}
              where Z is frame number and R is radius, and
\begin{displaymath}
                        R\sigma = \mbox{const}
\end{displaymath}
              where $\sigma$ is the width of the ring.
              To get a good guess at $A$ and $B$, one should make sure that the rings used in each series
              are a reasonable number of frames apart (say 5--10) if possible. Try to
              avoid rings with small radii as the small radius rings definitely look more
              Cauchy--like.

              When you are asked if the output is to be an RVF, answer `Y' as PRERING is also used
              for estimates for the RVT and the output files are slightly different.  NSER is the
              number of series of rings. (This is usually 2 but you can have more.  At the
              moment, the routine which calculates the FSR doesn't cope with series of different
              wavelengths, if, for example, your calibration source is a doublet.  So for the
              moment, use the rings of one particular wavelength and stick with it.)  When you're
              asked for SER\_NOS, you need to input 2 values which are basically the first frame of
              the series and the last frame of the series.  Obviously, if you have a frame where
              there is only a teeny part of a ring in one corner, it isn't worthwhile to try and
              fit it, so be judicious if you don't want to waste time.  FRAMES\_PROC  are the 2
              frames from each series which you will be using to define the parameters for that
              series.  If, for example, the first series spans frames 1 to 31, then try processing
              frames 1 and 10.  After asking you for the name of the output file, the program
              should then do a 2-d colour plot of the first ring.  You can indicate with the cursor
              up to 10 points on the ring.  Obviously the more the better as
              it's advantageous to make sure you indicate enough points around the ring to
              give the routine an idea of the curvature, otherwise the answer will be garbage.
              Hit the spacebar to identify a point. If you want to quit identifying points, type `Q'.
              The fitted circle should then appear on the plot.  The plot should then erase and
              a line plot of the profiles with a gaussian fit should appear.  This procedure repeats
              $2*\mbox{NSER}$ times.  It may sound a bit tedious, but in reality only takes about a minute.

  \item[CRE\_RV] The output file from PRERING is used as both the input and output from the ring
              fitting program (RINGS).  If you have somehow screwed up this file (e.g. deleted it,
              run RINGS with the wrong parameters, etc.), it is possible to recover all of the
              info from PRERING (if you are using a TAUCAL file), by using this program.

  \item[RINGS] This is the program which does the actual ring fitting.  It's fairly uncomplicated
              in the way that it works. If the ring frames are fairly
              large, quite a bit of the information is somewhat redundant.  So if you want your
              answers more quickly, then the parameter COMP\_FAC may be of some help.  This governs
              what fraction of the pixels which the program actually takes into account.  e.g.
              if $\mbox{COMP\_FAC}=2$ then every second row and every second column is used or every
              FOURTH pixel.  One should be fairly careful here though as the rings
              with large radii are fairly thin and if one is cutting out a large percentage of
              the pixels, it may be that you don't give the program enough to go on.
              TOLCENT and TOLRAD are what you consider to be a threshold of pain
              for the errors in the position of the centre $(X_c,Y_c)$ and the radius $R$.  If the
              error is greater than these tolerances, then the fit is flagged as bad.   WEIGHT
              is a flag for the weighting scheme you want to use.  At present there are $\sqrt n$,
              or equal weights available.  You are asked whether you want to use a grid as
              described in the previous section.  RESTRICT allows you to restrict
              the area to be used in fitting to a certain number of sigma around the ring.
              This is useful if you have multiple rings on a frame.  Running this program in batch
              may be a good thing especially for large frames where $\mbox{COMP\_FAC}=1$ and
              $\mbox{RESTRICT}=\mbox{`N'}$.

  \item[PRINT\_RV] This is a program to take your RVF or RVT file and make an ASCII copy of it.
               The resulting file is {\em file}.OUT where {\em file} is the name of our RVF or RVT.
               This is useful in case you think you've got something wrong, either with
               PRERING or RINGS.

  \item[EXAM\_RVF] This is the program which takes the RVF file from RINGS and calculates the
               FSR, the gap and the mean centre of the rings.  Note that you MUST have access to
               some sort of soft graphics device for this program. The only parameter which
               may need some comment is SAME\_SLOPE.  What this does is allows you to
               constrain all the slopes to be the same.  This is useful if you have one
               good series and one bad one (for whatever reason).  If you answer `Y' to
               this, then you will have to nominate one of the series to be the `fiducial'
               (i.e. `good') one.  The rest is straight forward.  On the graph, you will get
               points plotted either as open or filled circles.  Hollow circles are the rings
               which fit properly in RINGS and filled ones are ones which either didn't fit
               well or you skipped when you nominated the endpoints for each series in PRERING.
               Occasionally one will appear as an X, which means that RINGS thought the fit
               was bad, but not too bad; those rings will get half weight.  All series which
               you mark out in the current version of this program must be of the same
               wavelength. N.B. {\em the program expects you to mark out the series from left to
               right}.  For example, the left-most series is series \#1. If you use a
               fiducial series then you will be asked to mark that one out first.  Each
               succeeding series should then be done starting from the left most series.
               Note that the fiducial series is only to be marked once. When you are asked
               to mark the endpoint of each series with the cursor you have three cursor options:

\begin{description}
                 \item[Q:] Quit marking out series
                 \item[S:] Skip the current series
                 \item[Anything else:] Mark the series endpoint at that point.
\end{description}

               You can easily
               skip ones on the ends which have a dodgy fit by just skipping over when indicating
               the series endpoints.  Don't worry if there appears to be a dodgy fit somewhere in the
               midst of a lot of good ones -- you can always delete it later.
               You are then asked if you want to fit both the full and half-weighted
               points or just the full weighted ones.  A fitted line should appear.  If you then
               want to delete any of the interior points or change the weight of a point, you
               can.  You will then have the following options:

\begin{description}
                 \item[F:] Full weight a point
                 \item[H:] Half weight a point
                 \item[Q:] Quit editing the fit
                 \item[R:] Redraw the plot
                 \item[Z:] Zero weight a point
                 \item[?:] Print up a help message
\end{description}

               You basically need to repeat the procedure of indicating series and editing
               fits until you have fit all the series you want.  Note that you need at least
               two series to calculate both the FSR and the gap.  If however you only have one
               series in your data, but you have a good indication of the FSR from elsewhere,
               the program will then ask you for this estimate and it will give you an
               estimate of the gap. $X_c$ and $Y_c$ are calculated as the mean centre of
               all of the rings used in this program. Note that the FSR is in MPUs
               as are the regression coefficients.

\end{description}

\subsection{Do the RVT Analysis}

\begin{description}
  \item[PRERING] One uses this program pretty much as you did before with a few of exceptions.
               First, when it asks if the output is to be an RVF answer `N'.  If you are using
               a TAUCAL file, it will tell you how many ring frames are available for fitting
               and ask if you want to use them all.  If you don't want to use them all, it
               prompts you for the rings to be used.  If you are not using a TAUCAL file, then
               you are asked to supply the names of each of the individual ring structures.
               In one way or another you will also need to supply the program with a frame from
               the CAL cube.  This frame should be the one which was taken at the same
               etalon spacing as the single rings (as is given from the microprocessor coordinates).
               A 2-d plot of the first ring will appear, you will be requested to indicate
               points on the ring and you will get the profile fit as before.  For the rest of the
               rings, the program takes the first estimate of the ring centre and extracts
               profiles from the other rings along the radial paths between that centre and the
               points you indicated on the 2-d plot.  You should then get a series of line plots
               with profile fits for each of the rest of the rings in the RVT.

  \item[RINGS] Again, you use this in a very similar way as before.  When it asks if this is
               to be an RVF then answer `N'.  The program will open the
               series of ring files and will do all the fits at once.

\end{description}

\subsection{Create Residual Phase Map} \label{sec-resid}

\begin{description}

  \item[EXAM\_RVT] This program calculates offsets in $X_c, Y_c$ and$Z$ which may be
               due to drift over time or from slewing of the telescope.  You have a choice of 4 estimation
               methods.
      \begin{itemize}
           \item Use the X,Y,R from the ring taken just before the OBS cube
           \item Use the X,Y,R from the ring taken just after the OBS cube
           \item Use an average of these from the two adjacent rings
           \item Use an interpolation between the two.
      \end{itemize}
               Which one of these you choose is up to you.  The plots you get are all self-explanatory.
               It may seem a little silly to you to do this for the CAL cube, which is what is
               being suggested here.  After all, $\delta R$ will equal 0 and hence so will $\delta z$.
               However the $X_c$ and $Y_c$ for the CAL cube ring used for comparison {\em may}
               (and in general {\em will}) not be the same as the average for the whole cube and
               thus the values of $\delta x$ and $\delta y$ may make the residual phase map more valid.

 \item[RESIDUAL] This program takes the FSR, gap and regression coefficients from EXAM\_RVF and
               predicts where the emission line should occur in the CAL cube as a function
               of $(x,y)$ position.  It then does a moments analysis and calculates the residual.
               The only parameters likely to confuse are: WINDOW which is a window in the
               spectral direction over which to search for the line. This helps to avoid
               noise spikes and brighter lines in the case of multiple rings. A reasonable
               value here is 3. SMOOTH\_SIZE is a smoothing box in the x,y plane, and really
               helps out in the larger radius pixels where the rings start getting very weak.
               It's usually a good idea to examine the output map on a 2-d plot, remembering
               that the result will be in MPUs!
\end{description}

\subsection{Create the Phase Map and Phase Correct}

               (***Note that phase correcting the CAL cube is a good way to check that
               you've got all this right. Thus from here on out the term `OBS cube' can
               also refer to the CAL cube.***)

\begin{description}

  \item[EXAM\_RVT] This program calculates offsets in $X_c, Y_c$ and$Z$ which may be
               due to drift over time or from slewing of the telescope.  See
               section~\ref{sec-resid} for more information.

  \item[LAMDA] This program does the wavelength scaling of the OBS cube.  Actually you can do
            it for a number of OBS cubes at a time.  The information which appears on the screen
            is very useful and most of the important bits are stored away in the TAUCAL file,
            if you are using one.

  \item[PHASE\_MAP] This program calculates the `phase map', that is a map which tells the
                phase correction program how many MPUs (pixels) to shift each spectrum (in
                the negative direction) so that the desired wavelength appears at the
                central spectral pixel. It doesn't ask any difficult questions.

  \item[CORRECT] Note that before you can use this program, the OBS cube MUST by ZXY sorted,
              (i.e. the spectral axis must be the first axis of the data cube-- the NDPROGS
              routine TRANSPOSE is useful for this).
              As a result of this, the program asks you for the name of the file rather
              than reading it straight from your TAUCAL file.  This is the program which
              does the actual phase correction.  You are given the choice to do either a
              linear interpolation or a sinc interpolation. This choice of interpolation scheme
              can be problematic.  For certain shifts near about
              0.5 the sinc interpolation weights go roughly like so:  -0.1 0.6 0.55 -0.05, or something similar.
              As you can see, they all add up to 1 which is right, but something funny
              happens if you use INTEGER*2 data.  If you consider the following program:
\begin{verbatim}

      program test
      integer*2 data_old(10),data_new(10)
      real blah,w(5)
      data data_old /0,0,0,0,1,0,0,0,0,0/
      w(1) = 0.0
      w(2) = -0.11
      w(3) = 0.56
      w(4) = 0.69
      w(5) = -0.14
      do j = 3,8
         blah = 0.0
         do i = 1,5
            blah = blah + float(data_old(j+i-3))*w(i)
         end do
         data_new(j) = nint(blah)
         write(6,*) blah
      end do
      end

\end{verbatim}
              The weights here are the sinc function weights for a shift of 0.55.  If you run this
              program, you'll find that `blah' becomes:-0.14,0.69,0.56,-0.11,0,0.
              Hence data\_new(3:8) become 0,1,1,0,0,0.  In other words, it doesn't conserve
              flux.  What happens in this case is if you use the sinc interpolation like
              this on INTEGER*2 data and then you collapse the resulting cube in the spectral
              direction, you see a ring pattern in the background which corresponds to the
              places in the phase map where the fractional shift is near 0.5.  This obviously
              isn't a problem for real data.  Note also that if the data are converted to integer
              by doing `int' as opposed to `nint', you still wouldn't conserve flux as then
              data\_new(3:8) would become 0,0,0,0,0,0.  Hence for INTEGER*2 data it is recommended
              that you use the linear interpolation scheme, rather than the sinc interpolation.
              If this bothers you, then convert your INTEGER*2 data to FLOAT using the NDPROGS routine
              TYPECON.  For real data, it doesn't matter which you use.

              The rest of the parameters are all easy and the output file will also be
              ZXY sorted.  By the end of this step you should have a phase calibrated cube
              which is ready for profile fitting.
\end{description}

\vfill
\eject
\section{Profile analysis}
\label{Profile analysis}
\outerhead{{\large\bf PROFILE ANALYSIS}}



\subsection{Introduction}

In order to get some science out of this enormous calibrated cube you
now have, it will be necessary to do some sort of analysis of the individual
profiles.  This can be accomplished in a number of different ways:

\begin{description}
  \item[Moments analysis --] This is probably the quickest
   way to get the results you want. It has the advantage 
   over profile fitting of being a relatively objective 
   way of parameterising the data.

   However, there are major disadvantages. Unless your spectra 
   are noise free, you will always get a 
   somewhat biassed result from a moments analysis. The results can
   also be very noisy if the threshold is not set correctly.
   Still, for very high signal/noise data, this may not be a problem,  
   and moments analysis can
   be a useful way of getting a quick first look at the velocity field.
   If this is the
   route you wish to take, then the NDPROGS routine MOMENTS is the program for
   you.

  \item[Cross correlation --] This has the advantage of using all of the 
   information in each spectrum.  It is therefore a good way of
   getting the velocity field when a large number of lines are
   present. It is reasonably objective, though there may be a 
   problem defining a sensible template spectrum to cross-correlate
   with.

   It is, however, very time consuming and in the long run
   something like a profile fit has to be done in order to measure the
   peak of the cross correlation function.  This method also has the
   disadvantage that at the time of writing this document, no routine
   to do this exists.  You could always write your own...

  \item[Profile fitting --] The time taken to analyse a datacube
   using profile-fitting depends upon how fancy you want 
   to get with your fitting
   function.  There are times when several components can be seen in the data
   and in this case a multi-component profile fit is the only way to
   extract the data. This can be rather time-consuming. There are
   also cases where the line profile is too complex to be modelled
   in terms of any simple set of parameters.

   However, for the reasonably simple spectra that one is most likely to
   encounter with TAURUS data, a fast and efficient routine (TAU\_FITS) has
   been developed.  The use of this program is the subject of the rest of
   this section.
\end{description}

\subsection{Introduction to TAU\_FITS} \label{sec-linefits}
\subsubsection{Preparation of the Input File}

Before you start doing any line fitting there are one or two things you
might consider doing to your calibrated cube.  First of all, there are a
number of things which TAU\_FITS needs to know.  These include the free
spectral range, the wavelength zeropoint and increment etc.  TAU\_FITS
will either read these from the header of your cube or will ask you for
them directly. If you want to avoid being asked for this sort of
information all the time and you think it would be a good idea to have
this sort of information in the header of your cube (which it is, for
general reference), then the program TAU\_HEAD is very useful.  If you
have used a TAUCAL file, then it just takes the information straight
from there and places it in the header of the cube.  If you haven't
you'll be prompted for the information. A substructure called {\em file}.MORE.TAURUS
is created with all the information.

TAU\_FITS also maps input files as REAL.  What this means is that if you
use an INTEGER*2 cube as input, then TAU\_FITS has to spend quite a bit of
time converting the data internally before any fits can be done.  This was
done quite deliberately as trying to fit to integer data will not yield great
results owing to rounding errors.  Thus converting your cube to REAL (using
the NDPROGS routine TYPECON) will save a lot of time in the long run.  Doing
a gentle smooth on the data will not only help the signal/noise, but will also
smooth away those nasty round off errors which you got from CORRECT if you
insisted on INTEGER*2 output.  The NDPROGS routine SMOOTH allows you
to smooth data in up to 3 dimensions using a number of different smoothing
functions.  The run time depends on the size of the smoothing function (e.g.
the $\sigma$ of a gaussian) and can be rather slow for large widths.  It's
probably best, therefore to run this in batch overnight.

\subsubsection{The Main Menu} \label{sec:main}

When you first enter TAU\_FITS you will be asked for a number of things,
none of which is particularly difficult to understand.  You will then get
a message which tells you what the default parameters are currently and
a prompt for an option.  If you type `H' then you get the help message
which explains all of the options available in the main menu.  Before
the guts of the program are explained, it will probably be worthwhile
to explain some of the logic behind the program.

TAU\_FITS tries its best not to carry around more data than is absolutely
necessary.  This is based on the problem of finding enough page file for
the large bits of workspace needed to do fits on such a large number of
spectra as you usually get from TAURUS.  Hence, any `action' taken on
the cube has to be `limited', e.g. you have to tell the program which
region of x,y space you want to consider when taking a certain action,
whether it be fitting some spectra, editing some fits or what ever.
It is possible to limit the region in three ways:
\begin{enumerate}
  \item Give the program limits in x,y over which the action is to
        occur.
  \item Give the program a mask image and thresholds between which
        the action is to occur.
  \item A combination of (1) and (2).
\end{enumerate}
It is important to remember to do this, since if you forget, the
program may end up converting, binning, etc a lot of data which either
you don't want or for which your particular VAX may not have the page
file space (the latter of which, of course, will cause the program
a major upset).

That warning now over, the first two options to be looked at are
MASK and LIMITS.  Note that all options in TAU\_FITS can be
abbreviated to a single character.  MASK basically sets a flag
which tells the program that you want to use a mask image.  It
doesn't actually ask for the name of the image or the thresholds.
LIMITS actually sets the limits on the spectra to be used.
If the mask flag has been set, it will first ask for a MASK image
and for some threshold values.  Note that the MASK image must have
the same x,y dimensions as the cube!  Next, LIMITS asks for the
minimum and maximum values of x and y which you want to consider.
Once you have input these, then limits decides which spectra will be
used.  To be included, the spectra must meet the following
criteria:
\begin{displaymath}
x_{min} \leq x \leq x_{max},\; y_{min} \leq y \leq y_{max}
\end{displaymath}
and given that a MASK image is being used:
\begin{displaymath}
m_{min} \leq m(x,y) \leq m_{max}
\end{displaymath}
where $m(x,y)$ is the value of the mask image at $(x,y)$.
If you suddenly decide that you don't want to use a MASK anymore,
you can just run the MASK option again and switch it off.  However,
you then must remember to run LIMITS again.

The next option which you may find useful is PICTURE.  This does
a 2-d colour plot of an image.  Thus, you may have a compacted image
of your cube (a 2-d image created by crushing your data cube in
the spectral direction -- very useful!  The NDPROGS routine COLLAPSE
will do this for you.) which you want to display.  PICTURE asks you
for the name of the file, the look up table (LUT) you want and for the min and max
for the colour plot.  If you run PICTURE for a second time, then
you will be asked if you want to plot the same file as before.
This cuts down on the amount of time you have to spend opening and closing
files, which can become pretty boring at the best of times.
The real beauty of PICTURE is that you can use it to help you
set the $(x,y)$ limits.  If TAU\_FITS sees that you have a picture displayed
when you enter LIMITS, then it will give you the option to indicate
the $(x,y)$ limits with the cursor.  This can be very useful as it isn't often
that someone knows off the top of his/her head where the object is
located on an image!  Other uses for the picture will become apparent
as time goes by.

If you have low s/n spectra you may want to bin the data.  In this case
the option BOXSIZE is useful.  This defines the size of the binning box
you want to use.  Note that the box is always square.

TAU\_FITS uses a $\chi^2$ criterion to define when a fit has converged.
Basically the fit is said to have converged when $\chi^2$ decreases by
a `trivial' fraction $n$ times, where the definition of `trivial' and
$n$ are given by the user.  In practice very small fractional changes in $\chi^2$
are never very meaningful, so you won't gain much by setting the threshold
too low and you may slow things down considerably.
The parameter which defines this threshold is called DCHI and
is the definition of a `trivial' {\em fractional} change in $\chi^2$.
Something like 0.05 is of the right order.  The parameter NTRIV tells the
program how many times $\chi^2$ has to change by DCHI in order for the
fit to have converged.  A value of 2 or 3 is usually sufficient -- you
will not gain much by asking for anything more strict.  Finally, you must
tell TAU\_FITS what is the maximum number of iterations you are willing to
do on a given spectrum (30 or 40 usually suffices).  These parameters are
set using the option CONVERGE.

The option TYPE tells you what fitting functions can be used on the spectra.
At the time of writing of this document there are only two choices: a single
Gaussian or a single Cauchy function.  Both of these assume a constant background.

Again at the time of writing, TAU\_FITS doesn't deal with error arrays within
the data cube.  So you have to tell it how to weight the data in the fit.  At
present there are two options: equal weights or $\sqrt n$ weights.  This is set using
the option WEIGHTS.

In order to get a fit in a reasonable amount of time, TAU\_FITS needs a
first guess at the fit parameters.  It currently gets this in a number of
ways.  The first way is to search for the peak and do a moments analysis
about it.  The second way is just to use an old result (in the case that maybe you want
to refine some fits) for that pixel.  A third way is to show TAU\_FITS
with a cursor where the line is.  There are two versions of this guessing algorithm.
The slow version asks you also to indicate the background level in the spectrum.  This
method will be discussed in more detail later on.  It is not advisable to use this
method if you have a lot of spectra to fit, for reasons of dull tedium.  Finally
one can estimate the fit parameters for one spectrum by using the fit parameters
of a nearby spectrum.  This option is not available in the main menu and will
be discussed later.  The option GUESS is used to decide which guessing algorithm
is appropriate.

It is worth noting that TAU\_FITS doesn't explicitly ask you for these values
unless it can't find anything worthwhile in your VARS.DST file.  If you have run
TAU\_FITS once, then your VARS.DST file will retain the last values for all of
the parameters described above.  Thus, the next time you run it, TAU\_FITS
will pick up the values for the options: TYPE, WEIGHTS, GUESS, BOXSIZE and CONVERGE.
Just before you are asked for the first option you will be presented with a list
of these set up parameters.  If you then wish to change any of these, you may do so.
If at some stage you can't remember what you have used for any of these parameters,
then the option INFO will put this same list one the screen again.

Finally the option FIT will do the actual fitting of the spectra.  This option gives
you a running commentary on how many spectra have been fit out of the total.  If it seems to take a long time
to do the first hundred, then it is worth remembering that before the fitting routine
actually starts, a routine is called which actually transfers and bins the data into a
workspace, which can take a significant amount of time, depending upon how may spectra
you've asked for in LIMITS and the binning box size.  Once this is done, however, the
fitting is quite rapid.

The option QUIT gets you out of TAU\_FITS completely.

\subsubsection{Edit mode}

Once you have done some fits, it is worth looking at the results to see if they
make any sense at all.  This may seem tedious, but is worth it in the long run.
(It's also a bit stupid to do a fit and not check it, as even the most sophisticated
fitting algorithms are capable of turning out rubbish at times, and human eyes are
far better at detecting this than even the most neural program...) Once you have received the prompt
in the main menu, you can then edit the fits with the command EDIT.  A few things are
worth remembering about EDIT before you get started.
\begin{enumerate}
   \item You MUST have access to a graphics device to use EDIT.
   \item EDIT will only edit the spectra which have been defined by LIMITS.  If you
   only want to look a subset of the spectra you have fit, then use LIMITS again.
   \item If you change the limits before running EDIT, then the data will have to be
   prepared over again.  Thus there may be a delay before you get the first panel of
   spectra.
   \item Once the data have been prepared, you will be asked for the number of plots
   to be done on a side.  This number squared will be the maximum number of plots on
   a given panel.
   \item Each spectrum will be plotted up in turn starting with the lower left hand
   corner of the box defined in LIMITS.  The fits which have been done will be overlaid
   in green.  There may be instances where you get less than the maximum number of plots
   on a panel.  This is because the total number of spectra on a side of the box defined
   by LIMITS may not be divisible evenly by the number of spectra on the side of a plot
   panel.
   \item If you have used a mask image, then even though a pixel may be within the $(x,y)$
   bounds defined by LIMITS, it may not be within the mask thresholds which you have
   defined.  Those spectra will be plotted as an empty box.
\end{enumerate}

Once you are in EDIT mode the command HELP will give you the list of commands available.
(Again all commands here can be abbreviated to one character.)  The first thing you'll
notice is that there are a number of commands in EDIT mode which are the same as ones
which have been described in the main menu (in some cases they are not {\em exactly}
the same, but these cases should become obvious).  These are CONVERGE, FIT, GUESS, HELP,
INFO, QUIT and TYPE.  The commands SHOW and ZAP are also very similar to those in the
main menu and will be discussed in due course.  You can indicate which spectrum you want
to take action on with the cursor and indicate which action by typing the appropriate
letter.  (If you type a letter which has no corresponding command, then nothing happens.)

If a spectrum has a bad fit, or if it doesn't have much of a line and the program has
attempted to fit something to it, then you can get rid of the fit with the option
ZAP.  This should erase the fit.  (Unfortunately this sometimes also erases part of
the spectrum, so if you really get confused, the option REDRAW will redraw the current
panel).  One thing to remember about ZAP is that once something have been ZAPped, it
can't be unZAPped without refitting. If you hate all of the spectra on the
current panel then the command WIPE will get rid of all of the fits on that panel and
will redraw that panel without the fits.

The command SHOW prints up the fit parameters for the indicated spectrum.
This will be in the order: peak, $\lambda_o$, $\sigma$, background, where the peak is
defined as the intensity {\em over} the background.  The error estimates for each
parameter will be printed underneath.

The GUESS command is exactly the same as before with one exception.  You now have
a fifth option which allows you to give the fit parameters of one spectrum as the
first guess for another.

The command FIT will attempt to fit the spectrum which is indicated by the cursor.
If you have chosen the moments or the previous results guessing algorithm, then the
fit which it has found should appear straight away (assuming it's found one!).  If you
have chosen either of the two `guess by hand' algorithms, you will be prompted to
indicate various locations on the spectrum.  To indicate a point, use the space
bar and the cursor. In the slow version, you can indicate
up to 10 continuum points. (If you wish to indicate less then either type `Q' or
indicate a point outside the box -- but you {\em must} indicate at least one!)
You are then requested to indicate one point on either side of the base of the line and
finally one point at the peak.  In the fast version, you are only requested to indicate
the sides of the line and the peak; it assumes that continuum is at the same level as
the base of the line.  If you choose the option to use the parameters of another fit as the
first guess at the fit for the indicated spectrum, then you will be asked to indicate another
spectrum on the panel whose fit can be used as a template.  If you suddenly discover that
you don't have any good fits on that panel, then type `Q' and choose another guessing
algorithm.

The command NEXT will then advance you to the next panel of spectra.  The command PREVIOUS
will move you to the previous panel.  If you have decided to
quit editing then use the command QUIT.  You will be asked if you are serious about quitting.
This is to help overcome typing `Q' by mistake.  If you answer YES, then you are returned
to the main menu.  As you are editing, the coordinates of the
spectrum on the lower left hand side of the panel will be displayed on the screen.  These may
prove useful for setting limits for another editing session.

\subsubsection{Nearest Neighbour Fitting}

In the main menu, there is an alternative mode of fitting spectra from FIT.  This is the
option NEIGHBOUR.  This mode sweeps through the region defined by limits looking for
pixels which have a neighbour with a good fit.  If a pixel does have a neighbour with
a good fit (`neighbour' is defined as a pixel which touches another pixel either on a
side or at the corner), then that neighbour's fit is used as the first guess for that
pixel's fit.  This has the advantage that the results tend to reflect the smooth nature of the
velocity fields of most astronomical objects. The user tells the program the maximum
number of sweeps to be taken through
the region.  (If all of the spectra which can be fit are fit in fewer sweeps than this maximum
then the fitting routine stops, obviously).  The user also gives the program limits in
the parameters.  Outside these limits, the fit is judged to be unphysical.  This is important
as, if an unphysical solution is found for one pixel, then it can propagate across the field
becoming more and more ridiculous.

To use this routine, there must be some pixels with good fits (e.g. seed points).
This can be done either with FIT or with EDIT, although the latter is favoured as one can then
see that the fit is not spurious straight away.  To do this one could adopt the following
method:
\begin{enumerate}
  \item Do a 2-d plot of the field using PICTURE and decide from that what is the region
  you ultimately want to fit.
  \item Use LIMITS to delimit a small (circa 50 spectra) region where you think you'll find
  good spectra.
  \item Use EDIT and fit a few of these.
  \item Do another 2-d plot.
  \item Go back to (2).  Do this until you think you have a representative sample across
  the object.
  \item Use LIMITS (and MASK if you want) to define the whole region to be fit ultimately.
  \item Use NEIGHBOUR.
\end{enumerate}
If NEIGHBOUR sees that you have a 2-d plot on the screen, then it will overlay a point
on pixels where it has tried to do fits, so you can monitor your progress.  It also
gives you a news report on each sweep.  Again, it may take a while before you get your
first news report as the routine which prepares and bins the data has to be called before
the fitting gets done.

\subsubsection{`Cleaning' Velocity Maps}

At some stage you might think it wise to actually get some velocity information
out of your fits. The trouble is that the wrap around inherent in TAURUS
data sometimes causes a line to appear twice on a spectrum.  If one is using
some sort of guessing algorithm which gets its initial guess for
$\lambda_o$ from the maximum in the spectrum (as the moments algorithm
does) then the velocity you get for a particular pixel may in fact be a
free spectral range out from the expected velocity.  Judicious guessing in
the initial stages of a NEIGHBOUR analysis will probably eliminate most of
the problems of this kind. But problems may occur if, for example, you fit
a large number of spectra in EDIT mode using the moments guessing
algorithm.  In this case, if two lines appear on the spectrum, then that
guessing algorithm will always choose the stronger line.

To get around this problem, there is the option VELOCITY.  You {\em MUST}
have access to a 2-d display to use this option! If you already
have a velocity map (for example, you've created one using XTRACT 
(see section~\ref{sec-other}) or you've
used VELOCITY before and you want to do further `cleaning') then you can
use it.  If you don't then VELOCITY will create one from the results
structure.  You are then presented with a 2-d colour map of the velocity
field.  If you decide you want to `clean' this map, you are asked to choose
a pixel on the map which has the `right' velocity (e.g. in the right
Fabry-Perot order).  You will also be asked for a tolerance (TOL) to be used by
the routine to decide whether or not a pixel is an FSR out or not.  This is
expressed as a {\em percentage} of the FSR.  What happens next is a lot
like NEIGHBOUR.  You are asked for a number of sweeps.  On each sweep, the
routine checks each pixel to see if there is a pixel with a velocity in the
right order next to it. (Obviously on the first sweep there will only be
one such pixel since you just nominated it with the cursor!)  If it has
such a neighbour, then it checks to see if the two velocities are an
integer number of FSRs apart ($\pm$ TOL*FSR).  If so, then the `program'
pixel's velocity is changed and it becomes a `fiducial' pixel.  If not,
then that pixel is in the `right' order and is also flagged as a fiducial
pixel.  If a pixel has no neighbour with a `good' velocity, then it has to
wait until it does.  The routine keeps iterating until either it has done
the number of sweeps you have given it, or until each pixel with a
neighbouring `right' velocity has been tested.

You will receive a news bulletin after each sweep has been done to tell you
how many of the pixels have had their velocities switched.  If the first
pixel you indicate with the cursor is somewhere in the middle of a sea of
other pixels with velocities in the same order, then it may be a while
before you see any velocities change.

Obviously if there are several objects on your frame, then you may have to
repeat this procedure several times.  Thus you will first get a new 2-d
plot of the map with the new velocities included.  You are then asked
if you want to accept the map with these velocities.  If you don't
accept the changes you are then presented with the old map again.  You can
finally choose whether or not to repeat this procedure on other objects in
the field.  Once you have finally decided to finish `cleaning' the map the
routine checks to see if any changes have been made to the velocity field. 
If there have, then you are given the option to write out the new velocity
field to a file.

Note that VELOCITY {\em does not} change the position $\lambda_o$ of the
fits.  It only writes out a velocity map (if you so choose).  To do the
former would be extremely naughty without doing a refit of the affected
spectra.  Also, it may be that the line in question has run off the red end
(for example) of the spectrum  because the velocity field {\em really does}
extend into such a wavelength region which is not covered in your cube.  
In such a case a line of a lower (by 1 FSR) wavelength may have been fit,
but the velocity at that pixel is {\em clearly} one FSR higher.  Thus such
a cleaning procedure is vital.

\subsubsection{Other Options in Main Menu} \label{sec-other}

There are a few more useful options in the main menu.  First there is SHOW, which,
as in EDIT mode, will display the fit parameters for a given pixel.  You may either
type the coordinates of the pixel you want or, if you have a 2-d plot displayed,
you may indicate the pixel with the cursor.

The option XTRACT extracts results from the output file which can then be plotted
using PICTURE.  You can extract any of the results parameters, their errors, their
relative errors or the velocity field.

Should you desire all line plots to have the same scale in the Y direction then the
option YSCALE takes care of that.  You will be asked, first of all, if you want
to scale all the plots similarly.  If so, you will then be prompted for the ranges
to be used.  Note, this option can also be used to {\em switch off} this scaling if you
so wish.  The default is that this option is off and thus all plots will be scaled in such
a way that they all fit.

The final option, ZAP, allows you to reject fits in bulk.  This works in several ways.
\begin{enumerate}
  \item Reject based on $(x,y)$ position
  \item Reject based on the output parameters (e.g. all negative intensities)
  \item A combination of (1) and (2).
\end{enumerate}
If you are rejecting by $(x,y)$ position you may type the $(x,y)$  limits or indicate them
with the cursor (if you already have a 2-d plot up).  You are then given the option
to zap fits either inside or outside the box you've just defined. If you are rejecting by the results,
you will be asked for the ranges for each parameter, outside which the fits will be rejected.
This routine can be rather drastic as a ZAPped fit cannot be recovered without refitting!

A complete list of the main menu and edit menu options can be found in appendix~\ref{app:optmen}
and appendix~\ref{app:edmen} respectively.

\subsubsection{TAU\_FITS in Batch}

For reasons of self preservation, it is often a good thing to do large
amounts of fitting in batch.  Unfortunately, as TAU\_FITS is a menu
driven program, it isn't possible to run it in batch in the same way as
you would interactively.  For one thing, it is not possible to fit two
different regions in $(x,y)$ space in the same job.  This is because the
OPTION parameter would have to take on several different values during
the course of the run and that isn't allowed by the FIGARO parameter system
when a program is running in batch.

To run TAU\_FITS in batch, therefore, you have to break up your actions
into separate jobs.  For instance, if you want to fit two separate regions
of a cube, then you should set up two batch jobs to do it.  In batch, TAU\_FITS
needs for things to either be specified on the command line or in your
BVARS.DST file.  The following table is a list of the parameters for
which TAU\_FITS will look.

\begin{table}[htb]
\caption{Parameters Required for TAU\_FITS in Batch}
\begin{center}
\begin{tabular}{|l|l|} \hline
{\em Parameter} &{\em Description}\\ \hline
NAME\_OBS&Input data cube\\
NEW\_FILE&Flag for creation of a new output file\\
NAME\_FIT&Output file\\
ALAM0    &Wavelength zeropoint\\
DLAM     &Wavelength increment\\
FSR      &Free spectral range\\
BOXSIZE  &Smoothing box size\\
NTRIV    &Number of trivial changes in $\chi^2$\\
DCHI     &Maximum fractional change in $\chi^2$\\
NITER    &Maximum number of iterations\\
TYPE\_FIT&Fitting function\\
START    &$(x,y)$ minima for LIMITS\\
END      &$(x,y)$ maxima for LIMITS\\
WT\_SCHEME&Weighting scheme\\
USE\_MASK&Flag to use mask image\\
NAME\_MASK&Name of mask image\\
MASK\_THRESH&Lower and upper thresholds in mask image\\
BATCH\_FIT&See below\\
NSWEEP   &Number of sweeps for neighbour fitting\\
RNG\_AMP &Min and max range of peak\\
RNG\_POS &Min and max range of position\\
RNG\_SIG &Min and max range of width\\
RNG\_BAC &Min and max range of background\\
HOW\_GUESS&Guessing algorithm to be used\\ \hline
\end{tabular}
\end{center}
\end{table}

The parameter BATCH\_FIT tells the program whether you want to use the
option FIT ($\mbox{BATCH\_FIT=1}$) or NEIGHBOUR ($\mbox{BATCH\_FIT=2}$).
The parameters: NAME\_OBS, NEW\_FILE, NAME\_FIT,
BOXSIZE, BATCH\_FIT, NTRIV, DCHI, NITER, WT\_SCHEME, START, END
and TYPE\_FIT are all required.  The parameters ALAM0, DLAM and FSR
are required if this information is not in the header of the
input data cube.  If one of these is not specified on the command
line, then the program will look for it in BVARS.DST.  If it isn't
there either, then the program quits.  If the parameter USE\_MASK isn't
specified on the command line, then the program assumes it's NO.  The
parameters NAME\_MASK and MASK\_THRESH are only required if $\mbox{USE\_MASK=Y}$.
If $\mbox{BATCH\_FIT=1}$ (FIT) then the parameter HOW\_GUESS must be specified.
(Note that in batch HOW\_GUESS can only have values of 1 or 2, the other options
not being possible in batch.)
If $\mbox{BATCH\_FIT=2}$ (NEIGHBOUR) then the parameter NSWEEP and all of the
RNG\_ parameters must be specified.

A typical .COM file to run TAU\_FITS in batch might look like this:
\medskip
\begin{verbatim}
$set verify
$set def tauvax_sys:[taurus.data.swu]
$figaro
$tau_fits name_obs=n1068 new_file=n name_fit=n1068_fits -
 boxsize=5 ntriv=2 dchi=0.05 niter=30 type_fit=1 -
 wt_scheme=1 use_mask=n start=(133,171) end=(166,206) -
 batch_fit=2 nsweep=100 rng_amp=(0.1,1.0e6) -
 rng_pos=(5019.0,5032.0) rng_sig=(0.14,10.0) -
 rng_bac=(0.0,10.0)
\end{verbatim}
\medskip
In this case, the user wanted to do a NEIGHBOUR fit.  In order to do
that he/she would have to have had a few good fits in the output file
which could have been achieved by running TAU\_FITS interactively
in EDIT mode and fitting a few spectra by hand.  The rest of the frame
could then be done in batch.

\subsubsection{The Output File}
The output file consist of a number of different components.  In the
$(x,y)$ space it will have the same dimensions as the input cube.  In
the z direction it will have one pixel for each of the maximum number of
parameters allowed to be fit (currently this is 4) and an extra 4 pixels
which are flags used by TAU\_FITS, and which may be of some use to you.
The errors in the parameters are also stored in an error array.  Note that
the error array also covers the flags, but, of course, these don't have
errors!  For each $(x,y)$ pixel the z pixels go as follows:
\begin{description}
  \item[1. Peak --] The maximum intensity of the fit {\em above}
   the background.
  \item[2. Position --] The position of the peak in \AA
  \item[3. Width --] The width of the function (e.g. $\sigma$ of
   a Gaussian or Cauchy function) in \AA
  \item[4. Background --] This is the level of the continuum.  It is always
   assumed to be constant.
  \item[5. Monitor --] This is an internal flag which is extremely useful
   for TAU\_FITS, but of no interest to the user.
  \item[6. Fit type --] This is the fitting function. It can have the following
   values: (1) Gaussian, (2) Cauchy function.
  \item[7. Fit flag --] This tells whether a successful fit has been obtained
   for the pixel.  It can have the following values: (-3) Fit failed in NEIGHBOUR,
   (-2) Fit was ZAPped by hand (in EDIT), (-1) Fit was rejected
   automatically (either by ZAP in main menu or it was considered to be
   unphysical in NEIGHBOUR),  (0) Fit wasn't even attempted,
   (1) Fit done successfully, (2) Fit was successfully done by hand (in EDIT).
  \item[8. Boxsize --] This is the smoothing box size for that pixel.
\end{description}

\newpage
\appendix
\section{Detailed programme descriptions} \label{app:prog}
\outerhead{{\large\bf PROGRAMME DETAILS}}

This appendix is intended to give a description of all of the
TAURUS data reduction programs available and the parameters required
for them.  Throughout this appendix parameters which have been marked
with an asterisk (*) are parameters which will only be requested if the
user is {\em not} using a TAUCAL file.  Parameters which have been marked
with a dagger (\dag) are hidden parameters which may be changed on the 
command line but which are not prompted for.
\subsection{CALBASIC}
\begin{description}
 \item[Function]:  Set up basic TAUCAL file with information about the
                   telescope, TAURUS and its set up.
 \item[Description]:  CALBASIC gives you a lists of telescope setups,
                      etalons and detectors.  You are asked to indicate which
                      in the lists are appropriate for your data.
 \item[Parameters]:

\begin{tabbing}
camera\_focusxxxxxxx\=typeofvariable\= \kill
CALOUT      \>Fixed string \>
\parbox[t]{75mm}{This is the name of the TAUCAL file to be created
with this program.}
 \end{tabbing}
\end{description}
\rule {\textwidth}{0.5mm}
\subsection{CALRUN}
\begin{description}
 \item[Function]: Sets up .RUN substructures in TAUCAL file to hold information
                  for specific TAURUS files.
 \item[Description]: CALRUN gives you the option of creating four different
                     run types-- OBS (cubes with the `object'), CAL (cubes
                     with the calibration source), MASK (frames with the
                     pinhole mask) and RING (individual ring frames for RVT).
                     Depending upon the run type, the user is then prompted for
                     other information about the structure.  Note that the
                     structures must exist as CALRUN tries to get dimensional
                     information for some of them.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
CALOUT \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the output TAURUS calibration file as
created in CALBASIC.
 }\\
 \\
RUNTYPE \>Fixed string       \>
\parbox[t]{75mm}{
This is the type of run to be added.  They can be: MASK, OBS,
CAL, or RING.
 }\\
 \\
NSTRUCT \>Integer       \>
\parbox[t]{75mm}{
This is the number of structures of the type you've just
nominated to be added to the TAUCAL file.
 }\\
 \\
RUN\_NOS \>Integer array \>
\parbox[t]{75mm}{
This is the array of run numbers which correspond to the
new substructures which you wish to create.
 }\\
 \\
AGAIN \>Logical       \>
\parbox[t]{75mm}{
Instruction to continue adding further structures.
 }\\
 \\
IMAGE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the image for a particular run number.
 }\\
 \\
MPU0 \>Float       \>
\parbox[t]{75mm}{
This is the Z axis zero point in micro-processor units
 }\\
 \\
DMPU \>Float       \>
\parbox[t]{75mm}{
This is the Z axis increment in micro-processor units
 }\\
 \\
WAVE \>Float       \>
\parbox[t]{75mm}{
This is the wavelength for a particular run
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{CORRECT}
\begin{description}
 \item[Function]: Does the actual phase correction of a TAURUS cube.
 \item[Description]: CORRECT takes the phase map as defined in PHASE\_MAP and
                     shifts each spectrum.  The sense is such that spectra
                     with a positive phase are shifted to {\em lower} pixel
                     values (e.g. CORRECT subtracts in wavelength space).  The
                     user is given a choice of two interpolation schemes. The
                     input cube {\em must} be ZXY sorted before using this program.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the TAUCAL file
 }\\
 \\
OBSRUN \>Integer       \>
\parbox[t]{75mm}{
This is the run number associated with the OBS cube
 }\\
 \\
NAME\_OBS \>Fixed string       \>
\parbox[t]{75mm}{
This is the observation cube file.  The cube must have been
ZXY sorted before using this program!
 }\\
 \\
USE\_GRID \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether you want to use a
predetermined grid of X,Y coordinates as calculated in MASK
and GRID which will automatically take into account the
detector distortions.
 }\\
 \\
NAME\_GRID\tc \>Fixed string       \>
\parbox[t]{75mm}{
The name of the output file from GRID.
 }\\
 \\
NAME\_COR \>Fixed string       \>
\parbox[t]{75mm}{
This is the output file for the corrected data.  Note that it
will also be ZXY sorted as the input file is.
 }\\
 \\
DX\tc \>Float       \>
\parbox[t]{75mm}{
This is the offset in X for the obs cube as found in EXAM\_RVT
 }\\
 \\
DY\tc \>Float       \>
\parbox[t]{75mm}{
This is the offset in Y for the obs cube as found in EXAM\_RVT
 }\\
 \\
XCEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the X position of the optical axis
 }\\
 \\
YCEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the Y position of the optical axis
 }\\
 \\
DMPU\tc \>Float       \>
\parbox[t]{75mm}{
This is the increment on the spectral axis in MPUs/frame.
 }\\
 \\
NAME\_SHIFTS\tc \>Fixed string       \>
\parbox[t]{75mm}{
This the output file for the final shifts.  The shifts are
defined as the total number of pixels to shift the spectra down
in order to get the desired wavelength into the centre of the
cube.  (e.g. the shifts are subtracted from the spectra).
 }\\
 \\
FSR\_OBS\tc \>Float       \>
\parbox[t]{75mm}{
This is the free spectral range in MPUs of the OBS cube
 }\\
 \\
PIXSIZE\_X\tc \>Float       \>
\parbox[t]{75mm}{
This is the pixel size in microns.
 }\\
 \\
CAMERA\_FOCUS\tc \>Float       \>
\parbox[t]{75mm}{
This is the focal length in microns of the camera used in the
observations.
 }\\
 \\
INTERP \>Integer       \>
\parbox[t]{75mm}{
This is the interpolation scheme to be employed.  At present
these are (1) linear and (2) sinc.  For integer data a sinc
can sometimes cause rounding problems which lead to a ring
pattern's appearing in the background.
 }\\
 \\
WHICH\_MASK \>Logical       \>
\parbox[t]{75mm}{
If there are more than one MASK in TAUCAL, then this decides
which one to use.
 }\\
 \\
WHICH\_GRID \>Logical       \>
\parbox[t]{75mm}{
If there are more than one GRID in TAUCAL, then this decides
which one to use.
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{CRE\_RV}
\begin{description}
 \item[Function]: Create estimated RVF or RVT files from information
                  in TAUCAL file.
 \item[Description]: CRE\_RV was designed to be used in the event that
                     the user has somehow lost the file with the ring
                     parameter estimates created in PRERING (e.g. deleted
                     it, run RINGS with the wrong parameters, etc) and he/she/it
                     doesn't want to have to rerun PRERING.  The information
                     can all be painlessly recovered from TAUCAL or can be
                     entered by hand.  The latter may be rather tedious!
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the TAUCAL file.
 }\\
 \\
RVF \>Logical       \>
\parbox[t]{75mm}{
Flag.  True if the output file is an RVF and false if it will be
an RVT.
 }\\
 \\
WHICH\_RVT \>Integer       \>
\parbox[t]{75mm}{
Which RVT from TAUCAL to use this time?
 }\\
 \\
WHICH\_RVF \>Integer       \>
\parbox[t]{75mm}{
Which RVF from TAUCAL to use this time?
 }\\
 \\
MPU0\tc \>Float       \>
\parbox[t]{75mm}{
This is the value in MPUs that the first Z pixel will have...
 }\\
 \\
DMPU\tc \>Float       \>
\parbox[t]{75mm}{
Increment in MPUs/pixel...
 }\\
 \\
NSER\tc \>Integer       \>
\parbox[t]{75mm}{
This is the number of series in the cube to be processed.
 }\\
 \\
SER\_NOS\tc \>Integer array \>
\parbox[t]{75mm}{
These are the first and last frame numbers which one wants to
consider in any given series.
 }\\
 \\
NZ\tc \>Integer       \>
\parbox[t]{75mm}{
This is the number of frames in the CAL cube
 }\\
 \\
NAME\_RVF\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the output file for the RVF.
 }\\
 \\
NAME\_RVT\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the output file for the RVT.
 }\\
 \\
RING\_PARS\tc \>Float array \>
\parbox[t]{75mm}{
(1) MPU or Frame no., (2) Xc, (3) Yc, (4) R, (5) SIG, (6) A
(7) B, (8) Ellipt, (9) Error, (10) Flag
 }\\
 \\
NRUNS\tc \>Integer       \>
\parbox[t]{75mm}{
This gives the number of rings which you want to consider for
the RVT.
 }\\
 \\
RUNS\tc \>Integer array \>
\parbox[t]{75mm}{
These are the run numbers to be included for this RVT
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{EXAM\_RVF}
\begin{description}
 \item[Function]: Examines the RVF array and calculates the free
                  spectral range, the nominal gap and the mean centre
                  of the rings (e.g. the coordinates of the optical axis).
 \item[Description]: EXAM\_RVF is an interactive program hence the user
                     must have access to some sort of display.  The user
                     is presented with a plot of $R^2$ vs. $Z$.  Because the
                     Airy function is basically a paraboloid of revolution
                     this plot should look linear.  The user then marks
                     where he wants each series to begin and end.  A line
                     is fitted to the points and the user is given a chance
                     to delete or reweight any of the interior points with
                     the cursor.  If only one series is available, then the
                     user must provide an estimate of the FSR.  If only one
                     series is any good, then the user may constrain all of
                     the slopes of the fitted lines to be equal to the slope
                     of the good series. The free spectral range is calculated from
                     the differences in the $x$-intercepts.  The gap is calculated
                     from the FSR, the wavelength and the spacial scale.  The
                     coordinates of the centre are calculated from a weighted
                     mean of all of the rings which have been used.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the TAUCAL file
 }\\
 \\
NSER\tc \>Integer       \>
\parbox[t]{75mm}{
This is the number of series in the cube to fit
 }\\
 \\
WHICH\_RVF \>Logical       \>
\parbox[t]{75mm}{
If there are more than one RVF in TAUCAL, then this decides
which one to use.
 }\\
 \\
WHICH\_MASK \>Logical       \>
\parbox[t]{75mm}{
If there are more than one MASK in TAUCAL, then this decides
which one to use.
 }\\
 \\
NAME\_RVF\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the input RVF file as determined in RINGS.
 }\\
 \\
PIXSIZE\_X\tc \>Float       \>
\parbox[t]{75mm}{
This is the pixel size in microns along the x direction in the
middle of the frame.
 }\\
 \\
CAMERA\_FOCUS\tc \>Float       \>
\parbox[t]{75mm}{
This is the focal length in microns of the camera used in the
observations.
 }\\
 \\
WAVE\_CAL\tc \>Float       \>
\parbox[t]{75mm}{
This is the wavelength of the source used for the calibration
rings.
 }\\
 \\
SAME\_SLOPE \>Logical       \>
\parbox[t]{75mm}{
If there isn't enough information in one of the series to fit a
reliable line, then you can constrain the subsequent lines to
have the same slope as the first one.
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{EXAM\_RVT}
\begin{description}
 \item[Function]: Finds the offsets in Z, $X_c$ and $Y_c$ by an
                  analysis of the RVT.
 \item[Description]: EXAM\_RVT uses the slopes found in EXAM\_RVF to
                     calculate a correction in $Z$ resulting from the
                     variation in $R$ over time ($\delta T$ being the time
                     between the taking of the CAL cube and the taking of
                     the OBS cube).  Quite often `time' is not the important
                     factor in whether $R$ has changed, rather it is whether
                     the telescope has been moved.  Hence the user is given a
                     choice of 4 different ways to estimate the shift $\delta R$.
                     These are described in section~\ref{sec-resid}.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the TAUCAL file.
 }\\
 \\
OBSRUN \>Integer       \>
\parbox[t]{75mm}{
This is the run number associated with the OBS cube
 }\\
 \\
WHICH\_RVT \>Integer       \>
\parbox[t]{75mm}{
This is the number of the RVT to use this time.
 }\\
 \\
WHICH\_RVF \>Integer       \>
\parbox[t]{75mm}{
This is the number of the RVF to use this time.
 }\\
 \\
EST \>Integer       \>
\parbox[t]{75mm}{
This is the method of estimation to be used.  There are four
possibilities (1) use the estimate from the ring just before
the OBS run, (2) use the estimate from the ring just after
the OBS run, (3) use an average of the above, (4) do an
interpolation of the above.  If you are doing this for the
cal cube, then you should use method (1).
 }\\
 \\
DISP \>Logical       \>
\parbox[t]{75mm}{
You may, if you wish, display R, $X_c$ and $Y_c$ versus time.
 }\\
 \\
IGNORE \>Logical    \>
\parbox[t]{75mm}{
You may, if you wish, ignore the variation of R (and its implied
variation in Z) and just do this calculation for Xc and Yc.
}\\
\\
NAME\_RVT\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the RVT file as opened in RINGS.
 }\\
 \\
XCEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the X position of the optical axis.
 }\\
 \\
YCEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the Y position of the optical axis.
 }\\
 \\
NSERFIT\tc \>Integer       \>
\parbox[t]{75mm}{
This is the total number of series actually fit in EXAM\_RVF
 }\\
 \\
FITDATA\tc \>Float array \>
\parbox[t]{75mm}{
This is the series number, slope, its error, intercept and
its error from each series.  Actually all that is needed
is the slopes and their errors so you can get away with
typing rubbish for the other four...
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{FINDPKS}
\begin{description}
 \item[Function]: Finds peaks in a pinhole mask frame, centroids them
                  and writes out the positions.
 \item[Description]: FINDPKS first does some rough statistics on the pinhole
                     frame to find a noise level.  It then locates pixels which
                     are a user-supplied threshold number of $\sigma$ above the
                     mean background value.  It does a test to make sure these are
                     not just noise spikes.  It then centroids the peaks it has
                     found.  The user has the option (and this is a highly
                     recommended option!) to get a grey plot of the matrix frame
                     with the located peaks indicated.  He/she/it may then delete
                     any peaks which may seem spurious (ghost images and the
                     like).  The final results are written to a file called
                     FINDPKS.OUT and (if it's being used) to the TAUCAL file.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of your TAUCAL file for this data.
 }\\
 \\
NAME\_MAT\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the file with the matrix mask image (e.g. pinhole mask).
The file must be 2-d.
 }\\
 \\
MASKRUN \>Integer       \>
\parbox[t]{75mm}{
This is the run number you have assigned the matrix image in
the TAUCAL file.
 }\\
 \\
DISP \>Logical       \>
\parbox[t]{75mm}{
If you want to display the image, you will get a grey scale plot
of the mask.  The peaks which the program has found will overlay
the image with open circles.  You will then be given the chance
to add or delete any points as you wish.  Those which you have
deleted will overlay as solid circles.
 }\\
 \\
NRAD \>Integer       \>
\parbox[t]{75mm}{
This is the radius from the pixel of maximum intensity out to
which you want to calculate the centroid of the peak.
 }\\
 \\
THRESH \>Float       \>
\parbox[t]{75mm}{
This is the number of sigma above the clipped background used
for defining which pixels can be considered as possible peaks.
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{GRID}
\begin{description}
 \item[Function]: Generates a pixel grid to take account of flexure
                  within the detector.
 \item[Description]: GRID takes the polynomial fits from TMASK and generates
                     a grid of new `positions' for each pixel.  The user
                     can subset or recentre the grid.  Extrapolating the
                     fits is allowed, but not recommended.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the TAUCAL file.
 }\\
 \\
WHICH\_MASK \>Integer       \>
\parbox[t]{75mm}{
This is the number of the mask to use if there are more than one
in the TAUCAL file.
 }\\
 \\
NAME\_MAT\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the file with the matrix mask image (e.g. pinhole mask).
The file must be 2-d.
 }\\
 \\
NAME\_GRID \>Fixed string       \>
\parbox[t]{75mm}{
This is the output file.  Its dimensions will by (2,nx,ny) where
nx,ny are the dimensions of the input matrix image.
 }\\
 \\
DIFFSIZE \>Logical       \>
\parbox[t]{75mm}{
True if the output file is smaller or larger than the input file
 }\\
 \\
CENTRED \>Logical       \>
\parbox[t]{75mm}{
True if the output file is centred on the MATRIX file.
 }\\
 \\
NX \>Integer       \>
\parbox[t]{75mm}{
X dimension of output file
 }\\
 \\
NY \>Integer       \>
\parbox[t]{75mm}{
Y dimension of output file
 }\\
 \\
XC \>Float       \>
\parbox[t]{75mm}{
X position of output file centre. This is relative to the coords
of the matrix file.
 }\\
 \\
YC \>Float       \>
\parbox[t]{75mm}{
Y position of output file centre. This is relative to the coords
of the matrix file.
 }\\
 \\
NORDER\tc \>Integer       \>
\parbox[t]{75mm}{
Pretty self-explanatory, really...As this is a bivariate polynomial,
the order will be the same in both coordinates.
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{LAMDA}
\begin{description}
 \item[Function]: Does the wavelength calibration of TAURUS cubes
 \item[Description]: LAMDA does the wavelength calibration in the following
                     way (where upper case letters refer to the OBS cube
                     and lower case to the CAL cube):
                     the FSR ($f$) in pixels, gap ($\ell$) and
                     central phase ($\phi_o$) are known for the CAL cube
                     from EXAM\_RVF.  The FSR can also be calculated by:
\begin{equation}
f' = {\lambda^2 \over 2\ell} \label{eq:fsr}
\end{equation}
                     where $\lambda$ and $\ell$ are both in microns.
                     Thus the dispersion in the CAL cube is:
\begin{equation}
\delta\lambda = {f'\over f}  \label{eq:dlam}
\end{equation}
                     and
\begin{displaymath}
\lambda_o = \lambda - \phi_o\delta\lambda.
\end{displaymath}
                     The Fabry-Perot order is defined as:
\begin{displaymath}
 n = {2\ell \over \lambda}.
\end{displaymath}
                     Because of errors in the calculation of $\ell$ this will
                     not in general be an integer, which, of course it should be.
                     So we take:
\begin{displaymath}
n' = [n]
\end{displaymath}
                     where $[]$ refers to the nearest integer and define a new
                     estimate of the gap:
\begin{displaymath}
\ell' = {n'\lambda \over 2}.
\end{displaymath}
                     Therefore,
\begin{displaymath}
N = \mbox{int}\left({2\ell' \over \Lambda}\right)
\end{displaymath}
                      and
\begin{displaymath}
\Lambda_o = {n'\lambda_o \over N}.
\end{displaymath}
                      The FSR of the OBS cube can be defined in pixels by:
\begin{displaymath}
F = {\Lambda f  \over \lambda}
\end{displaymath}
                      and in microns ($F'$) in the same way as
                      equation~\ref{eq:fsr} using $\Lambda$ and $\ell'$.
                      Thus the dispersion in the OBS cube $\Delta\Lambda$
                      can be found ala equation~\ref{eq:dlam}.  The wavelength
                      zeropoint in the eventual {\em corrected} cube is found by
                      assuming that you want $\Lambda$ to be centered in wavelength
                      space. Finally, the central phase in the OBS cube can be
                      found by:
\begin{equation}
\Phi_o = {\Lambda - \Lambda_o \over \Delta\Lambda}
\end{equation}
                      All of these results are printed to the terminal.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the TAUCAL file
 }\\
 \\
NOBS \>Integer       \>
\parbox[t]{75mm}{
This is the number of OBS cubes to be calibrated.
 }\\
 \\
OBSRUNS \>Integer array \>
\parbox[t]{75mm}{
This is the run numbers for all the obs cubes to be calibrated
 }\\
 \\
REPORT\hid \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a report will be given for
all the cubes or just the first one.
 }\\
 \\
WAVE\_CAL\tc \>Float       \>
\parbox[t]{75mm}{
This is the wavelength of the source used for the calibration
rings.
 }\\
 \\
FSR\_CEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the free spectral range in MPUs of the CAL cube
 }\\
 \\
GAP\tc \>Float       \>
\parbox[t]{75mm}{
This is the nominal gap in microns.
 }\\
 \\
CENPHASE\tc \>Float       \>
\parbox[t]{75mm}{
This is the central phase of the CAL cube.
 }\\
 \\
MPU0\_CAL\tc \>Float       \>
\parbox[t]{75mm}{
This is the zeropoint on the spectral axis in MPUs in CAL cube.
 }\\
 \\
DMPU\_CAL\tc \>Float       \>
\parbox[t]{75mm}{
This is the increment on the spectral axis in MPUs/frame in
CAL cube.
 }\\
 \\
MODE\tc \>Integer       \>
\parbox[t]{75mm}{
This should be 1, unless the slopes from EXAM\_RVF are negative.
In that case it should be -1.
 }\\
 \\
NZ\tc \>Integer     \>
\parbox[t]{75mm}{
Number of pixels in the spectral direction.
 }\\
 \\
WAVE\_WANT\tc \>Float       \>
\parbox[t]{75mm}{
This is the wavelength which you will eventually want to see
in the centre of the calibrated OBS cube.
 }\\
 \\
MPU0\_OBS\tc \>Float       \>
\parbox[t]{75mm}{
This is the zeropoint on the spectral axis in MPUs in OBS cube.
 }\\
 \\
DMPU\_OBS\tc \>Float       \>
\parbox[t]{75mm}{
This is the increment on the spectral axis in MPUs/frame in
OBS cube.
 }\\
 \\
WHICH\_RVF \>Logical       \>
\parbox[t]{75mm}{
If there are more than one RVF in TAUCAL, then this decides
which one to use.
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{PEAKDISP}
\begin{description}
 \item[Function]: Displays the MASK frame and the peaks found on it.
 \item[Description]: PEAKDISP displays the MASK frame and the peaks which
                     were located on it.  This is useful in the event that
                     the user has spotted something peculiar and wants to
                     see exactly which positions are being fit in MASK.
                     This program obviously requires a 2-d image display.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of your TAUCAL file for this data.  You must
have a TAUCAL file for this program otherwise the following
programs won't be able to find the peak information.
 }\\
 \\
MASKRUN \>Integer       \>
\parbox[t]{75mm}{
This is the run number you have assigned the matrix image in
the TAUCAL file.
 }\\
 \\
WHICH\_MASK \>Integer       \>
\parbox[t]{75mm}{
This is the number of the mask sub-structure to use if there are
more than one in the TAUCAL file.
 }\\
 \\
NAME\_MAT\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the file with the matrix mask image (e.g. pinhole mask).
The file must be 2-d.
 }\\
 \\
THRESH\tc \>Float       \>
\parbox[t]{75mm}{
This is the number of sigma above the clipped back ground used
for defining which pixels can be considered as possible peaks.
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{PHASE\_MAP}
\begin{description}
 \item[Function]: Defines the phase map for an individual cube
 \item[Description]: The theoretical phase map is defined by:
\begin{equation}
\Phi (x,y) = \Phi_o + {2 F\ell \over \Lambda}(\sec\theta - 1) \label{eq:theo}
\end{equation}
                     where $\Phi_o$ is the central phase, $F$ is the
                     free spectral range and $\Lambda$ is the wavelength of
                     the OBS cube. $\ell$ is the etalon gap and $\theta$
                     is the angle defined from optical axis to the pixel
                     in question.  Thus for a given spectrum the total shift
                     necessary to put $\Lambda$ in the centre of the cube
                     (in the wavelength direction) is:
\begin{equation}
{\cal S} = \Phi (x,y) + d\Phi (x,y) + dZ - \Gamma
\end{equation}
                     where $d\Phi (x,y)$ is the residual phase for that pixel found by
                     RESIDUAL, $dZ$ is the RVT shift for that cube found by EXAM\_RVT
                     and $\Gamma$ is defined as the mean position in the spectral
                     direction.  What all this means is that in CORRECT an output
                     pixel $O(z,x,y)$ will map onto the input pixel \mbox{$I(z+{\cal S},x,y)$}
                     or, in other words, CORRECT takes a pixel and {\em subtracts}
                     the shift ${\cal S}$ to obtain the new position in $z$.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the TAUCAL file
 }\\
 \\
OBSRUN \>Integer       \>
\parbox[t]{75mm}{
This is the run number associated with the OBS cube
 }\\
 \\
USE\_RES \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether you want to use a residual
phase map.  If you don't then the map is assumed to be all zeros
 }\\
 \\
NAME\_RES \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the file with the residual phase map.
 }\\
 \\
USE\_GRID \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether you want to use a
predetermined grid of X,Y coordinates as calculated in MASK
and GRID which will automatically take into account the
detector distortions.
 }\\
 \\
NAME\_GRID\tc \>Fixed string       \>
\parbox[t]{75mm}{
The name of the output file from GRID.
 }\\
 \\
NAME\_OBS\tc \>Fixed string       \>
\parbox[t]{75mm}{
The name of the OBS cube file.
 }\\
 \\
WAVE\_WANT\tc \>Float       \>
\parbox[t]{75mm}{
This is the wavelength to be centred (eventually) in OBS cube
 }\\
 \\
DX\tc \>Float       \>
\parbox[t]{75mm}{
This is the offset in X for the OBS cube as found in EXAM\_RVT
 }\\
 \\
DY\tc \>Float       \>
\parbox[t]{75mm}{
This is the offset in Y for the OBS cube as found in EXAM\_RVT
 }\\
 \\
DZ\tc \>Float       \>
\parbox[t]{75mm}{
This is the offset in Z for the OBS cube as found in EXAM\_RVT
 }\\
 \\
XCEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the X position of the optical axis
 }\\
 \\
YCEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the Y position of the optical axis
 }\\
 \\
CENPHASE\_OBS\tc \>Float       \>
\parbox[t]{75mm}{
This is the central phase of the OBS cube.
 }\\
 \\
MPU0\tc \>Float       \>
\parbox[t]{75mm}{
This is the spectral axis zero point in micro processor units
 }\\
 \\
DMPU\tc \>Float       \>
\parbox[t]{75mm}{
This is the increment on the spectral axis in MPUs/frame.
 }\\
 \\
FSR\_OBS\tc \>Float       \>
\parbox[t]{75mm}{
This is the free spectral range in MPUs of the OBS cube
 }\\
 \\
GAP\tc \>Float       \>
\parbox[t]{75mm}{
This is the nominal gap in microns.
 }\\
 \\
MODE\tc \>Integer       \>
\parbox[t]{75mm}{
This should be 1, unless the slopes from EXAM\_RVF are negative.
In that case it should be -1.
 }\\
 \\
PIXSIZE\_X\tc \>Float       \>
\parbox[t]{75mm}{
This is the pixel size in microns.
 }\\
 \\
CAMERA\_FOCUS\tc \>Float       \>
\parbox[t]{75mm}{
This is the focal length in microns of the camera used in the
observations.
 }\\
 \\
NAME\_SHIFTS \>Fixed string       \>
\parbox[t]{75mm}{
This the output file for the final shifts.  The shifts are
defined as the total number of pixels to shift the spectra down
in order to get the desired wavelength into the centre of the
cube.  (e.g. the shifts are subtracted from the spectra).
 }\\
 \\
WHICH\_RVF \>Logical       \>
\parbox[t]{75mm}{
If there are more than one RVF in TAUCAL, then this decides
which one to use.
 }\\
 \\
WHICH\_MASK \>Logical       \>
\parbox[t]{75mm}{
If there are more than one MASK in TAUCAL, then this decides
which one to use.
 }\\
 \\
WHICH\_GRID \>Logical       \>
\parbox[t]{75mm}{
If there are more than one GRID in TAUCAL, then this decides
which one to use.
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{PRERING}
\begin{description}
 \item[Function]: Does an initial guess at ring parameters
 \item[Description]: PRERING is an interactive program only and
                     requires a 2-d image display.  An exhaustive
                     description of PRERING is given in section~\ref{sec-rvf}.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the TAUCAL file.
 }\\
 \\
RINGRUN \>Integer       \>
\parbox[t]{75mm}{
This is the run number for either the CAL or RING
structure.
 }\\
 \\
CALRUN \>Integer       \>
\parbox[t]{75mm}{
This is the run number for the CAL cube whose frame is to
be used as the reference ring in the RVT
 }\\
 \\
CALFRAME \>Integer       \>
\parbox[t]{75mm}{
This is the frame number in the CAL cube for the frame which
is to be used as the reference ring in the RVT
 }\\
 \\
NAME\_CAL\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the input file with the ring/s to be fitted.  It can be
either 2-d or 3-d depending on whether you are doing the RVF
or the RVT relation.
 }\\
 \\
TABLE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the LUT (Look-up Table) for the 2-d image display.
 }\\
 \\
MPU0\tc \>Float       \>
\parbox[t]{75mm}{
This is the value in MPUs that the first Z pixel will have...
 }\\
 \\
DMPU\tc \>Float       \>
\parbox[t]{75mm}{
Increment in MPUs/pixel...
 }\\
 \\
SER\_NOS \>Integer array \>
\parbox[t]{75mm}{
These are the first and last frame numbers which one wants to
consider in any given series.
 }\\
 \\
FRAMES\_PROC \>Integer array \>
\parbox[t]{75mm}{
These are the frame numbers for the 2 rings in the current
series will be processed.
 }\\
 \\
NFRAME \>Integer       \>
\parbox[t]{75mm}{
This is the frame number of a cube to process in case you are
doing an RVT with rings in a cube.
 }\\
 \\
NBINS\hid \>Integer       \>
\parbox[t]{75mm}{
This is the number of bins used in histogramming the data
frame in intensity.
 }\\
 \\
NSER \>Integer       \>
\parbox[t]{75mm}{
This is the number of series in the cube to be processed.
 }\\
 \\
NAME\_RVF \>Fixed string       \>
\parbox[t]{75mm}{
This is the output file for the RVF.
 }\\
 \\
NAME\_RVT \>Fixed string       \>
\parbox[t]{75mm}{
This is the output file for the RVT.
 }\\
 \\
RVF \>Logical       \>
\parbox[t]{75mm}{
Flag.  True if the output file is an RVF and false if it will be
an RVT.
 }\\
 \\
USE\_ALL \>Logical       \>
\parbox[t]{75mm}{
Flag to use all the available rings for this RVT
 }\\
 \\
NRUNS\tc \>Integer       \>
\parbox[t]{75mm}{
This gives the number of rings which you want to consider for
the RVT.
 }\\
 \\
RUNNOS\tc \>Integer array \>
\parbox[t]{75mm}{
These are the run numbers to be included for this RVT
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{PRINT\_RV}
\begin{description}
 \item[Function]: Print RVF or RVT to an ASCII file.
 \item[Description]: PRINT\_RV will make an ASCII version of either the
                     RVF or RVT.  The output file name will be the same
                     as the input, except with the extension .OUT substituted.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
NAME\_RV \>Fixed string       \>
\parbox[t]{75mm}{
This is either an RVF or an RVT file.
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{RESIDUAL}
\begin{description}
 \item[Function]: Calculate and output the residual phase map.
 \item[Description]: RESIDUAL takes the theoretical phase for a spectrum
                     in the CAL cube ala equation~\ref{eq:theo} and calculates the
                     residual from a moments analysis of that spectrum. Results
                     can be binned in the spacial direction.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the TAUCAL file name.
 }\\
 \\
NAME\_CAL\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the file with the calibration cube to
be used.
 }\\
 \\
WINDOW \>Integer       \>
\parbox[t]{75mm}{
This is the area in Z over which a peak will be searched.  It
is centred upon the predicted position of the peak as defined
by the theoretical phase map.  Thus the total space in Z to be
searched will be 2*window + 1 pixels.
 }\\
 \\
SMOOTH\_SIZE \>Integer       \>
\parbox[t]{75mm}{
This is a box over which the results are smoothed.
 }\\
 \\
USE\_GRID \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether you want to use a
predetermined grid of X,Y coordinates as calculated in MASK
and GRID which will automatically take into account the
detector distortions.
 }\\
 \\
NAME\_GRID\tc \>Fixed string       \>
\parbox[t]{75mm}{
The name of the output file from GRID.
 }\\
 \\
NAME\_RES \>Fixed string       \>
\parbox[t]{75mm}{
The name of the output file for the residuals map.
 }\\
 \\
PIXSIZE\_X\tc \>Float       \>
\parbox[t]{75mm}{
This is the pixel size in microns.
 }\\
 \\
CAMERA\_FOCUS\tc \>Float       \>
\parbox[t]{75mm}{
This is the focal length in microns of the camera used in the
observations.
 }\\
 \\
WAVE\_CAL\tc \>Float       \>
\parbox[t]{75mm}{
This is the wavelength of the source used for the calibration
rings.
 }\\
 \\
FSR\_CEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the free spectral range of the CAL cube in MPUs.
 }\\
 \\
GAP\tc \>Float       \>
\parbox[t]{75mm}{
This is the etalon gap in microns.
 }\\
 \\
XCEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the X position of the optical axis
 }\\
 \\
YCEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the Y position of the optical axis
 }\\
 \\
CENPHASE\tc \>Float       \>
\parbox[t]{75mm}{
This is the central phase of the CAL cube
 }\\
 \\
MPU0\tc \>Float       \>
\parbox[t]{75mm}{
This is the spectral axis zero point in micro processor units
 }\\
 \\
DMPU\tc \>Float       \>
\parbox[t]{75mm}{
This is the spectral axis increment in micro processor units
per frame
 }\\
 \\
MODE\tc \>Integer       \>
\parbox[t]{75mm}{
This should be 1, unless the slopes from EXAM\_RVF are negative.
In that case it should be -1.
 }\\
 \\
DX\tc \>Float     \>
\parbox[t]{75mm}{
The mean RVT shift in $X_c$ for CAL cube.
 }\\
 \\
DY\tc \>Float     \>
\parbox[t]{75mm}{
The mean RVT shift in $Y_c$ for CAL cube.
 }\\
 \\
WHICH\_RVF \>Logical       \>
\parbox[t]{75mm}{
If there are more than one RVF in TAUCAL, then this decides
which one to use.
 }\\
 \\
WHICH\_MASK \>Logical       \>
\parbox[t]{75mm}{
If there are more than one MASK in TAUCAL, then this decides
which one to use.
 }\\
 \\
WHICH\_GRID \>Logical       \>
\parbox[t]{75mm}{
If there are more than one GRID in TAUCAL, then this decides
which one to use.
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{RINGS}
\begin{description}
 \item[Function]: Does proper fits to calibration rings.
 \item[Description]: RINGS does a proper fit to the calibration
                     rings.  The fitting function is of the form:
\begin{displaymath}
I(x,y) = Ae^{-(\rho-r)^2/2\sigma^2} + B
\end{displaymath}
                     where
\begin{displaymath}
\rho = \sqrt{(x-x_c)^2 + (y-y_c)^2\epsilon^2}
\end{displaymath}
                     Thus there are seven unknowns: $A$ and $B$
                     (the peak intensity and the background); $x_c$ and
                     $y_c$ (the coordinates of the centre of the ring);
                     $r$ (the radius of the ring); $\sigma$ (the width
                     of the ring); and $\epsilon$ (the axial ratio of
                     the ring).
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the TAUCAL file.
 }\\
 \\
RINGRUN \>Integer       \>
\parbox[t]{75mm}{
This is the run number of the structure containing the rings to
be fit.
 }\\
 \\
NAME\_CAL\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the input file with the ring/s to be fitted.  It can be
either 2-d or 3-d depending on whether you are doing the RVF
or the RVT relation.
 }\\
 \\
NAME\_RVF\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the output file for the RVF.
 }\\
 \\
NAME\_RVT\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the output file for the RVT.
 }\\
 \\
RVF \>Logical       \>
\parbox[t]{75mm}{
Flag.  True if the output file is an RVF and false if it will be
an RVT.
 }\\
 \\
COMP\_FAC \>Integer       \>
\parbox[t]{75mm}{
This is a factor by which the input data will be compressed. If
it = 1 then all the data is used.  If it = 2 then only every
second row and column is used, e.g. 1/4 of the data.
 }\\
 \\
WEIGHT \>Integer       \>
\parbox[t]{75mm}{
Flag to determine which weighting scheme gets used.
(1) $\sqrt n$
(2) Equal weights
 }\\
 \\
TRIVIAL\hid \>Float       \>
\parbox[t]{75mm}{
This parameter is used to test for the convergence of the fit.
The fit is judged by how much $\chi^2$ has changed over the
last fit.  TRIVIAL is thus the definition of a trivial change
in $\chi^2$ .
 }\\
 \\
NTRIV\hid \>Integer       \>
\parbox[t]{75mm}{
This is the number of trivial changes to $\chi^2$ needed to
define the fit as converged.
 }\\
 \\
RESTRICT \>Logical       \>
\parbox[t]{75mm}{
Flag.  True if you want to restrict the region of analysis to
an annulus of total width $2\mbox{SIGS}\sigma$ centred on the ring.  The $\sigma$
used is that of the estimate from PRERING.
 }\\
 \\
SIGS \>Float       \>
\parbox[t]{75mm}{
This is the number of $\sigma$ to define the width of the
annulus which will be used if the user wishes to restrict the
analysis region.
 }\\
 \\
USE\_GRID \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether you want to use a
predetermined grid of X,Y coordinates as calculated in MASK
and GRID which will automatically take into account the
detector distortions.
 }\\
 \\
NAME\_GRID\tc \>Fixed string       \>
\parbox[t]{75mm}{
The name of the output file from GRID.
 }\\
 \\
TOLCENT \>Float       \>
\parbox[t]{75mm}{
This is a user supplied tolerance for the error in the central
pixel determination.  If the error is over this tolerance, then
the fit is flagged in the output file.
 }\\
 \\
TOLRAD \>Float       \>
\parbox[t]{75mm}{
This is a user supplied tolerance for the error in the radius
determination.  If the error is over this tolerance, then
the fit is flagged in the output file.
 }\\
 \\
NRUNS\tc \>Integer       \>
\parbox[t]{75mm}{
This is the number of rings for the RVT you want to define.
 }\\
 \\
NAME\_USED\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the ring file used in PRERING to set the initial guesses
for the ring parameters.  Note that this is only used to get
the array sizes.
 }\\
 \\
WHICH\_RVT \>Logical       \>
\parbox[t]{75mm}{
If there are more than one RVT in TAUCAL, then this decides
which one to use.
 }\\
 \\
WHICH\_RVF \>Logical       \>
\parbox[t]{75mm}{
If there are more than one RVF in TAUCAL, then this decides
which one to use.
 }\\
 \\
WHICH\_MASK \>Logical       \>
\parbox[t]{75mm}{
If there are more than one MASK in TAUCAL, then this decides
which one to use.
 }\\
 \\
WHICH\_GRID \>Logical       \>
\parbox[t]{75mm}{
If there are more than one GRID in TAUCAL, then this decides
which one to use.
 }\\
 \\
WHICH\_FRAME \>Logical       \>
\parbox[t]{75mm}{
If you are doing RVTs from cubes, then define which frame to
analyse.
 }\\
 \\
CIRCLE\hid \>Logical       \>
\parbox[t]{75mm}{
This is a flag to constrain the axial ratio of the rings to 1.0
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{SIZES}
\begin{description}
 \item[Function]: Write a 2-d map of pixel sizes.
 \item[Description]: SIZES calculates the size in either $X$ or $Y$ of
                     a pixel as a function of its position and puts the
                     results into a 2-d map which is suitable for display.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the TAUCAL file.
 }\\
 \\
AXIS \>Integer       \>
\parbox[t]{75mm}{
You have a choice of either mapping the X pixel size (axis = 1)
or the Y pixel size (axis = 2).
 }\\
 \\
NX \>Integer       \>
\parbox[t]{75mm}{
How big an output map do you want in X?
 }\\
 \\
NY \>Integer       \>
\parbox[t]{75mm}{
How big an output map do you want in Y?
 }\\
 \\
PIX\_MAP \>Fixed string       \>
\parbox[t]{75mm}{
Name of the file to the map of pixel sizes.
 }\\
 \\
NORDER\tc \>Integer       \>
\parbox[t]{75mm}{
Pretty self-explanatory, really...As this is a bivariate
polynomial, the order will be the same in both coordinates.
 }\\
 \\
WHICH\_MASK \>Integer       \>
\parbox[t]{75mm}{
This is the number of the mask sub-structure to use if there
are more than one in the TAUCAL file.
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{TAU\_FITS}
\begin{description}
 \item[Function]: Fit profiles to spectral lines.
 \item[Description]: For a full description of TAU\_FITS, see
                     section~\ref{sec-linefits}
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
NAME\_OBS \>Fixed string       \>
\parbox[t]{75mm}{
This is the phase corrected observation cube for input.  Must be ZXY
sorted BEFORE using this program.
 }\\
 \\
NAME\_FIT \>Fixed string       \>
\parbox[t]{75mm}{
This is the output file for the fit results.  The fit parameters
will be stored in a separate plane for each and the associated
error array will give the parameter error.  Magic values flag
spectra which were either not analysed or failed to converge.
 }\\
 \\
NITER \>Integer       \>
\parbox[t]{75mm}{
Maximum number of iterations for each spectrum.
 }\\
 \\
OPT \>Fixed string       \>
\parbox[t]{75mm}{
This is the option parameter in the main menu.
 }\\
 \\
BOXSIZE \>Integer       \>
\parbox[t]{75mm}{
Data will be averaged over a box of this size.  For obvious
reasons, boxsize should be odd, although it won't be fatal if
it isn't
 }\\
 \\
TYPE\_FIT \>Integer       \>
\parbox[t]{75mm}{
This gives you the option of the fitting function for the
spectra
 }\\
 \\
REJ\_DOM \>Integer array \>
\parbox[t]{75mm}{
Type 1 to reject in a domain or 0 to leave that domain alone.
 }\\
 \\
START \>Float array \>
\parbox[t]{75mm}{
Lower limit on X and Y for action.
 }\\
 \\
END \>Float array \>
\parbox[t]{75mm}{
Upper limit on X and Y for action.
 }\\
 \\
MASK\_THRESH \>Float array \>
\parbox[t]{75mm}{
If the mask has a value between the thresholds at a particular
pixel position then that pixel will be analysed.
 }\\
 \\
NAME\_MASK \>Fixed string       \>
\parbox[t]{75mm}{
This is a 2-d mask image.
 }\\
 \\
DLAM \>Float       \>
\parbox[t]{75mm}{
This is the wavelength increment along the spectral axis.
 }\\
 \\
ALAM0 \>Float       \>
\parbox[t]{75mm}{
This is the wavelength zeropoint along the spectral axis.
 }\\
 \\
FSR \>Float       \>
\parbox[t]{75mm}{
This is the free spectral range of the obs cube at the optical
axis
 }\\
 \\
USE\_MASK \>Logical       \>
\parbox[t]{75mm}{
If true, the you will be prompted for a mask image, lower
and upper thresholds for masking when the limit routine is run.
 }\\
 \\
NEW\_FILE \>Logical       \>
\parbox[t]{75mm}{
If true, then the output file is a new file.
 }\\
 \\
WT\_SCHEME \>Integer       \>
\parbox[t]{75mm}{
The user may weight the points by (1) $\sqrt n$ or (2) equally.
 }\\
 \\
HOW\_GUESS \>Integer       \>
\parbox[t]{75mm}{
This is the choice of guessing algorithm to use.  See section~\ref{sec:main}
 }\\
 \\
NTRIV \>Integer       \>
\parbox[t]{75mm}{
This is the number of times that $\chi^2$ must change by
a trivial amount for the fit to be considered to have
converged.  This number should be greater than 1 as the first
trivial change may be a false alarm.
 }\\
 \\
DCHI \>Float       \>
\parbox[t]{75mm}{
This is a {\em fractional} change in chi-squared, e.g.
$d\chi^2 = \left|(\chi^2_1 - \chi^2_2)\right|/\chi^2_1$.  Therefore if $d\chi^2 = 0.05$,
then there has been a 5 percent change in $\chi^2$.
 }\\
 \\
XTRACT\_FIELD \>Fixed string       \>
\parbox[t]{75mm}{
This is the extracted field output file.
 }\\
 \\
XTRACT\_PAR \>Integer       \>
\parbox[t]{75mm}{
This is the parameter which you want to extract.
 }\\
 \\
RNG\_AMP \>Float array \>
\parbox[t]{75mm}{
Range of amplitudes to keep.
 }\\
 \\
RNG\_POS \>Float array \>
\parbox[t]{75mm}{
Range of peak positions to keep.
 }\\
 \\
RNG\_SIG \>Float array \>
\parbox[t]{75mm}{
Range of sigma to keep.
 }\\
 \\
RNG\_BAC \>Float array \>
\parbox[t]{75mm}{
Range of background to keep.
 }\\
 \\
NSWEEP \>Integer       \>
\parbox[t]{75mm}{
This is the number of sweeps through the monitor array in order
to try an get all of the included spectra...
 }\\
 \\
BATCH\_FIT \>Integer       \>
\parbox[t]{75mm}{
This is a flag which tells the program in batch what you
ultimately want to do.  (1) fit, using a guessing algorithm,
(2) nearest neighbour analysis.
 }\\
 \\
LAM\_CEN \>Float       \>
\parbox[t]{75mm}{
This is the wavelength about which the velocity field is to be
calculated
 }\\
\\
TOL   \>Float   \>
\parbox[t]{75mm}{
This is the tolerance which defines whether or not two velocities
are separated by an integer number of FSRs
}\\
\\
VEL\_FIELD  \>Fixed string  \>
\parbox[t]{75mm}{
This is the file for the input/output velocity field
}\\
\\
SCALE\_Y  \>Logical  \>
\parbox[t]{75mm}{
TRUE if you want to set the min and max values of the Y axis of
all line plots to be the same (e.g. all line plots have the
same scale)
}\\
\\
YRANGE  \>Float array \>
\parbox[t]{75mm}{
This is the min and max values for the Y axes of the line plots.
}
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{TAU\_HEAD}
\begin{description}
 \item[Function]: Write calibration information into a cube header.
 \item[Description]: TAU\_HEAD takes information from a TAUCAL file and
                     writes it into the header of a cube. If a TAUCAL file
                     isn't being used, then the user will be prompted for
                     this information (which may be rather boring).  The results end
                     up in the sub-structure .MORE.TAURUS and are very useful
                     for TAU\_FITS.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the TAUCAL file
 }\\
 \\
IMAGE \>Fixed string       \>
\parbox[t]{75mm}{
This is the file whose header you want to write
 }\\
 \\
RUNNUM \>Integer       \>
\parbox[t]{75mm}{
This is the run number associated with the OBS cube
 }\\
 \\
DLAM\tc \>Float       \>
\parbox[t]{75mm}{
This is the increment along the spectral axis.
 }\\
 \\
ALAM0\tc \>Float       \>
\parbox[t]{75mm}{
This is the zeropoint along the spectral axis.
 }\\
 \\
FSR\tc \>Float       \>
\parbox[t]{75mm}{
This is the free spectral range of the OBS cube at the optical
axis
 }\\
 \\
DMPU\tc \>Float       \>
\parbox[t]{75mm}{
This is the increment on the spectral axis in MPUs/frame.
 }\\
 \\
XCEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the X position of the optical axis
 }\\
 \\
YCEN\tc \>Float       \>
\parbox[t]{75mm}{
This is the Y position of the optical axis
 }\\
 \\
WHICH\_RVF \>Logical       \>
\parbox[t]{75mm}{
If there are more than one RVF in TAUCAL, then this decides
which one to use.
 }\\
 \\
WHICH\_MASK \>Logical       \>
\parbox[t]{75mm}{
If there are more than one MASK in TAUCAL, then this decides
which one to use.
 }\\
 \\
CAMERA\_FOCUS\tc \>Float       \>
\parbox[t]{75mm}{
This is the focal length in microns of the camera used in the
observations.
 }\\
 \\
COL\_FOCUS\tc \>Float       \>
\parbox[t]{75mm}{
This is the focal length in microns of the collimator of the
telescope.
 }\\
 \\
SCALE\tc \>Float       \>
\parbox[t]{75mm}{
This is the scale of the telescope in arcsec/mm
 }\\
 \\
TEL\_NAME\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of the telescope.
 }\\
 \\
CAM\_FNUM\tc \>Float       \>
\parbox[t]{75mm}{
This is the {\em f} number of the camera used for the observations.
 }\\
 \\
TAU\_VER\tc \>Integer       \>
\parbox[t]{75mm}{
This is the TAURUS version number.
 }\\
\\
PIXSIZE\_X\tc \>Float       \>
\parbox[t]{75mm}{
This is the pixel size in microns.
 }\\
 \\
GAP\tc \>Float       \>
\parbox[t]{75mm}{
This is the etalon gap in microns.
 }
 \end{tabbing}
 \end{description}
 \rule {\textwidth}{0.5mm}
\subsection{TMASK}
\begin{description}
 \item[Function]: Find transformation needed to create a grid
                  of uniform scale.
 \item[Description]: TMASK takes the peaks found in FINDPKS and fits
                     a bivariate polynomial to find the transformation
                     between the positions of the peaks in pixel space
                     and their positions on a grid of uniform scale.  The
                     latter has been defined by the known distance in microns
                     between the pinholes in the mask.   An output file called
                     MASK.OUT contains the transformation coefficients and grids
                     of the pixel sizes in each dimension and the axial ratio
                     of the pixels as a function of position on the map.  The
                     coefficients are also stored in the TAUCAL file, if one is
                     being used.
 \item[Parameters]:
 \begin{tabbing}
 camera\_focusxxxxxxx\=typeofvariable\= \kill
USE\_TAU \>Logical       \>
\parbox[t]{75mm}{
This is a flag to indicate whether a TAUCAL file will be used
in this application.
 }\\
 \\
CALFILE \>Fixed string       \>
\parbox[t]{75mm}{
This is the name of your TAUCAL file.
 }\\
 \\
WHICH\_MASK \>Integer       \>
\parbox[t]{75mm}{
This is the number of the mask sub-structure you wish to use, if
there are more than one in the TAUCAL file.
 }\\
 \\
NAME\_MAT\tc \>Fixed string       \>
\parbox[t]{75mm}{
This is the file with the matrix mask image (e.g. pinhole mask).
The file must be 2-d.
 }\\
 \\
MASK\_DIST\tc \>Float       \>
\parbox[t]{75mm}{
This is the actual distance between the pinholes as projected
onto the focal plane.
 }\\
 \\
NORDER \>Integer       \>
\parbox[t]{75mm}{
Pretty self-explanatory, really...As this is a bivariate polynomial,
the order will be the same in both coordinates.
 }\\
 \\
CAMFOC\tc \>Float       \>
\parbox[t]{75mm}{
This is the focal length of the camera in mm.
 }\\
 \\
COLFOC\tc \>Float       \>
\parbox[t]{75mm}{
This is the focal length of the collimator in mm.
 }
 \end{tabbing}
 \end{description}
\newpage
\section{Main Menu Options in TAU\_FITS} \label{app:optmen}
This is a complete listing of all of the available options for
the main menu in TAU\_FITS.  Note that all options can be abbreviated
to a single character.
\begin{table}[htb]
\caption{Main Menu Options in TAU\_FITS}
\begin{center}
\begin{tabular}{|l|l|} \hline
{\em Parameter}&{\em Description}\\ \hline
Boxsize        &Change the size of the smoothing box\\
Converge       &Change the convergence parameters\\
Edit           &Edit the fits in the current $(x,y)$ domain.\\
Fit            &Do fits in the current domains\\
Guess          &Change the guessing algorithm to be used\\
Help           &Print up this help menu\\
Info           &Print information about current set up.\\
Limits         &Define the limits in the current domains\\
Mask           &Decide whether or not to use a mask when setting limits\\
Neighbour      &Do fits with nearest neighbour algorithm\\
Picture        &Plot up a 2-d picture\\
Quit           &Get out of TAU\_FITS.\\
Show           &Show the results for a single spectrum\\
Type           &Change the type of fitting function\\
Weights        &Change the way individual pixels are weighted\\
Velocity       &Remove integral FSR jumps from velocity map\\
Xtract         &Extract a set of results and write them to a file\\
Yscale         &Make Y axis scale the same for all plots\\
Zap            &Reject bulk fits\\ \hline
\end{tabular}
\end{center}
\end{table}
\newpage
\section{Edit Menu Options in TAU\_FITS} \label{app:edmen}
This is a complete listing of all of the available options for
the EDIT menu in TAU\_FITS.  Note that all options can be abbreviated
to a single character.
\begin{table}[htb]
\caption{EDIT Menu Options in TAU\_FITS}
\begin{center}
\begin{tabular}{|l|l|} \hline
{\em Parameter}&{\em Description}\\ \hline
Converge      &Change convergence parameters\\
Fit           &Do fit of current spectrum\\
Guess         &Change the guessing algorithm to be used\\
Help          &Print up this help menu\\
Info          &Print up information on set up of program\\
Next          &Move on to the next panel of spectra\\
Quit          &Get out of EDIT mode\\
Previous      &Look at the previous panel again\\
Redraw        &Redraw the current panel\\
Show          &Display the fit parameters for indicated spectrum\\
Type          &Change the type of fitting function\\
Wipe          &Delete all the fits on the current panel\\
Zap           &Delete the current fit\\ \hline
\end{tabular}
\end{center}
\end{table}
\end{document}
