Changeset 32685 for branches/eam_branches/ipp-20111110/psphot/src
- Timestamp:
- Nov 17, 2011, 5:41:38 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20111110/psphot/src
- Files:
-
- 8 edited
-
psphot.h (modified) (2 diffs)
-
psphotEfficiency.c (modified) (1 diff)
-
psphotFake.c (modified) (1 diff)
-
psphotOutput.c (modified) (2 diffs)
-
psphotRadialApertures.c (modified) (1 diff)
-
psphotReadout.c (modified) (9 diffs)
-
psphotReplaceUnfit.c (modified) (10 diffs)
-
psphotStackReadout.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111110/psphot/src/psphot.h
r32633 r32685 108 108 bool psphotBlendFit_Threaded (psThreadJob *job); 109 109 110 bool psphotReplaceAllSources (pmConfig *config, const pmFPAview *view, const char *filerule );111 bool psphotReplaceAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe );110 bool psphotReplaceAllSources (pmConfig *config, const pmFPAview *view, const char *filerule, bool ignoreState); 111 bool psphotReplaceAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe, bool ignoreState); 112 112 113 113 bool psphotAddNoise (pmConfig *config, const pmFPAview *view, const char *filerule); … … 176 176 177 177 // in psphotReplaceUnfit.c: 178 bool psphotRemoveAllSources (const psArray *sources, const psMetadata *recipe); 178 bool psphotRemoveAllSourcesByArray (const psArray *sources, const psMetadata *recipe); 179 bool psphotRemoveAllSources (pmConfig *config, const pmFPAview *view, const char *filerule, bool ignoreState); 180 bool psphotRemoveAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool ignoreState); 179 181 bool psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal); 180 182 -
branches/eam_branches/ipp-20111110/psphot/src/psphotEfficiency.c
r32348 r32685 255 255 256 256 // remove all sources, adding noise for subtracted sources 257 psphotRemoveAllSources (realSources, recipe);257 psphotRemoveAllSourcesByArray(realSources, recipe); 258 258 259 259 #if TESTING -
branches/eam_branches/ipp-20111110/psphot/src/psphotFake.c
r26894 r32685 166 166 167 167 // remove all sources, adding noise for subtracted sources 168 psphotRemoveAllSources (realSources, recipe);168 psphotRemoveAllSourcesByArray(realSources, recipe); 169 169 psphotAddNoise(readout, realSources, recipe); 170 170 -
branches/eam_branches/ipp-20111110/psphot/src/psphotOutput.c
r32348 r32685 407 407 return true; 408 408 } 409 410 // for now, let's store the detections on the readout->analysis for each readout 411 bool psphotDumpTest (pmConfig *config, const pmFPAview *view, const char *filerule) 412 { 413 static int npass = 0; 414 char filename[64]; 415 416 // XXX uncomment to disreturn true; 417 418 bool status = true; 419 420 int num = psphotFileruleCount(config, filerule); 421 422 snprintf (filename, 64, "testdump.%02d.dat", npass); 423 FILE *f = fopen (filename, "w"); 424 425 // loop over the available readouts 426 for (int i = 0; i < num; i++) { 427 428 // find the currently selected readout 429 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest 430 psAssert (file, "missing file?"); 431 432 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 433 psAssert (readout, "missing readout?"); 434 435 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 436 psAssert (detections, "missing detections?"); 437 438 psArray *sources = detections->newSources ? detections->newSources : detections->allSources; 439 psAssert (sources, "missing sources?"); 440 441 if (detections->newSources) { 442 fprintf (f, "## --- from new sources ---\n"); 443 } else { 444 fprintf (f, "## --- from all sources ---\n"); 445 } 446 447 for (int i = 0; i < sources->n; i++) { 448 pmSource *source = sources->data[i]; 449 if (!source) continue; 450 451 pmPeak *peak = source->peak; 452 if (!peak) continue; 453 454 // XXX only dump a given region 455 if (peak->xf < 20) continue; 456 if (peak->yf < 20) continue; 457 if (peak->xf > 40) continue; 458 if (peak->yf > 70) continue; 459 460 float Msum = source->moments ? source->moments->Sum : NAN; 461 float Mx = source->moments ? source->moments->Mx : NAN; 462 float My = source->moments ? source->moments->My : NAN; 463 float Npix = source->moments ? source->moments->nPixels : NAN; 464 fprintf (f, "%f %f : %f %f : %f %f\n", peak->xf, peak->yf, Mx, My, Msum, Npix); 465 } 466 } 467 fclose (f); 468 npass ++; 469 470 return true; 471 } 472 473 # if (0) 409 474 bool psphotDumpTest (pmConfig *config, const pmFPAview *view, const char *filerule, char *filename) { 410 475 … … 449 514 return true; 450 515 } 451 516 # endif -
branches/eam_branches/ipp-20111110/psphot/src/psphotRadialApertures.c
r32633 r32685 156 156 157 157 // set this to 0 to run without threading 158 # if ( 1)158 # if (0) 159 159 if (!psThreadJobAddPending(job)) { 160 160 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); -
branches/eam_branches/ipp-20111110/psphot/src/psphotReadout.c
r32633 r32685 1 1 # include "psphotInternal.h" 2 bool psphotDumpTest (pmConfig *config, const pmFPAview *view, const char *filerule); 2 3 3 4 // this should be called by every program that links against libpsphot … … 9 10 } 10 11 11 // for now, let's store the detections on the readout->analysis for each readout12 bool psphotDumpChisqs (pmConfig *config, const pmFPAview *view, const char *filerule)13 {14 static int npass = 0;15 char filename[64];16 17 return true;18 19 bool status = true;20 21 int num = psphotFileruleCount(config, filerule);22 23 snprintf (filename, 64, "chisq.%02d.dat", npass);24 FILE *f = fopen (filename, "w");25 26 // loop over the available readouts27 for (int i = 0; i < num; i++) {28 29 // find the currently selected readout30 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, i); // File of interest31 psAssert (file, "missing file?");32 33 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);34 psAssert (readout, "missing readout?");35 36 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");37 psAssert (detections, "missing detections?");38 39 psArray *sources = detections->allSources;40 psAssert (sources, "missing sources?");41 42 for (int i = 0; i < sources->n; i++) {43 pmSource *source = sources->data[i];44 if (!source) continue;45 46 pmModel *model = pmSourceGetModel (NULL, source);47 if (!model) continue;48 49 if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) {50 fprintf (f, "%f %f %f %d %d %f 1 NONLINEAR\n", model->mag, model->params->data.F32[1], model->chisq, model->nDOF, model->nPix, model->chisqNorm);51 } else {52 fprintf (f, "%f %f %f %d %d %f 0 LINEAR\n", model->mag, model->params->data.F32[1], model->chisq, model->nDOF, model->nPix, model->chisqNorm);53 }54 }55 }56 fclose (f);57 npass ++;58 59 return true;60 }61 62 12 bool psphotReadout(pmConfig *config, const pmFPAview *view, const char *filerule) { 63 13 … … 133 83 return psphotReadoutCleanup (config, view, filerule); 134 84 } 85 psphotDumpTest (config, view, filerule); 135 86 136 87 // find blended neighbors of very saturated stars (detections->newSources) … … 188 139 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 189 140 psphotFitSourcesLinear (config, view, filerule, false); // pass 1 (detections->allSources) 190 psphotDump Chisqs(config, view, filerule);141 psphotDumpTest (config, view, filerule); 191 142 192 143 // measure the radial profiles to the sky … … 208 159 // replace model flux, adjust mask as needed, fit, subtract the models (full stamp) 209 160 psphotBlendFit (config, view, filerule); // pass 1 (detections->allSources) 210 psphotDumpChisqs (config, view, filerule);211 161 212 162 // replace all sources 213 psphotReplaceAllSources (config, view, filerule ); // pass 1 (detections->allSources)163 psphotReplaceAllSources (config, view, filerule, false); // pass 1 (detections->allSources) 214 164 215 165 // linear fit to include all sources (subtract again) 216 166 // NOTE : apply to ALL sources (extended + psf) 217 167 psphotFitSourcesLinear (config, view, filerule, true); // pass 2 (detections->allSources) 218 psphotDumpChisqs (config, view, filerule);219 168 220 169 // if we only do one pass, skip to extended source analysis … … 239 188 // NOTE: new sources are saved on detections->newSources 240 189 psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources) 190 psphotDumpTest (config, view, filerule); 241 191 242 192 // set source type … … 253 203 // replace all sources so fit below applies to all at once 254 204 // NOTE: apply only to OLD sources (which have been subtracted) 255 psphotReplaceAllSources (config, view, filerule ); // pass 2205 psphotReplaceAllSources (config, view, filerule, false); // pass 2 256 206 257 207 // merge the newly selected sources into the existing list … … 259 209 // XXX check on free of sources... 260 210 psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources) 211 psphotDumpTest (config, view, filerule); 261 212 262 213 // NOTE: apply to ALL sources 263 214 psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources) 264 psphotDumpChisqs (config, view, filerule);265 215 } 266 216 … … 295 245 // replace all sources so fit below applies to all at once 296 246 // NOTE: apply only to OLD sources (which have been subtracted) 297 psphotReplaceAllSources (config, view, filerule ); // pass 2247 psphotReplaceAllSources (config, view, filerule, false); // pass 2 298 248 299 249 // merge the newly selected sources into the existing list -
branches/eam_branches/ipp-20111110/psphot/src/psphotReplaceUnfit.c
r31452 r32685 1 1 # include "psphotInternal.h" 2 3 static int replace_pass = 0; 4 static int remove_pass = 0; 2 5 3 6 // replace the flux for sources which failed … … 9 12 10 13 for (int i = 0; i < sources->n; i++) { 11 source = sources->data[i];12 13 // replace other sources?14 if (source->mode & PM_SOURCE_MODE_FAIL) goto replace;15 continue;14 source = sources->data[i]; 15 16 // replace other sources? 17 if (source->mode & PM_SOURCE_MODE_FAIL) goto replace; 18 continue; 16 19 17 20 replace: … … 23 26 24 27 // for now, let's store the detections on the readout->analysis for each readout 25 bool psphotReplaceAllSources (pmConfig *config, const pmFPAview *view, const char *filerule )28 bool psphotReplaceAllSources (pmConfig *config, const pmFPAview *view, const char *filerule, bool ignoreState) 26 29 { 27 30 bool status = true; … … 35 38 // loop over the available readouts 36 39 for (int i = 0; i < num; i++) { 37 if (!psphotReplaceAllSourcesReadout (config, view, filerule, i, recipe )) {40 if (!psphotReplaceAllSourcesReadout (config, view, filerule, i, recipe, ignoreState)) { 38 41 psError (PSPHOT_ERR_CONFIG, false, "failed to replace all sources for %s entry %d", filerule, i); 39 42 return false; 40 43 } 41 44 } 42 return true; 43 } 44 45 bool psphotReplaceAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) { 45 replace_pass ++; 46 return true; 47 } 48 49 bool psphotReplaceAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool ignoreState) { 46 50 47 51 bool status; 48 pmSource *source;49 52 50 53 psTimerStart ("psphot.replace"); … … 57 60 psAssert (readout, "missing readout?"); 58 61 62 char name[128]; 63 snprintf (name, 128, "testadd.neg.%02d.%02d.fits", replace_pass, index); 64 psphotSaveImage (NULL, readout->image, name); 65 59 66 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 60 67 psAssert (detections, "missing detections?"); … … 75 82 76 83 for (int i = 0; i < sources->n; i++) { 77 source = sources->data[i]; 78 79 // replace other sources? 80 if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue; 81 82 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 83 } 84 pmSource *source = sources->data[i]; 85 86 if (ignoreState) { 87 // rely on the type of source to decide if we subtract it or not 88 89 // skip non-astronomical objects (very likely defects) 90 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 91 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 92 93 // do not include CRs in the full ensemble fit 94 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue; 95 96 // do not include MOMENTS_FAILURES in the fit 97 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue; 98 } else { 99 // if we respect the state, only remove unsubtracted sources 100 if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue; 101 } 102 103 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 104 } 105 106 snprintf (name, 128, "testadd.pos.%02d.%02d.fits", replace_pass, index); 107 psphotSaveImage (NULL, readout->image, name); 84 108 85 109 psphotVisualShowImage(readout); … … 88 112 } 89 113 90 bool psphotRemoveAllSources (const psArray *sources, const psMetadata *recipe) { 114 // for now, let's store the detections on the readout->analysis for each readout 115 bool psphotRemoveAllSources (pmConfig *config, const pmFPAview *view, const char *filerule, bool ignoreState) 116 { 117 bool status = true; 118 119 // select the appropriate recipe information 120 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 121 psAssert (recipe, "missing recipe?"); 122 123 int num = psphotFileruleCount(config, filerule); 124 125 // loop over the available readouts 126 for (int i = 0; i < num; i++) { 127 if (!psphotRemoveAllSourcesReadout (config, view, filerule, i, recipe, ignoreState)) { 128 psError (PSPHOT_ERR_CONFIG, false, "failed to replace all sources for %s entry %d", filerule, i); 129 return false; 130 } 131 } 132 remove_pass ++; 133 return true; 134 } 135 136 bool psphotRemoveAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool ignoreState) { 137 138 bool status; 139 140 psTimerStart ("psphot.replace"); 141 142 // find the currently selected readout 143 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 144 psAssert (file, "missing file?"); 145 146 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 147 psAssert (readout, "missing readout?"); 148 149 char name[128]; 150 snprintf (name, 128, "testsub.pos.%02d.%02d.fits", remove_pass, index); 151 psphotSaveImage (NULL, readout->image, name); 152 153 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 154 psAssert (detections, "missing detections?"); 155 156 psArray *sources = detections->allSources; 157 psAssert (sources, "missing sources?"); 158 159 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 160 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 161 psAssert (maskVal, "missing mask value?"); 162 163 // bit-mask to mark pixels not used in analysis 164 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 165 assert (markVal); 166 167 // maskVal is used to test for rejected pixels, and must include markVal 168 maskVal |= markVal; 169 170 for (int i = 0; i < sources->n; i++) { 171 pmSource *source = sources->data[i]; 172 173 // skip non-astronomical objects (very likely defects) 174 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 175 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 176 177 // do not include CRs in the full ensemble fit 178 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue; 179 180 // do not include MOMENTS_FAILURES in the fit 181 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue; 182 183 // if we respect the state, only remove unsubtracted sources 184 if (!ignoreState && (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue; 185 186 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 187 } 188 189 snprintf (name, 128, "testsub.neg.%02d.%02d.fits", remove_pass, index); 190 psphotSaveImage (NULL, readout->image, name); 191 192 psphotVisualShowImage(readout); 193 psLogMsg ("psphot.replace", PS_LOG_INFO, "replaced models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot.replace")); 194 return true; 195 } 196 197 bool psphotRemoveAllSourcesByArray (const psArray *sources, const psMetadata *recipe) { 91 198 92 199 bool status; … … 100 207 101 208 for (int i = 0; i < sources->n; i++) { 102 source = sources->data[i];103 104 // replace other sources?105 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) continue;106 107 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);209 source = sources->data[i]; 210 211 // replace other sources? 212 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) continue; 213 214 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 108 215 } 109 216 psLogMsg ("psphot.replace", PS_LOG_INFO, "replaced models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot.replace")); … … 158 265 159 266 for (int i = 0; i < sources->n; i++) { 160 source = sources->data[i];161 162 // sources have not yet been subtracted in this image (but this flag may be raised)163 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;164 if (!source->modelPSF) continue;165 166 float Xo = source->modelPSF->params->data.F32[PM_PAR_XPOS];167 float Yo = source->modelPSF->params->data.F32[PM_PAR_YPOS];168 float radius = source->modelPSF->fitRadius;169 170 // force a redefine to this image171 pmSourceFreePixels(source);172 pmSourceRedefinePixels (source, readout, Xo, Yo, radius);267 source = sources->data[i]; 268 269 // sources have not yet been subtracted in this image (but this flag may be raised) 270 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 271 if (!source->modelPSF) continue; 272 273 float Xo = source->modelPSF->params->data.F32[PM_PAR_XPOS]; 274 float Yo = source->modelPSF->params->data.F32[PM_PAR_YPOS]; 275 float radius = source->modelPSF->fitRadius; 276 277 // force a redefine to this image 278 pmSourceFreePixels(source); 279 pmSourceRedefinePixels (source, readout, Xo, Yo, radius); 173 280 } 174 281 return true; … … 229 336 230 337 for (int i = 0; i < sources->n; i++) { 231 source = sources->data[i];232 233 // *** we need to cache the 'best' model, and we have 3 cases:234 // 1) model is the psf model --> generate from the new psf235 // 2) model is an unconvolved extended model --> just cache the copy (not perfect)236 // 3) model is a convolved extended model --> re-generate237 238 // use the 'best' model to cache the model (PSF or EXT : EXT may point at one of modelFits239 bool isPSF = false;240 pmModel *model = pmSourceGetModel(&isPSF, source);241 if (!model) continue;242 243 float radius = model->fitRadius; // save for future use below244 245 // regenerate the PSF if the model is a PSF, or if we need the PSF for a PCM246 if (isPSF || model->isPCM) {247 // the guess central intensity comes from the peak:248 float Io = source->peak->rawFlux;249 float Xo = source->modelPSF->params->data.F32[PM_PAR_XPOS];250 float Yo = source->modelPSF->params->data.F32[PM_PAR_YPOS];251 252 // generate a model for this object with Io = 1.0253 pmModel *modelPSF = pmModelFromPSFforXY(psf, Xo, Yo, Io);254 if (modelPSF == NULL) {255 psWarning ("Failed to determine PSF model for source at (%f,%f), skipping", Xo, Yo);256 continue;257 }258 259 // set the source PSF model260 psFree (source->modelPSF);261 source->modelPSF = modelPSF;262 source->modelPSF->fitRadius = radius;263 }264 265 if (model->isPCM) {266 psAssert(false, "this section is not complete");267 268 pmSourceCachePSF (source, maskVal);269 270 psKernel *psfKernel = pmPCMkernelFromPSF(source, psfSize);271 if (!psfKernel) {272 psWarning ("no psf kernel");273 }274 275 // generate an image of the right size276 psImage *rawModelFlux = psImageCopy (NULL, source->pixels, PS_TYPE_F32);277 psImageInit (rawModelFlux, 0.0);338 source = sources->data[i]; 339 340 // *** we need to cache the 'best' model, and we have 3 cases: 341 // 1) model is the psf model --> generate from the new psf 342 // 2) model is an unconvolved extended model --> just cache the copy (not perfect) 343 // 3) model is a convolved extended model --> re-generate 344 345 // use the 'best' model to cache the model (PSF or EXT : EXT may point at one of modelFits 346 bool isPSF = false; 347 pmModel *model = pmSourceGetModel(&isPSF, source); 348 if (!model) continue; 349 350 float radius = model->fitRadius; // save for future use below 351 352 // regenerate the PSF if the model is a PSF, or if we need the PSF for a PCM 353 if (isPSF || model->isPCM) { 354 // the guess central intensity comes from the peak: 355 float Io = source->peak->rawFlux; 356 float Xo = source->modelPSF->params->data.F32[PM_PAR_XPOS]; 357 float Yo = source->modelPSF->params->data.F32[PM_PAR_YPOS]; 358 359 // generate a model for this object with Io = 1.0 360 pmModel *modelPSF = pmModelFromPSFforXY(psf, Xo, Yo, Io); 361 if (modelPSF == NULL) { 362 psWarning ("Failed to determine PSF model for source at (%f,%f), skipping", Xo, Yo); 363 continue; 364 } 365 366 // set the source PSF model 367 psFree (source->modelPSF); 368 source->modelPSF = modelPSF; 369 source->modelPSF->fitRadius = radius; 370 } 371 372 if (model->isPCM) { 373 psAssert(false, "this section is not complete"); 374 375 pmSourceCachePSF (source, maskVal); 376 377 psKernel *psfKernel = pmPCMkernelFromPSF(source, psfSize); 378 if (!psfKernel) { 379 psWarning ("no psf kernel"); 380 } 381 382 // generate an image of the right size 383 psImage *rawModelFlux = psImageCopy (NULL, source->pixels, PS_TYPE_F32); 384 psImageInit (rawModelFlux, 0.0); 278 385 279 // insert the model image normalized to 1.0280 pmModelAdd (rawModelFlux, NULL, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal);281 282 psImageConvolveFFT (source->modelFlux, rawModelFlux, NULL, 0, psfKernel);386 // insert the model image normalized to 1.0 387 pmModelAdd (rawModelFlux, NULL, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal); 388 389 psImageConvolveFFT (source->modelFlux, rawModelFlux, NULL, 0, psfKernel); 283 390 284 psFree (psfKernel);285 psFree (rawModelFlux);286 }287 288 pmSourceCacheModel (source, maskVal); // ALLOC x14 (!)391 psFree (psfKernel); 392 psFree (rawModelFlux); 393 } 394 395 pmSourceCacheModel (source, maskVal); // ALLOC x14 (!) 289 396 } 290 397 -
branches/eam_branches/ipp-20111110/psphot/src/psphotStackReadout.c
r32633 r32685 1 1 # include "psphotInternal.h" 2 bool psphotDumpTest (pmConfig *config, const pmFPAview *view, const char *filerule); 2 3 3 4 // we have 3 possible real filesets: … … 130 131 return psphotReadoutCleanup (config, view, STACK_SRC); 131 132 } 133 psphotDumpTest (config, view, STACK_SRC); 132 134 psMemDump("sourcestats"); 133 135 … … 170 172 psphotFitSourcesLinear (config, view, STACK_SRC, false); 171 173 psphotStackVisualFilerule(config, view, STACK_SRC); 174 psphotDumpTest (config, view, STACK_SRC); 172 175 173 176 // measure the radial profiles to the sky … … 186 189 psphotBlendFit (config, view, STACK_SRC); // pass 1 (detections->allSources) 187 190 188 // replace all sources 189 psphotReplaceAllSources (config, view, STACK_SRC ); // pass 1 (detections->allSources)191 // replace all sources (do NOT ignore subtraction state) 192 psphotReplaceAllSources (config, view, STACK_SRC, false); // pass 1 (detections->allSources) 190 193 191 194 // if we only do one pass, skip to extended source analysis … … 194 197 // linear fit to include all sources (subtract again) 195 198 // NOTE : apply to ALL sources (extended + psf) 199 // NOTE 2 : this function subtracts the models from the given filerule (SRC) 196 200 psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 2 (detections->allSources) 197 201 … … 200 204 // NOTE: this block performs the 2nd pass low-significance PSF detection stage 201 205 { 206 // subtract all sources from DET (this will subtract using the psf model for SRC, which 207 // will somewhat oversubtract the sources -- this is OK 208 psphotRemoveAllSources (config, view, STACK_DET, true); // ignore subtraction state for sources 209 202 210 // add noise for subtracted objects 203 211 psphotAddNoise (config, view, STACK_DET); // pass 1 (detections->allSources) … … 212 220 213 221 // if DET and SRC are different images, copy the detections from DET to SRC 222 // (this operation just ensures the metadata container has a view on SRC as well 214 223 if (strcmp(STACK_SRC, STACK_DET)) { 215 // XXX how does this handle 1st vs 2nd pass sources?216 224 if (!psphotCopySources (config, view, STACK_SRC, STACK_DET)) { 217 225 psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis"); … … 220 228 } 221 229 230 // replace all sources in DET 231 psphotReplaceAllSources (config, view, STACK_DET, true); // ignore subtraction state for sources 232 222 233 // define new sources based on only the new peaks & measure moments 223 234 // NOTE: new sources are saved on detections->newSources 224 235 psphotSourceStats (config, view, STACK_SRC, false); // pass 2 (detections->newSources) 236 psphotDumpTest (config, view, STACK_SRC); 225 237 226 238 // set source type … … 237 249 // replace all sources so fit below applies to all at once 238 250 // NOTE: apply only to OLD sources (which have been subtracted) 239 psphotReplaceAllSources (config, view, STACK_SRC ); // pass 2251 psphotReplaceAllSources (config, view, STACK_SRC, false); // pass 2 240 252 241 253 // merge the newly selected sources into the existing list … … 243 255 // XXX check on free of sources... 244 256 psphotMergeSources (config, view, STACK_SRC); // (detections->newSources + detections->allSources -> detections->allSources) 257 psphotDumpTest (config, view, STACK_SRC); 245 258 } 246 259 … … 256 269 257 270 psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects); 271 psphotDumpTest (config, view, STACK_SRC); 258 272 259 273 // NOTE: apply to ALL sources … … 295 309 int nRadialEntries = psphotStackMatchPSFsEntries(config, view, STACK_OUT); 296 310 311 psphotDumpTest (config, view, STACK_SRC); 312 297 313 for (int entry = 1; entry < nRadialEntries; entry++) { 298 314 // NOTE: entry 0 is the unmatched image set … … 312 328 313 329 // replace the flux in the image so it is returned to its original state 314 psphotReplaceAllSources (config, view, STACK_OUT );330 psphotReplaceAllSources (config, view, STACK_OUT, false); 315 331 316 332 // smooth to the next FWHM, or set 'smoothAgain' to false if no more
Note:
See TracChangeset
for help on using the changeset viewer.
