%\section{Simulating Observations}
\label{sec:simul}

Simulations may be need to evaluate whether observations with a given
array are relevant or not for the expected science goal. There are 3
basic questions in this respect:
\begin{enumerate}\itemsep 0pt
\item What array configuration gives the appropriate beam size.
\item Is the image reconstruction appropriate ?
\item What sensitivity is obtained ?
\end{enumerate}
Case (1) is described in Section \ref{sub:coverage}.  Case (2) requires
a complete simulator as in Section \ref{sub:simul}. 
The available tools are grouped in the \lang{SIMULATE} language,
but are also packages in a all-in-one command named \qom{SIMULATE} in the
\lang{IMAGER} language.

Case (3) is not treated separately by \imager{}, because Observatories like
\ALMA{} and \NOEMA{} provide their own tools to figure out the expected noise level. 
In Case (1), an approximate noise level can be derived using the \qomm{/WEIGHT}{FULL}
option, but it is based on a generic estimate for the system temperature. 
A user specified noise level (e.g. the one indicated by the Observatory tool) 
can be accounted for in Case (2). 

\subsection{UV coverage and beam size}
\label{sub:coverage}
UV coverages can be generated (and saved to a UV table if needed)
using command \com{ARRAY} to define which telescope array is being used, 
followed by command \com{UV\_TRACKS} which is used to define the array
configuration, the source declination and the observing frequency.

Command \com{UV\_TRACKS} can be used repetitively for multi-configurations.

Once the UV coverage is written, the usual commands \com{READ UV}, \qomm{UV\_STAT}{WEIGHT},
or \qomm{UV\_STAT}{BEAM} can be used to derive the dirty and the clean beam size.

\subsection{Complete Simulation}
\label{sub:simul}

\imager{}  offers a simple, but powerful, simulation tool that allows
users to process an input data cube (from a model, or other observations)
as if it was observed by an array. 

This is done through the \com{SIMULATE} command (from language \lang{SIMULATE}), that 
uses commands from the \lang{SIMULATE} language to mimick the whole observation process.
This involves
\begin{itemize}
 \item Specifying the array. \com{SIMULATE} uses command \com{ARRAY} from
 the \lang{SIMULATE} language for this.
 \item Specifying the configuration(s) used. \com{SIMULATE} uses command \com{UV\_TRACKS}
 for this purpose.
 \item Specifying the model cube (or single plane). This is done through
 a call to the command \com{MODEL} of the \lang{CALIBRATE} language. 
 \item Specifying the (virtual) source declination, observing frequency 
  through the arguments or options of the \qom{SIMULATE}
 command, and the required field of view through the \sicvar{SIZE} variable.
 \item Specifying the sensitivity, through the \qomm{SIMULATE}{/NOISE} option.
\end{itemize}

The simulator estimates whether a Mosaic is required and the corresponding
fields layout. A $uv$ coverage is derived from the source declination,
array configuration and hour angle coverage. Model visibilities are then
computed from the model plane or cube. Noise is added to the model visibilities,
and ultimately the produced simulated UV data can be imaged.

Up to now, the Simulator has no tool to predict the expected noise level from the
observation characteristics. It is the user responsibility to specify the
sensitivity in accordance to the expected array performance. The \astro{} program
in the \gildas{} suite, or the on-line time/sensitivity estimators 
that are available for most arrays (in particular NOEMA and ALMA) are possible tools
make this estimation. Just beware of being consistent between the required
Hour angle coverage, Bandwidth and the Noise.

Fig.\ref{fig:simulate} shows an example of Mosaicing pattern and UV coverage
using two ALMA configurations. Note the change of declination between the
model source and the `observed'' direction.
\begin{figure}[hb]
  \includegraphics[width=6.5cm]{simu-fields.png}\hspace{0.5cm}\includegraphics[width=9.0cm]{simu-tracks.png}
  \caption{Windows created by the \comm{SIMULATE} command.
\label{fig:simulate}}
\end{figure}

Try the \script{@ gag\_demo:demo-simulate} for a demonstration on the Simulator usage.
Use \com{HELP SIMULATE} for further details.


