Changeset 25027 for branches/pap/psModules/src/objects/pmSource.c
- Timestamp:
- Aug 7, 2009, 4:08:25 PM (17 years ago)
- Location:
- branches/pap
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/psModules
- Property svn:mergeinfo deleted
-
branches/pap/psModules/src/objects/pmSource.c
r23187 r25027 242 242 extend |= (mySource->maskView == NULL); 243 243 244 // extend = true;245 244 if (extend) { 246 245 // re-create the subimage … … 250 249 251 250 mySource->pixels = psImageSubset(readout->image, newRegion); 252 mySource->variance = psImageSubset(readout->variance, newRegion);251 mySource->variance = psImageSubset(readout->variance, newRegion); 253 252 mySource->maskView = psImageSubset(readout->mask, newRegion); 254 253 mySource->region = newRegion; … … 291 290 292 291 bool status = true; // Status of MD lookup 293 float PSF_ CLUMP_SN_LIM = psMetadataLookupF32(&status, recipe, "PSF_CLUMP_SN_LIM");292 float PSF_SN_LIM = psMetadataLookupF32(&status, recipe, "PSF_SN_LIM"); 294 293 if (!status) { 295 PSF_ CLUMP_SN_LIM = 0;294 PSF_SN_LIM = 0; 296 295 } 297 296 float PSF_CLUMP_GRID_SCALE = psMetadataLookupF32(&status, recipe, "PSF_CLUMP_GRID_SCALE"); … … 342 341 } 343 342 344 if (src->moments->SN < PSF_ CLUMP_SN_LIM) {343 if (src->moments->SN < PSF_SN_LIM) { 345 344 psTrace("psModules.objects", 10, "Rejecting source from clump because of low S/N (%f)\n", 346 345 src->moments->SN); … … 450 449 if (tmpSrc->moments == NULL) 451 450 continue; 452 if (tmpSrc->moments->SN < PSF_ CLUMP_SN_LIM)451 if (tmpSrc->moments->SN < PSF_SN_LIM) 453 452 continue; 454 453 … … 479 478 stats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 480 479 481 psVectorStats (stats, tmpSx, NULL, NULL, 0); 480 if (!psVectorStats (stats, tmpSx, NULL, NULL, 0)) { 481 psError(PS_ERR_UNKNOWN, false, "failed to measure Sx stats"); 482 return (emptyClump); 483 } 482 484 psfClump.X = stats->clippedMean; 483 485 psfClump.dX = stats->clippedStdev; 484 486 485 psVectorStats (stats, tmpSy, NULL, NULL, 0); 487 if (!psVectorStats (stats, tmpSy, NULL, NULL, 0)) { 488 psError(PS_ERR_UNKNOWN, false, "failed to measure Sy stats"); 489 return (emptyClump); 490 } 486 491 psfClump.Y = stats->clippedMean; 487 492 psfClump.dY = stats->clippedStdev; … … 528 533 bool status; 529 534 float PSF_SN_LIM = psMetadataLookupF32 (&status, recipe, "PSF_SN_LIM"); 530 if (!status) 531 PSF_SN_LIM = 20.0; 535 if (!status) PSF_SN_LIM = 20.0; 532 536 float PSF_CLUMP_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_CLUMP_NSIGMA"); 533 if (!status) 534 PSF_CLUMP_NSIGMA = 1.5; 535 float INNER_RADIUS = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS");537 if (!status) PSF_CLUMP_NSIGMA = 1.5; 538 539 // float INNER_RADIUS = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS"); 536 540 537 541 pmSourceMode noMoments = PM_SOURCE_MODE_MOMENTS_FAILURE | PM_SOURCE_MODE_SKYVAR_FAILURE | PM_SOURCE_MODE_SKY_FAILURE | PM_SOURCE_MODE_BELOW_MOMENTS_SN; … … 543 547 pmSource *source = (pmSource *) sources->data[i]; 544 548 545 // psf clumps are found for image subregions:546 // skip sources not in this region 549 // psf clumps are found for image subregions: 550 // skip sources not in this region 547 551 if (source->peak->x < region->x0) continue; 548 552 if (source->peak->x >= region->x1) continue; 549 553 if (source->peak->y < region->y0) continue; 550 if (source->peak->y >= region->y1) continue;551 552 // should be set by pmSourceAlloc554 if (source->peak->y >= region->y1) continue; 555 556 // should be set by pmSourceAlloc 553 557 psAssert (source->type == PM_SOURCE_TYPE_UNKNOWN, "source type was not init-ed?"); 554 558 … … 556 560 if (!source->moments) { 557 561 source->type = PM_SOURCE_TYPE_STAR; 558 psAssert (source->mode & noMoments, "why is this source missing moments?");562 psAssert (source->mode & noMoments, "why is this source missing moments?"); 559 563 Nstar++; 560 564 continue; … … 576 580 source->type = PM_SOURCE_TYPE_STAR; 577 581 source->mode |= PM_SOURCE_MODE_SATSTAR; 578 // recalculate moments here with larger box? 579 pmSourceMoments (source, INNER_RADIUS); 582 // why do we recalculate moments here? 583 // we already attempt to do this in psphotSourceStats 584 // pmSourceMoments (source, INNER_RADIUS); 580 585 Nsatstar ++; 581 586 continue; … … 590 595 } 591 596 592 // likely defect (too small to be stellar) (push out to 3 sigma) 593 // low S/N objects which are small are probably stellar 594 // only set candidate defects if 595 // XXX these limits are quite arbitrary 596 if ((sigX < 0.05) || (sigY < 0.05)) { 597 source->type = PM_SOURCE_TYPE_DEFECT; 598 source->mode |= PM_SOURCE_MODE_DEFECT; 599 Ncr ++; 600 continue; 601 } 602 603 // likely unsaturated extended source (too large to be stellar) 604 if ((sigX > (clump.X + 3*clump.dX)) || (sigY > (clump.Y + 3*clump.dY))) { 605 source->type = PM_SOURCE_TYPE_EXTENDED; 606 Next ++; 607 continue; 608 } 609 610 // the rest are probable stellar objects 611 starsn_moments->data.F32[starsn_moments->n] = source->moments->SN; 612 starsn_moments->n ++; 613 starsn_peaks->data.F32[starsn_peaks->n] = source->peak->SN; 614 starsn_peaks->n ++; 615 Nstar ++; 616 617 // PSF star (within 1.5 sigma of clump center, S/N > limit) 618 psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY); 619 if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) { 620 source->type = PM_SOURCE_TYPE_STAR; 621 source->mode |= PM_SOURCE_MODE_PSFSTAR; 622 Npsf ++; 623 continue; 597 // The following determinations require the use of moments 598 if (!(source->mode & noMoments)) { 599 // likely defect (too small to be stellar) (push out to 3 sigma) 600 // low S/N objects which are small are probably stellar 601 // XXX these limits are quite arbitrary 602 if (sigX < 0.05 || sigY < 0.05) { 603 source->type = PM_SOURCE_TYPE_DEFECT; 604 source->mode |= PM_SOURCE_MODE_DEFECT; 605 Ncr ++; 606 continue; 607 } 608 609 // likely unsaturated extended source (too large to be stellar) 610 if (sigX > clump.X + 3*clump.dX || sigY > clump.Y + 3*clump.dY) { 611 source->type = PM_SOURCE_TYPE_EXTENDED; 612 Next ++; 613 continue; 614 } 615 616 // the rest are probable stellar objects 617 starsn_moments->data.F32[starsn_moments->n] = source->moments->SN; 618 starsn_moments->n ++; 619 starsn_peaks->data.F32[starsn_peaks->n] = source->peak->SN; 620 starsn_peaks->n ++; 621 Nstar ++; 622 623 // PSF star (within 1.5 sigma of clump center, S/N > limit) 624 psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY); 625 if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) { 626 source->type = PM_SOURCE_TYPE_STAR; 627 source->mode |= PM_SOURCE_MODE_PSFSTAR; 628 Npsf ++; 629 continue; 630 } 624 631 } 625 632 … … 636 643 637 644 if (!psVectorStats (stats, starsn_moments, NULL, NULL, 0)) { 638 // Don't care about this error 639 psErrorClear(); 645 psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats"); 646 psFree (stats); 647 psFree (starsn_peaks); 648 return false; 640 649 } 641 650 psLogMsg ("pmObjects", 3, "SN range (moments): %f - %f\n", stats->min, stats->max); … … 648 657 stats = psStatsAlloc (PS_STAT_MIN | PS_STAT_MAX); 649 658 if (!psVectorStats (stats, starsn_peaks, NULL, NULL, 0)) { 650 // Don't care about this error 651 psErrorClear(); 659 psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats"); 660 psFree (stats); 661 psFree (starsn_peaks); 662 return false; 652 663 } 653 664 psLogMsg ("psModules.objects", 3, "SN range (peaks) : %f - %f (%ld)\n",
Note:
See TracChangeset
for help on using the changeset viewer.
