Changeset 4977 for trunk/psphot/src/psphotChoosePSF.c
- Timestamp:
- Sep 7, 2005, 6:32:40 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotChoosePSF.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotChoosePSF.c
r4949 r4977 1 1 # include "psphot.h" 2 2 3 // t estPSF models and select best option3 // try PSF models and select best option 4 4 5 5 pmPSF *psphotChoosePSF (psMetadata *config, psArray *sources, psStats *skystats) … … 7 7 bool status; 8 8 char *modelName; 9 pmPSF _Test *test= NULL;9 pmPSFtry *try = NULL; 10 10 psArray *stars = NULL; 11 11 psMetadataItem *item = NULL; … … 34 34 psListIterator *iter = psListIteratorAlloc (list, PS_LIST_HEAD, FALSE); 35 35 36 // set up an array to store the testresults37 psArray * tests = psArrayAlloc (list->n);36 // set up an array to store the results 37 psArray *models = psArrayAlloc (list->n); 38 38 39 // t esteach model option listed in config40 for (int i = 0; i < tests->n; i++) {39 // try each model option listed in config 40 for (int i = 0; i < models->n; i++) { 41 41 42 42 item = psListGetAndIncrement (iter); 43 43 modelName = item->data.V; 44 44 45 tests->data[i] = pmPSF_TestModel (stars, modelName, RADIUS);45 models->data[i] = pmPSFtryModel (stars, modelName, RADIUS); 46 46 psFree (modelName); 47 47 psFree (item); … … 51 51 psFree (stars); 52 52 53 // select the best of the testmodels53 // select the best of the models 54 54 // here we are using the clippedStdev on the metric as the indicator 55 t est = tests->data[0];55 try = models->data[0]; 56 56 int bestN = 0; 57 float bestM = t est->dApResid;58 for (int i = 1; i < tests->n; i++) {59 t est = tests->data[i];60 float M = t est->dApResid;57 float bestM = try->dApResid; 58 for (int i = 1; i < models->n; i++) { 59 try = models->data[i]; 60 float M = try->dApResid; 61 61 if (M < bestM) { 62 62 bestM = M; … … 65 65 } 66 66 67 // keep only the selected test:68 t est = tests->data[bestN];69 modelName = pmModelGetType (t est->modelType);70 psLogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, t est->ApResid, test->dApResid);67 // keep only the selected model: 68 try = models->data[bestN]; 69 modelName = pmModelGetType (try->modelType); 70 psLogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, try->ApResid, try->dApResid); 71 71 72 // XXX I am having trouble tracking down the double frees vs leaks 73 # if (0) 74 // we are keeping the modelPSF fits from the PSF test, 75 // but we replace these later on (apply_psf_model) 76 // set source->model based on best psf model fit 77 for (int i = 0; i < test->sources->n; i++) { 78 pmSource *source = test->sources->data[i]; 79 // drop masked sources from PSFSTAR list 80 if (test->mask->data.U8[i]) { 81 source->type = PS_SOURCE_OTHER; 82 source->modelPSF = NULL; 83 } else { 84 // source->modelPSF = psMemCopy(test->modelPSF->data[i]); 85 source->modelPSF = test->modelPSF->data[i]; 86 } 87 } 88 # endif 89 90 pmPSF *psf = psMemCopy(test->psf); 91 psFree (tests); 72 // keep only the pmPSF resulting from this analysis 73 pmPSF *psf = psMemCopy(try->psf); 74 psFree (models); 92 75 return (psf); 93 76 }
Note:
See TracChangeset
for help on using the changeset viewer.
