IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 9, 2025, 11:21:40 AM (14 months ago)
Author:
eugene
Message:

add psphotFindFeatures; enable forced-photometry between cameras; do NOT skip negative-flux sources in full-force photometry; make PSF residual component generation more robust: IRLS vs median; exclude pixels with poor values (scaled value > 1.5, relative to normalized PSF); exclude pixels with too few inputs (<5); allow PSF clump to use clipped stats or robust stats

Location:
trunk/psphot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot

  • trunk/psphot/src/psphotSourceStats.c

    r41359 r42842  
    120120        source->moments = pmMomentsAlloc();
    121121
     122        // XXX can this ever be set at this point? (we just allocated the source and moments)
    122123        if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) {
    123124            fprintf (stderr, "moment failure\n");
     
    144145
    145146    if (setWindow) {
     147        // identify sources on lines, drop from MomentsWindow analysis
     148        psphotFindFeatures (readout, sources);
     149
    146150        if (!psphotSetMomentsWindow(recipe, readout->analysis, sources, maskVal)) {
    147151            psError(PS_ERR_UNEXPECTED_NULL, false, "Failed to determine Moments Window!");
     
    503507    }
    504508
     509    // use clipped stats or robust stats to define the clump
     510    bool PSF_CLUMP_USE_CLIPPED_STATS = psMetadataLookupF32(&status, recipe, "PSF_CLUMP_USE_CLIPPED_STATS");
     511    if (!status) { PSF_CLUMP_USE_CLIPPED_STATS = true; }
     512
    505513    // when we set the window, we are not attempting to measure spatial variations; we can use a somewhat higher S/N limit
    506514    // since we are using all sources (true?)
     
    539547    sources = psArraySort (sources, pmSourceSortByFlux);
    540548
     549    // generate an array of the sources which we want to use for this analysis
     550    // XXX move max source number to config
     551    psArray *sourceSubset = psArrayAllocEmpty (100);
     552    for (int i = 0; (i < sources->n) && (i < 400); i++) {
     553
     554        pmSource *source = sources->data[i];
     555
     556        // skip faint sources for moments measurement
     557        if (sqrt(source->peak->detValue) < MIN_SN) continue;
     558
     559        // skip sources on lines
     560        if (source->mode2 & PM_SOURCE_MODE2_ON_LINE) continue;
     561        psArrayAdd (sourceSubset, 100, source);
     562    }
     563
    541564    // loop over radii:
    542565    for (int i = 0; i < nsigma; i++) {
    543 
    544         // XXX move max source number to config
    545         for (int j = 0; (j < sources->n) && (j < 400); j++) {
    546 
    547             pmSource *source = sources->data[j];
     566        for (int j = 0; j < sourceSubset->n; j++) {
     567            pmSource *source = sourceSubset->data[j];
    548568            psAssert (source->moments, "force moments to exist");
    549569            source->moments->nPixels = 0;
     
    565585          sprintf (name, "moments.v%d.dat", i);
    566586          FILE *fout = fopen (name, "w");
    567           for (int j = 0; j < sources->n; j++) {
    568             pmSource *source = sources->data[j];
     587          for (int j = 0; j < sourceSubset->n; j++) {
     588            pmSource *source = sourceSubset->data[j];
    569589            psAssert (source->moments, "force moments to exist");
    570590            source->moments->nPixels = 0;
     
    581601
    582602        // determine the PSF parameters from the source moment values
    583         pmPSFClump psfClump = pmSourcePSFClump (NULL, NULL, sources, PSF_SN_LIM, PSF_CLUMP_GRID_SCALE, MOMENTS_SX_MAX, MOMENTS_SY_MAX, MOMENTS_SX_MIN, MOMENTS_SY_MIN, MOMENTS_AR_MAX);
     603        pmPSFClump psfClump = pmSourcePSFClump (NULL, NULL, sourceSubset, PSF_SN_LIM, PSF_CLUMP_GRID_SCALE, MOMENTS_SX_MAX, MOMENTS_SY_MAX, MOMENTS_SX_MIN, MOMENTS_SY_MIN, MOMENTS_AR_MAX, PSF_CLUMP_USE_CLIPPED_STATS);
    584604        psLogMsg ("psphot", 3, "sigma guess (pix) %.1f, nStars: %d of %d in clump, nSigma: %5.2f, X,  Y: %f, %f (%f, %f)\n", sigma[i], psfClump.nStars, psfClump.nTotal, psfClump.nSigma, psfClump.X, psfClump.Y, sqrt(psfClump.X) / sigma[i], sqrt(psfClump.Y) / sigma[i]);
    585605
    586         Rmin[i] = pmSourceMinKronRadius(sources, PSF_SN_LIM);
     606        Rmin[i] = pmSourceMinKronRadius(sourceSubset, PSF_SN_LIM);
    587607
    588608#if 0
     
    600620        psMetadataAddF32 (regionMD, PS_LIST_TAIL, "PSF.CLUMP.DY", PS_META_REPLACE, "psf clump center", psfClump.dY);
    601621        if (pmVisualTestLevel("psphot.moments.full", 2)) {
    602             psphotVisualPlotMoments (recipe, analysis, sources);
     622            psphotVisualPlotMoments (recipe, analysis, sourceSubset);
    603623        }
    604624#endif
     
    608628        Sout[i] = (Nout[i] == 0) ? NAN : sqrt(0.5*(psfClump.X + psfClump.Y)) / sigma[i];
    609629    }
     630
     631    psFree (sourceSubset);
    610632
    611633    // we are looking for sigma for which Sout = 0.65 (or some other value)
Note: See TracChangeset for help on using the changeset viewer.