%APN3_PROCEEDINGS_FORM%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% TEMPLATE.TEX -- APN3 (2003) ASP Conference Proceedings template.
%
% Derived from ADASS VIII (98) ASP Conference Proceedings template
% Updated by N. Manset for ADASS IX (99), F. Primini for ADASS 2000,
% D.Bohlender for ADASS 2001, and H. Payne for ADASS XII and LaTeX2e.
%
% Use this template to create your proceedings paper in LaTeX format
% by following the instructions given below.  Much of the input will
% be enclosed by braces (i.e., { }).  The percent sign, "%", denotes
% the start of a comment; text after it will be ignored by LaTeX.  
% You might also notice in some of the examples below the use of "\ "
% after a period; this prevents LaTeX from interpreting the period as
% the end of a sentence and putting extra space after it.  
% 
% You should check your paper by processing it with LaTeX.  For
% details about how to run LaTeX as well as how to print out the User
% Guide, consult the README file.  You should also consult the sample
% LaTeX papers, sample1.tex and sample2.tex, for examples of including
% figures, html links, special symbols, and other advanced features.
%
% If you do not have access to the LaTeX software or a laser printer
% at your site, you can still prepare your paper following the
% instructions in the User Guide.  In such cases, the editors will
% process the file and make any necessary editorial adjustments.
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
\documentclass[11pt,twoside]{article}  % Leave intact
\usepackage{adassconf}

% If you have the old LaTeX 2.09, and not the current LaTeX2e, comment
% out the \documentclass and \usepackage lines above and uncomment
% the following:

%\documentstyle[11pt,twoside,adassconf]{article}

\begin{document}   % Leave intact

%-----------------------------------------------------------------------
%			    Paper ID Code
%-----------------------------------------------------------------------
% Enter the proper paper identification code.  The ID code for your
% paper is the session number associated with your presentation as
% published in the official conference proceedings.  You can           
% find this number locating your abstract in the printed proceedings
% that you received at the meeting or on-line at the conference web
% site; the ID code is the letter/number sequence proceeding the title 
% of your presentation. 
%
% This will not appear in your paper; however, it allows different
% papers in the proceedings to cross-reference each other.  Note that
% you should only have one \paperID, and it should not include a
% trailing period.
%
% EXAMPLE: \paperID{O4-1}
% EXAMPLE: \paperID{P7-7}
%

\paperID{P10-13}
%%%% ID=P10-13

%-----------------------------------------------------------------------
%		            Paper Title 
%-----------------------------------------------------------------------
% Enter the title of the paper.
%
% EXAMPLE: \title{A Breakthrough in Astronomical Software Development}
% 
% If your title is so long as to fill the page header when you print it,
% then please supply a short form as a \titlemark.
%
% EXAMPLE: 
%  \title{Rapid Development for Distributed Computing, with Implications
%         for the Virtual Observatory}
%  \titlemark{Rapid Development for Distributed Computing}
%

\title{Comparison of Echelle Spectra Reduction Packages  }
%\titlemark{ }

%-----------------------------------------------------------------------
%		          Authors of Paper
%-----------------------------------------------------------------------
% Enter the authors followed by their affiliations.  The \author and
% \affil commands may appear multiple times as necessary (see example
% below).  List each author by giving the first name or initials first
% followed by the last name.  Authors with the same affiliations
% should grouped together. 
%
% EXAMPLE: \author{Raymond Plante, Doug Roberts, 
%                  R.\ M.\ Crutcher\altaffilmark{1}}
%          \affil{National Center for Supercomputing Applications, 
%                 University of Illinois Urbana-Champaign, Urbana, IL
%                 61801}
%          \author{Tom Troland}
%          \affil{University of Kentucky}
%
%          \altaffiltext{1}{Astronomy Department, UIUC}
%
% In this example, the first three authors, "Plante", "Roberts", and
% "Crutcher" are affiliated with "NCSA".  "Crutcher" has an alternate 
% affiliation with the "Astronomy Department".  The fourth author,
% "Troland", is affiliated with "University of Kentucky"

\author{Petr \v{S}koda, Miroslav \v{S}lechta }
\affil{ Astronomical Institute of the Academy of Sciences of the Czech Republic} 

%-----------------------------------------------------------------------
%			 Contact Information
%-----------------------------------------------------------------------
% This information will not appear in the paper but will be used by
% the editors in case you need to be contacted concerning your
% submission.  Enter your name as the contact along with your email
% address.
% 
% EXAMPLE:  \contact{Dennis Crabtree}
%           \email{crabtree@cfht.hawaii.edu}
%

\contact{Petr Skoda}
\email{skoda@sunstel.asu.cas.cz}


%-----------------------------------------------------------------------
%		      Author Index Specification
%-----------------------------------------------------------------------
% Specify how each author name should appear in the author index.  The 
% \paindex{ } should be used to indicate the primary author, and the
% \aindex for all other co-authors.  You MUST use the following
% syntax: 
%
% SYNTAX:  \aindex{Lastname, F. M.}
% 
% where F is the first initial and M is the second initial (if
% used).  This guarantees that authors that appear in multiple papers
% will appear only once in the author index.  
%
% EXAMPLE: \paindex{Crabtree, D.}
%          \aindex{Manset, N.}        
%          \aindex{Veillet, C.}        
%
% NOTE: this information is also used to build the author list that
% appears in the table of contents.  Authors will be listed in the order
% of the \paindex and \aindex commmands.
%
\paindex{Skoda@\v{S}koda, P.}
\aindex{Slechta@\v{S}lechta, M.}     % Remove this line if there is only one author

%-----------------------------------------------------------------------
%		      Author list for page header	
%-----------------------------------------------------------------------
% Please supply a list of author last names for the page header. in
% one of these formats:
%
% EXAMPLES:
% \authormark{Lastname}
% \authormark{Lastname1 \& Lastname2}
% \authormark{Lastname1, Lastname2, ... \& LastnameN}
% \authormark{Lastname et al.}
%
% Use the "et al." form in the case of seven or more authors, or if
% the preferred form is too long to fit in the header.

\authormark{\v{S}koda \& \v{S}lechta }

%-----------------------------------------------------------------------
%			Subject Index keywords
%-----------------------------------------------------------------------
% Enter a comma separated list of up to 6 keywords describing your
% paper.  These will NOT be printed as part of your paper; however,
% they will be used to generate the subject index for the proceedings.
% There is no standard list; however, you can consult the indices
% for past proceedings (http://adass.org/adass/proceedings/).
%
% EXAMPLE:  \keywords{visualization, astronomy: radio, parallel
%                     computing, AIPS++, Galactic Center}
%
% In this example, the author noticed that "radio astronomy" appeared
% in the ADASS VII Index as "astronomy" being the major keyword and
% "radio" as the minor keyword.  The colon is used to introduce another
% level into the index.

\keywords{data: reduction, spectroscopy: echelle, spectral orders, calibration: wavelength}

%-----------------------------------------------------------------------
%			       Abstract
%-----------------------------------------------------------------------
% Type abstract in the space below.  Consult the User Guide and Latex
% Information file for a list of supported macros (e.g. for typesetting 
% special symbols). Do not leave a blank line between \begin{abstract} 
% and the start of your text.

\begin{abstract}          % Leave intact
% Place the text of your abstract here - NO BLANK LINES
The reduction of raw echelle data is a straightforward, although quite
complicated task, where the reliability of the final result strongly depends on
precise accomplishment of each step. Therefore the choice of reduction package
best suited for the particular instrument is very important.  We have tested
several software packages commonly used for reduction of data from fiber-fed
echelle spectrographs. We used them for processing of raw CCD echellegram of
early-type stars secured with HEROS fiber echelle spectrograph currently
installed at Cassegrain focus of Ond\v{r}ejov observatory 2m telescope.  The
main interest was focused on the methods and algorithms of determination of
dispersion relation. The spectra were reduced until the individual
one-dimensional lambda-calibrated orders were obtained. The precision of
wavelength calibration was then compared. 
 \end{abstract}

%-----------------------------------------------------------------------
%			      Main Body
%-----------------------------------------------------------------------
% Place the text for the main body of the paper here.  You should use
% the \section command to label the various sections; use of
% \subsection is optional.  Significant words in section titles should
% be capitalized.  Sections and subsections will be numbered
% automatically. 
%
% EXAMPLE:  \section{Introduction}
%           ...
%           \subsection{Our View of the World}
%           ...
%           \section{A New Approach}
%
% It is recommended that you look at the sample papers, sample1.tex
% and sample2.tex, for examples for formatting references, footnotes,
% figures, equations, html links, lists, and other special features.  

\section{Introduction}
Although quite complicated, the main part of echelle reduction is quite
straightforward and the automatic pipelines can be used to reduce the data until
the stage of individual wavelength-calibrated echelle orders. 

To check the quality of resulting spectra using different reduction packages, we
have selected a single exposure of hot star $\iota$\,Her secured by HEROS red
channel with 2 flat fields and 2 comparison arcs bracketing the stellar
exposure. The data had to be individually modified into the format required by
particullar package, but the principial reduction tasks were the same. The outputs
were converted into IRAF echelle format and compared in {\tt spectool} task.


\section{Brief Description of Packages}

\subsection{Standard HEROS Pipeline}

This is a set of MIDAS procedures and C and Fortran functions written by
A. Kaufer and O. Stahl as a customized version of standard MIDAS {\tt echelle}
context.  It is described by {\v S}koda and {\v S}lechta~(2002).  Before
processing the bad columns and pixels are interpolated on 2D frame using the
defect list.

It tries to be robust for orders with low flux  by fitting the 2-dimensional
polynomials of low degree through the Gaussian fitted cross-order profile
maxima, but the tracing of orders is sensitive on the tiny twiddling of parameters
(mainly threshold, order width and order slope).
Sometimes the algorithm is confused and such parts of low-flux data have to be
removed before tracing.

The dispersion fitting is quite clever and robust using several manually marked
lines at 2D image to fit a 2D low-order polynomial, than switches to order by
order line identification automatically adding more lines from the list and
again switching to 2D polynomials. 

The specific feature of the HEROS extension to the basic MIDAS echelle context
is the application of global 7-parameter (only) rational-polynomial fit
described by De~Cuyper and Hensberge (1998) on the final dispersion calibration. 


\subsection{Hensberge's Modified FEROS Package}

This is a custom package developed by H. Hensberge for reducing data from FEROS
spectrograph. It uses the basic FEROS package but corrects a number of errors
and strongly modifies the behaviour of several procedures
\htmladdnormallinkfoot{}{http://www.ls.eso.org/lasilla/sciops/2p2/E1p5M/FEROS/Reports/Draft/}.
It was partly modified for accepting data from HEROS. Due to various reasons,
however, the wavelength calibration was not successfully adapted to HEROS frames
and so the dispersion relation from preceding HEROS pipeline  was taken for this
test.  The order tracing is done using the cross-correlation with
Gaussian-shaped template of a averaged cross-order profile beginning in the
centre of frame and going to both ends or until the trace is lost. The fit is
then done order by order.

The background subtraction is done very carefully, using the digital filter and noise
statistics to fit 2D surface in inter-order space.  The extraction is done twice
- once with optimal variance weighting rejecting pixels deviating from
normalized cross-order profile (COP) and once using the plain aperture summing. 
By comparison of both results
the  cosmics and bad pixels are flagged and removed from optimal extracted data
by interpolation. The procedure runs well on individual bad pixels or columns
but fails on adjacent two or more of them.

This package has well-controlled behaviour and its precision had been well
tested on the number of FEROS spectra.


\subsection{IRAF {\tt dofoe} Task}

The {\tt dofoe}\htmladdnormallinkfoot{}{http://iraf.noao.edu/scripts/irafhelp?val=dofoe}
task was used separately on averaged flat field and stellar exposure and the
extracted data were divided by {\tt imarith}. The dispersion was then applied
using {\tt dispcorr} on flat-fielded extracted stellar orders taken from lambda
calibrated extracted star.  The main reason for this is the behaviour of
standard {\tt dofoe} that divides not by extracted flat-field but by
 {\tt Flatnorm.ec} that is normalized to intensity  about one. That preserves the
amount of ADU but scales the data in comparison to MIDAS approach and makes the
direct comparison difficult.

The tracing here is done using the automatic aperture finding in center of frame
following the position of COP fits using the {\tt fit1d} algorithm similar to
cross-correlation.  The extraction is optimal with cosmics cleaning and variable
aperture with taking the certain level (in our case 0.001) of the COP peak as
the background level. The background subtraction is using smoothed 2D surface
obtained from inter-order space minima (method {\tt scattered}).

The real challenge is the wavelength calibration with {\tt ecidentify} task
called from {\tt dofoe}.  Only the 1D separate orders are seen and the number of
lines required to get initial fit is quite high. After number of test we had to
mark about 100 lines to get reliable result. One has to be careful mainly at the
edges of orders and in IR orders (where is a lack of good Th lines and a number
of overexposed Ar lines). This may be tested by over-plotting adjacent orders.

\section{The Wavelength Calibration Methods}

As was said, the modified FEROS pipeline has to take the dispersion solution
from HEROS pipeline, so we can compare only the different  approaches  of MIDAS
and  IRAF respectively. In both cases we used the line list of 145 carefully
selected lines of Th and Ar over the HEROS red channel range (5800 -- 8400 \AA).
Then a number of lines was identified manually. For MIDAS package only 20 lines
spread over the entire frame  were enough to be able to run the automatic
finding procedure {\tt echiden} and achive the RMS about 0.01~\AA .

In IRAF case of procedure {\tt ecidentify} we had to mark manually about 100
lines to run the fitting procedure reliably.  Optimizing the rejection and
matching parameters and increasing the degree of 2D polynomials until the degree
6 (in x) and 5 in order coordinate  we achieved about the same RMS.  It
requires, however, 56 coefficients in comparison to 7 of MIDAS and it is less
reliable at the edges of frame or in orders contaminated by strong Ar lines (in
near IR). The extracted data were in both cases linearly rebinned to get
equidistant intervals in wavelength. 

\section{Comparison of Reduced Spectra}

The resulting extracted echelle orders unblazed by division of extracted flats
are compared on following pictures. The slight detected differences indicates
how the particular algorithm behaves.

\begin{figure} 
\begin{center}
\plotfiddle{P10-13_1.eps}{4.5cm}{0}{45}{55}{-244}{-177}
\plotfiddle{P10-13_2.eps}{1cm}{0}{45}{55}{-60}{-135.5}
 \caption{Comparison of results from HEROS (dotted line), modified FEROS (dashed line) and IRAF
 {\tt dofoe} (full line) packages}
\end{center}
\end{figure}


The incomplete background subtraction and variable aperture ({\tt resize=yes})
of IRAF is probably responsible for  change in flux level (see left panel of
Fig.~1).

Despite the small changes of line positions caused by different rebinning the
dispersion calibration in IRAF case is not perfect, and the problems of anchoring
the polynomials at edges may cause the incorrect dispersion fit in orders with
small number of usable lines,  as is shown at the edge of the frame in IR region
(see right panel of Fig.~1).


\section{Conclusions}
 
The tests have shown the good match of output from all three packages.  The
wavelength calibration procedure in MIDAS is much more comfortable and more
robust.  The IRAF approach requires many lines to be manually identified and the
2-dimensional polynomials have problems at the edges, so one should carefully
check the match of order overlaps. 


Despite the tiny differences, all packages may be used to produce reliable
echelle spectra from fiber-fed instruments.  The small differences seen in the
flux level depend  mainly on correct background subtraction. From our experience
follows the idea that a simple robust package would be IRAF {\tt dofoe}  task
calling completely different {\tt ecidentify} procedure working like MIDAS
 {\tt echiden} task and using the 2D manual line identification and global
7-parametric fit of  De~Cuyper and Hensberge.

\acknowledgments This work was supported by grant GA \v{C}R 102/02/1000.  The
Astronomical Institute Ond\v{r}ejov is supported by projects K2043105 and
Z1003909. 



%-----------------------------------------------------------------------
%			      References
%-----------------------------------------------------------------------
% List your references below within the reference environment
% (i.e. between the \begin{references} and \end{references} tags).
% Each new reference should begin with a \reference command which sets
% up the proper indentation.  Observe the following order when listing
% bibliographical information for each reference:  author name(s),
% publication year, journal name, volume, and page number for
% articles.  Note that many journal names are available as macros; see
% the User Guide listing "macro-ized" journals.   
%
% EXAMPLE:  \reference Hagiwara, K., \& Zeppenfeld, D.\  1986, 
%                Nucl.Phys., 274, 1
%           \reference H\'enon, M.\  1961, Ann.d'Ap., 24, 369
%           \reference King, I.\ R.\  1966, \aj, 71, 276
%           \reference King, I.\ R.\  1975, in Dynamics of Stellar 
%                Systems, ed.\ A.\ Hayli (Dordrecht: Reidel), 99
%           \reference Tody, D.\  1998, \adassvii, 146
%           \reference Zacharias, N.\ \& Zacharias, M.\ 2003,
%                \adassxii, \paperref{P7.6}
% 
% Note the following tricks used in the example above:
%
%   o  \& is used to format an ampersand symbol (&).
%   o  \'e puts an accent agu over the letter e.  See the User Guide
%      and the sample files for details on formatting special
%      characters.  
%   o  "\ " after a period prevents LaTeX from interpreting the period 
%      as an end of a sentence.
%   o  \aj is a macro that expands to "Astron. J."  See the User Guide
%      for a full list of journal macros
%   o  \adassvii is a macro that expands to the full title, editor,
%      and publishing information for the ADASS VII conference
%      proceedings.  Such macros are defined for ADASS conferences I
%      through XI.
%   o  When referencing a paper in the current volume, use the
%      \adassxii and \paperref macros.  The argument to \paperref is
%      the paper ID code for the paper you are referencing.  See the 
%      note in the "Paper ID Code" section above for details on how to 
%      determine the paper ID code for the paper you reference.  
%
\begin{references}
\reference de Cuyper, J.-P. \& {Hensberge}, H. 1998, \aaps, 128, 409
\reference {\v S}koda, P. \& {{\v S}lechta}, M. 2002, in Publ. Astron. Inst.~ASCR, 90, 40
\end{references}

% Do not place any material after the references section

\end{document}  % Leave intact
