Changeset 5802
- Timestamp:
- Dec 17, 2005, 10:26:59 AM (20 years ago)
- Location:
- trunk/psphot
- Files:
-
- 1 added
- 17 edited
-
Makefile (modified) (4 diffs)
-
src/modelTestFitSource.c (modified) (3 diffs)
-
src/psModulesUtils.c (modified) (2 diffs)
-
src/psphot.c (modified) (4 diffs)
-
src/psphot.h (modified) (1 diff)
-
src/psphotApResid.c (added)
-
src/psphotChoosePSF.c (modified) (1 diff)
-
src/psphotEnsemblePSF.c (modified) (5 diffs)
-
src/psphotEvalFLT.c (modified) (1 diff)
-
src/psphotEvalPSF.c (modified) (2 diffs)
-
src/psphotFullFit.c (modified) (7 diffs)
-
src/psphotMagnitudes.c (modified) (1 diff)
-
src/psphotModelTest.c (modified) (1 diff)
-
src/psphotOutput.c (modified) (11 diffs)
-
src/psphotRadiusChecks.c (modified) (1 diff)
-
src/psphotReplaceUnfit.c (modified) (1 diff)
-
src/psphotSetup.c (modified) (2 diffs)
-
src/psphotSourceStats.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/Makefile
r5772 r5802 51 51 $(SRC)/pmSourceFitFixed.$(ARCH).o \ 52 52 $(SRC)/psSparse.$(ARCH).o \ 53 $(SRC)/psImageData.$(ARCH).o 53 $(SRC)/psImageData.$(ARCH).o \ 54 $(SRC)/psphotApResid.$(ARCH).o 54 55 55 56 PSMODULES = \ … … 72 73 $(SRC)/modelTestFitSource.$(ARCH).o \ 73 74 $(SRC)/modelTestArguments.$(ARCH).o \ 75 $(SRC)/psphotModelGroupInit.$(ARCH).o \ 74 76 $(SRC)/psModulesUtils.$(ARCH).o \ 75 77 $(SRC)/psImageData.$(ARCH).o \ … … 111 113 112 114 $(BIN)/%.$(ARCH) : $(SRC)/%.$(ARCH).o 113 @if [ ! -d $(BIN) ]; then mkdir -p $(BIN) ; fi114 $(CC) $^ -o $@ $(LFLAGS) 115 @if [ ! -d $(BIN) ]; then mkdir -p $(BIN) || exit; fi 116 $(CC) $^ -o $@ $(LFLAGS) || exit 115 117 @echo "done with $@" 116 118 117 119 $(DESTBIN)/%: $(BIN)/%.$(ARCH) 118 @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN) ; fi119 rm -f $(DESTBIN)/$* 120 cp $(BIN)/$*.$(ARCH) $(DESTBIN)/$* 120 @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN) || exit; fi 121 rm -f $(DESTBIN)/$* || exit 122 cp $(BIN)/$*.$(ARCH) $(DESTBIN)/$* || exit 121 123 122 124 $(INSTALL): % : $(BIN)/%.$(ARCH) … … 127 129 128 130 %.install: 129 make $(DESTBIN)/$* 131 make $(DESTBIN)/$* || exit 130 132 131 133 # utilities ################################################# 132 134 133 135 install: 134 for i in $(INSTALL); do make $$i.install ; done136 for i in $(INSTALL); do make $$i.install || exit; done 135 137 136 138 clean: -
trunk/psphot/src/modelTestFitSource.c
r5755 r5802 67 67 source->peak->counts = source->moments->Peak; 68 68 69 fprintf (stderr, "sum: %f\n", source->moments->Sum); 70 69 71 // get the initial model parameter guess 70 72 pmModel *model = pmSourceModelGuess (source, modelType); … … 73 75 psF32 *params = model->params->data.F32; 74 76 for (int i = 0; i < nParams; i++) { 77 if (i == 2) { 78 params[i] = xObj; 79 continue; 80 } 81 if (i == 3) { 82 params[i] = yObj; 83 continue; 84 } 75 85 sprintf (name, "TEST_FIT_PAR%d", i); 76 86 value = psMetadataLookupF32 (&status, config, name); 77 87 if (status) { 88 fprintf (stderr, "using supplied value %f for PAR %d\n", value, i); 78 89 params[i] = value; 90 } else { 91 fprintf (stderr, "using guessed value %f for PAR %d\n", params[i], i); 79 92 } 80 93 } 94 95 float area = params[4]*params[5]; 96 fprintf (stderr, "peak: %f\n", source->moments->Sum*area); 81 97 82 98 // what fitting mode to use? … … 98 114 pmSourceSubModel (source->pixels, source->mask, model, false, false); 99 115 116 for (int i = 0; i < nParams; i++) { 117 fprintf (stderr, "result value %f for PAR %d\n", params[i], i); 118 } 119 100 120 // write out 101 121 DumpImage (source->pixels, "resid.fits"); -
trunk/psphot/src/psModulesUtils.c
r5772 r5802 65 65 float sky = model->params->data.F32[0]; 66 66 67 *fitMag = 99.0; 68 *obsMag = 99.0; 69 67 70 pmModelFlux modelFluxFunc = pmModelFlux_GetFunction (model->type); 68 71 fitSum = modelFluxFunc (model->params); 72 if (fitSum <= 0) return false; 73 if (!isfinite(fitSum)) return false; 74 *fitMag = -2.5*log10(fitSum); 69 75 70 76 for (int ix = 0; ix < image->numCols; ix++) { … … 75 81 } 76 82 if (obsSum <= 0) return false; 77 if (fitSum <= 0) return false;83 *obsMag = -2.5*log10(obsSum); 78 84 79 *fitMag = -2.5*log10(fitSum);80 *obsMag = -2.5*log10(obsSum);81 85 return (true); 82 86 } -
trunk/psphot/src/psphot.c
r5773 r5802 46 46 pmSourceRoughClass (sources, config, psfClump); 47 47 48 // optional dump of all rough source data49 char *output = psMetadataLookupPtr (&status, config, "MOMENTS_OUTPUT_FILE");50 if (status && (output != NULL) && (output[0]))51 {52 pmMomentsWriteText (sources, output);53 psFree (output);54 }55 if (!strcasecmp (breakPt, "CLASS")) exit (0);56 57 48 // mark blended peaks PS_SOURCE_BLEND 58 49 psphotBasicDeblend (sources, config, sky); … … 61 52 // source analysis is done in S/N order (brightest first) 62 53 sources = psArraySort (sources, psphotSortBySN); 54 55 psphotDumpMoments (config, sources); 56 if (!strcasecmp (breakPt, "CLASS")) exit (0); 63 57 64 58 // use bright stellar objects to measure PSF … … 75 69 case 0: 76 70 psphotEnsemblePSF (imdata, config, sources, psf, sky); 77 psphotFullFit (imdata, config, sources, psf, sky);78 // psphotReplaceUnfit (sources);79 71 break; 80 72 81 73 case 1: 74 psphotEnsemblePSF (imdata, config, sources, psf, sky); 75 psphotFullFit (imdata, config, sources, psf, sky); 76 psphotReplaceUnfit (sources); 77 psphotApResid (sources, config, psf); 78 break; 79 80 case 2: 82 81 // fit extended objects with galaxy models 83 82 psphotApplyPSF (imdata, config, sources, psf, sky); … … 85 84 break; 86 85 87 case 2:86 case 3: 88 87 // fit extended objects with galaxy models 89 88 psphotApplyPSF (imdata, config, sources, psf, sky); 90 89 break; 91 90 92 case 3:91 case 4: 93 92 // fit extended objects with galaxy models 94 93 psphotFixedPSF (imdata, config, sources, psf, sky); -
trunk/psphot/src/psphot.h
r5772 r5802 85 85 bool psphotSamplePSFs (pmPSF *psf, psImage *image); 86 86 bool psphotReplaceUnfit (psArray *sources); 87 bool psphotDumpMoments (psMetadata *config, psArray *sources); 88 bool psphotApResid (psArray *sources, psMetadata *config, pmPSF *psf); -
trunk/psphot/src/psphotChoosePSF.c
r5772 r5802 66 66 } 67 67 } 68 // XXX EAM : need to unflag the PSF stars which are not used to build the PSF 69 // XXX EAM : each pmPSFtry needs to have its own mask array 68 69 // use the best model: 70 try = models->data[bestN]; 70 71 71 // keep only the selected model: 72 try = models->data[bestN]; 72 // unset the PSFSTAR flag for stars not used for PSF model 73 for (int i = 0; i < try->sources->n; i++) { 74 pmSource *source = try->sources->data[i]; 75 if (try->mask->data.U8[i] & PSFTRY_MASK_FLT_FAIL) { 76 source->mode &= ~PM_SOURCE_PSFSTAR; 77 } 78 } 79 80 // save only the best model; 73 81 pmPSF *psf = psMemCopy(try->psf); 74 psFree (models); // keep only the pmPSF resulting from this analysis82 psFree (models); 75 83 76 84 modelName = pmModelGetType (psf->type); -
trunk/psphot/src/psphotEnsemblePSF.c
r5772 r5802 6 6 float x; 7 7 float y; 8 float Sky;9 8 10 9 psTimerStart ("psphot"); … … 14 13 15 14 float OUTER_RADIUS = psMetadataLookupF32 (&status, config, "SKY_OUTER_RADIUS"); 15 float INNER_RADIUS = psMetadataLookupF32 (&status, config, "SKY_INNER_RADIUS"); 16 16 float PSF_FIT_NSIGMA = psMetadataLookupF32 (&status, config, "PSF_FIT_NSIGMA"); 17 17 float PSF_FIT_PADDING = psMetadataLookupF32 (&status, config, "PSF_FIT_PADDING"); … … 38 38 pmSource *otSource = pmSourceAlloc (); 39 39 40 // really saturated stars should be re-measured for a better centroid 41 // XXX EAM : move this to a 'clear satstar function' 42 // XXX EAM : extend size of fit box around SATSTAR 43 if (inSource->mode & PM_SOURCE_SATSTAR) { 44 status = pmSourceMoments (inSource, INNER_RADIUS); 45 } 46 40 47 // XXX EAM : add option to use FLT or PSF form 41 48 // use the source moments, etc to guess basic model parameters 42 49 pmModel *modelFLT = pmSourceModelGuess (inSource, psf->type); 50 if (inSource->mode & PM_SOURCE_SATSTAR) { 51 modelFLT->params->data.F32[2] = inSource->moments->x; 52 modelFLT->params->data.F32[3] = inSource->moments->y; 53 } 54 // XXX EAM : add option to peak-up on peak (for non-sat objects) 43 55 44 56 // set PSF parameters for this model … … 69 81 psImage *flux = otSource->pixels; 70 82 psImage *mask = otSource->mask; 71 72 // XXX EAM : use these lines to fit to the peak73 // model->params->data.F32[2] = inSource->peak->x;74 // model->params->data.F32[3] = inSource->peak->y;75 // XXX EAM : better option: improve the peak with 2D poly fit 3x376 83 77 84 // set model to unit peak, zero sky (we assume sky is constant) … … 136 143 137 144 Fi->modelPSF = Mi->modelPSF; 145 146 // assign linearly-fitted normalization 138 147 Fi->modelPSF->params->data.F32[1] = norm->data.F32[i]; 139 148 140 149 // subtract object 141 150 pmSourceSubModel (Fi->pixels, Fi->mask, Fi->modelPSF, false, false); 142 143 Fi->modelPSF->params->data.F32[0] = Sky;144 // need to set this!145 151 } 146 152 -
trunk/psphot/src/psphotEvalFLT.c
r5772 r5802 37 37 38 38 // if the object has a fitted peak below 0, the fit did not converge cleanly 39 if (model->params->data.F32[1] < 0) {39 if (model->params->data.F32[1] <= 0) { 40 40 source->mode |= PM_SOURCE_FAIL; 41 41 return false; -
trunk/psphot/src/psphotEvalPSF.c
r5772 r5802 94 94 95 95 // if the object has a fitted peak below 0, the fit did not converge cleanly 96 if (model->params->data.F32[1] < 0) {96 if (model->params->data.F32[1] <= 0) { 97 97 source->mode |= PM_SOURCE_FAIL; 98 98 return false; … … 125 125 if (keep) return true; 126 126 127 // this source is not a star, unflag as PSFSTAR 128 // XXX : if this object was used to build the PSF, this flag should 129 // be set even if the object is not a star... 127 // this source is not a star, warn if it was a PSFSTAR 130 128 if (source->mode & PM_SOURCE_PSFSTAR) { 131 source->mode &= ~PM_SOURCE_PSFSTAR; 132 psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality\n"); 129 psphotSaveImage (NULL, source->pixels, "failpx.fits"); 130 psphotSaveImage (NULL, source->mask, "failmk.fits"); 131 psphotSaveImage (NULL, source->weight, "failwt.fits"); 132 psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality (%f, %f : %f %f %f %f)\n", 133 model->params->data.F32[2], model->params->data.F32[3], nSx, nSy, SN, Chi); 133 134 } 134 135 -
trunk/psphot/src/psphotFullFit.c
r5773 r5802 1 1 # include "psphot.h" 2 3 # define CLEAR_TRACE \ 4 if (TEST_SRC_ON) { \ 5 psTraceSetLevel (".pmObjects.pmSourceFitModel", 0); \ 6 psTraceSetLevel ("psMinimizeLMChi2", 0); \ 7 TEST_SRC_ON = false; } \ 2 8 3 9 bool psphotFullFit (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) 4 10 { 5 bool s kip, status;11 bool status; 6 12 float x, y; 7 13 int Nfit = 0; … … 26 32 psphotInitRadiusFLT (config, sky, modelTypeFLT); 27 33 34 float TEST_SRC_X = psMetadataLookupF32 (&status, config, "TEST_SRC_X"); 35 float TEST_SRC_Y = psMetadataLookupF32 (&status, config, "TEST_SRC_Y"); 36 bool TEST_SRC_ON = false; 37 bool TEST_SRC = status; 38 fprintf (stderr, "test src: %f %f\n", TEST_SRC_X, TEST_SRC_Y); 39 28 40 for (int i = 0; i < sources->n; i++) { 29 41 … … 37 49 38 50 // save the PSF model from the Ensemble fit 39 pmModel * save= pmModelCopy (source->modelPSF);51 pmModel *LIN = pmModelCopy (source->modelPSF); 40 52 41 53 // attempt to fit the PSF model … … 49 61 x = modelPSF->params->data.F32[2]; 50 62 y = modelPSF->params->data.F32[3]; 63 64 if (TEST_SRC && (fabs(TEST_SRC_X - x) < 5) && (fabs(TEST_SRC_Y - y) < 5)) { 65 psTraceSetLevel (".pmObjects.pmSourceFitModel", 6); 66 psTraceSetLevel ("psMinimizeLMChi2", 6); 67 TEST_SRC_ON = true; 68 } 51 69 52 70 // fit PSF model (set/unset the pixel mask) … … 63 81 pmSourceSubModel (source->pixels, source->mask, source->modelPSF, false, false); 64 82 source->mode |= PM_SOURCE_SUBTRACTED; 65 psFree ( save);83 psFree (LIN); 66 84 Nsub ++; 85 CLEAR_TRACE; 67 86 continue; 68 87 } 69 88 70 89 // skip the source if we don't think it is extended 71 skip = (source->type != PM_SOURCE_GALAXY); 72 skip |= (source->moments->SN < GAL_MIN_SN); 73 if (skip) { 74 source->modelPSF = save; 75 pmSourceSubModel (source->pixels, source->mask, source->modelPSF, false, false); 76 source->mode |= PM_SOURCE_SUBTRACTED; 77 psFree (modelPSF); 78 Nsub ++; 79 continue; 80 } 90 if (source->type != PM_SOURCE_GALAXY) goto subLINEAR; 91 if (source->moments->SN < GAL_MIN_SN) goto subLINEAR; 81 92 82 93 // add the double-PSF fit mode … … 84 95 85 96 // recalculate the source moments using the larger galaxy moments radius 86 if (!pmSourceMoments (source, GAL_MOMENTS_RAD)) { 87 source->mode |= PM_SOURCE_FAIL; // better choice? 88 continue; 89 } 97 if (!pmSourceMoments (source, GAL_MOMENTS_RAD)) goto subLINEAR; 90 98 91 99 // use the source moments, etc to guess basic model parameters … … 111 119 pmSourceSubModel (source->pixels, source->mask, source->modelFLT, false, false); 112 120 source->mode |= PM_SOURCE_SUBTRACTED; 113 psFree ( save);121 psFree (LIN); 114 122 Nsub ++; 123 CLEAR_TRACE; 115 124 continue; 116 125 } 117 126 118 127 // 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. 128 subLINEAR: 121 129 psFree (source->modelPSF); 122 source->modelPSF = save;130 source->modelPSF = LIN; 123 131 pmSourceSubModel (source->pixels, source->mask, source->modelPSF, false, false); 124 132 source->mode |= PM_SOURCE_SUBTRACTED; 133 source->mode |= PM_SOURCE_LINEAR; 134 Nsub ++; 135 CLEAR_TRACE; 125 136 } 126 137 -
trunk/psphot/src/psphotMagnitudes.c
r5773 r5802 8 8 int status; 9 9 float x, y; 10 float rflux , apMag, fitMag;10 float rflux; 11 11 pmModel *model; 12 12 -
trunk/psphot/src/psphotModelTest.c
r5622 r5802 2 2 3 3 int main (int argc, char **argv) { 4 5 psphotModelGroupInit (); 4 6 5 7 psMetadata *config = modelTestArguments (&argc, argv); -
trunk/psphot/src/psphotOutput.c
r5773 r5802 370 370 bool pmModelWritePSFs (psArray *sources, psMetadata *config, char *filename, pmPSF *psf) { 371 371 372 double dP , dmag;372 double dPos, dMag; 373 373 int i, j; 374 374 FILE *f; … … 393 393 // if (source->mode & PM_SOURCE_POOR) continue; 394 394 395 model = pmSourceMagnitudes (source, psf, RADIUS , true);395 model = pmSourceMagnitudes (source, psf, RADIUS); 396 396 if (model == NULL) continue; 397 397 … … 399 399 dPAR = model->dparams->data.F32; 400 400 401 // dP is positional error 402 dP = 0; 403 dP += PS_SQR(dPAR[2]); 404 dP += PS_SQR(dPAR[3]); 405 dP = sqrt (dP); 406 407 dmag = dPAR[1] / PAR[1]; 408 409 fprintf (f, "%7.1f %7.1f %5.1f %7.4f %7.4f %7.4f ", 410 PAR[2], PAR[3], PAR[0], source->fitMag, dmag, dP); 401 // dPos is positional error, dMag is mag error 402 dPos = hypot (dPAR[2], dPAR[3]); 403 dMag = dPAR[1] / PAR[1]; 404 405 fprintf (f, "%7.1f %7.1f %5.1f %8.4f %7.4f %7.4f ", 406 PAR[2], PAR[3], PAR[0], source->fitMag, dMag, dPos); 411 407 412 408 for (j = 4; j < model->params->n; j++) { … … 417 413 fprintf (f, "%9.6f ", dPAR[j]); 418 414 } 419 fprintf (f, ": %2d % 2d %7.3f %7.3f %7.2f %4d %2d\n",415 fprintf (f, ": %2d %#5x %7.3f %7.1f %7.2f %4d %2d\n", 420 416 source[0].type, source[0].mode, 421 417 log10(model[0].chisq/model[0].nDOF), … … 432 428 bool pmModelWriteFLTs (psArray *sources, char *filename) { 433 429 434 double dP ;430 double dPos, dMag; 435 431 int i, j; 436 432 FILE *f; 437 psVector *params; 438 psVector *dparams; 433 psF32 *PAR, *dPAR; 439 434 pmModel *model; 440 435 … … 450 445 451 446 if (source->type != PM_SOURCE_GALAXY) continue; 452 // if (source->mode & PM_SOURCE_FAIL) continue;453 // if (source->mode & PM_SOURCE_POOR) continue;454 447 455 model = pmSourceMagnitudes (source->modelFLT, NULL, model->radius);456 if (model == NULL) continue;448 if (source->modelFLT == NULL) continue; 449 model = pmSourceMagnitudes (source, NULL, source->modelFLT->radius); 457 450 458 451 PAR = model->params->data.F32; 459 452 dPAR = model->dparams->data.F32; 460 453 461 // dP is shape error454 // dPos is shape error 462 455 // XXX these are hardwired for SGAUSS 463 dP = 0; 464 dP += PS_SQR(dPAR[4] / PAR[4]); 465 dP += PS_SQR(dPAR[5] / PAR[5]); 466 dP += PS_SQR(dPAR[7] / PAR[7]); 467 dP = sqrt (dP); 468 469 dmag = dPAR[1] / PAR[1]; 470 471 fprintf (f, "%7.1f %7.1f %5.1f %7.3f %7.4f %7.4f ", 472 PAR[2], PAR[3], PAR[0], source->fitMag, dmag, dP); 456 dPos = 0; 457 dPos += PS_SQR(dPAR[4] / PAR[4]); 458 dPos += PS_SQR(dPAR[5] / PAR[5]); 459 // dPos += PS_SQR(dPAR[7] / PAR[7]); 460 dPos = sqrt (dPos); 461 dMag = dPAR[1] / PAR[1]; 462 463 fprintf (f, "%7.1f %7.1f %7.1f %7.3f %7.4f %7.4f ", 464 PAR[2], PAR[3], PAR[0], source->fitMag, dMag, dPos); 473 465 474 466 for (j = 4; j < model->params->n; j++) { … … 479 471 fprintf (f, "%9.6f ", dPAR[j]); 480 472 } 481 fprintf (f, ": %2d % 2d %7.3f %7.3f %7.2f %4d %2d\n",473 fprintf (f, ": %2d %#5x %7.3f %7.1f %7.2f %4d %2d\n", 482 474 source[0].type, source[0].mode, 483 475 log10(model[0].chisq/model[0].nDOF), … … 548 540 } 549 541 542 fprintf (stderr, "writing out moments\n"); 550 543 for (i = 0; i < sources->n; i++) { 551 544 source = sources->data[i]; 552 545 if (source->moments == NULL) 553 546 continue; 554 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",547 fprintf (f, "%5d %5d %7.1f %7.1f %7.1f %6.3f %6.3f %10.1f %7.1f %7.1f %7.1f %4d %2d %#5x\n", 555 548 source->peak->x, source->peak->y, source->peak->counts, 556 549 source->moments->x, source->moments->y, … … 558 551 source->moments->Sum, source->moments->Peak, 559 552 source->moments->Sky, source->moments->SN, 560 source->moments->nPixels, source->type );553 source->moments->nPixels, source->type, source->mode); 561 554 } 562 555 fclose (f); … … 599 592 600 593 psRegion region = {x - dx, x + dx, y - dy, y + dy}; 601 psImage *sample = psImageSubset (image, region); 594 psImage *view = psImageSubset (image, region); 595 psImage *sample = psImageCopy (NULL, view, PS_TYPE_F32); 602 596 psImageInit (sample, 0); 603 597 modelFLT->params->data.F32[2] = x; … … 635 629 return (TRUE); 636 630 } 631 632 bool psphotDumpMoments (psMetadata *config, psArray *sources) { 633 634 bool status; 635 636 // optional dump of all rough source data 637 char *output = psMetadataLookupPtr (&status, config, "MOMENTS_OUTPUT_FILE"); 638 if (!status) return false; 639 if (output == NULL) return false; 640 if (output[0] == 0) return false; 641 642 pmMomentsWriteText (sources, output); 643 psFree (output); 644 return true; 645 } -
trunk/psphot/src/psphotRadiusChecks.c
r5772 r5802 29 29 if (isnan(model->radius)) psAbort ("apply_psf_model", "error in radius"); 30 30 31 if (source->mode & PM_SOURCE_SATSTAR) { 32 model->radius *= 2; 33 } 34 31 35 // check if we need to redefine the pixels 32 36 // XXX EAM : a better test would examine the source pixels -
trunk/psphot/src/psphotReplaceUnfit.c
r5774 r5802 3 3 bool psphotReplaceUnfit (psArray *sources) { 4 4 5 bool status; 6 float x; 7 float y; 5 pmModel *model; 6 pmSource *source; 8 7 9 8 psTimerStart ("psphot"); 10 9 11 10 for (int i = 0; i < sources->n; i++) { 12 pmSource *source = sources->data[i];11 source = sources->data[i]; 13 12 14 13 // skip non-astronomical objects (very likely defects) 15 14 // these were never fitted and subtracted 16 15 if (source->mode & PM_SOURCE_BLEND) continue; 17 if (source->type == PM_SOURCE_DEFECT) continue;18 16 if (source->type == PM_SOURCE_SATURATED) continue; 17 18 if (source->type == PM_SOURCE_DEFECT) { 19 if (source->mode & PM_SOURCE_SUBTRACTED) goto addPSF; 20 continue; 21 } 22 23 if (source->type == PM_SOURCE_GALAXY) { 24 if (source->mode & PM_SOURCE_FAIL) goto addPSF; 25 if (source->mode & PM_SOURCE_POOR) goto addPSF; 26 continue; 27 } 19 28 20 29 // need to skip the successful fits 21 30 if (source->type == PM_SOURCE_STAR) { 22 if (source->mode & PM_SOURCE_FAIL) goto subPSF; 23 if (source->mode & PM_SOURCE_POOR) goto subPSF; 24 continue; 25 26 subPSF: 27 pmModel *model = source->modelPSF; 28 29 x = model->params->data.F32[2]; 30 y = model->params->data.F32[3]; 31 32 psImageKeepCircle (source->mask, x, y, model->radius, "OR", PSPHOT_MASK_MARKED); 33 pmSourceAddModel (source->pixels, source->mask, model, false, false); 34 psImageKeepCircle (source->mask, x, y, model->radius, "AND", ~PSPHOT_MASK_MARKED); 31 if (source->mode & PM_SOURCE_FAIL) goto addPSF; 32 if (source->mode & PM_SOURCE_POOR) goto addPSF; 35 33 continue; 36 34 } 37 35 38 if (source->type == PM_SOURCE_GALAXY) { 39 if (source->mode & PM_SOURCE_FAIL) goto subFLT; 40 if (source->mode & PM_SOURCE_POOR) goto subFLT; 41 continue; 36 addPSF: 37 model = source->modelPSF; 38 if (model == NULL) continue; 42 39 43 subPSF: 44 pmModel *model = source->modelFLT; 45 46 x = model->params->data.F32[2]; 47 y = model->params->data.F32[3]; 48 49 psImageKeepCircle (source->mask, x, y, model->radius, "OR", PSPHOT_MASK_MARKED); 50 pmSourceAddModel (source->pixels, source->mask, model, false, false); 51 psImageKeepCircle (source->mask, x, y, model->radius, "AND", ~PSPHOT_MASK_MARKED); 52 continue; 53 } 40 pmSourceAddModel (source->pixels, source->mask, model, false, false); 41 source->mode &= ~PM_SOURCE_SUBTRACTED; 54 42 } 55 43 psLogMsg ("psphot.replace", 4, "replace models: %f (%d objects)\n", psTimerMark ("psphot"), sources->n); -
trunk/psphot/src/psphotSetup.c
r5754 r5802 55 55 for (int iy = 0; iy < image->numRows; iy++) { 56 56 for (int ix = 0; ix < image->numCols; ix++) { 57 weight->data.F32[iy][ix] = image->data.F32[iy][ix] / GAIN + PS_SQR(RDNOISE/GAIN);57 weight->data.F32[iy][ix] = PS_MAX (image->data.F32[iy][ix] / GAIN + PS_SQR(RDNOISE/GAIN), 0.0); 58 58 } 59 59 } … … 104 104 psLogMsg ("psphot", 4, "load data: %f sec\n", psTimerMark ("psphot")); 105 105 106 psphotSaveImage (NULL, weight, "weight.fits"); 107 psphotSaveImage (NULL, mask, "mask.fits"); 108 106 109 // save the image data & return it 107 110 eamReadout *imdata = eamReadoutAlloc(image, weight, mask, header); -
trunk/psphot/src/psphotSourceStats.c
r5617 r5802 5 5 bool status = false; 6 6 psArray *sources = NULL; 7 float BIG_RADIUS; 7 8 8 9 psTimerStart ("psphot"); … … 35 36 36 37 // measure basic source moments 37 // XXX EAM : choose between these two versions38 38 status = pmSourceMoments (source, RADIUS); 39 if (!status) { 40 psFree (source); 41 continue; 39 if (status) { 40 // add to the source array 41 psArrayAdd (sources, 100, source); 42 psFree (source); 43 continue; 42 44 } 43 44 // add to the source array 45 psArrayAdd (sources, 100, source); 45 46 // if no valid pixels, or massive swing, likely saturated source, 47 // try a much larger box 48 BIG_RADIUS = PS_MIN (INNER, 3*RADIUS); 49 psTrace ("psphot", 4, "retrying moments for %d, %d\n", source->peak->x, source->peak->y); 50 status = pmSourceMoments (source, BIG_RADIUS); 51 if (status) { 52 // add to the source array 53 psArrayAdd (sources, 100, source); 54 psFree (source); 55 continue; 56 } 57 46 58 psFree (source); 59 continue; 47 60 } 48 61
Note:
See TracChangeset
for help on using the changeset viewer.
