Changeset 26808
- Timestamp:
- Feb 6, 2010, 2:01:30 PM (16 years ago)
- Location:
- branches/eam_branches/20091201/psphot/src
- Files:
-
- 5 edited
-
psphot.h (modified) (7 diffs)
-
psphotGuessModels.c (modified) (8 diffs)
-
psphotLoadPSF.c (modified) (3 diffs)
-
psphotModelBackground.c (modified) (3 diffs)
-
psphotReadoutMinimal.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/psphot/src/psphot.h
r26788 r26808 48 48 // XXX test functions 49 49 psArray *psphotFakeSources (void); 50 bool psphotMaskCosmicRayFootprintCheck (psArray *sources);50 bool psphotMaskCosmicRayFootprintCheck (psArray *sources); 51 51 52 52 // psphotReadout functions … … 63 63 bool psphotSubtractBackgroundReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 64 64 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);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); 101 101 bool psphotBlendFit_Threaded (psThreadJob *job); 102 102 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);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); 122 122 bool psphotMagnitudes_Threaded (psThreadJob *job); 123 123 124 bool psphotEfficiency (pmConfig *config, const pmFPAview *view);125 bool psphotEfficiencyReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe);124 bool psphotEfficiency (pmConfig *config, const pmFPAview *view); 125 bool psphotEfficiencyReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 126 126 127 127 bool psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources); 128 128 bool psphotPSFWeights_Threaded (psThreadJob *job); 129 129 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);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); 135 135 136 136 // in psphotSourceStats.c: 137 137 bool psphotSourceStats_Threaded (psThreadJob *job); 138 138 bool psphotSourceStatsUpdate (psArray *sources, pmConfig *config, pmReadout *readout); 139 bool psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources);139 bool psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources); 140 140 141 141 // in psphotChoosePSF.c: … … 144 144 145 145 // in psphotGuessModel.c 146 bool psphotGuessModel_Threaded (psThreadJob *job);146 bool psphotGuessModel_Threaded (psThreadJob *job); 147 147 148 148 // in psphotMergeSources.c: … … 156 156 157 157 // generate the detection structure for the supplied array of sources 158 bool psphotSetSourceParams (pmConfig *config, psArray *sources, pmPSF *psf);158 bool psphotSetSourceParams (pmConfig *config, psArray *sources, pmPSF *psf); 159 159 160 160 // in psphotModelBackground.c: … … 165 165 // in psphotReplaceUnfit.c: 166 166 bool psphotRemoveAllSources (const psArray *sources, const psMetadata *recipe); 167 bool psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal);167 bool psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal); 168 168 169 169 // thread-related: … … 227 227 228 228 bool psphotLoadPSF (pmConfig *config, const pmFPAview *view); 229 bool psphotLoadPSFReadout (pmConfig *config, const pmFPAview *view, const char * filename, int index);229 bool psphotLoadPSFReadout (pmConfig *config, const pmFPAview *view, const char *outFilename, const char *inFilename, int index); 230 230 231 231 bool psphotSetHeaderNstars (psMetadata *recipe, psArray *sources); … … 241 241 242 242 // 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);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); 249 249 250 250 // psphotVisual functions 251 251 bool 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);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); 272 272 273 273 bool psphotPetrosian (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal); -
branches/eam_branches/20091201/psphot/src/psphotGuessModels.c
r26788 r26808 3 3 // XXX : the threading here is not great. this may be due to blocks between elements, but 4 4 // 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 6 6 // 2) loop over the sources once and associate them with their cell 7 7 // 3) define the threaded function to work with sources for a given cell … … 17 17 // loop over the available readouts 18 18 for (int i = 0; i < num; i++) { 19 if (!psphotGuessModelsReadout (config, view, "PSPHOT.INPUT", i)) {19 if (!psphotGuessModelsReadout (config, view, "PSPHOT.INPUT", i)) { 20 20 psError (PSPHOT_ERR_CONFIG, false, "failed on to guess models for PSPHOT.INPUT entry %d", i); 21 return false;22 }21 return false; 22 } 23 23 } 24 24 return true; … … 46 46 47 47 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; 50 50 } 51 51 52 52 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 53 psAssert ( sources, "missing psf?");53 psAssert (psf, "missing psf?"); 54 54 55 55 // select the appropriate recipe information … … 60 60 int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads 61 61 if (!status) { 62 nThreads = 0;62 nThreads = 0; 63 63 } 64 64 … … 85 85 for (int i = 0; i < cellGroups->n; i++) { 86 86 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 job92 psThreadJob *job = psThreadJobAlloc ("PSPHOT_GUESS_MODEL");93 psArrayAdd(job->args, 1, readout);94 psArrayAdd(job->args, 1, cells->data[j]); // sources95 psArrayAdd(job->args, 1, psf);96 97 // XXX change these to use abstract mask type info98 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 results110 // wait here for the threaded jobs to finish111 // 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 here118 psThreadJob *job = NULL;119 while ((job = psThreadJobGetDone()) != NULL) {120 // we have no returned data from this operation121 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 } 126 126 } 127 127 … … 129 129 int nMiss = 0; 130 130 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 ++; 136 136 } 137 137 psAssert (nMiss == 0, "failed to attempt to build models for %d objects\n", nMiss); … … 149 149 psArray *sources = job->args->data[1]; 150 150 pmPSF *psf = job->args->data[2]; 151 151 152 152 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA); 153 153 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); … … 156 156 157 157 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 that161 // 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 the175 // peak and the position from the moments. Use the peak position if (a) there are no176 // moments and (b) the sources is not saturated177 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 moments181 useMoments = (useMoments && source->moments->nPixels); // can't if the moments were not measured182 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 model214 // this function affects the mask pixels215 psphotCheckRadiusPSF (readout, source, modelPSF, markVal);216 217 // set the source PSF model218 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 (!) 223 223 } 224 224 -
branches/eam_branches/20091201/psphot/src/psphotLoadPSF.c
r26793 r26808 11 11 12 12 // load an externally supplied psf model 13 bool psphotLoadPSFReadout (pmConfig *config, const pmFPAview *view, const char * filename, int index) {13 bool psphotLoadPSFReadout (pmConfig *config, const pmFPAview *view, const char *outFilename, const char *inFilename, int index) { 14 14 15 15 bool status; 16 16 17 17 // 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) { 20 27 psLogMsg ("psphot", 3, "no psf supplied for this chip"); 21 28 return true; … … 23 30 24 31 // find the currently selected chip 25 pmChip *chip = pmFPAviewThisChip (view, file->fpa);32 pmChip *chip = pmFPAviewThisChip (view, inFile->fpa); 26 33 if (!chip) return false; 27 34 28 35 // find the currently selected readout 29 pmReadout *readout = pmFPAviewThisReadout (view, file->fpa);36 pmReadout *readout = pmFPAviewThisReadout (view, outFile->fpa); 30 37 if (!readout) return false; 31 38 … … 64 71 65 72 // 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)) { 67 74 psError (PSPHOT_ERR_CONFIG, false, "failed to load PSF model for PSPHOT.PSF.LOAD entry %d", i); 68 75 return false; -
branches/eam_branches/20091201/psphot/src/psphotModelBackground.c
r26788 r26808 38 38 // readout->analysis 39 39 static bool psphotModelBackgroundReadout(psImage *model, // Model image 40 psImage *modelStdev, // Model stdev image41 psMetadata *analysis, // Analysis metadata for outputs42 pmReadout *readout, // Readout for which to generate a background model43 psImageBinning *binning, // Binning parameters44 const pmConfig *config // Configuration40 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 45 45 ) 46 46 { … … 218 218 stats->options = PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV; 219 219 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); 223 223 modelData[iy][ix] = modelStdevData[iy][ix] = NAN; 224 224 } else { … … 383 383 // loop over the available readouts 384 384 for (int i = 0; i < num; i++) { 385 if (!psphotModelBackgroundReadoutFileIndex(config, view, "PSPHOT.INPUT", i)) {385 if (!psphotModelBackgroundReadoutFileIndex(config, view, "PSPHOT.INPUT", i)) { 386 386 psError (PSPHOT_ERR_CONFIG, false, "failed to model background for PSPHOT.INPUT entry %d", i); 387 return false;388 }387 return false; 388 } 389 389 } 390 390 return true; -
branches/eam_branches/20091201/psphot/src/psphotReadoutMinimal.c
r26788 r26808 62 62 psphotGuessModels (config, view); 63 63 64 // merge the newly selected sources into the existing list 65 psphotMergeSources (config, view); 66 64 67 // linear PSF fit to source peaks 65 68 psphotFitSourcesLinear (config, view, false);
Note:
See TracChangeset
for help on using the changeset viewer.
