Changeset 16760
- Timestamp:
- Feb 29, 2008, 2:16:50 PM (18 years ago)
- Location:
- branches/eam_branch_20080229/psphot/src
- Files:
-
- 1 added
- 25 edited
-
Makefile.am (modified) (1 diff)
-
pmFootprint.c (modified) (1 diff)
-
pmFootprint.h (modified) (1 diff)
-
psphot.h (modified) (5 diffs)
-
psphotAddNoise.c (modified) (2 diffs)
-
psphotApResid.c (modified) (2 diffs)
-
psphotBlendFit.c (modified) (3 diffs)
-
psphotChoosePSF.c (modified) (1 diff)
-
psphotExtendedSources.c (modified) (2 diffs)
-
psphotFindDetections.c (added)
-
psphotFindPeaks.c (modified) (1 diff)
-
psphotFitSourcesLinear.c (modified) (3 diffs)
-
psphotGuessModels.c (modified) (1 diff)
-
psphotMagnitudes.c (modified) (1 diff)
-
psphotMaskReadout.c (modified) (2 diffs)
-
psphotModelBackground.c (modified) (2 diffs)
-
psphotModelTest.c (modified) (2 diffs)
-
psphotReadout.c (modified) (11 diffs)
-
psphotReadoutCleanup.c (modified) (2 diffs)
-
psphotReplaceUnfit.c (modified) (3 diffs)
-
psphotRoughClass.c (modified) (3 diffs)
-
psphotSourceFits.c (modified) (5 diffs)
-
psphotSourcePlots.c (modified) (1 diff)
-
psphotSourceSize.c (modified) (4 diffs)
-
psphotSourceStats.c (modified) (3 diffs)
-
psphotSubtractBackground.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080229/psphot/src/Makefile.am
r15936 r16760 27 27 psphotModelBackground.c \ 28 28 psphotSubtractBackground.c \ 29 psphotFindDetections.c \ 29 30 psphotFindPeaks.c \ 30 31 psphotSourceStats.c \ -
branches/eam_branch_20080229/psphot/src/pmFootprint.c
r16048 r16760 1241 1241 return peaks; 1242 1242 } 1243 1244 void pmDetectionsFree (pmDetections *detections) { 1245 1246 if (!detections) return; 1247 1248 psFree (detections->footprints); 1249 psFree (detections->peaks); 1250 psFree (detections->oldPeaks); 1251 return; 1252 } 1253 1254 // generate a pmDetections container with empty (allocated) footprints and peaks containers 1255 pmDetections *pmDetectionsAlloc() { 1256 1257 pmDetections *detections = (pmDetections *)psAlloc(sizeof(pmDetections)); 1258 psMemSetDeallocator(detections, (psFreeFunc) pmDetectionsFree); 1259 1260 detections->footprints = NULL; 1261 detections->peaks = NULL; 1262 detections->oldPeaks = NULL; 1263 detections->last = 0; 1264 1265 return (detections); 1266 } 1267 1268 /************************************************************************************************************/ 1269 /* 1270 * Cull a set of peaks contained in a psArray of pmFootprints 1271 */ 1272 psErrorCode 1273 psphotCullPeaks(const psImage *image, // the image wherein lives the footprint 1274 const psImage *weight, // corresponding variance image 1275 const psMetadata *recipe, 1276 psArray *footprints) { // array of pmFootprints 1277 bool status = false; 1278 float nsigma_delta = psMetadataLookupF32(&status, recipe, "FOOTPRINT_CULL_NSIGMA_DELTA"); 1279 if (!status) { 1280 nsigma_delta = 0; // min. 1281 } 1282 float nsigma_min = psMetadataLookupF32(&status, recipe, "FOOTPRINT_CULL_NSIGMA_MIN"); 1283 if (!status) { 1284 nsigma_min = 0; 1285 } 1286 const float skyStdev = psMetadataLookupF32(NULL, recipe, "SKY_STDEV"); 1287 1288 return pmFootprintArrayCullPeaks(image, weight, footprints, 1289 nsigma_delta, nsigma_min*skyStdev); 1290 } 1291 -
branches/eam_branch_20080229/psphot/src/pmFootprint.h
r14655 r16760 52 52 psArray *pmFootprintArrayToPeaks(const psArray *footprints); 53 53 54 typedef struct { 55 psArray *footprints; // collection of footprints in the image 56 psArray *peaks; // collection of all peaks contained by the footprints 57 psArray *oldPeaks; // collection of all peaks previously found 58 int last; 59 } pmDetections; 60 61 pmDetections *pmDetectionsAlloc (); 62 63 54 64 #endif -
branches/eam_branch_20080229/psphot/src/psphot.h
r15936 r16760 9 9 10 10 #include "psphotErrorCodes.h" 11 #include "pmFootprint.h" 12 11 13 #define PSPHOT_RECIPE "PSPHOT" // Name of the recipe to use 12 14 … … 16 18 psString psphotVersionLong(void); 17 19 18 bool psphotModelTest (pmConfig *config, const pmFPAview *view, psMetadata *recipe , psMaskType maskVal, psMaskType mark);20 bool psphotModelTest (pmConfig *config, const pmFPAview *view, psMetadata *recipe); 19 21 bool psphotReadout (pmConfig *config, const pmFPAview *view); 20 bool psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pm PSF *psf, psArray *sources);22 bool psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmDetections *detections, pmPSF *psf, psArray *sources); 21 23 bool psphotDefineFiles (pmConfig *config, pmFPAfile *input); 22 23 24 24 25 // XXX test functions … … 26 27 27 28 // psphotReadout functions 28 bool psphotModelBackground (pmConfig *config, const pmFPAview *view, const char *filename, psMaskType maskVal); 29 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filename, psMaskType maskVal) ; 30 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe, 31 const bool returnFootprints, const int pass, psMaskType maskVal); 32 #include "pmFootprint.h" 33 psErrorCode psphotCullPeaks(const psImage *img, const psImage *weight, 34 const psMetadata *recipe, psArray *footprints); 35 psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *allpeaks, psMaskType maskVal, psMaskType mark); 36 bool psphotRoughClass (psArray *sources, psMetadata *recipe, const bool findPsfClump, psMaskType maskSat); 29 bool psphotModelBackground (pmConfig *config, const pmFPAview *view, const char *filename); 30 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filename) ; 31 pmDetections *psphotFindDetections (pmDetections *detections, pmReadout *readout, psMetadata *recipe); 32 33 psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, pmDetections *detections); 34 bool psphotRoughClass (psArray *sources, psMetadata *recipe, const bool findPsfClump); 37 35 bool psphotBasicDeblend (psArray *sources, psMetadata *recipe); 38 pmPSF *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe , psMaskType maskVal, psMaskType mark);36 pmPSF *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe); 39 37 bool psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf); 40 38 bool psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources); 41 #if NOT_IN_LIBPSPHOT 42 bool psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final); 43 #endif 44 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final, psMaskType maskVal); 45 bool psphotGuessModels (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal); 46 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal); 39 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final); 40 bool psphotGuessModels (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf); 41 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf); 47 42 bool psphotReplaceUnfit (psArray *sources, psMaskType maskVal); 48 bool psphotReplaceAll (psArray *sources, psMaskType maskVal); 49 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal, psMaskType mark); 43 bool psphotReplaceAll (psArray *sources, psMetadata *recipe); 44 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf); 45 bool psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf, pmReadout *background); 46 bool psphotSkyReplace (pmConfig *config, const pmFPAview *view); 47 bool psphotExtendedSources (pmReadout *readout, psArray *sources, psMetadata *recipe); 48 49 // used by psphotFindDetections 50 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe, const bool returnFootprints, const int pass, psMaskType maskVal); 51 psErrorCode psphotCullPeaks(const psImage *img, const psImage *weight, const psMetadata *recipe, psArray *footprints); 52 53 // used by ApResid 50 54 bool psphotMagErrorScale (float *errorScale, float *errorFloor, psVector *dMag, psVector *dap, psVector *mask, int nGroup); 51 55 bool psphotApResidTrend (pmReadout *readout, pmPSF *psf, int Npsf, int scale, float *errorScale, float *errorFloor, psVector *mask, psVector *xPos, psVector *yPos, psVector *apResid, psVector *dMag); 52 bool psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf, pmReadout *background, psMaskType maskVal, psMaskType mark);53 bool psphotSkyReplace (pmConfig *config, const pmFPAview *view);54 56 55 57 // basic support functions 56 58 void psphotModelClassInit (void); 57 59 bool psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal); 58 bool psphot MaskReadout (pmReadout *readout, psMetadata *recipe, psMaskType maskVal);60 bool psphotSetMaskAndWeight (pmConfig *config, pmReadout *readout, psMetadata *recipe); 59 61 void psphotSourceFreePixels (psArray *sources); 60 62 … … 100 102 pmPSF *psphotLoadPSF (pmConfig *config, const pmFPAview *view, psMetadata *recipe); 101 103 bool psphotSetHeaderNstars (psMetadata *recipe, psArray *sources); 102 bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add, psMaskType maskVal); 104 bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe); 105 bool psphotSubNoise (pmReadout *readout, psArray *sources, psMetadata *recipe); 106 bool psphotAddOrSubNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add); 103 107 bool psphotRadialPlot (int *kapa, const char *filename, pmSource *source); 104 bool psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe , psMaskType maskVal);108 bool psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe); 105 109 bool psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY); 106 110 … … 109 113 bool psphotSetState (pmSource *source, bool curState, psMaskType maskVal); 110 114 bool psphotDeblendSatstars (psArray *sources, psMetadata *recipe); 111 bool psphotSourceSize (pmReadout *readout, psArray *sources, psMetadata *recipe );115 bool psphotSourceSize (pmReadout *readout, psArray *sources, psMetadata *recipe, long first); 112 116 113 117 bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal); 114 118 115 bool psphotExtendedSources (pmReadout *readout, psArray *sources, psMetadata *recipe, psMaskType maskVal);116 119 bool psphotPSFConvModel (pmSource *source, psMetadata *recipe, psMaskType maskVal); 117 120 psKernel *psphotKernelFromPSF (pmSource *source, int nPix); -
branches/eam_branch_20080229/psphot/src/psphotAddNoise.c
r14655 r16760 1 1 # include "psphotInternal.h" 2 2 3 bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add, psMaskType maskVal) { 3 bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe) { 4 return psphotAddOrSubNoise (readout, sources, recipe, true); 5 } 6 7 bool psphotSubNoise (pmReadout *readout, psArray *sources, psMetadata *recipe) { 8 return psphotAddOrSubNoise (readout, sources, recipe, false); 9 } 10 11 bool psphotAddOrSubNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add) { 4 12 5 13 bool status = false; … … 13 21 14 22 psTimerStart ("psphot"); 23 24 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 25 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 26 assert (maskVal); 15 27 16 28 // increase variance by factor*(object noise): -
branches/eam_branch_20080229/psphot/src/psphotApResid.c
r15143 r16760 3 3 # define SKIPSTAR(MSG) { psTrace ("psphot", 3, "invalid : %s", MSG); continue; } 4 4 // measure the aperture residual statistics and 2D variations 5 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal, psMaskType mark) 5 6 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) 6 7 { 7 8 int Nfail = 0; … … 19 20 20 21 psTimerStart ("psphot"); 22 23 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 24 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 25 assert (maskVal); 26 27 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 28 psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels 29 assert (mark); 21 30 22 31 // S/N limit to perform full non-linear fits -
branches/eam_branch_20080229/psphot/src/psphotBlendFit.c
r15800 r16760 2 2 3 3 // XXX I don't like this name 4 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf , psMaskType maskVal) {4 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) { 5 5 6 6 int Nfit = 0; … … 11 11 12 12 psTimerStart ("psphot"); 13 14 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 15 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 16 assert (maskVal); 13 17 14 18 // source analysis is done in S/N order (brightest first) … … 92 96 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 93 97 source->mode |= PM_SOURCE_MODE_SUBTRACTED; 94 source->mode |= PM_SOURCE_MODE_TEMPSUB; 98 } 99 100 if (psTraceGetLevel("psphot") >= 6) { 101 psphotSaveImage (NULL, readout->image, "image.v2.fits"); 95 102 } 96 103 -
branches/eam_branch_20080229/psphot/src/psphotChoosePSF.c
r15023 r16760 2 2 3 3 // try PSF models and select best option 4 pmPSF *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe , psMaskType maskVal, psMaskType mark) {4 pmPSF *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe) { 5 5 6 6 bool status; 7 7 8 8 psTimerStart ("psphot"); 9 10 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 11 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 12 assert (maskVal); 13 14 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 15 psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels 16 assert (mark); 9 17 10 18 // examine PSF sources in S/N order (brightest first) -
branches/eam_branch_20080229/psphot/src/psphotExtendedSources.c
r15562 r16760 1 1 # include "psphot.h" 2 2 3 bool psphotExtendedSources (pmReadout *readout, psArray *sources, psMetadata *recipe , psMaskType maskVal) {3 bool psphotExtendedSources (pmReadout *readout, psArray *sources, psMetadata *recipe) { 4 4 5 5 bool status; 6 6 int Next = 0; 7 7 int Npsf = 0; 8 9 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 10 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 11 assert (maskVal); 8 12 9 13 // S/N limit to perform full non-linear fits … … 117 121 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 118 122 source->mode |= PM_SOURCE_MODE_SUBTRACTED; 119 source->mode |= PM_SOURCE_MODE_TEMPSUB;120 123 } 121 124 -
branches/eam_branch_20080229/psphot/src/psphotFindPeaks.c
r15962 r16760 174 174 } 175 175 176 177 /************************************************************************************************************/178 /*179 * Cull a set of peaks contained in a psArray of pmFootprints180 */181 psErrorCode182 psphotCullPeaks(const psImage *image, // the image wherein lives the footprint183 const psImage *weight, // corresponding variance image184 const psMetadata *recipe,185 psArray *footprints) { // array of pmFootprints186 bool status = false;187 float nsigma_delta = psMetadataLookupF32(&status, recipe, "FOOTPRINT_CULL_NSIGMA_DELTA");188 if (!status) {189 nsigma_delta = 0; // min.190 }191 float nsigma_min = psMetadataLookupF32(&status, recipe, "FOOTPRINT_CULL_NSIGMA_MIN");192 if (!status) {193 nsigma_min = 0;194 }195 const float skyStdev = psMetadataLookupF32(NULL, recipe, "SKY_STDEV");196 197 return pmFootprintArrayCullPeaks(image, weight, footprints,198 nsigma_delta, nsigma_min*skyStdev);199 } -
branches/eam_branch_20080229/psphot/src/psphotFitSourcesLinear.c
r15132 r16760 12 12 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER); 13 13 14 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final , psMaskType maskVal) {14 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final) { 15 15 16 16 bool status; … … 21 21 22 22 psTimerStart ("psphot"); 23 24 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 25 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 26 assert (maskVal); 23 27 24 28 // source analysis is done in spatial order … … 187 191 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 188 192 source->mode |= PM_SOURCE_MODE_SUBTRACTED; 189 if (!final) source->mode |= PM_SOURCE_MODE_TEMPSUB;190 // XXX not sure about the use of TEMPSUB191 193 } 192 194 -
branches/eam_branch_20080229/psphot/src/psphotGuessModels.c
r13900 r16760 17 17 18 18 // construct an initial PSF model for each object 19 bool psphotGuessModels (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf , psMaskType maskVal) {19 bool psphotGuessModels (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) { 20 20 21 psTimerStart ("psphot");21 bool status; 22 22 23 // setup the PSF fit radius details 24 psphotInitRadiusPSF (recipe, psf->type); 23 psTimerStart ("psphot"); 25 24 26 for (int i = 0; i < sources->n; i++) { 27 pmSource *source = sources->data[i]; 25 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 26 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 27 assert (maskVal); 28 28 29 // skip non-astronomical objects (very likely defects) 30 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 31 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 29 // setup the PSF fit radius details 30 psphotInitRadiusPSF (recipe, psf->type); 32 31 33 // XXX if a source is faint, it will not have moments measured. 34 // it must be modelled as a PSF. In this case, we need to use 35 // the peak centroid to get the coordinates and get the peak flux 36 // from the image? 37 pmModel *modelEXT; 38 if (!source->moments) { 39 modelEXT = wildGuess(source, psf); 40 } else { 41 // use the source moments, etc to guess basic model parameters 42 modelEXT = pmSourceModelGuess (source, psf->type); 43 if (!modelEXT) { 44 modelEXT = wildGuess(source, psf); 45 } 46 // these valuse are set in pmSourceModelGuess, should this rule be in there as well? 47 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 48 modelEXT->params->data.F32[PM_PAR_XPOS] = source->moments->x; 49 modelEXT->params->data.F32[PM_PAR_YPOS] = source->moments->y; 50 } else { 51 modelEXT->params->data.F32[PM_PAR_XPOS] = source->peak->xf; 52 modelEXT->params->data.F32[PM_PAR_YPOS] = source->peak->yf; 53 } 32 for (int i = 0; i < sources->n; i++) { 33 pmSource *source = sources->data[i]; 34 35 // skip non-astronomical objects (very likely defects) 36 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 37 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 38 39 // XXX if a source is faint, it will not have moments measured. 40 // it must be modelled as a PSF. In this case, we need to use 41 // the peak centroid to get the coordinates and get the peak flux 42 // from the image? 43 pmModel *modelEXT; 44 if (!source->moments) { 45 modelEXT = wildGuess(source, psf); 46 } else { 47 // use the source moments, etc to guess basic model parameters 48 modelEXT = pmSourceModelGuess (source, psf->type); 49 if (!modelEXT) { 50 modelEXT = wildGuess(source, psf); 51 } 52 // these valuse are set in pmSourceModelGuess, should this rule be in there as well? 53 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 54 modelEXT->params->data.F32[PM_PAR_XPOS] = source->moments->x; 55 modelEXT->params->data.F32[PM_PAR_YPOS] = source->moments->y; 56 } else { 57 modelEXT->params->data.F32[PM_PAR_XPOS] = source->peak->xf; 58 modelEXT->params->data.F32[PM_PAR_YPOS] = source->peak->yf; 59 } 60 } 61 62 // set PSF parameters for this model (apply 2D shape model) 63 pmModel *modelPSF = pmModelFromPSF (modelEXT, psf); 64 if (modelPSF == NULL) { 65 psError(PSPHOT_ERR_PSF, false, 66 "Failed to determine PSF model at r,c = (%d,%d); trying centre of image", 67 source->peak->y, source->peak->x); 68 // 69 // Try the centre of the image 70 // 71 modelEXT->params->data.F32[PM_PAR_XPOS] = 0.5*readout->image->numCols; 72 modelEXT->params->data.F32[PM_PAR_YPOS] = 0.5*readout->image->numRows; 73 modelPSF = pmModelFromPSF (modelEXT, psf); 74 if (modelPSF == NULL) { 75 psError(PSPHOT_ERR_PSF, false, 76 "Failed to determine PSF model at centre of image"); 77 psFree(modelEXT); 78 return false; 79 } 80 81 source->mode |= PM_SOURCE_MODE_BADPSF; 82 } 83 psFree (modelEXT); 84 85 // XXX need to define the guess flux? 86 // set the fit radius based on the object flux limit and the model 87 psphotCheckRadiusPSF (readout, source, modelPSF); 88 89 // set the source PSF model 90 source->modelPSF = modelPSF; 91 source->modelPSF->residuals = psf->residuals; 92 93 pmSourceCacheModel (source, maskVal); 54 94 } 55 56 // set PSF parameters for this model (apply 2D shape model) 57 pmModel *modelPSF = pmModelFromPSF (modelEXT, psf); 58 if (modelPSF == NULL) { 59 psError(PSPHOT_ERR_PSF, false, 60 "Failed to determine PSF model at r,c = (%d,%d); trying centre of image", 61 source->peak->y, source->peak->x); 62 // 63 // Try the centre of the image 64 // 65 modelEXT->params->data.F32[PM_PAR_XPOS] = 0.5*readout->image->numCols; 66 modelEXT->params->data.F32[PM_PAR_YPOS] = 0.5*readout->image->numRows; 67 modelPSF = pmModelFromPSF (modelEXT, psf); 68 if (modelPSF == NULL) { 69 psError(PSPHOT_ERR_PSF, false, 70 "Failed to determine PSF model at centre of image"); 71 psFree(modelEXT); 72 return false; 73 } 74 75 source->mode |= PM_SOURCE_MODE_BADPSF; 76 } 77 psFree (modelEXT); 78 79 // XXX need to define the guess flux? 80 // set the fit radius based on the object flux limit and the model 81 psphotCheckRadiusPSF (readout, source, modelPSF); 82 83 // set the source PSF model 84 source->modelPSF = modelPSF; 85 source->modelPSF->residuals = psf->residuals; 86 87 pmSourceCacheModel (source, maskVal); 88 } 89 psLogMsg ("psphot.models", 4, "built models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot")); 90 return true; 95 psLogMsg ("psphot.models", 4, "built models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot")); 96 return true; 91 97 } 92 98 -
branches/eam_branch_20080229/psphot/src/psphotMagnitudes.c
r13900 r16760 1 1 # include "psphotInternal.h" 2 2 3 bool psphotMagnitudes(psArray *sources, 4 psMetadata *recipe, 5 pmPSF *psf, 6 pmReadout *background, 7 psMaskType maskVal, 8 psMaskType mark) 9 { 3 bool psphotMagnitudes(psArray *sources, psMetadata *recipe, pmPSF *psf, pmReadout *background) { 4 10 5 bool status = false; 11 6 int Nap = 0; 12 7 13 8 psTimerStart ("psphot"); 9 10 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 11 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 12 assert (maskVal); 13 14 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 15 psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels 16 assert (mark); 14 17 15 18 pmSourceMagnitudesInit (recipe); -
branches/eam_branch_20080229/psphot/src/psphotMaskReadout.c
r13900 r16760 1 1 # include "psphotInternal.h" 2 2 3 bool psphotMaskReadout (pmReadout *readout, psMetadata *recipe, psMaskType maskVal) { 3 // generate mask and weight if not defined, additional mask for restricted subregion 4 bool psphotSetMaskAndWeight (pmConfig *config, pmReadout *readout, psMetadata *recipe) { 4 5 5 6 bool status; 7 8 // ** Interpret the mask values: 9 10 // single-bit named masks 11 psMaskType maskMark = pmConfigMask("MARK", config); // Mask value for marking 12 psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.MARK", PS_META_REPLACE, "user-defined mask", maskMark); 13 14 psMaskType maskSat = pmConfigMask("SAT", config); // Mask value for saturated pixels 15 psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat); 16 17 psMaskType maskBad = pmConfigMask("BAD", config); // Mask value for bad pixels 18 psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.BAD", PS_META_REPLACE, "user-defined mask", maskBad); 19 20 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 21 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "PSPHOT"); // Mask value for bad pixels 22 if (!maskVal) { 23 const char *maskValStr = psMetadataLookupStr(NULL, recipe, "MASKVAL"); // String with mask names 24 if (!maskValStr) { 25 psError(PSPHOT_ERR_CONFIG, false, "Missing recipe item: MASKVAL(STR)"); 26 return false; 27 } 28 maskVal = pmConfigMask(maskValStr, config); // Mask values to mask against 29 psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal); 30 assert (maskVal); 31 } 32 33 // generate mask & weight images if they don't already exit 34 if (!readout->mask) { 35 if (!pmReadoutGenerateMask(readout, maskSat, maskBad)) { 36 psError (PSPHOT_ERR_CONFIG, false, "trouble creating mask"); 37 return false; 38 } 39 } 40 if (!readout->weight) { 41 if (!pmReadoutGenerateWeight(readout, true)) { 42 psError (PSPHOT_ERR_CONFIG, false, "trouble creating weight"); 43 return false; 44 } 45 } 6 46 7 47 // mask the excluded outer pixels … … 19 59 20 60 // psImageKeepRegion assumes the region refers to the parent coordinates 21 psImageKeepRegion (readout->mask, keep, "OR", maskVal); 61 psImageKeepRegion (readout->mask, keep, "OR", maskBad); 62 63 // test output of files at this stage 64 if (psTraceGetLevel("psphot") >= 5) { 65 psphotSaveImage (NULL, readout->image, "image.fits"); 66 psphotSaveImage (NULL, readout->mask, "mask.fits"); 67 psphotSaveImage (NULL, readout->weight, "weight.fits"); 68 } 22 69 23 70 return true; -
branches/eam_branch_20080229/psphot/src/psphotModelBackground.c
r15936 r16760 4 4 // generate the median in NxN boxes, clipping heavily 5 5 // linear interpolation to generate full-scale model 6 bool psphotModelBackground (pmConfig *config, const pmFPAview *view, const char *filename , psMaskType maskVal)6 bool psphotModelBackground (pmConfig *config, const pmFPAview *view, const char *filename) 7 7 { 8 8 bool status = true; … … 20 20 // select the appropriate recipe information 21 21 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 22 assert (recipe); 23 24 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 25 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 26 assert (maskVal); 22 27 23 28 // user supplied seed, if available -
branches/eam_branch_20080229/psphot/src/psphotModelTest.c
r14799 r16760 3 3 4 4 // XXX add more test information? 5 bool psphotModelTest (pmConfig *config, const pmFPAview *view, psMetadata *recipe , psMaskType maskVal, psMaskType mark) {5 bool psphotModelTest (pmConfig *config, const pmFPAview *view, psMetadata *recipe) { 6 6 7 7 bool status; … … 11 11 pmPSF *psf = NULL; 12 12 pmSourceFitMode fitMode; 13 14 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 15 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 16 psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels 17 assert (maskVal); 18 assert (mark); 13 19 14 20 // run model fitting tests on a single source? -
branches/eam_branch_20080229/psphot/src/psphotReadout.c
r16250 r16760 9 9 psTimerStart ("psphotReadout"); 10 10 11 bool dump = (psTraceGetLevel("psphot") >= 6);12 13 11 // select the current recipe 14 12 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE); … … 18 16 } 19 17 20 // Interpret the mask values21 const char *maskValStr = psMetadataLookupStr(NULL, recipe, "MASKVAL"); // String with mask names22 if (!maskValStr) {23 psError(PSPHOT_ERR_CONFIG, false, "Missing recipe item: MASKVAL(STR)");24 return false;25 }26 psMaskType maskVal = pmConfigMask(maskValStr, config); // Mask values to mask against27 psMaskType maskMark = pmConfigMask("MARK", config); // Mask value for marking28 psMaskType maskSat = pmConfigMask("SAT", config); // Mask value for saturated pixels29 psMaskType maskBad = pmConfigMask("BAD", config); // Mask value for bad pixels30 31 // find the currently selected readout32 pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT");33 PS_ASSERT_PTR_NON_NULL (readout, false);34 35 // optional break-point for processing36 char *breakPt = psMetadataLookupStr (NULL, recipe, "BREAK_POINT");37 PS_ASSERT_PTR_NON_NULL (breakPt, false);38 39 // Use the new pmFootprints approach?40 const bool useFootprints = psMetadataLookupBool(NULL, recipe, "USE_FOOTPRINTS");41 42 // generate mask & weight images if they don't already exit43 if (!readout->mask) {44 if (!pmReadoutGenerateMask(readout, maskSat, maskBad)) {45 psError (PSPHOT_ERR_CONFIG, false, "trouble creating mask");46 return false;47 }48 }49 if (!readout->weight) {50 if (!pmReadoutGenerateWeight(readout, true)) {51 psError (PSPHOT_ERR_CONFIG, false, "trouble creating weight");52 return false;53 }54 }55 56 18 // set the photcode for this image 57 19 if (!psphotAddPhotcode (recipe, config, view)) { … … 60 22 } 61 23 62 // I have a valid mask, now mask in the analysis region of interest 63 psphotMaskReadout (readout, recipe, maskBad); 64 65 if (psTraceGetLevel("psphot") >= 5) { 66 psphotSaveImage (NULL, readout->image, "image.fits"); 67 psphotSaveImage (NULL, readout->mask, "mask.fits"); 68 psphotSaveImage (NULL, readout->weight, "weight.fits"); 69 } 70 24 // find the currently selected readout 25 pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT"); 26 PS_ASSERT_PTR_NON_NULL (readout, false); 27 28 // optional break-point for processing 29 char *breakPt = psMetadataLookupStr (NULL, recipe, "BREAK_POINT"); 30 PS_ASSERT_PTR_NON_NULL (breakPt, false); 31 32 // Generate the mask and weight images, including the user-defined analysis region of interest 33 psphotSetMaskAndWeight (config, readout, recipe); 71 34 if (!strcasecmp (breakPt, "NOTHING")) { 72 return psphotReadoutCleanup(config, readout, recipe, NULL, NULL );35 return psphotReadoutCleanup(config, readout, recipe, NULL, NULL, NULL); 73 36 } 74 37 75 38 // generate a background model (median, smoothed image) 76 if (!psphotModelBackground (config, view, "PSPHOT.INPUT", maskVal)) { 77 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL); 78 } 79 if (!psphotSubtractBackground (config, view, "PSPHOT.INPUT", maskVal)) { 80 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL); 81 } 82 39 if (!psphotModelBackground (config, view, "PSPHOT.INPUT")) { 40 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL); 41 } 42 if (!psphotSubtractBackground (config, view, "PSPHOT.INPUT")) { 43 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL); 44 } 83 45 if (!strcasecmp (breakPt, "BACKMDL")) { 84 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL );85 } 86 87 // run a single-model test if desired 88 psphotModelTest (config, view, recipe , maskVal, maskMark);46 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL); 47 } 48 49 // run a single-model test if desired (exits from here if test is run) 50 psphotModelTest (config, view, recipe); 89 51 90 52 // load the psf model, if suppled. FWHM_X,FWHM_Y,etc are saved in the recipe … … 94 56 bool havePSF = (psf != NULL); 95 57 96 // find the peaks in the image. 97 98 // XXX clean this up into a single function. if psf is defined, we should treat this as 99 // pass "2", not "1". re-define this boolean to be "have PSF" 100 psArray *peaks; 101 psArray *footprints = NULL; 102 if (useFootprints) { 103 footprints = psphotFindPeaks (readout, recipe, useFootprints, 1, maskVal); 104 int growRadius = psMetadataLookupS32(NULL, recipe, "FOOTPRINT_GROW_RADIUS"); 105 if (growRadius > 0) { 106 psArray *tmp = pmGrowFootprintArray(footprints, growRadius); 107 psFree(footprints); 108 footprints = tmp; 109 } 110 psphotCullPeaks(readout->image, readout->weight, recipe, footprints); 111 112 peaks = pmFootprintArrayToPeaks(footprints); 113 } else { 114 peaks = psphotFindPeaks (readout, recipe, useFootprints, 1, maskVal); 115 } 116 117 if (!peaks) { 118 psLogMsg ("psphot", 3, "unable to find peaks in this image"); 119 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL); 58 // find the detections (by peak and/or footprint) in the image. 59 pmDetections *detections = psphotFindDetections (NULL, readout, recipe); 60 if (!detections) { 61 psLogMsg ("psphot", 3, "unable to find detections in this image"); 62 return psphotReadoutCleanup (config, readout, recipe, detections, psf, NULL); 120 63 } 121 64 122 65 // construct sources and measure basic stats 123 psArray *sources = psphotSourceStats (readout, recipe, peaks, maskVal, maskMark);66 psArray *sources = psphotSourceStats (readout, recipe, detections); 124 67 if (!sources) return false; 125 psFree (peaks);126 127 68 if (!strcasecmp (breakPt, "PEAKS")) { 128 return psphotReadoutCleanup(config, readout, recipe, NULL, sources); 129 } 130 69 return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources); 70 } 71 72 // find blended neighbors of very saturated stars 73 // XXX merge this with Basic Deblend? 131 74 psphotDeblendSatstars (sources, recipe); 132 75 … … 134 77 if (!psphotBasicDeblend (sources, recipe)) { 135 78 psLogMsg ("psphot", 3, "failed on deblend analysis"); 136 return psphotReadoutCleanup (config, readout, recipe, NULL, sources);79 return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources); 137 80 } 138 81 139 82 // classify sources based on moments, brightness 140 if (!psphotRoughClass (sources, recipe, havePSF , maskSat)) {83 if (!psphotRoughClass (sources, recipe, havePSF)) { 141 84 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 142 return psphotReadoutCleanup (config, readout, recipe, NULL, sources);85 return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources); 143 86 } 144 87 if (!strcasecmp (breakPt, "MOMENTS")) { 145 return psphotReadoutCleanup(config, readout, recipe, NULL, sources);88 return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources); 146 89 } 147 90 … … 151 94 // XXX if we do not have enough stars to generate the PSF, build one 152 95 // from the SEEING guess and model class 153 psf = psphotChoosePSF (readout, sources, recipe , maskVal, maskMark);96 psf = psphotChoosePSF (readout, sources, recipe); 154 97 if (psf == NULL) { 155 98 psLogMsg ("psphot", 3, "failure to construct a psf model"); 156 return psphotReadoutCleanup (config, readout, recipe, psf, sources);99 return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources); 157 100 } 158 101 havePSF = true; 159 102 } 160 161 // XXX Test dump of PSF parameters across image field.162 163 103 if (!strcasecmp (breakPt, "PSFMODEL")) { 164 return psphotReadoutCleanup (config, readout, recipe, psf, sources);104 return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources); 165 105 } 166 106 … … 169 109 170 110 // construct an initial model for each object 171 psphotGuessModels (readout, sources, recipe, psf , maskVal);111 psphotGuessModels (readout, sources, recipe, psf); 172 112 173 113 // XXX test output of models 174 114 // psphotTestSourceOutput (readout, sources, recipe, psf); 175 115 176 if (dump) psphotSaveImage (NULL, readout->image, "image.v0.fits"); 177 178 // linear PSF fit to peaks 179 psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE, maskVal); 180 if (dump) psphotSaveImage (NULL, readout->image, "image.v1.fits"); 116 // linear PSF fit to source peaks 117 psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE); 181 118 182 119 // XXX test the CR/EXT measurement 183 120 // XXX we need to call this here and after the second pass: option for starting number? 184 psphotSourceSize (readout, sources, recipe); 185 121 psphotSourceSize (readout, sources, recipe, 0); 186 122 if (!strcasecmp (breakPt, "ENSEMBLE")) { 187 123 goto finish; … … 189 125 190 126 // non-linear PSF and EXT fit to brighter sources 191 psphotBlendFit (readout, sources, recipe, psf, maskVal); 192 if (dump) psphotSaveImage (NULL, readout->image, "image.v2.fits"); 193 194 // replace all sources 195 psphotReplaceAll (sources, maskVal); 196 if (dump) psphotSaveImage (NULL, readout->image, "image.v3.fits"); 197 198 // linear PSF fit to remaining peaks 199 psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE, maskVal); 200 if (dump) psphotSaveImage (NULL, readout->image, "image.v4.fits"); 127 psphotBlendFit (readout, sources, recipe, psf); 128 129 // replace all sources (make this part of psphotFitSourcesLinear?) 130 psphotReplaceAll (sources, recipe); 131 132 // linear fit to include all sources 133 psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE); 201 134 if (!strcasecmp (breakPt, "PASS1")) { 202 135 goto finish; … … 210 143 211 144 // add noise for subtracted objects 212 psphotAddNoise (readout, sources, recipe, true, maskVal); 213 214 // find the peaks in the image 215 psArray *newPeaks; 216 if (useFootprints) { 217 psArray *newFootprints = psphotFindPeaks (readout, recipe, useFootprints, 2, maskVal); 218 219 int growRadius = psMetadataLookupS32(NULL, recipe, "FOOTPRINT_GROW_RADIUS_2"); 220 if (growRadius > 0) { 221 psArray *tmp = pmGrowFootprintArray(newFootprints, growRadius); 222 psFree(newFootprints); 223 newFootprints = tmp; 224 } 225 226 // merge in old peaks 227 const int includePeaks = 0x0 | 0x2; // i.e. just from newFootprints 228 psArray *mergedFootprints = pmMergeFootprintArrays(footprints, newFootprints, includePeaks); 229 psFree(footprints); 230 psFree(newFootprints); 231 232 psphotCullPeaks(readout->image, readout->weight, recipe, mergedFootprints); 233 234 newPeaks = pmFootprintArrayToPeaks(mergedFootprints); 235 236 psFree(mergedFootprints); 237 } else { 238 newPeaks = psphotFindPeaks(readout, recipe, useFootprints, 2, maskVal); 239 } 145 psphotAddNoise (readout, sources, recipe); 146 147 detections = psphotFindDetections (detections, readout, recipe); 240 148 241 149 // remove noise for subtracted objects 242 psphotAddNoise (readout, sources, recipe, false, maskVal); 243 244 // define new sources based on the new peaks 245 psArray *newSources = psphotSourceStats (readout, recipe, newPeaks, maskVal, maskMark); 246 psFree (newPeaks); 150 psphotSubNoise (readout, sources, recipe); 151 152 // define new sources based on only the new peaks 153 psArray *newSources = psphotSourceStats (readout, recipe, detections); 247 154 248 155 // set source type 249 if (!psphotRoughClass (newSources, recipe, havePSF , maskSat)) {156 if (!psphotRoughClass (newSources, recipe, havePSF)) { 250 157 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 251 return psphotReadoutCleanup (config, readout, recipe, psf, sources);158 return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources); 252 159 } 253 160 254 161 // create full input models 255 psphotGuessModels (readout, newSources, recipe, psf, maskVal); 256 257 // replace all sources 258 psphotReplaceAll (sources, maskVal); 259 if (dump) psphotSaveImage (NULL, readout->image, "image.v5.fits"); 260 261 // merge the newly selected peaks into the existing list 162 psphotGuessModels (readout, newSources, recipe, psf); 163 164 // replace all sources so fit below applies to all at once 165 psphotReplaceAll (sources, recipe); 166 167 // merge the newly selected sources into the existing list 262 168 psphotMergeSources (sources, newSources); 263 169 psFree (newSources); 264 170 265 // linear PSF fit to remaining peaks 266 psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE, maskVal); 267 if (dump) psphotSaveImage (NULL, readout->image, "image.v6.fits"); 268 269 psphotExtendedSources (readout, sources, recipe, maskVal); 171 // linear fit to all sources 172 psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE); 173 174 // measure source size for the remaining sources 175 psphotSourceSize (readout, sources, recipe, 0); 176 177 psphotExtendedSources (readout, sources, recipe); 270 178 271 179 finish: … … 273 181 // plot positive sources 274 182 if (!havePSF) { 275 // psphotSourcePlots (readout, sources, recipe , maskVal);183 // psphotSourcePlots (readout, sources, recipe); 276 184 } 277 185 278 186 // measure aperture photometry corrections 279 if (!havePSF && !psphotApResid (readout, sources, recipe, psf, maskVal, maskMark)) { 280 psTrace ("psphot", 4, "failure on psphotApResid"); 281 psError(PSPHOT_ERR_PHOTOM, false, "Measure aperture photometry corrections"); 282 return false; 187 if (!havePSF && !psphotApResid (readout, sources, recipe, psf)) { 188 psLogMsg ("psphot", 3, "failed on psphotApResid"); 189 return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources); 283 190 } 284 191 285 192 // calculate source magnitudes 286 193 pmReadout *background = psphotSelectBackground (config, view, false); 287 psphotMagnitudes(sources, recipe, psf, background , maskVal, maskMark);194 psphotMagnitudes(sources, recipe, psf, background); 288 195 289 196 // replace failed sources? … … 297 204 298 205 // create the exported-metadata and free local data 299 return psphotReadoutCleanup(config, readout, recipe, psf, sources);206 return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources); 300 207 } -
branches/eam_branch_20080229/psphot/src/psphotReadoutCleanup.c
r14655 r16760 1 1 # include "psphotInternal.h" 2 2 3 // psphotReadoutCleanup is called on exit from psphotReadout if the last raised4 // error is not a DATA error, then there was a serious problem. only in this5 // case, or if the failon the stats measurement, do we return false6 bool psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pm PSF *psf, psArray *sources) {3 // psphotReadoutCleanup is called on exit from psphotReadout. If the last raised error is 4 // not a DATA error, then there was a serious problem. Only in this case, or if the fail 5 // on the stats measurement, do we return false 6 bool psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmDetections *detections, pmPSF *psf, psArray *sources) { 7 7 8 8 // remove internal pmFPAfiles, if created … … 73 73 pmKapaClose (); 74 74 75 psFree (detections); 75 76 psFree (psf); 76 77 psFree (header); -
branches/eam_branch_20080229/psphot/src/psphotReplaceUnfit.c
r13900 r16760 18 18 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 19 19 source->mode &= ~PM_SOURCE_MODE_SUBTRACTED; 20 source->mode &= ~PM_SOURCE_MODE_TEMPSUB;21 20 } 22 21 psLogMsg ("psphot.replace", 3, "replace unfitted models: %f sec (%ld objects)\n", psTimerMark ("psphot"), sources->n); … … 24 23 } 25 24 26 bool psphotReplaceAll (psArray *sources, psM askType maskVal) {25 bool psphotReplaceAll (psArray *sources, psMetadata *recipe) { 27 26 27 bool status; 28 28 pmSource *source; 29 29 30 30 psTimerStart ("psphot"); 31 32 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 33 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 34 assert (maskVal); 31 35 32 36 for (int i = 0; i < sources->n; i++) { … … 39 43 source->mode &= ~PM_SOURCE_MODE_SUBTRACTED; 40 44 } 41 psLogMsg ("psphot.replace", PS_LOG_INFO, "replace models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot"));45 psLogMsg ("psphot.replace", PS_LOG_INFO, "replaced models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot")); 42 46 return true; 43 47 } -
branches/eam_branch_20080229/psphot/src/psphotRoughClass.c
r15059 r16760 1 1 # include "psphotInternal.h" 2 2 3 # define CHECK_STATUS(S,MSG) { \ 3 4 if (!status) { \ … … 7 8 8 9 // 2006.02.02 : no leaks 9 bool psphotRoughClass (psArray *sources, psMetadata *recipe, const bool havePSF , psMaskType maskSat) {10 bool psphotRoughClass (psArray *sources, psMetadata *recipe, const bool havePSF) { 10 11 11 12 bool status; … … 13 14 14 15 psTimerStart ("psphot"); 16 17 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 18 psMaskType maskSat = psMetadataLookupU8(&status, recipe, "MASK.SAT"); // Mask value for bad pixels 19 assert (maskSat); 15 20 16 21 if (!havePSF) { -
branches/eam_branch_20080229/psphot/src/psphotSourceFits.c
r15058 r16760 113 113 pmSourceSub (blend, PM_MODEL_OP_FULL, maskVal); 114 114 blend->mode |= PM_SOURCE_MODE_SUBTRACTED; 115 blend->mode &= ~PM_SOURCE_MODE_TEMPSUB;116 115 } 117 116 NfitBlend += modelSet->n; … … 137 136 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 138 137 source->mode |= PM_SOURCE_MODE_SUBTRACTED; 139 source->mode &= ~PM_SOURCE_MODE_TEMPSUB;140 138 return true; 141 139 } … … 176 174 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 177 175 source->mode |= PM_SOURCE_MODE_SUBTRACTED; 178 source->mode &= ~PM_SOURCE_MODE_TEMPSUB;179 180 176 return true; 181 177 } … … 275 271 pmSourceCacheModel (source, maskVal); 276 272 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 273 source->mode |= PM_SOURCE_MODE_SUBTRACTED; 277 274 psTrace ("psphot", 5, "blob as EXT: %f %f\n", EXT->params->data.F32[PM_PAR_XPOS], EXT->params->data.F32[PM_PAR_YPOS]); 278 279 source->mode |= PM_SOURCE_MODE_SUBTRACTED;280 source->mode &= ~PM_SOURCE_MODE_TEMPSUB;281 275 return true; 282 276 … … 290 284 source->mode |= PM_SOURCE_MODE_SUBTRACTED; 291 285 source->mode |= PM_SOURCE_MODE_PAIR; 292 source->mode &= ~PM_SOURCE_MODE_TEMPSUB;293 286 294 287 // copy most data from the primary source (modelEXT, blends stay NULL) -
branches/eam_branch_20080229/psphot/src/psphotSourcePlots.c
r15000 r16760 1 1 # include "psphotInternal.h" 2 2 3 bool psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe , psMaskType maskVal) {3 bool psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe) { 4 4 5 //bool status = false;5 bool status = false; 6 6 psTimerStart ("psphot"); 7 8 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 9 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 10 assert (maskVal); 7 11 8 12 // the source images are written to an image 10x the size of a PSF object -
branches/eam_branch_20080229/psphot/src/psphotSourceSize.c
r15802 r16760 6 6 // compares the observed flux to the model. 7 7 8 bool psphotSourceSize (pmReadout *readout, psArray *sources, psMetadata *recipe) { 8 bool psphotSourceSize (pmReadout *readout, psArray *sources, psMetadata *recipe, long first) { 9 10 psTimerStart ("psphot"); 9 11 10 12 // loop over all source 11 for (int i = 0; i < sources->n; i++) {13 for (int i = first; i < sources->n; i++) { 12 14 pmSource *source = sources->data[i]; 13 15 16 // skip source if it was already measured 17 if (isfinite(source->crNsigma)) continue; 18 19 source->crNsigma = -1.0; 20 source->extNsigma = -1.0; 21 14 22 // source must have been subtracted 23 source->crNsigma = -3.0; 15 24 if (!(source->mode & PM_SOURCE_MODE_SUBTRACTED)) continue; 16 25 … … 23 32 24 33 // skip sources which are too close to a boundary 34 source->crNsigma = -4.0; 25 35 if (xPeak < 1) continue; 26 36 if (xPeak > source->pixels->numCols - 2) continue; … … 29 39 30 40 // XXX for now, just skip any sources with masked pixels 41 source->crNsigma = -5.0; 31 42 bool keep = true; 32 43 for (int iy = -1; (iy <= +1) && keep; iy++) { … … 97 108 source->extNsigma = (nEXT > 0) ? fabs(fEXT) / nEXT : 0.0; 98 109 // NOTE: abs needed to make the Nsigma value positive 110 111 if (!isfinite(source->crNsigma)) { 112 fprintf (stderr, "."); 113 source->crNsigma = -6.0; 114 } 115 99 116 } 117 118 psLogMsg ("psphot.size", PS_LOG_INFO, "measure source sizes for %ld sources: %f sec\n", sources->n - first, psTimerMark ("psphot")); 119 100 120 return true; 101 121 } -
branches/eam_branch_20080229/psphot/src/psphotSourceStats.c
r15405 r16760 1 1 # include "psphotInternal.h" 2 2 3 psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, p sArray *peaks, psMaskType maskVal, psMaskType mark)3 psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, pmDetections *detections) 4 4 { 5 5 bool status = false; … … 8 8 9 9 psTimerStart ("psphot"); 10 11 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 12 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 13 assert (maskVal); 14 15 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 16 psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels 17 assert (mark); 10 18 11 19 // determine properties (sky, moments) of initial sources … … 20 28 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT"); 21 29 if (!status) return NULL; 30 31 psArray *peaks = detections->peaks; 22 32 23 33 sources = psArrayAllocEmpty (peaks->n); -
branches/eam_branch_20080229/psphot/src/psphotSubtractBackground.c
r15936 r16760 4 4 // generate the median in NxN boxes, clipping heavily 5 5 // linear interpolation to generate full-scale model 6 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filename , psMaskType maskVal)6 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filename) 7 7 { 8 8 bool status = true; … … 25 25 // select the appropriate recipe information 26 26 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 27 assert (recipe); 28 29 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 30 psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 31 assert (maskVal); 27 32 28 33 psImageBinning *binning = psMetadataLookupPtr(&status, recipe, "PSPHOT.BACKGROUND.BINNING");
Note:
See TracChangeset
for help on using the changeset viewer.
