IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 15, 2006, 2:26:17 PM (20 years ago)
Author:
eugene
Message:

fleshing out psphot APIs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/modules/ModulesSDRS.tex

    r5937 r6006  
    1 %%% $Id: ModulesSDRS.tex,v 1.69 2006-01-07 02:53:15 price Exp $
     1%%% $Id: ModulesSDRS.tex,v 1.70 2006-01-16 00:26:17 eugene Exp $
    22\documentclass[panstarrs,spec]{panstarrs}
    33
     
    5353
    5454\tableofcontents
     55\pagebreak
     56
     57\listoffigures
    5558\pagebreak
    5659\pagenumbering{arabic}
     
    16321635\subsection{Structures to Describe Sources}
    16331636
    1634 \subsubsection{pmSource and pmPeak}
    1635 
    1636 We start by defining a single source detected in a single band:
    1637 \begin{datatype}
    1638 typedef struct {
    1639   pmPeak *peak;            // description of peak pixel
    1640   psImage *pixels;         // rectangular region including object pixels
    1641   psImage *mask;           // mask to mark pixels associated with object in region
    1642   pmMoments *moments;      // basic moments measure for the object
    1643   pmModel *modelPSF;       // PSF model parameters and type
    1644   pmModel *modelFLT;       // FLT model parameters and type
    1645   pmSourceType type;       // best identification of object
    1646 } pmSource;
    1647 \end{datatype}
    1648 
    16491637In the object analysis process, we will use specific mask values to
    16501638mark the image pixels.  The following structure defines the relevant
    16511639mask values.
    16521640\begin{datatype}
    1653 enum {
     1641typedef enum {
    16541642    PSPHOT_MASK_CLEAR     = 0x00,
    16551643    PSPHOT_MASK_INVALID   = 0x01,
     
    16571645    PSPHOT_MASK_MARKED    = 0x08,
    16581646} psphotMaskValues;
     1647\end{datatype}
     1648
     1649\subsubsection{pmSource and pmPeak}
     1650
     1651We define the following structure to represent a single source
     1652detected in a single image. 
     1653\begin{datatype}
     1654typedef struct {
     1655  pmPeak *peak;            // description of peak pixel
     1656  psImage *pixels;         // rectangular region including object pixels
     1657  psImage *weight;         // Image variance.
     1658  psImage *mask;           // Mask which marks pixels associated with objects.
     1659  pmMoments *moments;      // basic moments measure for the object
     1660  pmModel *modelPSF;       // PSF model parameters and type
     1661  pmModel *modelEXT;       // FLT model parameters and type
     1662  pmSourceType type;       // Best identification of object
     1663  pmSourceMode mode;       // flags describing the model quality
     1664  psArray *blends;         // array of other sources blended with this source
     1665  float apMag;             // measured aperture magnitude for source
     1666  float fitMag;            // measured model magnitude for source
     1667  psRegion region;         // area on image covered by selected pixels
     1668} pmSource;
    16591669\end{datatype}
    16601670
     
    16841694  PM_PEAK_EDGE,             // peak on edge
    16851695  PM_PEAK_FLAT              // peak has equal-value neighbors
     1696  PM_PEAK_UNDEF             // Undefined.
    16861697} pmPeakType;
    16871698\end{datatype}
     
    16891700\subsubsection{pmMoments and source description}
    16901701
    1691 The pixels which contain the source may be specified with the
    1692 \code{psImage *pixels} element, and the mask image may be used to
    1693 exclude any pixels which are not considered part of the source.  Note
    1694 that the source image may be simply a subimage of the main image or a
    1695 separate copy if the pixels are modified (eg, by subtracting flux from
    1696 other sources, etc).
     1702The pixels which contain the source are specified with the
     1703\code{psImage *pixels} element, a subimage of the image being
     1704analysed.  Similarly, the \code{mask} element is a subimage of the
     1705corresponding mask image and the \code{weight} element is a subimage
     1706of the corresponding weight image (image varience).  Since these are
     1707subimages, a collection of many objects may include overlapping
     1708pixels; care must be taken that pixel manipulations for one source do
     1709not unintentionally interfere with the other source pixels.  The
     1710\code{mask} may be used to exclude any pixels which are not considered
     1711part of the source.  Along with these pixel structures, we include the
     1712\code{psRegion region} element which defines the boundaries of the
     1713current associated subimages.
    16971714
    16981715One of the simplest measurements which can be made quickly for an
     
    17321749A given source may be identified as most-likely to be one of several
    17331750source types.  The \code{pmSource} entry \code{pmSourceType} defines
    1734 the current best-guess for this source.  \tbd{The values given below
    1735 are currently illustrative and will require some modification as the
    1736 source classification code is developed.}
     1751the current best-guess for this source. 
    17371752
    17381753\begin{datatype}
    17391754typedef enum {
    1740     PM_SOURCE_DEFECT,              // a cosmic-ray
    1741     PM_SOURCE_SATURATED,           // random saturated pixels
    1742 
    1743     PM_SOURCE_SATSTAR,             // a saturated star
    1744     PM_SOURCE_PSFSTAR,             // a PSF star
    1745     PM_SOURCE_GOODSTAR,            // a good-quality star
    1746 
    1747     PM_SOURCE_POOR_FIT_PSF,        // poor quality PSF fit
    1748     PM_SOURCE_FAIL_FIT_PSF,        // failed to get a good PSF fit
    1749     PM_SOURCE_FAINTSTAR,           // below S/N cutoff
    1750 
    1751     PM_SOURCE_GALAXY,              // an extended object (galaxy)
    1752     PM_SOURCE_FAINT_GALAXY,        // a galaxy below S/N cutoff
    1753     PM_SOURCE_DROP_GALAXY,         // ?
    1754     PM_SOURCE_FAIL_FIT_GAL,        // failed on the galaxy fit
    1755     PM_SOURCE_POOR_FIT_GAL,        // poor quality galaxy fit
    1756 
    1757     PM_SOURCE_OTHER                // unidentified
    1758 } pmSourceType;
     1755    PM_SOURCE_UNKNOWN,                  ///< no guess yet made
     1756    PM_SOURCE_DEFECT,                   ///< a cosmic-ray
     1757    PM_SOURCE_SATURATED,                ///< random saturated pixels
     1758    PM_SOURCE_STAR,                     ///< a good-quality star
     1759    PM_SOURCE_EXTENDED,                 ///< an extended object (eg, galaxy)
     1760} pmSourceType;
     1761\end{datatype}
     1762
     1763The related element, \code{pmSourceMode mode}, holds a collection of flags which
     1764are used to indicate the status of the analysis for a source.  These
     1765are defined below:
     1766\begin{datatype}
     1767typedef enum {
     1768    PM_SOURCE_DEFAULT    = 0x0000, ///< no flags are set
     1769    PM_SOURCE_PSFMODEL   = 0x0001, ///< flags refer to the PSF model
     1770    PM_SOURCE_EXTMODEL   = 0x0002, ///< flags refer to the EXT model
     1771    PM_SOURCE_SUBTRACTED = 0x0004, ///< the model has been subtracted from the image
     1772    PM_SOURCE_FITTED     = 0x0008, ///< the source has been fitted with a model
     1773    PM_SOURCE_FAIL       = 0x0010, ///< the model fit failed
     1774    PM_SOURCE_POOR       = 0x0020, ///< the model fit was poor (low S/N, etc)
     1775    PM_SOURCE_PAIR       = 0x0040, ///< the model fit is one of a paired source
     1776    PM_SOURCE_PSFSTAR    = 0x0080, ///< the source was used to construct the image PSF model
     1777    PM_SOURCE_SATSTAR    = 0x0100, ///< the source is saturated
     1778    PM_SOURCE_BLEND      = 0x0200, ///< the source is a blend with another source
     1779    PM_SOURCE_LINEAR     = 0x0400, ///< the source was fitted with the linear PSF model
     1780    PM_SOURCE_TEMPSUB    = 0x0800, ///< the source has been subtracted, but should be replaced
     1781} pmSourceMode;
    17591782\end{datatype}
    17601783
     
    17771800\end{itemize}
    17781801
    1779 Every source may have two types of models: a PSF model and a FLT
    1780 (floating) model.  The PSF model represents the best fit of the image
    1781 PSF to the specific object.  In this case, the PSF-dependent
    1782 parameters are specified for the object by the PSF, not by the fit.
    1783 The FLT model represents the best fit of the given model to the
    1784 object, with all parameters floating in the fit. 
    1785 
     1802\tbd{should be include utility pointers to these parameters so that
     1803  functions do not need to know the parameter sequence?}
     1804
     1805The structure which carries the information about a given source model
     1806is defined below:
    17861807\begin{datatype}
    17871808typedef struct {
     
    17921813  psS32 nDOF;               // number of degrees of freedom
    17931814  psS32 nIter;              // number of iterations
     1815  pmModelStatus status;     // fit status
    17941816  float radius;             // fit radius actually used
    17951817} pmModel;
    17961818\end{datatype}
     1819
     1820The \code{status} element carries the resulting success/failure status
     1821of an attempt to fit the model to the source:
     1822\begin{datatype}
     1823typedef enum {
     1824    PM_MODEL_UNTRIED,               ///< model fit not yet attempted
     1825    PM_MODEL_SUCCESS,               ///< model fit succeeded
     1826    PM_MODEL_NONCONVERGE,           ///< model fit did not converge
     1827    PM_MODEL_OFFIMAGE,              ///< model fit drove out of range
     1828    PM_MODEL_BADARGS                ///< model fit called with invalid args
     1829} pmModelStatus;
     1830\end{datatype}
     1831
     1832We distinguish several ways in which an analytical model may be
     1833applied to a source.  The PSF model represents the best fit of the
     1834image PSF to the specific object.  In this case, the PSF-dependent
     1835parameters are specified for the object by the PSF, not by the fit.
     1836The EXT model represents the best fit of the given model to the
     1837object, with all parameters floating in the fit.  Such a model would
     1838typically be used to represent and extended object, hence the
     1839abbreviation EXT.  In some circumstances, a source may be fitted with
     1840a PSF model in which the position is held fixed, and not allowed to
     1841vary in the model fitting process.  We identify such a model as FIX.
     1842Finally, we allow for the case in which two nearly-merged PSFs are
     1843fitted with a single 2-PSF model.  We identify such a model as DBL.
     1844The \code{pmSource} structure contains a pointer to both a PSF and an
     1845EXT model, allowing any source to carry information about both
     1846possible fitting modes \tbd{not clear that we actually use this
     1847information; we might be better off simply distinguishing with one of
     1848the pmSourceMode flags}.  The value of the model at a specific
     1849coordinate can be determined by calling the function:
     1850\begin{prototype}
     1851psF32 pmModelEval(pmModel *model, psImage *image, psS32 col, psS32 row);
     1852\end{prototype}
     1853For this function, the values of \code{col,row} are in the
     1854\code{image} coordinates, which may be a subimage, while the reference
     1855coordinate for the model is in the parent image coordinates.
     1856
     1857In the \code{pmSource} structure, the elements \code{apMag} and
     1858\code{fitMag} are used to carry the measured magnitude of the source
     1859determined either from aperture photometry or from the integral of the
     1860fitted model function.  The element \code{blends} is used to carry
     1861pointers to the collection of sources which were found to be blended
     1862with this source.  Only the primary source of a blend group carries
     1863this information (see Section~\ref{blends}).
    17971864
    17981865Every model instance belongs to a class of models, defined by the
     
    18931960should be used to transfer models between programs or systems.
    18941961
     1962\subsubsection{pmGrowthCurve}
     1963
     1964When the photometry of source is measured in a fixed aperture, there
     1965is always a fraction of the source light which falls outside of the
     1966aperture.  The resulting aperture magnitude is thus larger (ie,
     1967fainter) than the actual source.  As the aperture is increased, the
     1968amount of loss decreases and the measured magnitude increases.  This
     1969trend is the curve of growth for the source.  We use the following
     1970structure to carry information about the curve of growth.  We use the
     1971PSF model to measure the curve of growth for an image. 
     1972
     1973\begin{datatype}
     1974typedef struct {
     1975    psVector *radius;
     1976    psVector *apMag;
     1977    psF32 refRadius;
     1978    psF32 maxRadius;
     1979    psF32 fitMag;
     1980    psF32 apRef;   // apMag[refRadius]
     1981    psF32 apLoss;  // fitMag - apRef
     1982} pmGrowthCurve;
     1983\end{datatype}
     1984In this structure, \code{radius} is a monotonically increasing
     1985sequence of radius values (in pixels).  The \code{apMag} vector
     1986contains the measured magnitude at any of these radius: this is the
     1987curve-of-growth trend.  The remaining entries summaries the
     1988relationship: \code{refRadius} is the global reference radius used for
     1989this image; \code{maxRadius} is the outermost radius at which the
     1990curve of growth was measured; \code{fitMag} is the fitted PSF model
     1991magnitude integrated to infinity; \code{apRef} is the aperture
     1992magnitude at the reference radius; \code{apLoss} is the difference
     1993between the aperture magnitude at the reference radius and the fitted
     1994model magnitude.  A few related functions are specified to interact
     1995with the curve of growth:
     1996
     1997\begin{prototype}
     1998pmGrowthCurve *pmGrowthCurveAlloc (psF32 minRadius, psF32 maxRadius, psF32 dRadius);
     1999\end{prototype}
     2000This function allocates a \code{pmGrowthCurve} structure and fills in
     2001the \code{radius} vector (see psLib SDRS \code{psVectorCreate}).  It
     2002does {\em not} allocate the \code{apMag} vector.
     2003
     2004\begin{prototype}
     2005psF32 pmGrowthCurveCorrect (pmGrowthCurve *growth, psF32 radius);
     2006\end{prototype}
     2007This function accepts a \code{growth} curve structure and returns the
     2008correction between the specified radius and the reference radius
     2009($apMag(refRadius) - apMag(radius)$).
     2010
     2011The following two functions are used to search the growth curve to the
     2012corresponding radius entry:
     2013\begin{prototype}
     2014int psVectorBracket (psVector *index, psF32 key, bool above);
     2015psF32 psVectorInterpolate (psVector *index, psVector *value, psF32 key);
     2016\end{prototype}
     2017
     2018\subsubsection{Aperture Trends}
     2019
     2020With PSF model fitting, there is always some discrepancy between the
     2021model of the PSF and the actual PSF.  As a result, the measured flux
     2022from the model will not represent exactly the flux of the source.  It
     2023is necessary to measure the correction between the model and the
     2024actual source flux.  One way to perform this measurement is to compare
     2025the model flux with the flux measured for bright stars within a fixed
     2026aperture.  The quantity to be measured is $dA = m_{\rm aperture} -
     2027m_{\rm fit}$.  In practice, $dA$ exhibits variations as a function of
     2028the source position ($x,y$) and the source flux.  The variations as a
     2029function of source position can be understood as a change in the PSF
     2030model error as a function of position due to the changing shape of the
     2031PSF (despite the varying PSF model, it is possible that the fitted
     2032model yields positional variations in the residual flux).  The
     2033variations in $dA$ as a function of magnitude can be understood as the
     2034result of a bias in the local background measurement (for the fainter
     2035sources) and as a result of non-linearity in the detector setting on
     2036the bright end.  We use a 4D polynomial to represent these trends.
     2037The first two dimensions of the polynomial represent the variation of
     2038$dA$ as a function of $x,y$; we provide helper functions to define 1st
     2039and 2nd order polynomials in $x,y$.  The next two dimensions are
     2040fitted independently (no cross terms).  The first represents the
     2041variation as a function of $r^2 / flux$, where $r$ is the aperture
     2042radius used to measure $dA$; this is the scaling of a magnitude error
     2043in the presence of a constant error in the sky level.  The last
     2044dimension represents the variation of $dA$ as a function of the
     2045stellar flux.
     2046
     2047The following forms of the aperture correction model may be selected
     2048by the user:
     2049\begin{datatype}
     2050typedef enum {
     2051    PM_PSF_NONE,
     2052    PM_PSF_CONSTANT,
     2053    PM_PSF_SKYBIAS,
     2054    PM_PSF_SKYSAT,
     2055    PM_PSF_XY_LIN,
     2056    PM_PSF_XY_QUAD,
     2057    PM_PSF_SKY_XY_LIN,
     2058    PM_PSF_SKYSAT_XY_LIN,
     2059    PM_PSF_ALL
     2060} pmPSF_ApTrendOptions;
     2061\end{datatype}
     2062
     2063The following utility function sets the aperture correction model
     2064coefficient masks to select the specific desired coefficients:
     2065\begin{prototype}
     2066bool pmPSF_MaskApTrend (pmPSF *psf, pmPSF_ApTrendOptions option);
     2067\end{prototype}
     2068
    18952069\subsubsection{pmPSF, pmPSFtry, and PSF model}
    18962070
     
    19022076of all of the source parameters, except the first four PSF-independent
    19032077parameters, are represented as polynomial, stored in a \code{psArray}.
     2078The structure also contains the aperture correction model
     2079(\code{ApTrend}) and the curve-of-growth model (\code{growth}).  The
     2080additional elements are: \code{ApResid}, the constant term in the
     2081aperture correction model; \code{dApResid}, the residual scatter for
     2082bright sources ($S/N > 100$) after applying the aperture correction;
     2083\code{skyBias}, the measured average bias in the sky measurement;
     2084\code{skySat}, the scaling of the flux-dependent portion of the
     2085correction.
     2086
    19042087The other elements of the structure define the quality of the PSF
    1905 determination.
     2088determination. 
    19062089
    19072090\begin{datatype}
    19082091typedef struct {
    1909     psS32 type;             ///< PSF Model in use
    1910     psArray *params;        ///< Model parameters (psPolynomial2D)
    1911     psF32 chisq;            ///< PSF goodness statistic
    1912     psS32 nPSFstars;        ///< number of stars used to measure PSF
     2092    pmModelType type;                   ///< PSF Model in use
     2093    psArray *params;                    ///< Model parameters (psPolynomial2D)
     2094    psPolynomial4D *ApTrend;            ///< ApResid vs (x,y,rflux) (rflux = ten(0.4*mInst)
     2095    pmGrowthCurve *growth;              ///< apMag vs Radius
     2096    float ApResid;                      ///< ???
     2097    float dApResid;                     ///< ???
     2098    float skyBias;                      ///< ???
     2099    float skySat;                       ///< ???
     2100    float chisq;                        ///< PSF goodness statistic
     2101    int nPSFstars;                      ///< number of stars used to measure PSF
     2102    int nApResid;                       ///< number of stars used to measure ApResid
    19132103} pmPSF;
    19142104\end{datatype}
    19152105
    19162106\begin{prototype}
    1917 pmModel    *pmModelFromPSF (pmModel *model, pmPSF *psf);
     2107pmModel *pmModelFromPSF (pmModel *model, pmPSF *psf);
    19182108\end{prototype}
    19192109This function constructs a \code{pmModel} instance based on the
     
    19252115
    19262116\begin{prototype}
    1927 bool        pmPSFFromModels (pmPSF *psf, psArray *models, psVector *mask);
     2117bool pmPSFFromModels (pmPSF *psf, psArray *models, psVector *mask);
    19282118\end{prototype}
    19292119This function takes a collection of \code{pmModel} fitted models from
     
    19372127mask value (1 == \code{PSFTRY_MASK_OUTLIER}). 
    19382128
     2129We definet he following two functions to convert the PSF model
     2130parameters into a collection of elements on a metadata structure, and
     2131vice versa.  These can be used to read and write PSFs to a file and or
     2132a database.
     2133\begin{prototype}
     2134psMetadata *pmPSFtoMD (psMetadata *metadata, pmPSF *psf);
     2135pmPSF *pmPSFfromMD (psMetadata *metadata);
     2136\end{prototype}
     2137
    19392138We have the capability to test several different model functions in an
    19402139attempt to build an accurate PSF for an image.  The complete set of
     
    19462145    pmPSF      *psf;
    19472146    psArray    *sources;      // pointers to the original sources
    1948     psArray    *modelFLT;     // model fits, floating parameters
     2147    psArray    *modelEXT;     // model fits, floating parameters
    19492148    psArray    *modelPSF;     // model fits, PSF parameters
    19502149    psVector   *mask;
    19512150    psVector   *metric;
    19522151    psVector   *fitMag;
    1953     float       ApResid;
    1954     float       dApResid;
    1955     float       skyBias;
    19562152} pmPSFtry;
    19572153\end{datatype}
     
    19672163the fitted instrumental magnitude is stored in \code{fitMag}.  The
    19682164quality metric for the PSF model is the aperture magnitude minus the
    1969 fitted magnitude for each source.  This collection of aperture
    1970 residuals is examined in the analysis process, and a linear trend of
    1971 the residual with the inverse object flux (ie, $10^{0.4*mag}$) is
    1972 fitted.  The result of this fit is a measured sky bias (systematic
    1973 error in the sky measured by the fits), an effective
    1974 infinite-magnitude aperture correction (\code{ApResid}), and the
    1975 scatter of the aperture correction for the ensemble of PSF stars
    1976 (\code{dApResid}).  The ultimate metric to intercompare multiple types
    1977 of PSF models is the value of the aperture correction scatter.
     2165fitted magnitude for each source. 
     2166
     2167This collection of aperture residuals is examined in the analysis
     2168process, and a linear trend of the residual with the inverse object
     2169flux (ie, $10^{0.4*mag}$) is fitted.  The result of this fit is a
     2170measured sky bias (systematic error in the sky measured by the fits),
     2171an effective infinite-magnitude aperture correction (\code{ApResid}),
     2172and the scatter of the aperture correction for the ensemble of PSF
     2173stars (\code{dApResid}).  The ultimate metric to intercompare multiple
     2174types of PSF models is the value of the aperture correction scatter.
    19782175
    19792176The following functions are used to try out a single PSF model.
     
    19992196    PSFTRY_MASK_CLEAR    = 0x00,
    20002197    PSFTRY_MASK_OUTLIER  = 0x01, // 1: outlier in psf polynomial fit (provided by psPolynomials)
    2001     PSFTRY_MASK_FLT_FAIL = 0x02, // 2: flt model failed to converge
     2198    PSFTRY_MASK_EXT_FAIL = 0x02, // 2: ext model failed to converge
    20022199    PSFTRY_MASK_PSF_FAIL = 0x04, // 3: psf model failed to converge
    20032200    PSFTRY_MASK_BAD_PHOT = 0x08, // 4: invalid source photometry           
     
    20052202} pmPSFtryMaskValues;
    20062203\end{datatype}
     2204
    20072205
    20082206\begin{datatype}
     
    20792277                          psF32 y,
    20802278                          psF32 Radius)
    2081 \end{prototype}
    2082 
    2083 Define \code{psImage} subarrays for the source located at coordinates
    2084 \code{x,y} on the image set defined by \code{readout}.  The pixels
    2085 defined by this operation consist of a square window (of full width $2
    2086 Radius + 1$) centered on the pixel which contains the given
    2087 coordinate, in the frame of the readout.  The window is defined to
    2088 have limits which are valid within the boundary of the \code{readout}
    2089 image, thus if the radius would fall outside the image pixels, the
    2090 subimage is truncated to only consist of valid pixels.  If
    2091 \code{readout->mask} or \code{readout->weight} are not \code{NULL},
    2092 matching subimages are defined for those images as well.  This
    2093 function fails if no valid pixels can be defined (x or y less than
    2094 Radius, for example).  This function should be used to define a region
    2095 of interest around a source, including both source and sky pixels.
     2279
     2280bool pmSourceRedefinePixels(pmSource *mySource,
     2281                            pmReadout *readout,
     2282                            psF32 x,
     2283                            psF32 y,
     2284                            psF32 Radius)
     2285\end{prototype}
     2286
     2287The first form defines \code{psImage} subarrays (pixel, weight, and
     2288mask) for the source located at coordinates \code{x,y} on the image
     2289set defined by \code{readout}.  The pixels defined by this operation
     2290consist of a square window (of full width $2 Radius + 1$) centered on
     2291the pixel which contains the given coordinate, in the frame of the
     2292readout.  The window is defined to have limits which are valid within
     2293the boundary of the \code{readout} image, thus if the radius would
     2294fall outside the image pixels, the subimage is truncated to only
     2295consist of valid pixels.  If \code{readout->mask} or
     2296\code{readout->weight} are not \code{NULL}, matching subimages are
     2297defined for those images as well.  This function fails if no valid
     2298pixels can be defined (x or y less than Radius, for example).  This
     2299function should be used to define a region of interest around a
     2300source, including both source and sky pixels.  The second form accepts
     2301an existing source and redefines the pixels if the requested radius
     2302encompasses more pixels than the existing images.
    20962303
    20972304\begin{prototype}
    20982305pmSource *pmSourceLocalSky(pmSource *source,
    20992306                           psStatsOptions statsOptions,
    2100                            psF32 Radius)
     2307                           float Radius)
    21012308\end{prototype}
    21022309
     
    21242331source is returned.  The moments are measured within the given
    21252332circular radius of the \code{source.peak} coordinates.  The return
    2126 value indicates the success (TRUE) of the operation.
     2333value indicates the success (TRUE) of the operation.  This function
     2334also measures the approximate signal-to-noise ratio of the source
     2335(\code{source.SN}) based on the total number of source counts divided
     2336by the square-root of the total source variance, as determined from
     2337the weight image.
    21272338
    21282339\begin{prototype}
     
    21722383type for these parameters are \code{psF32}.
    21732384
    2174 The following rules are used to make the classification.  Sources with
    2175 peak pixel above the value of \code{SATURATE} are identified as type
    2176 \code{PM_SOURCE_SATURATED}.  For the remaining sources, the signal to
    2177 noise of the detection is approximated by:
    2178 \[
    2179 SN = \frac{S \sqrt{g}}{\sqrt{S + A B + \frac{A R_e^2}{\sqrt{g}}}}
    2180 \]
    2181 where
    2182 \[
    2183 A = \pi \sigma_x \sigma_y
    2184 \]
    2185 and $\sigma_x$ is \code{pmMoment.Sx}, $\sigma_y$ is
    2186 \code{pmMoment.Sy}, $B$ is \code{pmMoment.Sky} and $S$ is
    2187 \code{pmMoment.Sum}. The two parameters, $g$ and $R_e$ are the gain,
    2188 stored with the metadata keyword \code{GAIN} and the read-noise in
    2189 electrons, stored with the metadata keyword \code{READ_NOISE}.
    2190 
    2191 All sources with:
    2192 \[ |\sigma_x - \mbox{CLUMP}_x| < \mbox{CLUMP}_{dx}\]
    2193 and
    2194 \[ |\sigma_y - \mbox{CLUMP}_y| < \mbox{CLUMP}_{dy}\]
    2195 should be identified as type \code{PM_SOURCE_PSFSTAR}.  Sources with
    2196 \[ \sigma_x < \mbox{CLUMP}_{x} - \mbox{CLUMP}_{dx}\]
     2385The following rules are used to make the classification.  The number
     2386of saturated pixels are counted, based on the mask having the
     2387\code{PSPHOT_MASK_SATURATED} bit set.  Sources which are greater than
     23881$\sigma$ larger than the \code{pmPSFClump} center in both dimensions
     2389and which have more than a single saturated pixel are identified as
     2390being a likely saturated star (\code{type = PM_SOURCE_STAR, mode =
     2391PM_SOURCE_SATSTAR}).  Sources which are not so large but which have
     2392multiple saturated pixels are identified as saturated regions, ie
     2393bleed trails or hot columns (\code{type = PM_SOURCE_SATURATED}).
     2394
     2395Sources with
     2396\[ \sigma_x < 0.05 \]
     2397or
     2398\[ \sigma_y < 0.05\]
     2399should be identified as type \code{PM_SOURCE_DEFECT} (likely cosmic
     2400ray pixel).
     2401
     2402Sources with
     2403\[ \sigma_x > \mbox{CLUMP}_{x} + 3\mbox{CLUMP}_{dx}\]
    21972404and
    2198 \[ \sigma_y < \mbox{CLUMP}_{y} - \mbox{CLUMP}_{dy}\]
    2199 should be identified as type \code{PM_SOURCE_DEFECT}.  Sources with
    2200 \[ \sigma_x > \mbox{CLUMP}_{x} + \mbox{CLUMP}_{dx}\]
    2201 and
    2202 \[ \sigma_y > \mbox{CLUMP}_{y} + \mbox{CLUMP}_{dy}\]
    2203 should be identified as type \code{PM_SOURCE_GALAXY}.  All other
    2204 sources should be identified as type \code{PM_SOURCE_OTHER}.
    2205 \tbd{need to exclude stars outside valid data region}.
    2206 
    2207 Sources with $SN$ less than \code{FAINT_SN_LIM} are identified as type
    2208 \code{PM_SOURCE_FAINTSTAR}.  Sources with $SN$ greater than
    2209 \code{PSF_SN_LIM} are then selected as possible PSF stars.  These
    2210 sources are used to determine a guess at the shape of the PSF, based
    2211 on the collection of $\sigma_x$ and $\sigma_y$ values.
    2212 
    2213 \tbd{this discussion needs to be adjusted to match the implementation}
     2405\[ \sigma_y > \mbox{CLUMP}_{y} + 3\mbox{CLUMP}_{dy}\]
     2406should be identified as type \code{PM_SOURCE_EXTENDED}. 
     2407
     2408All other sources should be identified as type \code{PM_SOURCE_STAR}.
     2409Of these sources, the mode should be set to \code{PM_SOURCE_PSFSTAR}
     2410for any sources with $SN$ greater than \code{PSF_SN_LIM} which are
     2411within 1.5$\sigma$ of the PSF clump center.  These sources are used to
     2412determine a guess at the shape of the PSF, based on the collection of
     2413$\sigma_x$ and $\sigma_y$ values.
    22142414
    22152415\subsection{Object Fitting}
     
    22452445function allocates a \code{pmModel} entry for the \code{pmSource}
    22462446structure based on the provided model selection.  The method of
    2247 defining the model parameter guesses are specified for each model
    2248 below.  The guess values are placed in the model parameters.  The
    2249 function returns \code{TRUE} on success or \code{FALSE} on failure.
     2447defining the model parameter guesses are determined by using
     2448\code{pmModelGuessFunc_GetFunction} to determine the guess function
     2449for the model of interest.  The returned function is called and the
     2450guess values are used to set the model parameters.  The function
     2451returns \code{TRUE} on success or \code{FALSE} on failure.
    22502452
    22512453\begin{prototype}
Note: See TracChangeset for help on using the changeset viewer.