Index: trunk/psphot/src/psphotChoosePSF.c
===================================================================
--- trunk/psphot/src/psphotChoosePSF.c	(revision 13516)
+++ trunk/psphot/src/psphotChoosePSF.c	(revision 13804)
@@ -5,8 +5,4 @@
 
     bool            status;
-    char           *modelName;
-    pmPSF          *psf = NULL;
-    pmPSFtry       *try = NULL;
-    psArray        *stars = NULL;
 
     psTimerStart ("psphot");
@@ -51,5 +47,5 @@
     }
 
-    stars = psArrayAllocEmpty (sources->n);
+    psArray *stars = psArrayAllocEmpty (sources->n);
 
     // select the candidate PSF stars (pointers to original sources)
@@ -92,5 +88,5 @@
     for (int i = 0; i < models->n; i++) {
         psMetadataItem *item = psListGetAndIncrement (iter);
-        modelName = item->data.V;
+        char *modelName = item->data.V;
         models->data[i] = pmPSFtryModel (stars, modelName, RADIUS, POISSON_ERRORS, psfTrendMask, PSF_PARAM_WEIGHTS);
     }
@@ -106,5 +102,5 @@
     float bestM = 0.0;
     for (int i = 0; i < models->n; i++) {
-        try = models->data[i];
+        pmPSFtry *try = models->data[i];
         if (try == NULL) {
             psError(PSPHOT_ERR_PSF, false, "PSF model %d is NULL", i);
@@ -125,5 +121,18 @@
     }
 
-    try = models->data[bestN];
+    pmPSFtry *try = models->data[bestN];
+
+    // print/dump psf parameters
+    if (psTraceGetLevel("psphot") >= 5) {
+	for (int i = PM_PAR_SXX; i < try->psf->params_NEW->n; i++) {
+	    psPolynomial2D *poly = try->psf->params_NEW->data[i];
+	    for (int nx = 0; nx <= poly->nX; nx++) {
+		for (int ny = 0; ny <= poly->nY; ny++) {
+		    if (poly->mask[nx][ny]) continue;
+		    fprintf (stderr, "%g x^%d y^%d\n", poly->coeff[nx][ny], nx, ny);
+		}
+	    }
+	}
+    }
 
     // measure and save the median value of dparams[PM_PAR_SXX],dparams[PM_PAR_SYY]
@@ -275,5 +284,5 @@
     // XXX we are not saving the fitted sources
     // XXX do we want to keep them so we may optionally write them out?
-    psf = psMemIncrRefCounter(try->psf);
+    pmPSF *psf = psMemIncrRefCounter(try->psf);
     psFree (models);
 
@@ -284,5 +293,5 @@
     }
 
-    modelName = pmModelGetType (psf->type);
+    char *modelName = pmModelGetType (psf->type);
     psLogMsg ("psphot.pspsf", PS_LOG_INFO, "select psf model: %f sec\n", psTimerMark ("psphot"));
     psLogMsg ("psphot.pspsf", PS_LOG_INFO, "psf model %s, ApResid: %f +/- %f\n", modelName, psf->ApResid, psf->dApResid);
