Changeset 13038
- Timestamp:
- Apr 25, 2007, 3:45:35 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmModel.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmModel.c
r12949 r13038 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-04-2 1 19:47:14$8 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-04-26 01:45:35 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 135 135 psImage *mask, 136 136 pmModel *model, 137 bool center, 138 bool sky, 137 pmModelOpMode mode, 139 138 bool add 140 139 ) … … 151 150 psS32 imageCol; 152 151 psS32 imageRow; 153 psF32 skyValue = params->data.F32[0];154 152 psF32 pixelValue; 155 153 156 float xCenter = model->params->data.F32[PM_PAR_XPOS]; 157 float yCenter = model->params->data.F32[PM_PAR_YPOS]; 158 float Io = model->params->data.F32[PM_PAR_I0]; 154 // save original values; restore before returning 155 // use the true source position for the residual model 156 // the PSF model has presumably already been set for this coordinate 157 float xPos = params->data.F32[PM_PAR_XPOS]; 158 float yPos = params->data.F32[PM_PAR_YPOS]; 159 float IoSave = params->data.F32[PM_PAR_I0]; 160 float skySave = params->data.F32[PM_PAR_SKY]; 161 162 if (mode & PM_MODEL_OP_NORM) { 163 params->data.F32[PM_PAR_I0] = 1.0; 164 } 165 if (!(mode & PM_MODEL_OP_SKY)) { 166 params->data.F32[PM_PAR_SKY] = 0.0; 167 } 168 if (mode & PM_MODEL_OP_CENTER) { 169 params->data.F32[PM_PAR_XPOS] = image->col0 + 0.5*image->numCols; 170 params->data.F32[PM_PAR_YPOS] = image->row0 + 0.5*image->numRows; 171 } 172 173 // use these values for this realization 174 float xCenter = params->data.F32[PM_PAR_XPOS]; 175 float yCenter = params->data.F32[PM_PAR_YPOS]; 176 float Io = params->data.F32[PM_PAR_I0]; 159 177 160 178 int xBin = 1; … … 166 184 psImageInterpolateOptions *Rx = NULL; 167 185 psImageInterpolateOptions *Ry = NULL; 168 if (model->residuals ) {186 if (model->residuals && (mode & (PM_MODEL_OP_RES0 | PM_MODEL_OP_RES1))) { 169 187 Ro = psImageInterpolateOptionsAlloc( 170 188 PS_INTERPOLATE_BILINEAR, … … 189 207 190 208 // Convert i/j to image coord space: 191 // 'center' option changes meaning of i,j: 192 if (center) { 193 imageCol = ix - 0.5*image->numCols + xCenter; 194 imageRow = iy - 0.5*image->numRows + yCenter; 195 } else { 196 imageCol = ix + image->col0; 197 imageRow = iy + image->row0; 198 } 209 // XXX should we use using 0.5 pixel offset? 210 imageCol = ix + image->col0; 211 imageRow = iy + image->row0; 199 212 200 213 x->data.F32[0] = (float) imageCol; 201 214 x->data.F32[1] = (float) imageRow; 202 215 203 // set the appropriate pixel value for this coordinate 204 if (sky) { 205 pixelValue = modelFunc (NULL, params, x);206 } else{207 pixelValue = modelFunc (NULL, params, x) - skyValue;208 } 216 pixelValue = 0.0; 217 218 // add in the desired components for this coordinate 219 if (mode & PM_MODEL_OP_FUNC) { 220 pixelValue += modelFunc (NULL, params, x); 221 } 209 222 210 223 // get the contribution from the residual model 211 // XXX for a test, do this for all sources and all pixels212 224 if (Ro) { 213 225 // fractional image position 214 // this is wrong for the 'center' case 215 float ox = xBin*(ix + 0.5 + image->col0 - xCenter) + xResidCenter; 216 float oy = yBin*(iy + 0.5 + image->row0 - yCenter) + yResidCenter; 217 218 psU8 mflux = 0; 219 double Fo = 0.0; 220 double Fx = 0.0; 221 double Fy = 0.0; 222 psImageInterpolate (&Fo, NULL, &mflux, ox, oy, Ro); 223 psImageInterpolate (&Fx, NULL, &mflux, ox, oy, Rx); 224 psImageInterpolate (&Fy, NULL, &mflux, ox, oy, Ry); 225 226 if (!mflux && isfinite(Fo) && isfinite(Fx) && isfinite(Fy)) { 227 double flux = Fo + xCenter*Fx + yCenter*Fy; 228 pixelValue += Io*flux; 226 float ox = xBin*(imageCol + 0.5 - xCenter) + xResidCenter; 227 float oy = yBin*(imageRow + 0.5 - yCenter) + yResidCenter; 228 229 if (mode & PM_MODEL_OP_RES0) { 230 psU8 mflux = 0; 231 double Fo = 0.0; 232 psImageInterpolate (&Fo, NULL, &mflux, ox, oy, Ro); 233 if (!mflux && isfinite(Fo)) { 234 pixelValue += Io*Fo; 235 } 236 } 237 if (mode & PM_MODEL_OP_RES1) { 238 psU8 mflux = 0; 239 double Fx = 0.0; 240 double Fy = 0.0; 241 psImageInterpolate (&Fx, NULL, &mflux, ox, oy, Rx); 242 psImageInterpolate (&Fy, NULL, &mflux, ox, oy, Ry); 243 if (!mflux && isfinite(Fx) && isfinite(Fy)) { 244 pixelValue += Io*(xPos*Fx + yPos*Fy); 245 } 229 246 } 230 247 } … … 238 255 } 239 256 } 257 258 // restore original values 259 params->data.F32[PM_PAR_I0] = IoSave; 260 params->data.F32[PM_PAR_SKY] = skySave; 261 params->data.F32[PM_PAR_XPOS] = xPos; 262 params->data.F32[PM_PAR_YPOS] = yPos; 263 240 264 psFree(x); 241 265 psFree(Ro); … … 251 275 psImage *mask, 252 276 pmModel *model, 253 bool center, 254 bool sky) 255 { 256 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 257 psBool rc = AddOrSubModel(image, mask, model, center, sky, true); 277 pmModelOpMode mode) 278 { 279 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 280 psBool rc = AddOrSubModel(image, mask, model, mode, true); 258 281 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 259 282 return(rc); … … 265 288 psImage *mask, 266 289 pmModel *model, 267 bool center, 268 bool sky) 269 { 270 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 271 psBool rc = AddOrSubModel(image, mask, model, center, sky, false); 290 pmModelOpMode mode) 291 { 292 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 293 psBool rc = AddOrSubModel(image, mask, model, mode, false); 272 294 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 273 295 return(rc);
Note:
See TracChangeset
for help on using the changeset viewer.
