Changeset 42843 for trunk/psModules
- Timestamp:
- May 9, 2025, 11:28:49 AM (12 months ago)
- Location:
- trunk/psModules
- Files:
-
- 9 edited
-
. (modified) (1 prop)
-
src/objects/pmPSF.h (modified) (1 diff)
-
src/objects/pmPSFtryFitEXT.c (modified) (1 diff)
-
src/objects/pmSource.c (modified) (5 diffs)
-
src/objects/pmSource.h (modified) (1 diff)
-
src/objects/pmSourceFitModel.c (modified) (2 diffs)
-
src/objects/pmSourceFitModel.h (modified) (1 diff)
-
src/objects/pmSourceMasks.h (modified) (1 diff)
-
src/objects/pmSourceMoments.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20230313/psModules (added) merged: 42436,42439,42501-42502,42504,42511,42528,42565,42678,42688,42710,42820
- Property svn:mergeinfo changed
-
trunk/psModules/src/objects/pmPSF.h
r36858 r42843 79 79 bool poissonErrorsParams; ///< use poission errors for model parameter fitting 80 80 81 bool fitPSFstarCoords; // Allow the PSF star positions to fit in the full fit? (pmPSFtryFitEXT) 81 82 bool chiFluxTrend; // Fit a trend in Chi2 as a function of flux? 82 83 pmSourceFitOptions *fitOptions; -
trunk/psModules/src/objects/pmPSFtryFitEXT.c
r36856 r42843 73 73 74 74 // in this segment, we are fitting the full PSF model class (shape unconstrained) 75 options->fitOptions->mode = PM_SOURCE_FIT_EXT; 76 75 if (options->fitPSFstarCoords) { 76 options->fitOptions->mode = PM_SOURCE_FIT_FULL; 77 } else { 78 options->fitOptions->mode = PM_SOURCE_FIT_EXT; 79 } 77 80 // maskVal is used to test for rejected pixels, and must include markVal 78 81 maskVal |= markVal; -
trunk/psModules/src/objects/pmSource.c
r40810 r42843 407 407 *****************************************************************************/ 408 408 409 pmPSFClump pmSourcePSFClump(psImage **savedImage, psRegion *region, psArray *sources, float PSF_SN_LIM, float PSF_CLUMP_GRID_SCALE, psF32 SX_MAX, psF32 SY_MAX, psF32 SX_MIN, psF32 SY_MIN, psF32 AR_MAX )409 pmPSFClump pmSourcePSFClump(psImage **savedImage, psRegion *region, psArray *sources, float PSF_SN_LIM, float PSF_CLUMP_GRID_SCALE, psF32 SX_MAX, psF32 SY_MAX, psF32 SX_MIN, psF32 SY_MIN, psF32 AR_MAX, bool useClippedMean) 410 410 { 411 411 psTrace("psModules.objects", 10, "---- begin ----\n"); … … 455 455 continue; 456 456 } 457 458 // skip sources associated with possible detector features 459 if (source->mode2 & PM_SOURCE_MODE2_ON_LINE) continue; 457 460 458 461 float Mxx = source->moments->Mxx, Myy = source->moments->Myy; // Second moments … … 598 601 } 599 602 600 // measures stats of Sx, Sy 601 stats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 602 603 if (!psVectorStats (stats, tmpSx, NULL, NULL, 0)) { 604 psError(PS_ERR_UNKNOWN, false, "failed to measure Sx stats"); 605 return (emptyClump); 606 } 607 psfClump.X = stats->clippedMean; 608 psfClump.dX = hypot(stats->clippedStdev, PSF_CLUMP_GRID_SCALE); 609 610 if (!psVectorStats (stats, tmpSy, NULL, NULL, 0)) { 611 psError(PS_ERR_UNKNOWN, false, "failed to measure Sy stats"); 612 return (emptyClump); 613 } 614 psfClump.Y = stats->clippedMean; 615 psfClump.dY = hypot(stats->clippedStdev, PSF_CLUMP_GRID_SCALE); 603 // measures stats of Sx, Sy 604 if (useClippedMean) { 605 stats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 606 } else { 607 stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 608 } 609 610 if (!psVectorStats (stats, tmpSx, NULL, NULL, 0)) { 611 psError(PS_ERR_UNKNOWN, false, "failed to measure Sx stats"); 612 return (emptyClump); 613 } 614 psfClump.X = psStatsGetValue (stats, psStatsMeanOption (stats->options)); 615 psfClump.dX = psStatsGetValue (stats, psStatsStdevOption (stats->options)); 616 psfClump.dX = hypot(psfClump.dX, PSF_CLUMP_GRID_SCALE); 617 618 if (!psVectorStats (stats, tmpSy, NULL, NULL, 0)) { 619 psError(PS_ERR_UNKNOWN, false, "failed to measure Sy stats"); 620 return (emptyClump); 621 } 622 psfClump.Y = psStatsGetValue (stats, psStatsMeanOption (stats->options)); 623 psfClump.dY = psStatsGetValue (stats, psStatsStdevOption (stats->options)); 624 psfClump.dY = hypot(psfClump.dX, PSF_CLUMP_GRID_SCALE); 616 625 617 626 psTrace ("psModules.objects", 2, "clump X, Y: %f, %f\n", psfClump.X, psfClump.Y); … … 746 755 } 747 756 757 psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY); 758 759 // XXX this is crude cut to avoid using extended sources in the PSF model 760 // psphot will update this analysis based on the PSF - Kron mags 748 761 // likely unsaturated extended source (too large to be stellar) 749 if (sigX > clump.X + 3*clump.dX || sigY > clump.Y + 3*clump.dY) { 762 // XXX old test: if (sigX > clump.X + 3*clump.dX || sigY > clump.Y + 3*clump.dY) { 763 764 if (radius > 2.0) { 750 765 source->type = PM_SOURCE_TYPE_EXTENDED; 751 766 Next ++; 752 767 continue; 753 768 } 769 770 // skip sources associated with possible detector features 771 if (source->mode2 & PM_SOURCE_MODE2_ON_LINE) continue; 754 772 755 773 // the rest are probable stellar objects … … 762 780 763 781 // PSF star (within 1.5 sigma of clump center, S/N > limit) 764 psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY);765 782 if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) { 766 783 source->type = PM_SOURCE_TYPE_STAR; -
trunk/psModules/src/objects/pmSource.h
r37321 r42843 245 245 psF32 SX_MIN, 246 246 psF32 SY_MIN, 247 psF32 AR_MAX 247 psF32 AR_MAX, 248 bool useClippedMean ///< use clipped mean & stdev to define clump, else robust 248 249 ); 249 250 -
trunk/psModules/src/objects/pmSourceFitModel.c
r42093 r42843 189 189 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_XPOS] = 0; 190 190 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_YPOS] = 0; 191 break; 192 case PM_SOURCE_FIT_FULL: 193 // PSFstar Full model fits all shape params and Xo, Yo, Io (not sky) 194 nParams = params->n - 1; 195 psVectorInit (constraint->paramMask, 0); 196 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1; 191 197 break; 192 198 case PM_SOURCE_FIT_EXT: … … 270 276 model->nPar = nParams; 271 277 272 psTrace ("psModules.objects", 4, "niter: %d, chisq: %f ", myMin->iter, myMin->value);278 psTrace ("psModules.objects", 4, "niter: %d, chisq: %f, status: %d", myMin->iter, myMin->value, fitStatus); 273 279 274 280 // save the resulting chisq, nDOF, nIter -
trunk/psModules/src/objects/pmSourceFitModel.h
r42093 r42843 18 18 PM_SOURCE_FIT_PSF, 19 19 PM_SOURCE_FIT_EXT, 20 PM_SOURCE_FIT_FULL, 20 21 PM_SOURCE_FIT_PSF_AND_SKY, 21 22 PM_SOURCE_FIT_EXT_AND_SKY, -
trunk/psModules/src/objects/pmSourceMasks.h
r42293 r42843 47 47 PM_SOURCE_MODE2_MATCHED = 0x00000004, ///< source generated based on another image 48 48 PM_SOURCE_MODE2_ON_SPIKE = 0x00000008, ///< > 25% of (PSF-weighted) pixels land on diffraction spike 49 49 50 PM_SOURCE_MODE2_ON_STARCORE = 0x00000010, ///< > 25% of (PSF-weighted) pixels land on starcore 50 51 PM_SOURCE_MODE2_ON_BURNTOOL = 0x00000020, ///< > 25% of (PSF-weighted) pixels land on burntool 51 52 PM_SOURCE_MODE2_ON_CONVPOOR = 0x00000040, ///< > 25% of (PSF-weighted) pixels land on convpoor 52 53 PM_SOURCE_MODE2_PASS1_SRC = 0x00000080, ///< source detected in first pass analysis 54 53 55 PM_SOURCE_MODE2_HAS_BRIGHTER_NEIGHBOR = 0x00000100, ///< peak is not the brightest in its footprint 54 56 PM_SOURCE_MODE2_BRIGHT_NEIGHBOR_1 = 0x00000200, ///< flux_n / (r^2 flux_p) > 1 55 57 PM_SOURCE_MODE2_BRIGHT_NEIGHBOR_10 = 0x00000400, ///< flux_n / (r^2 flux_p) > 10 56 58 PM_SOURCE_MODE2_DIFF_SELF_MATCH = 0x00000800, ///< positive detection match is probably this source 59 57 60 PM_SOURCE_MODE2_SATSTAR_PROFILE = 0x00001000, ///< saturated source is modeled with a radial profile 58 59 61 PM_SOURCE_MODE2_ECONTOUR_FEW_PTS = 0x00002000, ///< too few points to measure the elliptical contour 60 62 PM_SOURCE_MODE2_RADBIN_NAN_CENTER = 0x00004000, ///< radial bins failed with too many NaN center bin 61 63 PM_SOURCE_MODE2_PETRO_NAN_CENTER = 0x00008000, ///< petrosian radial bins failed with too many NaN center bin 64 62 65 PM_SOURCE_MODE2_PETRO_NO_PROFILE = 0x00010000, ///< petrosian not build because radial bins missing 63 64 66 PM_SOURCE_MODE2_PETRO_INSIG_RATIO = 0x00020000, ///< insignificant measurement of petrosian ratio 65 67 PM_SOURCE_MODE2_PETRO_RATIO_ZEROBIN = 0x00040000, ///< petrosian ratio in the 0th bin (likely bad) 66 67 68 PM_SOURCE_MODE2_EXT_FITS_RUN = 0x00080000, ///< we attempted to run extended fits on this source 69 68 70 PM_SOURCE_MODE2_EXT_FITS_FAIL = 0x00100000, ///< at least one of the model fits failed 69 71 PM_SOURCE_MODE2_EXT_FITS_RETRY = 0x00200000, ///< one of the model fits was re-tried with new window 70 72 PM_SOURCE_MODE2_EXT_FITS_NONE = 0x00400000, ///< ALL of the model fits failed 71 72 73 PM_SOURCE_MODE2_ON_GHOST = 0x00800000, ///< > 25% of (PSF-weighted) pixels land on ghost 74 73 75 PM_SOURCE_MODE2_ON_CROSSTALK = 0x01000000, ///< peaks land on electronic crostalk 74 76 PM_SOURCE_MODE2_ON_CTE = 0x02000000, ///< peaks land on CTE region 77 PM_SOURCE_MODE2_ON_LINE = 0x04000000, ///< peaks land on Linear feature 75 78 76 79 -
trunk/psModules/src/objects/pmSourceMoments.c
r42484 r42843 231 231 } 232 232 233 // we only update the centroid if the position is not supplied from elsewhere 233 // For faint externally-supplied sources, the centroids are unreliable. 234 // In those cases, we should keep the peak position instead of the centroid position. 234 235 bool skipCentroid = false; 235 236 skipCentroid |= (source->mode & PM_SOURCE_MODE_EXTERNAL); // skip externally supplied positions … … 245 246 } 246 247 247 // only skip negative sum sources if the sources are not forced248 // Skip negative-sum sources, but only if the sources are not forced (externally supplied) 248 249 if (!skipCentroid && (Sum <= 0)) { 249 250 psTrace ("psModules.objects", 3, "insufficient significant pixels (%d vs %d; %f) for source\n", numPixels, minPixels, Sum); … … 259 260 psTrace ("psModules.objects", 5, "id: %d, sky: %f Mx: %f My: %f Sum: %f X1: %f Y1: %f Npix: %d\n", source->id, sky, Mx, My, Sum, X1, Y1, numPixels); 260 261 262 // XXX EAM : I need to move this block so I can use SN to choose if we keep the centroids or not 263 source->moments->Sum = Sum; 264 source->moments->SN = Sum / sqrt(Var); 265 source->moments->Peak = peakPixel; 266 source->moments->nPixels = numPixels; 267 261 268 // add back offset of peak in primary image 262 269 // also offset from pixel index to pixel coordinate … … 264 271 // 0.5 PIX: moments are calculated using the pixel index and converted here to pixel coords 265 272 266 if (skipCentroid) { 273 // XXX for a test, do NOT skip the centroid for relatively strong sources, even if forced 274 // XXX this is a somewhat arbitrary limit. use PSF_SN_LIM (see below) instead? 275 if (skipCentroid && (source->moments->SN < 25)) { 267 276 source->moments->Mx = source->peak->xf; 268 277 source->moments->My = source->peak->yf; … … 270 279 if ((fabs(Mx) > radius) || (fabs(My) > radius)) { 271 280 psTrace ("psModules.objects", 3, "extreme centroid swing; invalid peak %d, %d\n", source->peak->x, source->peak->y); 281 282 // XXX should we really be rejecting these sources, or just keeping the peak position? 272 283 return (false); 284 285 source->moments->Mx = source->peak->xf; 286 source->moments->My = source->peak->yf; 287 return (true); 273 288 } 274 289 source->moments->Mx = Mx + xGuess; 275 290 source->moments->My = My + yGuess; 276 291 } 277 278 source->moments->Sum = Sum;279 source->moments->SN = Sum / sqrt(Var);280 source->moments->Peak = peakPixel;281 source->moments->nPixels = numPixels;282 292 283 293 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
