IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13012


Ignore:
Timestamp:
Apr 24, 2007, 3:27:44 PM (19 years ago)
Author:
rhl
Message:

Added pmFootprint support

Location:
trunk/psphot/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotFindPeaks.c

    r12817 r13012  
    22
    33// In this function, we smooth the image, then search for the peaks
    4 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe, int pass) {
     4psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe,
     5                          bool returnFootprints,
     6                          const int pass) {
    57
    68    float SIGMA_SMTH, NSIGMA_SMTH, NSIGMA_PEAK;
     
    110112    }
    111113
    112     psFree (smooth_im);
    113     psFree (smooth_wt);
    114 
    115114    // optional dump of all peak data
    116115    char *output = psMetadataLookupStr (&status, recipe, "PEAKS_OUTPUT_FILE");
     
    119118    }
    120119    psLogMsg ("psphot", PS_LOG_INFO, "%ld peaks: %f sec\n", peaks->n, psTimerMark ("psphot"));
     120    //
     121    // If they asked us to return a set of pmFootprints, not a raw pmPeak list,
     122    // go ahead and find the footprints, and assign them their peaks.
     123    //
     124    // N.b. We're not culling this list; call pmFootprintCullPeaks if you
     125    // want to do that
     126    //
     127    if (returnFootprints) {     // We want an array of pmFootprint, not pmPeak
     128        int npixMin = psMetadataLookupS32(&status, recipe, "FOOTPRINT_NPIXMIN");
     129        if (!status) {
     130            npixMin = 1;
     131        }
     132        float FOOTPRINT_NSIGMA_LIMIT =
     133            psMetadataLookupS32(&status, recipe,
     134                                (pass == 1) ? "FOOTPRINT_NSIGMA_LIMIT" : "FOOTPRINT_NSIGMA_LIMIT_2");
     135        if (!status) {
     136            FOOTPRINT_NSIGMA_LIMIT = NSIGMA_PEAK;
     137        }
     138        threshold = PS_SQR(FOOTPRINT_NSIGMA_LIMIT)/effArea;
     139
     140        psArray *footprints = pmFindFootprints(smooth_im, threshold, npixMin);
     141        pmPeaksAssignToFootprints(footprints, peaks);
     142
     143        psFree(peaks);
     144        peaks = footprints;             // well, you know what I mean
     145    }
     146
     147    psFree (smooth_im);
     148    psFree (smooth_wt);
    121149
    122150    return (peaks);
    123151}
     152
     153
     154/************************************************************************************************************/
     155/*
     156 * Cull a set of peaks contained in a psArray of pmFootprints
     157 */
     158psErrorCode
     159psphotCullPeaks(const pmReadout *readout,
     160                const psMetadata *recipe,
     161                psArray *footprints) { // array of pmFootprints
     162    bool status = false;
     163    float nsigma_delta = psMetadataLookupF32(&status, recipe, "FOOTPRINT_CULL_NSIGMA_DELTA");
     164    if (!status) {
     165        nsigma_delta = 0; // min.
     166    }
     167    float nsigma_min = psMetadataLookupF32(&status, recipe, "FOOTPRINT_CULL_NSIGMA_MIN");
     168    if (!status) {
     169        nsigma_min = 0;
     170    }
     171    const float skyStdev = psMetadataLookupF32(NULL, recipe, "SKY_STDEV");
     172
     173    return pmFootprintArrayCullPeaks(readout->image, readout->weight, footprints,
     174                                     nsigma_delta, nsigma_min*skyStdev);
     175}
  • trunk/psphot/src/psphotReadout.c

    r12950 r13012  
    2020    PS_ASSERT_PTR_NON_NULL (breakPt, false);
    2121
     22    // Use the new pmFootprints approach?
     23    const bool useFootprints = psMetadataLookupBool(NULL, recipe, "USE_FOOTPRINTS");
     24
    2225    // generate mask & weight images if they don't already exit
    2326    if (!pmReadoutGenerateMaskWeight (readout, true)) {
     
    5861
    5962    // find the peaks in the image
    60     psArray *peaks = psphotFindPeaks (readout, recipe, 1);
     63    psArray *peaks;
     64    if (useFootprints) {
     65       psArray *footprints = psphotFindPeaks (readout, recipe, useFootprints, 1);
     66       peaks = pmFootprintArrayToPeaks(footprints);
     67       psFree(footprints);
     68    } else {
     69       peaks = psphotFindPeaks (readout, recipe, useFootprints, 1);
     70    }
     71
    6172    if (!peaks) {
    6273        psLogMsg ("psphot", 3, "unable to find peaks in this image");
     
    146157
    147158    // find the peaks in the image
    148     psArray *newPeaks = psphotFindPeaks (readout, recipe, 2);
     159    psArray *newPeaks;
     160    if (useFootprints) {
     161       psArray *newFootprints = psphotFindPeaks (readout, recipe, useFootprints, 2);
     162
     163       psphotCullPeaks(readout, recipe, newFootprints);
     164
     165       newPeaks = pmFootprintArrayToPeaks(newFootprints);
     166
     167       psFree(newFootprints);
     168    } else {
     169       newPeaks = psphotFindPeaks(readout, recipe, useFootprints, 2);
     170    }
    149171
    150172    // remove noise for subtracted objects
     
    186208
    187209    // calculate source magnitudes
    188     pmReadout *background = psphotSelectBackground (config, view);
     210    pmReadout *background = psphotSelectBackground (config, view, false);
    189211    psphotMagnitudes(sources, recipe, psf, background);
    190212
Note: See TracChangeset for help on using the changeset viewer.