Changeset 30044
- Timestamp:
- Dec 15, 2010, 11:25:46 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
psLib/src/imageops/psImageMapFit.c (modified) (12 diffs)
-
psLib/src/imageops/psImageMapFit.h (modified) (4 diffs)
-
psModules/src/objects/pmPSFtry.h (modified) (2 diffs)
-
psModules/src/objects/pmPSFtryMakePSF.c (modified) (9 diffs)
-
psModules/src/objects/pmTrend2D.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageMapFit.c
r30031 r30044 48 48 49 49 // map defines the output image dimensions and scaling. 50 bool psImageMapFit(bool * goodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,50 bool psImageMapFit(bool *pGoodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 51 51 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 52 52 { 53 53 // XXX Add Asserts 54 54 55 * goodFit = false;55 *pGoodFit = false; 56 56 57 57 // dimensions of the output map image … … 83 83 map->map->data.F32[0][0] = psStatsGetValue(map->stats, mean); 84 84 map->error->data.F32[0][0] = psStatsGetValue(map->stats, stdev); 85 * goodFit = true;85 *pGoodFit = true; 86 86 return true; 87 87 } … … 89 89 if (Nx == 1) { 90 90 bool status; 91 status = psImageMapFit1DinY ( goodFit, map, mask, maskValue, x, y, f, df);91 status = psImageMapFit1DinY (pGoodFit, map, mask, maskValue, x, y, f, df); 92 92 return status; 93 93 } 94 94 if (Ny == 1) { 95 95 bool status; 96 status = psImageMapFit1DinX ( goodFit, map, mask, maskValue, x, y, f, df);96 status = psImageMapFit1DinX (pGoodFit, map, mask, maskValue, x, y, f, df); 97 97 return status; 98 98 } … … 339 339 psFree (Empty); 340 340 341 * goodFit = true;341 *pGoodFit = true; 342 342 return true; 343 343 } 344 344 345 345 // measure residuals on each pass and clip outliers based on stats 346 bool psImageMapClipFit(bool * goodFit, psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue,346 bool psImageMapClipFit(bool *pGoodFit, psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue, 347 347 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 348 348 { … … 354 354 psAssert(f, "impossible"); 355 355 356 * goodFit = false;356 *pGoodFit = false; 357 357 358 358 // the user supplies one of various stats option pairs, … … 398 398 psTrace("psLib.imageops", 6, "Loop iteration %d. Calling psImageMapFit()\n", N); 399 399 psS32 Nkeep = 0; 400 if (!psImageMapFit( goodFit, map, mask, maskValue, x, y, f, df)) {400 if (!psImageMapFit(pGoodFit, map, mask, maskValue, x, y, f, df)) { 401 401 psError(PS_ERR_UNKNOWN, false, "Could not fit image map.\n"); 402 402 psFree(resid); … … 404 404 return false; 405 405 } 406 if (! goodFit) {406 if (!*pGoodFit) { 407 407 psWarning ("bad fit to image map, try something else"); 408 408 return true; … … 463 463 psFree(resid); 464 464 if (!inMask) psFree (mask); 465 * goodFit = true; // XXX probably don't need to set this (set by psImageMapFit)465 *pGoodFit = true; // XXX probably don't need to set this (set by psImageMapFit) 466 466 return true; 467 467 } 468 468 469 469 // map defines the output image dimensions and scaling. 470 bool psImageMapFit1DinY(bool * goodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,470 bool psImageMapFit1DinY(bool *pGoodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 471 471 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 472 472 { … … 474 474 assert (map->binning->nXruff == 1); 475 475 476 * goodFit = false;476 *pGoodFit = false; 477 477 478 478 // dimensions of the output map image … … 613 613 psFree (Empty); 614 614 615 * goodFit = true;615 *pGoodFit = true; 616 616 return true; 617 617 } 618 618 619 619 // map defines the output image dimensions and scaling. 620 bool psImageMapFit1DinX(bool * goodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,620 bool psImageMapFit1DinX(bool *pGoodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue, 621 621 const psVector *x, const psVector *y, const psVector *f, const psVector *df) 622 622 { … … 624 624 assert (map->binning->nYruff == 1); 625 625 626 * goodFit = false;626 *pGoodFit = false; 627 627 628 628 // dimensions of the output map image … … 763 763 psFree (Empty); 764 764 765 * goodFit = true;765 *pGoodFit = true; 766 766 return true; 767 767 } -
trunk/psLib/src/imageops/psImageMapFit.h
r30031 r30044 8 8 9 9 // fit the image map to a set of points 10 bool psImageMapFit(bool * goodFit,10 bool psImageMapFit(bool *pGoodFit, 11 11 psImageMap *map, 12 12 const psVector *mask, … … 19 19 20 20 // fit the image map to a set of points 21 bool psImageMapClipFit(bool * goodFit,21 bool psImageMapClipFit(bool *pGoodFit, 22 22 psImageMap *map, 23 23 psStats *stats, … … 30 30 ); 31 31 32 bool psImageMapFit1DinY(bool * goodFit,32 bool psImageMapFit1DinY(bool *pGoodFit, 33 33 psImageMap *map, 34 34 const psVector *mask, … … 40 40 ); 41 41 42 bool psImageMapFit1DinX(bool * goodFit,42 bool psImageMapFit1DinX(bool *pGoodFit, 43 43 psImageMap *map, 44 44 const psVector *mask, -
trunk/psModules/src/objects/pmPSFtry.h
r30031 r30044 100 100 bool pmPSFtryFitEXT (pmPSFtry *psfTry, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal); 101 101 102 bool pmPSFtryMakePSF (bool * goodFit, pmPSFtry *psfTry);102 bool pmPSFtryMakePSF (bool *pGoodFit, pmPSFtry *psfTry); 103 103 104 104 bool pmPSFtryFitPSF (pmPSFtry *psfTry, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal); … … 123 123 ); 124 124 125 bool pmPSFFitShapeParams (bool * goodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask);125 bool pmPSFFitShapeParams (bool *pGoodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask); 126 126 127 127 float psVectorSystematicError (psVector *residuals, psVector *errors, float clipFraction); -
trunk/psModules/src/objects/pmPSFtryMakePSF.c
r30031 r30044 50 50 Note: some of the array entries may be NULL (failed fits); ignore them. 51 51 *****************************************************************************/ 52 bool pmPSFtryMakePSF (bool * goodFit, pmPSFtry *psfTry)52 bool pmPSFtryMakePSF (bool *pGoodFit, pmPSFtry *psfTry) 53 53 { 54 54 PS_ASSERT_PTR_NON_NULL(psfTry, false); … … 74 74 75 75 // fit the shape parameters (SXX, SYY, SXY) as a function of position 76 if (!pmPSFFitShapeParams ( goodFit, psf, psfTry->sources, x, y, srcMask)) {76 if (!pmPSFFitShapeParams (pGoodFit, psf, psfTry->sources, x, y, srcMask)) { 77 77 psFree(x); 78 78 psFree(y); 79 79 return false; 80 80 } 81 if (! goodFit) {81 if (!*pGoodFit) { 82 82 psWarning ("poor fit to PSF shape parameters for trend order %d, %d, skipping\n", psf->trendNx, psf->trendNy); 83 83 psFree(x); … … 121 121 // the mask is carried from previous steps and updated with this operation 122 122 // the weight is either the flux error or NULL, depending on 'psf->poissonErrorParams' 123 if (!pmTrend2DFit ( goodFit, trend, srcMask, 0xff, x, y, z, NULL)) {123 if (!pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, z, NULL)) { 124 124 psError(PS_ERR_UNKNOWN, false, "failed to build psf model for parameter %d", i); 125 125 psFree(x); … … 128 128 return false; 129 129 } 130 if (! goodFit) {130 if (!*pGoodFit) { 131 131 // if we do not get a good fit (but do not actually hit an error), 132 132 // tell the calling program to try something else … … 154 154 155 155 pmModel *modelPSF = pmModelFromPSF (source->modelEXT, psf); 156 if (!modelPSF) { 157 fprintf(f, "modelPSF is NULL\n"); 158 break; 159 } 160 if (!source->modelEXT) { 161 fprintf(f, "source->modelEXT is NULL\n"); 162 break; 163 } 156 164 157 165 fprintf (f, "%f %f : ", source->modelEXT->params->data.F32[PM_PAR_XPOS], source->modelEXT->params->data.F32[PM_PAR_YPOS]); … … 178 186 179 187 // fit the shape parameters using the supplied order (pmPSF->trendNx,trendNy) 180 bool pmPSFFitShapeParams (bool * goodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask) {188 bool pmPSFFitShapeParams (bool *pGoodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask) { 181 189 182 190 // we are doing a robust fit. after each pass, we drop points which are more deviant than … … 234 242 trend = psf->params->data[PM_PAR_E0]; 235 243 trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here 236 status &= pmTrend2DFit ( goodFit, trend, srcMask, 0xff, x, y, e0, NULL);237 if (! goodFit) {244 status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e0, NULL); 245 if (!*pGoodFit) { 238 246 psFree (e0); 239 247 psFree (e1); … … 249 257 trend = psf->params->data[PM_PAR_E1]; 250 258 trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here 251 status &= pmTrend2DFit ( goodFit, trend, srcMask, 0xff, x, y, e1, NULL);252 if (! goodFit) {259 status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e1, NULL); 260 if (!*pGoodFit) { 253 261 psFree (e0); 254 262 psFree (e1); … … 264 272 trend = psf->params->data[PM_PAR_E2]; 265 273 trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here 266 status &= pmTrend2DFit ( goodFit, trend, srcMask, 0xff, x, y, e2, NULL);267 if (! goodFit) {274 status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e2, NULL); 275 if (!*pGoodFit) { 268 276 psFree (e0); 269 277 psFree (e1); -
trunk/psModules/src/objects/pmTrend2D.c
r30031 r30044 179 179 } 180 180 181 bool pmTrend2DFit(bool * goodFit, pmTrend2D *trend, psVector *mask, psVectorMaskType maskVal, const psVector *x,181 bool pmTrend2DFit(bool *pGoodFit, pmTrend2D *trend, psVector *mask, psVectorMaskType maskVal, const psVector *x, 182 182 const psVector *y, const psVector *f, const psVector *df) 183 183 { … … 189 189 190 190 bool status = false; 191 * goodFit = false;191 *pGoodFit = false; 192 192 // for the psImageMap fit, it is possible to have valid data but no valid solution for 193 193 // example, an isolated cell may not be reached from other cells, making the solution 194 194 // degenerate. psImageMapFit should probably handle this case, but until it does, we allow 195 // it to fail on the result, but not yield an error ( goodFit = false).196 // psVectorClipFitPolynomial2D can not fail in this way (really?), so goodFit is always195 // it to fail on the result, but not yield an error (pGoodFit = false). 196 // psVectorClipFitPolynomial2D can not fail in this way (really?), so pGoodFit is always 197 197 // true 198 198 … … 204 204 // of points in the image, and potentially based on the fractional range of the 205 205 // data? 206 * goodFit = true;206 *pGoodFit = true; 207 207 break; 208 208 … … 210 210 // XXX supply fraction from trend elements 211 211 // XXX need to add the API which adjusts the scale 212 status = psImageMapClipFit( goodFit, trend->map, trend->stats, mask, maskVal, x, y, f, df);212 status = psImageMapClipFit(pGoodFit, trend->map, trend->stats, mask, maskVal, x, y, f, df); 213 213 break; 214 214
Note:
See TracChangeset
for help on using the changeset viewer.
