- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
psphot (modified) (1 prop)
-
psphot/src (modified) (1 prop)
-
psphot/src/psphotBlendFit.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/psphot
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psphot merged eligible /branches/eam_branches/stackphot.20100406/psphot 27622-27655 /branches/pap_delete/psphot 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/psphot/src
- Property svn:ignore
-
old new 18 18 psphotVersionDefinitions.h 19 19 psphotMomentsStudy 20 psphotPetrosianStudy 21 psphotForced 22 psphotMakePSF 23 psphotStack
-
- Property svn:ignore
-
branches/simtest_nebulous_branches/psphot/src/psphotBlendFit.c
r24029 r27840 1 1 # include "psphotInternal.h" 2 2 3 // for now, let's store the detections on the readout->analysis for each readout 4 bool psphotBlendFit (pmConfig *config, const pmFPAview *view) 5 { 6 bool status = true; 7 8 // select the appropriate recipe information 9 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 10 psAssert (recipe, "missing recipe?"); 11 12 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 13 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 14 15 // loop over the available readouts 16 for (int i = 0; i < num; i++) { 17 if (!psphotBlendFitReadout (config, view, "PSPHOT.INPUT", i, recipe)) { 18 psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (non-linear) for PSPHOT.INPUT entry %d", i); 19 return false; 20 } 21 } 22 return true; 23 } 24 3 25 // XXX I don't like this name 4 bool psphotBlendFit (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf) {26 bool psphotBlendFitReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) { 5 27 6 28 int Nfit = 0; … … 12 34 psTimerStart ("psphot.fit.nonlinear"); 13 35 14 // select the appropriate recipe information 15 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 16 assert (recipe); 36 // find the currently selected readout 37 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 38 psAssert (file, "missing file?"); 39 40 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 41 psAssert (readout, "missing readout?"); 42 43 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 44 psAssert (detections, "missing detections?"); 45 46 psArray *sources = detections->allSources; 47 psAssert (sources, "missing sources?"); 48 49 if (!sources->n) { 50 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping blend fit"); 51 return true; 52 } 53 54 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 55 psAssert (psf, "missing psf?"); 17 56 18 57 // determine the number of allowed threads … … 40 79 psphotInitLimitsPSF (recipe, readout); 41 80 psphotInitLimitsEXT (recipe); 42 psphotInitRadiusPSF (recipe, psf->type);81 psphotInitRadiusPSF (recipe, readout->analysis, psf->type); 43 82 44 83 // starts the timer, sets up the array of fitSets … … 47 86 // source analysis is done in S/N order (brightest first) 48 87 sources = psArraySort (sources, pmSourceSortBySN); 88 if (!sources->n) { 89 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping blend"); 90 return true; 91 } 49 92 50 93 // choose Cx, Cy (see psphotThreadTools.c for overview of the concepts) … … 254 297 pmSourceCacheModel (source, maskVal); 255 298 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 256 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;257 299 } 258 300 … … 273 315 } 274 316 275 # if (0)276 bool psphotBlendFit_Unthreaded (int *nfit, int *npsf, int *next, int *nfail, pmReadout *readout, psMetadata *recipe, psArray *sources, pmPSF *psf, psArray *newSources) {277 278 bool status = false;279 int Nfit = 0;280 int Npsf = 0;281 int Next = 0;282 int Nfail = 0;283 284 // bit-masks to test for good/bad pixels285 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");286 assert (maskVal);287 288 // bit-mask to mark pixels not used in analysis289 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");290 assert (markVal);291 292 // maskVal is used to test for rejected pixels, and must include markVal293 maskVal |= markVal;294 295 // S/N limit to perform full non-linear fits296 float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM");297 298 // option to limit analysis to a specific region299 char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION");300 psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region));301 if (psRegionIsNaN (AnalysisRegion)) psAbort("analysis region mis-defined");302 303 for (int i = 0; i < sources->n; i++) {304 pmSource *source = sources->data[i];305 306 // skip non-astronomical objects (very likely defects)307 if (source->mode & PM_SOURCE_MODE_BLEND) continue;308 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue;309 if (source->type == PM_SOURCE_TYPE_DEFECT) continue;310 if (source->type == PM_SOURCE_TYPE_SATURATED) continue;311 312 // skip DBL second sources (ie, added by psphotFitBlob)313 if (source->mode & PM_SOURCE_MODE_PAIR) continue;314 315 // limit selection to some SN limit316 if (source->peak->SN < FIT_SN_LIM) continue;317 318 // exclude sources outside optional analysis region319 if (source->peak->xf < AnalysisRegion.x0) continue;320 if (source->peak->yf < AnalysisRegion.y0) continue;321 if (source->peak->xf > AnalysisRegion.x1) continue;322 if (source->peak->yf > AnalysisRegion.y1) continue;323 324 // if model is NULL, we don't have a starting guess325 if (source->modelPSF == NULL) continue;326 327 // skip sources which are insignificant flux?328 // XXX this is somewhat ad-hoc329 if (source->modelPSF->params->data.F32[1] < 0.1) {330 psTrace ("psphot", 5, "skipping near-zero source: %f, %f : %f\n",331 source->modelPSF->params->data.F32[1],332 source->modelPSF->params->data.F32[2],333 source->modelPSF->params->data.F32[3]);334 continue;335 }336 337 // replace object in image338 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) {339 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);340 }341 Nfit ++;342 343 // try fitting PSFs or extended sources depending on source->mode344 // these functions subtract the resulting fitted source345 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) {346 if (psphotFitBlob (readout, source, newSources, psf, maskVal, markVal)) {347 source->type = PM_SOURCE_TYPE_EXTENDED;348 psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->peak->xf, source->peak->yf);349 Next ++;350 continue;351 }352 } else {353 if (psphotFitBlend (readout, source, psf, maskVal, markVal)) {354 source->type = PM_SOURCE_TYPE_STAR;355 psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->peak->xf, source->peak->yf);356 Npsf ++;357 continue;358 }359 }360 361 psTrace ("psphot", 5, "source at %7.1f, %7.1f failed", source->peak->xf, source->peak->yf);362 Nfail ++;363 364 // re-subtract the object, leave local sky365 pmSourceCacheModel (source, maskVal);366 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);367 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;368 }369 370 // change the value of a scalar on the array (wrap this and put it in psArray.h)371 *nfit = Nfit;372 *npsf = Npsf;373 *next = Next;374 *nfail = Nfail;375 376 return true;377 }378 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
