Changeset 6379 for trunk/psphot/src/psphotSourceFits.c
- Timestamp:
- Feb 7, 2006, 8:52:03 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotSourceFits.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotSourceFits.c
r6056 r6379 54 54 55 55 // extended source model descriptions 56 char *modelNameEXT = psMetadataLookup Ptr (&status, config, "EXT_MODEL");56 char *modelNameEXT = psMetadataLookupStr (&status, config, "EXT_MODEL"); 57 57 modelTypeEXT = pmModelSetType (modelNameEXT); 58 58 psphotInitRadiusEXT (config, sky, modelTypeEXT); … … 77 77 psTrace ("psphot.blend", 5, "trying blob...\n"); 78 78 79 // this temporary source is used as a place-holder by the psphotEval functions below 79 80 pmSource *tmpSrc = pmSourceAlloc (); 80 81 … … 89 90 chiDBL = ONE->chisq / ONE->nDOF; 90 91 92 psFree (tmpSrc); // XXX should I keep / save the flags set in the eval functions? 93 91 94 if (okEXT && okDBL) { 92 95 psTrace ("psphot.blend", 5, "blob chisq: %f vs %f\n", chiEXT, chiDBL); … … 98 101 if (okEXT && !okDBL) goto keepEXT; 99 102 if (!okEXT && okDBL) goto keepDBL; 103 104 // both models failed; reject them both 105 psFree (EXT); 106 psFree (DBL); 100 107 return false; 101 108 102 109 keepEXT: 103 110 // sub EXT 111 psFree (DBL); 104 112 pmSourceSubModel (source->pixels, source->mask, EXT, false, false); 105 113 psTrace ("psphot.blend", 5, "blob as EXT: %f %f\n", EXT->params->data.F32[2], EXT->params->data.F32[3]); … … 113 121 keepDBL: 114 122 // sub DLB 123 psFree (EXT); 115 124 pmSourceSubModel (source->pixels, source->mask, (pmModel *) DBL->data[0], false, false); 116 125 pmSourceSubModel (source->pixels, source->mask, (pmModel *) DBL->data[1], false, false); … … 120 129 source->mode |= PM_SOURCE_SUBTRACTED; 121 130 source->mode &= ~PM_SOURCE_TEMPSUB; 122 123 // save new model124 // tmpSrc->modelPSF = (pmModel *) modelSet->data[1];125 // psArrayAdd (sources, 100, tmpSrc);126 131 127 132 return true; … … 205 210 return status; 206 211 } 207 208 212 psTrace ("psphot.blend", 5, "trying blend...\n"); 209 213 … … 225 229 psArrayAdd (sourceSet, 16, source); 226 230 231 // counter to track the blend elements used in the fit 232 psVector *index = psVectorAlloc (source->blends->n + 1, PS_TYPE_S32); 233 index->data.S32[0] = -1; // first element corresponds to the primary source 234 227 235 for (int i = 0; i < source->blends->n; i++) { 228 236 pmSource *blend = source->blends->data[i]; … … 237 245 pmModel *model = blend->modelPSF; 238 246 239 for ( psS32 i = 0; i < model->params->n; i++) {240 model->params->data.F32[ i] = PSF->params->data.F32[i];241 model->dparams->data.F32[ i] = PSF->dparams->data.F32[i];247 for (int j = 0; j < model->params->n; j++) { 248 model->params->data.F32[j] = PSF->params->data.F32[j]; 249 model->dparams->data.F32[j] = PSF->dparams->data.F32[j]; 242 250 } 243 251 … … 247 255 248 256 // add this blend to the list 257 index->data.S32[modelSet->n] = i; 249 258 psArrayAdd (modelSet, 16, model); 250 259 psArrayAdd (sourceSet, 16, blend); … … 261 270 pmModel *model = modelSet->data[i]; 262 271 272 // if we skip this one, free the corresponding blend entry model 263 273 if (!psphotEvalPSF (src, model)) { 264 psFree (model); 265 src->modelPSF = NULL; 274 int n = index->data.S32[i]; 275 pmSource *blend = source->blends->data[n]; 276 psFree (blend->modelPSF); 277 blend->modelPSF = NULL; 266 278 continue; 267 279 } … … 272 284 src->mode &= ~PM_SOURCE_TEMPSUB; 273 285 } 286 psFree (index); 287 psFree (modelSet); 288 psFree (sourceSet); 274 289 275 290 // evaluate the primary object … … 281 296 psTrace ("psphot.blend", 5, "fitted primary as PSF\n"); 282 297 pmSourceSubModel (source->pixels, source->mask, PSF, false, false); 298 psFree (source->modelPSF); 283 299 source->modelPSF = PSF; 284 300 source->mode |= PM_SOURCE_SUBTRACTED;
Note:
See TracChangeset
for help on using the changeset viewer.
