IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 43019


Ignore:
Timestamp:
May 11, 2026, 3:21:33 PM (2 months ago)
Author:
eugene
Message:

plug leaks

Location:
branches/eam_branches/ipp-pstamp-20260421/ppStack/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-pstamp-20260421/ppStack/src/ppStackCleanup.c

    r34800 r43019  
    141141    pmVisualCleanup ();
    142142
     143    psLogMsg("ppStack", PS_LOG_INFO, "Memory leaks: %d\n", psMemCheckLeaks(0, NULL, stdout, false));
     144
    143145    exitValue = ppStackExitCode(exitValue);
    144146    exit(exitValue);
  • branches/eam_branches/ipp-pstamp-20260421/ppStack/src/ppStackFiles.c

    r42094 r43019  
    253253            return false;
    254254        }
     255        psFree(tmphead);
    255256    }
    256257    if (!psFitsClose(fits)) {
  • branches/eam_branches/ipp-pstamp-20260421/ppStack/src/ppStackOptions.c

    r42094 r43019  
    3232    psFree(options->inspect);
    3333    psFree(options->rejected);
     34    psFree(options->zpInput);
     35    psFree(options->expTimeInput);
     36    psFree(options->airmassInput);
     37    psFree(options->bkgImages);
    3438
    3539    return;
  • branches/eam_branches/ipp-pstamp-20260421/ppStack/src/ppStackSources.c

    r42893 r43019  
    295295    if (options->matchZPs) {
    296296
    297       psVector *trans = pmSourceMatchRelphot(matches, matchedSources, zp, tol, iter1, starRej1, starSys1,
     297        psVector *trans = pmSourceMatchRelphot(matches, matchedSources, zp, tol, iter1, starRej1, starSys1,
    298298                                               iter2, starRej2, starSys2, starLimit,
    299299                                               transIter, transRej, transThresh); // Transparencies per image
     
    345345    dumpMatches("source_match2.dat", num, matches, zp, trans);
    346346#endif
     347        // XXX this second block is always true (since options->matchZPs is true above)
    347348        if (options->matchZPs) {
    348349            options->norm = psVectorAlloc(num, PS_TYPE_F32);
     
    383384            }
    384385        }
    385         matches = pmSourceMatchSources(sourceLists, radius, true); // List of matches
     386
     387        // XXX this duplicates the pmSourceMatch above
     388        // matches = pmSourceMatchSources(sourceLists, radius, true); // List of matches
    386389
    387390        if (zpExpNum == numGoodImages) {
     
    393396            options->zp = NAN;
    394397        }
    395 
    396398
    397399        psFree(trans);
     
    487489
    488490
    489     if (options->photometry) {
    490         // Save best matches for future photometry
    491       psArray *sourcesBest = options->sources = psArrayAllocEmpty(matches->n);
    492         // XXX something of a hack: require at least 2 detections or the nominated fraction of the max possible
    493         //int minMatches = PS_MAX(2, fracMatch * num);// Minimum number of matches required
    494         //MEH - if many poor images, will hit oddity with num fraction. use numGoodImages instead
    495       int minMatches = PS_MAX(2, fracMatch * numGoodImages);// Minimum number of matches required
     491        if (options->photometry) {
     492            // Save best matches for future photometry
     493            psArray *sourcesBest = psArrayAllocEmpty(matches->n);
     494
     495            // XXX something of a hack: require at least 2 detections or the nominated fraction of the max possible
     496            //int minMatches = PS_MAX(2, fracMatch * num);// Minimum number of matches required
     497            //MEH - if many poor images, will hit oddity with num fraction. use numGoodImages instead
     498            int minMatches = PS_MAX(2, fracMatch * numGoodImages);// Minimum number of matches required
    496499     
    497       int good0 = 0;
    498       for (int i = 0; i < num; i++) {
    499         if (inputMask->data.U8[i]) {
    500           continue;
     500            int good0 = 0;
     501            for (int i = 0; i < num; i++) {
     502                if (inputMask->data.U8[i]) {
     503                    continue;
     504                }
     505                good0 = i;
     506                break;
     507            }
     508     
     509            for (int i = 0; i < matches->n; i++) {
     510                pmSourceMatch *match = matches->data[i]; // Match of interest
     511                if (match->num < minMatches) {
     512                    continue;
     513                }
     514
     515                // We need to grab a single instance of this source: just take the first available
     516                // MEH - if first available is a rejected image, then problem. so take first non-rejected instance above
     517                //       int image = match->image->data.S32[0]; // Index of image
     518                // int index = match->index->data.S32[0]; // Index of source within image
     519                int image = match->image->data.S32[good0]; // Index of image
     520                int index = match->index->data.S32[good0]; // Index of source within image
     521                psArray *sources = sourceLists->data[image]; // Sources for image
     522                pmSource *source = sources->data[index]; // Source of interest
     523
     524                // CZW: Accept the first source for all properties, except for the magnitudes.
     525                //      We have average magnitudes from relphot, so we should use those
     526                pmSource *photsource = matchedSources->data[i];
     527                if ((photsource)&&(isfinite(photsource->psfMag))) {
     528                    // CZW: photsource is the average relphot mag, which is equal to <m_i + zpIN_j>
     529                    //      (primed are averaged values for this discussion)
     530                    //      Therefore, the correct magnitude for psfMag' is:
     531                    //         psfMag' = (photsource - zpIN_j + magCorr)
     532                    //      apMag - psfMag should be retained, so:
     533                    //         apMag - psfMag = apMag' - psfMag'
     534                    //         apMag' = apMag + psfMag' - psfMag
     535                    source->apMag  = source->apMag + (photsource->psfMag + options->norm->data.F32[image] - zp->data.F32[image] - source->psfMag);
     536                    source->psfMag = photsource->psfMag + options->norm->data.F32[image] - zp->data.F32[image];
     537           
     538                    psTrace("ppStack", 5, "Best Source %d/%ld @ %f %f %f %f %f %d",i,sourcesBest->n,source->peak->xf,source->peak->yf,
     539                            source->psfMag,
     540                            photsource->psfMag + options->norm->data.F32[image] - zp->data.F32[image] ,
     541                            source->psfMagErr,-1);
     542                    psArrayAdd(sourcesBest, sourcesBest->n, source);
     543                }
     544            }
     545            psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis", sourcesBest->n);
     546
     547            // at this point, options->sources contains the full matched list
     548            // here we only keep the best sources:
     549            psFree (options->sources);
     550            options->sources = sourcesBest;
    501551        }
    502         good0 = i;
    503         break;
    504       }
    505      
    506       for (int i = 0; i < matches->n; i++) {
    507         pmSourceMatch *match = matches->data[i]; // Match of interest
    508          if (match->num < minMatches) {
    509            continue;
    510          }
    511 
    512          // We need to grab a single instance of this source: just take the first available
    513          // MEH - if first available is a rejected image, then problem. so take first non-rejected instance above
    514          //      int image = match->image->data.S32[0]; // Index of image
    515          // int index = match->index->data.S32[0]; // Index of source within image
    516          int image = match->image->data.S32[good0]; // Index of image
    517          int index = match->index->data.S32[good0]; // Index of source within image
    518          psArray *sources = sourceLists->data[image]; // Sources for image
    519          pmSource *source = sources->data[index]; // Source of interest
    520 
    521          // CZW: Accept the first source for all properties, except for the magnitudes.
    522          //      We have average magnitudes from relphot, so we should use those
    523          pmSource *photsource = matchedSources->data[i];
    524          if ((photsource)&&(isfinite(photsource->psfMag))) {
    525            // CZW: photsource is the average relphot mag, which is equal to <m_i + zpIN_j>
    526            //      (primed are averaged values for this discussion)
    527            //      Therefore, the correct magnitude for psfMag' is:
    528            //         psfMag' = (photsource - zpIN_j + magCorr)
    529            //      apMag - psfMag should be retained, so:
    530            //         apMag - psfMag = apMag' - psfMag'
    531            //         apMag' = apMag + psfMag' - psfMag
    532            source->apMag  = source->apMag + (photsource->psfMag + options->norm->data.F32[image] - zp->data.F32[image] - source->psfMag);
    533            source->psfMag = photsource->psfMag + options->norm->data.F32[image] - zp->data.F32[image];
    534            
    535            psTrace("ppStack", 5, "Best Source %d/%ld @ %f %f %f %f %f %d",i,sourcesBest->n,source->peak->xf,source->peak->yf,
    536                    source->psfMag,
    537                    photsource->psfMag + options->norm->data.F32[image] - zp->data.F32[image] ,
    538                    source->psfMagErr,-1);
    539            psArrayAdd(sourcesBest, sourcesBest->n, source);
    540          }
    541         }
    542       psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis", sourcesBest->n);
    543 
    544     }
    545     psFree(zp);
    546     psFree(matches);
    547 
    548     return true;
     552        psFree(zp);
     553        psFree(matches);
     554        psFree(matchedSources);
     555
     556        return true;
    549557}
  • branches/eam_branches/ipp-pstamp-20260421/ppStack/src/ppStackTarget.c

    r35383 r43019  
    8989            }
    9090        }
     91        psFree (indices);
    9192    }
    9293    psFree(coords);
Note: See TracChangeset for help on using the changeset viewer.