Changeset 10198
- Timestamp:
- Nov 26, 2006, 12:24:45 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmPSFtry.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPSFtry.c
r10103 r10198 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-11-2 0 20:37:50$7 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-11-26 22:24:45 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 46 46 psFree (test->psf); 47 47 psFree (test->sources); 48 // psFree (test->modelEXT);49 // psFree (test->modelPSF);50 48 psFree (test->metric); 51 49 psFree (test->metricErr); … … 73 71 test->fitMag = psVectorAlloc (sources->n, PS_TYPE_F64); 74 72 test->mask = psVectorAlloc (sources->n, PS_TYPE_U8); 75 // test->modelEXT = psArrayAlloc (sources->n);76 // test->modelPSF = psArrayAlloc (sources->n);77 73 78 74 test->sources = psArrayAlloc (sources->n); … … 83 79 test->metricErr->data.F64[i] = 0; 84 80 test->fitMag->data.F64[i] = 0; 85 // test->modelEXT->data[i] = NULL;86 // test->modelPSF->data[i] = NULL;87 81 } 88 82 … … 101 95 102 96 // generate a pmPSFtry with a copy of the test PSF sources 103 pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask )97 pmPSFtry *pmPSFtryModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask, bool applyWeights) 104 98 { 105 99 bool status; … … 140 134 continue; 141 135 } 142 // XXX is this still needed?143 // psfTry->modelEXT->data[i] = psMemIncrRefCounter (source->modelEXT);144 136 Next ++; 145 137 } … … 148 140 149 141 // stage 2: construct a psf (pmPSF) from this collection of model fits 150 pmPSFFromPSFtry (psfTry );142 pmPSFFromPSFtry (psfTry, applyWeights); 151 143 152 144 // stage 3: refit with fixed shape parameters … … 168 160 psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PM_MASK_MARK); 169 161 status = pmSourceFitModel (source, source->modelPSF, PM_SOURCE_FIT_PSF); 170 // pmModelSub (source->pixels, source->mask, source->modelPSF, false, false);171 162 psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_U8(PM_MASK_MARK)); 172 163 … … 176 167 continue; 177 168 } 178 179 // otherwise, save the resulting model180 // psfTry->modelPSF->data[i] = psMemIncrRefCounter (source->modelPSF);181 169 182 170 // XXX : use a different aperture radius from the fit radius? … … 292 280 293 281 // XXX test dump of fitted model (dump when tracing?) 294 if ( 1) {282 if (psTraceGetLevel("psModules.objects") >= 4) { 295 283 FILE *f = fopen ("resid.dat", "w"); 296 284 psVector *apfit = psPolynomial1DEvalVector (poly, r2rflux); … … 343 331 Note: some of the array entries may be NULL (failed fits); ignore them. 344 332 *****************************************************************************/ 345 bool pmPSFFromPSFtry (pmPSFtry *psfTry )333 bool pmPSFFromPSFtry (pmPSFtry *psfTry, bool applyWeight) 346 334 { 347 335 pmPSF *psf = psfTry->psf; … … 351 339 psVector *y = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64); 352 340 psVector *z = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64); 353 psVector *dz = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64); 341 342 psVector *dz = NULL; 343 if (applyWeight) { 344 dz = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64); 345 } 354 346 355 347 // construct the x,y terms … … 388 380 389 381 z->data.F64[j] = source->modelEXT->params->data.F32[i]; 390 dz->data.F64[j] = source->modelEXT->dparams->data.F32[i]; 391 // dz->data.F64[j] = 1; // use the model-fitted error? or S/N? 382 if (applyWeight) { 383 dz->data.F64[j] = source->modelEXT->dparams->data.F32[i]; 384 } 392 385 393 386 // for SXY, we actually fit SXY / (SXX^-2 + SYY^-2) … … 396 389 } 397 390 } 398 // XXX does psfTry->mask need to be init to 0 and set to 1 above? 399 if (!psVectorClipFitPolynomial2D(psf->params_NEW->data[i], stats, psfTry->mask, 0xff, z, dz, x, y)) { 391 392 // fit the collection of measured parameters to the PSF 2D model 393 // the mask is carried from previous steps and updated with this operation 394 // the weight is either the parameter error or NULL, depending on 'applyWeights' 395 if (!psVectorClipFitPolynomial2D(psf->params_NEW->data[i], stats, psfTry->mask, 0xff, z, NULL, x, y)) { 400 396 psError(PS_ERR_UNKNOWN, false, "failed to build psf model for parameter %d", i); 401 397 return false; 402 398 } 403 // psTrace ("psphot.psftest", 3, "keeping %d of %d PSF candidates (PSF param %d)\n", Nkeep, psfTry->mask->n, i); 404 } 405 406 // XXX test dump of star parameters vs position (compare with fitted values) 407 if (1) { 399 } 400 401 // test dump of star parameters vs position (compare with fitted values) 402 if (psTraceGetLevel("psModules.objects") >= 4) { 408 403 FILE *f = fopen ("params.dat", "w"); 409 404
Note:
See TracChangeset
for help on using the changeset viewer.
