Changeset 32157
- Timestamp:
- Aug 21, 2011, 10:44:17 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110710/psphot/src
- Files:
-
- 7 edited
-
. (modified) (1 prop)
-
psphot.h (modified) (3 diffs)
-
psphotExtendedSourceFits.c (modified) (7 diffs)
-
psphotKronMasked.c (modified) (3 diffs)
-
psphotRadiusChecks.c (modified) (2 diffs)
-
psphotReadout.c (modified) (5 diffs)
-
psphotSourceFits.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110710/psphot/src
- Property svn:ignore
-
old new 22 22 psphotMakePSF 23 23 psphotStack 24 psphotModelTest
-
- Property svn:ignore
-
branches/eam_branches/ipp-20110710/psphot/src/psphot.h
r32023 r32157 19 19 PSPHOT_FORCED, 20 20 PSPHOT_MAKE_PSF, 21 PSPHOT_MODEL_TEST, 21 22 } psphotImageLoopMode; 22 23 … … 328 329 bool psphotMakePSFReadout(pmConfig *config, const pmFPAview *view, const char *filerule); 329 330 331 pmConfig *psphotModelTestArguments(int argc, char **argv); 332 bool psphotModelTestReadout(pmConfig *config, const pmFPAview *view, const char *filerule); 333 330 334 int psphotFileruleCount(const pmConfig *config, const char *filerule); 331 335 bool psphotFileruleCountSet(const pmConfig *config, const char *filerule, int num); … … 476 480 477 481 bool psphotSetRadiusMoments (float *fitRadius, float *windowRadius, pmReadout *readout, pmSource *source, psImageMaskType markVal); 482 bool psphotSetRadiusMomentsExact (float *fitRadius, float *windowRadius, pmReadout *readout, pmSource *source, psImageMaskType markVal); 478 483 479 484 #endif -
branches/eam_branches/ipp-20110710/psphot/src/psphotExtendedSourceFits.c
r32023 r32157 316 316 Next ++; 317 317 318 // set the radius based on the first radial moment (also sets the mask pixels) 319 if (!psphotSetRadiusMoments(&fitRadius, &windowRadius, readout, source, markVal)) { 320 fprintf (stderr, "skipping (1) %f, %f\n", source->peak->xf, source->peak->yf); 321 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 322 // XXX raise an error of some kind or set a flag bit 323 continue; 324 } 318 // set the fit radius based on the first radial moment (also sets the mask pixels) 319 psphotSetRadiusMomentsExact(&fitRadius, &windowRadius, readout, source, markVal); 325 320 326 321 // Recalculate the source moments using the larger extended-source moments radius. At … … 332 327 fprintf (stderr, "skipping (2) %f, %f\n", source->peak->xf, source->peak->yf); 333 328 *source->moments = psfMoments; 329 330 // probably need to bump up the size for subtraction 334 331 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 335 332 // XXX raise an error flag of some kind 336 333 continue; 337 334 } 338 339 // save the PSF-based modelFlux here in case we need to subtract it (for failure). If340 // it does not exist, attempt to generate it. Give up if we cannot even do that.341 psImage *modelFluxStart = psMemIncrRefCounter (source->modelFlux);342 if (!modelFluxStart) {343 pmSourceCacheModel (source, maskVal);344 modelFluxStart = psMemIncrRefCounter (source->modelFlux);345 if (!modelFluxStart) {346 fprintf (stderr, "skipping (3) %f, %f\n", source->peak->xf, source->peak->yf);347 *source->moments = psfMoments;348 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);349 // XXX raise an error of some kind?350 continue;351 }352 }353 354 // array to store the pointers to the model flux images while the models are being fitted355 psArray *modelFluxes = psArrayAllocEmpty (models->list->n);356 335 357 336 // allocate the array to store the model fits … … 417 396 continue; 418 397 } 419 pmSourceCacheModel (source, maskVal);420 398 psTrace ("psphot", 4, "fit plain model for %f, %f : %s chisq = %f (npix: %d, niter: %d)\n", 421 399 source->moments->Mx, source->moments->My, pmModelClassGetName (modelFit->type), modelFit->chisq, modelFit->nPix, modelFit->nIter); … … 426 404 } 427 405 } 428 429 // save each of the model flux images for now, and (below) store the best430 psArrayAdd (modelFluxes, 4, source->modelFlux);431 406 432 407 pmSourceExtFitPars *extFitPars = pmSourceExtFitParsAlloc(); … … 477 452 psTrace ("psphot", 5, "failed to fit extended source model to object at %f, %f", source->moments->Mx, source->moments->My); 478 453 479 // replace original model, subtract it 480 psFree (source->modelFlux); 481 source->modelFlux = modelFluxStart; 454 // ensure the modelEXT is cached 455 pmSourceCacheModel (source, maskVal); 482 456 483 457 *source->moments = psfMoments; 484 458 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 485 486 psFree (modelFluxes);487 459 488 460 continue; … … 493 465 source->modelEXT = psMemIncrRefCounter (source->modelFits->data[minModel]); 494 466 495 // save the modelFlux for the best model 496 psFree (source->modelFlux); 497 source->modelFlux = psMemIncrRefCounter (modelFluxes->data[minModel]); 467 // adjust the window so the subtraction covers the faint wings 468 psphotSetRadiusMoments(&fitRadius, &windowRadius, readout, source, markVal); 469 470 // cache the model flux 471 if (source->modelEXT->isPCM) { 472 pmPCMCacheModel (source, maskVal, psfSize); 473 } else { 474 pmSourceCacheModel (source, maskVal); 475 } 498 476 499 477 // replace the original moments … … 502 480 // subtract the best fit from the object, leave local sky 503 481 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 504 505 // the initial model flux is no longer needed506 psFree (modelFluxStart);507 psFree (modelFluxes);508 482 509 483 psTrace ("psphot", 4, "best ext model for %f, %f : %s chisq = %f\n", source->moments->Mx, source->moments->My, pmModelClassGetName (source->modelEXT->type), source->modelEXT->chisq); -
branches/eam_branches/ipp-20110710/psphot/src/psphotKronMasked.c
r31673 r32157 96 96 if (!source->moments) continue; 97 97 98 float windowRadius = RADIUS; 99 if (source->moments->KronFlux / source->moments->KronFluxErr > 10.0) { 100 windowRadius = PS_MAX (RADIUS, 10*source->moments->Mrf); 101 } 102 103 // re-allocate image, weight, mask arrays for each peak with box big enough to fit BIG_RADIUS 104 pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2); 105 106 pmMoments psfMoments = *source->moments; 107 98 108 // replace object in image 99 109 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { … … 101 111 } 102 112 103 psphotKronMag (source, RADIUS, MIN_KRON_RADIUS, maskVal);113 psphotKronMag (source, windowRadius, MIN_KRON_RADIUS, maskVal); 104 114 105 115 // re-subtract the object, leave local sky … … 136 146 } 137 147 } 148 138 149 // psphotSaveImage (NULL, kronMask, "kronmask.fits"); 139 150 psLogMsg ("psphot.kron", PS_LOG_DETAIL, "measure masked kron magnitudes : %f sec for %ld objects\n", psTimerMark ("psphot.kron"), sources->n); -
branches/eam_branches/ipp-20110710/psphot/src/psphotRadiusChecks.c
r31990 r32157 144 144 # define MIN_WINDOW 5.0 145 145 # define SCALE1 5.0 146 # define SCALE2 12. 5146 # define SCALE2 12.0 147 147 148 148 // call this function whenever you (re)-define the EXT model 149 // XXX this function does not shrink the window 149 150 bool psphotSetRadiusMoments (float *fitRadius, float *windowRadius, pmReadout *readout, pmSource *source, psImageMaskType markVal) { 150 151 … … 160 161 // redefine the pixels if needed 161 162 pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, *windowRadius); 163 164 // set the mask to flag the excluded pixels 165 psImageKeepCircle (source->maskObj, source->peak->xf, source->peak->yf, *fitRadius, "OR", markVal); 166 167 return true; 168 } 169 # undef SCALE1 170 # undef SCALE2 171 # undef MIN_WINDOW 172 173 # define MIN_WINDOW 5.0 174 # define SCALE1 5.0 175 # define PAD_WINDOW 3.0 176 177 // call this function whenever you (re)-define the EXT model 178 // XXX alternate function to set exactly the desired window size 179 bool psphotSetRadiusMomentsExact (float *fitRadius, float *windowRadius, pmReadout *readout, pmSource *source, psImageMaskType markVal) { 180 181 psRegion newRegion; 182 183 psAssert (source, "source not defined??"); 184 psAssert (source->moments, "moments not defined??"); 185 186 *fitRadius = SCALE1 * source->moments->Mrf; 187 *fitRadius = PS_MIN (PS_MAX(*fitRadius, MIN_WINDOW), EXT_FIT_MAX_RADIUS); 188 189 *windowRadius = *fitRadius + PAD_WINDOW; 190 191 // check to see if new region is completely contained within old region 192 newRegion = psRegionForSquare (source->peak->xf, source->peak->yf, *windowRadius); 193 newRegion = psRegionForImage (readout->image, newRegion); 194 195 // redefine the pixels to match 196 pmSourceRedefinePixelsByRegion (source, readout, newRegion); 162 197 163 198 // set the mask to flag the excluded pixels -
branches/eam_branches/ipp-20110710/psphot/src/psphotReadout.c
r31452 r32157 137 137 } 138 138 139 // construct sources and measure basic stats (saved on detections->newSources) 139 // construct sources and measure moments and other basic stats (saved on detections->newSources) 140 // all sources use the auto-scaled window appropriate to a PSF, except for the saturated 141 // stars : these use a larger window (3x the basic window) 140 142 if (!psphotSourceStats (config, view, filerule, true)) { // pass 1 141 143 psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources"); … … 200 202 psphotDumpChisqs (config, view, filerule); 201 203 202 // XXX re-measure the kron mags with models subtracted 204 // re-measure the kron mags with models subtracted. this pass uses a circular window of size PSF_MOMENTS_RADIUS (same window used to measure the psf-scale moments) 205 206 // but this is chosen above to be appropriate for the PSF objects (not galaxies) 203 207 psphotKronMasked(config, view, filerule); 204 208 … … 214 218 psphotDumpChisqs (config, view, filerule); 215 219 220 // XXX note above the extended sources have their moments remeasured with a larger window, 221 // but the result is replaced with the original PSF-scaled window 222 216 223 // replace all sources 217 224 psphotReplaceAllSources (config, view, filerule); // pass 1 (detections->allSources) … … 240 247 psphotSubNoise (config, view, filerule); // pass 1 (detections->allSources) 241 248 242 // define new sources based on only the new peaks 249 // define new sources based on only the new peaks & measure moments 243 250 // NOTE: new sources are saved on detections->newSources 244 251 psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources) … … 313 320 314 321 // XXX re-measure the kron mags with models subtracted 322 // Note that this uses the PSF_MOMENTS_RADIUS as a window 315 323 psphotKronMasked(config, view, filerule); 316 324 -
branches/eam_branches/ipp-20110710/psphot/src/psphotSourceFits.c
r32023 r32157 511 511 } 512 512 513 # define TIMING 0513 # define TIMING 1 514 514 515 515 pmModel *psphotFitPCM (pmReadout *readout, pmSource *source, pmSourceFitOptions *fitOptions, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal, int psfSize) { … … 583 583 584 584 if (TIMING) { 585 fprintf (stderr, "psphotFitPCM : nIter: %2d, radius: %6.1f, npix: %5d, t1: %6.4f, t2: %6.4f, t4: %6.4f, t5: %6.4f\n", model->nIter, model->fitRadius, model->nPix, t1, t2, t4, t5); 585 int nPixBig = source->pixels->numCols * source->pixels->numRows; 586 fprintf (stderr, "psphotFitPCM : nIter: %2d, radius: %6.1f, npix: %5d of %5d, t1: %6.4f, t2: %6.4f, t4: %6.4f, t5: %6.4f\n", model->nIter, model->fitRadius, model->nPix, nPixBig, t1, t2, t4, t5); 586 587 } 587 588
Note:
See TracChangeset
for help on using the changeset viewer.
