Changeset 35559
- Timestamp:
- May 9, 2013, 12:15:43 PM (13 years ago)
- Location:
- trunk/psphot
- Files:
-
- 12 edited
-
. (modified) (1 prop)
-
src (modified) (1 prop)
-
src/models/pmModel_STRAIL.c (modified) (1 diff)
-
src/models/pmModel_TEST1.c (modified) (1 diff)
-
src/psphotExtendedSourceFits.c (modified) (6 diffs)
-
src/psphotFakeSources.c (modified) (1 diff)
-
src/psphotMakeResiduals.c (modified) (1 diff)
-
src/psphotModelTestArguments.c (modified) (2 diffs)
-
src/psphotModelTestReadout.c (modified) (10 diffs)
-
src/psphotSetThreads.c (modified) (1 diff)
-
src/psphotSourceFits.c (modified) (4 diffs)
-
src/psphotStackImageLoop.c (modified) (1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20130307/psphot (added) merged: 35322,35350,35377,35413 /branches/eam_branches/ipp-20130419/psphot (added) merged: 35421,35436,35458,35554
- Property svn:mergeinfo changed
-
trunk/psphot/src
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20130307/psphot/src (added) merged: 35322,35350,35377,35413 /branches/eam_branches/ipp-20130419/psphot/src (added) merged: 35421,35436,35458,35554
- Property svn:mergeinfo changed
-
trunk/psphot/src/models/pmModel_STRAIL.c
r31154 r35559 475 475 476 476 //fixed I think...no good way of guessing as far as I can tell 477 bool PM_MODEL_GUESS (pmModel *model, pmSource *source )477 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 478 478 { 479 479 pmMoments *Smoments = source->moments; -
trunk/psphot/src/models/pmModel_TEST1.c
r31154 r35559 123 123 124 124 // make an initial guess for parameters 125 bool PM_MODEL_GUESS (pmModel *model, pmSource *source )125 bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 126 126 { 127 127 pmMoments *moments = source->moments; -
trunk/psphot/src/psphotExtendedSourceFits.c
r34404 r35559 90 90 assert (markVal); 91 91 92 // source fitting parameters for extended source fits 93 int fitIter = psMetadataLookupS32(&status, recipe, "EXT_FIT_ITER"); // Max number of fit iterations 94 assert (status && fitIter > 0); 95 96 float fitMinTol = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MIN_TOL"); // Fit tolerance 97 if (!status || !isfinite(fitMinTol) || fitMinTol <= 0) { 98 fitMinTol = psMetadataLookupF32 (&status, recipe, "PSF_FIT_TOL"); // Fit tolerance 99 if (!status || !isfinite(fitMinTol) || fitMinTol <= 0) { 100 psAbort("PSF_FIT_MIN_TOL (and PSF_FIT_TOL) not defined or positive"); 101 } 102 } 103 104 float fitMaxTol = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MAX_TOL"); // Fit tolerance 105 if (!status || !isfinite(fitMaxTol) || fitMaxTol <= 0) { 106 fitMaxTol = 1.0; 107 } 108 92 109 // maskVal is used to test for rejected pixels, and must include markVal 93 110 maskVal |= markVal; … … 181 198 182 199 PS_ARRAY_ADD_SCALAR(job->args, psfSize, PS_TYPE_S32); 200 PS_ARRAY_ADD_SCALAR(job->args, fitIter, PS_TYPE_S32); 201 PS_ARRAY_ADD_SCALAR(job->args, fitMinTol, PS_TYPE_F32); 202 PS_ARRAY_ADD_SCALAR(job->args, fitMaxTol, PS_TYPE_F32); 203 183 204 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 184 205 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); … … 293 314 psRegion *region = job->args->data[4]; 294 315 int psfSize = PS_SCALAR_VALUE(job->args->data[5],S32); 295 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[6],PS_TYPE_IMAGE_MASK_DATA); 296 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[7],PS_TYPE_IMAGE_MASK_DATA); 316 int fitIter = PS_SCALAR_VALUE(job->args->data[6],S32); 317 float fitMinTol = PS_SCALAR_VALUE(job->args->data[7],F32); 318 float fitMaxTol = PS_SCALAR_VALUE(job->args->data[8],F32); 319 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[9],PS_TYPE_IMAGE_MASK_DATA); 320 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[10],PS_TYPE_IMAGE_MASK_DATA); 297 321 298 322 // Define source fitting parameters for extended source fits … … 301 325 fitOptions->saveCovariance = true; // XXX make this a user option? 302 326 fitOptions->covarFactor = psImageCovarianceFactorForAperture(readout->covariance, 10.0); // Covariance matrix 303 304 // XXX for now, use the defaults for the rest: 305 // fitOptions->nIter = fitIter; 306 // fitOptions->tol = fitTol; 307 // fitOptions->poissonErrors = poisson; 308 // fitOptions->weight = PS_SQR(skySig); 327 fitOptions->nIter = fitIter; 328 fitOptions->minTol = fitMinTol; 329 fitOptions->maxTol = fitMaxTol; 309 330 310 331 // choose the sources of interest … … 335 356 // set the fit radius based on the first radial moment (also sets the mask pixels) 336 357 psphotSetRadiusMomentsExact(&fitRadius, &windowRadius, readout, source, markVal); // NOTE : 6 allocs 358 359 // XXX WATCH OUT HERE!! 360 // fitRadius = 30; 337 361 338 362 // UPDATE : we have changed the moments calculation. There is now an iteration within … … 498 522 499 523 // change the value of a scalar on the array (wrap this and put it in psArray.h) 500 scalar = job->args->data[ 8];524 scalar = job->args->data[11]; 501 525 scalar->data.S32 = Next; 502 526 503 scalar = job->args->data[ 9];527 scalar = job->args->data[12]; 504 528 scalar->data.S32 = Nconvolve; 505 529 506 scalar = job->args->data[1 0];530 scalar = job->args->data[13]; 507 531 scalar->data.S32 = NconvolvePass; 508 532 509 scalar = job->args->data[1 1];533 scalar = job->args->data[14]; 510 534 scalar->data.S32 = Nplain; 511 535 512 scalar = job->args->data[1 2];536 scalar = job->args->data[15]; 513 537 scalar->data.S32 = NplainPass; 514 538 515 scalar = job->args->data[1 3];539 scalar = job->args->data[16]; 516 540 scalar->data.S32 = Nfaint; 517 541 518 scalar = job->args->data[1 4];542 scalar = job->args->data[17]; 519 543 scalar->data.S32 = Nfail; 520 544 -
trunk/psphot/src/psphotFakeSources.c
r19881 r35559 24 24 25 25 pmModelType modelType = pmModelClassGetType ("PS_MODEL_QGAUSS"); 26 source->modelPSF = pmSourceModelGuess (source, modelType );26 source->modelPSF = pmSourceModelGuess (source, modelType, 0, 0); 27 27 sources->data[i] = source; 28 28 } -
trunk/psphot/src/psphotMakeResiduals.c
r34086 r35559 105 105 if (model == NULL) continue; // model must be defined 106 106 107 psImage *image = psImageCopy (NULL, source->pixels,PS_TYPE_F32);108 psImage * variance = psImageCopy (NULL, source->variance, PS_TYPE_F32);109 psImage * mask = psImageCopy (NULL, source->maskView, PS_TYPE_IMAGE_MASK);107 psImage *image = psImageCopy (NULL, source->pixels, PS_TYPE_F32); 108 psImage *mask = psImageCopy (NULL, source->maskView ? source->maskView : source->maskObj, PS_TYPE_IMAGE_MASK); 109 psImage *variance = psImageCopy (NULL, source->variance ? source->variance : source->pixels, PS_TYPE_F32); 110 110 pmModelSub (image, mask, model, PM_MODEL_OP_FUNC, maskVal); 111 111 -
trunk/psphot/src/psphotModelTestArguments.c
r32348 r35559 151 151 } 152 152 153 // chip selection is used to limit chips to be processed 154 if ((N = psArgumentGet (argc, argv, "-moments-radius"))) { 155 psArgumentRemove (N, &argc, argv); 156 psMetadataAddBool (config->arguments, PS_LIST_TAIL, "TEST_MOMENTS_RADIUS", PS_DATA_BOOL, "", true); 157 } 158 153 159 // if these command-line options are supplied, load the file name lists into config->arguments 154 160 // override any configuration-specified source for these files … … 160 166 pmConfigFileSetsMD (config->arguments, &argc, argv, "SRC", "-src", "-srclist"); 161 167 pmConfigFileSetsMD (config->arguments, &argc, argv, "SRCTEXT", "-srctext", "-srctextlist"); 168 169 pmConfigFileSetsMD (config->arguments, &argc, argv, "PSPHOT.PSF", "-psf", "-psflist"); 162 170 163 171 if (argc == 1) { -
trunk/psphot/src/psphotModelTestReadout.c
r32348 r35559 5 5 6 6 bool status; 7 8 psTimerStart ("modelTest"); 7 9 8 10 pmModelClassSetLimits(PM_MODEL_LIMITS_LAX); … … 41 43 } 42 44 45 // load the psf model, if suppled. FWHM_MAJ,FWHM_MIN,etc are determined and saved on 46 // readout->analysis. NOTE: this function currently only loads from PSPHOT.PSF.LOAD 47 if (!psphotLoadPSF (config, view, filerule)) { // ??? need to supply 2 ? 48 psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model"); 49 return psphotReadoutCleanup (config, view, filerule); 50 } 51 43 52 float MIN_KRON_RADIUS = 5.0; 44 53 … … 53 62 // maskVal is used to test for rejected pixels, and must include markVal 54 63 maskVal |= markVal; 64 65 // what fraction of the PSF is used? (radius in pixels : 2 -> 5x5 box) 66 int psfSize = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE"); 67 assert (status); 55 68 56 69 // find the currently selected readout … … 84 97 85 98 // define the source of interest 86 float xObj = psMetadataLookupF32 (&status, recipe, "TEST_FIT_X");99 float xObj = psMetadataLookupF32 (&status, recipe, "TEST_FIT_X"); 87 100 float yObj = psMetadataLookupF32 (&status, recipe, "TEST_FIT_Y"); 88 101 if (!isfinite(xObj) || !isfinite(yObj)) psAbort ("object position is not defined"); … … 99 112 source->type = PM_SOURCE_TYPE_EXTENDED; 100 113 114 bool TEST_FIT_CONVOLVED = psMetadataLookupBool (&status, recipe, "TEST_FIT_CONVOLVED"); 115 101 116 // find the local sky 102 117 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 103 118 if (!status) psAbort("pmSourceLocalSky error"); 104 119 105 { 120 bool testMomentsRadius = psMetadataLookupBool (&status, config->arguments, "TEST_MOMENTS_RADIUS"); 121 if (testMomentsRadius) { 106 122 // XXX I want to test an iterative aperture for brighter sources 107 123 float radius = mRADIUS; … … 109 125 110 126 // get the source moments 111 status = pmSourceMoments (source, radius, 0. 0, 0.0, MIN_KRON_RADIUS, maskVal);127 status = pmSourceMoments (source, radius, 0.25*radius, 0.0, MIN_KRON_RADIUS, maskVal); 112 128 if (!status) psAbort("psSourceMoments error"); 113 129 … … 121 137 122 138 // get the source moments 123 status = pmSourceMoments (source, mRADIUS, 0. 0, 0.0, MIN_KRON_RADIUS, maskVal);139 status = pmSourceMoments (source, mRADIUS, 0.25*mRADIUS, 0.0, MIN_KRON_RADIUS, maskVal); 124 140 if (!status) psAbort("psSourceMoments error"); 125 141 … … 135 151 fprintf (stderr, "axes: %f @ (%f, %f)\n", axes.theta*180/M_PI, axes.major, axes.minor); 136 152 153 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 154 if (psf) { 155 // set PSF parameters for this model (apply 2D shape model to coordinates Xo, Yo) 156 source->peak->rawFlux = source->moments->Peak; 157 float Io = source->moments->Peak; 158 source->modelPSF = pmModelFromPSFforXY(psf, xObj, yObj, Io); 159 } 160 137 161 // get the initial model parameter guess 138 pmModel *model = pmSourceModelGuess (source, modelType );162 pmModel *model = pmSourceModelGuess (source, modelType, maskVal, markVal); 139 163 source->modelEXT = model; 140 164 … … 159 183 fprintf (stderr, "peak: %f @ (%f, %f)\n", source->moments->Sum*area, (double)source->peak->x, (double)source->peak->y); 160 184 161 // list model input shape 162 psEllipseShape shape; 163 shape.sx = 1.4 / model->params->data.F32[4]; 164 shape.sy = 1.4 / model->params->data.F32[5]; 165 shape.sxy = model->params->data.F32[6]; 166 axes = psEllipseShapeToAxes (shape, 20.0); 167 168 fprintf (stderr, "guess: %f @ (%f, %f)\n", axes.theta*180/M_PI, axes.major, axes.minor); 185 if (modelType == pmModelClassGetType("PS_MODEL_TRAIL")) { 186 fprintf (stderr, "guess: %f @ (%f, %f)\n", params[6]*180/M_PI, params[4], params[5]); 187 } else { 188 // list model input shape 189 psEllipseShape shape; 190 shape.sx = 1.4 / model->params->data.F32[4]; 191 shape.sy = 1.4 / model->params->data.F32[5]; 192 shape.sxy = model->params->data.F32[6]; 193 axes = psEllipseShapeToAxes (shape, 20.0); 194 fprintf (stderr, "guess: %f @ (%f, %f)\n", axes.theta*180/M_PI, axes.major, axes.minor); 195 } 169 196 170 197 fprintf (stderr, "input parameters: \n"); … … 190 217 fitOptions->covarFactor = psImageCovarianceFactorForAperture(readout->covariance, 10.0); // Covariance matrix 191 218 192 status = pmSourceFitModel (source, model, fitOptions, maskVal); 219 if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) { 220 fitOptions->mode = PM_SOURCE_FIT_NO_INDEX; 221 } 222 if (modelType == pmModelClassGetType("PS_MODEL_TRAIL")) { 223 fitOptions->mode = PM_SOURCE_FIT_TRAIL; 224 } 225 226 if (TEST_FIT_CONVOLVED) { 227 pmPCMdata *pcm = pmPCMinit (source, fitOptions, model, maskVal, psfSize); 228 if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) { 229 psphotSersicModelClassGuessPCM (pcm, source); 230 } else { 231 pmSourceModelGuessPCM (pcm, source, maskVal, markVal); 232 } 233 pmPCMupdate(pcm, source, fitOptions, model); 234 pmSourceFitPCM (pcm, source, fitOptions, maskVal, markVal, psfSize); 235 psFree (pcm); 236 } else { 237 status = pmSourceFitModel (source, model, fitOptions, maskVal); 238 } 193 239 194 240 // measure the source mags -
trunk/psphot/src/psphotSetThreads.c
r34559 r35559 40 40 psFree(task); 41 41 42 task = psThreadTaskAlloc("PSPHOT_EXTENDED_FIT", 1 5);42 task = psThreadTaskAlloc("PSPHOT_EXTENDED_FIT", 18); 43 43 task->function = &psphotExtendedSourceFits_Threaded; 44 44 psThreadTaskAdd(task); -
trunk/psphot/src/psphotSourceFits.c
r34258 r35559 457 457 458 458 // use the source moments, etc to guess basic model parameters 459 pmModel *model = pmSourceModelGuess (source, modelType );459 pmModel *model = pmSourceModelGuess (source, modelType, maskVal, markVal); 460 460 if (!model) { 461 461 psTrace ("psphot", 5, "failed to generate a model for source: moments: %f %f\n", source->moments->Mxx, source->moments->Myy); … … 625 625 model->params->data.F32[PM_PAR_7] = 0.5/indexGuess[i]; 626 626 627 if (!model->modelGuess(model, source )) {627 if (!model->modelGuess(model, source, maskVal, markVal)) { 628 628 model->flags |= PM_MODEL_STATUS_BADARGS; 629 629 return false; … … 648 648 model->flags = PM_MODEL_STATUS_NONE; // do not attempt to handle failures here, let the next iteration deal with it 649 649 model->params->data.F32[PM_PAR_7] = 0.5/indexGuess[iMin]; 650 model->modelGuess(model, source );650 model->modelGuess(model, source, maskVal, markVal); 651 651 652 652 return true; … … 677 677 model->params->data.F32[PM_PAR_7] = indexGuess[i]; 678 678 679 if (!model->modelGuess(model, source )) {679 if (!model->modelGuess(model, source, maskVal, markVal)) { 680 680 model->flags |= PM_MODEL_STATUS_BADARGS; 681 681 return false; -
trunk/psphot/src/psphotStackImageLoop.c
- Property svn:mergeinfo changed
Note:
See TracChangeset
for help on using the changeset viewer.
