source: trunk/docs/Guide.tex @ 107

Last change on this file since 107 was 107, checked in by Matthew Whiting, 18 years ago

Some minor corrections to code: use more generic maths functions (eg.
atan instead of atanf), and comment out vector at functions, use [] instead.
Added extern "C" to the front of prototypes for .c functions in Utils.
Added a configure script (with configure.ac) and a Makefile.in to go with it.
Some last additions to Guide.tex.

File size: 82.5 KB
Line 
1\documentclass[12pt,a4paper]{article}
2
3%%%%%% LINE SPACING %%%%%%%%%%%%
4\usepackage{setspace}
5\singlespacing
6%\onehalfspacing
7%\doublespacing
8
9%Define a test for doing PDF format -- use different code below
10\newif\ifPDF
11\ifx\pdfoutput\undefined\PDFfalse
12\else\ifnum\pdfoutput > 0\PDFtrue
13     \else\PDFfalse
14     \fi
15\fi
16
17\textwidth=161 mm
18\textheight=245 mm
19\topmargin=-15 mm
20\oddsidemargin=0 mm
21\parindent=6 mm
22
23\usepackage[sort]{natbib}
24\usepackage{lscape}
25\bibpunct[,]{(}{)}{;}{a}{}{,}
26
27\newcommand{\eg}{e.g.\ }
28\newcommand{\ie}{i.e.\ }
29\newcommand{\hi}{H{\sc i}}
30\newcommand{\hipass}{{\sc hipass}}
31\newcommand{\duchamp}{\emph{Duchamp}}
32\newcommand{\atrous}{\textit{{\`a} trous}}
33\newcommand{\Atrous}{\textit{{\`A} trous}}
34\newcommand{\diff}{{\rm d}}
35\newcommand{\entrylabel}[1]{\mbox{\textsf{\bf{#1:}}}\hfil}
36\newenvironment{entry}
37        {\begin{list}{}%
38                {\renewcommand{\makelabel}{\entrylabel}%
39                        \setlength{\labelwidth}{30mm}%
40                        \setlength{\labelsep}{5pt}%
41                        \setlength{\itemsep}{2pt}%
42                        \setlength{\parsep}{2pt}%
43                        \setlength{\leftmargin}{35mm}%
44                }%
45        }%
46{\end{list}}
47
48
49\title{Source Detection with \duchamp\ v1.0\\A User's Guide}
50\author{Matthew Whiting\\
51%{\small \href{mailto:Matthew.Whiting@csiro.au}{Matthew.Whiting@csiro.au}}\\
52Australia Telescope National Facility\\CSIRO}
53%\date{January 2006}
54\date{}
55
56% If we are creating a PDF, use different options for graphicx, hyperref.
57\ifPDF
58  \usepackage[pdftex]{graphicx,color}
59  \usepackage[pdftex]{hyperref}
60  \hypersetup{colorlinks=true,%             
61              citecolor=red,%
62              filecolor=red,%
63              linkcolor=red,%
64              urlcolor=red,%
65              }
66\else
67  \usepackage[dvips]{graphicx}
68  \usepackage[dvips]{hyperref}
69\fi
70
71\pagestyle{headings}
72\begin{document}
73
74\maketitle
75\thispagestyle{empty}
76\begin{figure}[!h]
77\begin{center}
78\includegraphics[width=\textwidth]{cover_image}
79\end{center}
80\end{figure}
81
82\newpage
83\tableofcontents
84
85\newpage
86\section{Introduction and getting going quickly}
87
88This document provides a user's guide to \duchamp, an object-finder
89for use on spectral-line data cubes. The basic execution of
90\duchamp\ is to read in a FITS data cube, find sources in the cube,
91and produce a text file of positions, velocities and fluxes of the
92detections, as well as a postscript file of the spectra of each
93detection.
94
95So, you have a FITS cube, and you want to find the sources in it. What
96do you do? The first step is to make an input file that contains the
97list of parameters. Brief and detailed examples are shown in
98Appendix~\ref{app-input}. This file provides the input file name, the various
99output files, and defines various parameters that control the
100execution.
101
102The standard way to run \duchamp\ is by the command
103\begin{quote}
104\texttt{Duchamp -p [parameter file]}
105\end{quote}
106replacing \texttt{[parameter file]} with the name of the file listing
107the parameters. Alternatively, you can use the syntax
108\begin{quote}
109\texttt{Duchamp -f [FITS file]}
110\end{quote}
111where \texttt{[FITS file]} is the file you wish to search. In the latter
112case, all parameters will take their default values detailed in
113Appendix~\ref{app-param}. In either case, the program will then work
114away and give you the list of detections and their spectra. The
115program execution is summarised below, and detailed in
116\S\ref{sec-flow}. Information on inputs is in \S\ref{sec-param} and
117Appendix~\ref{app-param}, and descriptions of the output is in
118\S\ref{sec-output}.
119
120\subsection{A summary of the execution steps}
121
122The basic flow of the program is summarised here -- all steps are
123discussed in more detail in the following sections.
124\begin{enumerate}
125\item If the \texttt{-p} option is used, the parameter file given on
126  the command line is read in, and the parameters absorbed.
127\item The FITS image is located and read in to memory.
128\item If requested, a FITS image with a previously reconstructed array
129  is read in.
130\item If requested, blank pixels are trimmed from the edges, and
131  the baseline of each spectrum is removed.
132\item If the reconstruction method is requested, and the reconstructed
133  array has not been read in at Step 3 above, the cube is
134  reconstructed using the \atrous\ wavelet method.
135\item Searching for objects then takes place, using the requested
136  thresholding method.
137\item The list of objects is condensed by merging neighbouring objects
138  and removing those deemed unacceptable.
139\item The baselines and trimmed pixels are replaced prior to output.
140\item The details of the detections are written to screen and to the
141  requested output file.
142\item Maps showing the spatial location of the detections are written.
143\item The integrated spectra of each detection are written to a
144  postscript file.
145\item If requested, the reconstructed array can be written to a new
146  FITS file.
147\end{enumerate}
148
149\subsection{Guide to terminology}
150
151First, a brief note on the use of terminology in this guide. \duchamp\
152is designed to work on FITS ``cubes''. These are FITS\footnote{FITS is
153the Flexible Image Transport System -- see \citet{hanisch01} or
154websites such as
155\href{http://fits.cv.nrao.edu/FITS.html}{http://fits.cv.nrao.edu/FITS.html}
156for details.} image arrays with three dimensions -- they are assumed
157to have the following form: the first two dimensions (referred to as
158$x$ and $y$) are spatial directions (that is, relating to the position
159on the sky), while the third dimension, $z$, is the spectral
160direction, which can correspond to frequency, wavelength, or
161velocity. The three dimensional analogue of pixels are ``voxels'', or
162volume cells -- a voxel is defined by a unique $(x,y,z)$ location and
163has a unique flux or intensity value associated with it.
164
165Each spatial pixel (a given $(x,y)$ coordinate) can be said to be a
166single spectrum, while a slice through the cube perpendicular to the
167spectral direction at a given $z$-value is a single channel (the 2-D
168image is a channel map).
169
170Detection involves locating a contiguous group of voxels with fluxes
171above a certain threshold. \duchamp\ makes no assumptions as to the
172size or shape of the detected features, other than having
173user-selected minimum size criteria.
174
175Features that are detected are assumed to be positive. The user can
176choose to search for negative features by setting an input parameter
177-- this inverts the cube prior to the search (see
178\S\ref{sec-detection} for details).
179
180Note that it is possible to run \duchamp\ on a two-dimensional image
181(\ie one with no frequency or velocity information), or indeed a
182one-dimensional array, and many of the features of the program will
183work fine. The focus, however, is on object detection in three
184dimensions.
185
186\subsection{Why \duchamp?}
187
188Well, it's important for a program to have a name, and the initial
189working title of \emph{cubefind} was somewhat uninspiring. I wanted to
190avoid the classic astronomical approach of designing a cute acronym,
191and since it is designed to work on cubes, I looked at naming it after
192a cubist. \emph{Picasso}, sadly, was already taken \citep{minchin99},
193so I settled on naming it after Marcel Duchamp, another cubist, but
194also one of the first artists to work with ``found objects''.
195
196\section{User Inputs}
197\label{sec-param}
198
199Input to the program is provided by means of a parameter
200file. Parameters are listed in the file, followed by the value that
201should be assigned to them. The syntax used is \texttt{paramName
202value}. Parameter names are not case-sensitive, and lines in the input
203file that start with \texttt{\#} are ignored. If a parameter is listed
204more than once, the latter value is used, but otherwise the order in
205which the parameters are listed in the input file is arbitrary.
206
207If a parameter is not listed, the default value is assumed. The
208defaults are chosen to provide a good result (using the reconstruction
209method), so the user doesn't need to specify many new parameters in
210the input file. Note that the image file \textbf{must} be specified! The
211parameters that can be set are listed in Appendix~\ref{app-param},
212with their default values in parentheses.
213
214The parameters with names starting with \texttt{flag} are stored as
215\texttt{bool} variables, and so are either \texttt{true = 1} or
216\texttt{false = 0}. \duchamp\ will only read them from the file as
217integers, and so they should be entered in the file as 0 or 1 (see
218example file in Appendix~\ref{app-input}).
219
220\section{What \duchamp\ is doing}
221\label{sec-flow}
222
223The execution flow of \duchamp\ is detailed here, indicating the
224main algorithmic steps that are used. The program is written in C/C++
225and makes use of the {\sc cfitsio}, {\sc wcslib} and {\sc pgplot}
226libraries.
227
228%\subsection{Parameter input}
229%
230%The user provides parameters that govern the selection of files and
231%the parameters used by the various subroutines in the program. This is
232%done via a parameter file, and the parameters are stored in a C++
233%class for use throughout the program. The form of the parameter file is
234%discussed in \S\ref{sec-param}, and the parameters themselves are
235%listed in Appendix~\ref{app-param}.
236
237\subsection{Image input}
238\label{sec-input}
239
240The cube is read in using basic {\sc cfitsio} commands, and stored as
241an array in a special C++ class. This class keeps track of
242the list of detected objects, as well as any reconstructed arrays that
243are made (see \S\ref{sec-recon}). The World Coordinate System (WCS)
244information for the cube is also obtained from the FITS header by {\sc
245wcslib} functions \citep{greisen02, calabretta02}, and this
246information, in the form of a \texttt{wcsprm} structure, is also stored
247in the same class.
248
249A sub-section of an image can be requested via the \texttt{subsection}
250parameter in the parameter file -- this can be a good idea if the cube
251has very noisy edges, which may produce many spurious detections. The
252generalised form of the subsection that is used by {\sc cfitsio} is
253\texttt{[x1:x2:dx,y1:y2:dy,z1:z2:dz]}, such that the x-coordinates run
254from \texttt{x1} to \texttt{x2} (inclusive), with steps of
255\texttt{dx}. The step value can be omitted (so a subsection of the
256form \texttt{[2:50,2:50,10:1000]} is still valid). \duchamp\ does not
257make use of any step value present in the subsection string, and any
258that are present are removed before the file is opened.
259
260If one wants the full range of a coordinate then replace the range
261with an asterisk, \eg \texttt{[2:50,2:50,*]}. If one wants to use a
262subsection, one must set \texttt{flagSubsection = 1}. A complete
263description of the section syntax can be found at the {\sc fitsio} web
264site
265\footnote{
266\href{http://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c\_user/node90.html}%
267{http://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c\_user/node90.html}}.
268
269\subsection{Image modification}
270\label{sec-modify}
271
272Several modifications to the cube can be made that improve the
273execution and efficiency of \duchamp\ (these are optional -- their
274use is indicated by the relevant flags set in the input parameter
275file).
276
277\subsubsection{Blank pixel removal}
278
279First, the cube is trimmed of any BLANK pixels that pad the image out
280to a rectangular shape. This is optional, its use determined by the
281\texttt{flagBlankPix} parameter. The value for these pixels is read from
282the FITS header (using the BLANK, BSCALE and BZERO keywords), but if
283these are not present then the value can be specified by the user in
284the parameter file using \texttt{blankPixValue}.
285
286This stage is particularly important for the reconstruction step, as
287lots of BLANK pixels on the edges will smooth out features in the
288wavelet calculation stage. The trimming will also reduce the size of
289the cube's array, speeding up the execution. The amount of trimming is
290recorded, and these pixels are added back in once the source-detection
291is completed (so that quoted pixel positions are applicable to the
292original cube).
293
294Rows and columns are trimmed one at a time until the first non-BLANK
295pixel is reached, so that the image remains rectangular. In practice,
296this means that there will be BLANK pixels left in the trimmed image
297(if the non-BLANK region is non-rectangular). However, these are
298ignored in all further calculations done on the cube.
299
300\subsubsection{Baseline removal}
301
302Second, the user may request the removal of baselines from the
303spectra, via the parameter \texttt{flagBaseline}. This may be necessary
304if there is a strong baseline ripple present, which can result in
305spurious detections at the high points of the ripple. The baseline is
306calculated from a wavelet reconstruction procedure (see
307\S\ref{sec-recon}) that keeps only the two largest scales. This is
308done separately for each spatial pixel (\ie for each spectrum in the
309cube), and the baselines are stored and added back in before any
310output is done. In this way the quoted fluxes and displayed spectra
311are as one would see from the input cube itself -- even though the
312detection (and reconstruction if applicable) is done on the
313baseline-removed cube.
314
315The presence of very strong signals (for instance, masers at several
316hundred Jy) can affect the determination of the baseline, leading to a
317large dip centred on the signal in the baseline-subtracted
318spectrum. To prevent this, the signal is trimmed prior to the
319reconstruction process at some standard threshold (at $8\sigma$ above
320the mean). The baseline determined should thus be representative of
321the true, signal-free baseline. Note that this trimming is only a
322temporary measure which does not affect the source-detection.
323
324\subsubsection{Ignoring bright Milky Way emission}
325
326Finally, a single set of contiguous channels can be ignored -- these
327may exhibit very strong emission, such as that from the Milky Way as
328seen in extragalactic \hi\ cubes (hence the references to ``Milky
329Way'' in relation to this task -- apologies to Galactic
330astronomers!). Such dominant channels will produce many detections
331that are unnecessary, uninteresting (if one is interested in
332extragalactic \hi) and large (in size and hence in memory usage), and
333so will slow the program down and detract from the interesting
334detections. The use of this feature is controlled by the
335\texttt{flagMW} parameter, and the exact channels concerned are able
336to be set by the user (using \texttt{maxMW} and \texttt{minMW} --
337these give an inclusive range of channels). When employed, these
338channels are temporarily blanked out for the searching, and the
339scaling of the spectral output (see Fig.~\ref{fig-spect}) will not
340take them into account. They will be present in the reconstructed
341array, however, and so will be included in the saved FITS file (see
342\S\ref{sec-reconIO}). When the final spectra are plotted, the range of
343channels covered by these parameters is indicated by a green hashed
344box.
345
346\subsection{Image reconstruction}
347\label{sec-recon}
348
349The user can direct \duchamp\ to reconstruct the data cube using the
350\atrous\ wavelet procedure. A good description of the procedure can be
351found in \citet{starck02:book}. The reconstruction is an effective way
352of removing a lot of the noise in the image, allowing one to search
353reliably to fainter levels, and reducing the number of spurious
354detections. This is an optional step, but one that greatly enhances
355the source-detection process, with the payoff that it can be
356relatively time- and memory-intensive.
357
358\subsubsection{Algorithm}
359
360The steps in the \atrous\ reconstruction are as follows:
361\begin{enumerate}
362\item Set the reconstructed array to 0 everywhere.
363\item The input array is discretely convolved with a given filter
364  function. This is determined from the parameter file via the
365  \texttt{filterCode} parameter -- see Appendix~\ref{app-param} for
366  details on the filters available.
367\item The wavelet coefficients are calculated by taking the difference
368  between the convolved array and the input array.
369\item If the wavelet coefficients at a given point are above the
370  requested threshold (given by \texttt{snrRecon} as the number of
371  $\sigma$ above the mean and adjusted to the current scale -- see
372  Appendix~\ref{app-scaling}), add these to the reconstructed array.
373\item The separation of the filter coefficients is doubled. (Note that
374  this step provides the name of the procedure\footnote{\atrous\ means
375  ``with holes'' in French.}, as gaps or holes are created in the
376  filter coverage.)
377\item The procedure is repeated from step 2, using the convolved array
378  as the input array.
379\item Continue until the required maximum number of scales is reached.
380\item Add the final smoothed (\ie convolved) array to the
381  reconstructed array. This provides the ``DC offset'', as each of the
382  wavelet coefficient arrays will have zero mean.
383\end{enumerate}
384
385The reconstruction has at least two iterations. The first iteration
386makes a first pass at the wavelet reconstruction (the process outlined
387in the 8 stages above), but the residual array will inevitably have
388some structure still in it, so the wavelet filtering is done on the
389residual, and any significant wavelet terms are added to the final
390reconstruction. This step is repeated until the change in the $\sigma$
391of the background is less than some fiducial amount.
392
393It is important to note that the \atrous\ decomposition is an
394example of a ``redundant'' transformation. If no thresholding is
395performed, the sum of all the wavelet coefficient arrays and the final
396smoothed array is identical to the input array. The thresholding thus
397removes only the unwanted structure in the array.
398
399Note that any BLANK pixels that are still in the cube will not be
400altered by the reconstruction -- they will be left as BLANK so that
401the shape of the valid part of the cube is preserved.
402
403\subsubsection{Note on Statistics}
404
405The correct calculation of the reconstructed array needs good
406estimation of the underlying mean and standard deviation of the
407background noise distribution. These statistics are estimated using
408robust methods, to avoid corruption by strong outlying points. The
409mean of the distribution is actually estimated by the median, while
410the median absolute deviation from the median (MADFM) is calculated
411and corrected assuming Gaussianity to estimate the underlying standard
412deviation $\sigma$. The Gaussianity (or Normality) assumption is
413critical, as the MADFM does not give the same value as the usual rms
414or standard deviation value -- for a normal distribution
415$N(\mu,\sigma)$ we find MADFM$=0.6744888\sigma$. The difference
416between the MADFM and $\sigma$ is corrected for, so the user need only
417think in the usual multiples of $\sigma$ when setting
418\texttt{snrRecon}. See Appendix~\ref{app-madfm} for a derivation of
419this value.
420
421When thresholding the different wavelet scales, the value of $\sigma$
422as measured from the wavelet array needs to be scaled to account for the
423increased amount of correlation between neighbouring pixels (due to
424the convolution). See Appendix~\ref{app-scaling} for details on this
425scaling.
426
427\subsubsection{User control of reconstruction parameters}
428
429The most important parameter for the user to select in relation to the
430reconstruction is the threshold for each wavelet array. This is set
431using the \texttt{snrRecon} parameter, and is given as a multiple of the
432rms (estimated by the MADFM) above the mean (which for the wavelet
433arrays should be approximately zero). There are several other
434parameters that can be altered as well that affect the outcome of the
435reconstruction.
436
437By default, the cube is reconstructed in three dimensions, using a
4383-dimensional filter and 3-dimensional convolution. This can be
439altered, however, using the parameter \texttt{reconDim}. If set to 1,
440this means the cube is reconstructed by considering each spectrum
441separately, whereas \texttt{reconDim=2} will mean the cube is
442reconstructed by doing each channel map separately. The merits of
443these choices are discussed in \S\ref{sec-notes}, but it should be
444noted that a 2-dimensional reconstruction can be susceptible to edge
445effects if the spatial shape is not rectangular.
446
447The user can also select the minimum scale to be used in the
448reconstruction -- the first scale exhibits the highest frequency
449variations, and so ignoring this one can sometimes be beneficial in
450removing excess noise. The default, however, is to use all scales
451(\texttt{minscale = 1}).
452
453Finally, the filter that is used for the convolution can be selected
454by using \texttt{filterCode} and the relevant code number -- the
455choices are listed in Appendix~\ref{app-param}. A larger filter will
456give a better reconstruction, but take longer and use more memory when
457executing. When multi-dimensional reconstruction is selected, this
458filter is used to construct a 2- or 3-dimensional equivalent.
459
460\subsection{Reconstruction I/O}
461\label{sec-reconIO}
462
463The reconstruction stage can be relatively time-consuming, particularly
464for large cubes and reconstructions in 3-D. To get around this, \duchamp\
465provides a shortcut to allow users to perform multiple searches (\eg with
466different thresholds) on the same reconstruction without calculating the
467reconstruction each time.
468
469The first step is to choose to save the reconstructed array as a FITS
470file by setting \texttt{flagOutputRecon = true}. The file will be saved
471in the same directory as the input image, so the user needs to have write
472permissions for that directory.
473
474The filename will be derived from the input filename, with extra
475information detailing the reconstruction that has been done. For
476example, suppose \texttt{image.fits} has been reconstructed using a
4773-dimensional reconstruction with filter 2, thresholded at $4\sigma$
478using all scales. The output filename will then be
479\texttt{image.RECON-3-2-4-1.fits} (\ie it uses the four parameters
480relevant for the \atrous\ reconstruction as listed in
481Appendix~\ref{app-param}). The new FITS file will also have these
482parameters as header keywords. If a subsection of the input image has
483been used (see \S\ref{sec-input}), the format of the output filename
484will be \texttt{image.sub.RECON-3-2-4-1.fits}, and the subsection that
485has been used is also stored in the FITS header.
486
487Likewise, the residual image, defined as the difference between the input
488and reconstructed arrays, can also be saved in the same manner by setting
489\texttt{flagOutputResid = true}. Its filename will be the same as above,
490with RESID replacing RECON.
491
492If a reconstructed image has been saved, it can be read in and used
493instead of redoing the reconstruction. To do so, the user should set
494\texttt{flagReconExists = true}. The user can indicate the name of the
495reconstructed FITS file using the \texttt{reconFile} parameter, or, if
496this is not specified, \duchamp\ searches for the file with the name
497as defined above. If the file is not found, the reconstruction is
498performed as normal. Note that to do this, the user needs to set
499\texttt{flagAtrous = true} (obviously, if this is \texttt{false}, the
500reconstruction is not needed).
501
502\subsection{Searching the image}
503\label{sec-detection}
504
505The image is searched for detections in two ways: spectrally (a
5061-dimensional search in the spectrum in each spatial pixel), and
507spatially (a 2-dimensional search in the spatial image in each
508channel). In both cases, the algorithm finds connected pixels that are
509above the user-specified threshold. In the case of the spatial image
510search, the algorithm of \citet{lutz80} is used to raster scan through
511the image and connect groups of pixels on neighbouring rows.
512
513Note that this algorithm cannot be applied directly to a 3-dimensional
514case, as it requires that objects are completely nested in a row: that
515is, if you are scanning along a row, and one object finishes and
516another starts, you know that you will not get back to the first one
517(if at all) until the second is completely finished for that
518row. Three-dimensional data does not have this property, which is why
519we break up the searching into 1- and 2-dimensional cases.
520
521The determination of the threshold is done in one of two ways. The
522first way is a simple sigma-clipping, where a threshold is set at a
523fixed number $n$ of standard deviations above the mean, and pixels
524above this threshold are flagged as detected. The value of $n$ is set
525with the parameter \texttt{snrCut}. As before, the value of the
526standard deviation is estimated by the MADFM, and corrected by the
527ratio derived in Appendix~\ref{app-madfm}.
528
529The second method uses the False Discovery Rate (FDR) technique
530\citep{miller01,hopkins02}, whose basis we briefly detail here. The
531false discovery rate (given by the number of false detections divided
532by the total number of detections) is fixed at a certain value
533$\alpha$ (\eg $\alpha=0.05$ implies 5\% of detections are false
534positives). In practice, an $\alpha$ value is chosen, and the ensemble
535average FDR (\ie $\langle FDR \rangle$) when the method is used will
536be less than $\alpha$.  One calculates $p$ -- the probability,
537assuming the null hypothesis is true, of obtaining a test statistic as
538extreme as the pixel value (the observed test statistic) -- for each
539pixel, and sorts them in increasing order. One then calculates $d$
540where
541\[
542d = \max_j \left\{ j : P_j < \frac{j\alpha}{c_N N} \right\},
543\]
544and then rejects all hypotheses whose $p$-values are less than or equal
545to $P_d$. (So a $P_i<P_d$ will be rejected even if $P_i \geq
546j\alpha/c_N N$.) Note that ``reject hypothesis'' here means ``accept
547the pixel as an object pixel'' (\ie we are rejecting the null
548hypothesis that the pixel belongs to the background).
549
550The $c_N$ values here are normalisation constants that depend on the
551correlated nature of the pixel values. If all the pixels are
552uncorrelated, then $c_N=1$. If $N$ pixels are correlated, then their
553tests will be dependent on each other, and so $c_N = \sum_{i=1}^N
554i^{-1}$. \citet{hopkins02} consider real radio data, where the pixels
555are correlated over the beam. In this case the sum is made over the
556$N$ pixels that make up the beam. The value of $N$ is calculated from
557the FITS header (if the correct keywords -- BMAJ, BMIN -- are not
558present, a default value of 10 pixels is assumed).
559
560The theory behind the FDR method implies a direct connection between the
561choice of $\alpha$ and the fraction of detections that will be false
562positives. However, due to the merging process, this direct connection is
563lost when looking at the final number of detections -- see discussion in
564\S\ref{sec-notes}. The effect is that the number of false detections will
565be less than indicated by the $\alpha$ value used.
566
567If a reconstruction has been made, the residuals (defined as original
568$-$ reconstruction) are used to estimate the noise parameters of the
569cube. Otherwise they are estimated directly from the cube itself. In
570both cases, robust estimators are used as described above.
571
572Detections must have a minimum number of pixels to be counted. This
573minimum number is given by the input parameters \texttt{minPix} (for
5742-dimensional searches) and \texttt{minChannels} (for 1-dimensional
575searches).
576
577The search only looks for positive features. If one is interested
578instead in negative features (such as absorption lines), set the
579parameter \texttt{flagNegative = true}. This will invert the cube (\ie
580multiply all pixels by $-1$) prior to the search, and then re-invert
581the cube (and the fluxes of any detections) after searching is
582complete. All outputs are done in the same manner as normal, so that
583fluxes of detections will be negative.
584
585\subsection{Merging detected objects}
586\label{sec-merger}
587
588The searching step produces a list of detected objects that will have many
589repeated detections of a given object -- for instance, spectral
590detections in adjacent pixels of the same object and/or spatial
591detections in neighbouring channels. These are then combined in an
592algorithm that matches all objects judged to be ``close''. This
593determination is made in one of two ways.
594
595One way is to define two thresholds -- one spatial and one in velocity
596-- and say that two objects should be merged if there is at least one
597pair of pixels that lie within these threshold distances of each
598other. These thresholds are specified by the parameters
599\texttt{threshSpatial} and \texttt{threshVelocity} (in units of pixels
600and channels respectively).
601
602Alternatively, the spatial requirement can be changed to say that
603there must be a pair of pixels that are \emph{adjacent} -- a stricter,
604but perhaps more realistic requirement, particularly when the spatial pixels
605have a large angular size (as is the case for \hi\ surveys). This
606method can be selected by setting the parameter
607\texttt{flagAdjacent} to 1 (\ie \texttt{true}) in the parameter file. The
608velocity thresholding is done in the same way as the first option.
609
610Once the detections have been merged, they may be ``grown''. This is a
611process of increasing the size of the detection by adding adjacent
612pixels that are above some secondary threshold. This threshold is
613lower than the one used for the initial detection, but above the noise
614level, so that faint pixels are only detected when they are close to a
615bright pixel. The value of this threshold is a possible input
616parameter (\texttt{growthCut}), with a default value of $1.5\sigma$. The
617use of the growth algorithm is controlled by the \texttt{flagGrowth}
618parameter -- the default value of which is \texttt{false}. If the
619detections are grown, they are sent through the merging algorithm a
620second time, to pick up any detections that now overlap or have grown
621over each other.
622
623Finally, to be accepted, the detections must span \emph{both} a minimum
624number of channels (to remove any spurious single-channel spikes that
625may be present), and a minimum number of spatial pixels. These
626numbers, as for the original detection step, are set with the
627\texttt{minChannels} and \texttt{minPix} parameters. The channel
628requirement means there must be at least one set of \texttt{minChannels}
629consecutive channels in the source for it to be accepted.
630
631\section{Outputs}
632\label{sec-output}
633
634\subsection{During execution}
635
636\duchamp\ provides the user with feedback whilst it is running, to
637keep the user informed on the progress of the analysis. Most of this
638consists of self-explanatory messages about the particular stage the
639program is up to. The relevant parameters are printed to the screen at
640the start (once the file has been successfully read in), so the user
641is able to make a quick check that the setup is correct (see
642Appendix~{app-input} for an example).
643
644If the cube is being trimmed (\S\ref{sec-modify}), the resulting
645dimensions are printed to indicate how much has been trimmed. If a
646reconstruction is being done, a continually updating message shows
647either the current iteration and scale, compared to the maximum scale
648(when \texttt{reconDim=3}), or a progress bar showing the amount of
649the cube that has been reconstructed (for smaller values of
650\texttt{reconDim}).
651
652During the searching algorithms, the progress through the 1D and 2D
653searches are shown. When the searches have completed,
654the number of objects found in both the 1D and 2D searches are
655reported (see \S\ref{sec-detection} for details).
656
657In the merging process (where multiple detections of the same object
658are combined -- see \S\ref{sec-merger}), two stages of output
659occur. The first is when each object in the list is compared with all
660others. The output shows two numbers: the first being how far through
661the list the current object is, and the second being the length of the
662list. As the algorithm proceeds, the first number should increase and
663the second should decrease (as objects are combined). When the numbers
664meet (\ie the whole list has been compared), the second phase begins,
665in which multiply-appearing pixels in each object are removed, as are
666objects not meeting the minimum channels requirement. During this
667phase, the total number of accepted objects is shown, which should
668steadily increase until all have been accepted or rejected. Note that
669these steps can be very quick for small numbers of detections.
670
671Since this continual printing to screen has some overhead of time and
672CPU involved, the user can elect to not print this information by
673setting the parameter \texttt{verbose = 0}. In this case, the user is
674still informed as to the steps being undertaken, but the details of
675the progress are not shown.
676
677\subsection{Results}
678
679\subsubsection{Table of Results}
680
681Finally, we get to the results -- the reason for running \duchamp\ in
682the first place. Once the detection list is finalised, it is sorted by
683the mean velocity of the detections (or, if there is no good WCS
684associated with the cube, by the mean Z-pixel position). The results
685are then printed to the screen and to the output file, given by the
686\texttt{OutFile} parameter. The results list, an example of which can be
687seen in Appendix~\ref{app-output}, contains the following columns
688(note that the title of the columns depending on WCS information will
689depend on the projection of the WCS):
690
691\begin{entry}
692\item[Obj\#] The ID number of the detection (simply the sequential
693  count for the list, which is ordered by increasing velocity).
694\item[Name] The IAU-format name of the detection (derived from the WCS
695  projection).
696\item[X] The average X-pixel position.
697\item[Y] The average Y-pixel position.
698\item[Z] The average Z-pixel position.
699\item[RA/GLON] The Right Ascension or Galactic Longitude of the centre
700of the object.
701\item[DEC/GLAT] The Declination or Galactic Latitude of the centre of
702the object.
703\item[VEL] The mean velocity of the object [units given by the
704  \texttt{spectralUnits} parameter].
705\item[w\_RA/w\_GLON] The width of the object in Right Ascension or
706Galactic Longitude [arcmin].
707\item[w\_DEC/w\_GLAT] The width of the object in Declination Galactic
708  Latitude [arcmin].
709\item[w\_VEL] The full velocity width of the detection (max channel
710  $-$ min channel, in velocity units [see note below]).
711\item[F\_int] The integrated flux over the object, in the units of
712  flux times velocity, corrected for the beam if necessary.
713\item[F\_peak] The peak flux over the object, in the units of flux.
714\item[X1, X2] The minimum and maximum X-pixel coordinates.
715\item[Y1, Y2] The minimum and maximum Y-pixel coordinates.
716\item[Z1, Z2] The minimum and maximum Z-pixel coordinates.
717\item[Npix] The number of voxels (\ie distinct $(x,y,z)$ coordinates)
718  in the detection.
719\item[Flag] Whether the detection has any warning flags (see below).
720\end{entry}
721The Name is derived from the WCS position. For instance, a source
722centred on the RA,Dec position 12$^h$53$^m$45$^s$,
723-36$^\circ$24$'$12$''$ will be called J1253$-$3624 (if the epoch is
724J2000) or B1253$-$3624 (if B1950). An alternative form is used for
725Galactic coordinates: a source centred on the position ($l$,$b$) =
726(323.1245, 5.4567) will be called G323.12$+$05.45. If the WCS is not
727valid (\ie is not present or does not have all the necessary
728information), the Name, RA, DEC, VEL and related columns are not
729printed, but the pixel coordinates are still provided.
730
731The velocity units can be specified by the user, using the parameter
732\texttt{spectralUnits} (enter it as a single string). The default value
733is km/s, which should be suitable for most users. These units are also
734used to give the units of integrated flux.
735
736The last column contains any warning flags about the detection. There
737are currently two options here. An `E' is printed if the detection is
738next to the edge of the image, meaning either the limit of the pixels,
739or the limit of the non-BLANK pixel region. An `N' is printed if the
740total flux, summed over all the (non-BLANK) pixels in the smallest box
741that completely encloses the detection, is negative. Note that this
742sum is likely to include non-detected pixels. It is of use in
743pointing out detections that lie next to strongly negative pixels,
744such as might arise due to interference -- the detected pixels might
745then also be due to the interference, so caution is advised.
746
747\subsubsection{Other results lists}
748
749Two alternative results files can also be requested. One option is a
750VOTable-format XML file, containing just the RA, Dec, Velocity and the
751corresponding widths of the detections, as well as the fluxes. The
752user should set \texttt{flagVOT = 1}, and put the desired filename in the
753parameter \texttt{votFile} -- note that the default is for it not to be
754produced. This file should be compatible with all Virtual Observatory
755tools (such as Aladin\footnote{ Aladin can be found on the web at
756\href{http://aladin.u-strasbg.fr/}{http://aladin.u-strasbg.fr/}}). The
757second option is an annotation file for use with the Karma toolkit of
758visualisation tools (in particular, with \texttt{kvis}). This will draw a
759circle at the position of each detection, and number it according to
760the Obj\# given above. To make use of this option, the user should
761set \texttt{flagKarma = 1}, and put the desired filename in the parameter
762\texttt{karmaFile} -- again, the default is for it not to be produced.
763
764As the program is running, it also (optionally) records the detections
765made in each individual spectrum or channel (see
766\S\ref{sec-detection} for details on this process). This is
767recorded in the file given by the parameter \texttt{LogFile}. This file
768does not include the columns \texttt{Name, RA, DEC, w\_RA, w\_DEC, VEL,
769w\_VEL}. This file is designed primarily for diagnostic purposes: \eg
770to see if a given set of pixels is detected in, say, one channel
771image, but does not survive the merging process. The list of pixels
772(and their fluxes) in the final detection list are also printed to
773this file, again for diagnostic purposes. This feature can be turned
774off by setting \texttt{flagLog = false}. (This may be a good idea if you
775are not interested in its contents, as it can be a large file.)
776
777\begin{figure}[t]
778\begin{center}
779\includegraphics[width=\textwidth]{example_spectrum}
780\end{center}
781\caption{\footnotesize An example of the spectrum output. Note several
782  of the features discussed in the text: the red lines indicating the
783  reconstructed spectrum; the blue dashed lines indicating the
784  spectral extent of the detection; the green hashed area indicating
785  the Milky Way channels that are ignored by the searching algorithm;
786  the blue border showing its spatial extent on the 0th moment map;
787  and the 15~arcmin-long scale bar.}
788\label{fig-spect}
789\end{figure}
790
791\begin{figure}[!t]
792\begin{center}
793\includegraphics[width=\textwidth]{example_moment_map}
794\end{center}
795\caption{\footnotesize An example of the moment map created by
796  \duchamp. The full extent of the cube is covered, and the 0th moment
797  of each object is shown (integrated individually over all the
798  detected channels).}
799\label{fig-moment}
800\end{figure}
801
802\subsubsection{Graphical output -- spectra}
803
804As well as the output data file, a postscript file is created that
805shows the spectrum for each detection, together with a small cutout
806image (the 0th moment) and basic information about the detection (note
807that any flags are printed after the name of the detection, in the
808format \texttt{[E]}). If the cube was reconstructed, the spectrum from
809the reconstruction is shown in red, over the top of the original
810spectrum. The spectral extent of the detected object is indicated by
811two dashed blue lines, and the region covered by the ``Milky Way''
812channels is shown by a green hashed box.
813
814The spectrum that is plotted is governed by the
815\texttt{spectralMethod} parameter. It can be either \texttt{peak},
816where the spectrum is from the spatial pixel containing the
817detection's peak flux; or \texttt{sum}, where the spectrum is summed
818over all spatial pixels, and then corrected for the beam size.
819
820The spectral extent of the detection is indicated with blue lines, and
821a zoom is shown in a separate window. The cutout image can optionally
822include a border around the spatial pixels that are in the detection
823(turned on and off by the parameter \texttt{drawBorders} -- the
824default is \texttt{true}). It also includes a scale bar in the bottom
825left corner to indicate size -- it is 15~arcmin long (note that due to
826projection effects it may be a slightly different physical length from
827object to object). An example detection can be seen below in
828Fig.~\ref{fig-spect}.
829
830\subsubsection{Graphical output -- maps}
831
832Finally, a couple of images are optionally produced: a 0th moment map
833of the cube, combining just the detected channels in each object,
834showing the integrated flux in grey-scale; and a ``detection image'',
835a grey-scale image where the pixel values are the number of channels
836that spatial pixel is detected in. In both cases, if
837\texttt{drawBorders = true}, a border is drawn around the spatial
838extent of each detection. An example moment map is shown in
839Fig.~\ref{fig-moment}.  The production or otherwise of these images is
840governed by the \texttt{flagMaps} parameter.
841
842The purpose of these images are to provide a visual guide to where the
843detections have been made, and, particularly in the case of the moment
844map, to provide an indication of the strength of the source. In both
845cases, the detections are numbered (in the same sense as the output
846list), and the spatial borders are marked out as for the cutout images
847in the spectra file. Both these images are saved as postscript files
848(given by the parameters \texttt{momentMap} and \texttt{detectionMap}
849respectively), with the latter also displayed in a {\sc pgplot}
850window (regardless of the state of \texttt{flagMaps}).
851
852\section{Notes and hints on the use of \duchamp}
853\label{sec-notes}
854
855In using \duchamp, the user has to make a number of decisions about
856the way the program runs. This section is designed to give the user
857some idea about what to choose.
858
859The main choice is whether or not to use the wavelet
860reconstruction. The main benefits of this are the marked reduction in
861the noise level, leading to regularly-shaped detections, and good
862reliability for faint sources. The main drawback with its use is the
863long execution time: to reconstruct a $170\times160\times1024$
864(\hipass) cube often requires three iterations and takes about 20-25
865minutes to run completely. Note that this is for the three-dimensional
866reconstruction: using \texttt{reconDim=1} makes the reconstruction
867quicker (the full program then takes about 6 minutes), but it is still
868the largest part of the time.
869
870The searching part of the procedure is much quicker: searching an
871un-reconstructed cube leads to execution times of only a couple of
872minutes. Alternatively, using the ability to read in previously-saved
873reconstructed arrays makes running the reconstruction more than once a
874more feasible prospect.
875
876On the positive side, the shape of the detections in a cube that has
877been reconstructed will be much more regular and smooth -- the ragged
878edges that objects in the raw cube possess are smoothed by the removal
879of most of the noise. This enables better determination of the shapes
880and characteristics of objects.
881
882A further point to consider when using the reconstruction is that if
883the two-dimensional reconstruction is chosen (\texttt{reconDim=2}), it
884can be susceptible to edge effects. If the valid area in the cube (\ie
885the part that is not BLANK) has non-rectangular edges, the convolution
886can produce artefacts in the reconstruction that mimic the edges and
887can lead (depending on the selection threshold) to some spurious
888sources. Caution is advised with such data -- the user is advised to
889check carefully the reconstructed cube for the presence of such
890artefacts. Note, however, that the 1- and 3-dimensional
891reconstructions are \emph{not} susceptible in the same way, since the
892spectral direction does not generally exhibit these BLANK edges, and
893so we recommend the use of either of these.
894
895If one chooses the reconstruction method, a further decision is
896required on the signal-to-noise cutoff used in determining acceptable
897wavelet coefficients. A larger value will remove more noise from the
898cube, at the expense of losing fainter sources, while a smaller value
899will include more noise, which may produce spurious detections, but
900will be more sensitive to faint sources. Values of less than about
901$3\sigma$ tend to not reduce the noise a great deal and can lead to
902many spurious sources (although this will depend on the nature of the
903cube).
904
905When it comes to searching, the FDR method produces more reliable results
906than simple sigma-clipping, particularly in the absence of reconstruction.
907However, it does not work in exactly the way one would expect for a
908given value of \texttt{alpha}. For instance, setting fairly liberal values
909of \texttt{alpha} (say, 0.1) will often lead to a much smaller fraction
910of false detections (\ie much less than 10\%). This is the effect of the
911merging algorithms, that combine the sources after the detection stage, 
912and reject detections not meeting the minimum pixel or channel requirements.
913It is thus better to aim for larger \texttt{alpha} values than those derived
914from a straight conversion of the desired false detection rate.
915
916Finally, as \duchamp\ is still undergoing development, there are some
917elements that are not fully developed. In particular, it is not as
918clever as I would like at avoiding interference. The ability to place
919requirements on the minimum number of channels and pixels partially
920circumvents this problem, but work is being done to make \duchamp\
921smarter at rejecting signals that are clearly (to a human eye at
922least) interference. See the following section for further
923improvements that are planned.
924
925%\section{Drawbacks of the current program}
926%
927%The program currently has a few problems/drawbacks/things to be aware
928%of that will hopefully be fixed in the future:
929%\begin{itemize}
930%
931%\item Narrow interference spikes are still getting found, particularly
932%  if there is no reconstruction, or reconstruction with a relatively
933%  low \texttt{snrRecon} (such as 2 or 3). Increasing the
934%  \texttt{minChannels} parameter is one way to circumvent this, but
935%  making the algorithm a bit more clever would be preferable.
936%
937%\item Sources that have strong continuum ripple and/or artefacts often
938%  generate many spurious detections. This needs some work to avoid
939%  \duchamp\ doing this, and until then users are advised to be aware
940%  of the possibility. Strong continuum ripples may generate many
941%  sources on the same spatial pixel, and this will be apparent on the
942%  detection images.
943%
944%\item Spectra are integrated over every spatial pixel of the
945%  detection, and this may dilute the actual detection, making it
946%  harder to see \ie the apparent strength of the line as plotted may
947%  not give a true indication of how strong it really is.
948%
949%%\item A caution on the merging part of the procedure. This can be time
950%%  consuming if there are many detections that do not require merging
951%%  -- in this case, the time will go like $N^2$ ($N$ = number of
952%%  detections). If there are plenty of mergers, the size of the list
953%%  reduces quickly, so the execution time will be less.
954%
955%
956%\end{itemize}
957
958
959%\section{Comparison with other software (to be developed further...)}
960%
961%\subsection{fred, by Matt Howlett}
962%
963%This is the program used in the \hipass\ analysis. It smoothes the
964%data spectrally with a boxcar filter of a size that varies over a
965%user-specified range, and then thresholds the data.
966%
967%Works effectively, but generally doesn't find as many sources as
968%\duchamp, particularly when the reconstruction is used. Sensitive to
969%faint, broad features that fall below the reconstruction threshold.
970%
971%Execution takes a long time, depending on the range of filter widths
972%that are used.
973%
974%\subsection{sfind}
975%
976%Hard to evaluate, as it does not (as far as I can see) output the
977%channel number at which detections are made, and does not merge
978%detections made at adjacent channels (\ie it just works in 2
979%dimensions).
980%
981
982\section{Future Developments}
983
984This is both a list of planned improvements and a wish-list of
985features that would be nice to include (but are not planned in the
986immediate future). Let me know if there are items not on this list, or
987items on the list you would like prioritised.
988
989\begin{itemize}
990
991\item Better determination of the noise characteristics of
992  spectral-line cubes, including understanding how the noise is
993  generated and developing a model for it. \textbf{Planned.}
994 
995\item Include more source analysis. Examples could be: shape
996  information; measurements of HI mass; more variety of measurements
997  of velocity width and profile. \textbf{Some planned.}
998
999\item Provide some indication of the significance of the detection
1000  (\ie some S/N-like value). \textbf{Planned.}
1001
1002\item Improved ability to reject interference, possibly on the
1003  spectral shape of features. \textbf{Planned.}
1004
1005\item Ability to separate (de-blend) distinct sources that have been
1006  merged. \textbf{Planned.}
1007
1008\item Link to lists of possible counterparts (\eg via NED/SIMBAD/other
1009  VO tools?). \textbf{Wish-list.}
1010
1011\item On-line web service interface, so a user can upload a cube and
1012  get back a source-list. \textbf{Wish-list}.
1013
1014\item Embed \duchamp\ in a GUI, to move away from the text-based
1015  interaction. \textbf{Wish-list}.
1016\end{itemize}
1017
1018
1019%\bibliographystyle{mn2e}
1020%\bibliographystyle{abbrvnat}
1021%\bibliography{mnrasmnemonic,sourceDetection}
1022\begin{thebibliography}{}
1023
1024\bibitem[\protect\citeauthoryear{{Calabretta} \& {Greisen}}{{Calabretta} \&
1025  {Greisen}}{2002}]{calabretta02}
1026{Calabretta} M.,  {Greisen} E.,  2002, A\&A, 395, 1077
1027
1028\bibitem[\protect\citeauthoryear{{Greisen} \& {Calabretta}}{{Greisen} \&
1029  {Calabretta}}{2002}]{greisen02}
1030{Greisen} E.,  {Calabretta} M.,  2002, A\&A, 395, 1061
1031
1032\bibitem[\protect\citeauthoryear{{Hanisch}, {Farris}, {Greisen}, {Pence},
1033  {Schlesinger}, {Teuben}, {Thompson} \& {Warnock}}{{Hanisch}
1034  et~al.}{2001}]{hanisch01}
1035{Hanisch} R.,  {Farris} A.,  {Greisen} E.,  {Pence} W.,  {Schlesinger} B.,
1036  {Teuben} P.,  {Thompson} R.,    {Warnock} A.,  2001, A\&A, 376, 359
1037
1038\bibitem[\protect\citeauthoryear{{Hopkins}, {Miller}, {Connolly}, {Genovese},
1039  {Nichol} \& {Wasserman}}{{Hopkins} et~al.}{2002}]{hopkins02}
1040{Hopkins} A.,  {Miller} C.,  {Connolly} A.,  {Genovese} C.,  {Nichol} R.,
1041  {Wasserman} L.,  2002, AJ, 123, 1086
1042
1043\bibitem[\protect\citeauthoryear{Lutz}{Lutz}{1980}]{lutz80}
1044Lutz R.,  1980, The Computer Journal, 23, 262
1045
1046\bibitem[\protect\citeauthoryear{{Meyer} et~al.,}{{Meyer}
1047  et~al.}{2004}]{meyer04:trunc}
1048{Meyer} M.,  et~al., 2004, MNRAS, 350, 1195
1049
1050\bibitem[\protect\citeauthoryear{{Miller}, {Genovese}, {Nichol}, {Wasserman},
1051  {Connolly}, {Reichart}, {Hopkins}, {Schneider} \& {Moore}}{{Miller}
1052  et~al.}{2001}]{miller01}
1053{Miller} C.,  {Genovese} C.,  {Nichol} R.,  {Wasserman} L.,  {Connolly} A.,
1054  {Reichart} D.,  {Hopkins} A.,  {Schneider} J.,    {Moore} A.,  2001, AJ, 122,
1055  3492
1056
1057\bibitem[\protect\citeauthoryear{Minchin}{Minchin}{1999}]{minchin99}
1058Minchin R.,  1999, PASA, 16, 12
1059
1060\bibitem[\protect\citeauthoryear{Starck \& Murtagh}{Starck \&
1061  Murtagh}{2002}]{starck02:book}
1062Starck J.-L.,  Murtagh F.,  2002, {``Astronomical Image and Data Analysis''}.
1063Springer
1064
1065\end{thebibliography}
1066
1067
1068\appendix
1069\newpage
1070\section{Available parameters}
1071\label{app-param}
1072
1073The full list of parameters that can be listed in the input file are
1074given here. If not listed, they take the default value given in
1075parentheses. Since the order of the parameters in the input file does
1076not matter, they are grouped here in logical sections.
1077
1078\subsection*{Input-output related}
1079\begin{entry}
1080\item[ImageFile (no default assumed)] The filename of the
1081  data cube to be analysed.
1082\item[flagSubsection \texttt{[false]}] A flag to indicate whether one
1083  wants a subsection of the requested image.
1084\item[Subsection \texttt{[ [*,*,*] ]}] The requested subsection, which
1085  should be specified in the format \texttt{[x1:x2,y1:y2,z1:z2]}, where
1086  the limits are inclusive. If the full range of a dimension is
1087  required, use a \texttt{*}, \eg if you want the full spectral range of
1088  a subsection of the image, use \texttt{[30:140,30:140,*]}.
1089\item[flagReconExists \texttt{[false]}] A flag to indicate whether the
1090  reconstructed array has been saved by a previous run of \duchamp. If
1091  set true, the reconstructed array will be read from the file given by
1092  \texttt{reconFile}, rather than calculated directly.
1093\item[reconFile (no default assumed)] The FITS file that contains the
1094  reconstructed array. If \texttt{flagReconExists} is true and this
1095  parameter is not defined, the default file searched will be
1096  determined by the \atrous\ parameters (see \S\ref{sec-recon}).
1097\item[OutFile \texttt{[duchamp-Results.txt]}] The file containing the
1098  final list of detections. This also records the list of input
1099  parameters.
1100\item[SpectraFile \texttt{[duchamp-Spectra.ps]}] The postscript file
1101  containing the resulting integrated spectra and images of the
1102  detections.
1103\item[flagLog \texttt{[true]}] A flag to indicate whether intermediate
1104  detections should be logged.
1105\item[LogFile \texttt{[duchamp-Logfile.txt]}] The file in which intermediate
1106  detections are logged. These are detections that have not been
1107  merged. This is primarily for use in debugging and diagnostic
1108  purposes -- normal use of the program will probably not require
1109  this.
1110\item[flagOutputRecon \texttt{[false]}] A flag to say whether or not to
1111  save the reconstructed cube as a FITS file. The filename will be
1112  derived from the ImageFile -- the reconstruction of \texttt{image.fits}
1113  will be saved as \texttt{image.RECON?.fits}, where \texttt{?} stands for
1114  the value of \texttt{snrRecon} (see below).
1115\item[flagOutputResid \texttt{[false]}] As for \texttt{flagOutputRecon}, but
1116  for the residual array -- the difference between the original cube
1117  and the reconstructed cube. The filename will be \texttt{image.RESID?.fits}.
1118\item[flagVOT \texttt{[false]}] A flag to say whether to create a VOTable
1119  file corresponding to the information in \texttt{outfile}. This will be
1120  an XML file in the Virtual Observatory VOTable format.
1121\item[votFile \texttt{[duchamp-Results.xml]}] The VOTable file with the
1122  list of final detections. Some input parameters are also recorded.
1123\item[flagKarma \texttt{[false]}] A flag to say whether to create a
1124  Karma annotation file corresponding to the information in
1125  \texttt{outfile}. This can be used as an overlay for the Karma
1126  programs such as \texttt{kvis}.
1127\item[karmaFile \texttt{[duchamp-Results.ann]}] The Karma annotation
1128  file showing the list of final detections.
1129\item[flagMaps \texttt{[true]}] A flag to say whether to save
1130  postscript files showing the 0th moment map of the whole cube
1131  (parameter \texttt{momentMap}) and the detection image
1132  (\texttt{detectionMap}).
1133\item[momentMap \texttt{[duchamp-MomentMap.ps]}] A postscript file
1134  containing a map of the 0th moment of the detected sources, as well
1135  as pixel and WCS coordinates.
1136\item[detectionMap \texttt{[duchamp-DetectionMap.ps]}] A postscript
1137  file showing each of the detected objects, coloured in greyscale by
1138  the number of channels spanned by each pixel. Also shows pixel and WCS
1139  coordinates.
1140\end{entry}
1141
1142\subsection*{Modifying the cube}
1143\begin{entry}
1144\item[flagBlankPix \texttt{[true]}] A flag to say whether to remove BLANK
1145  pixels from the analysis -- these are pixels set to some particular
1146  value because they fall outside the imaged area.
1147\item[blankPixValue \texttt{[-8.00061]}] The value of the BLANK pixels,
1148  if this information is not contained in the FITS header (the usual
1149  procedure is to obtain this value from the header information -- in
1150  which case the value set by this parameter is ignored).
1151\item[flagMW \texttt{[false]}] A flag to say whether to ignore channels
1152  contaminated by Milky Way (or other) emission -- the searching
1153  algorithms will not look at these channels.
1154\item[maxMW \texttt{[112]}] The maximum channel number containing
1155  ``Milky Way'' emission.
1156\item[minMW \texttt{[75]}] The minimum channel number containing
1157  ``Milky Way'' emission. Note that the range specified by
1158  \texttt{maxMW} and \texttt{minMW} is inclusive.
1159\item[flagBaseline \texttt{[false]}] A flag to say whether to remove the
1160  baseline from each spectrum in the cube for the purposes of
1161  reconstruction and detection.
1162\end{entry}
1163
1164\subsection*{Detection related}
1165
1166\subsubsection*{General detection}
1167\begin{entry}
1168\item[flagNegative \texttt{[false]}] A flag to indicate that the features
1169  being searched for are negative. The cube will be inverted prior to
1170  searching.
1171\item[snrCut \texttt{[3.]}] The cut-off value for thresholding, in terms
1172  of number of $\sigma$ above the mean.
1173\item[flagGrowth \texttt{[false]}] A flag indicating whether or not to
1174  grow the detected objects to a smaller threshold.
1175\item[growthCut \texttt{[2.]}] The smaller threshold using in growing
1176  detections. In units of $\sigma$ above the mean.
1177\end{entry}
1178
1179\subsubsection*{\Atrous\ reconstruction}
1180\begin{entry}
1181\item [flagATrous \texttt{[true]}] A flag indicating whether or not to
1182  reconstruct the cube using the \atrous\ wavelet
1183  reconstruction. See \S\ref{sec-recon} for details.
1184\item[reconDim \texttt{[3]}] The number of dimensions to use in the
1185  reconstruction. 1 means reconstruct each spectrum separately, 2
1186  means each channel map is done separately, and 3 means do the whole
1187  cube in one go.
1188\item[scaleMin \texttt{[1]}] The minimum wavelet scale to be used in the
1189  reconstruction. A value of 1 means ``use all scales''.
1190\item[snrRecon \texttt{[4]}] The thresholding cutoff used in the
1191  reconstruction -- only wavelet coefficients this many $\sigma$ above
1192  the mean (or greater) are included in the reconstruction.
1193\item[filterCode \texttt{[1]}] The code number of the filter to use in
1194  the reconstruction. The options are:
1195  \begin{itemize}
1196  \item \textbf{1:} B$_3$-spline filter: coefficients =
1197    $(\frac{1}{16}, \frac{1}{4}, \frac{3}{8}, \frac{1}{4}, \frac{1}{16})$
1198  \item \textbf{2:} Triangle filter: coefficients = $(\frac{1}{4}, \frac{1}{2}, \frac{1}{4})$
1199  \item \textbf{3:} Haar wavelet: coefficients = $(0, \frac{1}{2}, \frac{1}{2})$
1200  \end{itemize}
1201\end{entry}
1202
1203\subsubsection*{FDR method}
1204\begin{entry}
1205\item[flagFDR \texttt{[false]}] A flag indicating whether or not to use
1206  the False Discovery Rate method in thresholding the pixels.
1207\item[alphaFDR \texttt{[0.01]}] The $\alpha$ parameter used in the FDR
1208analysis. The average number of false detections, as a fraction of the
1209total number, will be less than $\alpha$ (see \S\ref{sec-detection}).
1210\end{entry}
1211
1212\subsubsection*{Merging detections}
1213\begin{entry}
1214\item[minPix \texttt{[2]}] The minimum number of spatial pixels for a single
1215  detection to be counted.
1216\item[minChannels \texttt{[3]}] The minimum number of consecutive
1217  channels that must be present in a detection.
1218\item[flagAdjacent \texttt{[true]}] A flag indicating whether to use the
1219  ``adjacent pixel'' criterion to decide whether to merge objects. If
1220  not, the next two parameters are used to determine whether objects
1221  are within the necessary thresholds.
1222\item[threshSpatial \texttt{[3.]}] The maximum allowed minimum spatial
1223  separation (in pixels) between two detections for them to be merged
1224  into one. Only used if \texttt{flagAdjacent = false}.
1225\item[threshVelocity \texttt{[7.]}] The maximum allowed minimum channel
1226  separation between two detections for them to be merged into
1227  one.
1228\end{entry}
1229
1230\subsubsection*{Other parameters}
1231\begin{entry}
1232\item[spectralMethod \texttt{[peak]}] This indicates which method is used
1233  to plot the output spectra: \texttt{peak} means plot the spectrum
1234  containing the detection's peak pixel; \texttt{sum} means sum the
1235  spectra of each detected spatial pixel, and correct for the beam
1236  size. Any other choice defaults to \texttt{peak}.
1237\item[spectralUnits \texttt{[km/s]}] The user can specify the units of
1238  the spectral axis. Assuming the WCS of the FITS file is valid, the
1239  spectral axis is transformed into velocity, and put into these units
1240  for all output and for calculations such as the integrated flux of a
1241  detection.
1242\item[drawBorders \texttt{[true]}] A flag indicating whether borders
1243  are to be drawn around the detected objects in the moment maps
1244  included in the output (see for example Fig.~\ref{fig-spect}).
1245\item[verbose \texttt{[true]}] A flag indicating whether to print the
1246  progress of computationally-intensive algorithms (such as the
1247  searching and merging) to screen.
1248\end{entry}
1249
1250
1251\newpage
1252\section{Example parameter files}
1253\label{app-input}
1254
1255This is what a typical parameter file would look like.
1256
1257\begin{verbatim}
1258imageFile       /DATA/SITAR_1/whi550/cubes/H201_abcde_luther_chop.fits
1259logFile         logfile.txt
1260outFile         results.txt
1261spectraFile     spectra.ps
1262flagSubsection  0
1263flagOutputRecon 0
1264flagOutputResid 0
1265flagBlankPix    1
1266flagMW          1
1267minMW           75
1268maxMW           112
1269minPix          3
1270flagGrowth      1
1271growthCut       1.5
1272flagATrous      0
1273scaleMin        1
1274snrRecon        4
1275flagFDR         1
1276alphaFDR        0.1
1277numPixPSF       20
1278snrCut          3
1279threshSpatial   3
1280threshVelocity  7
1281\end{verbatim}
1282
1283Note that it is not necessary to include all these parameters in the
1284file, only those that need to be changed from the defaults (as listed
1285in Appendix~\ref{app-param}), which in this case would be very few. A
1286minimal parameter file might look like:
1287\begin{verbatim}
1288imageFile       /DATA/SITAR_1/whi550/cubes/H201_abcde_luther_chop.fits
1289flagLog         0
1290snrRecon        3
1291snrCut          2.5
1292minChannels     4
1293\end{verbatim}
1294This will reconstruct the cube with a lower SNR value than the
1295default, select objects at a lower threshold,  with a looser minimum
1296channel requirement, and not keep a log of the intermediate
1297detections.
1298
1299The following page demonstrates how the parameters are presented to the
1300user, both on the screen at execution time, and in the output and log
1301files. On each line, there is a description on the parameter, the relevant
1302parameter name that is used in the input file (if there is one that the
1303user can enter), and the value of the parameter being used.
1304\newpage
1305\begin{landscape}
1306Typical presentation of parameters in output and log files: 
1307\begin{verbatim}
1308---- Parameters ----
1309Image to be analysed.........................[imageFile]  =  input.fits
1310Intermediate Logfile...........................[logFile]  =  duchamp-Logfile.txt         
1311Final Results file.............................[outFile]  =  duchamp-Results.txt         
1312Spectrum file..............................[spectraFile]  =  duchamp-Spectra.ps   
13130th Moment Map...............................[momentMap]  =  duchamp-MomentMap.ps
1314Detection Map.............................[detectionMap]  =  duchamp-DetectionMap.ps
1315Saving reconstructed cube?.............[flagoutputrecon]  =  false
1316Saving residuals from reconstruction?..[flagoutputresid]  =  false
1317------
1318Searching for Negative features?..........[flagNegative]  =  false
1319Fixing Blank Pixels?......................[flagBlankPix]  =  true
1320Blank Pixel Value.......................................  =  -8.00061
1321Removing Milky Way channels?....................[flagMW]  =  true
1322Milky Way Channels.......................[minMW - maxMW]  =  75-112
1323Beam Size (pixels)......................................  =  10.1788
1324Removing baselines before search?.........[flagBaseline]  =  false
1325Minimum # Pixels in a detection.................[minPix]  =  2
1326Minimum # Channels in a detection..........[minChannels]  =  3
1327Growing objects after detection?............[flagGrowth]  =  false
1328Using A Trous reconstruction?...............[flagATrous]  =  true
1329Number of dimensions in reconstruction........[reconDim]  =  3
1330Minimum scale in reconstruction...............[scaleMin]  =  1
1331SNR Threshold within reconstruction...........[snrRecon]  =  4
1332Filter being used for reconstruction........[filterCode]  =  1 (B3 spline function)
1333Using FDR analysis?............................[flagFDR]  =  false
1334SNR Threshold...................................[snrCut]  =  3
1335Using Adjacent-pixel criterion?...........[flagAdjacent]  =  true
1336Max. velocity separation for merging....[threshVelocity]  =  7
1337Method of spectral plotting.............[spectralMethod]  =  peak
1338\end{verbatim}
1339
1340\newpage
1341\section{Example results file}
1342\label{app-output}
1343This the typical content of an output file, after running \duchamp\
1344with the parameters illustrated on the previous page.
1345
1346{\scriptsize
1347  \begin{verbatim}
1348Results of the \duchamp\ source finder: Tue May 23 14:51:38 2006
1349---- Parameters ----
1350      (... omitted for clarity -- see previous page for examples...)
1351--------------------
1352Total number of detections = 25
1353--------------------
1354------------------------------------------------------------------------------------------------------------------------------------------------------
1355 Obj#       Name     X     Y     Z           RA          DEC      VEL     w_RA    w_DEC   w_VEL     F_int    F_peak  X1  X2  Y1  Y2  Z1  Z2  Npix Flag
1356                                                               [km/s] [arcmin] [arcmin]  [km/s] [Jy km/s] [Jy/beam]                         [pix]     
1357------------------------------------------------------------------------------------------------------------------------------------------------------
1358    1 J0618-2532  30.2  86.0 113.3  06:18:12.54 -25:32:44.79  208.502    45.17    34.61  26.383    24.394     0.350  25  35  82  90 112 114   137    E
1359    2 J0609-2156  59.5 140.6 114.6  06:09:19.66 -21:56:31.20  225.572    44.39    31.47  65.957    16.128     0.213  55  65 137 144 113 118   153     
1360    3 J0545-2143 141.2 143.2 114.8  05:45:51.71 -21:43:36.20  228.470    19.61    16.66  26.383     2.412     0.090 139 143 142 145 114 116    29     
1361    4 J0617-2633  33.3  70.8 115.6  06:17:25.52 -26:33:33.83  238.736    65.02    30.10  26.383     9.776     0.117  26  41  68  75 115 117   104    E
1362    5 J0601-2500  86.2  94.9 117.9  06:01:39.54 -25:00:32.46  269.419    27.99    24.02  26.383     3.920     0.124  83  89  92  97 117 119    44     
1363    6 J0602-2547  84.0  83.1 118.0  06:02:18.29 -25:47:31.69  270.319    20.01    19.99  26.383     2.999     0.118  82  86  81  85 117 119    34     
1364    7 J0547-2448 133.0  97.2 118.7  05:47:52.53 -24:48:38.16  279.113    19.72    12.54  26.383     1.474     0.074 131 135  96  98 118 120    21     
1365    8 J0606-2719  71.1  60.0 121.3  06:06:10.99 -27:19:48.61  314.090    52.36    39.59  39.574    14.268     0.150  65  77  55  64 120 123   154     
1366    9 J0611-2137  52.4 145.3 162.5  06:11:20.92 -21:37:29.57  857.955    32.39    23.49 118.722    43.178     0.410  49  56 142 147 158 167   265    E
1367   10 J0600-2859  89.7  35.3 202.4  06:00:34.08 -28:59:00.43 1383.160    23.93    24.10 171.487    24.439     0.173  87  92  33  38 196 209   271     
1368   11 J0558-2638  95.4  70.3 223.1  05:58:53.03 -26:38:45.91 1656.140    11.93    12.07  92.339     1.045     0.063  94  96  69  71 220 227    18     
1369   12 J0617-2723  34.7  58.3 227.4  06:17:07.07 -27:23:50.65 1712.868    16.75    23.53 290.209     8.529     0.093  33  36  56  61 215 237   118     
1370   13 J0558-2525  95.8  88.6 231.7  05:58:49.27 -25:25:33.60 1770.134    27.87    24.16 237.444    12.863     0.115  92  98  86  91 221 239   175     
1371   14 J0600-2141  88.8 144.4 232.5  06:00:54.02 -21:41:57.06 1780.188    27.96    24.13 224.252    30.743     0.166  86  92 142 147 222 239   344    E
1372   15 J0615-2634  40.0  70.8 232.6  06:15:25.50 -26:34:20.04 1782.214    12.44    15.69  52.765     2.084     0.068  39  41  69  72 231 235    31     
1373   16 J0604-2606  76.0  78.4 233.0  06:04:41.13 -26:06:21.19 1787.226    24.13    23.87 211.061    23.563     0.155  73  78  76  81 225 241   278     
1374   17 J0601-2340  87.9 114.9 235.8  06:01:08.83 -23:40:19.37 1824.122    31.95    28.09 237.444    82.380     0.297  85  92 112 118 227 245   647     
1375   18 J0615-2235  38.2 130.5 254.5  06:15:32.09 -22:35:37.24 2070.934    12.29    11.70 105.531     1.555     0.070  37  39 129 131 249 257    24     
1376   19 J0617-2305  31.4 122.8 258.1  06:17:33.45 -23:05:28.94 2118.752    12.34    11.65  26.383     1.022     0.062  30  32 122 124 257 259    16     
1377   20 J0612-2149  49.6 142.2 270.3  06:12:11.04 -21:49:29.72 2279.926    16.27    15.73 395.740    15.156     0.101  48  51 141 144 257 287   204     
1378   21 J0616-2133  35.3 146.0 300.6  06:16:15.78 -21:33:09.69 2679.148    20.22     7.47 224.252     3.014     0.127  33  37 145 146 294 311    28    E
1379   22 J0555-2956 107.3  20.9 367.6  05:55:08.02 -29:56:09.08 3562.236    19.71    20.30  39.574     5.891     0.169 105 109  19  23 366 369    58     
1380   23 J0557-2246  99.8 128.2 434.0  05:57:43.77 -22:46:42.95 4438.776    11.88    16.12 105.531     1.703     0.167  99 101 127 130 430 438    17    N
1381   24 J0616-2648  38.1  67.2 546.8  06:16:02.10 -26:48:35.49 5926.464    12.35    11.67  26.383     1.276     0.064  37  39  66  68 546 548    18     
1382   25 J0552-2916 117.0  30.5 727.0  05:52:13.64 -29:16:58.02 8303.952    11.59    20.25 303.400    35.523     0.479 116 118  28  32 716 739   111     
1383  \end{verbatim}
1384}
1385Note that the
1386width of the table can make it hard to read. A good trick for those
1387using UNIX/Linux is to make use of the \texttt{a2ps} command. The
1388following works well, producing a postscript file \texttt{results.ps}:
1389\\\verb|a2ps -1 -r -f8 -o duchamp-Results.ps duchamp-Results.txt|
1390
1391%\end{landscape}
1392
1393\newpage
1394\section{Example VOTable output}
1395\label{app-votable}
1396This is part of the VOTable, in XML format, corresponding to the
1397output file in Appendix~\ref{app-output} (the indentation has been
1398removed to make it fit on the page).
1399
1400%\begin{landscape}
1401{\scriptsize
1402  \begin{verbatim}
1403<?xml version="1.0"?>
1404<VOTABLE version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1405 xsi:noNamespaceSchemaLocation="http://www.ivoa.net/xml/VOTable/VOTable/v1.1">
1406<COOSYS ID="J2000" equinox="J2000." epoch="J2000." system="eq_FK5"/>
1407<RESOURCE name="Duchamp Output">
1408<TABLE name="Detections">
1409<DESCRIPTION>Detected sources and parameters from running the Duchamp source finder.</DESCRIPTION>
1410<PARAM name="FITS file" datatype="char" ucd="meta.file;meta.fits" value="/DATA/SITAR_1/whi550/cubes/H201_abcde_luther_chop.fits"/>
1411<PARAM name="Threshold" datatype="float" ucd="stat.snr" value="2.5">
1412<PARAM name="ATrous note" datatype="char" ucd="meta.note" value="The a trous reconstruction method was used, with the following parameters.">
1413<PARAM name="ATrous Dimension" datatype="int" ucd="meta.code;stat" value="3">
1414<PARAM name="ATrous Cut" datatype="float" ucd="stat.snr" value="4">
1415<PARAM name="ATrous Minimum Scale" datatype="int" ucd="stat.param" value="1">
1416<PARAM name="ATrous Filter" datatype="char" ucd="meta.code;stat" value="B3 spline function">
1417<FIELD name="ID" ID="col1" ucd="meta.id" datatype="int" width="4"/>
1418<FIELD name="Name" ID="col2" ucd="meta.id;meta.main" datatype="char" arraysize="14"/>
1419<FIELD name="RA" ID="col3" ucd="pos.eq.ra;meta.main" ref="J2000" datatype="float" width="10" precision="6" unit="deg"/>
1420<FIELD name="Dec" ID="col4" ucd="pos.eq.dec;meta.main" ref="J2000" datatype="float" width="10" precision="6" unit="deg"/>
1421<FIELD name="w_RA" ID="col3" ucd="phys.angSize;pos.eq.ra" ref="J2000" datatype="float" width="7" precision="2" unit="arcmin"/>
1422<FIELD name="w_Dec" ID="col4" ucd="phys.angSize;pos.eq.dec" ref="J2000" datatype="float" width="7" precision="2" unit="arcmin"/>
1423<FIELD name="Vel" ID="col4" ucd="phys.veloc;src.dopplerVeloc" datatype="float" width="9" precision="3" unit="km/s"/>
1424<FIELD name="w_Vel" ID="col4" ucd="phys.veloc;src.dopplerVeloc;spect.line.width" datatype="float" width="8" precision="3" unit="km/s"/>
1425<FIELD name="Integrated_Flux" ID="col4" ucd="phys.flux;spect.line.intensity" datatype="float" width="10" precision="3" unit="km/s"/>
1426<DATA>
1427<TABLEDATA>
1428<TR>
1429<TD>   1</TD><TD> J0609-2200</TD><TD> 92.410416</TD><TD>-22.013390</TD><TD>  48.50</TD><TD>  39.42</TD><TD>  213.061</TD><TD>  65.957</TD><TD>    17.572</TD>
1430</TR>
1431<TR>
1432<TD>   2</TD><TD> J0608-2605</TD><TD> 92.042633</TD><TD>-26.085157</TD><TD>  44.47</TD><TD>  39.47</TD><TD>  233.119</TD><TD>  39.574</TD><TD>     4.144</TD>
1433</TR>
1434<TR>
1435<TD>   3</TD><TD> J0606-2724</TD><TD> 91.637840</TD><TD>-27.412022</TD><TD>  52.48</TD><TD>  47.57</TD><TD>  302.213</TD><TD>  39.574</TD><TD>    17.066</TD>
1436</TR>
1437(... table truncated for clarity ...)
1438</TABLEDATA>
1439</DATA>
1440</TABLE>
1441</RESOURCE>
1442</VOTABLE>
1443  \end{verbatim}
1444}
1445\end{landscape}
1446
1447\newpage
1448\section{Example Karma Annotation File output}
1449\label{app-karma}
1450
1451This is the format of the Karma Annotation file, showing the locations
1452of the detected objects. This can be loaded by the plotting tools of
1453the Karma package (for instance, \texttt{kvis}) as an overlay on the FITS
1454file.
1455
1456\begin{verbatim}
1457# Duchamp Source Finder results for
1458#  cube /DATA/SITAR_1/whi550/cubes/H201_abcde_luther_chop.fits
1459COLOR RED
1460COORD W
1461CIRCLE 92.3376 -21.9475 0.403992
1462TEXT 92.3376 -21.9475 1
1463CIRCLE 91.9676 -26.0193 0.37034
1464TEXT 91.9676 -26.0193 2
1465CIRCLE 91.5621 -27.3459 0.437109
1466TEXT 91.5621 -27.3459 3
1467CIRCLE 92.8285 -21.6344 0.269914
1468TEXT 92.8285 -21.6344 4
1469CIRCLE 90.1381 -28.9838 0.234179
1470TEXT 90.1381 -28.9838 5
1471CIRCLE 89.72 -26.6513 0.132743
1472TEXT 89.72 -26.6513 6
1473CIRCLE 94.2743 -27.4003 0.195175
1474TEXT 94.2743 -27.4003 7
1475CIRCLE 92.2739 -21.6941 0.134538
1476TEXT 92.2739 -21.6941 8
1477CIRCLE 89.7133 -25.4259 0.232252
1478TEXT 89.7133 -25.4259 9
1479CIRCLE 90.2206 -21.6993 0.266247
1480TEXT 90.2206 -21.6993 10
1481CIRCLE 93.8581 -26.5766 0.163153
1482TEXT 93.8581 -26.5766 11
1483CIRCLE 91.176 -26.1064 0.234356
1484TEXT 91.176 -26.1064 12
1485CIRCLE 90.2844 -23.6716 0.299509
1486TEXT 90.2844 -23.6716 13
1487CIRCLE 93.8774 -22.581 0.130925
1488TEXT 93.8774 -22.581 14
1489CIRCLE 94.3882 -23.0934 0.137108
1490TEXT 94.3882 -23.0934 15
1491CIRCLE 93.0491 -21.8223 0.202928
1492TEXT 93.0491 -21.8223 16
1493CIRCLE 94.0685 -21.5603 0.168456
1494TEXT 94.0685 -21.5603 17
1495CIRCLE 86.0568 -27.6095 0.101113
1496TEXT 86.0568 -27.6095 18
1497CIRCLE 88.7932 -29.9453 0.202624
1498TEXT 88.7932 -29.9453 19
1499\end{verbatim}
1500
1501\newpage
1502\section{Installing \duchamp\ (README file)}
1503\begin{verbatim}
1504There is an executable (Duchamp) that has been compiled on a Debian
1505Linux kernel 2.6.8-2-686, with gcc version 3.3.5 (Debian 1:3.3.5-13)
1506
1507If that is no good to you, you can compile it yourself using the
1508Makefile included in this directory (sorry for not having a configure
1509script or similar yet!).
1510
1511Duchamp uses three main external libraries: pgplot, cfitsio and
1512wcslib. You will need to set the paths for the base directory and
1513three libraries, as they are currently configured for my use and will
1514not be of much use to you. These are:
1515
1516BASE --> the current directory
1517PGDIR --> where the pgplot libraries (and header files) are located
1518CFITSIODIR --> where the header file fitsio.h is
1519CFITSIOLDIR --> where the cfitsio library is located (libcfitsio.a)
1520WCSDIR --> where the wcslib header files are
1521WCSLDIR --> where the wcslib library is located (libwcs.a)
1522
1523If you do not have the libraries, they can be downloaded from the
1524following locations:
1525PGPlot -- http://www.astro.caltech.edu/~tjp/pgplot/
1526cfitsio -- http://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html
1527wcslib -- http://www.atnf.csiro.au/people/Mark.Calabretta/WCS/index.html
1528
1529Once you've set up the Makefile correctly, then simply typing
1530> make duchamp
1531will compile the program.
1532
1533To run it, you need to use the syntax
1534> Duchamp -p parameterFile
1535where parameterFile is a file with the input parameters, including the
1536name of the cube you want to search.
1537
1538There are two example input files included with the distribution. The
1539smaller one, InputExample, shows the typical parameters one might want
1540to set. The large one, InputComplete, lists all parameters that can be
1541entered, and a brief description of them. Refer to the documentation
1542for further details.
1543
1544To get going quickly, just replace the "your-file-here" in
1545InputExample with your image name, and type
1546> Duchamp -p InputExample
1547and you're off!
1548\end{verbatim}
1549
1550\section{Robust statistics for a Normal distribution}
1551\label{app-madfm}
1552
1553The Normal, or Gaussian, distribution for mean $\mu$ and standard
1554deviation $\sigma$ can be written as
1555\[
1556f(x) = \frac{1}{\sqrt{2\pi\sigma^2}}\ e^{-(x-\mu)^2/2\sigma^2}.
1557 \]
1558
1559When one has a purely Gaussian signal, it is straightforward to
1560estimate $\sigma$ by calculating the standard deviation (or rms) of
1561the data. However, if there is a small amount of signal present on top
1562of Gaussian noise, and one wants to estimate the $\sigma$ for the
1563noise, the presence of the large values from the signal can bias the
1564estimator to higher values.
1565
1566An alternative way is to use the median ($m$) and median absolute deviation
1567from the median ($s$) to estimate $\mu$ and $\sigma$. The median is the
1568middle of the distribution, defined for a continuous distribution by
1569\[
1570\int_{-\infty}^{m} f(x) \diff x = \int_{m}^{\infty} f(x) \diff x.
1571\]
1572From symmetry, we quickly see that for the continuous Normal
1573distribution, $m=\mu$. We consider the case henceforth of $\mu=0$,
1574without loss of generality.
1575
1576To find $s$, we find the distribution of the absolute deviation from
1577the median, and then find the median of that distribution. This
1578distribution is given by
1579\begin{eqnarray*}
1580g(x) &= &{\mbox{\rm distribution of }} |x|\\
1581     &= &f(x) + f(-x),\ x\ge0\\
1582     &= &\sqrt{\frac{2}{\pi\sigma^2}}\, e^{-x^2/2\sigma^2},\ x\ge0.
1583\end{eqnarray*}
1584So, the median absolute deviation from the median, $s$, is given by
1585\[
1586\int_{0}^{s} g(x) \diff x = \int_{s}^{\infty} g(x) \diff x.
1587\]
1588Now, $\int_{0}^{\infty}e^{-x^2/2\sigma^2} \diff x = \sqrt{\pi\sigma^2/2}$, and
1589so $\int_{s}^{\infty} e^{-x^2/2\sigma^2} \diff x =
1590\sqrt{\pi\sigma^2/2} - \int_{0}^{s} e^{-\frac{x^2}{2\sigma^2}} \diff x
1591$. Hence, to find $s$ we simply solve the following equation (setting $\sigma=1$ for
1592simplicity -- equivalent to stating $x$ and $s$ in units of $\sigma$):
1593\[
1594\int_{0}^{s}e^{-x^2/2} \diff x - \sqrt{\pi/8} = 0.
1595\]
1596This is hard to solve analytically (no nice analytic solution exists
1597for the finite integral that I'm aware of), but straightforward to
1598solve numerically, yielding the value of $s=0.6744888$. Thus, to
1599estimate $\sigma$ for a Normally distributed data set, one can calculate
1600$s$, then divide by 0.6744888 (or multiply by 1.4826042) to obtain the
1601correct estimator.
1602
1603Note that this is different to solutions quoted elsewhere,
1604specifically in \citet{meyer04:trunc}, where the same robust estimator
1605is used but with an incorrect conversion to standard deviation -- they
1606assume $\sigma = s\sqrt{\pi/2}$. This, in fact, is the conversion used
1607to convert the \emph{mean} absolute deviation from the mean to the
1608standard deviation. This means that the cube noise in the \hipass\
1609catalogue (their parameter Rms$_{\rm cube}$) should be 18\% larger
1610than quoted.
1611
1612\section{How Gaussian noise changes with wavelet scale.}
1613\label{app-scaling}
1614
1615The key element in the wavelet reconstruction of an array is the
1616thresholding of the individual wavelet coefficient arrays. This is
1617usually done by choosing a level to be some number of standard
1618deviations above the mean value.
1619
1620However, since the wavelet arrays are produced by convolving the input
1621array by an increasingly large filter, the pixels in the coefficient
1622arrays become increasingly correlated as the scale of the filter
1623increases. This results in the measured standard deviation from a
1624given coefficient array decreasing with increasing scale. To calculate
1625this, we need to take into account how many other pixels each pixel in
1626the convolved array depends on.
1627
1628To demonstrate, suppose we have a 1-D array with $N$ pixel values
1629given by $F_i,\ i=1,...,N$, and we convolve it with the B$_3$-spline
1630filter, defined by the set of coefficients
1631$\{1/16,1/4,3/8,1/4,1/16\}$. The flux of the $i$th pixel in the
1632convolved array will be
1633\[
1634F'_i = \frac{1}{16}F_{i-2} + \frac{1}{4}F_{i-1} + \frac{3}{8}F_{i}
1635+ \frac{1}{4}F_{i+1} + \frac{1}{16}F_{i+2}
1636\]
1637and the flux of the corresponding pixel in the wavelet array will be
1638\[
1639W'_i = F_i - F'_i = \frac{-1}{16}F_{i-2} - \frac{1}{4}F_{i-1} + \frac{5}{8}F_{i}
1640- \frac{1}{4}F_{i+1} - \frac{1}{16}F_{i+2}
1641\]
1642Now, assuming each pixel has the same standard deviation
1643$\sigma_i=\sigma$, we can work out the standard deviation for the
1644wavelet array:
1645\[
1646\sigma'_i = \sigma \sqrt{\left(\frac{1}{16}\right)^2 + \left(\frac{1}{4}\right)^2
1647  + \left(\frac{5}{8}\right)^2 + \left(\frac{1}{4}\right)^2 + \left(\frac{1}{16}\right)^2}
1648          = 0.72349\ \sigma
1649\]
1650Thus, the first scale wavelet coefficient array will have a standard
1651deviation of 72.3\% of the input array. This procedure can be followed
1652to calculate the necessary values for all scales, dimensions and
1653filters used by \duchamp.
1654
1655Calculating these values is clearly a critical step in performing the
1656reconstruction. \citet{starck02:book} did so by simulating data sets
1657with Gaussian noise, taking the wavelet transform, and measuring the
1658value of $\sigma$ for each scale. We take a different approach, by
1659calculating the scaling factors directly from the filter coefficients
1660by taking the wavelet transform of an array made up of a 1 in the
1661central pixel and 0s everywhere else. The scaling value is then
1662derived by taking the square root of the sum (in quadrature) of all
1663the wavelet coefficient values at each scale. We give the scaling
1664factors for the three filters available to \duchamp\ on the following
1665page. These values are hard-coded into \duchamp, so no on-the-fly
1666calculation of them is necessary.
1667
1668Memory limitations prevent us from calculating factors for large
1669scales, particularly for the three-dimensional case (hence the --
1670symbols in the tables). To calculate factors for
1671higher scales than those available, we note the following
1672relationships apply for large scales to a sufficient level of precision:
1673\begin{itemize}
1674\item 1-D: factor(scale $i$) = factor(scale $i-1$)$/\sqrt{2}$.
1675\item 2-D: factor(scale $i$) = factor(scale $i-1$)$/2$.
1676\item 1-D: factor(scale $i$) = factor(scale $i-1$)$/\sqrt{8}$.
1677\end{itemize}
1678
1679\newpage
1680\begin{itemize}
1681\item \textbf{B$_3$-Spline Function:} $\{1/16,1/4,3/8,1/4,1/16\}$
1682
1683\begin{tabular}{llll}
1684Scale & 1 dimension      & 2 dimension     & 3 dimension\\ \hline
16851     & 0.723489806      & 0.890796310     & 0.956543592\\
16862     & 0.285450405      & 0.200663851     & 0.120336499\\
16873     & 0.177947535      & 0.0855075048    & 0.0349500154\\
16884     & 0.122223156      & 0.0412474444    & 0.0118164242\\
16895     & 0.0858113122     & 0.0204249666    & 0.00413233507\\
16906     & 0.0605703043     & 0.0101897592    & 0.00145703714\\
16917     & 0.0428107206     & 0.00509204670   & 0.000514791120\\
16928     & 0.0302684024     & 0.00254566946   & --\\
16939     & 0.0214024008     & 0.00127279050   & --\\
169410    & 0.0151336781     & 0.000636389722  & --\\
169511    & 0.0107011079     & 0.000318194170  & --\\
169612    & 0.00756682272    & --              & --\\
169713    & 0.00535055108    & --              & --\\
1698%14    & 0.00378341085   & --              & --\\
1699%15    & 0.00267527545   & --              & --\\
1700%16    & 0.00189170541   & --              & --\\
1701%17    & 0.00133763772   & --              & --\\
1702%18    & 0.000945852704   & --             & --
1703\end{tabular}
1704
1705\item \textbf{Triangle Function:} $\{1/4,1/2,1/4\}$
1706
1707\begin{tabular}{llll}
1708Scale & 1 dimension      & 2 dimension     & 3 dimension\\ \hline
17091     & 0.612372436      & 0.800390530     & 0.895954449  \\
17102     & 0.330718914      & 0.272878894     & 0.192033014\\
17113     & 0.211947812      & 0.119779282     & 0.0576484078\\
17124     & 0.145740298      & 0.0577664785    & 0.0194912393\\
17135     & 0.102310944      & 0.0286163283    & 0.00681278387\\
17146     & 0.0722128185     & 0.0142747506    & 0.00240175885\\
17157     & 0.0510388224     & 0.00713319703   & 0.000848538128 \\
17168     & 0.0360857673     & 0.00356607618   & 0.000299949455 \\
17179     & 0.0255157615     & 0.00178297280   & -- \\
171810    & 0.0180422389     & 0.000891478237  & --  \\
171911    & 0.0127577667     & 0.000445738098  & --  \\
172012    & 0.00902109930    & 0.000222868922  & --  \\
172113    & 0.00637887978    & --              & -- \\
1722%14   & 0.00451054902    & --              & -- \\
1723%15   & 0.00318942978    & --              & -- \\
1724%16   & 0.00225527449    & --              & -- \\
1725%17   & 0.00159471988    & --              & -- \\
1726%18   & 0.000112763724   & --              & --
1727
1728\end{tabular}
1729
1730\item \textbf{Haar Wavelet:} $\{0,1/2,1/2\}$
1731
1732\begin{tabular}{llll}
1733Scale & 1 dimension      & 2 dimension     & 3 dimension\\ \hline
17341     & 0.707167810      & 0.433012702     & 0.935414347 \\
17352     & 0.500000000      & 0.216506351     & 0.330718914\\
17363     & 0.353553391      & 0.108253175     & 0.116926793\\
17374     & 0.250000000      & 0.0541265877    & 0.0413398642\\
17385     & 0.176776695      & 0.0270632939    & 0.0146158492\\
17396     & 0.125000000      & 0.0135316469    & 0.00516748303
1740
1741\end{tabular}
1742
1743
1744\end{itemize}
1745
1746\end{document}
Note: See TracBrowser for help on using the repository browser.