IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1113


Ignore:
Timestamp:
Jun 28, 2004, 3:44:33 PM (22 years ago)
Author:
Paul Price
Message:

Hacked sky subtraction.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/modules/include/phase2.h

    r1105 r1113  
    108108} psOverscanAxis;
    109109
    110 /** Fit type for bias */
     110/** Fit types */
    111111typedef enum {
    112     PS_OVERSCAN_FIT_NONE,               ///< No fit to bias
    113     PS_OVERSCAN_FIT_LINEAR,             ///< Do linear interpolation on bias
    114     PS_OVERSCAN_FIT_POLYNOMIAL,         ///< Fit polynomial to bias
    115     PS_OVERSCAN_FIT_CHEBYSHEV,          ///< Fit chebyshev to bias
    116     PS_OVERSCAN_FIT_SPLINE              ///< Fit cubic splines to bias
    117 } psBiasFit;
     112    PS_FIT_NONE,                        ///< No fit
     113    PS_FIT_LINEAR,                      ///< Do linear interpolation
     114    PS_FIT_POLYNOMIAL,                  ///< Fit polynomial
     115    PS_FIT_CHEBYSHEV,                   ///< Fit chebyshev
     116    PS_FIT_SPLINE                       ///< Fit cubic splines
     117} psFit;
    118118
    119119/** Subtracts an overscan and bias from the input image. */
     
    122122                                               ///< Also outputted
    123123                                psOverscanAxis overscanAxis, ///< Overscan axis
    124                                 psBiasFit fit, ///< How to fit the bias
     124                                psFit fit, ///< How to fit the bias
    125125                                int nBin, ///< Number of bins for overscan vector before fitting
    126126                                const psList *regions, ///< Linked list of psImageRegion types.
     
    139139
    140140
    141 /** Applies the correction for detector non-linearity.  Non-linearity coefficients are determined from the
    142  *  image metadata.
     141/** Applies the correction for detector non-linearity.  Non-linearity coefficients are provided by the caller.
     142 *  Two functions: one to do via a polynomial, the other via a lookup table.
    143143 */
    144 psReadout *psPhase2CorrectNonLinearity(psReadout *in, ///< Input image to be corrected, and output
    145                                        const psPolynomial1D *coeff ///< Polynomial with which to correct
    146                                        );
     144psReadout *psPhase2NonLinearityPolynomial(psReadout *in, ///< Input image to be corrected, and output
     145                                          const psPolynomial1D *coeff ///< Polynomial with which to correct
     146                                          );
     147
     148psReadout *psPhase2NonLinearityLookup(psReadout *in, ///< Input image to be corrected, and output
     149                                      const psVector *inFlux, ///< Input flux values
     150                                      const psVector *outFlux ///< Output flux values
     151                                      );
    147152
    148153/** Flat-fields the image. */
     
    151156                             );
    152157
    153 /** Subtracts the sky background. */
     158/** Simple sky subtraction */
    154159psReadout *psPhase2SubtractSky(psReadout *in, ///< Input image to be sky-subtracted, and output
    155                                psPolynomial2D *poly, ///< Polynomial specification, returns coeffcients
    156                                psVector *outNorms, ///< Normalisations of the template sky images: output
    157                                const psList *skyImages, ///< Template sky images: a list of type psImage, or
    158                                                         ///< NULL
    159                                const psList *catalog, ///< Sources nearby to mask when measuring the
    160                                                       ///< background: a list of type psObject, or NULL
    161                                float radiusMultiply, ///< Multiplying factor of object radius for mask
    162                                float radiusAdd, ///< Additive factor to grow the object masks
    163                                int binFactor ///< Binning factor to use on image before solving for polynomial
     160                               void *fitSpec, ///< Polynomial/Spline specification, returns coeffcients
     161                               psFit fit, ///< Fit type
     162                               int binFactor, ///< Binning factor to use on image before solving for polynomial
     163                               psStats *stats, ///< Statistics to use in binning
     164                               float clipSD ///< Standard deviations to clip at after binning.
    164165                               );
    165166
     
    168169/* Masking */
    169170
     171/** Mask values */
     172typedef enum {
     173    PS_MASK_TRAP,                       ///< The pixel is a charge trap
     174    PS_MASK_BADCOL,                     ///< The pixel is a bad column
     175    PS_MASK_SAT,                        ///< The pixel is saturated
     176    PS_MASK_FLAT,                       ///< The pixel is non-positive in the flat-field
     177    PS_MASK_CR_MORPH                    ///< The pixel is determined to be a cosmic ray, from morphology
     178} psMaskValue;
     179
    170180/** Returns an image that has the bad pixels masked.  Also masks saturated pixels */
    171 psReadout *psPhase2MaskBadPixels(psReadout *in ///< Image to be masked, and output
     181psReadout *psPhase2MaskBadPixels(psReadout *in, ///< Image to be masked, and output
    172182                                 const psImage *mask, ///< Bad pixel mask to apply
    173183                                 int maskVal, ///< Mask the pixels for which mask & maskVal > 0.
  • trunk/doc/modules/ModulesSDRS.tex

    r1110 r1113  
    1 %%% $Id: ModulesSDRS.tex,v 1.4 2004-06-26 03:42:48 price Exp $
     1%%% $Id: ModulesSDRS.tex,v 1.5 2004-06-29 01:44:23 price Exp $
    22\documentclass[panstarrs]{panstarrs}
    33
     
    294294
    295295\subsection{Bias subtraction}
     296\label{sec:bias}
    296297
    297298Given an input image and various other parameters,
     
    299300The API shall be the following:
    300301\begin{verbatim}
    301 psReadout *psPhase2SubtractBias(psReadout *in, void *fitSpec, psOverscanAxis overscanAxis, psBiasFit fit,
     302psReadout *psPhase2SubtractBias(psReadout *in, void *fitSpec, psOverscanAxis overscanAxis, psFit fit,
    302303                                int nBin, const psList *regions, const psStats *stat, const psImage *bias);
    303304\end{verbatim}
     
    310311
    311312\begin{verbatim}
    312 /** Fit type for bias */
     313/** Fit type */
    313314typedef enum {
    314     PS_OVERSCAN_FIT_NONE,               ///< No fit to bias
    315     PS_OVERSCAN_FIT_LINEAR,             ///< Do linear interpolation on bias
    316     PS_OVERSCAN_FIT_POLYNOMIAL,         ///< Fit polynomial to bias
    317     PS_OVERSCAN_FIT_CHEBYSHEV,          ///< Fit chebyshev to bias
    318     PS_OVERSCAN_FIT_SPLINE              ///< Fit cubic splines to bias
    319 } psBiasFit;
    320 \end{verbatim}
    321 
    322 If \code{fitSpec} is \code{NULL}, or \code{fit} is
    323 \code{PS_OVERSCAN_FIT_NONE}, then no fit shall be performed to the
    324 overscan.  If \code{fit} is \code{PS_OVERSCAN_FIT_LINEAR}, then the
    325 function shall perform simple linear interpolation between points in
    326 the overscan.  Otherwise, \code{fitSpec} shall be interpreted to be a
    327 structure of the appropriate type (\code{psPolynomial1D} for
    328 \code{PS_OVERSCAN_FIT_POLYNOMIAL} and
    329 \code{PS_OVERSCAN_FIT_CHEBYSHEV}, and \code{psSpline1D} for
    330 \code{PS_OVERSCAN_FIT_SPLINE}), and the overscan shall be fit using
    331 the specified functional form.  Upon return, the \code{fitSpec} shall
     315    PS_FIT_NONE,                ///< No fit
     316    PS_FIT_LINEAR,              ///< Do linear interpolation
     317    PS_FIT_POLYNOMIAL,          ///< Fit polynomial
     318    PS_FIT_CHEBYSHEV,           ///< Fit chebyshev
     319    PS_FIT_SPLINE               ///< Fit cubic splines
     320} psFit;
     321\end{verbatim}
     322
     323If \code{fitSpec} is \code{NULL}, or \code{fit} is \code{PS_FIT_NONE},
     324then no fit shall be performed to the overscan.  If \code{fit} is
     325\code{PS_FIT_LINEAR}, then the function shall perform simple linear
     326interpolation between points in the overscan.  Otherwise,
     327\code{fitSpec} shall be interpreted to be a structure of the
     328appropriate type (\code{psPolynomial1D} for \code{PS_FIT_POLYNOMIAL}
     329and \code{PS_FIT_CHEBYSHEV}, and \code{psSpline1D} for
     330\code{PS_FIT_SPLINE}), and the overscan shall be fit using the
     331specified functional form.  Upon return, the \code{fitSpec} shall
    332332contain the coefficients of the overscan fit.
    333333
     
    351351warning shall be generated if the \code{overscanAxis} is
    352352\code{PS_OVERSCAN_NONE} or \code{PS_OVERSCAN_ALL} and the \code{fit}
    353 is not \code{PS_OVERSCAN_FIT_NONE}.
     353is not \code{PS_FIT_NONE}.
    354354
    355355If the \code{overscanAxis} is \code{PS_OVERSCAN_ROWS} or
     
    361361If the overscan is not defined for each row/column, then the function
    362362shall generate a warning and then interpolate using the provided
    363 functional form if \code{fit} is not \code{PS_OVERSCAN_FIT_NONE};
     363functional form if \code{fit} is not \code{PS_FIT_NONE};
    364364otherwise, the function shall generate an error.
    365365
     
    484484\subsection{Subtract sky}
    485485
    486 Given an input image, a polynomial specifying the order of a desired
    487 fit, a list of template background images, a list of catalog stars on
    488 or near the chip, and parameters specifying how to grow the radius of
    489 the objects, and the binning factor, \code{psPhase2SubtractSky} shall
    490 fit and subtract the background of the image.  The API shall be the
    491 following:
    492 \begin{verbatim}
    493 /** Subtracts the sky background. */
     486\tbd{This is a simply sky subtraction routine.  A more complicated
     487routine will be specified in the future, following research into the
     488best algorithm.}
     489
     490Given an input image, a polynomial or spline specifying the order of a
     491desired fit, a binning factor and statistics to use for the binning,
     492along with a clipping level, \code{psPhase2SubtractSky} shall fit and
     493subtract a model for the background of the image.  The API shall be
     494the following:
     495\begin{verbatim}
     496/** Simple sky subtraction */
    494497psReadout *psPhase2SubtractSky(psReadout *in, ///< Input image to be sky-subtracted, and output
    495                                psPolynomial2D *poly, ///< Polynomial specification, returns coeffcients
    496                                psVector *outNorms, ///< Normalisations of the template sky images: output
    497                                const psList *skyImages, ///< Template sky images: a list of type psImage, or
    498                                                         ///< NULL
    499                                const psList *catalog, ///< Sources nearby to mask when measuring the
    500                                                       ///< background: a list of type psObject, or NULL
    501                                float radiusMultiply, ///< Multiplying factor of object radius for mask
    502                                float radiusAdd, ///< Additive factor to grow the object masks
    503                                int binFactor ///< Binning factor to use on image before solving for polynomial
    504                                );
    505 \end{verbatim}
    506 
    507 The polynomial specification, \code{poly}, specifies the order of the
    508 polynomial to be used in fitting the background.  Note that the input
    509 image, \code{in}, shall be subtracted in-place.  The function shall
    510 return the subtracted image, and also update the polynomial,
    511 \code{poly}, to hold the polynomial coefficients used in the
    512 subtraction, and update the vector \code{outNorms} to hold the
    513 normalisations of each of the template background images used in the
    514 subtraction.  The \code{outNorms} vector shall be resized if necessary
    515 to match the number of template sky images in the list
    516 \code{skyImages}.  If the polynomial specification is \code{NULL}, then
    517 no polynomial shall be fit to the input image.
    518 
    519 Note that the input image, \code{in}, and the template sky images,
    520 \code{skyImages}, need not be the same size, since the input image may
    521 already have been trimmed (following overscan subtraction), but the
    522 function shall use the offsets in the image (\code{in->x0} and
    523 \code{in->y0}) to determine the appropriate offsets to obtain the
    524 correct pixels.  In the event that one (or more) of the
    525 \code{skyImages} is too small (i.e., pixels on the input image refer
    526 to pixels outside the range of the \code{skyImages} image), the
    527 function shall generate an error.
    528 
    529 The \code{catalog} shall be a linked list of \code{psObject} which
    530 corresponds to objects on the input image.  If the size of a source in
    531 the \code{catalog} is \code{size}, then the radius to mask around the
    532 source before fitting the background shall be \code{radiusMultiply}
    533 $\times$ \code{size} + \code{radiusAdd}.
    534 
    535 \tbd{Are the catalog stars in celestial or pixel coordinates?  I lean
    536 to pixel coordinates.}
    537 
    538 \tbd{What size do we use?  FWHM?}
    539 
    540 When fitting a polynomial, the function shall bin the input image by
    541 \code{binFactor} in order to reduce the required processing time.
    542 
    543 \code{poly} may be \code{NULL} in order to specify that only the
    544 template sky images should be used in the fitting, and no polynomial
    545 terms.  \code{outNorms} may be \code{NULL} if the caller is not
    546 interested in the normalisations.  \code{skyImages} may be \code{NULL}
    547 in order to specify that there are no input sky template images.
    548 \code{catalog} may be \code{NULL} in order to specify that there are
    549 no objects to mask.  If both \code{poly} and \code{skyImages} are
    550 \code{NULL}, then the function shall simply return the input image
    551 with no processing.
     498                               void *fitSpec, ///< Polynomial/Spline specification, returns coeffcients
     499                               psFit fit, ///< Fit type
     500                               int binFactor, ///< Binning factor to use on image before solving for polynomial
     501                               psStats *stats, ///< Statistics to use in binning
     502                               float clipSD ///< Standard deviations to clip at after binning.
     503                               );
     504\end{verbatim}
     505
     506Note that the input image, \code{in}, shall be subtracted in-place.
     507The function shall return the subtracted image, and also update the
     508polynomial, chebyshev or spline specified by \code{fitSpec}, to hold
     509the coefficients used in the subtraction.
     510
     511The fit specification, \code{fitSpec}, specifies the order of the
     512polynomial or spline to be used in fitting the background.
     513\code{fitSpec} shall be interpreted as a polynomial, Chebyshev or
     514spline on the basis of \code{fit} (in the same manner as for bias
     515subtraction; \S\ref{sec:bias}).  If \code{fitSpec} is \code{NULL} or
     516\code{fit} is \code{PS_FIT_NONE}, then no fit shall be performed, and
     517the function shall simply return.
     518
     519When fitting the polynomial, the function shall first bin the input
     520image by \code{binFactor} in order to reduce the required processing
     521time.  The statistic to use in this binning is specified by
     522\code{stat}.  \code{stat} is of type \code{psStats} instead of simply
     523\code{psStatsOptions} so that clipping levels may be specified, if
     524desired.  In the event that multiple options are specified by
     525\code{stats}, a warning shall be generated, and the option with the
     526highest priority shall be used, according to the following priority
     527order: \code{PS_STAT_SAMPLE_MEAN}, \code{PS_STAT_SAMPLE_MEDIAN},
     528\code{PS_STAT_CLIPPED_MEAN}, \code{PS_STAT_ROBUST_MEAN},\
     529\code{PS_STAT_ROBUST_MEDIAN}, \code{PS_STAT_ROBUST_MODE}.  If the
     530\code{binFactor} is non-positive, or \code{stats} is \code{NULL} or
     531fails to specify an option, a warning shall be generated, and the fit
     532shall be performed on the entire image.
     533
     534Binned pixels deviating more than \code{clipSD} standard deviations
     535from the mean of the binned pixels shall be clipped in a single
     536clipping iteration.  If the \code{clipSD} is non-positive, then the
     537function shall generate a warning and not perform any clipping.
     538
    552539
    553540%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracChangeset for help on using the changeset viewer.