Changeset 27494
- Timestamp:
- Mar 28, 2010, 11:02:04 AM (16 years ago)
- Location:
- branches/eam_branches/20100225/psModules/src
- Files:
-
- 9 edited
-
objects/Makefile.am (modified) (3 diffs)
-
objects/pmGrowthCurveGenerate.c (modified) (1 diff)
-
objects/pmSource.c (modified) (8 diffs)
-
objects/pmSource.h (modified) (4 diffs)
-
objects/pmSourceIO.c (modified) (4 diffs)
-
objects/pmSourceIO.h (modified) (2 diffs)
-
objects/pmSourcePhotometry.c (modified) (6 diffs)
-
objects/pmSourcePhotometry.h (modified) (2 diffs)
-
psmodules.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20100225/psModules/src/objects/Makefile.am
r26162 r27494 22 22 pmSourceMasks.c \ 23 23 pmSourceMoments.c \ 24 pmSourceDiffStats.c \ 24 25 pmSourceExtendedPars.c \ 25 26 pmSourceUtils.c \ … … 40 41 pmSourceIO_CMF_PS1_V1.c \ 41 42 pmSourceIO_CMF_PS1_V2.c \ 43 pmSourceIO_CMF_PS1_DV1.c \ 42 44 pmSourceIO_MatchedRefs.c \ 43 45 pmSourcePlots.c \ … … 79 81 pmSource.h \ 80 82 pmSourceMasks.h \ 83 pmSourceDiffStats.h \ 81 84 pmSourceExtendedPars.h \ 82 85 pmSourceUtils.h \ -
branches/eam_branches/20100225/psModules/src/objects/pmGrowthCurveGenerate.c
r25754 r27494 157 157 158 158 // measure the fitMag for this model 159 pmSourcePhotometryModel (&fitMag, model);159 pmSourcePhotometryModel (&fitMag, NULL, model); 160 160 growth->fitMag = fitMag; 161 161 -
branches/eam_branches/20100225/psModules/src/objects/pmSource.c
r26893 r27494 46 46 psFree(tmp->maskView); 47 47 psFree(tmp->modelFlux); 48 psFree(tmp->psf Flux);48 psFree(tmp->psfImage); 49 49 psFree(tmp->moments); 50 50 psFree(tmp->modelPSF); … … 52 52 psFree(tmp->modelFits); 53 53 psFree(tmp->extpars); 54 psFree(tmp->blends); 54 psFree(tmp->moments); 55 psFree(tmp->diffStats); 55 56 psTrace("psModules.objects", 10, "---- end ----\n"); 56 57 } … … 68 69 psFree (source->maskView); 69 70 psFree (source->modelFlux); 70 psFree (source->psf Flux);71 psFree (source->psfImage); 71 72 72 73 source->pixels = NULL; … … 75 76 source->maskView = NULL; 76 77 source->modelFlux = NULL; 77 source->psf Flux= NULL;78 source->psfImage = NULL; 78 79 return; 79 80 } … … 103 104 source->maskView = NULL; 104 105 source->modelFlux = NULL; 105 source->psf Flux= NULL;106 source->psfImage = NULL; 106 107 source->moments = NULL; 107 108 source->blends = NULL; … … 113 114 source->tmpFlags = 0; 114 115 source->extpars = NULL; 116 source->diffStats = NULL; 117 115 118 source->region = psRegionSet(NAN, NAN, NAN, NAN); 116 119 psMemSetDeallocator(source, (psFreeFunc) sourceFree); 117 120 118 121 // default values are NAN 119 source->psfMag = NAN; 122 source->psfMag = NAN; 123 source->psfFlux = NAN; 124 source->psfFluxErr = NAN; 120 125 source->extMag = NAN; 121 126 source->errMag = NAN; … … 259 264 mySource->modelFlux = NULL; 260 265 261 // drop the old psf Fluxpixels and force the user to re-create262 psFree (mySource->psf Flux);263 mySource->psf Flux= NULL;266 // drop the old psfImage pixels and force the user to re-create 267 psFree (mySource->psfImage); 268 mySource->psfImage = NULL; 264 269 } 265 270 return extend; … … 873 878 874 879 // if we already have a cached image, re-use that memory 875 source->psf Flux = psImageCopy (source->psfFlux, source->pixels, PS_TYPE_F32);876 psImageInit (source->psf Flux, 0.0);880 source->psfImage = psImageCopy (source->psfImage, source->pixels, PS_TYPE_F32); 881 psImageInit (source->psfImage, 0.0); 877 882 878 883 // in some places (psphotEnsemble), we need a normalized version 879 884 // in others, we just want the model. which is more commonly used? 880 // psf Fluxalways has unity normalization (I0 = 1.0)881 pmModelAdd (source->psf Flux, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal);885 // psfImage always has unity normalization (I0 = 1.0) 886 pmModelAdd (source->psfImage, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal); 882 887 return true; 883 888 } -
branches/eam_branches/20100225/psModules/src/objects/pmSource.h
r27265 r27494 16 16 #include "pmMoments.h" 17 17 #include "pmSourceExtendedPars.h" 18 #include "pmSourceDiffStats.h" 18 19 19 20 /// @addtogroup Objects Object Detection / Analysis Functions … … 65 66 psImage *maskView; ///< view into global image mask for this object region 66 67 psImage *modelFlux; ///< cached copy of the best model for this source 67 psImage *psf Flux; ///< cached copy of the psf model for this source68 psImage *psfImage; ///< cached copy of the psf model for this source 68 69 pmMoments *moments; ///< Basic moments measured for the object. 69 70 pmModel *modelPSF; ///< PSF Model fit (parameters and type) … … 75 76 psArray *blends; ///< collection of sources thought to be confused with object 76 77 float psfMag; ///< calculated from flux in modelPSF 78 float psfFlux; ///< calculated from flux in modelPSF 79 float psfFluxErr; ///< calculated from flux in modelPSF 77 80 float extMag; ///< calculated from flux in modelEXT 78 81 float errMag; ///< error in psfMag OR extMag (depending on type) … … 86 89 psRegion region; ///< area on image covered by selected pixels 87 90 pmSourceExtendedPars *extpars; ///< extended source parameters 91 pmSourceDiffStats *diffStats; ///< extra parameters for difference detections 88 92 }; 89 93 -
branches/eam_branches/20100225/psModules/src/objects/pmSourceIO.c
r26893 r27494 539 539 status &= pmSourcesWrite_CMF_PS1_V2 (file->fits, readout, sources, file->header, outhead, dataname); 540 540 } 541 if (!strcmp (exttype, "PS1_DV1")) { 542 status &= pmSourcesWrite_CMF_PS1_DV1 (file->fits, readout, sources, file->header, outhead, dataname); 543 } 541 544 542 545 if (xsrcname) { … … 553 556 status &= pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe); 554 557 } 558 if (!strcmp (exttype, "PS1_DV1")) { 559 status &= pmSourcesWrite_CMF_PS1_DV1_XSRC (file->fits, sources, xsrcname, recipe); 560 } 555 561 } 556 562 if (xfitname) { … … 567 573 status &= pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname); 568 574 } 575 if (!strcmp (exttype, "PS1_DV1")) { 576 status &= pmSourcesWrite_CMF_PS1_DV1_XFIT (file->fits, sources, xfitname); 577 } 569 578 } 570 579 psFree (outhead); … … 1015 1024 sources = pmSourcesRead_CMF_PS1_V2 (file->fits, hdu->header); 1016 1025 } 1026 if (!strcmp (exttype, "PS1_DV1")) { 1027 sources = pmSourcesRead_CMF_PS1_DV1 (file->fits, hdu->header); 1028 } 1017 1029 1018 1030 if (!pmReadoutReadDetEff(file->fits, readout, deteffname)) { -
branches/eam_branches/20100225/psModules/src/objects/pmSourceIO.h
r24694 r27494 43 43 bool pmSourcesWrite_CMF_PS1_V2_XFIT (psFits *fits, psArray *sources, char *extname); 44 44 45 bool pmSourcesWrite_CMF_PS1_DV1 (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 46 bool pmSourcesWrite_CMF_PS1_DV1_XSRC (psFits *fits, psArray *sources, char *extname, psMetadata *recipe); 47 bool pmSourcesWrite_CMF_PS1_DV1_XFIT (psFits *fits, psArray *sources, char *extname); 48 45 49 bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config); 46 50 … … 53 57 psArray *pmSourcesRead_CMF_PS1_V1 (psFits *fits, psMetadata *header); 54 58 psArray *pmSourcesRead_CMF_PS1_V2 (psFits *fits, psMetadata *header); 59 psArray *pmSourcesRead_CMF_PS1_DV1 (psFits *fits, psMetadata *header); 55 60 56 61 bool pmSourcesWritePSFs (psArray *sources, char *filename); -
branches/eam_branches/20100225/psModules/src/objects/pmSourcePhotometry.c
r25980 r27494 109 109 psAssert (isfinite(fluxScale), "how can the flux scale be invalid? source at %d, %d\n", source->peak->x, source->peak->y); 110 110 psAssert (fluxScale > 0.0, "how can the flux scale be negative? source at %d, %d\n", source->peak->x, source->peak->y); 111 source->psfMag = -2.5*log10(fluxScale * source->modelPSF->params->data.F32[PM_PAR_I0]); 111 source->psfFlux = fluxScale * source->modelPSF->params->data.F32[PM_PAR_I0]; 112 source->psfFluxErr = fluxScale * source->modelPSF->dparams->data.F32[PM_PAR_I0]; 113 source->psfMag = -2.5*log10(source->psfFlux); 112 114 } else { 113 status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF); 115 status = pmSourcePhotometryModel (&source->psfMag, &source->psfFlux, source->modelPSF); 116 source->psfFluxErr = source->psfFlux * (source->modelPSF->dparams->data.F32[PM_PAR_I0] / source->modelPSF->params->data.F32[PM_PAR_I0]); 114 117 } 115 118 … … 119 122 for (int i = 0; i < source->modelFits->n; i++) { 120 123 pmModel *model = source->modelFits->data[i]; 121 status = pmSourcePhotometryModel (&model->mag, model);124 status = pmSourcePhotometryModel (&model->mag, NULL, model); 122 125 if (model == source->modelEXT) foundEXT = true; 123 126 } … … 125 128 source->extMag = source->modelEXT->mag; 126 129 } else { 127 status = pmSourcePhotometryModel (&source->extMag, source->modelEXT);130 status = pmSourcePhotometryModel (&source->extMag, NULL, source->modelEXT); 128 131 } 129 132 } else { 130 133 if (source->modelEXT) { 131 status = pmSourcePhotometryModel (&source->extMag, source->modelEXT);134 status = pmSourcePhotometryModel (&source->extMag, NULL, source->modelEXT); 132 135 } 133 136 } … … 143 146 if (mode & PM_SOURCE_PHOT_WEIGHT) { 144 147 pmSourcePixelWeight (&source->pixWeight, model, source->maskObj, maskVal); 148 } 149 150 // measure the contribution of included pixels 151 if (mode & PM_SOURCE_PHOT_DIFFSTATS) { 152 pmSourceMeasureDiffStats (source, maskVal); 145 153 } 146 154 … … 217 225 218 226 // return source model magnitude 219 bool pmSourcePhotometryModel (float *fitMag, pmModel *model) 220 { 221 PS_ASSERT_PTR_NON_NULL(fitMag, false); 222 if (model == NULL) { 223 return false; 224 } 225 226 float fitSum = 0; 227 *fitMag = NAN; 227 bool pmSourcePhotometryModel (float *fitMag, float *fitFlux, pmModel *model) 228 { 229 psAssert (fitMag || fitFlux, "at least one of magnitude or flux must be requested (not NULL)"); 230 if (model == NULL) return false; 231 232 float mag = NAN; 233 float flux = NAN; 228 234 229 235 // measure fitMag 230 fitSum = model->modelFlux (model->params); 231 if (fitSum <= 0) 232 return false; 233 if (!isfinite(fitSum)) 234 return false; 235 *fitMag = -2.5*log10(fitSum); 236 flux = model->modelFlux (model->params); 237 if (flux > 0) { 238 mag = -2.5*log10(flux); 239 } 240 if (fitMag) { 241 *fitMag = mag; 242 } 243 if (fitFlux) { 244 *fitFlux = flux; 245 } 246 247 if (flux <= 0) return false; 248 if (!isfinite(flux)) return false; 236 249 237 250 return (true); … … 356 369 357 370 *pixWeight = validSum / modelSum; 371 return (true); 372 } 373 374 # define FLUX_LIMIT 3.0 375 376 // return source aperture magnitude 377 bool pmSourceMeasureDiffStats (pmSource *source, psImageMaskType maskVal) 378 { 379 PS_ASSERT_PTR_NON_NULL(source, false); 380 381 if (source->diffStats == NULL) { 382 source->diffStats = pmSourceDiffStatsAlloc(); 383 } 384 385 float fGood = 0.0; 386 float fBad = 0.0; 387 int nGood = 0; 388 int nMask = 0; 389 int nBad = 0; 390 391 psImage *flux = source->pixels; 392 psImage *variance = source->variance; 393 psImage *mask = source->maskObj; 394 395 for (int iy = 0; iy < flux->numRows; iy++) { 396 for (int ix = 0; ix < flux->numCols; ix++) { 397 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) { 398 nMask ++; 399 continue; 400 } 401 402 float SN = flux->data.F32[iy][ix] / sqrt(variance->data.F32[iy][ix]); 403 404 if (SN > +FLUX_LIMIT) { 405 nGood ++; 406 fGood += flux->data.F32[iy][ix]; 407 } 408 409 if (SN < -FLUX_LIMIT) { 410 nBad ++; 411 fBad += flux->data.F32[iy][ix]; 412 } 413 } 414 } 415 416 source->diffStats->fRatio = fGood / (fGood + fBad); 417 source->diffStats->nRatioBad = nGood / (nGood + nBad); 418 source->diffStats->nRatioMask = nGood / (nGood + nMask); 419 source->diffStats->nRatioAll = nGood / (nGood + nMask + nBad); 420 source->diffStats->nGood = nGood; 421 358 422 return (true); 359 423 } -
branches/eam_branches/20100225/psModules/src/objects/pmSourcePhotometry.h
r25980 r27494 29 29 30 30 typedef enum { 31 PM_SOURCE_PHOT_NONE = 0x0000, 32 PM_SOURCE_PHOT_GROWTH = 0x0001, 33 PM_SOURCE_PHOT_APCORR = 0x0002, 34 PM_SOURCE_PHOT_WEIGHT = 0x0004, 35 PM_SOURCE_PHOT_INTERP = 0x0008, 31 PM_SOURCE_PHOT_NONE = 0x0000, 32 PM_SOURCE_PHOT_GROWTH = 0x0001, 33 PM_SOURCE_PHOT_APCORR = 0x0002, 34 PM_SOURCE_PHOT_WEIGHT = 0x0004, 35 PM_SOURCE_PHOT_INTERP = 0x0008, 36 PM_SOURCE_PHOT_DIFFSTATS = 0x0010, 36 37 } pmSourcePhotometryMode; 37 38 38 39 bool pmSourcePhotometryModel( 39 40 float *fitMag, ///< integrated fit magnitude 41 float *fitFlux, ///< integrated fit magnitude 40 42 pmModel *model ///< model used for photometry 41 43 ); … … 54 56 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psImageMaskType maskVal, const float covarFactor); 55 57 58 bool pmSourceMeasureDiffStats (pmSource *source, psImageMaskType maskVal); 56 59 57 60 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor); -
branches/eam_branches/20100225/psModules/src/psmodules.h
r26893 r27494 115 115 #include <pmDetections.h> 116 116 #include <pmMoments.h> 117 #include <pmSourceExtendedPars.h> 118 #include <pmSourceDiffPars.h> 117 119 #include <pmResiduals.h> 118 120 #include <pmGrowthCurve.h>
Note:
See TracChangeset
for help on using the changeset viewer.
