Changeset 6481 for trunk/psphot/src/psphotSourceFits.c
- Timestamp:
- Feb 23, 2006, 6:16:11 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotSourceFits.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotSourceFits.c
r6427 r6481 126 126 psTrace ("psphot.blend", 5, "blob as DBL: %f %f\n", ONE->params->data.F32[2], ONE->params->data.F32[3]); 127 127 128 source->modelPSF = (pmModel *) DBL->data[0]; 129 source->mode |= PM_SOURCE_SUBTRACTED; 130 source->mode &= ~PM_SOURCE_TEMPSUB; 131 128 // drop old model, save new second model... 129 psFree (source->modelPSF); 130 source->modelPSF = psMemCopy (DBL->data[0]); 131 source->mode |= PM_SOURCE_SUBTRACTED; 132 source->mode |= PM_SOURCE_PAIR; 133 source->mode &= ~PM_SOURCE_TEMPSUB; 134 135 // copy most data from the primary source (modelEXT, blends stay NULL) 136 pmSource *newSrc = pmSourceAlloc (); 137 newSrc->peak = psMemCopy (source->peak); 138 newSrc->pixels = psMemCopy (source->pixels); 139 newSrc->weight = psMemCopy (source->weight); 140 newSrc->mask = psMemCopy (source->mask); 141 newSrc->moments = psMemCopy (source->moments); 142 newSrc->modelPSF = psMemCopy (DBL->data[1]); 143 newSrc->type = source->type; 144 newSrc->mode = source->mode; 145 psArrayAdd (sources, 100, newSrc); 146 psFree (newSrc); 147 psFree (DBL); 132 148 return true; 133 149 } … … 154 170 // save the PSF model from the Ensemble fit 155 171 PSF = source->modelPSF; 156 psphotCheckRadiusPSF (readout, source, PSF);172 psphotCheckRadiusPSFBlend (readout, source, PSF, 8.0); 157 173 158 174 modelSet = psArrayAlloc (2); … … 160 176 DBL = pmModelCopy (PSF); 161 177 DBL->params->data.F32[1] *= 0.5; 162 DBL->params->data.F32[2] +=dx;163 DBL->params->data.F32[3] +=dy;178 DBL->params->data.F32[2] = source->moments->x + dx; 179 DBL->params->data.F32[3] = source->moments->y + dy; 164 180 modelSet->data[0] = DBL; 165 181 166 182 DBL = pmModelCopy (PSF); 167 183 DBL->params->data.F32[1] *= 0.5; 168 DBL->params->data.F32[2] -=dx;169 DBL->params->data.F32[3] -=dy;184 DBL->params->data.F32[2] = source->moments->x - dx; 185 DBL->params->data.F32[3] = source->moments->y - dy; 170 186 modelSet->data[1] = DBL; 171 187 172 x = PSF->params->data.F32[2];173 y = PSF->params->data.F32[3];188 x = source->moments->x; 189 y = source->moments->y; 174 190 175 191 // fit EXT (not PSF) model (set/unset the pixel mask) … … 214 230 // save the PSF model from the Ensemble fit 215 231 pmModel *PSF = pmModelCopy (source->modelPSF); 216 217 // extend source radius as needed218 psphotCheckRadiusPSF (readout, source, PSF);219 232 220 233 x = PSF->params->data.F32[2]; … … 229 242 psArrayAdd (sourceSet, 16, source); 230 243 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 244 // we need to include all blends in the fit (unless primary is saturated?) 245 dR = 0; 235 246 for (int i = 0; i < source->blends->n; i++) { 236 247 pmSource *blend = source->blends->data[i]; 237 248 238 // is this object close enough to include in the fit 239 // XXX this test is bogus: need to think about this 240 dR = hypot (blend->peak->x - x, blend->peak->y - y); 241 if (dR > PSF->radius - 3) continue; 249 // find the blend which is furthest from source 250 dR = PS_MAX (dR, hypot (blend->peak->x - x, blend->peak->y - y)); 242 251 243 252 // create the model and guess parameters for this blend … … 256 265 257 266 // add this blend to the list 258 index->data.S32[modelSet->n] = i;259 267 psArrayAdd (modelSet, 16, model); 260 268 psArrayAdd (sourceSet, 16, blend); 261 269 } 270 271 // extend source radius as needed 272 psphotCheckRadiusPSFBlend (readout, source, PSF, dR); 262 273 263 274 // fit PSF model (set/unset the pixel mask) … … 273 284 // if we skip this one, free the corresponding blend entry model 274 285 if (!psphotEvalPSF (src, model)) { 275 int n = index->data.S32[i]; 276 pmSource *blend = source->blends->data[n]; 286 pmSource *blend = source->blends->data[i - 1]; 277 287 psFree (blend->modelPSF); 278 288 blend->modelPSF = NULL; … … 285 295 src->mode &= ~PM_SOURCE_TEMPSUB; 286 296 } 287 psFree (index);288 297 psFree (modelSet); 289 298 psFree (sourceSet);
Note:
See TracChangeset
for help on using the changeset viewer.
