Changeset 5773
- Timestamp:
- Dec 13, 2005, 10:03:27 AM (20 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 4 edited
-
psphot.c (modified) (2 diffs)
-
psphotFullFit.c (modified) (2 diffs)
-
psphotMagnitudes.c (modified) (2 diffs)
-
psphotOutput.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphot.c
r5772 r5773 75 75 case 0: 76 76 psphotEnsemblePSF (imdata, config, sources, psf, sky); 77 sources = psArraySort (sources, psphotSortBySN);78 77 psphotFullFit (imdata, config, sources, psf, sky); 79 78 // psphotReplaceUnfit (sources); … … 99 98 100 99 // write out data in appropriate format 100 // measure aperture correction 101 // psphotApertureCorrection (sources, config, sky); 101 102 psphotOutput (imdata, config, sources, psf, sky); 102 103 exit (0); -
trunk/psphot/src/psphotFullFit.c
r5772 r5773 79 79 continue; 80 80 } 81 82 // add the double-PSF fit mode 83 // how do we compare the results? chisq? 81 84 82 85 // recalculate the source moments using the larger galaxy moments radius … … 113 116 } 114 117 115 // subtract object, leave local sky 118 // subtract PSF for object, leave local sky 119 // XXX : we should keep the non-linear PSF fit if object was marked extended but 120 // PSF fit is OK otherwise. 116 121 psFree (source->modelPSF); 117 122 source->modelPSF = save; -
trunk/psphot/src/psphotMagnitudes.c
r5772 r5773 1 1 # include "psphot.h" 2 2 3 // XXX EAM : this aperture correction business is invalid (& wrong) for galaxies 3 // XXX EAM : the apMag should only be calculated for the brighter sources 4 // XXX EAM : SN limit set by user? 5 // XXX EAM : masked region should be (optionally) elliptical 4 6 pmModel *pmSourceMagnitudes (pmSource *source, pmPSF *psf, float apRadius) { 5 7 6 8 int status; 7 9 float x, y; 8 float sky, rflux, apMag, fitMag; 10 float rflux, apMag, fitMag; 11 pmModel *model; 9 12 10 13 // use the correct model (PSF vs FLT) 11 pmModel *model = pmSourceSelectModel (source); 14 if (psf != NULL) { 15 model = source->modelPSF; 16 } else { 17 model = source->modelFLT; 18 } 12 19 if (model == NULL) return NULL; 13 20 … … 20 27 psImageKeepCircle (source->mask, x, y, apRadius, "OR", PSPHOT_MASK_MARKED); 21 28 22 // save local sky for later23 sky = model->params->data.F32[0];24 25 29 // replace source flux 26 30 pmSourceAddModel (source->pixels, source->mask, model, false, false); 27 31 28 32 // measure object photometry 29 status = pmSourcePhotometry (& fitMag, &apMag, model, source->pixels, source->mask);33 status = pmSourcePhotometry (&source->fitMag, &source->apMag, model, source->pixels, source->mask); 30 34 31 // correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS 32 rflux = pow (10.0, 0.4*fitMag); 33 source->apMag = apMag - rflux * psf->skyBias * (M_PI * PS_SQR(apRadius)); 34 source->fitMag = fitMag + psf->ApResid; 35 // for PSFs, correct both apMag and fitMag to same system, consistent with infinite flux star in aperture RADIUS 36 if (psf != NULL) { 37 rflux = pow (10.0, 0.4*source->fitMag); 38 source->apMag -= rflux * psf->skyBias * (M_PI * PS_SQR(apRadius)); 39 source->fitMag += psf->ApResid; 40 } 35 41 36 42 // subtract object, leave local sky -
trunk/psphot/src/psphotOutput.c
r5772 r5773 367 367 } 368 368 369 // dump thesources to an output file369 // write the PSF sources to an output file 370 370 bool pmModelWritePSFs (psArray *sources, psMetadata *config, char *filename, pmPSF *psf) { 371 371 … … 389 389 pmSource *source = (pmSource *) sources->data[i]; 390 390 391 // write out sources fitted as PSFs392 391 if (source->type != PM_SOURCE_STAR) continue; 393 if (source->mode & PM_SOURCE_FAIL) continue;394 if (source->mode & PM_SOURCE_POOR) continue;395 396 model = pmSourceMagnitudes (source, psf, RADIUS );392 // if (source->mode & PM_SOURCE_FAIL) continue; 393 // if (source->mode & PM_SOURCE_POOR) continue; 394 395 model = pmSourceMagnitudes (source, psf, RADIUS, true); 397 396 if (model == NULL) continue; 398 397 … … 400 399 dPAR = model->dparams->data.F32; 401 400 401 // dP is positional error 402 402 dP = 0; 403 403 dP += PS_SQR(dPAR[2]); … … 410 410 PAR[2], PAR[3], PAR[0], source->fitMag, dmag, dP); 411 411 412 for (j = 0; j < model->params->n - 4; j++) {413 fprintf (f, "%9.6f ", PAR[j +4]);412 for (j = 4; j < model->params->n; j++) { 413 fprintf (f, "%9.6f ", PAR[j]); 414 414 } 415 415 fprintf (f, " : "); 416 for (j = 0; j < model->params->n - 4; j++) {417 fprintf (f, "%9.6f ", dPAR[j +4]);416 for (j = 4; j < model->params->n; j++) { 417 fprintf (f, "%9.6f ", dPAR[j]); 418 418 } 419 fprintf (f, ": %2d % 7.3f %7.3f %7.2f %4d %2d\n",420 source[0].type, 419 fprintf (f, ": %2d %2d %7.3f %7.3f %7.2f %4d %2d\n", 420 source[0].type, source[0].mode, 421 421 log10(model[0].chisq/model[0].nDOF), 422 422 source[0].moments->SN, … … 448 448 for (i = 0; i < sources->n; i++) { 449 449 pmSource *source = (pmSource *) sources->data[i]; 450 model = (pmModel *) source->modelFLT; 450 451 if (source->type != PM_SOURCE_GALAXY) continue; 452 // if (source->mode & PM_SOURCE_FAIL) continue; 453 // if (source->mode & PM_SOURCE_POOR) continue; 454 455 model = pmSourceMagnitudes (source->modelFLT, NULL, model->radius); 451 456 if (model == NULL) continue; 452 if (source->type != PM_SOURCE_GALAXY) continue; 453 if (source->mode & PM_SOURCE_FAIL) continue;454 if (source->mode & PM_SOURCE_POOR) continue;457 458 PAR = model->params->data.F32; 459 dPAR = model->dparams->data.F32; 455 460 456 params = model->params; 457 dparams = model->dparams; 458 459 // XXX these are hardwired for SGAUSS : this should be pushed into the 460 // model functions as an abstract function 461 // dP is shape error 462 // XXX these are hardwired for SGAUSS 461 463 dP = 0; 462 dP += PS_SQR(d params[0].data.F32[4] / params[0].data.F32[4]);463 dP += PS_SQR(d params[0].data.F32[5] / params[0].data.F32[5]);464 dP += PS_SQR(d params[0].data.F32[7] / params[0].data.F32[7]);464 dP += PS_SQR(dPAR[4] / PAR[4]); 465 dP += PS_SQR(dPAR[5] / PAR[5]); 466 dP += PS_SQR(dPAR[7] / PAR[7]); 465 467 dP = sqrt (dP); 466 468 469 dmag = dPAR[1] / PAR[1]; 470 467 471 fprintf (f, "%7.1f %7.1f %5.1f %7.3f %7.4f %7.4f ", 468 params[0].data.F32[2], 469 params[0].data.F32[3], 470 params[0].data.F32[0], 471 -2.5*log10(params[0].data.F32[1]), 472 (dparams[0].data.F32[1]/params[0].data.F32[1]), 473 dP); 472 PAR[2], PAR[3], PAR[0], source->fitMag, dmag, dP); 474 473 475 474 for (j = 4; j < model->params->n; j++) { 476 fprintf (f, "%9.6f ", params[0].data.F32[j]);475 fprintf (f, "%9.6f ", PAR[j]); 477 476 } 478 477 fprintf (f, " : "); 479 478 for (j = 4; j < model->params->n; j++) { 480 fprintf (f, "%9.6f ", d params[0].data.F32[j]);479 fprintf (f, "%9.6f ", dPAR[j]); 481 480 } 482 fprintf (f, ": %2d %7.3f %7.3f %7.2f %4d %2d\n", 483 source[0].type, log10(model[0].chisq/model[0].nDOF), 481 fprintf (f, ": %2d %2d %7.3f %7.3f %7.2f %4d %2d\n", 482 source[0].type, source[0].mode, 483 log10(model[0].chisq/model[0].nDOF), 484 484 source[0].moments->SN, 485 485 model[0].radius, … … 497 497 int i; 498 498 FILE *f; 499 pmMoments *moment = NULL; 500 pmSource *source = NULL; 499 501 500 502 f = fopen (filename, "w"); … … 508 510 // write sources with models first 509 511 for (i = 0; i < sources->n; i++) { 510 pmSource *source = (pmSource *)sources->data[i];512 source = sources->data[i]; 511 513 512 514 // skip these sources (in PSF or FLT) 513 if (source->type == PM_SOURCE_STAR) { 514 if (source->mode & PM_SOURCE_FAIL) goto isNULL; 515 if (source->mode & PM_SOURCE_POOR) goto isNULL; 516 continue; 515 if (source->type == PM_SOURCE_STAR) continue; 516 if (source->type == PM_SOURCE_GALAXY) continue; 517 518 if (source->moments == NULL) { 519 moment = empty; 520 } else { 521 moment = source->moments; 517 522 } 518 if (source->type == PM_SOURCE_GALAXY) { 519 if (source->mode & PM_SOURCE_FAIL) goto isNULL; 520 if (source->mode & PM_SOURCE_POOR) goto isNULL; 521 continue; 522 } 523 524 isNULL: 525 526 if (source->moments == NULL) { 527 fprintf (f, "%5d %5d %7.1f %7.1f %7.1f %6.3f %6.3f %8.1f %7.1f %7.1f %7.1f %4d %2d\n", 528 source->peak->x, source->peak->y, source->peak->counts, 529 empty->x, empty->y, 530 empty->Sx, empty->Sy, 531 empty->Sum, empty->Peak, 532 empty->Sky, empty->SN, 533 empty->nPixels, source->type); 534 } else { 535 fprintf (f, "%5d %5d %7.1f %7.1f %7.1f %6.3f %6.3f %8.1f %7.1f %7.1f %7.1f %4d %2d\n", 536 source->peak->x, source->peak->y, source->peak->counts, 537 source->moments->x, source->moments->y, 538 source->moments->Sx, source->moments->Sy, 539 source->moments->Sum, source->moments->Peak, 540 source->moments->Sky, source->moments->SN, 541 source->moments->nPixels, source->type); 542 } 523 524 fprintf (f, "%5d %5d %7.1f %7.1f %7.1f %6.3f %6.3f %8.1f %7.1f %7.1f %7.1f %4d %2d\n", 525 source->peak->x, source->peak->y, source->peak->counts, 526 source->moments->x, source->moments->y, 527 source->moments->Sx, source->moments->Sy, 528 source->moments->Sum, source->moments->Peak, 529 source->moments->Sky, source->moments->SN, 530 source->moments->nPixels, source->type); 543 531 } 544 532 fclose (f); … … 552 540 int i; 553 541 FILE *f; 554 pmSource *source ;542 pmSource *source = NULL; 555 543 556 544 f = fopen (filename, "w"); … … 561 549 562 550 for (i = 0; i < sources->n; i++) { 563 source = (pmSource *)sources->data[i];551 source = sources->data[i]; 564 552 if (source->moments == NULL) 565 553 continue;
Note:
See TracChangeset
for help on using the changeset viewer.
