0804.1175/ms.tex
1: %% Beginning of main file
2: %% Last Modified 2006 Oct 19
3: 
4: %\documentclass[natbib209,flushrt]{aastex} % maybe useful when using bibtex  
5: \documentclass[preprint2]{aastex} % manuscript
6: 
7: %% directives for bibtex
8: %\citestyle{aa} % no commas in autor-year form
9: %\bibliographystyle{apj} % AASTeX standard style
10: 
11: \usepackage[latin1]{inputenc} % suporte para acentos e �
12: \usepackage{graphicx} % figures
13: 
14: \slugcomment{To appear in PASP} 
15: \shorttitle{The 2DPHOT environment}
16: \shortauthors{F. La Barbera et al.}
17: 
18: \author{F. La Barbera}
19: \affil{INAF-Osservatorio Astronomico di Capodimonte, via Moiariello
20:   n.16, Napoli, Italy}
21: \email{labarber@na.astro.it}
22: \author{R. R. de Carvalho}
23: \affil{INAF-VSTCeN, via Moiariello
24:   n.16, Napoli, Italy\footnote{On leave of absence INPE/DAS, Av. dos Astronautas 1758, S$\tilde{a}$o Jos\'e dos Campos, SP 12227-010, Brazil.}}
25: \email{reinaldo@das.inpe.br}
26: \author{J.L. Kohl-Moreira}
27: \affil{Observat\'orio Nacional, Rua General Jos\'e Cristino 77, S$\tilde{a}$o Crist\'ov$\tilde{a}$o, Rio de Janeiro 20921-400, Brazil}
28: \author{R.R. Gal}
29: \affil{University of Hawaii, Institute for Astronomy, 2680 Woodlawn Dr., Honolulu, HI, 96822, United States}
30: \author{M. Soares-Santos}
31: \affil{Instituto de Astronomia, Geof\'isica e Ciencias Atmosf\'ericas}
32: \author{M. Capaccioli}
33: \affil{INAF-VSTCeN, via Moiariello
34:   n.16, Napoli, Italy}
35: \author{R. Santos}
36: \affil{INPE/LAC, Av. dos Astronautas 1758, S$\tilde{a}$o Jos\'e dos Campos, SP 12227-010, Brazil}
37: \author{N. Sant'Anna}
38: \affil{INPE/LAC, Av. dos Astronautas 1758, S$\tilde{a}$o Jos\'e dos Campos, SP 12227-010, Brazil}
39: 
40: %\author{K. Kuijken}
41: %\affil{Leiden Observatory, 2300RA Leiden, The Netherlands}
42: 
43: \begin{document}
44: 
45: \title{2DPHOT:  a multi-purpose  environment  for  the
46:   two-dimensional analysis of wide-field images}
47: 
48: % list of authors has to be included here.................. 
49: 
50: %
51: %\author{R. R. de Carvalho}
52: % \affil{Instituto Nacional de Pesquisas Espaciais, S�o Jos� dos Campos SP}
53: %\email{reinaldo@das.inpe.br}
54: %
55: %\author{F. La Barbera}
56: %\affil{Osservatorio Astronomico di Capodimonte}
57: %\email{labarber@na.astro.it}
58: %
59: %\author{M. Soares-Santos}
60: %\affil{Instituto de Astronomia, Geof�sica e Ci�ncias Atmosf�ricas}
61: %\email{msoares@astro.iag.usp.br}
62: %
63: %
64: %
65: 
66: \begin{abstract}
67:   We  describe  2DPHOT, a  general  purpose  analysis environment  for
68:   source  detection and analysis in deep wide-field images.
69:   2DPHOT is  an automated tool  to obtain both integrated  and surface
70:   photometry  of   galaxies  in  an  image,  to   perform  reliable
71:   star-galaxy separation  with accurate estimates  of contamination at
72:   faint flux levels, and to  estimate completeness of the image catalog.
73:   We  describe the  analysis strategy  on which
74:   2DPHOT is based, and provide a detailed description of the different
75:   algorithms  implemented in  the  package.  This  new environment  is
76:   intended  as a dedicated  tool to  process the  wealth of  data from
77:   wide-field imaging surveys. To this end, the package is complemented
78:   by  2DGUI, an environment that  allows multiple
79:   processing of data using a range of computing architectures.
80: \end{abstract}
81: 
82: \keywords{Data Analysis and Techniques -- Astronomical Techniques --
83: Astrophysical Data -- Galaxies}
84: 
85: \section{Introduction}\label{intro}
86: 
87: In the past decade, wide-field surveys have provided the scientific
88: community with a huge amount of spectroscopic and photometric data,
89: allowing significant progress in our understanding of the Universe.
90: Perhaps the most widely known example is the Sloan Digital Sky Survey
91: (SDSS), whose sixth data release has now provided photometry in five
92: bands for more than $2 \! \cdot \!  10^8$ astronomical objects, as
93: well as spectra of about one million sources (see
94: \citealt{Adelman:07}) over more than $8500$ square degrees on the sky.
95: One key to the success of the SDSS has been its capability to
96: effectively store, process, and analyze, in a fully automated fashion,
97: the vast amount of data gathered during survey operations.  This goal
98: was achieved by using dedicated and well-designed software pipelines,
99: updated during survey operations with
100: reprocessing for the delivery of new data releases. In the coming
101: years, many general purpose astronomical surveys are slated to begin
102: taking data.  These wide-field imaging projects will gather deeper and
103: deeper multi-waveband data over large sky areas, producing ever
104: greater data flows. The scientific community must manage and analyze
105: the huge wealth of information contained in these enormous datasets.
106: 
107: In this environment, we have undertaken the development of a new image
108: analysis tool called 2DPHOT, designed to derive two-dimensional
109: information by analyzing both the surface brightness distributions of
110: individual astronomical sources and the spatial distribution of these
111: sources in the image.  The package includes several tasks, such as
112: star/galaxy classification, measurement of both integrated and surface
113: photometry of galaxies, PSF modeling, and estimation of catalog
114: completeness and classification accuracy. The package is complemented by a
115: graphical interface named 2DGUI. A schematic view of the 2DPHOT environment is shown in
116: Fig.~\ref{DBFIG}.  Briefly, the environment is conceived as
117: follows. To start processing, the input images are uploaded to a
118: computer system (e.g.  a local cluster or a grid computer) via the
119: 2DGUI interface.  2DGUI also allows the user to configure the 2DPHOT
120: input parameters. A scheduler is also included, allowing timed and
121: sequential execution of several 2DPHOT runs to be performed on the
122: same computer.  The actual image analysis is done by the 2DPHOT
123: package, which is the core of the whole environment.  During
124: execution, several output tables and plots are produced, showing the
125: different steps of the image analysis and providing a means of quality
126: control. These data, which can also be directly downloaded from the
127: user through the 2DGUI interface, are all uploaded into a database
128: system (by the 2DLOAD application, see Fig.~\ref{DBFIG}).  This system
129: produces a master catalog, by cross-matching 2DPHOT output results
130: with information provided from other VO-compliant web services, and
131: allows the user to perform data queries on this master catalog.
132: 
133: \begin{figure*}%[!bp]
134: \begin{center}
135: \scalebox{0.53}{\includegraphics{f1.eps}}
136: \end{center}
137: \caption[]{\footnotesize   Schematic representation of the 2DPHOT
138:   environment.~\label{DBFIG} }
139: \end{figure*}
140: 
141: There are several survey projects for which the 2DPHOT environment has
142: already  been partly  implemented  or will  be  implemented. We  have
143: automatically  processed the  $g$- and  $r$-band images  from  the Palomar
144: Abell Cluster  Survey~\citep{Gal:00}, with the main  goal of measuring
145: structural parameters,  i.e.  the effective  radius, the corresponding
146: mean  surface brightness,  and the  S\'{e}rsic  index $n$  of galaxies  in
147: clusters with different  richnesses, in the redshift range  of 0.05 to
148: 0.2.  The  structural  parameters  have  been  used  to  estimate  the
149: environmental dependencies  of internal color  gradients in early-type
150: galaxies  (see \citealt{LaB:05}).   Some examples  of  general purpose
151: imaging surveys  to be analyzed by  2DPHOT are those  carried out with
152: the  VLT Survey  Telescope (VST),  a 2.6m  diameter  imaging telescope
153: equipped with a large format (16k x16k pixels) CCD camera yielding a 1
154: square degree  field of view.  The  VST, which will be  located at the
155: ESO  Cerro   Paranal  Observatory  (Chile),  has   been  designed  and
156: constructed  under  a  joint   venture  of  ESO  and  the  Capodimonte
157: Astronomical  Observatory  (OAC).   Several  survey projects  will  be
158: carried      out      with      Capodimonte's      VST      guaranteed
159: time\footnote{\footnotesize See http://vstportal.oacn.inaf.it/}.
160: 
161: 
162: One  of the  most interesting  science  cases for  the development  of
163: 2DPHOT    is    the     Kilo-Degree    Survey    with    VST    (KIDS,
164: see~\citealt{Arn:07}), a  public survey project which  will image 1500
165: square  degrees of  the southern  sky in  the $u$$g$$r$$i$  bands.  As
166: shown  in a  forthcoming paper  \citep{paper2:08},
167: applying 2DPHOT  to a moderately  deep survey such as  VST-KIDS allows
168: detection and measurement of massive galaxy clusters up to redshift $z
169: \sim 1.2$ with high  completeness.  This cluster abundance measurement
170: can be used  to set strong constraints on the  dark energy equation of
171: state, which is one of the most crucial issues of modern observational
172: and  theoretical  cosmology.   Reliable star-galaxy  separation,  with
173: accurate estimates of contamination at very faint flux levels, as well
174: as  an  accurate cluster  detection  algorithm  are  among the  2DPHOT
175: features of paramount importance for such a dark energy project.
176: 
177: This  paper  presents  the  2DPHOT  package\footnote{\footnotesize The  source code
178:   of the package  is available on request to the authors in its
179:   standard form, namely without the VO structure and 2DGUI interface,
180: which will be made available in the near future. },
181: describing the image  analysis strategy on which it  is based, as well
182: as all  the algorithms which  are implemented for the  different tasks
183: the  package  performs.   We   also  describe  briefly  the  web-based
184: graphical interface.  This  paper is intended as a  reference work for
185: all current  and forthcoming  scientific applications of  2DPHOT.  The
186: layout  of the paper  closely follows  the order  of execution  of the
187: 2DPHOT   tasks.   In   Sec.~\ref{2DPHOT},  we   give   general,  short
188: descriptions  of these  tasks, and  how they  are linked  during image
189: analysis.  Section~\ref{catalog}  describes the initial components of
190: the first analysis  step, i.e.  how 2DPHOT produces  the image catalog
191: and identifies those objects which are classified as sure stars in the
192: input image.  The analysis of  each source in the catalog is performed
193: by extracting a  stamp image from the input  frame and constructing a
194: corresponding mask file (Sec.~\ref{stamps}).  The package performs PSF
195: modeling and  derives rough structural  parameters for all  sources in
196: the   image   as   described  in   Secs.~\ref{PSF}   and~\ref{INI2DF},
197: respectively.    Sec.~\ref{SGCLAS}    deals   with   the   star/galaxy
198: separation,  while  Sec.~\ref{2DFIT} describes  the  final fitting  of
199: galaxy stamps with  seeing-convolved S\'{e}rsic models.  The isophotal
200: analysis of galaxy stamps is then described in Sec.~\ref{SPHOT}, while
201: the determination  of the seeing-corrected  galaxy aperture magnitudes
202: is  outlined in  Sec.~\ref{GROWTH}.  Sections  ~\ref{COMPLETENESS} and
203: ~\ref{SG_CONTAM} describe how 2DPHOT estimates the completeness of the
204: galaxy  catalog and  the  uncertainty in  the star/galaxy  separation.
205: Section~13 shows how 2DPHOT performs in estimating contamination and 
206: completeness at faint magnitudes.
207:  Finally, Sec.~\ref{INTERF}  presents the
208: graphical  interface  (2DGUI).    A  summary  is  given  in
209: Sec.~\ref{SUMMARY}.   The  input   parameters  and  output  quantities
210: measured   by   2DPHOT    are   provided   in   Appendices~\ref{INPAR}
211: and~\ref{OUTPAR}, respectively.
212: 
213: \section{The 2DPHOT package: tasks and analysis strategy}
214: \label{2DPHOT}
215: 2DPHOT is  designed to have a  simple structure consisting  of a shell
216: script running  a suite of  C and Fortran77 programs developed using
217: freely available software libraries.  2DPHOT works on both single-chip
218: and wide-field (up to 16000x16000 pixels) images with a set of
219: input parameters provided either at the invocation of
220: the shell script through a command line syntax or a corresponding
221: graphical interface (see Sec.~\ref{INTERF}).  Thus, the package can be
222: used either as a standalone  application or via a dedicated web-based
223: interface.   The  list of  input  parameters along with short
224: descriptions is provided in Appendix~\ref{INPAR}.
225: 
226: 
227: The main tasks of 2DPHOT are:
228: \begin{description}
229: \item[1.]  Producing a cleaned catalog of the image.
230: \item[2.]  Performing reliable star/galaxy  classification.
231: \item[3.]  Estimating  the completeness of the galaxy  catalog and the
232:   contamination due to star/galaxy misclassification.
233: \item[4.] Constructing an accurate  model of the Point Spread Function
234:   (PSF)  of the  input  image, taking  into  account possible  spatial
235:   variations of  the PSF  as well as  deviations of  stellar isophotes
236:   from circularity.
237: \item[5.]  Deriving  structural parameters  of  galaxies by  fitting
238:   galaxy  images  with  two-dimensional  PSF-convolved  S\'{e}rsic  models.
239: \item[6.]  Measuring galaxy isophotes by fitting them with
240:   Fourier-expanded ellipses, and derivation of one-dimensional surface
241:   brightness profiles of galaxies.
242: \item[7.]  Measuring the  growth  curve of  seeing corrected  aperture
243:   magnitudes of galaxies.
244: %\item[8.]  Identifying  clusters/groups of  galaxies in the  field, by
245: %  estimating  the   local  density   of  galaxies  with   the  Voronoi
246: %  tessellation algorithm.
247: % \item[7.]  estimating Petrosian parameters for galaxies;
248: %\item[8.]  uploading all the derived information to a database where
249: %  data coming from different observations (e.g.  different wavebands)
250: %  can be cross-correlated.
251: \end{description}
252: 
253: All  of these  tasks  are part  of  an image  analysis  flow and  are
254: strictly linked with each other such that the output from one
255: task  is used  as input  to the  subsequent tasks.  Figure~\ref{FLOW}
256: provides  a graphical  representation of  this flow,  where  the boxes
257: represent different steps in the image analysis and the arrows follow
258: the  image  processing  timeline.    The  package  starts  by  running
259: S-Extractor~\citep{BeA:96}  on the  input image  through  an iterative
260: procedure, allowing  simultaneous measurement  of the seeing  FWHM and
261: removal of spurious object detections.  Stamp and mask images are then
262: extracted  for each object  in the  cleaned catalog,  and are  used to
263: model the PSF across the field  and to obtain a coarse estimate of the
264: S\'{e}rsic parameters of the detected sources.  Using both the S-Extractor
265: stellarity  index and  the coarse  effective radius  estimates, 2DPHOT
266: performs star/galaxy classification.  The selected  galaxies are
267: then analyzed using  a two-dimensional fitting procedure as  well as a
268: full isophotal analysis. Seeing corrected aperture magnitudes are also
269: estimated.   At  this point,  simulations  are  performed to  estimate
270: completeness   and  contamination   of  the   final catalog. 
271: 
272: The  following sections  describe  all of  the  image analysis  steps,
273: following  the  diagram  in  Fig.~\ref{FLOW}.  The  output  quantities
274: measured by  2DPHOT are  summarized in Appendix~\ref{OUTPAR}.
275: 
276: 
277: \begin{figure*}
278: \begin{center}
279: \scalebox{1.0}{\includegraphics{f2.eps}}
280: \end{center}
281: \caption[]{\footnotesize   Image   analysis   flow   of   2DPHOT.~\label{FLOW} }
282: \end{figure*}
283: 
284: 
285: 
286: \section{The image catalog and the definition  of `sure stars'}
287: \label{catalog}
288: 2DPHOT produces the source catalog from the input image using the S-Extractor
289: package~\citep{BeA:96}.  Star/galaxy separation is performed on the
290: basis of the S-Extractor stellarity index $SI$ and the effective
291: radius parameter $r_e$ (see Sec.~\ref{whyparam}).  In order to obtain a
292: reliable estimate of the stellarity index, the seeing FWHM of the
293: input image has to be provided to S-Extractor via the $SEEING\_FWHM$
294: input parameter (see the S-Extractor
295: documentation\footnote{\footnotesize $http://terapix.iap.fr/rubrique.php?id\_rubrique=91/index.html$}).
296: To measure this, 2DPHOT produces a catalog from the input image via the
297: following two-step procedure.  S-Extractor is first run for the sole
298: purpose of detecting sources in the input image and calculating their
299: Kron magnitudes and FWHM and ELLIPTICITY parameters.  By applying a
300: $3\sigma$ clipping procedure to the FWHM and ELLIPTICITY distributions
301: of all the bright ($S/N > 100$) unsaturated objects, 2DPHOT generates
302: a preliminary list of candidate stars.  The peak value $f$ and the
303: width $\sigma$ of the FWHM distribution of these objects is derived
304: using the bi-weight estimator (Beers et al.~1990).  The values of $f$
305: and $\sigma$ define what we call the {\it sure star locus}, with the
306: {\it sure stars} being the objects that lie within $\pm 2 \sigma$ of
307: $f$.  Given the values of $f$ and $\sigma$, S-Extractor is run a
308: second time by setting the $SEEING\_FWHM$ parameter to the value of
309: $f$.  As an example of this procedure, Fig.~\ref{surestars} shows the
310: FWHM versus $S/N$ ratio diagram for all the detected sources in two
311: CCD images of the galaxy cluster Abell 2495, which has been observed
312: twice, under different seeing conditions, as part of the Palomar Abell
313: Cluster Survey (Gal et al.  2000). Similar figures showing the sure
314: star locus and the sure stars are automatically produced during each
315: run of 2DPHOT.
316: 
317: After  sure stars  are defined,  the  catalog is  cleaned of  spurious
318: detections  by excluding  all sources  3$\sigma$ below  the  sure star
319: locus.  Objects whose distance from the image edges, in units of their
320: FWHM value, is  smaller than {\it REDGE}, where {\it  REDGE} is one of
321: the input  2DPHOT parameters (see Appendix~A), are  also excluded from
322: the  analysis   since  their  photometry  can   be  incomplete  and/or
323: corrupted.
324: 
325: \begin{figure}
326: %\resizebox{\hsize}{10cm}{\includegraphics{FIGURES/cca2495_n186g.ps}\includegraphics{FIGURES/cca2495_n187g.ps}}
327: %\scalebox{0.35}{\includegraphics{FIGURES/cca2495_g.ps}}
328: \begin{center}
329: \scalebox{0.41}{\includegraphics{f3.eps}}
330: \end{center}
331: % \includegraphics{FIGURES/cca2495_n187g.ps}}
332: \caption[]{\footnotesize Locus of sure  stars for two $g$-band images from
333:   the  Palomar Abell Cluster  Survey (see  Gal et  al.  2000).   The  images  were  obtained with  a  SITe  2048$\times$2048,
334:   AR-coated CCD, at  the Palomar 1.5m telescope, and  cover an area of
335:   12.56$^{\prime}\times$12.56$^{\prime}$   around   the   cluster   of
336:   galaxies Abell  2495 (at $z\sim0.09$),  with a pixel scale  of 0.368
337:   arcsec/pixel. Both panels plot the  $FWHM$ vs. $S/N$ diagram for all
338:   the sources  in the same field  around the cluster  center, with the
339:   lower  panel  for  the   image  taken  in  worse  seeing  conditions
340:   ($FWHM\sim1.7''$).  The  $FWHM$ is given in pixel  units.  The $S/N$
341:   ratio  is  computed  as  the  inverse  of  the  uncertainty  on  the
342:   S-Extractor Kron magnitude (neglecting readout noise).  The locus of
343:   sure stars is  defined by the two horizontal  dashed gray lines that
344:   mark  the $\pm2\sigma$  region around  the  peak value  of the  FWHM
345:   distribution  of star  candidates.  Sure  stars are  defined  as the
346:   bright  ($S/N>100$) non-saturated star  candidates which  lie inside
347:   the  sure  star  locus,  and   are  plotted  as  grey  circles  (see
348:   text). \label{surestars} }
349: \end{figure}
350: 
351: 
352: \section{Extraction of stamps and  mask images}
353: \label{stamps}
354: For each  detected source, 2DPHOT extracts an image  section (stamp) centered
355: on the  source.  The area of  the stamp is
356: proportional to the  $ISOAREA$ output by S-Extractor such  that a wide
357: sky region  around the central object  is also included  in the stamp.
358: This allows a reliable estimate of the local background to be obtained
359: from the two-dimensional  fitting program (see Sec.~\ref{2DFIT}).  For
360: each stamp, a  mask image is also produced by  flagging all the pixels
361: that  belong  to  all the  other  sources  in  the input  image  whose
362: isophotal areas overlap  the given stamp.  The  isophotal areas are
363: defined  through  the  $ISOAREA$,  $ELLIPTICITY$, and  position  angle
364: ($PA$) parameters  from S-Extractor, by multiplying  the $ISOAREA$ value
365: by an expansion factor $EXPND$ (with a default value of 1.5), which is
366: an input parameter of 2DPHOT.   This expansion factor allows us to mask
367: also  the  faintest  diffuse  external regions  of  each  object.
368: Sources whose isophotal areas overlap  the central source by more than
369: $50\%$ are  not masked  out and are  analyzed simultaneously  with the
370: central object (see Secs.~\ref{INI2DF} and~\ref{2DFIT}).  For each stamp,
371: the  number of  sources  treated simultaneously  is  written into  the
372: $NOBJ$  keyword of  the  corresponding mask  file  header.  The  local
373: background  value and  its standard  deviation are  also  estimated by
374: applying biweight statistics to all  the pixels which do not belong to
375: the isophotal  area of the central  source and are not  flagged in the
376: mask file. These values are stored in the keywords $M\_BK$ and $S\_BK$
377: of the  mask file  header, respectively.  Fig.~\ref{masks}  shows some
378: examples  of  the stamp  and  mask  images  automatically produced  by
379: 2DPHOT.
380: 
381: \begin{figure*}
382: \begin{center}
383: \scalebox{0.5}{\includegraphics{f4.eps}}
384: \end{center}
385: \caption[]{\footnotesize Examples of stamp and mask images produced by
386: 2DPHOT.  Stamps are shown in the upper panels, while lower panels plot
387: the corresponding  mask images.  The  pixels which are flagged  in the
388: mask files are plotted in black.  Notice that pixels very close to the
389: stamp edges  are also  flagged in  each mask image.   This is  done to
390: reduce     computational     overhead     in    the     2D     fitting
391: algorithm. \label{masks} }
392: \end{figure*}
393: 
394: \section{PSF  modeling}
395: \label{PSF} 
396: The Point  Spread Function (PSF) is  modeled by fitting  the images of
397: sure stars  (Sec.~\ref{catalog}) with a sum  of two-dimensional Moffat
398: functions.  In order to account  for PSF asymmetries, the isophotes of
399: each  Moffat  function  are  described  by ellipses,  whose  shape  is
400: modulated with  a sin/cos angular  expansion, similar to  that adopted
401: for  describing  deviations  of  the  isophotal  shape  of  early-type
402: galaxies  from  pure ellipses  (see  e.g.  \citealt{Bender:87}).   The
403: number  of fitted  stars  is given  by  the lesser  of  the number  of
404: available  sure stars and  the 2DPHOT  input parameter  $NSMAX$.  The
405: value of  $NSMAX$ is  chosen as a  compromise between  the computation
406: time  for the fitting  algorithm and  the accuracy  of the  PSF model.
407: Increasing  $NSMAX$ yields  more accurate  PSF models  at the  cost of
408: larger computational  times.  Usually, values of $NSMAX$  in the range
409: of 3 to 5 give reliable results\footnote{\footnotesize Processing several images, we
410: found that increasing  the value of $NSMAX$ to more  than 5 stars does
411: not  significantly change  the  output of  2DPHOT.}.   To account  for
412: possible  spatial  variations  of  the  PSF across  the  chip,  2DPHOT
413: provides two  PSF modeling options.  In  the first case,  a global PSF
414: model is  obtained by simultaneously fitting $NSMAX$ stars 
415: randomly extracted  from the entire list  of sure stars.   As a second
416: option, 2DPHOT can construct a two-dimensional grid on the input image
417: and  derive a  PSF  model  independently for  each  cell, by  randomly
418: selecting up  to $NSMAX$  stars among the  available sure  stars.  PSF
419: models are only  derived for cells including at  least two sure stars.
420: The cell  size has to be  provided through the  2DPHOT input parameter
421: $NSIZE$.  2DPHOT associates  to the PSF model of  each cell the median
422: values of  the x  and y coordinates  of the corresponding  fitted sure
423: stars    and   the   two-dimensional    modeling   of    each   galaxy
424: (Sec.~\ref{2DFIT}) is  performed by using  its closest PSF  model.  In
425: order to avoid a discretely varying  PSF across the chip, the user can
426: also  choose to  adopt a  locally  interpolated PSF  model.  For  each
427: galaxy, 2DPHOT selects  the PSF models of the  cells around the galaxy
428: itself, and performs a  bi-linear interpolation of the selected models
429: at  the galaxy  position. Since  there is  a strong  correlation between the
430: fitting parameters of each PSF model, 2DPHOT does not derive the local
431: PSF model  by interpolating  each single fitting  parameter.  Instead,
432: the interpolation is performed independently for each pixel of the PSF
433: models, by interpolating the corresponding intensity values.
434: 
435: \begin{figure}[!]
436: \begin{center}
437: \scalebox{0.35}{\includegraphics{f5.eps}}
438: \end{center}
439: \caption[]{\footnotesize Examples of the clipping procedure applied to
440: four stellar images.  Each column  corresponds to a different star.  From
441: top to bottom,  the star stamps, the corresponding  median images, the
442: original mask images  and the  updated mask images  are shown.  The  four stars
443: have  been selected  because  S-Extractor fails  to  detect the  faint
444: sources around  them, and therefore the corresponding  mask images are
445: blank.   The  2DPHOT  clipping  procedure  detects  the  missed  faint
446: sources, and  masks them in the  updated mask images.  The star stamps and
447: median images use the same intensity scale.
448: \label{STARCLIP} }
449: \end{figure}
450: 
451: Prior  to fitting  the PSF,  2DPHOT  applies a  clipping procedure  to
452: remove stars that  might be contaminated by nearby  objects.  For each
453: star, all of the other sure stars are co-registered to the same center
454: coordinates  and  median stacked.   An  rms  image  is constructed  by
455: estimating, at  each position, the  standard deviation of  the stacked
456: pixels. The mask images of the sure stars are then updated by flagging
457: all  the  pixels  which  deviate  by  more  than  5$\sigma$  from  the
458: corresponding  median images.  If  the fraction  of flagged  pixels is
459: larger than  $20\%$ of  the total  mask image area,  the sure  star is
460: considered to be strongly contaminated and it is excluded from the PSF
461: fitting.  This procedure allows faint sources which may not have been
462: detected by S-Extractor to be masked, and to exclude objects which
463: are misclassified  or blended with nearby  sources.  Some examples
464: of   the  clipping   and   mask  update   algorithms   are  shown   in
465: Fig.~\ref{STARCLIP}, while Fig.~\ref{PSF_FIT}  plots an example of the PSF
466: modeling  results.  The latter  figure  is  automatically produced  by
467: 2DPHOT.
468: 
469: 
470: \begin{figure}
471: \begin{center}
472: \scalebox{0.35}{\includegraphics{f6.eps}}
473: \end{center}
474: \caption[]{\footnotesize Examples of  PSF modeling.  Eight star images
475:   have   been  fitted  simultaneously   using   a  sum   of  three
476:   two-dimensional Moffat functions (see  the text). For each star, two
477:   panels are shown, with the  upper panel plotting the stamp image and
478:   the   lower  panel   showing   the  fitting   residuals.
479:   ~\label{PSF_FIT} }
480: \end{figure}
481: 
482: 
483: \section{Coarse 2D fitting} 
484: \label{INI2DF}
485: 2DPHOT produces an initial estimate of structural parameters for all
486: objects in the input image using a discrete, coarse two-dimensional
487: fitting algorithm (INI2DF).  For each object, a set of PSF-convolved
488: S\'{e}rsic models is constructed by varying the effective radius $r_{\rm
489: e}$, the total magnitude $m_{\rm T}$, and the S\'{e}rsic index $n$.
490: `Geometric' parameters, such as the center coordinates, the axis ratio
491: and the position angle of the models are estimated by fitting the
492: object image with a single 2D Moffat function, and are kept fixed
493: during the coarse fitting.  The Moffat fit is performed by excluding
494: the inner part of the object, which is strongly affected by seeing.
495: The local background value is also not changed in the fit and is
496: obtained from the keyword $M\_BK$ in the mask image header (see
497: Sec.~\ref{stamps}).  INI2DF changes the effective radius of the S\'{e}rsic
498: model using an adaptive grid of 10 values computed on the basis of
499: both the pixel scale and the seeing FWHM of the image.  Four different
500: values are considered for the S\'{e}rsic index parameter, $ n= \{1, 3, 5,
501: 7\}$, while the total magnitude can take the values $m_{\rm T} =
502: m_{\rm K}, m_{\rm K}-0.2, m_{\rm K}-0.4$, where $m_{\rm K}$ is the
503: Kron magnitude of the source (S-Extractor $MAGAUTO$).  We point out
504: that the grids of $r_{\rm e}$, $m_{\rm T}$ and $n$ values have been
505: empirically chosen by analyzing several images with a wide range of
506: characteristics (e.g.  optical and near-infrared data as well as
507: ground-based and HST images).  We found that further increasing the
508: grid size does not change significantly the 2DPHOT results.  With
509: these sizes for the $r_{\rm e}$, $m_{\rm T}$ and $n$ grids, INI2DF
510: produces a total of $120$ discrete models, each of which is compared
511: to the object image by computing the corresponding $\chi^2$ value.
512: The coarse structural parameters are given by the parameters of the
513: model with lowest $\chi^2$.
514: 
515: In  the case  that, for  a  given stamp,  several objects  have to  be
516: treated simultaneously (see Sec.~\ref{stamps}), the above procedure is
517: modified  as follows.   A simultaneous  fit  is performed  by using  a
518: single  two-dimensional Moffat  function for  each object.   Then, for
519: each overlapping  object, the others  are subtracted using  the fitted
520: Moffat models.   A corresponding updated mask image  is also produced,
521: by  flagging all pixels  for which  the sum  of the  subtracted Moffat
522: models exceeds the local background standard deviation ($S\_BK$ in the
523: mask  image  header,  see   Sec.~\ref{masks})  by  $>50  \%$.   Coarse
524: structural parameters are then obtained  by fitting each object in the
525: stamp as a single source,  applying the same procedure outlined above.
526: Some examples of this procedure  are shown in Fig.~\ref{MULTI}. We see
527: that there are some cases where the single Moffat models do not result
528: in accurate subtraction of overlapping sources. Nevertheless, we found
529: that  the  above  approach  allows reliable  estimation  of  structural
530: parameters, with the great  advantage of significantly
531: reduced computational times compared  to an approach where overlapping
532: galaxy models are fitted simultaneously (see also Sec.~\ref{2DFIT}).
533: 
534: \begin{figure}
535: \begin{center}
536: \scalebox{0.41}{\includegraphics{f7.eps}}
537: \end{center}
538: \caption[]{\footnotesize Coarse  fitting of double  objects. Panels in
539:   each column  of the  figure correspond to  a different  stamp image.
540:   From the  top row  down, the  first and second  rows show  the stamp
541:   image  and the  corresponding  Moffat model, obtained  by
542:   simultaneously fitting two single  Moffat functions. The third panel
543:   shows the  subtraction of one  Moffat function from the  stamp.  The
544:   corresponding updated mask  image is shown in the  fourth panel. The
545:   lowest  two  panels  show   the  Moffat  subtracted  image  and  the
546:   corresponding  updated  mask image  for  the  second  object in  the
547:   stamp. \label{MULTI} }
548: \end{figure}
549: 
550: 
551: \section{Identification of stars in the 2DPHOT package} 
552: \label{SGCLAS}
553: The classification of stars and galaxies is one of the most
554: challenging issue in the analysis of astronomical images, and there is
555: no method that works in all scenarios as the optimum classifier.  In
556: the current version, 2DPHOT adopts a simple method of star/galaxy
557: (hereafter $S/G$) separation, which is based on both the S-Extractor
558: and the coarse structural parameters estimated by the INI2DF procedure
559: (Sec.~\ref{INI2DF}).  The parameters which are used for $S/G$
560: classification have been chosen on the basis of Monte-Carlo
561: simulations as detailed in Sec.~\ref{whyparam}, while the $S/G$
562: classification algorithm is described in Sec.~\ref{SGrules}.  In the
563: future, we plan to implement more complex classification techniques
564: (such as wavelet approaches), and provide a detailed comparison of
565: their performance.  Since there is no method that correctly
566: classifies all sources in a given image, particularly at the faintest
567: flux levels, it is crucial that every classification framework provide
568: an estimate of contamination due to misclassified sources as a
569: function of the S/N ratio.  As described in Sec.~\ref{SGrules}, 2DPHOT
570: accurately estimates such contamination using simulated stars and
571: galaxies added to the input processed frame.
572: 
573: \subsection{Reliable parameters to identify stellar sources}
574: \label{whyparam}
575: 
576: We adopt a two-step procedure to  establish   useful  parameters  for  star/galaxy
577: separation. First, we look for reliable
578: classifiers of  point-like sources,  i.e. 2DPHOT output parameters
579: whose values for stellar sources lie in a
580: narrow region of parameter space over wide ranges of the S/N ratio,
581: seeing,  and sampling  characteristics of the images.   Then, we
582: analyze  the  ability  of  such  classifiers  to  separate  stars  and
583: galaxies by  examining the distribution of  values they  assume for
584: both  kinds  of objects.   To  address  the  first point,  we  created
585: simulated  CCD images,  each  with a  random  spatial distribution  of
586: stars.   The  simulations were  generated  using  the  same pixel  scale
587: ($0.369''/pix$),  image  size ($2048\times2048$  pixels), and
588: the noise properties as  the $r$-band images of the Palomar Abell
589: Cluster Survey  (hereafter PACS, see Gal  et al.  2000).
590: The PACS data have been extensively processed from the authors through
591: the 2DPHOT package in order  to investigate the effects of environment
592: on internal color gradients of  early-type galaxies (see La Barbera et
593: al.~2005).
594: 
595: Stellar images were  simulated using both the  Gaussian profile and
596: the Moffat law:
597: \begin{equation}
598:  P(r)=    \left[    1+    \left(   \frac{r}{r_{\rm    c}}    \right)^2
599:  \right]^{-\beta},
600: \end{equation}
601: where $P(r)$  is the surface brightness  of the star as  a function of
602: the distance $r$ to its center,  $\beta$ is the  shape parameter of
603: the profile, and $r_{\rm c}$ is  the Moffat scale radius,
604: which is  related to the  FWHM by $FWHM=2
605: r_{\rm c}  (2^{1/\beta}-1)^{0.5}$. For the Moffat  fits, we
606: set $\beta=3$, which  is the mean value for stellar images
607: in the PACS,  and we varied the $FWHM$ from  one star to 
608: another within each  simulated image according  to a  normal deviate
609: with central value $<FWHM>$ and width $\sigma_{FWHM}$.  Four simulated
610: fields  were created, labeled  F1, F2,  F3,  and F4.  The  main
611: simulation  parameters are  summarized in  Table~\ref{PARSIM}.
612: %,  while a
613: %section   of  the   image   of  F1   is   shown  as   an  example   in
614: %Fig.~\ref{F1FIELD}.   
615: For each field, we randomly created $N=500$ stars, and we set the
616: parameters $<FWHM>$ and $\sigma_{FWHM}$ as follows.  For field F1,
617: both the $<FWHM>$ and $\sigma_{FWHM}$ are set to the median values
618: measured from the $r$-band PACS images.  Fields F2 and F3 simulate
619: observations with worse seeing conditions.  F2 has the same $<FWHM>$
620: as F1 while $\sigma_{FWHM}$ is doubled, mimicking the case of large
621: scatter in the seeing $FWHM$ across the image.  Field F3 has the same
622: $\sigma_{FWHM}$ as field F1 but higher $<FWHM>$, corresponding to
623: either observations taken in worse mean seeing or data with better PSF
624: sampling.  Finally, for Field F4, we used the same $<FWHM>$ and
625: $\sigma_{FWHM}$ values as F1, but stellar images were created
626: with Gaussian profiles.  We note that the above simulated images
627: span all the possible cases that have been found when processing the
628: PACS images, and because of their wide range of seeing parameters,
629: they also reproduce the seeing properties of a variety of ground-based
630: images.
631: %. {\bf
632: %BUT  NOT THE  SAMPLING, SINCE  THE  P60 IMAGES  HAVE 2-3  PIXELS/FWHM,
633: %WHEREAS SOME NEWER SURVEYS WILL HAVE MUCH BETTER SAMPLING, I THINK}
634: 
635: %\begin{figure}
636: %\begin{center}
637: %\scalebox{0.35}{\includegraphics{SIM_STAR_FILED1.ps}}
638: %\end{center}
639: %\caption[]{\footnotesize Simulation of  CCD stellar fields.  A 
640: %  500x500 pixels section of field F1 is shown as example (see the text).
641: %\label{F1FIELD} }
642: %\end{figure}
643: 
644: \begin{figure}
645: \begin{center}
646: \scalebox{0.35}{\includegraphics{f8.eps}}
647: \end{center}
648: \caption[]{\footnotesize Measured  parameters for sources in
649:   field F1 as  a function of their S/N  ratio.  The quantities $r_{\rm
650:   e}$, $b/a$, and $n$ are the effective radius, axis ratio, and S\'{e}rsic
651:   index  obtained  from  2DPHOT  through  the  two-dimensional  fitting
652:   procedure (see Sec.~\ref{2DFIT}). The other parameters (ELLIPTICITY,
653:   FWHM, and STELLARITY INDEX)  are those measured by S-Extractor. As
654:   shown in the plot, the  solid, dashed and short-dashed grey lines in
655:   the upper-left panel mark the values of $r_{\rm e}$ corresponding to
656:   different pixel fractions. Grey circles and corresponding error bars
657:   in  the ELLIPTICITY,  FWHM, and  STELLARITY INDEX  panels  have been
658:   obtained  by binning the  data with  respect to  the S/N  ratio, and
659:   correspond to the mean and 1$\sigma$ interval in each bin.
660: \label{F1} }
661: \end{figure}
662: 
663: \begin{figure}
664: \begin{center}
665: \scalebox{0.35}{\includegraphics{f9.eps}}
666: \end{center}
667: \caption[]{\footnotesize Same as Fig.~\ref{F1} but for Field F2. \label{F2} }
668: \end{figure}
669: 
670: \begin{figure}
671: \begin{center}
672: \scalebox{0.35}{\includegraphics{f10.eps}}
673: \end{center}
674: \caption[]{\footnotesize  Same as Fig.~\ref{F1} but for Field F3. \label{F3} }
675: \end{figure}
676: 
677: \begin{figure}
678: \begin{center}
679: \scalebox{0.35}{\includegraphics{f11.eps}}
680: \end{center}
681: \caption[]{\footnotesize  Same as Fig.~\ref{F1} but for Field F4. \label{F4} }
682: \end{figure}
683: 
684: 
685: Catalogs of the simulated stellar  fields were generated as described in
686: Sec.~\ref{catalog}.   For each  field, all  detected  sources were
687: fit with  PSF convolved S\'{e}rsic  models, following the  procedure
688: described in  Secs.~3--5 and running the  final two-dimensional fitting
689: program  (see Sec.~\ref  {2DFIT}).  Figs.~\ref{F1},~\ref{F2},~\ref{F3}
690: and~\ref{F4} plot  the S\'{e}rsic  parameters, i.e.  the  effective radius
691: $r_e$, the S\'{e}rsic index $n$, and  the axis ratio $b/a$, as well as the
692: the ELLIPTICITY,  FWHM and stellarity index  (hereafter SI) parameters
693: from S-Extractor as a function of the S/N ratio of sources in fields F1,
694: F2,  F3, and  F4, respectively.   The S/N  ratio was  computed  as the
695: inverse of  the uncertainty on  the S-Extractor Kron  magnitude.  From
696: Figs.~\ref{F1},~\ref{F2},~\ref{F3} and~\ref{F4}, we draw the following
697: conclusions:
698: \begin{description}
699: \item[i)] The S\'{e}rsic  index and the $b/a$ parameters  are not reliable
700:   classifiers.  The scatter in these quantities is large compared
701:   to the range of values they can assume.
702: \item[ii)] The effective radius is a reliable classifier, in the sense
703:   that its  values are always  well limited to  a given region  of the
704:   corresponding parameter  space. Whatever the  seeing conditions are,
705:   the effective radius of stars  is always smaller than $\sim 1$ pixel,
706:   and for $S/N>30$, the values  of $r_{\rm e}$ are always smaller than
707:   $\sim 0.5$ pixel.
708: %{\bf WHAT IS THE Re
709: %  DISTRIBUTION FOR GALAXIES?}
710: \item[iii)] As one would expect~\citep{BeA:96}, the SI parameter of
711:   S-Extractor is a reliable classifier. Its values can range from 0 to
712:   1, but  for the simulated stars  with $S/N >20$, the  values of $SI$
713:   are always larger than $\sim0.7$.
714: \item[iv)]  The FWHM  and  ELLIPTICITY parameters  are good  potential
715:   classifiers  as well,  although  the values  of  FWHM are  obviously
716:   strongly  dependent on  the seeing  characteristics of  the analyzed
717:   image.   Generally, we  find  that using  the  FWHM and  ELLIPTICITY
718:   parameters  does not  lead  to any  significant  improvement in 
719:   star/galaxy separation,  and thus we  elected not  to use
720:   these parameters.
721: %, and the values of $r_{\rm e}$ are always smaller than $\sim
722: %  0.5$pixel. 
723: %{\bf WHAT ARE THE DISTRIBUTIONS FOR GALAXIES? ALSO I DO
724: %  NOT BELIEVE THE SI STATEMENT TO BE UNIVERSALLY TRUE}
725: \end{description}
726: The reliability  of the above star/galaxy separation  scheme, based on
727: the $SI$--$r_{e}$ diagram,  will be further  addressed in  Section 13,
728: where  we will assess  contamination and  completeness as  measured by
729: 2DPHOT.
730: \begin{table*}
731: \caption[]{Parameters of simulated  stellar fields.  Cols.~2,~3 and~4
732: give the  $FWHM$, $\sigma_{FWHM} /  FWHM$ and $\beta$  parameters (see
733: text). The gain, zero-point and read-out noise are in Cols.~5,~6 and 7,
734: respectively. In  the case  of field 4,  stellar images  have Gaussian
735: profiles.\label{PARSIM}}
736: \hspace{2.3cm}
737: \begin{tabular}{|c|cccccc|}
738: \hline
739: %Field $\#$ &  FWHM  &  $\sigma_$FWHM & $\beta$ & gain      & zpoint &rnoise \\
740: $Field  \#$ & $FWHM$  & $\frac{\sigma_{\rm  FWHM}}{FWHM}$ &  $\beta$ &
741:         $gain$ & $zpoint$ & $rnoise$ \\  & (pxls) & $\%$ & & $e^-/ADU$
742:         & & $e^-$ \\ 
743: \hline
744: 1 & 4 & 3 & 3 & 1.62 & 30.75 & 6.3 \\ 
745: 2 & 4 & 3 & 3 & 1.62 & 30.75  & 6.3 \\ 
746: 3 & 6 & 6 & 3  & 1.62 & 30.75 & 6.3 \\ 
747: 4 & 4 & 3 & Gaussian  & 1.62 & 30.75 & 6.3 \\ \hline
748: 
749: \end{tabular}
750: \end{table*}
751: 
752: %The  small angular  size of  faint and  high redshift  galaxies  is by
753: %itself  a challenge  for  any  method (parametric  or  not) trying  to
754: %properly separate stars and  galaxies. We will address the reliability
755: %of the
756: %separation scheme  based on the  $SI$ $r_{e}$ diagram, in  Section 13.
757: %There we  present deep data obtained  from the ground and  with ACS on
758: %board of HST and assess  contamination and completeness as measured by
759: %2DPHOT.
760: 
761: 
762: %To assess the reliability of the $SI$ and $r_{\rm e}$ parameters for
763: %S/G separation, we use simulated images of high redshift galaxy
764: %clusters.  Fig.~\ref{STARGAL}
765: %compares the distributions of $SI$ and $r_{\rm e}$ values as a
766: %function of S/N ratio for stars and galaxies in one simulated
767: %image.  Since the small angular size of high redshift galaxies is the
768: %most critical issue for reliable S/G classification, we consider here
769: %the case of a simulated cluster at high redshift ($z \sim 1.2$).  The
770: %figure shows that stars and galaxies are sharply separated in the $SI$
771: %vs.  $r_{\rm e}$ plane.  In this diagram, even at low S/N ratio, most stars occupy the region with $r_{\rm e}$ larger than
772: %$\sim 2/3 $ of the image pixel scale ($0.21''/pxl$) and $SI > \sim
773: %0.75$ (see hatched region of Fig.~\ref{STARGAL}), while almost all
774: %galaxies are found in the complementary area.  Hence, we conclude that
775: %the $r_{\rm e}$ and $SI$ parameters allow accurate S/G separation
776: %whose performance can be accurately quantified through the
777: %contamination estimated by 2DPHOT (Sec.~\ref{SG_CONTAM}).
778: 
779: 
780: %\begin{figure}[!bp]
781: %\begin{center}
782: %\scalebox{0.5}{\includegraphics{FIGURES/STAR_LOCUS_1.ps}\includegraphics{FIGURES/STAR_LOCUS_2.ps}}
783: %\scalebox{0.8}{\includegraphics{f12.eps}}
784: %\end{center}
785: %\caption[]{\footnotesize  Distribution of  stellarity  index (SI)  and
786: %  effective radius  ($r_{\rm e}$) for a simulated
787: %  image of a cluster of galaxies   at  redshift   $z   \sim   1.2$
788: %  (see paper II). Stars and galaxies are plotted as grey
789: %  circles and black crosses, respectively. The upper panels plot the
790: %  values of $r_{\rm e}$ and $SI$ as a function of the S/N ratio, while
791: %  the lower panel shows the $r_{\rm e}$ versus $SI$ diagram. For each
792: %  plot, the symbol size is proportional to the S/N ratio. The hatched
793: %  region in the lower panel mark the locus corresponding to an
794: %  effective radius smaller than $2/3$ of the image pixel scale, and to
795: %  a value of $SI$ larger than 0.75.  
796: %  \label{STARGAL} }
797: %\end{figure}
798: 
799: 
800: \begin{figure}[!]
801: \begin{center}
802: %\scalebox{0.5}{\includegraphics{FIGURES/STAR_LOCUS_1.ps}\includegraphics{FIGURES/STAR_LOCUS_2.ps}}
803: \scalebox{0.4}{\includegraphics{f12.eps}}
804: \end{center}
805: \caption[]{\footnotesize Definition of the stellar locus in the 2DPHOT
806:   package (see text). The plot shows the stellar index versus Kron
807:   magnitude diagram  for two $g$-band  images from PACS.   Grey points
808:   are  the simulated  stars added to  each  field by
809:   2DPHOT,  while black  circles show  the objects  with  stellar index
810:   larger than 0.5. The hatched area marks the region used
811:   to select star candidates.\label{STARLOCUS} }
812: \end{figure}
813: 
814: 
815: \begin{figure}
816: \begin{center}
817: \scalebox{0.4}{\includegraphics{f13.eps}}
818: \end{center}
819: \caption[]{\footnotesize Selection of stars  in 2DPHOT for
820:   two $g$-band  images of the PACS.   The upper panels  show the stellar
821:   index versus  Kron magnitude diagrams, with the  hatched region
822:   showing  the stellar  locus (see  text).   Grey circles  are the
823:   selected stars, while black  crosses plot all the remaining sources.
824:   Lower panels show the corresponding FWHM versus Kron magnitude plots
825:   for the same PACS images.~\label{STARDEF} }
826: \end{figure}
827: 
828: \subsection{Final rules for identifying stellar sources}
829: \label{SGrules}
830: After INI2DF  parameters have  been derived for  all the sources  in a
831: given field,  2PHOT performs  $S/G$ separation.  Simulated  images are
832: constructed by adding a spatially  random distribution of stars to the
833: input image.  The surface density of  stars is chosen so that 50 stars
834: are added to an input image area of 2000$\times$2000 pixels, while the
835: number of simulations is such that  we have a total of 2000 artificial
836: stars.  Stars are created from the actual PSF model, with photon noise
837: added  based on the  GAIN provided  in the  {\it default.sex}  file of
838: S-Extractor.   The  magnitude of  each  artificial  star is  extracted
839: according to a uniform random  $S/N$ ratio distribution, with an upper
840: cutoff of $S/N=200$.  For each  simulation, a new catalog is generated
841: and  the SI  parameter is  computed for  all of  the  artificial stars
842: detected by S-Extractor.  2DPHOT  defines star candidates on the basis
843: of  the  distribution of  these  artificial  stars  in the  SI  versus
844: magnitude diagram.   First, artificial stars are  ordered by ascending
845: magnitude, and  the 50 stars with  magnitudes closest to  that of each
846: artificial  star are  selected.   Then, for  each  artifial star,  the
847: $10\%$ percentile of the distribution  of SI values ($SI_{10}$) of the
848: 50 selected  artificial stars is  computed.  In order to  minimize the
849: number of  galaxies that are misclassified at  the faintest magnitudes
850: of  the catalog,  a minimum  cutoff of  $SI_{10}=0.7$ is  imposed (see
851: Sec.~\ref{SG_CONTAM} for details). As  a second option, that turns out
852: to be more  suitable in the case of deep  images (see Sec.~13), 2DPHOT
853: can  define the  star locus  by applying  the same  procedure outlined
854: above but replacing the $10\%$  percentile of the $SI$ distribution of
855: simulated stars  with the quantity $\theta- p  \sigma$, where $\theta$
856: and  $\sigma$  are  the  location  and  width  of  the  $SI$
857: distribution,  while $p$  is  a parameter input to  2DPHOT. With  a
858: suitable  choice of  $p$ this second  definition  allows a  narrower
859: stellar locus to be defined  in the $SI$ versus magnitude diagram (see
860: Sec.~\ref{SG_CONTAM}),  and thus  it  can be  more  suitable at  faint
861: magnitudes  where  galaxies  with   small  size are more likely to be 
862: misclassified  as  stars.   Hereafter,  unless  stated explicitly,  we  will
863: consider only the first definition of the star locus.
864: 
865: Since saturated  stars have lower $SI$ than  bright unsaturated stars,
866: at magnitudes  brighter than those  of artificial stars the  value of
867: $SI_{10}$ is  set to the minimum  $SI$ for observed  sources with $SI>
868: SI_{\rm min}=0.5$.  This procedure allows  even saturated stars  to be
869: correctly classified by 2DPHOT. The value of $SI_{\rm min}$ was chosen
870: empirically  based on  several processed  images where  we  found that
871: saturated stars always have $SI>0.5$, while the brightest galaxies all
872: have lower $SI$. As shown in Fig.~\ref{STARLOCUS}, star candidates are
873: selected using the region between  $SI=SI_{10}$ and $SI=1$ in the $SI$
874: versus  magnitude diagram.  Plots  like those  in Fig.~\ref{STARLOCUS}
875: are automatically  produced by each  run of 2DPHOT.  If  required, the
876: value of $SI_{\rm min}$ can be changed by the user after inspection of
877: the  stellar locus  plot.  As  final  rules for  $S/G$ separation,  we
878: define  an object  as  a candidate  star  if it  belongs  to the  star
879: candidate  locus and  its INI2DF  effective radius  is smaller  than 1
880: pixel,  with the  latter  criterion from  the  results of  Monte-Carlo
881: simulations  discussed  in  Sec.~\ref{whyparam}.   The locus  of  star
882: candidates should include most of  the point-like sources in the input
883: image, with the percentage  of misclassified objects increasing as the
884: magnitude increases.  The selection of stars through this procedure is
885: shown in Fig.~\ref{STARDEF}, where we consider two CCD images from the
886: PACS.  The  plots in Fig.~\ref{STARDEF} are  automatically produced by
887: 2DPHOT.   As one  would expect,  at faint  magnitudes  the star/galaxy
888: classification becomes progressively  more uncertain. The distribution
889: of  artificial stars  with respect  to  the locus  of star  candidates
890: provides a quantitative way to estimate the magnitude (and/or) the S/N
891: limit  above   which  the   $S/G$  classification  is   reliable  (see
892: Sec.~\ref{SG_CONTAM}).
893: 
894: \section{Final 2D fitting}
895: \label{2DFIT}
896: Objects identified as galaxies through the 2DPHOT $S/G$ classification
897: scheme  are then  fit with  PSF  convolved S\'{e}rsic  models.  This  `final'
898: fitting differs  from that of Sec.~\ref{INI2DF} since  a full $\chi^2$
899: minimization algorithm is adopted, without using any discrete (coarse)
900: grid  of  reference convolved  models  (as  for  INI2DF), providing  a
901: precise  estimate  of structural  parameters  at  the  cost of  longer
902: computation  times\footnote{\footnotesize The  CPU   time  required  for  the  final
903: two-dimensional fitting is 4-5 times longer than for the coarse fit.}.
904: The $\chi^2$ minimization is performed through the Levenberg-Marquardt
905: algorithm, assigning zero weight to all the flagged pixels in the mask
906: image.  The 2D  fitting routine adopted in the  2DPHOT package is also
907: described in \citet{LaB:02}, where several tests of its accuracy
908: have  been performed.   The  initial conditions  for the  optimization
909: routine are set  to the output values of INI2DF,  which are on average
910: quite close to the best fitting final parameters. This largely reduces
911: the  well known issue  of spurious  convergence that  can characterize
912: strongly  non-linear optimization problems.   The case  of overlapping
913: objects is  treated with  an analogous approach  to that  described in
914: Sec.~\ref{INI2DF} for  the coarse fit.  Instead of  using the multiple
915: single  Moffat  fits  described  in  Sec.~\ref{INI2DF},  2DPHOT  takes
916: advantage  of the  INI2DF  best  fitting models  to  reduce the  final
917: fitting  of overlapping objects  to that  of separate  single sources.
918: For each blended galaxy,  the overlapping objects are subtracted using
919: the INI2DF  models and  the mask image  is correspondingly  updated as
920: described  in  Sec.~\ref{INI2DF}.  Although  a  suitable treatment  of
921: overlapping galaxies would require  a simultaneous fit to be performed
922: (see  e.g.~\citealt{vanDokkum:96}), reducing  the problem  to  that of
923: fitting single sources greatly decreases computation times.  Comparing
924: both  approaches,  we verified  that  the  2DPHOT  procedure does  not
925: produce any  significant change in the final  structural parameters of
926: {\it multiple} objects.  Some  examples of two-dimensional fitting are
927: shown  in  Fig.~\ref{PLOT_2DFIT}.   The   plots  in  this  figure  are
928: automatically generated by 2DPHOT.
929: 
930: \begin{figure*}
931: \begin{center}
932: \scalebox{0.75}{\includegraphics{f14.eps}}
933: \end{center}
934: \caption[]{\footnotesize Two-dimensional fitting of galaxy stamps with
935:   seeing-convolved  S\'{e}rsic models.   Subpanels show the  galaxy stamps
936:   and the  corresponding residual images, obtained by
937:   subtracting the model fit from the galaxy stamp.  For each galaxy
938:   stamp, the fitted galaxy is marked by a grey circle of radius $2''$,
939:   and  the lower  subpanel shows  the residual  image, where  the same
940:   circle is plotted  in black.  From top to bottom  and left to right,
941:   galaxies  are   shown  in   order  of  decreasing   magnitude,  from
942:   $r\sim16.5$  for   the  upper-right  panel  to   $r\sim20$  for  the
943:   lower-right  panel. Images  are drawn  from  the PACS  image of  the
944:   cluster Abell~574 at $z \sim 0.185$.~\label{PLOT_2DFIT} }
945: \end{figure*}
946: 
947: \section{Isophotal analysis}
948: \label{SPHOT}
949: To  analyze  the isophotal  properties  of galaxies,  2DPHOT
950: performs  an  elliptical fit  of  galaxy  isophotes  and measures  the
951: deviations of  such isophotes from  purely elliptical shapes.   Details on
952: how the  package performs these  tasks are given  in Sec.~\ref{ISFIT}.
953: The  isophotal fit  allows the  radial surface  brightness  profile of
954: galaxies   and    stars   to   be   extracted.     As   described   in
955: Sec.~\ref{SBPROF},  the  package  uses  these brightness  profiles  to
956: obtain a  further estimate of the galaxy  structural parameters, hence
957: providing  an  independent  estimate  of these  parameters  than  that
958: obtained    with   the    full   two-dimensional    fitting   approach
959: (Sec.~\ref{2DFIT}). The  isophotal analysis is  also used to  extract a
960: growth  curve for each  galaxy's  aperture  magnitude. The  aperture
961: magnitudes are computed and  corrected for seeing effects as described
962: in Sec.~\ref{GROWTH}.
963: 
964: \subsection{Isophotal fitting}
965: \label{ISFIT}
966: For the measurement of galaxy isophotes, the package first defines the
967: corresponding  isophotal intensity  values.  For  each stamp,  a rough
968: estimate  of  the  object  center  coordinates  are  obtained  as  the
969: intensity-weighted means of the x  and y pixel coordinates.   The mean
970: values are  computed in a section  of 5x5 pixels  around the intensity
971: peak  of  the  object.   Using  these center  coordinates,  a  set  of
972: concentric circles  is constructed, with  radii equally spaced  by 0.5
973: pixel. For each circle, the mean value of 90 intensity samples equally
974: spaced in polar angle is computed via cubic interpolation of the stamp
975: intensity values  at the  corresponding radial and  polar coordinates.
976: The mean  intensity values provide  an initial estimate of  the object
977: surface  brightness profile,  and  are used  to  derive the  isophotal
978: contours  of  the  object.  This  procedure  allows  us  to  construct
979: isophotal  contours whose equivalent  radii are  approximately equally
980: spaced by 0.5 pixels.  For a given isophotal intensity level, $I$, the
981: isophote is  defined by a  set of  x and y  pairs on the  stamp. These
982: isophotal samples  are defined  as follows.  For  a given  polar angle
983: $\theta$,  different intensity  values $I_j$  are computed  at several
984: radii  $r_j$  from  the  galaxy  center.  The  algorithm  selects  the
985: smallest radius at which the intensity brackets the value of $I$ (i.e.
986: $ I_j \!  \le \!  I \!  \le \!  I_{j+1}$ or $ I_{j+1} \!  \le \!  I \!
987: \le \!   I_{j}$).  The radius  $r$ corresponding to this  intensity is
988: then computed by linear interpolation of the $r_j$ values with respect
989: to $I_j$.   The isophotal samples  are directly computed from  $r$ and
990: $\theta$  by varying  $\theta$  such  that the  number  of samples  is
991: proportional  to the  isophote length  and by  excluding  those points
992: flagged in the mask file.  To exclude low signal-to-noise regions, the
993: isophotal computation is  stopped when the background-subtracted value
994: of $I$ falls below four times the background standard deviation within
995: the stamp.  As a default, to exclude galaxies whose isophotal contours
996: are overly affected by  seeing, 2DPHOT performs the isophotal analysis
997: only for galaxies  whose S-Extractor isophotal
998: radius\footnote{\footnotesize This is
999: defined  as  $\sqrt{ISOAREA/\pi}$,  where  $ISOAREA$  is  the  ISOAREA
1000: parameter of S-Extractor.}  is larger than four times the seeing FWHM.
1001: Figure~\ref{IS_PLOT}  plots  some  example  of  isophotal  analysis  for
1002: galaxies from one PACS $r$-band image.  The  panels shown in the
1003: plot are automatically produced by 2DPHOT.
1004: 
1005: \begin{figure*}
1006: \begin{center}
1007: \scalebox{0.4}{\includegraphics{f15.eps}}
1008: \end{center}
1009: \caption[]{\footnotesize Fitting of galaxy isophotes with elliptical
1010: contours modulated by a series of sin/cos angular functions. The four
1011: panels plot different galaxy stamps, extracted from one PACS $r$-band
1012: image.  Solid lines are the isophotal contours, derived as described
1013: in Sec.~\ref{ISFIT}, while the fitted ellipses are plotted as dashed
1014: curves. The fits were performed by including only the $a_4$ term in
1015: the sin/cos expansion.  Isophotes are plotted with different gray
1016: levels, with the grayscale proportional to the corresponding surface
1017: brightness value.  The relations between gray intensity and surface
1018: brightness are shown on the grey scales at the right of each panel.
1019: Each surface brightness value on these gray scales corresponds to a
1020: different isophote. Surface brightness values are given in units of
1021: $mag/arcsec^2$, and become brighter as the isophotal color changes
1022: from white to black.  The spatial scale is shown in the lower-left
1023: corner of each panel.  The plots are produced automatically from the
1024: 2DPHOT package.~\label{IS_PLOT} }
1025: \end{figure*}
1026: 
1027: Galaxy  isophotes are  modeled as  described  in~\citet{Bender:87}, by
1028: fitting  each isophote  with an  elliptical contour  modulated  by the
1029: following sin/cos angular expansion:
1030: \begin{equation}
1031:  \sum a_n \cdot cos(n \theta) + b_n \cdot sin(n \theta),
1032: \label{sincos}
1033: \end{equation}
1034: where $\theta$ is the polar angle, and the sum is done with respect to
1035: the  index $n$.   For  $n \ge  3$,  the coefficients  $a_n$ and  $b_n$
1036: describe the  deviations of the  isophotes from the  elliptical shape.
1037: In particular, the $a_4$ term is  used to describe the boxy ($a_4 <0$)
1038: and  disky ($a_4>0$)  isophotal  shapes of  early-type galaxies.   Each
1039: ellipse  is characterized by  five fitting  parameters, which  are its
1040: center coordinates, equivalent radius, ellipticity, and position angle
1041: of the  major axis.  The  sin/cos terms which  have to be  included in
1042: Eq.~\ref{sincos}  are  defined as  input  parameters  of 2DPHOT.   The
1043: isophotal parameters are derived by a $\chi^2$ minimization procedure,
1044: through a  Levenberg-Marquardt algorithm.  Examples  of isophotal fits
1045: are  shown in Fig.~\ref{IS_PLOT}, while  Fig.~\ref{IS_PROF} shows the
1046: radial  profiles of  isophotal  parameters  measured by  the
1047: fitting  procedure.   All  of these  plots  are  automatically
1048: produced by 2DPHOT.  Global values  of $a_n$ and $b_n$ are computed as
1049: follows.  Following~\citet{Bender:87} and~\citet[hereafter
1050: B89]{Bender:89}, only  the range  of $a_n$ and  $b_n$ profiles between  a minimum
1051: radius $R_{min}$ and a  maximum radius $R_{max}$ is selected. $R_{min}$ is set to  four times the  seeing FWHM  of the
1052: image, while $R_{max}$ is set  to twice the galaxy effective
1053: radius.  The  global $a_n$ and  $b_n$  values  are then defined  as the
1054: average    of   their    profiles   within    the    selected   radial
1055: range. Fig.~\ref{BCOMP}  compares the $a_4$  values of B89  with those
1056: derived by running  2DPHOT on the $r$-band images of  42 galaxies from B89
1057: with  available photometry  from  the Sloan  Digital  Sky Survey  Data
1058: Release 5 (SDSS DR5). Ten out of the 42 galaxies have been observed
1059: multiple times in the SDSS, and we used  these repeated observations
1060: to check the reliability of  the $a_4$ values.  Looking at the figure,
1061: we  see  that there  is  good agreement  between  the  two sets  of
1062: measurements. Moreover, there is excellent agreement among repeated
1063: $a_4$ measurements.   We note that  2DPHOT measures global $a_n$  and $b_n$
1064:  values   somewhat   differently than \citet{Bender:89}, where either the peak  values or the values of $a_n$ and  $b_n$ at one
1065: effective radius  were considered.  Using  the mean
1066: values has  the advantage of  producing more robust  estimates, reducing
1067: the effects of possible spurious peaks in the $a_n$ and $b_n$ profiles
1068: that can arise  from noise fluctuations. Furthermore, as  shown above, the
1069: two methods give, on average, fully consistent results.
1070: 
1071: \begin{figure}
1072: \begin{center}
1073: \scalebox{0.43}{\includegraphics{f16.eps}}
1074: \end{center}
1075: \caption[]{\footnotesize Radial  profiles of isophotal  parameters, as
1076: derived  by the isophotal  fitting algorithm  (Sec.~\ref{ISFIT}). From
1077: top to bottom,  the panels show the profiles  of ellipticity, position
1078: angle of the ellipse's major axis, and $a_4$ coefficient as a function
1079: of the  equivalent radius of  the fitted isophotes.  Left  panels show
1080: the   profiles   of   the   galaxy   in  the   lower-left   panel   of
1081: Fig.~\ref{IS_PLOT}, while right panels  correspond to the galaxy shown
1082: in the  upper-right panel of  Fig.~\ref{IS_PLOT}. Error bars  mark one
1083: sigma standard  uncertainties. In the  bottom panels, the  minimum and
1084: maximum radii to  define the global $a_4$ value  are shown as vertical
1085: dashed  lines. The  effective  radius of  the  galaxy is  marked by  a
1086: vertical solid line.  The solid  horizontal gray line denotes the mean
1087: value of  $a_4$ in  the selected radial  range, while the  dashed gray
1088: lines   mark   the   corresponding $1\sigma$  interval.
1089: ~\label{IS_PROF} }
1090: \end{figure}
1091: 
1092: \begin{figure}
1093: \begin{center}
1094: \scalebox{0.36}{\includegraphics{f17.eps}}
1095: \end{center}
1096: \caption[]{\footnotesize Comparison of  $a_4$ values as estimated from
1097:  \citet{Bender:89}  (horizontal  axis)  and  from the  2DPHOT  package
1098:  (vertical axis).  The  new $a_4$ values were obtained  by running the
1099:  2DPHOT   package   on  r-band   images   of   the   42  galaxies   of
1100:  \citet{Bender:89} with  available photometry  from the SDSS  DR5. The
1101:  horizontal  error bars  mark  the typical  uncertainty  on the  $a_4$
1102:  values  of \citet{Bender:89}  (see their  sec.2).  The  vertical bars
1103:  denote   one   sigma  standard   uncertainties   as  estimated   from
1104:  2DPHOT. Most of these error bars  are smaller than the symbol size in
1105:  the plot.   From left to  right, the following galaxies  are plotted:
1106:  NGC4261,  NGC4365,  NGC4387,   NGC5322,  NGC3605,  NGC5127,  NGC4478,
1107:  NGC5532,  NGC3894,  NGC4551,   NGC4406,  NGC5576,  NGC4649,  NGC4374,
1108:  NGC4472,  NGC3842,  NGC6411,   NGC4636,  NGC4489,  NGC3608,  NGC3640,
1109:  NGC4486,  NGC5638,  NGC3379,   NGC3193,  NGC4494,  NGC5490,  NGC5831,
1110:  NGC3613,  NGC4382,  NGC4168,   NGC5845,  NGC4125,  NGC4473,  NGC2693,
1111:  NGC3377,  NGC4621,  NGC4550,   NGC4564,  NGC3610,  NGC4660,  NGC4251,
1112:  NGC4570.   In   several  cases,   a  galaxy  has   repeated  SDSS
1113:  observations.   Such  cases have  been  processed independently  by
1114:  2DPHOT, and the corresponding values  are plotted as gray symbols in
1115:  the figure. ~\label{BCOMP} }
1116: \end{figure}
1117: 
1118: \subsection{Measuring surface brightness radial profiles}
1119: \label{SBPROF}
1120: For all galaxies with final 2D fitting parameters, 2DPHOT extracts a
1121: one dimensional surface brightness profile.  Four galaxy isophotes,
1122: corresponding to intensity values of ${4, 6, 8,}$ and 10 background
1123: standard deviations over the background level are computed, and are
1124: fitted by elliptical contours, as described in Sec.~\ref{ISFIT}.  The
1125: values of center coordinates, axis ratio, and position angle of the
1126: fitted ellipses are averaged, and are used to construct several
1127: concentric ellipses on the galaxy stamp, with their equivalent radii
1128: equally spaced by 0.5 pixel.  The one dimensional surface brightness
1129: profile is then obtained as described in Sec.~\ref{ISFIT}, by
1130: computing the mean intensity value in each ellipse as a function of
1131: the ellipse equivalent radius.  The brightness profile is
1132: sky-subtracted by applying a similar procedure to that described
1133: in~\citet{Jorgensen:95}. The outermost part of the surface brightness
1134: profile intensities is fit with a power law, $\alpha \cdot r^{-\beta}
1135: + bg$, where the $\alpha$ and $\beta$ parameters as well as the local
1136: background value, $bg$, are estimated by a $\chi^2$ minimization
1137: procedure.  The outermost part of the profile is defined as that
1138: radial range where the mean isophotal intensity minus an approximated
1139: median background falls below twice the background standard deviation.
1140: Some examples of surface brightness profiles for the same galaxies as
1141: in Fig.~\ref{IS_PLOT} are shown in Fig.~\ref{1DPROF}.  The profiles
1142: are used to obtain a further estimate of galaxy structural parameters
1143: independent of the 2D fitting approach.  2DPHOT follows the procedure
1144: described by \citet[hereafter BPZ82]{Bendinelli:82}.  In this
1145: approach, one assumes the surface brightness distributions of both the
1146: galaxy and the PSF to have circular symmetry.  With this assumption,
1147: it can be shown that the 2D seeing convolution is reduced to a one
1148: dimensional integral, with the integrand given by the product of the
1149: surface brightness radial profile of the galaxy model with that of the
1150: PSF surface brightness profile, modulated by a zero-order modified
1151: Bessel function (see BPZ82 for details).  Drawbacks and advantages of
1152: the one and two-dimensional methods have been discussed in many papers
1153: (see \citealt{Kelson:00}, \citealt{LaB:02} and references therein).  To
1154: summarize, the one dimensional approach allows one to significantly
1155: reduce the computation time of galaxy structural parameters.  However,
1156: the uncertainties in the 1D parameters are larger, due to the circular
1157: symmetry approximation as well as to the interpolation of intensity
1158: values which is required to derive the galaxy and PSF one-dimensional
1159: profiles.  On the other hand, the 2D approach is more time consuming,
1160: but allows more accurate estimates of structural parameters by taking
1161: advantage of all the information contained in the galaxy image.  The
1162: one dimensional fitting procedure is included in the 2DPHOT package
1163: for completeness, particularly for cases where galaxy
1164: isophotes are strongly distorted and this distortion changes as a
1165: function of galaxy radius.  In these situations the 2D approach can
1166: provide a poorly constrained fitting model, while useful parameters
1167: can still be obtained by the 1D approach.  In order to apply the BPZ82
1168: method, for each cell of the two-dimensional grid over which the two
1169: dimensional PSF modeling is done (see Sec,~\ref{PSF}), a one
1170: dimensional PSF model is computed.  To this end, the circular surface
1171: brightness profiles of all the sure stars in a given cell are derived
1172: (see Sec.~\ref{ISFIT}) and averaged together after sky subtraction and
1173: flux scaling.  The 1D combined profiles are fit with a sum of Moffat
1174: or Gaussian functions applying a procedure similar to that described
1175: in Sec.~\ref{PSF}.  The one dimensional structural parameters are then
1176: derived by the BPZ82 method, convolving one dimensional S\'{e}rsic models
1177: with the derived 1D PSF models.  The best fitting 1D parameters, i.e.
1178: the central surface brightness, the effective radius and the S\'{e}rsic
1179: index are then derived using $\chi^2$ minimization with the
1180: Levenberg-Marquardt algorithm.  Examples of one dimensional fitting
1181: results are shown in Fig.~\ref{1DPROF} for the same galaxies as in
1182: Fig.~\ref{IS_PLOT}.
1183: 
1184: \begin{figure}
1185: \begin{center}
1186: \scalebox{0.2}{\includegraphics{f18.eps}}
1187: \end{center}
1188: \caption[]{\footnotesize Surface brightness profiles of the same
1189: galaxies as in Fig.~\ref{ISFIT}. In the upper plot of each panel, the
1190: surface brightnesses computed over different elliptical contours are
1191: plotted as a function of the ellipses' equivalent radii.  The surface
1192: brightness values have been sky subtracted as described in the text.
1193: The error bars denote $1\sigma$ uncertainties, computed by adding in
1194: quadrature the standard deviation of the intensity values in each
1195: ellipse with the uncertainty in the background estimate.  The solid
1196: line is the best-fitting one dimensional S\'{e}rsic model.  The lower plot
1197: of each panel shows the residuals, in units of $mag/arcsec^2$,
1198: obtained after subtracting the model from the data. The four panels
1199: correspond to the same galaxies as in Fig.~\ref{IS_PLOT}.
1200: ~\label{1DPROF} }
1201: \end{figure}
1202: 
1203: \begin{figure}
1204: %\begin{center}
1205: \scalebox{0.5}{\includegraphics{f19.eps}}
1206: %\end{center}
1207: \caption[]{\footnotesize Completeness as a function of magnitude
1208:   (upper panel) and S/N ratio (lower panel) for sources in the PACS
1209:   image of the cluster Abell~1081 at $z \sim 0.16$. Hatched regions
1210:   mark $1\sigma$ confidence intervals of the completeness.  Stars and
1211:   galaxies are plotted as grey and black regions, respectively, as
1212:   shown in the upper panel.  The dashed line in the lower plots marks
1213:   the 100$\%$ completeness level.
1214: ~\label{COMPL} }
1215: \end{figure}
1216: 
1217: 
1218: \section{Growth curves}
1219: \label{GROWTH}
1220: The  aperture magnitude  growth curve  of  each galaxy  is derived  by
1221: direct  integration  of  the  corresponding  one  dimensional  surface
1222: brightness  profile.  The  integration is  performed for  each  of the
1223: concentric ellipses used  to extract the 1D profile.   As described in
1224: Sec.~\ref{SBPROF},  all of  the ellipses  are defined  by  the average
1225: ellipticity and position angle of  the galaxy. In order to correct the
1226: growth  curve   for  seeing   effects,  the  following   procedure  is
1227: adopted. The 2D seeing convolved  S\'{e}rsic model obtained from the final
1228: 2D fitting  analysis is used to  extract a growth  curve following the
1229: same  procedure as for  the galaxy  image.  The  growth curve  is also
1230: computed for  the deconvolved  S\'{e}rsic model, which  is defined  by the
1231: output parameters  of the final 2D  fit. The model  is integrated over
1232: concentric ellipses  using an  adaptive 2D integration  algorithm, and
1233: aperture  magnitudes  are extracted  within  the  same apertures  that
1234: define  the galaxy growth  curve.  The  difference between  the growth
1235: curves of the  seeing convolved and the seeing  deconvolved models are
1236: used to  correct the galaxy  aperture magnitudes.  We note  that since
1237: the S\'{e}rsic model  appears in the difference between  the convolved and
1238: the  deconvolved curves,  the  correction is  expected  to be  largely
1239: independent  of  the  choice  of  galaxy  model,  especially  for  the
1240: outermost parts of the galaxy  where seeing corrections are small. The
1241: seeing  corrected growth  curve  is used  to  estimate the  half-light
1242: radius of  the galaxy, and  the corresponding mean  surface brightness
1243: within that radius.  We note  that the seeing corrected growth curve
1244: and surface brightness profile allows the so-called eta function to be
1245: computed,  which is  defined by  the ratio  of the  surface brightness
1246: value at a  given radius to its mean value  within the same radius
1247: (see~\citealt{Sandage:90}).   This  function can  be  used to  compute
1248: Petrosian    metric    radii    and   corresponding    mean    surface
1249: brightnesses. This  feature will be  implemented in  the 2DPHOT
1250: package.
1251: 
1252: \section{Completeness}
1253: \label{COMPLETENESS}
1254: In order to estimate the completeness of the galaxy catalog, we follow
1255: a procedure similar to that described in Sec.~\ref{SGrules}. 2DPHOT
1256: creates a set of simulated images by adding to the input image a
1257: random spatial distribution of artificial galaxies.  The surface
1258: density of artificial galaxies in each simulated image and the total
1259: number of simulations are chosen using the same criteria outlined in
1260: Sec.~\ref{SGrules}.  Artificial galaxies are created with
1261: seeing-convolved S\'{e}rsic models.  The parameters of each model are
1262: chosen to match the distribution of galaxy structural parameters as a
1263: function of galaxy magnitude obtained from the input image.  The
1264: coordinates of each artificial galaxy are chosen randomly within the
1265: input image, while its total magnitude $m_{\rm g}$ is extracted from a
1266: uniform random distribution spanning the same range as the observed
1267: galaxies\footnote{\footnotesize i.e.  the same magnitude range as objects classified
1268: as extended sources by 2DPHOT}.  2DPHOT randomly selects one of the
1269: fifty objects\footnote{\footnotesize This number is chosen to sample the full range
1270: of galaxy structural parameters at a given galaxy magnitude.  For
1271: several kinds of images, we verified that varying this number from
1272: twenty to eighty does not affect significantly the completeness
1273: estimates.  } in the catalog with magnitudes closest to $m_{\rm g}$
1274: and with corresponding S/N ratio larger than a cutoff value, $S/N_{\rm
1275: min}$.  The INI2DF parameters of this object and the PSF model that
1276: correspond to the extracted center coordinates are then used to create
1277: the artificial galaxy.  The $S/N$ cutoff $S/N_{\rm min}$ is introduced
1278: because at very low S/N ratios the catalog is highly incomplete,
1279: biasing the distribution of galaxy structural parameters toward
1280: objects with a higher detection probability, such as galaxies with
1281: smaller effective radii and/or higher central concentrations (i.e.
1282: higher S\'{e}rsic index).  Since the distribution of galaxy parameters at
1283: magnitudes below the completeness limit is not known, we adopt the
1284: working assumption that this distribution is similar to that of
1285: galaxies which are `close' to the completeness limit of the catalog.
1286: In other words $S/N_{\rm min}$ is chosen as the lowest value of the
1287: $S/N$ ratio for which the catalog is still nearly 100\% complete.
1288: 2DPHOT adopts a default value of $S/N_{\rm min}=25$.  However,
1289: processing several images, we found that changing $S/N_{\rm min}$ from
1290: 25 to 50 does not significantly change the completeness function.
1291: 
1292: For each simulated image, a catalog is generated using S-Extractor
1293: with the same settings as for the observed data.  The galaxy
1294: completeness function is then derived by binning the artificial
1295: galaxies in magnitude and measuring the fraction of detected objects
1296: in each bin.  The uncertainties on the completeness function are
1297: estimated by shifting magnitudes of artificial galaxies according to
1298: their corresponding uncertainties and recomputing the fraction of
1299: detected sources in each given bin. The same procedure is applied
1300: to the simulated stars created by 2DPHOT to define
1301: the locus of star candidates (Sec.~\ref{SGrules}).  In this way,
1302: the completeness functions of both extended and point-like sources are
1303: estimated.  Fig.~\ref{COMPL} shows the results of processing one
1304: $r$-band image from the PACS. The figure has been automatically produced
1305: by 2DPHOT. The completeness of the catalog is shown as a
1306: function of both magnitude and $S/N$ ratio. For the latter,
1307: artificial data are binned by $S/N$ ratio and
1308: the fraction of detected sources is measured in $S/N$ bins.  We see
1309: that both the galaxy and the star catalogs are almost $100\%$ complete down to
1310: $S/N \sim 20$ ($r\sim21^m$).
1311: 
1312: \begin{figure}
1313: \begin{center}
1314: \scalebox{0.43}{\includegraphics{f20.eps}}
1315: \end{center}
1316: \caption[]{\footnotesize The upper panel plots the stellarity index from
1317:   S-Extractor as a  function of the Kron magnitude  of simulated stars
1318:   (grey crosses) and simulated galaxies (black circles), respectively.
1319:   The  hatched  region corresponds  to  the  stellar  locus, which  is
1320:   defined as described in  Sec.~\ref{SGrules}.  The fractions of stars
1321:   and galaxies  that are  erroneously classified on  the basis  of the
1322:   stellar locus  are plotted as  grey and black  curves, respectively.
1323:   The plots  have been  obtained by processing  the PACS image  of the
1324:   cluster Abell~1081, as for Fig.~\ref{COMPL}. ~\label{CONTAM} }
1325: \end{figure}
1326: 
1327: \section{Contamination}
1328: \label{SG_CONTAM}
1329: Using simulated stars and galaxies described in Sec.~\ref{SGrules} and
1330: Sec.~\ref{COMPLETENESS},  2DPHOT estimates  the fractions  of galaxies
1331: and stars which  are misclassified as a function  of their magnitudes.
1332: We examine the distribution of the artificial galaxies and stars added
1333: to the  input image  in the $SI$  versus magnitude diagram,  using the
1334: definition  of the  star locus  (Sec.~\ref{SGrules}) to  perform $S/G$
1335: classification.  This  procedure is illustrated  in Fig.~\ref{CONTAM},
1336: where the  results obtained  for one of  the $r$-band PACS  images are
1337: displayed. These  figures are  automatically produced by  2DPHOT.  The
1338: upper panel shows  the star locus as well as  the distribution of both
1339: artificial stars  and artificial galaxies  in the $SI$ -  Mag diagram.
1340: We note that almost all of  the artificial galaxies have $SI \le 0.7$,
1341: which  holds true  for  all  images we  processed  with 2DPHOT.   This
1342: implies that adopting a lower cutoff of $SI=0.7$ for the definition of
1343: the star locus minimizes the fraction of misclassified galaxies at low
1344: $S/N$  ratios, as  noted in  Sec.~\ref{SGrules}.  The  lower  panel of
1345: Fig.~\ref{CONTAM} plots the fraction, $\phi_{\rm s}$, of misclassified
1346: stars, i.e.   the fraction  of artificial stars  that lie  outside the
1347: locus  of  star  candidates,  and  the fraction,  $\phi_{\rm  g}$,  of
1348: misclassified galaxies, i.e.  the fraction of artificial galaxies that
1349: are classified  as stars,  as a function  of their magnitude.   We see
1350: that $\phi_{\rm  g}$ is always smaller  than a few  percent, while the
1351: fraction  of  misclassified  stars  increases  rapidly  at  faint
1352: magnitudes ($MAG>21$).  For  bright  magnitudes, at  $MAG<20$,
1353: where one  would expect  that stars and  galaxies are  always properly
1354: identified, we  find that  the value of $\phi_{\rm  s}$ does
1355: not reach zero,  but is typically $\sim  5 \%$, varying from  $\sim  3\%  $  to $\sim  10\%$  between  $MAG=18$  and
1356: $MAG=20$. In order to understand why there is such a small fraction of
1357: misclassified  stars,  we  considered  the  PACS  frame  whose  2DPHOT
1358: contamination plots are shown  in Fig.~\ref{CONTAM} and selected those
1359: misclassified  stars   for  which  $MAG\le20$,  yielding $25$   out  of  $726$ total stars.
1360: Fig.~\ref{SG_TEST_BRIGHT}  shows the  regions where  each of  these 25
1361: simulated stars are randomly added to the PACS image.  The S-Extractor
1362: stellarity   index  and  FLAG   values  are   also  reported   in  the
1363: plot.  Looking  at the  figure,  we can  clearly  see  that the  small
1364: misclassification  fraction  at the  bright  magnitudes  is caused  by
1365: blending.  In  fact, the figure shows that  bright misclassified stars
1366: can be identified  as follows: (i) they lie just on  top of some other
1367: object in the  field, (ii) strongly blended with  bright galaxies, and
1368: (iii) embedded  within the extended  halo of a bright  saturated star.
1369: We also  find that for $\sim  70 \%$ (18  out of 25) of  the simulated
1370: stars the FLAG  value estimated by S-Extractor is  3, corresponding to
1371: the case  of blended sources  (see ~\citealt{BeA:96}). We  notice that
1372: the blending issue does in principle affect any star/galaxy separation
1373: algorithm, and can be more  or less important depending on how crowded
1374: is  the image  being processed.  On the  other hand,  adding simulated
1375: stars   and  galaxies   to   a   given  image   as   done  by   2DPHOT
1376: (Sec.~\ref{SGrules})   one   can   estimate   the  star   and   galaxy
1377: contamination fractions by  taking into account also misclassification
1378: due to blended sources.
1379: 
1380: \begin{figure*}
1381: \begin{center}
1382: \scalebox{0.7}{\includegraphics{f21.eps}}
1383: \end{center}
1384: \caption[]{\footnotesize  Regions of the same PACS image analyzed in Fig.~\ref{CONTAM} showing
1385: the position of bright simulated stars erroneously classified as galaxies by 2DPHOT (see the text).
1386: Each panel corresponds to a different simulated star. For clarity, we do not show the simulated star images added to the real one, but their positions on each panel are marked by a grey circle with a radius equal to three times the average FWHM value (1.8'') of the PACS
1387: image. The stellarity index and the FLAG parameters estimated by S-Extractor are
1388: reported in the lower-right corner of each panel, while the spatial scale is shown in the lower-left.
1389: ~\label{SG_TEST_BRIGHT} }
1390: \end{figure*}
1391: 
1392: \section{Testing the star/galaxy separation at faint magnitudes}
1393: \label{SG_FAINT}
1394: So far,  we have tested the star/galaxy  separation obtained with
1395:   2DPHOT using images from the  Palomar Abell Cluster Survey. As shown
1396:   in Sec.~\ref{SG_CONTAM}, with PACS  data we achieve reliable star/galaxy
1397:   separation down to  $r \sim 21$. On the  other hand, many scientific
1398:   programs are expected  to reach  significantly deeper limits,
1399:   where the  small size of galaxies and blending issues
1400:   can make  the star/galaxy separation far more  troublesome. In order
1401:   to  discuss how  the star/galaxy  separation in  2DPHOT  performs at
1402:   faint magnitudes, we use two  deep i-band image pointings taken with
1403:   the Large Format  Camera (LFC) at the Palomar  200" telescope.  Each
1404:   LFC pointing  covers a  circular area of  $24'$ in diameter,  with a
1405:   pixel scale of $0.182''/pixel$. Data for the same sky area were also
1406:   taken with the Advanced Camera  for Surveys (ACS) onboard of HST and
1407:   consist of 15  pointings taken with the F814W  filter.  The ACS data
1408:   were drizzled to  a pixel scale of $0.03''/pixel$,  covering a total
1409:   area of $\sim  13 \,arcmin^2$. For more details  on the data quality
1410:   and  main  characteristics  of  the  images,  we  refer  the  reader
1411:   to~\citet{Gal:05}.
1412: 
1413: %\subsection{HST and ground-based data}
1414: %\label{LFC_ACS_DATA}
1415: % We are using only fields sc1604_1_i and sc1604_2_i for LFC, since only those
1416: % fields are covered by ACS photometry. For the ACS images, we use all
1417: % the 15 images in the F814W filter.
1418: 
1419: 
1420: \subsection{Comparing the HST and ground-based classification}
1421: \label{LFC_ACS_SG}
1422: We  ran 2DPHOT on  each of  the ACS  and LFC  images and  obtained the
1423: corresponding  catalogs of  stars and  galaxies. All  the ACS  and LFC
1424: catalogs were  matched, resulting in a  final list of  3825 sources in
1425: common.  In order to define the star locus, we adopted here the second
1426: option provided by 2DPHOT (see Sec.~\ref{SGrules}), where the locus is
1427: defined  by setting  the minimum  value of  the stellarity  index $SI$
1428: equal to  $\theta - 2.5 \sigma$,  where $\theta$ and  $\sigma$ are the
1429: location  and width  values  of the  $SI$  distribution of  artificial
1430: stars.   As  shown in  Fig.~\ref{STAR_LOCUS_HST_LFC},  where the  star
1431: locus is  plotted for one of  the LFC and  one of the ACS  images, the
1432: above definition  establishes a  narrower stellar region  reducing the
1433: number of small faint  galaxies which can be potentially misclassified
1434: as galaxies.
1435: 
1436: As shown  in Fig.~\ref{STAR_LOCUS_HST_LFC}, the HST data  go about two
1437: magnitudes  fainter  than the LFC imaging.  Moreover,  HST  allows a  sharp
1438: separation of stars  and galaxies down to $i_{AB}  \sim 25$, while for
1439: LFC the  two classes begin to overlap by $i_{AB} \sim  22$. Assuming
1440: that the HST  data provide the 'true' classification,  we can estimate
1441: the  fraction  of  HST  stars  and galaxies  which  are  not  properly
1442: classified from  LFC and compare these fractions  with those estimated
1443: by   2DPHOT.    Fig.~\ref{STAR_LOCUS_HST_LFC}   compares  the   'true'
1444: misclassified fractions with those predicted by 2DPHOT, as computed by
1445: averaging those  obtained for  the two LFC  fields.  The  figure shows
1446: that  the  2DPHOT  results  are  in good  agreement  with  the  'true'
1447: contamination  estimates. The  fraction of  misclassified  galaxies is
1448: always very  close to zero, reaching $\sim 10\%$ at  $i_{\rm AB} \sim
1449: 24$ for both the 'true'  and 2DPHOT estimates. For stars, the fraction
1450: of both 'true' and  2DPHOT misclassified stars increases smoothly with
1451: magnitude, becoming  larger than  $50\%$ at $i_{\rm  AB} \sim  24$. We
1452: notice that the 'true' fraction is slightly larger than that estimated
1453: by 2DPHOT  in the magnitude range  of $i_{\rm AB} \sim  21$ to $i_{\rm
1454:   AB}  \sim 23$. However,  considering the  uncertainty on  the 'true'
1455: fraction  of   misclassified  stars  the  above   difference  is  only
1456: marginally significant.   Hence, we conclude that also  at the fainter
1457: magnitudes sampled  by the LFC  photometry, 2DPHOT is able  to provide
1458: realiable  estimates  of the  contamination  in  the  star and  galaxy
1459: catalogs.
1460: 
1461: \begin{figure}%[!bp]
1462: \begin{center}
1463: \scalebox{0.4}{\includegraphics{f22.eps}}
1464: \end{center}
1465: \caption[]{\footnotesize  Definition of star locus obtained from 2DPHOT for one
1466: of the HST (upper panel) and one of the LFC (lower panel) images. Each panel plots the
1467: stellarity index versus the $i_{AB}$ magnitude. Grey circles mark all the sources in a given
1468: image, with the corresponding stellar locus being represented by the
1469: hatched region.~\label{STAR_LOCUS_HST_LFC} }
1470: \end{figure}
1471: 
1472: \begin{figure}
1473: \begin{center}
1474: \scalebox{0.45}{\includegraphics{f23.eps}}
1475: \end{center}
1476: \caption[]{\footnotesize 
1477: Comparison of the fractions of misclassified stars and galaxies provided by 2DPHOT
1478: with the 'true' values obtained by comparing the HST and LFC data (see text).
1479: The fractions of stars and galaxies are plotted in grey and black, respectively.
1480: The 'true' fractions are plotted as filled circles, with the error bars marking
1481: $1 \sigma$ standard uncertainties, estimated by accounting for poissonian errors
1482: on counts in each magnitude bin. The fraction of misclassified sources provided by
1483: 2DPHOT are shown as continuous curves.~\label{SG_CONTAM_COMB} }
1484: \end{figure}
1485: 
1486:  
1487: \section{2DGUI: An interface for 2DPHOT}
1488: \label{INTERF}
1489: The 2DPHOT package requires installation of supporting software
1490: packages\footnote{\footnotesize such as S-Extractor and the cfitsio and pgplot
1491: libraries.} and its performance varies depending on the compilers
1492: used.  After installation, the user has to run the package by
1493: configuring both the input files for S-Extractor as well as some
1494: additional parameters specific to the package itself, which control
1495: the different steps of the image analysis (see Sec.~\ref{2DPHOT}). To
1496: simplify deployment and provide a uniform interface, we have developed
1497: a front-end called 2DGUI. To allow the timely execution of
1498: potentially time-consuming processing jobs and manage parallelization,
1499: we have also included a simple scheduler system.
1500: 
1501: The 2DGUI package consists of three basic components. First, we
1502: provide an interface where the user can execute several
1503: 2DPHOT runs (jobs) through a local 2DPHOT installation. Second, a
1504: small, local (i.e.  server-independent) database provides user access
1505: to the output files of 2DPHOT.  Finally, the simple scheduling system
1506: allows timely execution of several jobs to be performed without server
1507: overloading.  All of these components were either developed or adapted
1508: from well-known, portable, royalty-free software. Since the database is 
1509: included in the 2DGUI package, no additional software
1510: is required. Since the scheduler is based on the {\it cron} utility
1511: and on a bash-- or csh--system shell, the server must use a Unix-like
1512: operating system.  
1513: 
1514: The first step includes user
1515: identification and job creation through the form shown in panel 1 of
1516: Fig.~\ref{panels}.  Currently, only data available on the server can
1517: be processed. After creating a job, the user must configure
1518: parameters for both S-Extractor and 2DPHOT, using the two forms shown
1519: in panels 2 and 3 of Fig.~\ref{panels}, respectively.  Both forms show
1520: the command-line equivalent parameter names, their default values, and
1521: short comments. At this point, the job is created and scheduled, and
1522: information on the job execution is provided in the 2DGUI interface, as shown
1523: in panel 4 of Fig.~\ref{panels}. 
1524: 
1525: 2DGUI then creates a user directory (if necessary), along with a
1526: subdirectory for each job defined by the user identification, the
1527: 2DPHOT and S-Extractor parameters, and the filename of the input
1528: image. Four files are stored in this directory: 1) the original FITS
1529: image uploaded by the user; 2) a shell script (runme.sh), that
1530: includes the command-line syntax\footnote{\footnotesize An example of this syntax
1531: is shown in panel 4 of Fig.~\ref{panels}.} for running 2DPHOT; 3 and
1532: 4) The S-Extractor configuration and parameter files of S-Extractor,
1533: named {\it default.sex} and {\it default.param}.
1534: 
1535: During execution, the 2DPHOT main script dumps textual
1536: information on each step of the image analysis in a log file.  2DGUI reads this file and informs the user of
1537: the job processing status by automatically updating the form
1538: shown in panel 4 of Fig.~\ref{panels}.  When processing is finished,
1539: all the files generated by 2DPHOT are listed in the 2DGUI interface, and
1540: the user can select and download 2DPHOT output results.  The
1541: execution of several {\it runme.sh} files on a given server is done by
1542: a scheduling program which runs only a predefined maximum number of
1543: {\it runme.sh} scripts, in such a way as to avoid overloading the server.
1544: 
1545: Currently, 2DGUI is still under development and its components are
1546: actively being improved.  The major planned improvements include the
1547: following features: 1) the ability for a given user to submit several
1548: jobs, using the same parameters to process several images
1549: simultaneously; 2) use of the local database to store users' preferred
1550: parameters; 3) offline processing alerts (e.g.  sending an e-mail to
1551: the user when a task is completed); and 4) a remote dispatcher, that
1552: allows tasks to be executed remotely, e.g. on a local cluster or a
1553: grid computer. 
1554: 
1555: %4) Resources
1556: %accounting,  to limit  users usage  of the  server and  package and/or
1557: %selective  scheduling  based  on   control  lists;
1558: 
1559: %(e.g.  creation  of  profiles to  process collections  of
1560: %images)
1561: 
1562: 
1563: 
1564: 
1565: \begin{figure*}%[!bp]
1566: \begin{center}
1567: \scalebox{0.6}{\includegraphics{f24.eps}}
1568: \scalebox{0.6}{\includegraphics{f25.eps}}
1569: \scalebox{0.5}{\includegraphics{f26.eps}}
1570: \scalebox{0.6}{\includegraphics{f27.eps}}
1571: \end{center}
1572: \caption[]{\footnotesize  Web forms  used by  the 2DGUI  package.  The
1573: upper form,  panel 1, is  used for the  user login and  image upload.
1574: The middle  forms, panels 2 and 3,  are used to set  the S-Extractor and
1575: 2DPHOT parameters. The  bottom form, panel  4, provides
1576: information to the user about the image processing.~\label{panels} }
1577: \end{figure*}
1578: 
1579: %\section{A Database system for 2DPHOT}
1580: %\label{DB}
1581: %The 2DPHOT  package is  mainly aimed at  analyzing images  coming from
1582: %wide-field  survey  projects.   This  processing  would  produce  huge
1583: %amounts of output data, at  faster and faster rates, and thus requires
1584: %an efficient tool of data storage  and handling. To this aim, in order
1585: %to  accomadate  the  output   results  of  2DPHOT,  we  are  currently
1586: %developing a  suitable database (hereafter dB)  architecture, which is
1587: %realized   according   to  the   standards   proposed   by  the   IVOA
1588: %(International  Virtual Observatory  Alliance).  In  this  section, we
1589: %briefly highlight the main aspects of this dB system.
1590: 
1591: %The main motivation for developing an environment like 2DPHOT
1592: %is the  need for a better way  of analyzing and storing  data which is
1593: %becoming  available  at a  faster  rate  with  the recent  wide  field
1594: %systems. In previous  sections we presented a detailed  account of the
1595: %analysis been carried out here  in this work.  
1596: %Now we briefly describe
1597: %the dB modeling  proposed for 2DPHOT, which can be  part of a pipeline
1598: %specifically  designed  for processing  data  coming  from large  area
1599: %coverage surveys  and large amount of  data is better  managed when an
1600: %appropriate  dB is  used.   
1601: 
1602: %Designing  a dB  is  the first  step  for implementing  a robust  data
1603: %structure. A data model is an abstraction that represents objects from
1604: %the  real  world. A  model  defines  the  elements considered  in  our
1605: %scientific application, establishing the  relations among them. In our
1606: %case, the  scientific application is  2DPHOT, a software  package that
1607: %produces scientific  results in the  form of i) ASCII  tables, listing
1608: %astrophysical parameters obtained by several specialized programs, and
1609: %ii) postscript  files, providing plots  and images related to  all the
1610: %intermediate  steps of  the  whole analysis.   Modeling  our dB  means
1611: %structuring all these astrophysical information  as well as all of the
1612: %other  information related  to the  data processing  itself  (e.g., in
1613: %which computer system  the image was processed, by  whom, etc...).  It
1614: %is of  paramount importance that  proper relations are made,  so that,
1615: %all sorts of later on queries, the  user might want to do, can be made
1616: %in an efficient way.
1617: 
1618: %The 2DPHOT dB system uses PostgreQSL as a core element, an open source
1619: %relational  dB that  has the  two most  important features  needed for
1620: %making  the  environment as  robust  as possible  as  far  as data  is
1621: %concerned,  persistency and  retrieval. In  summary, PostgreSQL  1) is
1622: %capable of managing large amounts of  data (hundreds of TB - a maximum
1623: %Table  size is  32  TB);  2) can  be  assessed by  a  large number  of
1624: %connections  (users and applications);  3) has  concurrency management
1625: %(more than one user accessing the  same data at the same time); 4) has
1626: %a high level of efficiency  during transaction processing; 5) has high
1627: %availability level (dB is still available during backup operation); 6)
1628: %allows   physical   storage  management;   and   7)  allows   database
1629: %replication.   After  fifteen  years  of  active  development  and  an
1630: %architecture that  has earned  strong reputation of  reliability, data
1631: %integrity, and correctness, PostgreSQL is  one of the most powerful dB
1632: %available in the market. It  is fully ACID compliant, full support for
1633: %foreign  keys,  joins, views,  triggers,  and  stored procedures.   It
1634: %includes  most  SQL92 and  SQL99  data  types  like INTEGER,  NUMERIC,
1635: %BOOLEAN, CHAR,VARCHAR,  DATE, INTERVAL, and TIMESTAMP.   It has native
1636: %programming interfaces for C/C++, Java, .Net, Perl, Python, Ruby, Tcl,
1637: %ODBC among others, which  is essential for the software infrastructure
1638: %been developed here.
1639: 
1640: %The 2DPHOT dB  system is represented in Fig.~\ref{DBFIG},  by the part
1641: %of the diagram which comes after the 2DGUI and 2DPHOT boxes.
1642: % A dB system is composed of  data and a set of applications developed
1643: % to  manipulate  them.   Fig.~\ref{DBFIG}  shows the  environment  we
1644: % designed
1645: %for  2DPHOT  with  the  elements  defining  the  global  architecture.
1646: %XXXXXXXX TO BE DISCUSSED  XXXXXXXXXXXXX 
1647: %The first and most fundamental element of the system is the dB itself.
1648: %Based on  the relational concept,  the dB is  a set of 40  tables that
1649: %contain  all the  information produced  by running  2DPHOT on  a given
1650: %image.   Besides  the  scientific  data,  the dB  keeps  the  metadata
1651: %associated  to  the image  or  to the  process  itself,  such as,  for
1652: %instance,  the  image  fits  header,  the  time  when  the  image  was
1653: %processed, in  which computer system, by  whom, and what  is the setup
1654: %used for detection  and analysis.  A program called  2DLOAD brings all
1655: %the  2DPHOT output  information  into the  dB  structure.  The  second
1656: %element in the whole scheme is the application or applicative program.
1657: %Two classes of application can be identified: i) those which allow the
1658: %user to  interact with and the  system in order to  retrieve data; and
1659: %ii) the ones responsible  for exchanging information with web services
1660: %recognized  as VOs  (Virtual Observatories).   These  applications are
1661: %identified by the ellipses in  the lower part of Fig.~\ref{DBFIG}.  It
1662: %is  important to  emphasize that  in this  later category  we  have to
1663: %include  applications that manipulate  the information  resulting from
1664: %the  interaction  between  the  2DPHOT  system and  any  specific  VO.
1665: %Applications  can  be  used,  as instance,  to  cross-matching  2DPHOT
1666: %catalogs with  those available  in other VOs.   In our case,  a master
1667: %catalog will be created  after cross-matching the 2DPHOT catalogs with
1668: %those available on different wavelength domains, such as UV, Infrared,
1669: %X-ray, and Radio.
1670: %
1671: 
1672: \section{Summary}~\label{SUMMARY}  We  have  presented 2DPHOT,  a  new
1673: computational  tool  for astronomical  image  processing, designed  to
1674: analyze  the   output  data  of   wide-field  imaging  surveys   in  a
1675: completely automated  fashion.  The package  includes several tasks,
1676: such as star/galaxy classification, measurement of both integrated and
1677: surface photometry  of galaxies,  PSF modeling, estimation  of catalog
1678: completeness  and  classification accuracy.
1679: 2DPHOT  incorporates a variety  of quality  control plots,  which have
1680: historically been  left to a separate  step in image  analysis, and is
1681: complemented  by  a graphical  interface  named 2DGUI.   In
1682: addition, to accommodate the extensive output of 2DPHOT, both in terms
1683: of object  catalogs and quality  control figures, we are  developing a
1684: database architecture which will comply with the standards proposed by
1685: the  IVOA  (International Virtual  Observatory  Alliance).  All  these
1686: components make  2DPHOT a powerful environment to  analyze, handle, and
1687: store the output  data coming from large area  surveys.  Some examples
1688: of surveys  where we plan to  apply this new  analysis environment are
1689: those that  will be carried  out with the VLT-Survey  Telescope (VST).
1690: We emphasize  that 2DPHOT is  conceived as a general  purpose package,
1691: whose possible applications can  span different research topics.  In a
1692: forthcoming publication,  we illustrate one such applications
1693: by  describing a  project  to  measure the  abundance  of clusters  of
1694: galaxies at  high redshifts (up to  $z \sim 1.2$).   Running 2DPHOT on
1695: simulated    images   of    the   VST    KiloDegree    Survey   (KIDS,
1696: see~\citealt{Arn:07}),  we show  that  this cluster  abundance can  be
1697: measured with  a high completeness  level, allowing one to  put strong
1698: constraints on the nature of dark energy in the Universe.
1699: 
1700: \newpage
1701: 
1702: \appendix
1703: \section{Input parameters of 2DPHOT}~\label{INPAR}
1704: Table~\ref{INTAB} summarizes the main input parameters of
1705: 2DPHOT. These parameters can be either set as input options for the
1706: 2DPHOT main script or passed to the package by 2DGUI (see
1707: Secs.~\ref{2DPHOT},~\ref{INTERF}).  In the table, we also include a
1708: short description of each parameter, as well as a reference to the
1709: sections in this paper where the 2DPHOT task influenced by that
1710: parameter is described.
1711: 
1712: \begin{table*}
1713: \footnotesize
1714: \caption{ Summary of 2DPHOT input parameters. Column 1: Options for
1715:  the 2DPHOT main script. Column 2: Description of the parameter. Column 3: The name used to denote the parameter in the paper text. Column 4: Paper sections 
1716: related to the parameter.
1717: }
1718: \label{INTAB}
1719: \centering
1720: \begin{tabular}{|c|p{12.2cm}|c|c|}
1721: \hline 
1722:     -l &   Minimum S/N ratio required to perform 2D final fitting and surface photometry.  &  & \ref{2DFIT},~\ref{SPHOT}           \\
1723: \hline 
1724:     -x &   Stamp sizes are proportional to the S-Extractor ISOAREA parameter. This parameter provides the proportionality factor. & $EXPND$ & ~\ref{stamps} \\
1725: \hline 
1726:     -z &   Maximum size of the stamp images. This parameter can be used to prevent overly large stamp frames.   &     &  ~\ref{stamps}   \\
1727: \hline 
1728:     -i &   Minimum S/N ratio required to define sure stars. & &\ref{catalog} \\
1729: \hline 
1730:     -f &   Maximum S/N ratio required to define sure stars. & &\ref{catalog} \\
1731: \hline 
1732:     -j &   Number of Moffat/Gaussian functions for 1D PSF fitting. & &\ref{SBPROF} \\
1733: \hline 
1734:     -m &   Number of Moffat/Gaussian functions for 2D PSF fitting. & $NSMAX$ &\ref{PSF}  \\
1735: \hline 
1736:     -g &   Functions used in the 2D PSF fitting (0=Moffat, 1=Gaussian). & & \ref{PSF} \\
1737: \hline 
1738:     -t &   Number of cos/sin terms used for the expansion of star isophotes in the 2D PSF fitting. & & \ref{PSF}\\ 
1739: \hline 
1740:     -d &   Minimum S/N ratio to perform 2D fitting with expansion of the galaxy model into a cos/sin series. & & \ref{2DFIT} \\
1741: \hline 
1742:     -b &   Label providing the cos terms used for the expansion of the galaxy model in  2D  final fitting (e.g. -b 34 makes 2DPHOT calculate the $a_3$ and $a_4$ coefficients) & & ~\ref{2DFIT},~\ref{ISFIT} \\ 
1743: \hline 
1744:     -c &   Label providing the sin terms used for the expansion of the galaxy model in  2D final fitting. & & ~\ref{2DFIT},~\ref{ISFIT} \\ 
1745: \hline 
1746:     -e &   Minimum distance of an object to the image edges, in units of its FWHM. Objects that are closer to the edge this distance are not analyzed. & $REDGE$ & \ref{catalog} \\ 
1747: \hline 
1748:     -s &   Maximum number of sure stars used in a cell to perform PSF modeling.  & $NSIZE$ & \ref{PSF},~\ref{SBPROF}  \\
1749: \hline 
1750:     -a &   Flag that determines the 2D PSF fitting method. When equal to zero, this option forces all sure stars in a given cell to be fitted simultaneously. When equal to one, a single fit to each sure star is performed. & & \ref{PSF} \\
1751: \hline 
1752:     -n &   Size (in pixels) of the grid cells where  PSF modeling is performed.    & & \ref{PSF} \\
1753: \hline 
1754:     -o &   The user can choose to process only some objects in the image by providing a list  of x and y coordinates on the image. This feature is enabled with -o 1. & & \ref{catalog} \\
1755: \hline 
1756: \end{tabular}
1757: \end{table*}
1758: 
1759: 
1760: \section{Output quantities measured by 2DPHOT}~\label{OUTPAR}
1761: Table~\ref{OUTTAB} summarizes the output quantities measured by 2DPHOT.
1762: A short  description of  all quantities is  provided, together  with a
1763: reference  to  sections  where  the  corresponding  2DPHOT  tasks  are
1764: described.   The quantities  measured by  running S-Extractor  are not
1765: included for brevity.
1766: 
1767: \begin{table*}
1768: \footnotesize
1769: \caption{   Summary   of   2DPHOT   output  quantities.    Column   1:
1770: Quantity description. Column 2: Related sections in the text.  }
1771: \label{OUTTAB}
1772: \centering
1773: %\setlength{\arrayrulewidth}{0.4mm}
1774: %\renewcommand{\arraystretch}{0.5}
1775: \begin{tabular}{|p{12cm}|c|}
1776: \hline S-Extractor quantities. & \ref{catalog},~\ref{stamps} \\ 
1777: \hline Stellar locus  quantities: stellar index vs. S/N  ratio for S/G
1778: separation, mean and standard deviation values of the sure star locus. & \ref{catalog},~\ref{stamps},~\ref{SGCLAS}\\ 
1779: \hline PSF  fitting parameters: central intensity,  width, axis ratio,
1780:  position  angle, shape  parameter (in  the case  of PSF  fitting with
1781:  Moffat functions),  and cos/sin terms  of each PSF  fitting function;
1782:  central  coordinates and  local background  value of  each  sure star
1783:  stamp; reduced $\chi^2$ of PSF fitting. These quantities are obtained
1784:  for both the 2D and 1D fitting methods. & \ref{PSF},~\ref{SBPROF}\\
1785: \hline 
1786:  Coarse S\'{e}rsic parameters: center coordinates, central surface brightness, 
1787: effective radius, axis ratio, position angle of the major axis, S\'{e}rsic 
1788: index, total magnitude. & \ref{INI2DF}\\
1789: \hline 
1790: Final  2D  fitting  parameters:  center coordinates,  central  surface 
1791: brightness, effective radius, axis  ratio, position angle of the major
1792: axis, S\'{e}rsic index, total magnitude magnitude, local stamp background value, 
1793: reduced $\chi^2$. & \ref{2DFIT}\\
1794: \hline  
1795: Isophotal  parameters.    For  each  isophote,  the  following
1796: quantities  are  computed:   center  coordinates,  equivalent  radius,
1797: position  angle  of  the  major  axis,  coefficients  of  the  sin/cos
1798: expansion. &  \ref{SPHOT}\\ 
1799: \hline 
1800: 1D S\'{e}rsic fitting  parameters: central surface
1801: brightness, effective radius, S\'{e}rsic index, total magnitude,
1802: reduced $\chi^2$. & \ref{SBPROF}\\ 
1803: \hline 
1804: Seeing corrected parameters: aperture magnitudes and surface brightness values 
1805: corresponding to elliptical and circular contours,  half-light radius
1806: and the corresponding mean surface brightness is also computed, petrosian
1807: function. &  \ref{GROWTH}\\ 
1808: \hline
1809:  Completeness function: percentage of recovered simulated stars and galaxies as
1810: a function of the S/N ratio and magnitude. & \ref{COMPLETENESS} \\
1811: \hline 
1812:  Contamination estimates: percentages of misclassified stars and galaxies as
1813: a function of the S/N ratio and magnitude. & \ref{SG_CONTAM} \\
1814: \hline 
1815: \end{tabular}
1816: \end{table*}
1817: 
1818: \noindent Acknowledgements
1819: 
1820: We would like to thank Drs. Hugo Capelato, George Djorgovski and Scott
1821: Dodelson for careful reading of  the paper and suggestions that helped
1822: improve  the presentation.   We also  thank Drs.   G.  Busarello, C.P.
1823: Haines,  P.  Merluzzi,  and  M.   Radovich for  helpful  comments  and
1824: suggestions.
1825: 
1826: \begin{thebibliography}{}
1827: \bibitem[Adelman-McCarthy  et  al.(2007)]{Adelman:07} Adelman-McCarthy
1828:   J.  K.  et  al.,   2007,  submitted  to  The  Astrophysical  Journal
1829:   Supplement Series
1830: \bibitem[Arnaboldi  et   al.(2007)]{Arn:07}  Arnaboldi,  M.   et  al.,
1831: Messenger No. 127, March 2007, pp.28-32
1832: \bibitem[Bender \& M\"ollenhoff (1987)]{Bender:87} Bender, R., \&
1833:   M\"ollenhoff, C. 1987, A\&A 177, 71 
1834: \bibitem[Bender et al.(1989)]{Bender:89} Bender,  R. et al. 1989, A\&A
1835: 217, 35
1836: \bibitem[Bendinelli   et  al.(1982)]{Bendinelli:82}   Bendinelli,  O.,
1837:   Parmeggiani, G., \& Zavatti, F. 1982 Ap\&SS, 83, 239
1838: \bibitem[Bertin \& Arnouts (1996)]{BeA:96} Bertin, E., \& Arnouts,
1839:   S. 1996, A\&A 117, 393
1840: \bibitem[Gal  et  al.(2000)]{Gal:00}  Gal,  R.R., de  Carvalho,  R.R.,
1841:   Brunner, R., Odewahn, S.C., \& Djorgovski, S.G. 2000, AJ 120, 540
1842: \bibitem[Gal et al.(2005)]{Gal:05} Gal, R.R., Lubin, L.M., \& Squires, G.K. 2005, AJ, 129, 1827
1843: \bibitem[J\o rgensen et al.(1995)]{Jorgensen:95} J\o rgensen, I., Franx,
1844:   M., \& Kjaergaard, P. 1995, MNRAS 273, 1097
1845: \bibitem[Kelson et al.(2000)]{Kelson:00} Kelson, D., Illingworth, G.D., van Dokkum, P.G., \& Franx, M. 2000, ApJ 531, 184
1846: \bibitem[La Barbera et al.(2002)]{LaB:02} La Barbera, F., Busarello, G., 
1847:  Merluzzi, P., Massarotti, M., \&  Capaccioli, M., 2002, ApJ  571, 790
1848: \bibitem[La Barbera et al.(2005)]{LaB:05} La Barbera, F., de Carvalho,
1849:   R.R.,  Gal, R.R.,  Busarello, G., Merluzzi, P.,  Capaccioli, M.,
1850:   \& Djorgovski, S.G.  2005, ApJ, 626, 19
1851: \bibitem[Lopes et al.(2004)]{Lopes:04} Lopes,  P.A.A., et al. 2004, AJ
1852:   128, 1017
1853: \bibitem[Sandage  \&  Perelmuter(1990)]{Sandage:90}  Sandage,  A.   \&
1854: Perelmuter, J.M. 1990, ApJ 350, 481
1855: \bibitem[Shewchuk (1996)]{Shewchuk:96}  Shewchuk, J. 1996,  in Applied
1856:   Computational Geometry, ed. M.C. Lin \& D.N. Manocha (Berlin:
1857:   Springer), 203
1858: \bibitem[Soares-Santos et al.(2008)]{paper2:08} Soares-Santos, M., de Carvalho, R.R., La Barbera, F.,  Lopes, P., Kohl-Moreira, J.K., Gal, R.R., Capaccioli, M. 2007, ApJ {\it to be submitted}  
1859: \bibitem[van Dokkum \& Franx(1996)]{vanDokkum:96} van Dokkum, P. G., \& Franx, M. 1996, MNRAS 281, 985 
1860: \end{thebibliography}
1861: 
1862:  
1863: \end{document}
1864: 
1865: %% End Of File
1866: 
1867: 
1868: 
1869: 
1870: 
1871: %\section{Some applications of the 2DPHOT package}
1872: %In  the  present  section   we  show  three  examples  of  star/galaxy
1873: %separation from the 2DPHOT package.
1874: %
1875: %The first case  is the F1 simulated image  of Tab.~1. Fig.~\ref{PARF1}
1876: %shows the ELLIPTICITY and  FWHM parameters of simulated stellar images
1877: %which  have been randomly  added to  the given  field as  described at
1878: %point  iii)  of  the  previous  section.   The  blue  points  and  the
1879: %corresponding error bars  mark the peaks of each  distribution in each
1880: %S/N bin. Fig.~\ref{STARSF1} shows the final star/galaxy separation for
1881: %the F1 field. Blue circles are the stars which have been selected from
1882: %the INI2DF  parameters (steps i and ii  of Section.~\ref{rules}) while
1883: %blue  symbols mark  the  objects  which have  been  selected as  stars
1884: %through the last 2DPHOT step.
1885: %
1886: %The second case is a  $8.6x8.6$~$arcmin^2$ image extracted from one of
1887: %the R  band Deep  Lens Survey  (DLS) fields.  The  pixel scale  of the
1888: %image is $0.257''/pxl$ with a seeing FWHM of $0.95''$.
1889: %
1890: %The third case is a $12.5x12.5$~$arcmin^2$ image around the cluster of
1891: %galaxies Abell~1445 coming from the Palomar Abell Cluster Survey.  The
1892: %pixel  scale of  the  image is  $0.369''/pxl$  with a  seeing FWHM  of
1893: %$1.4''$.
1894: %\newpage
1895: %\begin{figure}[Top]
1896: %{ \hspace{1cm}
1897: %\psfig{figure=PARAMETERS_FWHM4_SFWHM0.06.ps,height=19cm,width=13cm}}
1898: %\caption[]{\footnotesize Ellipticity and  FWHM parameters of simulated
1899: %stars in  field F1 are plotted as  a function of the  S/N ratio (upper
1900: %and lower  panels respectively).  For each  S/N bin, the  peak and the
1901: %standard deviation of the  FWHM and ELLIPTICITY parameters are marked
1902: %as blue symbols.
1903: %\label{PARF1}
1904: %}
1905: %\end{figure}
1906: %\begin{figure}[Top]
1907: %{ \hspace{1cm}
1908: %\psfig{figure=PARAMETERS_FWHM4_SFWHM0.03.ps,height=19cm,width=13cm}}
1909: %\caption[]{\footnotesize  FWHM  of all  the  objects  in  field F1  is
1910: %  plotted vs.  S/N ratio  (upper panel) and S-Extractor auto magnitude
1911: %  (lower panel). Candidate stars are  marked as blue and red circles (
1912: %  see text). \label{STARSF1} }
1913: %\end{figure}
1914: %\begin{figure}[Top]%
1915: %
1916: %{ \hspace{1cm}
1917: %\psfig{figure=STARS_FIN_F1.ps,height=19cm,width=13cm}}
1918: %\caption[]{\footnotesize 
1919: %\label{FIN_F1}
1920: %}
1921: %\end{figure}
1922: %\begin{figure}[Top]%
1923: %
1924: %{ \hspace{1cm}
1925: %\psfig{figure=STARS_FIN_F2.ps,height=19cm,width=13cm}}
1926: %\caption[]{\footnotesize 
1927: %\label{FIN_F2}
1928: %}
1929: %\end{figure}
1930: %\begin{figure}[Top]
1931: %
1932: %{ \hspace{1cm}
1933: %\psfig{figure=STARS_FIN_F3.ps,height=19cm,width=13cm}}
1934: %\caption[]{\footnotesize 
1935: %\label{FIN_F3}
1936: %}
1937: %\end{figure}
1938: %
1939: %\begin{figure}[Top]
1940: %
1941: %{ \hspace{1cm}
1942: %\psfig{figure=STARS_FIN_DLS.ps,height=19cm,width=13cm}}
1943: %\caption[]{\footnotesize 
1944: %\label{STARSDLS}
1945: %}
1946: %\end{figure}
1947: %
1948: %\begin{figure}[Top]
1949: %{ \hspace{1cm}
1950: %\psfig{figure=STARS_FIN_A1445_n168r.ps,height=19cm,width=13cm}}
1951: %\caption[]{\footnotesize 
1952: %}
1953: %\end{figure}
1954: %
1955: %\begin{figure}[Top]
1956: %{ \hspace{1cm}
1957: %\psfig{figure=PLOT_SIM_STARS_cca1445_n168r.ps,height=19cm,width=13cm}}
1958: %\caption[]{\footnotesize 
1959: %}
1960: %\end{figure}
1961: %
1962: %\begin{figure}[Top]
1963: %{ \hspace{1cm}
1964: %\psfig{figure=STARS_FIN_cca1445_n168r.ps,height=19cm,width=13cm}}
1965: %\caption[]{\footnotesize 
1966: %}
1967: %\end{figure}
1968: 
1969: