Changeset 14545
- Timestamp:
- Aug 17, 2007, 11:27:05 AM (19 years ago)
- Location:
- branches/eam_branch_20070817/psphot/src
- Files:
-
- 19 edited
-
models/pmModel_STRAIL.c (modified) (5 diffs)
-
models/pmModel_TEST1.c (modified) (6 diffs)
-
pmFootprint.c (modified) (9 diffs)
-
pmFootprint.h (modified) (2 diffs)
-
psphot.c (modified) (1 diff)
-
psphot.h (modified) (1 diff)
-
psphotChoosePSF.c (modified) (3 diffs)
-
psphotCleanup.c (modified) (1 diff)
-
psphotEvalFLT.c (modified) (1 diff)
-
psphotFakeSources.c (modified) (1 diff)
-
psphotFindPeaks.c (modified) (1 diff)
-
psphotGrowthCurve.c (modified) (3 diffs)
-
psphotModelGroupInit.c (modified) (1 diff)
-
psphotModelTest.c (modified) (3 diffs)
-
psphotPSFConvModel.c (modified) (3 diffs)
-
psphotPSFResiduals.c (modified) (1 diff)
-
psphotRadiusChecks.c (modified) (7 diffs)
-
psphotSourceFits.c (modified) (1 diff)
-
psphotTestSourceOutput.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070817/psphot/src/models/pmModel_STRAIL.c
r11702 r14545 12 12 *****************************************************************************/ 13 13 14 # define PM_MODEL_FUNC pmModelFunc_STRAIL 15 # define PM_MODEL_FLUX pmModelFlux_STRAIL 16 # define PM_MODEL_GUESS pmModelGuess_STRAIL 17 # define PM_MODEL_LIMITS pmModelLimits_STRAIL 18 # define PM_MODEL_RADIUS pmModelRadius_STRAIL 19 # define PM_MODEL_FROM_PSF pmModelFromPSF_STRAIL 20 # define PM_MODEL_FIT_STATUS pmModelFitStatus_STRAIL 14 # define PM_MODEL_FUNC pmModelFunc_STRAIL 15 # define PM_MODEL_FLUX pmModelFlux_STRAIL 16 # define PM_MODEL_GUESS pmModelGuess_STRAIL 17 # define PM_MODEL_LIMITS pmModelLimits_STRAIL 18 # define PM_MODEL_RADIUS pmModelRadius_STRAIL 19 # define PM_MODEL_FROM_PSF pmModelFromPSF_STRAIL 20 # define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_STRAIL 21 # define PM_MODEL_FIT_STATUS pmModelFitStatus_STRAIL 21 22 22 23 psF32 PM_MODEL_FUNC(psVector *deriv, … … 474 475 475 476 //fixed I think...no good way of guessing as far as I can tell 476 bool PM_MODEL_GUESS (pmModel *model, pmSource *source) { 477 477 bool PM_MODEL_GUESS (void *inModel, void *inSource) 478 { 479 pmModel *model = inModel; 480 pmSource *source = inSource; 481 478 482 pmMoments *Smoments = source->moments; 479 483 psF32 *params = model->params->data.F32; … … 516 520 517 521 //fixed 518 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf) { 522 bool PM_MODEL_FROM_PSF (void *inModelPSF, void *inModelFLT, void *inPSF) 523 { 524 pmModel *modelPSF = inModelPSF; 525 pmModel *modelFLT = inModelFLT; 526 pmPSF *psf = inPSF; 519 527 520 528 psF32 *out = modelPSF->params->data.F32; … … 535 543 } 536 544 545 // construct the PSF model from the FLT model and the psf 546 // XXX is this sufficiently general do be a global function, not a pmModelClass function? 547 bool PM_MODEL_PARAMS_FROM_PSF (void *inModel, void *inPSF, float Xo, float Yo, float Io) 548 { 549 pmModel *model = inModel; 550 pmPSF *psf = inPSF; 551 552 psF32 *PAR = model->params->data.F32; 553 554 // we require these two parameters to exist 555 assert (psf->params_NEW->n > PM_PAR_YPOS); 556 assert (psf->params_NEW->n > PM_PAR_XPOS); 557 558 PAR[PM_PAR_SKY] = 0.0; 559 PAR[PM_PAR_I0] = Io; 560 PAR[PM_PAR_XPOS] = Xo; 561 PAR[PM_PAR_YPOS] = Yo; 562 563 // supply the model-fitted parameters, or copy from the input 564 for (int i = 0; i < psf->params_NEW->n; i++) { 565 if (i == PM_PAR_SKY) continue; 566 psPolynomial2D *poly = psf->params_NEW->data[i]; 567 assert (poly); 568 PAR[i] = psPolynomial2DEval(poly, Xo, Yo); 569 } 570 571 // the 2D PSF model fits polarization terms (E0,E1,E2) 572 // convert to shape terms (SXX,SYY,SXY) 573 // XXX user-defined value for limit? 574 if (!pmPSF_FitToModel (PAR, 0.1)) { 575 psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); 576 return false; 577 } 578 579 // apply the model limits here: this truncates excessive extrapolation 580 // XXX do we need to do this still? should we put in asserts to test? 581 for (int i = 0; i < psf->params_NEW->n; i++) { 582 // apply the limits to all components or just the psf-model parameters? 583 if (psf->params_NEW->data[i] == NULL) 584 continue; 585 586 bool status = true; 587 status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MIN, i, PAR, NULL); 588 status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MAX, i, PAR, NULL); 589 if (!status) { 590 psTrace ("psModules.objects", 5, "Hitting parameter limits at (r,c) = (%.1f, %.1f)", Xo, Yo); 591 model->flags |= PM_MODEL_STATUS_LIMITS; 592 } 593 } 594 return(true); 595 } 596 537 597 //done I think 538 bool PM_MODEL_FIT_STATUS (pmModel *model) { 598 bool PM_MODEL_FIT_STATUS (void *inModel) 599 { 600 pmModel *model = inModel; 539 601 540 602 psF32 dP; … … 566 628 # undef PM_MODEL_RADIUS 567 629 # undef PM_MODEL_FROM_PSF 630 # undef PM_MODEL_PARAMS_FROM_PSF 568 631 # undef PM_MODEL_FIT_STATUS -
branches/eam_branch_20070817/psphot/src/models/pmModel_TEST1.c
r11702 r14545 16 16 *****************************************************************************/ 17 17 18 # define PM_MODEL_FUNC pmModelFunc_TEST1 19 # define PM_MODEL_FLUX pmModelFlux_TEST1 20 # define PM_MODEL_GUESS pmModelGuess_TEST1 21 # define PM_MODEL_LIMITS pmModelLimits_TEST1 22 # define PM_MODEL_RADIUS pmModelRadius_TEST1 23 # define PM_MODEL_FROM_PSF pmModelFromPSF_TEST1 24 # define PM_MODEL_FIT_STATUS pmModelFitStatus_TEST1 25 26 // XXX consider changing to form PAR[SXY]*(1/PAR[SXX]^2 + 1/PAR[SYY]^2)*X*Y 27 // this would provide natural limits on PAR[SXY] of -0.25 : +0.25 18 # define PM_MODEL_FUNC pmModelFunc_TEST1 19 # define PM_MODEL_FLUX pmModelFlux_TEST1 20 # define PM_MODEL_GUESS pmModelGuess_TEST1 21 # define PM_MODEL_LIMITS pmModelLimits_TEST1 22 # define PM_MODEL_RADIUS pmModelRadius_TEST1 23 # define PM_MODEL_FROM_PSF pmModelFromPSF_TEST1 24 # define PM_MODEL_PARAMS_FROM_PSF pmModelParamsFromPSF_TEST1 25 # define PM_MODEL_FIT_STATUS pmModelFitStatus_TEST1 28 26 29 27 // the model is a function of the pixel coordinate (pixcoord[0,1] = x,y) 30 28 psF32 PM_MODEL_FUNC(psVector *deriv, 31 const psVector *params,32 const psVector *pixcoord)29 const psVector *params, 30 const psVector *pixcoord) 33 31 { 34 32 psF32 *PAR = params->data.F32; … … 125 123 126 124 // make an initial guess for parameters 127 bool PM_MODEL_GUESS (pmModel *model, pmSource *source) 128 { 125 bool PM_MODEL_GUESS (void *inModel, void *inSource) 126 { 127 pmModel *model = inModel; 128 pmSource *source = inSource; 129 129 130 130 pmMoments *moments = source->moments; … … 160 160 norm = 0.0; 161 161 162 # define DZ 0.25162 # define DZ 0.25 163 163 164 164 float f0 = 1.0; … … 207 207 } 208 208 209 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf) 210 { 209 bool PM_MODEL_FROM_PSF (void *inModelPSF, void *inModelFLT, void *inPSF) 210 { 211 pmModel *modelPSF = inModelPSF; 212 pmModel *modelFLT = inModelFLT; 213 pmPSF *psf = inPSF; 211 214 212 215 psF32 *out = modelPSF->params->data.F32; … … 232 235 } 233 236 237 // construct the PSF model from the FLT model and the psf 238 // XXX is this sufficiently general do be a global function, not a pmModelClass function? 239 bool PM_MODEL_PARAMS_FROM_PSF (void *inModel, void *inPSF, float Xo, float Yo, float Io) 240 { 241 pmModel *model = inModel; 242 pmPSF *psf = inPSF; 243 244 psF32 *PAR = model->params->data.F32; 245 246 // we require these two parameters to exist 247 assert (psf->params_NEW->n > PM_PAR_YPOS); 248 assert (psf->params_NEW->n > PM_PAR_XPOS); 249 250 PAR[PM_PAR_SKY] = 0.0; 251 PAR[PM_PAR_I0] = Io; 252 PAR[PM_PAR_XPOS] = Xo; 253 PAR[PM_PAR_YPOS] = Yo; 254 255 // supply the model-fitted parameters, or copy from the input 256 for (int i = 0; i < psf->params_NEW->n; i++) { 257 if (i == PM_PAR_SKY) continue; 258 psPolynomial2D *poly = psf->params_NEW->data[i]; 259 assert (poly); 260 PAR[i] = psPolynomial2DEval(poly, Xo, Yo); 261 } 262 263 // the 2D PSF model fits polarization terms (E0,E1,E2) 264 // convert to shape terms (SXX,SYY,SXY) 265 // XXX user-defined value for limit? 266 if (!pmPSF_FitToModel (PAR, 0.1)) { 267 psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo); 268 return false; 269 } 270 271 // apply the model limits here: this truncates excessive extrapolation 272 // XXX do we need to do this still? should we put in asserts to test? 273 for (int i = 0; i < psf->params_NEW->n; i++) { 274 // apply the limits to all components or just the psf-model parameters? 275 if (psf->params_NEW->data[i] == NULL) 276 continue; 277 278 bool status = true; 279 status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MIN, i, PAR, NULL); 280 status &= PM_MODEL_LIMITS (PS_MINIMIZE_PARAM_MAX, i, PAR, NULL); 281 if (!status) { 282 psTrace ("psModules.objects", 5, "Hitting parameter limits at (r,c) = (%.1f, %.1f)", Xo, Yo); 283 model->flags |= PM_MODEL_STATUS_LIMITS; 284 } 285 } 286 return(true); 287 } 288 234 289 // XXX double-check these definitions below 235 290 // this test is invalid if the parameters are derived 236 291 // from the PSF model 237 bool PM_MODEL_FIT_STATUS (pmModel *model) 238 { 292 bool PM_MODEL_FIT_STATUS (void *inModel) 293 { 294 pmModel *model = inModel; 239 295 240 296 psF32 dP; … … 265 321 # undef PM_MODEL_RADIUS 266 322 # undef PM_MODEL_FROM_PSF 323 # undef PM_MODEL_PARAMS_FROM_PSF 267 324 # undef PM_MODEL_FIT_STATUS -
branches/eam_branch_20070817/psphot/src/pmFootprint.c
r14335 r14545 29 29 } 30 30 31 bool pm IsSpan(const psPtr ptr)31 bool pmSpanTest(const psPtr ptr) 32 32 { 33 33 return (psMemGetDeallocator(ptr) == (psFreeFunc)spanFree); … … 115 115 } 116 116 117 bool pm IsFootprint(const psPtr ptr) {117 bool pmFootprintTest(const psPtr ptr) { 118 118 return (psMemGetDeallocator(ptr) == (psFreeFunc)footprintFree); 119 119 } … … 762 762 // Set stop bits from peaks list 763 763 // 764 assert (peaks == NULL || peaks->n == 0 || pm IsPeak(peaks->data[0]));764 assert (peaks == NULL || peaks->n == 0 || pmPeakTest(peaks->data[0])); 765 765 if (peaks != NULL) { 766 766 for (int i = 0; i < peaks->n; i++) { … … 859 859 } 860 860 const pmFootprint *fp = footprints->data[0]; 861 assert(pm IsFootprint((const psPtr)fp));861 assert(pmFootprintTest((const psPtr)fp)); 862 862 const int numCols = fp->region.x1 - fp->region.x0 + 1; 863 863 const int numRows = fp->region.y1 - fp->region.y0 + 1; … … 884 884 psImage *pmSetFootprintID(const pmFootprint *fp, // the footprint to insert 885 885 const int id) { // the desired ID 886 assert(fp != NULL && pm IsFootprint((const psPtr)fp));886 assert(fp != NULL && pmFootprintTest((const psPtr)fp)); 887 887 const int numCols = fp->region.x1 - fp->region.x0 + 1; 888 888 const int numRows = fp->region.y1 - fp->region.y0 + 1; … … 910 910 psArray *pmGrowFootprintArray(const psArray *footprints, // footprints to grow 911 911 int r) { // how much to grow each footprint 912 assert (footprints->n == 0 || pm IsFootprint(footprints->data[0]));912 assert (footprints->n == 0 || pmFootprintTest(footprints->data[0])); 913 913 914 914 if (footprints->n == 0) { // we don't know the size of the footprint's region … … 964 964 const psArray *footprints2, // the other set 965 965 const int includePeaks) { // which peaks to set? 0x1 => footprints1, 0x2 => 2 966 assert (footprints1->n == 0 || pm IsFootprint(footprints1->data[0]));967 assert (footprints2->n == 0 || pm IsFootprint(footprints2->data[0]));966 assert (footprints1->n == 0 || pmFootprintTest(footprints1->data[0])); 967 assert (footprints2->n == 0 || pmFootprintTest(footprints2->data[0])); 968 968 969 969 if (footprints1->n == 0 || footprints2->n == 0) { // nothing to do but put copies on merged … … 1032 1032 const psArray *peaks) { // the pmPeaks 1033 1033 assert (footprints != NULL); 1034 assert (footprints->n == 0 || pm IsFootprint(footprints->data[0]));1034 assert (footprints->n == 0 || pmFootprintTest(footprints->data[0])); 1035 1035 assert (peaks != NULL); 1036 assert (peaks->n == 0 || pm IsPeak(peaks->data[0]));1036 assert (peaks->n == 0 || pmPeakTest(peaks->data[0])); 1037 1037 1038 1038 if (footprints->n == 0) { … … 1222 1222 psArray *pmFootprintArrayToPeaks(const psArray *footprints) { 1223 1223 assert(footprints != NULL); 1224 assert(footprints->n == 0 || pm IsFootprint(footprints->data[0]));1224 assert(footprints->n == 0 || pmFootprintTest(footprints->data[0])); 1225 1225 1226 1226 int npeak = 0; -
branches/eam_branch_20070817/psphot/src/pmFootprint.h
r13442 r14545 11 11 12 12 pmSpan *pmSpanAlloc(int y, int x1, int x2); 13 bool pm IsSpan(const psPtr ptr);13 bool pmSpanTest(const psPtr ptr); 14 14 int pmSpanSortByYX (const void **a, const void **b); 15 15 … … 25 25 26 26 pmFootprint *pmFootprintAlloc(int nspan, const psImage *img); 27 bool pm IsFootprint(const psPtr ptr);27 bool pmFootprintTest(const psPtr ptr); 28 28 29 29 pmFootprint *pmFootprintNormalize(pmFootprint *fp); -
branches/eam_branch_20070817/psphot/src/psphot.c
r14005 r14545 11 11 pmErrorRegister(); // register psModule's error codes/messages 12 12 psphotErrorRegister(); // register our error codes/messages 13 psphotModel GroupInit (); // load implementation-specific models13 psphotModelClassInit (); // load implementation-specific models 14 14 15 15 // load command-line arguments, options, and system config data -
branches/eam_branch_20070817/psphot/src/psphot.h
r14338 r14545 51 51 52 52 // basic support functions 53 void psphotModel GroupInit (void);53 void psphotModelClassInit (void); 54 54 int pmPeakSortBySN (const void **a, const void **b); 55 55 int pmPeakSortByY (const void **a, const void **b); -
branches/eam_branch_20070817/psphot/src/psphotChoosePSF.c
r13900 r14545 295 295 } 296 296 297 char *modelName = pmModel GetType (psf->type);297 char *modelName = pmModelClassGetName (psf->type); 298 298 psLogMsg ("psphot.pspsf", PS_LOG_INFO, "select psf model: %f sec\n", psTimerMark ("psphot")); 299 299 psLogMsg ("psphot.pspsf", PS_LOG_INFO, "psf model %s, ApResid: %f +/- %f\n", modelName, psf->ApResid, psf->dApResid); … … 315 315 PS_ASSERT_PTR_NON_NULL(image, false); 316 316 317 pmModel *modelEXT = pmModelAlloc (psf->type); 318 PS_ASSERT_PTR_NON_NULL(modelEXT, false); 319 320 // make a model with unit central intensity at the image center 321 modelEXT->params->data.F32[PM_PAR_SKY] = 0; 322 modelEXT->params->data.F32[PM_PAR_I0] = 1; 323 modelEXT->params->data.F32[PM_PAR_XPOS] = 0.5*image->numCols; 324 modelEXT->params->data.F32[PM_PAR_YPOS] = 0.5*image->numRows; 325 326 // construct a PSF model at this coordinate 327 pmModel *modelPSF = pmModelFromPSF (modelEXT, psf); 317 // construct a normalized PSF model at this coordinate (Io = 1.0) 318 pmModel *modelPSF = pmModelFromPSFforXY (psf, 0.5*image->numCols, 0.5*image->numRows, 1.0); 328 319 if (modelPSF == NULL) { 329 320 psError(PSPHOT_ERR_PSF, false, "Failed to estimate PSF model at image centre"); 330 psFree(modelEXT);331 321 return false; 332 322 } 333 323 334 // get the correct model-radius function335 pmModelRadius modelRadiusFunc = pmModelRadius_GetFunction (psf->type);336 337 324 // get the model full-width at half-max 338 psF64 FWHM_X = 2*model RadiusFunc(modelPSF->params, 0.5);325 psF64 FWHM_X = 2*modelPSF->modelRadius (modelPSF->params, 0.5); 339 326 340 327 // XXX make sure this is consistent with the re-definition of PM_PAR_SXX … … 351 338 psMetadataAddS32 (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_META_REPLACE, "Number of stars used to make PSF", psf->nPSFstars); 352 339 psMetadataAddBool(recipe, PS_LIST_TAIL, "PSFMODEL", PS_META_REPLACE, "Valid PSF Model?", true); 353 354 psFree (modelEXT);355 340 psFree (modelPSF); 356 341 -
branches/eam_branch_20070817/psphot/src/psphotCleanup.c
r12805 r14545 7 7 psTimerStop (); 8 8 psMemCheckCorruption (stderr, true); 9 pmModel GroupCleanup ();9 pmModelClassCleanup (); 10 10 psTimeFinalize (); 11 11 pmConceptsDone (); -
branches/eam_branch_20070817/psphot/src/psphotEvalFLT.c
r13804 r14545 37 37 } 38 38 39 keep = pmModelFitStatus(model);39 keep = model->modelFitStatus(model); 40 40 if (keep) return true; 41 41 -
branches/eam_branch_20070817/psphot/src/psphotFakeSources.c
r12792 r14545 23 23 source->type = PM_SOURCE_TYPE_STAR; 24 24 25 pmModelType modelType = pmModel SetType ("PS_MODEL_QGAUSS");25 pmModelType modelType = pmModelClassGetType ("PS_MODEL_QGAUSS"); 26 26 source->modelPSF = pmSourceModelGuess (source, modelType); 27 27 sources->data[i] = source; -
branches/eam_branch_20070817/psphot/src/psphotFindPeaks.c
r13900 r14545 95 95 96 96 // find the peaks in the smoothed image 97 psArray *peaks = pm FindImagePeaks(smooth_im, threshold);97 psArray *peaks = pmPeaksInImage (smooth_im, threshold); 98 98 if (peaks == NULL) { 99 99 // XXX this may also be due to a programming or config error -
branches/eam_branch_20070817/psphot/src/psphotGrowthCurve.c
r13900 r14545 14 14 float radius; 15 15 16 // create template model17 pmModel *modelRef = pmModelAlloc(psf->type);18 19 16 // use the center of the center pixel of the image 20 17 xc = 0.5*readout->image->numCols + readout->image->col0 + 0.5; … … 23 20 dy = psf->growth->maxRadius + 1; 24 21 25 // assign the x and y coords to the image center 26 // create an object with center intensity of 1000 27 modelRef->params->data.F32[PM_PAR_SKY] = 0; 28 modelRef->params->data.F32[PM_PAR_I0] = 1000; 29 modelRef->params->data.F32[PM_PAR_XPOS] = xc; 30 modelRef->params->data.F32[PM_PAR_YPOS] = yc; 31 32 // create modelPSF from this model 33 pmModel *model = pmModelFromPSF (modelRef, psf); 22 // create normalized model object at xc,yc 23 pmModel *model = pmModelFromPSFforXY (psf, xc, yc, 1.0); 34 24 35 25 // measure the fitMag for this model … … 76 66 psFree (mask); 77 67 psFree (model); 78 psFree (modelRef);79 68 80 69 return true; -
branches/eam_branch_20070817/psphot/src/psphotModelGroupInit.c
r12792 r14545 7 7 # include "models/pmModel_STRAIL.c" 8 8 9 static pmModel GroupuserModels[] = {10 {"PS_MODEL_TEST1", 7, pmModelFunc_TEST1, pmModelFlux_TEST1, pmModelRadius_TEST1, pmModelLimits_TEST1, pmModelGuess_TEST1, pmModelFromPSF_TEST1, pmModel FitStatus_TEST1},11 {"PS_MODEL_STRAIL", 9, pmModelFunc_STRAIL, pmModelFlux_STRAIL, pmModelRadius_STRAIL, pmModelLimits_STRAIL, pmModelGuess_STRAIL, pmModelFromPSF_STRAIL, pmModel FitStatus_STRAIL},9 static pmModelClass userModels[] = { 10 {"PS_MODEL_TEST1", 7, pmModelFunc_TEST1, pmModelFlux_TEST1, pmModelRadius_TEST1, pmModelLimits_TEST1, pmModelGuess_TEST1, pmModelFromPSF_TEST1, pmModelParamsFromPSF_TEST1, pmModelFitStatus_TEST1}, 11 {"PS_MODEL_STRAIL", 9, pmModelFunc_STRAIL, pmModelFlux_STRAIL, pmModelRadius_STRAIL, pmModelLimits_STRAIL, pmModelGuess_STRAIL, pmModelFromPSF_STRAIL, pmModelParamsFromPSF_STRAIL, pmModelFitStatus_STRAIL}, 12 12 }; 13 13 14 void psphotModel GroupInit (void)14 void psphotModelClassInit (void) 15 15 { 16 16 17 // if pmModel GroupInit returns false, we have already init'ed18 if (!pmModel GroupInit ()) return;17 // if pmModelClassInit returns false, we have already init'ed 18 if (!pmModelClassInit ()) return; 19 19 20 int Nmodels = sizeof (userModels) / sizeof (pmModel Group);20 int Nmodels = sizeof (userModels) / sizeof (pmModelClass); 21 21 for (int i = 0; i < Nmodels; i++) { 22 pmModel GroupAdd (&userModels[i]);22 pmModelClassAdd (&userModels[i]); 23 23 } 24 24 return; -
branches/eam_branch_20070817/psphot/src/psphotModelTest.c
r14348 r14545 89 89 modelName = item->data.V; 90 90 } 91 modelType = pmModel SetType (modelName);91 modelType = pmModelClassGetType (modelName); 92 92 if (modelType < 0) psAbort("unknown model %s", modelName); 93 93 source->type = PM_SOURCE_TYPE_EXTENDED; … … 118 118 modelName = item->data.V; 119 119 } 120 modelType = pmModel SetType (modelName);120 modelType = pmModelClassGetType (modelName); 121 121 if (modelType < 0) psAbort("unknown model %s", modelName); 122 122 source->type = PM_SOURCE_TYPE_EXTENDED; … … 148 148 149 149 // if any parameters are defined by the user, take those values 150 int nParams = pmModel ParameterCount (modelType);150 int nParams = pmModelClassParameterCount (modelType); 151 151 psF32 *params = model->params->data.F32; 152 152 params[PM_PAR_XPOS] = xObj; // XXX use the user-supplied value, -
branches/eam_branch_20070817/psphot/src/psphotPSFConvModel.c
r14348 r14545 58 58 psVector *dparams = modelConv->dparams; 59 59 60 // get the model function for this model61 pmModelFunc modelFunc = pmModelFunc_GetFunction (modelConv->type);62 if (!modelFunc)63 psAbort("invalid model function");64 65 // get the limits function for this model66 pmModelLimits checkLimits = pmModelLimits_GetFunction (modelConv->type);67 if (!checkLimits)68 psAbort("invalid model limits function");69 70 60 // create the minimization constraints 71 61 psMinConstraint *constraint = psMinConstraintAlloc(); 72 62 constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_U8); 73 constraint->checkLimits = checkLimits;63 constraint->checkLimits = modelConv->modelLimits; 74 64 75 65 // set parameter mask based on fitting mode … … 81 71 // force the floating parameters to fall within the contraint ranges 82 72 for (int i = 0; i < params->n; i++) { 83 checkLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL);84 checkLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL);73 modelConv->modelLimits (PS_MINIMIZE_PARAM_MIN, i, params->data.F32, NULL); 74 modelConv->modelLimits (PS_MINIMIZE_PARAM_MAX, i, params->data.F32, NULL); 85 75 } 86 76 … … 90 80 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32); 91 81 92 bool fitStatus = psphotModelWithPSF_LMM (myMin, covar, params, constraint, source, psf, model Func);82 bool fitStatus = psphotModelWithPSF_LMM (myMin, covar, params, constraint, source, psf, modelConv->modelFunc); 93 83 for (int i = 0; i < dparams->n; i++) { 94 84 if (psTraceGetLevel("psphot") >= 4) { -
branches/eam_branch_20070817/psphot/src/psphotPSFResiduals.c
r12792 r14545 12 12 if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue; 13 13 14 // XXX if a source is faint, it will not have moments measured. 15 // it must be modelled as a PSF. In this case, we need to use 16 // the peak centroid to get the coordinates and get the peak flux 17 // from the image? 18 19 // use the source moments, etc to guess basic model parameters 20 pmModel *modelEXT = pmSourceModelGuess (source, psf->type); 21 22 // XXX put this in a function of its own.. 23 if (modelEXT == NULL) { 24 psErrorClear (); // XXX need to clear the error from failing the model 25 modelEXT = pmModelAlloc(psf->type); 26 psF32 *PAR = modelEXT->params->data.F32; 27 PAR[PM_PAR_SKY] = 0; 28 // XXX get this from the image pixels 29 PAR[PM_PAR_I0] = source->peak->flux; 30 PAR[PM_PAR_XPOS] = source->peak->xf; 31 PAR[PM_PAR_YPOS] = source->peak->yf; 14 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 15 Xo = source->moments->x; 16 Yo = source->moments->y; 17 Io = source->peak->flux; 32 18 } else { 33 // these valuse are set in pmSourceModelGuess, should this rule be in there as well? 34 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 35 modelEXT->params->data.F32[PM_PAR_XPOS] = source->moments->x; 36 modelEXT->params->data.F32[PM_PAR_YPOS] = source->moments->y; 37 } else { 38 modelEXT->params->data.F32[PM_PAR_XPOS] = source->peak->xf; 39 modelEXT->params->data.F32[PM_PAR_YPOS] = source->peak->yf; 40 } 19 Xo = source->peak->xf; 20 Yo = source->peak->yf; 21 Io = source->peak->flux; 41 22 } 42 23 43 24 // set PSF parameters for this model (apply 2D shape model) 44 pmModel *modelPSF = pmModelFromPSF (modelEXT, psf); 45 psFree (modelEXT); 25 pmModel *modelPSF = pmModelFromPSFforXY (psf, Xo, Yo, Io); 46 26 47 27 // XXX need to define the guess flux? -
branches/eam_branch_20070817/psphot/src/psphotRadiusChecks.c
r13035 r14545 6 6 static float PSF_FIT_RADIUS = 0; // radius to use in fitting (ignored if <= 0, 7 7 // and a per-object radius is calculated) 8 static pmModelRadius modelRadiusPSF;9 8 10 9 bool psphotInitRadiusPSF(const psMetadata *recipe, … … 17 16 PSF_FIT_RADIUS = psMetadataLookupF32(&status, recipe, "PSF_FIT_RADIUS"); 18 17 19 // this function specifies the radius at this the model hits the given flux20 modelRadiusPSF = pmModelRadius_GetFunction (type);21 18 return true; 22 19 } … … 34 31 if (radiusFit <= 0) { // use fixed radius 35 32 if (moments == NULL) { 36 radiusFit = model RadiusPSF(model->params, PSF_FIT_NSIGMA*moments->dSky);33 radiusFit = model->modelRadius(model->params, PSF_FIT_NSIGMA*moments->dSky); 37 34 } else { 38 radiusFit = model RadiusPSF(model->params, 1.0);35 radiusFit = model->modelRadius(model->params, 1.0); 39 36 } 40 37 } … … 62 59 63 60 // set the fit radius based on the object flux limit and the model 64 model->radiusFit = (RADIUS_TYPE) (model RadiusPSF(model->params, PSF_FIT_NSIGMA*moments->dSky) + dR + PSF_FIT_PADDING);61 model->radiusFit = (RADIUS_TYPE) (model->modelRadius (model->params, PSF_FIT_NSIGMA*moments->dSky) + dR + PSF_FIT_PADDING); 65 62 if (isnan(model->radiusFit)) psAbort("error in radius"); 66 63 … … 78 75 static float EXT_FIT_NSIGMA; 79 76 static float EXT_FIT_PADDING; 80 static pmModelRadius modelRadiusEXT;81 77 82 78 bool psphotInitRadiusEXT (psMetadata *recipe, pmModelType type) { … … 87 83 EXT_FIT_PADDING = psMetadataLookupF32 (&status, recipe, "EXT_FIT_PADDING"); 88 84 89 // this function specifies the radius at this the model hits the given flux90 modelRadiusEXT = pmModelRadius_GetFunction (type);91 85 return true; 92 86 } … … 101 95 102 96 // set the fit radius based on the object flux limit and the model 103 model->radiusFit = (RADIUS_TYPE) (model RadiusEXT(model->params, EXT_FIT_NSIGMA*moments->dSky) + EXT_FIT_PADDING);97 model->radiusFit = (RADIUS_TYPE) (model->modelRadius (model->params, EXT_FIT_NSIGMA*moments->dSky) + EXT_FIT_PADDING); 104 98 if (isnan(model->radiusFit)) psAbort("error in radius"); 105 99 -
branches/eam_branch_20070817/psphot/src/psphotSourceFits.c
r13900 r14545 195 195 // extended source model descriptions 196 196 char *modelNameEXT = psMetadataLookupStr (&status, recipe, "EXT_MODEL"); 197 modelTypeEXT = pmModel SetType (modelNameEXT);197 modelTypeEXT = pmModelClassGetType (modelNameEXT); 198 198 psphotInitRadiusEXT (recipe, modelTypeEXT); 199 199 -
branches/eam_branch_20070817/psphot/src/psphotTestSourceOutput.c
r12950 r14545 21 21 psVector *x = psVectorAlloc(2, PS_TYPE_F32); 22 22 psVector *params = model->params; 23 pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);24 23 psS32 imageCol; 25 24 psS32 imageRow; … … 68 67 // set the appropriate pixel value for this coordinate 69 68 if (mode & PSPHOT_ADD_MODEL) { 70 pixelValue = model Func (NULL, params, x) - skyValue;69 pixelValue = model->modelFunc (NULL, params, x) - skyValue; 71 70 } else { 72 71 pixelValue = 0.0;
Note:
See TracChangeset
for help on using the changeset viewer.
