Index: trunk/psphot/src/psphotRadialProfileWings.c
===================================================================
--- trunk/psphot/src/psphotRadialProfileWings.c	(revision 33838)
+++ trunk/psphot/src/psphotRadialProfileWings.c	(revision 33839)
@@ -55,4 +55,5 @@
 static float MIN_RADIUS = NAN;
 static float SKY_STDEV  = NAN;
+static float SKY_SLOPE_MIN = NAN;
 // static FILE *file = NULL;
 
@@ -81,5 +82,5 @@
 
     MIN_RADIUS = psMetadataLookupF32 (&status, readout->analysis, "PSF_MOMENTS_RADIUS");
-    if (!status) {
+    if (!status || (MIN_RADIUS > MAX_RADIUS)) {
         MIN_RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS");
     }
@@ -89,4 +90,10 @@
     if (!status) {
 	SKY_STDEV = 1.0; // a crude default value (why would this not exist?)
+    }
+
+    // SKY_SLOPE_MIN is the sigma of the sky model (ie, smoothed on large scales)
+    SKY_SLOPE_MIN = psMetadataLookupF32 (&status, recipe, "SKY_SLOPE_MIN");
+    if (!status) {
+	SKY_SLOPE_MIN = 3.0; 
     }
 
@@ -302,10 +309,10 @@
 	    limitSlope = slope;
 	}
-	if (!limit && isfinite(slope) && (fabs(slope) < 3.0)) { 
+	if (!limit && isfinite(slope) && (fabs(slope) < SKY_SLOPE_MIN)) { 
 	    // SB no longer changing.	    
 	    limit = true;
 	    // linearly interpolate to the radius at which we hit the sky, using the last flux and the limiting slope
 	    if (isfinite(lastFlux)) {
-                float interpolatedRadius = lastRadius + lastFlux / 3.0;
+                float interpolatedRadius = lastRadius + lastFlux / SKY_SLOPE_MIN;
                 if (interpolatedRadius < MAX_RADIUS) {
                     limitRadius = interpolatedRadius;
