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)

File:
1 edited

Legend:

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

    r39618 r39920  
    1 
     1\documentclass[12pt,preprint]{aastex}
    22%\documentclass[iop,floatfix]{emulateapj}
    33
    4 % \pdfoutput=1
     4\pdfoutput=1
    55
    66% see latex.readme.txt for notes on using the PS1 template
    7 \documentclass[12pt,preprint]{aastex}
     7
    88%\documentclass[manuscript]{aastex}
    99%\documentclass[preprint2]{aastex}
    1010%\documentclass[preprint2,longabstract]{aastex}
     11
    1112\RequirePackage{color}
    1213\input{astro.sty}
    1314%\usepackage{subcaption}
     15%\usepackage{natbib}
    1416
    1517% online version may use color, but print version needs b/w
     
    3335}
    3436\newcommand{\erfcinv}{\mathop{\rm erfcinv}\nolimits}
    35 \newcommand{\ippprog}[1]{\textbf{\texttt{#1}}}
    36 \newcommand{\ippstage}[1]{\textsc{#1}}
     37% CZW Moved to global input file.
     38%\newcommand{\ippprog}[1]{\textbf{\texttt{#1}}}
     39%\newcommand{\ippstage}[1]{\textsc{#1}}
    3740\newcommand{\asinh}{\mathop{\rm asinh}\nolimits}
    38 
    3941
    4042% Pick a terse version of the title here;
     
    4951% list and (2) re-order the list at the bottom (and comment-out as needed)
    5052\def\IfA{1}
    51 \def\CfA{2}
    52 \def\MPIA{3}
    53 \def\Princeton{3}
    54 \def\USNO{4}
    55 \def\JHU{1}
     53\def\Princeton{2}
     54\def\DUR{3}
     55\def\STSCI{4}
     56\def\Pitt{5}
     57%\def\CfA{2}
     58%\def\MPIA{3}
     59%\def\USNO{4}
     60%\def\JHU{1}
    5661
    5762% This example has a first author from UH:
    5863\author{
    59 C. Z. Waters,\altaffilmark{\IfA}
    60 IPP Team,
     64C.~Z. Waters,\altaffilmark{\IfA}
     65E.~A. Magnier,\altaffilmark{\IfA}
     66P.~A. Price,\altaffilmark{\Princeton}
     67K.~C. Chambers,\altaffilmark{\IfA}
     68W.~S. Burgett,\altaffilmark{\IfA}
     69P. Draper,\altaffilmark{\DUR}
     70H.~A. Flewelling,\altaffilmark{\IfA}
     71K. W. Hodapp,\altaffilmark{\IfA}
     72M.~E. Huber,\altaffilmark{\IfA}
     73R. Jedicke,\altaffilmark{\IfA}
     74N. Kaiser,\altaffilmark{\IfA}
     75R.-P. Kudritzki,\altaffilmark{\IfA}
     76R.~H. Lupton,\altaffilmark{\Princeton}
     77 N. Metcalfe,\altaffilmark{\DUR}
     78A. Rest,\altaffilmark{\STSCI}
     79W.~E. Sweeney,\altaffilmark{\IfA}
     80J.~L. Tonry, \altaffilmark{\IfA}
     81R.~J. Wainscoat,\altaffilmark{\IfA}
     82W.~M. Wood-Vasey\altaffilmark{\Pitt}
     83}
     84%PS1 Builders
    6185%PS Builder List
    62 % W.~S. Burgett,\altaffilmark{\IfA}
    63 % K.~C. Chambers,\altaffilmark{\IfA}
     86
    6487% L. Denneau,\altaffilmark{\IfA}
    65 % P. Draper,\altaffilmark{\DUR}
    66 % H.~A. Flewelling,\altaffilmark{\IfA}
    6788% T. Grav,\altaffilmark{\IfA}
    6889% J. N. Heasley,\altaffilmark{\IfA}
    69 % K. W. Hodapp,\altaffilmark{\IfA}
    70 % M. E. Huber,\altaffilmark{\IfA}
    71 % R. Jedicke,\altaffilmark{\IfA}
    72 % N. Kaiser,\altaffilmark{\IfA}
    73 % R.-P. Kudritzki,\altaffilmark{\IfA}
    7490% G. A. Luppino,\altaffilmark{\IfA}
    75 % R. H. Lupton,\altaffilmark{\Princeton}
    76 % E. A. Magnier,\altaffilmark{\IfA}
    77 % N. Metcalfe,\altaffilmark{\DUH}
    7891% D. G. Monet,\altaffilmark{\USNO}
    7992% J.~S. Morgan,\altaffilmark{\IfA}
    8093% P. M. Onaka,\altaffilmark{\IfA}
    81 % P.~A. Price,\altaffilmark{\Princeton}
    8294% C.~W. Stubbs,\altaffilmark{\CfA}
    83 % W.~E. Sweeney,\altaffilmark{\IfA}
    84 % J.~L. Tonry, \altaffilmark{\IfA}
    85 % R. J. Wainscoat,\altaffilmark{\IfA} and
    86 % C. Z. Waters,\altaffilmark{\IfA}
    87 } % this bracket terminates author list
     95 % this bracket terminates author list
    8896
    8997% The ordering here should be sequential, matching the sequence in the list of authors:
    9098\altaffiltext{\IfA}{Institute for Astronomy, University of Hawaii, 2680 Woodlawn Drive, Honolulu HI 96822}
    9199% \altaffiltext{\CfA}{Harvard-Smithsonian Center for Astrophysics, 60 Garden Street, Cambridge, MA 02138}
    92 % \altaffiltext{\Princeton}{Department of Astrophysical Sciences, Princeton University, Princeton, NJ 08544, USA}
     100\altaffiltext{\Princeton}{Department of Astrophysical Sciences, Princeton University, Princeton, NJ 08544, USA}
     101\altaffiltext{\STSCI}{Space Telescope Science Institute, 3700 San Martin Drive, Baltimore, MD 21218, USA}
     102\altaffiltext{\DUR}{Department of Physics, Durham University, South Road, Durham DH1 3LE, UK}
     103\altaffiltext{\Pitt}{Pittsburgh Particle Physics, Astrophysics, and Cosmology Center (PITT PACC), Physics and Astronomy Department, University of Pittsburgh, Pittsburgh, PA 15260, USA}
    93104% \altaffiltext{\USNO}{US Naval Observatory, Flagstaff Station, Flagstaff, AZ 86001, USA}
    94105% \altaffiltext{\JHU}{Department of Physics and Astronomy, Johns Hopkins University, 3400 North Charles Street, Baltimore, MD 21218, USA}
     
    96107\begin{abstract}
    97108
    98 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum
    99 bibendum nisi id tristique posuere. Duis eu mollis nulla. Maecenas est
    100 turpis, mattis tempor urna vitae, placerat rhoncus sem. Lorem ipsum
    101 dolor sit amet, consectetur adipiscing elit. Sed quis velit
    102 nisl. Aliquam erat volutpat. Cras lacinia, nisl tristique auctor
    103 molestie, dolor nulla rhoncus purus, ac accumsan nunc nunc ac
    104 nibh. Maecenas vitae mollis mauris. Ut sollicitudin pulvinar purus,
    105 eget luctus lorem tincidunt vitae. Vestibulum eu mattis neque. Nulla
    106 in tortor id urna dapibus gravida a vel leo.
     109The Pan-STARRS1 Science Consortium have carried out a set of imaging
     110surveys using the 1.4 giga-pixel GPC1 camera on the PS1 telescope.  As
     111this camera is composed of many individual electronic readouts, and
     112covers a very large field of view, great care was taken to ensure that
     113the many instrumental effects were corrected to produce the most
     114uniform detector response possible.  We present the image detrending
     115steps used as part of the processing of the data contained within the
     116public release of the Pan-STARRS1 Data Release 1 (DR1).  In addition
     117to the single image processing, the methods used to transform the
     118375,573 individual exposures into a common sky-oriented grid are
     119discussed, as well as those used to produce both the image stack and
     120difference combination products.
    107121
    108122\end{abstract}
     
    111125\keywords{Surveys:\PSONE }
    112126
    113 %% http://articles.adsabs.harvard.edu/cgi-bin/nph-iarticle_query?2007ASPC..364..153M&data_type=PDF_HIGH&whole_paper=YES&type=PRINTER&filetype=.pdf
    114127\section{Introduction and Survey Description}
     128
     129This is the third in a series of seven papers describing the Pan-STARRS1
     130Surveys,
     131the data reduction techniques and the resulting data products. This paper (Paper III)
     132describes the details of the pixel processing algorithms, including
     133detrending, warping, and adding (to create stacked images) and subtracting
     134(to create difference images) and resulting image products and their
     135properties.
     136\citet[][Paper I]{chambers2017} provides an overview of the Pan-STARRS System, the
     137design and execution of the Surveys, the resulting image and catalog data
     138products, a discussion of the overall data quality and basic
     139characteristics, and a brief summary of important results.
     140%Magnier et al. 2017 (Paper II)
     141%Pan-STARRS Data Processing Stages
     142\citet[][Paper II]{magnier2017a}
     143describes how the various data processing stages are organized and
     144implemented
     145in the Imaging Processing Pipeline (IPP), including details of the
     146the processing database which is a critical element in the IPP
     147infrastructure.
     148%Waters et al. 2017 (Paper III)
     149%Pan-STARRS Pixel Processing : Detrending, Warping, Stacking
     150%\citet[][Paper III]{waters2017}
     151%Magnier et al. 2017 (Paper IV)
     152%Pan-STARRS Pixel Analysis : Source Detection
     153\citet[][Paper IV]{magnier2017b}
     154describes the details of the source detection and photometry, including
     155point-spread-function and extended source fitting models, and the
     156techniques for ``forced'' photometry measurements.
     157%Magnier et al. 2017 (Paper V)
     158%Pan-STARRS Photometric and Astrometric Calibration
     159\citet[][Paper V]{magnier2017c}
     160describes the final calibration process, and the resulting photometric and
     161astrometric quality.
     162%Flewelling et al. 2017 (Paper VI)
     163%Pan-STARRS 1 Database and Data Products
     164\citet[][Paper VI]{flewelling2017}
     165describes  the details of the resulting catalog data and its organization
     166in the Pan-STARRS database.
     167%
     168%
     169\citet[][Paper VII]{huber2017}
     170%Huber et al. 2017 (Paper VII)
     171describes the Medium Deep Survey in detail, including the unique issues and
     172data products specific to that survey. The Medium Deep Survey is not part
     173of Data Release 1. (DR1)
     174The Pan-STARRS1 filters and photometric system has already been described
     175in detail in \cite{2012ApJ...750...99T}.
    115176
    116177
     
    118179with the PS1 telescope on Haleakala Maui to image the sky north of
    119180$-30^\circ$ declination.  The GPC1 camera is composed of 60 orthogonal
    120 transfer array (OTA) devices, each of with is an $8\times{}8$ grid of
     181transfer array (OTA) devices, each of which is an $8\times{}8$ grid of
    121182readout cells.  This parallelizes the readout process, reducing the
    122183overhead in each exposure.  However, as a consequence of this large
    123 number of individual detector readouts, there are a number of
    124 calibrations that need to be included to ensure the response is
    125 consistent across the entire field of view.
    126 
    127 The PV3 reduction represents the third full processing version of the
    128 Pan-STARRS archival data.  The first two reductions were used
    129 internally for pipeline optimization and the development of the
    130 initial photometric and astrometric reference catalog.  The products
    131 from these reductions were not publicly released, but have been used
    132 to produce a wide range of scientific papers from the Pan-STARRS 1
    133 Science Consortium members.
     184number of individual detector readouts, many calibrations are needed
     185to ensure the response is consistent across the entire field of view.
     186
     187The Processing Version 3 (PV3) reduction represents the third full
     188reduction of the Pan-STARRS archival data.  The first two reductions
     189were used internally for pipeline optimization and the development of
     190the initial photometric and astrometric reference catalog \citep{magnier2017c}.  The
     191products from these reductions were not publicly released, but have
     192been used to produce a wide range of scientific papers from the
     193Pan-STARRS 1 Science Consortium members.
    134194
    135195The Pan-STARRS image processing pipeline (IPP) is described elsewhere
    136 \citep{MagnierKaiserChambers2006}, but a short summary follows.  The
     196\citep{magnier2017a}, but a short summary follows.  The
    137197archive of raw exposures is stored on disk, with a database storing
    138198the metadata of exposure parameters.  For the PV3 processing, large
     
    141201This stage performs the image detrending (described below in section
    142202\ref{sec:detrending}), as well as the single epoch photometry
    143 \citep{MagnierXXY}, in parallel on the individual OTA device data.
     203\citep{magnier2017b}, in parallel on the individual OTA device data.
    144204Following the \ippstage{chip} stage is the \ippstage{camera} stage, in
    145205which the astrometry and photometry for the entire exposure is
    146 calibrated against the reference catalog.  This stage also performs
    147 masking updates based on the now-known positions and brightnesses of
    148 stars that create dynamic features (see Section
    149 \ref{sec:dynamic_masks} below).  The \ippstage{warp} stage is the next
    150 to operate on the data, transforming the detector oriented
    151 \ippstage{chip} stage images into sky oriented images that have common
    152 tessellations and sky projections (Section \ref{sec:warping}).  When
    153 all \ippstage{warp} stage processing is done for the region of the
    154 sky, \ippstage{stack} processing is performed (Section
    155 \ref{sec:stacking}) to construct deeper, fully populated images from
    156 the set of \ippstage{warp} images that cover that region of the sky.
    157 Beyond the \ippstage{stack} stage, a series of additional stages are
    158 done that are more fully described in other papers.  Transient
    159 features are identified in the \ippstage{diff} stage, which takes
    160 input \ippstage{warp} and/or \ippstage{stack} data and performs image
    161 differencing \citep{HuberXXX}.  Further photometry is performed in the
    162 \ippstage{staticsky} and \ippstage{skycal} stages, which add extended
    163 source fitting to the point source photometry of objects detected in
    164 the \ippstage{stack} images, and calibrate the results against the
    165 reference catalog.  The \ippstage{fullforce} stage takes the catalog
    166 output of the \ippstage{skycal} stage, and uses the objects detected
    167 in that to perform forced photometry on the individual \ippstage{warp}
    168 stage images.  The details of these stages are provided in
    169 \citet{MagnierXXY}.
     206calibrated by matching the detections against the reference catalog.
     207This stage also performs masking updates based on the now-known
     208positions and brightnesses of stars that create dynamic features (see
     209Section \ref{sec:dynamic_masks} below).  The \ippstage{warp} stage is
     210the next to operate on the data, transforming the detector oriented
     211\ippstage{chip} stage images onto common sky oriented images that have
     212fixed sky projections (Section \ref{sec:warping}).  When all
     213\ippstage{warp} stage processing is done for the region of the sky,
     214\ippstage{stack} processing is performed (Section \ref{sec:stacking})
     215to construct deeper, fully populated images from the set of
     216\ippstage{warp} images that cover that region of the sky.  Beyond the
     217\ippstage{stack} stage, a series of additional stages are done that
     218are more fully described in other papers.  Transient features are
     219identified in the \ippstage{diff} stage, which takes input
     220\ippstage{warp} and/or \ippstage{stack} data and performs image
     221differencing (Section \ref{sec:diffs}).  Further photometry is
     222performed in the \ippstage{staticsky} and \ippstage{skycal} stages,
     223which add extended source fitting to the point source photometry of
     224objects detected in the \ippstage{stack} images, and calibrate the
     225results against the reference catalog.  The \ippstage{fullforce} stage
     226takes the catalog output of the \ippstage{skycal} stage, and uses the
     227objects detected in that to perform forced photometry on the
     228individual \ippstage{warp} stage images.  The details of these stages
     229are provided in \citet{magnier2017b}.
    170230
    171231The same reduction procedure described above is also performed in real
     
    178238\ippstage{diff} stage.  This allows the ongoing solar system moving
    179239object search to identify candidates for follow up observations within
    180 24 hours of the initial set of observations \citep{WainscoatXXX}.
    181 
    182 \czwdraft{Should there be a discussion of any header keywords/OTA file formats?}
    183 
    184 Section \ref{sec:detrend construction} provides an overview of the
    185 detrend creation process for GPC1, with details of the application of
    186 those detrends to correct particular issues in Section
    187 \ref{sec:detrending}.  An analysis of the algorithms used to complete
    188 the \ippstage{warp} (section \ref{sec:warping}) and \ippstage{stack}
    189 (section \ref{sec:stacking}) stage transformations of the image data
    190 to from the detector frame to a common sky frame, and the co-adding of
     24024 hours of the initial set of observations \citep{2015IAUGA..2251124W}.
     241
     242Section \ref{sec:detrending} provides an overview of the detrending
     243process that corrects the instrumental signatures of GPC1, with
     244details of the construction of those detrends in Section
     245\ref{sec:detrend construction}.  An analysis of the algorithms used to
     246complete the \ippstage{warp} (section \ref{sec:warping}),
     247\ippstage{stack} (section \ref{sec:stacking}), and \ippstage{diff}
     248(section \ref{sec:diffs}) stage transformations of the image data to
     249from the detector frame to a common sky frame, and the co-adding of
    191250those common sky frame images continues after the list of detrend
    192251steps.  Finally, a discussion of the remaining issues and possible
    193252future improvements is presented in section \ref{sec:discussion}.
    194253
    195 
    196 \czwdraft{Is this a sufficient explanation?  Also, is this the right
    197   place for it?}  Image products presented in figures have been
    198 mosaicked to arrange pixels in the following way.  Single cell images
    199 are arranged such that pixel $(1,1)$ is at the lower left corner.
    200 Images mosaicked to the OTA level have cell xy00 in the lower left
    201 corner, with cells xy10, xy20, etc. sequentially to the right, and
    202 cells xy01, xy02, etc. sequentially to the top of this cell.  Again,
    203 pixel $(1,1)$ of cell xy00 is located in the lower left corner of the
    204 image.  For mosaics of the full field of view, the OTAs are arranged
    205 as they see the sky.  The lower left corner is the empty location
    206 where OTA70 would exist.  Toward the right, the OTA labels decrease in
    207 $X$ label, with the empty OTA00 located in the lower right.  The OTA
    208 $Y$ labels increase upward in the mosaic.  The OTAs to the left of the
    209 midplane (OTA4Y-OTA7Y) are oriented with cell xy00 and pixel $(1,1)$
    210 to the lower left of their position.  Due to the electronic
    211 connections of the OTAs in the focal plane, the OTAs to the right of
    212 the midplane (OTA0Y-OTA3Y) oriented with cell xy00 and pixel $(1,1)$
    213 to the top right of their position, and have a negative parity to the
    214 mosaic in both x and y.
    215 
    216 % Discuss 2-phase/3-phase device differnces
    217 
    218 %\section{General Detrend Discussion}
    219 %\label{sec:detrending}
     254Image products presented in figures have been
     255mosaicked to arrange pixels as follows.  Single cell images are
     256arranged such that pixel $(1,1)$ is at the lower left corner.  Images
     257mosaicked to the OTA level have cell xy00 in the lower left corner,
     258with cells xy10, xy20, etc. sequentially to the right, and cells xy01,
     259xy02, etc. sequentially to the top of this cell.  Again, pixel $(1,1)$
     260of cell xy00 is located in the lower left corner of the image.  For
     261mosaicks of the full field of view, the OTAs are arranged as they see
     262the sky.  The lower left corner is the empty location where OTA70
     263would exist.  Toward the right, the OTA labels decrease in $X$ label,
     264with the empty OTA00 located in the lower right.  The OTA $Y$ labels
     265increase upward in the mosaic.  The OTAs to the left of the midplane
     266(OTA4Y-OTA7Y) are oriented with cell xy00 and pixel $(1,1)$ to the
     267lower left of their position.  Due to the electronic connections of
     268the OTAs in the focal plane, the OTAs to the right of the midplane
     269(OTA0Y-OTA3Y) are rotated 180 degrees, and are oriented with cell xy00
     270and pixel $(1,1)$ to the top right of their position.
     271
     272\textit{Note: These papers are being placed on the arXiv.org to
     273  provide crucial support information at the time of the public
     274  release of Data Release 1 (DR1).  We expect the arXiv versions to be
     275  updated prior to submission to the Astrophysical Journal in January
     276  2017.  Feedback and suggestions for additional information from early
     277  users of the data products are welcome during the submission and
     278  refereeing process.}
     279
     280
     281\section{GPC1 Detrend Details}
     282\label{sec:detrending}
     283
     284Ensuring a consistent and uniform detector response across the
     285three-degree diameter field of view of the GPC1 camera is essential to
     286a well calibrated survey.  Many standard image detrending steps are
     287done for GPC1, with overscan subtraction removing the detector bias
     288level, dark frame subtraction to remove temperature and exposure time
     289dependent detector glows, and flat field correction to remove pixel to
     290pixel response functions.  We also construct fringe correction for the
     291reddest data in the \yps{} filter, to remove the interference patterns that
     292arise in that filter due to the variations in the thickness of the
     293detector surface.
     294
     295These corrections, however, assume that the detector response is
     296linear across the full range of values.  This is not universally the
     297case with GPC1, and this requires an additional set of detrending
     298steps to remove these non-linear responses.  The first of these is the
     299\ippprog{burntool} correction, which removes the persistence trails
     300caused by the incomplete transfer of charge along the readout columns.
     301This bright-end nonlinearity is generally only evident for the
     302brightest stars, as only pixels that are at or beyond the saturation
     303point of the detector have this issue.  More widespread is the
     304non-linearity at the faint end of the pixel range.  Some readout cells
     305and some readout cell edge pixels experience a sag relative to linear
     306at low illumination, such that faint pixels appear fainter than
     307expected.  The correction to this requires amplifying the pixel values
     308in these regions to match the expected model.
     309
     310The final non-linear response issue has no good option for correction.
     311Large regions of some OTA cells experience significant charge transfer
     312issues, making them unusable for science observations.  These regions
     313are therefore masked in processing, with these CTE regions making up
     314the largest fraction of masked pixels on the detector.  Other regions
     315are masked for other regions, such as static bad pixel features or
     316temporary readout masking caused by issues in the camera electronics
     317that make these regions unreliable.  These all contribute to the
     318detector mask, which is augmented in each exposure for dynamic
     319features that are masked based on the astronomical features within the
     320field of view.
     321
     322For the PV3 processing, all detrending is done by the
     323\ippprog{ppImage} program.  This program applies the detrends to the
     324individual cells, and then an OTA level mosaic is constructed for the
     325science image, the mask image, and the variance map image.  The single
     326epoch photometry is done at this stage as well.  The following
     327subsections (\ref{sec:burntool} - \ref{sec:background}) detail these
     328detrending steps, presented in the order in which they are applied to
     329the individual OTA image data.
     330
     331\subsection{Burntool / Persistence effect}
     332\label{sec:burntool}
     333
     334Pixels that approach the saturation point on GPC1, which varies by
     335readout with common values around 60000 DN, cause persistence problems
     336on that and subsequent images.  During the read out process of an
     337image with such a bright pixel, some of the charge associated with it
     338is not fully shifted down the detector column toward the amplifier.
     339As a result, this charge remains in the starting cell, and is
     340partially collected in subsequent shifts, resulting in a ``burn
     341trail'' that extends from the center of the bright source away from
     342the amplifier (vertically along the pixel columns toward the top of
     343the cell).
     344
     345This incomplete charge shifting in nearly full wells continues as each
     346row is read out.  This results in a remnant charge being deposited in
     347the pixels that the full well was shifted through.  In following
     348exposures, this remnant charge leaks out, resulting in a trail that
     349extends from the initial location of the bright source on the previous
     350image towards the amplifier (vertically down along the pixel column).
     351This remnant charge can remain on the detector for up to thirty
     352minutes, requiring the locations of these ``burns'' be retained
     353between exposures.
     354
     355Both of these types of persistence trails are measured and optionally
     356repaired via the \ippprog{burntool} program.  This program does an
     357initial scan of the images, and identifies objects with pixel values
     358brighter than a conservative threshold of 30000 DN.  The trail from
     359the peak of that object is fit with a one-dimensional power law in
     360each pixel column above the threshold, based on empirical evidence
     361that this is the functional form of this persistence effect.  This
     362also matches the expectation that a constant fraction of charge is
     363incompletely transferred at each shift beyond the persistence
     364threshold.  Once this fit is done, the model can be subtracted from
     365the image, and the location of the star is stored in a table along
     366with the exposure PONTIME, which denotes the number of seconds since
     367the detector was last powered on, and provides an internally consistent
     368time scale.
     369
     370For subsequent exposures, the table associated with the previous image
     371is read in, and after correcting trails from the stars on the new
     372image, the positions of the bright stars from the table are used to
     373check for remnant trails on the image.  These are fit and subtracted
     374using a one-dimensional exponential model, again based on empirical
     375studies.  If a significant model is found, then this location is
     376retained in the image output table.  If not, the old burn is allowed
     377to expire.
     378
     379The main concern with this method of correcting the persistence trails
     380is that it is based on fits to the raw image data, which may have
     381other signal sources not determined by the persistence effect.  The
     382presence of other stars or artifacts along the path of the burn can
     383result in a poor model to be fit, resulting in either an over- or
     384under-subtraction of the persistence burn.  For this reason, the image
     385mask is marked with a value indicating that this correction has been
     386applied.  These pixels are not fully excluded, but they are marked as
     387suspect, which allows them to be excluded from consideration in
     388subsequent stages, such as image stacking.
     389
     390Another concern is that the cores of very bright stars are deformed by
     391this process, as the burntool fitting subtracts flux
     392from only one side of the star.  As most stars that result in burns already
     393have saturated cores, they are already ignored for the purpose of
     394PSF determination and are flagged as saturated by the photometry
     395reduction.
     396
     397\begin{figure}
     398  \centering
     399  \begin{minipage}{0.45\hsize}
     400    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_XY11_bt_trail.png}
     401%    \caption{(a)}
     402%  \end{subfigure}%
     403%  \begin{subfigure}[]{.45\hsize}
     404  \end{minipage}%
     405  \begin{minipage}{0.45\hsize}
     406    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0124o_XY11_bt_trail.png}
     407%    \caption{(b)}
     408%  \end{subfigure}
     409  \end{minipage}
     410
     411  \caption{Example of a profile cut along the y-axis through a bright star on exposure o5677g0123o OTA11 in cell xy60 (left panel) and on the subsequent exposure o5677g0124o (right panel).  In both figures, the green points show the image corrected with all appropriate detrending steps, but without burntool applied, illustrating the amplitude of the persistence trails.  The red points show the same data after the burntool correction, which reduces the impact of these features.  Both exposures are in the \gps{} filter with exposure times of 43s}
     412\end{figure}
     413
     414\begin{figure}
     415  \centering
     416  \begin{minipage}{0.45\hsize}
     417    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_XY11_nobt.png}
     418%    \caption{(a)}
     419%  \end{subfigure}%
     420%  \begin{subfigure}[]{.45\hsize}
     421  \end{minipage}%
     422  \begin{minipage}{0.45\hsize}
     423    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0124o_XY11_nobt.png}
     424%    \caption{(b)}
     425%  \end{subfigure}
     426  \end{minipage}
     427  \begin{minipage}{0.45\hsize}
     428    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_XY11_bt.png}
     429%    \caption{(a)}
     430%  \end{subfigure}%
     431%  \begin{subfigure}[]{.45\hsize}
     432  \end{minipage}%
     433  \begin{minipage}{0.45\hsize}
     434    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0124o_XY11_bt.png}
     435%    \caption{(b)}
     436%  \end{subfigure}
     437  \end{minipage}
     438  \caption{Example of OTA11 cell xy60 on exposures o5677g0123o (left) and o5677g0124o (right).  The top panels show the image with all appropriate detrending steps, but without burntool, and the bottom show the same with burntool applied.  There is some slight over subtraction in fitting the initial trail, but the impact of the trail is greatly reduced in both exposures.}
     439\end{figure}
     440
     441
     442\subsection{Overscan}
     443\label{sec:overscan}
     444
     445Each cell on GPC1 has an overscan region that covers the first 34
     446columns of each row, and the last 10 rows of each column.  No light
     447lands on these pixels, so the image region is trimmed to exclude them.
     448Each row has an overscan value subtracted, calculated by finding the
     449median value of that row's overscan pixels and then smoothing between
     450rows with a three-row boxcar median.
     451
     452\subsection{Non-linearity Correction}
     453\label{sec:nonlinearity}
     454
     455The pixels of GPC1 are not uniformly linear at all flux levels.  In
     456particular, at low flux levels, some pixels have a tendency to sag
     457relative to the expected linear value.  This effect is most pronounced
     458along the edges of the detector cells, although some entire cells show
     459evidence of this effect.
     460
     461To correct this sag, we studied the flux behavior of a series of flat
     462frames for a ramp of exposure times with approximate logarithmically
     463equal spacing between 0.01s and 57.04s.  As the exposure time
     464increases, the flux on each pixel also increases in what is expected
     465to be a linear manner.  Each of these flat exposures in this ramp is
     466overscan corrected, and then the median is calculated for each cell,
     467as well as for the rows and columns within ten pixels of the edge of
     468the science region.  From these median values at each exposure time
     469value, we can construct the expected trend by fitting a linear model,
     470$f_{region} = G * t_{exp} + B$, to determine the gain, $G$, and the
     471bias, $B$, for the region considered.  This fitting was limited to only
     472the range of fluxes between 12000 and 38000 counts, as these ranges
     473were found to match the linear model well.  This range avoids the
     474non-linearity at low fluxes, as well as the possibility of high-flux
     475non-linearity effects.
     476
     477We store the average flux measurement and deviation from the linear
     478fit for each exposure time for all regions on all detector cells in
     479the linearity detrend look up tables.  When this is applied to science
     480data, these lookup tables are loaded, and a linear interpolation is
     481performed to determine the correction needed for the flux in that
     482pixel.  This look up is performed for both the row and column of each
     483pixel, to allow the edge correction to be applied where applicable,
     484and the full cell correction elsewhere.  The average of these two
     485values is then applied to the pixel value, reducing the effects of
     486pixel nonlinearity.
     487
     488This non-linearity effect appears to be stable in time for the
     489majority of the detector pixels, with little evident change over the
     490survey duration.  However, as the non-linearity is most pronounced at
     491the edges of the detector cells, those are the regions where the
     492correction is most likely to be incomplete.  Because of this fact,
     493most pixels in the static mask with either the DARKMASK or FLATMASK
     494bit set are found along these edges.  As the non-linearity correction
     495is unable to reliably restore these pixels, they produce inconsistent
     496values after the dark and flat have been applied, and are therefore
     497rejected.
     498
     499\begin{figure}
     500  \centering
     501  \includegraphics[width=0.9\hsize,angle=0,clip]{images/linearity_XY27_xy16.png}
     502  \caption{Example plot of the linearity correction as a fraction of observed flux for OTA27, cell xy16.}
     503\end{figure}
     504
     505\subsection{Dark/Bias Subtraction}
     506\label{sec:dark}
     507
     508The dark model we make for GPC1 considers each pixel individually,
     509independent of any neighbors.  To construct this model, we fit a
     510multi-dimensional model to the array of input pixels from a randomly
     511selected set of 100-150 overscan and non-linearity corrected dark
     512frames chosen from a given date range.  The model fits each pixel as a
     513function of the exposure time $t_{exp}$ and the detector temperature
     514$T_{chip}$ of the input images such that $\mathrm{dark} = a_0 + a_1
     515t_{exp} + a_2 T_{chip} t_{exp} + a_3 T_{chip}^2 t_{exp}$.  This
     516fitting uses two iterations to produce a clipped fit, rejecting at the
     517$3\sigma$ level.  The final coefficients $a_i$ for the dark model are
     518stored in the detrend image.  The constant $a_0$ term includes the
     519residual bias signal after overscan subtraction, and as such, a
     520separate bias subtraction is not necessary.
     521
     522Applying the dark model is simply a matter of calculating the response
     523to the exposure time and detector temperature for the image to be
     524corrected, and subtracting the resulting dark signal from the image.
     525
     526\subsubsection{Time evolution}
     527
     528The dark model is not consistently stable over the full survey, with
     529significant drift over the course of multiple months.  Some of the
     530changes in the dark can be attributed to changes in the voltage
     531settings of the GPC1 controller electronics, but the majority seem to
     532be the result of some unknown parameter.  We can separate the dark
     533model history of GPC1 into three epochs.  The first epoch covers all
     534data taken prior to 2010-01-23.  This epoch used a different header
     535keyword for the detector temperature, making data from this epoch
     536incompatible with later dark models.
     537
     538The second epoch covers data between 2010-01-23 and 2011-05-01, and is
     539characterized by a largely stable but oscillatory dark solution.
     540There are two modes that the dark model switches between apparently at
     541random.  No clear cause has been established for the switching, but
     542there are clear differences between the two modes that require the
     543observation dates to be split to use the model that is most
     544appropriate.
     545
     546The initial evidence of these two modes comes from the discovery of a
     547slight gradient along the rows of certain cells.  This is a result of
     548a drift in the bias level of the detector as it is read out.  An
     549appropriate dark model should remove this gradient entirely.  For
     550these two modes, the direction of this bias drift is different, so a
     551single dark model generated from all dark images in the time range
     552over corrects the positive-gradient mode, and under corrects the
     553negative-gradient mode.  Upon identifying this two-mode behavior, and
     554determining the dates each mode was dominant, two separate dark
     555models were constructed from appropriate ``A'' and ``B'' mode dark
     556frames.  Using the appropriate dark minimizes the effect of this bias
     557gradient in the dark corrected data. 
     558
     559The bias drift gradients of the mode switching can be visualized in
     560Figure \ref{fig:dark switching}.  This figure shows the image profile
     561along the x-pixel axis binned along the full y-axis of the first row
     562of cells.  The raw data is shown, illustrating the positional
     563dependence the dark signal has on the image values.  In addition,
     564both the correct B-mode dark and incorrect A-mode dark have been
     565applied to this image, showing that although both correct the bulk of
     566the dark signal, using the incorrect mode creates larger intensity
     567gradients.
     568
     569After 2011-05-01, the two-mode behavior of the dark disappears, and is
     570replaced with a slow observation date dependent drift in the magnitude
     571of the gradient.  This drift is sufficiently slow that we have modeled
     572it using three observation date independent dark model for different
     573date ranges.  These darks cover the range from 2011-05-01 to
     5742011-08-01, 2011-08-01 to 2011-11-01, and 2011-11-01 and on.  The
     575reason for this time evolution is unknown, but as it is correctable
     576with a small number of dark models, this does not significantly impact
     577detrending.
     578
     579\begin{figure}
     580  \centering
     581%  \begin{subfigure}[]{.45\hsize}
     582  \begin{minipage}{0.45\hsize}
     583    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_M_OS_NL_XY23_b1.jpg}
     584%    \caption{(a)}
     585%  \end{subfigure}%
     586%  \begin{subfigure}[]{.45\hsize}
     587  \end{minipage}%
     588  \begin{minipage}{0.45\hsize}
     589    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_to_DARK_XY23_b1.jpg}
     590%    \caption{(b)}
     591%  \end{subfigure}
     592  \end{minipage}
     593  \caption{An example of the dark model application to exposure o5677g0123o, OTA23 (2011-04-26, 43s \gps{} filter).  The left panel shows the image data mosaicked to the OTA level, and has had the static mask applied, the overscan subtracted, and the detector non-linearity corrected.  The right panel, shows the same exposure with the dark applied in addition to the processing shown on the left.}
     594\end{figure}
     595
     596\begin{figure}
     597  \centering
     598  \includegraphics[width=0.9\hsize,angle=0,clip]{images/B_profile_ex.png}
     599  \caption{Example showing a profile cut across exposure o5676g0195, OTA67 (2011-04-25, 43s \gps{} filter).  The entire first row of cells (xy00-xy07) have had a median calculated along each pixel column on the OTA mosaicked image.  Arbitrary offsets have been applied to shift the curves to not overlap.  The top curve (in purple) shows the initial raw profile, with no dark model applied.  The next curve (in green) shows the smoother profile after applying the correct B-mode dark model.  Applying the incorrect A-mode dark results in the blue curve, which shows a significant increase in gradients across the cells.  The orange curve shows the result of the PATTERN.CONTINUITY correction.  Although this creates a larger gradient across the mosaicked images, it decreases the cell-to-cell level changes.  The final yellow curve shows the final image profile after all detrending and background subtraction, and has not had an offset applied.  The bright source at the cell xy00 to xy01 transition is a result of a large optical ghost, which due to the area covered, increases the median level more than the field stars.}
     600  \label{fig:dark switching}
     601\end{figure}
     602
     603\subsubsection{Video Dark}
     604\label{sec:video_darks}
     605
     606The dark signal is stronger in cell corners due to glow from the
     607read-out amplifiers.  The standard dark model corrects this for most
     608observations.  However, as mentioned above, when a cell is repeatedly
     609read in video mode, the dark model for the OTA containing it changes.
     610Surprisingly, added reads for the video cell do not amplify the
     611amplifier glow, but rather decrease the dark signal in these regions.
     612As a result, using the standard dark model on the data for these OTAs
     613results in oversubtraction of the corner glow.
     614
     615Video darks have been constructed to eliminate the effect this
     616observational change has on the final image quality.  This was done by
     617running the standard dark construction process on a series of dark
     618frames that have had the video signal enabled for some cells.  GPC1
     619can only run video signals on a subset of the OTAs at a given time.
     620This requires two passes to enable the video signal across the full
     621set of OTAs that support video cells.  This is convenient for the
     622process of creating darks, as those OTAs that do not have video
     623signals enabled create standard dark models, while the video dark is
     624created for those that do.
     625
     626This simultaneous construction of video and standard dark models is
     627useful, as it provides the ability to isolate the response on the
     628standard dark from the video signals.  Isolating this response is
     629essential for attempting to create archival video darks.  We only have
     630raw video dark frame data after 2012-05-16, when this problem was
     631initially identified, so any data prior to that can not be directly
     632corrected for the video dark signal.  Isolating the video signal
     633response allows linear corrections to the pre-existing standard dark
     634models for archival data.  Testing this shows that constructing a
     635video dark for older data simply as $VD_{2009} = D_{2009} - D_{Modern}
     636+ VD_{Modern}$ produces a satisfactory result that does not
     637over subtract the amplifier glow.  This is shown in figure
     638\ref{fig:video_darks}, which shows video cells from before 2012-05-16,
     639corrected with both the standard and video darks, with the early video
     640dark constructed in such a manner.
     641
     642\begin{figure}
     643  \centering
     644%  \begin{subfigure}[]{.45\hsize}
     645  \begin{minipage}{0.45\hsize}
     646    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_VIDEODARK_VDim_Rdark_XY22_b1.jpg}
     647%    \caption{(a)}
     648%  \end{subfigure}%
     649%  \begin{subfigure}[]{.45\hsize}
     650  \end{minipage}%
     651  \begin{minipage}{0.45\hsize}
     652    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_VIDEODARK_VDim_VDdark_XY22_b1.jpg}
     653%    \caption{(b)}
     654%  \end{subfigure}
     655  \end{minipage}
     656  \caption{An example of the video dark model application to exposure o5677g0123o, OTA22 (2011-04-26, 43s \gps{} filter), which has a video cell located in cell xy16.  The left panel shows the image data mosaicked to the OTA level, and has had the static mask applied, the overscan subtracted, the detector non-linearity corrected, and a regular dark applied.  The right panel, shows the same exposure with a video dark applied instead of the standard dark.  The main impact of this change is the improved correction of the corner glows, which are over subtracted with the standard dark.}
     657  \label{fig:video_darks}
     658\end{figure}
     659
     660\subsection{Noisemap}
     661\label{sec:noisemap}
     662
     663Based on a study of the positional dependence of all detected sources,
     664we have discovered that the cells in GPC1 do not have uniform noise
     665characteristics.  Instead, there is a gradient along the pixel rows,
     666with the noise generally higher away from the read out amplifier
     667(higher cell x pixel positions).  This is likely an effect of the
     668row-by-row bias issue discussed below.  This gradient causes the read
     669noise to increase as the row is read out.  As a result of this
     670increased noise, more sources are detected in the higher noise regions
     671when the read noise is assumed constant across the readout.  Read noise is the
     672
     673To
     674mitigate this noise gradient, we constructed an initial set of
     675noisemap images by measuring the median variance on bias frames.  The
     676variance is calculated in boxes of 20x20 pixels, and then linearly
     677interpolated to cover the full image.
     678
     679Unfortunately, due to correlations within this noise, the variance
     680measured from the bias images does not fully remove the positional
     681dependence of objects that are detected.  This simple noisemap
     682underestimates the noise observed when the image is filtered during
     683the object detection process.  This filtering convolves the background
     684noise with a PSF, which has the effect of amplifying the correlated
     685peaks in the noise.  This amplification can therefore boost background
     686fluctuations above the threshold used to select real objects,
     687contaminating the final object catalogs.
     688
     689In the detection process, we expect false positives at a rate equal to
     690the one-tailed probability beyond the detection threshold.  For these
     691tests, only detections measured at the $\sigma_{thresh} = 5\sigma$
     692level are used, to match that used in the photometry on science data.
     693This probability can be converted into a number of false number by
     694considering a given area.  As the detections must be isolated to not
     695be detected as an extended object, this area must be reduced by the
     696area a given PSF occupies.  Combining this, we find that we expect a
     697probability $P = 1 - \Phi_{normal}(5) = \frac{1}{2}
     698\erfcinv\left(\frac{5}{\sqrt{2}}\right)$, and an area given $N$
     699exposures of area $X\times Y$, $A = \frac{X \times Y \times
     700  N}{A_{PSF}}$.  For a typical $1"$ seeing, $A_{PSF}$ is approximately
     70116 pixels.  Using this model for the false positives, we found that
     702the added read noise was insufficient to account for the observed
     703false positive rate.  Inverting this relation, we can measure
     704$\sigma_{obs}$, the true threshold level based on the number of false
     705positives observed.  This $\sigma_{obs}$ is the combined to form a
     706boost factor $B = \sigma_{thresh} / \sigma_{obs}$ that amplifies the
     707  noisemap to match the observed false detection rate.
     708
     709The row-to-row variations that contribute to the extra noise are
     710related to the dark model, and because of this, as the dark model
     711changes, the effective noise also changes.  To ensure that the
     712noisemap accurately matches the true noise level, we have created
     713different noisemap models for the three major time ranges of the dark
     714model.  We do not see any strong evidence that the noisemaps have the
     715A/B modes visible in the dark, and so we do not generate different
     716models for each individual dark model.  The additional pixel-to-pixel
     717variance from this noisemap is added to the Poissonian variance to
     718form the science variance image generated by the \ippstage{chip}
     719processing.
     720
     721\subsection{Flat}
     722
     723Determining a flat field correction for GPC1 is a challenging
     724endeavor, as the wide field of view makes it difficult to construct a
     725uniformly illuminated image.  Using a dome screen is not possible, as
     726the variations in illumination and screen rigidity create large
     727scatter between different images that are not caused by the detector
     728response function.  Because of this, we use sky flat images taken at
     729twilight, which are more consistently illuminated than screen flats.
     730We calculate the mean of these images to determine the initial flat
     731model.
     732
     733From this starting skyflat model, we construct a photometric
     734correction to remove the effect of the illumination differences over
     735the detector surface.  This is done by dithering a series of science
     736exposures with a given pointing.  By fully calibrating these exposures
     737with the initial flat model, and then comparing the measured fluxes
     738for the same star as a function of position on the detector, we can
     739determine position dependent scaling factors.  From the set of scaling
     740factors for the full catalog of stars observed in the dithered
     741sequence, we can construct a model of the error in the initial flat
     742model as a function of detector position.  Applying a correction that
     743reduces the amplitude of these errors produces a flat field model that
     744better represents the true detector response.
     745
     746In addition to this flat field applied to the individual images, the
     747ubercal process used to calibrate the database of all detections
     748\citep{2012ApJ...756..158S} constructs internal ``flat field'' corrections.
     749Although a single set of image flat fields was used for the entire PV3
     750survey, five separate ``seasons'' of database flat fields were needed
     751to ensure proper calibration.  This indicates that the flat field
     752response is not completely fixed in time.  More details on this
     753process are contained in \citet{magnier2017c}.
     754
     755\subsection{Pattern correction}
     756\label{sec:pattern}
     757
     758Due to detector specific issues that are not cleanly removed by the
     759dark model, we have a set of ``pattern'' corrections that are applied
     760to some selection of the OTAs in the camera.  This is done to reduce
     761the effect that detector differences have on the measured astronomical
     762signal that are not stable enough to be corrected with a static model.
     763Because of this, the pattern corrections attempt to identify and
     764correct the detector issues based on appropriate filtering the
     765individual science exposures.
     766
     767The PATTERN.ROW correction is used to remove any remaining row-by-row
     768bias variation, and the PATTERN.CONTINUITY correction attempts to
     769ensure that the cells of a given OTA are consistent with the other
     770cells on that OTA.
     771
     772\subsubsection{Pattern Row}
     773%% Statistics so I have them written down somewhere
     774%% chipProcessedImfile.bg/bg_stdev by filter for XY33 (a good chip)
     775%% filter  bg_mean stdev median Qsig                              bg_stdev_mean stdev median Qsig
     776%% g        36.37422026669   64.64175104057  32.693   6.10284     14.696938349131  78.80460307171  8.8401  0.5417843
     777%% r       200.96143304525  471.87743546238 117.105  94.55608     33.854672792146  79.01642728089 13.4564  5.3771355
     778%% i       447.00504994458  938.38517801037 286.810 154.71397     57.298335510188  99.38392923935 20.0217 24.2254723
     779%% z       317.54933679054  390.38930252748 241.014 114.13316     48.359069000176  94.44452756094 17.9404  9.1535209
     780%% y       371.09019536218  293.57439970375 288.481 133.38769     43.724342221691 135.04286534327 19.9029  7.5396461
     781
     782As discussed above in the dark and noisemap sections, certain
     783detectors have significant bias offsets between adjacent rows, caused
     784by noise in the camera control electronics.  The magnitude of these
     785offsets increases as the distance from the readout amplifier
     786increases, resulting in horizontal streaks that are more pronounced
     787along the large x pixel edge of the cell.  As the level of the offset
     788is apparently random between exposures, the dark correction cannot
     789fully remove this structure from the images, and the noisemap value
     790only indicates the level of the average variance added by these bias
     791offsets.  Therefore, we apply the PATTERN.ROW correction in an attempt
     792to mitigate the offsets and correct the image values.  To force the
     793rows to agree, a second order clipped polynomial is fit to each row in
     794the cell.  Four fit iterations are run, and pixels $2.5\sigma$ deviant
     795are excluded from subsequent fits, to minimize the effect stars and
     796other astronomical signals have.  This final trend is then subtracted
     797from that row.  Simply doing this subtraction will also have the
     798effect of removing the background sky level.  To prevent this, the
     799constant and linear terms for each row are stored, and linear fits are
     800made to these parameters as a function of row, perpendicular to the
     801initial fits.  This produces a plane that is added back to the image
     802to restore the background offset and any linear ramp that exists in
     803the sky.
     804
     805These row-by-row variations have the largest impact on data taken in
     806the \gps{} filter, as the read noise is the dominant noise source in
     807that filter.  At longer wavelengths, the noise from the Poissonian
     808variation in the sky level increases.  Although the PATTERN.ROW correction is still applied to data taken in the other filters,
     809
     810This correction was required on all cells on all OTAs prior to
     8112009-12-01, at which point a modification of the camera electronics
     812reduced the scale of the row-by-row offsets for the majority of the
     813OTAs.  As a result, we only apply this correction to the cells where
     814it is still necessary, as shown in Figure \ref{fig: pattern row
     815  cells}.  A list of these cells is listed in Table
     816\ref{tab:pattern_row_cells}.
     817
     818Although this correction does largely resolve the row-by-row offset
     819issue in a satisfactory way, large and bright astronomical objects can
     820bias the fit significantly.  This results in an oversubtraction of the
     821offset near these objects.  As the offsets are calculated on the pixel
     822rows, this oversubtraction is not uniform around the object, but is
     823preferentially along the horizontal x axis of the object.  Most
     824astronomical objects are not significantly distorted by this, with
     825this only becoming on issue for only bright objects comparable to the
     826size of the cell (598 pixels = 150").
     827
     828\begin{deluxetable}{lcccc}
     829  \tablecolumns{3}
     830  \tablewidth{0pc}
     831  \tablecaption{Cells which have PATTERN.ROW correction applied}
     832  \tablehead{\colhead{OTA} & \colhead{Cell columns} & \colhead{Additional cells}}
     833  \startdata
     834  OTA11 &  & xy02, xy03, xy04, xy07 \\
     835  OTA14 &  & xy23 \\
     836  OTA15 & 0 & \\
     837  OTA27 & 0, 1, 2, 3, 7 & \\
     838  OTA31 & 7 & \\
     839  OTA32 & 3, 7 & \\
     840  OTA45 & 3, 7 & \\
     841  OTA47 & 0, 3, 5, 7 & \\
     842  OTA57 & 0, 1, 2, 6, 7 & \\
     843  OTA60 &  & xy55 \\
     844  OTA74 & 2, 7 & \\
     845  \enddata
     846  \label{tab:pattern_row_cells}
     847\end{deluxetable}
     848
     849\begin{figure}
     850  \centering
     851  \includegraphics[width=0.9\hsize,angle=0,clip]{images/pattern_row_edit.png}
     852  \caption{Diagram illustrating in red which cells on GPC1 require the PATTERN.ROW correction to be applied.  The footprint of each OTA is outlined, and cell xy00 is marked with either a filled box or an outline.  The labeling of the non-existent corner OTAs is provided to orient the focal plane.}
     853  \label{fig: pattern row cells}
     854\end{figure}
     855
     856\begin{figure}
     857  \centering
     858  \begin{minipage}{0.45\hsize}
     859    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5379g0103o_XY57_nopat.png}
     860%    \caption{(a)}
     861%  \end{subfigure}%
     862%  \begin{subfigure}[]{.45\hsize}
     863  \end{minipage}%
     864  \begin{minipage}{0.45\hsize}
     865    \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5379g0103o_XY57_pat.png}
     866%    \caption{(b)}
     867%  \end{subfigure}
     868  \end{minipage}
     869  \caption{Example of the PATTERN.ROW correction on exposure o5379g0103o OTA57 cell xy00 (\ips{} filter 45s).  The left panel shows the cell with all appropriate detrending except the PATTERN.ROW, and the right shows the same cell with PATTERN.ROW applied.  The correction reduces the correlated noise on the right side, which is most distant from the read out amplifier.  There is a slight over subtraction along the rows near the bright star.}
     870\end{figure}
     871
     872\subsubsection{Pattern Continuity}
     873
     874After previous attempts to ensure that adjacent cells on an OTA
     875matched background levels were insufficient in many situations, we
     876designed a replacement correction that would reduce the background
     877distortion for large objects.  In addition, studies of the background
     878level illustrated that the row-by-row bias can introduce small
     879background gradient variations along the rows of the cells that is not
     880stable enough to be completely fit by the dark model.  This common
     881feature across the columns of cells results in a ``saw tooth'' pattern
     882horizontally across an OTA, and as the background model fits a smooth
     883sky level, this induces over and under subtraction at the cell
     884boundaries. 
     885
     886The PATTERN.CONTINUITY correction, attempts to match the edges of a
     887cell to those of its neighbors.  For each cell, a thin box 10 pixels
     888wide on each edge is extracted and the median value of unmasked values
     889calculated for that box.  These median values are then used to
     890construct a vector of differences $\Delta_i = \sum_{j} \mathrm{Edge}_{i} -
     891\mathrm{Edge}_{j}$, along with a matrix of associations $A_{i,i'} = \sum_{j}
     892\delta(i,j) \delta(j,i')$ denoting which cell boundaries are adjacent.
     893By solving the system $A x = \Delta$, we find the set of offsets $x_i$
     894to be applied to each cell to ensure the minimum differences between
     895all cell edges and their neighbors.
     896
     897For OTAs that initially show the saw tooth pattern, the effect of this
     898correction is to align the cells into a single ramp, at the expense of
     899the absolute background level.  However, as we subtract off a smooth
     900background model prior to doing photometry, these deviations from an
     901absolute sky level are unimportant.  The fact that the final ramp is
     902smoother than it would be otherwise also allows for the background
     903subtracted image to more closely match the astronomical sky, without
     904significant errors at cell boundaries.  An example of the effect of
     905this correction on an image profile is shown in Figure \ref{fig:dark switching}.
     906
     907
     908\subsection{Fringe correction}
     909\label{sec:fringe}
     910% det_id 296 is the fringe we use.
     911
     912Due to variations in the thickness of the detectors, we observe
     913interference patterns at the infrared end of the filter set, as the
     914wavelength of the light becomes comparable to the thickness of the
     915detectors.  Visually inspecting the images shows that the fringing is
     916most prevalent in the \yps{} filter images, with negligible fringing in the
     917other bands.  As a result of this, we only apply a fringe correction
     918to the \yps{} filter data.
     919
     920The fringe used for PV3 processing was constructed from a set of 20
     921120s science exposures.  These exposures are overscan subtracted, and
     922corrected for non-linearity, and have the dark and flat models
     923applied.  These images are smoothed with a Gaussian kernel with
     924$\sigma = 2$ pixels to minimize pixel to pixel noise.  The fringe
     925image data is then constructed by calculating the clipped mean of the
     926input images with two iteration of clipping at the $3\sigma$ level.
     927
     928A course background model for each cell is constructed by calculating
     929the median on a 3x3 grid (approximately 200x200 pixels each).  A set
     930of 1000 randomly selected points are then selected on the fringe image
     931for each cell, and a median calculated for this position in a 10x10
     932pixel box, with the background level subtracted.  These sample
     933locations provide scale points to allow the amplitude of the measured
     934fringe to be compared to that found on science images.
     935
     936To apply the fringe, the same sample locations are measured on the
     937science image to determine the relative strength of the fringing in
     938that particular image.  A least squares fit between the fringe
     939measurements and the corresponding measurements on the science image
     940provides the scale factor multiplied to the fringe before it is
     941subtracted from the science image.
     942
     943\begin{figure}
     944  \centering
     945  \begin{minipage}{0.5\hsize}
     946    \includegraphics[width=1.5\hsize,angle=0,clip]{images/o5220g0025o_XY53_nofringe.png}
     947  \end{minipage}%
     948  \begin{minipage}{0.5\hsize}
     949    \includegraphics[width=1.5\hsize,angle=0,clip]{images/o5220g0025o_XY53_fringe.png}
     950  \end{minipage}
     951  \caption{Example of the \yps{} filter fringe pattern on exposure o5220g0025o OTA53 (\yps{} filter 30s).  The left panel shows the OTA mosaic with all detrending except the fringe correction, while the right shows the same including the fringe correction.  Both images have been smoothed with a Gaussian with $\sigma = 3$ pixels to highlight the faint and large scale fringe patterns.
     952}
     953  \label{fig: fringe example}
     954\end{figure}
     955
     956\subsection{Masking}
     957\label{sec:masking}
     958
     959\subsubsection{Static Masks}
     960\label{sec:static_masks}
     961
     962Due to the large size of the detector, it is expected that there
     963are a number of pixel defects that do not have the detection
     964sensitivity on par with their neighbors.  To remove these pixels, we
     965have constructed a static mask that identifies the known defects.
     966This mask is constructed in three phases.
     967
     968First, a CTEMASK is constructed to mask out regions in which the
     969charge transfer efficiency is low compared to the rest of the
     970detector.  Twenty-five of the sixty OTAs in GPC1 show some evidence of
     971CTE issues, with this pattern appearing (to varying degrees) in
     972roughly triangular patches on the OTA due to defects in the
     973semiconductor manufacturing.  To generate the mask for these regions,
     974a sample set of 26 evenly illuminated flat field images were measured
     975to produce a map of the image variance in 20x20 pixel bins.  As the
     976flat image is expected to illuminate the image uniformly, the expected
     977variances in each bin should be Poissonian distributed with the flux
     978level.  However, in regions with CTE issues, adjacent pixels are not
     979independent, as the charge in those pixels is more free to spread.
     980This reduces the pixel-to-pixel differences, resulting in a lower than
     981expected variance.  All regions with variance less than half the
     982average image level are added to the static CTEMASK.
     983
     984The next step of mask construction is to examine the flat and dark
     985models, and exclude pixels that appear to be poorly corrected by these
     986models.  The DARKMASK process looks for pixels that are more than
     987$8\sigma$ discrepant in $10\%$ of the 100 input dark frame images
     988after those images have had the dark model applied to them.  These
     989pixels are assumed to be unstable with respect to the dark model, and
     990have the DARK bit set in the static mask, indicating that they are
     991unreliable in scientific observing.  Similarly, the FLATMASK process
     992looks for pixels that are $3\sigma$ discrepant in the same fraction of
     99316 input flat field images after both the dark and flat models have
     994been applied.  Those pixels that do not follow the flat field model of
     995the rest of image are assigned the FLAT mask bit in the static mask,
     996removing the pixels that cannot be corrected to a linear response.
     997
     998The final step of mask construction is to examine the detector for
     999bright columns and other static pixel issues.  This is first done by
     1000processing a set of 100 \ips{} filter science images in the same fashion as
     1001for the DARKMASK.  A median image is constructed from these inputs
     1002along with the per-pixel variance.  These images are used to identify
     1003pixels that have unexpectedly low variation between all inputs, as
     1004well as those that significantly deviate from the global median value.
     1005Once this initial set of bad pixels is identified, a $3\times{}3$
     1006pixel triangular kernel is convolved with the initial set, and any
     1007convolved pixel with value greater than 1 is assigned to the static
     1008mask.  This does an excellent job of removing the majority of the
     1009problem pixels.  A subsequent manual inspection allows human
     1010interaction to identify other inconsistent pixels including the
     1011vignetted regions around the edge of the detector. 
     1012
     1013Figure \ref{fig:static mask} shows an example of the static mask for
     1014the full GPC1 field of view.  Table \ref{tab:mask_values} lists the
     1015bit mask values used for the different sources of masking.
     1016
     1017\begin{figure}
     1018  \centering
     1019  \includegraphics[width=0.9\hsize,angle=0,clip]{images/gpc1_mask_indexed.png}
     1020  \label{fig:static mask}
     1021 
     1022  \caption{Image map of the GPC1 static mask.  The CTE regions are clearly visible as roughly triangular patches covering the corners of some OTAs.  Some entire cells are masked, including an entire column of cells on OTA14.  Calcite cells remove large areas from OTA17 AND OTA76.}
     1023\end{figure}
     1024
     1025\begin{deluxetable}{ccl}
     1026  \tablecolumns{3}
     1027  \tablewidth{0pc}
     1028  \tablecaption{GPC1 Mask Values}
     1029  \tablehead{\colhead{Mask Name} & \colhead{Mask Value} & \colhead{Description}}
     1030  \startdata
     1031  DETECTOR & 0x0001 & A detector defect is present. \\
     1032  FLAT     & 0x0002 & The flat field model does not calibrate the pixel reliably. \\
     1033  DARK     & 0x0004 & The dark model does not calibrate the pixel reliably. \\
     1034  BLANK    & 0x0008 & The pixel does not contain valid data. \\
     1035  CTE      & 0x0010 & The pixel has poor charge transfer efficiency. \\
     1036  SAT      & 0x0020 & The pixel is saturated. \\
     1037  LOW      & 0x0040 & The pixel has a lower value than expected. \\
     1038  SUSPECT  & 0x0080 & The pixel is suspected of being bad. \\
     1039  BURNTOOL & 0x0080 & The pixel contain an burntool repaired streak. \\
     1040  CR       & 0x0100 & A cosmic ray is present. \\
     1041  SPIKE    & 0x0200 & A diffraction spike is present. \\
     1042  GHOST    & 0x0400 & An optical ghost is present. \\
     1043  STREAK   & 0x0800 & A streak is present. \\
     1044  STARCORE & 0x1000 & A bright star core is present. \\
     1045  CONV.BAD & 0x2000 & The pixel is bad after convolution with a bad pixel. \\
     1046  CONV.POOR& 0x4000 & The pixel is poor after convolution with a bad pixel. \\
     1047  MARK     & 0x8000 & An internal flag for temporarily marking a pixel. \\
     1048  \enddata
     1049  \label{tab:mask_values}
     1050\end{deluxetable}
     1051
     1052\subsubsection{Dynamic masks}
     1053\label{sec:dynamic_masks}
     1054
     1055In addition to the static mask that removes the constant detector
     1056defects, we also generate a set of dynamic masks that change with the
     1057astronomical features in the image.  These masks are advisory in
     1058nature, and do not completely exclude the pixel from further
     1059processing consideration.  The first of these dynamic masks is the
     1060burntool advisory mask mentioned above.  These pixels are included for
     1061photometry, but are rejected more readily in the stacking and
     1062difference image construction, as they are more likely to have small
     1063deviations due to imperfections in the burntool correction.
     1064
     1065The remaining dynamic masks are not generated until the IPP
     1066\ippstage{camera} stage, at which point all object photometry is
     1067complete, and an astrometric solution is known for the exposure.  This
     1068added information provides the positions of bright sources based on
     1069the reference catalog, including those that fall slightly out of the
     1070detector field of view or within the inter chip gaps, where internal
     1071photometry may not identify them.  These bright sources are the origin
     1072for many of the image artifacts that the dynamic mask identifies and
     1073excludes.
     1074
     1075\subsubsubsection{Electronic crosstalk ghosts}
     1076\label{sec:crosstalk}
     1077
     1078Due to electrical crosstalk between the flex cables connecting the
     1079individual detector OTA devices, ghost objects can be created by the
     1080presence of a bright source at a different position on the camera.
     1081Table \ref{tab:crosstalk_rules} summarizes the list of known crosstalk
     1082rules, with an estimate of the magnitude difference between the source
     1083and ghost.  For all of the rules, any cell $v$ within the specified
     1084column of cells on any of the OTAs in the specified column of OTAs $Y$
     1085creates the ghost in the same $v$ and $Y$ in the target column of
     1086cells and OTAs.  In each of these cases, a source object with an
     1087instrumental magnitude brighter than -14.47 creates a ghost object
     1088many orders of magnitude fainter at the target location.  The cell
     1089(x,y) pixel coordinate is identical between source and ghost, as a
     1090result of the transfer occurring as the devices are read.  A circular
     1091mask is added to the ghost location with radius $R = 3.44 \left(-14.47
     1092- m_{source, instrumental}\right)$ pixels.  Any objects in the
     1093photometric catalog found at the location of the ghost mask have the
     1094GHOST mask bit set, marking the object as a likely ghost.  The
     1095majority of the crosstalk rules are bi-directional, with a source in
     1096either position creating a ghost at the corresponding crosstalk target
     1097position.  The two faintest rules are uni-directional, due to
     1098differences in the electronic path for the crosstalk.
     1099
     1100For the very brightest sources ($m_{instrumental} < -15$), there can
     1101be crosstalk ghosts between all columns of cells during the readout.
     1102These ``bleed'' ghosts were originally identified as ghosts of the
     1103saturation bleeds appearing in the neighboring cells, and as such, the
     1104masking for these objects puts a rectangular mask down from top to
     1105bottom of cells in all columns that are in the same row of cells as
     1106the bright source.  The width of this box is a function of the source
     1107magnitude, with $W = 5 * \left(-15 - m_{source, instrumental}\right)$
     1108pixels.
     1109
     1110\begin{deluxetable}{lllc}
     1111  \tablecolumns{4}
     1112  \tablewidth{0pc}
     1113  \tablecaption{GPC1 Crosstalk Rules}
     1114  \tablehead{\colhead{Type}&\colhead{Source OTA/Cell}&\colhead{Ghost OTA/Cell}&\colhead{$\Delta m$}}
     1115  \startdata
     1116  Inter-OTA & OTA2Y XY3v & OTA3Y XY3v & 6.16 \\
     1117            & OTA3Y XY3v & OTA2Y XY3v &      \\
     1118            & OTA4Y XY3v & OTA5Y XY3v &      \\
     1119            & OTA5Y XY3v & OTA4Y XY3v &      \\
     1120  Intra-OTA & OTA2Y XY5v & OTA2Y XY6v & 7.07 \\
     1121            & OTA2Y XY6v & OTA2Y XY5v &      \\
     1122            & OTA5Y XY5v & OTA5Y XY6v &      \\
     1123            & OTA5Y XY6v & OTA5Y XY5v &      \\
     1124  One-way   & OTA2Y XY7v & OTA3Y XY2v & 7.34 \\
     1125            & OTA5Y XY7v & OTA4Y XY2v &      \\
     1126  \enddata
     1127  \label{tab:crosstalk_rules}
     1128\end{deluxetable}
     1129 
     1130
     1131\subsubsubsection{Optical ghosts}
     1132\label{sec:optical_ghosts}
     1133
     1134Due to imperfections in the anti-reflective coating on the optical
     1135surfaces of GPC1, bright sources can also result in large out of focus
     1136objects, particularly in the \gps{} filter data.  These objects are the
     1137result of light reflecting back off the surface of the detector,
     1138reflecting again off the lower surfaces of the optics (particularly
     1139the L1 corrector lens), and then back down onto the focal plane.  Due
     1140to the extra travel distance, the resulting source is out of focus and
     1141elongated along the radial direction of the camera focal plane. These
     1142optical ghosts can be modeled in the focal plane coordinates (L,M)
     1143which has its origin at the center of the focal plane.  In this
     1144system, a bright object at location (L,M) on the focal plane creates a
     1145reflection ghost on the opposite side of the optical axis at (-L,-M).
     1146The exact location is fit as a third order polynomial in the focal
     1147plane L and M directions (as listed in Table \ref{tab:ghost_centers}).
     1148An elliptical annulus mask is constructed at the expected ghost
     1149location, with the major and minor axes defined by linear functions of
     1150the ghost distance from the optical axis, and oriented with the
     1151ellipse major axis is along the radial direction (Table
     1152\ref{tab:ghost_radii}).  All stars brighter than a filter-dependent
     1153threshold (listed in Table \ref{tab:ghost_magnitudes}) have such masks
     1154constructed.
     1155
     1156\begin{deluxetable}{lcc}
     1157  \tablecolumns{3}
     1158  \tablewidth{0pc}
     1159  \tablecaption{Optical Ghost Center Transformations}
     1160  \tablehead{\colhead{Polynomial Term}&\colhead{L center}&\colhead{M center}}
     1161  \startdata
     1162  $x^0 y^0$ & -1.215661e+02 &  2.422174e+01 \\
     1163  $x^1 y^0$ &  1.321875e-02 &  4.170486e-04 \\
     1164  $x^2 y^0$ & -4.017026e-09 & -1.934260e-08 \\
     1165  $x^3 y^0$ &  1.148288e-10 & -1.173657e-12 \\
     1166  $x^0 y^1$ & -1.908074e-03 &  1.189352e-02 \\
     1167  $x^1 y^1$ &  8.479150e-08 & -9.256748e-08 \\
     1168  $x^2 y^1$ &  1.635732e-11 &  1.140772e-10 \\
     1169  $x^0 y^2$ &  2.625405e-08 &  8.123932e-08 \\
     1170  $x^1 y^2$ &  1.125586e-10 &  1.328378e-11 \\
     1171  $x^0 y^3$ &  2.912432e-12 &  1.170865e-10 \\
     1172  \enddata
     1173  \label{tab:ghost_centers}
     1174\end{deluxetable}
     1175
     1176\begin{deluxetable}{lcccc}
     1177  \tablecolumns{5}
     1178  \tablewidth{0pc}
     1179  \tablecaption{Optical Ghost Annulus Axis Length}
     1180  \tablehead{\colhead{Radial Order}&\colhead{Inner Major Axis}&\colhead{Inner Minor Axis}&    \colhead{Outer Major Axis}&\colhead{Outer Minor Axis}}
     1181  \startdata
     1182  $r^0$ & 3.926693e+01 & 5.287548e+01 & 7.928722e+01 & 1.314265e+02 \\
     1183  $r^1$ & 5.325759e-03 &-2.191669e-03 & 1.722181e-02 & -2.627153e-03 \\
     1184  \enddata
     1185  \label{tab:ghost_radii}
     1186\end{deluxetable}
     1187
     1188\begin{deluxetable}{lc}
     1189  \tablecolumns{2}
     1190  \tablewidth{0pc}
     1191  \tablecaption{Optical Ghost Magnitude Limits}
     1192  \tablehead{\colhead{Filter}&\colhead{$m_{inst}$}}
     1193  \startdata
     1194  \gps{} & -16.5 \\
     1195  \rps{} & -20.0 \\
     1196  \ips{} & -25.0 \\
     1197  \zps{} & -25.0 \\
     1198  \yps{} & -25.0 \\
     1199  \wps{} & -20.0 \\
     1200  \enddata
     1201  \label{tab:ghost_magnitudes}
     1202\end{deluxetable}
     1203
     1204
     1205\begin{figure}
     1206  \centering
     1207  \includegraphics[width=0.9\hsize,angle=0,clip]{images/full_fpa_ghosts.jpg}
     1208  \caption{Example of the full GPC1 field of view illustrating the sources and destinations of optical ghosts on exposure o5677g0123o (2011-04-26, 43s \gps{} filter).  The bright stars on OTA33 and OTA44 result in nearly circular ghosts on the opposite OTA.  In contrast, the trio of stars on OTA11 result in very elongated ghosts on OTA66.}
     1209\end{figure}
     1210
     1211\subsubsubsection{Optical glints}
     1212\label{sec:glints}
     1213
     1214Prior to 2010-08-24, a reflective surface at the edge of the camera
     1215aperture was incompletely screened to light passing through the
     1216telescope.  Sources brighter than $m_{inst} = -21$ that fell on this
     1217reflective surface resulted in light being scattered across the
     1218detector surface in a long narrow glint.  This surface was physically
     1219masked on 2010-08-24, removing the possibility of glints in subsequent
     1220data, but that taken prior have an advisory dynamic mask constructed
     1221when a reference source falls on the focal plane within one degree of
     1222the detector edge.  This mask is 150 pixels wide, with length $L =
     12232500 \left(-20 - m_{inst}\right)$ pixels.  These glint masks are
     1224constructed by selecting sufficiently bright sources in the reference
     1225catalog that fall within rectangular regions around each edge of the
     1226GPC1 camera.  These regions are separated from the edge of the camera
     1227by 17 arcminutes, and extend outwards an additional degree.
     1228
     1229\begin{figure}
     1230  \centering
     1231  \includegraphics[width=0.9\hsize,angle=0,clip]{images/glint_example_o5379g0103o.jpg}
     1232  \caption{Example of a glint on exposure o5379g0103o (2010-07-02, 45s \ips{} filter).  The source star out of the field of view creates a long reflection that extends through OTA73 and OTA63.}
     1233\end{figure}
     1234
     1235\subsubsubsection{Diffraction Spikes and Saturated Stars}
     1236\label{sec:diffraction_spikes}
     1237
     1238Bright sources also form diffraction spikes that are dynamically
     1239masked.  These are filter independent, and are modeled as rectangles
     1240with length $L = 10^{0.096 * (7.35 - m_{instrumental})} - 200$ and
     1241width $W = 8 + (L - 200) * 0.01$, with negative values indicating no
     1242mask is constructed, as the source is likely too faint to produce the
     1243feature.  These spikes are dependent on the camera rotation, and are
     1244oriented at $\theta = n * \frac{\pi}{2} - \mathrm{ROTANGLE} + 0.798$,
     1245based on the header keyword.
     1246
     1247The cores of stars that are saturated are masked as well, with a
     1248circular mask radius $r = 10.15 * (-15 - m_{instrumental})$.  An
     1249example of a saturated star, with the masked regions for the
     1250diffraction spikes and core saturation highlighted, is shown in Figure
     1251\ref{fig:saturated star}.
     1252
     1253\begin{figure}
     1254  \centering
     1255  \includegraphics[width=0.9\hsize,angle=0,clip]{images/o6802g0338o_XY51_b1.jpg}
     1256  \caption{Example of saturated star, with diffraction spikes extending from the core on exposure o6802g0338o, OTA51 (2014-05-25, 45s \gps{} filter).}
     1257  \label{fig:saturated star}
     1258\end{figure}
     1259
     1260\subsubsection{Masking Fraction}
     1261\label{sec:masking_fraction}
     1262
     1263For the full field of view that falls on the sixty OTAs, 14.7\% of all
     1264pixels are masked.  The large fraction of this masking is due to
     1265regions that fall within the vignetted region.  Defining the diameter
     1266of the unvignetted region to have be 3 degrees, and excluding pixels
     1267that fall beyond this point reduces the static masking fraction to
     12689.7\%.
     1269
     1270Unfortunately, due to the design of the OTAs and readout cells, a
     1271non-negligible fraction of the field of view falls onto an area that
     1272does not have a detector pixel.  For a given OTA mosaicked to a
     1273$4846\times{}4868$ pixel image, the 64 $590\times{}598$ pixel readout
     1274cells cover 95.7\% of the OTA area, providing an additional 4.3\%
     1275masking in the unvignetted field of view due to the absence of a
     1276detector pixel.
     1277
     1278For the inter-chip gap area loss, we use two field of view
     1279calculations to estimate the masking fraction.  The reference field of
     1280view of GPC1 is 3 degrees, which at the nominal plate scale of 0.258
     1281arcseconds per pixel, translates to a 20930 FPA pixel radius.  Summing
     1282mask fractions from these three contributions within the unvignetted
     1283field of view results in an average of $\sim 20\%$ masking fraction
     1284across the field of view.  Dynamic masking adds an additional $2-3\%$
     1285on average, with advisory burntool masking contributing the largest
     1286single component.  Table \ref{tab:mask fraction} contains estimates of
     1287the mask fraction in the GPC1 detector footprint by the sources of the
     1288masking for the 3 degree field of view, as well as for a larger 3.25
     1289degree field of view that allows addition unvignetted regions in the
     1290corners to contribute.
     1291
     1292\begin{deluxetable}{lcc}
     1293  \tablecolumns{3}
     1294  \tablewidth{0pc}
     1295  \tablecaption{Mask Fraction by Mask Source}
     1296  \tablehead{\colhead{Mask Source}&\colhead{3 Degree FOV}&\colhead{3.25 Degree FOV}}
     1297  \startdata
     1298  No pixel        & 4.44\% & 9.47\% \\
     1299  Detector defect & 6.37\% & 7.91\% \\
     1300  CTE issue       & 2.62\% & 3.13\% \\
     1301  \enddata
     1302  \label{tab:mask fraction}
     1303\end{deluxetable}
     1304
     1305\subsection{Background subtraction}
     1306\label{sec:background}
     1307
     1308Once all other detrending is done, the pixels from each cell are
     1309mosaicked into the full $4846\times{}4868$ pixel OTA image.  A
     1310background model for the full OTA is then determined prior to the
     1311photometric analysis.  The mosaicked image is subdivided into
     1312$800\times{}800$ pixel segments that define each pixel of the
     1313background model, with the segments centered on the image center, and
     1314overlapping adjacent subdivisions by 400 pixels.  These overlaps help
     1315smooth the background model, as adjacent model pixels share input
     1316pixels.
     1317
     1318From each subdivision, 10000 random unmasked pixels are drawn.  In the
     1319case where the mask fraction is large (such as on OTAs near the edge
     1320of the field of view), and there are insufficient unmasked pixels to
     1321meet this criterion, all possible unmasked pixels are used instead.
     1322If this number is still small (less than 100 good pixels), the
     1323subdivision does not have a background model calculated, and instead,
     1324the value assigned to that model pixel is set as the average of the
     1325adjacent model pixels.  This allows up to eight neighboring background
     1326values to be used to patch these bad pixels.
     1327
     1328For the remaining subdivisions that have sufficient unmasked pixels
     1329for the background to be measured, the pixel values are used to
     1330calculate a set of robust statistics for the initial background guess.
     1331The minimum and maximum of the values are found, and checked to ensure
     1332that these are not the same value, which would indicate some problem
     1333with the input values.  The values are then inserted into a histogram
     1334with 1000 bins between the minimum and maximum values, and again
     1335checked for issues with the inputs by ensuring that the bin with the
     1336most input pixels does not contain more than half of the input values.
     1337In this case, the minimum and maximum do not constrain the true
     1338distribution of the input values well, and any values outside of the
     133920 bins closest to the bin with the peak are masked for future
     1340consideration.  A cumulative distribution is then constructed from the
     1341histogram, which saves the computational cost of sorting all the input
     1342values.  The bins containing the 50-percentile point, as well as the
     134315.8\%, 84.1\% ($\pm 1 \sigma$), 30.8\%, 69.1\% ($\pm 0.5 \sigma$),
     13442.2\%, and 97.7\% ($\pm 2 \sigma$) points are identified in this
     1345cumulative histogram.  These bins, and the two bins to either side are
     1346then linearly interpolated to identify the pixel value corresponding
     1347to these points in the distribution.  The 50\% point is set as the
     1348median of the pixel distribution, with the standard deviation of the
     1349distribution set as the median of the $\sigma$ values calculated from
     1350the $0.5 * (\sigma_{+1} - \sigma_{-1})$, $\sigma_{+0.5} -
     1351\sigma_{-0.5}$, and $0.25 * (\sigma_{+2} - \sigma_{-2})$ differences.
     1352If this measured standard deviation is smaller than 3 times the bin
     1353size, then all points more than 25 bins away from the calculated
     1354median are masked, and the process is repeated until the bin size is
     1355sufficiently small to ensure that the distribution width is well
     1356sampled.  Once this iterative process converges, or 20 iterations are
     1357run, the 25- and 75-percentile values are found by interpolating the 5
     1358bins around the expected bin as well, and the count of the number of
     1359input values within this inner 50-percentile region, $N_{50}$ is
     1360calculated.
     1361
     1362These initial statistics are then used as the starting guesses for a
     1363second calculation of the background level that attempts to fit the
     1364distribution with a Gaussian.  All pixels that were masked in the
     1365initial calculation are unmasked, and a histogram is again constructed
     1366of the values, with a bin size set to $\sigma_{guess} / \left( N_{50} /
     1367500 \right)$.  With this bin size, we expect that a bin at $\pm 2
     1368\sigma$ will have approximately 50 input points, which gives a
     1369Poissonian signal to noise estimate around 7.  In the case where
     1370$N_{50}$ is small (due to a poorly populated input image), this bin
     1371size is fixed to be no larger than the guess of the standard
     1372deviation.  The endpoints of the histogram are clipped based on the
     1373input guesses, such that any input point with a value more than $5
     1374\sigma_{guess}$ away from the input mean are excluded from
     1375consideration. 
     1376
     1377Two second order polynomial fits are then performed to the logarithm
     1378of the histogram counts set at the midpoint of each bin.  The first
     1379fit considers the ``lower half'' of the distribution, under the
     1380assumption that deviations from a normal distribution are caused by
     1381real astrophysical sources that will be brighter than the true
     1382background level.  From the bin with most pixel values, the lower
     1383bound is set by searching for the first bin from the peak that has
     1384fewer inputs than 25\% of the peak.  A similar search is performed for
     1385the upper bound, but with a criterion that the bin has fewer than 50\%
     1386of the peak.  On both sides of the peak, the bounds are adjusted to
     1387ensure that at least seven bins, equally distributed around the peak,
     1388are used.  The second fit is symmetric, fitting both sides of the
     1389distribution out to the point where the bin contains fewer than 15\%
     1390of the peak value.  The same seven-bin constraint is used for this
     1391fit.  The Gaussian mean and standard deviation are calculated from the
     1392polynomial coefficients, and the symmetric fit results are accepted
     1393unless the lower-half fit results in a smaller mean.  This process is
     1394repeated again if the calculated standard deviation is not larger than
     139575\% of the initial guess (suggesting an issue with the initial bin
     1396size).
     1397
     1398With this two-stage calculation performed across all subdivisions of
     1399the mosaicked OTA image, and missing model pixels filled with the
     1400average of their neighbors, the final background model is stored on
     1401disk as a $13\times{}13$ image with header entries listing the binning
     1402used.  The full scale background image is then constructed by
     1403bilinearly interpolating this binned model, and this is subtracted
     1404from the science image.  Each object in the photometric catalog has a
     1405SKY and SKY\_SIGMA value that is the evaluation of this model at the
     1406location of that object.
     1407
     1408Although this background modeling process works well for most of the
     1409sky, astronomical sources that are large compared to the
     1410$800\times{}800$ pixel subdivisions can bias the calculated background
     1411level high, resulting in an oversubtraction near that object.  The
     1412most common source that can cause this issue are large galaxies, which
     1413can have their own features modeled as being part of the background.
     1414For the specialized processing of M31, which covers an entire pointing
     1415of GPC1, the measured background was added back to the \ippstage{chip}
     1416stage images, but this special processing was not used for the large
     1417scale $3\Pi$ PV3 reduction.
    2201418
    2211419\section{GPC1 Detrend Construction}
    2221420\label{sec:detrend construction}
    2231421
    224 The detrends for GPC1 are all constructed in similar ways.  A series
    225 of appropriate exposures is selected from the database, and processed
    226 with the \ippprog{ppImage} program.  This program is used for the
    227 \ippstage{chip} stage processing as well, and is designed to do image
    228 processing.  The extent of this processing is dependent on the order
    229 in which the detrend is applied to science data.  In general, the
    230 input exposures to the detrend have all prior stages of detrend
    231 processing applied.  Table \ref{tab:detrend ppImage} summarizes stages
    232 applied for the detrends we construct.
     1422The various detrends for GPC1 are constructed in similar ways.  A
     1423series of appropriate exposures is selected from the database, and
     1424processed with the \ippprog{ppImage} program.  This program is used
     1425for the \ippstage{chip} stage processing as well, and is designed to
     1426do multiple image processing operations.  The extent of this
     1427processing is dependent on the order in which the detrend to be
     1428constructed is applied to science data.  In general, the input
     1429exposures to the detrend have all prior stages of detrend processing
     1430applied.  Table \ref{tab:detrend ppImage} summarizes stages applied
     1431for the detrends we construct.
    2331432
    2341433Once the input data has been prepared, the \ippprog{ppMerge} program
     
    2411440format of the detrend under construction, and after construction, are
    2421441applied to the processed input data.  This creates a set of residual
    243 files that can be checked to determine if the newly created detrend
    244 works correctly.
    245 
    246 The process of detrend construction and testing can be iterated, with
     1442files that are checked to determine if the newly created detrend
     1443correctly removes the detector dependent signal.
     1444
     1445This process of detrend construction and testing can be iterated, with
    2471446individual exposures excluded if they are found to be contaminating
    248 the output.  If the final detrend is considered sufficient, then the
    249 iterations are stopped and the detrend is finalized by selecting the
    250 date range to which it applies.  This allows subsequent science
    251 processing to select the detrends needed based on the observation
    252 date.  Table \ref{tab:detrend list} lists the set of detrends used in
    253 the PV3 processing.
     1447the output.  If the final detrend has sufficiently small residuals,
     1448then the iterations are stopped and the detrend is finalized by
     1449selecting the date range to which it applies.  This allows subsequent
     1450science processing to select the detrends needed based on the
     1451observation date.  Table \ref{tab:detrend list} lists the set of
     1452detrends used in the PV3 processing.
    2541453
    2551454\begin{deluxetable}{lcccc}
     
    3211520            & 964  & 2010-09-01 00:00:00 & 2011-05-01 00:00:00 & \\
    3221521            & 965  & 2011-05-01 00:00:00 & & \\
    323   FLAT      & 300  & 2009-12-09 00:00:00 & & g filter \\
    324             & 301  & 2009-12-09 00:00:00 & & r filter \\
    325             & 302  & 2009-12-09 00:00:00 & & i filter \\
    326             & 303  & 2009-12-09 00:00:00 & & z filter \\
    327             & 304  & 2009-12-09 00:00:00 & & y filter \\
     1522  FLAT      & 300  & 2009-12-09 00:00:00 & & \gps{} filter \\
     1523            & 301  & 2009-12-09 00:00:00 & & \rps{} filter \\
     1524            & 302  & 2009-12-09 00:00:00 & & \ips{} filter \\
     1525            & 303  & 2009-12-09 00:00:00 & & \zps{} filter \\
     1526            & 304  & 2009-12-09 00:00:00 & & \yps{} filter \\
     1527            & 305  & 2009-12-09 00:00:00 & & \wps{} filter \\
    3281528  FRINGE    & 296  & 2009-12-09 00:00:00 & & \\
    3291529  ASTROM    & 1064 & 2008-05-06 00:00:00 & & \\
     
    3331533\end{deluxetable}
    3341534
    335 \section{GPC1 Detrend Details}
    336 \label{sec:detrending}
    337 
    338 Ensuring a consistent and uniform detector response across the
    339 three-degree diameter field of view of the GPC1 camera is essential to
    340 a well calibrated survey.  Many standard image detrending steps are
    341 done for GPC1, with overscan subtraction removing the detector bias
    342 level, dark frame subtraction to remove temperature and exposure time
    343 dependent detector glows, and flat field correction to remove pixel to
    344 pixel response functions.  We also construct fringe correction for the
    345 reddest data in the y filter, to remove the interference patterns that
    346 arise in that filter due to the variations in the thickness of the
    347 detector surface.
    348 
    349 These corrections, however, assume that the detector response is
    350 linear across the full range of values.  This is not universally the
    351 case with GPC1, and this requires an additional set of detrending
    352 steps to remove these non-linear responses.  The first of these is the
    353 \ippprog{burntool} correction, which removes the persistence trails
    354 caused by the incomplete transfer of charge along the readout columns.
    355 This bright-end nonlinearity is generally only evident for the
    356 brightest stars, as only pixels that are at or beyond the saturation
    357 point of the detector have this issue.  More widespread is the
    358 non-linearity at the faint end of the pixel range.  Some readout cells
    359 and some readout cell edge pixels experience a sag relative to linear
    360 at low illumination, such that faint pixels appear fainter than
    361 expected.  The correction to this requires amplifying the pixel values
    362 in these regions to match the expected model.
    363 
    364 The final non-linear response issue has no good option for correction.
    365 Large regions of some OTA cells experience charge transfer issues,
    366 making them unusable to be used for science observations.  These
    367 regions are therefore masked in processing, with these CTE regions
    368 making up the largest fraction of masked pixels on the detector.
    369 Other regions are masked for other regions, such as static bad pixel
    370 features or temporary readout masking caused by issues in the camera
    371 electronics that make these regions unreliable.  These all contribute
    372 to the detector mask, which is augmented in each exposure for dynamic
    373 features that are masked based on the astronomical features within the
    374 field of view.
    375 
    376 For the PV3 processing, all detrending is done by the
    377 \ippprog{ppImage} program.  This program applies the detrends to the
    378 individual cells, and then an OTA level mosaic is constructed for the
    379 science image, the mask image, and the variance map image.  The single
    380 epoch photometry is done at this stage as well.  The following
    381 subsections (\ref{sec:burntool} - \ref{sec:background}) detail these
    382 detrending steps, presented in the order in which they are applied to
    383 the individual OTA image data.
    384 
    385 \subsection{Burntool / Persistence effect}
    386 \label{sec:burntool}
    387 
    388 Pixels that approach the saturation point on GPC1, which varies by
    389 readout with common values around 60000 DN, cause persistence problems
    390 on that and subsequent images.  During the read out process of an
    391 image with such a bright pixel, some of the charge associated with it
    392 is not fully shifted down the detector column toward the amplifier.
    393 As a result, this charge remains in the starting cell, and is
    394 partially collected in subsequent shifts, resulting in a ``burn
    395 trail'' that extends from the center of the bright source away from
    396 the amplifier (vertically along the pixel columns toward the top of
    397 the cell).
    398 
    399 This incomplete charge shifting in nearly full wells continues as each
    400 row is read out.  This results in a remnant charge being deposited in
    401 the pixels that the full well was shifted through.  In following
    402 exposures, this remnant charge leaks out, resulting in a trail that
    403 extends from the initial location of the bright source on the previous
    404 image towards the amplifier (vertically down along the pixel column).
    405 This remnant charge can remain on the detector for up to thirty
    406 minutes, requiring the locations of these ``burns'' be retained
    407 between exposures.
    408 
    409 Both of these types of persistence trails are detected and optionally
    410 repaired via the \ippprog{burntool} program.  This program does an
    411 initial scan of the images, and identifies objects with pixel values
    412 brighter than a threshold of 30000 DN.  The trail from that star is
    413 fit with a one-dimensional power law in each pixel column above that
    414 threshold, based on empirical evidence that this is the functional
    415 form of this persistence effect.  This also matches the expectation
    416 that a constant fraction of charge is incompletely transferred at each
    417 shift beyond the persistence threshold.  Once this fit is done, the
    418 model can subtracted from the image, and the location of the star is
    419 stored in a table along with the exposure PONTIME, which denotes the
    420 number of seconds since the detector was last powered on and provides
    421 an internally consistent time scale.
    422 
    423 For subsequent exposures, the table associated with the previous image
    424 is read in, and after correcting trails from the stars on the new
    425 image, the positions of the bright stars from the table are used to
    426 check for remnant trails on the image.  These are fit and subtracted
    427 using a one-dimensional exponential model, again based on empirical
    428 studies.  If a significant model with is determined, then this
    429 location is retained in the image output table.  If not, the old burn
    430 is allowed to expire.
    431 
    432 An issue with this method of correcting the persistence trails is that
    433 it is based on fits to the raw image data, which may have other signal
    434 sources not determined by the persistence effect.  The presence of
    435 other stars or artifacts along the path of the burn can result in a
    436 poor model to be determined, resulting in either an over- or
    437 under-subtraction of the persistence burn.  For this reason, the image
    438 mask is marked with a value indicating that this correction has been
    439 applied.  These pixels are not fully excluded, but they are marked as
    440 suspect, which allows them to be excluded from consideration in
    441 subsequent stages, such as image stacking.
    442 
    443 Another concern is that the cores of very bright stars are deformed by
    444 this process, as the burntool fitting subtracts flux
    445 from only one side of the star.  As most stars that result in burns already
    446 have saturated cores, they are already ignored for the purpose of
    447 PSF determination and are flagged as saturated by the photometry
    448 reduction.
    449 
    450 \begin{figure}
    451   \centering
    452   \begin{minipage}{0.45\hsize}
    453     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_XY11_bt_trail.png}
    454 %    \caption{(a)}
    455 %  \end{subfigure}%
    456 %  \begin{subfigure}[]{.45\hsize}
    457   \end{minipage}%
    458   \begin{minipage}{0.45\hsize}
    459     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0124o_XY11_bt_trail.png}
    460 %    \caption{(b)}
    461 %  \end{subfigure}
    462   \end{minipage}
    463 
    464   \caption{Example of a profile cut along the y-axis through a bright star on exposure o5677g0123o OTA11 in cell xy60 (left panel) and on the subsequent exposure o5677g0124o (right panel).  In both figures, the green points show the image corrected with all appropriate detrending steps, but without burntool applied, illustrating the amplitude of the persistence trails.  The red points show the same data after the burntool correction, which reduce the impact of these features.  Both exposures are in the g-filter with exposure times of 43s}
    465 \end{figure}
    466 
    467 \begin{figure}
    468   \centering
    469   \begin{minipage}{0.45\hsize}
    470     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_XY11_nobt.png}
    471 %    \caption{(a)}
    472 %  \end{subfigure}%
    473 %  \begin{subfigure}[]{.45\hsize}
    474   \end{minipage}%
    475   \begin{minipage}{0.45\hsize}
    476     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0124o_XY11_nobt.png}
    477 %    \caption{(b)}
    478 %  \end{subfigure}
    479   \end{minipage}
    480   \begin{minipage}{0.45\hsize}
    481     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_XY11_bt.png}
    482 %    \caption{(a)}
    483 %  \end{subfigure}%
    484 %  \begin{subfigure}[]{.45\hsize}
    485   \end{minipage}%
    486   \begin{minipage}{0.45\hsize}
    487     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0124o_XY11_bt.png}
    488 %    \caption{(b)}
    489 %  \end{subfigure}
    490   \end{minipage}
    491   \caption{Example of OTA11 cell xy60 on exposures o5677g0123o (left) and o5677g0124o (right).  The top panels show the image with all appropriate detrending steps, but with burntool, and the bottom show the same with burntool applied.  There is some slight over subtraction in fitting the initial trail, but the impact of the trail is greatly reduced in both exposures.}
    492 \end{figure}
    493 
    494 \subsection{Masking}
    495 \label{sec:masking}
    496 
    497 \subsubsection{Static Masks}
    498 \label{sec:static_masks}
    499 
    500 Due to the large size of the detector, it is expected that there
    501 are a number of pixel defects that do not have the detection
    502 sensitivity on par with their neighbors.  To remove these pixels, we
    503 have constructed a static mask that identifies the known defects.
    504 This mask is constructed in three phases.
    505 
    506 First, a CTEMASK is constructed to mask out regions in which the
    507 charge transfer efficiency is low compared to the rest of the
    508 detector.  Twenty-five of the sixty OTAs in GPC1 show some evidence of
    509 CTE issues, with this pattern showing up (to varying degrees) in
    510 roughly triangular patches on the OTA due to defects in the
    511 semiconductor manufacturing.  To generate the mask for these regions,
    512 a sample set of 26 evenly illuminated flat field images were measured
    513 to produce a map of the image variance in 20x20 pixel bins.  As the
    514 flat image is expected to illuminate the image uniformly, the expected
    515 variances in each bin should be Poissonian distributed with the flux
    516 level.  However, in regions with CTE issues, adjacent pixels are not
    517 independent, as the charge in those pixels is more free to spread.
    518 This reduces the pixel-to-pixel differences, resulting in a lower than
    519 expected variance.  All regions with variance less than half the
    520 average image level are added to the static CTEMASK.
    521 
    522 The next step of mask construction is to examine the flat and dark
    523 models, and exclude pixels that appear to be poorly corrected by these
    524 models.  The DARKMASK process looks for pixels that are more than
    525 $8\sigma$ discrepant in $10\%$ of the 100 input dark frame images
    526 after those images have had the dark model applied to them.  These
    527 pixels are assumed to be unstable with respect to the dark model, and
    528 have the DARK bit set in the static mask, indicating that they are
    529 unreliable in scientific observing.  Similarly, the FLATMASK process
    530 looks for pixels that are $3\sigma$ discrepant in the same fraction of
    531 16 input flat field images after both the dark and flat models have
    532 been applied.  Those pixels that do not follow the flat field model of
    533 the rest of image are assigned the FLAT mask bit in the static mask,
    534 removing the pixels that cannot be corrected to a linear response.
    535 
    536 The final step of mask construction is to examine the detector for
    537 bright columns and other static pixel issues.  This is first done by
    538 processing a set of 100 i filter science images in the same fashion as
    539 for the DARKMASK.  A median image is constructed from these inputs
    540 along with the per-pixel variance.  These images are used to identify
    541 pixels that have unexpectedly low variation between all inputs, as
    542 well as those that significantly deviate from the global median value.
    543 Once this initial set of bad pixels is identified, a $3\times{}3$
    544 pixel triangular kernel is convolved with the initial set, and any
    545 convolved pixel with value greater than 1 is assigned to the static
    546 mask.  This does an excellent job of removing the majority of the
    547 problem pixels.  A subsequent manual inspection allows human
    548 interaction to identify other inconsistent pixels including the
    549 vignetted regions around the edge of the detector. 
    550 
    551 Figure \ref{fig:static mask} shows an example of the static mask for
    552 the full GPC1 field of view.  Table \ref{tab:mask_values} lists the
    553 bit mask values used for the different sources of masking.
    554 
    555 \begin{figure}
    556   \centering
    557   \includegraphics[width=0.9\hsize,angle=0,clip]{images/gpc1_mask_indexed.png}
    558   \label{fig:static mask}
    559  
    560   \caption{Image map of static mask. color coded based on mask reason?  It won't be visible at true pixel scale.}
    561 \end{figure}
    562 
    563 \begin{deluxetable}{ccl}
    564   \tablecolumns{3}
    565   \tablewidth{0pc}
    566   \tablecaption{GPC1 Mask Values}
    567   \tablehead{\colhead{Mask Name} & \colhead{Mask Value} & \colhead{Description}}
    568   \startdata
    569   DETECTOR & 0x0001 & A detector defect is present. \\
    570   FLAT     & 0x0002 & The flat field model does not calibrate the pixel reliably. \\
    571   DARK     & 0x0004 & The dark model does not calibrate the pixel reliably. \\
    572   BLANK    & 0x0008 & The pixel does not contain valid data. \\
    573   CTE      & 0x0010 & The pixel has poor charge transfer efficiency. \\
    574   SAT      & 0x0020 & The pixel is saturated. \\
    575   LOW      & 0x0040 & The pixel has a lower value than expected. \\
    576   SUSPECT  & 0x0080 & The pixel is suspected of being bad. \\
    577   BURNTOOL & 0x0080 & The pixel contain an burntool repaired streak. \\
    578   CR       & 0x0100 & A cosmic ray is present. \\
    579   SPIKE    & 0x0200 & A diffraction spike is present. \\
    580   GHOST    & 0x0400 & An optical ghost is present. \\
    581   STREAK   & 0x0800 & A streak is present. \\
    582   STARCORE & 0x1000 & A bright star core is present. \\
    583   CONV.BAD & 0x2000 & The pixel is bad after convolution with a bad pixel. \\
    584   CONV.POOR& 0x4000 & The pixel is poor after convolution with a bad pixel. \\
    585   MARK     & 0x8000 & An internal flag for temporarily marking a pixel. \\
    586   \enddata
    587   \label{tab:mask_values}
    588 \end{deluxetable}
    589 
    590 \subsubsection{Dynamic masks}
    591 \label{sec:dynamic_masks}
    592 
    593 In addition to the static mask that removes the constant detector
    594 level defects, we also generate a set of dynamic masks that change
    595 with the astronomical features in the image.  These masks are advisory
    596 in nature, and do not completely exclude the pixel from further
    597 processing consideration.  The first of these dynamic masks is the
    598 burntool advisory mask mentioned above.  These pixels are included for
    599 photometry, but are rejected more readily in the stacking and
    600 difference image construction, as they are more likely to have small
    601 deviations due to imperfections in the burntool correction.
    602 
    603 The remaining dynamic masks are not generated until the IPP \ippstage{camera}
    604 stage, at which point all object photometry is complete, and an
    605 astrometric solution is known for the exposure.  This added
    606 information provides the positions of bright sources based on the
    607 reference catalog, including those that fall slightly out of the
    608 detector field of view or within the inter chip gaps, where internal
    609 photometry may not have identified them.  These bright sources are the
    610 origin for many of the image artifacts that the dynamic mask
    611 identifies and excludes.
    612 
    613 \subsubsection{Electronic crosstalk ghosts}
    614 \label{sec:crosstalk}
    615 
    616 Due to electrical crosstalk between the flex cables connecting the
    617 individual detector OTA devices, ghost objects can be created due to
    618 the presence of a bright source at a different position on the camera.
    619 Table \ref{tab:crosstalk_rules} summarizes the list of known crosstalk
    620 rules, with an estimate of the magnitude difference between the source
    621 and ghost.  For all of the rules, any cell $v$ within the specified
    622 column of cells on any of the OTAs in the specified column of OTAs $Y$
    623 creates the ghost in the same $v$ and $Y$ in the target column of
    624 cells and OTAs.  In each of these cases, a source object brighter than
    625 -14.47 instrumental magnitude creates a ghost object many orders of
    626 magnitude fainter at the target location.  The cell (x,y) pixel
    627 coordinate is identical between source and ghost, as a result of the
    628 transfer occurring as the devices are read.  A circular mask is added
    629 to the ghost location with radius $R = 3.44 \left(-14.47 - m_{source,
    630   instrumental}\right)$ pixels.  Any objects in the photometric
    631 catalog found at the location of the ghost mask have the GHOST mask
    632 bit set, marking the object as a likely ghost.  The majority of the
    633 crosstalk rules are bi-directional, with a source in either position
    634 creating a ghost at the corresponding crosstalk target position.  The
    635 two faintest rules are uni-directional, due to differences in the
    636 electronic path for the crosstalk.
    637 
    638 For the very brightest sources ($m_{instrumental} < -15$), there can
    639 be crosstalk ghosts between all columns of cells during the readout.
    640 These ``bleed'' ghosts were originally identified as ghosts of the
    641 saturation bleeds appearing in the neighboring cells, and as such, the
    642 masking for these objects puts a rectangular mask down from top to
    643 bottom of cells in all columns that are in the same row of cells as
    644 the bright source.  The width of this box is a function of the source
    645 magnitude, with $W = 5 * \left(-15 - m_{source, instrumental}\right)$
    646 pixels.
    647 
    648 \begin{deluxetable}{lllc}
    649   \tablecolumns{4}
    650   \tablewidth{0pc}
    651   \tablecaption{GPC1 Crosstalk Rules}
    652   \tablehead{\colhead{Type}&\colhead{Source OTA/Cell}&\colhead{Ghost OTA/Cell}&\colhead{$\Delta m$}}
    653   \startdata
    654   Inter-OTA & OTA2Y XY3v & OTA3Y XY3v & 6.16 \\
    655             & OTA3Y XY3v & OTA2Y XY3v &      \\
    656             & OTA4Y XY3v & OTA5Y XY3v &      \\
    657             & OTA5Y XY3v & OTA4Y XY3v &      \\
    658   Intra-OTA & OTA2Y XY5v & OTA2Y XY6v & 7.07 \\
    659             & OTA2Y XY6v & OTA2Y XY5v &      \\
    660             & OTA5Y XY5v & OTA5Y XY6v &      \\
    661             & OTA5Y XY6v & OTA5Y XY5v &      \\
    662   One-way   & OTA2Y XY7v & OTA3Y XY2v & 7.34 \\
    663             & OTA5Y XY7v & OTA4Y XY2v &      \\
    664   \enddata
    665   \label{tab:crosstalk_rules}
    666 \end{deluxetable}
    667  
    668 %% \begin{figure}
    669 %%   \centering
    670 %%   \caption{Figure of crosstalk ghost and bright star source.  Plot of cut across ghost to illustrate the flat-top shape.}
    671 %% \end{figure}
    672 
    673 \subsubsection{Optical ghosts}
    674 \label{sec:optical_ghosts}
    675 % http://arxiv.org/pdf/1207.2513v1.pdf
    676 
    677 Due to imperfections in the anti-reflective coating on the optical
    678 surfaces of GPC1, bright sources can also result in large out of focus
    679 objects, particularly in the g-filter data.  These objects are the
    680 result of light reflecting back off the surface of the detector,
    681 reflecting again off the lower surfaces of the optics (particularly
    682 the L1 corrector lens), and then back down onto the focal plane.  Due
    683 to the extra travel distance, the resulting source is out of focus and
    684 elongated along the radial direction of the camera focal plane. These
    685 optical ghosts can be modeled in the focal plane coordinates (L,M)
    686 which has its origin at the center of the focal plane.  In this
    687 system, a bright object at location (L,M) on the focal plane creates a
    688 reflection ghost on the opposite side of the optical axis at (-L,-M).
    689 The exact location is fit as a third order polynomial in the focal
    690 plane L and M directions (as listed in Table \ref{tab:ghost_centers}).
    691 An elliptical annulus mask is constructed at the expected ghost
    692 location, with the major and minor axes defined by linear functions of
    693 the ghost distance from the optical axis, and oriented with the
    694 ellipse major axis is along the radial direction (Table
    695 \ref{tab:ghost_radii}).  All stars brighter than a filter-dependent
    696 threshold (listed in Table \ref{tab:ghost_magnitudes}) have such masks
    697 constructed.
    698 
    699 \begin{deluxetable}{lcc}
    700   \tablecolumns{3}
    701   \tablewidth{0pc}
    702   \tablecaption{Optical Ghost Center Transformations}
    703   \tablehead{\colhead{Polynomial Term}&\colhead{L center}&\colhead{M center}}
    704   \startdata
    705   $x^0 y^0$ & -1.215661e+02 &  2.422174e+01 \\
    706   $x^1 y^0$ &  1.321875e-02 &  4.170486e-04 \\
    707   $x^2 y^0$ & -4.017026e-09 & -1.934260e-08 \\
    708   $x^3 y^0$ &  1.148288e-10 & -1.173657e-12 \\
    709   $x^0 y^1$ & -1.908074e-03 &  1.189352e-02 \\
    710   $x^1 y^1$ &  8.479150e-08 & -9.256748e-08 \\
    711   $x^2 y^1$ &  1.635732e-11 &  1.140772e-10 \\
    712   $x^0 y^2$ &  2.625405e-08 &  8.123932e-08 \\
    713   $x^1 y^2$ &  1.125586e-10 &  1.328378e-11 \\
    714   $x^0 y^3$ &  2.912432e-12 &  1.170865e-10 \\
    715   \enddata
    716   \label{tab:ghost_centers}
    717 \end{deluxetable}
    718 
    719 \begin{deluxetable}{lcccc}
    720   \tablecolumns{5}
    721   \tablewidth{0pc}
    722   \tablecaption{Optical Ghost Annulus Axis Length}
    723   \tablehead{\colhead{Radial Order}&\colhead{Inner Major Axis}&\colhead{Inner Minor Axis}&    \colhead{Outer Major Axis}&\colhead{Outer Minor Axis}}
    724   \startdata
    725   $r^0$ & 3.926693e+01 & 5.287548e+01 & 7.928722e+01 & 1.314265e+02 \\
    726   $r^1$ & 5.325759e-03 &-2.191669e-03 & 1.722181e-02 & -2.627153e-03 \\
    727   \enddata
    728   \label{tab:ghost_radii}
    729 \end{deluxetable}
    730 
    731 \begin{deluxetable}{lc}
    732   \tablecolumns{2}
    733   \tablewidth{0pc}
    734   \tablecaption{Optical Ghost Magnitude Limits}
    735   \tablehead{\colhead{Filter}&\colhead{$m_{inst}$}}
    736   \startdata
    737   g & -16.5 \\
    738   r & -20.0 \\
    739   i & -25.0 \\
    740   z & -25.0 \\
    741   y & -25.0 \\
    742   w & -20.0 \\
    743   \enddata
    744   \label{tab:ghost_magnitudes}
    745 \end{deluxetable}
    746 
    747 
    748 \begin{figure}
    749   \centering
    750   \includegraphics[width=0.9\hsize,angle=0,clip]{images/full_fpa_ghosts.jpg}
    751   \caption{Example of the full GPC1 field of view illustrating the sources and destinations of optical ghosts on exposure o5677g0123o (2011-04-26, 43s g-filter).  The bright stars on OTA33 and OTA44 result in nearly circular ghosts on the opposite OTA.  In contrast, the trio of stars on OTA11 result in very elongated ghosts on OTA66.}
    752 \end{figure}
    753 
    754 \subsubsection{Optical glints}
    755 \label{sec:glints}
    756 Prior to \czwdraft{DATE}, a reflective surface at the edge of the
    757 camera aperture was incompletely screened to light passing through the
    758 telescope.  Sources brighter than $m = -20$ that fell on this
    759 reflective surface resulted in light being scattered across the
    760 detector surface in a long narrow glint.  This surface was physically
    761 masked on \czwdraft{DATE}, removing the possibility of glints in
    762 subsequent data, but that taken prior have a dynamic mask constructed
    763 when a reference source falls on the focal plane within one degree of
    764 the detector edge.  This mask is 150 pixels wide, with length $L =
    765 2500 \left(-20 - m_{inst}\right)$ pixels.  \czwdraft{Am I correct that
    766   this is basically a one-degree edge around the detector?}
    767 
    768 %%
    769 %% GLINT_MAX_MAG                   F32 -21.0
    770 %% GLINT.REGION                    MULTI
    771 
    772 %% GLINT.REGION                    METADATA
    773 %%   REGION                        STR  [-38000:-24000,-20000:+20000]
    774 %%   GLINT.TYPE                    STR  LEFT
    775 %% END
    776 
    777 %% GLINT.REGION                    METADATA
    778 %%   REGION                        STR  [+24000:+38000,-20000:+20000]
    779 %%   GLINT.TYPE                    STR  RIGHT
    780 %% END
    781 
    782 %% GLINT.REGION                    METADATA
    783 %%   REGION                        STR  [-20000:+20000,+24000:+38000:]
    784 %%   GLINT.TYPE                    STR  TOP
    785 %% END
    786 
    787 %% GLINT.REGION                    METADATA
    788 %%   REGION                        STR  [-20000:+20000,-38000:-24000]
    789 %%   GLINT.TYPE                    STR  BOTTOM
    790 %% END
    791 
    792 \begin{figure}
    793   \centering
    794   \includegraphics[width=0.9\hsize,angle=0,clip]{images/glint_example_o5379g0103o.jpg}
    795   \caption{Example of a glint on exposure o5379g0103o (2010-07-02, 45s i-filter).  The source star out of the field of view creates a long reflection that extends through OTA73 and OTA63.}
    796 \end{figure}
    797 
    798 \subsubsection{Diffraction Spikes and Saturated Stars}
    799 \label{sec:diffraction_spikes}
    800 
    801 Bright sources also form diffraction spikes that are dynamically
    802 masked.  These are filter independent, and are modeled as rectangles
    803 with length $L = 10^{0.096 * (7.35 - m_{instrumental})} - 200$ and
    804 width $W = 8 + (L - 200) * 0.01$, with negative values indicating no
    805 mask is constructed, as the source is likely too faint to produce the
    806 feature.  These spikes are dependent on the camera rotation, and are
    807 oriented at $\theta = n * \frac{\pi}{2} - \mathrm{ROTANGLE} + 0.798$,
    808 based on the header keyword.
    809 
    810 %\subsubsection{Saturated stars}
    811 %\label{sec:saturated_stars}
    812 
    813 The cores of stars that are saturated are masked as well, with a
    814 circular mask radius $r = 10.15 * (-15 - m_{instrumental})$.  An
    815 example of a saturated star, with the masked regions for the
    816 diffraction spikes and core saturation highlighted, is shown in Figure
    817 \ref{fig:saturated star}.
    818 
    819 \begin{figure}
    820   \centering
    821   \includegraphics[width=0.9\hsize,angle=0,clip]{images/o6802g0338o_XY51_b1.jpg}
    822   \caption{Example of saturated star, with diffraction spikes extending from the core on exposure o6802g0338o, OTA51 (2014-05-25, 45s g-filter).}
    823   \label{fig:saturated star}
    824 \end{figure}
    825 
    826 \subsubsection{Video Mask}
    827 \label{sec:video_masks}
    828 
    829 One aspect of the OTAs on GPC1 is that an individual cell can be read
    830 repeatedly while the other cells integrate, resulting in a video
    831 signal from that cell.  This data is used for telescope guiding
    832 purposes, and a single exposure is likely to have a number of these
    833 video cells active on different OTAs.  For the 3PI survey, the median
    834 exposure has 14 video cells being read, although this number ranges
    835 from less than five to more than thirty, depending on the stellar
    836 density and field pointing.  Reading these cells while integrating on
    837 the others changes the characteristic dark model (see Section
    838 \ref{sec:video_darks} below) experienced by the other cells on the
    839 OTA.  The observed effect of this is that the glow associated with the
    840 amplifiers in the corners of the cells is suppressed during the video
    841 readout, relative to the nominal glow.  The standard dark model
    842 oversubtracts this glow, resulting in dark regions in the corners of
    843 the cells on an OTA taking video data.  Before the nature of this
    844 issue was fully understood, these poorly constrained corners were
    845 masked with 25-pixel radius quarter circles, centered on the (0,0)
    846 pixel nearest the cell amplifier.  The other corners of the cell were
    847 masked with a 15-pixel radius quarter circle, as the amplifier
    848 creating the glow is associated with another cell, separated by the
    849 inter-cell spacing, diminishing the area affected.  Due to the large
    850 area that this masking would cover, the PV3 processing used a more
    851 robust video dark model to correct this problem, as described in
    852 section \ref{sec:video_darks} below.
    853 
    854 
    855 \subsubsection{Masking Fraction}
    856 \label{sec:masking_fraction}
    857 
    858 For the full field of view that falls on the sixty OTAs, 14.7\% of all
    859 pixels are masked.  The large fraction of this masking is due to
    860 regions that fall within the vignetted region.  Defining the diameter
    861 of the unvignetted region to be 3 degrees, and excluding pixels that
    862 fall beyond this point reduces the static masking fraction to 9.7\%.
    863 
    864 Unfortunately, due to the design of the OTAs and readout cells, a
    865 non-negligible fraction of the field of view falls onto an area that
    866 does not have a detector pixel.  For a given OTA mosaicked to a
    867 $4846\times{}4868$ pixel image, the 64 $590\times{}598$ pixel readout
    868 cells cover 95.7\% of the OTA area, providing an additional 4.3\%
    869 masking in the unvignetted field of view due to the absence of a
    870 detector pixel.
    871 
    872 For the inter-chip gap area loss, we use two field of view
    873 calculations to estimate the masking fraction.  The reference field of
    874 view of GPC1 is 3 degrees, which at the nominal plate scale of 0.258
    875 arcseconds per pixel, translates to a 20930 FPA pixel radius.
    876 
    877 %% mysql> select filter,AVG(camProcessedExp.maskfrac_ref_static), AVG(camProcessedExp.maskfrac_ref_dynamic), AVG(camProcessedExp.maskfrac_ref_advisory), AVG(camProcessedExp.maskfrac_max_static),AVG(camProcessedExp.maskfrac_max_dynamic),AVG(camProcessedExp.maskfrac_max_advisory) from camRun join camProcessedExp USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) WHERE camRun.label = 'LAP.PV3.20140730.final' GROUP BY filter;
    878 %% +---------+------------------------------------------+-------------------------------------------+--------------------------------------------+------------------------------------------+-------------------------------------------+--------------------------------------------+
    879 %% | filter  | AVG(camProcessedExp.maskfrac_ref_static) | AVG(camProcessedExp.maskfrac_ref_dynamic) | AVG(camProcessedExp.maskfrac_ref_advisory) | AVG(camProcessedExp.maskfrac_max_static) | AVG(camProcessedExp.maskfrac_max_dynamic) | AVG(camProcessedExp.maskfrac_max_advisory) |
    880 %% +---------+------------------------------------------+-------------------------------------------+--------------------------------------------+------------------------------------------+-------------------------------------------+--------------------------------------------+
    881 %%             static              dynamic                advisory
    882 %% | g.00000 |   0.19642137972007 | 0.00010322263512709 |    0.026838445469766
    883 %%           |   0.20949461794863 |   9.89200027293e-05 |    0.026431927734548 |
    884 %% | r.00000 |   0.19675996201399 | 0.00025214447869606 |    0.032641054600788
    885 %%           |   0.20989768279138 | 0.00023994155711801 |    0.032178525485201 |
    886 %% | i.00000 |   0.19677587604327 | 0.00057470697316504 |    0.038096251937072
    887 %%           |   0.21003570722292 | 0.00053987093278142 |    0.037471018638997 |
    888 %% | z.00000 |    0.1974290315691 | 0.00024758901226967 |     0.03064123748973
    889 %%           |   0.21055007930696 | 0.00023452690039757 |    0.030144453360769 |
    890 %% | y.00000 |   0.19828990634315 | 0.00014523787521897 |    0.021984846417987
    891 %%           |   0.21130344126869 | 0.00013634812877977 |     0.02163070300815 |
    892 
    893 Summing mask fractions from these three contributions within the
    894 unvignetted field of view results in an average of $\sim 20\%$ masking
    895 fraction across the field of view.  Dynamic masking adds an additional
    896 $2-3\%$, with advisory burntool masking contributing the largest
    897 single component.
    898 
    899 \subsection{Overscan}
    900 \label{sec:overscan}
    901 
    902 Each cell on GPC1 has an overscan region that covers the first 34
    903 columns of each row, and the last 10 rows of each column.  No light
    904 lands on these pixels, so the image region is trimmed to exclude them.
    905 Each row has an overscan value subtracted, calculated by finding the
    906 median value of that row's overscan pixels and then smoothing between
    907 rows with a three-row boxcar median.
    908 
    909 \subsection{Non-linearity Correction}
    910 \label{sec:nonlinearity}
    911 % check notebook, 2010-07/08
    912 
    913 The pixels of GPC1 are not uniformly linear at all flux levels.  In
    914 particular, at low flux levels, some pixels have a tendency to sag
    915 relative to the expected linear value.  This effect is most pronounced
    916 along the edges of the detector cells, although some entire cells show
    917 evidence of this effect.
    918 
    919 To correct this sag, we studied the flux behavior of a series of flat
    920 frames for a ramp of exposure times with approximate logarithmically
    921 equal spacing between 0.01s and 57.04s.  As the exposure time
    922 increases, the flux on each pixel also increases in what is expected
    923 to be a linear manner.  Each of these flat exposures in this ramp is
    924 overscan corrected, and then the median is calculated for each cell,
    925 as well as for the rows and columns within ten pixels of the edge of
    926 the science region.  From these median values at each exposure time
    927 value, we can construct the expected trend by fitting a linear model,
    928 $f_{region} = G * t_{exp} + B$, to determine the gain, $G$, and the
    929 bias, $B$, for the region considered.  This fitting was limited to only
    930 the range of fluxes between 12000 and 38000 counts, as these ranges
    931 were found to match the linear model well.  This range avoids the
    932 non-linearity at low fluxes, as well as the possibility of high-flux
    933 non-linearity effects.
    934 
    935 We store the average flux measurement and deviation from the linear
    936 fit for each exposure time for all regions on all detector cells in
    937 the linearity detrend look up tables.  When this is applied to science
    938 data, these lookup tables are loaded, and a linear interpolation is
    939 performed to determine the correction needed for the flux in that
    940 pixel.  This look up is performed for both the row and column of each
    941 pixel, to allow the edge correction to be applied where applicable,
    942 and the full cell correction elsewhere.  The average of these two
    943 values is then applied to the pixel value, reducing the effects of
    944 pixel nonlinearity.
    945 
    946 This non-linearity effect appears to be stable in time for the
    947 majority of the detector pixels, with little evident change over the
    948 survey duration.  However, as the non-linearity is most pronounced at
    949 the edges of the detector cells, those are the regions where the
    950 correction is most likely to be incomplete.  Because of this fact,
    951 most pixels in the static mask with either the DARKMASK or FLATMASK
    952 bit set are found along these edges.  As the non-linearity correction
    953 is unable to reliably restore these pixels, they produce inconsistent
    954 values after the dark and flat have been applied, and are therefore
    955 rejected.
    956 
    957 %% exptime n_included/det_id = 372
    958 %% clearly this isn't the one used, as 3-12 spans three data points, poorly.x
    959 %% 0.01 2
    960 %% 0.14 2
    961 %% 0.27 2
    962 %% 0.49 2
    963 %% 0.72 2
    964 %% 1.06 2
    965 %% 1.41 2
    966 %% 2.02 2
    967 %% 2.63 2
    968 %% 3.94 2
    969 %% 5.25 2
    970 %% 8.74 2
    971 %% 13.09 2
    972 %% 17.4 2
    973 %% 20.86 2
    974 %% 24.3 2
    975 %% 27.78 2
    976 %% 31.24 2
    977 %% 34.65 2
    978 %% 38.12 2
    979 %% 42.41 2
    980 %% 46.69 2
    981 %% 51.89 2
    982 %% 57.04 2
    983 
    984 
    985 %http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/DetectorLinearity_AllEdges
    986 %http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/DetectorLinearityArchive
    987 
    988 \begin{figure}
    989   \centering
    990   \includegraphics[width=0.9\hsize,angle=0,clip]{images/linearity_XY27_xy16.png}
    991   \caption{Example plot of the linearity correction as a fraction of observed flux for OTA27, cell xy16.}
    992 \end{figure}
    993 
    994 \subsection{Dark/Bias Subtraction}
    995 \label{sec:dark}
    996 % http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Background_Dark_Model
    997 
    998 The dark model we make for GPC1 considers each pixel individually,
    999 independent of any neighbors.  To create the dark model, we fit an
    1000 multi-dimensional model to the array of input pixels from a randomly
    1001 selected set of 100-150 overscan and non-linearity corrected dark
    1002 frames chosen from a given date range.  The model fits each pixel as a
    1003 function of the exposure time $t_{exp}$ and the detector temperature
    1004 $T_{chip}$ of the input images such that $\mathrm{dark} = a_0 + a_1
    1005 t_{exp} + a_2 T_{chip} t_{exp} + a_3 T_{chip}^2 t_{exp}$.  This
    1006 fitting uses two iterations to produce a clipped fit, rejecting at the
    1007 $3\sigma$ level.  The final coefficients $a_i$ for the dark model are
    1008 stored in the detrend image.  The constant $a_0$ term includes the
    1009 residual bias signal after overscan subtraction, and as such, a
    1010 separate bias subtraction is not necessary.
    1011 
    1012 Applying the dark model is simply a matter of calculating the response
    1013 to the exposure time and detector temperature for the image to be
    1014 corrected, and subtracting the resulting dark signal from the image.
    1015 
    1016 \subsubsection{Time evolution}
    1017 
    1018 The dark model is not consistently stable over the full survey, with
    1019 significant drift over the course of multiple months.  Some of the
    1020 changes in the dark can be attributed to changes in the voltage
    1021 settings of the GPC1 controller electronics, but the majority seem to
    1022 be the result of some unknown parameter.  We can separate the dark
    1023 model history of GPC1 into three epochs.  The first epoch covers all
    1024 data taken prior to 2010-01-23.  This epoch used a different header
    1025 keyword for the detector temperature, making data from this epoch
    1026 incompatible with later dark models.
    1027 
    1028 The second epoch covers data between 2010-01-23 and 2011-05-01, and is
    1029 characterized by a largely stable but oscillatory dark solution.
    1030 There are two modes that the dark model switches between apparently at
    1031 random.  No clear cause has been established for the switching, but
    1032 there are clear differences between the two modes that require the
    1033 observation dates to be split to use the model that is most
    1034 appropriate.
    1035 
    1036 The initial evidence of these two modes comes from the discovery of a
    1037 slight gradient along the rows of certain cells.  This is a result of
    1038 a drift in the bias level of the detector as it is read out.  An
    1039 appropriate dark model should remove this gradient entirely.  For
    1040 these two modes, the direction of this bias drift is different, so a
    1041 single dark model generated from all dark images in the time range
    1042 over corrects the positive-gradient mode, and under corrects the
    1043 negative-gradient mode.  Upon identifying this two-mode behavior, and
    1044 determining the dates each mode was dominant, two separate dark
    1045 models were constructed from appropriate ``A'' and ``B'' mode dark
    1046 frames.  Using the appropriate dark minimizes the effect of this bias
    1047 gradient in the dark corrected data. 
    1048 
    1049 The bias drift gradients of the mode switching can be visualized in
    1050 Figure \ref{fig:dark switching}.  This figure shows image profile
    1051 along the x-pixel axis binned along the full y-axis of dark corrected
    1052 images for OTA67.  These images are from sequential days, and have
    1053 been corrected with a dark model constructed from the full set of dark
    1054 data within the second epoch.  The opposite sign of the slopes of
    1055 these profiles indicates that the average dark model does not correct
    1056 these dates sufficiently, due to the contradictory dark signals
    1057 between the two modes. \czwdraft{this paragraph dependent on that figure.}
    1058 
    1059 After 2011-05-01, the two-mode behavior of the dark disappears, and is
    1060 replaced with a slow observation date dependent drift in the magnitude
    1061 of the gradient.  This drift is sufficiently slow that we have modeled
    1062 it using three observation date independent dark model for different
    1063 date ranges.  These darks cover the range from 2011-05-01 to
    1064 2011-08-01, 2011-08-01 to 2011-11-01, and 2011-11-01 and on.  The
    1065 reason for this time evolution is unknown, but as it is correctable
    1066 with a small number of dark models, this does not significantly impact
    1067 detrending.
    1068 
    1069 \begin{figure}
    1070   \centering
    1071 %  \begin{subfigure}[]{.45\hsize}
    1072   \begin{minipage}{0.45\hsize}
    1073     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_M_OS_NL_XY23_b1.jpg}
    1074 %    \caption{(a)}
    1075 %  \end{subfigure}%
    1076 %  \begin{subfigure}[]{.45\hsize}
    1077   \end{minipage}%
    1078   \begin{minipage}{0.45\hsize}
    1079     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_to_DARK_XY23_b1.jpg}
    1080 %    \caption{(b)}
    1081 %  \end{subfigure}
    1082   \end{minipage}
    1083   \caption{An example of the dark model application to exposure o5677g0123o, OTA23 (2011-04-26, 43s g-filter).  The left panel shows the image data mosaicked to the OTA level, and has had the static mask applied, the overscan subtracted, and the detector non-linearity corrected.  The right panel, shows the same exposure with the dark applied in addition to the processing shown on the left.}
    1084 \end{figure}
    1085 
    1086 \begin{figure}
    1087   \centering
    1088   \includegraphics[width=0.9\hsize,angle=0,clip]{images/B_profile_ex.png}
    1089   \caption{Example showing a profile cut across exposure o5676g0195, OTA67 (2011-04-25, 43s g-filter).  The entire first row of cells (xy00-xy07) have had a median calculated along each pixel column on the OTA mosaicked image.  Arbitrary offsets have been applied to shift the curves to not overlap.  The top curve (in purple) shows the initial raw profile, without no dark model applied.  The next curve (in green) shows the smoother profile after applying the correct B-mode dark model.  Applying the incorrect A-mode dark results in the blue curve, which shows a significant increase in gradients across the cells.  The orange curve shows the result of the PATTERN.CONTINUITY correction.  Although this creates a larger gradient across the mosaicked images, it decreases the cell-to-cell level changes.  The final yellow curve shows the final image profile after all detrending and background subtraction, and has not had an offset applied.  The bright source at the cell xy00 to xy01 transition is a result of a large optical ghost, which due to the area covered, increases the median level more than the field stars.}
    1090   \label{fig:dark switching}
    1091 \end{figure}
    1092 
    1093 \subsubsection{Video Dark}
    1094 \label{sec:video_darks}
    1095 
    1096 The dark signal is stronger in cell corners due to glow from the
    1097 read-out amplifiers.  The standard dark model corrects this for most
    1098 observations.  However, as mentioned above, when a cell is repeatedly
    1099 read in video mode, the dark model for the OTA containing it changes.
    1100 Surprisingly, added reads for the video cell do not amplify the
    1101 amplifier glow, but rather decrease the dark signal in these regions.
    1102 As a result, using the standard dark model on the data for these OTAs
    1103 results in oversubtraction of the corner glow.
    1104 
    1105 Video darks have been constructed to eliminate the effect this
    1106 observational change has on the final image quality.  This was done by
    1107 running the standard dark construction process on a series of dark
    1108 frames that have had the video signal enabled for some cells.  GPC1
    1109 can only run video signals on a subset of the OTAs at a given time.
    1110 This requires two passes to enable the video signal across the full
    1111 set of OTAs that support video cells.  This is beneficial to the
    1112 process of creating darks, as those OTAs that do not have video
    1113 signals enabled create standard dark models, while the video dark is
    1114 created for the other devices.
    1115 
    1116 This simultaneous construction of video and standard dark models is
    1117 useful, as it provides the ability to isolate the response on the
    1118 standard dark from the video signals.  Isolating this response is
    1119 essential for attempting to create archival video darks.  We only have
    1120 raw video dark frame data after 2012-05-16, when this problem was
    1121 initially identified, so any data prior to that can not be directly
    1122 corrected for the video dark signal.  Isolating the video signal
    1123 response allows linear corrections to the pre-existing standard dark
    1124 models for archival data.  Testing this shows that constructing a
    1125 video dark for older data simply as $VD_{2009} = D_{2009} - D_{Modern}
    1126 + VD_{Modern}$ produces a satisfactory result that does not
    1127 oversubtract the amplifier glow.  This is shown in figure
    1128 \ref{fig:video_darks}, which shows video cells from before 2012-05-16,
    1129 corrected with both the standard and video darks, with the early video
    1130 dark constructed in such a manner.
    1131 
    1132 \begin{figure}
    1133   \centering
    1134 %  \begin{subfigure}[]{.45\hsize}
    1135   \begin{minipage}{0.45\hsize}
    1136     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_VIDEODARK_VDim_Rdark_XY22_b1.jpg}
    1137 %    \caption{(a)}
    1138 %  \end{subfigure}%
    1139 %  \begin{subfigure}[]{.45\hsize}
    1140   \end{minipage}%
    1141   \begin{minipage}{0.45\hsize}
    1142     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5677g0123o_VIDEODARK_VDim_VDdark_XY22_b1.jpg}
    1143 %    \caption{(b)}
    1144 %  \end{subfigure}
    1145   \end{minipage}
    1146   \caption{An example of the video dark model application to exposure o5677g0123o, OTA22 (2011-04-26, 43s g-filter), which has a video cell located in cell xy16.  The left panel shows the image data mosaicked to the OTA level, and has had the static mask applied, the overscan subtracted, the detector non-linearity corrected, and a regular dark applied.  The right panel, shows the same exposure with a video dark applied instead of the standard dark.  The main impact of this change is the improved correction of the corner glows, which are oversubtracted with the standard dark.}
    1147   \label{fig:video_darks}
    1148 \end{figure}
    1149 
    1150 \subsection{Noisemap}
    1151 \label{sec:noisemap}
    1152 
    1153 Based on a study of the positional dependence of all detected sources,
    1154 we have discovered that the cells in GPC1 do not have uniform noise
    1155 characteristics.  Instead, there is a gradient along the pixel rows,
    1156 with the noise generally higher away from the read out amplifier
    1157 (higher cell x pixel positions).  This is likely an effect of the
    1158 row-by-row bias issue discussed below.  This gradient causes the read
    1159 noise to increase as the row is read out.  As a result of this
    1160 increased noise, more sources are detected in the higher noise regions
    1161 when the read noise is assumed constant across the readout.  To
    1162 mitigate this noise gradient, we constructed an initial set of
    1163 noisemap images by measuring the median variance on bias frames.  The
    1164 variance is calculated in boxes of 20x20 pixels, and then linearly
    1165 interpolated to cover the full image.
    1166 
    1167 Unfortunately, due to correlations within this noise, the variance
    1168 measured from the bias images does not fully remove the positional
    1169 dependence of objects that are detected.  The reason for this is that
    1170 this simple noisemap underestimates the noise observed when the image
    1171 is filtered during the object detection process.  This filtering
    1172 convolves the background noise with a PSF, which has the effect of
    1173 amplifying the correlated peaks in the noise.  This amplification can
    1174 therefore boost background fluctuations above the threshold used to
    1175 select real objects, contaminating the final object catalogs.
    1176 
    1177 In the detection process, we expect false positives at a rate equal to
    1178 the one-tailed probability beyond the detection threshold.  For these
    1179 tests, only detections measured at the $\sigma_{thresh} = 5\sigma$
    1180 level are used, to match that used in the photometry on science data.
    1181 This probability can be converted into a number of false number by
    1182 considering a given area.  As the detections must be isolated to not
    1183 be detected as an extended object, this area must be reduced by the
    1184 area a given PSF occupies.  Combining this, we find that we expect a
    1185 probability $P = 1 - \Phi_{normal}(5) = \frac{1}{2}
    1186 \erfcinv\left(\frac{5}{\sqrt{2}}\right)$, and an area given $N$
    1187 exposures of area $X\times Y$, $A = \frac{X \times Y \times
    1188   N}{A_{PSF}}$.  For a typical $1"$ seeing, $A_{PSF}$ is approximately
    1189 16 pixels.  Using this model for the false positives, we found that
    1190 the added read noise was insufficient to account for the observed
    1191 false positive rate.  Inverting this relation, we can measure
    1192 $\sigma_{obs}$, the true threshold level based on the number of false
    1193 positives observed.  This $\sigma_{obs}$ is the combined to form a
    1194 boost factor $B = \sigma_{thresh} / \sigma_{obs}$ that amplifies the
    1195   noisemap to match the observed false detection rate.
    1196 
    1197 The row-to-row variations that contribute to the extra noise are
    1198 related to the dark model, and because of this, as the dark model
    1199 changes, the effective noise also changes.  To ensure that the
    1200 noisemap accurately matches the true noise level, we have created
    1201 different noisemap models for the three major time ranges of the dark
    1202 model.  We do not see any strong evidence that the noisemaps have the
    1203 A/B modes visible in the dark, and so we do not generate different
    1204 models for each individual dark model.  The additional pixel-to-pixel
    1205 variance from this noisemap is added to the Poissonian variance to
    1206 form the science variance image generated by the \ippstage{chip}
    1207 processing.
    1208 
    1209 \subsection{Flat}
    1210 
    1211 Determining a flat field correction for GPC1 is a challenging
    1212 endeavor, as the wide field of view makes it difficult to construct a
    1213 uniformly illuminated image.  Using a dome screen is not possible, as
    1214 the variations in illumination and screen rigidity create large
    1215 scatter between different images that are not caused by the detector
    1216 response function.  Because of this, we use sky flat images taken at
    1217 twilight, which are more consistently illuminated than screen flats.
    1218 We calculate the mean of these images to determine the initial flat
    1219 model.
    1220 
    1221 From this starting model, we construct a correction to remove the
    1222 effect of the illumination differences over the detector surface.
    1223 This is done by dithering a series of science exposures with a given
    1224 pointing.  By fully calibrating these exposures with the initial flat
    1225 model, and then comparing the measured fluxes for the same star as a
    1226 function of position on the detector, we can determine position
    1227 dependent scaling factors.  From the set of scaling factors for the
    1228 full catalog of stars observed in the dithered sequence, we can
    1229 construct a model of the error in the initial flat model as a function
    1230 of detector position.  Applying a correction that reduces the
    1231 amplitude of these errors produces a flat field model that better
    1232 represents the true detector response.
    1233 
    1234 The flat model appears stable with time, although directly measuring
    1235 this is as difficult as originally constructing the model.  However,
    1236 due to the photometric consistency observed in the final catalog of
    1237 GPC1 measurements \citep{MagnierXXX}, we can be confident that the
    1238 flat model does not have a major time dependent component.
    1239 
    1240 \subsection{Pattern correction}
    1241 \label{sec:pattern}
    1242 
    1243 Due to detector specific issues that are not cleanly removed by the
    1244 dark model, we have a set of ``pattern'' corrections that are applied
    1245 to some selection of the OTAs in the camera.  This is done to reduce
    1246 the effect that detector differences that are not stable enough to be
    1247 corrected with a global model have on the measured astronomical
    1248 signal.  Because these are not stable features that can simply be
    1249 averaged over a large number of inputs, the pattern corrections
    1250 attempt to identify and correct the detector issues based on
    1251 appropriate filtering the individual science exposures.
    1252 
    1253 The PATTERN.ROW correction is used to remove any remaining row-by-row
    1254 bias variation, and the PATTERN.CELL and PATTERN.CONTINUITY
    1255 corrections attempt to ensure that the cells of a given OTA are
    1256 consistent with the other cells on that OTA. 
    1257 
    1258 \subsubsection{Pattern Row}
    1259 % http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/GPC1_Bias_Pattern_Study
    1260 As discussed above in the dark and noisemap sections, certain
    1261 detectors have significant row-by-row bias offsets, caused by noise in
    1262 the camera control electronics.  The magnitude of these offsets
    1263 increases as the distance from the readout amplifier increases,
    1264 resulting in horizontal streaks that are more pronounced along the
    1265 large x pixel edge of the cell.  As the level of the offset is
    1266 apparently random between exposures, the dark correction cannot fully
    1267 remove this structure from the images, and the noisemap value only
    1268 indicates the level of the average variance added by these bias
    1269 offsets.  Therefore, we apply the PATTERN.ROW correction in an attempt
    1270 to mitigate the offsets and correct the image values.  To force the
    1271 rows to agree, a second order clipped polynomial is fit to each row in
    1272 the cell.  Four fit iterations are run, and pixels $2.5\sigma$ deviant
    1273 are excluded from subsequent fits, to minimize the effect stars and
    1274 other astronomical signals have.  The final trend is then subtracted
    1275 from the image.  Simply doing this subtraction will also have the
    1276 effect of removing the background sky level.  To prevent this, the
    1277 constant and linear terms for each row are stored, and linear fits are
    1278 made to these parameters as a function of row.  This produces a plane
    1279 that is added back to the image to restore the background offset and
    1280 any linear ramp that exists in the sky.
    1281 
    1282 
    1283 This correction was required on all cells on all OTAs prior to
    1284 2009-12-01, at which point a modification of the camera electronics
    1285 reduced the scale of the row-by-row offsets for the majority of the
    1286 OTAs.  As a result, we only apply this correction to the cells where
    1287 it is still necessary, as shown in Figure \ref{fig: pattern row
    1288   cells}.  A list of these cells is listed in Table
    1289 \ref{tab:pattern_row_cells}.
    1290 
    1291 Although this correction does largely resolve the row-by-row offset
    1292 issue in a satisfactory way, large and bright astronomical objects can
    1293 bias the fit significantly.  This results in an oversubtraction of the
    1294 offset near these objects.  As the offsets are calculated on the pixel
    1295 rows, this oversubtraction is not uniform around the object, but is
    1296 preferentially along the horizontal x axis of the object.  Most
    1297 astronomical objects are not significantly distorted by this, with
    1298 this only becoming on issue for only bright objects comparable to the
    1299 size of the cell (598 pixels = 150").
    1300 
    1301 %% \czwdraft{keep this?}  This row-by-row offset is visible in similar
    1302 %% camera designs, and has been removed by identifying the noise signal
    1303 %% in the pixel data stream.  By taking the FFT of the pixels and a
    1304 %% reference signal, the frequency of this noise can be isolated and
    1305 %% removed, resulting in a much cleaner image.  However, GPC1 does not
    1306 %% record the value of the reference signal, instead automatically
    1307 %% subtracting it from the data values.  Without this comparison signal,
    1308 %% we have been unable to reproduce this method, as there is no obvious
    1309 %% FFT component visible.
    1310 
    1311 \begin{deluxetable}{lcccc}
    1312   \tablecolumns{3}
    1313   \tablewidth{0pc}
    1314   \tablecaption{Cells which have PATTERN.ROW correction applied}
    1315   \tablehead{\colhead{OTA} & \colhead{Cell columns} & \colhead{Additional cells}}
    1316   \startdata
    1317   OTA11 &  & xy02, xy03, xy04, xy07 \\
    1318   OTA14 &  & xy23 \\
    1319   OTA15 & 0 & \\
    1320   OTA27 & 0, 1, 2, 3, 7 & \\
    1321   OTA31 & 7 & \\
    1322   OTA32 & 3, 7 & \\
    1323   OTA45 & 3, 7 & \\
    1324   OTA47 & 0, 3, 5, 7 & \\
    1325   OTA57 & 0, 1, 2, 6, 7 & \\
    1326   OTA60 &  & xy55 \\
    1327   OTA74 & 2, 7 & \\
    1328   \enddata
    1329   \label{tab:pattern_row_cells}
    1330 \end{deluxetable}
    1331 
    1332 \begin{figure}
    1333   \centering
    1334   \includegraphics[width=0.9\hsize,angle=0,clip]{images/pattern_row_edit.png}
    1335   \caption{Diagram illustrating in red which cells on GPC1 require the PATTERN.ROW correction to be applied.  The footprint of each OTA is outlined, and cell xy00 is marked with either a filled box or an outline.  The labeling of the non-existent corner OTAs is provided to orient the focal plane.}
    1336   \label{fig: pattern row cells}
    1337 \end{figure}
    1338 
    1339 \begin{figure}
    1340   \centering
    1341   \begin{minipage}{0.45\hsize}
    1342     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5379g0103o_XY57_nopat.png}
    1343 %    \caption{(a)}
    1344 %  \end{subfigure}%
    1345 %  \begin{subfigure}[]{.45\hsize}
    1346   \end{minipage}%
    1347   \begin{minipage}{0.45\hsize}
    1348     \includegraphics[width=0.9\hsize,angle=0,clip]{images/o5379g0103o_XY57_pat.png}
    1349 %    \caption{(b)}
    1350 %  \end{subfigure}
    1351   \end{minipage}
    1352   \caption{Example of the PATTERN.ROW correction on exposure o5379g0103o OTA57 cell xy00 (i-filter 45s).  The left panel shows the cell with all appropriate detrending except the PATTERN.ROW, and the right shows the same cell with PATTERN.ROW applied.  The correction reduces the correlated noise on the right side, which is most distant from the read out amplifier.  There is a slight over subtraction along the rows near the bright star. \czwdraft{which I can't seem to find proper ranges to highlight.}}
    1353 \end{figure}
    1354 
    1355 \subsubsection{Pattern Cell}
    1356 
    1357 As the measured background level of a given cell may not exactly match
    1358 that of its neighbors, fitting a smooth background model over the full
    1359 OTA can result in over and under-subtraction of the sky level at the
    1360 cell boundary discontinuities.  The PATTERN.CELL correction was an
    1361 initial attempt to remove this effect on the worst cells, by forcing
    1362 all the cells of an OTA to the same level.  Each cell had the median
    1363 value measured, and then each cell had an offset added that shifts the
    1364 cell to match the median of those medians.
    1365 
    1366 This correction is reasonable when the astronomical signal is smooth,
    1367 with no objects that are large relative to the size of an individual
    1368 cell.  However, the presence of large galaxies (or even bright stars)
    1369 can bias the offsets for some cells from their neighbors.  Because of
    1370 this issue, we no longer apply this correction to any data.
    1371 
    1372 \subsubsection{Pattern Continuity}
    1373 
    1374 As the PATTERN.CELL correction was insufficient in many situations, we
    1375 designed a replacement correction that would reduce the background
    1376 distortion for large objects.  In addition, studies of the background
    1377 level illustrated that the row-by-row bias can introduce small
    1378 background gradient variations along the rows of the cells that is not
    1379 stable enough to be completely fit by the dark model.  This common
    1380 feature across the columns of cells results in a ``saw tooth'' pattern
    1381 horizontally across an OTA, and as the background model fits a smooth
    1382 sky level, this induces over and under subtraction at the cell
    1383 boundaries.  As the PATTERN.CELL was designed to correct changes only
    1384 in the median value between cells, it could not adequately resolve
    1385 this higher order issue.
    1386 
    1387 The replacement for PATTERN.CELL is the PATTERN.CONTINUITY correction,
    1388 which attempts to match the edges of a cell to those of its neighbors.
    1389 For each cell, a thin box 10 pixels wide on each edge is extracted and
    1390 the median value of unmasked values calculated for that box.  These
    1391 median values are then used to construct a vector of differences
    1392 $\Delta_i = \sum_{j} Edge_{i} - Edge_{j}$, along with a matrix of
    1393 associations $A_{i,i'} = \sum_{j} \delta(i,j) \delta(j,i')$ denoting
    1394 which cell boundaries touch another.  By solving the system $A x =
    1395 diff$, we find the set of offsets $x_i$ to be applied to each cell to
    1396 ensure the minimum differences between all cell edges and their
    1397 neighbors.
    1398 
    1399 For OTAs that initially show the saw tooth pattern, the effect of this
    1400 correction is to align the cells into a single ramp, at the expense of
    1401 the absolute background level.  However, as we subtract off a smooth
    1402 background model prior to doing photometry, these deviations from an
    1403 absolute sky level are unimportant.  The fact that the final ramp is
    1404 smoother than it would be otherwise also allows for the background
    1405 subtracted image to more closely match the astronomical sky, without
    1406 significant errors at cell boundaries.  An example of the effect of
    1407 this correction on an image profile is shown in Figure \ref{fig:dark switching}.
    1408 
    1409 %% \begin{figure}
    1410 %%   \centering
    1411 %%   \caption{Continuity example, with background issue.}
    1412 %%   \label{fig: continuity example}
    1413 %% \end{figure}
    1414 
    1415 \subsection{Fringe correction}
    1416 \label{sec:fringe}
    1417 % det_id 296 is the fringe we use.
    1418 
    1419 \czwdraft{This is still a mess}
    1420 
    1421 Due to variations in the thickness of the detectors, we observe
    1422 interference patterns at the infrared end of the filter set, as the
    1423 wavelength of the light becomes comparable to the thickness of these
    1424 variations.  Visually inspecting the images shows that the fringing is
    1425 most prevalent in the y-filter images, with negligible fringing in
    1426 other bands.  As a result of this, we only apply a fringe correction
    1427 to the y filter data.
    1428 
    1429 The fringe used for PV3 processing was constructed from a set of 20
    1430 120s science exposures.  These exposures are overscan subtracted, and
    1431 corrected for non-linearity, and have the dark and flat models
    1432 applied.  These images are smoothed with a Gaussian of $\sigma = 2$
    1433 pixels to minimize pixel to pixel noise.  The fringe image data is
    1434 then constructed by calculating the clipped mean of the input images
    1435 with two iteration of clipping at the $3\sigma$ level.
    1436 
    1437 A course background model is constructed by calculating the median on
    1438 a 3x3 grid (200x200 pixels each).  A set of 1000 randomly selected
    1439 points are selected on \czwdraft{the final image} in each cell, and
    1440 median calculated for this position in a 10x10 pixel box, and the
    1441 background level subtracted.  These sample locations provide scale
    1442 points to allow the amplitude of the measured fringe to be compared to
    1443 that found on science images.
    1444 
    1445 To apply the fringe, the same sample locations are measured on science
    1446 image to determine the relative strength of the fringing in that
    1447 particular image.  A least squares fit between the fringe measurements
    1448 and the corresponding measurements on the science provides the scale
    1449 factor multiplied by the fringe before it is subtracted from the
    1450 science image.
    1451 
    1452 \begin{figure}
    1453   \centering
    1454   \begin{minipage}{0.5\hsize}
    1455     \includegraphics[width=1.0\hsize,angle=0,clip]{images/o5220g0025o_XY53_nofringe.png}
    1456 %    \caption{(a)}
    1457 %  \end{subfigure}%
    1458 %  \begin{subfigure}[]{.45\hsize}
    1459   \end{minipage}%
    1460   \begin{minipage}{0.5\hsize}
    1461     \includegraphics[width=1.0\hsize,angle=0,clip]{images/o5220g0025o_XY53_fringe.png}
    1462 %    \caption{(b)}
    1463 %  \end{subfigure}
    1464   \end{minipage}
    1465   \caption{Example of the y-filter fringe pattern on exposure o5220g0025o OTA53 (y-filter 30s).  The left panel shows the OTA mosaic with all detrending except the fringe correction, while the right shows the same including the fringe correction.  Both images have been smoothed with a Gaussian with $\sigma = 3$ pixels to highlight the faint and large scale fringe patterns. \czwdraft{See if there's a way to have mana produce images larger than the screen size.}}
    1466   \label{fig: fringe example}
    1467 \end{figure}
    1468 
    1469 \subsection{Background subtraction}
    1470 \label{sec:background}
    1471 
    1472 
    1473 Once all other detrending is done, the pixels from each cell are
    1474 mosaicked into the full $4846\times{}4868$ pixel OTA image.  A
    1475 background model for the full OTA is then determined prior to the
    1476 photometric analysis.  The mosaicked image is binned into
    1477 $800\times{}800$ pixel bins, centered on the image center, and
    1478 overlapping by a factor of 2 in both axes.  These bins have 10000
    1479 random samples drawn, and a binned cumulative distribution function is
    1480 generated.  These bins are interpolated to find the best mean value at
    1481 the $50\%$ level, as well as the distribution $\sigma$ by estimating
    1482 from the $32\%$ and $68\%$ levels.  Repeating this across all bins
    1483 results in a $13\times{}13$ grid of background bins, which are
    1484 bilinearly interpolated to generate the background model to subtract.
    1485 Each object in the photometric catalog has a SKY and SKY\_SIGMA value
    1486 based on this model as well.
    1487 
    1488 %% * Magic
    1489 %% * Warping
    1490 %%   * warping kernel
    1491 %%   * linear-by-pieces
    1492 %%   * Covariance
    1493 %%   * def of skycells?
    1494 %% * Stacking
    1495 %%   * pixel combination rules
    1496 %%   * pixel rejections
    1497 %%   * convolution for matching (success and failure)
    1498 %% * Difference Image analysis
    1499 
    1500 
    15011535\section{Warping}
    15021536\label{sec:warping}
     
    15051539projected onto a common set of tangent plane projected regions called
    15061540projection cells.  These projection cells are $4\times{}4$ degree
    1507 fields spaced onto set of centers that fully cover the sky.  They are
     1541fields spaced onto a set of centers that fully cover the sky.  They are
    15081542arranged into rings of constant declination, and allowed to overlap as
    15091543$|\delta|$ increases.  Each projection cell is further subdivided into
    1510 $10\times{}10$ sky cells with fixed $0.25"$ resolution pixels, with
     1544$10\times{}10$ sky cells with fixed $0.25"$ resolution pixels, and
    15111545constant overlap regions between adjacent skycells of $60"$.  These
    15121546skycells are the main image unit used for processing image data beyond
     
    15651599name, and the SEC keyword lists the image section corresponding to the
    15661600locally linear grid box.  The MPX and MPY contain the transformation
    1567 parameters for the locally linear grid.  \czwdraft{Is this accurate?}
    1568 
    1569 % Read all images and astrometry
    1570 % Check which input images overlap with output image. => 8007 when the inputs don't overlap.
    1571 % Loop over each image.
    1572 % Append detections from input into output detection list.
    1573 % Determine transform back from warp pixels to source image.
    1574 %% 2nd order polynomial in both x and y for this transformation. and save to header
    1575 % Break warp image into 128x128pixel locally linear areas
    1576 % Mask non finite pixels as saturated.
    1577 % Define Lanczos-3 interpolation over the input image.
    1578 % Iterate over warp pixel space (on each locally linear grid) and map interpolated input pixel positions onto warp.
    1579 % Warp pixel space is defined as center based, so that's where the intpolation point comes from.
    1580 % Covariance calculated based on the interpolation kernel at the center of the ll grid.
    1581 % image = interp_image * jacobian
    1582 % var   = interp_var * jacobian**2
    1583 % mask  = interp_mask
    1584 % jacobian = abs(mapXx * mapYy - mapYx * mapXy)
    1585 % I don't understand that jacobian.
    1586 %
    1587 
     1601parameters for the locally linear grid.  These parameters are stored
     1602in a string listing the reference position in the chip coordinate
     1603frame, the slope of the relation in the warp x axis, and the slope of
     1604the relation in the warp y axis.  From these keywords, any position in
     1605the warp can be mapped back to the location in any of the input OTA
     1606images.
     1607
     1608\begin{figure}
     1609  \centering
     1610  \includegraphics[width=0.9\hsize,angle=0,clip]{images/warp_1046511_sci.jpg}
     1611  \caption{Example of the warp image for skycell skycell.2047.005
     1612    centered at ($\alpha,\delta$) = (179.763, 32.1899) for exposure
     1613    o4985g0073o, (2009-06-03, 30s \zps{} filter).  The data from six
     1614    OTAs contribute to this image, although they are all truncated by
     1615    the skycell boundaries.  This skycell image is aligned such that
     1616    north points to the top of the image, and east to the left.  The
     1617    contributing OTAs are from the right half of the detector, with
     1618    OTA24 contributing the most pixels, and originally have the
     1619    positive y axis pointing to the southwest in this warped image,
     1620    with the positive x axis to the northwest.}
     1621  \label{fig:warp image}
     1622\end{figure}
     1623
     1624\begin{figure}
     1625  \centering
     1626  \includegraphics[width=0.9\hsize,angle=0,clip]{images/warp_1046511_wt.jpg}
     1627  \caption{Example of the warp variance image for skycell
     1628    skycell.2047.005 of exposure o4985g0073o, the same as in Figure
     1629    \ref{fig:warp image}.  This variance map retains information about
     1630    the higher flux levels that were found in burntool corrected
     1631    persistence trails, which appear here as streaks along the
     1632    original OTA y axis.  The amplifier glows that are corrected in
     1633    the dark model are also more visible in the corners of the cells
     1634    in OTA24.  As both of these effects are corrected in the science
     1635    image, there are no significant features visible there.}
     1636  \label{fig:warp variance}
     1637\end{figure}
     1638
     1639\begin{figure}
     1640  \centering
     1641  \includegraphics[width=0.9\hsize,angle=0,clip]{images/warp_1046511_mask.jpg}
     1642  \caption{Example of the warp mask image for skycell skycell.2047.005
     1643    of exposure o4985g0073o, the same as in Figure \ref{fig:warp
     1644      image}.  This mask image shows the many small defects removed
     1645    from the image, along with larger advisory trails on corrected
     1646    burntool trails.  The saturated cores of the bright stars are also
     1647    masked, along with the diffraction spikes found on these stars.
     1648    In addition OTA24 shows the precautionary crosstalk bleed masks
     1649    for the two brightest stars applied to all cells within the same
     1650    row.}
     1651\end{figure}
    15881652
    15891653\section{Stacking}
     
    15921656Once individual exposures have been warped onto a common projection
    15931657system, they can then be combined pixel-by-pixel regardless of their
    1594 original orientation.  Creating a stacked image by coadding the
    1595 individual warps increases the signal to noise which allows objects
    1596 fainter than can be found on the individual inputs to be detected.
    1597 Creating this stack also allows a complete image to be constructed
    1598 that does not have regions masked due to the gaps between cells and
    1599 OTAs.  This provides a fully populated static sky image that can
    1600 be used for subtraction to find transient sources.
     1658original orientation.  Creating a stacked image by co-adding the
     1659individual warps increases the signal to noise, allowing for the
     1660detection of objects that would not be sufficiently significant to be measured from a single image.
     1661Creating this stack also allows a complete image to be
     1662constructed that does not have regions masked due to the gaps between
     1663cells and OTAs.  This fully populated static sky image can also be
     1664used as a template for subtraction to find transient sources.
    16011665
    16021666The stacked image is comprised of all warp frames for a given skycell
     
    16071671Once all files are ingested, the first step is to measure the size and
    16081672shapes of the input image PSFs.  We exclude images that have a PSF
    1609 FWHM greater than 10 pixels, as those images have the seeing far worse
    1610 than average, and would degrade the final output stack.  For the PV3
    1611 survey, this size represents a PSF larger than $97$th percentile in
    1612 all filters.  A target PSF for the stack is constructed by finding the
    1613 maximum envelope of all input PSFs, which sets the target PSF to the
    1614 largest value among the input PSFs for a given position from the peak.
    1615 This PSF is then circularized to ensure azimuthal symmetry, which
    1616 prevents any of the input images from being deconvolved when matched
    1617 to the target.
    1618 
    1619 The input images also need to have their flux normalized to prevent
     1673FWHM greater than 10 pixels (2.5 arcseconds), as those images have the
     1674seeing far worse than average, and would degrade the final output
     1675stack.  For the PV3 $3\Pi$ survey, this size represents a PSF larger
     1676than the $97$th percentile in all filters.  A target PSF for the stack
     1677is constructed by finding the maximum envelope of all input PSFs,
     1678which sets the target PSF to the largest value among the input PSFs
     1679for a given position from the peak.  This PSF is then circularized to
     1680ensure azimuthal symmetry, which prevents deconvolution of any of the
     1681input images when matched to the target.
     1682
     1683The input images also need to have their fluxes normalized to prevent
    16201684differences in seeing and sky transparency from causing discrepancies
    1621 during pixel rejection.  From the calibrated input catalogs, we have
    1622 the instrumental magnitudes of all sources, along with the airmass,
    1623 image exposure time, and zeropoint.  All output stacks are calibrated
    1624 to a zeropoint of 25.0 in all filters, and to have an airmass of 1.0.
    1625 The output exposure time is set to the sum of the input exposure
    1626 times.  We can determine the relative transparency for each input
    1627 image by comparing the magnitudes of matched sources between the
    1628 different images.  Each image then has a normalization factor defined,
    1629 equal to $norm_{i} = (ZP_{i} - ZP_{target}) - transparency_{i} - 2.5 *
    1630 \log_{10} (t_{target} / t_{i}) - airmassTerm * (airmass_{i} -
    1631 airmass_{target})$.  \czwdraft{ZP.AIRMASS is zero for all filters.
    1632   Does this simply mean that we assume any airmass differences are
    1633   folded into the transparency differences?  This would simplify this
    1634   discussion quite a bit if that's the case, as we can just say that
    1635   and skip all the extra airmass terms.}
    1636 
    1637 % PREPARE
    1638 % load sources
    1639 % load psfs
    1640 % determine target as envelope of input psfs
    1641 % FWHM clipping at 10
    1642 % measure seeing
    1643 % -         // M_app = m_inst + zp + c1 * airmass + 2.5log(t) - transparency
    1644 %         // EAM : the discussion here was not quite right (or at least sloppy).  Here is a replacement explanation:
    1645 %        // For any star, the observed instrumental magnitude on an image and the apparent magnitude are related by:
    1646 %        // M_app = m_inst + zp + c1 * airmass + 2.5log(t) - transparency
    1647 %        // NOTE the sign of 'transparency'  this must agree with the definition in pmSourceMatch.c. see, eg, line 457 where
    1648 %        // transparency = m_inst + zp + c1 * airmass + 2.5log(t) - M_app
    1649 %        // we want to adjust the input images to be in a consistent flux system so that the
    1650 %        // final stack can be generated with a specific target zero point.  Any adjustment to
    1651 %        // the flux scale of the image must be made in coordination with the resulting
    1652 %        // zeropoint, exposure time, and airmass such that the above relationship yields the
    1653 %        // same apparent magnitude for a given star:
    1654 %        // m_inst_i : instrumental mags on input image (in)
    1655 %        // m_inst_o : instrumental mags on re-normalized image (out)
    1656 %        // m_inst_o + zp_o + c1 * airmass_o + 2.5log(t_o) - trans_o = m_inst_i + zp_i + c1 * airmass_i + 2.5log(t_i) - trans_i
    1657 %        // m_inst_o = m_inst_i + (zp_i - zp_o) + c1 * (airmass_i - airmass_o) + 2.5log(t_i) - 2.5log(t_o) - trans_i + trans_o
    1658 %        // zp_i, airmass_i, t_i, trans_i : reported or measured for input image
    1659 %        // zp_o      = zpTarget      (from recipe)
    1660 %        // airmass_o = airmassTarget (from recipe)
    1661 %        // t_o       = sumExpTime    [sum of input exposure times: once images are scale to this time, they can be avereaged]
    1662 %        // trans_o   = 0.0           [obviously!]
    1663 %        // we have 2 cases: (a) all reported ZPs are good or (b) some are bad:
    1664 %        // (a) FPA.ZP = zp_i + c1 * airmass_i
    1665 %        //  --> zp[i] = zp_i + c1 * airmass_i + 2.5log(exptime_i)
    1666 %        // (b)  zp[i] = c1 * airmass_i + 2.5log(exptime_i)
    1667 %        // NOTE: in case (b), the current code is equating the TARGET zp with the NOMINAL zp, which is wrong.
    1668 %        // m_inst_o - m_inst_i = zp[i] - zpTarget - c1 * airmassTarget - 2.5log(sumExpTime) - trans_i
     1685during pixel rejection.  From the reference catalog calibrated input
     1686catalogs, we have the instrumental magnitudes of all sources, along
     1687with the airmass, image exposure time, and zeropoint.  All output
     1688stacks are calibrated to a zeropoint of 25.0 in all filters, and to
     1689have an airmass of 1.0.  The output exposure time is set to the sum of
     1690the input exposure times, regardless of if those inputs are rejected
     1691later in the combination process.  We can determine the relative
     1692transparency for each input image by comparing the magnitudes of
     1693matched sources between the different images.  Each image then has a
     1694normalization factor defined, equal to $\mathrm{norm}_{input} = (ZP_\mathrm{input}
     1695- ZP_\mathrm{target}) - \mathrm{transparency}_\mathrm{input} - 2.5 *
     1696\log_{10} (t_\mathrm{target} / t_\mathrm{input}) -
     1697\mathrm{F}_\mathrm{airmass} * (\mathrm{airmass}_\mathrm{input} -
     1698\mathrm{airmass}_\mathrm{target})$.  For the PV3 processing, the
     1699airmass factor $\mathrm{F}_\mathrm{airmass}$ was set to zero, such
     1700that all flux differences from differing exposure airmasses are
     1701assumed to be included in the zeropoint and transparency values.
     1702
     1703The zeropoint calibration performed here uses the calibration of the
     1704individual input exposures against the reference catalog.  Upon the
     1705conclusion of the survey, the entire set of detection catalogs is
     1706further re-calibrated in the ``ubercal'' process \citep{2012ApJ...756..158S}.
     1707This produces a more consistent calibration of each exposure across
     1708the entire region of the sky imaged.  This further calibration is not
     1709available at the time of stacking, and so there may be small residuals
     1710in the transparency values as a result of this \citet{magnier2017c}.
    16691711
    16701712With the flux normalization factors and target PSF chosen, the
    16711713convolution kernels can be calculated for each image.  ISIS kernels
    1672 are used with FWHM values of 1.5, 3.0, and 6.0 pixels and polynomial
    1673 orders of 6, 4, and 2.  \czwdraft{Skipping this bit because I'm not
    1674   completely sure I understand it.}  The image is then scaled by the
    1675 normalization as $renorm = 10^{-0.4 * norm_{image}} /
    1676 norm_{convolution}$, and the variance by the square of that value.
    1677 
    1678 
    1679 % MATCH
    1680 % match to target PSF.
    1681 % use ISIS kernels to do matching/convolution
    1682 % Input sources used for psf matching.
    1683 % @ISIS.WIDTHS    F32     1.5  3.0  6.0   # Gaussian kernel FWHM values
    1684 % @ISIS.ORDERS    S32     6    4    2     # Polynomial orders for ISIS kernels
     1714\citep{1998ApJ...503..325A} are used with FWHM values of 1.5, 3.0, and 6.0
     1715pixels and polynomial orders of 6, 4, and 2.  Regions around the
     1716sources identified in the input images are extracted, convolved with
     1717the kernel, and the residual with the target PSF used to update the
     1718parameters of the kernel via least squares optimization.  Stamps that
     1719significantly deviate are rejected, but as the squared residual
     1720difference will increase with increasing source flux.  To mitigate
     1721this effect, a parabola is fit to the distribution of squared
     1722residuals as a function of source flux.  Stamps that deviate from this
     1723fit by more than $2.5\sigma$ are rejected, and not used on further
     1724kernel fit iterations.  This process is repeated twice, and the final
     1725convolution kernel is returned.
     1726
     1727This convolution may change the image flux scaling, so a normalization
     1728factor is used to correct this.  This normalization factor is equal to
     1729the ratio of $10^{-0.4 \mathrm{norm}_{input}}$ to the sum of the
     1730kernel.  The image is multiplied by this factor, and the variance by
     1731the square of it, scaling all inputs to the common zeropoint.
    16851732
    16861733Once the convolution kernels are defined for each image, they are used
    16871734to convolve the image to match the target PSF.  Any input image that
    1688 has a $\chi^2$ value greater than 4.0$\sigma$ larger than the median
    1689 value is rejected from the stack.  Each image also has a weight
    1690 assigned, based on the image variance after convolution.  For a given
    1691 image, the weight is equal to $W^{-1} = \langle Variance(x,y) \rangle
    1692 * f_{covariance}$, where the angle brackets denote a robust median of
    1693 the variance image, and the covariance factor $f_{covariance}$ is the
    1694 peak value of the covariance matrix of the convolution.
    1695 
    1696 % CONVOLVE
    1697 % Normalization to match target zeropoint/exptime
    1698 % Reject images with bad match chi^2 values.  MATCH.REJ * rms + median threshold.
    1699 % Additional variance from the convolution chi^2
    1700 % Calculate image weights based on variance: W_i = 1 / (ROBUST_MEDIAN(variance_image_i) * CovarianceFactor)
    1701 % CovarianceFactor = covariance->kernel[0][0]
     1735has a kernel match $\chi^2$ value greater than 4.0$\sigma$ larger than
     1736the median value is rejected from the stack.  Each image also has a
     1737weight assigned, based on the image variance after convolution.  A
     1738full image weight is then calculated for each input, with the weight,
     1739$W_\mathrm{input}$ is equal to the inverse of the median of the image
     1740variance multiplied by the peak of the image covariance (due to the
     1741warping process).
    17021742
    17031743Following the convolution, an initial stack is constructed.  For a
     
    17201760
    17211761\begin{eqnarray}
    1722   S_{value} &=& \sum_i\left(value_{i} * W_i\right) / \sum_i\left(W_i\right) \\
    1723   S_{exp weight} &=& \sum_i \left(exptime_i * W_i\right) / \sum_i\left(W_i\right) \\
     1762  \mathrm{Stack}_\mathrm{value} &=& \sum_i\left(\mathrm{value}_\mathrm{input} * W_\mathrm{input}\right) / \sum_\mathrm{inputs}\left(W_\mathrm{input}\right) \\
     1763  \mathrm{Stack}_\mathrm{exp weight} &=& \sum_i \left(\mathrm{exptime}_\mathrm{input} * W_\mathrm{input}\right) / \sum_\mathrm{inputs}\left(W_\mathrm{input}\right) \\
    17241764\end{eqnarray}
    17251765
     
    17271767
    17281768\begin{eqnarray}
    1729   S_{variance} &=& 1 / \sum_i \left( 1 / variance_i \right)
     1769  \mathrm{Stack}_\mathrm{variance} &=& 1 / \sum_i \left( 1 / \sigma^2_\mathrm{input} \right)
    17301770\end{eqnarray}
    17311771
    17321772The output mask value is taken to be zero (no masked bits), unless
    17331773there were no valid inputs, in which case the BLANK mask bit is set.
    1734 
    1735 % INITIAL COMBINE
    1736 % Calculate weighted mean of input images
    1737 % mu = sum_i(f_i * W_i) / sum_i(W_i)
    1738 % sigma = 1 / sum_i(1 / W_i)
    1739 % nu = sum_i(m_i)
    1740 %     // We're not using the input pixel variances to generate a weighted average for the pixel flux (because
    1741 %    // that introduces systematic biases), so the variance of the output pixel value should simply be:
    1742 %    //     simga^2 = sum(weight_i^2 * sigma_i^2) / (sum(weight_i))^2
    1743 %    // This reduces, when the weights are all identically unity, to:
    1744 %    //     variance_combination = sum(variance_i) / N^2
    1745 %    // and if the variances are all equal:
    1746 %    //     variance_combination = variance_individual / N
    1747 %    // which makes sense --- the standard deviation of the combination is reduced by a factor of sqrt(N).
    1748 % sumValueWeight = sum_i(values * weights)
    1749 % sumWeight = sum_i(weights)
    1750 % sumVarianceWeight == sum( 1 / variances)
    1751 % sumExp  = sum_i(exptimes)
    1752 % sumExpWeight = sum_i(exptims * weights)
    1753 % mean = sumValueWeight / sumWeight
    1754 % var  = 1 / sumVarianceWeight
    1755 % exp = sumExp
    1756 % expWeight = sumExpWeight
    1757 
    1758 % EXCEPT: if N = 1, accept it.  if N = 2, take average.
    1759 
    1760 %     if (!pmStackCombine(outRO, NULL, stack, maskBad, maskSuspect, maskBlank, kernelSize, iter,
    1761 %                        combineRej, combineSys, combineDiscard, useVariance, safe, nminpix, false)) {
    1762 %bool pmStackCombine(
    1763 %    pmReadout *combined,                // output stacked readout
    1764 %    pmReadout *expmaps,                 // output exposure map information
    1765 %    psArray *input,                     // input exposures
    1766 %    psImageMaskType badMaskBits,        // treat these bits as 'bad'
    1767 %    psImageMaskType suspectMaskBits,    // treat these bits as 'suspect'
    1768 %    psImageMaskType blankMaskBits,      // use this mask value for pixels missing input data (distinguish between Ninput = 0 and Ngood = 0?)
    1769 %    int kernelSize,
    1770 %    float iter,             0.5
    1771 %    float rej,              4.0
    1772 %    float sys,              0.1
    1773 %    float olympic,          0.2
    1774 %    bool useVariance,
    1775 %    bool safe,
    1776 %    int nminpix,
    1777 %    bool rejection)
    1778 %{
    1779 
    1780 % combineExtract
    1781 %% pixels with mask values as suspect are appended to suspect pixel list.
    1782 % combinePixels
    1783 %% As described above.
    17841774
    17851775Due to the various non-astronomical ghosts that can occur on GPC1, and
     
    17941784warp-warp difference images to be constructed to identify transient
    17951785detections, higher pixel values that come from sources like optical
    1796 ghosts depend on the telescope pointing will come in pairs as well.
     1786ghosts that depend on the telescope pointing will come in pairs as well.
    17971787The higher pixel value contaminants are also potentially problematic
    17981788as they may appear to be real sources, prompting photometry to be
     
    18011791to reject higher pixel values than lower pixel values.
    18021792
    1803 Following this initial combination, a ``testing'' loop iterates in an
     1793Following the initial combination, a ``testing'' loop iterates in an
    18041794attempt to identify outlier points.  Again, if only one input is
    18051795available, that input is accepted.  If there are two inputs, $A$ and
    1806 $B$, then a check is made to see if $(0.5 * (value_A - value_B))^2 >
    1807 rej^2 * (variance_A + variance_B + (sys * value_A)^2 + (sys *
    1808 value_B)^2)$, where $rej$ is the number of sigma deviant a point needs
    1809 to be to be excluded, set to 4.0 for the PV3 processing, and $sys$ is
    1810 an estimate of the systematic error, taken to be 0.1.
     1796$B$, then a check is made to see if $(0.5 * (\mathrm{value}_A -
     1797\mathrm{value}_B))^2 > 16 * (\sigma^2_A + \sigma^2_B
     1798+ (0.1 * \mathrm{value}_A)^2 + (0.1 * \mathrm{value}_B)^2)$, such that
     1799the deviation of the inputs from their mean position is greater than
     1800four times the sum of their measured uncertainties and a 10\%
     1801systematic error term.  If this is the case, neither input is trusted,
     1802and both are flagged for rejection
    18111803
    18121804If the number of inputs is larger than 6, then a Gaussian mixture
     
    18221814input values are passed to an Olympic weighted mean calculation.  We
    18231815reject $20\%$ of the number of inputs through this process.  The
    1824 number of bad inputs is set to $N_{bad} = 0.2 * N_{input} + 0.5$, with
    1825 the 0.5 term ensuring at least one input is rejected.  This number is
    1826 further separated into the number of low values to exclude $N_{low} =
    1827 N_{bad} / 2$, which will default to zero if there are few inputs, and
    1828 $N_{high} = N_{input} + N_{low} - N_{bad}$.  After sorting the input
    1829 values to determine which values fall into the low and high groups,
    1830 the remaining input values are used in a weighted mean using the image
    1831 weights above.
     1816number of bad inputs is set to $N_\mathrm{bad} = 0.2 *
     1817N_\mathrm{input} + 0.5$, with the 0.5 term ensuring at least one input
     1818is rejected.  This number is further separated into the number of low
     1819values to exclude $N_\mathrm{low} = N_\mathrm{bad} / 2$, which will
     1820default to zero if there are few inputs, and $N_\mathrm{high} =
     1821N_\mathrm{input} + N_\mathrm{low} - N_\mathrm{bad}$.  After sorting
     1822the input values to determine which values fall into the low and high
     1823groups, the remaining input values are used in a weighted mean using
     1824the image weights above.
    18321825
    18331826A systematic variance term is necessary to correctly scale how
     
    18391832
    18401833\begin{eqnarray}
    1841   limit_{mixture model} &=& 4^2 * (variance_i + \sigma_{MM}^2) \\
    1842   limit_{default} &=& 4^2 * (variance_i + (0.1 * value_i)^2)
     1834  \mathrm{limit}_\mathrm{mixture\ model} &=& 4^2 * (\sigma^2_\mathrm{input} + \sigma_\mathrm{mixture\ model}^2) \\
     1835  \mathrm{limit}_\mathrm{default} &=& 4^2 * (\sigma^2_\mathrm{input} + (0.1 * \mathrm{value}_\mathrm{input})^2)
    18431836\end{eqnarray}
    18441837
    18451838Each input pixel is then compared against this limit, and the most
    1846 discrepant pixel that has $(value_i - mean)^2$ exceeding this limit is
    1847 identified.  If there are suspect pixels in the set those pixels are
    1848 marked for rejection, otherwise this worst pixel is marked for
    1849 rejection.  Following this, the combine and test loop is repeated for
    1850 until no more pixels are rejected, up to a maximum number of
    1851 iterations equal to $50\%$ of the number of inputs.
    1852 
    1853 % combineTest
    1854 %% if (Ninput > 6) { use KMM }
    1855 %% KMM:
    1856 %% Calculate KMMmu KMMsigma KMMpi KMMPunimodal
    1857 %% SumWeights = sum(pixelWeights)
    1858 %% SysVar = KMMSigma**2 OR (sys * pixelData[i])**2
    1859 %% pixelLimts[i] = rej**2 * (pixelVariances[i] + sysVar)
    1860 % Iterate 0.5 * Ninput times (at least once)
    1861 %% Ninput = 1 => accept
    1862 %% Ninput = 2 => if (0.5 * (A - B))**2 > rej**2 * (pixelVariance[A] + pixelVariance[B] + (sys * A)**2 + (sys * B)**2)
    1863 %%               then if (suspect) mark reject else mark inspect
    1864 %% Else       => if (useKMM and Punimodal < 0.05) median = KMMmean
    1865 %%            => else median = combinationWeightedOlympic{}
    1866 %%            => if (pixelData - median)**2 > pixelLimits[i] then find single worst deviant pixel value
    1867 %% then       => if suspect (mark reject) else (mark reject worst deviant pixel value)
    1868 
    1869 
    1870 %% combinationWeightedOlympic =>
    1871 %% numBad = frac * Ninput + 0.5
    1872 %% low = numBad / 2, high = low + numGood - numBad
    1873 %% sort(values) =>
    1874 %% if (i > low && i <= high) { sumValues = sum_i(values * weights); sumWeight = sum_i(weights)
    1875 %% return (sumValues / sumWeight)
    1876 
    1877 % obtain lists of inspect and reject pixels.
    1878 
    1879 % normalize:?
    1880 %            float normalise = powf(10.0, -0.4 * norm->data.F32[i]); // Normalisation
    1881 %            psBinaryOp(ro->image, ro->image, ``*'', psScalarAlloc(normalise, PS_TYPE_F32));
    1882 %            psBinaryOp(ro->variance, ro->variance, ``*'', psScalarAlloc(PS_SQR(normalise), PS_TYPE_F32));
     1839discrepant pixel that has $(\mathrm{value}_\mathrm{input} -
     1840\mathrm{mean})^2$ exceeding this limit is identified.  If there are
     1841suspect pixels in the set, those pixels are marked for rejection,
     1842otherwise this worst pixel is marked for rejection.  Following this,
     1843the combine and test loop is repeated for until no more pixels are
     1844rejected, up to a maximum number of iterations equal to $50\%$ of the
     1845number of inputs.
    18831846
    18841847With the initial list of rejected pixels generated, a rejection mask
    1885 is made by constructing an empty image that has the rejected pixels
    1886 set to a value of 1.0.  This image is then convolved with a 5 pixel
    1887 FWHM zeroth-order ISIS kernel.  Any pixels that are above the threshold of
    1888 0.5 after this mask convolution are marked as bad and will be rejected in the final combination.
    1889 If more than 10\% of all pixels from an input image are rejected, then
    1890 that entire image is rejected as well.
    1891 
    1892 % PIXEL REJECTION
    1893 % Construct 15-pixel wide ISIS kernel with 5 pixel FWHM 0-order.
    1894 % Construct image of pixels to inspect and convolve with kernel (normalize out kernel power)
    1895 % Determine pixels are bad if they're larger than THRESHOLD.MASK = 0.5.
    1896 % If more than IMAGE.REJ = 0.1 fraction of pixels are rejected, the entire image is rejected.
    1897 
    1898 
    1899 \czwdraft{I'm not entirely sure why we do what appears to be a similar
    1900   operation twice.  It also seems odd that this is in the CombineFinal
    1901   step, and not in the Reject step.}  Finally, the rejected pixels are
    1902 allowed to grow to include pixels that are neighbors to many rejected
    1903 pixels.  The ISIS kernel used in the previous step is used to
     1848is made for the input warp by constructing an empty image that has the
     1849rejected pixels from that input set to a value of 1.0.  This image is
     1850then convolved with a 5 pixel FWHM zeroth-order ISIS kernel.  Any
     1851pixels that are above the threshold of 0.5 after this mask convolution
     1852are marked as bad and will be rejected in the final combination.  If
     1853more than 10\% of all pixels from an input image are rejected, then
     1854the entire image is rejected as it likely has some systematic issue.
     1855
     1856Finally, a second pass at rejecting pixels is conducted, by growing the
     1857current list to include pixels that are neighbors to many rejected
     1858pixels.  The ISIS kernel used in the previous step is again used to
    19041859determine the largest square box that contains under the limit of
    1905 $0.25 * \sum_{x,y} kernel^2$.  This box is then convolved with the
    1906 rejected pixel mask to reject their neighbors.  This final list of
    1907 rejected pixels is passed to the final combination, which creates the
    1908 final stack values from the weighted mean of the non-rejected pixels.
    1909 Six total images are constructed for this final stack: the image, its
    1910 variance, a mask, a map of the exposure time per pixel, that exposure
    1911 time map weighted by the input image weight, and a map of the number
    1912 of inputs per pixel.
    1913 
    1914 % FINAL COMBINE
    1915 % Grow rejected pixels
    1916 %% set threshold of (POOR.FRACTION = 0.25) * sum(kernel)**2
    1917 %% Choose the largest square box that contains just under that threshold.
    1918 %% Convolve that box with the rejected pixels to grow them.
    1919 % Run combination pass again, but without doing rejection, simply applying the rejection lists already calculated.
    1920 % ::
    1921 %      if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, true, true, true)) {
    1922 % iter = 0
    1923 % combineRej = NAN
    1924 % combineSys = NAN
    1925 % combineDiscard = NAN
    1926 %    if (!pmStackCombine(outRO, expRO, stack, maskBad, maskSuspect, maskBlank, 0, iter, combineRej,
    1927 %                        combineSys, combineDiscard, useVariance, safe, nminpix, rejected)) {
     1860$0.25 * \sum_{x,y} kernel^2$.  This square box is then convolved with
     1861the rejected pixel mask to reject the neighboring pixels.  This final
     1862list of rejected pixels is passed to the final combination, which
     1863creates the final stack values from the weighted mean of the
     1864non-rejected pixels.  Six total images are constructed for this final
     1865stack: the image, its variance, a mask, a map of the exposure time per
     1866pixel, that exposure time map weighted by the input image weight, and
     1867a map of the number of inputs per pixel.
    19281868
    19291869These convolved stack products are not retained, as the convolution
     
    19351875across the image, as the different PSF widths of the input images
    19361876print through in the different regions to which they have contributed.
    1937 
    1938 % UNCONVOLVED IMAGE
    1939 %         if (!ppStackCombineFinal(stack, options->origCovars, options, config, false, true, false, true)) {
    1940 % no grow
    1941 
    1942 % only retain unconvolved products.
    19431877
    19441878%% Asinh compression
     
    19581892data values must first be made positive, which then sets the highest
    19591893quantization sampling near the lowest values in the image.  Following
    1960 techniques used by SDSS \citep{sdss}, we have instead opted to use the
     1894techniques used by SDSS \citep{2000AJ....120.1579Y}, we have instead opted to use the
    19611895inverse hyperbolic sine function to transform the data.  The domain of
    19621896this function allows any input value to be converted.  In addition,
     
    19811915/ \alpha) - \exp(-C / \alpha)\right)$.
    19821916
     1917\begin{figure}
     1918  \centering
     1919  \includegraphics[width=0.9\hsize,angle=0,clip]{images/stack_3775944_sci.jpg}
     1920  \caption{Example of the stack image for skycell skycell.2047.005
     1921    centered at ($\alpha,\delta$) = (179.763, 32.1899) in the \zps{}
     1922    filter, stack\_id 3775944.  This stack includes 25 input images,
     1923    including o4985g0073o the warp image in Figure \ref{fig:warp
     1924      image}, and has a combined exposure time of 870s.  Combining
     1925    such a large number of input images removes the inter-cell and
     1926    inter-chip gaps, providing a fully populated image.  In addition,
     1927    the combined signal allows many more faint objects to be found
     1928    than were visible on the single frame warp image.}
     1929
     1930  \label{fig:stack image}
     1931\end{figure}
     1932
     1933\begin{figure}
     1934  \centering
     1935  \includegraphics[width=0.9\hsize,angle=0,clip]{images/stack_3775944_mask.jpg}
     1936  \caption{Example of the stack mask image for skycell
     1937    skycell.2047.005 centered at ($\alpha,\delta$) = (179.763,
     1938    32.1899) in the \zps{} filter, stack\_id 3775944.  The entire
     1939    frame is largely unmasked after combining inputs, with the only
     1940    remaining masks falling on the cores of bright stars, and in small
     1941    regions around the brightest objects where the overlapping of
     1942    diffraction spike masks have removed all inputs.}
     1943
     1944  \label{fig:stack mask image}
     1945\end{figure}
     1946
     1947\begin{figure}
     1948  \centering
     1949  \includegraphics[width=0.9\hsize,angle=0,clip]{images/stack_3775944_wt.jpg}
     1950  \caption{Example of the stack variance image for skycell
     1951    skycell.2047.005 centered at ($\alpha,\delta$) = (179.763,
     1952    32.1899) in the \zps{} filter, stack\_id 3775944.  The variance
     1953    map for this stack is reasonably smooth, with the mottled pattern
     1954    from the inter-chip and inter-cell gaps printing through.  Some
     1955    regions with higher variance are found where the number of inputs
     1956    is lower.}
     1957
     1958  \label{fig:stack wt image}
     1959\end{figure}
     1960
     1961\begin{figure}
     1962  \centering
     1963  \includegraphics[width=0.9\hsize,angle=0,clip]{images/stack_3775944_num.jpg}
     1964  \caption{Example of the stack number image for skycell
     1965    skycell.2047.005 centered at ($\alpha,\delta$) = (179.763,
     1966    32.1899) in the \zps{} filter, stack\_id 3775944.  This map shows
     1967    the number of inputs contributing to each pixel of the output
     1968    stack.  Again, the pattern of the inter-chip and inter-cell gaps
     1969    is visible, along with the mask pattern of regions with CTE
     1970    problems (visible in the upper right corner). }
     1971
     1972  \label{fig:stack num image}
     1973\end{figure}
     1974
     1975\begin{figure}
     1976  \centering
     1977  \includegraphics[width=0.9\hsize,angle=0,clip]{images/stack_3775944_exp.jpg}
     1978  \caption{Example of the stack exposure time image for skycell
     1979    skycell.2047.005 centered at ($\alpha,\delta$) = (179.763,
     1980    32.1899) in the \zps{} filter, stack\_id 3775944.  As all input
     1981    warps had the same 30s exposure time, this map essentially
     1982    recreates the number map, with units of seconds of exposure
     1983    instead of number of inputs contributing to a given pixel.}
     1984
     1985  \label{fig:stack exp image}
     1986\end{figure}
     1987
     1988\begin{figure}
     1989  \centering
     1990  \includegraphics[width=0.9\hsize,angle=0,clip]{images/stack_3775944_expwt.jpg}
     1991  \caption{Example of the stack weighted exposure image for skycell
     1992    skycell.2047.005 centered at ($\alpha,\delta$) = (179.763,
     1993    32.1899) in the \zps{} filter, stack\_id 3775944.  This map shows
     1994    the weighted average exposure time, as described in the text.  It
     1995    is similar to the simple exposure time map, but shows how some
     1996    input exposures have their contributions weighted down due to the
     1997    observed larger image variances.}
     1998
     1999
     2000  \label{fig:stack exp wtimage}
     2001\end{figure}
     2002
     2003\section{Difference Images}
     2004\label{sec:diffs}
     2005
     2006Constructing difference images is essentially the same as that used in
     2007the stacking process.  An image is chosen as a template, another image
     2008as the input, and after matching sources to determine the scaling and
     2009transparency, convolution kernels are defined that are used to
     2010convolve one or both of the images to a target PSF.  The images are
     2011then subtracted, and as they should now share a common PSF, static
     2012sources are largely subtracted (completely in an ideal case), whereas
     2013sources that are not static between the two images leave a significant
     2014remnant.  More information on the difference image construction is
     2015contained in \citet{price2017}.  The follow section contains a
     2016overview of the difference image construction used for the data in
     2017DR2.
     2018
     2019The images used to construct difference images can be either
     2020individual warp skycell frames or stacked images, with support for
     2021either to be used as the template or input.  In general, for
     2022differences using stacks, the deepest stack (or the only stack in the
     2023case of a warp-stack difference) is used as the template.  The PV3
     2024processing used warp-stack differences of all input warps against the
     2025stack that was constructed from those inputs.  The same ISIS kernels
     2026as were used in the stack image combination were again used to match
     2027the stack PSF to the input warp PSF.  After convolution of the image
     2028products, the difference is constructed for both the positive (warp
     2029minus stack) and inverse (stack minus warp) to allow for the
     2030photometry of the difference image to detect sources that both rise
     2031and fall relative to the stack.  Note that the convolution process
     2032grows the mask fraction of pixels relative to the warp (the largest
     2033source of masked pixels in these warp stack differences).  Any pixel
     2034that after convolution has any contribution from a masked pixel is
     2035masked as well, ensuring only fully unmasked pixels are used.
     2036
     2037For warp-warp differences, such as those used for the ongoing Solar
     2038System moving object search in nightly observations \citep{2013PASP..125..357D}, the
     2039warp that was taken first is used as the template.  As there is less
     2040certainty in which of the two input images will have better seeing, a
     2041``dual'' convolution method is used.  Both inputs are convolved to a
     2042target PSF that is not identical to either input.  This intermediate
     2043target is essential for the case in which the PSFs of the two inputs
     2044have been distorted in orthogonal directions.  Simply convolving one
     2045to match the other would require some degree of deconvolution along
     2046one axis.  As this convolution method by necessity uses more free
     2047parameters, the ISIS kernels used are chosen to be simpler than those
     2048used in the warp-stack differences.  The ISIS widths are kept the same
     2049(1.5, 3.0, 6.0 pixel FWHMs), but each Gaussian kernel is constrained
     2050to only use a second-order polynomial.  As with the warp-stack
     2051differences, the mask fraction grows between the input warp and the
     2052final difference image due to the convolution.  For the warp-warp
     2053differences, each image mask grows based on the appropriate
     2054convolution kernel, so the final usable image area is highly dependent
     2055on ensuring that the telescope pointings are as close to identical as
     2056possible.  The observing strategy to enable this is discussed in more
     2057detail in \citet{chambers2017}.
     2058
     2059
     2060
    19832061\section{Discussion}
    19842062\label{sec:discussion}
    19852063
    1986 \czwdraft{Although the detrending and image combination algorithms
    1987   work well to produce a consistent and calibrated images, having the
    1988   full PV3 data set allows issues to be identified and solutions
    1989   created for future improvements to the IPP pipeline.  In addition,
    1990   the existence of the final calibrated catalog can be used to look
    1991   for issues that appear dependent on focal plane position.}
     2064Although the detrending and image combination algorithms work well to
     2065produce a consistent and calibrated images, having the full PV3 data
     2066set allows issues to be identified and solutions created for future
     2067improvements to the IPP pipeline.  In addition, the existence of the
     2068final calibrated catalog can be used to look for issues that appear
     2069dependent on focal plane position.
    19922070
    19932071An obvious way to make use of the PV3 catalog is to do a statistical
     
    20032081There is some evidence that we have not fully identified all of these
    20042082crosstalk rules, based on a study of PV3 images.  For example,
    2005 extremely bright stars \czwdraft{exp o5677g0123o has this rule, find a
    2006   magnitude} may be able to create crosstalk ghosts between the second
     2083extremely bright stars may be able to create crosstalk ghosts between the second
    20072084cell column of OTA01 and OTA21, with possibly fainter ghosts appearing
    20082085on OTA11.  Despite the symmetry observed in the main ghost rules,
     
    20362113
    20372114The fringe model used currently is based on only a limited number of
    2038 days of data \czwdraft{one, I believe}.  This means that the model
    2039 calculated may not be fully sensitive to the exact spectrum of the
    2040 sky.  This may make the model quality differ based on the date and
    2041 local time of observation.  There is some evidence that the fringe
    2042 model does fit some dates better than others, and so improving this by
    2043 expanding the number of input exposures may improve a wider range of
    2044 dates.
    2045 % o5818g0349o is a good example of bad fringe correction.
     2115days of data.  This means that the model calculated may not be fully
     2116sensitive to the exact spectrum of the sky.  This may make the model
     2117quality differ based on the date and local time of observation.  There
     2118is some evidence that the fringe model does fit some dates better than
     2119others, and so improving this by expanding the number of input
     2120exposures may improve a wider range of dates.
    20462121
    20472122Finally, a large number of issues arise due to the row-to-row bias
     
    20562131
    20572132
    2058 \czwdraft{I need a good concluding thing to say, so it doesn't end with, ``we should do better next time.''}
    2059 
    2060 The Pan-STARRS1 Surveys (PS1) have been
    2061 made possible through contributions by the Institute for Astronomy, the
    2062 University of Hawaii, the Pan-STARRS Project Office, the Max-Planck
    2063 Society and its participating institutes, the Max Planck Institute for
    2064 Astronomy, Heidelberg and the Max Planck Institute for Extraterrestrial
    2065 Physics, Garching, The Johns Hopkins University, Durham University,
    2066 the University of Edinburgh, the Queen's University Belfast, the
    2067 Harvard-Smithsonian Center for Astrophysics, the Las
    2068 Cumbres Observatory Global Telescope Network Incorporated, the
    2069 National Central University of Taiwan, the Space Telescope Science Institute, and the National
    2070 Aeronautics and Space Administration under Grant No. NNX08AR22G issued
    2071 through the Planetary Science Division of the NASA Science Mission
    2072 Directorate, the National Science Foundation Grant No. AST-1238877,
    2073 the University of Maryland, Eotvos Lorand University (ELTE),
    2074 and the Los Alamos National Laboratory.
     2133\section{Conclusion}
     2134
     2135The Pan-STARRS1 PV3 processing has reduced an unprecedented volume of
     2136image data, and has produced a catalog for the $3\Pi$ Survey
     2137containing hundreds of billions of individual measurements of
     2138three billion astronomical objects.  Accurately calibrating
     2139and detrending is essential to ensuring the quality of these results.
     2140The detrending process detailed here produces consistent data, despite
     2141the many individual detectors and their individual response functions.
     2142
     2143From these individual exposures, we are able to construct images on
     2144common projections and orientations, further removing the particulars
     2145of any single exposure.  Furthermore, by created stacked images, we
     2146can determine an estimate of the true static sky, providing a deep
     2147data set that is ideal for use as a template for image differences.
     2148
     2149The Pan-STARRS1 Surveys (PS1) have been made possible through
     2150contributions by the Institute for Astronomy, the University of
     2151Hawaii, the Pan-STARRS Project Office, the Max-Planck Society and its
     2152participating institutes, the Max Planck Institute for Astronomy,
     2153Heidelberg and the Max Planck Institute for Extraterrestrial Physics,
     2154Garching, The Johns Hopkins University, Durham University, the
     2155University of Edinburgh, the Queen's University Belfast, the
     2156Harvard-Smithsonian Center for Astrophysics, the Las Cumbres
     2157Observatory Global Telescope Network Incorporated, the National
     2158Central University of Taiwan, the Space Telescope Science Institute,
     2159and the National Aeronautics and Space Administration under Grant
     2160No. NNX08AR22G issued through the Planetary Science Division of the
     2161NASA Science Mission Directorate, the National Science Foundation
     2162Grant No. AST-1238877, the University of Maryland, Eotvos Lorand
     2163University (ELTE), and the Los Alamos National Laboratory.
     2164
     2165\bibliography{lib}{}
     2166\bibliographystyle{apj}
    20752167
    20762168
     
    20782170
    20792171
    2080 % http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/GPC1_Detrend_Documentation
    2081 % http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/GPC1_Detrend_Documentation#Currentdetrends
    2082 % http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/stacking_coverage.20130307
    2083 % http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/staticsky.20120706_excess_detections
    2084 % http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Stack_Rejection_Discussion
    2085 % http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Stack_Algorithm
Note: See TracChangeset for help on using the changeset viewer.