Index: trunk/psphot/src/psphotChoosePSF.c
===================================================================
--- trunk/psphot/src/psphotChoosePSF.c	(revision 4949)
+++ trunk/psphot/src/psphotChoosePSF.c	(revision 4977)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-// test PSF models and select best option
+// try PSF models and select best option
 
 pmPSF *psphotChoosePSF (psMetadata *config, psArray *sources, psStats *skystats) 
@@ -7,5 +7,5 @@
     bool       	    status;
     char       	   *modelName;
-    pmPSF_Test 	   *test  = NULL;
+    pmPSFtry 	   *try   = NULL;
     psArray    	   *stars = NULL;
     psMetadataItem *item  = NULL;
@@ -34,14 +34,14 @@
     psListIterator *iter = psListIteratorAlloc (list, PS_LIST_HEAD, FALSE); 
 
-    // set up an array to store the test results
-    psArray *tests = psArrayAlloc (list->n);
+    // set up an array to store the results
+    psArray *models = psArrayAlloc (list->n);
 
-    // test each model option listed in config
-    for (int i = 0; i < tests->n; i++) { 
+    // try each model option listed in config
+    for (int i = 0; i < models->n; i++) { 
 
 	item = psListGetAndIncrement (iter);
 	modelName = item->data.V;
 
-	tests->data[i] = pmPSF_TestModel (stars, modelName, RADIUS);
+	models->data[i] = pmPSFtryModel (stars, modelName, RADIUS);
 	psFree (modelName);
 	psFree (item);
@@ -51,12 +51,12 @@
     psFree (stars);
 
-    // select the best of the test models
+    // select the best of the models
     // here we are using the clippedStdev on the metric as the indicator
-    test = tests->data[0];
+    try = models->data[0];
     int bestN = 0;
-    float bestM = test->dApResid;
-    for (int i = 1; i < tests->n; i++) {
-	test = tests->data[i];
-	float M = test->dApResid;
+    float bestM = try->dApResid;
+    for (int i = 1; i < models->n; i++) {
+	try = models->data[i];
+	float M = try->dApResid;
 	if (M < bestM) {
 	    bestM = M;
@@ -65,29 +65,12 @@
     }
 
-    // keep only the selected test:
-    test = tests->data[bestN];
-    modelName = pmModelGetType (test->modelType);
-    psLogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, test->ApResid, test->dApResid);
+    // keep only the selected model:
+    try = models->data[bestN];
+    modelName = pmModelGetType (try->modelType);
+    psLogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, try->ApResid, try->dApResid);
 
-    // XXX I am having trouble tracking down the double frees vs leaks
-    # if (0)
-    // we are keeping the modelPSF fits from the PSF test, 
-    // but we replace these later on (apply_psf_model)
-    // set source->model based on best psf model fit
-    for (int i = 0; i < test->sources->n; i++) {
-	pmSource *source = test->sources->data[i];
-	// drop masked sources from PSFSTAR list
-	if (test->mask->data.U8[i]) {
-	  source->type = PS_SOURCE_OTHER;
-	  source->modelPSF = NULL;
-	} else {
-	  // source->modelPSF = psMemCopy(test->modelPSF->data[i]);
-	  source->modelPSF = test->modelPSF->data[i];
-	}
-    }
-    # endif
-
-    pmPSF *psf = psMemCopy(test->psf);
-    psFree (tests);
+    // keep only the pmPSF resulting from this analysis
+    pmPSF *psf = psMemCopy(try->psf);
+    psFree (models);
     return (psf);
 }
