\documentclass{mem}
\usepackage{natbib}\usepackage{txfonts}\usepackage{balance}
\usepackage{graphicx}
\usepackage[a4paper]{hyperref}
\idline{0}{0}
\begin{document}
\def\cms{$\textrm {cm s}^{-1}$}

\title{Data treatment towards the ELT age}

\subtitle{The ESPRESSO case}

\author{
\mbox{G. \,Cupani}\inst{1}
\and \mbox{S. \,Cristiani}\inst{1}
\and \mbox{V. \,D'Odorico}\inst{1}
\and \mbox{J.~I. \,Gonz\'alez-Hern\'andez}\inst{2}
\and \mbox{C. \,Lovis}\inst{3}
\and \mbox{A.~G. \,Segovia Milla}\inst{3}
\and \mbox{S. \,Sousa}\inst{4}
\and \mbox{D. \,Sosnowska}\inst{3}
\and \mbox{P. \,Di Marcantonio}\inst{1}
\and \mbox{D. \, M\'egevand}\inst{3}
}

\offprints{G. Cupani (\email{cupani@oats.inaf.it})}
 
\institute{
Istituto Nazionale di Astrofisica -- Osservatorio Astronomico di Trieste, 
Via Tiepolo 11, I-34143 Trieste, Italy
\and
Instituto de Astrof\'isica de Canarias, 
V\'ia L\'actea, E-38205 La Laguna, Tenerife, Spain
\and
Universit\'e de Gen\`eve, 
51 Chemin des Maillettes, CH-1290 Versoix, Switzerland
\and
Centro de Astrof\'isica da Universidade do Porto, 
Rua das Estrelas, PT-4150-762 Porto, Portugal
}

\authorrunning{Cupani}

\titlerunning{Data treatment towards the ELT age}

\abstract{
Several ambitious scientific projects are currently pushing the limits of astrophysical spectroscopy, in terms of wavelength accuracy and long-term stability. These objectives put strong constraints also on the treatment of observational data, requiring dedicated software to be developed as an integral part of the instrument. In this context, a key role will be played by ESPRESSO, an ultra-stable, high-resolution spectrograph for the VLT. ESPRESSO will be the first ESO instrument to be delivered with a dedicated tool for data analysis, in addition to data reduction. New solutions to treat ESPRESSO data have been developed in view of their application to the the next-generation spectrographs.

\keywords{
Instrumentation: spectrographs -- Methods: data analysis -- Cosmology: observations }
}
\maketitle{}

\section{Introduction}
In the recent years, observational cosmology is gradually evolving into a precision science. A number of compelling projects depend on the possibility to observe with unprecedented accuracy the absorption features imprinted on the spectra of distant sources (e.g.~quasars) by the intervening inter-galactic medium (IGM). A description of the current scenario can be found in another contribution to this volume \citep{cristiani+15}; we recall here only the most relevant science cases in the field of fundamental physics. These are: (i) the measurement of a possible variability of the dimensionless constants $\alpha$ (fine-structure constant) and $\mu$ (proton-to-electron mass ratio) across the cosmic time (detected from a redshift-dependent shift between associated absorption lines: see e.g.~\citealt{webb+11}, \citealt{king12}, \citealt{rahmani+13}), and (ii) the direct observation of the expansion of the Universe from the determination of a time-drift in the redshift of absorbers, the so-called Sandage test \citep{liske+08}. 

Both these science cases pose extreme technological challenges, as they require high sensitivity (to achieve a significant signal-to-noise ratio with $z>2$ sources), high resolution over a wide wavelength range (to resolve and correlate distant absorption lines), and an extreme thermo-mechanical stability. The required wavelength accuracy is \mbox{$\sim$$10$ \cms} for the fundamental constant variability and \mbox{$\sim$$1$ \cms} (to be maintained across at least two decades) for the Sandage test. To achieve these limits, specifically-designed instruments have been conceived. One such instrument is ESPRESSO \citep{pepe+13}, the Echelle SPectrograph for Rocky Exoplanets And Stable Spectral Observations, currently under construction for the ESO Very Large Telescope.

In this article we discuss the case of ESPRESSO as a forerunner to the high-resolution spectrograph envisioned for the European Extremely Large Telescope (E-ELT) \citep{maiolino+13,oliva+15}. We will focus in particular on the scientific software which is meant to complement both instruments to fully exploit their capabilities. A new science-driven approach to instrument design is described, the so-called ``science machine'' concept, which regards the data treatment as an integral part of the spectrograph. The key idea is that the exceptional requirements raised by the current age of high-precision cosmology cannot be met without implementing \emph{ad-hoc} solutions to extract scientific information from the data.

\section{ESPRESSO}
ESPRESSO is an ultra-stable, fibre-fed echelle spectrograph which combines and enhances the capabilities of UVES \citep{dekker+01}, HARPS \citep{mayor+03}, and HARPS-N \citep{cosentino+12}. Its first light is foreseen for 2017. It will operate at very high (130,000 to 200,000) and high (55,000) resolution using respectively one or all four VLT Unit Telescopes (UT), thanks to its location in the coud\'e combined laboratory of Paranal. In the 4-UT mode, the equivalent collecting area will be the same of a 16 meter telescope; in the 1-UT mode, the wavelength accuracy will be better than 10 \cms. All these specifications are meant to bridge the gap towards E-ELT high-resolution spectrograph, which will profit from a 39-meter telescope collecting area and will reach an accuracy of 1 \cms, using similar solutions (vacuum vessels and thermal chambers) to maintain stability. 

ESPRESSO's main science cases are the search of Earth-like exoplanets in the habitable zone and the study of fundamental constant variability; as a consequence, it will observe mainly stars and quasars. This very consistent set of targets strongly favours the development of a dedicated software suite covering all the requirements of data treatment. In fact, ESPRESSO is the first VLT instrument to include among its deliverables a tool to analyse the data, the Data Analysis Software (DAS), developed alongside the customary Data Reduction Software (DRS). The first complete release of both packages is foreseen for the end of 2015.

Both the DRS and the DAS are designed and written in compliance with the ESO Data Flow System, which manages all the steps from observation preparation to data treatment and archiving. They consist of independent ANSI-C plug-ins (``recipes'') based on the ESO Common Pipeline Library (CPL; \citealt{mckay+04}), each one performing a separate operation. The plug-ins can be executed as stand-alone modules or in cascade (``pipeline''); the DRS recipes, in particular, will be triggered on the fly by the injection of raw data as soon as they are produced by the instrument, while the DAS will be called at the user's discretion. In this respect, ESPRESSO will work as a real ``machine to produce science'', as the observers will be able to obtain high-level science products from the instrument (e.g. radial velocities of stars; accurate wavelengths, column densities, and Doppler widths of the absorbers towards distant quasars) within minutes after the execution of the observing blocks. The DAS is particularly relevant in this framework as it allows to close the data flow cycle, by driving the preparation of new observations depending on the scientific output of the previous ones. This model will naturally fit in the E-ELT high-resolution spectrograph concept.

\subsection{Data Reduction Software}
The DRS includes 12 recipes, responsible for (i) creating a master bias, a master dark, and a master flat; (ii) determining the gain, the pixel linearity and the location of bad and hot pixels; (iii) determining the position and geometry of the orders, the geometry of pixels, and the wavelength calibration; (iv) computing the relative efficiency of the fibres, removing contamination and performing flux calibration; and (v) extracting the spectrum of the science target. 

The most innovative calibration source of ESPRESSO is the Laser-Frequency Comb (LFC; \citealt{wilken+12}, \citealt{locurto+12}), which consists of a regular array of laser-generated emission lines spanning the whole wavelength range of the instrument, with a foreseen accuracy is $\Delta\lambda/\lambda\sim 10^{-10}$. The LFC output will be available as a simultaneous reference spectrum on the same frame of the science observations; besides for wavelength calibration, it can be used to monitor any irregularities in size and sensitivity of the detector pixel grid. The assumption that all pixels have equal size can lead to systematic errors of tens of \mbox{$\textrm {m s}^{-1}$} \citep{molaro+13}. Tests on HARPS-N show that the LFC is capable of determining relative variations in pixel size of $\sim$$10^{-4}$, whose effect would be unrecoverable by flat-fielding alone. The DRS will monitor and correct for such irregularities.

Another relevant feature of the ESPRESSO approach to data reduction is the conservative treatment of detector readings (i.e. photon counts and relative errors). It is quite common, when reducing echelle spectra with curved order, to ``rectify'' them into a single merged spectrum whose pixels do not correspond one-to-one to the original detector pixels. This process, called ``rebinning'', is performed during wavelength calibration by combining the contribution of different pixels, and introduces a spurious correlation in the flux errors \citep{bonifacio05}. Under such circumstances, standard best-fitting techniques like the $\chi^2$ test, although routinely applied, cannot be safely used to interpret the spectral features. On the contrary, the DRS will propagate the detector pixels throughout the reduction chain with their original wavelengths, as determined by the LFC. Along with the standard rebinned spectrum, a set of non-rebinned \mbox{2-d} matrices will be issued, containing the flux values, the relative errors, and the wavelengths of all pixels in the different echelle orders.

\begin{figure*}[t!]
\resizebox{\hsize}{!}{\includegraphics[clip=true]{chi-squared.eps}}
\caption{\footnotesize Value of $\chi^2$ computed on 10,000 realisation of a simulated absorption line. Left panel: results with a rebinned spectrum obtained combining 10 simulated exposures (11 pixels); right panel: results with the collective spectrum of all the exposures (110 pixels). Three tests were performed: (a) we run the code to determine the best-fitting line parameters (i.e. position, column density, Doppler width), (b) we compared the individual realisations with the known theoretical profile, and (c) we run the code on a null line (i.e. on a spectrum of un-absorbed, normalized continuum). The degrees of freedom in the latter two cases correspond to the number of pixels, while in the first case this value is decreased by the number of fitted parameters. The obtained distributions of reduced $\chi^2$ values (bold, thin, and thin dashed histograms, for (a), (b), and (c) respectively) are superimposed to the expected theoretical distributions (bold and thin lines); the relevant location parameters of the distributions are also given (theoretical values in italic).}
\label{chi-squared}
\end{figure*}
\subsection{Data Analysis Software}
The DAS includes of 13 recipes, split into two branches, for the analysis of stellar and quasar spectra respectively \citep{cupani+15}. The stellar recipes are responsible for (i) measuring the radial velocity of the star, either with the cross-correlation method or by comparison with synthetic spectra; (ii) computing the stellar activity indexes; (iii) estimating the stellar continuum and comparing observed spectra with synthetic spectra; (iv) measuring the equivalent width of absorption lines and  estimating of the effective temperature and [Fe/H] metallicity (only for FGK stars). The quasar recipes are responsible for (i) determining the level of the quasar continuum emission; (ii) fitting Voigt profiles to the absorption lines; and (iii) identifying the absorption systems, assigning to each line the ionic transition that most probably produced it. A set of common utilities have also been developed to combine different exposures of the same object, to mask spectral regions, and to detect the absorption lines.

The DAS was designed to combine the somehow conflicting needs of automation, control, and flexibility. Unlike data reduction, data analysis is not a one-way procedure. Users typically refine the results through multiple iterations; in the case of quasar spectra analysis, in particular, each task takes advantage from the results of the others. This model will be implemented in the software by exploiting the capabilities of the Reflex enviroment \citep{freudling+13}, which is currently offered by ESO as the primary interface to the instrument pipelines. Reflex is developed within the Kepler workflow engine and takes care of organizing the I/O data, executing the recipes, and interactively displaying the results. Using Python scripts, we have devised a way to feed into the workflow the information extracted from its previous executions. 

Algorithmically, the DAS implements several new solutions. An iterative technique for estimating the level of quasar continuum emission \citep{cupani+15} has been implemented, relying on a progressive removal of all the absorption features (modeled with Voigt profiles). The Voigt-fitting module employs the package \texttt{gsl\_multifit} from the GNU Scientific Library (GSL, \citealt{galassi+09}) and applies the $\chi^2$-test on the non-rebinned \mbox{2-d} spectra produced by the DRS. 

The reliability of the fitting procedure has been widely tested on simulated absorption line; some results are shown in Fig.~\ref{chi-squared}. As expected, the fit is not well constrained when performed on rebinned spectra (left panel): the median of distribution of $\chi^2$ values obtained over 10,000 different realizations  departs from the expected values, partly because the errors are underestimated (due to rebinning) and partly because the degrees of freedom (d.o.f.) are ill-defined (since the line parameters are correlated). The problem can be overcome by constraining the fit on the non-rebinned spectra (right panel): in this case no spurious correlation is introduced, and the d.o.f. are enough to cancel any uncertainty on the expected shape of the distribution. Such careful treatment of the data is of paramount importance in the incoming age of high-precision spectroscopy.

\bibliographystyle{aa}
\begin{thebibliography}{}
\bibitem[Bonifacio(2005)]{bonifacio05}Bonifacio, P.\ 2005, Mem. SAIt, 8, 114
\bibitem[Cosentino et al.(2012)]{cosentino+12} Cosentino, R.~et al.\ 2012, SPIE, 8446, 84461V
\bibitem[Cristiani et al.(2015)]{cristiani+15} Cristiani, S.~et al.\ 2015, Mem. SAIt, 0, 0
\bibitem[Cupani et al.(2015)]{cupani+15} Cupani, G.~et al.\ 2015, \pasp\ (in press)
\bibitem[Dekker et al.(2000)]{dekker+01} Dekker, H.~et al.\ 2000, SPIE, 4008, 534
\bibitem[Di Marcantonio et al.(2014)]{dimarcantonio+14} Di Marcantonio, P.~et al.\ 2014, SPIE, 9149, 91491Q
\bibitem[Freudling et al.(2013)]{freudling+13} Freudling, W.~et al.\ 2013, \aap, 559, A96
\bibitem[Galassi et al.(2009)]{galassi+09} Galassi, M.~et al.\ 2009, GNU Scientific Library Reference Manual
\bibitem[King(2012)]{king12} King, J.~A.\ 2012, arxiv:1202.6365
\bibitem[Liske et al.(2008)]{liske+08} Liske, J.~et al.\ 2008, \mnras, 386, 1192
\bibitem[Lo Curto et al.(2012)]{locurto+12} Lo Curto et al.\ 2012, The Messenger, 149, 2 
\bibitem[Maiolino et al.(2013)]{maiolino+13} Maiolino, R.~et al.\ 2013, arxiv:1310.3163
\bibitem[Mayor et al.(2003)]{mayor+03} Mayor, M. et al.\ 2003, The Messenger, 114, 20
\bibitem[McKay et al.(2004)]{mckay+04} McKay. D.~J.~et al.\ 2004, SPIE, 5493, 444
\bibitem[Molaro et al.(2013)]{molaro+13} Molaro, P.~et al.\ 2013, \aap, 560, 61
\bibitem[Oliva et al.(2015)]{oliva+15} Oliva, E.~et al.\ 2015, Mem. SAIt, 0, 0
\bibitem[Pepe et al.(2013)]{pepe+13} Pepe, F.~et al.\ 2013, ESO Messenger, 153, 6
\bibitem[Rahmani et al.(2013)]{rahmani+13} Rahmani H.~et al.\ 2013, \mnras, 435, 861
\bibitem[Webb et al.(2011)]{webb+11} Webb, J.~et al.\ 2011, \prl, 107, 191101
\bibitem[Wilken et al.(2012)]{wilken+12} Wilken, T. et al.\ 2012, \nat, 485, 611
\end{thebibliography}

\end{document}

