% Format: LaTeX
%
% target selection paper
%
% Neil Phillips
%
% 2007

\documentclass[a4paper,11pt]{article}
%\usepackage{epsfig}
%\usepackage{graphics}
%\usepackage{amssymb}
%\usepackage{wasysym}

\evensidemargin=0pt
\oddsidemargin=0pt
\topmargin=-1.8cm
\textwidth=15.99cm
\textheight=24.8cm

\begin{document}

\begin{center}
{\Large\bf SimpleCOSMOS Quick Guide}

\bigskip

{\large Neil Phillips 2012-04-04}
\end{center}

\section*{Hardware Setup}

\subsection*{Plate Mounting}

{\bf Summary:} Use black (opaque) plate holder, and cover plate with paper where not imaging to minimise stray light. Place plate emulsion side up (be very careful not to scratch with cover paper!).

\subsection*{Camera Mechanical Setup}

{\bf Summary:} Mount at top of slot in enlarger mount for repeatability. Line up top of mount with 45 position on enlarger scale for nominal field size ($30'\!\times\!20'$). Use lens hood. 
\\

\subsection*{Image Format}

{\bf Summary:} `HI' resolution, `RAW' quality (p58 of SD14 manual).
\\

Only use the raw full resolution format. JPEGs are of no use, and there is no reason to reduce the resolution from the native detector resolution. Images are produced in a proprietary format specific to Sigma.

\subsection*{Lens Aperture}

{\bf Summary:} Use $f/8.0$. Set on camera body (see p39 of SD14 manual).
\\

This is only a trade-off of sharpness and depth of field, as there is no need to minimise exposure time. $f/8.0$ appears to give near optimal sharpness, and the depth of field is large enough that typical focus setting error and small tilts of the camera relative to the plate do not cause any significant defocus.

\subsection*{Focus}

{\bf Summary:} Use auto-focus (AF) with automatic point selection (see p47/48 in SD14 manual).
\\

The AF can be a little unreliable at the very close distances required for plate imaging. It seems to be slightly more reliable starting from the closest focus end. With a few attempts you will usually be able to get it to work, but you can always switch the lens to manual mode if necessary.

\subsection*{Exposure Time}

{\bf Summary:} 
\begin{itemize}
\item Use auto exposure (aperture priority; p39 in SD14 manual)
\item Use ISO 100 (p57 in SD14 manual)
\item Start with exposure compensation of $+3.0$ stops and reduce as needed to avoid saturation (p63 of SD14 manual).
\item Typical optimal exposure times are around $0.1$--$10$ seconds.
\end{itemize}

The exposure time can have a significant effect on the image quality, especially for the central regions of bright objects. The combination of being a negative image and the logarithmic photographic response means that the Poisson noise in captured images translates to very large noise in the centres of bright stars when converted to approximate intensity. To minimise noise, the lowest readout gain of ISO 100 should be used, and the exposure time should be maximised subject to avoiding saturation. There is no need to avoid long exposure times of a few seconds due to either camera shake or dark current. The saturation value in raw images produced by the camera is around 7100. With the exception of emulsion scratches, pixel values should be checked to be below about 7000.

The camera's auto exposure system can be used to determine the exposure, with the caveat that it systematically underexposes most plate scenes. This underexposure is mostly just due to the large fraction of the scene which is bright background, but may also be intended to avoid detector non-linearity or problems with measuring colour with the detector. For simple scenes of point sources on a uniform sky background, a $+3.0$ stop exposure compensation (the maximum available) generally gives an optimal exposure. For more complicated scenes, such as regions of significant cirrus emission, reducing the exposure compenstation can be necessary to avoid saturating the regions with the least cirrus emission. The camera offers three exposure metering modes (centre, 8-segment matrix, and average), but they appear to make little difference for plate scenes.

The camera should typically be left set at ISO 100 readout gain and in aperture priority exposure mode. In most cases you should set the exposure compensation to $+3.0$ and take and reduce an image. The image should be inspected, e.g. in \texttt{gaia}, to check for saturated pixels. For simple scenes the background average values reported duing the reduction (mean, median and mode), should typically be around 4000--5000. Adjust the exposure compensation and repeat as necessary to get an optimal exposure. Remember that a stop is a factor of two in exposure time, so you can often estimate the change required from the background level.

\subsection*{Taking an Image}

{\bf Summary:} Use the shutter button as we don't have a remote release. Use a 2 second delay to avoid shake (p52 of SD14 manual). USB cable must be disconnected!

\subsection*{Tranferring images}

{\bf Summary:} Connect USB cable and \texttt{mount /media/usbpen00} or \texttt{mount /media/usbpen10}. Copy files, unmount and disconnect USB cable.

\newpage

\section*{Data Reduction}

Please make sure \texttt{sc\_reduce} and \texttt{dcraw} from the SimpleCOSMOS software package are somewhere in your shell PATH. Please read the output from \texttt{sc\_reduce --help}, and read \texttt{sc\_reduce.c} and other sources for further information.

\subsection*{\texttt{\bf dcraw}: Convert X3F Files to PPM Images}

{\bf Summary:} Automatically run by \texttt{sc\_reduce}. \texttt{dcraw -4 -D -v <file.X3F>}.
\\

The proprietary raw files produced by the camera can be read by the open source program \texttt{dcraw} \footnote{\tt http://www.cybercom.net/\~dcoffin/dcraw/}, which can produce standard PPM or TIFF images with 16-bit linear encoding suitable for scientific processing. PPM is the default output format. The relevant options used for SimpleCOSMOS images are:
\begin{itemize}
\item \texttt{-4}: produce linear 16-bit output without any value scaling (no brightness, contrast etc.)
\item \texttt{-D}: document mode -- no colour processing.
\item \texttt{-v}: verbose
\end{itemize}

A minor modification of \texttt{dcraw} was made to prevent it truncating negative pixel values to zero. In the reduction using the PPM images produced by \texttt{dcraw}, and in FITS files, values are assumed to be signed, so the negative values can be preserved even though this is strictly breaking the PPM format which is only intended for encoding positive values. The change is just to comment out 3 lines in \texttt{foveon\_load\_raw()} in \texttt{dcraw.c}:
\begin{verbatim}
#if 0
  if (document_mode)
    for (i=0; i < height*width*4; i++)
      if ((short) image[0][i] < 0) image[0][i] = 0;
#endif
\end{verbatim}

\subsection*{Basic Reduction: Producing FITS files}

{\bf Summary:} \texttt{sc\_reduce -i <file>}
\\

The \texttt{sc\_reduce} program can take a Sigma raw (X3F) file or PPM file produced by \texttt{dcraw}. If given an X3F file it will run \texttt{dcraw} to produce a PPM file. Only the green channel from the PPM image is used. \texttt{sc\_reduce} will by default perform the following simple steps, outputting a FITS file after each:
\begin{enumerate}
\item Crop unexposed regions from the edges of the image
\item Despike individual discrepant pixels
\item Compute intensity image (input image is transmission)
\item Produce inverted original image after cropping and despiking.
\end{enumerate}

Any of the four FITS files produced may be of interest to the user depending on the application. The intensity image is the closest to a real image of the sky.

\subsection*{More reduction: source extraction}

{\bf Summary:} \texttt{sc\_reduce -i <file> -e}. Or use your favourite package (sextractor etc.).
\\

The reduction program can perform quite robust source extraction for the purpose of astrometric calibration (although the actual astrometric fitting is not implemented). This produces a catalog of centroids and object measurements. The segmentation is specifically targeted at SimpleCOSMOS images of photographic plates. A clever, but slow, background estimation routine is used which suppresses linear features such as diffraction spikes and satellite trails in the image. The result is relatively few false detections along linear features. The routine has also been tested on cirrussy fields with success. The steps performed in addition to those for basic reduction are:
\begin{enumerate}
\item Produce inverted original image with peak values suppressed to lessen there affect in background estimation
\item Produce background image using maximum of images median filtered with line-shaped kernels at different orientations. This is slow. If re-running with different extraction options you can reuse the the background image produced by a previous run by using the \texttt{--readbg} option.
\item Subtract background from inverted original image
\item Threshold at $n\sigma$ above background mode value ($n$ settable with \texttt{--threshsigma} option)
\item Select regions of objects and background from threshold image
\item Optionally deblend source regions using increasing thresholds (fractional step settable with \texttt{--deblendsep} option)
\item Measure centroids and ellipse parameters using pixel values from intensity image
\item Plot ellipses on intensity image (looks ugly though)
\item Dump object catalog
\end{enumerate}

\end{document}
