\documentclass{article}
\usepackage{a4wide,graphicx}

\begin{document}
\title{\textbf{Practice Work Session P10 (3h)}\\AMBER data reduction}
\author{G.\ Duvert, F.\ Malbet \& F.\ Millour\\
        Laboratoire d'Astrophysique de Grenoble (LAOG)}
\date{\textbf{Euro Summer School}\\
  \emph{Observation and Data reduction with the Very Large Telescope
    Interferometer} \\
4-16 June 2006, Goutelas (France)}
\maketitle

\begin{abstract}
  Hands on real AMBER data! Impersonate Dr. Stee, receiving freshly
  observed Science Demonstration Time observations of Alpha Arae!
\end{abstract}

\section{Sorting AMBER data}

The complete set of observation files for SDT7, containing
observations for Alpha Arae, are stored in the ``data'' directory on
your computer. You will browse through this data and reduce it with
one of the currently available software.


Have a look to the contents of the ``data'' directory, which is ``as
is'' received from ESO. Can you make any sense of it?


\begin{itemize}
\item browse AMBER data: Now, call ``gasgano'', the ESO tool to browse
  through the raw data files. Use the `` File$\rightarrow$Add/Remove File''
  menu to add the contents of ``data''. Expand the list of files. Note
  that uncompressed files show full headers, compressed files only the
  first header (eventually uncompress a file to see
  this)\footnote{gasgano refreshes its directory list only once in a
    while (dependending on a ``Preferences...'' setup). To view new
    file, use the ``File$\rightarrow$Refresh'' menu}.

  How is the data organised? Notice the DPR.CATG and DPR.TYPE
  values. Why do we have data not pertaining to the ``Alf-Ara-Stee''
  project?

  What are the observing modes present in the data? Where are the P2VM
  raw data files associated with the Alf-Ara observations? 

  Calibrator: Which calibrator was used for these obervations? In
  total, what are the relevant files for a complete calibrated set of
  observations (science object + calibrator)?. According to the AMBER data
  reduction scheme, what calibration steps should be taken and in
  which order?

\item headers of raw data: On an uncompressed file, browse
  through the various headers with gasgano. Better, on any file
  (zipped or not), call the 'fv' utility to explore the contents of
  the fits file. See fig~\ref{fig:1} (page~\pageref{fig:1}) for
  details.

  What are the telescopes used for the file in observing block
  ``200147575''? What is the intergration time per frame (DIT)?  What
  indication of the (u,v) values of the baseline are present in the
  raw data header?


\begin{figure*}[thb]
\begin{center}
\includegraphics[width=\textwidth]{P10-fig1.ps} 
\caption{Calling a script (fits viewer) from gasgano}\label{fig:1}
\end{center}
\end{figure*}

\item view raw data files: use the ``viewfile'' script entry to start
  a gildas-based dedicated viewer (may take some time to
  start). Figure~\ref{fig:2} (page~\pageref{fig:2}) shows the
  different windows now available. Peruse the ``PLOT AMBER DATA
  FRAMES'' panel to explore the raw data file.
\end{itemize}

\begin{figure*}[thb]
\begin{center}
\includegraphics[width=\textwidth]{P10-fig2.ps} 
\caption{Gildas amber-drs called on a raw file from gasgano}\label{fig:2}
\end{center}
\end{figure*}

\section{Standard calibration}

\begin{itemize}
\item bad pixel map: The associated Bad Pixel Map is located at \\
{\tt
    /server/softs/amber/amdmsBadPixelMap.fits.gz}. Use fv to view this file.
\item flat-field map: The associated Flat Field Map is located at\\
 {\tt
    /server/softs/amber/amdmsFlatFieldMap.fits}. Use fv to view this 
  file (hint: use histogram equalization). Comment.
\item spectral calibration: identify files relates to the (improperly
  named) spectral calibration step. Eventually run the script {\tt
    amdlibComputeSpectralCalibration} on the relevant files, and
  compare values of the {\em spectral displacement} between
  interferometric spectrum and photometric spectra (``photometric
  channels'') returned in {\tt /tmp/ComputeSpectralCalibration.log}
  with the values stored in the following file's headers (keyword
  `DET1.P1.OFFSETY`).
\item perform a ``cosmetic calibration only'' on a raw data file. This
  is if you want to check the raw data ``images'', but is normally not
  needed by the users (fortunately). The result file is still a raw
  data file, but bad pixels have been set to zero, biases and other
  detector effects removed and the images corrected from flat and
  gain. Select the file {\tt AMBER.2005-02-25T09:38:46.349.fits.gz},
  the accompanying DARK file, and run ``amdlibCalibrateRawData''. 

  This script produce a file in a new directory in the current
  directory, named ``Calibrated''. Instruct gagsgano to check files in
  that directory if needed.

  Use ``viewFile'' to plot the pixels, and the menu item ``AMBER
  VIEWER$\rightarrow$Explore data cube with mview'' to plot all the fringes in
  the observation. What kind of evolution do yo see in the fringe
  pattern from first frame to the last?
\end{itemize}

\section{Interferometric calibration}

\begin{itemize}
\item view calibration data files.
\item build a P2VM: Selecting the relevant set of files, create your
  first P2VM by using the ``amdlibComputeP2vm'' script. Use the first
  available set in the two-telescope data (Medium-K observations), for
  Low\_JHK observations, and for the 3-telescope observations. 
\item checking a P2VM: after refreshing gasgano, view each of the p2vm's
  content with ``viewFile'' (opens yet another widget panel). In
  particular, plot the ``VK'' and ``MATRIX'' items. Observe the
  differences due to the number of observing bands and telescopes.
\end{itemize}

\section{Compute interferometric observables}

\begin{itemize}
\item compute OIFITS files: Use the amdlibExtractVis script to call
  the amdlib program of same name to process a science raw data
  file. Take for example the same raw data file as before, {\tt AMBER.2005-02-25T09:38:46.349.fits.gz}.  Note that this script needs only a SCIENCE/OBJECT file and a
  SCIENCE/DARK file, it finds automagically the corresponding P2VM
  file.

  This script produce a file in a new directory in the current
  directory, named ``Calibrated''. Instruct gagsgano to check files in
  that directory if needed. The filename is the same as the original
  raw data file, terminated with ``\_VIS''.

\item view the results: Use ``viewfile'' which opens an OIFITS
  explorer panel. Almost any entry in an OIFITS file (which is a 2-
  or 3-D array) can be viewed
  against another, with various combinations of frame/spectral channel
  selections. View especially PISTON vs. TIME (did we see this
  before?), VIS2DATA vs. FRINGEQUAL, VIS2DATA vs. WAVELENGTH,
  differential phases (VISPHI vs. WAVELENGTH), closure phases vs. time.

\end{itemize}

\section{Frame selection}

\begin{itemize}
\item SNR selection.
The script ``amdlibComputeAveragedMergedVis'' creates OIFITS files
where observables are averaged after frame selection, unsing a default
frame selection criterium based on fringe constrast SNR and a
threshold value of 20\% best frames. Use and view the corresponding
file. For bookeeping purposes, the result file has the same name as
the raw data file, followed by ``-XXX-YY\_VIS'', where XXX is the frame
semction criterium (FRG in our default case) and YY the percentage of
frames selected according to this criterium (0 to 1).

By selecting a number of science
raw data files, the resulting file is the concatenation of each
observation, individually averaged. Eperience the results with this
script, view the resulting files with ``viewFile''.

\item Photometry selection.

  Waiting for a more flexible gasgano interface, this is possible only 
through the command line mode. Retrieve the (long) command used to create the
last OIFITS file, it is written in the log file {\tt
  /tmp/ExtractVis.log}. Use it to modify options ``-e'' and ``-r'' to
suit your purposes. Wiew result with ``viewFile''.
\end{itemize}


\section{Using the processed data}
Under ideal conditions, the frame-selected averaged values should be
sufficient for the normal user. However, a few calibrations steps are
not provided in the current software:
\begin{itemize}
\item correction of visibility loss due to atmospheric piston
  (large instrumental OPD), and
  atmospheric piston jitter.
\item visibility absolute calibration using a calibrator.
\end{itemize}

This can be done afterwards with any general purpose software equipped
with an OIFITS reader, such as Yorick, IDL, Gildas, etc...

\begin{itemize}
\item reading OIFITS in Yorick
\item Averaging in frame, in selection
\end{itemize}


\end{document}
