IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32689


Ignore:
Timestamp:
Nov 17, 2011, 1:09:10 PM (15 years ago)
Author:
eugene
Message:

correctly handle the second pass in the detection image: the code was creating duplicate detections in 2 ways: 1) the source subtraction before the second pass was only being applied to the SRC, not the DET image, thus all 1st pass detections were also found as 2nd pass detections; 2) the DBL star fitting function was causing trouble, with the two positions merging to a single object -- this was considered a success, but left behind flux in the subtracted image (and garbage detections in general); Ive turned off the DBL fitting for now as I am not convinced that code is ready

Location:
branches/eam_branches/ipp-20111110/psphot/src
Files:
9 edited

Legend:

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

    r32685 r32689  
    455455psArray *psphotSourceChildrenByObject (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *objectsSrc);
    456456
     457bool psphotSourceParents (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc);
     458bool psphotSourceParentsReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index);
     459
     460bool psphotCopyPeaks (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc);
     461bool psphotCopyPeaksReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index);
     462
    457463bool psphotSersicModelClassGuessPCM (pmPCMdata *pcm, pmSource *source);
    458464void psphotSersicModelClassInit ();
  • branches/eam_branches/ipp-20111110/psphot/src/psphotBlendFit.c

    r32348 r32689  
    236236        pmSource *source = sources->data[i];
    237237
    238 # define TEST_X -420.0
    239 # define TEST_Y 300.0
     238# if (0)
     239# define TEST_X 34
     240# define TEST_Y 28
    240241   
    241242        if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
    242             fprintf (stderr, "test galaxy\n");
     243            fprintf (stderr, "test object\n");
    243244        }
    244245
    245246# undef TEST_X
    246247# undef TEST_Y
     248# endif
    247249
    248250        // skip non-astronomical objects (very likely defects)
  • branches/eam_branches/ipp-20111110/psphot/src/psphotFitSourcesLinear.c

    r32633 r32689  
    342342    psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "solve matrix: %f sec (%d elements)\n", psTimerMark ("psphot.linear"), sparse->Nelem);
    343343
    344     // XXXX **** philosophical question:
    345     // we measure bright objects in three passes: 1) linear fit; 2) non-linear fit; 3) linear fit:
    346     // should retain the chisq and errors from the intermediate non-linear fit?
    347     // the non-linear fit provides better values for the position errors, and for
    348     // extended sources, the shape errors
     344    // Philosophical question: we measure bright objects in three passes: 1) linear fit; 2)
     345    // non-linear fit; 3) linear fit: should we retain the chisq and errors from the
     346    // intermediate non-linear fit?  the non-linear fit provides better values for the position
     347    // errors, and for extended sources, the shape errors
    349348
    350349    // adjust I0 for fitSources and subtract
  • branches/eam_branches/ipp-20111110/psphot/src/psphotMergeSources.c

    r32686 r32689  
    520520}
    521521
    522 // create source parents children from ruleSrc for ruleOut for orphans
    523 bool psphotSourceParent (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc)
     522// copy the newPeaks from the detections of one pmFPAfile to another
     523bool psphotCopyPeaks (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc)
    524524{
    525525    bool status = true;
     
    534534    for (int i = 0; i < num; i++) {
    535535        if (i == chisqNum) continue; // skip chisq image
    536         if (!psphotSourceParentReadout (config, view, ruleOut, ruleSrc, i)) {
     536        if (!psphotCopyPeaksReadout (config, view, ruleOut, ruleSrc, i)) {
     537            psError (PSPHOT_ERR_CONFIG, false, "failed to copy peaks from %s to %s entry %d", ruleSrc, ruleOut, i);
     538            return false;
     539        }
     540    }
     541    return true;
     542}
     543
     544// add newly detected peaks to the existing list of sources
     545bool psphotCopyPeaksReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) {
     546
     547    bool status;
     548
     549    // find the currently selected readout
     550    pmFPAfile *fileSrc = pmFPAfileSelectSingle(config->files, ruleSrc, index); // File of interest
     551    psAssert (fileSrc, "missing file?");
     552
     553    pmReadout *readoutSrc = pmFPAviewThisReadout(view, fileSrc->fpa);
     554    psAssert (readoutSrc, "missing readout?");
     555
     556    pmDetections *detections = psMetadataLookupPtr (&status, readoutSrc->analysis, "PSPHOT.DETECTIONS");
     557    psAssert (detections, "missing detections?");
     558
     559    // find the currently selected readout
     560    pmFPAfile *fileOut = pmFPAfileSelectSingle(config->files, ruleOut, index); // File of interest
     561    psAssert (fileOut, "missing file?");
     562
     563    pmReadout *readoutOut = pmFPAviewThisReadout(view, fileOut->fpa);
     564    psAssert (readoutOut, "missing readout?");
     565
     566    // generate a new detection structure for the output filerule
     567    pmDetections *detectionsOut = psMetadataLookupPtr (&status, readoutOut->analysis, "PSPHOT.DETECTIONS");
     568    psAssert (detectionsOut, "missing PSPHOT.DETECTIONS?");
     569
     570    psAssert (detectionsOut->peaks, "programming error");
     571    psAssert (!detectionsOut->oldPeaks, "programming error");
     572    psAssert (detections->peaks, "programming error");
     573
     574    // save the OUT existing peaks on oldPeaks
     575    detectionsOut->oldPeaks = detectionsOut->peaks;
     576    detectionsOut->peaks = psArrayAllocEmpty(detections->peaks->n);
     577
     578    for (int i = 0; i < detections->peaks->n; i++) {
     579        psAssert (detections->peaks->data[i], "programming error");
     580        pmPeak *peak = pmPeakAlloc (0, 0, 0.0, PM_PEAK_LONE);
     581        pmPeakCopy(peak, detections->peaks->data[i]);
     582        psArrayAdd (detectionsOut->peaks, 100, peak);
     583        psFree (peak);
     584    }
     585    return true;
     586}
     587
     588// create source parents children from ruleSrc for ruleOut for orphans
     589bool psphotSourceParents (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc)
     590{
     591    bool status = true;
     592
     593    int num = psphotFileruleCount(config, ruleSrc);
     594
     595    // skip the chisq image because it is a duplicate of the detection version
     596    int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM");
     597    if (!status) chisqNum = -1;
     598
     599    // loop over the available readouts
     600    for (int i = 0; i < num; i++) {
     601        if (i == chisqNum) continue; // skip chisq image
     602        if (!psphotSourceParentsReadout (config, view, ruleOut, ruleSrc, i)) {
    537603            psError (PSPHOT_ERR_CONFIG, false, "failed to copy sources from %s to %s entry %d", ruleSrc, ruleOut, i);
    538604            return false;
     
    542608}
    543609
    544 // create source parents from ruleSrc for ruleOut for orphaned children for this readout.  XXX currently, this is only
    545 // used by psphotStackReadout (sources go on allSources so that psphotChoosePSF can be called
    546 // repeatedly)
    547 
    548 // XXX this function will do bad things if called repeatedly.  It needs to either (1) delete
    549 // the existing DETECTION container on the output images, or (2) intelligently supplement the
    550 // existing DETECTION container with only the new detections.
    551 bool psphotSourceParentReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) {
     610// create source parents from ruleSrc for ruleOut for orphaned children for this readout. 
     611bool psphotSourceParentsReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) {
    552612
    553613    bool status;
     614    int nParents = 0;
     615    int nNonOrphans = 0;
    554616
    555617    // find the currently selected readout
     
    583645    for (int i = 0; i < sourcesSrc->n; i++) {
    584646      pmSource *sourceSrc = sourcesSrc->data[i];
    585       if (sourceSrc->parent) continue; // I am not an orphan
     647      if (sourceSrc->parent) {
     648          nNonOrphans ++;
     649          continue; // Not an orphan
     650      }
    586651
    587652      pmSource *sourceOut = pmSourceCopy(sourceSrc);
     
    609674      pmSourceFreePixels (sourceOut);
    610675
    611       // XXX do we need to skip the Chisq image sources?
    612 
    613676      // allocate image, weight, mask for the new image for each peak
    614677      if (sourceOut->modelPSF) {
     
    620683      sourceOut->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
    621684
     685      nParents ++;
    622686      psArrayAdd (detectionsOut->allSources, 100, sourceOut);
    623687      psFree (sourceOut);
    624688    }
    625     psLogMsg ("psphot", 3, "%ld known sources supplied", detectionsOut->allSources->n);
    626 
     689    psLogMsg ("psphot", 3, "%d parents created, %d unorphaned children, %ld input vs %ld output", nParents, nNonOrphans, sourcesSrc->n, detectionsOut->allSources->n);
    627690
    628691    return true;
     
    651714}
    652715
    653 // create source children from ruleSrc for ruleOut for this entry.  XXX currently, this is only
     716// Create source children from ruleSrc for ruleOut for this entry.  Currently, this is only
    654717// used by psphotStackReadout (sources go on allSources so that psphotChoosePSF can be called
    655 // repeatedly)
    656 
    657 // XXX this function will do bad things if called repeatedly.  It needs to either (1) delete
    658 // the existing DETECTION container on the output images, or (2) intelligently supplement the
    659 // existing DETECTION container with only the new detections.
     718// repeatedly).
    660719bool psphotSourceChildrenReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) {
    661720
     
    682741    psAssert (readoutOut, "missing readout?");
    683742
    684     // generate a new detection structure for the output filerule
    685     pmDetections *detectionsOut = psMetadataLookupPtr (&status, readoutOut->analysis, "PSPHOT.DETECTIONS");
    686     if (!detectionsOut) {
    687         detectionsOut = pmDetectionsAlloc();
    688         detectionsOut->allSources = psArrayAllocEmpty (100);
    689         // save detections on the readout->analysis
    690         if (!psMetadataAddPtr (readoutOut->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detectionsOut)) {
    691             psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
    692             return false;
    693         }
    694         psFree(detectionsOut); // a copy remains on the analysis metadata
     743    // replace any existing DETECTION container on readoutOut->analysis with the new one
     744    pmDetections *detectionsOut = pmDetectionsAlloc();
     745    detectionsOut->allSources = psArrayAllocEmpty (100);
     746    if (!psMetadataAddPtr (readoutOut->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detectionsOut)) {
     747        psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     748        return false;
    695749    }
    696750
     
    729783
    730784      // allocate image, weight, mask for the new image for each peak
    731       if (sourceOut->modelPSF) {
    732         pmSourceRedefinePixels (sourceOut, readoutOut, sourceOut->peak->x, sourceOut->peak->y, sourceOut->modelPSF->fitRadius);
    733       }
     785      pmSourceRedefinePixels (sourceOut, readoutOut, sourceOut->peak->x, sourceOut->peak->y, sourceOut->windowRadius);
    734786
    735787      // child sources have not been subtracted in this image, but this flag may be raised if
     
    740792      psFree (sourceOut);
    741793    }
    742     psLogMsg ("psphot", 3, "%ld known sources supplied", detectionsOut->allSources->n);
    743 
     794    psLogMsg ("psphot", 3, "created %ld children", detectionsOut->allSources->n);
     795
     796    psFree(detectionsOut); // a copy remains on the analysis metadata
    744797
    745798    return true;
  • branches/eam_branches/ipp-20111110/psphot/src/psphotOutput.c

    r32685 r32689  
    414414    char filename[64];
    415415
    416     // XXX uncomment to disreturn true;
     416    // XXX dump tests are disabled unless this is commented out:
     417    return true;
    417418
    418419    bool status = true;
     
    453454
    454455            // XXX only dump a given region
    455             if (peak->xf < 20) continue;
    456             if (peak->yf < 20) continue;
    457             if (peak->xf > 40) continue;
    458             if (peak->yf > 70) continue;
     456            // if (peak->xf < 20) continue;
     457            // if (peak->yf < 20) continue;
     458            // if (peak->xf > 40) continue;
     459            // if (peak->yf > 70) continue;
    459460
    460461            float Msum = source->moments ? source->moments->Sum : NAN;
    461462            float Mx   = source->moments ? source->moments->Mx : NAN;
    462463            float My   = source->moments ? source->moments->My : NAN;
    463             float Npix = source->moments ? source->moments->nPixels : NAN;
    464             fprintf (f, "%f %f  : %f %f : %f %f\n", peak->xf, peak->yf, Mx, My, Msum, Npix);
     464            // float Npix = source->moments ? source->moments->nPixels : NAN;
     465            float Io = source->modelPSF ? source->modelPSF->params->data.F32[PM_PAR_I0] : NAN;
     466            fprintf (f, "%d %f %f  : %f %f : %f %f\n", source->imageID, peak->xf, peak->yf, Mx, My, Msum, Io);
    465467        }
    466468    }
  • branches/eam_branches/ipp-20111110/psphot/src/psphotReadout.c

    r32685 r32689  
    11# include "psphotInternal.h"
    2 bool psphotDumpTest (pmConfig *config, const pmFPAview *view, const char *filerule);
    32
    43// this should be called by every program that links against libpsphot
     
    8382        return psphotReadoutCleanup (config, view, filerule);
    8483    }
    85     psphotDumpTest (config, view, filerule);
    8684
    8785    // find blended neighbors of very saturated stars (detections->newSources)
     
    139137    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    140138    psphotFitSourcesLinear (config, view, filerule, false); // pass 1 (detections->allSources)
    141     psphotDumpTest (config, view, filerule);
    142139
    143140    // measure the radial profiles to the sky
     
    188185        // NOTE: new sources are saved on detections->newSources
    189186        psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources)
    190         psphotDumpTest (config, view, filerule);
    191187
    192188        // set source type
     
    209205        // XXX check on free of sources...
    210206        psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources)
    211         psphotDumpTest (config, view, filerule);
    212207
    213208        // NOTE: apply to ALL sources
  • branches/eam_branches/ipp-20111110/psphot/src/psphotReplaceUnfit.c

    r32685 r32689  
    11# include "psphotInternal.h"
    2 
    3 static int replace_pass = 0;
    4 static int remove_pass = 0;
    52
    63// replace the flux for sources which failed
     
    4340        }
    4441    }
    45     replace_pass ++;
    4642    return true;
    4743}
     
    6056    psAssert (readout, "missing readout?");
    6157
    62     char name[128];
    63     snprintf (name, 128, "testadd.neg.%02d.%02d.fits", replace_pass, index);
    64     psphotSaveImage (NULL, readout->image, name);
     58    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     59    psAssert (detections, "missing detections?");
     60
     61    psArray *sources = detections->allSources;
     62    psAssert (sources, "missing sources?");
     63
     64    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
     65    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     66    psAssert (maskVal, "missing mask value?");
     67
     68    // bit-mask to mark pixels not used in analysis
     69    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
     70    assert (markVal);
     71
     72    // maskVal is used to test for rejected pixels, and must include markVal
     73    maskVal |= markVal;
     74
     75    for (int i = 0; i < sources->n; i++) {
     76        pmSource *source = sources->data[i];
     77
     78        if (ignoreState) {
     79            // rely on the type of source to decide if we subtract it or not
     80
     81            // skip non-astronomical objects (very likely defects)
     82            if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
     83            if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
     84     
     85            // do not include CRs in the full ensemble fit
     86            if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue;
     87       
     88            // do not include MOMENTS_FAILURES in the fit
     89            if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue;
     90        } else {
     91            // if we respect the state, do not replace unsubtracted sources
     92            if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue;
     93        }
     94
     95        pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
     96    }
     97
     98    psphotVisualShowImage(readout);
     99    psLogMsg ("psphot.replace", PS_LOG_INFO, "replaced models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot.replace"));
     100    return true;
     101}
     102
     103// for now, let's store the detections on the readout->analysis for each readout
     104bool psphotRemoveAllSources (pmConfig *config, const pmFPAview *view, const char *filerule, bool ignoreState)
     105{
     106    bool status = true;
     107
     108    // select the appropriate recipe information
     109    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     110    psAssert (recipe, "missing recipe?");
     111
     112    int num = psphotFileruleCount(config, filerule);
     113
     114    // loop over the available readouts
     115    for (int i = 0; i < num; i++) {
     116        if (!psphotRemoveAllSourcesReadout (config, view, filerule, i, recipe, ignoreState)) {
     117            psError (PSPHOT_ERR_CONFIG, false, "failed to replace all sources for %s entry %d", filerule, i);
     118            return false;
     119        }
     120    }
     121    return true;
     122}
     123
     124bool psphotRemoveAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool ignoreState) {
     125
     126    bool status;
     127
     128    psTimerStart ("psphot.replace");
     129
     130    // find the currently selected readout
     131    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     132    psAssert (file, "missing file?");
     133
     134    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
     135    psAssert (readout, "missing readout?");
    65136
    66137    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     
    98169        } else {
    99170            // if we respect the state, only remove unsubtracted sources
    100             if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue;
    101         }
    102 
    103         pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
    104     }
    105 
    106     snprintf (name, 128, "testadd.pos.%02d.%02d.fits", replace_pass, index);
    107     psphotSaveImage (NULL, readout->image, name);
    108 
    109     psphotVisualShowImage(readout);
    110     psLogMsg ("psphot.replace", PS_LOG_INFO, "replaced models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot.replace"));
    111     return true;
    112 }
    113 
    114 // for now, let's store the detections on the readout->analysis for each readout
    115 bool psphotRemoveAllSources (pmConfig *config, const pmFPAview *view, const char *filerule, bool ignoreState)
    116 {
    117     bool status = true;
    118 
    119     // select the appropriate recipe information
    120     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
    121     psAssert (recipe, "missing recipe?");
    122 
    123     int num = psphotFileruleCount(config, filerule);
    124 
    125     // loop over the available readouts
    126     for (int i = 0; i < num; i++) {
    127         if (!psphotRemoveAllSourcesReadout (config, view, filerule, i, recipe, ignoreState)) {
    128             psError (PSPHOT_ERR_CONFIG, false, "failed to replace all sources for %s entry %d", filerule, i);
    129             return false;
    130         }
    131     }
    132     remove_pass ++;
    133     return true;
    134 }
    135 
    136 bool psphotRemoveAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool ignoreState) {
    137 
    138     bool status;
    139 
    140     psTimerStart ("psphot.replace");
    141 
    142     // find the currently selected readout
    143     pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    144     psAssert (file, "missing file?");
    145 
    146     pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
    147     psAssert (readout, "missing readout?");
    148 
    149     char name[128];
    150     snprintf (name, 128, "testsub.pos.%02d.%02d.fits", remove_pass, index);
    151     psphotSaveImage (NULL, readout->image, name);
    152 
    153     pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
    154     psAssert (detections, "missing detections?");
    155 
    156     psArray *sources = detections->allSources;
    157     psAssert (sources, "missing sources?");
    158 
    159     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    160     psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    161     psAssert (maskVal, "missing mask value?");
    162 
    163     // bit-mask to mark pixels not used in analysis
    164     psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
    165     assert (markVal);
    166 
    167     // maskVal is used to test for rejected pixels, and must include markVal
    168     maskVal |= markVal;
    169 
    170     for (int i = 0; i < sources->n; i++) {
    171         pmSource *source = sources->data[i];
    172 
    173         // skip non-astronomical objects (very likely defects)
    174         if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
    175         if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
    176        
    177         // do not include CRs in the full ensemble fit
    178         if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue;
    179        
    180         // do not include MOMENTS_FAILURES in the fit
    181         if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue;
    182        
    183         // if we respect the state, only remove unsubtracted sources
    184         if (!ignoreState && (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue;
    185        
     171            if ((source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue;
     172        }
     173
    186174        pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    187175    }
    188 
    189     snprintf (name, 128, "testsub.neg.%02d.%02d.fits", remove_pass, index);
    190     psphotSaveImage (NULL, readout->image, name);
    191176
    192177    psphotVisualShowImage(readout);
  • branches/eam_branches/ipp-20111110/psphot/src/psphotSourceFits.c

    r32633 r32689  
    257257        okDBL  = psphotEvalDBL (tmpSrc, DBL->data[0]);
    258258        okDBL &= psphotEvalDBL (tmpSrc, DBL->data[1]);
     259        okDBL = false; // XXX this is failing badly...
    259260        // XXX should I keep / save the flags set in the eval functions?
    260261
  • branches/eam_branches/ipp-20111110/psphot/src/psphotStackReadout.c

    r32686 r32689  
    11# include "psphotInternal.h"
    2 bool psphotDumpTest (pmConfig *config, const pmFPAview *view, const char *filerule);
    32
    43// we have 3 possible real filesets:
     
    8382    }
    8483
    85     // XXX I think this is not defined correctly for an array of images.
    86     // XXX I probably need to subtract the model (same model?) for both RAW and OUT.
    87     // XXX But, probably not a problem in practice since the stacks are constructed with 0.0 mean level.
    88 
    8984    // generate a background model (median, smoothed image)
    9085    if (!psphotModelBackground (config, view, STACK_DET)) {
     
    9287    }
    9388    if (!psphotSubtractBackground (config, view, STACK_DET)) {
     89        return psphotReadoutCleanup (config, view, STACK_SRC);
     90    }
     91    if (!psphotSubtractBackground (config, view, STACK_SRC)) {
    9492        return psphotReadoutCleanup (config, view, STACK_SRC);
    9593    }
     
    133131        return psphotReadoutCleanup (config, view, STACK_SRC);
    134132    }
    135     psphotDumpTest (config, view, STACK_SRC);
     133    // psphotDumpTest (config, view, STACK_SRC);
    136134    psMemDump("sourcestats");
    137135
     
    170168
    171169    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    172     // XXX why do this as a stack operation?
    173     // psphotFitSourcesLinearStack (config, objects, false);
    174170    psphotFitSourcesLinear (config, view, STACK_SRC, false);
    175171    psphotStackVisualFilerule(config, view, STACK_SRC);
    176     psphotDumpTest (config, view, STACK_SRC);
    177172
    178173    // measure the radial profiles to the sky
     
    206201    // NOTE: this block performs the 2nd pass low-significance PSF detection stage
    207202    {
    208         // XXX the steps below to subtract the sources from DET should be skipped if SRC == DET!
    209 
    210         // generate children sources for all sources in the SRC image
    211         // XXX (DROP existing detections list)
    212         psphotSourceChildren (config, view, STACK_DET, STACK_SRC);
    213 
    214         //  subtract all sources from DET (this will subtract using the psf model for SRC, which
    215         //  will somewhat oversubtract the sources -- this is OK
    216         // *** this fails because the source->pixels are still pointing at SRC, not DET
    217         psphotRemoveAllSources (config, view, STACK_DET, true); // ignore subtraction state for sources
     203        // if DET and SRC are different images, generate children sources for all sources in
     204        // the SRC image.  This operation replaces the existing DETECTION container on DET
     205        // which is currently a view to the one on SRC).  children sources go to
     206        // det->allSources
     207        if (strcmp(STACK_SRC, STACK_DET)) {
     208            psphotSourceChildren (config, view, STACK_DET, STACK_SRC);
     209
     210            //  subtract all sources from DET (this will subtract using the psf model for SRC, which
     211            //  will somewhat oversubtract the sources -- this is OK
     212            psphotRemoveAllSources (config, view, STACK_DET, false); // ignore subtraction state for sources
     213        }
    218214
    219215        // add noise for subtracted objects
     
    231227        // (this operation just ensures the metadata container has a view on SRC as well
    232228        if (strcmp(STACK_SRC, STACK_DET)) {
    233             // XXX this operation now needs to create source parents for the new detections
    234             // XXX if (!psphotCopySources (config, view, STACK_SRC, STACK_DET)) {
    235             // XXX      psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    236             // XXX      return psphotReadoutCleanup (config, view, STACK_SRC);
    237             // XXX }
    238            
    239             // the old detection here are children of SRC; generate parents for the new detections
    240             if (!psphotSourceParents (config, view, STACK_SRC, STACK_DET)) {
     229            // replace all sources in DET
     230            psphotReplaceAllSources (config, view, STACK_DET, false); // ignore subtraction state for sources
     231
     232            // copy the newly detected peaks from DET to SRC so SourceStats below can operate on them
     233            if (!psphotCopyPeaks (config, view, STACK_SRC, STACK_DET)) {
    241234                psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    242235                return psphotReadoutCleanup (config, view, STACK_SRC);
     
    244237        }
    245238
    246         // replace all sources in DET
    247         psphotReplaceAllSources (config, view, STACK_DET, true); // ignore subtraction state for sources
    248 
    249239        // define new sources based on only the new peaks & measure moments
    250240        // NOTE: new sources are saved on detections->newSources
    251241        psphotSourceStats (config, view, STACK_SRC, false); // pass 2 (detections->newSources)
    252         psphotDumpTest (config, view, STACK_SRC);
    253242
    254243        // set source type
     
    271260        // XXX check on free of sources...
    272261        psphotMergeSources (config, view, STACK_SRC); // (detections->newSources + detections->allSources -> detections->allSources)
    273         psphotDumpTest (config, view, STACK_SRC);
    274262    }
    275263
     
    285273
    286274    psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects);
    287     psphotDumpTest (config, view, STACK_SRC);
    288275
    289276    // NOTE: apply to ALL sources
     
    324311
    325312    int nRadialEntries = psphotStackMatchPSFsEntries(config, view, STACK_OUT);
    326 
    327     psphotDumpTest (config, view, STACK_SRC);
    328313
    329314    for (int entry = 1; entry < nRadialEntries; entry++) {
Note: See TracChangeset for help on using the changeset viewer.