Changeset 9883 for trunk/psModules/src/objects/pmSourcePhotometry.c
- Timestamp:
- Nov 6, 2006, 11:11:12 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSourcePhotometry.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourcePhotometry.c
r9866 r9883 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-11-0 6 02:11:04$5 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-11-07 09:11:12 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 51 51 : is optionally corrected for curve-of-growth if: 52 52 - the source is a STAR (PSF) 53 - the option is selected ( how??)53 - the option is selected (mode & PM_SOURCE_PHOT_GROWTH) 54 54 - psfMag : all sources with non-NULL modelPSF 55 55 : is optionally corrected for aperture residual if: 56 56 - the source is a STAR (PSF) 57 - the option is selected ( how??)57 - the option is selected (mode & PM_SOURCE_PHOT_APCORR) 58 58 59 59 - extMag : all sources with non-NULL modelEXT 60 60 **/ 61 61 62 // XXX EAM :masked region should be (optionally) elliptical62 // XXX masked region should be (optionally) elliptical 63 63 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode) 64 64 { … … 71 71 pmModel *model; 72 72 73 source->psfMag = 99.0; 74 source->extMag = 99.0; 75 source->errMag = 99.0; 76 source->apMag = 99.0; 77 73 source->psfMag = NAN; 74 source->extMag = NAN; 75 source->errMag = NAN; 76 source->apMag = NAN; 77 78 // XXX these tests prevent aperture photometry without valid model. is 79 // this reasonable? probably not... 78 80 switch (source->type) { 79 81 case PM_SOURCE_TYPE_STAR: … … 99 101 source->errMag = 1.0 / SN; 100 102 } else { 101 SN = 0.0;102 source->errMag = 0.0;103 SN = NAN; 104 source->errMag = NAN; 103 105 } 104 106 x = model->params->data.F32[PM_PAR_XPOS]; … … 114 116 } 115 117 116 if ( SN < AP_MIN_SN)118 if (!isfinite(SN) || (SN < AP_MIN_SN)) 117 119 return false; 118 120 119 121 // replace source flux 120 // XXX test to see if source has been subtracted? 121 pmModelAdd (source->pixels, source->mask, model, false, false); 122 // XXX need to be certain which model and size of mask for prior subtraction 123 if (source->mode & PM_SOURCE_MODE_SUBTRACTED) { 124 pmModelAdd (source->pixels, source->mask, model, false, false); 125 } 126 127 // if we are measuring aperture photometry and applying the growth correction, 128 // we need to shift the flux in the selected pixels (but not the mask) 129 // psImageShift (); 130 psImage *flux; 131 if (mode & PM_SOURCE_PHOT_INTERP) { 132 float dx = 0.5 - x + (int)x; 133 float dy = 0.5 - y + (int)y; 134 flux = psImageShift (NULL, source->pixels, dx, dy, 0.0, PS_INTERPOLATE_BICUBE); 135 } else { 136 flux = source->pixels; 137 } 122 138 123 139 // set aperture mask circle to model radius 140 // XXX use a different radius for apertures and fits... 124 141 psImageKeepCircle (source->mask, x, y, model->radiusFit, "OR", PM_MASK_MARK); 125 142 126 143 // measure the weight of included pixels 144 // XXX is this supposed to use the weight or the flux? 127 145 if (mode & PM_SOURCE_PHOT_WEIGHT) { 128 146 pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->mask); … … 130 148 131 149 // measure object aperture photometry 132 status = pmSourcePhotometryAper (&source->apMag, model, source->pixels, source->mask);150 status = pmSourcePhotometryAper (&source->apMag, model, flux, source->mask); 133 151 134 152 // for PSFs, correct both apMag and psfMag to same system, consistent with infinite flux star in aperture RADIUS … … 142 160 } 143 161 } 162 if (mode & PM_SOURCE_PHOT_INTERP) { 163 psFree (flux); 164 } 144 165 145 166 // unmask aperture 146 167 psImageKeepCircle (source->mask, x, y, model->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK)); 147 168 148 // subtract object, leave local sky 149 pmModelSub (source->pixels, source->mask, model, false, false); 169 // if source was originally subtracted, re-subtract object, leave local sky 170 if (source->mode & PM_SOURCE_MODE_SUBTRACTED) { 171 pmModelSub (source->pixels, source->mask, model, false, false); 172 } 150 173 151 174 return status; … … 164 187 165 188 float fitSum = 0; 166 *fitMag = 99.0;189 *fitMag = NAN; 167 190 168 191 if (model == NULL) { … … 183 206 184 207 // return source aperture magnitude 185 // interpolate the image pixels to place the center at xi+0.5,yi+0.5186 208 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask) 187 209 { 188 210 float apSum = 0; 189 211 float sky = 0; 190 *apMag = 99.0;212 *apMag = NAN; 191 213 192 214 if (model == NULL) { … … 200 222 } 201 223 202 // shift image to have centroid at xi+0.5, yi+0.5203 # if (0)204 // this is necessary to make the measurement consistent with the growth model.205 // only do this if we are applying the model?206 float dx = 0.5 - model->params->data.F32[PM_PAR_XPOS] + (int)model->params->data.F32[PM_PAR_XPOS];207 float dy = 0.5 - model->params->data.F32[PM_PAR_YPOS] + (int)model->params->data.F32[PM_PAR_YPOS];208 psImage *tmpImage = psImageShift (NULL, image, dx, dy, 0.0, PS_INTERPOLATE_BICUBE);209 # else210 211 psImage *tmpImage = psImageCopy (NULL, image, PS_TYPE_F32);212 # endif213 214 224 // measure apMag 215 225 for (int ix = 0; ix < image->numCols; ix++) { … … 217 227 if (mask->data.U8[iy][ix]) 218 228 continue; 219 apSum += tmpImage->data.F32[iy][ix] - sky; 220 } 221 } 222 psFree (tmpImage); 229 apSum += image->data.F32[iy][ix] - sky; 230 } 231 } 223 232 if (apSum <= 0) 224 233 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
