- Timestamp:
- Dec 20, 2010, 2:30:45 PM (16 years ago)
- Location:
- branches/czw_branch/20101203
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
psModules/src/objects (modified) (1 prop)
-
psModules/src/objects/pmPSFtryMakePSF.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20101203
- Property svn:mergeinfo changed
-
branches/czw_branch/20101203/psModules/src/objects
-
Property svn:mergeinfo
set to
/branches/eam_branches/ipp-20101103/psModules/src/objects merged eligible /branches/eam_branches/ipp-20101205/psModules/src/objects merged eligible /trunk/psModules/src/objects merged eligible
-
Property svn:mergeinfo
set to
-
branches/czw_branch/20101203/psModules/src/objects/pmPSFtryMakePSF.c
r29004 r30118 50 50 Note: some of the array entries may be NULL (failed fits); ignore them. 51 51 *****************************************************************************/ 52 bool pmPSFtryMakePSF ( 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 (p sf, 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 } 81 if (!*pGoodFit) { 82 psWarning ("poor fit to PSF shape parameters for trend order %d, %d, skipping\n", psf->trendNx, psf->trendNy); 83 psFree(x); 84 psFree(y); 85 return true; 80 86 } 81 87 … … 115 121 // the mask is carried from previous steps and updated with this operation 116 122 // the weight is either the flux error or NULL, depending on 'psf->poissonErrorParams' 117 if (!pmTrend2DFit ( trend, srcMask, 0xff, x, y, z, NULL)) {123 if (!pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, z, NULL)) { 118 124 psError(PS_ERR_UNKNOWN, false, "failed to build psf model for parameter %d", i); 119 125 psFree(x); … … 122 128 return false; 123 129 } 130 if (!*pGoodFit) { 131 // if we do not get a good fit (but do not actually hit an error), 132 // tell the calling program to try something else 133 psWarning ("poor fit to PSF parameter %d for trend order %d, %d, skipping\n", i, psf->trendNx, psf->trendNy); 134 psFree(x); 135 psFree(y); 136 psFree(z); 137 return true; 138 } 124 139 if (trend->mode == PM_TREND_MAP) { 125 140 // p_psImagePrint (2, trend->map->map, "param N Before"); // XXX TEST: … … 139 154 140 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 } 141 164 142 165 fprintf (f, "%f %f : ", source->modelEXT->params->data.F32[PM_PAR_XPOS], source->modelEXT->params->data.F32[PM_PAR_YPOS]); … … 163 186 164 187 // fit the shape parameters using the supplied order (pmPSF->trendNx,trendNy) 165 bool pmPSFFitShapeParams ( 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) { 166 189 167 190 // we are doing a robust fit. after each pass, we drop points which are more deviant than … … 219 242 trend = psf->params->data[PM_PAR_E0]; 220 243 trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here 221 status &= pmTrend2DFit (trend, srcMask, 0xff, x, y, e0, NULL); 244 status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e0, NULL); 245 if (!*pGoodFit) { 246 psFree (e0); 247 psFree (e1); 248 psFree (e2); 249 return true; 250 } 222 251 mean = psStatsGetValue (trend->stats, meanOption); 223 252 stdev = psStatsGetValue (trend->stats, stdevOption); … … 228 257 trend = psf->params->data[PM_PAR_E1]; 229 258 trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here 230 status &= pmTrend2DFit (trend, srcMask, 0xff, x, y, e1, NULL); 259 status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e1, NULL); 260 if (!*pGoodFit) { 261 psFree (e0); 262 psFree (e1); 263 psFree (e2); 264 return true; 265 } 231 266 mean = psStatsGetValue (trend->stats, meanOption); 232 267 stdev = psStatsGetValue (trend->stats, stdevOption); … … 237 272 trend = psf->params->data[PM_PAR_E2]; 238 273 trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here 239 status &= pmTrend2DFit (trend, srcMask, 0xff, x, y, e2, NULL); 274 status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e2, NULL); 275 if (!*pGoodFit) { 276 psFree (e0); 277 psFree (e1); 278 psFree (e2); 279 return true; 280 } 240 281 mean = psStatsGetValue (trend->stats, meanOption); 241 282 stdev = psStatsGetValue (trend->stats, stdevOption); … … 246 287 if (!status) { 247 288 psError (PS_ERR_UNKNOWN, true, "failed to fit PSF shape params"); 289 psFree (e0); 290 psFree (e1); 291 psFree (e2); 248 292 return false; 249 293 }
Note:
See TracChangeset
for help on using the changeset viewer.
