\documentclass[11pt,twoside]{article}
\usepackage{adassconf}
%\usepackage{english}

\begin{document}

\paperID{P4-2}
%%%% ID=P4-2

\contact{J{\"u}rgen Schreiber, Max-Planck-Institut f{\"u}r extraterrestrische Physik, Postfach 1312, D-85741 Garching, Germany}
\email{schreib@mpe.mpg.de}

\title{Data Reduction Software for the VLT Integral Field Spectrometer SPIFFI}
\iffalse	%%% TOO LONG !
\titlemark{Data Reduction Software for the VLT Integral Field Spectrometer SPIFFI}
\else
\titlemark{Data Reduction Software for SPIFFI}
\fi
\authormark{Schreiber, Thatte, Eisenhauer, Tecza, Abuter, \& Horrobin}

\author{J{\"u}rgen Schreiber, Frank Eisenhauer, Matthias Tecza, Roberto Abuter, and Matthew Horrobin}
\affil{Max-Planck-Institut f{\"u}r extraterrestrische Physik, Postfach 1312, D-85741 Garching, Germany}
\author{Niranjan Thatte}
\affil{University of Oxford, Dept. of Astrophysics, Denys Wilkinson Building, Keble Road, Oxford OX1 3RH, UK}

\paindex{Schreiber, J.}
\aindex{Thatte, N.}
\aindex{Eisenhauer, F.}
\aindex{Tecza, M.}
\aindex{Abuter, R.}
\aindex{Horrobin, M.}

\keywords{data: reduction, pipelines, Spiffi, Sinfoni, Python, IFU} 

\begin{abstract}
A data reduction software package is developed to reduce data of the near-IR integral field spectrometer SPIFFI built at MPE. 
The basic data reduction routines are coded in ANSI C. The high level scripting language Python is used 
to connect the C-routines allowing fast prototyping. 
Several Python scripts are written to produce the needed calibration data and to generate the final result, 
a wavelength calibrated data cube with the instrumental signatures removed.
\end{abstract}


\section{Introduction}
The near-IR integral field spectrometer SPIFFI built at MPE was attached to the UT2 (Kueyen) telescope of the VLT
between February and April 2003 as a guest instrument with a total amount of 20 observing nights.\par
A data reduction software package was developed to be able to reduce SPIFFI data on a Unix-machine in the telescope control room
in the manner of an offline reduction pipeline. The basic data reduction routines are written in ANSI C. 
An interface between the freely available high level scripting language Python and the C-library was built to use Python
to connect the C-functions allowing fast prototyping. This interface is generated automatically by using the freely available
software SWIG. Basic FITS handling and image arithmetics routines are used from a linked Eclipse library (Devillard 1999).\par
A library of Python scripts was developed to launch reduction pipelines by using individual, editable input parameter files. 
These scripts are used to produce the necessary calibration data (several FITS- and ASCII files) and to generate the final result, 
a wavelength calibrated data cube from which the instrumental signature is removed. The final FITS data cube comprises 
32 by 32 spatial pixels (monochromatic images) and 2560 spectral pixels. 

\section{Short Description of the Instrument}
The heart of SPIFFI is an image slicer. The image slicer consists of two components, called the small and large slicer, 
which are a set of small plane mirrors with different tilt angles. It dissects the field of view in the object plane into 32 pieces
and rearranges them on a brickwall pattern like pseudo longslit consisting of so-called slitlets. 
Afterwards, each spatial pixel is dispersed by a grating and projected on a 1K detector. The result is a raw detector frame
comprising 32x32 (1024) spatial pixels (x-direction) and 1024 undersampled spectral pixels (y-direction) (Eisenhauer et al.
2000, 2003). \par Figure \ref{P4-2:fig1} (left hand side) shows an example of a K-band raw frame gained from a Neon arc lamp placed in an integrating sphere. 
The emission lines (indicating the slitlets) arranged in a brickwall pattern can be seen clearly. Such emission line frames 
are used to generate wavelength maps that associate pixel positions with wavelength values.


\section{Data Flow}
The reduction steps are sky-subtraction, flat-fielding, bad pixel interpolation, 
correction of a spectral tilt relative to the image columns, interleaving of two spectrally dithered frames 
to achieve fully sampled spectra, resampling on a linearized wavelength scale, 
data cube construction and combination of jittered (mosaicked) cubes.\par
Necessary calibration files are FITS frames like flatfields, dark frames, bad pixel masks, wavelength maps,
and ASCII files containing parameters like the slope of the spectral tilt and the distances of the slitlets to each other. 
They can also be produced in a pipeline like manner using different Python scripts.


\section{Data Cube Construction}
Figure \ref{P4-2:fig1} (right hand side) depicts an interleaved and wavelength calibrated Neon frame 
resampled on a regular linear wavelength grid in which
each row has a defined wavelength (the brickwall pattern and slit curvature disappeared).
Each row of such a resampled, wavelength calibrated frame yields one monochromatic 32x32 pixel image by stacking the slitlets on each other keeping
the correct sequence. 
To be able to construct these images the distances of the slitlets to each other must be known. They are measured by using a slit
illuminated by a halogen lamp that generates continuum spectra perpendicular to the slitlets. After fitting the positions of the spectra
the average distances are calculated. The resulting monochromatic images are stacked behind each 
other in z-direction to form a cube with 2560 spectral pixels which is stored as a FITS data cube. \par
Figure \ref{P4-2:fig2} shows an example of mosaicked jittered cubes: a collapsed cube of the galactic center (Eisenhauer et al. 2003). 
26 single cubes were merged into a 128x146x2560 pixel cube (192 MBytes).


\begin{figure}
\plottwo{P4-2_1l.eps}{P4-2_1r.eps}
\caption{Raw (left) and interleaved, resampled and wavelength calibrated (right) Neon arc lamp frame} \label{P4-2:fig1}
\end{figure}

\begin{figure}
\epsscale{0.6}
\plotone{P4-2_2.eps}
\caption{Mosaicked collapsed data cube of the galactic center} \label{P4-2:fig2}
\end{figure}

\section{Summary and Conclusions}
\begin{itemize}
\itemsep-0.005cm
\item First science data was successfully reduced by applying the available Python scripts.
\item The software will be implemented in ESO's Common Pipeline Library (CPL) and used for the SINFONI online pipeline.
\item Software to convert the SPIFFI data cube to the Euro3D data format is already developed.
\item The software is easily expandable for example for a planned 2K detector.
\end{itemize}

\acknowledgements
We want to thank Christoph Iserlohe, Nicolas Devillard, and Andrea Modigliani 
for their important contributions to this work.

\begin{references}
\reference Devillard, N. 1999 \adassviii, 333
\reference Eisenhauer, F., Tecza, M., Mengel, S., Thatte, N., R{\"o}hrle, C., Bickert, K., \& Schreiber, J. 2000, Proc. SPIE, 4008, 289
\reference Eisenhauer, F. et al. 2003, The ESO Messenger 113, 17
\end{references}

\end{document}
