- Timestamp:
- Sep 27, 2009, 10:30:57 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/psModules/src/objects/pmSourcePhotometry.c
r25496 r25594 84 84 85 85 // we must have a valid model 86 // XXX allow aperture magnitudes for sources without a model 86 87 model = pmSourceGetModel (&isPSF, source); 87 88 if (model == NULL) { … … 90 91 } 91 92 93 // XXX handle negative flux, low-significance 92 94 if (model->dparams->data.F32[PM_PAR_I0] > 0) { 93 95 SN = model->params->data.F32[PM_PAR_I0] / model->dparams->data.F32[PM_PAR_I0]; … … 101 103 102 104 // measure PSF model photometry 103 if (psf->FluxScale) { 105 // XXX TEST: do not use flux scale 106 if (0 && psf->FluxScale) { 104 107 // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center 105 108 double fluxScale = pmTrend2DEval (psf->FluxScale, (float)source->peak->x, (float)source->peak->y); 106 if (!isfinite(fluxScale)) { 107 // XXX objects on the edge can be slightly outside -- if we get an 108 // error, use the full fit. 109 psErrorClear(); 110 status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF); 111 } else { 112 if (isfinite(fluxScale) && (fluxScale > 0.0)) { 113 source->psfMag = -2.5*log10(fluxScale * source->modelPSF->params->data.F32[PM_PAR_I0]); 114 } else { 115 source->psfMag = NAN; 116 } 117 } 109 psAssert (isfinite(fluxScale), "how can the flux scale be invalid? source at %d, %d\n", source->peak->x, source->peak->y); 110 psAssert (fluxScale > 0.0, "how can the flux scale be negative? source at %d, %d\n", source->peak->x, source->peak->y); 111 source->psfMag = -2.5*log10(fluxScale * source->modelPSF->params->data.F32[PM_PAR_I0]); 118 112 } else { 119 113 status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF); 120 114 } 121 115 122 // if we have a collection of model fits, one of them is a pointer to modelEXT? 123 // XXX not guaranteed 116 // if we have a collection of model fits, check if one of them is a pointer to modelEXT 124 117 if (source->modelFits) { 125 for (int i = 0; i < source->modelFits->n; i++) { 126 pmModel *model = source->modelFits->data[i]; 127 status = pmSourcePhotometryModel (&model->mag, model); 128 } 129 if (source->modelEXT) { 130 source->extMag = source->modelEXT->mag; 131 } 118 bool foundEXT = false; 119 for (int i = 0; i < source->modelFits->n; i++) { 120 pmModel *model = source->modelFits->data[i]; 121 status = pmSourcePhotometryModel (&model->mag, model); 122 if (model == source->modelEXT) foundEXT = true; 123 } 124 if (foundEXT) { 125 source->extMag = source->modelEXT->mag; 126 } else { 127 status = pmSourcePhotometryModel (&source->extMag, source->modelEXT); 128 } 132 129 } else { 133 if (source->modelEXT) {134 status = pmSourcePhotometryModel (&source->extMag, source->modelEXT);135 }130 if (source->modelEXT) { 131 status = pmSourcePhotometryModel (&source->extMag, source->modelEXT); 132 } 136 133 } 137 134 … … 160 157 } 161 158 162 // replace source flux 163 // XXX need to be certain which model and size of mask for prior subtraction 164 // XXX full model or just analytical? 165 // XXX use pmSourceAdd instead? 166 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 167 pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal); 168 } 159 // if we measure aperture magnitudes, the source must not currently be subtracted! 160 psAssert (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED), "cannot measure ap mags if source is subtracted!"); 169 161 170 162 // if we are measuring aperture photometry and applying the growth correction, … … 212 204 psFree(flux); 213 205 psFree(mask); 214 }215 216 // if source was originally subtracted, re-subtract object, leave local sky217 // XXX replace with pmSourceSub...218 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) {219 pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal);220 206 } 221 207
Note:
See TracChangeset
for help on using the changeset viewer.
