Changeset 16911 for trunk/psModules/src/objects/pmSourcePhotometry.c
- Timestamp:
- Mar 10, 2008, 2:49:14 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSourcePhotometry.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourcePhotometry.c
r16292 r16911 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $6 * @date $Date: 2008-0 2-03 21:58:56$5 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2008-03-11 00:49:14 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 85 85 model = pmSourceGetModel (&isPSF, source); 86 86 if (model == NULL) { 87 psTrace ("psModules.objects", 3, "fail mag : no valid model");87 psTrace ("psModules.objects", 3, "fail mag : no valid model"); 88 88 return false; 89 89 } … … 101 101 // measure PSF model photometry 102 102 if (psf->FluxScale) { 103 // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center104 double fluxScale = pmTrend2DEval (psf->FluxScale, (float)source->peak->x, (float)source->peak->y);105 if (!isfinite(fluxScale)) {106 // XXX objects on the edge can be slightly outside -- if we get an 107 // error, use the full fit.108 psErrorClear();109 status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF);110 } else {111 if (isfinite(fluxScale) && (fluxScale > 0.0)) {112 source->psfMag = -2.5*log10(fluxScale * source->modelPSF->params->data.F32[PM_PAR_I0]);113 } else {114 source->psfMag = NAN;115 }116 }103 // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center 104 double fluxScale = pmTrend2DEval (psf->FluxScale, (float)source->peak->x, (float)source->peak->y); 105 if (!isfinite(fluxScale)) { 106 // XXX objects on the edge can be slightly outside -- if we get an 107 // error, use the full fit. 108 psErrorClear(); 109 status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF); 110 } else { 111 if (isfinite(fluxScale) && (fluxScale > 0.0)) { 112 source->psfMag = -2.5*log10(fluxScale * source->modelPSF->params->data.F32[PM_PAR_I0]); 113 } else { 114 source->psfMag = NAN; 115 } 116 } 117 117 } else { 118 status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF);118 status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF); 119 119 } 120 120 … … 124 124 // for PSFs, correct both apMag and psfMag to same system, consistent with infinite flux star in aperture RADIUS 125 125 if ((mode & PM_SOURCE_PHOT_APCORR) && isPSF && psf && psf->ApTrend) { 126 // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center127 double apTrend = pmTrend2DEval (psf->ApTrend, (float)source->peak->x, (float)source->peak->y);126 // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center 127 double apTrend = pmTrend2DEval (psf->ApTrend, (float)source->peak->x, (float)source->peak->y); 128 128 source->psfMag += apTrend; 129 129 } 130 130 131 131 if (!isfinite(SN) || (SN < AP_MIN_SN)) { 132 psTrace ("psModules.objects", 3, "fail mag : bad SN: %f (limit: %f)", SN, AP_MIN_SN);132 psTrace ("psModules.objects", 3, "fail mag : bad SN: %f (limit: %f)", SN, AP_MIN_SN); 133 133 return false; 134 134 } … … 145 145 // we need to shift the flux in the selected pixels (but not the mask) 146 146 // psImageShift (); 147 psImage *flux ;147 psImage *flux = NULL, *mask = NULL; // Star flux and mask images, to photometer 148 148 if (mode & PM_SOURCE_PHOT_INTERP) { 149 149 float dx = 0.5 - x + (int)x; … … 151 151 x += dx; 152 152 y += dy; 153 flux = psImageShift (NULL, source->pixels, dx, dy, 0.0, PS_INTERPOLATE_BICUBE); 154 // flux = psImageShift (NULL, source->pixels, dx, dy, 0.0, PS_INTERPOLATE_BILINEAR); 153 154 if (!psImageShiftMask(&flux, &mask, source->pixels, source->maskObj, maskVal, dx, dy, 155 NAN, 0xff, PS_INTERPOLATE_BICUBE)) { 156 // Not much we can do about it 157 psErrorClear(); 158 psTrace ("psModules.objects", 3, "fail shift"); 159 return false; 160 } 155 161 156 162 // XXX this is test code to verify the shift is doing the right thing (seems to be) … … 209 215 } else { 210 216 flux = source->pixels; 217 mask = source->maskObj; 211 218 } 212 219 // set aperture mask circle to model radius … … 219 226 // XXX is this supposed to use the weight or the flux? 220 227 if (mode & PM_SOURCE_PHOT_WEIGHT) { 221 pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->maskObj, maskVal );228 pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->maskObj, maskVal | mark); 222 229 } 223 230 224 231 // measure object aperture photometry 225 status = pmSourcePhotometryAper (&source->apMag, model, flux, source->maskObj, maskVal);232 status = pmSourcePhotometryAper (&source->apMag, model, flux, mask, maskVal | mark); 226 233 if (!status) { 227 psTrace ("psModules.objects", 3, "fail mag : bad Ap Mag");234 psTrace ("psModules.objects", 3, "fail mag : bad Ap Mag"); 228 235 psErrorCode last = psErrorCodeLast(); 229 // XXX flag the object?236 // XXX flag the object? 230 237 if (last == PM_ERR_PHOTOM) { 231 238 // the aper mag was undefined (flux < 0). bad object, but … … 246 253 } 247 254 if (mode & PM_SOURCE_PHOT_INTERP) { 248 psFree (flux); 255 psFree(flux); 256 psFree(mask); 249 257 } 250 258
Note:
See TracChangeset
for help on using the changeset viewer.
