IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30883


Ignore:
Timestamp:
Mar 12, 2011, 10:06:53 AM (15 years ago)
Author:
eugene
Message:

limit the number of psf clump regions based on number of available sources; require better sources in the initial assessment of the window for the psf clump (SNLIM*2)

Location:
branches/eam_branches/ipp-20110213/psphot/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/psphot/src/psphot.h

    r30749 r30883  
    253253bool            psphotVisualShowLogSignificance (psImage *image, float min, float max);
    254254bool            psphotVisualShowPeaks (pmDetections *detections);
     255bool            psphotVisualShowSources (psArray *sources);
    255256bool            psphotVisualShowFootprints (pmDetections *detections);
    256257bool            psphotVisualShowMoments (psArray *sources);
  • branches/eam_branches/ipp-20110213/psphot/src/psphotMergeSources.c

    r30776 r30883  
    11# include "psphotInternal.h"
    22
     3// Mask to apply for PSF sources : only exclude bad sources -- we will re-test for extendedness
    34#define PSF_SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_SATSTAR | PM_SOURCE_MODE_BLEND | \
    45                         PM_SOURCE_MODE_BADPSF | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \
    5                          PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply for PSF sources
     6                         PM_SOURCE_MODE_CR_LIMIT)
    67
    78// for now, let's store the detections on the readout->analysis for each readout
     
    347348
    348349    psLogMsg ("psphot", 3, "%ld PSF sources loaded", detections->peaks->n);
     350    psphotVisualShowSources (sources);
     351    psphotVisualShowPeaks (detections);
    349352
    350353    // save detections on the readout->analysis
     
    354357    }
    355358    psFree (detections);
     359
    356360    return true;
    357361}
    358362
    359363// generate the detection structure for the supplied array of sources
     364// XXX this function is currently unused
    360365bool psphotSetSourceParams (pmConfig *config, psArray *sources, pmPSF *psf) {
    361366
  • branches/eam_branches/ipp-20110213/psphot/src/psphotRoughClass.c

    r29936 r30883  
    6363    }
    6464
     65    int NstarsInClump = psMetadataLookupS32 (&status, readout->analysis, "PSF_CLUMP_NSTARS");
     66    // if NstarsInClump is not defined, use the user-selected option:
     67    if (!status) {
     68        NstarsInClump = 1000;
     69    }
     70
     71    int ScaleForClump = 1;
     72    if (NstarsInClump >= 12) ScaleForClump = 2; // 4 cells
     73    if (NstarsInClump >= 27) ScaleForClump = 3; // 9 cells
     74    if (NstarsInClump >= 48) ScaleForClump = 4; // 16 cells
     75    if (NstarsInClump >  75) ScaleForClump = 5; // 25 cells
     76
    6577    // we make this measurement on a NxM grid of regions across the readout
    6678    int NX  = psMetadataLookupS32 (&status, recipe, "PSF_CLUMP_NX");  CHECK_STATUS (status, "PSF_CLUMP_NX");
    6779    int NY  = psMetadataLookupS32 (&status, recipe, "PSF_CLUMP_NY");  CHECK_STATUS (status, "PSF_CLUMP_NY");
    68     int dX  = readout->image->numCols / NX;
    69     int dY  = readout->image->numRows / NY;
     80
     81    int NXuse, NYuse;
     82
     83    ScaleForClump = PS_MIN(ScaleForClump, PS_MAX(NX, NY));
     84    if (NX > NY) {
     85        NXuse = ScaleForClump;
     86        NYuse = (int) (ScaleForClump * (NY / NX) + 0.5);
     87    } else {
     88        NYuse = ScaleForClump;
     89        NXuse = (int) (ScaleForClump * (NY / NX) + 0.5);
     90    }
     91
     92    psLogMsg ("psphot", 4, "With %d stars, using %d x %d grid for PSF clump\n", NstarsInClump, NXuse, NYuse);
     93
     94    int dX  = readout->image->numCols / NXuse;
     95    int dY  = readout->image->numRows / NYuse;
    7096
    7197    int nRegion = 0;
    72     for (int ix = 0; ix < NX; ix ++) {
    73         for (int iy = 0; iy < NY; iy ++) {
     98    for (int ix = 0; ix < NXuse; ix ++) {
     99        for (int iy = 0; iy < NYuse; iy ++) {
    74100
    75101            psRegion *region = psRegionAlloc (ix*dX, (ix + 1)*dX, iy*dY, (iy + 1)*dY);
     
    181207        return false;
    182208    }
    183     psLogMsg ("psphot", 3, "psf clump  X,  Y: %f, %f\n", psfClump.X, psfClump.Y);
    184     psLogMsg ("psphot", 3, "psf clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY);
     209    psLogMsg ("psphot", 3, "psf clump  X,  Y: %f, %f : DX, DY: %f, %f : nStars %d of %d\n", psfClump.X, psfClump.Y, psfClump.dX, psfClump.dY, psfClump.nStars, psfClump.nTotal);
    185210
    186211    // get basic parameters, or set defaults
  • branches/eam_branches/ipp-20110213/psphot/src/psphotSourceStats.c

    r30866 r30883  
    482482
    483483    float MIN_SN = psMetadataLookupF32 (&status, recipe, "MOMENTS_SN_MIN"); psAssert (status, "missing MOMENTS_SN_MIN");
    484     float PSF_SN_LIM = psMetadataLookupF32(&status, recipe, "PSF_SN_LIM"); psAssert (status, "missing PSF_SN_LIM");
    485484    psF32 MOMENTS_AR_MAX = psMetadataLookupF32(&status, recipe, "MOMENTS_AR_MAX"); psAssert (status, "missing MOMENTS_AR_MAX");
     485
     486    // when we set the window, we are not attempting to measure spatial variations; we can use a somewhat higher S/N limit
     487    // since we are using all sources (true?)
     488    float PSF_SN_LIM = 2.0*psMetadataLookupF32(&status, recipe, "PSF_SN_LIM"); psAssert (status, "missing PSF_SN_LIM");
    486489
    487490    // XXX move this to a config file?
     
    489492    float sigma[NSIGMA] = {1.0, 2.0, 3.0, 4.5, 6.0, 9.0, 12.0, 18.0};
    490493    float Sout[NSIGMA];
     494    int   Nout[NSIGMA]; // number of stars found in clump : use this to control the number of regions measured by psphotRoughClass
    491495
    492496    // this sorts by peak->SN
     
    519523        // determine the PSF parameters from the source moment values
    520524        pmPSFClump psfClump = pmSourcePSFClump (NULL, NULL, sources, PSF_SN_LIM, PSF_CLUMP_GRID_SCALE, MOMENTS_SX_MAX, MOMENTS_SY_MAX, MOMENTS_AR_MAX);
    521         psLogMsg ("psphot", 3, "radius %.1f, nStars: %d, nSigma: %5.2f, X,  Y: %f, %f (%f, %f)\n", sigma[i], psfClump.nStars, psfClump.nSigma, psfClump.X, psfClump.Y, sqrt(psfClump.X) / sigma[i], sqrt(psfClump.Y) / sigma[i]);
     525        psLogMsg ("psphot", 3, "radius %.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]);
    522526
    523527#if 0
     
    540544
    541545        Sout[i] = sqrt(0.5*(psfClump.X + psfClump.Y)) / sigma[i];
     546        Nout[i] = psfClump.nStars;
    542547    }
    543548
    544549    // we are looking for sigma for which Sout = 0.65 (or some other value)
     550    int Nstars = 0;
    545551    float Sigma = NAN;
    546552    float minS = Sout[0];
     
    558564        if ((Sout[i] < 0.65) && (Sout[i+1] < 0.65)) continue;
    559565        Sigma = sigma[i] + (0.65 - Sout[i])*(sigma[i+1] - sigma[i])/(Sout[i+1] - Sout[i]);
     566        Nstars = 0.5*(Nout[i] + Nout[i+1]);
    560567    }
    561568    psAssert (isfinite(Sigma), "did we miss a case?");
     
    567574    psMetadataAddF32(analysis, PS_LIST_TAIL, "MOMENTS_GAUSS_SIGMA", PS_META_REPLACE, "moments limit", Sigma);
    568575    psMetadataAddF32(analysis, PS_LIST_TAIL, "PSF_MOMENTS_RADIUS", PS_META_REPLACE, "moments limit", 4.0*Sigma);
     576    psMetadataAddF32(analysis, PS_LIST_TAIL, "PSF_CLUMP_NSTARS", PS_META_REPLACE, "number of stars in clump", Nstars);
    569577
    570578    psLogMsg ("psphot", 3, "using window function with sigma = %f\n", Sigma);
  • branches/eam_branches/ipp-20110213/psphot/src/psphotVisual.c

    r30764 r30883  
    350350}
    351351
     352// requires psphotVisualShowImage
     353bool psphotVisualShowSources (psArray *sources) {
     354
     355    int Noverlay;
     356    KiiOverlay *overlay;
     357
     358    if (!pmVisualTestLevel("psphot.objects.sources", 1)) return true;
     359
     360    int kapa = psphotKapaChannel (1);
     361    if (kapa == -1) return false;
     362
     363    // note: this uses the Ohana allocation tools:
     364    // ALLOCATE (overlay, KiiOverlay, 3*peaks->n + 1);
     365    ALLOCATE (overlay, KiiOverlay, sources->n + 2);
     366
     367    Noverlay = 0;
     368    for (int i = 0; i < sources->n; i++) {
     369
     370        pmSource *source = sources->data[i];
     371        if (!source) continue;
     372
     373        pmPeak *peak = source->peak;
     374        if (!peak) continue;
     375
     376        overlay[Noverlay].type = KII_OVERLAY_BOX;
     377        overlay[Noverlay].x = peak->xf;
     378        overlay[Noverlay].y = peak->yf;
     379        overlay[Noverlay].dx = 4.0;
     380        overlay[Noverlay].dy = 4.0;
     381        overlay[Noverlay].angle = 0.0;
     382        overlay[Noverlay].text = NULL;
     383        Noverlay ++;
     384    }
     385
     386    KiiLoadOverlay (kapa, overlay, Noverlay, "blue");
     387    FREE (overlay);
     388
     389    pmVisualAskUser(NULL);
     390    return true;
     391}
     392
    352393// XXX : requires psphotVisualShowImage
    353394bool psphotVisualShowPeaks (pmDetections *detections) {
Note: See TracChangeset for help on using the changeset viewer.