IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33591


Ignore:
Timestamp:
Mar 22, 2012, 10:05:00 AM (14 years ago)
Author:
bills
Message:

Various bug fixes for psphotStack

Location:
tags/ipp-20120216
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20120216/psModules/src/objects

  • tags/ipp-20120216/psModules/src/objects/pmFootprintCullPeaks.c

    r32998 r33591  
    178178            psArray *myFP = pmFootprintsFind(subImg, threshold, 5);
    179179            if (!myFP) {
    180                 psWarning ("missing footprint?");
     180                psWarning ("missing footprint? threshold: %.f", threshold);
    181181                continue;
    182182            }
    183183            if (!myFP->n) {
    184                 psWarning ("empty footprint?");
     184                psWarning ("empty footprint? threshold: %.f", threshold);
    185185                psFree (myFP);
    186186                continue;
  • tags/ipp-20120216/psModules/src/objects/pmPSFtryFitEXT.c

    r30621 r33591  
    7373            continue;
    7474        }
     75        // If mask object does not exist, mark the source as bad.
     76        // We cannot proceed with it because psImageMaskPixels leaves an uncleared error code last which causes
     77        // psphot to exit with a fault.
     78        if (source->maskObj == NULL) {
     79            psTrace ("psModules.objects", 4, "source %d (%d,%d) : null maskObj\n", i, source->peak->x, source->peak->y);
     80            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
     81            continue;
     82        }
    7583
    7684        source->modelEXT = pmSourceModelGuess (source, options->type);
     
    8997
    9098        // clear object mask to define valid pixels
    91         psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask
     99        psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask
    92100
    93101        // exclude the poor fits
  • tags/ipp-20120216/psModules/src/objects/pmSourceIO.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • tags/ipp-20120216/psphot/src

  • tags/ipp-20120216/psphot/src/psphotSourceMatch.c

    r32996 r33591  
    33bool psphotMatchSourcesAddMissing (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *objects);
    44bool psphotMatchSourcesSetIDs (psArray *objects);
     5
     6static psArray     *psphotMatchFootprintCacheAlloc (int nImages);
     7static pmFootprint *psphotMatchLookupFootprint (psArray *cache, int footprintID, int imageID);
     8static pmFootprint *psphotMatchCopyFootprint (psArray *cache, pmFootprint *footprint, int imageID, psImage *image, psArray *footprints);
    59 
    610psArray *psphotMatchSources (pmConfig *config, const pmFPAview *view, const char *filerule)
     
    193197    // vector to track if source for an image is found
    194198    psVector *found = psVectorAlloc(nImages, PS_TYPE_U8);
     199    psArray *footprintCache = psphotMatchFootprintCacheAlloc(nImages);
    195200
    196201    for (int i = 0; i < objects->n; i++) {
     
    219224
    220225        // we make a copy of the largest footprint; this will be used for all new sources associated with this object
    221         pmFootprint *footprint = NULL;
     226        pmFootprint *largestFootprint = NULL;
    222227        if (iSpansMax != -1) { // copy the footprint info
    223228            pmSource *src = obj->sources->data[iSpansMax];
     
    226231            psAssert(src->peak->footprint->nspans == nSpansMax, "wrong footprint?");
    227232           
    228             // we only care about the spans, do not worry about the image of this footprint
    229             footprint = pmFootprintCopyData(src->peak->footprint, NULL);
     233            largestFootprint = src->peak->footprint;
    230234        }
    231235
     
    248252           
    249253            // assign to a footprint on this readout->image
    250             if (footprint) {
    251                 peak->footprint = pmFootprintCopyData(footprint, readout->image);
    252 
    253                 // the peak does not claim ownership of the footprint (it does not free it). save a copy of this
    254                 // footprint on detections->footprints so we can free it later
    255                 psArrayAdd(detections->footprints, 100, peak->footprint);
    256                 psFree (peak->footprint);
     254            if (largestFootprint) {
     255                // we save the copies that we make of the of the footprints in a hash so that we can reuse them
     256                // for all sources that share the fooprint. Without this we had serious memory explosion in
     257                // dense fields with lots of footprints (spans are small but when you have enough of them ...)
     258                peak->footprint = psphotMatchLookupFootprint(footprintCache, largestFootprint->id, index);
     259                if (!peak->footprint) {
     260                    // the peak does not claim ownership of the footprint (it does not free it).
     261                    // psphotMatchCopyFootprint saves a copy of this
     262                    // footprint on detections->footprints so we can free it later
     263                    peak->footprint = psphotMatchCopyFootprint(footprintCache, largestFootprint,
     264                                            index, readout->image, detections->footprints);
     265                }
    257266            }
    258267           
     
    272281            pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
    273282
     283#if (0)
     284            fprintf(stderr, "Add mising source for obj: %5d %5d image: %d flux: %f size: %4d %4d\n",
     285                                                      i, obj->id, index, peakFlux, source->pixels->numRows, source->pixels->numCols);
     286#endif
     287
    274288            peak->assigned = true;
    275289            pmPhotObjAddSource(obj, source);
     
    277291            psFree (source);
    278292        }
    279         psFree (footprint);
    280     }
     293    }
     294    psFree(footprintCache);
    281295
    282296    // how many sources do we have now?
     
    309323    return true;
    310324}
     325
     326// Cache of footprints created for unmatched sources.
     327static psArray * psphotMatchFootprintCacheAlloc (int nImages) {
     328    psArray *cache = psArrayAlloc(nImages);
     329    for (int i = 0; i < nImages; i++) {
     330        psHash *hash = psHashAlloc(5000);
     331        cache->data[i] = hash;
     332    }
     333    return cache;
     334}
     335
     336// Find copy of footprint with given ID made for a given image
     337static pmFootprint *psphotMatchLookupFootprint (psArray *cache, int footprintID, int imageID) {
     338    psHash *hash = (psHash *) cache->data[imageID];
     339
     340    psAssert(hash != NULL, "missing hash for image %d", imageID);
     341
     342    // footprintID is the id of the original footprint.
     343    char key[32];
     344    sprintf(key, "%d", footprintID);
     345
     346    // The footprints in our hashes are the copies of that footprint for the respective images
     347    pmFootprint *copy = psHashLookup(hash, key);
     348
     349    return copy;
     350}
     351
     352// Create a copy of a given footprint for a given image
     353static pmFootprint *psphotMatchCopyFootprint (psArray *cache, pmFootprint *footprint, int imageID, psImage *image, psArray *footprints) {
     354
     355    psAssert((imageID >= 0 && imageID < cache->n), "invalid imageID %d", imageID);
     356
     357    psHash *hash = (psHash *) cache->data[imageID];
     358
     359    psAssert(hash != NULL, "missing hash for image %d", imageID);
     360
     361    char key[32];
     362    sprintf(key, "%d", footprint->id);
     363
     364    pmFootprint *copy = pmFootprintCopyData (footprint, image);
     365
     366    // save a copy in this image's hash
     367    psHashAdd(hash, key, copy);
     368
     369    // save a copy of this footprint on the passed in footprints Array so we can free it later
     370    psArrayAdd(footprints, 100, copy);
     371
     372    // drop our ref
     373    psFree(copy);
     374
     375    return copy;
     376}
  • tags/ipp-20120216/psphot/src/psphotStackImageLoop.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • tags/ipp-20120216/psphot/src/psphotStackMatchPSFsPrepare.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset for help on using the changeset viewer.