Changeset 35768 for trunk/psModules/src/objects/models
- Timestamp:
- Jul 3, 2013, 2:37:22 PM (13 years ago)
- Location:
- trunk/psModules
- Files:
-
- 10 edited
-
. (modified) (1 prop)
-
src/objects/models/pmModel_DEV.c (modified) (9 diffs)
-
src/objects/models/pmModel_EXP.c (modified) (8 diffs)
-
src/objects/models/pmModel_GAUSS.c (modified) (7 diffs)
-
src/objects/models/pmModel_PGAUSS.c (modified) (7 diffs)
-
src/objects/models/pmModel_PS1_V1.c (modified) (8 diffs)
-
src/objects/models/pmModel_QGAUSS.c (modified) (12 diffs)
-
src/objects/models/pmModel_RGAUSS.c (modified) (7 diffs)
-
src/objects/models/pmModel_SERSIC.c (modified) (9 diffs)
-
src/objects/models/pmModel_TRAIL.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20130509/psModules (added) merged: 35594,35613,35628,35638-35639,35643-35648,35653,35657,35662,35750
- Property svn:mergeinfo changed
-
trunk/psModules/src/objects/models/pmModel_DEV.c
r35560 r35768 123 123 124 124 // first, use Rmajor and index to find the central pixel flux (fraction of total flux) 125 psEllipseShape shape; 126 127 shape.sx = PAR[PM_PAR_SXX]; 128 shape.sy = PAR[PM_PAR_SYY]; 129 shape.sxy = PAR[PM_PAR_SXY]; 130 131 // for a non-circular Sersic, the flux of the Rmajor equivalent is scaled by the AspectRatio 132 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 125 psEllipseAxes axes; 126 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 133 127 134 128 // get the central pixel flux from the lookup table … … 238 232 // if q1 < 0.0, f2 ~ f1, we have a very large axis ratio near 45deg.. Saturate at that 239 233 // angle and let f2,f1 fight it out 240 q2 = 0.5*sqrtf(q1); 234 // NOTE: the factor of 2 is needed to convert par[SXX,SYY] to shape.sx,sy 235 q2 = 2.0*0.5*sqrtf(q1); 241 236 } 242 237 … … 303 298 304 299 // set the shape parameters 305 // XXX adjust this? 306 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments)) { 300 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, true)) { 307 301 return false; 308 302 } … … 330 324 psF64 PM_MODEL_FLUX (const psVector *params) 331 325 { 332 psEllipseShape shape;333 334 326 psF32 *PAR = params->data.F32; 335 327 336 shape.sx = PAR[PM_PAR_SXX]; 337 shape.sy = PAR[PM_PAR_SYY]; 338 shape.sxy = PAR[PM_PAR_SXY]; 339 340 // for a non-circular DeVaucouleur, the flux of the Rmajor equivalent is scaled by the AspectRatio 341 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 328 psEllipseAxes axes; 329 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 342 330 float AspectRatio = axes.minor / axes.major; 343 331 … … 359 347 psF64 PM_MODEL_RADIUS (const psVector *params, psF64 flux) 360 348 { 361 psEllipseShape shape;362 363 349 psF32 *PAR = params->data.F32; 364 350 … … 370 356 return (1.0); 371 357 372 shape.sx = PAR[PM_PAR_SXX]; 373 shape.sy = PAR[PM_PAR_SYY]; 374 shape.sxy = PAR[PM_PAR_SXY]; 375 376 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 358 psEllipseAxes axes; 359 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 377 360 378 361 // f = Io exp(-z^n) -> z^n = ln(Io/f) … … 382 365 psAssert (isfinite(radius), "fix this code: radius should not be nan for Io = %f, flux = %f, major = %f (%f, %f, %f)", 383 366 PAR[PM_PAR_I0], flux, axes.major, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY]); 384 385 367 return (radius); 386 368 } … … 407 389 // the 2D PSF model fits polarization terms (E0,E1,E2) 408 390 // convert to shape terms (SXX,SYY,SXY) 409 if (!pmPSF_FitToModel (out, 0.1)) { 391 bool useReff = pmModelUseReff (modelPSF->type); 392 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 410 393 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); 411 394 return false; … … 460 443 // convert to shape terms (SXX,SYY,SXY) 461 444 // XXX user-defined value for limit? 462 if (!pmPSF_FitToModel (PAR, 0.1)) { 445 bool useReff = pmModelUseReff (model->type); 446 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 463 447 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); 464 448 return false; -
trunk/psModules/src/objects/models/pmModel_EXP.c
r35560 r35768 115 115 116 116 // first, use Rmajor and index to find the central pixel flux (fraction of total flux) 117 psEllipseShape shape; 118 119 shape.sx = PAR[PM_PAR_SXX]; 120 shape.sy = PAR[PM_PAR_SYY]; 121 shape.sxy = PAR[PM_PAR_SXY]; 122 123 // for a non-circular Sersic, the flux of the Rmajor equivalent is scaled by the AspectRatio 124 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 117 psEllipseAxes axes; 118 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 125 119 126 120 // get the central pixel flux from the lookup table … … 230 224 // if q1 < 0.0, f2 ~ f1, we have a very large axis ratio near 45deg.. Saturate at that 231 225 // angle and let f2,f1 fight it out 232 q2 = 0.5*sqrtf(q1); 226 // NOTE: the factor of 2 is needed to convert par[SXX,SYY] to shape.sx,sy 227 q2 = 2.0*0.5*sqrtf(q1); 233 228 } 234 229 … … 295 290 296 291 // set the shape parameters 297 // XXX adjust this? 298 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments)) { 292 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, true)) { 299 293 return false; 300 294 } … … 316 310 psF64 PM_MODEL_FLUX (const psVector *params) 317 311 { 318 psEllipseShape shape;319 320 312 psF32 *PAR = params->data.F32; 321 313 322 shape.sx = PAR[PM_PAR_SXX]; 323 shape.sy = PAR[PM_PAR_SYY]; 324 shape.sxy = PAR[PM_PAR_SXY]; 325 326 // for a non-circular Exponential, the flux of the Rmajor equivalent is scaled by the AspectRatio 327 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 314 psEllipseAxes axes; 315 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 328 316 float AspectRatio = axes.minor / axes.major; 329 317 … … 345 333 psF64 PM_MODEL_RADIUS (const psVector *params, psF64 flux) 346 334 { 347 psEllipseShape shape;348 349 335 psF32 *PAR = params->data.F32; 350 336 … … 356 342 return (1.0); 357 343 358 shape.sx = PAR[PM_PAR_SXX]; 359 shape.sy = PAR[PM_PAR_SYY]; 360 shape.sxy = PAR[PM_PAR_SXY]; 361 362 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 344 psEllipseAxes axes; 345 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 363 346 364 347 // f = Io exp(-sqrt(z)) -> sqrt(z) = ln(Io/f) … … 392 375 // the 2D PSF model fits polarization terms (E0,E1,E2) 393 376 // convert to shape terms (SXX,SYY,SXY) 394 if (!pmPSF_FitToModel (out, 0.1)) { 377 bool useReff = pmModelUseReff (modelPSF->type); 378 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 395 379 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); 396 380 return false; … … 445 429 // convert to shape terms (SXX,SYY,SXY) 446 430 // XXX user-defined value for limit? 447 if (!pmPSF_FitToModel (PAR, 0.1)) { 431 bool useReff = pmModelUseReff (model->type); 432 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 448 433 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); 449 434 return false; -
trunk/psModules/src/objects/models/pmModel_GAUSS.c
r35560 r35768 129 129 float q2 = NAN; 130 130 if (nParam == PM_PAR_SXY) { 131 float f1 = 1.0 / PS_SQR(params[PM_PAR_SYY]) + 1.0 / PS_SQR(params[PM_PAR_SXX]); 132 float f2 = 1.0 / PS_SQR(params[PM_PAR_SYY]) - 1.0 / PS_SQR(params[PM_PAR_SXX]); 131 // NOTE: the factor of 2 is needed to convert par[SXX,SYY] to shape.sx,sy 132 float f1 = 2.0 / PS_SQR(params[PM_PAR_SYY]) + 2.0 / PS_SQR(params[PM_PAR_SXX]); 133 float f2 = 2.0 / PS_SQR(params[PM_PAR_SYY]) - 2.0 / PS_SQR(params[PM_PAR_SXX]); 133 134 float q1 = PS_SQR(f1)*AR_RATIO - PS_SQR(f2); 134 135 q1 = (q1 < 0.0) ? 0.0 : q1; … … 200 201 201 202 // set the shape parameters 202 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments )) {203 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) { 203 204 return false; 204 205 } … … 219 220 psF64 PM_MODEL_FLUX (const psVector *params) 220 221 { 221 222 psEllipseShape shape;223 224 222 psF32 *PAR = params->data.F32; 225 223 226 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; 227 shape.sy = PAR[PM_PAR_SYY] / M_SQRT2; 228 shape.sxy = PAR[PM_PAR_SXY]; 224 psEllipseAxes axes; 225 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false); 229 226 230 227 // Area is equivalent to 2 pi sigma^2 231 // axes ratio < 20232 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);233 228 psF64 Area = 2.0 * M_PI * axes.major * axes.minor; 234 229 … … 242 237 psF64 PM_MODEL_RADIUS (const psVector *params, psF64 flux) 243 238 { 244 psEllipseShape shape;245 246 239 psF32 *PAR = params->data.F32; 247 240 … … 253 246 return (1.0); 254 247 255 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; 256 shape.sy = PAR[PM_PAR_SYY] / M_SQRT2; 257 shape.sxy = PAR[PM_PAR_SXY]; 258 259 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 248 psEllipseAxes axes; 249 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false); 250 260 251 psF64 radius = axes.major * sqrt (2.0 * log(PAR[PM_PAR_I0] / flux)); 261 252 psAssert (isfinite(radius), "fix this code: radius should not be nan for Io = %f, flux = %f, major = %f (%f, %f, %f)", … … 285 276 } 286 277 287 // the OLD 2D model for SXY actually fitted SXY / (SXX^-2 + SYY^-2); correct here288 // out[PM_PAR_SXY] = pmPSF_SXYtoModel (out);289 290 278 // the 2D PSF model fits polarization terms (E0,E1,E2) 291 279 // convert to shape terms (SXX,SYY,SXY) 292 // XXX user-defined value for limit? 293 if (!pmPSF_FitToModel (out, 0.1)) { 294 // psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); 280 bool useReff = pmModelUseReff (modelPSF->type); 281 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 295 282 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); 296 283 return false; … … 343 330 // the 2D PSF model fits polarization terms (E0,E1,E2) 344 331 // convert to shape terms (SXX,SYY,SXY) 345 // XXX user-defined value for limit?346 if (!pmPSF_FitToModel (PAR, 0.1 )) {332 bool useReff = pmModelUseReff (model->type); 333 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 347 334 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); 348 335 return false; -
trunk/psModules/src/objects/models/pmModel_PGAUSS.c
r35560 r35768 129 129 float q2 = NAN; 130 130 if (nParam == PM_PAR_SXY) { 131 float f1 = 1.0 / PS_SQR(params[PM_PAR_SYY]) + 1.0 / PS_SQR(params[PM_PAR_SXX]); 132 float f2 = 1.0 / PS_SQR(params[PM_PAR_SYY]) - 1.0 / PS_SQR(params[PM_PAR_SXX]); 131 // NOTE: the factor of 2 is needed to convert par[SXX,SYY] to shape.sx,sy 132 float f1 = 2.0 / PS_SQR(params[PM_PAR_SYY]) + 2.0 / PS_SQR(params[PM_PAR_SXX]); 133 float f2 = 2.0 / PS_SQR(params[PM_PAR_SYY]) - 2.0 / PS_SQR(params[PM_PAR_SXX]); 133 134 float q1 = PS_SQR(f1)*AR_RATIO - PS_SQR(f2); 134 135 q1 = (q1 < 0.0) ? 0.0 : q1; … … 201 202 202 203 // set the shape parameters 203 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments )) {204 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) { 204 205 return false; 205 206 } … … 222 223 { 223 224 float z, norm; 224 psEllipseShape shape;225 225 226 226 psF32 *PAR = params->data.F32; 227 227 228 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; 229 shape.sy = PAR[PM_PAR_SYY] / M_SQRT2; 230 shape.sxy = PAR[PM_PAR_SXY]; 231 232 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 228 psEllipseAxes axes; 229 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false); 230 233 231 float AspectRatio = axes.minor / axes.major; 234 232 … … 262 260 { 263 261 psF64 z; 264 psEllipseShape shape;265 262 266 263 psF32 *PAR = params->data.F32; … … 273 270 return (1.0); 274 271 275 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; 276 shape.sy = PAR[PM_PAR_SYY] / M_SQRT2; 277 shape.sxy = PAR[PM_PAR_SXY]; 278 279 // this estimates the radius assuming f(z) is roughly exp(-z) 280 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 272 psEllipseAxes axes; 273 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false); 274 281 275 psF64 sigma = axes.major; 282 276 … … 347 341 } 348 342 349 // the OLD 2D model for SXY actually fitted SXY / (SXX^-2 + SYY^-2); correct here350 // out[PM_PAR_SXY] = pmPSF_SXYtoModel (out);351 352 343 // the 2D PSF model fits polarization terms (E0,E1,E2) 353 344 // convert to shape terms (SXX,SYY,SXY) 354 if (!pmPSF_FitToModel (out, 0.1)) { 345 bool useReff = pmModelUseReff (modelPSF->type); 346 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 355 347 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); 356 348 return false; … … 403 395 // the 2D PSF model fits polarization terms (E0,E1,E2) 404 396 // convert to shape terms (SXX,SYY,SXY) 405 // XXX user-defined value for limit?406 if (!pmPSF_FitToModel (PAR, 0.1 )) {397 bool useReff = pmModelUseReff (model->type); 398 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 407 399 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); 408 400 return false; -
trunk/psModules/src/objects/models/pmModel_PS1_V1.c
r35560 r35768 1 1 /****************************************************************************** 2 * this file defines the PS1_V1 source shape model. Note that these model functions are loaded 3 * by pmModelClass.c using 'include', and thus need no 'include' statements of their own. The 4 * models use a psVector to represent the set of parameters, with the sequence used to specify 5 * the meaning of the parameter. The meaning of the parameters may thus vary depending on the 6 * specifics of the model. All models which are used as a PSF representations share a few 7 * parameters, for which # define names are listed in pmModel.h: 2 * this file defines the PS1_V1 source shape model. Note that these model functions are 3 * loaded by pmModelClass.c using 'include', and thus need no 'include' statements of 4 * their own. The models use a psVector to represent the set of parameters, with the 5 * sequence used to specify the meaning of the parameter. The meaning of the parameters 6 * may thus vary depending on the specifics of the model. All models which are used as a 7 * PSF representations share a few parameters, for which # define names are listed in 8 * pmModel.h: 8 9 9 10 power-law with fitted linear term … … 148 149 float q2 = NAN; 149 150 if (nParam == PM_PAR_SXY) { 150 float f1 = 1.0 / PS_SQR(params[PM_PAR_SYY]) + 1.0 / PS_SQR(params[PM_PAR_SXX]);151 float f2 = 1.0 / PS_SQR(params[PM_PAR_SYY]) - 1.0 / PS_SQR(params[PM_PAR_SXX]);151 float f1 = 2.0 / PS_SQR(params[PM_PAR_SYY]) + 2.0 / PS_SQR(params[PM_PAR_SXX]); 152 float f2 = 2.0 / PS_SQR(params[PM_PAR_SYY]) - 2.0 / PS_SQR(params[PM_PAR_SXX]); 152 153 float q1 = PS_SQR(f1)*AR_RATIO - PS_SQR(f2); 153 154 q1 = (q1 < 0.0) ? 0.0 : q1; … … 220 221 221 222 // set the shape parameters 222 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments )) {223 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) { 223 224 return false; 224 225 } … … 244 245 { 245 246 float z, norm; 246 psEllipseShape shape;247 247 248 248 psF32 *PAR = params->data.F32; 249 249 250 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; 251 shape.sy = PAR[PM_PAR_SYY] / M_SQRT2; 252 shape.sxy = PAR[PM_PAR_SXY]; 253 254 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 250 psEllipseAxes axes; 251 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false); 255 252 float AspectRatio = axes.minor / axes.major; 256 253 … … 284 281 { 285 282 psF64 z; 286 psEllipseShape shape;287 283 288 284 psF32 *PAR = params->data.F32; … … 292 288 if (flux >= PAR[PM_PAR_I0]) return 1.0; 293 289 294 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; 295 shape.sy = PAR[PM_PAR_SYY] / M_SQRT2; 296 shape.sxy = PAR[PM_PAR_SXY]; 297 298 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 290 psEllipseAxes axes; 291 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false); 299 292 psF64 sigma = axes.major; 300 293 … … 363 356 // the 2D PSF model fits polarization terms (E0,E1,E2) 364 357 // convert to shape terms (SXX,SYY,SXY) 365 if (!pmPSF_FitToModel (out, 0.1)) { 358 bool useReff = pmModelUseReff (modelPSF->type); 359 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 366 360 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); 367 361 return false; … … 416 410 // convert to shape terms (SXX,SYY,SXY) 417 411 // XXX user-defined value for limit? 418 if (!pmPSF_FitToModel (PAR, 0.1)) { 412 bool useReff = pmModelUseReff (model->type); 413 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 419 414 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); 420 415 return false; -
trunk/psModules/src/objects/models/pmModel_QGAUSS.c
r35560 r35768 1 1 /****************************************************************************** 2 * this file defines the QGAUSS source shape model (XXX need a better name!). Note that these 3 * model functions are loaded by pmModelClass.c using 'include', and thus need no 'include' 4 * statements of their own. The models use a psVector to represent the set of parameters, with 5 * the sequence used to specify the meaning of the parameter. The meaning of the parameters 6 * may thus vary depending on the specifics of the model. All models which are used a PSF 7 * representations share a few parameters, for which # define names are listed in pmModel.h: 2 * this file defines the QGAUSS source shape model. Note that these model functions are 3 * loaded by pmModelClass.c using 'include', and thus need no 'include' statements of 4 * their own. The models use a psVector to represent the set of parameters, with the 5 * sequence used to specify the meaning of the parameter. The meaning of the parameters 6 * may thus vary depending on the specifics of the model. All models which are used as a 7 * PSF representations share a few parameters, for which # define names are listed in 8 * pmModel.h: 8 9 9 10 power-law with fitted linear term … … 14 15 * PM_PAR_XPOS 2 - X center of object 15 16 * PM_PAR_YPOS 3 - Y center of object 16 * PM_PAR_SXX 4 - X^2 term of elliptical contour ( sqrt(2) / SigmaX)17 * PM_PAR_SYY 5 - Y^2 term of elliptical contour ( sqrt(2) / SigmaY)17 * PM_PAR_SXX 4 - X^2 term of elliptical contour (SigmaX / sqrt(2)) 18 * PM_PAR_SYY 5 - Y^2 term of elliptical contour (SigmaY / sqrt(2)) 18 19 * PM_PAR_SXY 6 - X*Y term of elliptical contour 19 20 * PM_PAR_7 7 - amplitude of the linear component (k) … … 138 139 # define AR_MAX 20.0 139 140 # define AR_RATIO 0.99 140 141 141 bool PM_MODEL_LIMITS (psMinConstraintMode mode, int nParam, float *params, float *beta) 142 142 { … … 149 149 float q2 = NAN; 150 150 if (nParam == PM_PAR_SXY) { 151 float f1 = 1.0 / PS_SQR(params[PM_PAR_SYY]) + 1.0 / PS_SQR(params[PM_PAR_SXX]); 152 float f2 = 1.0 / PS_SQR(params[PM_PAR_SYY]) - 1.0 / PS_SQR(params[PM_PAR_SXX]); 151 // NOTE: the factor of 2 is needed to convert par[SXX,SYY] to shape.sx,sy 152 float f1 = 2.0 / PS_SQR(params[PM_PAR_SYY]) + 2.0 / PS_SQR(params[PM_PAR_SXX]); 153 float f2 = 2.0 / PS_SQR(params[PM_PAR_SYY]) - 2.0 / PS_SQR(params[PM_PAR_SXX]); 153 154 float q1 = PS_SQR(f1)*AR_RATIO - PS_SQR(f2); 154 155 q1 = (q1 < 0.0) ? 0.0 : q1; … … 203 204 return true; 204 205 } 205 default:206 default: 206 207 psAbort("invalid choice for limits"); 207 208 } … … 221 222 222 223 // set the shape parameters 223 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments )) {224 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) { 224 225 return false; 225 226 } … … 245 246 { 246 247 float z, norm; 247 psEllipseShape shape;248 248 249 249 psF32 *PAR = params->data.F32; 250 250 251 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; 252 shape.sy = PAR[PM_PAR_SYY] / M_SQRT2; 253 shape.sxy = PAR[PM_PAR_SXY]; 254 255 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 251 psEllipseAxes axes; 252 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false); 256 253 float AspectRatio = axes.minor / axes.major; 257 254 … … 285 282 { 286 283 psF64 z; 287 psEllipseShape shape;288 284 289 285 psF32 *PAR = params->data.F32; … … 293 289 if (flux >= PAR[PM_PAR_I0]) return 1.0; 294 290 295 // if (PAR[PM_PAR_7] == 0.0) return powf(PAR[PM_PAR_I0] / flux - 1.0, 1.0 / ALPHA); 296 297 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; 298 shape.sy = PAR[PM_PAR_SYY] / M_SQRT2; 299 shape.sxy = PAR[PM_PAR_SXY]; 300 301 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 291 psEllipseAxes axes; 292 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false); 302 293 psF64 sigma = axes.major; 303 294 … … 307 298 return ( sigma * sqrt (2.0 * z) ); 308 299 } 309 310 300 psF64 limit = flux / PAR[PM_PAR_I0]; 311 301 … … 367 357 // the 2D PSF model fits polarization terms (E0,E1,E2) 368 358 // convert to shape terms (SXX,SYY,SXY) 369 if (!pmPSF_FitToModel (out, 0.1)) { 359 bool useReff = pmModelUseReff (modelPSF->type); 360 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 370 361 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); 371 362 return false; … … 424 415 // the 2D PSF model fits polarization terms (E0,E1,E2) 425 416 // convert to shape terms (SXX,SYY,SXY) 426 // XXX user-defined value for limit?427 if (!pmPSF_FitToModel (PAR, 0.1 )) {417 bool useReff = pmModelUseReff (model->type); 418 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 428 419 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); 429 420 return false; -
trunk/psModules/src/objects/models/pmModel_RGAUSS.c
r35560 r35768 138 138 float q2 = NAN; 139 139 if (nParam == PM_PAR_SXY) { 140 float f1 = 1.0 / PS_SQR(params[PM_PAR_SYY]) + 1.0 / PS_SQR(params[PM_PAR_SXX]); 141 float f2 = 1.0 / PS_SQR(params[PM_PAR_SYY]) - 1.0 / PS_SQR(params[PM_PAR_SXX]); 140 // NOTE: the factor of 2 is needed to convert par[SXX,SYY] to shape.sx,sy 141 float f1 = 2.0 / PS_SQR(params[PM_PAR_SYY]) + 2.0 / PS_SQR(params[PM_PAR_SXX]); 142 float f2 = 2.0 / PS_SQR(params[PM_PAR_SYY]) - 2.0 / PS_SQR(params[PM_PAR_SXX]); 142 143 float q1 = PS_SQR(f1)*AR_RATIO - PS_SQR(f2); 143 144 q1 = (q1 < 0.0) ? 0.0 : q1; … … 210 211 211 212 // set the shape parameters 212 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments )) {213 if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) { 213 214 return false; 214 215 } … … 234 235 { 235 236 float z, norm; 236 psEllipseShape shape;237 237 238 238 psF32 *PAR = params->data.F32; 239 239 240 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; 241 shape.sy = PAR[PM_PAR_SYY] / M_SQRT2; 242 shape.sxy = PAR[PM_PAR_SXY]; 243 244 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 240 psEllipseAxes axes; 241 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false); 245 242 float AspectRatio = axes.minor / axes.major; 246 243 … … 274 271 { 275 272 psF64 z; 276 psEllipseShape shape;277 273 278 274 psF32 *PAR = params->data.F32; … … 285 281 return (1.0); 286 282 287 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; 288 shape.sy = PAR[PM_PAR_SYY] / M_SQRT2; 289 shape.sxy = PAR[PM_PAR_SXY]; 290 291 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 283 psEllipseAxes axes; 284 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false); 292 285 psF64 sigma = axes.major; 293 286 … … 357 350 // the 2D PSF model fits polarization terms (E0,E1,E2) 358 351 // convert to shape terms (SXX,SYY,SXY) 359 if (!pmPSF_FitToModel (out, 0.1)) { 352 bool useReff = pmModelUseReff (modelPSF->type); 353 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 360 354 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); 361 355 return false; … … 409 403 // the 2D PSF model fits polarization terms (E0,E1,E2) 410 404 // convert to shape terms (SXX,SYY,SXY) 411 // XXX user-defined value for limit?412 if (!pmPSF_FitToModel (PAR, 0.1 )) {405 bool useReff = pmModelUseReff (model->type); 406 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 413 407 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); 414 408 return false; -
trunk/psModules/src/objects/models/pmModel_SERSIC.c
r35560 r35768 125 125 126 126 // first, use Rmajor and index to find the central pixel flux (fraction of total flux) 127 psEllipseShape shape; 128 129 shape.sx = PAR[PM_PAR_SXX]; 130 shape.sy = PAR[PM_PAR_SYY]; 131 shape.sxy = PAR[PM_PAR_SXY]; 132 133 // for a non-circular Sersic, the flux of the Rmajor equivalent is scaled by the AspectRatio 134 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 127 psEllipseAxes axes; 128 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 135 129 136 130 // get the central pixel flux from the lookup table … … 250 244 // if q1 < 0.0, f2 ~ f1, we have a very large axis ratio near 45deg.. Saturate at that 251 245 // angle and let f2,f1 fight it out 252 q2 = 0.5*sqrtf(q1); 246 // NOTE: the factor of 2 is needed to convert par[SXX,SYY] to shape.sx,sy 247 q2 = 2.0*0.5*sqrtf(q1); 253 248 } 254 249 … … 347 342 axes.major = Rmajor; 348 343 axes.minor = Rminor; 349 psEllipseShape shape = psEllipseAxesToShape (axes); 350 351 if (!isfinite(shape.sx)) return false; 352 if (!isfinite(shape.sy)) return false; 353 if (!isfinite(shape.sxy)) return false; 344 345 pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], axes, true); 354 346 355 347 float bn = 1.9992*index - 0.3271; … … 357 349 float Io = exp(0.5*bn); 358 350 359 float Sxx = PS_MAX(0.5, shape.sx);360 float Syy = PS_MAX(0.5, shape.sy);361 362 PAR[PM_PAR_SXX] = Sxx;363 PAR[PM_PAR_SYY] = Syy;364 PAR[PM_PAR_SXY] = shape.sxy;365 366 351 // set the model normalization (adjust for Sersic best guess) 367 352 if (!pmModelSetNorm(&PAR[PM_PAR_I0], source)) { … … 381 366 psF64 PM_MODEL_FLUX (const psVector *params) 382 367 { 383 psEllipseShape shape;384 385 368 psF32 *PAR = params->data.F32; 386 369 387 shape.sx = PAR[PM_PAR_SXX]; 388 shape.sy = PAR[PM_PAR_SYY]; 389 shape.sxy = PAR[PM_PAR_SXY]; 390 391 // for a non-circular Sersic, the flux of the Rmajor equivalent is scaled by the AspectRatio 392 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 370 psEllipseAxes axes; 371 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 393 372 float AspectRatio = axes.minor / axes.major; 394 373 … … 410 389 psF64 PM_MODEL_RADIUS (const psVector *params, psF64 flux) 411 390 { 412 psEllipseShape shape;413 414 391 psF32 *PAR = params->data.F32; 415 392 … … 421 398 return (1.0); 422 399 423 shape.sx = PAR[PM_PAR_SXX]; 424 shape.sy = PAR[PM_PAR_SYY]; 425 shape.sxy = PAR[PM_PAR_SXY]; 426 427 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 400 psEllipseAxes axes; 401 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 428 402 429 403 // f = Io exp(-z^n) -> z^n = ln(Io/f) … … 457 431 // the 2D PSF model fits polarization terms (E0,E1,E2) 458 432 // convert to shape terms (SXX,SYY,SXY) 459 if (!pmPSF_FitToModel (out, 0.1)) { 433 bool useReff = pmModelUseReff (modelPSF->type); 434 if (!pmPSF_FitToModel (out, 0.1, useReff)) { 460 435 psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]); 461 436 return false; … … 510 485 // convert to shape terms (SXX,SYY,SXY) 511 486 // XXX user-defined value for limit? 512 if (!pmPSF_FitToModel (PAR, 0.1)) { 487 bool useReff = pmModelUseReff (model->type); 488 if (!pmPSF_FitToModel (PAR, 0.1, useReff)) { 513 489 psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); 514 490 return false; -
trunk/psModules/src/objects/models/pmModel_TRAIL.c
r35577 r35768 350 350 PAR[PM_PAR_SKY] = 0.0; 351 351 352 // XXX test : modify the Io, SXX, SYY terms based on the psf SXX, SYY terms: 353 psEllipseShape psfShape; 354 psfShape.sx = source->modelPSF->params->data.F32[PM_PAR_SXX] / M_SQRT2; 355 psfShape.sxy = source->modelPSF->params->data.F32[PM_PAR_SXY]; 356 psfShape.sy = source->modelPSF->params->data.F32[PM_PAR_SYY] / M_SQRT2; 357 psEllipseAxes psfAxes = psEllipseShapeToAxes (psfShape, 20.0); 352 psF32 *psfPAR = source->modelPSF->params->data.F32; 353 bool useReff = pmModelUseReff (source->modelPSF->type); 354 355 psEllipseAxes psfAxes; 356 pmModelParamsToAxes (&psfAxes, psfPAR[PM_PAR_SXX], psfPAR[PM_PAR_SXY], psfPAR[PM_PAR_SYY], useReff); 358 357 359 358 psEllipseMoments emoments; … … 369 368 if (!isfinite(axes.theta)) return false; 370 369 371 float size = (axes.major > sqrt(source->moments->Mrf)) ? axes.major : sqrt(source->moments->Mrf); 372 // if (size > psfAxes.major) { size -= psfAxes.major; } 373 //else { size = psfAxes.major; } 370 float size = NAN; 371 if (!isfinite(source->moments->Mrf)) { 372 size = axes.major; 373 } else { 374 size = (axes.major > sqrt(source->moments->Mrf)) ? axes.major : sqrt(source->moments->Mrf); 375 } 374 376 375 377 float theta, peak;
Note:
See TracChangeset
for help on using the changeset viewer.
