- Timestamp:
- Jan 26, 2010, 5:10:34 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/psphot.stack.20100120/src/psphotBlendFit.c
r26681 r26688 36 36 // find the currently selected readout 37 37 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 38 psAssert ( readout, "missing file?");38 psAssert (file, "missing file?"); 39 39 40 40 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 41 41 psAssert (readout, "missing readout?"); 42 42 43 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 43 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 44 psAssert (detections, "missing detections?"); 45 46 psArray *sources = detections->allSources; 44 47 psAssert (sources, "missing sources?"); 45 48 … … 312 315 } 313 316 314 # if (0)315 bool psphotBlendFit_Unthreaded (int *nfit, int *npsf, int *next, int *nfail, pmReadout *readout, psMetadata *recipe, psArray *sources, pmPSF *psf, psArray *newSources) {316 317 bool status = false;318 int Nfit = 0;319 int Npsf = 0;320 int Next = 0;321 int Nfail = 0;322 323 // bit-masks to test for good/bad pixels324 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");325 assert (maskVal);326 327 // bit-mask to mark pixels not used in analysis328 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");329 assert (markVal);330 331 // maskVal is used to test for rejected pixels, and must include markVal332 maskVal |= markVal;333 334 // S/N limit to perform full non-linear fits335 float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM");336 337 // option to limit analysis to a specific region338 char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION");339 psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region));340 if (psRegionIsNaN (AnalysisRegion)) psAbort("analysis region mis-defined");341 342 for (int i = 0; i < sources->n; i++) {343 pmSource *source = sources->data[i];344 345 // skip non-astronomical objects (very likely defects)346 if (source->mode & PM_SOURCE_MODE_BLEND) continue;347 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue;348 if (source->type == PM_SOURCE_TYPE_DEFECT) continue;349 if (source->type == PM_SOURCE_TYPE_SATURATED) continue;350 351 // skip DBL second sources (ie, added by psphotFitBlob)352 if (source->mode & PM_SOURCE_MODE_PAIR) continue;353 354 // limit selection to some SN limit355 if (source->peak->SN < FIT_SN_LIM) continue;356 357 // exclude sources outside optional analysis region358 if (source->peak->xf < AnalysisRegion.x0) continue;359 if (source->peak->yf < AnalysisRegion.y0) continue;360 if (source->peak->xf > AnalysisRegion.x1) continue;361 if (source->peak->yf > AnalysisRegion.y1) continue;362 363 // if model is NULL, we don't have a starting guess364 if (source->modelPSF == NULL) continue;365 366 // skip sources which are insignificant flux?367 // XXX this is somewhat ad-hoc368 if (source->modelPSF->params->data.F32[1] < 0.1) {369 psTrace ("psphot", 5, "skipping near-zero source: %f, %f : %f\n",370 source->modelPSF->params->data.F32[1],371 source->modelPSF->params->data.F32[2],372 source->modelPSF->params->data.F32[3]);373 continue;374 }375 376 // replace object in image377 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) {378 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);379 }380 Nfit ++;381 382 // try fitting PSFs or extended sources depending on source->mode383 // these functions subtract the resulting fitted source384 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) {385 if (psphotFitBlob (readout, source, newSources, psf, maskVal, markVal)) {386 source->type = PM_SOURCE_TYPE_EXTENDED;387 psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->peak->xf, source->peak->yf);388 Next ++;389 continue;390 }391 } else {392 if (psphotFitBlend (readout, source, psf, maskVal, markVal)) {393 source->type = PM_SOURCE_TYPE_STAR;394 psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->peak->xf, source->peak->yf);395 Npsf ++;396 continue;397 }398 }399 400 psTrace ("psphot", 5, "source at %7.1f, %7.1f failed", source->peak->xf, source->peak->yf);401 Nfail ++;402 403 // re-subtract the object, leave local sky404 pmSourceCacheModel (source, maskVal);405 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);406 }407 408 // change the value of a scalar on the array (wrap this and put it in psArray.h)409 *nfit = Nfit;410 *npsf = Npsf;411 *next = Next;412 *nfail = Nfail;413 414 // moments are modified by the fit; re-display415 psphotVisualPlotMoments (recipe, sources);416 psphotVisualShowResidualImage (readout);417 418 return true;419 }420 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
