Changeset 37865
- Timestamp:
- Jan 18, 2015, 1:13:42 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/doc/release.2015/ps1.analysis/analysis.tex (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/release.2015/ps1.analysis/analysis.tex
r37862 r37865 105 105 \section{INTRODUCTION}\label{sec:intro} 106 106 107 \section{Pan-STARRS1} 108 109 \section{Discussion} 110 111 \section{Conclusion} 107 The Pan-STARRS Image Processing Pipeline is responsible for the basic 108 analysis of images from the Pan-STARRS telescopes Gigapixel Camera. 109 The overall goals and requirements of the Image Processing Pipeline 110 are described in the IPP System/Subsystem Design Description (SSDD; 111 PSDC-430-XXX) and the IPP System Requirements Specification (SRS; 112 PSDC-430-XXX). Among the Pan-STARRS project survey goals is a 113 repeated all-sky survey in 5 filters, {\it grizy}, beginning with a 114 pre-survey with the prototype telescope PS-1. The photometric and 115 astrometric precision goals for the all-sky surveys, as well as the 116 other survey components, are quite stringent: 117 118 \begin{itemize} 119 \item relative photometry: 10 millimagnitudes scatter for bright stars 120 across the sky in the internal photometric system; 121 122 \item relative astrometry; 10 milliarcseconds scatter for individual 123 stars between repeated images. 124 125 \item absolute astrometry: 100 milliarcseconds scatter for all ICRS 126 reference stars (Tycho). 127 \end{itemize} 128 129 An additional constraint on the Pan-STARRS system comes from the high 130 data rate. The prototype telescope alone is expected to produce 131 typically $\sim 700$ GB per night of imaging data. These images will 132 not be limited to high galactic latitudes, so large numbers of 133 measurable stars can be expected in much of the data. The combination 134 of the high precision goals of the astrometric and photometric 135 measurements and the high data rate (and a finite computing budget) 136 mean that the process of detecting, classifying, and measuring the 137 astronomical objects in the image data stream will be a significant 138 challenge. 139 140 In order to achieve these ambitious goals, the object detection, 141 classification, and measurement process must be both precise and 142 efficient. Not only is it necessary to make a careful measurement of 143 the flux of individual objects, it is also critical to characterize 144 the image point-spread-function, and its variations across the field 145 and from image to image. Since comparisons between images must be 146 reliable, the measurements must be stable for both photometry and 147 astrometry. 148 149 \subsection{Comparable Programs} 150 151 A variety of astronomical software packages perform the basic object 152 detection, measurement, and classification tasks needed by the 153 Pan-STARRS IPP. Each of these programs have their own advantages and 154 disadvantages. Below we discuss some of the most widely used of these 155 other packages, highlighting the features of the programs which are 156 particularly desirable, and noting aspects of the programs which are 157 problematic for the IPP. 158 159 \begin{itemize} 160 161 \item DoPhot : analytical fitted model with aperture corrections. 162 pro: well-tested, stable code. con: limited range of models, 163 algorithm converges slowly to a PSF model, limited tests of PSF 164 validity, inflexible code base, fortran (P. Schechter) 165 166 \item DAOPhot : Pixel-map PSF model with analytical component. pro: 167 well-tested, high-quality photometry. con: Difficult to use in an 168 automated fashion, does it handle 2D variations well? (P. Stetson) 169 170 \item Sextractor : pure aperture measurement with rudimentary 171 object subtraction. pro: fast, widely used, easy to automate. con: 172 poor object separation in crowded regions, PSF-modeling is only 173 beta (psfex), what models are available? (E. Bertin) 174 175 \item apphot : IRAF-based aperture photometry. pro: widely used. 176 con: IRAF-based, aperture photometry. (???) 177 178 \item galfit : detailed galaxy modeling. not a multi-object PSF 179 analysis tool. con: does not provide a PSF model, not easily 180 automated. very detailed results in very slow processing. only a 181 galaxy analysis program. (C. Impey) 182 183 \item SDSS phot : con: tightly integrated into the SDSS software 184 environment. (R. Lupton) 185 186 \end{itemize} 187 188 \note{discussion of these packages is insufficient: flesh out 189 discussion and add in the references.} 190 191 \note{Add discussion of the lessons learned from experience with previous 192 analysis programs} 193 194 The Pan-STARRS IPP team decided that none of the existing packages met 195 all of their needs, particularly given the very challenging goals of 196 the project. We decided to redesign the photometry analysis from 197 scratch, using the lessons learned from the existing photometry 198 systems. In the process, the object analysis software would be 199 written using the data analysis C-code library written for the IPP, 200 \code{psLib}, and the components of the photometry code would be 201 integrated into the IPP's mid-level astronomy data analysis toolkit 202 called \code{psModules}. The result is 'PSPhot', which can be used 203 either as a stand-alone C program, or as one of the high-level IPP 204 components of \code{psModules}, available to programmers either via a 205 C interface or through a SWIG interface in Perl (or potentially 206 Python). 207 208 \note{discuss the psphot program varients} 209 210 \section{PSPhot Design Goals} 211 212 PSPhot has a number of important requirements that it must meet, and a 213 number of design goals which we believe will help to make usable in a 214 wide range of circumstances. The critical requirements of the 215 Pan-STARRS IPP which drive the requirements for PSPhot: 216 217 \begin{itemize} 218 \item {\bf 10 millimagnitude photometric accuracy}. For PSPhot, this 219 implies that the measured photometry of stellar objects must be 220 substantially better than this 10 mmag since the photometry error 221 per image is combined with an error in the flat-field calibration 222 and an error in measuring the atmospheric effects. We have set a 223 goal for PSPhot of 3mmag photometric consistency for bright stars 224 between pairs of images obtained in photometric conditions at the 225 same pointing, ie to remove sensitivity to flat-field errors. This 226 goal splits the difference between the three main contributors and 227 still allows some leeway. This requirement must be met for 228 well-sampled images and images with only modest undersampling. 229 230 \item {\bf 10 milliarcsecond astrometric accuracy}. Relative 231 astrometric calibration depends on the consistency of the individual 232 measurements. The measurements from PSPhot must be sufficiently 233 representative of the true object position to enable astrometric 234 calibration at the 10mas level. The error in the individual 235 measurements will be folded together with the errors introduced by 236 the optical system, the effects of seeing, and by the available 237 reference catalogs. We have set a goal for PSPhot of 5mas 238 consistency between the true source postion and the measured 239 position given reasonable PSF variations under simulations. This 240 level must be reached for images with 250 mas pixels, implying 241 PSPhot must introduce measurement errors less than 1/50th of a 242 pixel. \note{the choice of F32 parameters places a numerical limit 243 of 1e-7 on the accuracy of a pixel relative to the size of a chip 244 (since a single data value is used for X or Y). For the $4800^2$ 245 GPC chips, this yields a limit of about 0.25 milliarcsecond.} 246 247 \item {\bf processing time of 45 seconds} This requirement depends 248 strongly on the hardware organization, the amount of time spent on 249 other analysis steps, the density of stars per image, and the depth 250 for a given type of image. For the sources at the faint limit (eg, 251 $5\sigma$), the average density of sources is expected to be roughly 252 $3\times10^5$ per square degree, while sources at the 20 $\sigma$ 253 level may have densities of $\sim 5\times10^4$ per square degree. 254 Allowing 30 seconds for the PSPhot portion of the analysis, of which 255 15 is used for careful analysis of the brighter sources, 10 seconds 256 is used for PSF modeling and other overheads, and the remaining 5 257 seconds is used for the PSF fitting of the faintest source implies 258 that the detailed modelling may take roughly 3msec per source, and 259 the basic PSF fitting may be allowed 150 usec per source. 260 \end{itemize} 261 262 The design goals for PSPhot are chosen to make the program flexible, 263 general, and able to meet the unknown usages cases future projects may 264 require: 265 266 \begin{itemize} 267 \item {\bf Flexible PSF model} Different image sources require 268 different ways of representing the PSF. Ideally, both analytical 269 and pixel-based versions should be possible. 270 271 \item {\bf PSF spatial variation} Most images result in some spatial 272 PSF variations at a certain level. The PSF representation should 273 naturally incorporate 2-D variations. 274 275 \item {\bf Flexible non-PSF models} PSPhot must be able to represent 276 PSF-like objects as well as non-PSF sources. It must be easy to add 277 new object models as interesting representations of sources are 278 invented. 279 280 \item {\bf Clean code base} PSPhot should incorporate a high-degree of 281 abstraction and encapsulation so that changes to the code structure 282 can be performed without pulling the code apart and starting from scratch. 283 284 \item {\bf PSF validity tests} PSPhot should include the ability to 285 choose different types of PSF models for diffent situations, or to 286 provide the user with methods for assessing the different PSF models. 287 288 \item {\bf Careful aperture corrections} PSPhot must carefully measure 289 and correct for the photometric and astrometric trends introduced by 290 using analytical PSF models. 291 292 \item {\bf User Configurable} PSPhot should allow users to change the 293 options easily and to allow different approaches to the analysis. 294 295 \end{itemize} 296 297 \section{PSPhot Analysis Process} 298 299 \subsection{Overview} 300 301 The PSPhot analysis is divided into several major stages: 302 303 \begin{itemize} 304 \item {\bf Image preparation} Load data, characterize the image 305 background, load or construct noise and mask images. 306 307 \item {\bf Initial object detection} Smooth, find peaks, measure basic 308 properties 309 310 \item {\bf PSF determination} Select PSF candidates, perform model 311 fits, build PSF model from fits, select best PSF model class. 312 313 \item {\bf Bright object analysis} Fit objects with PSFs, determine 314 PSF validity, subtract PSF-like objects, fit non-PSF model(s), 315 select best model class, subtract model. 316 317 \item {\bf Low S/N sources} Detect low-level sources, measure 318 properties (aperture or PSF) 319 320 \item {\bf Aperture corrections} Measure the curve-of-growth, spatial 321 aperture variations, and background-error corrections. 322 323 \item {\bf Output} Write out objects in selected format, write out 324 difference image, noise image, etc, as selected. 325 \end{itemize} 326 327 Note that a given run of PSPhot allows the user to perform many of 328 these stages only if needed. For example, the PSF model may already be 329 available from external information, in which case the PSF modeling 330 stage can be skipped. Or, when used as a library function, the image 331 may have already been loaded and the mask and weight images 332 constructed. In some implementations, it may be possible to skip the 333 initial object detection stage because only supplied sources are 334 measured. These are only some of the possible configurations. The 335 use of these different configurations depends on the source of the 336 image, the desired detail and speed of the processing, and the level 337 of accuracy desired from the analysis. 338 339 \subsection{Image Preparation} 340 341 The first step is to prepare the image for detection of the 342 astronomical objects. We need three separate images: the measured 343 flux, the corresponding variance image, and a mask defining which 344 pixels are valid and which should be ignored. For the stand-alone 345 program, the input flux image is a required program argument. When it 346 is loaded, it is converted by default to 32-bit floating point 347 representation. In the function-call form of PSPhot, the image must 348 be supplied by the user in 32-bit floating point format. The noise 349 and mask images may either be provided by the user, or they may be 350 automatically generated from the input image, based on 351 configuration-defined values for the image gain, read-noise, 352 saturation, and so forth. For the function-call form of the program, 353 the flux image is provided in the API, and references to the mask and 354 noise are provided in the configuration information. As in the 355 stand-alone C-program, the noise and mask may be constructed 356 automatically by PSPhot. 357 358 \note{describe the use of the covariance image} 359 \note{describe the difference between 'bad' and 'suspect' pixels} 360 361 For the mask, we use a 16-bit image in which a value of 0 represents a 362 valid pixel. We use each of the 16 bits to define different reasons a 363 pixel should be ignored. This allows us to optionally respect or 364 ignore the mask depending on the circumstance. For example, in some 365 cases, we ignore saturated pixels completely while in other 366 circumstances, it may be useful to know the flux value of the 367 saturated pixel. In addition, the mask pixels are used to define the 368 pixels available during a model fit, and which should be ignored for 369 that specific fit. The initial mask, if not supplied by the user, is 370 constructed by default from the image by applying three rules: 1) 371 Pixels which are above a specified saturation level are marked as 372 saturated (configuration keyword: \code{SATURATE}). 2) Pixels which 373 are below a user-defined value are considered unresponsive and masked 374 as dead. 3) Pixels which lie outside of a user-defined window are 375 considered non-data pixels (eg, overscan) and are marked as invalid. 376 The valid window is defined by the configuration variables 377 \code{XMIN}, \code{XMAX}, \code{YMIN}, \code{YMAX}. 378 379 \note{discuss the mask.config file, in which the mask meanings are assigned to bit values} 380 381 The noise image, if not supplied is constructed by default from the 382 flux image using the configuration supplied values of \code{GAIN} and 383 \code{READ\_NOISE} to calculate the appropriate Poisson statistics for 384 each pixel. In this case, the image is assumed to represent the 385 readout from a single detector, with well-defined gain and read noise 386 characteristics. In some obvious cases, this assumption will not be 387 valid. For example, if the input flux image is the result of an image 388 stack with significantly variable number of input measurements per 389 pixel, it will be necessary to supply a noise image which accurately 390 represents the noise as a function of position in the image. 391 392 \subsection{Initial Object Detection} 393 394 The objects are initially detected by finding the location of local 395 peaks in the image. The flux and variance images are smoothed with a 396 small circularly symmetric kernel using a two-pass 1D Gaussian 397 (\note{KEYWORD?}). The smoothed flux and variance images are combined 398 to generate a significance image in signal-to-noise units 399 \note{including correction for the covariance, if known}. At this 400 stage, the goal is only to detect the brighter sources, above a user 401 defined S/N limit (configuration keyword: \code{PEAK\_NSIGMA}). The 402 detection efficiency for the brighter sources is not strongly 403 dependent on the form of this smoothing function. 404 405 The local peaks in the smoothed image are found by first detecting 406 local peaks in each row. For each peak, the neighboring pixels are 407 then examined and the peak is accepted or rejected depending on a set 408 of simple rules. First, any peak which is greater than all 8 409 neighboring pixels is kept. Any peak which is lower than any of the 8 410 neighboring pixels is rejected. Any peak which has the same value as 411 any of the other 8 pixels is kept if the pixel $X$ and $Y$ coordinates 412 are greater than or equal to the other equal value pixels. This 413 simple rule set means that a flat-topped region will maintain peaks at 414 the maximum $X$ and $Y$ corners of the region. 415 416 \subsection{Footprints} 417 418 \note{need to describe the process of generating the source footprints 419 and then culling the insignificant peaks} 420 421 \subsubsection{Moments and related} 422 423 \note{disucss the Kron mags} 424 425 \note{this section is wrong: we no longer use S/N clipping, but a 426 Gaussian window function, chosed based on the measured moment} 427 428 Once a collection of peaks have been identified, basic properties of 429 the objects are measured. First, the local sky flux is measured 430 within a square annulus with user-defined dimensions 431 (\code{INNER\_RADIUS} and \code{OUTER\_RADIUS}), using the sample 432 median. This local background value is then used to calculate the 433 object first and second moments within a small user-defined aperture 434 (\code{MOMENT\_RADIUS}). The first-order moments are a good 435 representation of the object position, while the second-order moments 436 are a measure of the object shape. The second-order moments are 437 somewhat sensitive to the size of the aperture and the accuracy of the 438 background measurement. The moment calculation is only performed 439 using pixels which exceed a S/N of 1. If, in the process of 440 calculating the source moments, the S/N limits reject all but \note{3} 441 or fewer of the source pixels, the peak is identified as being 442 suspect, and is not used for further analysis. If the measured 443 centroid coordinates differ from the peak coordinates be a large 444 amount (\code{MOMENT\_RADIUS}), then the peak is again identified as 445 being of poor quality and is rejected. In both of these cases, it is 446 likely that the `peak' was identified in a region of flat flux 447 distribution or many saturated or edge pixels. 448 449 \subsubsection{Determination of the Peak Coordinates and Errors} 450 451 \note{this section is wrong: it is a poor estimator of the source 452 position errors. we gave up a reverted to using the FWHM / (S/N)} 453 454 We use the 9 pixels which include the source peak to fit for the 455 position and position errors. We model the peak of the sources as a 456 2D quadratic polynomial, and use a very simple bi-quadratic fit to 457 these pixels. We use the following function to describe the peak 458 459 \[ f(x,y) = C_{00} + C_{10}x + C_{01} y + C_{11} x y + C_{20} x^2 + C_{02} y^2 \] 460 461 and write the Chi-Square equation: 462 463 \[ \chi^2 = \sum_{i,j} (F_{i,j} - f(x,y))^2 / \sigma_{i,j}^2 \] 464 465 By approximating the error per pixel as the error on just the peak, 466 and pulling that term out of the above equation, and recognizing that 467 the values x,y in the 3x3 grid centered on the peak pixel have values 468 of only 0 or 1, we can greatly simplify the chi-square equation to a 469 square matrix equation with the following values: 470 471 %% fix this: 472 \begin{verbatim} 473 | 9 0 0 0 6 6 | C_00 | = \sum F_{i,j} 474 | 0 6 0 0 0 0 | C_10 | = \sum F_{i,j} x 475 | 0 0 6 0 0 0 | C_01 | = \sum F_{i,j} y 476 | 0 0 0 6 0 0 | C_11 | = \sum F_{i,j} x y 477 | 6 0 0 0 6 4 | C_20 | = \sum F_{i,j} x^2 478 | 6 0 0 0 4 6 | C_02 | = \sum F_{i,j} y^2 479 \end{verbatim} 480 481 The inverse of the 3x3 matrix terms for $C_{00}$, $C_{20}$, and $C_{02}$ is: 482 \begin{verbatim} 483 | +5/9 -1/3 -1/3 | 484 | -1/3 +1/2 0 | 485 | -1/3 0 +1/2 | 486 \end{verbatim} 487 488 which can be used to determine the errors on the coefficients: 489 490 \begin{eqnarray} 491 \sigma^2_{00} & = & \sigma^2 (5/9) \\ 492 \sigma^2_{10} & = & \sigma^2 (1/6) \\ 493 \sigma^2_{01} & = & \sigma^2 (1/6) \\ 494 \sigma^2_{11} & = & \sigma^2 (1/6) \\ 495 \sigma^2_{20} & = & \sigma^2 (1/2) \\ 496 \sigma^2_{02} & = & \sigma^2 (1/2) \\ 497 \end{eqnarray} 498 499 The location of the peak is determined from the minimum of the 500 bi-quadratic function above, and is given by: 501 502 \begin{eqnarray} 503 Det & = & 4 C_{20} C_{02} - C_{11}^2 \\ 504 x_{min} & = & (C_{11} C_{01} - 2 C_{02} C_{10}) / Det \\ 505 y_{min} & = & (C_{11} C_{10} - 2 C_{20} C_{01}) / Det \\ 506 \end{eqnarray} 507 508 Applying error propagation to the above, we find: 509 510 \begin{eqnarray} 511 \sigma_{Det}^2 & = & \sigma_{11}^2 (4 C_{11}^2) + \sigma_{20}^2 (16 C_{02}^2) + \sigma_{02}^2 (16 C_{20}^2) \\ 512 \sigma_{xn}^2 & = & \sigma_{11}^2 C_{01}^2 + \sigma_{01}^2 C_{11}^2 + \sigma_{02}^2 (4 C_{10}^2) + \sigma_{10}^2 (4 C_{02}^2) \\ 513 \sigma_{yn}^2 & = & \sigma_{11}^2 C_{10}^2 + \sigma_{10}^2 C_{11}^2 + \sigma_{20}^2 (4 C_{01}^2) + \sigma_{01}^2 (4 C_{20}^2) \\ 514 \sigma_{x}^2 & = & x^2 (\sigma_{xn}^2 / xn^2 + \sigma_{Det}^2 / Det^2) \\ 515 \sigma_{y}^2 & = & y^2 (\sigma_{yn}^2 / yn^2 + \sigma_{Det}^2 / Det^2) \\ 516 \end{eqnarray} 517 518 \subsection{PSF Determination} 519 520 \subsubsection{PSF Model vs Object Model} 521 522 PSPhot uses an analytical model to represent the shape and flux of an 523 object. An important concept within the PSPhot code is the 524 distinction between a model which describes an object on an image and 525 a model with describes the point-spread-function (PSF) across an 526 image. 527 528 Any object in an image may be represented by some analytical model, 529 for example, a 2-D elliptical Gaussian: 530 \begin{eqnarray} 531 f(x,y) & = & I_o exp (-z) + S \\ 532 R & = & \frac{(x - x_o)^2}{2\sigma_x^2} + \frac{(y - 533 y_o)^2}{2\sigma_y^2} + \sigma_{\rm xy}(x - x_o)(y - y_o) 534 \end{eqnarray} 535 The object model will have a variety of model parameters, in this case 536 the centroid coordinates ($x_o, y_o$), the elliptical shape parameters 537 ($\sigma_x, \sigma_y, \sigma_{\rm xy}$), the model normalization 538 ($I_o$) and the local value of the background ($S$). A specific 539 object will have a particular set of values for these different 540 parameters. 541 542 The point-spread-function (PSF) of an image describes the shape of all 543 unresolved objects in the image. In a typical image, the shape of 544 point sources is not well described by a single functional form; 545 rather, the shape will vary as a function of position in the image. 546 The PSF model therefore must describe the parameter variation as a 547 function of the position of the object on the image. Note that the 548 object model consists of a certain number of parameters which are 549 defined by the PSF model, and another set of parameters which are 550 independent from object to object. For the case of the elliptical 551 Gaussian model, the PSF parameters would be the shape terms 552 ($\sigma_x, \sigma_y, \sigma_{\rm xy}$) while the independent 553 parameters would be the centroid, normalization and local sky values 554 ($x_o, y_o, I_o, S$). PSPhot uses a 2-D polynomial to specify the 555 variation in the PSF parameters as a function of position in the 556 image. In the case of the elliptical Gaussian, this implies that the 557 parameters are each a function of the object centroid coordinates: 558 \begin{eqnarray} 559 \sigma_x & = & f_1(x,y) \\ 560 \sigma_y & = & f_2(x,y) \\ 561 \sigma_{xy} & = & f_3(x,y) \\ 562 \end{eqnarray} 563 564 PSPhot uses a single structure to represent the object model and 565 another structure to represent the PSF model. The object model 566 structure consists of the collection of measured object model 567 parameters, carried as a \code{psLib} vector (\code{psVector}) along 568 with an equal-length vector with the parameter errors. The structure 569 also includes an integer giving the identifier of the model used in 570 the particular case, as well as model fit statistics such as the 571 Chi-Square of the fit and the magnitude representation of the ratio 572 between the model flux and an aperture flux (see below for more 573 details on this value). 574 575 The PSPhot representation of the PSF consists of an array of 576 polynomials, each representing the variation in the object model PSF 577 parameters (\code{psArray} of \code{psPolynomial2D}). The PSF model 578 structure also includes the same integer used to identify which model 579 corresponds to particular instance of the PSF. At the moment, the 580 number of PSF parameters is a fixed number (4) fewer than the number 581 of parameters of the corresponding object model. For example, the 582 elliptical Gaussian model uses 7 parameters to represent the object and 583 3 for the PSF model. 584 585 PSPhot is written so that the object detection, measurement, and 586 classification code does not depend on the specific form of the 587 available object model functions. Access to the characteristics of 588 the models is provided through a simple function abstraction method. 589 Throughout PSPhot, there are many places where it is necessary for the 590 code to refer to an aspect of the object or PSF model. Often, these 591 quantities are needed deep within other parts of the code. For 592 example, when attempting to fit the pixel flux values for an object, 593 it is necessary to generate a guess for the model parameters. Or, in 594 order to limit the domain of the fit, it is necessary to determine an 595 isophotal radius for a model. 596 597 In order to avoid having the code depend on the specific form of a 598 model, the function calls needed in these types of circumstances are 599 abstracted, and a method is provided to return the necessary function 600 to the higher-level software. For example, each model type has its 601 own function to define an initial guess for the model, or a function 602 to determine the radius for a given flux level. These are then 603 registered as part of the model function code. Another function is 604 then used to return the appropriate function for a specific model 605 type. For example, the \code{psModelLookup\_GetFunction} will return 606 the \code{psModelLookup} function for a given model type. This 607 mechanism makes it very easy to add new model functions into the 608 PSPhot code base. To add a new model function, the programmer simply 609 defines a new model name (a string), the set of all necessary model 610 lookup functions, and places the reference to the model code at the 611 appropriate location in the psModelInit.c routine. 612 613 When a new model is provided to PSPhot, it is not necessary to specify 614 the intended use of the object model function (ie, PSF-like object, 615 galaxy, comet, etc). Any model can be used for the PSF model, or to 616 describe the flux distributions of the non-PSF objects. The code 617 currently uses a fixed translation between the object model parameters 618 and the PSF model parameters. It also defines a specific order for 619 the 4 independent parameters. 620 621 \note{the code may also require that two of the PSF-like parameters 622 represent the shape in some way}. 623 624 \subsubsection{PSF Candidate Object Selection} 625 626 The first stage of determining the PSF model for an image is to 627 identify a collection of objects in the image which are {\em likely} 628 to be PSF-like. PSPhot uses the object moments to make the initial 629 guess at a collection of PSF-like objects. At this point, the program 630 has measured the second order moments for all objects identified by 631 their peaks, as well as an approximate signal-to-noise ratio. All 632 objects with a S/N ratio greater than a user-defined parameter 633 (\code{PSF\_SHAPE\_NSIGMA} ???) are selected by PSPhot, though objects 634 which have more than a certain number of saturated pixels are excluded 635 at this stage. PSPhot then examines the 2-D plane of $\sigma_x, 636 \sigma_y$ in search of a concentrated clump of objects. To do this, 637 it constructs an artificial image with pixels representing the value 638 of $\sigma_x, \sigma_y$, using a user-defined scale for the size of a 639 pixel in this artificial image (note that the units of the $\sigma_x, 640 \sigma_y$ plane are the size of the second-moment in pixels in the 641 original image). A typical value for the bin size is approximately 642 0.1 image pixels. The binned $\sigma_x, \sigma_y$ plane is then 643 examined to find a peak which has a significance greater than XXX. 644 Unless the image is extremely sparse, such a peak will be well-defined 645 and should represent the objects which are all very similar in shape. 646 Other objects in the image will tend to land in very different 647 locations, failing to produce a single peak. To avoid detecting a 648 peak from the unresolved cosmic rays, objects which have 649 second-moments very close to 0 are ignored. The only danger is if the 650 PSF is very small and too many of these objects are rejected as cosmic 651 rays. 652 653 Once a peak has been detected in this plane, the centroid and second 654 moments of this peak are measured. All objects which land within XXX 655 $\sigma$ of this centroid are selected as likely PSF-like objects in 656 the image. 657 658 \subsubsection{PSF Candidate Object Model Fits} 659 660 All candidate PSF objects are then fitted with the selected object 661 model, allowing all of the parameters (PSF and independent) to vary in 662 the fit. PSPhot uses the Levenberg-Marqardt process for the 663 non-linear fitting. Non-linear fitting can be very computationally 664 intensive, particularly for if the starting parameters are far from 665 the minimization values. PSPhot uses the first and second moments to 666 make a good guess for the centroid and shape parameters for the PSF 667 models. \note{still true? In order to minimize the impact of close 668 neighbors, the noise values used in the fit are enhanced by a 669 fraction of the deviation of the particular pixel value from the 670 model guess.} Any objects which fail to converge in the fit are 671 flagged as invalid. 672 673 \note{does the noise enhancement introduce too much bias?} 674 675 \note{discuss the convergence criteria, model parameter guesses} 676 677 For the resulting collection of object model parameters, the 678 PSF-dependent parameters of the models are all fitted as a function of 679 position to a 2-D polynomial. The order of this polynomial is (should 680 be?) a user-defined parameter. The fitting process for these 681 polynomials is iterative, and rejects the $3-\sigma$ outliers in each 682 of three passes. This fitting technique results in a robust 683 measurement of the variation of the PSF model parameters as a function 684 of position without being excessively biased by individual objects 685 which fail drastically. Objects whose model parameters are rejected 686 by this iterative fitting technique are also marked as invalid and 687 ignored in the later PSF model fitting stages. 688 689 All of the PSF-candidate objects are then re-fitted using the PSF 690 model to specify the dependent model parameter values for each object. 691 For example, in the case of the elliptical Gaussian model, the shape 692 parameters ($\sigma_x, \sigma_y, \sigma_{xy}$) for each object are 693 set by the coordinates of the object centroid and fixed (not allowed 694 to vary) in the fitting procedure. The resulting fitted models are 695 then used to determine a metric which tests the quality of the PSF 696 model for this particular image. 697 698 The metric used by PSPhot to assess the PSF model is the scatter in 699 the differences between the aperture and fit magnitudes for the PSF 700 objects. The difference between the aperture and fit magnitudes ({\em 701 ApResid}) is a critical parameter for any PSF modeling software which 702 uses an analytical model to represent the flux distribution of the 703 objects in an image. An approximate correction is measured here, with 704 a more detailed correction measured after all object analysis is 705 performed. The PSF model with the best consistency of the aperture 706 correction is judged to be the best model. 707 708 \subsubsection{Basic Deblending} 709 710 The collection of identified peaks is examined to find peaks which are 711 'blended', that is, they are close enough together to make the 712 analysis of one of the sources difficult if performed in isolation. 713 Saturated stars also result in additional peaks which are likely to be 714 invalid; it is useful to restrict a saturated star to a single primary 715 position with associated neighboring peaks. 716 717 The deblending process first searches for any peaks which are within 718 the image cell of another peak. All such groups are examined, 719 starting with the brightest source. An isophot is found about the 720 primary peak which is at least \code{DEBLEND\_SKY\_NSIGMA} times the sky 721 sigma above the local background and which is otherwise 722 \code{DEBLEND\_PEAK\_FRACTION} of the primary peak central pixel flux. 723 Any secondary sources which are contained within this isophot are 724 considered to be blended peaks associated with the primary peak. 725 726 \subsection{Bright Source Analysis} 727 728 After a PSF model has been determined, PSPhot performs the analysis of 729 the bright objects in the image. In this stage, all of the objects 730 with an estimated signal to noise (based on the moments analysis) 731 greater than a user-set threshold are analysed and subtracted from the 732 image. An optional successive stage then finds fainter sources and 733 measures them as well (see Faint Source Analysis, 734 Section~\ref{faintsources}). In the bright source analysis stage, two 735 major varients are available. In the primary version, all objects are 736 examined (in decending order of brightness) and an appropriate models 737 is determined for each object which is then subtracted; in the 738 alternate version, the objects are examined (in decending order of 739 brightness) and the PSF-like objects subtracted first, then the 740 extended objects are analysed on a second pass. 741 742 \subsubsection{Fast Ensemble PSF Fitting} 743 744 Before the detailed analysis of the objects is performed, it is 745 convenient to subtract off all of the sources, at least as well as 746 possible at this stage. We make the assumption that all sources are 747 PSF-like. We also assume their position can be taken as the peak of a 748 2D quadratic function fitted to the peak pixel and its surrounding 8 749 pixels. A single linear fit is used to simultaneously measure all 750 source fluxes. Since the local sky has been subtracted, this 751 measurement assumes the local sky is zero. 752 753 \[ 754 \chi^2 = \sum_{\rm pixels} (F_{x,y} - \sum_{\rm sources} A_i PSF[x,y])^2 755 \] 756 757 Minimizing this equation with respect to each of the $A_i$ values 758 results in a matrix equation: 759 \[ M_{i,j} \bar{A_i} = \bar{F_j}\] 760 where $\bar{A_i}$ is the vector of $A_i$ values, the elements of 761 $M_{i,j}$ consist of the dot product of the unit-flux PSF for source 762 $i$ and source $i$, and $\bar{F_j}$ is the dot product of the 763 unit-flux PSF for source $i$ with the pixels corresponding to source 764 $i$. The dot products are calculated only using pixels within the 765 source apertures. Since most sources have no overlap with most other 766 sources, this matrix equation results in a very sparse, mostly 767 diagonal square matrix. The dimension is the number of sources, 768 likely to be 1000s or 10,000s. Such a matrix does not lend itself to 769 direct inversion. However, an interative solution quickly yields a 770 result with sufficient accuracy. In the iterative solution, a guess 771 at the solution is made; the guess is multiplied by the matrix, and 772 the result compared with the observed vector $\bar{F_j}$. The 773 difference is used to modify the initial guess. This proces is 774 repeated several times to achieve a good convergence. 775 776 Once a solution set for $A_i$ is found, all of the objects are 777 subtracted from the by applying these values to the unit-flux PSF. 778 779 \subsubsection{PSF Model applied to detected objects} 780 781 Once a PSF model has been selected for an image, PSPhot attempts to 782 fit all of the detected objects, above a user-defined signal-to-noise 783 ratio (\note{KEYWORD}) with the PSF model. For these fits, the 784 dependent parameters are fixed by the PSF model and only the 4 785 independent object model parameters are allowed to vary in the fit. 786 PSPhot again uses the Levenberg-Marqardt process for the non-linear 787 fitting. The objects are fitted in their S/N order, starting with the 788 brightest and working down to the user-specified limit. 789 790 Once a solution has been achieved, PSPhot attempts to judge the 791 quality of the PSF model as a representation of the object shape. To 792 do this, it calculates the next step of the minimization {\em allowing 793 the shape parameters to vary}. This step, essentially the 794 Gauss-Newton minimization distance from the current local minimum, 795 should be very small if the object is well represented by the PSF, but 796 large if the PSF is not a good representation of the object flux. The 797 model quality is judged by the change in the two shape parameters 798 which represent the 2D size of the object. For the case of the 799 elliptical Gaussian, these two parameters are $\sigma_x$ and 800 $\sigma_y$. For a generic model, the shape parameters may be defined 801 differently, but the should always be two parameters which scale the 802 object size in two dimensions (what about a polar-coordinate form?) 803 Currently, PSPhot requires the two relevant shape parameters to be the 804 first two dependent parameters in the list of model parameters (ie, 805 parameters 4 \& 5). 806 807 The expected distribution of the variation of the two shape parameters 808 will be a function of the signal-to-noise of the object in question 809 and the value of the shape parameter itself. The expected standard 810 deviation on the shape parameter is, eg, $\sigma_x / {\rm SN}$. If 811 the object is well-represented by the PSF, then the shape parameter 812 values should be close to their minimization value. We can thus ask, 813 for each object, given the measured amplitude of the Gauss-Newton 814 step, how many standard deviations from the expected value (of 0.0) is 815 this particular value? Objects for which the variation in the shape 816 parameters is a large positive number of standard deviations are 817 likely to be better represented by a larger flux distribution than the 818 PSF (eg, a Galaxy or Comet, etc). Objects for which the variation in 819 the shape parameters is a large negative number of standard deviations 820 are likely to be better represented by a smaller flux distribution 821 than the PSF (ie, a cosmic ray or other defect). A user-defined 822 number of standard deviations is used to select these two cases, and 823 to flag the object as a likely galaxy (really meaning 'extended') or 824 as a likely defect. 825 826 At this stage of the analysis, PSPhot uses two additional indicators 827 to identify good and poor PSF fits. The first of these is the 828 signal-to-noise ratio. It is possible for the peak finding algorithm 829 to identify peaks in locations which are not actually a normal peak. 830 Some of these cases are in the edges of saturated, bleeding columns 831 from bright stars, in the nearly flat halos of very bright stars, and 832 so on. In these cases, a local peak exists, with a lower nearby sky 833 region. However, the fitted PSF model cannot converge on the peak 834 because it is very poorly defined (perhaps only existing in the 835 smoothed image). The fit can either fail to converge or it can 836 converge on a fit with very low or negative peak flux / flux 837 normalization. PSPhot will flag any non-convergent PSF fit and any 838 object with PSF S/N ratio lower than a user-defined cutoff. It is 839 also useful to identify very poor fits by setting a maximum Chi-Square 840 cutoff for objects. 841 842 As the objects are fitted to the PSF model, those which survive the 843 exclusion stage are subtracted from the image. The subtraction 844 process modifies the image pixels (removing the fitted flux, though 845 not the locally fitted background) but does not modify the mask or the 846 noise images. The signal-to-noise ratio in the image after 847 subtraction represents the significance of the remaining flux. If the 848 subtractions are sufficiently accurate models of the PSF flux 849 distribution, the remaining flux should be below 1 $\sigma$ 850 significance. In practice the cores of bright stars are poorly 851 represented and may have larger residual significance. \note{in future 852 work, we may choose to enhance the noise to minimize detection of 853 objects in the residuals of brighter objects}. 854 855 \subsubsection{Blended Sources} 856 857 Sources which are blended with other sources are fitted together as a set of 858 PSFs. A single multi-object fit is performed on all blended peaks. 859 The resulting fits are evaluated independently and any which are 860 determined to be PSFs are subtracted from the image. 861 862 \subsubsection{Double Sources} 863 864 Sources which are judged to be non-PSF-like are confronted with two 865 possible alternative choices. First, the object is fitted with a 866 double-source model. In this pass, the assumption is made that there 867 are two neighboring sources, but the peaks are blended together, or 868 otherwise not distinguished. The initial guess for the two peaks is 869 made by splitting the flux of the single source in half and locating 870 the two starting peaks at +/- 2 pixels from the original peak along 871 the direction of the semi-major axis of the sources, as measured from 872 the second moments. In order for the two-source model to be accepted, 873 both sources must be judged as a valid PSF source. Otherwise, the 874 double-PSF model is rejected and the source is fitted with the 875 available non-PSF model or models. 876 877 \note{better description of the acceptance criteria; the FLT model is 878 tried before the DBL is accepted or rejected}. 879 880 \subsubsection{Non-PSF Objects} 881 882 Once every object (above the S/N cutoff) has been confronted with the 883 PSF model, the objects which are thought to be galaxies (extended) can 884 now be fit with appropriate models for the galaxies (or other likely 885 extended shapes). Again, the fitting stage starts with the brightest 886 sources (as judged by the rough S/N measured from the moments 887 aperture) and working to a user defined S/N limit. 888 889 PSPhot will use the user-selected galaxy model to attempt the galaxy 890 model fits. In the configuration system, the keyword \code{GAL\_MODEL} 891 is set to the model of interest. All suspected extended objects are 892 fitted with the model, allowing all of the parameters to float. The 893 initial parameter guesses are critical here to achieving convergence 894 on the model fits in a reasonable time. The moments and the pixel 895 flux distribution are used to make the initial parameter guess. Many 896 of the object parameters can be accurately guessed from the first and 897 second moments. The power-law slope can be guessed by measuring the 898 isophotal level at two elliptical radii and comparing the ratio to 899 that expected. 900 901 For each of the galaxy models (in fact for all object models), a 902 function is defined which examines the fit results and determines if 903 the fit can be consider as a success or a failure. The exact criteria 904 for this decision will depend on the details of the model, and so this 905 level of abstraction is needed. For example, in some case, the range 906 of valid values for each of the parameters must be considered in the 907 fit assessment. In other cases, we may choose to use only the 908 parameter errors and the fit Chi-Square value. 909 910 All galaxy model fits which are successful are then subtracted from 911 the image as is done for the successful PSF model fits. Of course, 912 the background flux is retained, with the result that only the object 913 is subtracted from the image. Again, the noise image is (currently) 914 not modified. 915 916 \note{we have no code yet to select the best of several models for a 917 given objects. The relative value of the Chi-Square is the obvious 918 test in this case}. 919 920 \subsection{Faint Sources} 921 922 \note{this is not done : should use the ensemble PSF fitting to fit 923 just the new significant peaks} 924 925 After a first pass through the image, in which the brighter sources 926 above a high threshold level have been detected, measured, and 927 subtracted, PSPhot optionally begins a second pass at the image. In 928 this stage, the new peaks are detected on the image with the bright 929 objects subtracted. In this pass, the peak detection process uses the 930 noise image to test the validity of the individual peaks. All peaks 931 with a significance greater than a user-defined minimum threshold are 932 accepted as objects of potential interest. 933 934 The objects which are measured in this faint-object stage are clearly 935 low significance detections. A typical threshold for the bright 936 object analysis would S/N of 5 - 10. The lower limit cutoff for the 937 faint object analysis would typically be S/N of 2 - 4. In this stage, 938 PSPhot can perform one of three types of analysis. The difference 939 between these options is one of speed vs detail. 940 941 In the first option, PSPhot can repeat the analysis described above in 942 sections XXX and XXX, performing a PSF fit followed by a non-PSF fit 943 to the objects which are not PSF-like, and subtracting them. The 944 advantage of this option is that the faint objects are treated 945 identically to the bright objects, and all potential parameters are 946 measured, even for marginally extended sources. The disadvantage of 947 this option is that the low signal-to-noise of the objects in this 948 stage limits the amount of information which can be extracted from 949 them. The marginal gain may not be worth the large expense of 950 processing time. 951 952 In the second option, PSPhot can perform only the PSF model fit to the 953 remaining peaks, but ignore any further questions of the shape of the 954 objects. The advantage of this option is that it is substantially 955 faster than performing the more complex (and less stable) 956 multi-parameter non-linear fits on all faint objects. On the 957 downside, less information is learned about the objects. 958 959 Finally, PSPhot can simply ignore the fitting process and instead 960 glean information about the fainter sources on the basis of the peak 961 characteristics. In this option, the image is smoothed with the PSF 962 model, and the peak for each object is measured. The peak flux and 963 the local peak curvature theoretically give sufficient information to 964 recover the object flux, the centroid coordinates, and the centroid 965 errors. The advantage of the stage is speed, especially for the very 966 faintest levels: if the lower limit is not sufficiently faint, the 967 time spent in performing the smoothing (3 FFTs) cannot make up for the 968 time which would have been spent applying the PSF model to the peaks. 969 The downside of this method is an increased sensitivity to the local 970 sky model (the local sky must be correctly subtracted) and fewer 971 constraints on the quality of the detection (no Chi-Square is 972 measured, for example). 973 974 \note{In the ideal case, if we were only interested in detecting PSFs, 975 and we had a good model for the PSF, we could optimally find the 976 sources by smoothing the image and the noise image with the PSF model. 977 \em write out the description of Nick's optimal PSF finding}. 978 979 PSPhot allows the user to select between these three options for the 980 analysis of the faint sources. Three separate user-controlled 981 signal-to-noise ratio limits are defined. One specifies the depth to 982 which the PSF / non-PSF analysis is performed. A second (which must 983 be smaller) specifies the depth to which only the PSF is fitted. A 984 third specifies the depth to which the analysis is performed using on 985 the peak statistics. If two of these are identical, then certain of 986 these options are simply skipped. For example, if the peak analysis 987 threshold is set to the same value as the PSF-only threshold, no peak 988 analysis is performed. 989 990 \subsection{Aperture Correction Measurement} 991 992 The important concept here is that an analytical model will always 993 fail to describe the flux of the objects at some level. In the end, 994 all astronomical photometry is in some sense a relative measurement 995 between two images. Whether the goal is calibration of a science 996 image taken at one location to a standard star image at another 997 location, or the goal is simply the repetitive photometry of the same 998 star at the same location in the image, it is always necessary to 999 compare the photometry between two images. If this measurement is to 1000 be consistent, then the measurement must represent the flux of the 1001 stars in the same way regardless of the conditions under which the 1002 images were taken, at least within some range of normal image 1003 conditions. So, for example, two images with different image quality, 1004 or with different tracking and focus errors, will have different PSF 1005 models. Since an analytical model will always fail to represent the 1006 flux of the star at some level, the measured flux of the same object 1007 in the two images will be different (even assuming all other 1008 atmospheric and instrumental effects have been corrected). The 1009 amplitude of the error will by determined by how inconsistently the 1010 models represent the actual object flux. For example, if the first 1011 image PSF model flux is consistently 10\% too low and the second is 5\% 1012 too high, then the comparison between the two images will be in error 1013 by 15\%. 1014 1015 Aperture photometry avoids these problems, by trading for other 1016 difficulties. In aperture photometry, if a large enough aperture is 1017 chosen, the amount of flux which is lost will be a small fraction of 1018 the total object flux. Even more importantly, as the image conditions 1019 change, the amount lost will change by an even smaller fraction, at 1020 least for a large aperture. This can be seen by the fact that the 1021 dominant variations in the image quality are in the focus, tracking 1022 and seeing. All of these errors initially affect the cores of the 1023 stellar images, rather than the wide wings. The wide wings are 1024 largely dominated by scattering in the optics and scattering in the 1025 atmosphere. The amplitude and distribution of these two scattering 1026 functions do not change significantly or quickly for a single 1027 telescope and site. 1028 1029 The difficulty for aperture photometry is the need to make an accurate 1030 measurement of the local background for each object. As the aperture 1031 grows, errors in the measurement of the sky flux start to become 1032 dominant. If the aperture is too small, then variation in the image 1033 quality are dominant. The brighter is the object, the smaller is the 1034 error introduced by the large size of the aperture. However, the 1035 number of very bright stars is limited in any image, and of course the 1036 brighter stars are more likely to suffer from non-linearity or 1037 saturation. 1038 1039 \note{this discussion sucks: put in some more details of my point: 1040 amplitude of systematic vs random sky errors} 1041 1042 How important is this effect? Consider a typical bright object with a 1043 flux of (say) 40,000 counts in an image of background 1000 counts per 1044 pixel, with FWHM of 4 pixels. In principle, the flux of this object 1045 should be measurable with an accuracy of roughly 0.57\% 1046 ($\frac{\sqrt{40000 + 1000 \times 12}}{40000}$). However, the 1047 measurement of the sky is limited at some finite level by Poisson 1048 statistics. If we are required to use an aperture of (say) 25 pixels 1049 in radius (eg, 5 arcseconds for an 0.2 arcsec / pixel detector), and 1050 we have an annulus of twice this radius to measure the local sky, then 1051 we will have an error of XXX. 1052 1053 \note{outline the variation of {\em ApResid} as a function of 1054 magnitude}. 1055 1056 PSPhot measures the aperture correction ({\em ApResid}) for every PSF 1057 candidate object, then calculates the trend of this correction as a 1058 function of the magnitude. This trend is fitted with a line. The 1059 resulting function can be used to determine the effective aperture 1060 correction for an infinite flux object and the average bias inherent 1061 in the sky measurement for the image. The scatter of the 1062 PSF-candidate object measurements about this trend is a measure of how 1063 well we can measure photometry from the image by applying the specific 1064 PSF model. The slope of this trend is a measure of the bias in the 1065 local sky measurment for each object. In principal, the measured sky 1066 levels could be modified by this bias. More generally, the measured 1067 bias in a collection of images could be used to improve the model 1068 fitting or sky fitting portion of the software the remove the bias 1069 term. 1070 1071 PSPhot allows a collection of PSF model functions to be tried on all 1072 PSF candidate objects. For each model test, the above corrected 1073 ApResid scatter is measured. The PSF model function with the smallest 1074 value for the ApResid scatter is then used by PSPhot as the best PSF 1075 model for this image. The number of models to be tested is specified 1076 by the configuration keyword \code{PSF\_MODEL\_N}. The configuration 1077 variables \code{PSF\_MODEL\_0}, \code{PSF\_MODEL\_1}, through 1078 \code{PSF\_MODEL\_N - 1} specify the names of the models which should be 1079 tested. 1080 1081 \subsubsection{Types of Object / PSF models currently available} 1082 1083 \note{the discussion of the model types needs to be extended} 1084 1085 \begin{itemize} 1086 \item GAUSS : Pure elliptical Gaussian 1087 \item PGAUSS : polynomial approximation to a Gaussian (PGAUSS) 1088 \item QGAUSS : power law with variable exponential term 1089 \item SGAUSS : 1090 \end{itemize} 1091 1092 \note{discuss the stability issues with the galaxy model(s)} 1093 1094 \subsection{Output Options} 1095 1096 \note{need to discuss tests} 1097 1098 \note{need to discuss failings and holes} 1099 1100 \section{Alternative Scenarios} 1101 1102 \subsection{Trailed Sources} 1103 1104 \subsection{Fixed / Known-position Sources} 1105 1106 \subsection{Difference Images} 1107 1108 The noise map for a difference image must be generated from the two 1109 images use to construct the difference. Otherwise, the low sky level 1110 will automatically result in inconsistent interpretation of the noise. 1111 1112 For a difference image, both positive and negative objects will be 1113 present. The basic peak detection algorithm will only trigger for the 1114 positive sources. One solution is to simply apply PSPhot to both the 1115 difference image and its negative value. \note{do we want to code in 1116 an automatic switch to get both positive and negative excursions in 1117 the single pass?}. 1118 1119 In the case of a difference image, the PSF model construction stage 1120 will probably fail for lack of valid sources. It is better in these 1121 cases to provide PSF model from some other source. For example, the 1122 two images which are combined to generate the difference image 1123 represent the PSF. Presumably, one or both have been convolved with a 1124 PSF-matching kernel. The images which result from the convolution 1125 should be used to measure the PSF model. 1126 1127 The object classification scheme defaults to the galaxy models for 1128 objects which are not well represented by the PSF model. In a 1129 properly-constructed difference image, galaxies are unlikely to remain 1130 behind as significant sources. Most real objects in the difference 1131 image will be PSF-like and will consist of photometrically variable 1132 objects (flare stars, supernovae, etc) or astrometrically variable 1133 objects (high-proper motion stars or solar-system objects). There are 1134 three likely classes of objects which will not be well represented by 1135 the PSF model. 1) Fast-moving solar-system objects will appear as 1136 short streaks. For example, a fast solar system object would have an 1137 apparent rate of 0.5 degrees per hour, translating to 15 arcseconds in 1138 a 30 second exposure. Even a main belt asteroid at roughly 1 AU would 1139 have reflect motion of approximately 1 degree per day, equivalent to 1140 1.25 arcsec in a 30 second exposure, and could be noticeably smeared 1141 and non-PSF-like. A trailed-star model can be used to characterize 1142 these types of objects. 2) Small offset stars, either due to 1143 atmospheric / color effects or modest proper motion will appear as PSF 1144 dipoles in the difference images. The positive and the negative 1145 images will have stellar profiles, but they will be significantly 1146 offset and will not subtract well. The two components may not have 1147 the same amplitude. A PSF-dipole model can be used to fit these types 1148 of objects, with free parameters of the two centroids and the two 1149 fluxes. 3) Comets will appear in the difference images as a non-PSF 1150 objects. Their 2-D structure includes both the flux from the coma 1151 (with a typical power-law profile) and flux from the tail (with a more 1152 complex flux distribution). A comet flux model can be used to 1153 characterize these objects in difference images. A major difficulty 1154 in applying these three types of models is in making a robust test of 1155 which model should be used. This problem is akin to the issue of 1156 selecting and distinguishing between multiple galaxy models, as 1157 discussed in the section on Galaxy models. 1158 1159 \section{PSPhot Structures and Data Elements} 1160 1161 The following structures are described in detail in the document 1162 `Pan-STARRS PS-1 Image Processing Pipeline Modules Supplementary 1163 Design Requirements' (psModules SDRS; PSDC-430-012). 1164 1165 \begin{verbatim} 1166 pmModel 1167 pmModelGroup 1168 pmGrowthCurve 1169 pmPSF 1170 pmPSFTry 1171 pmSource 1172 pmPeak 1173 pmMoments 1174 \end{verbatim} 1175 1176 \note{psphot is supposed to operate on individual readouts, and use 1177 the techniques used by ppImage to extract header-related metadata. 1178 currently, psphot uses an alternative to the psReadout until the 1179 ppImage code can be folded together with psphot}. 1180 1181 \subsection{Top-Level APIs} 1182 1183 \begin{verbatim} 1184 psMetadata *psphotArguments (int *argc, char **argv); 1185 \end{verbatim} 1186 Load the command-line arguments, parse the configuration file, and 1187 place the configuration information on a single metadata structure. 1188 This function searches for the following command line option flags, 1189 and places their corresponding values on the output metadata with the 1190 given name. These options override any such values in the 1191 configuration file. 1192 \begin{verbatim} 1193 -mask (filename) : MASK_IMAGE 1194 -weight (filename) : WEIGHT_IMAGE 1195 -resid (filename) : RESID_IMAGE 1196 -region [x0:x1,y0:y1] : ANALYSIS_REGIONP 1197 -photcode (code) : PHOTCODE 1198 -psf (filename) : PSF_INPUT_FILE 1199 -modeltest x y : TEST_FIT_X, TEST_FIT_Y 1200 -model (name) : TEST_FIT_MODEL 1201 -fitmode (name) : TEST_FIT_MODE 1202 -fitset (name) : TEST_FIT_SET 1203 \end{verbatim} 1204 1205 The following option flags can be used to set any option: 1206 \begin{verbatim} 1207 -D (key) (value) : any string value 1208 -Df (key) (value) : any F32 value 1209 -Di (key) (value) : any S32 value 1210 \end{verbatim} 1211 1212 The function next examines the remaining command-line arguments and 1213 complains if there are not exactly 3 arguments, reporting the program 1214 usage. It sets default configuration variables, and then loads the 1215 configuration file specified as the third command-line option. 1216 Finally, it sets the \code{IMAGE} and \code{OUTPUT\_FILE} config 1217 options to arguments 1 and 2, respecitively. 1218 1219 \begin{verbatim} 1220 eamReadout *psphotSetup (psMetadata *config); 1221 \end{verbatim} 1222 This function examines the configuration data in \code{config} and 1223 loads the image into memory. It constructs the weight and mask images 1224 if they have not been specified, or loads the specified images. The 1225 weight image is built based on the read noise and gain of the image, 1226 as extracted from the header or from the configuration options 1227 directly. It defines the mask based on the selection image region, 1228 the values for saturation and the \code{min\_VALID\_PIXEL}. 1229 1230 \begin{verbatim} 1231 bool psphotModelTest (eamReadout *imdata, psMetadata *config); 1232 \end{verbatim} 1233 This function is an optional test mode for psphot. If the test mode 1234 has been selected, this function will attempt to fit a single object 1235 with the requested model. It writes out subimage containing the 1236 source, the difference, the mask, and the weight. This function may 1237 load a PSF model or fit a floating model. 1238 1239 \begin{verbatim} 1240 psStats *psphotImageStats (eamReadout *imdata, psMetadata *config); 1241 \end{verbatim} 1242 Measure the basic image properties: median sky, expected sky sigma 1243 1244 \begin{verbatim} 1245 psPolynomial2D *psphotImageBackground (eamReadout *imdata, psMetadata *config, psStats *sky); 1246 \end{verbatim} 1247 Model the image background as a 2D polynomial and subtract from the 1248 image. The should use a more sophisticated model and return the 1249 subtracted image. 1250 1251 \begin{verbatim} 1252 psArray *psphotFindPeaks (eamReadout *imdata, psMetadata *config, psStats *sky); 1253 \end{verbatim} 1254 Create a smoothed image and find all local peaks above the threshold 1255 level (uses: \code{PEAKS\_SMOOTH\_SIGMA, PEAKS\_SMOOTH\_NSIGMA, 1256 PEAKS\_NSIGMA\_LIMIT, PEAKS\_OUTPUT\_FILE}) 1257 1258 \begin{verbatim} 1259 psArray *psphotSourceStats (eamReadout *imdata, psMetadata *config, psArray *allpeaks); 1260 \end{verbatim} 1261 Create the basic source structures for all peaks, define the initial 1262 pixels, measure the local sky (sky offset) and the source moments. 1263 1264 \begin{verbatim} 1265 bool psphotRoughClass (psArray *sources, psMetadata *config); 1266 \end{verbatim} 1267 Find the PSF clump and make the first cut source identifications 1268 1269 \begin{verbatim} 1270 bool psphotBasicDeblend (psArray *sources, psMetadata *config, psStats *sky); 1271 \end{verbatim} 1272 Find all blended peaks and tag, group with single primary source. 1273 1274 \begin{verbatim} 1275 pmPSF *psphotChoosePSF (psMetadata *config, psArray *sources, psStats *sky); 1276 \end{verbatim} 1277 Try each of the selected PSF models on a subset of likely PSF stars. 1278 Measure the metric (aperture residual scatter) for each PSF model and 1279 choose the best model. 1280 1281 \begin{verbatim} 1282 bool psphotEnsemblePSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 1283 \end{verbatim} 1284 Perform simultaneous fitting to all sources in the array using a 1285 linear fitting process which assumes all sources are PSFs and their 1286 positions are fixed. Set the positions based on the bilinear 1287 interpolation of the peak implied by the 3x3 square of pixels 1288 containing the peak. Local sky is also assumed to be correctly subtracted. 1289 1290 \begin{verbatim} 1291 bool psphotFullFit (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 1292 \end{verbatim} 1293 Fit all sources in sequence starting from the brightest, and 1294 subtracting the sources as they are fitted. This function only 1295 attempts single PSF and single EXT models and chooses between them. 1296 The sources are assumed to have been subtracted in advance (ie, using 1297 psphotEnsembleFit). The models which do not succeed are re-subtracted 1298 using the prior model. 1299 1300 \begin{verbatim} 1301 bool psphotBlendFit (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 1302 \end{verbatim} 1303 Fit all sources in sequence starting from the brightest, and 1304 subtracting the sources as they are fitted. This function attempts a 1305 multi-source fit for blended sources, or a single PSF if it is not a 1306 blend, followed by both EXT and DBL models and chooses between them. 1307 The sources are assumed to have been subtracted in advance (ie, using 1308 psphotEnsembleFit). The models which do not succeed are re-subtracted 1309 using the prior model. 1310 1311 \begin{verbatim} 1312 bool psphotReplaceUnfit (psArray *sources); 1313 \end{verbatim} 1314 After models have been attempted for all sources, this function 1315 replaces the sources which were temporarily subtracted, but which did 1316 not succeed or converge on a good solution. 1317 1318 \begin{verbatim} 1319 bool psphotApplyPSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 1320 \end{verbatim} 1321 Attempt to fit the PSF model to all sources in brightness order, 1322 subtracting the resulting model if successful. Only attempts single 1323 PSF models. 1324 1325 \begin{verbatim} 1326 bool psphotFitExtended (eamReadout *imdata, psMetadata *config, psArray *sources, psStats *skyStats); 1327 \end{verbatim} 1328 Attempt to fit the PSF model to all sources in brightness order, 1329 subtracting the resulting model if successful. Only attempts single 1330 EXT models. 1331 1332 \begin{verbatim} 1333 bool psphotApResid (eamReadout *imdata, psArray *sources, psMetadata *config, pmPSF *psf); 1334 \end{verbatim} 1335 Measure the curve-of-growth and the aperture correction trend. 1336 1337 \begin{verbatim} 1338 void psphotOutput (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 1339 \end{verbatim} 1340 Write out data in various formats as selected. 1341 1342 \section{User's Guide} 1343 1344 \subsection{Configuration Parameters} 1345 1346 \begin{verbatim} 1347 FAINT_SN_LIM 1348 FIT_MAX_CHI 1349 FIT_MIN_SN 1350 FIT_NSIGMA 1351 FIT_PADDING 1352 FIT_RADIUS 1353 GAIN 1354 GAL_MODEL 1355 GAL_MOMENTS_RADIUS 1356 INNER_RADIUS 1357 INPUT 1358 MASK 1359 NOISE 1360 NSUBSET 1361 OUTER_RADIUS 1362 OUTPUT 1363 OUTPUT_MODE 1364 PEAK_NSIGMA 1365 PSF_MODEL_N 1366 PSF_MOMENTS_RADIUS 1367 PSF_SHAPE_NSIGMA 1368 RDNOISE 1369 SATURATE 1370 SMOOTH_NSIGMA 1371 SMOOTH_SIGMA 1372 XMAX 1373 XMIN 1374 YMAX 1375 YMIN 1376 \end{verbatim} 1377 1378 \subsection{Command-Line Arguments and Options} 1379 1380 \subsection{Input \& Output Data Formats} 1381 1382 \section{Sample Tests} 1383 1384 \section{Further Work to be Completed} 1385 1386 \begin{itemize} 1387 \item convert to pmCell as input data 1388 \item loop over all readouts in a pmCell 1389 \item write out multiple files? 1390 \item better method for defining the recipe? 1391 \item additional options for image background 1392 \item image background should return a background image 1393 \end{itemize} 112 1394 113 1395 \end{document}
Note:
See TracChangeset
for help on using the changeset viewer.
