Changeset 29004 for trunk/psModules/src/objects/models
- Timestamp:
- Aug 20, 2010, 1:14:11 PM (16 years ago)
- Location:
- trunk/psModules
- Files:
-
- 7 edited
- 4 copied
-
. (modified) (1 prop)
-
src/objects/models/pmModel_DEV.c (copied) (copied from branches/eam_branches/ipp-20100621/psModules/src/objects/models/pmModel_DEV.c )
-
src/objects/models/pmModel_DEV.h (copied) (copied from branches/eam_branches/ipp-20100621/psModules/src/objects/models/pmModel_DEV.h )
-
src/objects/models/pmModel_EXP.c (copied) (copied from branches/eam_branches/ipp-20100621/psModules/src/objects/models/pmModel_EXP.c )
-
src/objects/models/pmModel_EXP.h (copied) (copied from branches/eam_branches/ipp-20100621/psModules/src/objects/models/pmModel_EXP.h )
-
src/objects/models/pmModel_GAUSS.c (modified) (5 diffs)
-
src/objects/models/pmModel_PGAUSS.c (modified) (3 diffs)
-
src/objects/models/pmModel_PS1_V1.c (modified) (4 diffs)
-
src/objects/models/pmModel_QGAUSS.c (modified) (3 diffs)
-
src/objects/models/pmModel_RGAUSS.c (modified) (4 diffs)
-
src/objects/models/pmModel_SERSIC.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules
- Property svn:mergeinfo deleted
-
trunk/psModules/src/objects/models/pmModel_GAUSS.c
r26916 r29004 21 21 #include <stdio.h> 22 22 #include <pslib.h> 23 23 #include "pmHDU.h" 24 #include "pmFPA.h" 25 26 #include "pmTrend2D.h" 27 #include "pmResiduals.h" 28 #include "pmGrowthCurve.h" 29 #include "pmSpan.h" 30 #include "pmFootprintSpans.h" 31 #include "pmFootprint.h" 32 #include "pmPeaks.h" 24 33 #include "pmMoments.h" 25 #include "pmPeaks.h" 34 #include "pmModelFuncs.h" 35 #include "pmModel.h" 36 #include "pmModelUtils.h" 37 #include "pmModelClass.h" 38 #include "pmSourceMasks.h" 39 #include "pmSourceExtendedPars.h" 40 #include "pmSourceDiffStats.h" 26 41 #include "pmSource.h" 27 #include "pmModel.h" 42 #include "pmSourceFitModel.h" 43 #include "pmPSF.h" 44 #include "pmPSFtry.h" 45 #include "pmDetections.h" 46 28 47 #include "pmModel_GAUSS.h" 29 48 49 # define PM_MODEL_NPARAM 7 30 50 # define PM_MODEL_FUNC pmModelFunc_GAUSS 31 51 # define PM_MODEL_FLUX pmModelFlux_GAUSS … … 83 103 dPAR[PM_PAR_XPOS] = q*(2*px/PAR[PM_PAR_SXX] + Y*PAR[PM_PAR_SXY]); 84 104 dPAR[PM_PAR_YPOS] = q*(2*py/PAR[PM_PAR_SYY] + X*PAR[PM_PAR_SXY]); 105 85 106 // the extra factor of 2 below is needed to avoid excessive swings 86 107 dPAR[PM_PAR_SXX] = +4.0*q*px*px/PAR[PM_PAR_SXX]; … … 102 123 return true; 103 124 } 104 psAssert(nParam >= 0 && nParam < = PM_PAR_7, "Parameter index is out of bounds");125 psAssert(nParam >= 0 && nParam < PM_MODEL_NPARAM, "Parameter index is out of bounds"); 105 126 106 127 // we need to calculate the limits for SXY specially … … 347 368 // this test is invalid if the parameters are derived 348 369 // from the PSF model 370 // XXX how is this used? it prevents forced photometry from ever being 'successful' 349 371 bool PM_MODEL_FIT_STATUS (pmModel *model) 350 372 { … … 394 416 return; 395 417 } 396 397 # undef PM_MODEL_FUNC398 # undef PM_MODEL_FLUX399 # undef PM_MODEL_GUESS400 # undef PM_MODEL_LIMITS401 # undef PM_MODEL_RADIUS402 # undef PM_MODEL_FROM_PSF403 # undef PM_MODEL_PARAMS_FROM_PSF404 # undef PM_MODEL_FIT_STATUS405 # undef PM_MODEL_SET_LIMITS -
trunk/psModules/src/objects/models/pmModel_PGAUSS.c
r27565 r29004 21 21 #include <stdio.h> 22 22 #include <pslib.h> 23 23 #include "pmHDU.h" 24 #include "pmFPA.h" 25 26 #include "pmTrend2D.h" 27 #include "pmResiduals.h" 28 #include "pmGrowthCurve.h" 29 #include "pmSpan.h" 30 #include "pmFootprintSpans.h" 31 #include "pmFootprint.h" 32 #include "pmPeaks.h" 24 33 #include "pmMoments.h" 25 #include "pmPeaks.h" 34 #include "pmModelFuncs.h" 35 #include "pmModel.h" 36 #include "pmModelUtils.h" 37 #include "pmModelClass.h" 38 #include "pmSourceMasks.h" 39 #include "pmSourceExtendedPars.h" 40 #include "pmSourceDiffStats.h" 26 41 #include "pmSource.h" 27 #include "pmModel.h" 42 #include "pmSourceFitModel.h" 43 #include "pmPSF.h" 44 #include "pmPSFtry.h" 45 #include "pmDetections.h" 46 28 47 #include "pmModel_PGAUSS.h" 29 48 49 # define PM_MODEL_NPARAM 7 30 50 # define PM_MODEL_FUNC pmModelFunc_PGAUSS 31 51 # define PM_MODEL_FLUX pmModelFlux_PGAUSS … … 103 123 return true; 104 124 } 105 psAssert(nParam >= 0 && nParam < = PM_PAR_7, "Parameter index is out of bounds");125 psAssert(nParam >= 0 && nParam < PM_MODEL_NPARAM, "Parameter index is out of bounds"); 106 126 107 127 // we need to calculate the limits for SXY specially … … 448 468 return; 449 469 } 450 451 # undef PM_MODEL_FUNC452 # undef PM_MODEL_FLUX453 # undef PM_MODEL_GUESS454 # undef PM_MODEL_LIMITS455 # undef PM_MODEL_RADIUS456 # undef PM_MODEL_FROM_PSF457 # undef PM_MODEL_PARAMS_FROM_PSF458 # undef PM_MODEL_FIT_STATUS459 # undef PM_MODEL_SET_LIMITS -
trunk/psModules/src/objects/models/pmModel_PS1_V1.c
r27565 r29004 22 22 #include <stdio.h> 23 23 #include <pslib.h> 24 24 #include "pmHDU.h" 25 #include "pmFPA.h" 26 27 #include "pmTrend2D.h" 28 #include "pmResiduals.h" 29 #include "pmGrowthCurve.h" 30 #include "pmSpan.h" 31 #include "pmFootprintSpans.h" 32 #include "pmFootprint.h" 33 #include "pmPeaks.h" 25 34 #include "pmMoments.h" 26 #include "pmPeaks.h" 35 #include "pmModelFuncs.h" 36 #include "pmModel.h" 37 #include "pmModelUtils.h" 38 #include "pmModelClass.h" 39 #include "pmSourceMasks.h" 40 #include "pmSourceExtendedPars.h" 41 #include "pmSourceDiffStats.h" 27 42 #include "pmSource.h" 28 #include "pmModel.h" 43 #include "pmSourceFitModel.h" 44 #include "pmPSF.h" 45 #include "pmPSFtry.h" 46 #include "pmDetections.h" 47 29 48 #include "pmModel_PS1_V1.h" 30 49 50 # define PM_MODEL_NPARAM 8 31 51 # define PM_MODEL_FUNC pmModelFunc_PS1_V1 32 52 # define PM_MODEL_FLUX pmModelFlux_PS1_V1 … … 122 142 return true; 123 143 } 124 psAssert(nParam >= 0 && nParam < = PM_PAR_7, "Parameter index is out of bounds");144 psAssert(nParam >= 0 && nParam < PM_MODEL_NPARAM, "Parameter index is out of bounds"); 125 145 126 146 // we need to calculate the limits for SXY specially … … 222 242 PAR[PM_PAR_SYY] = PS_MAX(0.5, M_SQRT2*shape.sy); 223 243 PAR[PM_PAR_SXY] = shape.sxy; 224 PAR[PM_PAR_7] = 1.0;244 PAR[PM_PAR_7] = 0.5; 225 245 226 246 return(true); … … 468 488 return; 469 489 } 470 471 # undef PM_MODEL_FUNC472 # undef PM_MODEL_FLUX473 # undef PM_MODEL_GUESS474 # undef PM_MODEL_LIMITS475 # undef PM_MODEL_RADIUS476 # undef PM_MODEL_FROM_PSF477 # undef PM_MODEL_PARAMS_FROM_PSF478 # undef PM_MODEL_FIT_STATUS479 # undef PM_MODEL_SET_LIMITS480 # undef ALPHA481 # undef ALPHA_M -
trunk/psModules/src/objects/models/pmModel_QGAUSS.c
r27565 r29004 22 22 #include <stdio.h> 23 23 #include <pslib.h> 24 24 #include "pmHDU.h" 25 #include "pmFPA.h" 26 27 #include "pmTrend2D.h" 28 #include "pmResiduals.h" 29 #include "pmGrowthCurve.h" 30 #include "pmSpan.h" 31 #include "pmFootprintSpans.h" 32 #include "pmFootprint.h" 33 #include "pmPeaks.h" 25 34 #include "pmMoments.h" 26 #include "pmPeaks.h" 35 #include "pmModelFuncs.h" 36 #include "pmModel.h" 37 #include "pmModelUtils.h" 38 #include "pmModelClass.h" 39 #include "pmSourceMasks.h" 40 #include "pmSourceExtendedPars.h" 41 #include "pmSourceDiffStats.h" 27 42 #include "pmSource.h" 28 #include "pmModel.h" 43 #include "pmSourceFitModel.h" 44 #include "pmPSF.h" 45 #include "pmPSFtry.h" 46 #include "pmDetections.h" 47 29 48 #include "pmModel_QGAUSS.h" 30 49 50 # define PM_MODEL_NPARAM 8 31 51 # define PM_MODEL_FUNC pmModelFunc_QGAUSS 32 52 # define PM_MODEL_FLUX pmModelFlux_QGAUSS … … 123 143 return true; 124 144 } 125 psAssert(nParam >= 0 && nParam < = PM_PAR_7, "Parameter index is out of bounds");145 psAssert(nParam >= 0 && nParam < PM_MODEL_NPARAM, "Parameter index is out of bounds"); 126 146 127 147 // we need to calculate the limits for SXY specially … … 469 489 return; 470 490 } 471 472 # undef PM_MODEL_FUNC473 # undef PM_MODEL_FLUX474 # undef PM_MODEL_GUESS475 # undef PM_MODEL_LIMITS476 # undef PM_MODEL_RADIUS477 # undef PM_MODEL_FROM_PSF478 # undef PM_MODEL_PARAMS_FROM_PSF479 # undef PM_MODEL_FIT_STATUS480 # undef PM_MODEL_SET_LIMITS481 # undef ALPHA482 # undef ALPHA_M -
trunk/psModules/src/objects/models/pmModel_RGAUSS.c
r27565 r29004 22 22 #include <stdio.h> 23 23 #include <pslib.h> 24 24 #include "pmHDU.h" 25 #include "pmFPA.h" 26 27 #include "pmTrend2D.h" 28 #include "pmResiduals.h" 29 #include "pmGrowthCurve.h" 30 #include "pmSpan.h" 31 #include "pmFootprintSpans.h" 32 #include "pmFootprint.h" 33 #include "pmPeaks.h" 25 34 #include "pmMoments.h" 26 #include "pmPeaks.h" 35 #include "pmModelFuncs.h" 36 #include "pmModel.h" 37 #include "pmModelUtils.h" 38 #include "pmModelClass.h" 39 #include "pmSourceMasks.h" 40 #include "pmSourceExtendedPars.h" 41 #include "pmSourceDiffStats.h" 27 42 #include "pmSource.h" 28 #include "pmModel.h" 43 #include "pmSourceFitModel.h" 44 #include "pmPSF.h" 45 #include "pmPSFtry.h" 46 #include "pmDetections.h" 47 29 48 #include "pmModel_RGAUSS.h" 30 49 50 # define PM_MODEL_NPARAM 8 31 51 # define PM_MODEL_FUNC pmModelFunc_RGAUSS 32 52 # define PM_MODEL_FLUX pmModelFlux_RGAUSS … … 112 132 return true; 113 133 } 114 psAssert(nParam >= 0 && nParam < = PM_PAR_7, "Parameter index is out of bounds");134 psAssert(nParam >= 0 && nParam < PM_MODEL_NPARAM, "Parameter index is out of bounds"); 115 135 116 136 // we need to calculate the limits for SXY specially … … 209 229 PAR[PM_PAR_XPOS] = peak->xf; 210 230 PAR[PM_PAR_YPOS] = peak->yf; 211 PAR[PM_PAR_SXX] = PS_MAX(0.5, M_SQRT2*shape.sx);212 PAR[PM_PAR_SYY] = PS_MAX(0.5, M_SQRT2*shape.sy);231 PAR[PM_PAR_SXX] = PS_MAX(0.5, shape.sx); 232 PAR[PM_PAR_SYY] = PS_MAX(0.5, shape.sy); 213 233 PAR[PM_PAR_SXY] = shape.sxy; 214 PAR[PM_PAR_7] = 2.25;234 PAR[PM_PAR_7] = 1.5; 215 235 216 236 return(true); … … 463 483 return; 464 484 } 465 466 # undef PM_MODEL_FUNC467 # undef PM_MODEL_FLUX468 # undef PM_MODEL_GUESS469 # undef PM_MODEL_LIMITS470 # undef PM_MODEL_RADIUS471 # undef PM_MODEL_FROM_PSF472 # undef PM_MODEL_PARAMS_FROM_PSF473 # undef PM_MODEL_FIT_STATUS474 # undef PM_MODEL_SET_LIMITS -
trunk/psModules/src/objects/models/pmModel_SERSIC.c
r26916 r29004 18 18 * PM_PAR_7 7 - normalized sersic parameter 19 19 20 note that a standard sersic model uses exp(-K*(z^(1/ n) - 1). the additional elements (K,20 note that a standard sersic model uses exp(-K*(z^(1/2n) - 1). the additional elements (K, 21 21 the -1 offset) are absorbed in this model by the normalization, the exponent, and the 22 22 radial scale. We fit the elements in this form, then re-normalize them on output. … … 25 25 #include <stdio.h> 26 26 #include <pslib.h> 27 27 #include "pmHDU.h" 28 #include "pmFPA.h" 29 30 #include "pmTrend2D.h" 31 #include "pmResiduals.h" 32 #include "pmGrowthCurve.h" 33 #include "pmSpan.h" 34 #include "pmFootprintSpans.h" 35 #include "pmFootprint.h" 36 #include "pmPeaks.h" 28 37 #include "pmMoments.h" 29 #include "pmPeaks.h" 38 #include "pmModelFuncs.h" 39 #include "pmModel.h" 40 #include "pmModelUtils.h" 41 #include "pmModelClass.h" 42 #include "pmSourceMasks.h" 43 #include "pmSourceExtendedPars.h" 44 #include "pmSourceDiffStats.h" 30 45 #include "pmSource.h" 31 #include "pmModel.h" 46 #include "pmSourceFitModel.h" 47 #include "pmPSF.h" 48 #include "pmPSFtry.h" 49 #include "pmDetections.h" 50 32 51 #include "pmModel_SERSIC.h" 33 52 53 # define PM_MODEL_NPARAM 8 34 54 # define PM_MODEL_FUNC pmModelFunc_SERSIC 35 55 # define PM_MODEL_FLUX pmModelFlux_SERSIC … … 47 67 48 68 // Lax parameter limits 49 static float paramsMinLax[] = { -1.0e3, 1.0e-2, -100, -100, 0.0 5, 0.05, -1.0, 0.05 };69 static float paramsMinLax[] = { -1.0e3, 1.0e-2, -100, -100, 0.001, 0.001, -1.0, 0.05 }; 50 70 static float paramsMaxLax[] = { 1.0e5, 1.0e8, 1.0e4, 1.0e4, 100, 100, 1.0, 4.0 }; 51 71 … … 84 104 assert (z >= 0); 85 105 86 psF32 f2 = pow(z,PAR[PM_PAR_7]); 87 psF32 f1 = exp(-f2); 106 float index = 0.5 / PAR[PM_PAR_7]; 107 float bn = 1.9992*index - 0.3271; 108 float Io = exp(bn); 109 110 psF32 f2 = bn*pow(z,PAR[PM_PAR_7]); 111 psF32 f1 = Io*exp(-f2); 88 112 psF32 z0 = PAR[PM_PAR_I0]*f1; 89 113 psF32 f0 = PAR[PM_PAR_SKY] + z0; … … 98 122 99 123 // gradient is infinite for z = 0; saturate at z = 0.01 100 psF32 z1 = (z < 0.01) ? z0* PAR[PM_PAR_7]*pow(0.01,PAR[PM_PAR_7] - 1.0) : z0*PAR[PM_PAR_7]*pow(z,PAR[PM_PAR_7] - 1.0);124 psF32 z1 = (z < 0.01) ? z0*bn*PAR[PM_PAR_7]*pow(0.01,PAR[PM_PAR_7] - 1.0) : z0*bn*PAR[PM_PAR_7]*pow(z,PAR[PM_PAR_7] - 1.0); 101 125 102 126 dPAR[PM_PAR_SKY] = +1.0; 103 127 dPAR[PM_PAR_I0] = +f1; 104 dPAR[PM_PAR_7] = (z == 0.0) ? 0.0 : -z0*f2*log(z); 128 dPAR[PM_PAR_7] = (z < 0.01) ? -z0*pow(0.01,PAR[PM_PAR_7])*log(0.01) : -z0*f2*log(z); 129 dPAR[PM_PAR_7] *= 3.0; 105 130 106 131 assert (isfinite(z1)); … … 109 134 dPAR[PM_PAR_XPOS] = +1.0*z1*(2.0*px/PAR[PM_PAR_SXX] + Y*PAR[PM_PAR_SXY]); 110 135 dPAR[PM_PAR_YPOS] = +1.0*z1*(2.0*py/PAR[PM_PAR_SYY] + X*PAR[PM_PAR_SXY]); 111 dPAR[PM_PAR_SXX] = +2.0*z1*px*px/PAR[PM_PAR_SXX]; 136 dPAR[PM_PAR_SXX] = +2.0*z1*px*px/PAR[PM_PAR_SXX]; // XXX : increase drag? 112 137 dPAR[PM_PAR_SYY] = +2.0*z1*py*py/PAR[PM_PAR_SYY]; 113 dPAR[PM_PAR_SXY] = -1.0*z1*X*Y;114 138 dPAR[PM_PAR_SXY] = -1.0*z1*X*Y; 115 139 } … … 127 151 return true; 128 152 } 129 psAssert(nParam >= 0 && nParam < = PM_PAR_7, "Parameter index is out of bounds");153 psAssert(nParam >= 0 && nParam < PM_MODEL_NPARAM, "Parameter index is out of bounds"); 130 154 131 155 // we need to calculate the limits for SXY specially … … 201 225 psF32 *PAR = model->params->data.F32; 202 226 227 // the other parameters depend on the guess for PAR_7 228 if (!isfinite(PAR[PM_PAR_7])) { 229 PAR[PM_PAR_7] = 0.25; 230 } 231 float index = 0.5 / PAR[PM_PAR_7]; 232 233 // the scale-length is a function of the moments and the index: 234 // Rmajor_guess = Rmajor_moments * Scale * Zero 235 float Scale = 0.70 + 0.053 * PAR[PM_PAR_7]; 236 float Zero = 1.16 - 0.615 * PAR[PM_PAR_7]; 237 203 238 psEllipseMoments emoments; 204 239 emoments.x2 = moments->Mxx; … … 213 248 if (!isfinite(axes.theta)) return false; 214 249 250 // set a lower limit to avoid absurd solutions.. 251 float Rmajor = PS_MAX(1.0, Scale * axes.major + Zero); 252 float Rminor = Rmajor * (axes.minor / axes.major); 253 254 fprintf (stderr, "guess index: %f : %f, %f -> %f, %f\n", index, axes.major, axes.minor, Rmajor, Rminor); 255 256 axes.major = Rmajor; 257 axes.minor = Rminor; 215 258 psEllipseShape shape = psEllipseAxesToShape (axes); 216 259 … … 219 262 if (!isfinite(shape.sxy)) return false; 220 263 264 float bn = 1.9992*index - 0.3271; 265 // float fR = 1.0 / (sqrt(2.0) * pow (bn, index)); 266 float Io = exp(0.5*bn); 267 268 // XXX do we need this factor of sqrt(2)? 269 // float Sxx = PS_MAX(0.5, M_SQRT2*shape.sx); 270 // float Syy = PS_MAX(0.5, M_SQRT2*shape.sy); 271 272 float Sxx = PS_MAX(0.5, shape.sx); 273 float Syy = PS_MAX(0.5, shape.sy); 274 221 275 PAR[PM_PAR_SKY] = 0.0; 222 PAR[PM_PAR_I0] = peak->flux ;276 PAR[PM_PAR_I0] = peak->flux / Io; 223 277 PAR[PM_PAR_XPOS] = peak->xf; 224 278 PAR[PM_PAR_YPOS] = peak->yf; 225 PAR[PM_PAR_SXX] = PS_MAX(0.5, M_SQRT2*shape.sx);226 PAR[PM_PAR_SYY] = PS_MAX(0.5, M_SQRT2*shape.sy);279 PAR[PM_PAR_SXX] = Sxx; 280 PAR[PM_PAR_SYY] = Syy; 227 281 PAR[PM_PAR_SXY] = shape.sxy; 228 PAR[PM_PAR_7] = 0.5;229 282 230 283 return(true); … … 254 307 float f1, f2; 255 308 for (z = DZ; z < 50; z += DZ) { 256 f1 = 1.0 / (1 + PAR[PM_PAR_7]*z + pow(z, 2.25)); 309 // f1 = 1.0 / (1 + PAR[PM_PAR_7]*z + pow(z, 2.25)); 310 f1 = exp(-pow(z,PAR[PM_PAR_7])); 257 311 z += DZ; 258 f2 = 1.0 / (1 + PAR[PM_PAR_7]*z + pow(z, 2.25));312 f2 = exp(-pow(z,PAR[PM_PAR_7])); 259 313 norm += f0 + 4*f1 + f2; 260 314 f0 = f2; … … 287 341 288 342 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 289 psF64 sigma = axes.major; 290 291 psF64 limit = flux / PAR[PM_PAR_I0]; 292 293 psF64 z = pow (-log(limit), (1.0 / PAR[PM_PAR_7])); 294 psAssert (isfinite(z), "fix this code: z should not be nan for %f", PAR[PM_PAR_7]); 295 296 psF64 radius = sigma * sqrt (2.0 * z); 297 psAssert (isfinite(radius), "fix this code: radius should not be nan for %f, %f", PAR[PM_PAR_7], sigma); 298 299 if (isnan(radius)) 300 psAbort("error in code: radius is NaN"); 301 343 344 // f = Io exp(-z^n) -> z^n = ln(Io/f) 345 psF64 zn = log(PAR[PM_PAR_I0] / flux); 346 psF64 radius = axes.major * sqrt (2.0) * pow(zn, 0.5 / PAR[PM_PAR_7]); 347 348 fprintf (stderr, "sersic model %f %f, n %f, radius: %f, zn: %f, f/Io: %f, major: %f\n", PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], PAR[PM_PAR_7], radius, zn, flux/PAR[PM_PAR_I0], axes.major); 349 350 psAssert (isfinite(radius), "fix this code: z should not be nan for %f", PAR[PM_PAR_7]); 302 351 return (radius); 303 352 } … … 448 497 return; 449 498 } 450 451 # undef PM_MODEL_FUNC452 # undef PM_MODEL_FLUX453 # undef PM_MODEL_GUESS454 # undef PM_MODEL_LIMITS455 # undef PM_MODEL_RADIUS456 # undef PM_MODEL_FROM_PSF457 # undef PM_MODEL_PARAMS_FROM_PSF458 # undef PM_MODEL_FIT_STATUS459 # undef PM_MODEL_SET_LIMITS
Note:
See TracChangeset
for help on using the changeset viewer.
