- Timestamp:
- Jul 9, 2010, 10:56:32 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceFitModel.c
r26070 r28643 23 23 #include "pmHDU.h" 24 24 #include "pmFPA.h" 25 26 #include "pmTrend2D.h" 27 #include "pmResiduals.h" 28 #include "pmGrowthCurve.h" 25 29 #include "pmSpan.h" 30 #include "pmFootprintSpans.h" 26 31 #include "pmFootprint.h" 27 32 #include "pmPeaks.h" 28 33 #include "pmMoments.h" 29 #include "pmGrowthCurve.h" 30 #include "pmResiduals.h" 31 #include "pmTrend2D.h" 32 #include "pmPSF.h" 34 #include "pmModelFuncs.h" 33 35 #include "pmModel.h" 36 #include "pmModelUtils.h" 37 #include "pmModelClass.h" 38 #include "pmSourceMasks.h" 39 #include "pmSourceExtendedPars.h" 40 #include "pmSourceDiffStats.h" 34 41 #include "pmSource.h" 35 #include "pmModelClass.h"36 42 #include "pmSourceFitModel.h" 37 43 38 // save as static values so they may be set externally 39 static psF32 PM_SOURCE_FIT_MODEL_NUM_ITERATIONS = 15; 40 static psF32 PM_SOURCE_FIT_MODEL_TOLERANCE = 0.1; 41 static psF32 PM_SOURCE_FIT_MODEL_WEIGHT = 1.0; 42 static bool PM_SOURCE_FIT_MODEL_PIX_WEIGHTS = true; 43 44 bool pmSourceFitModelInit (float nIter, float tol, float weight, bool poissonErrors) 44 void pmSourceFitOptionsFree(pmSourceFitOptions *opt) 45 45 { 46 47 PM_SOURCE_FIT_MODEL_NUM_ITERATIONS = nIter; 48 PM_SOURCE_FIT_MODEL_TOLERANCE = tol; 49 PM_SOURCE_FIT_MODEL_WEIGHT = weight; 50 PM_SOURCE_FIT_MODEL_PIX_WEIGHTS = poissonErrors; 51 52 return true; 46 return; 47 } 48 49 pmSourceFitOptions *pmSourceFitOptionsAlloc(void) { 50 51 pmSourceFitOptions *opt = (pmSourceFitOptions *) psAlloc(sizeof(pmSourceFitOptions)); 52 psMemSetDeallocator(opt, (psFreeFunc) pmSourceFitOptionsFree); 53 54 opt->mode = PM_SOURCE_FIT_PSF; 55 opt->nIter = 15; 56 opt->tol = 0.1; 57 opt->weight = 1.0; 58 opt->poissonErrors = true; 59 60 return opt; 53 61 } 54 62 55 63 bool pmSourceFitModel (pmSource *source, 56 64 pmModel *model, 57 pmSourceFit Mode mode,65 pmSourceFitOptions *options, 58 66 psImageMaskType maskVal) 59 67 { … … 111 119 // as variance to avoid the bias from systematic errors here we would just use the 112 120 // source sky variance 113 if ( PM_SOURCE_FIT_MODEL_PIX_WEIGHTS) {121 if (options->poissonErrors) { 114 122 yErr->data.F32[nPix] = 1.0 / source->variance->data.F32[i][j]; 115 123 } else { 116 yErr->data.F32[nPix] = 1.0 / PM_SOURCE_FIT_MODEL_WEIGHT;124 yErr->data.F32[nPix] = 1.0 / options->weight; 117 125 } 118 126 nPix++; … … 133 141 // set parameter mask based on fitting mode 134 142 int nParams = 0; 135 switch ( mode) {143 switch (options->mode) { 136 144 case PM_SOURCE_FIT_NORM: 137 145 // NORM-only model fits only source normalization (Io) … … 173 181 } 174 182 175 psMinimization *myMin = psMinimizationAlloc ( PM_SOURCE_FIT_MODEL_NUM_ITERATIONS, PM_SOURCE_FIT_MODEL_TOLERANCE);183 psMinimization *myMin = psMinimizationAlloc (options->nIter, options->tol); 176 184 177 185 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32);
Note:
See TracChangeset
for help on using the changeset viewer.
