Changeset 21363 for trunk/psModules/src/objects/pmSourceFitSet.c
- Timestamp:
- Feb 5, 2009, 4:31:25 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSourceFitSet.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceFitSet.c
r21183 r21363 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-0 1-27 06:39:38$8 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-06 02:31:25 $ 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 11 * … … 55 55 56 56 if (!fitSets) { 57 fitSets = psArrayAlloc (PS_MAX (1, nThreads));58 } 59 60 // the allocated elements should be NULL on psArrayAlloc, 61 // and a previously allocated array of fitSets should have been cleared 57 fitSets = psArrayAlloc (PS_MAX (1, nThreads)); 58 } 59 60 // the allocated elements should be NULL on psArrayAlloc, 61 // and a previously allocated array of fitSets should have been cleared 62 62 // before pmSourceFitSetInit is called 63 63 for (int i = 0; i < fitSets->n; i++) { 64 psAssert (fitSets->data[i] == NULL, "failure to init or clear fitSets?");64 psAssert (fitSets->data[i] == NULL, "failure to init or clear fitSets?"); 65 65 } 66 66 return true; … … 125 125 // we do not need to lock to do this.... 126 126 for (int i = 0; i < fitSets->n; i++) { 127 thisSet = fitSets->data[i];128 if (!thisSet) continue;129 if (thisSet->thread == id) {130 break;131 }132 thisSet = NULL;127 thisSet = fitSets->data[i]; 128 if (!thisSet) continue; 129 if (thisSet->thread == id) { 130 break; 131 } 132 thisSet = NULL; 133 133 } 134 134 psAssert (thisSet == NULL, "pmSourceFitSetDataSet() called but previous entry not cleared"); … … 137 137 138 138 pthread_mutex_lock (&fitSetInitMutex); 139 139 140 140 // find an entry that is NULL and place it there 141 141 for (int i = 0; i < fitSets->n; i++) { 142 if (fitSets->data[i]) continue;143 fitSets->data[i] = thisSet;144 pthread_mutex_unlock (&fitSetInitMutex);145 return thisSet;142 if (fitSets->data[i]) continue; 143 fitSets->data[i] = thisSet; 144 pthread_mutex_unlock (&fitSetInitMutex); 145 return thisSet; 146 146 } 147 147 pthread_mutex_unlock (&fitSetInitMutex); … … 160 160 pmSourceFitSetData *thisSet = NULL; 161 161 for (int i = 0; i < fitSets->n; i++) { 162 thisSet = fitSets->data[i];163 if (!thisSet) continue;164 if (thisSet->thread == id) {165 break;166 }167 thisSet = NULL;162 thisSet = fitSets->data[i]; 163 if (!thisSet) continue; 164 if (thisSet->thread == id) { 165 break; 166 } 167 thisSet = NULL; 168 168 } 169 169 psAssert (thisSet != NULL, "pmSourceFitSetDataGet() called, but no entry found"); … … 184 184 pmSourceFitSetData *thisSet = NULL; 185 185 for (i = 0; i < fitSets->n; i++) { 186 thisSet = fitSets->data[i];187 if (!thisSet) continue;188 if (thisSet->thread == id) {189 break;190 }191 thisSet = NULL;186 thisSet = fitSets->data[i]; 187 if (!thisSet) continue; 188 if (thisSet->thread == id) { 189 break; 190 } 191 thisSet = NULL; 192 192 } 193 193 psAssert (thisSet != NULL, "pmSourceFitSetDataClear() called, but no entry found"); … … 256 256 psVector *derivOne = set->derivSet->data[i]; 257 257 258 // one or the other (param or deriv) must be set259 assert ((deriv != NULL) || (param != NULL));260 261 // if we are setting derive, derivOne and paramOne must be same length258 // one or the other (param or deriv) must be set 259 assert ((deriv != NULL) || (param != NULL)); 260 261 // if we are setting derive, derivOne and paramOne must be same length 262 262 assert ((deriv == NULL) || (paramOne->n == derivOne->n)); 263 263 264 264 for (int j = 0; j < paramOne->n; j++, n++) { 265 if (param) {266 param->data.F32[n] = paramOne->data.F32[j];267 }265 if (param) { 266 param->data.F32[n] = paramOne->data.F32[j]; 267 } 268 268 if (deriv) { 269 269 deriv->data.F32[n] = derivOne->data.F32[j]; … … 275 275 276 276 // distribute parameters from single param and deriv vectors into FitSet models 277 bool pmSourceFitSetSplit (pmSourceFitSetData *set, const psVector *deriv, const psVector *param) 277 bool pmSourceFitSetSplit (pmSourceFitSetData *set, const psVector *deriv, const psVector *param) 278 278 { 279 279 PS_ASSERT_VECTOR_NON_NULL(param, false); … … 301 301 302 302 // set the model parameters for this fit set 303 bool pmSourceFitSetValues (pmSourceFitSetData *set, const psVector *dparam, 303 bool pmSourceFitSetValues (pmSourceFitSetData *set, const psVector *dparam, 304 304 const psVector *param, pmSource *source, 305 305 psMinimization *myMin, int nPix, bool fitStatus) … … 420 420 421 421 for (int i = 0; i < modelSet->n; i++) { 422 pmModel *model = modelSet->data[i];423 int nParams = pmModelClassParameterCount (model->type);424 for (int j = 0; j < nParams; j++) {425 fprintf (file, "%d %d : %f %f\n", i, j, model->params->data.F32[j], model->dparams->data.F32[j]);426 }422 pmModel *model = modelSet->data[i]; 423 int nParams = pmModelClassParameterCount (model->type); 424 for (int j = 0; j < nParams; j++) { 425 fprintf (file, "%d %d : %f %f\n", i, j, model->params->data.F32[j], model->dparams->data.F32[j]); 426 } 427 427 } 428 428 return true; … … 435 435 psVector *derivOne = set->derivSet->data[i]; 436 436 for (int j = 0; j < paramOne->n; j++) { 437 fprintf (file, "%d %d : %f %f\n", i, j, paramOne->data.F32[j], derivOne->data.F32[j]);437 fprintf (file, "%d %d : %f %f\n", i, j, paramOne->data.F32[j], derivOne->data.F32[j]); 438 438 } 439 439 } … … 450 450 PS_ASSERT_PTR_NON_NULL(source->pixels, false); 451 451 PS_ASSERT_PTR_NON_NULL(source->maskObj, false); 452 PS_ASSERT_PTR_NON_NULL(source-> weight, false);452 PS_ASSERT_PTR_NON_NULL(source->variance, false); 453 453 454 454 bool fitStatus = true; … … 471 471 continue; 472 472 } 473 // skip zero- weightpoints474 if (source-> weight->data.F32[i][j] == 0) {473 // skip zero-variance points 474 if (source->variance->data.F32[i][j] == 0) { 475 475 continue; 476 476 } … … 489 489 490 490 // psMinimizeLMChi2 takes wt = 1/dY^2. suggestion from RHL is to use the local sky 491 // as weightto avoid the bias from systematic errors here we would just use the491 // as variance to avoid the bias from systematic errors here we would just use the 492 492 // source sky variance 493 493 if (PM_SOURCE_FIT_MODEL_PIX_WEIGHTS) { 494 yErr->data.F32[nPix] = 1.0 / source-> weight->data.F32[i][j];494 yErr->data.F32[nPix] = 1.0 / source->variance->data.F32[i][j]; 495 495 } else { 496 496 yErr->data.F32[nPix] = 1.0 / PM_SOURCE_FIT_MODEL_WEIGHT; … … 543 543 psFree (params); 544 544 psFree(constraint); 545 pmSourceFitSetDataClear(); // frees thisSet and removes if from the array of fitSets545 pmSourceFitSetDataClear(); // frees thisSet and removes if from the array of fitSets 546 546 return(false); 547 547 }
Note:
See TracChangeset
for help on using the changeset viewer.
