IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 5, 2010, 3:11:11 PM (16 years ago)
Author:
eugene
Message:

bug fixes to psphot APIs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/psphot/src/psphotMergeSources.c

    r26788 r26793  
    1515    // loop over the available readouts
    1616    for (int i = 0; i < num; i++) {
    17         if (!psphotMergeSourcesReadout (config, view, "PSPHOT.INPUT", i)) {
     17        if (!psphotMergeSourcesReadout (config, view, "PSPHOT.INPUT", i)) {
    1818            psError (PSPHOT_ERR_CONFIG, false, "failed to merge sources for PSPHOT.INPUT entry %d", i);
    19             return false;
    20         }
     19            return false;
     20        }
    2121    }
    2222    return true;
     
    4343    // XXX TEST:
    4444    if (detections->allSources) {
    45         psphotMaskCosmicRayFootprintCheck(detections->allSources);
     45        psphotMaskCosmicRayFootprintCheck(detections->allSources);
    4646    }
    4747    if (detections->newSources) {
    48         psphotMaskCosmicRayFootprintCheck(detections->newSources);
     48        psphotMaskCosmicRayFootprintCheck(detections->newSources);
    4949    }
    5050
    5151    if (!detections->allSources) {
    52         detections->allSources = psArrayAllocEmpty(newSources->n);
     52        detections->allSources = psArrayAllocEmpty(newSources->n);
    5353    }
    5454    psArray *allSources = detections->allSources;
     
    8787    psAssert (detections, "missing detections?");
    8888
    89     // XXX allSources of newSources?
     89    // XXX allSources or newSources?
    9090    psArray *sources = detections->allSources;
    9191    psAssert (sources, "missing sources?");
     
    9696        if (!readoutCMF) goto loadTXT;
    9797
    98         extCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.DETECTIONS");
    99         if (extCMF) {
    100             for (int i = 0; i < extCMF->allSources->n; i++) {
    101                 pmSource *source = extCMF->allSources->data[i];
    102                 source->mode |= PM_SOURCE_MODE_EXTERNAL;
     98        extCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.DETECTIONS");
     99        if (extCMF) {
     100            for (int i = 0; i < extCMF->allSources->n; i++) {
     101                pmSource *source = extCMF->allSources->data[i];
     102                source->mode |= PM_SOURCE_MODE_EXTERNAL;
    103103
    104104                // the supplied peak flux needs to be re-normalized
     
    106106                source->peak->value = 1.0;
    107107
    108                 // drop the loaded source modelPSF
    109                 psFree (source->modelPSF);
    110                 source->modelPSF = NULL;
    111 
    112                 psArrayAdd (detections->allSources, 100, source);
    113             }
    114         }
     108                // drop the loaded source modelPSF
     109                psFree (source->modelPSF);
     110                source->modelPSF = NULL;
     111
     112                psArrayAdd (detections->allSources, 100, source);
     113            }
     114        }
    115115    }
    116116
     
    128128                source->mode |= PM_SOURCE_MODE_EXTERNAL;
    129129
    130                 // drop the loaded source modelPSF
    131                 psFree (source->modelPSF);
    132                 source->modelPSF = NULL;
    133 
    134                 psArrayAdd (detections->allSources, 100, source);
    135             }
    136         }
     130                // drop the loaded source modelPSF
     131                psFree (source->modelPSF);
     132                source->modelPSF = NULL;
     133
     134                psArrayAdd (detections->allSources, 100, source);
     135            }
     136        }
    137137    }
    138138
     
    168168    if (!detections) {
    169169        psLogMsg ("psphot", 3, "no psf sources for this readout");
    170         return NULL;
     170        return NULL;
    171171    }
    172172
     
    174174    if (!sources) {
    175175        psLogMsg ("psphot", 3, "no psf sources for this readout");
    176         return NULL;
     176        return NULL;
    177177    }
    178178
     
    212212
    213213// generate the detection structure for the supplied array of sources
    214 // XXX this currently assumes there is a single input file 
     214// XXX this currently assumes there is a single input file
    215215bool psphotDetectionsFromSources (pmConfig *config, const pmFPAview *view, psArray *sources) {
    216216
     
    274274    // save detections on the readout->analysis
    275275    if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detectinos", detections)) {
    276         psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
    277         return false;
     276        psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     277        return false;
    278278    }
    279279    psFree (detections);
     
    343343
    344344    if (sources->n) {
    345         // the user wants to make the psf from these stars; define them as psf stars:
    346         for (int i = 0; i < sources->n; i++) {
    347             pmSource *source = sources->data[i];
    348             source->mode |= PM_SOURCE_MODE_PSFSTAR;
    349         }
    350         // force psphotChoosePSF to use all loaded sources
    351         psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF_MAX_NSTARS", PS_META_REPLACE, "max number of sources for PSF model", sources->n);
    352 
    353         // measure stats of externally specified sources
    354         if (!psphotSourceStatsUpdate (sources, config, readout)) {
    355             psError(PSPHOT_ERR_CONFIG, false, "failure to measure stats of existing sources");
    356             return false;
    357         }
     345        // the user wants to make the psf from these stars; define them as psf stars:
     346        for (int i = 0; i < sources->n; i++) {
     347            pmSource *source = sources->data[i];
     348            source->mode |= PM_SOURCE_MODE_PSFSTAR;
     349        }
     350        // force psphotChoosePSF to use all loaded sources
     351        psMetadataAddS32 (recipe, PS_LIST_TAIL, "PSF_MAX_NSTARS", PS_META_REPLACE, "max number of sources for PSF model", sources->n);
     352
     353        // measure stats of externally specified sources
     354        if (!psphotSourceStatsUpdate (sources, config, readout)) {
     355            psError(PSPHOT_ERR_CONFIG, false, "failure to measure stats of existing sources");
     356            return false;
     357        }
    358358    } else {
    359359
    360         // find the detections (by peak and/or footprint) in the image.
    361         if (!psphotFindDetections (config, view, true)) {
    362             psError(PSPHOT_ERR_CONFIG, false, "unable to find detections in this image");
    363             return psphotReadoutCleanup (config, view);
    364         }
    365 
    366         // construct sources and measure basic stats
    367         psphotSourceStats (config, view, true);
    368 
    369         // find blended neighbors of very saturated stars
    370         psphotDeblendSatstars (config, view);
    371 
    372         // mark blended peaks PS_SOURCE_BLEND
    373         if (!psphotBasicDeblend (config, view)) {
    374             psLogMsg ("psphot", 3, "failed on deblend analysis");
    375             return psphotReadoutCleanup (config, view);
    376         }
    377 
    378         // classify sources based on moments, brightness
    379         if (!psphotRoughClass (config, view)) {
    380             psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
    381             return psphotReadoutCleanup (config, view);
    382         }
    383     }
    384 
    385     return true;
    386 }
     360        // find the detections (by peak and/or footprint) in the image.
     361        if (!psphotFindDetections (config, view, true)) {
     362            psError(PSPHOT_ERR_CONFIG, false, "unable to find detections in this image");
     363            return psphotReadoutCleanup (config, view);
     364        }
     365
     366        // construct sources and measure basic stats
     367        psphotSourceStats (config, view, true);
     368
     369        // find blended neighbors of very saturated stars
     370        psphotDeblendSatstars (config, view);
     371
     372        // mark blended peaks PS_SOURCE_BLEND
     373        if (!psphotBasicDeblend (config, view)) {
     374            psLogMsg ("psphot", 3, "failed on deblend analysis");
     375            return psphotReadoutCleanup (config, view);
     376        }
     377
     378        // classify sources based on moments, brightness
     379        if (!psphotRoughClass (config, view)) {
     380            psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
     381            return psphotReadoutCleanup (config, view);
     382        }
     383    }
     384
     385    return true;
     386}
Note: See TracChangeset for help on using the changeset viewer.