Changeset 26688
- Timestamp:
- Jan 26, 2010, 5:10:34 PM (16 years ago)
- Location:
- branches/eam_branches/psphot.stack.20100120
- Files:
-
- 28 edited
-
doc/stack.txt (modified) (1 diff)
-
src/Makefile.am (modified) (2 diffs)
-
src/psphot.h (modified) (12 diffs)
-
src/psphotAddNoise.c (modified) (3 diffs)
-
src/psphotApResid.c (modified) (2 diffs)
-
src/psphotBasicDeblend.c (modified) (1 diff)
-
src/psphotBlendFit.c (modified) (2 diffs)
-
src/psphotChoosePSF.c (modified) (1 diff)
-
src/psphotDeblendSatstars.c (modified) (1 diff)
-
src/psphotEfficiency.c (modified) (2 diffs)
-
src/psphotExtendedSourceAnalysis.c (modified) (2 diffs)
-
src/psphotExtendedSourceFits.c (modified) (3 diffs)
-
src/psphotFindDetections.c (modified) (7 diffs)
-
src/psphotFitSourcesLinear.c (modified) (1 diff)
-
src/psphotGuessModels.c (modified) (2 diffs)
-
src/psphotImageQuality.c (modified) (3 diffs)
-
src/psphotMagnitudes.c (modified) (4 diffs)
-
src/psphotMergeSources.c (modified) (2 diffs)
-
src/psphotModelBackground.c (modified) (1 diff)
-
src/psphotOutput.c (modified) (2 diffs)
-
src/psphotReadout.c (modified) (13 diffs)
-
src/psphotReadoutCleanup.c (modified) (1 diff)
-
src/psphotReplaceUnfit.c (modified) (2 diffs)
-
src/psphotRoughClass.c (modified) (2 diffs)
-
src/psphotSkyReplace.c (modified) (1 diff)
-
src/psphotSourceFreePixels.c (modified) (2 diffs)
-
src/psphotSourceSize.c (modified) (7 diffs)
-
src/psphotSourceStats.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/psphot.stack.20100120/doc/stack.txt
r26643 r26688 24 24 can we use the processing flags to distinguish the these cases and carry around 25 25 only a single source list? 26 27 * detections->peaks holds the most recently detected set of peaks 28 detections->oldPeaks holds the previous collection 29 30 detections->footprints holds the full set of merged footprints, 31 including assigned peaks from the old and new set. 26 32 27 33 20100107 : updates for stack processing -
branches/eam_branches/psphot.stack.20100120/src/Makefile.am
r25984 r26688 33 33 psphot_LDADD = libpsphot.la 34 34 35 psphotForced_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)36 psphotForced_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)37 psphotForced_LDADD = libpsphot.la38 39 psphotMakePSF_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)40 psphotMakePSF_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)41 psphotMakePSF_LDADD = libpsphot.la42 43 psphotTest_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)44 psphotTest_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)45 psphotTest_LDADD = libpsphot.la46 47 psphotMomentsStudy_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)48 psphotMomentsStudy_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)49 psphotMomentsStudy_LDADD = libpsphot.la35 # psphotForced_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 36 # psphotForced_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 37 # psphotForced_LDADD = libpsphot.la 38 # 39 # psphotMakePSF_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 40 # psphotMakePSF_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 41 # psphotMakePSF_LDADD = libpsphot.la 42 # 43 # psphotTest_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 44 # psphotTest_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 45 # psphotTest_LDADD = libpsphot.la 46 # 47 # psphotMomentsStudy_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 48 # psphotMomentsStudy_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 49 # psphotMomentsStudy_LDADD = libpsphot.la 50 50 51 51 # psphotPetrosianStudy_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) … … 62 62 psphotCleanup.c 63 63 64 # forced photometry of specified positions given a specified psf65 psphotForced_SOURCES = \66 psphotForced.c \67 psphotForcedArguments.c \68 psphotForcedImageLoop.c \69 psphotForcedReadout.c \70 psphotParseCamera.c \71 psphotMosaicChip.c \72 psphotCleanup.c73 74 # a psphot-variant that simply generates the PSF model75 psphotMakePSF_SOURCES = \76 psphotMakePSF.c \77 psphotMakePSFArguments.c \78 psphotMakePSFImageLoop.c \79 psphotMakePSFReadout.c \80 psphotParseCamera.c \81 psphotMosaicChip.c \82 psphotCleanup.c83 84 85 # psphot analysis of the detectability of specified positions86 psphotDetect_SOURCES = \87 psphotDetect.c \88 psphotDetectArguments.c \89 psphotDetectParseCamera.c \90 psphotDetectImageLoop.c \91 psphotDetectReadout.c \92 psphotMosaicChip.c \93 psphotCleanup.c94 95 psphotTest_SOURCES = \96 psphotTest.c97 98 psphotMomentsStudy_SOURCES = \99 psphotMomentsStudy.c64 # # forced photometry of specified positions given a specified psf 65 # psphotForced_SOURCES = \ 66 # psphotForced.c \ 67 # psphotForcedArguments.c \ 68 # psphotForcedImageLoop.c \ 69 # psphotForcedReadout.c \ 70 # psphotParseCamera.c \ 71 # psphotMosaicChip.c \ 72 # psphotCleanup.c 73 # 74 # # a psphot-variant that simply generates the PSF model 75 # psphotMakePSF_SOURCES = \ 76 # psphotMakePSF.c \ 77 # psphotMakePSFArguments.c \ 78 # psphotMakePSFImageLoop.c \ 79 # psphotMakePSFReadout.c \ 80 # psphotParseCamera.c \ 81 # psphotMosaicChip.c \ 82 # psphotCleanup.c 83 # 84 # 85 # # psphot analysis of the detectability of specified positions 86 # psphotDetect_SOURCES = \ 87 # psphotDetect.c \ 88 # psphotDetectArguments.c \ 89 # psphotDetectParseCamera.c \ 90 # psphotDetectImageLoop.c \ 91 # psphotDetectReadout.c \ 92 # psphotMosaicChip.c \ 93 # psphotCleanup.c 94 # 95 # psphotTest_SOURCES = \ 96 # psphotTest.c 97 # 98 # psphotMomentsStudy_SOURCES = \ 99 # psphotMomentsStudy.c 100 100 101 101 # psphotPetrosianStudy_SOURCES = \ -
branches/eam_branches/psphot.stack.20100120/src/psphot.h
r26681 r26688 12 12 13 13 #define PSPHOT_RECIPE_PSF_FAKE_ALLOW "PSF.FAKE.ALLOW" // Name for recipe component permitting fake PSFs 14 15 // pmPCMData : PSF Convolved Model data storage structure 16 typedef struct { 17 psImage *model; 18 psArray *dmodels; 19 psImage *modelConv; 20 psArray *dmodelsConv; 21 } pmPCMData; 14 22 15 23 // top-level psphot functions … … 38 46 // XXX test functions 39 47 psArray *psphotFakeSources (void); 40 bool psphotMaskCosmicRayFootprintCheck (psArray *sources);48 bool psphotMaskCosmicRayFootprintCheck (psArray *sources); 41 49 42 50 // psphotReadout functions 51 bool psphotAddPhotcode (pmConfig *config, const pmFPAview *view); 52 bool psphotAddPhotcodeReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index); 53 54 bool psphotSetMaskAndVariance (pmConfig *config, const pmFPAview *view, psMetadata *recipe); 55 bool psphotSetMaskAndVarianceReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 56 43 57 bool psphotModelBackground (pmConfig *config, const pmFPAview *view); 44 58 bool psphotModelBackgroundReadoutFileIndex (pmConfig *config, const pmFPAview *view, const char *filename, int index); 45 59 46 // Create a background model for a readout, without saving the result as a pmFPAfile on47 // config->files. Otherwise identical to psphotModelBackgroundFileIndex.48 psImage *psphotModelBackgroundReadoutNoFile(pmReadout *readout, const pmConfig *config);49 50 // worker function for above background model functions51 bool psphotModelBackgroundReadout(psImage *model, // Model image52 psImage *modelStdev, // Model stdev image53 psMetadata *analysis, // Analysis metadata for outputs54 pmReadout *readout, // Readout for which to generate a background model55 psImageBinning *binning, // Binning parameters56 const pmConfig *config // Configuration57 );58 59 psImageBinning *psphotBackgroundBinning(const psImage *, const pmConfig *);60 61 62 63 60 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view); 64 bool psphotSubtractBackgroundReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index); 65 66 67 pmDetections *psphotFindDetections (pmDetections *detections, pmReadout *readout, psMetadata *recipe); 68 69 bool psphotRoughClass (pmReadout *readout, psArray *sources, psMetadata *recipe, const bool findPsfClump); 70 bool psphotBasicDeblend (psArray *sources, psMetadata *recipe); 71 pmPSF *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe); 61 bool psphotSubtractBackgroundReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 62 63 bool psphotFindDetections (pmConfig *config, const pmFPAview *view); 64 bool psphotFindDetectionsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 65 66 bool psphotSourceStats (pmConfig *config, const pmFPAview *view, bool setWindow); 67 bool psphotSourceStatsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool setWindow); 68 69 bool psphotDeblendSatstars (pmConfig *config, const pmFPAview *view); 70 bool psphotDeblendSatstarsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index); 71 72 bool psphotBasicDeblend (pmConfig *config, const pmFPAview *view); 73 bool psphotBasicDeblend (pmConfig *config, const pmFPAview *view, const char *filename, int index); 74 75 bool psphotRoughClass (pmConfig *config, const pmFPAview *view); 76 bool psphotRoughClassReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 77 bool psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata *analysis, psMetadata *recipe, const bool havePSF); 78 79 bool psphotImageQuality (pmConfig *config, const pmFPAview *view); 80 bool psphotImageQualityReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 81 82 bool psphotChoosePSF (pmConfig *config, const pmFPAview *view); 83 bool psphotChoosePSFReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 84 85 bool psphotGuessModels (pmConfig *config, const pmFPAview *view); 86 bool psphotGuessModelsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index); 87 88 bool psphotMergeSources (pmConfig *config, const pmFPAview *view); 89 bool psphotMergeSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index); 90 91 bool psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, bool final); 92 bool psphotFitSourcesLinearReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index); 93 94 bool psphotSourceSize (pmConfig *config, const pmFPAview *view, bool getPSFsize); 95 bool psphotSourceSizeReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool getPSFsize); 96 97 bool psphotBlendFit (pmConfig *config, const pmFPAview *view); 98 bool psphotBlendFitReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 99 bool psphotBlendFit_Threaded (psThreadJob *job); 100 101 bool psphotReplaceAllSources (pmConfig *config, const pmFPAview *view); 102 bool psphotReplaceAllSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 103 104 bool psphotAddNoise (pmConfig *config, const pmFPAview *view); 105 bool psphotSubNoise (pmConfig *config, const pmFPAview *view); 106 bool psphotAddOrSubNoise (pmConfig *config, const pmFPAview *view, bool add); 107 bool psphotAddOrSubNoiseReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool add); 108 109 bool psphotExtendedSourceAnalysis (pmConfig *config, const pmFPAview *view); 110 bool psphotExtendedSourceAnalysisReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 111 112 bool psphotExtendedSourceFits (pmConfig *config, const pmFPAview *view); 113 bool psphotExtendedSourceFitsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 114 115 bool psphotApResid (pmConfig *config, const pmFPAview *view); 116 bool psphotApResid (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 117 118 bool psphotMagnitudes (pmConfig *config, const pmFPAview *view); 119 bool psphotMagnitudesReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 120 bool psphotMagnitudes_Threaded (psThreadJob *job); 121 122 bool psphotEfficiency (pmConfig *config, const pmFPAview *view); 123 bool psphotEfficiencyReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe); 124 125 bool psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources); 126 bool psphotPSFWeights_Threaded (psThreadJob *job); 127 128 bool psphotSkyReplace (pmConfig *config, const pmFPAview *view); 129 bool psphotSkyReplaceReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index); 130 131 bool psphotSourceFreePixels (pmConfig *config, const pmFPAview *view); 132 bool psphotSourceFreePixelsReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index); 133 134 // in psphotSourceStats.c: 135 bool psphotSourceStats_Threaded (psThreadJob *job); 136 bool psphotSourceStatsUpdate (psArray *sources, pmConfig *config, pmReadout *readout); 137 bool psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources); 138 139 // in psphotChoosePSF.c: 72 140 bool psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf); 73 141 bool psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources); 74 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, const psMetadata *recipe, const pmPSF *psf, bool final); 142 143 // in psphotGuessModel.c 144 bool psphotGuessModel_Threaded (psThreadJob *job); 145 146 // in psphotMergeSources.c: 147 bool psphotLoadExtSources (pmConfig *config, const pmFPAview *view, psArray *sources); 148 psArray *psphotLoadPSFSources (pmConfig *config, const pmFPAview *view); 149 150 // generate the detection structure for the supplied array of sources 151 pmDetections *psphotDetectionsFromSources (pmConfig *config, psArray *sources); 152 153 // generate the detection structure for the supplied array of sources 154 bool psphotSetSourceParams (pmConfig *config, psArray *sources, pmPSF *psf); 155 156 // in psphotModelBackground.c: 157 // Create a background model for a readout, without saving the result as a pmFPAfile on config->files. Otherwise identical to psphotModelBackgroundFileIndex. 158 psImage *psphotModelBackgroundReadoutNoFile(pmReadout *readout, const pmConfig *config); 159 psImageBinning *psphotBackgroundBinning(const psImage *, const pmConfig *); 160 161 // in psphotReplaceUnfit.c: 162 bool psphotRemoveAllSources (const psArray *sources, const psMetadata *recipe); 163 bool psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal); 75 164 bool psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal); 76 77 bool psphotSetMomentsWindow (psMetadata *recipe, psMetadata *analysis, psArray *sources);78 165 79 166 bool psphotReplaceAllSources (psArray *sources, psMetadata *recipe); 80 167 bool psphotRemoveAllSources (const psArray *sources, const psMetadata *recipe); 81 82 bool psphotBlendFit (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);83 bool psphotBlendFit_Threaded (psThreadJob *job);84 85 bool psphotSourceStatsUpdate (psArray *sources, pmConfig *config, pmReadout *readout);86 psArray *psphotSourceStats (pmConfig *config, pmReadout *readout, pmDetections *detections, bool setWindow);87 bool psphotSourceStats_Threaded (psThreadJob *job);88 89 bool psphotGuessModels (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);90 bool psphotGuessModel_Threaded (psThreadJob *job);91 92 bool psphotMagnitudes (pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, const pmPSF *psf);93 bool psphotMagnitudes_Threaded (psThreadJob *job);94 95 bool psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources);96 bool psphotPSFWeights_Threaded (psThreadJob *job);97 98 bool psphotApResid (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf);99 100 bool psphotSkyReplace (pmConfig *config, const pmFPAview *view);101 bool psphotExtendedSourceAnalysis (pmReadout *readout, psArray *sources, psMetadata *recipe);102 bool psphotExtendedSourceFits (pmReadout *readout, psArray *sources, psMetadata *recipe);103 bool psphotEfficiency(pmConfig *config, pmReadout *readout, const pmFPAview *view, const pmPSF *psf, psMetadata *recipe, const psArray *realSources);104 168 105 169 // thread-related: … … 115 179 psErrorCode psphotCullPeaks(const psImage *img, const psImage *weight, const psMetadata *recipe, psArray *footprints); 116 180 117 // generate the detection structure for the supplied array of sources 118 pmDetections *psphotDetectionsFromSources (pmConfig *config, psArray *sources); 119 120 // used by ApResid 181 // in psphotApResid.c: 121 182 pmTrend2D *psphotApResidTrend (float *apResidSysErr, pmReadout *readout, int Nx, int Ny, psVector *xPos, psVector *yPos, psVector *apResid, psVector *dMag); 122 183 bool psphotApResidMags_Threaded (psThreadJob *job); … … 125 186 void psphotModelClassInit (void); 126 187 bool psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal); 127 bool psphotSetMaskAndVariance (pmConfig *config, const pmFPAview *view, psMetadata *recipe);128 bool psphotSetMaskAndVarianceReadout (pmConfig *config, pmReadout *readout, psMetadata *recipe);129 188 void psphotSourceFreePixels (psArray *sources); 130 131 bool psphotRoughClassRegion (int nRegion, psRegion *region, psArray *sources, psMetadata *target, psMetadata *recipe, const bool havePSF);132 189 133 190 // functions to set the correct source pixels … … 138 195 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal); 139 196 float psphotSetRadiusEXT (pmReadout *readout, pmSource *source, psImageMaskType markVal); 140 141 // output functions142 bool psphotAddPhotcodeReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index);143 bool psphotAddPhotcode (pmConfig *config, const pmFPAview *view);144 197 145 198 bool psphotDumpMoments (psMetadata *recipe, psArray *sources); … … 173 226 bool psphotFitSummary (void); 174 227 175 bool psphotMergeSources (psArray *oldSources, psArray *newSources);176 bool psphotLoadExtSources (pmConfig *config, const pmFPAview *view, psArray *sources);177 psArray *psphotLoadPSFSources (pmConfig *config, const pmFPAview *view);178 179 228 pmPSF *psphotLoadPSF (pmConfig *config, const pmFPAview *view, psMetadata *recipe); 180 229 bool psphotSetHeaderNstars (psMetadata *recipe, psArray *sources); … … 186 235 bool psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY, bool normalize); 187 236 188 bool psphotAddWithTest (pmSource *source, bool useState, psImageMaskType maskVal);189 bool psphotSubWithTest (pmSource *source, bool useState, psImageMaskType maskVal);190 bool psphotSetState (pmSource *source, bool curState, psImageMaskType maskVal);191 bool psphotDeblendSatstars (pmReadout *readout, psArray *sources, psMetadata *recipe);192 bool psphotSourceSize (pmConfig *config, pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, long first);193 194 237 bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psImageMaskType maskVal); 195 238 … … 199 242 200 243 // functions related to extended source analysis 201 bool psphotRadialProfile (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal);202 bool psphotRadialProfilesByAngles (pmSource *source, int Nsec, float Rmax);203 float psphotRadiusFromProfile (pmSource *source, psVector *radius, psVector *flux, float fluxMin, float fluxMax);204 bool psphotRadiiFromProfiles (pmSource *source, float fluxMin, float fluxMax);205 bool psphotEllipticalProfile (pmSource *source);206 bool psphotEllipticalContour (pmSource *source);244 bool psphotRadialProfile (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal); 245 bool psphotRadialProfilesByAngles (pmSource *source, int Nsec, float Rmax); 246 float psphotRadiusFromProfile (pmSource *source, psVector *radius, psVector *flux, float fluxMin, float fluxMax); 247 bool psphotRadiiFromProfiles (pmSource *source, float fluxMin, float fluxMax); 248 bool psphotEllipticalProfile (pmSource *source); 249 bool psphotEllipticalContour (pmSource *source); 207 250 208 251 // psphotVisual functions 209 bool psphotVisualShowImage (pmReadout *readout); 210 bool psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout); 211 bool psphotVisualShowSignificance (psImage *image, float min, float max); 212 bool psphotVisualShowPeaks (pmDetections *detections); 213 bool psphotVisualShowFootprints (pmDetections *detections); 214 bool psphotVisualShowMoments (psArray *sources); 215 bool psphotVisualPlotMoments (psMetadata *recipe, psMetadata *analysis, psArray *sources); 216 bool psphotVisualShowRoughClass (psArray *sources); 217 bool psphotVisualShowPSFStars (psMetadata *recipe, pmPSF *psf, psArray *sources); 218 bool psphotVisualShowSatStars (psMetadata *recipe, pmPSF *psf, psArray *sources); 219 bool psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf); 220 bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal); 221 bool psphotVisualPlotRadialProfiles (psMetadata *recipe, psArray *sources); 222 bool psphotVisualShowFlags (psArray *sources); 223 bool psphotVisualShowSourceSize (pmReadout *readout, psArray *sources); 224 bool psphotVisualShowResidualImage (pmReadout *readout); 225 bool psphotVisualPlotApResid (psArray *sources, float mean, float error); 226 bool psphotVisualPlotChisq (psArray *sources); 227 bool psphotVisualPlotSourceSize (psMetadata *recipe, psMetadata *analysis, psArray *sources); 228 bool psphotVisualShowPetrosians (psArray *sources); 229 230 // bool psphotPetrosianAnalysis (pmReadout *readout, psArray *sources, psMetadata *recipe); 231 // bool psphotPetrosianProfile (pmReadout *readout, pmSource *source, float skynoise); 252 bool psphotVisualShowImage (pmReadout *readout); 253 bool psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout); 254 bool psphotVisualShowSignificance (psImage *image, float min, float max); 255 bool psphotVisualShowPeaks (pmDetections *detections); 256 bool psphotVisualShowFootprints (pmDetections *detections); 257 bool psphotVisualShowMoments (psArray *sources); 258 bool psphotVisualPlotMoments (psMetadata *recipe, psMetadata *analysis, psArray *sources); 259 bool psphotVisualShowRoughClass (psArray *sources); 260 bool psphotVisualShowPSFStars (psMetadata *recipe, pmPSF *psf, psArray *sources); 261 bool psphotVisualShowSatStars (psMetadata *recipe, pmPSF *psf, psArray *sources); 262 bool psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf); 263 bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal); 264 bool psphotVisualPlotRadialProfiles (psMetadata *recipe, psArray *sources); 265 bool psphotVisualShowFlags (psArray *sources); 266 bool psphotVisualShowSourceSize (pmReadout *readout, psArray *sources); 267 bool psphotVisualShowResidualImage (pmReadout *readout); 268 bool psphotVisualPlotApResid (psArray *sources, float mean, float error); 269 bool psphotVisualPlotChisq (psArray *sources); 270 bool psphotVisualPlotSourceSize (psMetadata *recipe, psMetadata *analysis, psArray *sources); 271 bool psphotVisualShowPetrosians (psArray *sources); 272 bool psphotVisualEraseOverlays (int channel, char *overlay); 232 273 233 274 bool psphotPetrosian (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal); … … 235 276 bool psphotPetrosianStats (pmSource *source); 236 277 237 // XXX old versions, currently disabled278 // currently disabled: 238 279 // bool psphotIsophotal (pmSource *source, psMetadata *recipe, psImageMaskType maskVal); 239 280 // bool psphotAnnuli (pmSource *source, psMetadata *recipe, psImageMaskType maskVal); … … 250 291 // float petFlux, float radiusForFlux); 251 292 252 bool psphotImageQuality (psMetadata *recipe, psArray *sources);253 254 293 // structures & functions to support psf-convolved model fitting 255 256 // pmPCMData : PSF Convolved Model data storage structure257 typedef struct {258 psImage *model;259 psArray *dmodels;260 psImage *modelConv;261 psArray *dmodelsConv;262 } pmPCMData;263 264 294 265 295 // psf-convolved model fitting … … 291 321 292 322 int psphotKapaOpen (void); 293 bool psphotVisualEraseOverlays (int channel, char *overlay);294 323 bool psphotKapaClose (void); 295 324 bool psphotImageBackgroundCellHistogram (psVector *values, float mean, float sigma, int ix, int iy); … … 305 334 int psphotSupplementStars (psArray *stars, psArray *sources, psImageBinning *binning, int ix, int iy); 306 335 307 308 336 pmConfig *psphotForcedArguments(int argc, char **argv); 309 337 bool psphotForcedImageLoop (pmConfig *config); -
branches/eam_branches/psphot.stack.20100120/src/psphotAddNoise.c
r26681 r26688 31 31 } 32 32 33 bool psphotAddOrSubNoise (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool add) {33 bool psphotAddOrSubNoiseReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool add) { 34 34 35 35 bool status = false; … … 40 40 // find the currently selected readout 41 41 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 42 psAssert ( readout, "missing file?");42 psAssert (file, "missing file?"); 43 43 44 44 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); … … 47 47 psAssert (readout->parent->concepts, "missing concepts?"); 48 48 49 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 49 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 50 psAssert (detections, "missing detections?"); 51 52 psArray *sources = detections->allSources; 50 53 psAssert (sources, "missing sources?"); 51 54 -
branches/eam_branches/psphot.stack.20100120/src/psphotApResid.c
r26261 r26688 4 4 // measure the aperture residual statistics and 2D variations 5 5 6 bool psphotApResid (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf) 6 // for now, let's store the detections on the readout->analysis for each readout 7 bool psphotApResid (pmConfig *config, const pmFPAview *view) 8 { 9 bool status = true; 10 11 // select the appropriate recipe information 12 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 13 psAssert (recipe, "missing recipe?"); 14 15 int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 16 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 17 18 // loop over the available readouts 19 for (int i = 0; i < num; i++) { 20 if (!psphottApResidReadout (config, view, "PSPHOT.INPUT", i, recipe)) { 21 psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i); 22 return false; 23 } 24 } 25 return true; 26 } 27 28 bool psphotApResid (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) 7 29 { 8 30 int Nfail = 0; … … 13 35 pmSource *source; 14 36 15 PS_ASSERT_PTR_NON_NULL(config, false);16 PS_ASSERT_PTR_NON_NULL(readout, false);17 PS_ASSERT_PTR_NON_NULL(sources, false);18 PS_ASSERT_PTR_NON_NULL(psf, false);19 20 37 psTimerStart ("psphot.apresid"); 21 38 22 // select the appropriate recipe information 23 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 24 assert (recipe); 39 // find the currently selected readout 40 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 41 psAssert (readout, "missing file?"); 42 43 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 44 psAssert (readout, "missing readout?"); 45 46 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 47 psAssert (detections, "missing detections?"); 48 49 psArray *sources = detections->allSources; 50 psAssert (sources, "missing sources?"); 51 52 if (!sources->n) { 53 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping ap resid"); 54 return true; 55 } 56 57 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 58 psAssert (psf, "missing psf?"); 25 59 26 60 // determine the number of allowed threads -
branches/eam_branches/psphot.stack.20100120/src/psphotBasicDeblend.c
r26681 r26688 32 32 // find the currently selected readout 33 33 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 34 psAssert ( readout, "missing file?");34 psAssert (file, "missing file?"); 35 35 36 36 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 37 37 psAssert (readout, "missing readout?"); 38 38 39 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 39 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 40 psAssert (detections, "missing detections?"); 41 42 psArray *sources = detections->newSources; 40 43 psAssert (sources, "missing sources?"); 41 44 -
branches/eam_branches/psphot.stack.20100120/src/psphotBlendFit.c
r26681 r26688 36 36 // find the currently selected readout 37 37 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 38 psAssert ( readout, "missing file?");38 psAssert (file, "missing file?"); 39 39 40 40 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 41 41 psAssert (readout, "missing readout?"); 42 42 43 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 43 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 44 psAssert (detections, "missing detections?"); 45 46 psArray *sources = detections->allSources; 44 47 psAssert (sources, "missing sources?"); 45 48 … … 312 315 } 313 316 314 # if (0)315 bool psphotBlendFit_Unthreaded (int *nfit, int *npsf, int *next, int *nfail, pmReadout *readout, psMetadata *recipe, psArray *sources, pmPSF *psf, psArray *newSources) {316 317 bool status = false;318 int Nfit = 0;319 int Npsf = 0;320 int Next = 0;321 int Nfail = 0;322 323 // bit-masks to test for good/bad pixels324 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");325 assert (maskVal);326 327 // bit-mask to mark pixels not used in analysis328 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");329 assert (markVal);330 331 // maskVal is used to test for rejected pixels, and must include markVal332 maskVal |= markVal;333 334 // S/N limit to perform full non-linear fits335 float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM");336 337 // option to limit analysis to a specific region338 char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION");339 psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region));340 if (psRegionIsNaN (AnalysisRegion)) psAbort("analysis region mis-defined");341 342 for (int i = 0; i < sources->n; i++) {343 pmSource *source = sources->data[i];344 345 // skip non-astronomical objects (very likely defects)346 if (source->mode & PM_SOURCE_MODE_BLEND) continue;347 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue;348 if (source->type == PM_SOURCE_TYPE_DEFECT) continue;349 if (source->type == PM_SOURCE_TYPE_SATURATED) continue;350 351 // skip DBL second sources (ie, added by psphotFitBlob)352 if (source->mode & PM_SOURCE_MODE_PAIR) continue;353 354 // limit selection to some SN limit355 if (source->peak->SN < FIT_SN_LIM) continue;356 357 // exclude sources outside optional analysis region358 if (source->peak->xf < AnalysisRegion.x0) continue;359 if (source->peak->yf < AnalysisRegion.y0) continue;360 if (source->peak->xf > AnalysisRegion.x1) continue;361 if (source->peak->yf > AnalysisRegion.y1) continue;362 363 // if model is NULL, we don't have a starting guess364 if (source->modelPSF == NULL) continue;365 366 // skip sources which are insignificant flux?367 // XXX this is somewhat ad-hoc368 if (source->modelPSF->params->data.F32[1] < 0.1) {369 psTrace ("psphot", 5, "skipping near-zero source: %f, %f : %f\n",370 source->modelPSF->params->data.F32[1],371 source->modelPSF->params->data.F32[2],372 source->modelPSF->params->data.F32[3]);373 continue;374 }375 376 // replace object in image377 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) {378 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);379 }380 Nfit ++;381 382 // try fitting PSFs or extended sources depending on source->mode383 // these functions subtract the resulting fitted source384 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) {385 if (psphotFitBlob (readout, source, newSources, psf, maskVal, markVal)) {386 source->type = PM_SOURCE_TYPE_EXTENDED;387 psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->peak->xf, source->peak->yf);388 Next ++;389 continue;390 }391 } else {392 if (psphotFitBlend (readout, source, psf, maskVal, markVal)) {393 source->type = PM_SOURCE_TYPE_STAR;394 psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->peak->xf, source->peak->yf);395 Npsf ++;396 continue;397 }398 }399 400 psTrace ("psphot", 5, "source at %7.1f, %7.1f failed", source->peak->xf, source->peak->yf);401 Nfail ++;402 403 // re-subtract the object, leave local sky404 pmSourceCacheModel (source, maskVal);405 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);406 }407 408 // change the value of a scalar on the array (wrap this and put it in psArray.h)409 *nfit = Nfit;410 *npsf = Npsf;411 *next = Next;412 *nfail = Nfail;413 414 // moments are modified by the fit; re-display415 psphotVisualPlotMoments (recipe, sources);416 psphotVisualShowResidualImage (readout);417 418 return true;419 }420 # endif -
branches/eam_branches/psphot.stack.20100120/src/psphotChoosePSF.c
r26681 r26688 38 38 // find the currently selected readout 39 39 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 40 psAssert ( readout, "missing file?");40 psAssert (file, "missing file?"); 41 41 42 42 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 43 43 psAssert (readout, "missing readout?"); 44 44 45 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 45 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 46 psAssert (detections, "missing detections?"); 47 48 psArray *sources = detections->newSources; 46 49 psAssert (sources, "missing sources?"); 47 50 -
branches/eam_branches/psphot.stack.20100120/src/psphotDeblendSatstars.c
r26681 r26688 31 31 // find the currently selected readout 32 32 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 33 psAssert ( readout, "missing file?");33 psAssert (file, "missing file?"); 34 34 35 35 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 36 36 psAssert (readout, "missing readout?"); 37 37 38 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 38 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 39 psAssert (detections, "missing detections?"); 40 41 psArray *sources = detections->newSources; 39 42 psAssert (sources, "missing sources?"); 40 43 -
branches/eam_branches/psphot.stack.20100120/src/psphotEfficiency.c
r26266 r26688 149 149 150 150 151 bool psphotEfficiency (pmConfig *config, const pmFPAview *view) 152 { 153 bool status = true; 154 155 // select the appropriate recipe information 156 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 157 psAssert (recipe, "missing recipe?"); 158 159 int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 160 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 161 162 // loop over the available readouts 163 for (int i = 0; i < num; i++) { 164 if (!psphotReadout (config, view, "PSPHOT.INPUT", i, recipe)) { 165 psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i); 166 return false; 167 } 168 } 169 return true; 170 } 171 151 172 // Determine detection efficiency 152 bool psphotEfficiency(pmConfig *config, pmReadout *readout, const pmFPAview *view, const pmPSF *psf, 153 psMetadata *recipe, const psArray *realSources) 173 bool psphotEfficiencyReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) 154 174 { 175 psTimerStart("psphot.fake"); 176 177 // find the currently selected readout 178 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 179 psAssert (readout, "missing file?"); 180 181 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 182 psAssert (readout, "missing readout?"); 183 184 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 185 psAssert (detections, "missing detections?"); 186 187 psArray *realSources = detections->allSources; 188 psAssert (realSources, "missing sources?"); 189 190 // XXX do we need to skip this step if we do not have a psf? 191 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 192 psAssert (psf, "missing psf?"); 193 155 194 PM_ASSERT_READOUT_NON_NULL(readout, false); 156 195 PM_ASSERT_READOUT_IMAGE(readout, false); 157 196 PS_ASSERT_PTR_NON_NULL(psf, false); 158 197 PS_ASSERT_METADATA_NON_NULL(recipe, false); 159 PS_ASSERT_ARRAY_NON_NULL(realSources, false);160 161 psTimerStart("psphot.fake");162 198 163 199 // Collect recipe information … … 202 238 // remove all sources, adding noise for subtracted sources 203 239 psphotRemoveAllSources(realSources, recipe); 204 // psphotAddNoise(readout, realSources, recipe);240 // psphotAddNoise(readout, realSources, recipe); 205 241 206 242 -
branches/eam_branches/psphot.stack.20100120/src/psphotExtendedSourceAnalysis.c
r25755 r26688 1 1 # include "psphotInternal.h" 2 2 3 // for now, let's store the detections on the readout->analysis for each readout 4 bool psphotExtendedSourceAnalysis (pmConfig *config, const pmFPAview *view) 5 { 6 bool status = true; 7 8 // select the appropriate recipe information 9 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 10 psAssert (recipe, "missing recipe?"); 11 12 // perform full non-linear fits / extended source analysis? 13 if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANALYSIS")) { 14 psLogMsg ("psphot", PS_LOG_INFO, "skipping extended source measurements\n"); 15 return true; 16 } 17 18 int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 19 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 20 21 // loop over the available readouts 22 for (int i = 0; i < num; i++) { 23 if (!psphotExtendedSourceAnalysisReadout (config, view, "PSPHOT.INPUT", i, recipe)) { 24 psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i); 25 return false; 26 } 27 } 28 return true; 29 } 30 3 31 // aperture-like measurements for extended sources 4 bool psphotExtendedSourceAnalysis (pmReadout *readout, psArray *sources, psMetadata *recipe) {32 bool psphotExtendedSourceAnalysisReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) { 5 33 6 34 bool status; … … 11 39 int Nkron = 0; 12 40 41 // find the currently selected readout 42 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 43 psAssert (readout, "missing file?"); 44 45 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 46 psAssert (readout, "missing readout?"); 47 48 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 49 psAssert (detections, "missing detections?"); 50 51 psArray *sources = detections->allSources; 52 psAssert (sources, "missing sources?"); 53 54 if (!sources->n) { 55 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping source size"); 56 return true; 57 } 58 13 59 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 14 60 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 15 61 assert (maskVal); 16 17 // perform full non-linear fits / extended source analysis?18 if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_ANALYSIS")) {19 psLogMsg ("psphot", PS_LOG_INFO, "skipping extended source measurements\n");20 return true;21 }22 62 23 63 // XXX require petrosian analysis for non-linear fits? -
branches/eam_branches/psphot.stack.20100120/src/psphotExtendedSourceFits.c
r25755 r26688 1 1 # include "psphotInternal.h" 2 2 3 // for now, let's store the detections on the readout->analysis for each readout 4 bool psphotExtendedSourceFits (pmConfig *config, const pmFPAview *view) 5 { 6 bool status = true; 7 8 // select the appropriate recipe information 9 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 10 psAssert (recipe, "missing recipe?"); 11 12 // perform full extended source non-linear fits? 13 if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_FITS")) { 14 psLogMsg ("psphot", PS_LOG_INFO, "skipping extended source measurements\n"); 15 return true; 16 } 17 18 int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 19 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 20 21 // loop over the available readouts 22 for (int i = 0; i < num; i++) { 23 if (!psphotExtendedSourceFitsReadout (config, view, "PSPHOT.INPUT", i, recipe)) { 24 psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i); 25 return false; 26 } 27 } 28 return true; 29 } 30 3 31 // non-linear model fitting for extended sources 4 bool psphotExtendedSourceFits (pmReadout *readout, psArray *sources, psMetadata *recipe) {32 bool psphotExtendedSourceFitsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) { 5 33 6 34 bool status; … … 12 40 bool savePics = false; 13 41 42 // find the currently selected readout 43 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 44 psAssert (readout, "missing file?"); 45 46 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 47 psAssert (readout, "missing readout?"); 48 49 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 50 psAssert (detections, "missing detections?"); 51 52 psArray *sources = detections->allSources; 53 psAssert (sources, "missing sources?"); 54 55 if (!sources->n) { 56 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping source size"); 57 return true; 58 } 59 14 60 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 15 61 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels … … 21 67 // maskVal is used to test for rejected pixels, and must include markVal 22 68 maskVal |= markVal; 23 24 // perform full extended source non-linear fits?25 if (!psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_FITS")) {26 psLogMsg ("psphot", PS_LOG_INFO, "skipping extended source measurements\n");27 return true;28 }29 69 30 70 // select the collection of desired models -
branches/eam_branches/psphot.stack.20100120/src/psphotFindDetections.c
r26643 r26688 1 1 # include "psphotInternal.h" 2 2 3 // we store the detections on the readout->analysis for each readout this function finds new 4 // peaks and new footprints. any old peaks are saved on oldPeaks. the resulting footprint set 5 // contains all footprints (old and new) 6 bool psphotFindDetections (pmConfig *config, const pmFPAview *view) 7 { 8 bool status = true; 9 10 // select the appropriate recipe information 11 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 12 psAssert (recipe, "missing recipe?"); 13 14 int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 15 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 16 17 // loop over the available readouts 18 for (int i = 0; i < num; i++) { 19 if (!psphotFindDetectionsReadout (config, view, "PSPHOT.INPUT", i, recipe)) { 20 psError (PSPHOT_ERR_CONFIG, false, "failed to find initial detections for PSPHOT.INPUT entry %d", i); 21 return false; 22 } 23 } 24 return true; 25 } 26 3 27 // smooth the image, search for peaks, optionally define footprints based on the peaks 4 bool psphotFindDetections (pmConfig *config, const pmFPAview *view, const char *filename, int index) {28 bool psphotFindDetectionsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) { 5 29 6 30 bool status; … … 11 35 // find the currently selected readout 12 36 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 13 psAssert ( readout, "missing file?");37 psAssert (file, "missing file?"); 14 38 15 39 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 16 40 psAssert (readout, "missing readout?"); 17 18 // select the appropriate recipe information19 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);20 psAssert (recipe, "missing recipe?");21 41 22 42 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) … … 27 47 const bool useFootprints = psMetadataLookupBool(NULL, recipe, "USE_FOOTPRINTS"); 28 48 29 // on first pass, detections have not yet been allocated 49 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 50 // on the initial pass, detections have not yet been allocated or saved on readout->analysis 30 51 if (!detections) { 52 // create the container 31 53 detections = pmDetectionsAlloc(); 54 55 // save detections on the readout->analysis 56 if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_PTR, "psphot detectinos", detections)) { 57 psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout"); 58 return false; 59 } 60 32 61 pass = 1; 33 62 NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT"); PS_ASSERT (status, NULL); 34 63 NMAX = psMetadataLookupS32 (&status, recipe, "PEAKS_NMAX"); PS_ASSERT (status, NULL); 35 64 } else { 65 psMemIncrRefCounter(detections); // so we can free the detections below 36 66 pass = 2; 37 67 NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT_2"); PS_ASSERT (status, NULL); … … 41 71 float threshold = PS_SQR(NSIGMA_PEAK); 42 72 43 // move the old peaks array (if it exists) to oldPeaks 44 // XXX generically, we should be able to call this function an arbitrary number of times 73 // move the old peaks array (if it exists) to oldPeaks XXX generically, we should be able 74 // to call this function an arbitrary number of times the old peaks are saved so they can 75 // be freed later -- the have to be freed after psphotFindFootprints is called below, since 76 // they are also owned by the oldFootprints, which are in turn merged into the new 77 // footprints. (what about the source->peak entry?) 78 45 79 assert (detections->oldPeaks == NULL); 46 80 detections->oldPeaks = detections->peaks; … … 68 102 psFree (detections); 69 103 psError (PSPHOT_ERR_CONFIG, false, "failed on peak search"); 70 return NULL;104 return false; 71 105 } 72 106 … … 82 116 psphotVisualShowFootprints (detections); 83 117 84 // save detections on the readout->analysis 85 if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_PTR, "psphot detectinos", detections)) { 86 psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout"); 87 return NULL; 88 } 118 psFree (detections); 89 119 90 120 return true; … … 94 124 // otherwise it only contains the new peaks. 95 125 96 // for now, let's store the detections on the readout->analysis for each readout97 bool psphotFindDetections (pmConfig *config, const pmFPAview *view)98 {99 bool status = true;100 101 int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");102 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");103 104 // loop over the available readouts105 for (int i = 0; i < num; i++) {106 if (!psphotFindDetectionsReadout (config, view, "PSPHOT.INPUT", i)) {107 psError (PSPHOT_ERR_CONFIG, false, "failed to find initial detections for PSPHOT.INPUT entry %d", i);108 return false;109 }110 }111 return true;112 } -
branches/eam_branches/psphot.stack.20100120/src/psphotFitSourcesLinear.c
r26681 r26688 44 44 // find the currently selected readout 45 45 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 46 psAssert ( readout, "missing file?");46 psAssert (file, "missing file?"); 47 47 48 48 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 49 49 psAssert (readout, "missing readout?"); 50 50 51 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 51 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 52 psAssert (detections, "missing detections?"); 53 54 psArray *sources = detections->allSources; 52 55 psAssert (sources, "missing sources?"); 53 56 -
branches/eam_branches/psphot.stack.20100120/src/psphotGuessModels.c
r26681 r26688 25 25 } 26 26 27 // construct an initial PSF model for each object 27 // construct an initial PSF model for each object (new sources only) 28 28 bool psphotGuessModelsReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index) { 29 29 … … 39 39 psAssert (readout, "missing readout?"); 40 40 41 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 41 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 42 psAssert (detections, "missing detections?"); 43 44 psArray *sources = detections->newSources; 42 45 psAssert (sources, "missing sources?"); 43 46 -
branches/eam_branches/psphot.stack.20100120/src/psphotImageQuality.c
r26681 r26688 31 31 // find the currently selected readout 32 32 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 33 psAssert ( readout, "missing file?");33 psAssert (file, "missing file?"); 34 34 35 35 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); … … 41 41 } 42 42 43 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 43 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 44 psAssert (detections, "missing detections?"); 45 46 psArray *sources = detections->newSources; 44 47 psAssert (sources, "missing sources?"); 45 48 … … 123 126 124 127 if (num == 0) { 125 psWarning("Unable to find sources from which to measure image quality");126 return false;128 psLogMsg ("psphot", PS_LOG_INFO, "no valid sources for image quality, skipping"); 129 return true; 127 130 } 128 131 -
branches/eam_branches/psphot.stack.20100120/src/psphotMagnitudes.c
r25755 r26688 1 1 # include "psphotInternal.h" 2 2 3 bool psphotMagnitudes(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, const pmPSF *psf) { 3 bool psphotMagnitudes (pmConfig *config, const pmFPAview *view) 4 { 5 bool status = true; 6 7 // select the appropriate recipe information 8 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 9 psAssert (recipe, "missing recipe?"); 10 11 int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 12 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 13 14 // loop over the available readouts 15 for (int i = 0; i < num; i++) { 16 if (!psphotMagnitudesReadout (config, view, "PSPHOT.INPUT", i, recipe)) { 17 psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i); 18 return false; 19 } 20 } 21 return true; 22 } 23 24 bool psphotMagnitudesReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe) { 4 25 5 26 bool status = false; … … 8 29 psTimerStart ("psphot.mags"); 9 30 10 // select the appropriate recipe information 11 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 12 assert (recipe); 31 // find the currently selected readout 32 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 33 psAssert (readout, "missing file?"); 34 35 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 36 psAssert (readout, "missing readout?"); 37 38 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 39 psAssert (detections, "missing detections?"); 40 41 psArray *sources = detections->allSources; 42 psAssert (sources, "missing sources?"); 43 44 if (!sources->n) { 45 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping source size"); 46 return true; 47 } 48 49 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 50 psAssert (psf, "missing psf?"); 13 51 14 52 // determine the number of allowed threads … … 64 102 65 103 psArrayAdd(job->args, 1, cells->data[j]); // sources 66 psArrayAdd(job->args, 1, (pmPSF*)psf); // Casting away const104 psArrayAdd(job->args, 1, psf); 67 105 psArrayAdd(job->args, 1, binning); 68 106 psArrayAdd(job->args, 1, backModel); … … 179 217 } 180 218 181 # if (0)182 bool psphotMagnitudes_Unthreaded (int *nap, psArray *sources, pmPSF *psf, psImageBinning *binning, pmReadout *backModel, pmReadout *backStdev, pmSourcePhotometryMode photMode, psImageMaskType maskVal) {183 184 bool status;185 int Nap = 0;186 187 for (int i = 0; i < sources->n; i++) {188 pmSource *source = (pmSource *) sources->data[i];189 status = pmSourceMagnitudes (source, psf, photMode, maskVal);190 if (status && isfinite(source->apMag)) Nap ++;191 192 if (backModel) {193 psAssert (binning, "if backModel is defined, so should binning be");194 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning);195 if (isnan(source->sky) && false) {196 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky");197 }198 } else {199 source->sky = NAN;200 }201 202 if (backStdev) {203 psAssert (binning, "if backStdev is defined, so should binning be");204 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning);205 if (isnan(source->skyErr) && false) {206 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr");207 }208 } else {209 source->skyErr = NAN;210 }211 }212 213 // change the value of a scalar on the array (wrap this and put it in psArray.h)214 *nap = Nap;215 216 return true;217 }218 # endif219 220 219 bool psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources) { 221 220 -
branches/eam_branches/psphot.stack.20100120/src/psphotMergeSources.c
r26317 r26688 5 5 PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply for PSF sources 6 6 7 // for now, let's store the detections on the readout->analysis for each readout 8 bool psphotMergeSources (pmConfig *config, const pmFPAview *view) 9 { 10 bool status = true; 11 12 int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 13 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 14 15 // loop over the available readouts 16 for (int i = 0; i < num; i++) { 17 if (!psphotMergeSourcesReadout (config, view, "PSPHOT.INPUT", i)) { 18 psError (PSPHOT_ERR_CONFIG, false, "failed to merge sources for PSPHOT.INPUT entry %d", i); 19 return false; 20 } 21 } 22 return true; 23 } 24 25 // add newly selected sources to the existing list of sources 26 bool psphotMergeSourcesReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index) { 27 28 // find the currently selected readout 29 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 30 psAssert (file, "missing file?"); 31 32 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 33 psAssert (readout, "missing readout?"); 34 35 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 36 psAssert (detections, "missing detections?"); 37 38 psArray *newSources = detections->newSources; 39 psAssert (newSources, "missing sources?"); 40 41 if (!detections->allSources) { 42 detections->allSources = psArrayAllocEmpty(newSources->n); 43 } 44 psArray *allSources = detections->allSources; 45 46 for (int i = 0; i < newSources->n; i++) { 47 pmSource *source = newSources->data[i]; 48 psArrayAdd (allSources, 100, source); 49 } 50 51 // XXX free detections->newSources? 52 return true; 53 } 54 7 55 // merge the externally supplied sources with the existing sources. mark them as having 8 56 // mode PM_SOURCE_MODE_EXTERNAL 57 // XXX this function needs to be updated to work with the new context of pshot inputs 9 58 bool psphotLoadExtSources (pmConfig *config, const pmFPAview *view, psArray *sources) { 10 59 … … 71 120 } 72 121 73 // add newly selected sources to the existing list of sources74 bool psphotMergeSources (psArray *oldSources, psArray *newSources) {75 76 for (int i = 0; i < newSources->n; i++) {77 pmSource *source = newSources->data[i];78 psArrayAdd (oldSources, 100, source);79 }80 return true;81 }82 83 122 // extract the input sources corresponding to this readout 123 // XXX this function needs to be updated to work with the new context of pshot inputs 84 124 psArray *psphotLoadPSFSources (pmConfig *config, const pmFPAview *view) { 85 125 -
branches/eam_branches/psphot.stack.20100120/src/psphotModelBackground.c
r26681 r26688 32 32 // generate the median in NxN boxes, clipping heavily 33 33 // linear interpolation to generate full-scale model 34 bool psphotModelBackgroundReadout(psImage *model, // Model image34 static bool psphotModelBackgroundReadout(psImage *model, // Model image 35 35 psImage *modelStdev, // Model stdev image 36 36 psMetadata *analysis, // Analysis metadata for outputs -
branches/eam_branches/psphot.stack.20100120/src/psphotOutput.c
r26681 r26688 126 126 } 127 127 128 bool psphotAddPhotcodeReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index) {129 130 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest131 PS_ASSERT (file, false);132 133 pmReadout *readout = pmFPAviewThisReadout (view, file->fpa);134 135 // determine PHOTCODE from fpa & view, overwrite in readout->analysis136 char *photcode = pmConceptsPhotcodeForView (file, view);137 PS_ASSERT (photcode, false);138 139 psMetadataAddStr (readout->analysis, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "photcode from FPA concepts", photcode);140 psLogMsg ("psphot", 3, "PHOTCODE is %s", photcode);141 142 psFree (photcode);143 return true;144 }145 146 128 bool psphotAddPhotcode (pmConfig *config, const pmFPAview *view) { 147 129 … … 158 140 } 159 141 } 142 return true; 143 } 144 145 bool psphotAddPhotcodeReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index) { 146 147 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest 148 PS_ASSERT (file, false); 149 150 pmReadout *readout = pmFPAviewThisReadout (view, file->fpa); 151 152 // determine PHOTCODE from fpa & view, overwrite in readout->analysis 153 char *photcode = pmConceptsPhotcodeForView (file, view); 154 PS_ASSERT (photcode, false); 155 156 psMetadataAddStr (readout->analysis, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "photcode from FPA concepts", photcode); 157 psLogMsg ("psphot", 3, "PHOTCODE is %s", photcode); 158 159 psFree (photcode); 160 160 return true; 161 161 } -
branches/eam_branches/psphot.stack.20100120/src/psphotReadout.c
r26681 r26688 51 51 52 52 // run a single-model test if desired (exits from here if test is run) 53 // XXX drop this and only keep the stand-alone program?53 // XXX fix this in the new multi-input context (or drop this and only keep a stand-alone program) 54 54 // psphotModelTest (config, view, recipe); 55 55 56 56 // load the psf model, if suppled. FWHM_X,FWHM_Y,etc are saved in the recipe 57 // XXX this needs to save the PSF on the chip->analysis or readout->analysis 58 if (!psphotLoadPSF (config, view, recipe)) { 59 // this only happens if we had a programming error in psphotLoadPSF 60 psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model"); 61 return psphotReadoutCleanup (config, view); 62 } 57 // XXX the recipe is probably the wrong place to store those results... 58 // XXX this is using the wrong file... fix in the new context 59 // if (!psphotLoadPSF (config, view, recipe)) { 60 // // this only happens if we had a programming error in psphotLoadPSF 61 // psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model"); 62 // return psphotReadoutCleanup (config, view); 63 // } 63 64 64 65 // find the detections (by peak and/or footprint) in the image. 65 if (!psphotFindDetections (config, view)) { 66 if (!psphotFindDetections (config, view)) { // pass 1 66 67 // this only happens if we had an error in psphotFindDetections 67 68 psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis"); … … 69 70 } 70 71 71 XXX: // need to handle or ignore this !! 72 if (!detections->peaks->n) { 73 psLogMsg ("psphot", 3, "unable to find detections in this image"); 74 return psphotReadoutCleanup (config, view); 75 } 76 77 // construct sources and measure basic stats 78 if (!psphotSourceStats (config, view, true)) { 72 // construct sources and measure basic stats (saved on detections->newSources) 73 if (!psphotSourceStats (config, view, true)) { // pass 1 79 74 psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources"); 80 75 return psphotReadoutCleanup (config, view); … … 84 79 } 85 80 86 // find blended neighbors of very saturated stars 81 // find blended neighbors of very saturated stars (detections->newSources) 87 82 if (!psphotDeblendSatstars (config, view)) { 88 83 psError (PSPHOT_ERR_UNKNOWN, false, "failed on satstar deblend analysis"); … … 90 85 } 91 86 92 // mark blended peaks PS_SOURCE_BLEND 87 // mark blended peaks PS_SOURCE_BLEND (detections->newSources) 93 88 if (!psphotBasicDeblend (config, view)) { 94 89 psError (PSPHOT_ERR_UNKNOWN, false, "failed on deblend analysis"); … … 97 92 98 93 // classify sources based on moments, brightness. if a PSF model has been loaded, the PSF 99 // clump defined for it is used not measured 100 if (!psphotRoughClass (config, view)) { 94 // clump defined for it is used not measured (detections->newSources) 95 if (!psphotRoughClass (config, view)) { // pass 1 101 96 psError (PSPHOT_ERR_UNKNOWN, false, "failed to determine rough classifications"); 102 97 return psphotReadoutCleanup (config, view); … … 106 101 } 107 102 108 // if we were not supplied a PSF model, determine the IQ stats here 109 if (!psphotImageQuality (config, view)) { 110 ps LogMsg("psphot", 3, "failed to measure image quality");103 // if we were not supplied a PSF model, determine the IQ stats here (detections->newSources) 104 if (!psphotImageQuality (config, view)) { // pass 1 105 psError (PSPHOT_ERR_UNKNOWN, false, "failed to measure image quality"); 111 106 return psphotReadoutCleanup(config, view); 112 107 } … … 114 109 // use bright stellar objects to measure PSF if we were supplied a PSF for any input file, 115 110 // this step is skipped 116 if (!psphotChoosePSF (config, view)) { 111 if (!psphotChoosePSF (config, view)) { // pass 1 117 112 psLogMsg ("psphot", 3, "failure to construct a psf model"); 118 113 return psphotReadoutCleanup (config, view); … … 123 118 124 119 // include externally-supplied sources 125 // XXX hmm... 126 psphotLoadExtSources (config, view, sources); 127 128 // construct an initial model for each object, set the radius to fitRadius, set circular fit mask 129 psphotGuessModels (config, view); 120 // XXX fix this in the new multi-input context 121 // psphotLoadExtSources (config, view, sources); // pass 1 122 123 // construct an initial model for each object, set the radius to fitRadius, set circular 124 // fit mask (detections->newSources) 125 psphotGuessModels (config, view); // pass 1 126 127 // merge the newly selected sources into the existing list 128 // NOTE: merge OLD and NEW 129 psphotMergeSources (config, view); FIX: 130 130 131 131 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 132 psphotFitSourcesLinear (config, view, FALSE);133 134 // identify CRs and extended sources 135 psphotSourceSize (config, view );132 psphotFitSourcesLinear (config, view, false); // pass 1 (detections->allSources) 133 134 // identify CRs and extended sources (only unmeasured sources are measured) 135 psphotSourceSize (config, view, true); // pass 1 (detections->allSources) 136 136 if (!strcasecmp (breakPt, "ENSEMBLE")) { 137 137 goto finish; … … 140 140 // non-linear PSF and EXT fit to brighter sources 141 141 // replace model flux, adjust mask as needed, fit, subtract the models (full stamp) 142 psphotBlendFit (config, view); 142 psphotBlendFit (config, view); // pass 1 (detections->allSources) 143 143 144 144 // replace all sources 145 psphotReplaceAllSources (config, view); 145 psphotReplaceAllSources (config, view); // pass 1 (detections->allSources) 146 146 147 147 // linear fit to include all sources (subtract again) 148 psphotFitSourcesLinear (config, view, TRUE); 148 // NOTE : apply to ALL sources (extended + psf) 149 psphotFitSourcesLinear (config, view, true); // pass 2 (detections->allSources) 149 150 150 151 // if we only do one pass, skip to extended source analysis 151 if (!strcasecmp (breakPt, "PASS1")) { 152 goto pass1finish; 153 } 154 // NOTE: possibly re-measure background model here with objects subtracted 152 if (!strcasecmp (breakPt, "PASS1")) goto pass1finish; 153 154 // NOTE: possibly re-measure background model here with objects subtracted / or masked 155 155 156 156 // add noise for subtracted objects 157 psphotAddNoise (config, view); 158 159 // find fainter sources (pass 2)160 // XXX need to distinguish old from new sources161 psphotFindDetections (config, view); 157 psphotAddNoise (config, view); // pass 1 (detections->allSources) 158 159 // find fainter sources 160 // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections 161 psphotFindDetections (config, view); // pass 2 (detections->peaks, detections->footprints) 162 162 163 163 // remove noise for subtracted objects (ie, return to normal noise level) 164 // XXXthis needs to operate only on the OLD sources165 psphotSubNoise (config, view); 164 // NOTE: this needs to operate only on the OLD sources 165 psphotSubNoise (config, view); // pass 1 (detections->allSources) 166 166 167 167 // define new sources based on only the new peaks 168 // XXX need to distinguish old from new sources169 psphotSourceStats (config, view, false); 168 // NOTE: new sources are saved on detections->newSources 169 psphotSourceStats (config, view, false); // pass 2 (detections->newSources) 170 170 171 171 // set source type 172 if (!psphotRoughClass (config, view)) { 172 // NOTE: apply only to detections->newSources 173 if (!psphotRoughClass (config, view)) { // pass 2 (detections->newSources) 173 174 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 174 175 return psphotReadoutCleanup (config, view); … … 176 177 177 178 // create full input models, set the radius to fitRadius, set circular fit mask 178 // XXX need to distinguish old from new sources179 psphotGuessModels (config, view); 179 // NOTE: apply only to detections->newSources 180 psphotGuessModels (config, view); // pass 2 (detections->newSources) 180 181 181 182 // replace all sources so fit below applies to all at once 182 psphotReplaceAllSources (config, view); 183 // NOTE: apply only to OLD sources (which have been subtracted) 184 psphotReplaceAllSources (config, view); // pass 2 183 185 184 186 // merge the newly selected sources into the existing list 185 // XXX old vs new???? 186 FIX: psphotMergeSources (sources, newSources); 187 psFree (newSources); 188 189 // linear fit to all sources 190 psphotFitSourcesLinear (config, view, TRUE); 187 // NOTE: merge OLD and NEW 188 psphotMergeSources (config, view); FIX: // (detections->newSources + detections->allSources -> detections->allSources) 189 190 // NOTE: apply to ALL sources 191 psphotFitSourcesLinear (config, view, true); // pass 3 (detections->allSources) 191 192 192 193 pass1finish: 193 194 194 195 // measure source size for the remaining sources 195 psphotSourceSize (config, view); 196 197 FIX: psphotExtendedSourceAnalysis (readout, sources, recipe); 198 FIX: psphotExtendedSourceFits (readout, sources, recipe); 196 // NOTE: applies only to NEW (unmeasured) sources 197 psphotSourceSize (config, view, false); // pass 2 (detections->allSources) 198 199 psphotExtendedSourceAnalysis (config, view); // pass 1 (detections->allSources) 200 psphotExtendedSourceFits (config, view); // pass 1 (detections->allSources) 199 201 200 202 finish: … … 204 206 205 207 // measure aperture photometry corrections 206 FIX: if (!psphotApResid (config, readout, sources, psf)) { 208 if (!psphotApResid (config, view)) { // pass 1 (detections->allSources) 207 209 psLogMsg ("psphot", 3, "failed on psphotApResid"); 208 210 return psphotReadoutCleanup (config, view); … … 210 212 211 213 // calculate source magnitudes 212 FIX: psphotMagnitudes(config, readout, view, sources, psf); 213 214 FIX: if (!psphotEfficiency(config, readout, view, psf, recipe, sources)) { 214 psphotMagnitudes(config, view); // pass 1 (detections->allSources) 215 216 if (!psphotEfficiency(config, view)) { // pass 1 215 217 psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources"); 216 218 psErrorClear(); … … 221 223 222 224 // replace background in residual image 223 FIX: psphotSkyReplace (config, view); 225 psphotSkyReplace (config, view); // pass 1 224 226 225 227 // drop the references to the image pixels held by each source 226 FIX: psphotSourceFreePixels (sources); 228 psphotSourceFreePixels (config, view); // pass 1 227 229 228 230 // create the exported-metadata and free local data -
branches/eam_branches/psphot.stack.20100120/src/psphotReadoutCleanup.c
r26681 r26688 51 51 52 52 // when psphotReadoutCleanup is called, these are not necessarily defined 53 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 54 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 53 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 55 54 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 56 55 psArray *sources = detections->allSources; 57 56 // XXX where do we free these, in here (psMetadataRemove?) 58 57 -
branches/eam_branches/psphot.stack.20100120/src/psphotReplaceUnfit.c
r26681 r26688 53 53 // find the currently selected readout 54 54 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 55 psAssert ( readout, "missing file?");55 psAssert (file, "missing file?"); 56 56 57 57 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 58 58 psAssert (readout, "missing readout?"); 59 59 60 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 60 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 61 psAssert (detections, "missing detections?"); 62 63 psArray *sources = detections->allSources; 61 64 psAssert (sources, "missing sources?"); 62 65 … … 99 102 return true; 100 103 } 101 102 # if (0)103 // add source, if the source has been subtracted; do not modify state104 bool psphotAddWithTest (pmSource *source, bool useState, psImageMaskType maskVal) {105 106 // what is current state? (true : add; false : sub)107 bool state = !(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);108 if (state && useState) return true;109 110 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);111 return true;112 }113 114 // sub source, if the source has been added; do not modify state115 bool psphotSubWithTest (pmSource *source, bool useState, psImageMaskType maskVal) {116 117 // what is current state? (true : sub; false : add)118 bool state = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);119 if (state && useState) return true;120 121 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);122 return true;123 }124 125 // add or sub source to match recorded state: supply current state as true (add) or false (sub)126 bool psphotSetState (pmSource *source, bool curState, psImageMaskType maskVal) {127 128 // what is desired state? (true : add; false : sub)129 bool newState = !(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED);130 if (curState == newState) return true;131 132 if (curState && !newState) {133 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);134 }135 if (newState && !curState) {136 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);137 }138 return true;139 }140 # endif -
branches/eam_branches/psphot.stack.20100120/src/psphotRoughClass.c
r26681 r26688 37 37 // find the currently selected readout 38 38 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 39 psAssert ( readout, "missing file?");39 psAssert (file, "missing file?"); 40 40 41 41 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); … … 48 48 } 49 49 50 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 50 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 51 psAssert (detections, "missing detections?"); 52 53 psArray *sources = detections->newSources; 51 54 psAssert (sources, "missing sources?"); 52 55 -
branches/eam_branches/psphot.stack.20100120/src/psphotSkyReplace.c
r21183 r26688 1 1 # include "psphotInternal.h" 2 3 bool psphotSkyReplace (pmConfig *config, const pmFPAview *view) 4 { 5 bool status = true; 6 7 int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 8 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 9 10 // loop over the available readouts 11 for (int i = 0; i < num; i++) { 12 if (!psphotReadout (config, view, "PSPHOT.INPUT", i)) { 13 psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i); 14 return false; 15 } 16 } 17 return true; 18 } 2 19 3 20 // XXX make this an option? 4 21 // in order to successfully replace the sky, we must define a corresponding file... 5 bool psphotSkyReplace (pmConfig *config, const pmFPAview *view) {22 bool psphotSkyReplaceReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index) { 6 23 7 24 psTimerStart ("psphot.skyreplace"); 8 25 9 26 // find the currently selected readout 10 pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT"); 11 if (readout == NULL) psAbort("input not defined"); 27 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 28 psAssert (readout, "missing file?"); 29 30 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 31 psAssert (readout, "missing readout?"); 12 32 13 33 // select background pixels, from output background file, or create -
branches/eam_branches/psphot.stack.20100120/src/psphotSourceFreePixels.c
r12792 r26688 1 1 # include "psphotInternal.h" 2 2 3 void psphotSourceFreePixels (psArray *sources) { 3 bool psphotSourceFreePixels (pmConfig *config, const pmFPAview *view) 4 { 5 bool status = true; 4 6 5 if (!sources) return; 7 int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 8 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 9 10 // loop over the available readouts 11 for (int i = 0; i < num; i++) { 12 if (!psphotSourceFreePixelsReadout (config, view, "PSPHOT.INPUT", i)) { 13 psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i); 14 return false; 15 } 16 } 17 return true; 18 } 19 20 bool psphotSourceFreePixelsReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index) { 21 22 // find the currently selected readout 23 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 24 psAssert (readout, "missing file?"); 25 26 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 27 psAssert (readout, "missing readout?"); 28 29 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 30 psAssert (detections, "missing detections?"); 31 32 psArray *sources = detections->allSources; 33 psAssert (sources, "missing sources?"); 6 34 7 35 for (int i = 0; i < sources->n; i++) { … … 9 37 pmSourceFreePixels (source); 10 38 } 11 return ;39 return true; 12 40 } -
branches/eam_branches/psphot.stack.20100120/src/psphotSourceSize.c
r26681 r26688 16 16 17 17 // local functions: 18 bool psphotSourceSizeReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index);19 18 bool psphotSourceSizePSF (psphotSourceSizeOptions *options, psArray *sources, pmPSF *psf); 20 19 bool psphotSourceClass (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, psphotSourceSizeOptions *options); … … 31 30 32 31 // for now, let's store the detections on the readout->analysis for each readout 33 bool psphotSourceSize (pmConfig *config, const pmFPAview *view )32 bool psphotSourceSize (pmConfig *config, const pmFPAview *view, bool getPSFsize) 34 33 { 35 34 bool status = true; … … 44 43 // loop over the available readouts 45 44 for (int i = 0; i < num; i++) { 46 if (!psphotSourceSizeReadout (config, view, "PSPHOT.INPUT", i, recipe )) {45 if (!psphotSourceSizeReadout (config, view, "PSPHOT.INPUT", i, recipe, getPSFsize)) { 47 46 psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i); 48 47 return false; … … 52 51 } 53 52 54 // XXXuse an internal flag to mark sources which have already been measured55 bool psphotSourceSizeReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe )53 // this function use an internal flag to mark sources which have already been measured 54 bool psphotSourceSizeReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index, psMetadata *recipe, bool getPSFsize) 56 55 { 57 56 bool status; … … 67 66 psAssert (readout, "missing readout?"); 68 67 69 psArray *sources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES"); 68 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 69 psAssert (detections, "missing detections?"); 70 71 psArray *sources = detections->allSources; 70 72 psAssert (sources, "missing sources?"); 71 73 … … 116 118 // XXX move this to the code that generates the PSF? 117 119 // XXX store the results on pmPSF? 118 psphotSourceSizePSF (&options, sources, psf); 120 121 // XXX this should only be done on the first pass (ie, if we have newSources or allSources?) 122 if (getPSFsize) { 123 psphotSourceSizePSF (&options, sources, psf); 124 } 119 125 120 126 // classify the sources based on ApResid and Moments (extended sources) 127 // NOTE: only sources not already measured !(source->tmpFlags & PM_SOURCE_TMPF_SIZE_MEASURED) 121 128 psphotSourceClass(readout, sources, recipe, psf, &options); 122 129 130 // NOTE: only sources not already measured !(source->tmpFlags & PM_SOURCE_TMPF_SIZE_MEASURED) 123 131 psphotSourceSizeCR (readout, sources, &options); 124 132 … … 376 384 for (int i = 0; i < sources->n; i++) { 377 385 pmSource *source = sources->data[i]; 386 387 // skip source if it was already measured 388 if (source->tmpFlags & PM_SOURCE_TMPF_SIZE_MEASURED) { 389 psTrace("psphot", 7, "Not calculating source size since it has already been measured\n"); 390 continue; 391 } 378 392 379 393 // Integer position of peak -
branches/eam_branches/psphot.stack.20100120/src/psphotSourceStats.c
r26681 r26688 1 1 # include "psphotInternal.h" 2 2 3 // convert detections to sources and measure their basic properties (moments, local sky, sky variance) 3 // convert detections to sources and measure their basic properties (moments, local sky, sky 4 // variance) Note: this function only generates sources for the new peaks (peak->assigned) 4 5 bool psphotSourceStats (pmConfig *config, const pmFPAview *view, bool setWindow) 5 6 { … … 39 40 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 40 41 psAssert (detections, "missing detections?"); 42 psAssert (!detections->newSources, "new sources already defined?"); 41 43 42 44 // determine the number of allowed threads … … 67 69 // if there are no peaks, we save the empty source array and return 68 70 if (!peaks->n) { 69 // save sources on the readout->analysis 70 if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources)) { 71 psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout"); 72 psFree(sources); 73 return false; 74 } 75 psFree(sources); 71 // save the new sources on the detection structure: 72 detections->newSources = sources; 76 73 return true; 77 74 } … … 103 100 psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n"); 104 101 psphotVisualShowMoments (sources); 105 // save sources on the readout->analysis 106 if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources)) { 107 psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout"); 108 psFree(sources); 109 return false; 110 } 111 psFree(sources); 102 detections->newSources = sources; 112 103 return true; 113 104 } … … 187 178 psphotVisualShowMoments (sources); 188 179 189 // save sources on the readout->analysis 190 if (!psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources)) { 191 psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout"); 192 psFree(sources); 193 return false; 194 } 195 psFree(sources); 180 // save the new sources on the detection structure: 181 detections->newSources = sources; 196 182 return true; 197 183 } … … 216 202 // determine properties (sky, moments) of initial sources 217 203 float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS"); 218 if (!status) return NULL;204 if (!status) return false; 219 205 220 206 OUTER = PS_MAX(OUTER, 20.0); // XXX Guarantee that we can encompass the max moments radius 221 207 222 208 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT"); 223 if (!status) return NULL;209 if (!status) return false; 224 210 225 211 for (int i = 0; i < sources->n; i++) { … … 509 495 } 510 496 511 512 497 // if we use the footprints, the output peaks list contains both old and new peaks, 513 498 // otherwise it only contains the new peaks.
Note:
See TracChangeset
for help on using the changeset viewer.
