Changeset 15055
- Timestamp:
- Sep 27, 2007, 2:39:47 PM (19 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 2 edited
-
pmSourceFitSet.c (modified) (10 diffs)
-
pmSourceFitSet.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceFitSet.c
r14938 r15055 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-09-2 1 00:09:05$8 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-09-28 00:39:41 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 69 69 int nParams = pmModelClassParameterCount (model->type); 70 70 71 set->paramSet->data[i] = psVector Alloc (nParams, PS_DATA_F32);71 set->paramSet->data[i] = psVectorCopy (NULL, model->params, PS_DATA_F32); 72 72 set->derivSet->data[i] = psVectorAlloc (nParams, PS_DATA_F32); 73 psVectorInit (set->derivSet->data[i], 0.0); 73 74 74 75 set->nParamSet += nParams; … … 107 108 } 108 109 110 // merge parameters from FitSet models into single param and deriv vectors 109 111 bool pmSourceFitSetJoin (psVector *deriv, psVector *param, pmSourceFitSetData *set) { 110 112 … … 117 119 psVector *paramOne = set->paramSet->data[i]; 118 120 psVector *derivOne = set->derivSet->data[i]; 119 assert ((deriv == NULL) || (paramOne->n == derivOne->n)); 120 121 122 // one or the other (param or deriv) must be set 123 assert ((deriv != NULL) || (param != NULL)); 124 assert ((deriv == NULL) || (param == NULL) || (paramOne->n == derivOne->n)); 125 121 126 for (int j = 0; j < paramOne->n; j++, n++) { 122 param->data.F32[n] = paramOne->data.F32[j]; 127 if (param) { 128 param->data.F32[n] = paramOne->data.F32[j]; 129 } 123 130 if (deriv) { 124 131 deriv->data.F32[n] = derivOne->data.F32[j]; … … 129 136 } 130 137 138 // distribute parameters from single param and deriv vectors into FitSet models 131 139 bool pmSourceFitSetSplit (pmSourceFitSetData *set, const psVector *deriv, const psVector *param) { 132 140 … … 191 199 } 192 200 201 // generic psMinLMM-style function for fitting: split the parameters across the models, call 202 // each model function one-at-a-time, the join the derivatives for on-going evaluation 193 203 psF32 pmSourceFitSetFunction(psVector *deriv, const psVector *param, const psVector *x) 194 204 { … … 209 219 chisqSum += chisqOne; 210 220 } 221 pmSourceFitSetJoin (deriv, NULL, thisSet); 211 222 212 223 return (chisqSum); … … 248 259 } 249 260 n += paramOne->n; 261 } 262 return true; 263 } 264 265 bool pmSourcePrintModelSet (FILE *file, psArray *modelSet) { 266 267 for (int i = 0; i < modelSet->n; i++) { 268 pmModel *model = modelSet->data[i]; 269 int nParams = pmModelClassParameterCount (model->type); 270 for (int j = 0; j < nParams; j++) { 271 fprintf (file, "%d %d : %f %f\n", i, j, model->params->data.F32[j], model->dparams->data.F32[j]); 272 } 273 } 274 return true; 275 } 276 277 bool pmSourceFitSetPrint (FILE *file, pmSourceFitSetData *set) { 278 279 for (int i = 0; i < set->paramSet->n; i++) { 280 psVector *paramOne = set->paramSet->data[i]; 281 psVector *derivOne = set->derivSet->data[i]; 282 for (int j = 0; j < paramOne->n; j++) { 283 fprintf (file, "%d %d : %f %f\n", i, j, paramOne->data.F32[j], derivOne->data.F32[j]); 284 } 250 285 } 251 286 return true; … … 314 349 yErr->n = nPix; 315 350 351 // create the FitSet and set the initial parameter guesses 316 352 thisSet = pmSourceFitSetDataAlloc (modelSet); 317 353 … … 383 419 altmask->data.U8[i] = (constraint->paramMask->data.U8[i]) ? 0 : 1; 384 420 } 385 if (!psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, pmSourceFitSetFunction)) { 386 // Can we really do anything about it? 387 // It will happily continue on, but the presence of an error upsets the psphot cleanup 388 psErrorClear(); 389 } 421 psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, pmSourceFitSetFunction); 422 390 423 for (int i = 0; i < dparams->n; i++) { 391 424 if (!constraint->paramMask->data.U8[i]) -
trunk/psModules/src/objects/pmSourceFitSet.h
r14652 r15055 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 8-24 00:11:02$5 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-09-28 00:39:47 $ 7 7 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 8 8 */ … … 50 50 ); 51 51 52 bool pmSourcePrintModelSet (FILE *file, psArray *modelSet); 53 bool pmSourceFitSetPrint (FILE *file, pmSourceFitSetData *set); 54 52 55 /// @} 53 56 # endif /* PM_SOURCE_FIT_MODEL_H */
Note:
See TracChangeset
for help on using the changeset viewer.
