IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26808


Ignore:
Timestamp:
Feb 6, 2010, 2:01:30 PM (16 years ago)
Author:
eugene
Message:

need to pass psf from PSPHOT.PSF.LOAD to PSPHOT.INPUT

Location:
branches/eam_branches/20091201/psphot/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/psphot/src/psphot.h

    r26788 r26808  
    4848// XXX test functions
    4949psArray        *psphotFakeSources (void);
    50 bool            psphotMaskCosmicRayFootprintCheck (psArray *sources);
     50bool            psphotMaskCosmicRayFootprintCheck (psArray *sources);
    5151
    5252// psphotReadout functions
     
    6363bool            psphotSubtractBackgroundReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
    6464
    65 bool            psphotFindDetections (pmConfig *config, const pmFPAview *view, bool firstPass);
    66 bool            psphotFindDetectionsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool firstPass);
    67 
    68 bool            psphotSourceStats (pmConfig *config, const pmFPAview *view, bool setWindow);
    69 bool            psphotSourceStatsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool setWindow);
    70 
    71 bool            psphotDeblendSatstars (pmConfig *config, const pmFPAview *view);
    72 bool            psphotDeblendSatstarsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
    73 
    74 bool            psphotBasicDeblend (pmConfig *config, const pmFPAview *view);
    75 bool            psphotBasicDeblendReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
    76 
    77 bool            psphotRoughClass (pmConfig *config, const pmFPAview *view);
    78 bool            psphotRoughClassReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
    79 bool            psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata *analysis, psMetadata *recipe, const bool havePSF);
    80 
    81 bool            psphotImageQuality (pmConfig *config, const pmFPAview *view);
    82 bool            psphotImageQualityReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
    83 
    84 bool            psphotChoosePSF (pmConfig *config, const pmFPAview *view);
    85 bool            psphotChoosePSFReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
    86 
    87 bool            psphotGuessModels (pmConfig *config, const pmFPAview *view);
    88 bool            psphotGuessModelsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
    89 
    90 bool            psphotMergeSources (pmConfig *config, const pmFPAview *view);
    91 bool            psphotMergeSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
    92 
    93 bool            psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, bool final);
    94 bool            psphotFitSourcesLinearReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, bool final);
    95 
    96 bool            psphotSourceSize (pmConfig *config, const pmFPAview *view, bool getPSFsize);
    97 bool            psphotSourceSizeReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool getPSFsize);
    98 
    99 bool            psphotBlendFit (pmConfig *config, const pmFPAview *view);
    100 bool            psphotBlendFitReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     65bool            psphotFindDetections (pmConfig *config, const pmFPAview *view, bool firstPass);
     66bool            psphotFindDetectionsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool firstPass);
     67
     68bool            psphotSourceStats (pmConfig *config, const pmFPAview *view, bool setWindow);
     69bool            psphotSourceStatsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool setWindow);
     70
     71bool            psphotDeblendSatstars (pmConfig *config, const pmFPAview *view);
     72bool            psphotDeblendSatstarsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     73
     74bool            psphotBasicDeblend (pmConfig *config, const pmFPAview *view);
     75bool            psphotBasicDeblendReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     76
     77bool            psphotRoughClass (pmConfig *config, const pmFPAview *view);
     78bool            psphotRoughClassReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     79bool            psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata *analysis, psMetadata *recipe, const bool havePSF);
     80
     81bool            psphotImageQuality (pmConfig *config, const pmFPAview *view);
     82bool            psphotImageQualityReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     83
     84bool            psphotChoosePSF (pmConfig *config, const pmFPAview *view);
     85bool            psphotChoosePSFReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     86
     87bool            psphotGuessModels (pmConfig *config, const pmFPAview *view);
     88bool            psphotGuessModelsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     89
     90bool            psphotMergeSources (pmConfig *config, const pmFPAview *view);
     91bool            psphotMergeSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     92
     93bool            psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, bool final);
     94bool            psphotFitSourcesLinearReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, bool final);
     95
     96bool            psphotSourceSize (pmConfig *config, const pmFPAview *view, bool getPSFsize);
     97bool            psphotSourceSizeReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool getPSFsize);
     98
     99bool            psphotBlendFit (pmConfig *config, const pmFPAview *view);
     100bool            psphotBlendFitReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
    101101bool            psphotBlendFit_Threaded (psThreadJob *job);
    102102
    103 bool            psphotReplaceAllSources (pmConfig *config, const pmFPAview *view);
    104 bool            psphotReplaceAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
    105 
    106 bool            psphotAddNoise (pmConfig *config, const pmFPAview *view);
    107 bool            psphotSubNoise (pmConfig *config, const pmFPAview *view);
    108 bool            psphotAddOrSubNoise (pmConfig *config, const pmFPAview *view, bool add);
    109 bool            psphotAddOrSubNoiseReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool add);
    110 
    111 bool            psphotExtendedSourceAnalysis (pmConfig *config, const pmFPAview *view);
    112 bool            psphotExtendedSourceAnalysisReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
    113 
    114 bool            psphotExtendedSourceFits (pmConfig *config, const pmFPAview *view);
    115 bool            psphotExtendedSourceFitsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
    116 
    117 bool            psphotApResid (pmConfig *config, const pmFPAview *view);
    118 bool            psphotApResidReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
    119 
    120 bool            psphotMagnitudes (pmConfig *config, const pmFPAview *view);
    121 bool            psphotMagnitudesReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     103bool            psphotReplaceAllSources (pmConfig *config, const pmFPAview *view);
     104bool            psphotReplaceAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     105
     106bool            psphotAddNoise (pmConfig *config, const pmFPAview *view);
     107bool            psphotSubNoise (pmConfig *config, const pmFPAview *view);
     108bool            psphotAddOrSubNoise (pmConfig *config, const pmFPAview *view, bool add);
     109bool            psphotAddOrSubNoiseReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool add);
     110
     111bool            psphotExtendedSourceAnalysis (pmConfig *config, const pmFPAview *view);
     112bool            psphotExtendedSourceAnalysisReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     113
     114bool            psphotExtendedSourceFits (pmConfig *config, const pmFPAview *view);
     115bool            psphotExtendedSourceFitsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     116
     117bool            psphotApResid (pmConfig *config, const pmFPAview *view);
     118bool            psphotApResidReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     119
     120bool            psphotMagnitudes (pmConfig *config, const pmFPAview *view);
     121bool            psphotMagnitudesReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
    122122bool            psphotMagnitudes_Threaded (psThreadJob *job);
    123123
    124 bool            psphotEfficiency (pmConfig *config, const pmFPAview *view);
    125 bool            psphotEfficiencyReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
     124bool            psphotEfficiency (pmConfig *config, const pmFPAview *view);
     125bool            psphotEfficiencyReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);
    126126
    127127bool            psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources);
    128128bool            psphotPSFWeights_Threaded (psThreadJob *job);
    129129
    130 bool            psphotSkyReplace (pmConfig *config, const pmFPAview *view);
    131 bool            psphotSkyReplaceReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
    132 
    133 bool            psphotSourceFreePixels (pmConfig *config, const pmFPAview *view);
    134 bool            psphotSourceFreePixelsReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index);
     130bool            psphotSkyReplace (pmConfig *config, const pmFPAview *view);
     131bool            psphotSkyReplaceReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     132
     133bool            psphotSourceFreePixels (pmConfig *config, const pmFPAview *view);
     134bool            psphotSourceFreePixelsReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index);
    135135
    136136// in psphotSourceStats.c:
    137137bool            psphotSourceStats_Threaded (psThreadJob *job);
    138138bool            psphotSourceStatsUpdate (psArray *sources, pmConfig *config, pmReadout *readout);
    139 bool            psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources);
     139bool            psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources);
    140140
    141141// in psphotChoosePSF.c:
     
    144144
    145145// in psphotGuessModel.c
    146 bool            psphotGuessModel_Threaded (psThreadJob *job);
     146bool            psphotGuessModel_Threaded (psThreadJob *job);
    147147
    148148// in psphotMergeSources.c:
     
    156156
    157157// generate the detection structure for the supplied array of sources
    158 bool            psphotSetSourceParams (pmConfig *config, psArray *sources, pmPSF *psf);
     158bool            psphotSetSourceParams (pmConfig *config, psArray *sources, pmPSF *psf);
    159159
    160160// in psphotModelBackground.c:
     
    165165// in psphotReplaceUnfit.c:
    166166bool            psphotRemoveAllSources (const psArray *sources, const psMetadata *recipe);
    167 bool            psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal);
     167bool            psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal);
    168168
    169169// thread-related:
     
    227227
    228228bool            psphotLoadPSF (pmConfig *config, const pmFPAview *view);
    229 bool            psphotLoadPSFReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index);
     229bool            psphotLoadPSFReadout (pmConfig *config, const pmFPAview *view, const char *outFilename, const char *inFilename, int index);
    230230
    231231bool            psphotSetHeaderNstars (psMetadata *recipe, psArray *sources);
     
    241241
    242242// functions related to extended source analysis
    243 bool            psphotRadialProfile (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal);
    244 bool            psphotRadialProfilesByAngles (pmSource *source, int Nsec, float Rmax);
    245 float           psphotRadiusFromProfile (pmSource *source, psVector *radius, psVector *flux, float fluxMin, float fluxMax);
    246 bool            psphotRadiiFromProfiles (pmSource *source, float fluxMin, float fluxMax);
    247 bool            psphotEllipticalProfile (pmSource *source);
    248 bool            psphotEllipticalContour (pmSource *source);
     243bool            psphotRadialProfile (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal);
     244bool            psphotRadialProfilesByAngles (pmSource *source, int Nsec, float Rmax);
     245float           psphotRadiusFromProfile (pmSource *source, psVector *radius, psVector *flux, float fluxMin, float fluxMax);
     246bool            psphotRadiiFromProfiles (pmSource *source, float fluxMin, float fluxMax);
     247bool            psphotEllipticalProfile (pmSource *source);
     248bool            psphotEllipticalContour (pmSource *source);
    249249
    250250// psphotVisual functions
    251251bool            psphotVisualShowImage (pmReadout *readout);
    252 bool            psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout);
    253 bool            psphotVisualShowSignificance (psImage *image, float min, float max);
    254 bool            psphotVisualShowPeaks (pmDetections *detections);
    255 bool            psphotVisualShowFootprints (pmDetections *detections);
    256 bool            psphotVisualShowMoments (psArray *sources);
    257 bool            psphotVisualPlotMoments (psMetadata *recipe, psMetadata *analysis, psArray *sources);
    258 bool            psphotVisualShowRoughClass (psArray *sources);
    259 bool            psphotVisualShowPSFStars (psMetadata *recipe, pmPSF *psf, psArray *sources);
    260 bool            psphotVisualShowSatStars (psMetadata *recipe, pmPSF *psf, psArray *sources);
    261 bool            psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf);
    262 bool            psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal);
    263 bool            psphotVisualPlotRadialProfiles (psMetadata *recipe, psArray *sources);
    264 bool            psphotVisualShowFlags (psArray *sources);
    265 bool            psphotVisualShowSourceSize (pmReadout *readout, psArray *sources);
    266 bool            psphotVisualShowResidualImage (pmReadout *readout);
    267 bool            psphotVisualPlotApResid (psArray *sources, float mean, float error);
    268 bool            psphotVisualPlotChisq (psArray *sources);
    269 bool            psphotVisualPlotSourceSize (psMetadata *recipe, psMetadata *analysis, psArray *sources);
    270 bool            psphotVisualShowPetrosians (psArray *sources);
    271 bool            psphotVisualEraseOverlays (int channel, char *overlay);
     252bool            psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout);
     253bool            psphotVisualShowSignificance (psImage *image, float min, float max);
     254bool            psphotVisualShowPeaks (pmDetections *detections);
     255bool            psphotVisualShowFootprints (pmDetections *detections);
     256bool            psphotVisualShowMoments (psArray *sources);
     257bool            psphotVisualPlotMoments (psMetadata *recipe, psMetadata *analysis, psArray *sources);
     258bool            psphotVisualShowRoughClass (psArray *sources);
     259bool            psphotVisualShowPSFStars (psMetadata *recipe, pmPSF *psf, psArray *sources);
     260bool            psphotVisualShowSatStars (psMetadata *recipe, pmPSF *psf, psArray *sources);
     261bool            psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf);
     262bool            psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal);
     263bool            psphotVisualPlotRadialProfiles (psMetadata *recipe, psArray *sources);
     264bool            psphotVisualShowFlags (psArray *sources);
     265bool            psphotVisualShowSourceSize (pmReadout *readout, psArray *sources);
     266bool            psphotVisualShowResidualImage (pmReadout *readout);
     267bool            psphotVisualPlotApResid (psArray *sources, float mean, float error);
     268bool            psphotVisualPlotChisq (psArray *sources);
     269bool            psphotVisualPlotSourceSize (psMetadata *recipe, psMetadata *analysis, psArray *sources);
     270bool            psphotVisualShowPetrosians (psArray *sources);
     271bool            psphotVisualEraseOverlays (int channel, char *overlay);
    272272
    273273bool psphotPetrosian (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal);
  • branches/eam_branches/20091201/psphot/src/psphotGuessModels.c

    r26788 r26808  
    33// XXX : the threading here is not great.  this may be due to blocks between elements, but
    44// the selection of the objects in a cell is not optimal.  To fix:
    5 // 1) define the boundaries of the cells up front 
     5// 1) define the boundaries of the cells up front
    66// 2) loop over the sources once and associate them with their cell
    77// 3) define the threaded function to work with sources for a given cell
     
    1717    // loop over the available readouts
    1818    for (int i = 0; i < num; i++) {
    19         if (!psphotGuessModelsReadout (config, view, "PSPHOT.INPUT", i)) {
     19        if (!psphotGuessModelsReadout (config, view, "PSPHOT.INPUT", i)) {
    2020            psError (PSPHOT_ERR_CONFIG, false, "failed on to guess models for PSPHOT.INPUT entry %d", i);
    21             return false;
    22         }
     21            return false;
     22        }
    2323    }
    2424    return true;
     
    4646
    4747    if (!sources->n) {
    48         psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping model guess");
    49         return true;
     48        psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping model guess");
     49        return true;
    5050    }
    5151
    5252    pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
    53     psAssert (sources, "missing psf?");
     53    psAssert (psf, "missing psf?");
    5454
    5555    // select the appropriate recipe information
     
    6060    int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads
    6161    if (!status) {
    62         nThreads = 0;
     62        nThreads = 0;
    6363    }
    6464
     
    8585    for (int i = 0; i < cellGroups->n; i++) {
    8686
    87         psArray *cells = cellGroups->data[i];
    88 
    89         for (int j = 0; j < cells->n; j++) {
    90 
    91             // allocate a job -- if threads are not defined, this just runs the job
    92             psThreadJob *job = psThreadJobAlloc ("PSPHOT_GUESS_MODEL");
    93             psArrayAdd(job->args, 1, readout);
    94             psArrayAdd(job->args, 1, cells->data[j]); // sources
    95             psArrayAdd(job->args, 1, psf);
    96 
    97             // XXX change these to use abstract mask type info
    98             PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
    99             PS_ARRAY_ADD_SCALAR(job->args, markVal,  PS_TYPE_IMAGE_MASK);
    100 
    101             if (!psThreadJobAddPending(job)) {
    102                 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    103                 psFree (job);
    104                 return false;
    105             }
    106             psFree(job);
    107         }
    108 
    109         // wait for the threads to finish and manage results
    110         // wait here for the threaded jobs to finish
    111         // fprintf (stderr, "wait for threads (%d, %d)\n", jx, jy);
    112         if (!psThreadPoolWait (false)) {
    113             psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    114             return false;
    115         }
    116 
    117         // we have only supplied one type of job, so we can assume the types here
    118         psThreadJob *job = NULL;
    119         while ((job = psThreadJobGetDone()) != NULL) {
    120             // we have no returned data from this operation
    121             if (job->args->n < 1) {
    122                 fprintf (stderr, "error with job\n");
    123             }
    124             psFree(job);
    125         }
     87        psArray *cells = cellGroups->data[i];
     88
     89        for (int j = 0; j < cells->n; j++) {
     90
     91            // allocate a job -- if threads are not defined, this just runs the job
     92            psThreadJob *job = psThreadJobAlloc ("PSPHOT_GUESS_MODEL");
     93            psArrayAdd(job->args, 1, readout);
     94            psArrayAdd(job->args, 1, cells->data[j]); // sources
     95            psArrayAdd(job->args, 1, psf);
     96
     97            // XXX change these to use abstract mask type info
     98            PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
     99            PS_ARRAY_ADD_SCALAR(job->args, markVal,  PS_TYPE_IMAGE_MASK);
     100
     101            if (!psThreadJobAddPending(job)) {
     102                psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     103                psFree (job);
     104                return false;
     105            }
     106            psFree(job);
     107        }
     108
     109        // wait for the threads to finish and manage results
     110        // wait here for the threaded jobs to finish
     111        // fprintf (stderr, "wait for threads (%d, %d)\n", jx, jy);
     112        if (!psThreadPoolWait (false)) {
     113            psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     114            return false;
     115        }
     116
     117        // we have only supplied one type of job, so we can assume the types here
     118        psThreadJob *job = NULL;
     119        while ((job = psThreadJobGetDone()) != NULL) {
     120            // we have no returned data from this operation
     121            if (job->args->n < 1) {
     122                fprintf (stderr, "error with job\n");
     123            }
     124            psFree(job);
     125        }
    126126    }
    127127
     
    129129    int nMiss = 0;
    130130    for (int i = 0; i < sources->n; i++) {
    131         pmSource *source = sources->data[i];
    132         if (source->tmpFlags & PM_SOURCE_TMPF_MODEL_GUESS) {
    133             continue;
    134         }
    135         nMiss ++;
     131        pmSource *source = sources->data[i];
     132        if (source->tmpFlags & PM_SOURCE_TMPF_MODEL_GUESS) {
     133            continue;
     134        }
     135        nMiss ++;
    136136    }
    137137    psAssert (nMiss == 0, "failed to attempt to build models for %d objects\n", nMiss);
     
    149149    psArray *sources   = job->args->data[1];
    150150    pmPSF *psf         = job->args->data[2];
    151    
     151
    152152    psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA);
    153153    psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
     
    156156
    157157    for (int i = 0; i < sources->n; i++) {
    158         pmSource *source = sources->data[i];
    159 
    160         // this is used to mark sources for which the model is measured. We check later that
    161         // all are used.
    162         source->tmpFlags |= PM_SOURCE_TMPF_MODEL_GUESS;
    163 
    164         // skip non-astronomical objects (very likely defects)
    165         if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
    166         if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
    167         if (!source->peak) continue;
    168 
    169         nSrc ++;
    170        
    171         // the guess central intensity comes from the peak:
    172         float Io = source->peak->flux;
    173 
    174         // We have two options to get a guess for the object position: the position from the
    175         // peak and the position from the moments.  Use the peak position if (a) there are no
    176         // moments and (b) the sources is not saturated
    177 
    178         bool useMoments = false;
    179         useMoments = (source->mode & PM_SOURCE_MODE_SATSTAR);  // we only want to try if SATSTAR is set, but..
    180         useMoments = (useMoments && source->moments);          // can't if there are no moments
    181         useMoments = (useMoments && source->moments->nPixels); // can't if the moments were not measured
    182         useMoments = (useMoments && !(source->mode && PM_SOURCE_MODE_MOMENTS_FAILURE)); // can't if the moments failed...
    183 
    184         float Xo, Yo;
    185         if (useMoments) {
    186             Xo = source->moments->Mx;
    187             Yo = source->moments->My;
    188         } else {
    189             Xo = source->peak->xf;
    190             Yo = source->peak->yf;
    191         }
    192 
    193         // set PSF parameters for this model (apply 2D shape model to coordinates Xo, Yo)
    194         pmModel *modelPSF = pmModelFromPSFforXY(psf, Xo, Yo, Io);
    195 
    196         if (modelPSF == NULL) {
    197             psWarning ("Failed to determine PSF model at (%f,%f); trying image center", Xo, Yo);
    198 
    199             float Xc = 0.5*readout->image->numCols;
    200             float Yc = 0.5*readout->image->numRows;
    201             pmModel *modelPSF = pmModelFromPSFforXY(psf, Xc, Yc, Io);
    202             if (modelPSF == NULL) {
    203                 psError(PSPHOT_ERR_PSF, false, "Failed to determine PSF model at center of image");
    204                 return false;
    205             }
    206 
    207             // Now set the object position at the expected location:
    208             modelPSF->params->data.F32[PM_PAR_XPOS] = Xo;
    209             modelPSF->params->data.F32[PM_PAR_YPOS] = Yo;
    210             source->mode |= PM_SOURCE_MODE_BADPSF;
    211         }
    212 
    213         // set the fit radius based on the object flux limit and the model
    214         // this function affects the mask pixels
    215         psphotCheckRadiusPSF (readout, source, modelPSF, markVal);
    216 
    217         // set the source PSF model
    218         psAssert (source->modelPSF == NULL, "failed to free one of the models?");
    219         source->modelPSF = modelPSF;
    220         source->modelPSF->residuals = psf->residuals;
    221 
    222         pmSourceCacheModel (source, maskVal);  // ALLOC x14 (!)
     158        pmSource *source = sources->data[i];
     159
     160        // this is used to mark sources for which the model is measured. We check later that
     161        // all are used.
     162        source->tmpFlags |= PM_SOURCE_TMPF_MODEL_GUESS;
     163
     164        // skip non-astronomical objects (very likely defects)
     165        if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
     166        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
     167        if (!source->peak) continue;
     168
     169        nSrc ++;
     170
     171        // the guess central intensity comes from the peak:
     172        float Io = source->peak->flux;
     173
     174        // We have two options to get a guess for the object position: the position from the
     175        // peak and the position from the moments.  Use the peak position if (a) there are no
     176        // moments and (b) the sources is not saturated
     177
     178        bool useMoments = false;
     179        useMoments = (source->mode & PM_SOURCE_MODE_SATSTAR);  // we only want to try if SATSTAR is set, but..
     180        useMoments = (useMoments && source->moments);          // can't if there are no moments
     181        useMoments = (useMoments && source->moments->nPixels); // can't if the moments were not measured
     182        useMoments = (useMoments && !(source->mode && PM_SOURCE_MODE_MOMENTS_FAILURE)); // can't if the moments failed...
     183
     184        float Xo, Yo;
     185        if (useMoments) {
     186            Xo = source->moments->Mx;
     187            Yo = source->moments->My;
     188        } else {
     189            Xo = source->peak->xf;
     190            Yo = source->peak->yf;
     191        }
     192
     193        // set PSF parameters for this model (apply 2D shape model to coordinates Xo, Yo)
     194        pmModel *modelPSF = pmModelFromPSFforXY(psf, Xo, Yo, Io);
     195
     196        if (modelPSF == NULL) {
     197            psWarning ("Failed to determine PSF model at (%f,%f); trying image center", Xo, Yo);
     198
     199            float Xc = 0.5*readout->image->numCols;
     200            float Yc = 0.5*readout->image->numRows;
     201            pmModel *modelPSF = pmModelFromPSFforXY(psf, Xc, Yc, Io);
     202            if (modelPSF == NULL) {
     203                psError(PSPHOT_ERR_PSF, false, "Failed to determine PSF model at center of image");
     204                return false;
     205            }
     206
     207            // Now set the object position at the expected location:
     208            modelPSF->params->data.F32[PM_PAR_XPOS] = Xo;
     209            modelPSF->params->data.F32[PM_PAR_YPOS] = Yo;
     210            source->mode |= PM_SOURCE_MODE_BADPSF;
     211        }
     212
     213        // set the fit radius based on the object flux limit and the model
     214        // this function affects the mask pixels
     215        psphotCheckRadiusPSF (readout, source, modelPSF, markVal);
     216
     217        // set the source PSF model
     218        psAssert (source->modelPSF == NULL, "failed to free one of the models?");
     219        source->modelPSF = modelPSF;
     220        source->modelPSF->residuals = psf->residuals;
     221
     222        pmSourceCacheModel (source, maskVal);  // ALLOC x14 (!)
    223223    }
    224224
  • branches/eam_branches/20091201/psphot/src/psphotLoadPSF.c

    r26793 r26808  
    1111
    1212// load an externally supplied psf model
    13 bool psphotLoadPSFReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index) {
     13bool psphotLoadPSFReadout (pmConfig *config, const pmFPAview *view, const char *outFilename, const char *inFilename, int index) {
    1414
    1515    bool status;
    1616
    1717    // find the currently selected readout
    18     pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
    19     if (file == NULL) {
     18    pmFPAfile *inFile = pmFPAfileSelectSingle(config->files, inFilename, index); // File of interest
     19    if (inFile == NULL) {
     20        psLogMsg ("psphot", 3, "no psf supplied for this chip");
     21        return true;
     22    }
     23
     24    // find the currently selected readout
     25    pmFPAfile *outFile = pmFPAfileSelectSingle(config->files, outFilename, index); // File of interest
     26    if (outFile == NULL) {
    2027        psLogMsg ("psphot", 3, "no psf supplied for this chip");
    2128        return true;
     
    2330
    2431    // find the currently selected chip
    25     pmChip *chip = pmFPAviewThisChip (view, file->fpa);
     32    pmChip *chip = pmFPAviewThisChip (view, inFile->fpa);
    2633    if (!chip) return false;
    2734
    2835    // find the currently selected readout
    29     pmReadout *readout = pmFPAviewThisReadout (view, file->fpa);
     36    pmReadout *readout = pmFPAviewThisReadout (view, outFile->fpa);
    3037    if (!readout) return false;
    3138
     
    6471
    6572        // Generate the mask and weight images, including the user-defined analysis region of interest
    66         if (!psphotLoadPSFReadout (config, view, "PSPHOT.PSF.LOAD", i)) {
     73        if (!psphotLoadPSFReadout (config, view, "PSPHOT.INPUT", "PSPHOT.PSF.LOAD", i)) {
    6774            psError (PSPHOT_ERR_CONFIG, false, "failed to load PSF model for PSPHOT.PSF.LOAD entry %d", i);
    6875            return false;
  • branches/eam_branches/20091201/psphot/src/psphotModelBackground.c

    r26788 r26808  
    3838// readout->analysis
    3939static bool psphotModelBackgroundReadout(psImage *model,  // Model image
    40                                   psImage *modelStdev, // Model stdev image
    41                                   psMetadata *analysis, // Analysis metadata for outputs
    42                                   pmReadout *readout, // Readout for which to generate a background model
    43                                   psImageBinning *binning, // Binning parameters
    44                                   const pmConfig *config // Configuration
     40                                  psImage *modelStdev, // Model stdev image
     41                                  psMetadata *analysis, // Analysis metadata for outputs
     42                                  pmReadout *readout, // Readout for which to generate a background model
     43                                  psImageBinning *binning, // Binning parameters
     44                                  const pmConfig *config // Configuration
    4545    )
    4646{
     
    218218                stats->options = PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV;
    219219                if (!psImageBackground(stats, &sample, subset, submask, maskVal, rng)) {
    220                     psLogMsg ("psphot", PS_LOG_WARN, "Failed to estimate background using ROBUST_MEDIAN for "
    221                                "(%dx%d, (row0,col0) = (%d,%d)",
    222                                subset->numRows, subset->numCols, subset->row0, subset->col0);
     220                    // psLogMsg ("psphot", PS_LOG_WARN, "Failed to estimate background using ROBUST_MEDIAN for "
     221                    //            "(%dx%d, (row0,col0) = (%d,%d)",
     222                    //            subset->numRows, subset->numCols, subset->row0, subset->col0);
    223223                    modelData[iy][ix] = modelStdevData[iy][ix] = NAN;
    224224                } else {
     
    383383    // loop over the available readouts
    384384    for (int i = 0; i < num; i++) {
    385         if (!psphotModelBackgroundReadoutFileIndex(config, view, "PSPHOT.INPUT", i)) {
     385        if (!psphotModelBackgroundReadoutFileIndex(config, view, "PSPHOT.INPUT", i)) {
    386386            psError (PSPHOT_ERR_CONFIG, false, "failed to model background for PSPHOT.INPUT entry %d", i);
    387             return false;
    388         }
     387            return false;
     388        }
    389389    }
    390390    return true;
  • branches/eam_branches/20091201/psphot/src/psphotReadoutMinimal.c

    r26788 r26808  
    6262    psphotGuessModels (config, view);
    6363
     64    // merge the newly selected sources into the existing list
     65    psphotMergeSources (config, view);
     66
    6467    // linear PSF fit to source peaks
    6568    psphotFitSourcesLinear (config, view, false);
Note: See TracChangeset for help on using the changeset viewer.