Changeset 14544
- Timestamp:
- Aug 17, 2007, 11:01:59 AM (19 years ago)
- Location:
- branches/eam_branch_20070817/psModules
- Files:
-
- 5 added
- 29 edited
-
src/astrom/pmAstrometryObjects.c (modified) (3 diffs)
-
src/astrom/pmAstrometryObjects.h (modified) (2 diffs)
-
src/objects/Makefile.am (modified) (3 diffs)
-
src/objects/models/pmModel_GAUSS.c (modified) (5 diffs)
-
src/objects/pmModel.c (modified) (14 diffs)
-
src/objects/pmModel.h (modified) (5 diffs)
-
src/objects/pmModelClass.c (added)
-
src/objects/pmModelClass.h (added)
-
src/objects/pmModelGroup.c (modified) (3 diffs)
-
src/objects/pmModelGroup.h (modified) (4 diffs)
-
src/objects/pmModelUtils.c (modified) (2 diffs)
-
src/objects/pmModelUtils.h (added)
-
src/objects/pmPSF.c (modified) (5 diffs)
-
src/objects/pmPSF_IO.c (modified) (8 diffs)
-
src/objects/pmPSFtry.c (modified) (3 diffs)
-
src/objects/pmPeaks.c (modified) (14 diffs)
-
src/objects/pmPeaks.h (modified) (5 diffs)
-
src/objects/pmSource.c (modified) (3 diffs)
-
src/objects/pmSource.h (modified) (2 diffs)
-
src/objects/pmSourceFitModel.c (modified) (9 diffs)
-
src/objects/pmSourceIO.c (modified) (2 diffs)
-
src/objects/pmSourceIO_CMP.c (modified) (3 diffs)
-
src/objects/pmSourceIO_OBJ.c (modified) (2 diffs)
-
src/objects/pmSourceIO_PS1_DEV_0.c (modified) (3 diffs)
-
src/objects/pmSourceIO_RAW.c (modified) (2 diffs)
-
src/objects/pmSourceIO_SMPDATA.c (modified) (3 diffs)
-
src/objects/pmSourceIO_SX.c (modified) (2 diffs)
-
src/objects/pmSourcePhotometry.c (modified) (5 diffs)
-
src/objects/pmSourceUtils.c (added)
-
src/objects/pmSourceUtils.h (added)
-
src/psmodules.h (modified) (2 diffs)
-
test/objects/tap_pmSourceFitModel.c (modified) (1 diff)
-
test/objects/tap_pmSourceFitModel_Delta.c (modified) (2 diffs)
-
test/objects/tst_pmObjects01.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070817/psModules/src/astrom/pmAstrometryObjects.c
r13943 r14544 8 8 * @author EAM, IfA 9 9 * 10 * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $11 * @date $Date: 2007-0 6-22 00:40:01$10 * @version $Revision: 1.31.4.1 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2007-08-17 21:01:59 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 135 135 PS_ASSERT_PTR_NON_NULL(st2, NULL); \ 136 136 \ 137 assert(st1->n == 0 || pm IsAstromObj(st1->data[0])); \138 assert(st2->n == 0 || pm IsAstromObj(st2->data[0])); \137 assert(st1->n == 0 || pmAstromObjTest(st1->data[0])); \ 138 assert(st2->n == 0 || pmAstromObjTest(st2->data[0])); \ 139 139 \ 140 140 /* sort both lists by X coord; st1 first */ \ … … 400 400 } 401 401 402 bool pm IsAstromObj(const psPtr ptr)402 bool pmAstromObjTest(const psPtr ptr) 403 403 { 404 404 return (psMemGetDeallocator(ptr) == (psFreeFunc)astromObjFree); -
branches/eam_branch_20070817/psModules/src/astrom/pmAstrometryObjects.h
r11253 r14544 4 4 * @author EAM, IfA 5 5 * 6 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 1-24 02:54:14$6 * @version $Revision: 1.15.14.1 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-08-17 21:01:59 $ 8 8 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 9 9 */ … … 293 293 * Is a given pointer a pmAstromObj? 294 294 */ 295 bool pm IsAstromObj(const psPtr ptr);295 bool pmAstromObjTest(const psPtr ptr); 296 296 297 297 -
branches/eam_branch_20070817/psModules/src/objects/Makefile.am
r14472 r14544 7 7 pmMoments.c \ 8 8 pmModel.c \ 9 pmModelGroup.c \ 9 pmModelClass.c \ 10 pmModelUtils.c \ 10 11 pmSource.c \ 12 pmSourceUtils.c \ 11 13 pmSourceSky.c \ 12 14 pmSourceContour.c \ … … 31 33 32 34 EXTRA_DIST = \ 33 models/pmModel_GAUSS.c \34 models/pmModel_PGAUSS.c \35 models/pmModel_QGAUSS.c \36 models/pmModel_SGAUSS.c \37 models/pmModel_RGAUSS.c \38 models/pmModel_SERSIC.c35 models/pmModel_GAUSS.c \ 36 models/pmModel_PGAUSS.c \ 37 models/pmModel_QGAUSS.c \ 38 models/pmModel_SGAUSS.c \ 39 models/pmModel_RGAUSS.c \ 40 models/pmModel_SERSIC.c 39 41 40 42 pkginclude_HEADERS = \ … … 42 44 pmMoments.h \ 43 45 pmModel.h \ 44 pmModelGroup.h \ 46 pmModelClass.h \ 47 pmModelUtils.h \ 45 48 pmSource.h \ 49 pmSourceUtils.h \ 46 50 pmSourceSky.h \ 47 51 pmSourceContour.h \ -
branches/eam_branch_20070817/psModules/src/objects/models/pmModel_GAUSS.c
r14220 r14544 19 19 *****************************************************************************/ 20 20 21 # define PM_MODEL_FUNC pmModelFunc_GAUSS 22 # define PM_MODEL_FLUX pmModelFlux_GAUSS 23 # define PM_MODEL_GUESS pmModelGuess_GAUSS 24 # define PM_MODEL_LIMITS pmModelLimits_GAUSS 25 # define PM_MODEL_RADIUS pmModelRadius_GAUSS 26 # define PM_MODEL_FROM_PSF pmModelFromPSF_GAUSS 27 # define PM_MODEL_FIT_STATUS pmModelFitStatus_GAUSS 21 # define PM_MODEL_FUNC pmModelFunc_GAUSS 22 # define PM_MODEL_FLUX pmModelFlux_GAUSS 23 # define PM_MODEL_GUESS pmModelGuess_GAUSS 24 # define PM_MODEL_LIMITS pmModelLimits_GAUSS 25 # define PM_MODEL_RADIUS pmModelRadius_GAUSS 26 # define PM_MODEL_FROM_PSF pmModelFromPSF_GAUSS 27 # define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_GAUSS 28 # define PM_MODEL_FIT_STATUS pmModelFitStatus_GAUSS 28 29 29 30 psF32 PM_MODEL_FUNC(psVector *deriv, … … 185 186 186 187 // make an initial guess for parameters 187 bool PM_MODEL_GUESS (pmModel *model, pmSource *source) 188 { 188 bool PM_MODEL_GUESS (void *inModel, void *inSource) 189 { 190 pmModel *model = inModel; 191 pmSource *source = inSource; 192 189 193 pmMoments *moments = source->moments; 190 194 psF32 *PAR = model->params->data.F32; … … 255 259 256 260 // construct the PSF model from the FLT model and the psf 257 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf) 258 { 261 bool PM_MODEL_FROM_PSF (void *inModelPSF, void *inModelFLT, void *inPSF) 262 { 263 pmModel *modelPSF = inModelPSF; 264 pmModel *modelFLT = inModelFLT; 265 pmPSF *psf = inPSF; 259 266 260 267 psF32 *out = modelPSF->params->data.F32; … … 306 313 } 307 314 315 // construct the PSF model from the FLT model and the psf 316 // XXX is this sufficiently general do be a global function, not a pmModelClass function? 317 bool PM_MODEL_PARAMS_FROM_PSF (void *inModel, void *inPSF, float Xo, float Yo, float Io) 318 { 319 pmModel *model = inModel; 320 pmPSF *psf = inPSF; 321 322 psF32 *PAR = model->params->data.F32; 323 324 // we require these two parameters to exist 325 assert (psf->params_NEW->n > PM_PAR_YPOS); 326 assert (psf->params_NEW->n > PM_PAR_XPOS); 327 328 PAR[PM_PAR_SKY] = 0.0; 329 PAR[PM_PAR_I0] = Io; 330 PAR[PM_PAR_XPOS] = Xo; 331 PAR[PM_PAR_YPOS] = Yo; 332 333 // supply the model-fitted parameters, or copy from the input 334 for (int i = 0; i < psf->params_NEW->n; i++) { 335 if (i == PM_PAR_SKY) continue; 336 psPolynomial2D *poly = psf->params_NEW->data[i]; 337 assert (poly); 338 PAR[i] = psPolynomial2DEval(poly, Xo, Yo); 339 } 340 341 // the 2D PSF model fits polarization terms (E0,E1,E2) 342 // convert to shape terms (SXX,SYY,SXY) 343 // XXX user-defined value for limit? 344 if (!pmPSF_FitToModel (PAR, 0.1)) { 345 psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); 346 return false; 347 } 348 349 // apply the model limits here: this truncates excessive extrapolation 350 // XXX do we need to do this still? should we put in asserts to test? 351 for (int i = 0; i < psf->params_NEW->n; i++) { 352 // apply the limits to all components or just the psf-model parameters? 353 if (psf->params_NEW->data[i] == NULL) 354 continue; 355 356 bool status = true; 357 status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MIN, i, PAR, NULL); 358 status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MAX, i, PAR, NULL); 359 if (!status) { 360 psTrace ("psModules.objects", 5, "Hitting parameter limits at (r,c) = (%.1f, %.1f)", Xo, Yo); 361 model->flags |= PM_MODEL_STATUS_LIMITS; 362 } 363 } 364 return(true); 365 } 366 308 367 // check the status of the fitted model 309 368 // this test is invalid if the parameters are derived 310 369 // from the PSF model 311 bool PM_MODEL_FIT_STATUS (pmModel *model) 312 { 370 bool PM_MODEL_FIT_STATUS (void *inModel) 371 { 372 pmModel *model = inModel; 313 373 314 374 psF32 dP; … … 339 399 # undef PM_MODEL_RADIUS 340 400 # undef PM_MODEL_FROM_PSF 401 # undef PM_MODEL_PARAMS_FROM_PSF 341 402 # undef PM_MODEL_FIT_STATUS -
branches/eam_branch_20070817/psModules/src/objects/pmModel.c
r13898 r14544 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 6-20 02:22:26$8 * @version $Revision: 1.13.6.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-08-17 21:01:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 23 23 #include "pmResiduals.h" 24 24 #include "pmModel.h" 25 26 /* The following types and functions need to be known by pmModel.c and are defined in 27 pmModelGroup.h. The use of pmSource and other types in pmModelGroup.h prevent us from 28 directly including it here ***/ 29 30 typedef psMinimizeLMChi2Func pmModelFunc; 31 typedef bool (*pmModelFitStatusFunc)(pmModel *model); 32 pmModelFunc pmModelFunc_GetFunction (pmModelType type); 33 pmModelFitStatusFunc pmModelFitStatusFunc_GetFunction (pmModelType type); 34 int pmModelParameterCount(pmModelType type); 25 #include "pmModelClass.h" 35 26 36 27 static void modelFree(pmModel *tmp) … … 45 36 pmModelAlloc(): Allocate the pmModel structure, along with its parameters, 46 37 and initialize the type member. Initialize the params to 0.0. 47 XXX EAM: simplifying code with pmModelParameterCount48 38 *****************************************************************************/ 49 39 pmModel *pmModelAlloc(pmModelType type) … … 53 43 pmModel *tmp = (pmModel *) psAlloc(sizeof(pmModel)); 54 44 psMemSetDeallocator(tmp, (psFreeFunc) modelFree); 45 46 pmModelClass *class = pmModelClassSelect (type); 47 if (class == NULL) { 48 psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType"); 49 return(NULL); 50 } 55 51 56 52 tmp->type = type; … … 62 58 tmp->residuals = NULL; // XXX should the model own this memory? 63 59 64 psS32 Nparams = pmModelParameterCount(type); 65 if (Nparams == 0) { 66 psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType"); 67 return(NULL); 68 } 60 psS32 Nparams = pmModelClassParameterCount(type); 61 assert (Nparams); 69 62 70 63 tmp->params = psVectorAlloc(Nparams, PS_TYPE_F32); 71 64 tmp->dparams = psVectorAlloc(Nparams, PS_TYPE_F32); 65 assert (tmp->params); 66 assert (tmp->dparams); 72 67 73 68 for (psS32 i = 0; i < tmp->params->n; i++) { … … 75 70 tmp->dparams->data.F32[i] = 0.0; 76 71 } 72 73 tmp->modelFunc = class->modelFunc; 74 tmp->modelFlux = class->modelFlux; 75 tmp->modelRadius = class->modelRadius; 76 tmp->modelLimits = class->modelLimits; 77 tmp->modelGuess = class->modelGuess; 78 tmp->modelFromPSF = class->modelFromPSF; 79 tmp->modelParamsFromPSF = class->modelParamsFromPSF; 80 tmp->modelFitStatus = class->modelFitStatus; 77 81 78 82 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__); … … 92 96 new->radiusFit = model->radiusFit; 93 97 94 // XXX note that model->residuals is just a reference95 new->residuals = model->residuals;96 97 98 for (int i = 0; i < new->params->n; i++) { 98 99 new->params->data.F32[i] = model->params->data.F32[i]; 99 100 new->dparams->data.F32[i] = model->dparams->data.F32[i]; 100 101 } 102 103 // note that model->residuals is just a reference 104 new->residuals = model->residuals; 101 105 102 106 return (new); … … 123 127 x->data.F32[1] = (psF32) (row + image->row0); 124 128 psF32 tmpF; 125 pmModelFunc modelFunc; 126 127 modelFunc = pmModelFunc_GetFunction (model->type); 128 tmpF = modelFunc (NULL, model->params, x); 129 130 tmpF = model->modelFunc (NULL, model->params, x); 131 psFree(x); 132 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__); 133 return(tmpF); 134 } 135 136 psF32 pmModelEvalWithOffset(pmModel *model, psImage *image, psS32 col, psS32 row, int dx, int dy) 137 { 138 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 139 PS_ASSERT_PTR_NON_NULL(image, false); 140 PS_ASSERT_PTR_NON_NULL(model, false); 141 PS_ASSERT_PTR_NON_NULL(model->params, false); 142 143 // Allocate the x coordinate structure and convert row/col to image space. 144 // 145 psVector *x = psVectorAlloc(2, PS_TYPE_F32); 146 x->data.F32[0] = (psF32) (col + image->col0 + dx); 147 x->data.F32[1] = (psF32) (row + image->row0 + dy); 148 psF32 tmpF; 149 150 tmpF = model->modelFunc (NULL, model->params, x); 129 151 psFree(x); 130 152 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__); … … 137 159 pmModelOpMode mode, 138 160 bool add, 139 psMaskType maskVal 161 psMaskType maskVal, 162 int dx, 163 int dy 140 164 ) 141 165 { … … 148 172 psVector *x = psVectorAlloc(2, PS_TYPE_F32); 149 173 psVector *params = model->params; 150 pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type); 174 151 175 psS32 imageCol; 152 176 psS32 imageRow; … … 209 233 // Convert i/j to image coord space: 210 234 // XXX should we use using 0.5 pixel offset? 211 imageCol = ix + image->col0 ;212 imageRow = iy + image->row0 ;235 imageCol = ix + image->col0 + dx; 236 imageRow = iy + image->row0 + dy; 213 237 214 238 x->data.F32[0] = (float) imageCol; … … 219 243 // add in the desired components for this coordinate 220 244 if (mode & PM_MODEL_OP_FUNC) { 221 pixelValue += model Func (NULL, params, x);245 pixelValue += model->modelFunc (NULL, params, x); 222 246 } 223 247 … … 280 304 { 281 305 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 282 psBool rc = AddOrSubModel(image, mask, model, mode, true, maskVal );306 psBool rc = AddOrSubModel(image, mask, model, mode, true, maskVal, 0.0, 0.0); 283 307 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 284 308 return(rc); … … 294 318 { 295 319 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 296 psBool rc = AddOrSubModel(image, mask, model, mode, false, maskVal );320 psBool rc = AddOrSubModel(image, mask, model, mode, false, maskVal, 0.0, 0.0); 297 321 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 298 322 return(rc); 299 323 } 300 324 301 // check for success of model fit 302 bool pmModelFitStatus (pmModel *model) 303 { 304 305 bool status; 306 307 pmModelFitStatusFunc statusFunc = pmModelFitStatusFunc_GetFunction (model->type); 308 status = statusFunc (model); 309 310 return (status); 311 } 312 325 /****************************************************************************** 326 *****************************************************************************/ 327 bool pmModelAddWithOffset(psImage *image, 328 psImage *mask, 329 pmModel *model, 330 pmModelOpMode mode, 331 psMaskType maskVal, 332 int dx, 333 int dy) 334 { 335 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 336 psBool rc = AddOrSubModel(image, mask, model, mode, true, maskVal, dx, dy); 337 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 338 return(rc); 339 } 340 341 /****************************************************************************** 342 *****************************************************************************/ 343 bool pmModelSubWithOffset(psImage *image, 344 psImage *mask, 345 pmModel *model, 346 pmModelOpMode mode, 347 psMaskType maskVal, 348 int dx, 349 int dy) 350 { 351 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 352 psBool rc = AddOrSubModel(image, mask, model, mode, false, maskVal, dx, dy); 353 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 354 return(rc); 355 } -
branches/eam_branch_20070817/psModules/src/objects/pmModel.h
r13898 r14544 1 /* @file pm Objects.h1 /* @file pmModel.h 2 2 * @brief Functions to define and manipulate object models 3 3 * … … 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $8 * @date $Date: 2007-0 6-20 02:22:26$7 * @version $Revision: 1.11.6.1 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-08-17 21:01:59 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 14 14 # define PM_MODEL_H 15 15 16 # define TMP_PSF_TYPE void 17 # define TMP_MODEL_TYPE void 18 # define TMP_SOURCE_TYPE void 19 16 20 /// @addtogroup Objects Object Detection / Analysis Functions 17 21 /// @{ 22 23 /* pointers for the functions types below are supplied to each pmModel, and can be used by 24 the programmer without needing to know the model class */ 18 25 19 26 // type of model carried by the pmModel structure … … 41 48 } pmModelOpMode; 42 49 50 // This function is the model chi-square minimization function for this model. 51 typedef psMinimizeLMChi2Func pmModelFunc; 52 53 // This function sets the parameter limits for this model. 54 typedef psMinimizeLMLimitFunc pmModelLimits; 55 56 // This function returns the integrated flux for the given model parameters. 57 typedef psF64 (*pmModelFlux)(const psVector *params); 58 59 // This function returns the radius at which the given model and parameters 60 // achieves the given flux. 61 typedef psF64 (*pmModelRadius)(const psVector *params, double flux); 62 63 // This function provides the model guess parameters based on the details of 64 // the given source. 65 typedef bool (*pmModelGuessFunc)(TMP_MODEL_TYPE *model, TMP_SOURCE_TYPE *source); 66 67 // This function constructs the PSF model for the given source based on the 68 // supplied psf and the EXT model for the object. 69 typedef bool (*pmModelFromPSFFunc)(TMP_MODEL_TYPE *modelPSF, TMP_MODEL_TYPE *modelEXT, TMP_PSF_TYPE *psf); 70 71 // This function sets the model parameters based on the PSF for a given coordinate and central 72 // intensity 73 typedef bool (*pmModelParamsFromPSF)(TMP_MODEL_TYPE *model, TMP_PSF_TYPE *psf, float Xo, float Yo, float Io); 74 75 // This function returns the success / failure status of the given model fit 76 typedef bool (*pmModelFitStatusFunc)(TMP_MODEL_TYPE *model); 77 43 78 /** pmModel data structure 44 79 * … … 62 97 float radiusFit; ///< fit radius actually used 63 98 pmResiduals *residuals; ///< normalized PSF residuals 64 }65 pmModel;66 99 67 /* XXX we are currently saving the residuals with the pmModel. It might be better to save this 68 * in the pmSource. we may want an API to Add/Sub a pmModel (analytical model only) or a 69 * pmSource (analytical + residuals). 70 */ 100 // functions for this model which depend on the model class 101 pmModelFunc modelFunc; 102 pmModelFlux modelFlux; 103 pmModelRadius modelRadius; 104 pmModelLimits modelLimits; 105 pmModelGuessFunc modelGuess; 106 pmModelFromPSFFunc modelFromPSF; 107 pmModelParamsFromPSF modelParamsFromPSF; 108 pmModelFitStatusFunc modelFitStatus; 109 } pmModel; 71 110 72 111 /** Symbolic names for the elements of [d]params -
branches/eam_branch_20070817/psModules/src/objects/pmModelGroup.c
r14325 r14544 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 7-20 00:31:43$8 * @version $Revision: 1.17.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-08-17 21:01:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 #include "pmResiduals.h" 29 29 #include "pmModel.h" 30 #include "pmResiduals.h"31 #include "pmPSF.h"32 #include "pmSource.h"30 // #include "pmResiduals.h" 31 // #include "pmPSF.h" 32 // #include "pmSource.h" 33 33 #include "pmModelGroup.h" 34 34 #include "pmErrorCodes.h" … … 198 198 return (models[type].name); 199 199 } 200 201 /******************************************************************************202 pmSourceModelGuess(source, model): This function allocates a new203 pmModel structure based on the given modelType specified in the argument list.204 The corresponding pmModelGuess function is returned, and used to205 supply the values of the params array in the pmModel structure.206 207 XXX: Many parameters are based on the src->moments structure, which is in208 image, not subImage coords. Therefore, the calls to the model evaluation209 functions will be in image, not subImage coords. Remember this.210 *****************************************************************************/211 pmModel *pmSourceModelGuess(pmSource *source,212 pmModelType modelType)213 {214 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);215 PS_ASSERT_PTR_NON_NULL(source, NULL);216 PS_ASSERT_PTR_NON_NULL(source->moments, NULL);217 PS_ASSERT_PTR_NON_NULL(source->peak, NULL);218 219 pmModel *model = pmModelAlloc(modelType);220 221 pmModelGuessFunc modelGuessFunc = pmModelGuessFunc_GetFunction(modelType);222 if (!modelGuessFunc(model, source)) {223 psFree (model);224 return NULL;225 }226 227 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__);228 return(model);229 }230 -
branches/eam_branch_20070817/psModules/src/objects/pmModelGroup.h
r11253 r14544 1 1 /* @file pmModelGroup.h 2 2 * 3 * The object model function types are defined to allow for the flexible addition 4 * of new object models. Every object model, with parameters represented by 5 * pmModel, has an associated set of functions which provide necessary support 6 * operations. A set of abstract functions allow the programmer to select the 7 * approriate function or property for a specific named object model. 3 * The object model function types are desined to allow for the flexible addition of new object 4 * models. Every object model, with parameters represented by pmModel, has an associated set of 5 * functions which provide necessary support operations. A set of abstract functions allow the 6 * programmer to select the approriate function or property for a specific named object model. 7 * 8 * Every model instance belongs to a class of models, defined by the value of 9 * the pmModelType type entry. Various functions need access to information about 10 * each of the models. Some of this information varies from model to model, and 11 * may depend on the current parameter values or other data quantities. In order 12 * to keep the code from requiring the information about each model to be coded 13 * into the low-level fitting routines, we define a collection of functions which 14 * allow us to abstract this type of model-dependent information. These generic 15 * functions take the model type and return the corresponding function pointer 16 * for the specified model. Each model is defined by creating this collection of 17 * specific functions, and placing them in a single file for each model. We 18 * define the following structure to carry the collection of information about 19 * the models. 8 20 * 9 21 * @author EAM, IfA 10 22 * 11 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $12 * @date $Date: 2007-0 1-24 02:54:15$23 * @version $Revision: 1.7.14.1 $ $Name: not supported by cvs2svn $ 24 * @date $Date: 2007-08-17 21:01:59 $ 13 25 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 14 26 */ … … 23 35 typedef psMinimizeLMChi2Func pmModelFunc; 24 36 25 // This function is the model chi-square minimization functionfor this model.37 // This function sets the parameter limits for this model. 26 38 typedef psMinimizeLMLimitFunc pmModelLimits; 27 39 … … 29 41 typedef psF64 (*pmModelFlux)(const psVector *params); 30 42 31 32 43 // This function returns the radius at which the given model and parameters 33 44 // achieves the given flux. 34 45 typedef psF64 (*pmModelRadius)(const psVector *params, double flux); 35 46 36 /* This function sets the model parameter limits vectors for the given model 37 */ 38 // typedef bool (*pmModelLimits)(psVector **beta_lim, psVector **params_min, psVector **params_max); 39 40 /* This function provides the model guess parameters based on the details of 41 * the given source. 42 */ 47 // This function provides the model guess parameters based on the details of 48 // the given source. 43 49 typedef bool (*pmModelGuessFunc)(pmModel *model, pmSource *source); 44 50 45 46 /* This function constructs the PSF model for the given source based on the 47 * supplied psf and the EXT model for the object. 48 */ 51 // This function constructs the PSF model for the given source based on the 52 // supplied psf and the EXT model for the object. 49 53 typedef bool (*pmModelFromPSFFunc)(pmModel *modelPSF, pmModel *modelEXT, pmPSF *psf); 50 54 51 /* This function returns the success / failure status of the given model fit 52 */ 55 // This function sets the model parameters based on the PSF for a given coordinate and central 56 // intensity 57 typedef bool (*pmModelParamsFromPSF)(pmModel *model, pmPSF *psf, float Xo, float Yo, float Io); 58 59 // This function returns the success / failure status of the given model fit 53 60 typedef bool (*pmModelFitStatusFunc)(pmModel *model); 54 61 55 /* Every model instance belongs to a class of models, defined by the value of56 * the pmModelType type entry. Various functions need access to information about57 * each of the models. Some of this information varies from model to model, and58 * may depend on the current parameter values or other data quantities. In order59 * to keep the code from requiring the information about each model to be coded60 * into the low-level fitting routines, we define a collection of functions which61 * allow us to abstract this type of model-dependent information. These generic62 * functions take the model type and return the corresponding function pointer63 * for the specified model. Each model is defined by creating this collection of64 * specific functions, and placing them in a single file for each model. We65 * define the following structure to carry the collection of information about66 * the models.67 */68 62 typedef struct 69 63 { … … 76 70 pmModelGuessFunc modelGuessFunc; 77 71 pmModelFromPSFFunc modelFromPSFFunc; 72 pmModelParamsFromPSF modelParamsFromPSF; 78 73 pmModelFitStatusFunc modelFitStatusFunc; 79 74 } -
branches/eam_branch_20070817/psModules/src/objects/pmModelUtils.c
r14530 r14544 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.1 $ $Name: not supported by cvs2svn $8 * @date $Date: 2007-08-1 6 18:33:37$7 * @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-08-17 21:01:59 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 #include <string.h> 21 21 #include <pslib.h> 22 #include "pmHDU.h" 23 #include "pmFPA.h" 24 #include "pmGrowthCurve.h" 22 25 #include "pmResiduals.h" 23 26 #include "pmModel.h" 27 #include "pmPSF.h" 28 #include "pmErrorCodes.h" 29 #include "pmModelUtils.h" 24 30 25 // instantiate a model for the PSF at this location (normalized or not?)26 // NOTE: psf and ( x,y) are defined wrt chip coordinates27 pmModel *pmModelFromPSFforXY (pmPSF *psf, float x, float y, float flux) {31 // instantiate a model for the PSF at this location with peak flux 32 // NOTE: psf and (Xo,Yo) are defined wrt chip coordinates 33 pmModel *pmModelFromPSFforXY (pmPSF *psf, float Xo, float Yo, float Io) { 28 34 29 35 assert (psf); 30 36 31 37 // allocate a new pmModel to hold the PSF version 32 pmModel *modelEXT = pmModelAlloc (psf->type);33 34 modelEXT->params->data.F32[PM_PAR_SKY] = 0.0;35 modelEXT->params->data.F32[PM_PAR_I0] = 1.0;36 modelEXT->params->data.F32[PM_PAR_XPOS] = x;37 modelEXT->params->data.F32[PM_PAR_YPOS] = y;38 39 // find function used to set the model parameters40 pmModelFromPSFFunc modelFromPSFFunc = pmModelFromPSFFunc_GetFunction (psf->type);41 42 // allocate a new pmModel to hold the PSF version43 38 pmModel *modelPSF = pmModelAlloc (psf->type); 44 39 45 // adjust the normalization:46 pmModelFlux modelFluxFunc = pmModelFlux_GetFunction (model->type);47 normFlux = modelFluxFunc (model->params);48 assert (isfinite(normFlux));49 assert (normFlux > 0);50 51 // set the correct normalization52 modelEXT->params->data.F32[PM_PAR_I0] = flux / normFlux;53 54 40 // set model parameters for this source based on PSF information 55 if (!model FromPSFFunc (modelPSF, modelEXT, psf)) {41 if (!modelPSF->modelParamsFromPSF (modelPSF, psf, Xo, Yo, Io)) { 56 42 psError(PM_ERR_PSF, false, "Failed to set model params from PSF"); 57 43 psFree(modelPSF); 58 44 return NULL; 59 45 } 46 60 47 // XXX note that model->residuals is just a reference 61 48 modelPSF->residuals = psf->residuals; 62 psFree (modelEXT);63 49 64 50 return (modelPSF); 65 51 } 66 52 67 pmSource *pmSourceFromModel (pmModel *model, pmReadout *readout, pmSourceType type) { 53 // set this model to have the requested flux 54 bool pmModelSetFlux (pmModel *model, float flux) { 68 55 69 pmSource *source = pmSourceAlloc (); 56 // set Io to be 1.0 57 model->params->data.F32[PM_PAR_I0] = 1.0; 70 58 71 // use the model centroid for the peak 72 switch (type) { 73 case PM_SOURCE_TYPE_STAR: 74 source->modelPSF = model; 75 break; 76 case PM_SOURCE_TYPE_EXTENDED: 77 source->modelEXT = model; 78 break; 79 default: 80 psAbort ("psphot", "error"); 81 } 59 // determine the normalized flux 60 float normFlux = model->modelFlux (model->params); 61 assert (isfinite(normFlux)); 62 assert (normFlux > 0); 82 63 83 source->peak = pmPeakAlloc (); 64 // set the desired normalization 65 model->params->data.F32[PM_PAR_I0] = flux / normFlux; 84 66 85 float x = model->params->data.F32[PM_PAR_XPOS]; 86 float y = model->params->data.F32[PM_PAR_YPOS]; 87 88 // XXX need to define the radius in some rational way 89 // XXX x,y are defined wrt readout->image parent, but the model 90 // parameters are defined wrt chip coordinates 91 pmSourceDefinePixels (source, readout, x, y, radius); 92 93 return (source); 67 return true; 94 68 } -
branches/eam_branch_20070817/psModules/src/objects/pmPSF.c
r13898 r14544 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 6-20 02:22:26$8 * @version $Revision: 1.25.6.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-08-17 21:01:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 32 32 #include "pmGrowthCurve.h" 33 33 #include "pmPSF.h" 34 #include "pmModel Group.h"34 #include "pmModelClass.h" 35 35 #include "pmSourcePhotometry.h" 36 36 #include "pmFPAMaskWeight.h" … … 124 124 psf->residuals = NULL; 125 125 126 Nparams = pmModel ParameterCount (type);126 Nparams = pmModelClassParameterCount (type); 127 127 if (!Nparams) { 128 128 psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType"); … … 169 169 pmModel *pmModelFromPSF (pmModel *modelEXT, pmPSF *psf) 170 170 { 171 172 // need to define the relationship between the modelEXT and modelPSF ?173 174 // find function used to set the model parameters175 pmModelFromPSFFunc modelFromPSFFunc = pmModelFromPSFFunc_GetFunction (psf->type);176 177 171 // allocate a new pmModel to hold the PSF version 178 172 pmModel *modelPSF = pmModelAlloc (psf->type); 179 173 180 174 // set model parameters for this source based on PSF information 181 if (!model FromPSFFunc(modelPSF, modelEXT, psf)) {175 if (!modelEXT->modelFromPSF (modelPSF, modelEXT, psf)) { 182 176 psError(PM_ERR_PSF, false, "Failed to set model params from PSF"); 183 177 psFree(modelPSF); … … 335 329 va_start(ap, sxy); 336 330 337 pmModelType type = pmModel SetType (typeName);331 pmModelType type = pmModelClassGetType (typeName); 338 332 psPolynomial2D *psfTrend = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, 0, 0); 339 333 pmPSF *psf = pmPSFAlloc (type, true, psfTrend); -
branches/eam_branch_20070817/psModules/src/objects/pmPSF_IO.c
r14207 r14544 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 7-14 03:20:22$8 * @version $Revision: 1.20.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-08-17 21:01:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 44 44 #include "pmPSF_IO.h" 45 45 #include "pmSource.h" 46 #include "pmModel Group.h"46 #include "pmModelClass.h" 47 47 #include "pmSourceIO.h" 48 48 … … 313 313 psMetadata *header = psMetadataAlloc(); 314 314 315 char *modelName = pmModel GetType (psf->type);315 char *modelName = pmModelClassGetName (psf->type); 316 316 psMetadataAddStr (header, PS_LIST_TAIL, "PSF_NAME", 0, "PSF model name", modelName); 317 317 318 318 psMetadataAddBool (header, PS_LIST_TAIL, "POISSON", 0, "Use Poisson errors in fits?", psf->poissonErrors); 319 319 320 int nPar = pmModel ParameterCount (psf->type) ;320 int nPar = pmModelClassParameterCount (psf->type) ; 321 321 psMetadataAdd (header, PS_LIST_TAIL, "PSF_NPAR", PS_DATA_S32, "PSF model parameter count", nPar); 322 322 … … 599 599 // load the PSF model parameters from the FITS table 600 600 char *modelName = psMetadataLookupStr (&status, header, "PSF_NAME"); 601 pmModelType type = pmModel SetType (modelName);601 pmModelType type = pmModelClassGetType (modelName); 602 602 if (type == -1) { 603 603 psError(PS_ERR_UNKNOWN, true, "invalid model name %s in psf file %s", modelName, file->filename); … … 612 612 // check the number of expected parameters 613 613 int nPar = psMetadataLookupS32 (&status, header, "PSF_NPAR"); 614 if (nPar != pmModel ParameterCount (psf->type))614 if (nPar != pmModelClassParameterCount (psf->type)) 615 615 psAbort("mismatch model par count"); 616 616 … … 717 717 } 718 718 719 char *modelName = pmModel GetType (psf->type);719 char *modelName = pmModelClassGetName (psf->type); 720 720 psMetadataAdd (metadata, PS_LIST_TAIL, "PSF_MODEL_NAME", PS_DATA_STRING, "PSF model name", modelName); 721 721 722 int nPar = pmModel ParameterCount (psf->type) ;722 int nPar = pmModelClassParameterCount (psf->type) ; 723 723 psMetadataAdd (metadata, PS_LIST_TAIL, "PSF_MODEL_NPAR", PS_DATA_S32, "PSF model parameter count", nPar); 724 724 … … 749 749 750 750 char *modelName = psMetadataLookupPtr (&status, metadata, "PSF_MODEL_NAME"); 751 pmModelType type = pmModel SetType (modelName);751 pmModelType type = pmModelClassGetType (modelName); 752 752 753 753 bool poissonErrors = psMetadataLookupPtr (&status, metadata, "PSF_POISSON_ERRORS"); … … 759 759 760 760 int nPar = psMetadataLookupS32 (&status, metadata, "PSF_MODEL_NPAR"); 761 if (nPar != pmModel ParameterCount (psf->type))761 if (nPar != pmModelClassParameterCount (psf->type)) 762 762 psAbort("mismatch model par count"); 763 763 -
branches/eam_branch_20070817/psModules/src/objects/pmPSFtry.c
r13898 r14544 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.43 $ $Name: not supported by cvs2svn $8 * @date $Date: 2007-0 6-20 02:22:26$7 * @version $Revision: 1.43.6.1 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-08-17 21:01:59 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 25 25 #include "pmModel.h" 26 26 #include "pmSource.h" 27 #include "pmSourceUtils.h" 27 28 #include "pmGrowthCurve.h" 28 29 #include "pmPSF.h" 29 30 #include "pmPSFtry.h" 30 #include "pmModel Group.h"31 #include "pmModelClass.h" 31 32 #include "pmSourceFitModel.h" 32 33 #include "pmSourcePhotometry.h" … … 59 60 60 61 // validate the requested model name 61 pmModelType type = pmModel SetType (modelName);62 pmModelType type = pmModelClassGetType (modelName); 62 63 if (type == -1) { 63 64 psError (PS_ERR_UNKNOWN, true, "invalid model name %s", modelName); -
branches/eam_branch_20070817/psModules/src/objects/pmPeaks.c
r13034 r14544 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 4-26 01:20:29 $8 * @version $Revision: 1.15.8.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-08-17 21:01:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 pmPeakType type) 36 36 { 37 psTrace( __func__, 5, "---- begin ----\n");37 psTrace("psModules.objects", 5, "---- begin ----\n"); 38 38 39 39 if (peaks == NULL) { … … 67 67 psFree (peak); 68 68 69 psTrace( __func__, 5, "---- end ----\n");69 psTrace("psModules.objects", 5, "---- end ----\n"); 70 70 return(peaks); 71 71 } … … 118 118 *****************************************************************************/ 119 119 static void peakFree(pmPeak *tmp) 120 {} // used by pm IsPeak()120 {} // used by pmPeakTest() 121 121 122 122 pmPeak *pmPeakAlloc(psS32 x, … … 145 145 } 146 146 147 bool pm IsPeak(const psPtr ptr)147 bool pmPeakTest(const psPtr ptr) 148 148 { 149 149 return (psMemGetDeallocator(ptr) == (psFreeFunc)peakFree); … … 193 193 194 194 /****************************************************************************** 195 pm FindVectorPeaks(vector, threshold): Find all local peaks in the given vector195 pmPeaksInVector(vector, threshold): Find all local peaks in the given vector 196 196 above the given threshold. Returns a vector of type PS_TYPE_U32 containing 197 197 the location (x value) of all peaks. … … 203 203 Depending upon actual use, this may need to be optimized. 204 204 *****************************************************************************/ 205 psVector *pm FindVectorPeaks(const psVector *vector,206 psF32 threshold)205 psVector *pmPeaksInVector(const psVector *vector, 206 psF32 threshold) 207 207 { 208 208 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); … … 295 295 296 296 /****************************************************************************** 297 pm FindImagePeaks(image, threshold): Find all local peaks in the given psImage297 pmPeaksInImage(image, threshold): Find all local peaks in the given psImage 298 298 above the given threshold. Returns a psArray containing location (x/y value) 299 299 of all peaks. … … 309 309 310 310 *****************************************************************************/ 311 psArray *pm FindImagePeaks(const psImage *image, psF32 threshold)311 psArray *pmPeaksInImage(const psImage *image, psF32 threshold) 312 312 { 313 313 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); … … 327 327 row = 0; 328 328 tmpRow = getRowVectorFromImage((psImage *) image, row); 329 psVector *row1 = pm FindVectorPeaks(tmpRow, threshold);330 // pm FindVectorPeaksreturns coords in the vector, not corrected for col0329 psVector *row1 = pmPeaksInVector(tmpRow, threshold); 330 // pmPeaksInVector returns coords in the vector, not corrected for col0 331 331 332 332 for (psU32 i = 0 ; i < row1->n ; i++ ) { … … 382 382 for (row = 1 ; row < (image->numRows - 1) ; row++) { 383 383 tmpRow = getRowVectorFromImage((psImage *) image, row); 384 row1 = pm FindVectorPeaks(tmpRow, threshold);384 row1 = pmPeaksInVector(tmpRow, threshold); 385 385 386 386 // Step through all local peaks in this row. … … 461 461 row = image->numRows - 1; 462 462 tmpRow = getRowVectorFromImage((psImage *) image, row); 463 row1 = pm FindVectorPeaks(tmpRow, threshold);463 row1 = pmPeaksInVector(tmpRow, threshold); 464 464 for (psU32 i = 0 ; i < row1->n ; i++ ) { 465 465 col = row1->data.U32[i]; … … 501 501 } 502 502 503 504 /****************************************************************************** 505 psCullPeaks(peaks, maxValue, valid): eliminate peaks from the psArray that have 506 a peak value above the given maximum, or fall outside the valid region. 507 508 XXX: Should the sky value be used when comparing the maximum? 509 510 XXX: warning message if valid is NULL? 511 512 XXX: changed API to create a NEW output psArray (should change name as well) 513 514 XXX: Do we free the psList elements of those culled peaks? 515 516 XXX EAM : do we still need pmCullPeaks, or only pmPeaksSubset? 517 *****************************************************************************/ 518 psList *pmCullPeaks(psList *peaks, 519 psF32 maxValue, 520 const psRegion valid) 521 { 522 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 523 PS_ASSERT_PTR_NON_NULL(peaks, NULL); 524 525 psListElem *tmpListElem = (psListElem *) peaks->head; 526 psS32 indexNum = 0; 527 528 // printf("pmCullPeaks(): list size is %d\n", peaks->size); 529 while (tmpListElem != NULL) { 530 pmPeak *tmpPeak = (pmPeak *) tmpListElem->data; 531 if ((tmpPeak->value > maxValue) || 532 (true == isItInThisRegion(valid, tmpPeak->x, tmpPeak->y))) { 533 psListRemoveData(peaks, (psPtr) tmpPeak); 534 } 535 536 indexNum++; 537 tmpListElem = tmpListElem->next; 538 } 539 540 psTrace("psModules.objects", 3, "---- %s() end ----\n", __func__); 541 return(peaks); 542 } 543 544 // XXX EAM: I changed this to return a new, subset array 545 // rather than alter the existing one 546 // XXX: Fix the *valid pointer. 503 // return a new array of peaks which are in the valid region and below threshold 504 // XXX this function is unused and probably could be dropped 547 505 psArray *pmPeaksSubset( 548 506 psArray *peaks, … … 555 513 psArray *output = psArrayAllocEmpty (200); 556 514 557 psTrace (" .pmObjects.pmCullPeaks", 3, "list size is %ld\n", peaks->n);515 psTrace ("psModules.objects", 3, "list size is %ld\n", peaks->n); 558 516 559 517 for (int i = 0; i < peaks->n; i++) { -
branches/eam_branch_20070817/psModules/src/objects/pmPeaks.h
r11253 r14544 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $13 * @date $Date: 2007-0 1-24 02:54:15$12 * @version $Revision: 1.6.14.1 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-08-17 21:01:59 $ 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 15 15 */ … … 72 72 ); 73 73 74 bool pm IsPeak(const psPtr ptr);74 bool pmPeakTest(const psPtr ptr); 75 75 76 /** pm FindVectorPeaks()76 /** pmPeaksInVector() 77 77 * 78 78 * Find all local peaks in the given vector above the given threshold. A peak … … 91 91 * 92 92 */ 93 psVector *pm FindVectorPeaks(93 psVector *pmPeaksInVector( 94 94 const psVector *vector, ///< The input vector (float) 95 95 float threshold ///< Threshold above which to find a peak … … 97 97 98 98 99 /** pm FindImagePeaks()99 /** pmPeaksInImage() 100 100 * 101 101 * Find all local peaks in the given image above the given threshold. This … … 111 111 * 112 112 */ 113 psArray *pm FindImagePeaks(113 psArray *pmPeaksInImage( 114 114 const psImage *image, ///< The input image where peaks will be found (float) 115 115 float threshold ///< Threshold above which to find a peak -
branches/eam_branch_20070817/psModules/src/objects/pmSource.c
r14529 r14544 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $9 * @date $Date: 2007-08-1 6 18:33:00$8 * @version $Revision: 1.34.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-08-17 21:01:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 113 113 } 114 114 115 bool pm IsSource(const psPtr ptr)115 bool pmSourceTest(const psPtr ptr) 116 116 { 117 117 return (psMemGetDeallocator(ptr) == (psFreeFunc)sourceFree); … … 337 337 return emptyClump; 338 338 } 339 peaks = pm FindImagePeaks(splane, stats[0].max / 2);339 peaks = pmPeaksInImage (splane, stats[0].max / 2); 340 340 psTrace ("psModules.objects", 2, "clump threshold is %f\n", stats[0].max/2); 341 341 -
branches/eam_branch_20070817/psModules/src/objects/pmSource.h
r14505 r14544 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $6 * @date $Date: 2007-08-1 5 20:21:18$5 * @version $Revision: 1.16.2.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-08-17 21:01:59 $ 7 7 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 8 8 */ … … 114 114 void pmSourceFreePixels(pmSource *source); 115 115 116 bool pm IsSource(const psPtr ptr);116 bool pmSourceTest(const psPtr ptr); 117 117 118 118 /** pmSourceDefinePixels() -
branches/eam_branch_20070817/psModules/src/objects/pmSourceFitModel.c
r13932 r14544 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 6-21 22:58:11$8 * @version $Revision: 1.24.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-08-17 21:01:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 30 30 #include "pmPSF.h" 31 31 #include "pmSource.h" 32 #include "pmModel Group.h"32 #include "pmModelClass.h" 33 33 #include "pmSourceFitModel.h" 34 34 … … 116 116 psVector *dparams = model->dparams; 117 117 118 pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);119 if (!modelFunc)120 psAbort("invalid model function");121 pmModelLimits checkLimits = pmModelLimits_GetFunction (model->type);122 if (!checkLimits)123 psAbort("invalid model limits function");124 125 118 // create the minimization constraints 126 119 psMinConstraint *constraint = psMinConstraintAlloc(); 127 120 constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_U8); 128 constraint->checkLimits = checkLimits;121 constraint->checkLimits = model->modelLimits; 129 122 130 123 // set parameter mask based on fitting mode … … 156 149 // force the floating parameters to fall within the contraint ranges 157 150 for (int i = 0; i < params->n; i++) { 158 checkLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL);159 checkLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL);151 model->modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL); 152 model->modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL); 160 153 } 161 154 … … 174 167 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32); 175 168 176 fitStatus = psMinimizeLMChi2(myMin, covar, params, constraint, x, y, yErr, model Func);169 fitStatus = psMinimizeLMChi2(myMin, covar, params, constraint, x, y, yErr, model->modelFunc); 177 170 for (int i = 0; i < dparams->n; i++) { 178 171 if (psTraceGetLevel("psModules.objects") >= 4) { … … 201 194 altmask->data.U8[i] = (constraint->paramMask->data.U8[i]) ? 0 : 1; 202 195 } 203 psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, model Func);196 psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, model->modelFunc); 204 197 for (int i = 0; i < dparams->n; i++) { 205 198 if (!constraint->paramMask->data.U8[i]) … … 236 229 return(rc); 237 230 } 231 232 # define SKIP_FIT_SET 1 233 # if (SKIP_FIT_SET) 234 235 bool pmSourceFitSet (pmSource *source, 236 psArray *modelSet, 237 pmSourceFitMode mode, 238 psMaskType maskVal) 239 { 240 psTrace("psModules.objects", 3, "---- %s begin ----\n", __func__); 241 PS_ASSERT_PTR_NON_NULL(source, false); 242 PS_ASSERT_PTR_NON_NULL(source->pixels, false); 243 PS_ASSERT_PTR_NON_NULL(source->maskObj, false); 244 PS_ASSERT_PTR_NON_NULL(source->weight, false); 245 246 return true; 247 } 248 249 # else 238 250 239 251 /********************* Source Model Set Functions ***************************/ … … 255 267 oneModelFunc = pmModelFunc_GetFunction (type); 256 268 oneCheckLimits = pmModelLimits_GetFunction (type); 257 nOnePar = pmModel ParameterCount (type);269 nOnePar = pmModelClassParameterCount (type); 258 270 259 271 onePar = psVectorAlloc (nOnePar, PS_DATA_F32); … … 567 579 } 568 580 581 # endif -
branches/eam_branch_20070817/psModules/src/objects/pmSourceIO.c
r14208 r14544 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 7-14 03:20:44$5 * @version $Revision: 1.45.4.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-08-17 21:01:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 37 37 #include "pmPSF.h" 38 38 #include "pmSource.h" 39 #include "pmModel Group.h"39 #include "pmModelClass.h" 40 40 #include "pmSourceIO.h" 41 41 -
branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_CMP.c
r13137 r14544 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 5-03 00:13:03$5 * @version $Revision: 1.29.8.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-08-17 21:01:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "pmPSF.h" 36 36 #include "pmSource.h" 37 #include "pmModel Group.h"37 #include "pmModelClass.h" 38 38 #include "pmSourceIO.h" 39 39 … … 154 154 155 155 // define PSF model type 156 int modelType = pmModel SetType ("PS_MODEL_GAUSS");156 int modelType = pmModelClassGetType ("PS_MODEL_GAUSS"); 157 157 158 158 char *PSF_NAME = psMetadataLookupStr (&status, header, "PSF_NAME"); 159 159 if (PSF_NAME != NULL) { 160 modelType = pmModel SetType (PSF_NAME);160 modelType = pmModelClassGetType (PSF_NAME); 161 161 } 162 162 -
branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_OBJ.c
r13137 r14544 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 5-03 00:13:03$5 * @version $Revision: 1.13.8.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-08-17 21:01:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "pmPSF.h" 36 36 #include "pmSource.h" 37 #include "pmModel Group.h"37 #include "pmModelClass.h" 38 38 #include "pmSourceIO.h" 39 39 -
branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_PS1_DEV_0.c
r13139 r14544 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 5-03 00:13:42$5 * @version $Revision: 1.10.8.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-08-17 21:01:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "pmPSF.h" 36 36 #include "pmSource.h" 37 #include "pmModel Group.h"37 #include "pmModelClass.h" 38 38 #include "pmSourceIO.h" 39 39 … … 152 152 153 153 // define PSF model type 154 int modelType = pmModel SetType ("PS_MODEL_GAUSS");154 int modelType = pmModelClassGetType ("PS_MODEL_GAUSS"); 155 155 156 156 char *PSF_NAME = psMetadataLookupStr (&status, header, "PSF_NAME"); 157 157 if (PSF_NAME != NULL) { 158 modelType = pmModel SetType (PSF_NAME);158 modelType = pmModelClassGetType (PSF_NAME); 159 159 } 160 160 -
branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_RAW.c
r12949 r14544 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 4-21 19:47:14$5 * @version $Revision: 1.15.8.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-08-17 21:01:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "pmPSF.h" 36 36 #include "pmSource.h" 37 #include "pmModel Group.h"37 #include "pmModelClass.h" 38 38 #include "pmSourcePhotometry.h" 39 39 #include "pmSourceIO.h" -
branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_SMPDATA.c
r13139 r14544 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 5-03 00:13:42$5 * @version $Revision: 1.9.8.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-08-17 21:01:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "pmPSF.h" 36 36 #include "pmSource.h" 37 #include "pmModel Group.h"37 #include "pmModelClass.h" 38 38 #include "pmSourceIO.h" 39 39 … … 132 132 133 133 // define PSF model type 134 int modelType = pmModel SetType ("PS_MODEL_GAUSS");134 int modelType = pmModelClassGetType ("PS_MODEL_GAUSS"); 135 135 136 136 char *PSF_NAME = psMetadataLookupStr (&status, header, "PSF_NAME"); 137 137 if (PSF_NAME != NULL) { 138 modelType = pmModel SetType (PSF_NAME);138 modelType = pmModelClassGetType (PSF_NAME); 139 139 } 140 140 -
branches/eam_branch_20070817/psModules/src/objects/pmSourceIO_SX.c
r13064 r14544 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 4-27 22:14:08$5 * @version $Revision: 1.11.8.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-08-17 21:01:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 #include "pmPSF.h" 36 36 #include "pmSource.h" 37 #include "pmModel Group.h"37 #include "pmModelClass.h" 38 38 #include "pmSourceIO.h" 39 39 -
branches/eam_branch_20070817/psModules/src/objects/pmSourcePhotometry.c
r13898 r14544 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 6-20 02:22:26$5 * @version $Revision: 1.28.6.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-08-17 21:01:59 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 #include "pmPSF.h" 30 30 #include "pmSource.h" 31 #include "pmModel Group.h"31 #include "pmModelClass.h" 32 32 #include "pmSourcePhotometry.h" 33 33 … … 250 250 251 251 // measure fitMag 252 pmModelFlux modelFluxFunc = pmModelFlux_GetFunction (model->type); 253 fitSum = modelFluxFunc (model->params); 252 fitSum = model->modelFlux (model->params); 254 253 if (fitSum <= 0) 255 254 return false; … … 324 323 325 324 // the model function returns the source flux at a position 326 pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);327 325 psVector *coord = psVectorAlloc(2, PS_TYPE_F32); 328 326 … … 354 352 355 353 // for the full model, add all points 356 value = model Func (NULL, params, coord) - sky;354 value = model->modelFunc (NULL, params, coord) - sky; 357 355 modelSum += value; 358 356 -
branches/eam_branch_20070817/psModules/src/psmodules.h
r14505 r14544 84 84 #include <pmModel.h> 85 85 #include <pmSource.h> 86 #include <pmSourceUtils.h> 86 87 #include <pmSourceIO.h> 87 88 #include <pmSourceSky.h> … … 93 94 #include <pmPSF_IO.h> 94 95 #include <pmPSFtry.h> 95 #include <pmModelGroup.h> 96 #include <pmModelClass.h> 97 #include <pmModelUtils.h> 96 98 #include <pmSourcePhotometry.h> 97 99 -
branches/eam_branch_20070817/psModules/test/objects/tap_pmSourceFitModel.c
r13034 r14544 117 117 source->moments = pmMomentsAlloc (); 118 118 119 pmModelType type = pmModel SetType ("PS_MODEL_GAUSS");119 pmModelType type = pmModelClassGetType ("PS_MODEL_GAUSS"); 120 120 source->modelEXT = pmModelAlloc (type); 121 121 -
branches/eam_branch_20070817/psModules/test/objects/tap_pmSourceFitModel_Delta.c
r13034 r14544 35 35 source->moments = pmMomentsAlloc (); 36 36 37 pmModelType type = pmModel SetType ("PS_MODEL_GAUSS");37 pmModelType type = pmModelClassGetType ("PS_MODEL_GAUSS"); 38 38 source->modelEXT = pmModelAlloc (type); 39 39 … … 71 71 pmModel *guess; 72 72 73 type = pmModel SetType ("PS_MODEL_PGAUSS");73 type = pmModelClassGetType ("PS_MODEL_PGAUSS"); 74 74 guess = pmModelAlloc (type); 75 75 -
branches/eam_branch_20070817/psModules/test/objects/tst_pmObjects01.c
r6511 r14544 31 31 most of psObjects.c is not tested 32 32 * 33 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $34 * @date $Date: 200 6-03-04 01:01:34$33 * @version $Revision: 1.8.16.1 $ $Name: not supported by cvs2svn $ 34 * @date $Date: 2007-08-17 21:01:59 $ 35 35 * 36 36 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 186 186 // 187 187 psS32 i = 0; 188 while (0 != pmModel ParameterCount(i)) {189 printf("Testing pmModelAlloc(%s)...\n", pmModel GetType(0));188 while (0 != pmModelClassParameterCount(i)) { 189 printf("Testing pmModelAlloc(%s)...\n", pmModelClassGetName(0)); 190 190 pmModel *tmpModel = pmModelAlloc(i); 191 191 if (tmpModel == NULL) { 192 printf("TEST ERROR: pmModelAlloc(%s) returned a NULL pmModel\n", pmModel GetType(0));192 printf("TEST ERROR: pmModelAlloc(%s) returned a NULL pmModel\n", pmModelClassGetName(0)); 193 193 testStatus = false; 194 194 } else {
Note:
See TracChangeset
for help on using the changeset viewer.
