Index: trunk/doc/release.2015/ps1.analysis/Makefile
===================================================================
--- trunk/doc/release.2015/ps1.analysis/Makefile	(revision 41306)
+++ trunk/doc/release.2015/ps1.analysis/Makefile	(revision 41307)
@@ -4,5 +4,5 @@
 # 
 DO_PDFLATEX = 1
-DO_BIBTEX = 0
+DO_BIBTEX = 1
 
 help:
Index: trunk/doc/release.2015/ps1.analysis/analysis.tex
===================================================================
--- trunk/doc/release.2015/ps1.analysis/analysis.tex	(revision 41306)
+++ trunk/doc/release.2015/ps1.analysis/analysis.tex	(revision 41307)
@@ -29,6 +29,6 @@
 
 %\def\picdir{/home/eugene/chipresid.20140404}
-%\def\picdir{pics}
-\def\picdir{.}
+\def\picdir{pics}
+%\def\picdir{.}
 
 % Pick a terse version of the title here;
@@ -98,6 +98,6 @@
 images from other telescopes.  We describe the analysis of the
 astronomical sources by \ippprog{psphot} in general as well as for the
-specific case of the 3rd processing version used for the first public
-release of the Pan-STARRS $3\pi$ survey data.
+specific case of the 3rd processing version used for the first \textmod{two public
+releases} of the Pan-STARRS $3\pi$ survey data.
 \end{abstract}
 
@@ -155,5 +155,5 @@
 Pan-STARRS produced its first large-scale public data release, Data
 Release 1 (DR1) on 16 December 2016.  DR1 contains the results of the
-third full reduction of the Pan-STARRS $3\pi$ Survey archival data,
+third full reduction of the Pan-STARRS $3\pi$ Surveyo archival data,
 identified as PV3.  Previous reductions \citep[PV0, PV1, PV2;
   see][]{magnier2017.datasystem} were used internally for pipeline
@@ -166,6 +166,8 @@
 images obtained by the $3\pi$ Survey observations.  A second data
 release, DR2, was made available 28 January 2019.  DR2 provides
-measurements from all of the individual exposures, and include an
-improved calibration of the PV3 processing of that dataset.
+measurements from all of the individual exposures, and includes an
+improved \textmod{astrometric calibration as well as improvements to the
+  photometric calibration of the stack and 'forced warp' measurements
+from} the PV3 processing of that dataset.
 
 This is the fourth in a series of seven papers describing the
@@ -174,7 +176,12 @@
 source detection and photometry, including point-spread-function and
 extended source model fitting, and the techniques for ``forced''
-photometry measurements.  The software described here was used with a
+photometry measurements.  \textadd{The same analysis software is used
+  for individual images, image stacks, and difference images.}
+The software described here was used with a
 single consistent set of parameters for the complete PV3 analysis,
-used for both DR1 and DR2.
+used for both DR1 and DR2.  \textadd{The software was also used for the
+analysis of the Medium Deep Survey data, though with a different
+software version and some modifications of
+the analysis parameters to better suite the longer exposures.}
 
 %Chambers et al. 2017 (Paper I)
@@ -190,5 +197,5 @@
 \citet[][Paper II]{magnier2017.datasystem}
 describe how the various data processing stages are organized and implemented
-in the Imaging Processing Pipeline (IPP), including details of the 
+in the \textmod{Image Processing Pipeline} (IPP), including details of the 
 the processing database which is a critical element in the IPP infrastructure . 
 
@@ -231,11 +238,28 @@
 %%    submission and refereeing process.}}
 
+\textadd{In this article, we use the following type-faces to distinguish
+different concepts:}
+\begin{itemize}
+\item \ippstage{Small caps} for the analysis stages.
+\item \ippdbtable{Italics} for database tables and columns.
+\item \ippprog{Fixed-width} font for program names, variables, and
+  miscellaneous constants.
+\end{itemize}
+
+\textadd{
+The latter catagory includes a number of configuration parameters used
+to define the \ippprog{psphot} analysis.  In those cases, unless the
+values used for the PV3 analysis are explicitly discussed, we include
+the PV3 value immediately after the configuration variable name in parenthesis.}
+
 \section{Background}
 
 The photometric and astrometric precision goals for the Pan-STARRS\,1
-surveys were quite stringent: photometric accuracy of 10
-millimagnitudes, relative astrometric accuracy of 10 milliarcseconds
+surveys were quite stringent.  The astrometric goals were relative astrometric accuracy of 10 milliarcseconds
 and absolute astrometric accuracy of 100 milliarcseconds with respect
-to the ICRS reference stars.
+to the ICRS reference stars.  For photometry, the goal was 10
+millimagnitudes accuracy within the internal photometric system across
+the sky, though the tie to an absolute standard was not required to
+meet this standard.
 
 An additional constraint on the Pan-STARRS analysis system comes from
@@ -311,6 +335,8 @@
 Several variants of \ippprog{psphot} have been used in the PS1 PV3
 analysis.  The main variant of \ippprog{psphot} operates on a single
-image, or a group of related images representing the data read from a
-camera in a single exposure.  The images are expected to have already
+image, or a group of related images representing the data read from
+\textmod{the multiple chips of a mosaic 
+camera from} a single exposure.  \textadd{In the IPP sequencing, this step is
+called the \ippstage{chip} stage.}  The images are expected to have already
 been detrended so that pixel values are linearly related to the flux.
 The gain may be specified by the configuration system, or a variance
@@ -322,6 +348,10 @@
 
 The variant called \ippprog{psphotStack} accepts a set of images, each
-representing the same patch of sky in a different filter, nominally
-the full $grizy$ filter set for the analysis of the PS1 PV3 stack
+representing the same patch of sky \textadd{(with pixels aligned)} in
+a different \textmod{filter.  This version was used for the analysis
+  of the deep ``stacks'' (co-added images combining multiple
+  observations of the same field) produced by the IPP \ippstage{stack}
+  stage.  Nominally,
+the full $grizy$ filter set was used for the analysis} of the PS1 PV3 stack
 images, though where insufficient data were available in a given
 filter, a subset of these filters was processed as a group.  As
@@ -329,5 +359,5 @@
 capability of measuring forced PSF photometry in some filter images
 based on the position of sources detected in the other filters.  It
-also include an option to convolve the set of images to a single,
+also includes an option to convolve the set of images to a single,
 common PSF size across the filters for the purpose of fixed aperture
 photometry.
@@ -335,5 +365,5 @@
 Another variant of \ippprog{psphot} used in the PV3 analysis is called
 \ippprog{psphotFullForce}.  In this variant, a set of images all representing the
-same pixels are processed together, with the positions of sources to
+same \textadd{co-aligned} pixels are processed together, with the positions of sources to
 be analyzed loaded from a supplied file.  In this variant of the
 analysis, sources are not discovered -- only the supplied sources are
@@ -348,20 +378,32 @@
 % \subsection{Astronomy Measurement Goals}
 
-\ippprog{psphot} has a number of important requirements that it must
-meet, and a number of design goals which we believe will help to make
-it usable in a wide range of circumstances.  The critical
-astronomy-driven measurement goals of the Pan-STARRS project, which
-drive the design of \ippprog{psphot}, are the photometric accuracy
-goal (10 millimagntudes) and the astrometric accuracy goal (10
-milliarcseconds).  For \ippprog{psphot}, the photometry accuracy goal
-implies that the measured photometry of stellar sources must be
-substantially better than this 10 mmag goal since the photometry error
-per image is combined with an error in the flat-field calibration and
-an error in measuring the atmospheric effects.  We have set a goal for
+\textadd{The top-level design goals of \ippprog{psphot} are to detect and
+determine the instrumental positions and fluxes of astronomical
+sources in the images.  For extended sources, the goals also include
+the measurement of a variety of morphological information, including
+galaxy model parameters and non-parametric measurements of the sizes
+and profiles of the galaxies to aid in classification and for
+weak-lensing analysis.  For trailed asteroids, the goal also includes
+the measurement of the length and direction of the trail.}
+
+\textmod{Beyond these basic elements, \ippprog{psphot} has a number of
+  design goals} which we believe will help to make it usable in a wide
+range of circumstances.  The critical astronomy-driven measurement
+goals of the Pan-STARRS project, which drive the design of
+\ippprog{psphot}, are the photometric accuracy goal (10
+millimagnitudes) and the \textadd{relative} astrometric accuracy goal
+(10 milliarcseconds) \textadd{for bright stars for which the photon
+  shot-noise is small compared to the systematic errors.}
+
+For \ippprog{psphot}, the photometry accuracy goal implies that the
+measured photometry of stellar sources must be substantially better
+than this 10 mmag goal since the photometry error per image is
+combined with an error in the flat-field calibration and an error in
+measuring the atmospheric effects.  We have set a goal for
 \ippprog{psphot} of 3 mmag photometric consistency for bright stars
 between pairs of images obtained in photometric conditions at the same
 pointing, ie to remove sensitivity to flat-field errors.  This goal
 splits the difference between the three main contributors and still
-allows some leeway.  This requirement must be met for well-sampled
+allows some leeway.  This goal must be met for well-sampled
 images and images with only modest undersampling.
 
@@ -420,4 +462,11 @@
 \end{itemize}
 
+\note{get a better example of the psphot accuracy achieved}
+
+\textadd{The success of the \ippprog{psphot} implementation is meeting
+  the photometry and astrometry design requirements is demonstrated by
+  the achieved accuracy for the Pan-STARRS $3\pi$ Survey data.  
+}
+
 \section{Basic Analysis}
 
@@ -480,5 +529,6 @@
 \hline
 \hline
-{\bf Measurement} & {\bf Camera} & {\bf Stack} & {\bf Forced Warp} & {\bf Diff} & {\bf Section} & {\bf Which} \\
+{\bf Measurement} & {\sc \bf CHIP} & {\sc \bf STACK} & {\sc \bf FORCED
+  WARP} & {\sc \bf DIFF} & {\bf Section} & {\bf Which} \\
 \hline
   Background Subtraction     & Y & Y & Y & N$^1$ & \ref{sec:image.preparation}      & N/A \\
@@ -524,9 +574,9 @@
 field \ippmisc{FLAGS}.  When data from \ippprog{psphot} is loaded into
 a DVO database \citep{magnier2017.calibration}, these values are
-stored in the field \code{Measure.photFlags} and exposed in the public
+stored in the field \ippdbtable{Measure.photFlags} and exposed in the public
 database \citep[PSPS][]{flewelling2017} in the fields
-\code{Detection.infoFlag}, \code{StackObjectThin.XinfoFlag} (where
-\code{X} is one of {$grizy$}), and
-\code{ForcedWarpMeasurement.FinfoFlag}.
+\ippdbtable{Detection.infoFlag}, \ippdbtable{StackObjectThin.XinfoFlag} (where
+\ippdbtable{X} is one of {$grizy$}), and
+\ippdbtable{ForcedWarpMeasurement.FinfoFlag}.
 %
 Table~\ref{tab:det_flag2_values} lists the flags recorded in the
@@ -534,7 +584,7 @@
 loaded into a DVO database \citep{magnier2017.calibration}, these
 values are not currently loaded, but they are exposed in PSPS in the fields
-\code{Detection.infoFlag2}, \code{StackObjectThin.XinfoFlag2} (where
-\code{X} is one of {$grizy$}), and
-\code{ForcedWarpMeasurement.FinfoFlag2}.
+\ippdbtable{Detection.infoFlag2}, \ippdbtable{StackObjectThin.XinfoFlag2} (where
+\ippdbtable{X} is one of {$grizy$}), and
+\ippdbtable{ForcedWarpMeasurement.FinfoFlag2}.
 
 \begin{table*}
@@ -635,5 +685,10 @@
 be provided by the user, or they may be automatically generated from
 the input image, based on configuration-defined values for the image
-gain, read-noise, saturation, and so forth.  For the function-call
+gain, read-noise, saturation, and so forth.  \textadd{Within the IPP analysis,
+we normally use images which are equivalent to the digital numbers
+(scaled by the detrend images), but as long as the variance image is
+constructed in a consistent fashion, \ippprog{psphot} can use images
+in electron, calibrated flux units or other conventions (though this would
+require some tuning of configuration parameters).}  For the function-call
 form of the program, the flux image is provided in the API, and
 references to the mask and variance are provided in the configuration
@@ -643,5 +698,7 @@
 The mask is represented as a 16-bit integer image in which a value of
 0 represents a valid pixel.  Each of the 16 bits define different
-reasons a pixel should be ignored.  This allows us to optionally
+reasons a pixel should be ignored, \textadd{listed in
+  Table~\ref{tab:mask_values}}.
+This allows us to optionally
 respect or ignore the mask depending on the circumstance.  For
 example, in some cases, we ignore saturated pixels completely while in
@@ -658,7 +715,6 @@
 case of PS1 PV3, the header keyword \code{MAXLIN} specifies the
 saturation level for each chip \citep[see][]{waters2017}. 2) Pixels
-which are below a user-defined value are considered unresponsive and
-masked as dead.  (camera format keyword \code{CELL.BAD} = 0 for PS1
-PV3).  3) Pixels which lie outside of a user-defined coordinate window
+which are below a user-defined value (\code{CELL.BAD} = 0 for PV3) are considered unresponsive and
+masked as dead.  3) Pixels which lie outside of a user-defined coordinate window
 are considered non-data pixels (\eg, overscan) and are marked as
 invalid.  (\ippprog{psphot} recipe keywords \code{XMIN}, \code{XMAX},
@@ -744,14 +800,14 @@
 subtracted.  The image is divided into a grid of background points
 with a spacing defined by the \ippprog{psphot} recipe values
-\code{BACKGROUND.XBIN, BACKGROUND.YBIN}, set to 400 pixels for PS1
-PV3.  Superpixels of size \code{BACKGROUND.XSAMPLE, BACKGROUND.YSAMPLE}
-($2 \times 2$ for PS1 PV3) times larger than
-this spacing are used to measure the local background for each
-background grid point, thus over-sampling the background spatial
-variations.  In the interest of speed, a subset of \code{IMSTATS_NPIX}
-(10,000 for PS1 PV3) randomly selected {\em unmasked} pixels in these
-regions are used to determine the background.  The background value
-for each superpixel is determined by fitting a Gaussian distribution
-to the histogram of pixels values.  
+\code{BACKGROUND.XBIN, BACKGROUND.YBIN}, set to 400 pixels
+\textadd{($\sim 100$ arcseconds)} for PV3.  Superpixels of size
+\code{BACKGROUND.XSAMPLE, BACKGROUND.YSAMPLE} ($2 \times 2$ for PV3)
+times larger than this spacing are used to measure the local
+background for each background grid point, thus over-sampling the
+background spatial variations.  In the interest of speed, a subset of
+\code{IMSTATS_NPIX} (10,000 for PV3) randomly selected {\em unmasked}
+pixels in these regions are used to determine the background.  The
+background value for each superpixel is determined by fitting a
+Gaussian distribution to the histogram of pixels values.  
 
 If the image were empty of stars and only contained flux from a
@@ -788,4 +844,21 @@
 the discussion in Section~3.11 of \cite{waters2017}.
 
+\textadd{Since the subtraction of the sky model supresses larger-scale
+  structures, features such as large galaxies which are comparable to
+  the superpixel size are adversely affected by the subtraction.
+  Photometry for galaxies larger than $\sim 30$ arcseconds is
+  unreliable as a result.  The superpixel size used for the sky model
+  in the PV3 analysis was chosen as compromise between the need to
+  follow bright features with small spatial scales and the desire to
+  measure photometry of galaxies of sizes up to at least 30
+  arcseconds.  Features which we wished to suppress include both
+  astronomical sources, such as bright nebulosity and the wings of
+  bright stars, and non-astronomical sources, such as moonlight and
+  other scattered light sources.  In some contexts, we have used a
+  finer spacing for the background model, such as in the dedicated
+  analysis of the photometry of the Andromeda Galaxy, where we are
+  only interested in stellar sources and the analysis is otherwise
+  badly affected by the background from this galaxy.}
+
 \subsection{Initial Source Detection}
 
@@ -801,20 +874,31 @@
 significance image in signal-to-noise units, including correction for
 the covariance, if known. At this stage, the goal is only to detect
-the brighter sources, above a user defined S/N limit (configuration
-keyword: \code{PEAKS_NSIGMA_LIMIT} = 20.0 for PS1 PV3).  A maximum of
-\code{PEAKS_NMAX} (5000 of PS1 PV3) are found at this stage.  The
+the brighter sources, above a user defined S/N limit
+(\code{PEAKS_NSIGMA_LIMIT} = 20.0 for PV3).  A maximum of
+\code{PEAKS_NMAX} (5000 for PV3) are found at this stage.
+
+\textadd{For an image with a Gaussian PSF of the same size, this method
+  would represent the optimal detection algorithm, equivalent to a
+  matched filter \note{add ref}.  At this stage, our goal is simply to
+  detect the brighter sources, so the exact size and shape of the PSF
+  is not critical. }
+The
 detection efficiency for the brighter sources is not strongly
-dependent on the form of this smoothing function.
+dependent on the form of this smoothing function.  \textadd{Instead,
+  our goal with the smoothing kernel is to reduce our sensitivity to
+  pixel-to-pixel fluctuations in the location of the peak of the
+  sources in the image.}.  
 
 The local peaks in the smoothed image are found by first detecting
 local peaks in each row.  For each peak, the neighboring pixels are
 then examined and the peak is accepted or rejected depending on a set
-of simple rules.  First, any peak which is greater than all 8
+of simple rules.  \textadd{The rules are defined so that we choose a unique set
+of peaks which are not immediately adjacent to other peaks.}  First, any peak which is greater than all 8
 neighboring pixels is kept.  Any peak which is lower than any of the 8
 neighboring pixels is rejected.  Any peak which has the same value as
-any of the other 8 pixels is kept if the pixel $X$ and $Y$ coordinates
-are greater than or equal to the other equal value pixels.  This
-simple rule set means that a flat-topped region will result peaks at
-the maximum $X$ and $Y$ corners of the region.
+any of the other 8 pixels is kept {\em if} the pixel $X$ and $Y$ coordinates
+are greater than or equal to the other equal-value pixels.  \textmod{This
+last rule means that a flat-topped region will result in peaks at
+the maximum $X$ and $Y$ corners of the region.}
 
 We use the 9 pixels which include the source peak to fit for the
@@ -882,5 +966,6 @@
   \caption{\label{fig:peaks} Illustration of peak finding and culling peaks within a
     footprint.  Insignificant peaks within the footprint of a brighter
-    peak are ignored in further processing. }
+    peak are ignored in further processing. \note{NOTE that the
+      diagram is a 1D rep of a 2D path.}}
   \end{center}
 \end{figure}
@@ -897,18 +982,20 @@
 (\code{PEAKS_NSIGMA_LIMIT}).  These regions are grown by a small
 amount to avoid errors on rough edges -- an image of the footprints is
-convolved with a disk of radius \code{FOOTPRINT_GROW_RADIUS} (= 3
-pixels for PS1 PV3).  Peaks are assigned to the footprints in which
+convolved with a disk of radius \code{FOOTPRINT_GROW_RADIUS} (3
+pixels for PV3).  Peaks are assigned to the footprints in which
 they are contained (note by construction all peaks must be located in
 a footprint since the peaks must be above the detection threshold).
 
 For any peak which is not the brightest peak in that footprint it is
-possible to reach the brightest peak by following the highest valued
-pixels between the two peaks.  The lowest pixel along this path is the
+possible to reach the brightest peak by following a sequence of the highest valued
+pixels between the two peaks.  The lowest pixel along this
+\textadd{(potentially meandering)} path is the
 {\em key col} for this peak (as used in topographic descriptions of a
 mountain).  If the key col for a given peak is less than
-\code{FOOTPRINT_CULL_NSIGMA_DELTA} (4.0 for PS1 PV3) sigmas below the
+\code{FOOTPRINT_CULL_NSIGMA_DELTA} (4.0 for PV3) sigmas below the
 peak of interest, the peak is considered to be {\em locally
   insignificant} and removed from the list of possible detections (see
-Figure~\ref{fig:peaks}).  In the vicinity of a saturated star, the
+Figure~\ref{fig:peaks}).  \textadd{If more than one such path is possible, the
+path with the highest key col is used for this test.}  In the vicinity of a saturated star, the
 rule is somewhat more aggressive as the flat-topped or structured
 saturated top of a bright star may appear as multiple peaks with
@@ -976,5 +1063,5 @@
 and the aperture is an iterative process: for a given value of
 $\sigma_w$, the PSF stars will have a measured value of the PSF size,
-$\sigma^{\prime}_{\rm PSF}$ which different from the true value due to
+$\sigma^{\prime}_{\rm PSF}$ \textmod{which is different} from the true value due to
 the effect of the window function.  The measured value of the PSF size
 will be biased high or low depending on both the signal-to-noise of
@@ -992,6 +1079,6 @@
 FWHM for faint stars rises, and then over-shoots the truth value,
 while the scatter increases.  Thus, for large values of $\sigma_w$,
-the result is both a poorly estimated FWHM for the image and a trend
-this the signal-to-noise of the star.  We attempt to minimize the
+the result is both a poorly estimated FWHM for the image and a \textmod{trend
+with the} signal-to-noise of the star.  We attempt to minimize the
 scatter and trends with instrumental magnitude at the cost of overall
 bias.
@@ -1057,5 +1144,5 @@
 $S = \sum_i (f_i - s_i) w_i$ is the window-weighted sum of the source
 flux, used to re-normalize the moments; $r_i$ is the radius of a
-pixel, $\sqrt{(x_i - x_0)^2 + (y_i - y_0)^2}$; The sums are performed
+pixel, $\sqrt{(x_i - x_0)^2 + (y_i - y_0)^2}$. The sums are performed
 over all (unmasked) pixels in the aperture.  For the centroid calculation ($x_0,
 y_0$), the peak coordinate (see~\ref{sec:peaks}) is used to define the
@@ -1076,5 +1163,5 @@
 
 If the measured centroid coordinates ($x_0, y_0$) differ from the peak
-coordinates be a large amount (1.5$\sigma_w$), then the peak is
+coordinates \textmod{by} a large amount (1.5$\sigma_w$), then the peak is
 identified as being of poor quality and is skipped in further
 analyses; the flag bit
@@ -1161,5 +1248,6 @@
 parameters would be the shape terms ($\sigma_x, \sigma_y, \sigma_{\rm
   xy}$) while the independent parameters would be the centroid,
-normalization and local sky values ($x_o, y_o, I_o, S$).  Thus the
+normalization and local sky values ($x_o, y_o, I_o, S$).  \note{we do
+  not fit sky as a free parametery, right?}  Thus the
 shape parameters are each a function of the source centroid
 coordinates:
@@ -1169,20 +1257,22 @@
 \sigma_{xy} & = & f_3(x_{\rm ccd},y_{\rm ccd}).
 \end{eqnarray}
-\ippprog{psphot} represents the variation in the PSF parameters as a function of
-position in the image in two possible ways, specified by the
-configuration.  The first option is to use a 2-D polynomial which is
-fitted to the measured parameter values across the image.  The second
-option is to use a grid of values which are measured for sources
-within a subregion of the image.  In the latter case, the value at a
-specific coordinate in the image is determined by interpolation
-between the nearest grid points.  The order of the polynomial or the
-sampling size of the grid is dynamically determined depending on the
-number of available of PSF stars.  In the case of the PV3 analysis,
-the grid of values was used, with a maximum of $6\times 6$ samples per
-GPC1 chip image.  For the earlier PV2 analysis, the maximum grid
-sampling was $3\times 3$ per GPC1 chip image.  For the PV1 analysis,
-the polynomial representation was used, with up to 3rd order terms.
-The higher order representation was used for PV3 in order to follow
-some of the observed PSF variations in the images
+\ippprog{psphot} represents the variation in the PSF parameters as a
+function of position in the image in two possible ways, specified by
+the configuration.  The first option is to use a 2-D polynomial which
+is fitted to the measured parameter values across the image.  The
+second option is to use a grid of values which are measured for
+sources within a subregion of the image.  In the latter case, the
+value at a specific coordinate in the image is determined \textmod{via
+  bi-linear} interpolation between the nearest grid points.  The order
+of the polynomial or the sampling size of the grid is dynamically
+determined depending on the number of available of PSF stars.  In the
+case of the PV3 analysis, the grid of values was used, with a maximum
+of $6\times 6$ samples per GPC1 chip image \textadd{(grid cells of
+  size $\sim 3.4$ arcminutes)}.  For the earlier PV2 analysis, the
+maximum grid sampling was $3\times 3$ per GPC1 chip image
+\textadd{(grid cells of size $\sim 6.9$ arcminutes)}.  For the PV1
+analysis, the polynomial representation was used, with up to 3rd order
+terms.  The higher order representation was used for PV3 in order to
+follow some of the observed PSF variations in the images.
 
 % \note{write up the fitting process to define the grid?}
@@ -1193,5 +1283,5 @@
 \item Gaussian : $f = I_0 e^{-z}$
 \item Pseudo-Gaussian : $f = I_0 (1 + z + \frac{1}{2} z^2 + \frac{1}{6} z^3)^{-1}$ \code{[PGAUSS]}
-\item Variable Power-Law : $f = I_0 (1 + z + z^{\alpha})^{-1}$ \code{[RGAUSS]}
+\item Variable Power-Law : $f = I_0 (1 + z + z^{\alpha})^{-1}$ \code{[RGAUSS]}, $\alpha > 1.25$
 \item Steep Power-Law : $f = I_0 (1 + \kappa z + z^{2.25})^{-1}$ \code{[QGAUSS]}
 \item PS1 Power-Law : $f = I_0 (1 + \kappa z + z^{1.67})^{-1}$ \code{[PS1_V1]}
@@ -1201,4 +1291,9 @@
 similar to the Moffat profile form
 \citep{1969AA.....3..455M,1983AA...126..278B}, with small differences.
+\textadd{For these PSF models, the functions are evaluated at the pixel center.
+Unlike some galaxy model representations (see
+Section~\label{sec:galaxy.conv.fit} ), the first derivatives of these
+functions approach zero as the radius approaches zero, so sub-pixel
+integration is not necessary.}
 A user may choose to try more than one analytical function for a given
 image.  As discussed below (Section~\ref{sec:psf.model.choice}),
@@ -1245,7 +1340,7 @@
 renormalized by the flux of the star to put them on a consistent flux
 scale.  For each PSF star, all pixels within a user-specified radius
-(\code{PSF.RESIDUALS.RADIUS = 9}) are selected for the measurement.  For a
-given pixel in the model, the pixel values from the PSF stars are
-interpolated to the center of the model pixel. Pixels may be used in
+(\code{PSF.RESIDUALS.RADIUS = 9}) are selected for the measurement.  \textmod{For a
+given pixel in the model, the value is calculated from the 4 closest
+pixels in the PSF stars via bi-linear interpolation.} Pixels may be used in
 this analysis if their signal-to-noise exceeds a user-defined limit.
 For the PV3 $3\pi$ analysis, we allowed all pixels within the
@@ -1271,8 +1366,8 @@
 \]
 where $R[(x_{\rm mod},y_{\rm mod})][(x_{\rm ccd},y_{\rm ccd})]$ is the
-value for model pixel $(x_{\rm mod},y_{\rm mod})$ for a star with
-centroid at image pixel $(x_{\rm ccd},y_{\rm ccd})$.  The parameters
-$R_o, R_x, R_y$ are determined for each pixel in the model $[(x_{\rm
-    mod},y_{\rm mod})]$.
+\textmod{value of the residual for model} pixel $(x_{\rm mod},y_{\rm mod})$ for a star with
+centroid at image pixel $(x_{\rm ccd},y_{\rm ccd})$.  \textmod{The parameters
+$R_o, R_x, R_y$ are the elements of the 2-D linear fit for each pixel $(x_{\rm mod},y_{\rm mod})$
+in the model. }
 
 \subsubsection{Candidate PSF Source Selection}
@@ -1355,6 +1450,6 @@
 For the resulting collection of source model parameters, the
 PSF-dependent parameters of the models are all fitted as a function of
-position using either the 2-D polynomial or the gridded superpixel
-representation.  The maximum order of these fits depends on the number
+position using either the 2-D polynomial or the gridded 
+representation described above.  The maximum order of these fits depends on the number
 of PSF sources (see Table~\ref{tab:psf.order.nstars}).  The fitting process for
 these polynomials is iterative, and rejects the $3\sigma$ outliers in
@@ -1380,15 +1475,15 @@
   for a given order of the PSF 2D variations.} % \vspace{-0.5cm}
 \begin{center}
-\begin{tabular}{lll}
+\begin{tabular}{llll}
 \hline
 \hline
-{\bf Minimum Number} & {\bf Order} & {\bf Number of} \\
-{\bf of Stars}       &             & {\bf Grid Cells} \\
+{\bf Minimum }    & {\bf Order} & {\bf Number of}  & {\bf Cell Size} \\
+{\bf \# of Stars} &             & {\bf Grid Cells} & {\bf (arcmin) } \\
 \hline
- 16 &  1 &  4 \\
- 54 &  2 &  9 \\
-128 &  3 & 16 \\
-300 &  4 & 25 \\
-576 &  5 & 36 \\
+ 16 &  1 &  4 & 10.3 \\
+ 54 &  2 &  9 &  6.9 \\
+128 &  3 & 16 &  5.1 \\
+300 &  4 & 25 &  4.1 \\
+576 &  5 & 36 &  3.4 \\
 \hline
 \end{tabular}
@@ -1405,26 +1500,38 @@
 the PSF model for this particular image.
 
-The metric used by \ippprog{psphot} to assess the PSF model is the
-scatter in the differences between the aperture and fit magnitudes for
-the PSF sources.  This difference is a critical parameter for any PSF
-modeling software as it is a measurement of how well the PSF model
-captures the flux of the star.  Aperture photometry is measured for a
-circular aperture with a radius of \code{PSF_APERTURE_SCALE} (= 4.5
-for the PV3 $3\pi$ analysis) times $\sigma_w$
+% For each model test, the above
+% corrected ApResid scatter is measured.  The PSF model function with
+% the smallest value for the ApResid scatter is then used by
+% \ippprog{psphot} as the best PSF model for this image.  
+
+{\bf \ippprog{psphot} allows a collection of PSF model functions to be
+tried on all PSF candidate sources.  The number of models to be tested
+is specified by the configuration keyword \code{PSF_MODEL_N}.  The
+configuration variables \code{PSF_MODEL_0}, \code{PSF_MODEL_1},
+through \code{PSF_MODEL_N - 1} specify the names of the models which
+should be tested.  The metric used by \ippprog{psphot} to assess the
+PSF model is the scatter in the differences between the aperture and
+fit magnitudes for the PSF sources.  This difference is a critical
+parameter for any PSF modeling software as it is a measurement of how
+well the PSF model captures the flux of the star.  Aperture photometry
+is measured for a circular aperture with a radius of
+\code{PSF_APERTURE_SCALE} (4.5 for PV3) times $\sigma_w$
 (Section~\ref{sec:moments}).  The average aperture correction ($m_{\rm
   AP} - m_{\rm PSF}$) is measured and, if multiple PSF model types are
 selected, the PSF model with the minimum clipped scatter in this
-statistic is chosen for the image.  An approximate aperture correction
-is measured here, with a more detailed correction measured after all
-source analysis is performed (see
-Section~\ref{sec:aperture.correction}).  Sources for which the
-aperture magnitude is measured have the flag bit
+statistic is chosen for the image.  For the PV3 analysis, however, only the
+\code{PS1_V1} model function was used.}
+
+An approximate aperture correction is measured at this stage, with a
+more detailed correction measured after all source analysis is
+performed (see Section~\ref{sec:aperture.correction}).  Sources for
+which the aperture magnitude is measured have the flag bit
 \code{PM_SOURCE_MODE_AP_MAGS} set.  These aperture magnitudes are
-stored in the DVO field \code{Measure.Map} and exported to the PSPS as
-a flux in Janskies in the field \code{Detection.apFlux}.  The radius
-(in arcseconds)
-of the aperture used for each exposure is reported in PSPS as
-\code{Detection.apRadius}, while the unmasked fraction of the aperture
-is reported in PSPS as \code{Detection.apFillF}.
+stored in the DVO field \ippdbtable{Measure.Map} and exported to the
+PSPS as a flux in Janskies in the field \ippdbtable{Detection.apFlux}.
+The radius (in arcseconds) of the aperture used for each exposure is
+reported in PSPS as \ippdbtable{Detection.apRadius}, while the
+unmasked fraction of the aperture is reported in PSPS as
+\ippdbtable{Detection.apFillF}.
 
 When the PSF and aperture photometry for a source is measured, two
@@ -1486,5 +1593,7 @@
 % maybe drop this discussion? too much detail?
 In order to allow for multiple threads to process a single image, the
-pixels in an image are divided into a grid of superpixels.  The
+pixels in an image are divided into a grid of superpixels \textadd{(note that
+these superpixels are not the same as those used for either the
+background model or the PSF parameter variations)}.  The
 superpixels are assigned to one of four groups so that each superpixel
 in a group is well separated from the other superpixels of that group.
@@ -1498,4 +1607,6 @@
 considering the nearby pixels from neighboring superpixel (guaranteed
 not to be in the current thread group).
+
+\note{explain number of superpixels (psphotThreadTools.c)}
 
 As the threads complete their analysis, they are assigned the next
@@ -1589,5 +1700,5 @@
 one annulus to the next is less than a user-defined limit, then the
 annulus at which the slope reaches this limit is used to define the
-sky radius.  These values are saved in the output smf / cmf files, but
+sky radius.  These values are saved in the \textmod{output FITS catalog files}, but
 not sent to the PSPS.  The sky radius value is used below in the
 calculation of the Kron magnitude.
@@ -1625,5 +1736,5 @@
 surface brightness.  The aperture is constrained to be less than a
 maximum value defined such that the minimum surface brightness is
-1/2$times$ the effective surface brightness of a point source detected at the
+1/2$\times$ the effective surface brightness of a point source detected at the
 $5\sigma$ limit.
 
@@ -1636,5 +1747,9 @@
 suppressed by the matched pixel on the other side.  This trick has the
 effect of reducing the impact of pixels which include flux from near
-neighbors.
+neighbors.  \textadd{We found it necessary to apply this filter because,
+although the source models have been subtracted, at this point in the
+analysis, only PSF models have been used.  Thus extended objects
+(galaxies) can leave behind significant amounts of flux to contaminate
+the neighbors.}
 
 % \note{give a test example}
@@ -1645,10 +1760,10 @@
 After the PSF model has been fitted to all sources, and the Kron flux
 has been measured for all sources, \ippprog{psphot} uses these two
-measurements, along with some additional pixel-level analysis, to
-determine the size class of the source.  Sources identified as
+measurements, along with some additional pixel-level analysis, \textmod{for
+classification based on source size.}  Sources identified as
 extended will be fitted with a galaxy model (or possibly another type
-of extended source model in special cases).  If the source is small
+of extended source model in special cases).  \textadd{If the source is small
 compared to a PSF, it is considered to be a {\em cosmic ray} and
-masked.
+masked.}
 
 Extended sources are identified as those for which the Kron magnitude
@@ -1660,5 +1775,5 @@
 star.  The result is divided by the quadrature error of the PSF and
 Kron magnitudes and called \code{extNsigma}.  If \code{extNsigma} is
-larger than \code{PSPHOT.EXT.NSIGMA.LIMIT} (3.0), the source is
+larger than the configuration value \code{PSPHOT.EXT.NSIGMA.LIMIT} (3.0 for PV3), the source is
 considered to be extended and the flag bit
 \code{PM_SOURCE_MODE_EXT_LIMIT} is set for the source.
@@ -1830,11 +1945,13 @@
 exclusion stage are subtracted from the image.  The subtraction
 process modifies the image pixels (removing the fitted flux, though
-not the locally fitted background) but does not modify the mask or the
-variance images.  The signal-to-noise ratio in the image after
-subtraction represents the significance of the remaining flux.  If the
+not the locally fitted background)\note{is the background actually
+  fitted locally?} but does not modify the mask or the variance
+images.  The signal-to-noise ratio in the image after subtraction
+represents the significance of the remaining flux.  If the
 subtractions are sufficiently accurate models of the PSF flux
-distribution, the remaining flux should be below 1 $\sigma$
-significance.  In practice the cores of bright stars are poorly
-represented and may have larger residual significance.
+distribution, \textmod{the remaining flux should be normally distributed about
+zero with a standard deviation of 1 $\sigma$}.  In practice the cores
+of bright stars are poorly represented and may have larger residual
+significance.
 
 For sources in groups of blended stars, the resulting fits are
@@ -1895,5 +2012,5 @@
 image is not modified.  
 
-For the single exposure (\ippstage{camera}) and \ippstage{stack} image
+For the single exposure (\ippstage{chip}) and \ippstage{stack} image
 analysis, these galaxy model fits are only used internally to generate
 a clean object-subtracted residual image.  For the PV3 analysis of the
@@ -1949,4 +2066,6 @@
 on one image based on detections in other images have the flag bit
 \code{PM_SOURCE_MODE2_MATCHED} set.
+
+\note{need to discuss the injection \& recovery analysis of the completeness}
 
 \subsection{Aperture Correction and Total Aperture Fluxes}
@@ -1979,12 +2098,16 @@
 fraction of the total source flux.  Even more importantly, as the
 image conditions change, the amount lost will change by an even
-smaller fraction, at least for a large aperture.  This can be seen by
-the fact that the dominant variations in the image quality are in the
-focus, tracking and seeing.  All of these errors initially affect the
-cores of the stellar images, rather than the wide wings.  The wide
-wings are largely dominated by scattering in the optics and scattering
-in the atmosphere.  The amplitude and distribution of these two
-scattering functions do not change significantly or quickly for a
-single telescope and site.  Aperture photometry can then be used to
+smaller fraction, at least for a large aperture.  
+%
+% This can be seen by
+% the fact that the dominant variations in the image quality are in the
+% focus, tracking and seeing.  All of these errors initially affect the
+% cores of the stellar images, rather than the wide wings.  The wide
+% wings are largely dominated by scattering in the optics and scattering
+% in the atmosphere.  The amplitude and distribution of these two
+% scattering functions do not change significantly or quickly for a
+% single telescope and site.  
+%
+Aperture photometry can then be used to
 correct the PSF photometry.
 
@@ -2111,14 +2234,4 @@
 %%% term.
 
-\ippprog{psphot} allows a collection of PSF model functions to be tried on all
-PSF candidate sources.  For each model test, the above corrected
-ApResid scatter is measured.  The PSF model function with the smallest
-value for the ApResid scatter is then used by \ippprog{psphot} as the best PSF
-model for this image.  The number of models to be tested is specified
-by the configuration keyword \code{PSF_MODEL_N}.  The configuration
-variables \code{PSF_MODEL_0}, \code{PSF_MODEL_1}, through
-\code{PSF_MODEL_N - 1} specify the names of the models which should be
-tested.
-
 \subsection{Stellar Photometry Example}
 
@@ -2191,5 +2304,5 @@
 %% step ($S/N > 20$, Section~\ref{sec:xxxx}).  
 
-The extended source analysis is not applied to all object which may be
+The extended source analysis is not applied to all \textmod{objects} which may be
 galaxies.  Several restrictions are possible within the software.  For
 example, it is possible to limit which objects are processed by their
@@ -2311,4 +2424,6 @@
 output file FITS header (\code{RMIN_NN}, \code{RMAX_NN}).  
 
+\note{specify PV3 config values?}
+
 % \note{these profiles are not saved in PSPS}
 
@@ -2319,6 +2434,6 @@
 ratio of surface brightnesses.  The motivation is to define an
 aperture which can be determined for galaxies without significant
-biases as a function of distance from the observer.  Since surface
-brightness in a resolved source is conserved as a function of
+biases as a function of distance from the observer.  \textmod{Since the surface
+brightness profile} in a resolved source is conserved as a function of
 distance, using a ratio of surface brightness to define a spatial
 scale results in a spatial scale which is constant regardless of
@@ -2421,5 +2536,5 @@
 fewer. The 1st radial moment (see
 \ref{sec:moments}) is used to estimate the effective radius of the
-model based on the results of Graham \& Driver (2005, Table 1).  They
+model based on the results of \cite[][Table1]{2005PASA...22..118G}.  They
 quantify the relationships between the first radial moment used to
 calculated a Kron Magnitude and the effective radius for different
@@ -2447,9 +2562,4 @@
 with the PSF model.
 
-We simplify this by defining:
-\begin{eqnarray}
-f_p (a_m)         & = & \frac{1}{\sigma_p} (I_p - M_p \otimes \mbox{PSF}) \\
-\end{eqnarray}
-
 To determine the minimization, we need the gradient and laplacian of
 $\chi^2$ with respect to the model parameters, $a_m$:
@@ -2460,7 +2570,13 @@
 2 H_{m,n}  & = & \sum_p \frac{\partial f_p}{\partial a_m} \frac{\partial f_p}{\partial a_n}
 \end{eqnarray}
-where we have approximated the Laplacian with the Hessian matrix,
+where we define
+\begin{eqnarray}
+f_p (a_m)         & = & \frac{1}{\sigma_p} (I_p - M_p \otimes \mbox{PSF}) 
+\end{eqnarray}
+and we have approximated the Laplacian with the Hessian matrix,
 $H_{m,n}$ by dropping the second-derivatives (which are assumed to be
-a small perturbation).  Since
+a small perturbation).
+
+Since
 \[
 \frac{\partial f_p}{\partial a_m} = -\frac{1}{\sigma_p}\frac{\partial M_p \otimes \mbox{PSF}}{\partial a_m}
@@ -2486,7 +2602,7 @@
 parameters compared to the local-linear expectation and small when the
 last change was small.  The iteration ends when the change in the
-parameters is small and/or the change in the $\chi^2$ value is small.
-
-In the analysis, convolved galaxy fit, the galaxy model image and the
+parameters is small or the change in the $\chi^2$ value is small.
+
+In the analysis, convolved galaxy fits, the galaxy model image and the
 model derivative images must be convolved with the PSF at each
 iteration step.  To save computation time, this convolution is
@@ -2577,4 +2693,6 @@
 additions, or up to $6 \times$ that number if we interpolate between
 any of the parameters.
+
+\note{how much error does this approximation introduce?}
 
 \subsection{Fixed Aperture Photometry}
@@ -3162,7 +3280,7 @@
 negative (minuend) images.  We identify the closest source in both the
 positive and negative images to the detection in the difference image,
-out to a maximum of \code{INPUT.MATCH.RADIUS} (= 50 pixels), but only
+out to a maximum of \code{INPUT.MATCH.RADIUS} (50 pixels for PV3), but only
 if the source in those images has a signal-to-noise greater than
-\code{INPUT.MATCH.MIN.SN} (= 10).  If there is a close neighbor in the
+\code{INPUT.MATCH.MIN.SN} (10 for PV3).  If there is a close neighbor in the
 positive image, and the difference in the magnitudes of the source in
 that image and the source in the difference image is less than 5
@@ -3206,5 +3324,5 @@
 \section{Conclusions}
 
-The Pan-STARRS Image Processing Pipeline has used the \code{psphot}
+The Pan-STARRS Image Processing Pipeline has used the \ippprog{psphot}
 software to detect and characterize astronomical sources in images
 from both the PS\,1 and PS\,2 telescopes since 2008.  This software
@@ -3238,6 +3356,6 @@
 
 \bibliographystyle{apj}
-%\bibliography{lib}{}
-\input{analysis.bbl}
+\bibliography{lib}{}
+%\input{analysis.bbl}
 
 \end{document}
Index: trunk/doc/release.2015/ps1.analysis/response.txt
===================================================================
--- trunk/doc/release.2015/ps1.analysis/response.txt	(revision 41307)
+++ trunk/doc/release.2015/ps1.analysis/response.txt	(revision 41307)
@@ -0,0 +1,605 @@
+
+---------------------------------------------------------------------
+Referee Report
+Reviewer's Comments:
+This is an important piece of work to be published as the last of
+a set of seven papers describing the Pan-STARRS-1 survey and
+data release 1. It represents a substantial body of work over
+many years. There are no major revisions requested, but there
+are quite a number of suggestions to further improve the clarity of
+the presentation.
+
+The authors could present early in the paper that the goals of the
+accuracy for photometry and astrometry of stars has indeed been
+achieved, with quantitative estimates of the accuracy as presented
+in other PS1 papers, or even by others is comparisons to external
+data sets.
+
+**** TBD : all of these items until Abstract
+
+For many of the sections, the reader would benefit by starting with
+more of a description of the intention of the algorithms described.
+For example:
+
+- Section 4.1: The initial source detection is appears intended is
+identify bright point sources and omit extended sources. That should
+be stated, along with the goal of providing sources for the PSF modeling.
+
+- Section 4.4.3: The purpose of the moments is to identify problematic
+sources and to measure Kron magnitudes. The importance of the Kron
+fits isn't revealed until much later in Sec 4.6.5 in determining the
+classification of sources. This importance of Kron fits should
+therefore be described much earlier, and the rationale for using
+this for classification since it is typically a noisy measure.
+
+- Section 5: The extended source photometry has not been motivated
+and it is unclear what the goals are for those objects.
+
+The text doesn't explain how in general bad (saturated, light traps,
+masked) pixels are treated in the image. Presumably, these must be
+replaced with some value to allow measurements of some if not all
+of the source properties described in the paper. The large number
+of bad pixels is a motivation for all of the averaged quantities
+in Section 6, so it should be presented what fraction of pixels
+are compromised and what fraction of objects are compromised in
+individual images.
+
+** we do NOT interpolate or replace masked values; instead they are
+   ignored in model fits. their presence affects aperture-like
+   measurements.  TBD
+
+The paper should identify which of these measurements and tabulated
+mask values appear in the DR1 and DR2 data releases. For example,
+Tables 1-4 must refer to some named quantities in the data releases.
+This paper should also clearly indicate which quantities are recommended
+to be most reliable for point source astrometry, fluxes and colors.
+(My guess would be the astrometry from the stacked images in Sec 4.7, since
+those aren't recomputed; fluxes from the averaged forced photometry
+in Sec 6; and colors from either aperture photometry on the stacked
+images or from the averaged forced photometry, and the authors must
+know which is demonstrated to be more reliable). The paper should
+state the same for galaxy astrometry, fluxes and colors.
+
+A detail of the code is presented (variable names, etc) that imply
+that the code would be publicly available. Is it, and if so where?
+
+The other PS1 papers are discussed in the introduction, but not
+otherwise referenced throughout the paper. Some notable places
+where references to these other papers in the series should be made:
+
+- Sec 5.5, where the typical stellar detection limits are quoted
+
+- Sec 6, which of these averaged photometry measurements are used in
+the PS1 global photometry solution, and which papers demonstrate
+that the photometric goals are achieved
+
+- Sec 7, where the image differencing detections and photometry is used
+
+A handful of places use lower-case "psf" (Table 2 and pg 13) and
+should be written "PSF" for consistency. "chi-square" is used
+both lower-case and upper-case.
+
+A number of places refer to starting guesses for ML minimizations
+(search for "guess" in the text to find these). It would be useful
+to provide the formulae for these initializations (and potentially
+necessary if one were want to repeat the fits).
+
+Although this paper is primarily meant to present the decisions made
+in the calculations presented in the PS1 catalogs, the authors should
+consider including a section about any different choices were they
+to start such an effort in the future. There are a few places within
+the text where they allude to such things, but collecting these thoughts
+in one place would be a useful service.
+
+Abstract:
+- This abstract states this is the version used for the "first public
+release" of the data, but the text says this was used for both
+DR1 and DR2. Suggest explicitly stating this was used for Data Releases
+1 and 2.
+
+** fixed in abstract
+
+Intro:
+- "...and include an improved calibration of the PV3"
+Please specify if this is limited to the photometric calibration,
+or astrometry or any other parameters as well.
+
+** clarified in Intro, paragraph 5.
+
+- Intro should state that this analysis is applied to individual images,
+image stacks, and image differences (if true), and if the Medium Deep
+Field program makes use of the same code.
+
+** clarified in Intro, par 6
+
+Sec 2:
+- For the photometric accuracy goal, it's not stated here whether
+the 1% number is absolute or relative. Presumably, it's the relative
+photometry requirement that would be applicable to this work.
+(This is repeated in Sec 3.)
+
+** The goal was for accuracy within the Pan-STARRS photometric system,
+   but the requirement on the tie to the absolute flux system was not
+   as stringent.
+
+- IPP should be defined at first mention.
+
+** defined in Intro par 7
+
+- "CHIP analysis stage" is mentioned without definition.
+
+** defined in Background, par 6 (2nd after the bullets). 
+
+- For all of the "psphot" variants described, it would be of interest
+whether the various input images are required to be pixel-aligned.
+
+** clarified in Background, par 7 for psphotStack, reworded the
+   description for the basic psphot to clarify (Background, par 6),
+   added the word 'co-aligned' for psphotFullForce (Background, par 8)
+
+- Single-epoch images and stacked images should be explicitly defined here
+(not just the code that acts on them). There are some instances later
+that refer to "CAMERA", "CHIP" and "STACK" (upper-case), and common terminology
+should be used throughout. The usage of "CAMERA" and "CHIP" seem to be
+the same, but maybe they aren't?
+
+** Our typography is to write the major IPP analysis stages in
+   small-caps (CHIP, STACK, etc).  We added some words to Background,
+   par 6 to (minimally) define the stack stage and products.  We also
+   added a desription of the typographic choices (end of Intro).
+   Replaced Camera in a couple of places where the text should have
+   referred to the CHIP stage.  (Table 1 and Sec 4.8, par 5).
+
+Sec 3:
+- The overall design goals aren't stated: fluxes and positions for stars;
+fluxes and positions and shape parameters for galaxies suitably for
+weak lensing measurements; detection and measurements of transient
+sources for use by the Moving Object Pipeline for asteroids and supernovae.
+
+** good point: we added an intro paragraph to Sec 3 to explicity state
+   the top-level design goals.
+
+- The astrometry and photometry goals are likely written for stars,
+not galaxies. It should be explicitly stated the the quantitative goals
+are for the contributions to the errors beyond the statistical errors
+(it looks like you disfavor the term systematic errors?)
+
+** added text to specify that these are goals for bright stars where
+   photon noise is small compared to the systematic errors.
+
+- "astrometric accuracy goal" -> "relative astrometric accuracy goal"
+** fixed
+
+- "requirement" -> "goal" to be consistent with the text elsewhere
+** fixed, and cleaned the introduction sentence of 'requirement' vs
+'goal' confusion.
+
+Sec 4:
+- As a reader, I found it confusing to keep track of which measurements
+are only being made on the brightest 20-sigma sources, vs. the fainter
+5-sigma sources. For example, Sec 4.6.5 discussing doing fits to "all
+sources", but I think this might still only be to the 20-sigma detections?
+Consdier splitting this Sec 4 into two sections, one with all the subsections
+applying to bright sources, and another addessing all (==faint) sources.
+
+**** review this
+
+Sec 4.1:
+- This overview describes the PSF model class as being defined in step 3,
+but reading the text it appears that a set of PSF models are determined
+there and it is only during the faint source analysis (see very end
+of Sec 4.8) that the PSF model for an image is actually selected.
+
+**** clarify this
+** The aperture correction is measured at the end of the bright-star
+** pass, at which point the PSF model is chosen and fixed.  A final
+** aperture correction is measured at the end of the full analysis,
+** but only for the PSF model class selected earlier.
+
+Sec 4.3:
+- It would be of interest to state whether the convention is used for
+the images to be in units of ADU, electrons, or some other physical unit
+(albeit only approximately, owing to flat-fielding, etc).
+
+** IPP normally uses ADU (digital numbers), but psphot could be used
+   with other units if the variance is consistently defined.  Added
+   text to this effect.
+
+- Table 3 needs to be explicitly referenced in the 2nd paragraph.
+
+** added
+
+- Superpixels are defined in this section as something used for the sky
+fitting, but in fact are used in other contexts, so it would be
+good to define it as such and also state the typical physical scale.
+
+** added text to explain the difference between the sky superpixels,
+   the PSF parameter variations, and the thread assignment superpixels.
+
+- The sky fitting scale length of 400 pixels should be expressed
+in arcsec as well, and some discussion for the trade-offs in this choice.
+Are there any instrumental effects (ie, vignetting gradients) effecting
+this choice, or only sky and astrophysical?
+
+** added a paragraph to describe the rational for the choice of the scale
+
+- There must be an estimate of the accuracy of the mean sky heuristic,
+perhaps as just the step-function-difference of when the more complex
+measure is used.
+
+**** model?
+
+Sec 4.4.1:
+- For those readers unaware, the first paragraph could explain that
+in the limit of a Gaussian PSF and isolated sources, this is the
+optimal detection algorithm. Then the choice of approximating the
+PSF by a Gaussian for the convolution is presumably to allow the
+fast compution by having a kernal that's separable in x&y.
+
+** added text to explain that this is an optimal detection for sources
+   matching this PSF, but that since our goal is brighter sources, the
+   choice of smoothing function is not critical.  The smoothing at
+   this stage is to reduce the impact of pixel-to-pixel scatter on the
+   initial detections.
+
+- Par 2 should start by saying the intention is to uniquely identify
+peaks. The last sentence is missing some words.
+
+** clarified this 
+
+Sec 4.4.2:
+- Should be stated here and in the Fig 1 caption if these aren't
+straight line paths. Also, which path is chosen in the event
+that there are several?
+
+**** implementation looks for any key col between peaks that are
+      above a threshold, thus the highest one matters. ADD TO TEXT
+
+Sec 4.4.3:
+- "sigma_PSF which different" -> "sigma_PSF, which is different"
+** fixed
+
+- "and a trend this the" -- fix wording
+** fixed
+
+- semi-colon should be period before "The sums"
+** fixed
+
+- "be a large amount" -> "by a large amount"
+** fixed
+
+Sec 4.5.1:
+- PSF variations are due to optical aberration (and defocus), not-flatness
+of the CCDs, and atmospheric variation. It would be good to tell the
+reader the typical scale and amplitude of variations due to each of these.
+This may even warrant inclusion of on image of the PSF width variations
+for a typical exposure.
+
+**** SHOW SOME EXAMPLES of PSF variations 
+
+- Please state whether the PSF model is this set of formulae
+evaluated at the pixel centers, or must be integrated over the pixel,
+and the reason for the choice.
+** @ pixel centers (added sentence)
+
+- There are a few uses of "interpolation" in this section, the first
+use is presumably "linear interpolation", but the details of this
+for PSF interpolation are worth describing.
+** reworded to note that bi-linear interpolation in used
+
+- The last paragraph and formula in this section is inscrutable as
+R,R_0,R_X,... are undefined.
+
+** reworded to explain that these are the linear fit parameters for each pixel in the residual mode.
+
+Sec 4.5.2:
+- Since the GAIA catalog is now available, an interesting question is
+whether using that catalog for PSF star selection would be preferable
+to the heuristic of selecting such stars from the PS1 data. An interesting
+metric would be the fraction of PS1 PSF stars are confirmed to be point
+sources by GAIA.
+***** TBD
+
+Sec 4.5.3:
+- Please present the number of grid cells in these fits also in terms
+of the physical scale (in arcsec) on the sky for those grids. Both
+in the text and Table 5. This can be tied back to the requested
+description of the expected PSF variations in Sec 4.5.1.
+** adding in table in the the introductory text in section 4.5.1.
+
+- As discussed at the start of this report, the handing of masked
+pixels should be descsribed here. Some measurements (such as aperture flux)
+are formally undefined with even a single masked pixel; are those reported
+as undefined measurements, or are they measured with the pixels first
+replaced based upon interpolation or linear prediction or some other method?
+**** TBD
+
+Sec 4.5.3:
+- "smf/cmf files" are not defined or referenced anywhere else in this paper.
+** removed the jargon and replace with 'output FITS catalog files'
+
+PSPS if referred to few enough instances (3) in the paper, that it could be
+explicitly defined in each of those instances. The term "public" here
+isn't what many people would expect, so should be defined as public to
+the other code.
+**** TBD
+
+Sec 4.6.4:
+- "times" -> "\times"
+** fixed
+
+- Not clear why the geometric mean trick is necessary in this calculation
+to reduce blending issues if neighboring sources have already been subtracted.
+
+** only PSF models have been subtracted at this point, so galaxy
+   neighbors tend to leave behind a lot of contaminating flux.  Explanation added to text.
+
+Sec 4.5.4:
+- The term "size class" is only used once here, so perhaps only use
+the term "classification".
+** reworded to make this clearer.
+
+Sec 4.6.5:
+- PSPHOT.EXT.NSIGMA.LIMIT is the only variable that looks like this
+in the paper, and isn't defined in the tables.
+** we added an explanation at the end of Section 1 that the
+configuration variables, in fixed-width font, have the PV3 value
+listed after them in parenthesis.  We have also made the text more
+consistent about how this appears throughout the tex.
+
+- Explicitly state that the cosmic ray identification is based upon
+sources appearing more morphologically compact than the PSF.
+** done in 1st paragraph
+
+Sec 4.6.6:
+- This section should be greatly clarified. It sounds like the intention
+was to perform the same joint fit as described in Sec 4.6.1, and it's not
+clear why this was something different. The current text reads as if
+it's a single iteration of fitting one star at time, subtracting fits
+only to brighter neighboring stars. The paragraph beginning "Sources
+which are blended..." should be relegated to the end of the section,
+and presented as a future development effort.
+**** TBD
+
+- Remind the reader that the 4 independent parameters includes a local sky
+value.
+**** TBD: double-check if the sky is allowed to float in this step
+
+- "remaining flux should be below 1\sigma significance" ->
+"remaing flux divided by the errors should be normally distributed about 1"
+** fixed wording 
+
+Sec 4.6.7:
+- This double-star case would be a common and interesting case, and it
+is worth demonstrating the validity of this approach. No doubt simulations
+were run showing this approach works for some separation and flux ratio
+range.
+**** TDB: was the turned on for PV3?
+
+Sec 4.7:
+- Completeness and purity should be discussed here. Even if this is
+more fully described in another paper, a summary of those findings
+could be included here.
+**** TBD: include detection limit description
+
+Sec 4.8:
+- The pronouncement that the wings of the PSF do not change significantly
+or quickly should be backed up with a reference, if possible. I'm not
+aware of a thorough study of this (although there may be one), and the
+PS1 data may be the best data set to ask these questions.
+
+** The argument in the paragraph, that photometry using a large
+aperture can correct the PSF photometry, does not really depend on the
+stability of the wide wings as much on the small fraction of light in
+the wings.  Since we could not back up the statement about the source
+of the wide wings (and Saglia et al 1993 shows some variations in the
+wings of MDM 1.3 and JKT 1m data), we have removed that part of the
+argument and simplified that paragraph. A larger study of stellar
+profiles from PS1 on large scales would be interesting, but beyond the
+scope of this papper.
+
+- "ApResid" is only sort of defined implicitly.  
+
+** The choice of PSF model form is actually made early on, after the
+first pass on bright stars (section 4.5).  The choice of the model is
+based on the psf - aperture (ApResid) residual scatter.  The discussion of the model
+selection at this point in the paper was an artifact of an attempt to
+consolidate the discussion of the aperture correction with the earlier
+aperture photometry.  We've fixed the text to leave the discussion of
+the selection of the PSF model form in section 4.5 and leave 4.8 to
+the calculation of the aperture correction for the photometry.  As a
+result, we eliminate the term ApResid entirely.
+
+- It's interesting that the choice of the PSF model is made based upon
+the fainter, not the brighter, stars.
+
+** this is not the case, but the organization made it seem that way.
+   See previous comment.
+
+- An interesting result is the fraction of images that use each of the
+PSF models, and whether that strongly depends upon the density of stars
+and/or filter, or to what extent a similar image requires a different PSF
+model owing to atmospheric variations. For example, in the following
+section 4.9, has the same PSF model class been automatically selected
+for all 18 images?
+** This would be very interesting, but unfortunately we only used the
+single functional form PS1_V1 for all of the PV3 analysis.  We've
+added text to section 4.5 to state that explicitly.
+
+Sec 4.9:
+- A very interesting quantitative result that could be shown here is
+the variation in bright star magnitudes using aperture photometry.
+This would be a measure of the site's atmospheric transparency variations.
+There are results for this presented in the conclusions of an earlier PS1
+paper ("Photometric Calibration..."), but those ~10 mmag numbers may
+be dominated by the PSF mis-estimation of bright stars rather than the
+atmospheric transparency variations.
+**** TBD
+
+Sec 5:
+- "to all object" -> "to all objects"
+** fixed
+
+- The definition of where in Galactic coordinates extended source photometry
+is performed is a little confusing. If the "l" in the in-text formula
+is galactic latitude, is it really the case that no extended source
+photometry is performed within 65 deg of the galactic center?
+Is this decision made for all sources within the same image, or is
+the decision made object-by-object?
+**** Draw a little picture?
+** The avoidance contour approaches a constant Galactic
+latitude far from the galactic center, but rises in a Gaussian shape
+to avoid the bulge, with the max avoidance latitude of 35 degrees at Galactic
+longitude of 0.0.  
+
+Sec 5.2:
+- The argument is that the surface brightness *profile shape* is conserved,
+not that the surface brightness is conserved with distance, which of
+course it is not.
+** right, fixed wording
+
+- It may be useful to point out that these choices of Petrosian parameters
+to evaluate (R50 and R90 using circular aperatures) appears to be the same
+as those in the SDSS catalogs. Can one expect those quantities to
+compare well to those in the PS1 catalog?
+**** compare to SDSS
+
+Sec 5.3:
+- Equn 28 is a blank line
+** fixed
+
+- Equn 27 would conventionally be written after equns 29-32 as "with
+the definition f_p=..." (remove the word "simplify").
+** re-written as suggested
+
+- "and/or" -> "or" ?
+** fixed
+
+- "In the analysis, convolved galaxy fit..." -> "In the convolved galaxy fits..."
+** fixed
+
+- Graham & Driver missing in the References
+** fixed
+
+- For the approximation of the central pixel values, the maximum fractional
+error of this approximation should be stated.
+**** TBD
+
+Sec 5.4:
+- It's not clear what happens with poor-quality (worse than 1.5 or 2.0
+arcsec seeing) images. Have they been included in the image stack, and
+the assumption made that the stacked seeing is always better than that?
+- It's convenient that the aperture fluxes are made with the same choice
+of radii as used in SDSS. However, it should be noted here that the
+SDSS aperture fluxes in the SDSS catalogs are computed without any
+convolution. Since the median SDSS seeing is ~1.5 arcsec, those may
+be expected to compare well with the 1.5-arcsec convolved PS1 aperture fluxes.
+
+Sec 5.5:
+- State the seeing of these simulated images.
+
+Sec 6 and 6.1:
+- These sections could be clarified by splitting the sections, and
+calling the section something like "Averaged Single-Epoch Measurements"
+(where single-epoch could be "warp image" or whatever appropriate). Forced
+photometry is only performed on the stars, and it's something very
+different from the galaxies. The lensing subsection isn't "photometry"
+at all. What all 3 subsections have in common is that measurements
+are made on all of the single-epoch images, and then those measurements
+are averaged.
+- The general description of the section should end with "variant of psphot",
+with the motivation being written such that it applies to both the
+averaged forced photometry on stars and the averaged single-epoch fits
+for galaxies
+
+Sec 6.1 (now 6.2):
+- CFHT, COSMOS should have citations to the relevant publications
+discussing their stacked images. There are multiple possible references
+for the mathematical appropriateness of image stacking, a nice recent
+discussion would be Zackay & Ofek 2016.
+- The terms "skycell" and "warp image" are first used here without
+definition. Are warp images the same as CAMERA and CHIP?
+- For the forced photometry on single epoch images, is this a joint
+fit for overlapping objects?
+Are overlapping galaxy models subtracted first? "The PSF model is
+fitted..." -> "The amplitude of the PSF model is fitted as the flux..."
+
+Sec 6.2 (now 6.3):
+- The reader only learns in the last few sentences that lensing
+parameters are an average of all of the single-epoch measurements.
+This should be stated upfront, and then again at the end of the subsection
+clarifying how the PSF systematics are removed. Phrases like
+"interpolated PSF ellipticities" are confusing, when I *think* what's
+being used are "interpolated star ellipticities".
+- Was this lensing code used in any of the GREAT challenge papers,
+and if not, which code would it be most similar to?
+- Define "KSB" and "HFK" references in-line
+- "ie,," -> "ie,"
+" absoluate" -> "absolute"
+
+Sec 7:
+- This section is more cursory than the other sections. It's not clear
+how the end user should identify high-confidence asteroid or comet
+detections, and the completeness and purity of such detections.
+If these questions are covered in other Pan-STARRS papers, please reference
+them here.
+- A basic piece of information that should be given is whether the differencing
+is performed on pairs of images, or single (warp) images compared to
+image stacks.
+- "model from is" -> "model is"
+
+Conclusions:
+- The PS2 telescope is only mentioned here. At least give a reference.
+
+Tables:
+- For all of the tables, a caption should be included that explicitly
+describes all of the columns. Some readers will be using these papers
+as reference material, in which case the tables should be self-explanatory.
+
+Tables 2,3,4:
+- Please provide the names of these masks in the data products. From the
+text, the only mapping I could figure out is that Table 3 corresponds
+to "mask2".
+
+Figures:
+- For all the multi-panel figures, typical style would be to label
+each of the sub-panels (a), (b), etc, and describe in the caption.
+
+Figure 2:
+- "window" in the figure text should be "\sigma_w" to be consistent
+with the caption and text.
+- For Figures 2,5,6, please do the mathematical calisthenics of stating
+how these instrumental magnitudes can be read as magnitudes above the
+detection threshold. If possible, it would be preferable to convert
+these figures to threshold magnitudes as done for Figure 7.
+
+Figure 3:
+- This figure isn't referenced in the text.
+- State if each point is a single pixel value.
+- State whether the black line model is part of the PSF models for these
+particular stars
+
+Figure 4:
+- State that this is for one image (or image stack?), with each source
+denoted by a point.
+
+Figures 5 and 6:
+- I can't find a definition of "STS" anywhere in the text.
+- Upper panels should be labeled "Number of stars".
+
+Figure 7:
+- Caption should specify the seeing of these images (not in the text either).
+
+Figures 8 and 9:
+- These figures need much more explanation. The upper-left panel is
+presumably an RMS of the total magnitudes from the simulations?
+The upper right panel shows "ellipticity", which is not a defined quantity
+in the text. The other 4 panels could refer to the explanation in Sec 5.5.
+
+References:
+- It would be helpful to append "[Paper I]", "[Paper II]", etc, to
+the references for this sequence of papers.
+- It would be helpful to append "[KSB]" and "[HFK]" to those references
+since they are cited that way in the text.
+- Some additional references should be included; some suggestions above.
+
