Changeset 5772
- Timestamp:
- Dec 13, 2005, 6:43:44 AM (20 years ago)
- Location:
- trunk/psphot
- Files:
-
- 4 added
- 17 edited
-
Makefile (modified) (2 diffs)
-
src/models/pmModel_SGAUSS.c (modified) (1 diff)
-
src/pmPeaksSigmaLimit.c (modified) (1 diff)
-
src/psModulesUtils.c (modified) (1 diff)
-
src/psphot.c (modified) (3 diffs)
-
src/psphot.h (modified) (1 diff)
-
src/psphotApplyPSF.c (modified) (3 diffs)
-
src/psphotBasicDeblend.c (modified) (3 diffs)
-
src/psphotChoosePSF.c (modified) (3 diffs)
-
src/psphotEnsemblePSF.c (modified) (3 diffs)
-
src/psphotEvalFLT.c (added)
-
src/psphotEvalPSF.c (added)
-
src/psphotFitGalaxies.c (modified) (2 diffs)
-
src/psphotFixedPSF.c (modified) (1 diff)
-
src/psphotFullFit.c (added)
-
src/psphotImageBackground.c (modified) (1 diff)
-
src/psphotMagnitudes.c (modified) (2 diffs)
-
src/psphotMarkPSF.c (modified) (8 diffs)
-
src/psphotOutput.c (modified) (4 diffs)
-
src/psphotRadiusChecks.c (added)
-
src/psphotReapplyPSF.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/Makefile
r5718 r5772 34 34 $(SRC)/psphotOutput.$(ARCH).o \ 35 35 $(SRC)/psphotMarkPSF.$(ARCH).o \ 36 $(SRC)/psphotSubtractPSF.$(ARCH).o \37 36 $(SRC)/psphotSortBySN.$(ARCH).o \ 38 37 $(SRC)/psphotDefinePixels.$(ARCH).o\ … … 41 40 $(SRC)/psphotBasicDeblend.$(ARCH).o \ 42 41 $(SRC)/psphotModelGroupInit.$(ARCH).o \ 42 $(SRC)/psphotRadiusChecks.$(ARCH).o \ 43 $(SRC)/psphotReplaceUnfit.$(ARCH).o \ 44 $(SRC)/psphotEvalPSF.$(ARCH).o \ 45 $(SRC)/psphotEvalFLT.$(ARCH).o \ 46 $(SRC)/psphotFullFit.$(ARCH).o \ 43 47 $(SRC)/pmSourceContour.$(ARCH).o \ 44 48 $(SRC)/psLine.$(ARCH).o \ -
trunk/psphot/src/models/pmModel_SGAUSS.c
r5593 r5772 81 81 params_min[0][0].data.F32[6] = -5.0; 82 82 params_min[0][0].data.F32[7] = 0.5; 83 params_min[0][0].data.F32[8] = 0.0 01;83 params_min[0][0].data.F32[8] = 0.05; 84 84 85 85 params_max[0][0].data.F32[0] = 1e5; -
trunk/psphot/src/pmPeaksSigmaLimit.c
r5672 r5772 24 24 NSIGMA = psMetadataLookupF32 (&status, config, "PEAKS_NSIGMA_LIMIT"); 25 25 26 //threshold = NSIGMA*sky->sampleStdev + sky->sampleMean;27 threshold = NSIGMA*sky->sampleStdev;26 threshold = NSIGMA*sky->sampleStdev + sky->sampleMean; 27 // threshold = NSIGMA*sky->sampleStdev; 28 28 psLogMsg ("psphot", 3, "threshold: %f DN\n", threshold); 29 29 -
trunk/psphot/src/psModulesUtils.c
r5350 r5772 101 101 return true; 102 102 } 103 104 pmModel *pmModelCopy (pmModel *model) { 105 106 pmModel *new = pmModelAlloc (model->type); 107 108 new->chisq = model->chisq; 109 new->nIter = model->nIter; 110 111 for (int i = 0; i < new->params->n; i++) { 112 new->params->data.F32[i] = model->params->data.F32[i]; 113 new->dparams->data.F32[i] = model->dparams->data.F32[i]; 114 } 115 116 return (new); 117 } -
trunk/psphot/src/psphot.c
r5756 r5772 43 43 psfClump = pmSourcePSFClump (sources, config); 44 44 45 // group into STAR, COSMIC, GALAXY, SATURATED 45 // group into STAR, COSMIC, GALAXY, SATURATED, etc. 46 46 pmSourceRoughClass (sources, config, psfClump); 47 48 // optional dump of all rough source data 49 char *output = psMetadataLookupPtr (&status, config, "MOMENTS_OUTPUT_FILE"); 50 if (status && (output != NULL) && (output[0])) 51 { 52 pmMomentsWriteText (sources, output); 53 psFree (output); 54 } 47 55 if (!strcasecmp (breakPt, "CLASS")) exit (0); 48 56 57 // mark blended peaks PS_SOURCE_BLEND 49 58 psphotBasicDeblend (sources, config, sky); 50 59 if (!strcasecmp (breakPt, "DEBLEND")) exit (0); … … 57 66 if (!strcasecmp (breakPt, "PSFFIT")) exit (0); 58 67 68 // XXX add this as conditional output 69 psphotSamplePSFs (psf, imdata->image); 70 59 71 int FITMODE = psMetadataLookupS32 (&status, config, "FIT_MODE"); 60 72 if (!status) FITMODE = 2; 61 73 62 74 switch (FITMODE) { 63 case -2:75 case 0: 64 76 psphotEnsemblePSF (imdata, config, sources, psf, sky); 65 psphotReapplyPSF (imdata, config, sources, psf, sky); 66 break; 67 68 case -1: 69 psphotEnsemblePSF (imdata, config, sources, psf, sky); 70 break; 71 72 case 0: 73 psphotFixedPSF (imdata, config, sources, psf, sky); 77 sources = psArraySort (sources, psphotSortBySN); 78 psphotFullFit (imdata, config, sources, psf, sky); 79 // psphotReplaceUnfit (sources); 74 80 break; 75 81 76 82 case 1: 77 // test PSF on all except SATURATE and DEFECT (artifacts)83 // fit extended objects with galaxy models 78 84 psphotApplyPSF (imdata, config, sources, psf, sky); 85 psphotFitGalaxies (imdata, config, sources, sky); 79 86 break; 80 87 … … 82 89 // fit extended objects with galaxy models 83 90 psphotApplyPSF (imdata, config, sources, psf, sky); 84 psphotFitGalaxies (imdata, config, sources, sky);85 91 break; 86 92 -
trunk/psphot/src/psphot.h
r5718 r5772 74 74 psMetadata *psphotTestArguments (int *argc, char **argv); 75 75 bool psphotBasicDeblend (psArray *sources, psMetadata *config, psStats *sky); 76 77 bool psphotFullFit (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 78 bool psphotInitLimitsPSF (psMetadata *config); 79 bool psphotEvalPSF (pmSource *source); 80 bool psphotEvalFLT (pmSource *source); 81 bool psphotInitRadiusPSF (psMetadata *config, psStats *sky, pmModelType type); 82 bool psphotCheckRadiusPSF (eamReadout *imdata, pmSource *source); 83 bool psphotInitRadiusFLT (psMetadata *config, psStats *sky, pmModelType type); 84 bool psphotCheckRadiusFLT (eamReadout *imdata, pmSource *source); 85 bool psphotSamplePSFs (pmPSF *psf, psImage *image); 86 bool psphotReplaceUnfit (psArray *sources); -
trunk/psphot/src/psphotApplyPSF.c
r5131 r5772 2 2 3 3 // fit psf model to all objects 4 // PSFSTAR objects will be refitted5 // run this function to a specific flux limit?6 7 4 bool psphotApplyPSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) 8 5 { 9 bool status;10 6 float x; 11 7 float y; 12 int Nfit = 0;13 int Nsub = 0;8 int Nfit = 0; 9 int Nsub = 0; 14 10 int Niter = 0; 15 11 16 12 psTimerStart ("psphot"); 17 13 18 // we may set this differently here from the value used to mark likely saturated stars 19 float SATURATION = psMetadataLookupF32 (&status, config, "SATURATION"); 20 float OUTER_RADIUS = psMetadataLookupF32 (&status, config, "SKY_OUTER_RADIUS"); 21 22 float PSF_MIN_SN = psMetadataLookupF32 (&status, config, "PSF_MIN_SN"); 23 float PSF_MAX_CHI = psMetadataLookupF32 (&status, config, "PSF_MAX_CHI"); 24 float PSF_FIT_NSIGMA = psMetadataLookupF32 (&status, config, "PSF_FIT_NSIGMA"); 25 float PSF_FIT_PADDING = psMetadataLookupF32 (&status, config, "PSF_FIT_PADDING"); 26 float PSF_SHAPE_NSIGMA = psMetadataLookupF32 (&status, config, "PSF_SHAPE_NSIGMA"); 27 28 // set the object surface-brightness limit for fitted pixels 29 float FLUX_LIMIT = PSF_FIT_NSIGMA * sky->sampleStdev; 30 psLogMsg ("psphot.apply_psf_model", 4, "fitting pixels with at least %f object counts\n", FLUX_LIMIT); 31 32 // this function specifies the radius at this the model hits the given flux 33 pmModelRadius modelRadius = pmModelRadius_GetFunction (psf->type); 14 psphotInitLimitsPSF (config); 15 psphotInitRadiusPSF (config, sky, psf->type); 34 16 35 17 for (int i = 0; i < sources->n; i++) { … … 38 20 39 21 // skip non-astronomical objects (very likely defects) 40 // XXX EAM : should we try these anyway?22 if (source->mode & PM_SOURCE_BLEND) continue; 41 23 if (source->type == PM_SOURCE_DEFECT) continue; 42 24 if (source->type == PM_SOURCE_SATURATED) continue; … … 47 29 // set PSF parameters for this model 48 30 pmModel *model = pmModelFromPSF (modelFLT, psf); 31 psFree (modelFLT); 32 33 source->modelPSF = model; 34 35 // sets the model radius (via source->model) and adjusts pixels as needed 36 psphotCheckRadiusPSF (imdata, source); 37 49 38 x = model->params->data.F32[2]; 50 39 y = model->params->data.F32[3]; 51 psFree (modelFLT);52 40 53 // set the fit radius based on the object flux limit and the model54 // XXX EAM : FLUX_LIMIT should be set based on local sky model (not global median)55 model->radius = modelRadius (model->params, FLUX_LIMIT) + PSF_FIT_PADDING;56 if (isnan(model->radius)) {57 psAbort ("apply_psf_model", "error in radius");58 }59 60 // check if we need to redefine the pixels61 // XXX EAM : a better test would examine the source pixels62 if (model->radius > OUTER_RADIUS) {63 // (re)-allocate image, weight, mask arrays for each peak (square of radius OUTER)64 psphotDefinePixels (source, imdata, x, y, model->radius);65 }66 67 // if (i > 66) psTraceSetLevel (".psLib.dataManip.psMinimizeLMChi2", 5);68 69 41 // fit PSF model (set/unset the pixel mask) 70 42 psImageKeepCircle (source->mask, x, y, model->radius, "OR", PSPHOT_MASK_MARKED); 71 status =pmSourceFitModel (source, model, true);43 pmSourceFitModel (source, model, true); 72 44 psImageKeepCircle (source->mask, x, y, model->radius, "AND", ~PSPHOT_MASK_MARKED); 73 45 74 if (!status || (model->params->data.F32[1] < 0)) {75 psLogMsg ("psphot", 5, "PSF fit failed for %f, %f (%d iterations)\n", x, y, model->nIter);76 source->type = PM_SOURCE_FAIL_FIT_PSF; // better choice?77 psFree (model);78 continue;79 }80 // XXX EAM : this was an attempt to correct for fit-sky biases81 // pmModelSkyOffset (model, x, y, model->radius);82 83 // model succeeded : tentatively keep it84 source->modelPSF = model;85 46 Niter += model[0].nIter; 86 47 Nfit ++; 87 48 88 // is it a good model? 89 psphotMarkPSF (source, PSF_SHAPE_NSIGMA, PSF_MIN_SN, PSF_MAX_CHI, SATURATION); 90 if (psphotSubtractPSF (source)) { 91 Nsub ++; 49 // check if model fit is acceptable 50 if (psphotEvalPSF (source)) { 51 pmSourceSubModel (source->pixels, source->mask, source->modelPSF, false, false); 52 source->mode |= PM_SOURCE_SUBTRACTED; 53 Nsub ++; 92 54 } 93 55 } 94 56 95 57 psLogMsg ("psphot", 3, "fit PSF models: %f sec for %d objects (%d total iterations)\n", psTimerMark ("psphot"), Nfit, Niter); 96 psLogMsg ("psphot", 4, "subtracted %d PSF objects\n", Nsub);58 psLogMsg ("psphot", 4, "subtracted %d PSF models\n", Nsub); 97 59 return (true); 98 60 } -
trunk/psphot/src/psphotBasicDeblend.c
r5718 r5772 14 14 psTimerStart ("psphot"); 15 15 16 // this should be added to the PM_SOURCE flags:17 i nt PM_SOURCE_BLEND = PM_SOURCE_OTHER + 1;16 float FRACTION = psMetadataLookupF32 (&status, config, "DEBLEND_PEAK_FRACTION"); 17 if (!status) FRACTION = 0.25; 18 18 19 float FRACTION = psMetadataLookupF32 (&status, config, "DEBLEND_PEAK_FRACTION");20 19 float NSIGMA = psMetadataLookupF32 (&status, config, "DEBLEND_SKY_NSIGMA"); 20 if (!status) NSIGMA = 5.0; 21 21 22 float minThreshold = NSIGMA*sky->sampleStdev; 22 fprintf (stderr, "min threshold: %f\n", minThreshold);23 23 24 24 // we need sources spatially-sorted to find overlaps … … 43 43 source = sources->data[N]; 44 44 45 if (source-> type ==PM_SOURCE_BLEND) continue;45 if (source->mode & PM_SOURCE_BLEND) continue; 46 46 47 47 overlap->n = 0; … … 119 119 ); 120 120 121 testSource-> type= PM_SOURCE_BLEND;121 testSource->mode |= PM_SOURCE_BLEND; 122 122 Nblend ++; 123 123 j = xv->n; -
trunk/psphot/src/psphotChoosePSF.c
r5058 r5772 13 13 // array to store candidate PSF stars 14 14 int NSTARS = psMetadataLookupS32 (&status, config, "PSF_MAX_NSTARS"); 15 if (!status) NSTARS = sources->n; 15 if (!status) NSTARS = PS_MIN (sources->n, 200); 16 16 17 stars = psArrayAlloc (sources->n); 17 18 stars->n = 0; … … 20 21 for (int i = 0; (i < sources->n) && (stars->n < NSTARS); i++) { 21 22 pmSource *source = sources->data[i]; 22 if (source->type != PM_SOURCE_PSFSTAR) continue; 23 psArrayAdd (stars, 200, source); 23 if (source->mode & PM_SOURCE_PSFSTAR) psArrayAdd (stars, 200, source); 24 24 } 25 ps Trace (".psphot.pspsf", 3, "selected candidate %d PSF objects\n", stars->n);25 psLogMsg ("psphot.pspsf", 3, "selected candidate %d PSF objects\n", stars->n); 26 26 27 27 // get the fixed PSF fit radius … … 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 70 69 71 // keep only the selected model: -
trunk/psphot/src/psphotEnsemblePSF.c
r5718 r5772 12 12 // source analysis is done in spatial order 13 13 sources = psArraySort (sources, psphotSortByY); 14 15 // this should be added to the PM_SOURCE flags:16 int PM_SOURCE_BLEND = PM_SOURCE_OTHER + 1;17 14 18 15 float OUTER_RADIUS = psMetadataLookupF32 (&status, config, "SKY_OUTER_RADIUS"); … … 35 32 // skip non-astronomical objects (very likely defects) 36 33 // XXX EAM : should we try these anyway? 37 if (inSource-> type ==PM_SOURCE_BLEND) continue;34 if (inSource->mode & PM_SOURCE_BLEND) continue; 38 35 if (inSource->type == PM_SOURCE_DEFECT) continue; 39 36 if (inSource->type == PM_SOURCE_SATURATED) continue; … … 73 70 psImage *mask = otSource->mask; 74 71 75 // XXX EAM : set model to unit peak, zero sky, maybe use peak (x,y)72 // XXX EAM : use these lines to fit to the peak 76 73 // model->params->data.F32[2] = inSource->peak->x; 77 74 // model->params->data.F32[3] = inSource->peak->y; 75 // XXX EAM : better option: improve the peak with 2D poly fit 3x3 76 77 // set model to unit peak, zero sky (we assume sky is constant) 78 78 model->params->data.F32[0] = 0.0; 79 79 model->params->data.F32[1] = 1.0; -
trunk/psphot/src/psphotFitGalaxies.c
r5672 r5772 3 3 bool psphotFitGalaxies (eamReadout *imdata, psMetadata *config, psArray *sources, psStats *skyStats) 4 4 { 5 bool status , goodfit;5 bool status; 6 6 float x; 7 7 float y; 8 int Nfit = 0;9 int N fail= 0;8 int Nfit = 0; 9 int Nsub = 0; 10 10 int Niter = 0; 11 11 12 float OUTER_RADIUS = psMetadataLookupF32 (&status, config, "SKY_OUTER_RADIUS");12 psTimerStart ("psphot"); 13 13 14 14 float GAL_MIN_SN = psMetadataLookupF32 (&status, config, "GAL_MIN_SN"); 15 float GAL_FIT_NSIGMA = psMetadataLookupF32 (&status, config, "GAL_FIT_NSIGMA");16 float GAL_FIT_PADDING = psMetadataLookupF32 (&status, config, "GAL_FIT_PADDING");17 15 float GAL_MOMENTS_RAD = psMetadataLookupF32 (&status, config, "GAL_MOMENTS_RADIUS"); 16 char *modelName = psMetadataLookupPtr (&status, config, "GAL_MODEL"); 17 pmModelType modelType = pmModelSetType (modelName); 18 18 19 float FLUX_LIMIT = GAL_FIT_NSIGMA * skyStats->sampleStdev; 20 21 char *modelName = psMetadataLookupPtr (&status, config, "GAL_MODEL"); 22 pmModelType modelType = pmModelSetType (modelName); 23 pmModelRadius modelRadius = pmModelRadius_GetFunction (modelType); 24 25 psTimerStart ("psphot"); 19 psphotInitRadiusFLT (config, skyStats, modelType); 26 20 27 21 for (int i = 0; i < sources->n; i++) { 28 22 pmSource *source = sources->data[i]; 29 23 30 // sources which should not be fitted 31 // skip all valid stars 32 if (source->type == PM_SOURCE_PSFSTAR) continue; 33 if (source->type == PM_SOURCE_SATSTAR) continue; 34 if (source->type == PM_SOURCE_GOODSTAR) continue; 24 // only fit suspected extended sources 25 if (source->type != PM_SOURCE_GALAXY) continue; 26 if (source->mode & PM_SOURCE_BLEND) continue; 35 27 36 // skip all likely defects 37 if (source->type == PM_SOURCE_DEFECT) continue; 38 if (source->type == PM_SOURCE_SATURATED) continue; 39 40 // skip poorly fitted stars 41 if (source->type == PM_SOURCE_FAINTSTAR) continue; 42 if (source->type == PM_SOURCE_POOR_FIT_PSF) continue; 43 44 // XXX EAM when do we pick these up again? 45 if (source->moments->SN < GAL_MIN_SN) { 46 source->type = PM_SOURCE_FAINT_GALAXY; // better choice? 47 continue; 48 } 28 // skip possible extended sources below fit threshold 29 if (source->moments->SN < GAL_MIN_SN) continue; 49 30 50 31 // recalculate the source moments using the larger galaxy moments radius 51 32 status = pmSourceMoments (source, GAL_MOMENTS_RAD); 52 33 if (!status) { 53 source-> type = PM_SOURCE_DROP_GALAXY; // better choice?34 source->mode |= PM_SOURCE_FAIL; // better choice? 54 35 continue; 55 36 } … … 57 38 // use the source moments, etc to guess basic model parameters 58 39 pmModel *model = pmSourceModelGuess (source, modelType); 40 source->modelFLT = model; 59 41 x = model->params->data.F32[2]; 60 42 y = model->params->data.F32[3]; 61 43 62 // set the fit radius based on the object flux limit and the model 63 // XXX EAM : FLUX_LIMIT should be set based on local sky model (not global median) 64 model->radius = modelRadius (model->params, FLUX_LIMIT) + GAL_FIT_PADDING; 65 if (isnan(model->radius)) psAbort ("fit_galaxies", "error in radius"); 66 67 // check if we need to redefine the pixels 68 // XXX EAM : a better test would examine the source pixels 69 if (model->radius > OUTER_RADIUS) { 70 // (re)-allocate image, weight, mask arrays for each peak (square of radius OUTER) 71 psphotDefinePixels (source, imdata, x, y, model->radius); 72 } 44 // sets the model radius (via source->model) and adjusts pixels as needed 45 psphotCheckRadiusFLT (imdata, source); 73 46 74 47 // fit FLT (not PSF) model (set/unset the pixel mask) 75 48 psImageKeepCircle (source->mask, x, y, model->radius, "OR", PSPHOT_MASK_MARKED); 76 status =pmSourceFitModel (source, model, false);49 pmSourceFitModel (source, model, false); 77 50 psImageKeepCircle (source->mask, x, y, model->radius, "AND", ~PSPHOT_MASK_MARKED); 78 if (!status) {79 // if the fit fails, we need to change the classification80 psLogMsg ("psphot", 5, "GAL fit failed for %f, %f (%d iterations, %f radius)\n", x, y, model->nIter, model->radius);81 source->type = PM_SOURCE_FAIL_FIT_GAL; // better choice?82 source->modelFLT = model;83 Nfail ++;84 continue;85 }86 51 87 // check if model fit is acceptable88 goodfit = pmModelFitStatus (model);89 if (!goodfit) {90 // if the fit fails, we need to change the classification91 psLogMsg ("psphot", 5, "GAL fit poor for %f, %f (%d iterations, %f radius)\n", x, y, model->nIter, model->radius);92 source->type = PM_SOURCE_POOR_FIT_GAL; // better choice?93 source->modelFLT = model;94 Nfail ++;95 continue;96 }97 98 // accept the model99 source->type = PM_SOURCE_GALAXY;100 source->modelFLT = model;101 52 Niter += model[0].nIter; 102 53 Nfit++; 103 54 104 // subtract object, leave local sky 105 pmSourceSubModel (source->pixels, source->mask, model, false, false); 55 // check if model fit is acceptable 56 if (pmModelFitStatus (model)) { 57 pmSourceSubModel (source->pixels, source->mask, model, false, false); 58 source->mode |= PM_SOURCE_SUBTRACTED; 59 Nsub ++; 60 } 106 61 } 107 psLogMsg ("psphot", 3, "fit galaxies: %f sec for %d galaxies (%d failures, %d total iterations)\n", psTimerMark ("psphot"), Nfit, Nfail, Niter); 62 psLogMsg ("psphot", 3, "fit GAL models: %f sec for %d galaxies (%d total iterations)\n", psTimerMark ("psphot"), Nfit, Niter); 63 psLogMsg ("psphot", 4, "subtracted %d GAL models\n", Nsub); 108 64 return (true); 109 65 } -
trunk/psphot/src/psphotFixedPSF.c
r5672 r5772 66 66 if (!status || (model->params->data.F32[1] < 0)) { 67 67 psLogMsg ("psphot", 5, "PSF fit failed for %f, %f (peak %f\n", x, y, model->params->data.F32[1]); 68 source-> type = PM_SOURCE_FAIL_FIT_PSF; // better choice?68 source->mode |= PM_SOURCE_FAIL; // better choice? 69 69 psFree (model); 70 70 continue; -
trunk/psphot/src/psphotImageBackground.c
r5718 r5772 64 64 } 65 65 } 66 sky->sampleMean = 0.0; 66 67 67 68 psLogMsg ("psphot", 5, "back: %f sec (fit model)\n", psTimerMark ("psphot")); 68 69 69 70 psphotSaveImage (imdata->header, imdata->image, "backsub.fits"); 70 71 71 return (skyModel); 72 72 } -
trunk/psphot/src/psphotMagnitudes.c
r5672 r5772 49 49 50 50 // use PSF model with stars 51 case PM_SOURCE_PSFSTAR: 52 case PM_SOURCE_SATSTAR: 53 case PM_SOURCE_GOODSTAR: 51 case PM_SOURCE_STAR: 54 52 model = source->modelPSF; 55 53 break; … … 61 59 62 60 // skip defects and poorly fitted stars or galaxies 63 case PM_SOURCE_DEFECT:64 case PM_SOURCE_SATURATED:65 case PM_SOURCE_FAINTSTAR:66 case PM_SOURCE_POOR_FIT_PSF:67 case PM_SOURCE_POOR_FIT_GAL:68 case PM_SOURCE_FAIL_FIT_GAL:69 61 default: 70 62 model = NULL; -
trunk/psphot/src/psphotMarkPSF.c
r5672 r5772 1 1 # include "psphot.h" 2 3 // given a pmSource which has been fitted using modelPSF, evaluate the 4 // resulting fit: did the fit succeed? is this object PSF-like? is this object 5 // extended? return status is TRUE for a valid PSF, FALSE otherwise. 2 6 3 7 // identify objects consistent with PSF shape/magnitude distribution … … 14 18 // this includes a minimum buffer (DS) for the brighter objects 15 19 16 // saturated stars should fall outside ( but are already IDed)17 // galaxies should be larger, cosmic rays smaller , but need to test?20 // saturated stars should fall outside (larger), but have peaks above SATURATE 21 // galaxies should be larger, cosmic rays smaller 18 22 // we also reject objects with S/N too low or ChiSquare to high 19 20 // any object which meets the criterion is marked as PM_SOURCE_BRIGHTSTAR21 23 22 24 // floor for DS value … … 33 35 34 36 // do we actually have a valid PSF model? 35 if (model == NULL) return (false); 37 if (model == NULL) { 38 source->mode &= ~PM_SOURCE_FITTED; 39 return false; 40 } 36 41 37 42 // did the model fit fail for one or another reason? 38 43 switch (model->status) { 44 case PM_MODEL_UNTRIED: 45 source->mode &= ~PM_SOURCE_FITTED; 46 return false; 39 47 case PM_MODEL_BADARGS: 40 case PM_MODEL_UNTRIED: 41 source->type = PM_SOURCE_FAIL_FIT_PSF; // better choice? 48 source->mode |= PM_SOURCE_FAIL; 42 49 return false; 43 50 case PM_MODEL_SUCCESS: … … 46 53 case PM_MODEL_OFFIMAGE: 47 54 psLogMsg ("psphot", 5, "PSF fit failed for %f, %f (%d iterations)\n", model->params->data.F32[2], model->params->data.F32[3], model->nIter); 48 source-> type = PM_SOURCE_FAIL_FIT_PSF; // better choice?55 source->mode |= PM_SOURCE_FAIL; 49 56 return false; 50 57 default: … … 52 59 } 53 60 61 // unless we prove otherwise, this object is a star. 62 source->type = PM_SOURCE_STAR; 63 54 64 // if the object has fitted peak above saturation, label as SATSTAR 55 65 // this is a valid PSF object, but ignore the other quality tests 56 66 // remember: fit does not use saturated pixels (masked) 67 // XXX no extended object can saturate and stay extended... 57 68 if (model->params->data.F32[1] >= SATURATE) { 58 if (source-> type ==PM_SOURCE_PSFSTAR) {69 if (source->mode & PM_SOURCE_PSFSTAR) { 59 70 psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n"); 60 71 } 61 source->type = PM_SOURCE_SATSTAR; 62 return (true); 72 source->mode &= ~PM_SOURCE_PSFSTAR; 73 source->mode |= PM_SOURCE_SATSTAR; 74 return true; 63 75 } 64 76 65 77 // if the object has a fitted peak below 0, the fit did not converge cleanly 66 78 if (model->params->data.F32[1] < 0) { 67 source-> type = PM_SOURCE_FAIL_FIT_PSF;68 return (false);79 source->mode |= PM_SOURCE_FAIL; 80 return false; 69 81 } 70 82 71 83 // if the source was predicted to be a SATSTAR, but it fitted below saturation, 72 84 // make a note to the user 73 if (source-> type ==PM_SOURCE_SATSTAR) {74 psLogMsg ("psphot", 5, "SATSTAR marked GOODSTAR(fitted peak below saturation)\n");75 source-> type = PM_SOURCE_GOODSTAR;85 if (source->mode & PM_SOURCE_SATSTAR) { 86 psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n"); 87 source->mode &= ~PM_SOURCE_SATSTAR; 76 88 } 77 89 … … 93 105 keep &= (SN > minSN); 94 106 keep &= (Chi < maxChi); 95 if (keep) {96 if (source->type == PM_SOURCE_PSFSTAR) return (true); 97 source->type = PM_SOURCE_GOODSTAR; 98 return (true); 99 }100 101 if (source->type == PM_SOURCE_PSFSTAR) { 107 if (keep) return true; 108 109 // this source is not a star, unflag as PSFSTAR 110 // XXX : if this object was used to build the PSF, this flag should 111 // be set even if the object is not a star... 112 if (source->mode & PM_SOURCE_PSFSTAR) { 113 source->mode &= ~PM_SOURCE_PSFSTAR; 102 114 psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality\n"); 103 115 } … … 106 118 if ((nSx <= -shapeNsigma) || (nSy <= -shapeNsigma)) { 107 119 source->type = PM_SOURCE_DEFECT; 108 return (false);120 return false; 109 121 } 110 122 … … 112 124 if ((nSx >= shapeNsigma) || (nSy >= shapeNsigma)) { 113 125 source->type = PM_SOURCE_GALAXY; 114 return (false);126 return false; 115 127 } 116 128 117 // object appears to be extremely faint: what is this? 118 if (SN < minSN) { 119 source->type = PM_SOURCE_FAINTSTAR; 120 return (false); 121 } 122 123 // these are pooly fitted, probable stars near other stars? 124 source->type = PM_SOURCE_POOR_FIT_PSF; 125 return (false); 129 // poor-quality fit; only keep if nothing else works... 130 source->mode |= PM_SOURCE_POOR; 131 return false; 126 132 } -
trunk/psphot/src/psphotOutput.c
r5754 r5772 389 389 pmSource *source = (pmSource *) sources->data[i]; 390 390 391 // valid source types for this function 392 if (source->type == PM_SOURCE_SATSTAR) goto valid; 393 if (source->type == PM_SOURCE_PSFSTAR) goto valid; 394 if (source->type == PM_SOURCE_GOODSTAR) goto valid; 395 continue; 396 397 valid: 391 // write out sources fitted as PSFs 392 if (source->type != PM_SOURCE_STAR) continue; 393 if (source->mode & PM_SOURCE_FAIL) continue; 394 if (source->mode & PM_SOURCE_POOR) continue; 395 398 396 model = pmSourceMagnitudes (source, psf, RADIUS); 399 397 if (model == NULL) continue; … … 452 450 model = (pmModel *) source->modelFLT; 453 451 if (model == NULL) continue; 454 if (source->type == PM_SOURCE_GALAXY) goto valid;455 continue;456 457 valid: 452 if (source->type != PM_SOURCE_GALAXY) continue; 453 if (source->mode & PM_SOURCE_FAIL) continue; 454 if (source->mode & PM_SOURCE_POOR) continue; 455 458 456 params = model->params; 459 457 dparams = model->dparams; … … 513 511 514 512 // skip these sources (in PSF or FLT) 515 if (source->type == PM_SOURCE_GALAXY) continue; 516 if (source->type == PM_SOURCE_PSFSTAR) continue; 517 if (source->type == PM_SOURCE_SATSTAR) continue; 518 if (source->type == PM_SOURCE_GOODSTAR) continue; 519 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; 517 } 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 520 526 if (source->moments == NULL) { 521 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", … … 579 585 return (8); 580 586 581 case PM_SOURCE_SATSTAR: 582 return (10); 583 584 case PM_SOURCE_PSFSTAR: 585 case PM_SOURCE_GOODSTAR: 587 case PM_SOURCE_STAR: 588 if (source->mode & PM_SOURCE_SATSTAR) return (10); 589 if (source->mode & PM_SOURCE_POOR) return (7); 590 if (source->mode & PM_SOURCE_FAIL) return (4); 586 591 return (1); 587 592 588 case PM_SOURCE_POOR_FIT_PSF:589 return (7);590 591 case PM_SOURCE_FAIL_FIT_PSF:592 case PM_SOURCE_FAINTSTAR:593 return (4);594 595 593 case PM_SOURCE_GALAXY: 596 case PM_SOURCE_FAINT_GALAXY:597 case PM_SOURCE_DROP_GALAXY:598 case PM_SOURCE_FAIL_FIT_GAL:599 case PM_SOURCE_POOR_FIT_GAL:600 594 return (2); 601 595 602 case PM_SOURCE_OTHER:603 596 default: 604 597 return (0); -
trunk/psphot/src/psphotReapplyPSF.c
r5718 r5772 14 14 sources = psArraySort (sources, psphotSortBySN); 15 15 16 // this should be added to the PM_SOURCE flags:17 int PM_SOURCE_BLEND = PM_SOURCE_OTHER + 1;18 19 16 // we may set this differently here from the value used to mark likely saturated stars 20 17 float SATURATION = psMetadataLookupF32 (&status, config, "SATURATION"); … … 29 26 // skip non-astronomical objects (very likely defects) 30 27 // XXX EAM : should we try these anyway? 31 if (source-> type == PM_SOURCE_BLEND) continue;28 if (source->mode |= PM_SOURCE_BLEND) continue; 32 29 if (source->type == PM_SOURCE_DEFECT) continue; 33 30 if (source->type == PM_SOURCE_SATURATED) continue; … … 70 67 return (true); 71 68 } 72 73 pmModel *pmModelCopy (pmModel *model) {74 75 pmModel *new = pmModelAlloc (model->type);76 77 new->chisq = model->chisq;78 new->nIter = model->nIter;79 80 for (int i = 0; i < new->params->n; i++) {81 new->params->data.F32[i] = model->params->data.F32[i];82 new->dparams->data.F32[i] = model->dparams->data.F32[i];83 }84 85 return (new);86 }
Note:
See TracChangeset
for help on using the changeset viewer.
