- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/psModules
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psModules merged eligible /branches/eam_branches/stackphot.20100406/psModules 27623-27653 /branches/pap_delete/psModules 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/psModules/src/objects/pmModel.c
r23187 r27840 56 56 57 57 tmp->type = type; 58 tmp->chisq = 0.0; 59 tmp->chisqNorm = 0.0; 58 tmp->mag = NAN; 59 tmp->chisq = NAN; 60 tmp->chisqNorm = NAN; 60 61 tmp->nDOF = 0; 61 62 tmp->nPix = 0; 62 63 tmp->nIter = 0; 63 tmp-> radiusFit= 0;64 tmp->fitRadius = 0; 64 65 tmp->flags = PM_MODEL_STATUS_NONE; 65 66 tmp->residuals = NULL; // XXX should the model own this memory? … … 86 87 tmp->modelParamsFromPSF = class->modelParamsFromPSF; 87 88 tmp->modelFitStatus = class->modelFitStatus; 89 tmp->modelSetLimits = class->modelSetLimits; 88 90 89 91 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); … … 108 110 new->nIter = model->nIter; 109 111 new->flags = model->flags; 110 new-> radiusFit = model->radiusFit;112 new->fitRadius = model->fitRadius; 111 113 112 114 for (int i = 0; i < new->params->n; i++) { … … 189 191 psVector *params = model->params; 190 192 191 psS32imageCol;192 psS32imageRow;193 psF32pixelValue;193 float imageCol; 194 float imageRow; 195 float pixelValue; 194 196 195 197 // save original values; restore before returning … … 232 234 psF32 **Rx = NULL; 233 235 psF32 **Ry = NULL; 234 p sImageMaskType **Rm = NULL;236 pmResidMaskType **Rm = NULL; 235 237 236 238 if (model->residuals) { … … 240 242 Rx = (model->residuals->Rx) ? model->residuals->Rx->data.F32 : NULL; 241 243 Ry = (model->residuals->Ry) ? model->residuals->Ry->data.F32 : NULL; 242 Rm = (model->residuals->mask) ? model->residuals->mask->data.P S_TYPE_IMAGE_MASK_DATA : NULL;244 Rm = (model->residuals->mask) ? model->residuals->mask->data.PM_TYPE_RESID_MASK_DATA : NULL; 243 245 if (Ro) { 244 246 NX = model->residuals->Ro->numCols; … … 255 257 continue; 256 258 257 // XXX should we use using 0.5 pixel offset?258 // Convert to coordinate in parent image, with offset (dx,dy)259 imageCol = ix + image->col0 - dx;260 imageRow = iy + image->row0 - dy;261 262 x->data.F32[0] = (float)imageCol;263 x->data.F32[1] = (float)imageRow;259 // Convert to coordinate in parent image, with offset (dx,dy) 260 // 0.5 PIX: the model take pixel coordinates so convert the pixel index here 261 imageCol = ix + 0.5 + image->col0 - dx; 262 imageRow = iy + 0.5 + image->row0 - dy; 263 264 x->data.F32[0] = imageCol; 265 x->data.F32[1] = imageRow; 264 266 265 267 pixelValue = 0.0; … … 276 278 float rx = xBin*ix + DX; 277 279 278 int rx0 = rx - 0.5;279 int rx1 = rx + 0.5;280 int ry0 = ry - 0.5;281 int ry1 = ry + 0.5;282 283 if (rx0 < 0) goto skip;284 if (ry0 < 0) goto skip;285 if (rx1 >= NX) goto skip;286 if (ry1 >= NY) goto skip;287 288 // these go from 0.0 to 1.0 between the centers of the pixels 289 float fx = rx - 0.5 - rx0;290 float Fx = 1.0 - fx;291 float fy = ry - 0.5 - ry0;292 float Fy = 1.0 - fy;293 294 // check the residual image mask (if set). give up if any of the 4 pixels are masked.295 if (Rm) {296 if (Rm[ry0][rx0]) goto skip;297 if (Rm[ry0][rx1]) goto skip;298 if (Rm[ry1][rx0]) goto skip;299 if (Rm[ry1][rx1]) goto skip;300 }301 302 // a possible further optimization if we re-use these values303 // XXX allow for masked pixels, and add pixel weights304 float V0 = (Ro[ry0][rx0]*Fx + Ro[ry0][rx1]*fx);305 float V1 = (Ro[ry1][rx0]*Fx + Ro[ry1][rx1]*fx);306 float Vo = V0*Fy + V1*fy;307 if (!isfinite(Vo)) goto skip;308 309 float Vx = 0.0;310 float Vy = 0.0;311 312 // skip Rx,Ry if Ro is masked313 if (Rx && Ry && (mode & PM_MODEL_OP_RES1)) {314 V0 = (Rx[ry0][rx0]*Fx + Rx[ry0][rx1]*fx);315 V1 = (Rx[ry1][rx0]*Fx + Rx[ry1][rx1]*fx);316 Vx = V0*Fy + V1*fy;317 318 V0 = (Ry[ry0][rx0]*Fx + Ry[ry0][rx1]*fx);319 V1 = (Ry[ry1][rx0]*Fx + Ry[ry1][rx1]*fx);320 Vy = V0*Fy + V1*fy;321 }322 if (!isfinite(Vx)) goto skip;323 if (!isfinite(Vy)) goto skip;324 325 // 2D residual variations are set for the true source position326 pixelValue += Io*(Vo + XoSave*Vx + XoSave*Vy);280 int rx0 = rx - 0.5; 281 int rx1 = rx + 0.5; 282 int ry0 = ry - 0.5; 283 int ry1 = ry + 0.5; 284 285 if (rx0 < 0) goto skip; 286 if (ry0 < 0) goto skip; 287 if (rx1 >= NX) goto skip; 288 if (ry1 >= NY) goto skip; 289 290 // these go from 0.0 to 1.0 between the centers of the pixels 291 float fx = rx - 0.5 - rx0; 292 float Fx = 1.0 - fx; 293 float fy = ry - 0.5 - ry0; 294 float Fy = 1.0 - fy; 295 296 // check the residual image mask (if set). give up if any of the 4 pixels are masked. 297 if (Rm) { 298 if (Rm[ry0][rx0]) goto skip; 299 if (Rm[ry0][rx1]) goto skip; 300 if (Rm[ry1][rx0]) goto skip; 301 if (Rm[ry1][rx1]) goto skip; 302 } 303 304 // a possible further optimization if we re-use these values 305 // XXX allow for masked pixels, and add pixel weights 306 float V0 = (Ro[ry0][rx0]*Fx + Ro[ry0][rx1]*fx); 307 float V1 = (Ro[ry1][rx0]*Fx + Ro[ry1][rx1]*fx); 308 float Vo = V0*Fy + V1*fy; 309 if (!isfinite(Vo)) goto skip; 310 311 float Vx = 0.0; 312 float Vy = 0.0; 313 314 // skip Rx,Ry if Ro is masked 315 if (Rx && Ry && (mode & PM_MODEL_OP_RES1)) { 316 V0 = (Rx[ry0][rx0]*Fx + Rx[ry0][rx1]*fx); 317 V1 = (Rx[ry1][rx0]*Fx + Rx[ry1][rx1]*fx); 318 Vx = V0*Fy + V1*fy; 319 320 V0 = (Ry[ry0][rx0]*Fx + Ry[ry0][rx1]*fx); 321 V1 = (Ry[ry1][rx0]*Fx + Ry[ry1][rx1]*fx); 322 Vy = V0*Fy + V1*fy; 323 } 324 if (!isfinite(Vx)) goto skip; 325 if (!isfinite(Vy)) goto skip; 326 327 // 2D residual variations are set for the true source position 328 pixelValue += Io*(Vo + XoSave*Vx + XoSave*Vy); 327 329 } 328 330 329 skip:331 skip: 330 332 // add or subtract the value 331 333 if (add) {
Note:
See TracChangeset
for help on using the changeset viewer.
