Changeset 29230
- Timestamp:
- Sep 24, 2010, 2:49:53 PM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100823
- Files:
-
- 9 edited
-
psModules/src/objects/pmGrowthCurveGenerate.c (modified) (1 diff)
-
psModules/src/objects/pmPSFtryFitPSF.c (modified) (1 diff)
-
psModules/src/objects/pmSource.c (modified) (1 diff)
-
psModules/src/objects/pmSource.h (modified) (1 diff)
-
psModules/src/objects/pmSourceIO_CMF_PS1_DV2.c (modified) (1 diff)
-
psModules/src/objects/pmSourcePhotometry.c (modified) (10 diffs)
-
psModules/src/objects/pmSourcePhotometry.h (modified) (1 diff)
-
psphot/src/psphotModelTest.c (modified) (1 diff)
-
psphot/src/psphotSourceStats.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100823/psModules/src/objects/pmGrowthCurveGenerate.c
r29004 r29230 197 197 // mask the given aperture and measure the apMag 198 198 psImageKeepCircle (mask, xc, yc, radius, "OR", markVal); 199 if (!pmSourcePhotometryAper (&apMag, model, pixels, mask, maskVal)) {199 if (!pmSourcePhotometryAper (&apMag, NULL, NULL, model, pixels, NULL, mask, maskVal)) { 200 200 psFree (growth); 201 201 psFree (view); -
branches/eam_branches/ipp-20100823/psModules/src/objects/pmPSFtryFitPSF.c
r29004 r29230 41 41 #include "pmSourcePhotometry.h" 42 42 #include "pmSourceVisual.h" 43 44 # define DEBUG 1 43 45 44 46 // stage 3: Refit with fixed shape parameters. This function uses the LMM fitting, but could -
branches/eam_branches/ipp-20100823/psModules/src/objects/pmSource.c
r29004 r29230 132 132 133 133 // default values are NAN 134 source->psfMag = NAN; 135 source->psfFlux = NAN; 136 source->psfFluxErr = NAN; 137 source->extMag = NAN; 138 source->errMag = NAN; 139 source->apMag = NAN; 140 source->sky = NAN; 141 source->skyErr = NAN; 142 source->pixWeightNotBad = NAN; 134 source->psfMag = NAN; 135 source->psfFlux = NAN; 136 source->psfFluxErr = NAN; 137 source->extMag = NAN; 138 source->errMag = NAN; 139 source->apMag = NAN; 140 source->apMagRaw = NAN; 141 source->apRadius = NAN; 142 source->apFlux = NAN; 143 source->apFluxErr = NAN; 144 source->sky = NAN; 145 source->skyErr = NAN; 146 source->pixWeightNotBad = NAN; 143 147 source->pixWeightNotPoor = NAN; 144 148 145 source->psfChisq = NAN;146 source->crNsigma = NAN;147 source->extNsigma = NAN;149 source->psfChisq = NAN; 150 source->crNsigma = NAN; 151 source->extNsigma = NAN; 148 152 149 153 psTrace("psModules.objects", 10, "---- end ----\n"); -
branches/eam_branches/ipp-20100823/psModules/src/objects/pmSource.h
r29004 r29230 76 76 float apMagRaw; ///< raw mag in given aperture 77 77 float apRadius; ///< radius for aperture magnitude 78 float apFlux; ///< apFlux corresponding to psfMag or extMag (depending on type) 79 float apFluxErr; ///< apFluxErr corresponding to psfMag or extMag (depending on type) 78 80 79 81 float pixWeightNotBad; ///< PSF-weighted coverage of unmasked (not BAD) pixels -
branches/eam_branches/ipp-20100823/psModules/src/objects/pmSourceIO_CMF_PS1_DV2.c
r29124 r29230 185 185 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfFlux); 186 186 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental magnitude", source->psfFluxErr); 187 187 188 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG", PS_DATA_F32, "magnitude in standard aperture", source->apMag); 188 // XXX replace with AP_FLUX (& ERR)? psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG", PS_DATA_F32, "magnitude in standard aperture", source->apMag); 189 189 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RAW", PS_DATA_F32, "magnitude in real aperture", source->apMagRaw); 190 190 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS", PS_DATA_F32, "radius used for aperture mags", apRadius); 191 psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX", PS_DATA_F32, "instrumental flux in standard aperture", source->apFlux); 192 psMetadataAdd (row, PS_LIST_TAIL, "AP_FLUX_SIG", PS_DATA_F32, "aperture flux error", source->apFluxErr); 193 191 194 psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude", peakMag); 192 195 psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG", PS_DATA_F32, "PSF Magnitude using supplied calibration", calMag); -
branches/eam_branches/ipp-20100823/psModules/src/objects/pmSourcePhotometry.c
r29124 r29230 62 62 63 63 /** 64 this function is used to calculate the three defined source magnitudes:65 - apMag : only if S/N > AP_MIN_SN66 : is optionally corrected for curve-of-growth if:67 - the source is a STAR (PSF)68 - the option is selected (mode & PM_SOURCE_PHOT_GROWTH)69 - psfMag : all sources with non-NULL modelPSF70 : is optionally corrected for aperture residual if:71 - the source is a STAR (PSF)72 - the option is selected (mode & PM_SOURCE_PHOT_APCORR)73 74 - extMag : all sources with non-NULL modelEXT64 this function is used to calculate the three defined source magnitudes: 65 - apMag : only if S/N > AP_MIN_SN 66 : is optionally corrected for curve-of-growth if: 67 - the source is a STAR (PSF) 68 - the option is selected (mode & PM_SOURCE_PHOT_GROWTH) 69 - psfMag : all sources with non-NULL modelPSF 70 : is optionally corrected for aperture residual if: 71 - the source is a STAR (PSF) 72 - the option is selected (mode & PM_SOURCE_PHOT_APCORR) 73 74 - extMag : all sources with non-NULL modelEXT 75 75 **/ 76 76 … … 88 88 pmModel *model; 89 89 90 source->psfMag = NAN; 91 source->extMag = NAN; 92 source->errMag = NAN; 93 source->apMag = NAN; 90 source->psfMag = NAN; 91 source->extMag = NAN; 92 source->errMag = NAN; 93 source->apMag = NAN; 94 source->apMagRaw = NAN; 95 source->apRadius = NAN; 96 source->apFlux = NAN; 97 source->apFluxErr = NAN; 94 98 95 99 // we must have a valid model … … 182 186 // if we are measuring aperture photometry and applying the growth correction, 183 187 // we need to shift the flux in the selected pixels (but not the mask) 184 psImage *flux = NULL, *mask = NULL; // Star flux and mask images, to photometer 188 psImage *flux = NULL; 189 psImage *variance = NULL; 190 psImage *mask = NULL; // Star flux and mask images, to photometer 185 191 if (mode & PM_SOURCE_PHOT_INTERP) { 186 192 float dx = 0.5 - x + (int)x; … … 199 205 } else { 200 206 flux = source->pixels; 207 variance = source->variance; 201 208 mask = source->maskObj; 202 209 } 203 210 204 211 // measure object aperture photometry 205 status = pmSourcePhotometryAper (&source->apMagRaw, model, flux, mask, maskVal);212 status = pmSourcePhotometryAperSource (source, model, flux, variance, mask, maskVal); 206 213 if (!status) { 207 214 psTrace ("psModules.objects", 3, "fail mag : bad Ap Mag"); … … 215 222 if (psf->growth && (mode & PM_SOURCE_PHOT_GROWTH)) { 216 223 source->apMag = source->apMagRaw + pmGrowthCurveCorrect (psf->growth, source->apRadius); 224 // XXX correct the apFlux? 217 225 } 218 226 if (mode & PM_SOURCE_PHOT_APCORR) { … … 234 242 235 243 /* 236 aprMag' - fitMag = flux*skySat + r^2*rflux*skyBias + ApTrend(x,y)237 (aprMag - flux*skySat - r^2*rflux*skyBias) - fitMAg = ApTrend(x,y)238 (aprMag - flux*skySat - r^2*rflux*skyBias) = fitMAg + ApTrend(x,y)244 aprMag' - fitMag = flux*skySat + r^2*rflux*skyBias + ApTrend(x,y) 245 (aprMag - flux*skySat - r^2*rflux*skyBias) - fitMAg = ApTrend(x,y) 246 (aprMag - flux*skySat - r^2*rflux*skyBias) = fitMAg + ApTrend(x,y) 239 247 240 248 */ … … 268 276 269 277 // return source aperture magnitude 270 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask, psImageMaskType maskVal) 278 bool pmSourcePhotometryAperSource (pmSource *source, pmModel *model, psImage *image, psImage *variance, psImage *mask, psImageMaskType maskVal) 279 { 280 PS_ASSERT_PTR_NON_NULL(source, false); 281 PS_ASSERT_PTR_NON_NULL(image, false); 282 PS_ASSERT_PTR_NON_NULL(mask, false); 283 284 if (DO_SKY) { 285 PS_ASSERT_PTR_NON_NULL(model, false); 286 } 287 288 bool status; 289 status = pmSourcePhotometryAper(&source->apMagRaw, &source->apFlux, &source->apFluxErr, model, image, variance, mask, maskVal); 290 291 return status; 292 } 293 294 // return source aperture magnitude 295 bool pmSourcePhotometryAper (float *apMag, float *apFluxOut, float *apFluxErr, pmModel *model, psImage *image, psImage *variance, psImage *mask, psImageMaskType maskVal) 271 296 { 272 297 PS_ASSERT_PTR_NON_NULL(apMag, false); … … 278 303 } 279 304 280 float apSum = 0;281 305 float sky = 0; 282 *apMag = NAN; 306 float apFlux = 0; 307 float apFluxVar = 0; 283 308 284 309 if (DO_SKY) { 285 310 sky = model->params->data.F32[PM_PAR_SKY]; 286 } else {287 sky = 0;288 311 } 289 312 290 313 psF32 **imData = image->data.F32; 291 314 psImageMaskType **mkData = mask->data.PS_TYPE_IMAGE_MASK_DATA; 292 int nAperPix = 0; 293 294 // measure apMag 295 // XXX save the apFlux and apFluxErr 315 psF32 **varData = (variance) ? variance->data.F32 : image->data.F32; // if variance is not supplied, assume gain of 1.0, no read noise 316 317 // measure apFlux and apFluxVar, save apMag if not NAN 296 318 // XXX note that these fluxes/mags are uncorrected for masked pixels 297 319 // XXX raise a bit if the aperture has a masked pixel (not marked)? 298 320 for (int iy = 0; iy < image->numRows; iy++) { 299 321 for (int ix = 0; ix < image->numCols; ix++) { 300 if (mkData[iy][ix] & maskVal) 301 continue; 302 apSum += imData[iy][ix] - sky; 303 nAperPix ++; 304 // fprintf (stderr, "aper: %d %d %f %f %f\n", ix, iy, sky, imData[iy][ix], apSum); 305 } 306 } 307 if (apSum <= 0) { 322 if (mkData[iy][ix] & maskVal) continue; 323 apFlux += imData[iy][ix] - sky; 324 apFluxVar += varData[iy][ix]; 325 } 326 } 327 if (apFluxOut) *apFluxOut = apFlux; 328 if (apFluxErr) *apFluxErr = sqrt(apFluxVar); 329 330 if (apFlux <= 0) { 308 331 *apMag = NAN; 309 return true; 310 } 311 312 *apMag = -2.5*log10(apSum); 332 } else { 333 *apMag = -2.5*log10(apFlux); 334 } 313 335 return true; 314 336 } … … 617 639 618 640 switch (term) { 619 case 0:641 case 0: 620 642 factor = 1; 621 643 break; 622 case 1:644 case 1: 623 645 factor = xi + Pi->col0; 624 646 break; 625 case 2:647 case 2: 626 648 factor = yi + Pi->row0; 627 649 break; 628 default:650 default: 629 651 psAbort("invalid term for pmSourceWeight"); 630 652 } … … 695 717 696 718 switch (term) { 697 case 0:719 case 0: 698 720 factor = 1; 699 721 break; 700 case 1:722 case 1: 701 723 factor = xi + Pi->col0; 702 724 break; 703 case 2:725 case 2: 704 726 factor = yi + Pi->row0; 705 727 break; 706 default:728 default: 707 729 psAbort("invalid term for pmSourceWeight"); 708 730 } -
branches/eam_branches/ipp-20100823/psModules/src/objects/pmSourcePhotometry.h
r29004 r29230 44 44 45 45 bool pmSourcePhotometryAper( 46 float *apMag, ///< aperture flux magnitude 46 float *apMag, 47 float *apFluxOut, 48 float *apFluxErr, 47 49 pmModel *model, ///< model used for photometry 48 50 psImage *image, ///< image pixels to be used 51 psImage *variance, ///< variance pixels to be used 52 psImage *mask, ///< mask of pixels to ignore 53 psImageMaskType maskVal ///< Value to mask 54 ); 55 56 bool pmSourcePhotometryAperSource( 57 pmSource *source, ///< aperture flux magnitude 58 pmModel *model, ///< model used for photometry 59 psImage *image, ///< image pixels to be used 60 psImage *variance, ///< variance pixels to be used 49 61 psImage *mask, ///< mask of pixels to ignore 50 62 psImageMaskType maskVal ///< Value to mask -
branches/eam_branches/ipp-20100823/psphot/src/psphotModelTest.c
r28013 r29230 226 226 // measure the source mags 227 227 pmSourcePhotometryModel (&fitMag, model); 228 pmSourcePhotometryAper (&obsMag, model, source->pixels, source->maskObj, maskVal);228 pmSourcePhotometryAper (&obsMag, NULL, NULL, model, source->pixels, source->variance, source->maskObj, maskVal); 229 229 fprintf (stderr, "ap: %f, fit: %f, apmifit: %f, nIter: %d\n", obsMag, fitMag, obsMag - fitMag, model->nIter); 230 230 -
branches/eam_branches/ipp-20100823/psphot/src/psphotSourceStats.c
r29004 r29230 418 418 419 419 float apMag = NAN; 420 pmSourcePhotometryAper (&apMag, NULL, source->pixels, source->maskObj, maskVal);420 pmSourcePhotometryAper (&apMag, NULL, NULL, NULL, source->pixels, source->variance, source->maskObj, maskVal); 421 421 fprintf (stderr, "apMag: %f, kronMag: %f\n", apMag, -2.5*log10(source->moments->KronFlux)); 422 422
Note:
See TracChangeset
for help on using the changeset viewer.
