IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 6, 2017, 11:15:00 AM (10 years ago)
Author:
eugene
Message:

merge changes from trunk (updates to the papers)

Location:
branches/czw_branch/20160809/doc/release.2015/ps1.analysis
Files:
3 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20160809/doc/release.2015/ps1.analysis

    • Property svn:ignore
      •  

        old new  
        55analysis.dvi
        66analysisNotes.bib
         7analysis.bbl
         8analysis.blg
         9analysis.tgz
         10analysis.tpm
         11texput.log
  • branches/czw_branch/20160809/doc/release.2015/ps1.analysis/Makefile

    r37890 r39920  
    11# $Id: Makefile,v 1.16 2006-01-16 01:11:40 eugene Exp $
     2
     3# WARNING : pdflatex does not do .ps
     4#
     5DO_PDFLATEX = 1
     6DO_BIBTEX = 0
    27
    38help:
    49        @echo "USAGE: make (target)"
    5         @echo "  targets:  all analysis"
     10        @echo "  targets:  all pdf tgz"
    611
    7 all: analysis.pdf
     12all: pdf tgz
     13pdf: analysis.pdf
     14tgz: analysis.tgz
    815
    9 ANALYSIS = analysis.tex
     16PDFPICS = \
     17pics/peaks.pdf \
     18pics/FWHM.smooth.trend.ps1.pdf \
     19pics/moment.class.pdf \
     20pics/radial.profiles.pdf
    1021
    11 #       pics/Metadata.ps
    12 #       pics/earthrot.ps
     22FILES = \
     23../inputs/astro.sty \
     24../inputs/code.sty \
     25../inputs/apj.bst \
     26../inputs/lib.bib \
     27$(PDFPICS) \
     28analysis.tex
    1329
    14 analysis.pdf: $(ANALYSIS)
     30pics/%.pdf : pics/%.ps
     31        echo $^
     32        echo $<
     33        echo $@
     34        echo $*
     35        ps2pdf -dEPSCrop $< $@
    1536
    16 analysis.ps: $(ANALYSIS)
     37pdfpics: $(PDFPICS)
     38analysis.pdf: $(FILES)
     39analysis.tgz: $(FILES)
    1740
    1841include ../Makefile.Common
  • branches/czw_branch/20160809/doc/release.2015/ps1.analysis/analysis.tex

    r38591 r39920  
    22% \pdfoutput=1
    33
    4 % see latex.readme.txt for notes on using the PS1 template
    5 %\documentclass[12pt,preprint]{aastex}
    6 %\documentclass[manuscript]{aastex}
    7 %\documentclass[preprint2]{aastex}
    8 %\documentclass[preprint2,longabstract]{aastex}
     4\RequirePackage{graphicx}
    95\RequirePackage{color}
     6\RequirePackage{code}
    107\input{astro.sty}
    118
     
    1411%\def\plotmode{bw}
    1512
     13% latex uses the .ps regardless of \plotext if passed with ext=.\plotext
     14% pdflatex uses the png if it exists, pdf otherwise OK with pdf, png
     15% independent of graphicx or graphics
     16% pdflatex fails on files with multiple dots, protect with {file.name.long}.pdf
     17% use ps2pdf -dEPSCrop input.ps to convert to pdf
     18
     19% \includegraphics[width=\hsize,clip]{peaks}
     20% \includegraphics[width=\hsize]{temp.pdf}
     21% \includegraphics[width=\hsize]{{FWHM.smooth.trend.ps1}.pdf}
     22
    1623%\def\plotext{pdf}
    17 \def\plotext{ps}
     24%\def\plotext{png}
     25\def\plotext{pdf}
    1826
    1927%\def\picdir{/home/eugene/chipresid.20140404}
    20 \def\picdir{/data/pikake.2/eugene/chipresid.20140404}
     28\def\picdir{pics}
    2129
    2230% Pick a terse version of the title here;
     
    2432\shortauthors{E.A. Magnier et al}
    2533\begin{document}
    26 \title{Pan-STARRS Pixel Analysis : Source Detection \& Characterization}
     34\title{Pan-STARRS Pixel Analysis : Source Detection and Characterization}
    2735
    2836% this is a crude trick to get the order of affiliations right.  These
     
    3139% list and (2) re-order the list at the bottom (and comment-out as needed)
    3240\def\IfA{1}
     41\def\Princeton{2}
     42\def\DUR{3}
    3343\def\CfA{2}
    34 \def\MPIA{3}
    35 \def\Princeton{3}
    36 \def\USNO{4}
    37 \def\JHU{1}
    3844
    3945% This example has a first author from UH:
    4046\author{
    4147Eugene A. Magnier,\altaffilmark{\IfA}
    42 IPP Team,
    43 %PS Builder List
     48% R. H. Lupton,\altaffilmark{\Princeton}
     49W.~E. Sweeney,\altaffilmark{\IfA}
     50K.~C. Chambers,\altaffilmark{\IfA}
     51H.~A. Flewelling,\altaffilmark{\IfA}
     52M. E. Huber,\altaffilmark{\IfA}
     53P.~A. Price,\altaffilmark{\Princeton}
     54C. Z. Waters,\altaffilmark{\IfA}
     55% PS1 Builders
     56L. Denneau,\altaffilmark{\IfA}
     57P. Draper,\altaffilmark{\DUR}
     58R. Jedicke,\altaffilmark{\IfA}
     59K. W. Hodapp,\altaffilmark{\IfA}
     60N. Kaiser,\altaffilmark{\IfA}
     61R.-P. Kudritzki,\altaffilmark{\IfA}
     62N. Metcalfe,\altaffilmark{\DUR}
     63C.~W. Stubbs,\altaffilmark{\CfA}
    4464% W.~S. Burgett,\altaffilmark{\IfA}
    45 % K.~C. Chambers,\altaffilmark{\IfA}
    46 % L. Denneau,\altaffilmark{\IfA}
    47 % P. Draper,\altaffilmark{\DUR}
    48 % H.~A. Flewelling,\altaffilmark{\IfA}
    4965% T. Grav,\altaffilmark{\IfA}
    5066% J. N. Heasley,\altaffilmark{\IfA}
    51 % K. W. Hodapp,\altaffilmark{\IfA}
    52 % M. E. Huber,\altaffilmark{\IfA}
    53 % R. Jedicke,\altaffilmark{\IfA}
    54 % N. Kaiser,\altaffilmark{\IfA}
    55 % R.-P. Kudritzki,\altaffilmark{\IfA}
    5667% G. A. Luppino,\altaffilmark{\IfA}
    5768% R. H. Lupton,\altaffilmark{\Princeton}
    5869% E. A. Magnier,\altaffilmark{\IfA}
    59 % N. Metcalfe,\altaffilmark{\DUH}
    6070% D. G. Monet,\altaffilmark{\USNO}
    6171% J.~S. Morgan,\altaffilmark{\IfA}
    6272% P. M. Onaka,\altaffilmark{\IfA}
    63 % P.~A. Price,\altaffilmark{\Princeton}
    64 % C.~W. Stubbs,\altaffilmark{\CfA}
    65 % W.~E. Sweeney,\altaffilmark{\IfA}
    6673% J.~L. Tonry, \altaffilmark{\IfA}
    67 % R. J. Wainscoat,\altaffilmark{\IfA} and
    68 % C. Z. Waters,\altaffilmark{\IfA}
     74R. J. Wainscoat\altaffilmark{\IfA}
    6975} % this bracket terminates author list
    7076
    7177% The ordering here should be sequential, matching the sequence in the list of authors:
    7278\altaffiltext{\IfA}{Institute for Astronomy, University of Hawaii, 2680 Woodlawn Drive, Honolulu HI 96822}
    73 % \altaffiltext{\CfA}{Harvard-Smithsonian Center for Astrophysics, 60 Garden Street, Cambridge, MA 02138}
    74 % \altaffiltext{\Princeton}{Department of Astrophysical Sciences, Princeton University, Princeton, NJ 08544, USA}
     79\altaffiltext{\Princeton}{Department of Astrophysical Sciences, Princeton University, Princeton, NJ 08544, USA}
     80\altaffiltext{\DUR}{Department of Physics, Durham University, South Road, Durham DH1 3LE, UK}
     81\altaffiltext{\CfA}{Harvard-Smithsonian Center for Astrophysics, 60 Garden Street, Cambridge, MA 02138}
    7582% \altaffiltext{\USNO}{US Naval Observatory, Flagstaff Station, Flagstaff, AZ 86001, USA}
    7683% \altaffiltext{\JHU}{Department of Physics and Astronomy, Johns Hopkins University, 3400 North Charles Street, Baltimore, MD 21218, USA}
     
    7885\begin{abstract}
    7986
    80 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum
    81 bibendum nisi id tristique posuere. Duis eu mollis nulla. Maecenas est
    82 turpis, mattis tempor urna vitae, placerat rhoncus sem. Lorem ipsum
    83 dolor sit amet, consectetur adipiscing elit. Sed quis velit
    84 nisl. Aliquam erat volutpat. Cras lacinia, nisl tristique auctor
    85 molestie, dolor nulla rhoncus purus, ac accumsan nunc nunc ac
    86 nibh. Maecenas vitae mollis mauris. Ut sollicitudin pulvinar purus,
    87 eget luctus lorem tincidunt vitae. Vestibulum eu mattis neque. Nulla
    88 in tortor id urna dapibus gravida a vel leo.
    89 
     87Over 3 billion astronomical objects have been detected in the more
     88than 22 million orthogonal transfer CCD images obtained as part of the
     89Pan-STARRS\,1 $3\pi$ survey.  Over 85 billion instances of those
     90objects have been automatically detected and characterized by the
     91Pan-STARRS Image Processing Pipeline photometry software,
     92\code{psphot}.  This fast, automatic, and reliable software was
     93developed for the Pan-STARRS project, but is easily adaptable to
     94images from other telescopes.  We describe the analysis of the
     95astronomical objects by \code{psphot} in general as well as for the
     96specific case of the 3rd processing version used for the first public
     97release of the Pan-STARRS $3\pi$ survey data.
    9098\end{abstract}
    9199
     
    93101\keywords{Surveys:\PSONE }
    94102
    95 \section{OUTLINE}
    96 \begin{verbatim}
    97 Intro
    98  Pan-STARRS background
    99  Scope: Source Detection \& Characterization, Galaxy modeling
    100  Requirements / Goals
    101  Comparable programs
    102  PSPhot
    103 \end{verbatim}
    104 
    105103\section{INTRODUCTION}\label{sec:intro}
    106104
    107 \note{more PS1 background}
    108 
    109 The Pan-STARRS Image Processing Pipeline is responsible for the basic
    110 analysis of images from the Pan-STARRS telescopes Gigapixel Camera.
    111 The photometric and astrometric precision goals for the all-sky
    112 surveys, as well as the other survey components, are quite stringent:
    113 
    114 \begin{itemize}
    115 \item relative photometry: 10 millimagnitudes scatter for bright stars
    116 across the sky in the internal photometric system;
    117 
    118 \item relative astrometry; 10 milliarcseconds scatter for individual
    119 stars between repeated images.
    120 
    121 \item absolute astrometry: 100 milliarcseconds scatter for all ICRS
    122   reference stars (Tycho).
    123 \end{itemize}
    124 
    125 An additional constraint on the Pan-STARRS system comes from the high
    126 data rate.  PS1 produces typically $\sim 700$ GB per night of imaging
    127 data.  These images range from high galactic latitudes to the Galactic
    128 Bulge, so large numbers of measurable stars can be expected in much of
    129 the data.  The combination of the high precision goals of the
    130 astrometric and photometric measurements and the high data rate (and a
    131 finite computing budget) mean that the process of detecting,
    132 classifying, and measuring the astronomical objects in the image data
    133 stream in a timely fashion are a significant challenge.
     105This is the fourth in a series of seven papers describing the
     106Pan-STARRS1 Surveys, the data reduction techiques and the resulting
     107data products.  This paper (Paper IV) describes the details of the
     108source detection and photometry, including point-spread-function and
     109extended source fitting models, and the techniques for ``forced''
     110photometry measurements.
     111
     112%Chambers et al. 2017 (Paper I)
     113%The Pan-STARRS\,1 Surveys
     114\citet[][Paper I]{chambers2017}
     115provides an overview of the Pan-STARRS System, the design and
     116execution of the Surveys, the resulting image and catalog data
     117products, a discussion of the overall data quality and basic
     118characteristics, and a brief summary of important results.
     119
     120%Magnier et al. 2017 (Paper II)
     121%Pan-STARRS Data Processing Stages
     122\citet[][Paper II]{magnier2017c}
     123describes how the various data processing stages are organised and implemented
     124in the Imaging Processing Pipeline (IPP), including details of the
     125the processing database which is a critical element in the IPP infrastructure .
     126
     127%Waters et al. 2017 (Paper III)
     128%Pan-STARRS Pixel Processing : Detrending, Warping, Stacking
     129\citet[][Paper III]{waters2017}
     130describes the details of the pixel processing algorithms, including detrending, warping, and adding (to create stacked images) and subtracting (to create difference images) and resulting image products and their properties.
     131
     132
     133%Magnier et al. 2017 (Paper IV)
     134%Pan-STARRS Pixel Analysis : Source Detection
     135%\citet[][Paper IV]{magnier2017a}
     136%describes the details of the source detection and photometry, including point-spread-function and extended source fitting models, and the techniques for ``forced" photometry measurements.
     137
     138%Magnier et al. 2017 (Paper V)
     139%Pan-STARRS Photometric and Astrometric Calibration
     140\citet[][Paper V]{magnier2017b}
     141describes the final calibration process, and the resulting photometric and astrometric quality. 
     142
     143
     144%Flewelling et al. 2017 (Paper VI)
     145%Pan-STARRS 1 Database and Data Products
     146\citet[][Paper VI]{flewelling2017}
     147describes  the details of the resulting catalog data and its organization in the Pan-STARRS database.
     148%
     149%
     150\citet[][Paper VII]{huber2017}
     151%Huber et al. 2017 (Paper VII)
     152describes the Medium Deep Survey in detail, including the unique issues and data products specific to that survey. The Medium Deep Survey is not part of Data Release 1. (DR1)
     153
     154%
     155The Pan-STARRS1 filters and photometric system have already been
     156described in detail in \cite{2012ApJ...750...99T}.
     157
     158{\color{red} {\em Note: These papers are being placed on arXiv.org to
     159    provide crucial support information at the time of the public
     160    release of Data Release 1 (DR1). We expect the arXiv versions to
     161    be updated prior to submission to the Astrophysical Journal in
     162    January 2017. Feedback and suggestions for additional information
     163    from early users of the data products are welcome during the
     164    submission and refereeing process.}}
     165
     166\section{Background}
     167
     168The photometric and astrometric precision goals for the Pan-STARRS\,1
     169surveys were quite stringent: photmetric accuracy of 10
     170millimagnitudes, relative astrometric accuracy of 10 milliarcseconds
     171and absolute astrometric accuracy of 100 milliarcseconds with respect
     172to the ICRS reference stars.
     173
     174An additional constraint on the Pan-STARRS analysis system comes from
     175the high data rate.  PS1 produces typically $\sim 500$ exposures per
     176night, corresponding to $\sim 750$ billion pixels of imaging data.
     177The images range from high galactic latitudes to the Galactic bulge,
     178so large numbers of measurable stars can be expected in much of the
     179data.  The combination of the high precision goals of the astrometric
     180and photometric measurements and the high data rate (and a finite
     181computing budget) mean that the process of detecting, classifying, and
     182measuring the astronomical objects in the image data stream in a
     183timely fashion are a significant challenge.
    134184
    135185In order to achieve these ambitious goals, the object detection,
     
    142192astrometry.
    143193
    144 \subsection{Comparable Programs}
    145 
    146194A variety of astronomical software packages perform the basic object
    147195detection, measurement, and classification tasks needed by the
     
    157205  pro: well-tested, stable code.  con: limited range of models,
    158206  algorithm converges slowly to a PSF model, limited tests of PSF
    159   validity, inflexible code base, fortran (P. Schechter)
     207  validity, inflexible code base, fortran \citep{1993PASP..105.1342S}.
    160208
    161209\item DAOPhot : Pixel-map PSF model with analytical component.  pro:
    162210  well-tested, high-quality photometry.  con: Difficult to use in an
    163   automated fashion, does it handle 2D variations well? (P. Stetson)
    164 
    165 \item Sextractor : pure aperture measurement with rudimentary
    166   object subtraction.  pro: fast, widely used, easy to automate.  con:
    167   poor object separation in crowded regions, PSF-modeling is only
    168   beta (psfex), what models are available? (E. Bertin)
    169 
    170 \item apphot : IRAF-based aperture photometry.  pro: widely used.
    171   con: IRAF-based, aperture photometry. (???)
     211  automated fashion, does it handle 2D variations well? \citep{1987PASP...99..191S}.
     212
     213\item Sextractor : pure aperture measurement with rudimentary object
     214  subtraction.  pro: fast, widely used, easy to automate.  con: poor
     215  object separation in crowded regions, PSF-modeling was only in beta,
     216  not widely used at the time \citep{sextractor}.
    172217
    173218\item galfit : detailed galaxy modeling.  not a multi-object PSF
    174219  analysis tool.  con: does not provide a PSF model, not easily
    175220  automated.  very detailed results in very slow processing.  only a
    176   galaxy analysis program. (C. Impey)
     221  galaxy analysis program \citep{2002AJ....124..266P}.
    177222
    178223\item SDSS phot : con: tightly integrated into the SDSS software
    179   environment.  (R. Lupton)
     224  environment \citep{2001ASPC..238..269L}.
    180225
    181226\end{itemize}
    182227
    183 \note{re-phrase this:} The Pan-STARRS IPP team decided that none of
    184 the existing packages met all of their needs, particularly given the
    185 very challenging goals of the project.  We decided to redesign the
    186 photometry analysis from scratch, using the lessons learned from the
    187 existing photometry systems.  In the process, the object analysis
    188 software would be written using the data analysis C-code library
    189 written for the IPP, \code{psLib}, and the components of the
    190 photometry code would be integrated into the IPP's mid-level astronomy
    191 data analysis toolkit called \code{psModules}.  The result is
    192 'PSPhot', which can be used either as a stand-alone C program, or as
    193 callable set of functions.
    194 
    195 \note{discuss the psphot program varients}
    196 
    197 \begin{verbatim}
    198 Other Varients:
    199 * psphotStack -- 5 filter simultaneous fitting
    200 * psphotFullForce
    201 \end{verbatim}
     228When the IPP development was starting, the existing photometry
     229packages either did not meet the level of accuracy required or were
     230required too much human intervention to be considered for the needs of
     231PS1.  In the case of the SDSS Photo tool, the software was judged to
     232be too tightly integrated to the architecture of SDSS to be easily
     233re-integrated into the Pan-STARRS pipelin.  A new photometry analysis
     234package was developed using lessons learned from the existing
     235photometry systems.  In the process, the object analysis software was
     236written using the data analysis C-code library written for the IPP,
     237\code{psLib}.  Components of the photometry code were integrated into
     238the IPP's mid-level astronomy data analysis toolkit called
     239\code{psModules}.  The result software, 'PSPhot', can be used either
     240as a stand-alone C program, or as a set of library functions which may
     241be integrated into other programs
     242
     243The main version of PSPhot is a stand-alone program which is run on a
     244single image or a group of related images representing the data read
     245from a camera in a single exposure.  The images are expected to have
     246already been detrended so that pixel values are linearly related to
     247the flux.  The gain may be specific by the configuration system, or a
     248variance image may be supplied.  A mask may also be supplied to mark
     249good, bad, and suspect pixels.  Several variants of psphot have also
     250been used in the PS1 PV3 analysis. 
     251
     252The version called PSPhotStack accepts a set of images, each
     253representing the same patch of sky in a different filter, nominally
     254the full $grizy$ filter set for the analysis of the PS1 PV3 stack
     255images, though where insufficient data were available in a given
     256filter, a subset of these filters was processed as a group.  As
     257discussed in detail below, the PSPhotStack analysis includes the
     258capability of measuring forced PSF photometry in some filter images
     259based on the position of sources detected in the other filters.  It
     260also include an option to convolve the set of images to a single,
     261common PSF size across the filters for the purpose of fixed aperture
     262photometry.
     263
     264A second version of PSPhot used in the PV3 analysis is called
     265PSPhotFullForce.  In this version, a set of image all representing the
     266same pixels are processed together, with the positions of sources to
     267be analysed loaded from a supplied file.  In this version the
     268analysis, sources are not discovered -- only the supplied sources are
     269considered.  PSF models are determined for each exposure and the
     270forced PSF photometry is measured for all sources.  A subset of
     271sources may also be used to measure forced galaxy shape parameters.
     272As described below, a grid of galaxy models are fitted based on the
     273supplied guess model. 
    202274
    203275\section{PSPhot Design Goals}
     
    233305  level must be reached for images with 250 mas pixels, implying
    234306  PSPhot must introduce measurement errors less than 1/50th of a
    235   pixel. \note{the choice of F32 parameters places a numerical limit
    236   of 1e-7 on the accuracy of a pixel relative to the size of a chip
    237   (since a single data value is used for X or Y).  For the $4800^2$
    238   GPC chips, this yields a limit of about 0.25 milliarcsecond.}
     307  pixel. The choice of 32 bit floating point data values for the
     308  source centroids places a numerical limit of 1e-7 on the accuracy of
     309  a pixel relative to the size of a chip (since a single data value is
     310  used for X or Y).  For the $4800^2$ GPC chips, this yields a limit
     311  of about 0.25 milliarcsecond.
    239312\end{itemize}
    240313
     
    253326
    254327\item {\bf Flexible non-PSF models} PSPhot must be able to represent
    255   PSF-like objects as well as non-PSF sources.  It must be easy to add
    256   new object models as interesting representations of sources are
    257   invented.
     328  PSF-like objects as well as non-PSF sources (e.g., galaxies).  It
     329  must be easy to add new object models as interesting representations
     330  of sources are invented.
    258331
    259332\item {\bf Clean code base} PSPhot should incorporate a high-degree of
     
    265338  provide the user with methods for assessing the different PSF models.
    266339
    267 \item {\bf Careful aperture corrections} PSPhot must carefully measure
    268   and correct for the photometric and astrometric trends introduced by
    269   using analytical PSF models.
     340\item {\bf Careful systematic corrections} PSPhot must carefully
     341  measure and correct for the photometric and astrometric trends
     342  introduced by using analytical PSF models.
    270343
    271344\item {\bf User Configurable} PSPhot should allow users to change the
     
    280353The PSPhot analysis is divided into several major stages:
    281354
    282 \begin{itemize}
     355\begin{enumerate}
    283356\item {\bf Image preparation} Load data, characterize the image
    284357  background, load or construct variance and mask images.
    285358
    286359\item {\bf Initial object detection} Smooth, find peaks, measure basic
    287   properties
     360  properties.
    288361
    289362\item {\bf PSF determination} Select PSF candidates, perform model
     
    297370  properties (aperture or PSF)
    298371
     372\item {\bf Extended Source Analysis} Detailed measurements relevant to
     373  galaxies and/or other extended (non-PSF) sources.
     374
    299375\item {\bf Aperture corrections} Measure the curve-of-growth, spatial
    300376  aperture variations, and background-error corrections. 
     
    302378\item {\bf Output} Write out objects in selected format, write out
    303379  difference image, variance image, etc, as selected.
    304 \end{itemize}
     380\end{enumerate}
    305381
    306382PSPhot is highly configurable.  Users may choose via the configuration
    307 system which of the above analyses are performed.  This may be useful
    308 for testing, but may also allow for specialized use cases.  For
    309 example, the PSF model may already be available from external
    310 information, in which case the PSF modeling stage can be skipped.
     383system which of the above analyses are performed.  This is useful for
     384testing, but also allows for specialized use cases.  For example, the
     385PSF model may already be available from external information, in which
     386case the PSF modeling stage can be skipped.
    311387
    312388\subsection{Image Preparation}
     
    352428circumstance, while a pixel in which persistence ghosts have been
    353429subtracted might be useful for detection or even analysis of brighter
    354 sources.  \note{can I identify which functions respect which sets of masks}
     430sources.  Table~\ref{tab:mask_values} lists the 16 bit values used for
     431PS1 mask images, along with their description \citep[see][for
     432  additional information]{waters2017}.
     433
     434\begin{table*}
     435\caption{\label{tab:mask_values} PSPhot / GPC1 Mask Image Pixel Values}\vspace{-0.5cm}
     436\begin{center}
     437\begin{tabular}{lcl}
     438\hline
     439\hline
     440{\bf Mask Name} & {\bf Mask Value} & {\bf Description} \\
     441\hline
     442  DETECTOR & 0x0001 & A detector defect is present. \\
     443  FLAT     & 0x0002 & The flat field model does not calibrate the pixel reliably. \\
     444  DARK     & 0x0004 & The dark model does not calibrate the pixel reliably. \\
     445  BLANK    & 0x0008 & The pixel does not contain valid data. \\
     446  CTE      & 0x0010 & The pixel has poor charge transfer efficiency. \\
     447  SAT      & 0x0020 & The pixel is saturated. \\
     448  LOW      & 0x0040 & The pixel has a lower value than expected. \\
     449  SUSPECT  & 0x0080 & The pixel is suspected of being bad. \\
     450  BURNTOOL & 0x0080 & The pixel contain an burntool repaired streak. \\
     451  CR       & 0x0100 & A cosmic ray is present. \\
     452  SPIKE    & 0x0200 & A diffraction spike is present. \\
     453  GHOST    & 0x0400 & An optical ghost is present. \\
     454  STREAK   & 0x0800 & A streak is present. \\
     455  STARCORE & 0x1000 & A bright star core is present. \\
     456  CONV.BAD & 0x2000 & The pixel is bad after convolution with a bad pixel. \\
     457  CONV.POOR& 0x4000 & The pixel is poor after convolution with a bad pixel. \\
     458  MARK     & 0x8000 & An internal flag for temporarily marking a pixel. \\
     459\hline
     460\end{tabular}
     461\end{center}
     462\end{table*}
    355463
    356464The variance image, if not supplied is constructed by default from the
    357465flux image using the configuration supplied values of \code{GAIN} and
    358 \code{READ\_NOISE} to calculate the appropriate Poisson statistics for
     466\code{READ_NOISE} to calculate the appropriate Poisson statistics for
    359467each pixel.  In this case, the image is assumed to represent the
    360468readout from a single detector, with well-defined gain and read noise
     
    376484Since a typical smoothing or warping operation may introduce
    377485correlation between 25 - 100 neighboring pixels, the size of such a
    378 covariance image is prohibitive.  In practice, however, there are two
    379 extreme cases which generally are relevant.  \note{talk about the
    380   covar matrix for a PSF}
    381 
    382 \subsection{Background (Sky) Model}
     486covariance image is prohibitive. 
     487
     488Before sources are detected in the image, a model of the background is
     489subtracted.  The image is divided into a grid of background points
     490with a spacing of 400 pixels.  Superpixels of size $800\times 800$
     491pixels are used to measure the local background for each background
     492grid point, thus over-sampling the background spatial variations by a
     493factor of 2.  In the interest of speed, 10,000 randomly selected {\em
     494  unmasked} pixels in these regions are sampled to determine the
     495background.  Bilinear interpolation is used to generate a
     496full-resolution image from the grid of background points, and this
     497image is then subtracted from the science image.  The background image
     498and the background standard deviation image are kept in memory from
     499which the values of \code{SKY} and \code{SKY_SIGMA} are calculated for
     500each object in the output catalog.  See also the discussion in
     501\cite{waters2017}.
    383502
    384503\subsection{Initial Object Detection}
     504
     505\subsubsection{Peak Detection}
     506\label{sec:peaks}
    385507
    386508The objects are initially detected by finding the location of local
    387509peaks in the image.  The flux and variance images are smoothed with a
    388 small circularly symmetric kernel using a two-pass 1D Gaussian
    389 (\note{KEYWORD?}).  The smoothed flux and variance images are combined
    390 to generate a significance image in signal-to-noise units
    391 \note{including correction for the covariance, if known}. At this
    392 stage, the goal is only to detect the brighter sources, above a user
    393 defined S/N limit (configuration keyword: \code{PEAK\_NSIGMA}).  The
    394 detection efficiency for the brighter sources is not strongly
    395 dependent on the form of this smoothing function.
     510small circularly symmetric kernel using a two-pass 1D Gaussian.  The
     511smoothed flux and variance images are combined to generate a
     512significance image in signal-to-noise units, including correction for
     513the covariance, if known. At this stage, the goal is only to detect
     514the brighter sources, above a user defined S/N limit (configuration
     515keyword: \code{PEAKS_NSIGMA_LIMIT}).  A maximum of
     516\code{PEAKS_NMAX} are found at this stage.  The detection efficiency
     517for the brighter sources is not strongly dependent on the form of this
     518smoothing function.
    396519
    397520The local peaks in the smoothed image are found by first detecting
     
    406529the maximum $X$ and $Y$ corners of the region.
    407530
    408 \subsection{Footprints}
    409 
    410 \note{need to describe the process of generating the source footprints
    411   and then culling the insignificant peaks}
    412 
    413 \subsubsection{Moments and related}
    414 
    415 \note{disucss the Kron mags}
    416 
    417 \note{this section is wrong: we no longer use S/N clipping, but a
    418   Gaussian window function, chosen based on the measured moment}
    419 
    420 Once a collection of peaks have been identified, basic properties of
    421 the objects are measured.  First, the local sky flux is measured
    422 within a square annulus with user-defined dimensions
    423 (\code{INNER\_RADIUS} and \code{OUTER\_RADIUS}), using the sample
    424 median.  This local background value is then used to calculate the
    425 object first and second moments within a small user-defined aperture
    426 (\code{MOMENT\_RADIUS}).  The first-order moments are a good
    427 representation of the object position, while the second-order moments
    428 are a measure of the object shape.  The second-order moments are
    429 somewhat sensitive to the size of the aperture and the accuracy of the
    430 background measurement.  The moment calculation is only performed
    431 using pixels which exceed a S/N of 1.  If, in the process of
    432 calculating the source moments, the S/N limits reject all but \note{3}
    433 or fewer of the source pixels, the peak is identified as being
    434 suspect, and is not used for further analysis.  If the measured
    435 centroid coordinates differ from the peak coordinates be a large
    436 amount (\code{MOMENT\_RADIUS}), then the peak is again identified as
    437 being of poor quality and is rejected.  In both of these cases, it is
    438 likely that the `peak' was identified in a region of flat flux
    439 distribution or many saturated or edge pixels.
    440 
    441 \subsubsection{Determination of the Peak Coordinates and Errors}
    442 
    443 \note{this section is wrong: it is a poor estimator of the source
    444   position errors.  we gave up a reverted to using the FWHM / (S/N)}
    445 
    446531We use the 9 pixels which include the source peak to fit for the
    447532position and position errors.  We model the peak of the sources as a
     
    460545of only 0 or 1, we can greatly simplify the chi-square equation to a
    461546square matrix equation with the following values:
    462 
    463 %% fix this:
    464 \begin{verbatim}
    465 | 9 0 0 0 6 6 | C_00 | = \sum F_{i,j}
    466 | 0 6 0 0 0 0 | C_10 | = \sum F_{i,j} x
    467 | 0 0 6 0 0 0 | C_01 | = \sum F_{i,j} y
    468 | 0 0 0 6 0 0 | C_11 | = \sum F_{i,j} x y
    469 | 6 0 0 0 6 4 | C_20 | = \sum F_{i,j} x^2
    470 | 6 0 0 0 4 6 | C_02 | = \sum F_{i,j} y^2
    471 \end{verbatim}
    472 
    473 The inverse of the 3x3 matrix terms for $C_{00}$, $C_{20}$, and $C_{02}$ is:
    474 \begin{verbatim}
    475 | +5/9 -1/3 -1/3 |
    476 | -1/3 +1/2    0 |
    477 | -1/3    0 +1/2 |
    478 \end{verbatim}
    479 
    480 which can be used to determine the errors on the coefficients:
    481 
     547\[
     548\left( \begin{array}{cccccc}
     5499 & 0 & 0 & 0 & 6 & 6 \\
     5500 & 6 & 0 & 0 & 0 & 0 \\
     5510 & 0 & 6 & 0 & 0 & 0 \\
     5520 & 0 & 0 & 6 & 0 & 0 \\
     5536 & 0 & 0 & 0 & 6 & 4 \\
     5546 & 0 & 0 & 0 & 4 & 6 \\
     555\end{array} \right)
     556\left( \begin{array}{c}
     557C_{00}\\
     558C_{10}\\
     559C_{01}\\
     560C_{11}\\
     561C_{20}\\
     562C_{02}\\
     563\end{array} \right)
     564=
     565\left( \begin{array}{c}
     566\sum F_{i,j}     \\
     567\sum F_{i,j} x   \\
     568\sum F_{i,j} y   \\
     569\sum F_{i,j} x y \\
     570\sum F_{i,j} x^2 \\
     571\sum F_{i,j} y^2 \\
     572\end{array} \right)
     573\]
     574
     575Inverting the 3x3 matrix terms for $C_{00}$, $C_{20}$, and $C_{02}$,
     576the location of the peak is determined from the minimum of the
     577bi-quadratic function above, and is given by:
    482578\begin{eqnarray}
    483 \sigma^2_{00} & = & \sigma^2 (5/9) \\
    484 \sigma^2_{10} & = & \sigma^2 (1/6) \\
    485 \sigma^2_{01} & = & \sigma^2 (1/6) \\
    486 \sigma^2_{11} & = & \sigma^2 (1/6) \\
    487 \sigma^2_{20} & = & \sigma^2 (1/2) \\
    488 \sigma^2_{02} & = & \sigma^2 (1/2) \\
     579x_{min} & = & (C_{11} C_{01} - 2 C_{02} C_{10}) D^{-1} \\
     580y_{min} & = & (C_{11} C_{10} - 2 C_{20} C_{01}) D^{-1} \\
     581D      & = & 4 C_{20} C_{02} - C_{11}^2
    489582\end{eqnarray}
    490583
    491 The location of the peak is determined from the minimum of the
    492 bi-quadratic function above, and is given by:
     584\begin{figure}[htbp]
     585  \begin{center}
     586 \includegraphics[width=\hsize,clip]{pics/peaks}
     587  \caption{\label{fig:peaks} Illustration of peak finding and culling peaks within a
     588    footprint.  Insignificant peaks within the footprint of a brighter
     589    peak are ignored in further processing. }
     590  \end{center}
     591\end{figure}
     592
     593\subsubsection{Footprints}
     594
     595The peaks detected in the image may correspond to real sources, but
     596they may also correspond to noise fluctuations, especially in the
     597wings of bright stars.  PSPhot attempts to identify peaks which may be
     598formally significant, but are not locally significant.  It first
     599generates a set of ``footprints'', contiguous collections of pixels in
     600the smoothed significance image above the detection threshold.  These
     601regions are grown by a small amount to avoid errors on rough edges --
     602an image of the footprints is convolved with a disk of radius 3
     603pixels.  Peaks are assigned to the footprints in which they are
     604contained (note by definition all peaks must be located in a
     605footprint). 
     606
     607For any peak which is not the brightest peak in that footprint it is
     608possible to reach the brightest peak by following the highest valued
     609pixels between the two peaks.  The lowest pixel along this path is the
     610{\em key col} for this peak (as used in topographic descriptions of a
     611mountain).  If the key col for a given peak is less than
     612\code{FOOTPRINT_CULL_NSIGMA_DELTA} (4.0) sigmas below the peak of
     613interest, the peak is considered to be {\em locally insignificant} and
     614removed from the list of possible detections (see
     615Figure~\ref{fig:peaks}).  In the vicinity of a saturated star, the
     616rule is somewhat more agressive as the flat-topped or structured
     617saturated top of a bright star may appear as multiple peaks with
     618highly significant cols between them.  However, this is an artifact of
     619the proximity to saturation.  In this regime, we require the col to
     620also be a fixed fraction (5\%) of the saturation below the peak to
     621avoid being marked as locally insignificant.
     622
     623\subsubsection{Centroid and higher-order Moments}
     624\label{sec:moments}
     625
     626\begin{figure}[htbp]
     627  \begin{center}
     628  \includegraphics[width=\hsize]{{pics/FWHM.smooth.trend.ps1}.\plotext}
     629  \caption{\label{fig:moments.window} Example of the biases encountered when measuring the second
     630    moments.  A simulated image was generated using the PS1 PSF
     631    profile.  Each panel corresponds to a different value of
     632    $\sigma_w$, as marked.  The solid red line is the true FWHM of the
     633    PSF used to generate the stars.  The blue solid line is the FWHM
     634    of the window function ($2.35\sigma_w$).  The gray dots are the
     635    FWHM derived from the measured second moments for stars in the
     636    image.  The dotted blue line is the target (65\% of the window
     637    function).  In this example, we would choose $\sigma_w$ between
     638    0.5 and 0.8 arcseconds so the dotted blue line would match the
     639    bright end of the gray dots.}
     640  \end{center}
     641\end{figure}
     642
     643Once a collection of peaks has been identified, a number of basic
     644properties of the objects related to the first and second moments are
     645measured.  Below, the second moments are used to select candidate
     646stellar sources to be used in modeling the PSF.
     647
     648In order to measure the moments, it is necessary to define an
     649appropriate aperture in which the moments are measured.  We also apply
     650a ``window function'', down-weighting the pixels by a Gaussian of size
     651$\sigma_W$ which is chosen to be large compared to the PSF size,
     652$\sigma_{\rm PSF}$.  This
     653window function reduces the noise of the measurement of the first and
     654second moments by suppressing the noisy pixels at high radial distance
     655as well as by reducing the contaminating effects of neighboring stars.
     656The choice of the window function $\sigma_W$ and the aperture is an
     657iterative process: for a given value of $\sigma_W$, the PSF stars will
     658have a measured value of $\sigma_{\rm PSF}$ which is modified by the effect of
     659the window function.  In addition, depending on the size of the window
     660function compared to the true PSF size, the measured value of the PSF
     661size, $\sigma_{\rm PSF}$, will be biased high or low depending on the
     662signal-to-noise of the object. 
     663
     664These effects are illustrated in Figure~\ref{fig:moments.window} using
     665simulated data.  An image was generated with a PSF model matching the
     666radial profile of the PS1 PSF model with a FWHM of 1.4 arcseconds.  As
     667the window function $\sigma_W$ is increased, the measured FWHM for the
     668bright simulated stars rises to meet the truth value.  For small
     669values of $\sigma_W$, fainter stars are biased to low measured values
     670of the FWHM.  For large values of $\sigma_W$, the faint stars are
     671biased to higher values and the scatter increases.
     672
     673In a real image, we do not know the true value of the PSF size.  If we
     674simply choose a very large window function and rely on bright stars,
     675our estimate of the PSF size will be quite noisy.  Compounding this
     676problem are the two additional facts that (1) we do not know which are
     677the real stars (as opposed to bright galaxies or possible image
     678artifacts) and (2) the brighter stars are themselves subject to
     679additional biases due to saturation and other non-linear effects
     680(c.f., ``the Brighter-Fatter'' effect, REF).  To make a robust
     681choice for the window function $sigma_w$, we choose a value
     682such that the measured value of $\sigma_{\rm PSF}$ is 65\% of
     683$\sigma_w$.  The resulting second moment values are biased somewhat
     684low (\approx 75\% of the truth value for the PS1 PSF profile), but are
     685relatively unbiased as a function of brightness.
     686
     687To choose the value of $\sigma_W$, we try values of (1, 2, 3, 4.5, 6,
     6889, 12, 18) pixels $\approx$ (0.26, 0.51, 0.77, 1.15, 1.54, 2.3, 3.1,
     6894.6) arcseconds.  For each of these values, we then select candidate
     690PSF stars based on the distribution of the measured $\sigma_{x,x},
     691\sigma_{y,y}$ values.  For each test value of $\sigma_w$, we determine
     692the ratio $f = \frac{\sigma_{x,x} + \sigma{y,y}}{2 \sigma_w}$, i.e.,
     693the ratio of the window size to the observed PSF size.  We interpolate
     694to find a value of $\sigma_W$ for which $f$ is expected to be 0.65.
     695We call this value the \code{MOMENTS_GAUSS_SIGMA}.  We use an aperture
     696with a radius of \code{PSF_MOMENTS_RADIUS} = 4$\times$
     697\code{MOMENTS_GAUSS_SIGMA} to select the pixels for the measurement.
     698
     699Once \code{PSF_MOMENTS_SIGMA} has been determined, moments are
     700measured as defined below. 
    493701
    494702\begin{eqnarray}
    495 Det    & = & 4 C_{20} C_{02} - C_{11}^2 \\
    496 x_{min} & = & (C_{11} C_{01} - 2 C_{02} C_{10}) / Det \\
    497 y_{min} & = & (C_{11} C_{10} - 2 C_{20} C_{01}) / Det \\
     703x_0      & = & \frac{1}{S} \sum_i (f_i - s_i)x_i w_i \\
     704y_0      & = & \frac{1}{S} \sum_i (f_i - s_i)y_i w_i \\
     705M_{xx}   & = & \frac{1}{S} \sum_i (f_i - s_i)(x_i - x_0)^2w_i \\
     706M_{xy}   & = & \frac{1}{S} \sum_i (f_i - s_i)(x_i - x_0)(y_i - y_0)w_i \\
     707M_{yy}   & = & \frac{1}{S} \sum_i (f_i - s_i)(y_i - y_0)^2w_i \\
     708M_{xxx}  & = & \frac{1}{S} \sum_i (f_i - s_i)(x_i - x_0)^3w_i / r_i \\
     709M_{xxy}  & = & \frac{1}{S} \sum_i (f_i - s_i)(x_i - x_0)^2(y_i - y_0)w_i / r_i \\
     710M_{xyy}  & = & \frac{1}{S} \sum_i (f_i - s_i)(x_i - x_0)(y_i - y_0)^2w_i / r_i \\
     711M_{yyy}  & = & \frac{1}{S} \sum_i (f_i - s_i)(y_i - y_0)^3w_i / r_i \\
     712M_{xxxx} & = & \frac{1}{S} \sum_i (f_i - s_i)(x_i - x_0)^4w_i / r^2_i \\
     713M_{xxxy} & = & \frac{1}{S} \sum_i (f_i - s_i)(x_i - x_0)^3(y_i - y_0)w_i / r^2_i \\
     714M_{xxyy} & = & \frac{1}{S} \sum_i (f_i - s_i)(x_i - x_0)^2(y_i - y_0)^2w_i / r^2_i \\
     715M_{xyyy} & = & \frac{1}{S} \sum_i (f_i - s_i)(y_i - y_0)(y_i - y_0)^3w_i / r^2_i \\
     716M_{yyyy} & = & \frac{1}{S} \sum_i (f_i - s_i)(y_i - y_0)^4w_i / r^2_i
    498717\end{eqnarray}
    499 
    500 Applying error propagation to the above, we find:
    501 
     718where $f_i$ is the flux in a pixel; $s_i$ is the local sky value for
     719that pixel; $w_i$ is the value of the window function for the pixel;
     720$S = \sum_i (f_i - s_i) w_i$ is the window-weighted sum of the source
     721flux, used to re-normalize the moments; $r_i$ is the radius of a
     722pixel, $\sqrt{(x_i - x_0)^2 + (y_i - y_0)^2}$; The sum is performed
     723over all pixels in the aperture.  For the centroid calculation ($x_0,
     724y_0$), the peak coordinate (see~\ref{sec:peaks}) is used to define the
     725aperture and the window function; for higher order moments, the
     726centroid is used to center the window function.
     727
     728If the measured centroid coordinates ($x_0, y_0$) differs from the
     729peak coordinates be a large amount (\code{MOMENT_RADIUS}), then the
     730peak is identified as being of poor quality and is rejected.  In
     731both of these cases, it is likely that the `peak' was identified in a
     732region of flat flux distribution or many saturated or edge pixels.
     733
     734In addition to the moments above, a preliminary Kron radius and flux
     735are also calculated at this stage.  In this analysis, the 1st and
     736half-radial moments are calculated:
    502737\begin{eqnarray}
    503 \sigma_{Det}^2  & = & \sigma_{11}^2 (4 C_{11}^2) + \sigma_{20}^2 (16 C_{02}^2) + \sigma_{02}^2 (16 C_{20}^2) \\
    504 \sigma_{xn}^2   & = & \sigma_{11}^2 C_{01}^2 + \sigma_{01}^2 C_{11}^2 + \sigma_{02}^2 (4 C_{10}^2) + \sigma_{10}^2 (4 C_{02}^2) \\
    505 \sigma_{yn}^2   & = & \sigma_{11}^2 C_{10}^2 + \sigma_{10}^2 C_{11}^2 + \sigma_{20}^2 (4 C_{01}^2) + \sigma_{01}^2 (4 C_{20}^2) \\
    506 \sigma_{x}^2    & = & x^2 (\sigma_{xn}^2 / xn^2 + \sigma_{Det}^2 / Det^2) \\
    507 \sigma_{y}^2    & = & y^2 (\sigma_{yn}^2 / yn^2 + \sigma_{Det}^2 / Det^2) \\
     738M_r & = & \frac{1}{S} \sum_i (f_i - s_i)r_i \\
     739M_h & = & \frac{1}{S} \sum_i (f_i - s_i)\sqrt{r_i}
    508740\end{eqnarray}
     741Note that the window function is not applied in the calculation of
     742these moments.
     743
     744The Kron radius \citep{1980ApJS...43..305K} is defined the be
     7452.5$\times$ the first radial moment.  The Kron flux is the sum of
     746(sky-subtracted) pixel fluxes within the Kron radius.  We also
     747calculate the flux in two related annular apertures: the Kron inner
     748flux is the sum of pixel values for the annulus $R_1 < r < 2.5 R_1$,
     749while the Kron outer flux is the sum of pixel values for $2.5 R_1 < r
     750< 4 R_1$.  The first radial moment is limited at the low and high ends
     751by $R_{\rm min} < M_r < R_{\rm max}$ where $R_{\rm min}$ is the first
     752radial moment of the PSF stars, or 0.75$\times$
     753\code{MOMENTS_GAUSS_SIGMA} if that cannot be determined.  $R_{\rm
     754  max}$ is set to \code{PSF_MOMENTS_RADIUS}, the size of the moments
     755aperture.
    509756
    510757\subsection{PSF Determination}
     
    521768for example, a 2-D elliptical Gaussian:
    522769\begin{eqnarray}
    523 f(x,y) & = & I_o exp (-z) + S  \\
    524     R  & = & \frac{(x - x_o)^2}{2\sigma_x^2} + \frac{(y -
    525     y_o)^2}{2\sigma_y^2} + \sigma_{\rm xy}(x - x_o)(y - y_o)
     770f(x,y) & = & I_o e^{-z} + S  \\
     771    z  & = & \frac{x^2}{2\sigma_x^2} + \frac{y^2}{2\sigma_y^2} + \sigma_{\rm xy} x y \\
     772    x  & = & x_{\rm ccd} - x_o \\
     773    y  & = & y_{\rm ccd} - y_o
    526774\end{eqnarray}
    527775The object model will have a variety of model parameters, in this case
     
    534782The point-spread-function (PSF) of an image describes the shape of all
    535783unresolved objects in the image.  In a typical image, the shape of
    536 point sources is not well described by a single functional form;
    537 rather, the shape will vary as a function of position in the image.
    538 The PSF model therefore must describe the parameter variation as a
    539 function of the position of the object on the image.  Note that the
    540 object model consists of a certain number of parameters which are
    541 defined by the PSF model, and another set of parameters which are
    542 independent from object to object.  For the case of the elliptical
    543 Gaussian model, the PSF parameters would be the shape terms
    544 ($\sigma_x, \sigma_y, \sigma_{\rm xy}$) while the independent
    545 parameters would be the centroid, normalization and local sky values
    546 ($x_o, y_o, I_o, S$).  PSPhot uses a 2-D polynomial to specify the
    547 variation in the PSF parameters as a function of position in the
    548 image.  In the case of the elliptical Gaussian, this implies that the
    549 parameters are each a function of the object centroid coordinates:
     784point sources is not well described by a single function.  Instead,
     785the shape will vary as a function of position in the image.  The PSF
     786model therefore must describe the parameter variation as a function of
     787the position of the object on the image.  Note that the object model
     788consists of a certain number of parameters which are defined by the
     789PSF model, and another set of parameters which are independent from
     790object to object.  For the case of the elliptical Gaussian model, the
     791PSF parameters would be the shape terms ($\sigma_x, \sigma_y,
     792\sigma_{\rm xy}$) while the independent parameters would be the
     793centroid, normalization and local sky values ($x_o, y_o, I_o, S$).
     794Thus these parameters are each a function of the object centroid
     795coordinates:
    550796\begin{eqnarray}
    551797\sigma_x    & = & f_1(x,y) \\
     
    553799\sigma_{xy} & = & f_3(x,y) \\
    554800\end{eqnarray}
     801PSPhot represents the variation in the PSF parameters as a function of
     802position in the image in two possible ways, specified by the
     803configuration.  The first option is to use a 2-D polynomial which is
     804fitted to the measured parameter values across the image.  The second
     805option is to use a grid of values which are measured for objects
     806within a subregion of the image.  In the latter case, the value at a
     807specific coordinate in the image is determined by interpolation
     808between the nearest grid points.  The order of the polynomial or the
     809sampling size of the grid is dynamically determined depending on the
     810number of available of PSF stars.  In the case of the PV3 analysis,
     811the grid of values was used, with a maximum of $6\times 6$ samples per
     812GPC1 chip image.  For the earlier PV2 analysis, the maximum grid
     813sampling was $3\times 3$ per GPC1 chip image.  For the PV1 analysis,
     814the polynomial representation was used, with up to 3rd order terms.
     815The higher order representation was used for PV3 in order to follow
     816some of the observed PSF variations in the images
     817
     818% XXX specify the rule for the polynomial order and grid scale
     819% XXX discuss the improvements in the astrometric modeling PV1 - PV3
    555820
    556821PSPhot uses a single structure to represent the object model and
     
    595860registered as part of the model function code.  Another function is
    596861then used to return the appropriate function for a specific model
    597 type.  For example, the \code{psModelLookup\_GetFunction} will return
     862type.  For example, the \code{psModelLookup_GetFunction} will return
    598863the \code{psModelLookup} function for a given model type.  This
    599864mechanism makes it very easy to add new model functions into the
     
    611876the 4 independent parameters. 
    612877
    613 \note{the code may also require that two of the PSF-like parameters
    614 represent the shape in some way}.
    615 
    616878\subsubsection{PSF Candidate Object Selection}
    617879
     
    623885their peaks, as well as an approximate signal-to-noise ratio.  All
    624886objects with a S/N ratio greater than a user-defined parameter
    625 (\code{PSF\_SHAPE\_NSIGMA} ???) are selected by PSPhot, though objects
    626 which have more than a certain number of saturated pixels are excluded
    627 at this stage.  PSPhot then examines the 2-D plane of $\sigma_x,
    628 \sigma_y$ in search of a concentrated clump of objects.  To do this,
    629 it constructs an artificial image with pixels representing the value
    630 of $\sigma_x, \sigma_y$, using a user-defined scale for the size of a
    631 pixel in this artificial image (note that the units of the $\sigma_x,
    632 \sigma_y$ plane are the size of the second-moment in pixels in the
    633 original image).  A typical value for the bin size is approximately
    634 0.1 image pixels.  The binned $\sigma_x, \sigma_y$ plane is then
    635 examined to find a peak which has a significance greater than XXX.
    636 Unless the image is extremely sparse, such a peak will be well-defined
    637 and should represent the objects which are all very similar in shape.
    638 Other objects in the image will tend to land in very different
    639 locations, failing to produce a single peak.  To avoid detecting a
    640 peak from the unresolved cosmic rays, objects which have
     887(\code{PSF_SHAPE_NSIGMA} = 20.0) are selected by PSPhot, though
     888objects which have more than a certain number of saturated pixels are
     889excluded at this stage.  PSPhot then examines the 2-D plane of
     890$\sigma_x, \sigma_y$ in search of a concentrated clump of objects (see
     891Figure~\ref{fig:moment.class}).  To
     892do this, it constructs an artificial image with pixels representing
     893the value of $\sigma_x, \sigma_y$, using a user-defined scale for the
     894size of a pixel in this artificial image (note that the units of the
     895$\sigma_x, \sigma_y$ plane are the size of the second-moment in pixels
     896in the original image).  A typical value for the bin size is
     897approximately 0.1 image pixels.  The binned $\sigma_x, \sigma_y$ plane
     898is then examined to find a peak which has a significance greater than
     899XXX.  Unless the image is extremely sparse, such a peak will be
     900well-defined and should represent the objects which are all very
     901similar in shape.  Other objects in the image will tend to land in
     902very different locations, failing to produce a single peak.  To avoid
     903detecting a peak from the unresolved cosmic rays, objects which have
    641904second-moments very close to 0 are ignored.  The only danger is if the
    642905PSF is very small and too many of these objects are rejected as cosmic
     
    648911the image. 
    649912
     913\begin{figure}[htbp]
     914  \begin{center}
     915  \includegraphics[width=\hsize]{{pics/moment.class}.\plotext}
     916  \caption{\label{fig:moment.class} Illustration of PSF star selection using the FWHM derived
     917    from the second moments in $X_{\rm ccd}$ and $Y_{\rm ccd}$
     918    directions.  The dominant clump is located in this diagram.
     919    Galaxies tend to have a range of sizes and thus spread out above
     920    the stars.  Cosmic rays also have a range of sizes, with one
     921    dimension smaller than the PSF.  The red circle represents the PSF
     922    star candidates. }
     923  \end{center}
     924\end{figure}
     925
    650926\subsubsection{PSF Candidate Object Model Fits}
     927
     928% \note{link to psLibADD}
    651929
    652930All candidate PSF objects are then fitted with the selected object
    653931model, allowing all of the parameters (PSF and independent) to vary in
    654 the fit.  PSPhot uses the Levenberg-Marqardt process for the
    655 non-linear fitting.  Non-linear fitting can be very computationally
    656 intensive, particularly for if the starting parameters are far from
    657 the minimization values.  PSPhot uses the first and second moments to
    658 make a good guess for the centroid and shape parameters for the PSF
    659 models.  \note{still true? In order to minimize the impact of close
    660   neighbors, the variance values used in the fit are enhanced by a
    661   fraction of the deviation of the particular pixel value from the
    662   model guess.}  Any objects which fail to converge in the fit are
    663 flagged as invalid.
    664 
    665 \note{does the variance enhancement introduce too much bias?}
    666 
    667 \note{discuss the convergence criteria, model parameter guesses}
     932the fit.  PSPhot uses the Levenberg-Marquardt minimization technique
     933for the non-linear fitting.  Non-linear
     934fitting can be very computationally intensive, particularly for if the
     935starting parameters are far from the minimization values.  PSPhot uses
     936the first and second moments to make a good guess for the centroid and
     937shape parameters for the PSF models.  Any objects which fail to
     938converge in the fit are flagged as invalid.
    668939
    669940For the resulting collection of object model parameters, the
    670941PSF-dependent parameters of the models are all fitted as a function of
    671 position to a 2-D polynomial.  The order of this polynomial is (should
    672 be?) a user-defined parameter.  The fitting process for these
    673 polynomials is iterative, and rejects the $3-\sigma$ outliers in each
    674 of three passes.  This fitting technique results in a robust
    675 measurement of the variation of the PSF model parameters as a function
    676 of position without being excessively biased by individual objects
    677 which fail drastically.  Objects whose model parameters are rejected
    678 by this iterative fitting technique are also marked as invalid and
    679 ignored in the later PSF model fitting stages.
     942position to a 2-D polynomial.  The order of this polynomial is a
     943user-defined parameter.  The fitting process for these polynomials is
     944iterative, and rejects the $3-\sigma$ outliers in each of three
     945passes.  This fitting technique results in a robust measurement of the
     946variation of the PSF model parameters as a function of position
     947without being excessively biased by individual objects which fail
     948drastically.  Objects whose model parameters are rejected by this
     949iterative fitting technique are also marked as invalid and ignored in
     950the later PSF model fitting stages.
    680951
    681952All of the PSF-candidate objects are then re-fitted using the PSF
     
    698969correction is judged to be the best model.
    699970
    700 \subsubsection{Basic Deblending}
    701 
    702 The collection of identified peaks is examined to find peaks which are
    703 'blended', that is, they are close enough together to make the
    704 analysis of one of the sources difficult if performed in isolation.
    705 Saturated stars also result in additional peaks which are likely to be
    706 invalid; it is useful to restrict a saturated star to a single primary
    707 position with associated neighboring peaks.
    708 
    709 The deblending process first searches for any peaks which are within
    710 the image cell of another peak.  All such groups are examined,
    711 starting with the brightest source.  An isophot is found about the
    712 primary peak which is at least \code{DEBLEND\_SKY\_NSIGMA} times the sky
    713 sigma above the local background and which is otherwise
    714 \code{DEBLEND\_PEAK\_FRACTION} of the primary peak central pixel flux.
    715 Any secondary sources which are contained within this isophot are
    716 considered to be blended peaks associated with the primary peak. 
    717 
    718971\subsection{Bright Source Analysis}
    719972
    720 After a PSF model has been determined, PSPhot performs the analysis of
    721 the bright objects in the image.  In this stage, all of the objects
    722 with an estimated signal to noise (based on the moments analysis)
    723 greater than a user-set threshold are analysed and subtracted from the
    724 image.  An optional successive stage then finds fainter sources and
    725 measures them as well (see Faint Source Analysis,
    726 Section~\ref{faintsources}).  In the bright source analysis stage, two
    727 major varients are available.  In the primary version, all objects are
    728 examined (in decending order of brightness) and an appropriate models
    729 is determined for each object which is then subtracted; in the
    730 alternate version, the objects are examined (in decending order of
    731 brightness) and the PSF-like objects subtracted first, then the
    732 extended objects are analysed on a second pass.
     973%% \subsubsection{Very Bright Stars}
     974%%
     975%% The PSF modeling code fails to fit the wings of highly saturated stars
     976%% if the core of the star is too contaminated by saturated pixels. For
     977%% stars with estimated instrumental magnitudes brighter than XXX, we fit
     978%% and subtract a radial profile modeled with a spline (?).
    733979
    734980\subsubsection{Fast Ensemble PSF Fitting}
     
    737983convenient to subtract off all of the sources, at least as well as
    738984possible at this stage.  We make the assumption that all sources are
    739 PSF-like.  We also assume their position can be taken as the peak of a
    740 2D quadratic function fitted to the peak pixel and its surrounding 8
    741 pixels.  A single linear fit is used to simultaneously measure all
    742 source fluxes.  Since the local sky has been subtracted, this
    743 measurement assumes the local sky is zero. 
    744 
     985PSF-like.  If the centroid of the source has been determined, we use
     986this value for its position; otherwise, we use the interpolated
     987position of the peak. A single linear fit is used to simultaneously
     988measure all source fluxes.  Since the local sky has been subtracted,
     989this measurement assumes the local sky is zero.  We can write a single
     990$\chi^2$ equation for this image:
    745991\[
    746 \chi^2 = \sum_{\rm pixels} (F_{x,y} - \sum_{\rm sources} A_i PSF[x,y])^2
     992\chi^2 = \sum_{\rm pixels} (F_{x,y} - \sum_{\rm sources} A_i P[x_0,y_0])^2
    747993\]
     994where $F_{x,y}$ is image flux for each pixel, $P[x_0,y_0]$ is the PSF
     995model realized at the position of source $i$, and $A_i$ is the
     996normalization for the source.
    748997
    749998Minimizing this equation with respect to each of the $A_i$ values
     
    7511000\[ M_{i,j} \bar{A_i} = \bar{F_j}\]
    7521001where $\bar{A_i}$ is the vector of $A_i$ values, the elements of
    753 $M_{i,j}$ consist of the dot product of the unit-flux PSF for source
    754 $i$ and source $i$, and $\bar{F_j}$ is the dot product of the
    755 unit-flux PSF for source $i$ with the pixels corresponding to source
    756 $i$.  The dot products are calculated only using pixels within the
     1002$M_{i,j}$ consist of the dot products of the unit-flux PSF for source
     1003$i$ and source $j$, and $\bar{F_j}$ is the dot product of the
     1004unit-flux PSF for source $j$ with the pixels corresponding to source
     1005$j$.  The dot products are calculated only using pixels within the
    7571006source apertures.  Since most sources have no overlap with most other
    7581007sources, this matrix equation results in a very sparse, mostly
    7591008diagonal square matrix.  The dimension is the number of sources,
    760 likely to be 1000s or 10,000s.  Such a matrix does not lend itself to
    761 direct inversion.  However, an interative solution quickly yields a
    762 result with sufficient accuracy.  In the iterative solution, a guess
    763 at the solution is made; the guess is multiplied by the matrix, and
    764 the result compared with the observed vector $\bar{F_j}$.  The
    765 difference is used to modify the initial guess. This proces is
    766 repeated several times to achieve a good convergence. 
     1009likely to be 1000s or 10,000s.  Direct inversion of the matrix would
     1010be computationally very slow.  However, an interative solution quickly
     1011yields a result with sufficient accuracy.  In the iterative solution,
     1012a guess at the solution $\bar{A}$ is made assuming $M_{i,j}$ is purely
     1013diagonal; the guess is multiplied by $M_{i,j}$, and the result
     1014compared with the observed vector $\bar{F_j}$.  The difference is used
     1015to modify the initial guess.  This proces is repeated several times to
     1016achieve a good convergence.
    7671017
    7681018Once a solution set for $A_i$ is found, all of the objects are
     
    7711021\subsubsection{PSF Model applied to detected objects}
    7721022
     1023% \note{review the discussion below}
     1024
    7731025Once a PSF model has been selected for an image, PSPhot attempts to
    7741026fit all of the detected objects, above a user-defined signal-to-noise
    775 ratio (\note{KEYWORD}) with the PSF model.  For these fits, the
    776 dependent parameters are fixed by the PSF model and only the 4
    777 independent object model parameters are allowed to vary in the fit.
    778 PSPhot again uses the Levenberg-Marqardt process for the non-linear
    779 fitting.  The objects are fitted in their S/N order, starting with the
    780 brightest and working down to the user-specified limit.
    781 
    782 Once a solution has been achieved, PSPhot attempts to judge the
    783 quality of the PSF model as a representation of the object shape.  To
    784 do this, it calculates the next step of the minimization {\em allowing
    785 the shape parameters to vary}.  This step, essentially the
    786 Gauss-Newton minimization distance from the current local minimum,
     1027ratio with the PSF model.  For these fits, the dependent parameters
     1028are fixed by the PSF model and only the 4 independent object model
     1029parameters are allowed to vary in the fit.  PSPhot again uses
     1030Levenberg-Marquardt minimization for the non-linear fitting.  The
     1031objects are fitted in their S/N order, starting with the brightest and
     1032working down to the user-specified limit.
     1033
     1034Once a solution has been achieved for an object, PSPhot attempts to
     1035judge the quality of the PSF model as a representation of the object
     1036shape.  To do this, it calculates the next step of the minimization
     1037{\em allowing the shape parameters to vary}.  This step, essentially
     1038the Gauss-Newton minimization distance from the current local minimum,
    7871039should be very small if the object is well represented by the PSF, but
    7881040large if the PSF is not a good representation of the object flux.  The
     
    7911043elliptical Gaussian, these two parameters are $\sigma_x$ and
    7921044$\sigma_y$.  For a generic model, the shape parameters may be defined
    793 differently, but the should always be two parameters which scale the
    794 object size in two dimensions (what about a polar-coordinate form?)
    795 Currently, PSPhot requires the two relevant shape parameters to be the
    796 first two dependent parameters in the list of model parameters (ie,
    797 parameters 4 \& 5).
     1045differently, but there should always be two parameters which scale the
     1046object size in two dimensions.  Currently, PSPhot requires the two
     1047relevant shape parameters to be the first two dependent parameters in
     1048the list of model parameters (ie, parameters 4 \& 5).
    7981049
    7991050The expected distribution of the variation of the two shape parameters
    8001051will be a function of the signal-to-noise of the object in question
    8011052and the value of the shape parameter itself.  The expected standard
    802 deviation on the shape parameter is, eg, $\sigma_x / {\rm SN}$.  If
     1053deviation on the shape parameter is, eg, $\sigma_x / {\rm S/N}$.  If
    8031054the object is well-represented by the PSF, then the shape parameter
    8041055values should be close to their minimization value.  We can thus ask,
     
    8411092distribution, the remaining flux should be below 1 $\sigma$
    8421093significance.  In practice the cores of bright stars are poorly
    843 represented and may have larger residual significance. \note{in future
    844 work, we may choose to enhance the variance to minimize detection of
    845 objects in the residuals of brighter objects}.
     1094represented and may have larger residual significance.
    8461095
    8471096\subsubsection{Blended Sources}
     
    8671116available non-PSF model or models.
    8681117
    869 \note{better description of the acceptance criteria; the FLT model is
    870   tried before the DBL is accepted or rejected}.
     1118\subsubsection{Source Size Assessment}
     1119\label{sec:source.size}
     1120
     1121After the PSF model has been fitted to all sources, and the Kron flux
     1122has been measured for all sources, PSPhot uses these two measurements,
     1123along with some additional pixel-level analysis, to determine the size class
     1124of the object.  If the object is large compared to a PSF, it is
     1125considered to be {\em extended} and will be
     1126fitted with a galaxy model (or possibly another type of extended
     1127source model in special cases).  If the object is small compared to a
     1128PSF, it is considered to be a {\em cosmic ray} and masked.
     1129
     1130Extended sources are identified as those for which the Kron magnitude is
     1131significantly brighter than the PSF magnitude when compared to a PSF
     1132star.  The value $dMagKP = m_{\rm Kron} - m_{\rm PSF}$, the difference between the PSF
     1133and Kron magnitudes, is calculated for each object.  The median of
     1134$dMagKP$ is calculated for the PSF stars.  This median is subtracted
     1135from $dMagKP$ for each star.  The result is divided by the quadrature
     1136error of the PSF and Kron magnitudes and called \code{extNsigma}.  If
     1137\code{extNsigma} is larger than \code{PSPHOT.EXT.NSIGMA.LIMIT} (3.0),
     1138the object is considered to be extended.
     1139
     1140Cosmic Rays are identified by a combination of the Kron magnitude and
     1141the second-moment width of the object in the minor axis direction.
     1142The second-moment in the minor axis direction is calculated from
     1143$M_{xx}, M_{xy}, M_{yy}$ as follows:
     1144\[
     1145M_{\rm minor} = \frac{1}{2}(M_{xx} + M_{yy}) - \frac{1}{2}\sqrt{(M_{xx} - M_{yy})^2 + 4 M_{xy}^2}
     1146\]
     1147If $M_{\rm minor} < 1.2$ pixels$^2$ and the instrumental Kron
     1148magnitude is $< -5.5$, then the object is identified as a cosmic ray
     1149and the associated pixels are masked.
    8711150
    8721151\subsubsection{Non-PSF Objects}
     
    8801159
    8811160PSPhot will use the user-selected galaxy model to attempt the galaxy
    882 model fits.  In the configuration system, the keyword \code{GAL\_MODEL}
     1161model fits.  In the configuration system, the keyword \code{GAL_MODEL}
    8831162is set to the model of interest.  All suspected extended objects are
    8841163fitted with the model, allowing all of the parameters to float.  The
     
    9061185not modified. 
    9071186
    908 \note{we have no code yet to select the best of several models for a
    909   given objects.  The relative value of the Chi-Square is the obvious
    910   test in this case}.
    911 
    9121187\subsection{Faint Sources}
    913 
    914 \note{this is not done : should use the ensemble PSF fitting to fit
    915   just the new significant peaks}
    9161188
    9171189After a first pass through the image, in which the brighter sources
     
    9251197
    9261198The objects which are measured in this faint-object stage are clearly
    927 low significance detections.  A typical threshold for the bright
    928 object analysis would S/N of 5 - 10.  The lower limit cutoff for the
    929 faint object analysis would typically be S/N of 2 - 4.  In this stage,
    930 PSPhot can perform one of three types of analysis.  The difference
    931 between these options is one of speed vs detail.
    932 
    933 In the first option, PSPhot can repeat the analysis described above in
    934 sections XXX and XXX, performing a PSF fit followed by a non-PSF fit
    935 to the objects which are not PSF-like, and subtracting them.  The
    936 advantage of this option is that the faint objects are treated
    937 identically to the bright objects, and all potential parameters are
    938 measured, even for marginally extended sources.  The disadvantage of
    939 this option is that the low signal-to-noise of the objects in this
    940 stage limits the amount of information which can be extracted from
    941 them.  The marginal gain may not be worth the large expense of
    942 processing time.
    943 
    944 In the second option, PSPhot can perform only the PSF model fit to the
    945 remaining peaks, but ignore any further questions of the shape of the
    946 objects.  The advantage of this option is that it is substantially
    947 faster than performing the more complex (and less stable)
    948 multi-parameter non-linear fits on all faint objects.  On the
    949 downside, less information is learned about the objects.
    950 
    951 Finally, PSPhot can simply ignore the fitting process and instead
    952 glean information about the fainter sources on the basis of the peak
    953 characteristics.  In this option, the image is smoothed with the PSF
    954 model, and the peak for each object is measured.  The peak flux and
    955 the local peak curvature theoretically give sufficient information to
    956 recover the object flux, the centroid coordinates, and the centroid
    957 errors.  The advantage of the stage is speed, especially for the very
    958 faintest levels: if the lower limit is not sufficiently faint, the
    959 time spent in performing the smoothing (3 FFTs) cannot make up for the
    960 time which would have been spent applying the PSF model to the peaks.
    961 The downside of this method is an increased sensitivity to the local
    962 sky model (the local sky must be correctly subtracted) and fewer
    963 constraints on the quality of the detection (no Chi-Square is
    964 measured, for example).
    965 
    966 \note{In the ideal case, if we were only interested in detecting PSFs,
    967 and we had a good model for the PSF, we could optimally find the
    968 sources by smoothing the image and the variance image with the PSF model.
    969 \em write out the description of Nick's optimal PSF finding}.
    970 
    971 PSPhot allows the user to select between these three options for the
    972 analysis of the faint sources.  Three separate user-controlled
    973 signal-to-noise ratio limits are defined.  One specifies the depth to
    974 which the PSF / non-PSF analysis is performed.  A second (which must
    975 be smaller) specifies the depth to which only the PSF is fitted.  A
    976 third specifies the depth to which the analysis is performed using on
    977 the peak statistics.  If two of these are identical, then certain of
    978 these options are simply skipped.  For example, if the peak analysis
    979 threshold is set to the same value as the PSF-only threshold, no peak
    980 analysis is performed.
     1199low significance detections.  The PV3 threshold for the bright object
     1200analysis is a signal-to-noise of 20.  The lower limit cutoff for the
     1201faint object analysis in PV3 is a signal-to-noise of 5.0.  Objects
     1202detected in the faint object stage are fitted with the PSF model using
     1203the linear, ensemble fitting process.
    9811204
    9821205\subsection{Aperture Correction Measurement}
     
    10271250number of very bright stars is limited in any image, and of course the
    10281251brighter stars are more likely to suffer from non-linearity or
    1029 saturation. 
    1030 
    1031 \note{this discussion sucks: put in some more details of my point:
    1032   amplitude of systematic vs random sky errors}
    1033 
    1034 How important is this effect?  Consider a typical bright object with a
    1035 flux of (say) 40,000 counts in an image of background 1000 counts per
    1036 pixel, with FWHM of 4 pixels.  In principle, the flux of this object
    1037 should be measurable with an accuracy of roughly 0.57\%
    1038 ($\frac{\sqrt{40000 + 1000 \times 12}}{40000}$).  However, the
    1039 measurement of the sky is limited at some finite level by Poisson
    1040 statistics.  If we are required to use an aperture of (say) 25 pixels
    1041 in radius (eg, 5 arcseconds for an 0.2 arcsec / pixel detector), and
    1042 we have an annulus of twice this radius to measure the local sky, then
    1043 we will have an error of XXX.
    1044 
    1045 \note{outline the variation of {\em ApResid} as a function of
    1046 magnitude}.
    1047 
    1048 PSPhot measures the aperture correction ({\em ApResid}) for every PSF
    1049 candidate object, then calculates the trend of this correction as a
    1050 function of the magnitude.  This trend is fitted with a line.  The
    1051 resulting function can be used to determine the effective aperture
    1052 correction for an infinite flux object and the average bias inherent
    1053 in the sky measurement for the image.  The scatter of the
    1054 PSF-candidate object measurements about this trend is a measure of how
    1055 well we can measure photometry from the image by applying the specific
    1056 PSF model.  The slope of this trend is a measure of the bias in the
    1057 local sky measurment for each object.  In principal, the measured sky
    1058 levels could be modified by this bias.  More generally, the measured
    1059 bias in a collection of images could be used to improve the model
    1060 fitting or sky fitting portion of the software the remove the bias
    1061 term.
     1252saturation.  PSPhot measures the aperture correction ({\em ApResid})
     1253for every PSF candidate object and applies this correction to the PSF
     1254model photometry.
     1255
     1256% How important is this effect?  Consider a typical bright object with a
     1257% flux of (say) 40,000 counts in an image of background 1000 counts per
     1258% pixel, with FWHM of 4 pixels.  In principle, the flux of this object
     1259% should be measurable with an accuracy of roughly 0.57\%
     1260% ($\frac{\sqrt{40000 + 1000 \times 12}}{40000}$).  However, the
     1261% measurement of the sky is limited at some finite level by Poisson
     1262% statistics.  If we are required to use an aperture of (say) 25 pixels
     1263% in radius (eg, 5 arcseconds for an 0.2 arcsec / pixel detector), and
     1264% we have an annulus of twice this radius to measure the local sky, then
     1265% we will have an error of XXX.
     1266%
     1267% \note{outline the variation of {\em ApResid} as a function of
     1268% magnitude}.
     1269
     1270%%% PSPhot measures the aperture correction ({\em ApResid}) for every PSF
     1271%%% candidate object, then calculates the trend of this correction as a
     1272%%% function of the magnitude.  This trend is fitted with a line.  The
     1273%%% resulting function can be used to determine the effective aperture
     1274%%% correction for an infinite flux object and the average bias inherent
     1275%%% in the sky measurement for the image.  The scatter of the
     1276%%% PSF-candidate object measurements about this trend is a measure of how
     1277%%% well we can measure photometry from the image by applying the specific
     1278%%% PSF model.  The slope of this trend is a measure of the bias in the
     1279%%% local sky measurment for each object.  In principal, the measured sky
     1280%%% levels could be modified by this bias.  More generally, the measured
     1281%%% bias in a collection of images could be used to improve the model
     1282%%% fitting or sky fitting portion of the software the remove the bias
     1283%%% term.
    10621284
    10631285PSPhot allows a collection of PSF model functions to be tried on all
     
    10661288value for the ApResid scatter is then used by PSPhot as the best PSF
    10671289model for this image.  The number of models to be tested is specified
    1068 by the configuration keyword \code{PSF\_MODEL\_N}.  The configuration
    1069 variables \code{PSF\_MODEL\_0}, \code{PSF\_MODEL\_1}, through
    1070 \code{PSF\_MODEL\_N - 1} specify the names of the models which should be
     1290by the configuration keyword \code{PSF_MODEL_N}.  The configuration
     1291variables \code{PSF_MODEL_0}, \code{PSF_MODEL_1}, through
     1292\code{PSF_MODEL_N - 1} specify the names of the models which should be
    10711293tested.
    10721294
    1073 \subsubsection{Types of Object / PSF models currently available}
    1074 
    1075 \note{the discussion of the model types needs to be extended}
    1076 
     1295Several likely PSF model classes are available within \code{psphot}:
    10771296\begin{itemize}
    1078 \item GAUSS  : Pure elliptical Gaussian
    1079 \item PGAUSS : polynomial approximation to a Gaussian (PGAUSS)
    1080 \item QGAUSS : power law with variable exponential term
    1081 \item SGAUSS :
     1297\item Gaussian : $f = I_0 e^{-z}$
     1298\item Pseudo-Gaussian : $f = I_0 (1 + z + \frac{1}{2} z^2 + \frac{1}{6} z^3)^{-1}$ \code{[PGAUSS]}
     1299\item Variable Power-Law : $f = I_0 (1 + z + z^{\alpha})^{-1}$ \code{[RGAUSS]}
     1300\item Steep Power-Law : $f = I_0 (1 + \kappa z + z^{2.25})^{-1}$ \code{[QGAUSS]}
     1301\item PS1 Power-Law : $f = I_0 (1 + \kappa z + z^{1.67})^{-1}$ \code{[PS1_V1]}
    10821302\end{itemize}
    1083 
    1084 \note{discuss the stability issues with the galaxy model(s)}
     1303where $z \propto r^2$ ($z = \frac{x^2}{2\sigma_x^2} +
     1304\frac{y^2}{2\sigma_y^2} + \sigma_{\rm xy} x y $).  The Pseudo-Gaussian
     1305is a Taylor expansion of the Gaussian and is used by Dophot
     1306\citep{1993PASP..105.1342S}.  The latter profiles are similar to the
     1307Moffat profile form \citep{1969AA.....3..455M,1983AA...126..278B},
     1308with small differences.  For the PS1 GPC1 analysis, we used the
     1309\code{PS1_V1} model, which we found by experimentation to match well
     1310to the observed profiles generated by PS1.
     1311Figure~\ref{fig:radial.profiles} shows example radial profiles for
     1312moderately bright stars in fairly good (0.9 arcsec) and poor (2.2
     1313arcsec) seeing.  Using a fixed power-law exponent results in somewhat
     1314faster profile fitting compared to the variable power-law exponent
     1315model.
     1316
     1317% moffat : 1969A&A.....3..455M
     1318% buonanno : 1983A&AS...51...83B
     1319
     1320\begin{figure}[htbp]
     1321  \begin{center}
     1322  \includegraphics[width=\hsize]{{pics/radial.profiles}.\plotext}
     1323  \caption{\label{fig:radial.profiles} Radial profiles of stellar images from PS1.  These two
     1324    profiles illustrate the radial trend of the PS1 PSFs for a star
     1325    with FWHM 0.9 arcsec (red) and 2.2 arcsec (blue).  The black line
     1326    shows the PSF model with radial trend of the form $(1 + \kappa r^2 + r^{3.33})^{-1}$.}
     1327  \end{center}
     1328\end{figure}
     1329
     1330\subsection{Radial Profiles}
     1331
     1332Galaxies with regular profiles, such as elliptical galaxies and
     1333regular spiral galaxies, may be described as primarily a radial
     1334surface brightness profile, with additional structure acting as a
     1335perturbation on that profile.  For many galaxies, the azimuthal shape
     1336at a given isophotal level may be described as an elliptical contour.
     1337To first order, a galaxy may be well decribed with a single elliptical
     1338contour and radial profile. 
     1339
     1340In order to facilitate the Petrosian photometry analysis below, PSPhot
     1341generates a radial profile for each suspected galaxy.  This analysis
     1342starts by generating a radial profile in 24 azimuthal segments.  Near
     1343the center of the galaxy, the profile is defined for radial
     1344coordinates in steps of 1 pixel, with the closest pixel values
     1345interpolated to that radial position.  Further from the center,
     1346profile is defined using the median of the pixels landing in an
     1347annular segment of size $\delta R = r \sin \theta$, rounded up to the
     1348nearest integer pixel value.  The median of all pixels within a
     1349rectangular approximation to the radial wedge is used.
     1350
     1351The resulting 24 radial profiles are subject to contamination from
     1352neighboring sources or to NAN values from masked pixels.  To clean the
     1353profiles, pairs of radial profiles from opposite sides of the source
     1354are compared.  Any masked values are replaced by the corresponding
     1355value in the other profile.  The minimum of both profiles is the kept
     1356for both profiles.  The result of this analysis is a set of profiles
     1357of the form $f_i(r_i)$.  In this case, $f_i$ is effectively the
     1358surface brightness for each radius in instrumental counts per pixel.
     1359
     1360The surface brightness profiles are then used to define the radial
     1361contour at a specific isophotal level.  This contour will be used to
     1362rescale the radial profiles into a single set of profiles normalized
     1363by the elliptical contour.  This contour is defined by determining the
     1364median radius for profile bins with surface brightness in the range
     1365$F_{\rm min} + 0.1 F_{\rm range}$ to $F_{\rm min} + 0.5 F_{\rm
     1366  range}$.  The result of this analysis is a value for the radius as a
     1367function of the angle for a well-defined surface brightness regime.
     1368We then determine the elliptical shape parameters for this elliptical
     1369contour: $R_{\rm major}, R_{\rm minor}, \theta$.  This ellipse is then
     1370used to redefine a single radial profile normalized by the elliptical
     1371contour:
     1372\[
     1373\rho = \sqrt{\frac{x^2}{S^2_{xx}} + \frac{y^2}{S^2_{yy}} + x y S_{xy}} \\
     1374\]
     1375
     1376The surface brightness values are sampled at a number of radial
     1377annuli, with the radii defined in the configuration
     1378(\code{RADIAL.ANNULAR.BINS.LOWER} \&
     1379\code{RADIAL.ANNULAR.BINS.UPPER}).  For each source, the resulting
     1380surface brightness profile is saved in the output cmf-file as an
     1381N-element value in the FITS table (\code{PROF_SB}).  The flux at each
     1382radial position and the fill-factor (fraction of pixels used to the
     1383total possible) as also saved as equal-length vectors in the FITS
     1384table (\code{PROF_FLUX} and \code{PROF_FILL}).  The values of the
     1385radial bins are saved in the cmf header (\code{RMIN_NN},
     1386\code{RMAX_NN}).
     1387
     1388% \note{these profiles are not saved in PSPS}
     1389
     1390\subsection{Petrosian Radii and Magnitudes}
     1391
     1392\cite{1976ApJ...209L...1P} defined an adaptive aperture based on a
     1393ratio of surface brightnesses.  The motivation is to define an
     1394aperture which can be determined for galaxies without significant
     1395biases as a function of distance.  Since surface brightness in a
     1396resolved object is conserved, using a ratio of surface brightness to
     1397define a spatial scale results in a spatial scale which is constant
     1398regardless of galaxy distance.
     1399
     1400To measure the Petrosian radius and flux, we start by defining a
     1401series of radial apertures with power-law spacing: $r_{i + 1} = 1.25
     1402r_i$.  We calculate the surface brightness for the annulus from $r_i -
     1403r_{i+1}$ by calculating the median of the values in the range $r_i /
     1404\sqrt{1.25}$ to $r_{i+1} \sqrt{1.25}$ and dividing the the effective
     1405area of the annulus corresponding to $r_i - r_{i+1}$. 
     1406
     1407For any annulus $i$ spanning the radii $r_{\rm min}$ to $r_{\rm max} =
     1408\beta r_{\rm min}$, the
     1409Petrosian Ratio for that annulus is defined as the ratio of the
     1410surface brightness in the annulus to the average surface brigthness
     1411within $r_{\rm max}$.  The Petrosian Radius is defined to be $r_{\rm
     1412  max}$ for the annulus for which the Petrosian Ratio = 0.2, i.e., the
     1413point on the galaxy radial profile at which the surface brightness is
     141420\% of the average surface brightness at that point. 
     1415
     1416We determine the Petrosian Radius for the galaxy by quadratic
     1417interpolation between the last two of the fixed annuli with Petrosian
     1418Ratio $> 0.2$ and the first annulus with Petrosian Ratio $< 0.2$.  In
     1419general, the Petrosian Ratio for a galaxy with a regular morphology
     1420(spiral or elliptical) is falling monotonically, so this interpolation
     1421is unambiguous.  However, irregular galaxy morphologies, noise, and/or
     1422significant masking can cause the Petrosian Ratio to have rises as
     1423well as drops.  We track the Petrosian Ratio until the value is no
     1424longer significant ($\sigma_{\rm Ratio} < 2 {\rm Ratio}$).  If the
     1425Petrosian Ratio drops below 0.2 for more than one radius, we choose
     1426the largest such radius. 
     1427
     1428Once the Petrosian Radius has been determined, we can now measure the
     1429Petrosian Flux : this is defined to be the total flux within an
     1430aperture corresponding to 2 $\times$ the Petrosian Radius.  Using the
     1431Petrosian Flux, we can calculate two other interesting radii: $R_{50}$
     1432and $R_{90}$, the radii inside which 50\% and 90\% of the total
     1433Petrosian flux is contained. 
     1434
     1435\subsection{Radial Profile Wings}
     1436
     1437We attempt to measure the radial profile of sources in order to find
     1438the radius at which the flux of the object is matches the sky.  In
     1439this analysis, a series of up to 25 radial bins with power-law spacing
     1440are defined and the flux of the object in each annulus is measured.
     1441The ``sky radius'' is defined to be the radius at which the (robust
     1442median) flux in the annulus is within 1 $\sigma$ of the local sky
     1443level.  If this limit is not reached before the slope of the flux from
     1444one annulus to the next is less than a user-defined limit, then the
     1445annulus at which the slope reaches this limit is used to define the
     1446sky radius.  These values are saved in the output smf / cmf files, but
     1447not sent to the PSPS.  The sky radius value is used below in the
     1448calculation of the kron magnitude.
     1449
     1450\subsection{Kron Magnitudes}
     1451
     1452Preliminary Kron radius and flux values \citep{1980ApJS...43..305K}
     1453are calculated soon after sources are detected (Section~\ref{sec:moments}).
     1454However, these preliminary values are not accurate due to the
     1455window-functions applied.  After sources have been characterized and
     1456the PSF model is well-determined, the Kron parameters are
     1457re-calculated more carefully.  In this version of the calculation, the
     1458image is first smoothed by Gaussian kernel with $\sigma = 1.7$ pixels,
     1459corresponding to a FWHM of 1.0\arcsec\ in the PS1 stack images.  Next,
     1460the Kron radius is determined in an iterative process: the first
     1461radial moment is measured using the pixels in an aperture 6$\times$
     1462the first radial moment from the previous iteration.  On the first
     1463iteration, the sky radius is used in place of the first radial moment.
     1464By default, 2 iterations are performed.  The Kron radius is defined
     1465the be 2.5$\times$ the first radial moment.  The Kron flux is the sum
     1466of pixel fluxes within the Kron radius.  We also calculate the flux in
     1467two related annular apertures: the Kron inner flux is the sum of pixel
     1468values for the annulus $R_1 < r < 2.5 R_1$, while the Kron outer flux
     1469is the sum of pixel values for $2.5 R_1 < r < 4 R_1$.
     1470
     1471Two details in the calculation above should be noted.  First, for
     1472faint sources, noise in the measurement of the 1st radial moment may
     1473result in an excessively small aperture for the successive
     1474calculations.  The window used for the calculations is constrained to
     1475be at least the size of the aperture based on the PSF stars
     1476(Section~\ref{sec:moments}).  At the other extreme, noise may make the radius
     1477grow excessively, resulting in an unrealistically low effective
     1478surface brightness.  The aperture is constrained to be less than a
     1479maximum value defined such that the minimum surface brightness is
     14801/2$times$ the effective surface brightness of a source detected at the
     1481$5\sigma$ limit.
     1482
     1483Second, the measurement of the 1st radial moment includes a filter to
     1484reduce contamination from outlier pixels.  Pairs of pixels on
     1485opposites sides of the central pixel are considered together.  The
     1486geometric mean of the two fluxes is used to replace the flux values.
     1487If the object has 180\degree\ symmetry, this operation has no impact.
     1488However, if one of the two pixels is unusually high, the value will be
     1489surpressed by the matched pixel on the other side.  This trick has the
     1490effect of reducing the impact of pixels which include flux from near
     1491neighbors.
     1492
     1493\subsection{Convolved Galaxy Model Fits}
     1494
     1495In the galaxy model fittting stage, sources which meet certain
     1496criteria are fitted with analytical models for galaxies.  Three
     1497traditional analytical galaxy models are implemented in \code{psphot}
     1498and used in the PV3 analysis:
     1499\begin{itemize}
     1500\item Exponential profile : $f = I_0 e^{-\rho}$
     1501\item DeVaucouleur profile \citep{1948AnAp...11..247D}: $f = I_0 e^{-\rho^{1/4}}$
     1502\item Sersic \citep{1963BAAA....6...41S} : $f = I_0 e^{-\rho^{1/n}}$
     1503\end{itemize}
     1504where $\rho$ is a normalized radial term: $\rho =
     1505\sqrt{\frac{x^2}{R^2_{xx}} + \frac{y^2}{R^2_{yy}} + x y R_{xy}}$.  The
     1506terms ($R_{xx}$, $R_{yy}$ , $R_{xy}$) describe the elliptical contour
     1507and the profile scale in all three models and the coordinates $x$ \&
     1508$y$ are determined relative to the centroids ($x,y = X_{\rm chip} -
     1509x_0, Y_{\rm chip} - y_0$).  Including the normalization ($I_0$) and a
     1510local sky value, the Exponential and DeVaucouleur profiles have 7 free
     1511parameters and the Sersic profile has the additional free parameter of
     1512the Sersic index $n$.
     1513
     1514In this stage, the galaxy model is convolved with an approximation to
     1515our best guess for the PSF model at the location of the galaxy.  For
     1516the PV3 analysis, all sources detected in the 'bright source' analysis
     1517step ($S/N > 20$) were fitted with all three galaxy models, unless (a)
     1518the morphological test identified the source as a likely cosmic ray
     1519(Section~\ref{sec:source.size}) or (b) the peak of the PSF profile was
     1520above the saturation limit for the chip \citep[see the discussion in
     1521][ regarding the masking of saturated pixels]{waters2017}.  Sources in
     1522the denser portions of the Galactic plane and bulge were not included
     1523in the analysis.  This restriction limited the total time spent on the
     1524galaxy modeling analysis at the expense of galaxy photometry in the
     1525plane (though Kron photometry is available for those objects).  The
     1526Galactic Plane region was defined by $|b| > b_{\rm min}$ where $b_{\rm
     1527  min} = b_0 + r_b e^{\frac{-l^2}{2 \sigma_b^2}}$.  For the PV3
     1528analysis, $b_0 = $20\degree, $r_b = $15\degree, $\sigma_b = $50\degree.
     1529
     1530%  \note{need a discussion of the detector saturation behavior
     1531
     1532% \note{more detail below?} 
     1533
     1534Before the non-linear fitting may be performed, it is necessary to
     1535determine initial values for the parameters to be fitted.  For each of
     1536the three model types, the position determined from the PSF fitting
     1537analysis is used as the initial centroid $x_0,y_0$.  A guess for the
     1538terms ($R_{xx}$, $R_{yy}$ , $R_{xy}$) is generated based on the second
     1539moments.  The guess does not attempt to use the PSF model to adjust the
     1540($R_{xx}$, $R_{yy}$ , $R_{xy}$) values; it was found that such a guess
     1541tended to be too small and resulted in more iterations rather than
     1542fewer. The 1st radial moment (see
     1543\ref{sec:moments}) is used to estimate the effective radius of the
     1544model based on the results of Graham \& Driver (2005, Table 1).  They
     1545quantive the relationships between the first radial moment used to
     1546calculated a Kron Magnitude and the effective radius for different
     1547Sersic index values, $n$.  Since the Exponential and DeVaucouleur
     1548models are equivalent to Sersic models with $n$ = 1 and 4,
     1549respectively, this work can be used to generate the initial effective
     1550radius values for all 3 model types.  Once the effective radius is
     1551chosen, the second moments are used to define the aspect ratio and
     1552position angle of the elliptical contour.  The Kron flux is used to
     1553generate a guess for the normalization, applying an appropriate scale
     1554factor based on the ($R_{xx}$, $R_{yy}$ , $R_{xy}$) values, generated
     1555by integrating normalized Sersic models and determining the
     1556relationship between the central intensity and the integrated flux as
     1557a function of the Sersic index.
     1558
     1559The PSF-convolved galaxy model fitting analysys uses the
     1560Levenberg-Marquardt minimization method to determine the best fit.  In this
     1561process, the $\chi^2$ value to be minimized is:
     1562\[
     1563\chi^2 (\bar{a}) = \sum_p \frac{1}{\sigma_p^2} \left[I_p - M_p(\bar{a}) \otimes \mbox{PSF} \right]^2
     1564\]
     1565where $I_p$ represents the pixel values in the image (within some
     1566aperture) and $M_p(\bar{a})$ represents the unconvolved galaxy model, a
     1567function of a number of parameters $\bar{a}$, which is then convolved
     1568with the PSF model.
     1569
     1570We simplify this by defining:
     1571\begin{eqnarray}
     1572f_p (a_m)         & = & \frac{1}{\sigma_p} (I_p - M_p \otimes \mbox{PSF}) \\
     1573\end{eqnarray}
     1574
     1575To determine the minimization, we need the gradient and laplacian of
     1576$\chi^2$ with respect to the model parameters, $a_m$:
     1577\begin{eqnarray}
     1578\chi^2 (\bar{a})  & = & \sum_p f_p^2  \\
     15792 \nabla   \chi^2  & = & \sum_p f_p \frac{\partial f_p}{\partial a_m} \\
     1580\nabla^2 \chi^2  & \approx & H_{m,n} \\
     15812 H_{m,n}  & = & \sum_p \frac{\partial f_p}{\partial a_m} \frac{\partial f_p}{\partial a_n}
     1582\end{eqnarray}
     1583where we have approximated the Laplacian with the Hessian matrix,
     1584$H_{m,n}$ by dropping the second-derivatives (which are assumed to be
     1585a small perturbation).  Since
     1586\[
     1587\frac{\partial f_p}{\partial a_m} = -\frac{1}{\sigma_p}\frac{\partial M_p \otimes \mbox{PSF}}{\partial a_m}
     1588\]
     1589and since the order of the derivative and convolution may be
     1590exchanged, we can write these in terms of the convolved image of the
     1591model and the convolved images of the derivatives of the model $M_p$ with respect to the model parameters, $a_m$:
     1592\begin{eqnarray}
     1593\mathcal{M}_{p}   & = & M_p \otimes \mbox{PSF} \\
     1594\mathcal{M}^\prime_{p,m} & = & \frac{\partial M_p}{\partial a_m} \otimes \mbox{PSF} \\
     15952 \nabla \chi^2    & = & -\sum_p \frac{I_p - \mathcal{M}_p}{\sigma_p} \mathcal{M}^\prime_{p,m} \\
     15962 H_{m,n}  & = &  \sum_p \frac{1}{\sigma_p^2} \mathcal{M}^\prime_{p,m} \mathcal{M}^\prime_{p,n}
     1597\end{eqnarray}
     1598The gradient vector and Hessian matrix are used in the
     1599Levenberg-Marquardt minimization analysis using the standard
     1600techinique of determining a step from the current set of model
     1601parameters to a new set by solving the matrix equation:
     1602\[
     1603(1 + \lambda_{m,n}) H_{m,n} = \delta \nabla \chi^2
     1604\]
     1605where $\lambda_{m,n}$ is zero for $m \neq n$ and for $m = n$ set to be
     1606large when the last iteration produced a large change in the
     1607parameters compared to the local-linear expectation and small when the
     1608last change was small.  The iteration ends when the change in the
     1609parameters is small and/or the change in the $\chi^2$ value is small.
     1610
     1611In the analysis, convolved galaxy fit, the galaxy model image and the
     1612model derivative images must be convolved with the PSF at each
     1613iteration step.  To save computation time, this convolution is
     1614performed using a circularly symmetric approximation of the PSF model,
     1615with the PSF model scale size set to the average of the major and
     1616minor axis direction scale size of the full PSF model, with the same
     1617radial profile term as the PSF model.  The convolution is performed
     1618directly using the circular symmetry to reduce the number of
     1619multiplications performed: all points in the 2D circularly symmetric
     1620PSF model which have the same radial pixel coordinate can be evaluated
     1621in the convolution by summing up the corresponding pixels in the
     1622(galaxy model) image to be convolved before multiplying by the PSF
     1623model profile at that radial coordinate.  This approximation reduces
     1624the number of multiplications by a factor of near 8 for larger radii.
     1625For the small size of the PSF model used to convolve the galaxy model
     1626images, it was found that this direct convolution was faster than
     1627using an FFT-based convolution.
     1628
     1629% \note{(examples?)}
     1630
     1631For the Exponential and DeVaucouleur fits, all parameters are fitted
     1632in the non-linear minimization stage.  For the Sersic model, we do not
     1633fit the index within the Levenberg-Marquardt analysis.  Instead, we
     1634start with a coarse grid search over a range of possible index values,
     1635($n = 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0$) and a range of possible
     1636values for $R_{\rm eff}$ based on the value of $R_1$, the first radial
     1637moment.  For a given value of the Sersic index, the $R_{\rm eff}$ is
     1638related to the 1st radial moment by the scale factor specificy by
     1639Graham \& Driver.  We use the observed value of the 1st radial moment
     1640and try $R_{\rm eff}$ values of a factor of (0.8, 0.9, 1.0, 1.12,
     16411.25) times the value predicted by the Graham and Driver equation.
     1642For each of these steps, the aspect ratio and position angle are held
     1643constant and the normalization is determined to minimize the $\chi^2$.
     1644
     1645We next perform 3 Levenberg-Marquardt minimization fits allowing the
     1646shape parameters ($R_{xx}$, $R_{yy}$ , $R_{xy}$) and the normalization
     1647to be fitted, holding the centroid ($x_0, y_0$), Sersic index $n$, and
     1648sky constant.  In these fits, the index $n$ is set to the minimum
     1649value previously calculated as well as values halfway to the next, and
     1650previous, values in the grid above.  E.g., if the minimum fitted index
     1651value is 3.0, then the LMM fits are performed using $n$ = 2.5, 3.0, 3.5.
     1652The resulting $\chi^2$ values are then used to perform quadratid
     1653interpolation to find the index $n$ which produces the locally minium
     1654$\chi^2$ value.  Finally, this best-fit index value is held constant
     1655while Levenberg-Marquardt minimization is used to find the best fit
     1656values of all other parameters.
     1657
     1658% Graham & Driver : Graham A. W., Driver S. P.  2005, PASA 22, 118
     1659% DOI: https://doi.org/10.1071/AS05001
     1660
     1661\subsection{Convolved Radial Aperture Photometry}
     1662
     1663For some science goals, a well-measured color of a galaxy is more
     1664important than an accurate total magnitude.  In the case of PS1, the image
     1665quality variations for stacks of different filters presents a serious
     1666challenge for the determination of precise colors.  PSPhot determines
     1667a set of PSF-matched radial aperture flux measurements in order to
     1668minimize the impact of the stack image quality variations.
     1669
     1670In PSPhotStack, the stack analysis version of PSPhot, the 5 filter
     1671images are processed together.  After the PSF models have been fitted
     1672and a best set of galaxy models have been determined, three sets of
     1673radial apertures are measured.  In the first set, the fluxes in the
     1674radial apertures are measured using the raw stack images.  The centers
     1675of the apertures for each object across the 5 filters are fixed so
     1676that the pixels represent the equivalent portions of the same galaxy
     1677for all 5 filters.  In this analysis, the best model for each object
     1678is subtracted from the image pixels for all objects excluding the
     1679object in consideration.  The 'best model' is determined based on the
     1680minimum $\chi^2$ value for the model fits.
     1681
     1682% \note{more discussion of the selection of the best model}. 
     1683
     1684In addition to the raw radial apertures, the stack images are each
     1685convolved with a circular Gaussian with $\sigma$ chosen to yield an
     1686image with a typical FWHM of 6\arcsec.  The full set of radial
     1687apertures are again measured on these convolved images.  Again, the
     1688best object models are subtracted from the image for objects not being
     1689measured.  This subtraction includes the convolution to smooth the
     1690model to the effective FWHM of the convolved image.  The entire
     1691procedure is then repeated with a target FWHM of 8\arcsec. 
     1692
     1693% \note{is the first convolution done with the Alard-Lupton technique?}
     1694
     1695\acknowledgments
     1696
     1697The Pan-STARRS1 Surveys (PS1) have been made possible through
     1698contributions of the Institute for Astronomy, the University of
     1699Hawaii, the Pan-STARRS Project Office, the Max-Planck Society and its
     1700participating institutes, the Max Planck Institute for Astronomy,
     1701Heidelberg and the Max Planck Institute for Extraterrestrial Physics,
     1702Garching, The Johns Hopkins University, Durham University, the
     1703University of Edinburgh, Queen's University Belfast, the
     1704Harvard-Smithsonian Center for Astrophysics, the Las Cumbres
     1705Observatory Global Telescope Network Incorporated, the National
     1706Central University of Taiwan, the Space Telescope Science Institute,
     1707the National Aeronautics and Space Administration under Grant
     1708No. NNX08AR22G issued through the Planetary Science Division of the
     1709NASA Science Mission Directorate, the National Science Foundation
     1710under Grant No. AST-1238877, the University of Maryland, and Eotvos
     1711Lorand University (ELTE) and the Los Alamos National Laboratory.
     1712
     1713\bibliographystyle{apj}
     1714% \bibliography{lib}{}
     1715\input{analysis.bbl}
     1716
     1717\end{document}
     1718
     1719\subsection{Forced Photometry : PSFs}
     1720
     1721\subsection{Forced Photometry : galaxies}
    10851722
    10861723\subsection{Output Options}
    10871724
    1088 \note{need to discuss tests}
    1089 
    1090 \note{need to discuss failings and holes}
     1725% \note{need to discuss tests}
     1726
     1727% \note{need to discuss failings and holes}
    10911728
    10921729\section{Alternative Scenarios}
     
    10941731\subsection{Trailed Sources}
    10951732
    1096 \subsection{Fixed / Known-position Sources}
    1097 
    10981733\subsection{Difference Images}
    10991734
    11001735The variance map for a difference image must be generated from the two
    1101 images use to construct the difference.  Otherwise, the low sky level
     1736images used to construct the difference.  Otherwise, the low sky level
    11021737will automatically result in inconsistent interpretation of the variance.
    11031738
     
    11531788\section{Sample Tests}
    11541789
    1155 \end{document}
     1790\begin{verbatim}
     1791Configuration variables affecting the peak detection process:
     1792PEAKS_SMOOTH_SIGMA [2.5]   : Gaussian sigma of smoothing kernel, in pixels.
     1793PEAKS_SMOOTH_NSIGMA [2.0]  : Gaussian smoothing kernel window size in sigmas.
     1794PEAKS_NSIGMA_LIMIT [20.0]  : Detection limit on first pass (sigmas).
     1795PEAKS_NSIGMA_LIMIT_2 [5.0] : Detection limit on faint detection pass (sigmas).
     1796\end{verbatim}
     1797
     1798Recipe parameters which affect the PSF-convolved galaxy model fitting
     1799process:
     1800\begin{verbatim}
     1801EXT_FIT_NSIGMA_CONV [9] : number of sigma
     1802EXT_FIT_ITER
     1803EXT_FIT_MIN_TOL
     1804EXT_FIT_MAX_TOL
     1805LMM_FIT_CHISQ_CONVERGENCE
     1806LMM_FIT_GAIN_FACTOR_MODE
     1807\end{verbatim}
     1808
     1809Figures Needed for this document:
     1810
     1811* aperture - PSF model example
     1812* map of the sky with galaxy region illustrated?
     1813* plots showing the quality of the data?
     1814
     1815Tables needed:
     1816
     1817* table of models?
     1818
     1819Work still needed:
     1820
     1821* Tables
     1822* refereces for other programs
     1823
     1824* authors
     1825* PSF residual map
     1826* section 3.5.3 Model applied to detected objects needs to be reviewed
     1827
     1828* read for english & phrasing
     1829* convert XXX
     1830* background model description (see waters)
     1831* reduce / remove design goal wording?
     1832* too many bullets?
     1833* reduce coding description?
     1834* put engineering docs (psLib, psModules) on public website
     1835
Note: See TracChangeset for help on using the changeset viewer.