Changeset 12978
- Timestamp:
- Apr 23, 2007, 4:54:30 PM (19 years ago)
- Location:
- branches/eam_02_branch/psphot/src
- Files:
-
- 1 added
- 12 edited
-
Makefile.am (modified) (3 diffs)
-
psphot.h (modified) (1 diff)
-
psphotChoosePSF.c (modified) (1 diff)
-
psphotFitSet.c (modified) (3 diffs)
-
psphotFitSourcesLinear.c (added)
-
psphotGuessModels.c (modified) (1 diff)
-
psphotMakeResiduals.c (modified) (1 diff)
-
psphotModelTest.c (modified) (5 diffs)
-
psphotOutput.c (modified) (3 diffs)
-
psphotRadialPlot.c (modified) (1 diff)
-
psphotRadiusChecks.c (modified) (5 diffs)
-
psphotReadout.c (modified) (3 diffs)
-
psphotSourceFits.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_02_branch/psphot/src/Makefile.am
r12945 r12978 30 30 psphotChoosePSF.c \ 31 31 psphotGuessModels.c \ 32 psphot EnsemblePSF.c\32 psphotFitSourcesLinear.c \ 33 33 psphotBlendFit.c \ 34 34 psphotReplaceUnfit.c \ … … 46 46 psphotModelTest.c \ 47 47 psphotFitSet.c \ 48 psphotWeightBias.c \49 48 psphotSourceFreePixels.c \ 50 49 psphotSummaryPlots.c \ 51 psphotTestPSF.c \52 50 psphotMergeSources.c \ 53 51 psphotReadoutCleanup.c \ … … 57 55 psphotMosaicSubimage.c \ 58 56 psphotMakeResiduals.c \ 59 psphotTestSourceOutput.c \60 57 psphotAddNoise.c 61 58 -
branches/eam_02_branch/psphot/src/psphot.h
r12945 r12978 36 36 bool psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources); 37 37 bool psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final); 38 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final); 38 39 bool psphotGuessModels (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf); 39 40 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf); -
branches/eam_02_branch/psphot/src/psphotChoosePSF.c
r12959 r12978 239 239 240 240 // set the mask and subtract the PSF model 241 // XXX should we be using maskObj? should we be unsetting the mask? 242 assert (source->maskObj); 241 243 psImageKeepCircle (source->maskObj, x, y, RADIUS, "OR", PM_MASK_MARK); 242 244 pmModelSub (source->pixels, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL); -
branches/eam_02_branch/psphot/src/psphotFitSet.c
r12957 r12978 1 1 # include "psphotInternal.h" 2 2 3 // XXX this is not used in main psphot code3 // This is not used in main psphot code (only in psphotModelTest.c) 4 4 bool psphotFitSet (pmSource *source, pmModel *oneModel, char *fitset, pmSourceFitMode mode) { 5 5 … … 33 33 for (int i = 0; i < modelSet->n; i++) { 34 34 pmModel *model = modelSet->data[i]; 35 pmModelSub (source->pixels, source->mask , model, PM_MODEL_OP_FULL);35 pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL); 36 36 37 37 fprintf (stderr, "output parameters (obj %d):\n", i); … … 43 43 // write out 44 44 psphotSaveImage (NULL, source->pixels, "resid.fits"); 45 psphotSaveImage (NULL, source->mask , "mask.fits");45 psphotSaveImage (NULL, source->maskObj, "mask.fits"); 46 46 return true; 47 47 } -
branches/eam_02_branch/psphot/src/psphotGuessModels.c
r12947 r12978 56 56 source->modelPSF = modelPSF; 57 57 source->modelPSF->residuals = psf->residuals; 58 59 pmSourceCacheModel (source); 58 60 } 59 61 psLogMsg ("psphot.models", 4, "built models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot")); -
branches/eam_02_branch/psphot/src/psphotMakeResiduals.c
r12957 r12978 76 76 if (model == NULL) continue; // model must be defined 77 77 78 psImage *image = psImageCopy (NULL, source->pixels, PS_TYPE_F32); 79 psImage *weight = psImageCopy (NULL, source->weight, PS_TYPE_F32); 80 psImage *mask = psImageCopy (NULL, source->mask, PS_TYPE_U8); 78 // why is the mask copied? 79 psImage *image = psImageCopy (NULL, source->pixels, PS_TYPE_F32); 80 psImage *weight = psImageCopy (NULL, source->weight, PS_TYPE_F32); 81 // NOTE: this function is expected to be called BEFORE the object pixels 82 // are masked. Thus, we use the maskView, NOT the maskObj image. 83 psImage *mask = psImageCopy (NULL, source->maskView, PS_TYPE_U8); 81 84 pmModelSub (image, mask, model, PM_MODEL_OP_FULL); 82 85 -
branches/eam_02_branch/psphot/src/psphotModelTest.c
r12957 r12978 2 2 static char DEFAULT_MODE[] = "EXT"; 3 3 4 // XXX consider this function : add more test information? 4 5 bool psphotModelTest (pmReadout *readout, psMetadata *recipe) { 5 6 … … 158 159 159 160 // define the pixels used for the fit 160 psImageKeepCircle (source->mask , xObj, yObj, RADIUS, "OR", PM_MASK_MARK);161 psImageKeepCircle (source->maskObj, xObj, yObj, RADIUS, "OR", PM_MASK_MARK); 161 162 162 163 char *fitset = psMetadataLookupStr (&status, recipe, "TEST_FIT_SET"); … … 170 171 // measure the source mags 171 172 pmSourcePhotometryModel (&fitMag, model); 172 pmSourcePhotometryAper (&obsMag, model, source->pixels, source->mask );173 pmSourcePhotometryAper (&obsMag, model, source->pixels, source->maskObj); 173 174 fprintf (stderr, "ap: %f, fit: %f, apmifit: %f\n", obsMag, fitMag, obsMag - fitMag); 174 175 … … 177 178 178 179 // subtract object, leave local sky 179 pmModelSub (source->pixels, source->mask , model, PM_MODEL_OP_FULL);180 pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL); 180 181 181 182 fprintf (stderr, "output parameters: \n"); … … 186 187 // write out 187 188 psphotSaveImage (NULL, source->pixels, "resid.fits"); 188 psphotSaveImage (NULL, source->mask , "mask.fits");189 psphotSaveImage (NULL, source->maskObj, "mask.fits"); 189 190 190 191 exit (0); -
branches/eam_02_branch/psphot/src/psphotOutput.c
r12957 r12978 56 56 for (int j = 0; j < source->pixels->numCols; j++) { 57 57 // skip masked points 58 if (source->mask ->data.U8[i][j]) {58 if (source->maskObj->data.U8[i][j]) { 59 59 continue; 60 60 } … … 69 69 source->pixels->data.F32[i][j], 70 70 1.0 / source->weight->data.F32[i][j], 71 source->mask ->data.U8[i][j]);71 source->maskObj->data.U8[i][j]); 72 72 } 73 73 } … … 101 101 for (int i = 0; (sources != NULL) && (i < sources->n); i++) { 102 102 pmSource *source = (pmSource *) sources->data[i]; 103 pmModel *model = pmSource SelectModel (source);103 pmModel *model = pmSourceGetModel (NULL, source); 104 104 if (model == NULL) 105 105 continue; -
branches/eam_02_branch/psphot/src/psphotRadialPlot.c
r12933 r12978 60 60 for (int iy = 0; iy < source->pixels->numRows; iy++) { 61 61 for (int ix = 0; ix < source->pixels->numCols; ix++) { 62 if (source->mask ->data.U8[iy][ix]) {62 if (source->maskObj->data.U8[iy][ix]) { 63 63 rb->data.F32[nb] = hypot (ix - Xo, iy - Yo) ; 64 64 fb->data.F32[nb] = log10(source->pixels->data.F32[iy][ix]); -
branches/eam_02_branch/psphot/src/psphotRadiusChecks.c
r12792 r12978 25 25 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model) 26 26 { 27 psF32 *PAR = model->params->data.F32; 28 29 // XXX do we have a better value for the sky noise level? not really... 27 30 pmMoments *moments = source->moments; 28 // do we have a better value for the sky noise level?29 // not really...30 31 31 32 // set the fit radius based on the object flux limit and the model … … 46 47 } 47 48 48 bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radiusFit); 49 bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit); 50 51 // set the mask to flag the excluded pixels 52 psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK); 49 53 return status; 50 54 } 51 55 52 56 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR) { 57 58 psF32 *PAR = model->params->data.F32; 53 59 54 60 pmMoments *moments = source->moments; … … 63 69 } 64 70 65 bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radiusFit); 71 bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit); 72 73 // set the mask to flag the excluded pixels 74 psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK); 66 75 return status; 67 76 } … … 86 95 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model) { 87 96 97 psF32 *PAR = model->params->data.F32; 98 88 99 pmMoments *moments = source->moments; 89 100 if (moments == NULL) return false; … … 94 105 95 106 // redefine the pixels if needed 96 bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radiusFit); 107 bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit); 108 109 // set the mask to flag the excluded pixels 110 psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK); 97 111 return status; 98 112 } -
branches/eam_02_branch/psphot/src/psphotReadout.c
r12945 r12978 115 115 116 116 // linear PSF fit to peaks 117 psphot EnsemblePSF(readout, sources, recipe, psf, FALSE);117 psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE); 118 118 if (dump) psphotSaveImage (NULL, readout->image, "image.v1.fits"); 119 119 if (!strcasecmp (breakPt, "ENSEMBLE")) { … … 130 130 131 131 // linear PSF fit to remaining peaks 132 psphot EnsemblePSF(readout, sources, recipe, psf, TRUE);132 psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE); 133 133 if (dump) psphotSaveImage (NULL, readout->image, "image.v4.fits"); 134 134 if (!strcasecmp (breakPt, "PASS1")) { … … 170 170 171 171 // linear PSF fit to remaining peaks 172 psphot EnsemblePSF(readout, sources, recipe, psf, TRUE);172 psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE); 173 173 if (dump) psphotSaveImage (NULL, readout->image, "image.v6.fits"); 174 174 -
branches/eam_02_branch/psphot/src/psphotSourceFits.c
r12957 r12978 67 67 // these should never be invalid values 68 68 // XXX drop these tests eventually 69 if (isnan(model->params->data.F32[PM_PAR_I0])) psAbort("nan in blend fit");69 if (isnan(model->params->data.F32[PM_PAR_I0])) psAbort("nan in blend fit"); 70 70 if (isnan(model->params->data.F32[PM_PAR_XPOS])) psAbort("nan in blend fit"); 71 71 if (isnan(model->params->data.F32[PM_PAR_YPOS])) psAbort("nan in blend fit"); … … 83 83 84 84 // fit PSF model (set/unset the pixel mask) 85 psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "OR", PM_MASK_MARK);86 85 pmSourceFitSet (source, modelSet, PM_SOURCE_FIT_PSF); 87 psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));88 86 89 87 // correct model chisq for flux trend … … 110 108 blend->modelPSF = psMemIncrRefCounter (model); 111 109 psTrace ("psphot", 5, "fitted blend as PSF\n"); 112 pmModelSub (source->pixels, source->mask , model, PM_MODEL_OP_FULL);110 pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL); 113 111 blend->mode |= PM_SOURCE_MODE_SUBTRACTED; 114 112 blend->mode &= ~PM_SOURCE_MODE_TEMPSUB; … … 128 126 129 127 psTrace ("psphot", 5, "fitted primary as PSF\n"); 130 pmModelSub (source->pixels, source->mask , PSF, PM_MODEL_OP_FULL);128 pmModelSub (source->pixels, source->maskObj, PSF, PM_MODEL_OP_FULL); 131 129 psFree (source->modelPSF); 132 130 source->modelPSF = PSF; … … 138 136 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf) { 139 137 140 float x, y;141 138 double chiTrend; 142 139 … … 150 147 psphotCheckRadiusPSF (readout, source, PSF); 151 148 152 x = PSF->params->data.F32[PM_PAR_XPOS];153 y = PSF->params->data.F32[PM_PAR_YPOS];154 155 149 // fit PSF model (set/unset the pixel mask) 156 psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "OR", PM_MASK_MARK);157 150 pmSourceFitModel (source, PSF, PM_SOURCE_FIT_PSF); 158 psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));159 151 160 152 // correct model chisq for flux trend … … 169 161 170 162 psTrace ("psphot", 5, "fitted as PSF\n"); 171 pmModelSub (source->pixels, source->mask, PSF, PM_MODEL_OP_FULL); 163 // should this be pmSourceSub? 164 pmModelSub (source->pixels, source->maskObj, PSF, PM_MODEL_OP_FULL); 172 165 173 166 // free old model, save new model … … 264 257 // sub EXT 265 258 psFree (DBL); 266 pmModelSub (source->pixels, source->mask , EXT, PM_MODEL_OP_FULL);259 pmModelSub (source->pixels, source->maskObj, EXT, PM_MODEL_OP_FULL); 267 260 psTrace ("psphot", 5, "blob as EXT: %f %f\n", EXT->params->data.F32[PM_PAR_XPOS], EXT->params->data.F32[PM_PAR_YPOS]); 268 261 … … 276 269 // sub DLB 277 270 psFree (EXT); 278 pmModelSub (source->pixels, source->mask , (pmModel *) DBL->data[0], PM_MODEL_OP_FULL);279 pmModelSub (source->pixels, source->mask , (pmModel *) DBL->data[1], PM_MODEL_OP_FULL);271 pmModelSub (source->pixels, source->maskObj, (pmModel *) DBL->data[0], PM_MODEL_OP_FULL); 272 pmModelSub (source->pixels, source->maskObj, (pmModel *) DBL->data[1], PM_MODEL_OP_FULL); 280 273 psTrace ("psphot", 5, "blob as DBL: %f %f\n", ONE->params->data.F32[PM_PAR_XPOS], ONE->params->data.F32[PM_PAR_YPOS]); 281 274 … … 292 285 newSrc->pixels = psMemIncrRefCounter (source->pixels); 293 286 newSrc->weight = psMemIncrRefCounter (source->weight); 294 newSrc->mask = psMemIncrRefCounter (source->mask);287 newSrc->maskObj = psMemIncrRefCounter (source->maskObj); 295 288 newSrc->moments = psMemIncrRefCounter (source->moments); 296 289 newSrc->modelPSF = psMemIncrRefCounter (DBL->data[1]); … … 306 299 psArray *psphotFitDBL (pmReadout *readout, pmSource *source) { 307 300 308 float x, y,dx, dy;301 float dx, dy; 309 302 pmModel *DBL; 310 303 pmModel *PSF; … … 344 337 modelSet->data[1] = DBL; 345 338 346 x = source->moments->x;347 y = source->moments->y;348 349 339 // fit PSF model (set/unset the pixel mask) 350 psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "OR", PM_MASK_MARK);351 340 pmSourceFitSet (source, modelSet, PM_SOURCE_FIT_PSF); 352 psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));353 354 341 return (modelSet); 355 342 } 356 343 357 344 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source) { 358 359 float x, y;360 345 361 346 NfitEXT ++; … … 369 354 psphotCheckRadiusEXT (readout, source, EXT); 370 355 371 x = EXT->params->data.F32[PM_PAR_XPOS];372 y = EXT->params->data.F32[PM_PAR_YPOS];373 374 356 if ((source->moments->Sx < 1e-3) || (source->moments->Sx < 1e-3)) { 375 357 psTrace ("psphot", 5, "problem source: moments: %f %f\n", source->moments->Sx, source->moments->Sy); … … 377 359 378 360 // fit EXT (not PSF) model (set/unset the pixel mask) 379 psImageKeepCircle (source->mask, x, y, EXT->radiusFit, "OR", PM_MASK_MARK);380 361 pmSourceFitModel (source, EXT, PM_SOURCE_FIT_EXT); 381 psImageKeepCircle (source->mask, x, y, EXT->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));382 383 362 return (EXT); 384 363 }
Note:
See TracChangeset
for help on using the changeset viewer.
