Index: /trunk/psphot/src/psphotChoosePSF.c
===================================================================
--- /trunk/psphot/src/psphotChoosePSF.c	(revision 9660)
+++ /trunk/psphot/src/psphotChoosePSF.c	(revision 9661)
@@ -13,5 +13,5 @@
 
     // check if a PSF model is supplied by the user
-    psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
+    psf = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.PSF");
     if (psf != NULL) return psf;
 
@@ -21,17 +21,29 @@
     // array to store candidate PSF stars
     int NSTARS = psMetadataLookupS32 (&status, recipe, "PSF_MAX_NSTARS");
-    if (!status) NSTARS = PS_MIN (sources->n, 200);
+    if (!status) {
+        NSTARS = PS_MIN (sources->n, 200);
+        psWarning("PSF_MAX_NSTARS is not set in the recipe --- defaulting to %d\n", NSTARS);
+    }
 
     // use poissonian errors or local-sky errors
     bool POISSON_ERRORS = psMetadataLookupBool (&status, recipe, "POISSON_ERRORS");
-    if (!status) POISSON_ERRORS = true;
+    if (!status) {
+        POISSON_ERRORS = true;
+        psWarning("POISSON_ERRORS is not set in the recipe --- defaulting to true.\n");
+    }
 
     // how to model the PSF variations across the field
     // XXX make a default value?  or not?
     psMetadata *md = psMetadataLookupMetadata (&status, recipe, "PSF.TREND.MASK");
-    psPolynomial2D *psfTrendMask = psPolynomial2DfromMetadata (md);
-    if (!psfTrendMask) {
-	psError(PSPHOT_ERR_PSF, true, "PSF.TREND.MASK is not defined in recipe");
-	return false;
+    psPolynomial2D *psfTrendMask;
+    if (!status || !md) {
+        psWarning("PSF.TREND.MASK is not set in the recipe --- defaulting to use zeroth order.\n");
+        psfTrendMask = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 0, 0);
+    } else {
+        psfTrendMask = psPolynomial2DfromMetadata (md);
+        if (!psfTrendMask) {
+            psError(PSPHOT_ERR_PSF, true, "Unable to construct polynomial from PSF.TREND.MASK in the recipe");
+            return false;
+        }
     }
 
@@ -48,6 +60,6 @@
 
     if (stars->n == 0) {
-	psError(PSPHOT_ERR_PSF, true, "Failed to find any PSF candidates");
-	return NULL;
+        psError(PSPHOT_ERR_PSF, true, "Failed to find any PSF candidates");
+        return NULL;
     }
 
@@ -55,4 +67,8 @@
     // XXX EAM : check that PSF_FIT_RADIUS < SKY_OUTER_RADIUS
     float RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_FIT_RADIUS");
+    if (!status) {
+        psWarning("PSF_FIT_RADIUS is not set in the recipe --- defaulting to 20.0\n");
+        RADIUS = 20.0;
+    }
 
     // get the list pointers for the PSF_MODEL entries
@@ -91,8 +107,8 @@
     for (int i = 0; i < models->n; i++) {
         try = models->data[i];
-	if (try == NULL) {
-	    psError(PSPHOT_ERR_PSF, false, "PSF model %d is NULL", i);
-	    continue;
-	}
+        if (try == NULL) {
+            psError(PSPHOT_ERR_PSF, false, "PSF model %d is NULL", i);
+            continue;
+        }
         float M = try->psf->dApResid;
         if (bestN < 0 || M < bestM) {
@@ -104,9 +120,9 @@
     // use the best model:
     if (bestN < 0) {
-	psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF");
-	psFree (models);
-	return NULL;
-    }
-    
+        psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF");
+        psFree (models);
+        return NULL;
+    }
+
     try = models->data[bestN];
 
@@ -199,5 +215,5 @@
     for (int i = 0; i < sources->n; i++) {
         pmSource *source = sources->data[i];
-	if (!source) continue;
+        if (!source) continue;
         if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue;
 
