Changeset 13898
- Timestamp:
- Jun 19, 2007, 4:22:26 PM (19 years ago)
- Location:
- trunk/psModules/src
- Files:
-
- 18 edited
-
camera/Makefile.am (modified) (2 diffs)
-
camera/pmFPAMosaic.c (modified) (13 diffs)
-
camera/pmFPAMosaic.h (modified) (3 diffs)
-
objects/pmModel.c (modified) (9 diffs)
-
objects/pmModel.h (modified) (5 diffs)
-
objects/pmPSF.c (modified) (12 diffs)
-
objects/pmPSF.h (modified) (8 diffs)
-
objects/pmPSFtry.c (modified) (13 diffs)
-
objects/pmPSFtry.h (modified) (7 diffs)
-
objects/pmSource.c (modified) (13 diffs)
-
objects/pmSource.h (modified) (4 diffs)
-
objects/pmSourceFitModel.c (modified) (6 diffs)
-
objects/pmSourceFitModel.h (modified) (3 diffs)
-
objects/pmSourcePhotometry.c (modified) (23 diffs)
-
objects/pmSourcePhotometry.h (modified) (2 diffs)
-
objects/pmSourceSky.c (modified) (5 diffs)
-
objects/pmSourceSky.h (modified) (3 diffs)
-
psmodules.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/Makefile.am
r13810 r13898 26 26 pmFPALevel.c \ 27 27 pmFPAExtent.c \ 28 pmCellSquish.c 28 pmCellSquish.c \ 29 pmReadoutStack.c 29 30 30 31 pkginclude_HEADERS = \ … … 51 52 pmFPALevel.h \ 52 53 pmFPAExtent.h \ 53 pmCellSquish.h 54 pmCellSquish.h \ 55 pmReadoutStack.h 54 56 55 57 CLEANFILES = *~ -
trunk/psModules/src/camera/pmFPAMosaic.c
r13499 r13898 22 22 23 23 #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). 24 29 25 30 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 397 402 for (int x = 0; x < image->numCols; x++) { \ 398 403 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]; \ 400 405 } \ 401 406 } \ … … 416 421 for (int k = 0; k < xBinSource->data.S32[i]; k++) { \ 417 422 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]; \ 419 424 } \ 420 425 } \ … … 504 509 psTrace("psModules.camera", 3, "Spliced image will be %dx%d\n", (int)xSize, (int)ySize); 505 510 psImage *mosaic = psImageAlloc((int)xSize, (int)ySize, type); // The mosaic image 506 psImageInit(mosaic, 0);511 psImageInit(mosaic, unexposed); 507 512 508 513 // Next pass through the images to do the mosaicking … … 524 529 (yFlip->data.U8[i] == 0)) { 525 530 // Let someone else do the hard work 526 psImageOverlaySection(mosaic, image, xTargetBase, yTargetBase, " +");531 psImageOverlaySection(mosaic, image, xTargetBase, yTargetBase, "="); 527 532 continue; 528 533 } … … 723 728 int *xBinChip, int *yBinChip, // The binning in x and y, to be returned 724 729 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 726 732 ) 727 733 { … … 804 810 // Mosaic the images together and we're done 805 811 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); 809 815 } 810 816 … … 830 836 const pmFPA *fpa, // FPA to mosaic 831 837 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 833 840 ) 834 841 { … … 937 944 // Mosaic the images together and we're done 938 945 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); 942 949 } 943 950 … … 986 993 // the mosaic image. 987 994 988 bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy )995 bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy, psMaskType blank) 989 996 { 990 997 // Target exists, and has only a single cell … … 1039 1046 // Case 2 --- we need to mosaic by cut and paste 1040 1047 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)) { 1042 1049 psError(PS_ERR_UNKNOWN, false, "Unable to mosaic cells.\n"); 1043 1050 return false; … … 1217 1224 1218 1225 1219 bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy )1226 bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy, psMaskType blank) 1220 1227 { 1221 1228 // Target exists, and has only a single chip with single cell … … 1260 1267 psTrace("psModules.camera", 1, "Case 2 mosaicking: cut and paste.\n"); 1261 1268 if (!fpaMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source, 1262 targetChip, targetCell )) {1269 targetChip, targetCell, blank)) { 1263 1270 psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chips.\n"); 1264 1271 return false; -
trunk/psModules/src/camera/pmFPAMosaic.h
r12696 r13898 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 3-30 21:12:56 $6 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-06-20 02:22:26 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 22 22 /// the pixels, if possible. 23 23 bool 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 26 27 ); 27 28 … … 32 33 /// CELL.X0 and CELL.Y0 offsets. This is useful for getting an image of the FPA on the sky. The mosaicking 33 34 /// 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 ); // 35 bool 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 ); 38 40 /// @} 39 41 #endif -
trunk/psModules/src/objects/pmModel.c
r13803 r13898 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.1 2$ $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 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 60 60 tmp->radiusFit = 0; 61 61 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? 63 63 64 64 psS32 Nparams = pmModelParameterCount(type); … … 105 105 /****************************************************************************** 106 106 pmModelEval(source, level, row): evaluates the model function at the specified coords. 107 107 108 108 NOTE: The coords are in subImage source->pixel coords, not image coords. 109 109 110 110 XXX: Use static vectors for x (NO: needs to be thread safe) 111 111 *****************************************************************************/ … … 132 132 } 133 133 134 bool AddOrSubModel(psImage *image, 135 psImage *mask, 136 pmModel *model, 137 pmModelOpMode mode, 138 bool add 139 ) 134 static bool AddOrSubModel(psImage *image, 135 psImage *mask, 136 pmModel *model, 137 pmModelOpMode mode, 138 bool add, 139 psMaskType maskVal 140 ) 140 141 { 141 142 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); … … 151 152 psS32 imageRow; 152 153 psF32 pixelValue; 153 154 154 155 // save original values; restore before returning 155 156 // use the true source position for the residual model … … 161 162 162 163 if (mode & PM_MODEL_OP_NORM) { 163 params->data.F32[PM_PAR_I0] = 1.0;164 params->data.F32[PM_PAR_I0] = 1.0; 164 165 } 165 166 if (!(mode & PM_MODEL_OP_SKY)) { 166 params->data.F32[PM_PAR_SKY] = 0.0;167 params->data.F32[PM_PAR_SKY] = 0.0; 167 168 } 168 169 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; 171 172 } 172 173 … … 185 186 psImageInterpolateOptions *Ry = NULL; 186 187 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; 201 202 } 202 203 203 204 for (psS32 iy = 0; iy < image->numRows; iy++) { 204 205 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)) 206 207 continue; 207 208 208 209 // 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; 212 213 213 214 x->data.F32[0] = (float) imageCol; 214 215 x->data.F32[1] = (float) imageRow; 215 216 216 pixelValue = 0.0;217 pixelValue = 0.0; 217 218 218 219 // add in the desired components for this coordinate 219 220 if (mode & PM_MODEL_OP_FUNC) { 220 221 pixelValue += modelFunc (NULL, params, x); 221 } 222 223 // get the contribution from the residual model224 if (Ro) {225 // fractional image position226 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 } 248 249 249 250 // add or subtract the value … … 275 276 psImage *mask, 276 277 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); 281 283 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 282 284 return(rc); … … 288 290 psImage *mask, 289 291 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); 294 297 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 295 298 return(rc); -
trunk/psModules/src/objects/pmModel.h
r13803 r13898 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.1 0$ $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 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 30 30 31 31 typedef 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, 36 36 PM_MODEL_OP_FULL = 0x07, 37 PM_MODEL_OP_SKY = 0x08,37 PM_MODEL_OP_SKY = 0x08, 38 38 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, 41 41 } pmModelOpMode; 42 42 … … 52 52 typedef struct 53 53 { 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 freedom60 int nIter; ///< number of iterations to reach min61 pmModelStatus flags; ///< model status flags62 float radiusFit; ///< fit radius actually used63 pmResiduals *residuals; ///< normalized PSF residuals54 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 64 64 } 65 65 pmModel; … … 105 105 */ 106 106 bool 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 111 112 ); 112 113 … … 122 123 */ 123 124 bool 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 128 130 ); 129 131 -
trunk/psModules/src/objects/pmPSF.c
r13803 r13898 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.2 4$ $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 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 81 81 /***************************************************************************** 82 82 pmPSFAlloc (type): allocate a pmPSF. 83 83 84 84 NOTE: PSF model parameters which are not modeled on an image are set to NULL in psf->params. 85 85 86 86 These are normally: 87 87 88 88 X-center 89 89 Y-center … … 180 180 // set model parameters for this source based on PSF information 181 181 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; 185 185 } 186 186 // XXX note that model->residuals is just a reference … … 245 245 // New Concept: the PSF modelling function fits the polarization terms e0, e1, e2: 246 246 247 // convert the parameters used in the fitted source model 247 // convert the parameters used in the fitted source model 248 248 // to the parameters used in the 2D PSF model 249 249 bool pmPSF_FitToModel (psF32 *fittedPar, float minMinorAxis) … … 257 257 psEllipseAxes axes; 258 258 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; 262 262 } 263 263 psEllipseShape shape = psEllipseAxesToShape (axes); … … 279 279 shape.sy = modelPar[PM_PAR_SYY] / M_SQRT2; 280 280 shape.sxy = modelPar[PM_PAR_SXY]; 281 281 282 282 psEllipsePol pol = psEllipseShapeToPol (shape); 283 283 284 284 return pol; 285 285 } … … 297 297 298 298 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; 302 302 } else { 303 // XXX this is not really consistent with the model fit range above304 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 307 307 return axes; 308 308 } … … 313 313 { 314 314 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 321 321 psEllipseShape shape = psEllipseAxesToShape (axes); 322 322 … … 478 478 479 479 // 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 )480 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType mark) 481 481 { 482 482 … … 526 526 // no need to mask the source here 527 527 // 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); 529 529 530 530 // loop over a range of source fluxes 531 531 // no need to interpolate since we have forced the object center 532 532 // 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? 534 534 for (int i = 0; i < psf->growth->radius->n; i++) { 535 535 … … 537 537 538 538 // 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)); 548 548 549 549 // the 'ignore' mode is for testing … … 556 556 557 557 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; 560 560 } else { 561 psf->growth->apRef = NAN;562 psf->growth->apLoss = 0;561 psf->growth->apRef = NAN; 562 psf->growth->apLoss = 0; 563 563 } 564 564 -
trunk/psModules/src/objects/pmPSF.h
r13064 r13898 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 4-27 22:14:08$8 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-06-20 02:22:26 $ 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 11 */ … … 31 31 32 32 /** pmPSF data structure 33 * 33 * 34 34 * It is useful to generate a model to define the point-spread-function which 35 35 * describes the flux distribution for unresolved sources in an image. In … … 40 40 * psArray. The other elements of the structure define the quality of the PSF 41 41 * determination. 42 * 42 * 43 43 */ 44 44 typedef struct … … 49 49 // unfitted elements (So, Io, Xo, Yo) and leave them as NULL 50 50 // 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 ApResid55 float skyBias; ///< implied residual sky offset from ApResid fit56 float skySat; ///< roll-over of ApResid fit57 float chisq; ///< PSF goodness statistic (unused??)58 int nPSFstars; ///< number of stars used to measure PSF59 int nApResid; ///< number of stars used to measure ApResid51 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 60 60 bool poissonErrors; 61 pmGrowthCurve *growth; ///< apMag vs Radius62 pmResiduals *residuals; ///< normalized residual image (no spatial variation)61 pmGrowthCurve *growth; ///< apMag vs Radius 62 pmResiduals *residuals; ///< normalized residual image (no spatial variation) 63 63 } 64 64 pmPSF; … … 69 69 70 70 /** 71 * 71 * 72 72 * Allocator for the pmPSF structure. 73 * 73 * 74 74 */ 75 75 pmPSF *pmPSFAlloc( … … 80 80 81 81 /** 82 * 82 * 83 83 * This function constructs a pmModel instance based on the pmPSF description 84 84 * of the PSF. The input is a pmModel with at least the values of the centroid … … 86 86 * the PSF-dependent parameters are specified for the specific realization based 87 87 * on the coordinates of the object. 88 * 88 * 89 89 */ 90 90 pmModel *pmModelFromPSF( … … 100 100 double pmPSF_SXYtoModel (psF32 *fittedPar); 101 101 102 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore );102 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType mark); 103 103 pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...); 104 104 -
trunk/psModules/src/objects/pmPSFtry.c
r13803 r13898 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.4 2$ $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 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 96 96 97 97 // 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 )98 pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask, bool applyWeights, psMaskType maskVal, psMaskType mark) 99 99 { 100 100 bool status; … … 116 116 if (source->modelEXT == NULL) { 117 117 psError(PS_ERR_UNKNOWN, false, "failed to build model"); 118 psFree(psfTry);118 psFree(psfTry); 119 119 return NULL; 120 120 } 121 121 122 122 // 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); 124 124 125 125 // 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); 127 127 128 128 // exclude the poor fits … … 139 139 if (!pmPSFFromPSFtry (psfTry, applyWeights)) { 140 140 psError(PS_ERR_UNKNOWN, false, "failed to construct a psf model from collection of sources"); 141 psFree(psfTry);141 psFree(psfTry); 142 142 return NULL; 143 143 } … … 154 154 // set shape for this model based on PSF 155 155 source->modelPSF = pmModelFromPSF (source->modelEXT, psfTry->psf); 156 if (source->modelPSF == NULL) {156 if (source->modelPSF == NULL) { 157 157 psfTry->mask->data.U8[i] = PSFTRY_MASK_BAD_MODEL; 158 abort();159 continue;160 }158 abort(); 159 continue; 160 } 161 161 source->modelPSF->radiusFit = RADIUS; 162 162 163 163 // 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); 165 165 166 166 // 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); 168 168 169 169 // skip poor fits 170 170 if (!status) { 171 171 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); 173 173 continue; 174 174 } 175 175 176 176 // 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)) { 178 178 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); 180 180 continue; 181 181 } … … 203 203 flux->data.F64[i] = 0.0; 204 204 chisq->data.F64[i] = 0.0; 205 mask->data.U8[i] = 1;205 mask->data.U8[i] = 0xff; 206 206 } else { 207 207 flux->data.F64[i] = source->modelPSF->params->data.F32[PM_PAR_I0]; … … 217 217 218 218 // 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); 220 220 psLogMsg ("pmPSFtry", 4, "chisq vs flux fit: %f +/- %f\n", stats->robustMedian, stats->robustStdev); 221 221 … … 289 289 psError(PS_ERR_UNKNOWN, false, "Failed to fit clipped poly"); 290 290 291 psFree(poly);292 psFree(r2rflux);293 psFree(stats);291 psFree(poly); 292 psFree(r2rflux); 293 psFree(stats); 294 294 295 295 return false; … … 373 373 y->data.F64[i] = source->modelEXT->params->data.F32[PM_PAR_YPOS]; 374 374 375 // weight by the error on the source flux376 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 } 379 379 } 380 380 … … 399 399 psVector *e2 = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64); 400 400 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; 409 409 } 410 410 … … 413 413 for (int i = 0; i < stats->clipIter; i++) { 414 414 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); 416 416 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); 418 418 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); 420 420 } 421 421 422 422 // XXX temporary dump of the psf parameters 423 423 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); 431 431 } 432 432 … … 437 437 // skip the unfitted parameters (X, Y, Io, Sky) and the shape parameters (SXX, SYY, SXY) 438 438 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 } 451 451 452 452 // select the per-object fitted data for this parameter … … 463 463 if (!psVectorClipFitPolynomial2D(psf->params_NEW->data[i], stats, psfTry->mask, 0xff, z, NULL, x, y)) { 464 464 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); 470 470 return false; 471 471 } -
trunk/psModules/src/objects/pmPSFtry.h
r13803 r13898 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.1 2$ $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 $ 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 11 */ … … 18 18 19 19 /** 20 * 20 * 21 21 * This structure contains a pointer to the collection of sources which will 22 22 * be used to test the PSF model form. It lists the pmModelType type of model … … 38 38 * ultimate metric to intercompare multiple types of PSF models is the value of 39 39 * the aperture correction scatter. 40 * 40 * 41 41 * XXX: There are many more members in the SDRS then in the prototype code. 42 42 * I stuck with the prototype code. 43 * 44 * 43 * 44 * 45 45 */ 46 46 typedef struct … … 57 57 58 58 /** pmPSFtryMaskValues 59 * 59 * 60 60 * The following datatype defines the masks used by the pmPSFtry analysis to 61 61 * identify sources which should or should not be included in the analysis. 62 * 62 * 63 63 */ 64 64 typedef enum { … … 74 74 75 75 /** pmPSFtryAlloc() 76 * 76 * 77 77 * Allocate a pmPSFtry data structure. 78 * 78 * 79 79 */ 80 80 pmPSFtry *pmPSFtryAlloc (psArray *sources, char *modelName, bool poissonErrors, psPolynomial2D *psfTrendMask); 81 81 82 82 /** pmPSFtryModel() 83 * 83 * 84 84 * This function takes the input collection of sources and performs a complete 85 85 * analysis to determine a PSF model of the given type (specified by model name). 86 86 * The result is a pmPSFtry with the results of the analysis. 87 * 87 * 88 88 */ 89 pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask, bool applyWeights );89 pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask, bool applyWeights, psMaskType maskVal, psMaskType mark); 90 90 91 91 /** pmPSFtryMetric() 92 * 92 * 93 93 * This function is used to measure the PSF model metric for the set of 94 94 * results contained in the pmPSFtry structure. 95 * 95 * 96 96 */ 97 97 bool pmPSFtryMetric( … … 113 113 114 114 /** 115 * 115 * 116 116 * This function takes a collection of pmModel fitted models from across a 117 117 * single image and builds a pmPSF representation of the PSF. The input array of … … 122 122 * outliers and excluded from the fit. These elements will be marked with a 123 123 * specific mask value (1 == PSFTRY_MASK_OUTLIER). 124 * 124 * 125 125 */ 126 126 bool pmPSFFromPSFtry (pmPSFtry *psfTry, bool applyWeights); -
trunk/psModules/src/objects/pmSource.c
r13338 r13898 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 5-10 20:25:05$8 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-06-20 02:22:26 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 135 135 *source->moments = *in->moments; 136 136 137 // These images are all views to the parent. 137 // These images are all views to the parent. 138 138 // We want a new view, but pointing at the same pixels. 139 139 source->pixels = psImageCopyView (NULL, in->pixels); … … 143 143 // the maskObj is a unique mask array; create a new mask image 144 144 if (in->maskObj) { 145 source->maskObj = psImageCopy (NULL, in->maskObj, PS_TYPE_MASK);145 source->maskObj = psImageCopy (NULL, in->maskObj, PS_TYPE_MASK); 146 146 } 147 147 … … 216 216 mySource->region = newRegion; 217 217 218 // re-copy the main mask pixels. NOTE: the user will need to reset the object mask219 // 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-create223 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; 225 225 } 226 226 return extend; … … 233 233 234 234 // 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 236 236 // psphot-specific function which applies the recipe values 237 237 pmPSFClump pmSourcePSFClump(psArray *sources, psMetadata *recipe) … … 436 436 *****************************************************************************/ 437 437 438 bool pmSourceRoughClass(psArray *sources, psMetadata *recipe, pmPSFClump clump )438 bool pmSourceRoughClass(psArray *sources, psMetadata *recipe, pmPSFClump clump, psMaskType maskSat) 439 439 { 440 440 psTrace("psModules.objects", 5, "---- begin ----"); … … 487 487 inner = psRegionForSquare (source->peak->x, source->peak->y, 2); 488 488 inner = psRegionForImage (source->maskView, inner); 489 int Nsatpix = psImageCountPixelMask (source->maskView, inner, PM_MASK_SAT);489 int Nsatpix = psImageCountPixelMask (source->maskView, inner, maskSat); 490 490 491 491 // saturated star (size consistent with PSF or larger) … … 747 747 } 748 748 749 // construct a realization of the source model 750 bool pmSourceCacheModel (pmSource *source ) {749 // construct a realization of the source model 750 bool pmSourceCacheModel (pmSource *source, psMaskType maskVal) { 751 751 752 752 // select appropriate model 753 753 pmModel *model = pmSourceGetModel (NULL, source); 754 754 if (model == NULL) return false; // model must be defined 755 755 756 756 // if we already have a cached image, re-use that memory 757 757 source->modelFlux = psImageCopy (source->modelFlux, source->pixels, PS_TYPE_F32); … … 761 761 // in others, we just want the model. which is more commonly used? 762 762 // 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); 764 764 return true; 765 765 } 766 766 767 767 // should we call pmSourceCacheModel if it does not exist? 768 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add ) {768 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psMaskType maskVal) { 769 769 770 770 bool status; 771 771 772 772 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); 774 774 } 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); 776 776 } 777 777 … … 780 780 781 781 if (source->modelFlux) { 782 // add in the pixels from the modelFlux image783 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 normalization791 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 } 822 822 823 823 psImage *target = source->pixels; 824 824 if (mode & PM_MODEL_OP_NOISE) { 825 target = source->weight;825 target = source->weight; 826 826 } 827 827 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); 829 829 } else { 830 status = pmModelSub (target, source->maskObj, model, PM_MODEL_OP_FULL);830 status = pmModelSub (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal); 831 831 } 832 832 … … 834 834 } 835 835 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; 836 bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psMaskType maskVal) { 837 return pmSourceOp (source, mode, true, maskVal); 838 } 839 840 bool pmSourceSub (pmSource *source, pmModelOpMode mode, psMaskType maskVal) { 841 return pmSourceOp (source, mode, false, maskVal); 844 842 } 845 843 … … 863 861 if (isPSF) { 864 862 *isPSF = true; 865 }863 } 866 864 return model; 867 865 … … 871 869 if (isPSF) { 872 870 *isPSF = true; 873 }874 return source->modelPSF;871 } 872 return source->modelPSF; 875 873 } 876 874 return (model); -
trunk/psModules/src/objects/pmSource.h
r13567 r13898 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 5-31 12:30:19$5 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-06-20 02:22:26 $ 7 7 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 8 8 */ … … 59 59 typedef struct 60 60 { 61 const int id; ///< Unique ID for object62 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 source66 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 region68 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. 73 73 psArray *blends; 74 float psfMag; ///< calculated from flux in modelPsf75 float extMag; ///< calculated from flux in modelEXT76 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 pixels79 psRegion region; // area on image covered by selected pixels80 float sky, skyErr; //?< The sky and its error at the center of the object74 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 81 81 } 82 82 pmSource; … … 192 192 psArray *source, ///< The input pmSource 193 193 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 195 196 ); 196 197 … … 213 214 pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source); 214 215 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 );216 bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psMaskType maskVal); 217 bool pmSourceSub (pmSource *source, pmModelOpMode mode, psMaskType maskVal); 218 219 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psMaskType maskVal); 220 bool pmSourceCacheModel (pmSource *source, psMaskType maskVal); 220 221 221 222 /// @} -
trunk/psModules/src/objects/pmSourceFitModel.c
r13803 r13898 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.2 2$ $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 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 52 52 bool pmSourceFitModel (pmSource *source, 53 53 pmModel *model, 54 pmSourceFitMode mode) 54 pmSourceFitMode mode, 55 psMaskType maskVal) 55 56 { 56 57 psTrace("psModules.objects", 5, "---- %s begin ----\n", __func__); … … 77 78 for (psS32 j = 0; j < source->pixels->numCols; j++) { 78 79 // skip masked points 79 if (source->maskObj->data.U8[i][j] ) {80 if (source->maskObj->data.U8[i][j] & maskVal) { 80 81 continue; 81 82 } … … 324 325 bool pmSourceFitSet (pmSource *source, 325 326 psArray *modelSet, 326 pmSourceFitMode mode) 327 pmSourceFitMode mode, 328 psMaskType maskVal) 327 329 { 328 330 psTrace("psModules.objects", 3, "---- %s begin ----\n", __func__); … … 349 351 for (psS32 j = 0; j < source->pixels->numCols; j++) { 350 352 // skip masked points 351 if (source->maskObj->data.U8[i][j] ) {353 if (source->maskObj->data.U8[i][j] & maskVal) { 352 354 continue; 353 355 } … … 524 526 525 527 // 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; 528 530 529 531 // models can go insane: reject these -
trunk/psModules/src/objects/pmSourceFitModel.h
r11253 r13898 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 1-24 02:54:15$5 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-06-20 02:22:26 $ 7 7 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 8 8 */ … … 40 40 pmSource *source, ///< The input pmSource 41 41 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 43 44 ); 44 45 … … 69 70 pmSource *source, ///< The input pmSource 70 71 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 72 75 ); 73 76 -
trunk/psModules/src/objects/pmSourcePhotometry.c
r13472 r13898 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.2 7$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 5-22 21:45:00$5 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-06-20 02:22:26 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 58 58 - the source is a STAR (PSF) 59 59 - the option is selected (mode & PM_SOURCE_PHOT_APCORR) 60 60 61 61 - extMag : all sources with non-NULL modelEXT 62 62 **/ 63 63 64 64 // XXX masked region should be (optionally) elliptical 65 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode )65 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal, psMaskType mark) 66 66 { 67 67 … … 110 110 // XXX use pmSourceAdd instead? 111 111 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); 113 113 } 114 114 … … 185 185 // XXX can I remove this? the source should have the mask defined when it is constructed or 186 186 // 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); 188 188 189 189 // measure the weight of included pixels 190 190 // XXX is this supposed to use the weight or the flux? 191 191 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); 193 193 } 194 194 195 195 // measure object aperture photometry 196 status = pmSourcePhotometryAper (&source->apMag, model, flux, source->maskObj );196 status = pmSourcePhotometryAper (&source->apMag, model, flux, source->maskObj, maskVal); 197 197 if (!status) { 198 psErrorCode last = psErrorCodeLast();199 if (last == PM_ERR_PHOTOM) {200 // the aper mag was undefined (flux < 0). bad object, but201 // don't keep the error on the stack202 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 } 204 204 } 205 205 … … 220 220 // unmask aperture 221 221 // 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)); 223 223 224 224 // if source was originally subtracted, re-subtract object, leave local sky 225 225 // XXX replace with pmSourceSub... 226 226 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); 228 228 } 229 229 … … 235 235 (aprMag - flux*skySat - r^2*rflux*skyBias) - fitMAg = ApTrend(x,y) 236 236 (aprMag - flux*skySat - r^2*rflux*skyBias) = fitMAg + ApTrend(x,y) 237 237 238 238 */ 239 239 … … 262 262 263 263 // return source aperture magnitude 264 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask )264 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal) 265 265 { 266 266 float apSum = 0; … … 269 269 270 270 if (model == NULL) { 271 psError(PM_ERR_OBJECTS, true, "Model is NULL");271 psError(PM_ERR_OBJECTS, true, "Model is NULL"); 272 272 return false; 273 273 } … … 285 285 for (int ix = 0; ix < image->numCols; ix++) { 286 286 for (int iy = 0; iy < image->numRows; iy++) { 287 if (mkData[iy][ix] )287 if (mkData[iy][ix] & maskVal) 288 288 continue; 289 289 apSum += imData[iy][ix] - sky; … … 291 291 } 292 292 if (apSum <= 0) { 293 psError(PM_ERR_PHOTOM, true, "apSum is negative");293 psError(PM_ERR_PHOTOM, true, "apSum is negative"); 294 294 return false; 295 295 } … … 300 300 301 301 // return source aperture magnitude 302 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask )302 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal) 303 303 { 304 304 float modelSum = 0; … … 366 366 if (my >= NY) 367 367 continue; 368 if (mask->data.U8[my][mx] )368 if (mask->data.U8[my][mx] & maskVal) 369 369 continue; 370 370 … … 400 400 const psImage *Wi = Mi->weight; 401 401 if (!unweighted_sum) { 402 assert (Wi != NULL);402 assert (Wi != NULL); 403 403 } 404 404 … … 463 463 const psImage *Wi = Mi->weight; 464 464 if (!unweighted_sum) { 465 assert (Wi != NULL);465 assert (Wi != NULL); 466 466 } 467 467 … … 518 518 const psImage *Wi = Mi->weight; 519 519 if (!unweighted_sum) { 520 assert (Wi != NULL);520 assert (Wi != NULL); 521 521 } 522 522 const psImage *Ti = Mi->maskObj; … … 561 561 # endif 562 562 563 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight )563 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psMaskType maskVal) 564 564 { 565 565 … … 568 568 for (int j = 0; j < image->numRows; j++) { 569 569 for (int i = 0; i < image->numCols; i++) { 570 if (mask->data.U8[j][i] )570 if (mask->data.U8[j][i] & maskVal) 571 571 continue; 572 572 if (weight->data.F32[j][i] <= 0) … … 593 593 const psImage *Wi = Mi->weight; 594 594 if (!unweighted_sum) { 595 assert (Wi != NULL);595 assert (Wi != NULL); 596 596 } 597 597 const psImage *Ti = Mi->maskObj; … … 633 633 634 634 double 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? 637 637 { 638 638 int Xs, Xe, Ys, Ye; … … 649 649 const psImage *Wi = Mi->weight; 650 650 if (!unweighted_sum) { 651 assert (Wi != NULL);651 assert (Wi != NULL); 652 652 } 653 653 … … 680 680 continue; 681 681 682 // XXX skip the nonsense weight pixels?682 // XXX skip the nonsense weight pixels? 683 683 if (unweighted_sum) { 684 684 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]); … … 712 712 const psImage *Wi = Mi->weight; 713 713 if (!unweighted_sum) { 714 assert (Wi != NULL);714 assert (Wi != NULL); 715 715 } 716 716 … … 743 743 continue; 744 744 745 // XXX skip the nonsense weight pixels?745 // XXX skip the nonsense weight pixels? 746 746 if (unweighted_sum) { 747 747 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]); -
trunk/psModules/src/objects/pmSourcePhotometry.h
r13034 r13898 4 4 * @author EAM, IfA; GLG, MHPCC 5 5 * 6 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 4-26 01:20:29$6 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-06-20 02:22:26 $ 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 9 9 */ … … 45 45 pmModel *model, ///< model used for photometry 46 46 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 48 49 ); 49 50 50 51 bool 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 );52 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal, psMaskType mark); 53 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal); 54 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psMaskType maskVal); 54 55 55 56 -
trunk/psModules/src/objects/pmSourceSky.c
r13034 r13898 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 4-26 01:20:29$8 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-06-20 02:22:26 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 44 44 pmSource *source, 45 45 psStatsOptions statsOptions, 46 psF32 Radius) 46 psF32 Radius, 47 psMaskType maskVal, 48 psMaskType mark) 47 49 { 48 50 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); … … 68 70 srcRegion = psRegionForImage(mask, srcRegion); 69 71 70 psImageMaskRegion(mask, srcRegion, "OR", PM_MASK_MARK);72 psImageMaskRegion(mask, srcRegion, "OR", mark); 71 73 psStats *myStats = psStatsAlloc(statsOptions); 72 if (!psImageStats(myStats, image, mask, 0xff)) {74 if (!psImageStats(myStats, image, mask, maskVal | mark)) { 73 75 psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n"); 74 76 psFree(myStats); 75 77 return false; 76 78 } 77 psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8( PM_MASK_MARK));79 psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(mark)); 78 80 double value = psStatsGetValue(myStats, statistic); 79 81 psFree(myStats); … … 95 97 pmSource *source, 96 98 psStatsOptions statsOptions, 97 psF32 Radius) 99 psF32 Radius, 100 psMaskType maskVal, 101 psMaskType mark 102 ) 98 103 { 99 104 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); … … 119 124 srcRegion = psRegionForImage(mask, srcRegion); 120 125 121 psImageMaskRegion(mask, srcRegion, "OR", PM_MASK_MARK);126 psImageMaskRegion(mask, srcRegion, "OR", mark); 122 127 psStats *myStats = psStatsAlloc(statsOptions); 123 if (!psImageStats(myStats, image, mask, 0xff)) {128 if (!psImageStats(myStats, image, mask, maskVal | mark)) { 124 129 psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n"); 125 130 psFree(myStats); 126 131 return false; 127 132 } 128 psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8( PM_MASK_MARK));133 psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(mark)); 129 134 double value = psStatsGetValue(myStats, statistic); 130 135 psFree(myStats); -
trunk/psModules/src/objects/pmSourceSky.h
r11253 r13898 2 2 * @author EAM, IfA; GLG, MHPCC 3 3 * 4 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $5 * @date $Date: 2007-0 1-24 02:54:15$4 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 5 * @date $Date: 2007-06-20 02:22:26 $ 6 6 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 7 7 */ … … 29 29 pmSource *source, ///< The input image (float) 30 30 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 32 34 ); 33 35 … … 37 39 pmSource *source, ///< The input image (float) 38 40 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 40 44 ); 41 45 -
trunk/psModules/src/psmodules.h
r13813 r13898 53 53 #include <pmFPAExtent.h> 54 54 #include <pmFPACalibration.h> 55 #include <pmReadoutStack.h> 55 56 56 57 // the following headers are from psModule:detrend
Note:
See TracChangeset
for help on using the changeset viewer.
