Index: /branches/eam_branches/ipp-20111122/psphot/src/psphotKronIterate.c
===================================================================
--- /branches/eam_branches/ipp-20111122/psphot/src/psphotKronIterate.c	(revision 33611)
+++ /branches/eam_branches/ipp-20111122/psphot/src/psphotKronIterate.c	(revision 33612)
@@ -83,4 +83,9 @@
     if (!status) {
         MIN_KRON_RADIUS = 0.25*RADIUS;
+    }
+
+    int KRON_ITERATIONS = psMetadataLookupS32 (&status, recipe, "KRON_ITERATIONS");
+    if (!status) {
+        KRON_ITERATIONS = 2;
     }
 
@@ -140,7 +145,8 @@
             PS_ARRAY_ADD_SCALAR(job->args, RADIUS,             PS_TYPE_F32);
             PS_ARRAY_ADD_SCALAR(job->args, MIN_KRON_RADIUS,    PS_TYPE_F32);
+            PS_ARRAY_ADD_SCALAR(job->args, KRON_ITERATIONS,    PS_TYPE_S32);
 
 // set this to 0 to run without threading
-# if (1)
+# if (0)
             if (!psThreadJobAddPending(job)) {
                 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
@@ -150,5 +156,4 @@
 	    if (!psphotKronIterate_Threaded(job)) {
 		psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
-		psFree(AnalysisRegion);
 		return false;
 	    }
@@ -188,7 +193,8 @@
     float RADIUS                    = PS_SCALAR_VALUE(job->args->data[5],F32);
     float MIN_KRON_RADIUS           = PS_SCALAR_VALUE(job->args->data[6],F32);
+    int KRON_ITERATIONS             = PS_SCALAR_VALUE(job->args->data[7],S32);
 
     // XXX TEST : set iteration to 1
-    for (int j = 0; j < 1; j++) {
+    for (int j = 0; j < KRON_ITERATIONS; j++) {
 	for (int i = 0; i < sources->n; i++) {
 
@@ -217,8 +223,18 @@
 	    // XXX float windowRadius = PS_MIN(PS_MAX(RADIUS, 4.0*source->moments->Mrf), maxWindow);
 
+	    // Sextractor apparently takes something like the skyRadius window, measures the moments inside that window,
+	    // then uses an elliptical outline based on the 2nd moments, but 6x the size
+
 	    // XXX TEST : use a window based on the radial profile numbers: max is skyRadius, min is RADIUS
 	    // if we lack the skyRadius (eg MATCHED sources), go to the default value
-	    float maxWindow = isfinite(source->skyRadius) ? source->skyRadius : RADIUS;
-	    float windowRadius = PS_MAX(RADIUS, maxWindow);
+	    float maxWindow, windowRadius;
+	    
+	    if (j == 0) {
+		maxWindow = isfinite(source->skyRadius) ? source->skyRadius : RADIUS;
+		windowRadius = PS_MAX(RADIUS, maxWindow);
+	    } else {
+		maxWindow = isfinite(source->moments->Mrf) ? 6.0*source->moments->Mrf : RADIUS;
+		windowRadius = PS_MAX(RADIUS, maxWindow);
+	    }
 
 	    // re-allocate image, weight, mask arrays for each peak with box big enough to fit BIG_RADIUS
Index: /branches/eam_branches/ipp-20111122/psphot/src/psphotSetThreads.c
===================================================================
--- /branches/eam_branches/ipp-20111122/psphot/src/psphotSetThreads.c	(revision 33611)
+++ /branches/eam_branches/ipp-20111122/psphot/src/psphotSetThreads.c	(revision 33612)
@@ -30,5 +30,5 @@
     psFree(task);
 
-    task = psThreadTaskAlloc("PSPHOT_KRON_ITERATE", 7);
+    task = psThreadTaskAlloc("PSPHOT_KRON_ITERATE", 8);
     task->function = &psphotKronIterate_Threaded;
     psThreadTaskAdd(task);
