Changeset 13898 for trunk/psModules/src/objects/pmSourcePhotometry.c
- Timestamp:
- Jun 19, 2007, 4:22:26 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSourcePhotometry.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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]);
Note:
See TracChangeset
for help on using the changeset viewer.
