IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13898


Ignore:
Timestamp:
Jun 19, 2007, 4:22:26 PM (19 years ago)
Author:
Paul Price
Message:

Extensive changes to APIs to allow use of a nominated value to mask
against (the maskVal). Previously, the mask values were either
hard-coded (e.g., PM_MASK_SAT) or taken as anything non-zero. The
code is tested under psphot (which has similar changes) and does not
crash, but neither is it successful in marking all bad pixels (EAM
will investigate). For this reason, I have left the "gutter" pixels
(cell gaps) set to 0 instead of NAN in pmFPAMosaic.

Location:
trunk/psModules/src
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/Makefile.am

    r13810 r13898  
    2626        pmFPALevel.c \
    2727        pmFPAExtent.c \
    28         pmCellSquish.c
     28        pmCellSquish.c \
     29        pmReadoutStack.c
    2930
    3031pkginclude_HEADERS = \
     
    5152        pmFPALevel.h \
    5253        pmFPAExtent.h \
    53         pmCellSquish.h
     54        pmCellSquish.h \
     55        pmReadoutStack.h
    5456
    5557CLEANFILES = *~
  • trunk/psModules/src/camera/pmFPAMosaic.c

    r13499 r13898  
    2222
    2323#define CELL_LIST_BUFFER 10             // Buffer size for cell lists
     24
     25#define BLANK_VALUE 0.0                 // Value for pixels that are blank in the mosaicked image (e.g., //
     26                                        // between cells).
     27                                        // XXX This should ultimately be set to NAN, but psphot doesn't like
     28                                        // that (masking needs to be more thorough).
    2429
    2530//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    397402                    for (int x = 0; x < image->numCols; x++) { \
    398403                        int xTarget = xTargetBase + xParity * x; \
    399                         mosaic->data.TYPE[yTarget][xTarget] += image->data.TYPE[y][x]; \
     404                        mosaic->data.TYPE[yTarget][xTarget] = image->data.TYPE[y][x]; \
    400405                    } \
    401406                } \
     
    416421                        for (int k = 0; k < xBinSource->data.S32[i]; k++) { \
    417422                            int xTarget = (int)(xTargetBinBase + xParity * (float)k / (float)xBinTarget); \
    418                             mosaic->data.TYPE[yTarget][xTarget] += image->data.TYPE[y][x]; \
     423                            mosaic->data.TYPE[yTarget][xTarget] = image->data.TYPE[y][x]; \
    419424                        } \
    420425                    } \
     
    504509    psTrace("psModules.camera", 3, "Spliced image will be %dx%d\n", (int)xSize, (int)ySize);
    505510    psImage *mosaic = psImageAlloc((int)xSize, (int)ySize, type); // The mosaic image
    506     psImageInit(mosaic, 0);
     511    psImageInit(mosaic, unexposed);
    507512
    508513    // Next pass through the images to do the mosaicking
     
    524529            (yFlip->data.U8[i] == 0)) {
    525530            // Let someone else do the hard work
    526             psImageOverlaySection(mosaic, image, xTargetBase, yTargetBase, "+");
     531            psImageOverlaySection(mosaic, image, xTargetBase, yTargetBase, "=");
    527532            continue;
    528533        }
     
    723728                       int *xBinChip, int *yBinChip, // The binning in x and y, to be returned
    724729                       const pmChip *chip, // Chip to mosaic
    725                        const pmCell *targetCell // Cell to which to mosaic
     730                       const pmCell *targetCell, // Cell to which to mosaic
     731                       psMaskType blank // Mask value to give blank pixels
    726732                      )
    727733{
     
    804810    // Mosaic the images together and we're done
    805811    if (allGood) {
    806         *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, NAN);
    807         *mosaicWeights = imageMosaic(weights, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, NAN);
    808         *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, 0xff);
     812        *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE);
     813        *mosaicWeights = imageMosaic(weights, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE);
     814        *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, blank);
    809815    }
    810816
     
    830836                      const pmFPA *fpa,  // FPA to mosaic
    831837                      const pmChip *targetChip, // Chip to which to mosaic
    832                       const pmCell *targetCell // Cell to which to mosaic
     838                      const pmCell *targetCell, // Cell to which to mosaic
     839                      psMaskType blank  // Mask value to give blank pixels
    833840                     )
    834841{
     
    937944    // Mosaic the images together and we're done
    938945    if (allGood) {
    939         *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, NAN);
    940         *mosaicWeights = imageMosaic(weights, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, NAN);
    941         *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, 0xff);
     946        *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE);
     947        *mosaicWeights = imageMosaic(weights, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE);
     948        *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, blank);
    942949    }
    943950
     
    986993// the mosaic image.
    987994
    988 bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy)
     995bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy, psMaskType blank)
    989996{
    990997    // Target exists, and has only a single cell
     
    10391046        // Case 2 --- we need to mosaic by cut and paste
    10401047        psTrace("psModules.camera", 1, "Case 2 mosaicking: cut and paste.\n");
    1041         if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source, targetCell)) {
     1048        if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source, targetCell, blank)) {
    10421049            psError(PS_ERR_UNKNOWN, false, "Unable to mosaic cells.\n");
    10431050            return false;
     
    12171224
    12181225
    1219 bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy)
     1226bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy, psMaskType blank)
    12201227{
    12211228    // Target exists, and has only a single chip with single cell
     
    12601267        psTrace("psModules.camera", 1, "Case 2 mosaicking: cut and paste.\n");
    12611268        if (!fpaMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source,
    1262                        targetChip, targetCell)) {
     1269                       targetChip, targetCell, blank)) {
    12631270            psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chips.\n");
    12641271            return false;
  • trunk/psModules/src/camera/pmFPAMosaic.h

    r12696 r13898  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-03-30 21:12:56 $
     6 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-06-20 02:22:26 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    2222/// the pixels, if possible.
    2323bool pmChipMosaic(pmChip *target,       ///< Target chip --- may contain only a single cell
    24                   const pmChip *source,  ///< Source chip whose cells will be mosaicked
    25                   bool deepCopy         ///< require a deep copy (disregard 'nice' chip)
     24                  const pmChip *source, ///< Source chip whose cells will be mosaicked
     25                  bool deepCopy,        ///< Require a deep copy (disregard 'nice' chip)
     26                  psMaskType blank      ///< Mask value to give blank pixels
    2627    );
    2728
     
    3233/// CELL.X0 and CELL.Y0 offsets.  This is useful for getting an image of the FPA on the sky.  The mosaicking
    3334/// is done so as to avoid performing a deep copy of the pixels, if possible.
    34 bool pmFPAMosaic(pmFPA *target, ///< Target FPA --- may contain only a single chip with a single cell
    35                  const pmFPA *source,   ///< FPA whose chips and cells will be mosaicked
    36                  bool deepCopy          ///< require a deep copy (disregard 'nice' chip)
    37                 );                      //
     35bool pmFPAMosaic(pmFPA *target, ///< Target FPA --- may contain only a single chip with a single cell
     36                 const pmFPA *source,   ///< FPA whose chips and cells will be mosaicked
     37                 bool deepCopy,         ///< Require a deep copy (disregard 'nice' chip)
     38                 psMaskType blank       ///< Mask value to give blank pixels
     39                );
    3840/// @}
    3941#endif
  • trunk/psModules/src/objects/pmModel.c

    r13803 r13898  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-06-13 23:41:51 $
     8 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-06-20 02:22:26 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6060    tmp->radiusFit = 0;
    6161    tmp->flags = PM_MODEL_STATUS_NONE;
    62     tmp->residuals = NULL;              // XXX should the model own this memory?
     62    tmp->residuals = NULL;              // XXX should the model own this memory?
    6363
    6464    psS32 Nparams = pmModelParameterCount(type);
     
    105105/******************************************************************************
    106106    pmModelEval(source, level, row): evaluates the model function at the specified coords.
    107  
     107
    108108    NOTE: The coords are in subImage source->pixel coords, not image coords.
    109  
     109
    110110    XXX: Use static vectors for x (NO: needs to be thread safe)
    111111*****************************************************************************/
     
    132132}
    133133
    134 bool AddOrSubModel(psImage *image,
    135                    psImage *mask,
    136                    pmModel *model,
    137                    pmModelOpMode mode,
    138                    bool add
    139                       )
     134static bool AddOrSubModel(psImage *image,
     135                          psImage *mask,
     136                          pmModel *model,
     137                          pmModelOpMode mode,
     138                          bool add,
     139                          psMaskType maskVal
     140    )
    140141{
    141142    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     
    151152    psS32 imageRow;
    152153    psF32 pixelValue;
    153    
     154
    154155    // save original values; restore before returning
    155156    // use the true source position for the residual model
     
    161162
    162163    if (mode & PM_MODEL_OP_NORM) {
    163         params->data.F32[PM_PAR_I0] = 1.0;
     164        params->data.F32[PM_PAR_I0] = 1.0;
    164165    }
    165166    if (!(mode & PM_MODEL_OP_SKY)) {
    166         params->data.F32[PM_PAR_SKY] = 0.0;
     167        params->data.F32[PM_PAR_SKY] = 0.0;
    167168    }
    168169    if (mode & PM_MODEL_OP_CENTER) {
    169         params->data.F32[PM_PAR_XPOS] = image->col0 + 0.5*image->numCols;
    170         params->data.F32[PM_PAR_YPOS] = image->row0 + 0.5*image->numRows;
     170        params->data.F32[PM_PAR_XPOS] = image->col0 + 0.5*image->numCols;
     171        params->data.F32[PM_PAR_YPOS] = image->row0 + 0.5*image->numRows;
    171172    }
    172173
     
    185186    psImageInterpolateOptions *Ry = NULL;
    186187    if (model->residuals && (mode & (PM_MODEL_OP_RES0 | PM_MODEL_OP_RES1))) {
    187         Ro = psImageInterpolateOptionsAlloc(
    188             PS_INTERPOLATE_BILINEAR,
    189             model->residuals->Ro, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
    190         Rx = psImageInterpolateOptionsAlloc(
    191             PS_INTERPOLATE_BILINEAR,
    192             model->residuals->Rx, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
    193         Ry = psImageInterpolateOptionsAlloc(
    194             PS_INTERPOLATE_BILINEAR,
    195             model->residuals->Ry, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
    196 
    197         xBin = model->residuals->xBin;
    198         yBin = model->residuals->yBin;
    199         xResidCenter = model->residuals->xCenter;
    200         yResidCenter = model->residuals->yCenter;
     188        Ro = psImageInterpolateOptionsAlloc(
     189            PS_INTERPOLATE_BILINEAR,
     190            model->residuals->Ro, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
     191        Rx = psImageInterpolateOptionsAlloc(
     192            PS_INTERPOLATE_BILINEAR,
     193            model->residuals->Rx, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
     194        Ry = psImageInterpolateOptionsAlloc(
     195            PS_INTERPOLATE_BILINEAR,
     196            model->residuals->Ry, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
     197
     198        xBin = model->residuals->xBin;
     199        yBin = model->residuals->yBin;
     200        xResidCenter = model->residuals->xCenter;
     201        yResidCenter = model->residuals->yCenter;
    201202    }
    202203
    203204    for (psS32 iy = 0; iy < image->numRows; iy++) {
    204205        for (psS32 ix = 0; ix < image->numCols; ix++) {
    205             if ((mask != NULL) && mask->data.U8[iy][ix])
     206            if ((mask != NULL) && (mask->data.U8[iy][ix] & maskVal))
    206207                continue;
    207208
    208209            // Convert i/j to image coord space:
    209             // XXX should we use using 0.5 pixel offset?
    210             imageCol = ix + image->col0;
    211             imageRow = iy + image->row0;
     210            // XXX should we use using 0.5 pixel offset?
     211            imageCol = ix + image->col0;
     212            imageRow = iy + image->row0;
    212213
    213214            x->data.F32[0] = (float) imageCol;
    214215            x->data.F32[1] = (float) imageRow;
    215216
    216             pixelValue = 0.0;
     217            pixelValue = 0.0;
    217218
    218219            // add in the desired components for this coordinate
    219220            if (mode & PM_MODEL_OP_FUNC) {
    220221                pixelValue += modelFunc (NULL, params, x);
    221             } 
    222 
    223             // get the contribution from the residual model
    224             if (Ro) {
    225                 // fractional image position
    226                 float ox = xBin*(imageCol + 0.5 - xCenter) + xResidCenter;
    227                 float oy = yBin*(imageRow + 0.5 - yCenter) + yResidCenter;
    228 
    229                 if (mode & PM_MODEL_OP_RES0) {
    230                     psU8 mflux = 0;
    231                     double Fo = 0.0;
    232                     psImageInterpolate (&Fo, NULL, &mflux, ox, oy, Ro);
    233                     if (!mflux && isfinite(Fo)) {
    234                         pixelValue += Io*Fo;
    235                     }
    236                 }
    237                 if (mode & PM_MODEL_OP_RES1) {
    238                     psU8 mflux = 0;
    239                     double Fx = 0.0;
    240                     double Fy = 0.0;
    241                     psImageInterpolate (&Fx, NULL, &mflux, ox, oy, Rx);
    242                     psImageInterpolate (&Fy, NULL, &mflux, ox, oy, Ry);
    243                     if (!mflux && isfinite(Fx) && isfinite(Fy)) {
    244                         pixelValue += Io*(xPos*Fx + yPos*Fy);
    245                     }
    246                 }
    247             }
     222            }
     223
     224            // get the contribution from the residual model
     225            if (Ro) {
     226                // fractional image position
     227                float ox = xBin*(imageCol + 0.5 - xCenter) + xResidCenter;
     228                float oy = yBin*(imageRow + 0.5 - yCenter) + yResidCenter;
     229
     230                if (mode & PM_MODEL_OP_RES0) {
     231                    psU8 mflux = 0;
     232                    double Fo = 0.0;
     233                    psImageInterpolate (&Fo, NULL, &mflux, ox, oy, Ro);
     234                    if (!mflux && isfinite(Fo)) {
     235                        pixelValue += Io*Fo;
     236                    }
     237                }
     238                if (mode & PM_MODEL_OP_RES1) {
     239                    psU8 mflux = 0;
     240                    double Fx = 0.0;
     241                    double Fy = 0.0;
     242                    psImageInterpolate (&Fx, NULL, &mflux, ox, oy, Rx);
     243                    psImageInterpolate (&Fy, NULL, &mflux, ox, oy, Ry);
     244                    if (!mflux && isfinite(Fx) && isfinite(Fy)) {
     245                        pixelValue += Io*(xPos*Fx + yPos*Fy);
     246                    }
     247                }
     248            }
    248249
    249250            // add or subtract the value
     
    275276                psImage *mask,
    276277                pmModel *model,
    277                 pmModelOpMode mode)
    278 {
    279     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
    280     psBool rc = AddOrSubModel(image, mask, model, mode, true);
     278                pmModelOpMode mode,
     279                psMaskType maskVal)
     280{
     281    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     282    psBool rc = AddOrSubModel(image, mask, model, mode, true, maskVal);
    281283    psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);
    282284    return(rc);
     
    288290                psImage *mask,
    289291                pmModel *model,
    290                 pmModelOpMode mode)
    291 {
    292     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
    293     psBool rc = AddOrSubModel(image, mask, model, mode, false);
     292                pmModelOpMode mode,
     293                psMaskType maskVal)
     294{
     295    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     296    psBool rc = AddOrSubModel(image, mask, model, mode, false, maskVal);
    294297    psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);
    295298    return(rc);
  • trunk/psModules/src/objects/pmModel.h

    r13803 r13898  
    55 * @author EAM, IfA
    66 *
    7  * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-06-13 23:41:51 $
     7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2007-06-20 02:22:26 $
    99 *
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3030
    3131typedef enum {
    32     PM_MODEL_OP_NONE    = 0x00,
    33     PM_MODEL_OP_FUNC    = 0x01,
    34     PM_MODEL_OP_RES0    = 0x02,
    35     PM_MODEL_OP_RES1    = 0x04,
     32    PM_MODEL_OP_NONE    = 0x00,
     33    PM_MODEL_OP_FUNC    = 0x01,
     34    PM_MODEL_OP_RES0    = 0x02,
     35    PM_MODEL_OP_RES1    = 0x04,
    3636    PM_MODEL_OP_FULL    = 0x07,
    37     PM_MODEL_OP_SKY     = 0x08,
     37    PM_MODEL_OP_SKY     = 0x08,
    3838    PM_MODEL_OP_CENTER  = 0x10,
    39     PM_MODEL_OP_NORM    = 0x20,
    40     PM_MODEL_OP_NOISE   = 0x40,
     39    PM_MODEL_OP_NORM    = 0x20,
     40    PM_MODEL_OP_NOISE   = 0x40,
    4141} pmModelOpMode;
    4242
     
    5252typedef struct
    5353{
    54     pmModelType type;                   ///< Model to be used.
    55     psVector *params;                   ///< Paramater values.
    56     psVector *dparams;                  ///< Parameter errors.
    57     float chisq;                        ///< Fit chi-squared.
    58     float chisqNorm;                    ///< re-normalized fit chi-squared.
    59     int nDOF;                           ///< number of degrees of freedom
    60     int nIter;                          ///< number of iterations to reach min
    61     pmModelStatus flags;                ///< model status flags
    62     float radiusFit;                    ///< fit radius actually used
    63     pmResiduals *residuals;             ///< normalized PSF residuals
     54    pmModelType type;                   ///< Model to be used.
     55    psVector *params;                   ///< Paramater values.
     56    psVector *dparams;                  ///< Parameter errors.
     57    float chisq;                        ///< Fit chi-squared.
     58    float chisqNorm;                    ///< re-normalized fit chi-squared.
     59    int nDOF;                           ///< number of degrees of freedom
     60    int nIter;                          ///< number of iterations to reach min
     61    pmModelStatus flags;                ///< model status flags
     62    float radiusFit;                    ///< fit radius actually used
     63    pmResiduals *residuals;             ///< normalized PSF residuals
    6464}
    6565pmModel;
     
    105105 */
    106106bool pmModelAdd(
    107     psImage *image,                     ///< The output image (float)
    108     psImage *mask,                      ///< The image pixel mask (valid == 0)
    109     pmModel *model,                     ///< The input pmModel
    110     pmModelOpMode mode               ///< mode to control how the model is added into the image
     107    psImage *image,                     ///< The output image (float)
     108    psImage *mask,                      ///< The image pixel mask (valid == 0)
     109    pmModel *model,                     ///< The input pmModel
     110    pmModelOpMode mode,                 ///< mode to control how the model is added into the image
     111    psMaskType maskVal                  ///< Value to mask
    111112);
    112113
     
    122123 */
    123124bool pmModelSub(
    124     psImage *image,                     ///< The output image (float)
    125     psImage *mask,                      ///< The image pixel mask (valid == 0)
    126     pmModel *model,                     ///< The input pmModel
    127     pmModelOpMode mode               ///< mode to control how the model is added into the image
     125    psImage *image,                     ///< The output image (float)
     126    psImage *mask,                      ///< The image pixel mask (valid == 0)
     127    pmModel *model,                     ///< The input pmModel
     128    pmModelOpMode mode,                 ///< mode to control how the model is added into the image
     129    psMaskType maskVal                  ///< Value to mask
    128130);
    129131
  • trunk/psModules/src/objects/pmPSF.c

    r13803 r13898  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-06-13 23:41:51 $
     8 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-06-20 02:22:26 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8181/*****************************************************************************
    8282 pmPSFAlloc (type): allocate a pmPSF.
    83  
     83
    8484 NOTE: PSF model parameters which are not modeled on an image are set to NULL in psf->params.
    85  
     85
    8686 These are normally:
    87  
     87
    8888 X-center
    8989 Y-center
     
    180180    // set model parameters for this source based on PSF information
    181181    if (!modelFromPSFFunc (modelPSF, modelEXT, psf)) {
    182         psError(PM_ERR_PSF, false, "Failed to set model params from PSF");
    183         psFree(modelPSF);
    184         return NULL;
     182        psError(PM_ERR_PSF, false, "Failed to set model params from PSF");
     183        psFree(modelPSF);
     184        return NULL;
    185185    }
    186186    // XXX note that model->residuals is just a reference
     
    245245// New Concept: the PSF modelling function fits the polarization terms e0, e1, e2:
    246246
    247 // convert the parameters used in the fitted source model 
     247// convert the parameters used in the fitted source model
    248248// to the parameters used in the 2D PSF model
    249249bool pmPSF_FitToModel (psF32 *fittedPar, float minMinorAxis)
     
    257257    psEllipseAxes axes;
    258258    if (psEllipsePolToAxes (pol, minMinorAxis, &axes) != PS_ERR_NONE) {
    259         psError(PM_ERR_PSF, false, "Failed to convert e[012] (%g,%g,%g) to axes",
    260                 pol.e0, pol.e1, pol.e2);
    261         return false;
     259        psError(PM_ERR_PSF, false, "Failed to convert e[012] (%g,%g,%g) to axes",
     260                pol.e0, pol.e1, pol.e2);
     261        return false;
    262262    }
    263263    psEllipseShape shape = psEllipseAxesToShape (axes);
     
    279279    shape.sy  = modelPar[PM_PAR_SYY] / M_SQRT2;
    280280    shape.sxy = modelPar[PM_PAR_SXY];
    281    
     281
    282282    psEllipsePol pol = psEllipseShapeToPol (shape);
    283    
     283
    284284    return pol;
    285285}
     
    297297
    298298    if ((shape.sx == 0) || (shape.sy == 0)) {
    299         axes.major = 0.0;
    300         axes.minor = 0.0;
    301         axes.theta = 0.0;
     299        axes.major = 0.0;
     300        axes.minor = 0.0;
     301        axes.theta = 0.0;
    302302    } else {
    303         // XXX this is not really consistent with the model fit range above
    304         axes = psEllipseShapeToAxes (shape, maxAR);
    305     }
    306    
     303        // XXX this is not really consistent with the model fit range above
     304        axes = psEllipseShapeToAxes (shape, maxAR);
     305    }
     306
    307307    return axes;
    308308}
     
    313313{
    314314    if ((axes.major <= 0) || (axes.minor <= 0)) {
    315         modelPar[PM_PAR_SXX] = 0.0;
    316         modelPar[PM_PAR_SYY] = 0.0;
    317         modelPar[PM_PAR_SXY] = 0.0;
    318         return true;
    319     }   
    320    
     315        modelPar[PM_PAR_SXX] = 0.0;
     316        modelPar[PM_PAR_SYY] = 0.0;
     317        modelPar[PM_PAR_SXY] = 0.0;
     318        return true;
     319    }
     320
    321321    psEllipseShape shape = psEllipseAxesToShape (axes);
    322322
     
    478478
    479479// we generate the growth curve for the center of the image with the specified psf model
    480 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore)
     480bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType mark)
    481481{
    482482
     
    526526    // no need to mask the source here
    527527    // XXX should we measure this for the analytical model only or the full model?
    528     pmModelAdd (image, NULL, model, PM_MODEL_OP_FULL);
     528    pmModelAdd (image, NULL, model, PM_MODEL_OP_FULL, maskVal);
    529529
    530530    // loop over a range of source fluxes
    531531    // no need to interpolate since we have forced the object center
    532532    // to 0.5, 0.5 above
    533     bool completeGrowthCurve = true;            // do we have a complete curve of growth?
     533    bool completeGrowthCurve = true;            // do we have a complete curve of growth?
    534534    for (int i = 0; i < psf->growth->radius->n; i++) {
    535535
     
    537537
    538538        // mask the given aperture and measure the apMag
    539         psImageKeepCircle (mask, xc, yc, radius, "OR", PM_MASK_MARK);
    540         if (!pmSourcePhotometryAper (&apMag, model, image, mask)) {
    541             psError(PM_ERR_PHOTOM, false, "Measuring apMag for radius == %g", radius);
    542             completeGrowthCurve = false;
    543             break;
    544         }
    545 
    546         // XXX since we re-mask on each pass, this could be dropped.
    547         psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_U8(PM_MASK_MARK));
     539        psImageKeepCircle (mask, xc, yc, radius, "OR", mark);
     540        if (!pmSourcePhotometryAper (&apMag, model, image, mask, maskVal)) {
     541            psError(PM_ERR_PHOTOM, false, "Measuring apMag for radius == %g", radius);
     542            completeGrowthCurve = false;
     543            break;
     544        }
     545
     546        // XXX since we re-mask on each pass, this could be dropped.
     547        psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_U8(mark));
    548548
    549549        // the 'ignore' mode is for testing
     
    556556
    557557    if (completeGrowthCurve) {
    558         psf->growth->apRef = psVectorInterpolate (psf->growth->radius, psf->growth->apMag, psf->growth->refRadius);
    559         psf->growth->apLoss = psf->growth->fitMag - psf->growth->apRef;
     558        psf->growth->apRef = psVectorInterpolate (psf->growth->radius, psf->growth->apMag, psf->growth->refRadius);
     559        psf->growth->apLoss = psf->growth->fitMag - psf->growth->apRef;
    560560    } else {
    561         psf->growth->apRef = NAN;
    562         psf->growth->apLoss = 0;
     561        psf->growth->apRef = NAN;
     562        psf->growth->apLoss = 0;
    563563    }
    564564
  • trunk/psModules/src/objects/pmPSF.h

    r13064 r13898  
    66 * @author EAM, IfA
    77 *
    8  * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-04-27 22:14:08 $
     8 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-06-20 02:22:26 $
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    3131
    3232/** pmPSF data structure
    33  * 
     33 *
    3434 * It is useful to generate a model to define the point-spread-function which
    3535 * describes the flux distribution for unresolved sources in an image. In
     
    4040 * psArray. The other elements of the structure define the quality of the PSF
    4141 * determination.
    42  * 
     42 *
    4343 */
    4444typedef struct
     
    4949    // unfitted elements (So, Io, Xo, Yo) and leave them as NULL
    5050    // I am using a new name to catch all refs to params with gcc
    51     psPolynomial1D *ChiTrend;         ///< Chisq vs flux fit (correction for systematic errors)
    52     psPolynomial4D *ApTrend;            ///< ApResid vs (x,y,rflux) (rflux = ten(0.4*mInst))
    53     float ApResid;                      ///< apMag - psfMag (for PSF stars)
    54     float dApResid;                     ///< scatter of ApResid
    55     float skyBias;                      ///< implied residual sky offset from ApResid fit
    56     float skySat;                       ///< roll-over of ApResid fit
    57     float chisq;                        ///< PSF goodness statistic (unused??)
    58     int nPSFstars;                      ///< number of stars used to measure PSF
    59     int nApResid;                       ///< number of stars used to measure ApResid
     51    psPolynomial1D *ChiTrend;         ///< Chisq vs flux fit (correction for systematic errors)
     52    psPolynomial4D *ApTrend;            ///< ApResid vs (x,y,rflux) (rflux = ten(0.4*mInst))
     53    float ApResid;                      ///< apMag - psfMag (for PSF stars)
     54    float dApResid;                     ///< scatter of ApResid
     55    float skyBias;                      ///< implied residual sky offset from ApResid fit
     56    float skySat;                       ///< roll-over of ApResid fit
     57    float chisq;                        ///< PSF goodness statistic (unused??)
     58    int nPSFstars;                      ///< number of stars used to measure PSF
     59    int nApResid;                       ///< number of stars used to measure ApResid
    6060    bool poissonErrors;
    61     pmGrowthCurve *growth;              ///< apMag vs Radius
    62     pmResiduals *residuals;             ///< normalized residual image (no spatial variation)
     61    pmGrowthCurve *growth;              ///< apMag vs Radius
     62    pmResiduals *residuals;             ///< normalized residual image (no spatial variation)
    6363}
    6464pmPSF;
     
    6969
    7070/**
    71  * 
     71 *
    7272 * Allocator for the pmPSF structure.
    73  * 
     73 *
    7474 */
    7575pmPSF *pmPSFAlloc(
     
    8080
    8181/**
    82  * 
     82 *
    8383 * This function constructs a pmModel instance based on the pmPSF description
    8484 * of the PSF. The input is a pmModel with at least the values of the centroid
     
    8686 * the PSF-dependent parameters are specified for the specific realization based
    8787 * on the coordinates of the object.
    88  * 
     88 *
    8989 */
    9090pmModel *pmModelFromPSF(
     
    100100double pmPSF_SXYtoModel (psF32 *fittedPar);
    101101
    102 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore);
     102bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType mark);
    103103pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...);
    104104
  • trunk/psModules/src/objects/pmPSFtry.c

    r13803 r13898  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-06-13 23:41:51 $
     7 *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-06-20 02:22:26 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9696
    9797// generate a pmPSFtry with a copy of the test PSF sources
    98 pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask, bool applyWeights)
     98pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask, bool applyWeights, psMaskType maskVal, psMaskType mark)
    9999{
    100100    bool status;
     
    116116        if (source->modelEXT == NULL) {
    117117            psError(PS_ERR_UNKNOWN, false, "failed to build model");
    118             psFree(psfTry);
     118            psFree(psfTry);
    119119            return NULL;
    120120        }
    121121
    122122        // set object mask to define valid pixels
    123         psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, RADIUS, "OR", PM_MASK_MARK);
     123        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, RADIUS, "OR", mark);
    124124
    125125        // fit model as EXT, not PSF
    126         status = pmSourceFitModel (source, source->modelEXT, PM_SOURCE_FIT_EXT);
     126        status = pmSourceFitModel (source, source->modelEXT, PM_SOURCE_FIT_EXT, maskVal);
    127127
    128128        // exclude the poor fits
     
    139139    if (!pmPSFFromPSFtry (psfTry, applyWeights)) {
    140140        psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources");
    141         psFree(psfTry);
     141        psFree(psfTry);
    142142        return NULL;
    143143    }
     
    154154        // set shape for this model based on PSF
    155155        source->modelPSF = pmModelFromPSF (source->modelEXT, psfTry->psf);
    156         if (source->modelPSF == NULL) {
     156        if (source->modelPSF == NULL) {
    157157            psfTry->mask->data.U8[i] = PSFTRY_MASK_BAD_MODEL;
    158             abort();
    159             continue;
    160         }
     158            abort();
     159            continue;
     160        }
    161161        source->modelPSF->radiusFit = RADIUS;
    162162
    163163        // set object mask to define valid pixels
    164         psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, RADIUS, "OR", PM_MASK_MARK);
     164        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, RADIUS, "OR", mark);
    165165
    166166        // fit the PSF model to the source
    167         status = pmSourceFitModel (source, source->modelPSF, PM_SOURCE_FIT_PSF);
     167        status = pmSourceFitModel (source, source->modelPSF, PM_SOURCE_FIT_PSF, maskVal);
    168168
    169169        // skip poor fits
    170170        if (!status) {
    171171            psfTry->mask->data.U8[i] = PSFTRY_MASK_PSF_FAIL;
    172             psTrace ("psModules.pmPSFtry", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y);
     172            psTrace ("psModules.pmPSFtry", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y);
    173173            continue;
    174174        }
    175175
    176176        // XXX : use a different aperture radius from the fit radius?
    177         if (!pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP)) {
     177        if (!pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal, mark)) {
    178178            psfTry->mask->data.U8[i] = PSFTRY_MASK_BAD_PHOT;
    179             psTrace ("psModules.pmPSFtry", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y);
     179            psTrace ("psModules.pmPSFtry", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y);
    180180            continue;
    181181        }
     
    203203            flux->data.F64[i] = 0.0;
    204204            chisq->data.F64[i] = 0.0;
    205             mask->data.U8[i] = 1;
     205            mask->data.U8[i] = 0xff;
    206206        } else {
    207207            flux->data.F64[i] = source->modelPSF->params->data.F32[PM_PAR_I0];
     
    217217
    218218    // linear clipped fit of chisq trend vs flux
    219     bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, stats, mask, 1, chisq, NULL, flux);
     219    bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, stats, mask, 0xff, chisq, NULL, flux);
    220220    psLogMsg ("pmPSFtry", 4, "chisq vs flux fit: %f +/- %f\n", stats->robustMedian, stats->robustStdev);
    221221
     
    289289        psError(PS_ERR_UNKNOWN, false, "Failed to fit clipped poly");
    290290
    291         psFree(poly);
    292         psFree(r2rflux);
    293         psFree(stats);
     291        psFree(poly);
     292        psFree(r2rflux);
     293        psFree(stats);
    294294
    295295        return false;
     
    373373        y->data.F64[i] = source->modelEXT->params->data.F32[PM_PAR_YPOS];
    374374
    375         // weight by the error on the source flux
    376         if (dz) {
    377             dz->data.F64[i] = source->modelEXT->dparams->data.F32[PM_PAR_I0];
    378         }
     375        // weight by the error on the source flux
     376        if (dz) {
     377            dz->data.F64[i] = source->modelEXT->dparams->data.F32[PM_PAR_I0];
     378        }
    379379    }
    380380
     
    399399    psVector *e2   = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
    400400    for (int i = 0; i < psfTry->sources->n; i++) {
    401         pmSource *source = psfTry->sources->data[i];
    402         if (source->modelEXT == NULL) continue;
    403 
    404         psEllipsePol pol = pmPSF_ModelToFit (source->modelEXT->params->data.F32);
    405 
    406         e0->data.F64[i] = pol.e0;
    407         e1->data.F64[i] = pol.e1;
    408         e2->data.F64[i] = pol.e2;
     401        pmSource *source = psfTry->sources->data[i];
     402        if (source->modelEXT == NULL) continue;
     403
     404        psEllipsePol pol = pmPSF_ModelToFit (source->modelEXT->params->data.F32);
     405
     406        e0->data.F64[i] = pol.e0;
     407        e1->data.F64[i] = pol.e1;
     408        e2->data.F64[i] = pol.e2;
    409409    }
    410410
     
    413413    for (int i = 0; i < stats->clipIter; i++) {
    414414        psVectorClipFitPolynomial2D (psf->params_NEW->data[PM_PAR_E0], stats, psfTry->mask, 0xff, e0, dz, x, y);
    415         psTrace ("psModules.pmPSFtry", 4, "clipped E0 : keeping %ld of %ld\n", stats->clippedNvalues, e0->n);
     415        psTrace ("psModules.pmPSFtry", 4, "clipped E0 : keeping %ld of %ld\n", stats->clippedNvalues, e0->n);
    416416        psVectorClipFitPolynomial2D (psf->params_NEW->data[PM_PAR_E1], stats, psfTry->mask, 0xff, e1, dz, x, y);
    417         psTrace ("psModules.pmPSFtry", 4, "clipped E1 : keeping %ld of %ld\n", stats->clippedNvalues, e1->n);
     417        psTrace ("psModules.pmPSFtry", 4, "clipped E1 : keeping %ld of %ld\n", stats->clippedNvalues, e1->n);
    418418        psVectorClipFitPolynomial2D (psf->params_NEW->data[PM_PAR_E2], stats, psfTry->mask, 0xff, e2, dz, x, y);
    419         psTrace ("psModules.pmPSFtry", 4, "clipped E2 : keeping %ld of %ld\n", stats->clippedNvalues, e2->n);
     419        psTrace ("psModules.pmPSFtry", 4, "clipped E2 : keeping %ld of %ld\n", stats->clippedNvalues, e2->n);
    420420    }
    421421
    422422    // XXX temporary dump of the psf parameters
    423423    if (psTraceGetLevel("psModules.objects") >= 4) {
    424         FILE *f = fopen ("pol.dat", "w");
    425         for (int i = 0; i < e0->n; i++) {
    426             fprintf (f, "%f %f  :  %f %f %f  : %d\n",
    427                      x->data.F64[i], y->data.F64[i],
    428                      e0->data.F64[i], e1->data.F64[i], e2->data.F64[i], psfTry->mask->data.U8[i]);
    429         }
    430         fclose (f);
     424        FILE *f = fopen ("pol.dat", "w");
     425        for (int i = 0; i < e0->n; i++) {
     426            fprintf (f, "%f %f  :  %f %f %f  : %d\n",
     427                     x->data.F64[i], y->data.F64[i],
     428                     e0->data.F64[i], e1->data.F64[i], e2->data.F64[i], psfTry->mask->data.U8[i]);
     429        }
     430        fclose (f);
    431431    }
    432432
     
    437437    // skip the unfitted parameters (X, Y, Io, Sky) and the shape parameters (SXX, SYY, SXY)
    438438    for (int i = 0; i < psf->params_NEW->n; i++) {
    439         switch (i) {
    440           case PM_PAR_SKY:
    441           case PM_PAR_I0:
    442           case PM_PAR_XPOS:
    443           case PM_PAR_YPOS:           
    444           case PM_PAR_SXX:           
    445           case PM_PAR_SYY:           
    446           case PM_PAR_SXY:           
    447             continue;
    448           default:
    449             break;
    450         }
     439        switch (i) {
     440          case PM_PAR_SKY:
     441          case PM_PAR_I0:
     442          case PM_PAR_XPOS:
     443          case PM_PAR_YPOS:
     444          case PM_PAR_SXX:
     445          case PM_PAR_SYY:
     446          case PM_PAR_SXY:
     447            continue;
     448          default:
     449            break;
     450        }
    451451
    452452        // select the per-object fitted data for this parameter
     
    463463        if (!psVectorClipFitPolynomial2D(psf->params_NEW->data[i], stats, psfTry->mask, 0xff, z, NULL, x, y)) {
    464464            psError(PS_ERR_UNKNOWN, false, "failed to build psf model for parameter %d", i);
    465             psFree(stats);
    466             psFree(x);
    467             psFree(y);
    468             psFree(z);
    469             psFree(dz);
     465            psFree(stats);
     466            psFree(x);
     467            psFree(y);
     468            psFree(z);
     469            psFree(dz);
    470470            return false;
    471471        }
  • trunk/psModules/src/objects/pmPSFtry.h

    r13803 r13898  
    66 * @author EAM, IfA
    77 *
    8  * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-06-13 23:41:51 $
     8 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-06-20 02:22:26 $
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    1818
    1919/**
    20  * 
     20 *
    2121 * This structure contains a pointer to the collection of sources which will
    2222 * be used to test the PSF model form. It lists the pmModelType type of model
     
    3838 * ultimate metric to intercompare multiple types of PSF models is the value of
    3939 * the aperture correction scatter.
    40  * 
     40 *
    4141 * XXX: There are many more members in the SDRS then in the prototype code.
    4242 * I stuck with the prototype code.
    43  * 
    44  * 
     43 *
     44 *
    4545 */
    4646typedef struct
     
    5757
    5858/** pmPSFtryMaskValues
    59  * 
     59 *
    6060 * The following datatype defines the masks used by the pmPSFtry analysis to
    6161 * identify sources which should or should not be included in the analysis.
    62  * 
     62 *
    6363 */
    6464typedef enum {
     
    7474
    7575/** pmPSFtryAlloc()
    76  * 
     76 *
    7777 * Allocate a pmPSFtry data structure.
    78  * 
     78 *
    7979 */
    8080pmPSFtry *pmPSFtryAlloc (psArray *sources, char *modelName, bool poissonErrors, psPolynomial2D *psfTrendMask);
    8181
    8282/** pmPSFtryModel()
    83  * 
     83 *
    8484 * This function takes the input collection of sources and performs a complete
    8585 * analysis to determine a PSF model of the given type (specified by model name).
    8686 * The result is a pmPSFtry with the results of the analysis.
    87  * 
     87 *
    8888 */
    89 pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask, bool applyWeights);
     89pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask, bool applyWeights, psMaskType maskVal, psMaskType mark);
    9090
    9191/** pmPSFtryMetric()
    92  * 
     92 *
    9393 * This function is used to measure the PSF model metric for the set of
    9494 * results contained in the pmPSFtry structure.
    95  * 
     95 *
    9696 */
    9797bool pmPSFtryMetric(
     
    113113
    114114/**
    115  * 
     115 *
    116116 * This function takes a collection of pmModel fitted models from across a
    117117 * single image and builds a pmPSF representation of the PSF. The input array of
     
    122122 * outliers and excluded from the fit. These elements will be marked with a
    123123 * specific mask value (1 == PSFTRY_MASK_OUTLIER).
    124  * 
     124 *
    125125 */
    126126bool pmPSFFromPSFtry (pmPSFtry *psfTry, bool applyWeights);
  • trunk/psModules/src/objects/pmSource.c

    r13338 r13898  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-05-10 20:25:05 $
     8 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-06-20 02:22:26 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    135135    *source->moments = *in->moments;
    136136
    137     // These images are all views to the parent. 
     137    // These images are all views to the parent.
    138138    // We want a new view, but pointing at the same pixels.
    139139    source->pixels   = psImageCopyView (NULL, in->pixels);
     
    143143    // the maskObj is a unique mask array; create a new mask image
    144144    if (in->maskObj) {
    145         source->maskObj = psImageCopy (NULL, in->maskObj, PS_TYPE_MASK);
     145        source->maskObj = psImageCopy (NULL, in->maskObj, PS_TYPE_MASK);
    146146    }
    147147
     
    216216        mySource->region   = newRegion;
    217217
    218         // re-copy the main mask pixels.  NOTE: the user will need to reset the object mask
    219         // pixels (eg, with psImageKeepCircle)
    220         mySource->maskObj = psImageCopy (mySource->maskObj, mySource->maskView, PS_TYPE_MASK);
    221        
    222         // drop the old modelFlux pixels and force the user to re-create
    223         psFree (mySource->modelFlux);
    224         mySource->modelFlux = NULL;
     218        // re-copy the main mask pixels.  NOTE: the user will need to reset the object mask
     219        // pixels (eg, with psImageKeepCircle)
     220        mySource->maskObj = psImageCopy (mySource->maskObj, mySource->maskView, PS_TYPE_MASK);
     221
     222        // drop the old modelFlux pixels and force the user to re-create
     223        psFree (mySource->modelFlux);
     224        mySource->modelFlux = NULL;
    225225    }
    226226    return extend;
     
    233233
    234234// XXX EAM include a S/N cutoff in selecting the sources?
    235 // XXX this function should probably accept the values, not a recipe. wrap with a 
     235// XXX this function should probably accept the values, not a recipe. wrap with a
    236236// psphot-specific function which applies the recipe values
    237237pmPSFClump pmSourcePSFClump(psArray *sources, psMetadata *recipe)
     
    436436*****************************************************************************/
    437437
    438 bool pmSourceRoughClass(psArray *sources, psMetadata *recipe, pmPSFClump clump)
     438bool pmSourceRoughClass(psArray *sources, psMetadata *recipe, pmPSFClump clump, psMaskType maskSat)
    439439{
    440440    psTrace("psModules.objects", 5, "---- begin ----");
     
    487487        inner = psRegionForSquare (source->peak->x, source->peak->y, 2);
    488488        inner = psRegionForImage (source->maskView, inner);
    489         int Nsatpix = psImageCountPixelMask (source->maskView, inner, PM_MASK_SAT);
     489        int Nsatpix = psImageCountPixelMask (source->maskView, inner, maskSat);
    490490
    491491        // saturated star (size consistent with PSF or larger)
     
    747747}
    748748
    749 // construct a realization of the source model 
    750 bool pmSourceCacheModel (pmSource *source) {
     749// construct a realization of the source model
     750bool pmSourceCacheModel (pmSource *source, psMaskType maskVal) {
    751751
    752752    // select appropriate model
    753753    pmModel *model = pmSourceGetModel (NULL, source);
    754754    if (model == NULL) return false;  // model must be defined
    755        
     755
    756756    // if we already have a cached image, re-use that memory
    757757    source->modelFlux = psImageCopy (source->modelFlux, source->pixels, PS_TYPE_F32);
     
    761761    // in others, we just want the model.  which is more commonly used?
    762762    // modelFlux always has unity normalization (I0 = 1.0)
    763     pmModelAdd (source->modelFlux, source->maskObj, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM);
     763    pmModelAdd (source->modelFlux, source->maskObj, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal);
    764764    return true;
    765765}
    766766
    767767// should we call pmSourceCacheModel if it does not exist?
    768 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add) {
     768bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psMaskType maskVal) {
    769769
    770770    bool status;
    771771
    772772    if (add) {
    773         psTrace ("psphot", 3, "replacing object at %f,%f\n", source->peak->xf, source->peak->yf);
     773        psTrace ("psphot", 3, "replacing object at %f,%f\n", source->peak->xf, source->peak->yf);
    774774    } else {
    775         psTrace ("psphot", 3, "removing object at %f,%f\n", source->peak->xf, source->peak->yf);
     775        psTrace ("psphot", 3, "removing object at %f,%f\n", source->peak->xf, source->peak->yf);
    776776    }
    777777
     
    780780
    781781    if (source->modelFlux) {
    782         // add in the pixels from the modelFlux image
    783         int dX = source->modelFlux->col0 - source->pixels->col0;
    784         int dY = source->modelFlux->row0 - source->pixels->row0;
    785         assert (dX >= 0);
    786         assert (dY >= 0);
    787         assert (dX + source->modelFlux->numCols <= source->pixels->numCols);
    788         assert (dY + source->modelFlux->numRows <= source->pixels->numRows);
    789        
    790         // modelFlux has unity normalization
    791         float Io = model->params->data.F32[PM_PAR_I0];
    792         if (mode & PM_MODEL_OP_NORM) {
    793             Io = 1.0;
    794         }
    795 
    796         psU8 **mask = NULL;
    797         if (source->maskObj) {
    798             mask = source->maskObj->data.U8;
    799         }
    800 
    801         psF32 **target = source->pixels->data.F32;
    802         if (mode & PM_MODEL_OP_NOISE) {
    803             target = source->weight->data.F32;
    804         }
    805 
    806         // XXX need to respect the source and model masks?
    807         for (int iy = 0; iy < source->modelFlux->numRows; iy++) {
    808             int oy = iy + dY;
    809             for (int ix = 0; ix < source->modelFlux->numCols; ix++) {
    810                 int ox = ix + dX;
    811                 if (mask && mask[iy][ix]) continue;
    812                 float value = Io*source->modelFlux->data.F32[iy][ix];
    813                 if (add) {
    814                     target[oy][ox] += value;
    815                 } else {
    816                     target[oy][ox] -= value;
    817                 }
    818             }
    819         }
    820         return true;
    821     } 
     782        // add in the pixels from the modelFlux image
     783        int dX = source->modelFlux->col0 - source->pixels->col0;
     784        int dY = source->modelFlux->row0 - source->pixels->row0;
     785        assert (dX >= 0);
     786        assert (dY >= 0);
     787        assert (dX + source->modelFlux->numCols <= source->pixels->numCols);
     788        assert (dY + source->modelFlux->numRows <= source->pixels->numRows);
     789
     790        // modelFlux has unity normalization
     791        float Io = model->params->data.F32[PM_PAR_I0];
     792        if (mode & PM_MODEL_OP_NORM) {
     793            Io = 1.0;
     794        }
     795
     796        psU8 **mask = NULL;
     797        if (source->maskObj) {
     798            mask = source->maskObj->data.U8;
     799        }
     800
     801        psF32 **target = source->pixels->data.F32;
     802        if (mode & PM_MODEL_OP_NOISE) {
     803            target = source->weight->data.F32;
     804        }
     805
     806        // XXX need to respect the source and model masks?
     807        for (int iy = 0; iy < source->modelFlux->numRows; iy++) {
     808            int oy = iy + dY;
     809            for (int ix = 0; ix < source->modelFlux->numCols; ix++) {
     810                int ox = ix + dX;
     811                if (mask && (mask[iy][ix] & maskVal)) continue;
     812                float value = Io*source->modelFlux->data.F32[iy][ix];
     813                if (add) {
     814                    target[oy][ox] += value;
     815                } else {
     816                    target[oy][ox] -= value;
     817                }
     818            }
     819        }
     820        return true;
     821    }
    822822
    823823    psImage *target = source->pixels;
    824824    if (mode & PM_MODEL_OP_NOISE) {
    825         target = source->weight;
     825        target = source->weight;
    826826    }
    827827    if (add) {
    828         status = pmModelAdd (target, source->maskObj, model, PM_MODEL_OP_FULL);
     828        status = pmModelAdd (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal);
    829829    } else {
    830         status = pmModelSub (target, source->maskObj, model, PM_MODEL_OP_FULL);
     830        status = pmModelSub (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal);
    831831    }
    832832
     
    834834}
    835835
    836 bool pmSourceAdd (pmSource *source, pmModelOpMode mode) {
    837     bool status = pmSourceOp (source, mode, true);
    838     return status;
    839 }
    840 
    841 bool pmSourceSub (pmSource *source, pmModelOpMode mode) {
    842     bool status = pmSourceOp (source, mode, false);
    843     return status;
     836bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psMaskType maskVal) {
     837    return pmSourceOp (source, mode, true, maskVal);
     838}
     839
     840bool pmSourceSub (pmSource *source, pmModelOpMode mode, psMaskType maskVal) {
     841    return pmSourceOp (source, mode, false, maskVal);
    844842}
    845843
     
    863861        if (isPSF) {
    864862            *isPSF = true;
    865         }
     863        }
    866864        return model;
    867865
     
    871869            if (isPSF) {
    872870                *isPSF = true;
    873             }
    874             return source->modelPSF;
     871            }
     872            return source->modelPSF;
    875873        }
    876874        return (model);
  • trunk/psModules/src/objects/pmSource.h

    r13567 r13898  
    33 * @author EAM, IfA; GLG, MHPCC
    44 *
    5  * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    6  * @date $Date: 2007-05-31 12:30:19 $
     5 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     6 * @date $Date: 2007-06-20 02:22:26 $
    77 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    88 */
     
    5959typedef struct
    6060{
    61     const int id;                       ///< Unique ID for object
    62     pmPeak *peak;                       ///< Description of peak pixel.
    63     psImage *pixels;                    ///< Rectangular region including object pixels.
    64     psImage *weight;                    ///< Image variance.
    65     psImage *modelFlux;                 ///< cached copy of the model for this source
    66     psImage *maskObj;                   ///< unique mask for this object which marks included pixels associated with objects.
    67     psImage *maskView;                  ///< view into global image mask for this object region
    68     pmMoments *moments;                 ///< Basic moments measure for the object.
    69     pmModel *modelPSF;                  ///< PSF Model fit (parameters and type)
    70     pmModel *modelEXT;                  ///< EXT (floating) Model fit (parameters and type).
    71     pmSourceType type;                  ///< Best identification of object.
    72     pmSourceMode mode;                  ///< Best identification of object.
     61    const int id;                       ///< Unique ID for object
     62    pmPeak *peak;                       ///< Description of peak pixel.
     63    psImage *pixels;                    ///< Rectangular region including object pixels.
     64    psImage *weight;                    ///< Image variance.
     65    psImage *modelFlux;                 ///< cached copy of the model for this source
     66    psImage *maskObj;                   ///< unique mask for this object which marks included pixels associated with objects.
     67    psImage *maskView;                  ///< view into global image mask for this object region
     68    pmMoments *moments;                 ///< Basic moments measure for the object.
     69    pmModel *modelPSF;                  ///< PSF Model fit (parameters and type)
     70    pmModel *modelEXT;                  ///< EXT (floating) Model fit (parameters and type).
     71    pmSourceType type;                  ///< Best identification of object.
     72    pmSourceMode mode;                  ///< Best identification of object.
    7373    psArray *blends;
    74     float psfMag;                       ///< calculated from flux in modelPsf
    75     float extMag;                       ///< calculated from flux in modelEXT
    76     float errMag;                       ///< error in psfMag OR extMag (depending on type)
    77     float apMag;               ///< apMag corresponding to psfMag or extMag (depending on type)
    78     float pixWeight;                    // model-weighted coverage of valid pixels
    79     psRegion region;                    // area on image covered by selected pixels
    80     float sky, skyErr;                  //?< The sky and its error at the center of the object
     74    float psfMag;                       ///< calculated from flux in modelPsf
     75    float extMag;                       ///< calculated from flux in modelEXT
     76    float errMag;                       ///< error in psfMag OR extMag (depending on type)
     77    float apMag;               ///< apMag corresponding to psfMag or extMag (depending on type)
     78    float pixWeight;                    // model-weighted coverage of valid pixels
     79    psRegion region;                    // area on image covered by selected pixels
     80    float sky, skyErr;                  //?< The sky and its error at the center of the object
    8181}
    8282pmSource;
     
    192192    psArray *source,   ///< The input pmSource
    193193    psMetadata *metadata,  ///< Contains classification parameters
    194     pmPSFClump clump   ///< Statistics about the PSF clump
     194    pmPSFClump clump,   ///< Statistics about the PSF clump
     195    psMaskType maskSat                  ///< Mask value for saturated pixels
    195196);
    196197
     
    213214pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source);
    214215
    215 bool pmSourceAdd (pmSource *source, pmModelOpMode mode);
    216 bool pmSourceSub (pmSource *source, pmModelOpMode mode);
    217 
    218 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add);
    219 bool pmSourceCacheModel (pmSource *source);
     216bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psMaskType maskVal);
     217bool pmSourceSub (pmSource *source, pmModelOpMode mode, psMaskType maskVal);
     218
     219bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psMaskType maskVal);
     220bool pmSourceCacheModel (pmSource *source, psMaskType maskVal);
    220221
    221222/// @}
  • trunk/psModules/src/objects/pmSourceFitModel.c

    r13803 r13898  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-06-13 23:41:51 $
     8 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-06-20 02:22:26 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252bool pmSourceFitModel (pmSource *source,
    5353                       pmModel *model,
    54                        pmSourceFitMode mode)
     54                       pmSourceFitMode mode,
     55                       psMaskType maskVal)
    5556{
    5657    psTrace("psModules.objects", 5, "---- %s begin ----\n", __func__);
     
    7778        for (psS32 j = 0; j < source->pixels->numCols; j++) {
    7879            // skip masked points
    79             if (source->maskObj->data.U8[i][j]) {
     80            if (source->maskObj->data.U8[i][j] & maskVal) {
    8081                continue;
    8182            }
     
    324325bool pmSourceFitSet (pmSource *source,
    325326                     psArray *modelSet,
    326                      pmSourceFitMode mode)
     327                     pmSourceFitMode mode,
     328                     psMaskType maskVal)
    327329{
    328330    psTrace("psModules.objects", 3, "---- %s begin ----\n", __func__);
     
    349351        for (psS32 j = 0; j < source->pixels->numCols; j++) {
    350352            // skip masked points
    351             if (source->maskObj->data.U8[i][j]) {
     353            if (source->maskObj->data.U8[i][j] & maskVal) {
    352354                continue;
    353355            }
     
    524526
    525527        // set the model success or failure status
    526         model->flags |= PM_MODEL_STATUS_FITTED;
    527         if (!fitStatus) model->flags |= PM_MODEL_STATUS_NONCONVERGE;
     528        model->flags |= PM_MODEL_STATUS_FITTED;
     529        if (!fitStatus) model->flags |= PM_MODEL_STATUS_NONCONVERGE;
    528530
    529531        // models can go insane: reject these
  • trunk/psModules/src/objects/pmSourceFitModel.h

    r11253 r13898  
    33 * @author EAM, IfA; GLG, MHPCC
    44 *
    5  * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    6  * @date $Date: 2007-01-24 02:54:15 $
     5 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     6 * @date $Date: 2007-06-20 02:22:26 $
    77 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    88 */
     
    4040    pmSource *source,   ///< The input pmSource
    4141    pmModel *model,   ///< model to be fitted
    42     pmSourceFitMode mode  ///< define parameters to be fitted
     42    pmSourceFitMode mode,  ///< define parameters to be fitted
     43    psMaskType maskVal                  ///< Value to mask
    4344);
    4445
     
    6970    pmSource *source,   ///< The input pmSource
    7071    psArray *modelSet,   ///< model to be fitted
    71     pmSourceFitMode mode  ///< define parameters to be fitted
     72    pmSourceFitMode mode,  ///< define parameters to be fitted
     73    psMaskType maskVal                  ///< Vale to mask
     74
    7275);
    7376
  • trunk/psModules/src/objects/pmSourcePhotometry.c

    r13472 r13898  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-05-22 21:45:00 $
     5 *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-06-20 02:22:26 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5858        - the source is a STAR (PSF)
    5959        - the option is selected (mode & PM_SOURCE_PHOT_APCORR)
    60  
     60
    6161    - extMag : all sources with non-NULL modelEXT
    6262**/
    6363
    6464// XXX masked region should be (optionally) elliptical
    65 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode)
     65bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal, psMaskType mark)
    6666{
    6767
     
    110110    // XXX use pmSourceAdd instead?
    111111    if (source->mode & PM_SOURCE_MODE_SUBTRACTED) {
    112         pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
     112        pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal);
    113113    }
    114114
     
    185185    // XXX can I remove this?  the source should have the mask defined when it is constructed or
    186186    // when the fit / aperture radius is changed...
    187     psImageKeepCircle (source->maskObj, x, y, model->radiusFit, "OR", PM_MASK_MARK);
     187    psImageKeepCircle (source->maskObj, x, y, model->radiusFit, "OR", mark);
    188188
    189189    // measure the weight of included pixels
    190190    // XXX is this supposed to use the weight or the flux?
    191191    if (mode & PM_SOURCE_PHOT_WEIGHT) {
    192         pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->maskObj);
     192        pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->maskObj, maskVal);
    193193    }
    194194
    195195    // measure object aperture photometry
    196     status = pmSourcePhotometryAper  (&source->apMag, model, flux, source->maskObj);
     196    status = pmSourcePhotometryAper  (&source->apMag, model, flux, source->maskObj, maskVal);
    197197    if (!status) {
    198         psErrorCode last = psErrorCodeLast();
    199         if (last == PM_ERR_PHOTOM) {
    200             // the aper mag was undefined (flux < 0).  bad object, but
    201             // don't keep the error on the stack
    202             psErrorClear();
    203         }
     198        psErrorCode last = psErrorCodeLast();
     199        if (last == PM_ERR_PHOTOM) {
     200            // the aper mag was undefined (flux < 0).  bad object, but
     201            // don't keep the error on the stack
     202            psErrorClear();
     203        }
    204204    }
    205205
     
    220220    // unmask aperture
    221221    // XXX can I remove this?  this will probably break things downstream...
    222     psImageKeepCircle (source->maskObj, x, y, model->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));
     222    psImageKeepCircle (source->maskObj, x, y, model->radiusFit, "AND", PS_NOT_U8(mark));
    223223
    224224    // if source was originally subtracted, re-subtract object, leave local sky
    225225    // XXX replace with pmSourceSub...
    226226    if (source->mode & PM_SOURCE_MODE_SUBTRACTED) {
    227         pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
     227        pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal);
    228228    }
    229229
     
    235235(aprMag - flux*skySat - r^2*rflux*skyBias) - fitMAg = ApTrend(x,y)
    236236(aprMag - flux*skySat - r^2*rflux*skyBias) = fitMAg + ApTrend(x,y)
    237  
     237
    238238*/
    239239
     
    262262
    263263// return source aperture magnitude
    264 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask)
     264bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal)
    265265{
    266266    float apSum = 0;
     
    269269
    270270    if (model == NULL) {
    271         psError(PM_ERR_OBJECTS, true, "Model is NULL");
     271        psError(PM_ERR_OBJECTS, true, "Model is NULL");
    272272        return false;
    273273    }
     
    285285    for (int ix = 0; ix < image->numCols; ix++) {
    286286        for (int iy = 0; iy < image->numRows; iy++) {
    287             if (mkData[iy][ix])
     287            if (mkData[iy][ix] & maskVal)
    288288                continue;
    289289            apSum += imData[iy][ix] - sky;
     
    291291    }
    292292    if (apSum <= 0) {
    293         psError(PM_ERR_PHOTOM, true, "apSum is negative");
     293        psError(PM_ERR_PHOTOM, true, "apSum is negative");
    294294        return false;
    295295    }
     
    300300
    301301// return source aperture magnitude
    302 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask)
     302bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal)
    303303{
    304304    float modelSum = 0;
     
    366366            if (my >= NY)
    367367                continue;
    368             if (mask->data.U8[my][mx])
     368            if (mask->data.U8[my][mx] & maskVal)
    369369                continue;
    370370
     
    400400    const psImage *Wi = Mi->weight;
    401401    if (!unweighted_sum) {
    402         assert (Wi != NULL);
     402        assert (Wi != NULL);
    403403    }
    404404
     
    463463    const psImage *Wi = Mi->weight;
    464464    if (!unweighted_sum) {
    465         assert (Wi != NULL);
     465        assert (Wi != NULL);
    466466    }
    467467
     
    518518    const psImage *Wi = Mi->weight;
    519519    if (!unweighted_sum) {
    520         assert (Wi != NULL);
     520        assert (Wi != NULL);
    521521    }
    522522    const psImage *Ti = Mi->maskObj;
     
    561561# endif
    562562
    563 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight)
     563bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psMaskType maskVal)
    564564{
    565565
     
    568568    for (int j = 0; j < image->numRows; j++) {
    569569        for (int i = 0; i < image->numCols; i++) {
    570             if (mask->data.U8[j][i])
     570            if (mask->data.U8[j][i] & maskVal)
    571571                continue;
    572572            if (weight->data.F32[j][i] <= 0)
     
    593593    const psImage *Wi = Mi->weight;
    594594    if (!unweighted_sum) {
    595         assert (Wi != NULL);
     595        assert (Wi != NULL);
    596596    }
    597597    const psImage *Ti = Mi->maskObj;
     
    633633
    634634double pmSourceModelDotModel (const pmSource *Mi,
    635                               const pmSource *Mj,
    636                               const bool unweighted_sum) // should the cross product be weighted?
     635                              const pmSource *Mj,
     636                              const bool unweighted_sum) // should the cross product be weighted?
    637637{
    638638    int Xs, Xe, Ys, Ye;
     
    649649    const psImage *Wi = Mi->weight;
    650650    if (!unweighted_sum) {
    651         assert (Wi != NULL);
     651        assert (Wi != NULL);
    652652    }
    653653
     
    680680                continue;
    681681
    682             // XXX skip the nonsense weight pixels?
     682            // XXX skip the nonsense weight pixels?
    683683            if (unweighted_sum) {
    684684                flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
     
    712712    const psImage *Wi = Mi->weight;
    713713    if (!unweighted_sum) {
    714         assert (Wi != NULL);
     714        assert (Wi != NULL);
    715715    }
    716716
     
    743743                continue;
    744744
    745             // XXX skip the nonsense weight pixels?
     745            // XXX skip the nonsense weight pixels?
    746746            if (unweighted_sum) {
    747747                flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
  • trunk/psModules/src/objects/pmSourcePhotometry.h

    r13034 r13898  
    44 * @author EAM, IfA; GLG, MHPCC
    55 *
    6  * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-04-26 01:20:29 $
     6 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2007-06-20 02:22:26 $
    88 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    99 */
     
    4545    pmModel *model,                     ///< model used for photometry
    4646    psImage *image,                     ///< image pixels to be used
    47     psImage *mask                       ///< mask of pixels to ignore
     47    psImage *mask,                      ///< mask of pixels to ignore
     48    psMaskType maskVal                  ///< Value to mask
    4849);
    4950
    5051bool pmSourceMagnitudesInit (psMetadata *config);
    51 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode);
    52 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask);
    53 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight);
     52bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal, psMaskType mark);
     53bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal);
     54bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psMaskType maskVal);
    5455
    5556
  • trunk/psModules/src/objects/pmSourceSky.c

    r13034 r13898  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-04-26 01:20:29 $
     8 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-06-20 02:22:26 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4444    pmSource *source,
    4545    psStatsOptions statsOptions,
    46     psF32 Radius)
     46    psF32 Radius,
     47    psMaskType maskVal,
     48    psMaskType mark)
    4749{
    4850    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     
    6870    srcRegion = psRegionForImage(mask, srcRegion);
    6971
    70     psImageMaskRegion(mask, srcRegion, "OR", PM_MASK_MARK);
     72    psImageMaskRegion(mask, srcRegion, "OR", mark);
    7173    psStats *myStats = psStatsAlloc(statsOptions);
    72     if (!psImageStats(myStats, image, mask, 0xff)) {
     74    if (!psImageStats(myStats, image, mask, maskVal | mark)) {
    7375        psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n");
    7476        psFree(myStats);
    7577        return false;
    7678    }
    77     psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(PM_MASK_MARK));
     79    psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(mark));
    7880    double value = psStatsGetValue(myStats, statistic);
    7981    psFree(myStats);
     
    9597    pmSource *source,
    9698    psStatsOptions statsOptions,
    97     psF32 Radius)
     99    psF32 Radius,
     100    psMaskType maskVal,
     101    psMaskType mark
     102)
    98103{
    99104    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     
    119124    srcRegion = psRegionForImage(mask, srcRegion);
    120125
    121     psImageMaskRegion(mask, srcRegion, "OR", PM_MASK_MARK);
     126    psImageMaskRegion(mask, srcRegion, "OR", mark);
    122127    psStats *myStats = psStatsAlloc(statsOptions);
    123     if (!psImageStats(myStats, image, mask, 0xff)) {
     128    if (!psImageStats(myStats, image, mask, maskVal | mark)) {
    124129        psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n");
    125130        psFree(myStats);
    126131        return false;
    127132    }
    128     psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(PM_MASK_MARK));
     133    psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(mark));
    129134    double value = psStatsGetValue(myStats, statistic);
    130135    psFree(myStats);
  • trunk/psModules/src/objects/pmSourceSky.h

    r11253 r13898  
    22 * @author EAM, IfA; GLG, MHPCC
    33 *
    4  * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    5  * @date $Date: 2007-01-24 02:54:15 $
     4 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     5 * @date $Date: 2007-06-20 02:22:26 $
    66 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    77 */
     
    2929    pmSource *source,   ///< The input image (float)
    3030    psStatsOptions statsOptions, ///< The statistic used in calculating the background sky
    31     float Radius   ///< The inner radius of the square annulus to exclude
     31    float Radius,   ///< The inner radius of the square annulus to exclude
     32    psMaskType maskVal,                 ///< Value to mask
     33    psMaskType mark                     ///< Mask value for marking
    3234);
    3335
     
    3739    pmSource *source,   ///< The input image (float)
    3840    psStatsOptions statsOptions, ///< The statistic used in calculating the background sky
    39     float Radius   ///< The inner radius of the square annulus to exclude
     41    float Radius,   ///< The inner radius of the square annulus to exclude
     42    psMaskType maskVal,                 ///< Value to mask
     43    psMaskType mark                     ///< Mask value for marking
    4044);
    4145
  • trunk/psModules/src/psmodules.h

    r13813 r13898  
    5353#include <pmFPAExtent.h>
    5454#include <pmFPACalibration.h>
     55#include <pmReadoutStack.h>
    5556
    5657// the following headers are from psModule:detrend
Note: See TracChangeset for help on using the changeset viewer.