Changeset 31438 for branches/eam_branches/ipp-20110404/psModules/src/objects/pmGrowthCurveGenerate.c
- Timestamp:
- May 4, 2011, 4:44:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110404/psModules/src/objects/pmGrowthCurveGenerate.c
r31361 r31438 226 226 } 227 227 228 # define DEBUG 0 229 # if (DEBUG) 230 static FILE *fgr = NULL; 231 # endif 232 228 233 // we generate the growth curve for the center of the image with the specified psf model 229 234 bool pmGrowthCurveGenerateFromSources (pmReadout *readout, pmPSF *psf, psArray *sources, bool INTERPOLATE_AP, psImageMaskType maskVal, psImageMaskType markVal) … … 240 245 psArray *growths = psArrayAllocEmpty (100); 241 246 247 # if (DEBUG) 248 fgr = fopen ("growth.mags.dat", "w"); 249 # endif 250 242 251 for (int i = 0; i < sources->n; i++) { 243 252 … … 254 263 psAssert (growths->n, "cannot build growth curve (no valid PSF stars?)"); 255 264 256 # if (0) 257 FILE *f = fopen ("growth.dat", "w"); 258 assert (f); 259 260 for (int j = 0; j < psf->growth->radius->n; j++) { 261 262 fprintf (f, "%f : ", psf->growth->radius->data.F32[j]); 263 264 // XXX dump the growth curves: 265 for (int i = 0; i < growths->n; i++) { 266 267 pmGrowthCurve *growth = growths->data[i]; 268 if (!growth) continue; 269 270 fprintf (f, "%8.4f ", growth->apMag->data.F32[j]); 271 } 272 fprintf (f, "\n"); 273 } 274 fclose (f); 265 # if (DEBUG) 266 fclose (fgr); 275 267 # endif 276 268 … … 290 282 pmGrowthCurve *growth = growths->data[j]; 291 283 if (!isfinite(growth->apMag->data.F32[i])) continue; 292 psVectorAppend (values, growth->apMag->data.F32[i] - growth-> fitMag);284 psVectorAppend (values, growth->apMag->data.F32[i] - growth->refMag); 293 285 } 294 286 if (values->n == 0) { … … 354 346 growth->apMag->data.F32[i] = source->apMag; 355 347 } 348 psAssert(growth->refBin >= 0, "invalid growth reference bin"); 349 psAssert(growth->refBin < growth->apMag->n, "invalid growth reference bin"); 350 growth->refMag = growth->apMag->data.F32[growth->refBin]; 351 352 // Loop over the range of radii 353 # if (DEBUG) 354 for (int i = 0; i < growth->radius->n; i++) { 355 fprintf (fgr, "%f %f %f %f %f %f\n", xc, yc, growth->radius->data.F32[i], growth->apMag->data.F32[i], growth->fitMag, growth->refMag); 356 } 357 # endif 358 356 359 return growth; 357 360 } 358 359 # if (0)360 // solve for the best growth and the offsets per star to minimize the scatter361 362 // generate the per-star and per-radius sums363 int Nradius = psf->growth->radius->n;364 int Nstar = growths->n;365 366 psVector *Mstar = psVectorAlloc (Nstar, PS_DATA_F32);367 psVector *Mradius = psVectorAlloc (Nradius, PS_DATA_F32);368 369 psVectorInit (Mstar, 0.0);370 psVectorInit (Mradius, 0.0);371 372 for (int i = 0; i < Nstar; i++) {373 pmGrowthCurve *growth = growths->data[i];374 for (int j = 0; j < Nradius; j++) {375 Mstar->data.F32[i] += growth->apMag->data.F32[j];376 Mradius->data.F32[j] += growth->apMag->data.F32[j];377 }378 }379 380 psImage *A = psImageAlloc(Nstar + Nradius, Nstar + Nradius, PS_DATA_F32);381 psVector *B = psVectorAlloc(Nstar + Nradius, PS_DATA_F32);382 383 psImageInit (A, 0.0);384 psVectorInit (B, 0.0);385 386 for (int i = 0; i < Nstar; i++) {387 A->data.F32[i][i] = Nradius;388 B->data.F32[i] = Mstar->data.F32[i];389 }390 for (int i = 0; i < Nradius; i++) {391 int j = i + Nstar;392 A->data.F32[j][j] = Nstar;393 B->data.F32[j] = Mradius->data.F32[i];394 }395 396 if (!psMatrixGJSolve(A, B)) {397 psAbort("GJ failure");398 }399 400 for (int i = 0; i < Nradius; i++) {401 psf->growth->apMag->data.F32[i] = B->data.F32[Nstar+i];402 }403 404 // XXX this analysis produces a biased growth curve: points with small radius are more405 // likely to err on the side of being too faint (bacause of mis-aligned aperture), while on406 // the bright side the tend to be too bright (because of contaminating neighbors). Bright407 // stars are less likely to be biased,408 409 // XXX at this point, we could iterate and exclude some of the stars with low data quality410 // XXX we could also weight the above by flux or something411 412 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
