IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11188


Ignore:
Timestamp:
Jan 19, 2007, 12:17:35 PM (19 years ago)
Author:
eugene
Message:

moved psphotReadoutCleanup out to new file, added merge sources

File:
1 edited

Legend:

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

    r11178 r11188  
    4343
    4444    // find the peaks in the image
    45     psArray *peaks = psphotFindPeaks (readout, recipe);
     45    psArray *peaks = psphotFindPeaks (readout, recipe, 1);
    4646
    4747    // construct sources and measure basic stats
     
    5858
    5959    // classify sources based on moments, brightness
    60     // faint sources not classified?
    6160    if (!psphotRoughClass (sources, recipe)) {
    6261        psFree (sources);
     
    6665        return false;
    6766    }
    68     // XXX test the plotting function
    69     // psphotPlotMoments (config, view, sources);
    70 
    7167    if (!strcasecmp (breakPt, "MOMENTS")) {
    7268        return psphotReadoutCleanup(config, readout, recipe, NULL, sources);
    7369    }
    74 
    75     // psphotTestPSF (readout, sources, recipe);
    76     // exit (1);
    7770
    7871    // use bright stellar objects to measure PSF
     
    8275        return false;
    8376    }
    84 
    8577    if (!strcasecmp (breakPt, "PSFMODEL")) {
    8678        return psphotReadoutCleanup(config, readout, recipe, psf, sources);
    8779    }
    8880
     81    // construct an initial PSF model for each object
    8982    psphotGuessModels (readout, sources, recipe, psf);
    9083
     
    114107
    115108    // find the peaks in the image
    116     psMetadataAddF32 (recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", 5.0);
    117     psArray *newPeaks = psphotFindPeaks (readout, recipe);
     109    psArray *newPeaks = psphotFindPeaks (readout, recipe, 2);
    118110
    119111    // define new sources based on the new peaks
     
    127119    psphotGuessModels (readout, newSources, recipe, psf);
    128120
    129     // linear PSF fit to remaining peaks
    130     psphotEnsemblePSF (readout, newSources, recipe, psf, TRUE);
     121    // replace all sources
     122    psphotReplaceAll (sources);
    131123
    132124    // merge the newly selected peaks into the existing list
    133     // psphotIncludeNewPeaks (sources, newSources);
     125    psphotMergeSources (sources, newSources);
    134126    psFree (newSources);
     127
     128    // linear PSF fit to remaining peaks
     129    psphotEnsemblePSF (readout, sources, recipe, psf, TRUE);
    135130
    136131finish:
     
    146141    psphotMagnitudes(sources, recipe, psf, background);
    147142
    148     // replace fitted sources
    149     // XXX we need to replace failed objects, not all objects
     143    // replace failed sources?
    150144    // psphotReplaceUnfit (sources);
    151145
     
    155149    // drop the references to the image pixels held by each source
    156150    psphotSourceFreePixels (sources);
    157     // psphotSaveImage (NULL, readout->image, "resid.fits");
    158151
    159152    // create the exported-metadata and free local data
    160153    return psphotReadoutCleanup(config, readout, recipe, psf, sources);
    161154}
    162 
    163 bool psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmPSF *psf, psArray *sources) {
    164 
    165     // use the psf-model to measure FWHM stats
    166     if (psf) {
    167         if (!psphotPSFstats (readout, recipe, psf)) {
    168             psError(PS_ERR_IO, true, "Failed to measure PSF shape parameters");
    169             return false;
    170         }
    171     } else if (sources) {
    172         if (!psphotMomentsStats (readout, recipe, sources)) {
    173             psError(PS_ERR_IO, true, "Failed to measure Moment shape parameters");
    174             return false;
    175         }
    176     }
    177 
    178     // create an output header with stats results
    179     psMetadata *header = psphotDefineHeader (recipe);
    180 
    181     // save the results of the analysis
    182     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY,    "psphot sources", sources);
    183     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER",  PS_DATA_METADATA, "header stats", header);
    184     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF",     PS_DATA_UNKNOWN,  "psphot psf", psf);
    185 
    186     // remove internal pmFPAfiles, if created
    187     pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");
    188     pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");
    189 
    190     // XXX move this to top of loop
    191     pmKapaClose ();
    192 
    193     psFree (psf);
    194     psFree (header);
    195     psFree (sources);
    196 
    197     return true;
    198 }
Note: See TracChangeset for help on using the changeset viewer.