- Timestamp:
- Jul 11, 2010, 3:19:38 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceFitModel.c
r28643 r28656 44 44 void pmSourceFitOptionsFree(pmSourceFitOptions *opt) 45 45 { 46 return;46 return; 47 47 } 48 48 … … 53 53 54 54 opt->mode = PM_SOURCE_FIT_PSF; 55 opt->nIter = 15; 56 opt->tol = 0.1; 57 opt->weight = 1.0; 55 opt->nIter = 15; 56 opt->minTol = 0.01; 57 opt->maxTol = 1.00; 58 opt->weight = 1.00; 59 opt->maxChisqDOF = NAN; 58 60 opt->poissonErrors = true; 59 61 … … 103 105 // skip nan values in image 104 106 if (!isfinite(source->variance->data.F32[i][j])) { 105 fprintf (stderr, "impossible! %x vs %x\n", source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j], maskVal);106 continue;107 fprintf (stderr, "impossible! %x vs %x\n", source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j], maskVal); 108 continue; 107 109 } 108 110 … … 142 144 int nParams = 0; 143 145 switch (options->mode) { 144 case PM_SOURCE_FIT_NORM:146 case PM_SOURCE_FIT_NORM: 145 147 // NORM-only model fits only source normalization (Io) 146 148 nParams = 1; … … 148 150 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_I0] = 0; 149 151 break; 150 case PM_SOURCE_FIT_PSF:152 case PM_SOURCE_FIT_PSF: 151 153 // PSF model only fits x,y,Io 152 154 nParams = 3; … … 156 158 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_YPOS] = 0; 157 159 break; 158 case PM_SOURCE_FIT_EXT:160 case PM_SOURCE_FIT_EXT: 159 161 // EXT model fits all params (except sky) 160 162 nParams = params->n - 1; … … 162 164 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1; 163 165 break; 164 default: 165 psAbort("invalid fitting mode"); 166 case PM_SOURCE_FIT_INDEX: 167 // PSF model only fits Io, index (PAR7) -- only Io for models with < 8 params 168 psVectorInit (constraint->paramMask, 1); 169 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_I0] = 0; 170 if (params->n == 7) { 171 nParams = 1; 172 } else { 173 nParams = 2; 174 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_7] = 0; 175 } 176 break; 177 case PM_SOURCE_FIT_NO_INDEX: 178 // PSF model only fits Io, index (PAR7) -- only Io for models with < 8 params 179 psVectorInit (constraint->paramMask, 0); 180 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1; 181 if (params->n == 7) { 182 nParams = params->n - 1; 183 } else { 184 nParams = params->n - 2; 185 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_7] = 1; 186 } 187 break; 188 default: 189 psAbort("invalid fitting mode"); 166 190 } 167 191 // force the floating parameters to fall within the contraint ranges 168 192 for (int i = 0; i < params->n; i++) { 169 model->modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL);170 model->modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL);193 model->modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL); 194 model->modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL); 171 195 } 172 196 … … 181 205 } 182 206 183 psMinimization *myMin = psMinimizationAlloc (options->nIter, options-> tol);207 psMinimization *myMin = psMinimizationAlloc (options->nIter, options->minTol, options->maxTol); 184 208 185 209 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32); … … 202 226 model->flags |= PM_MODEL_STATUS_FITTED; 203 227 if (!fitStatus) model->flags |= PM_MODEL_STATUS_NONCONVERGE; 228 if (myMin->lastDelta > myMin->minTol) model->flags |= PM_MODEL_STATUS_WEAK_FIT; 204 229 205 230 // get the Gauss-Newton distance for fixed model parameters
Note:
See TracChangeset
for help on using the changeset viewer.
