Index: trunk/psphot/src/psphotKronIterate.c
===================================================================
--- trunk/psphot/src/psphotKronIterate.c	(revision 33877)
+++ trunk/psphot/src/psphotKronIterate.c	(revision 33879)
@@ -1,6 +1,3 @@
 # include "psphotInternal.h"
-
-#define NO_USE_SE_KR   1
-#define NO_SAVE_IMAGES 1
 
 bool psphotKronWindowSetSource(pmSource *source, psImage *kronWindow, bool useKronRadius, bool insert, bool oldWindow);
@@ -57,101 +54,4 @@
 bool psphotVisualRangeImage (int kapaFD, psImage *inImage, const char *name, int channel, float min, float max);
 
-bool pass1 = true;
-// This is defined in pmSource.c
-extern psString psphot_outroot;
-
-#ifdef USE_SE_KR
-static int   nKR = 0;
-// input list indexed by list file's source->id
-static float kr_sextractor[10000];
-static int used[10000];
-
-int numMatched = 0;
-
-#define SE_KR_USED 0x800
-
-static void find_se_kr(pmSource *source) {
-    int sid = source->id;
-    if (isfinite(kr_sextractor[sid])) {
-        source->moments->Mrf = kr_sextractor[sid] / 2.5;
-        source->tmpFlags |= SE_KR_USED;
-        numMatched++;
-    }
-}
-
-static void getxy(pmSource *source, float *pX, float *pY) {
-    float x, y;
-    if (source->modelPSF) {
-	psF32 *PAR = source->modelPSF->params->data.F32;
-        x = PAR[PM_PAR_XPOS];
-	y = PAR[PM_PAR_YPOS];
-    } else if (pmSourcePositionUseMoments(source)) {
-        x = source->moments->Mx;
-        y = source->moments->My;
-    } else {
-        x = source->peak->x;
-        y = source->peak->y;
-    }
-    *pX = x;
-    *pY = y;
-}
-
-static void build_kr_list(psArray *sources) {
-    // write list of source->id X Y to a file
-    pid_t pid = getpid();
-    char filename[40];
-    sprintf(filename, "sources.%d.list", pid);
-    FILE *out = fopen(filename, "w");
-    for (int i=0; i < sources->n; i++) {
-        pmSource *source = sources->data[i];
-        float x, y;
-        getxy(source, &x, &y);
-        fprintf(out, "%6.3f %6.3f %5d\n", x, y, source->id);
-    }
-    fclose(out);
-    // run gcompare on that file
-
-    char matchedfilename[20];
-    sprintf(matchedfilename, "sources.%d.matched", pid);
-    char command[80];
-    sprintf(command, "rungcompare %s %s", filename, matchedfilename);
-    int rc = system(command);
-    if (rc) {
-        fprintf(stderr, "failed to read matched list %d %d\n", rc, rc >> 8);
-        return;
-    }
-
-    unlink(filename);
-
-    for (int i = 0; i < 10000; i++) {
-        used[i] = -1;
-        kr_sextractor[i] = NAN;
-    }
-    int sid;
-    int ipp_idet;
-    float kr;
-    // read the results to build the kr_sextractor
-    FILE *in = fopen(matchedfilename, "r");
-    while (fscanf(in, "%d %f %d", &sid, &kr, &ipp_idet) > 0) {
-        // take first match for each sid ...
-        if (!isfinite(kr_sextractor[sid])) { 
-            // .. and for each ipp_idet Since the lists are sorted in
-            // order of SN this makes it more likely to get the right match
-            if (used[ipp_idet] == -1) {
-                kr_sextractor[sid] = kr;
-                used[ipp_idet] = sid;
-                nKR++;
-            } else {
-                fprintf(stderr, "match for %d %d is already used for %d\n",
-                    sid, ipp_idet, used[ipp_idet]);
-            }
-        }
-    }
-    fclose(in);
-    unlink(matchedfilename);
-}
-
-#endif // USE_SE_KR
-
 bool psphotKronIterateReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources, pmPSF *psf, int index) {
 
@@ -165,9 +65,4 @@
     psTimerStart ("psphot.kron");
 
-#ifdef USE_SE_KR
-    if (!pass1) {
-        build_kr_list(sources);
-    }
-#endif
 
     // determine the number of allowed threads
@@ -237,7 +132,4 @@
 
     // start with the currently known moments (Mxx, Myy, Mxy) and generate a window image
-#ifdef USE_SE_KR
-    int previous = numMatched;
-#endif
     for (int i = 0; i < sources->n; i++) {
 
@@ -247,15 +139,5 @@
 	// (this skips really bad sources (no peak, no moments, DEFECT)
 	psphotKronWindowSetSource (source, kronWindow, false, true, KRON_APPLY_WINDOW);
-#ifdef USE_SE_KR
-        if (!pass1) {
-            find_se_kr(source);
-        }
-#endif
-    }
-#ifdef USE_SE_KR
-    if (!pass1) {
-        fprintf(stdout, "Matched %d sources previous %d\n", numMatched, previous);
-    }
-#endif
+    }
 
     // We measure the Kron Radius on a smoothed copy of the readout image
@@ -291,26 +173,4 @@
 
     }
-
-#ifdef SAVE_IMAGES
-    psphot_outroot = psMetadataLookupStr(&status, config->arguments, "OUTPUT");
-    {
-        // Save the background subtracted image
-        psString fn = NULL;
-        psStringAppend(&fn, "%s.p%d.src.sub.fits", psphot_outroot, pass1 ? 1 : 2);
-        psphotSaveImage(0, readout->image, fn);
-        psFree(fn);
-        fn = NULL;
-        if (KRON_SMOOTH) {
-            psStringAppend(&fn, "%s.p%d.src.sub.sm.fits", psphot_outroot, pass1 ? 1 : 2);
-            psphotSaveImage(0, smoothedImage, fn);
-            psFree(fn);
-        }
-        if (KRON_APPLY_WINDOW) {
-            psStringAppend(&fn, "%s.p%d.window.fits", psphot_outroot, pass1 ? 1 : 2);
-            psphotSaveImage(0, kronWindow, fn);
-            psFree(fn);
-        }
-    }
-#endif
 
     // threaded measurement of the source magnitudes
@@ -377,7 +237,4 @@
     psFree (kronWindow);
     psFree (smoothedImage);
-    if (pass1) {
-        pass1 = false;
-    }
 
     psLogMsg ("psphot.kron", PS_LOG_WARN, "measure masked kron magnitudes : %f sec for %ld objects\n", psTimerMark ("psphot.kron"), sources->n);
@@ -465,18 +322,4 @@
 	    if (psphotKronWindowSetSource (source, kronWindow, (j > 0), false, KRON_APPLY_WINDOW)) {
 
-#ifdef SAVE_IMAGES
-#ifdef SAVE_SOURCE_IMAGES
-                if (j == 1 && !pass1) {
-                    char fn[80];
-                    if (smoothedPixels) {
-                        sprintf(fn, "%s.s.%d.p%d.sm.fits", psphot_outroot, source->id, pass1 ? 1 : 2);
-                        psphotSaveImage(0, smoothedPixels, fn);
-                    }
-                    sprintf(fn, "%s.s.%d.p%d.fits", psphot_outroot, source->id, pass1 ? 1 : 2);
-                    psphotSaveImage(0, source->pixels, fn);
-                }
-#endif
-#endif
-
                 // this function populates moments->Mrf,KronFlux,KronFluxErr
                 psphotKronWindowMag (source, kronWindow, windowRadius, MIN_KRON_RADIUS, maskVal, KRON_APPLY_WEIGHT, smoothedPixels);
@@ -606,9 +449,4 @@
 	    psF32 rs = 0.5 * (fDiff1 + fDiff2);
 
-#ifdef BE_SIMPLE_MINDED
-            rf = vPix[row][col] * sqrt(r2);
-            rs = vPix[row][col];
-#endif
-
 	    RF  += rf;
 	    RS  += rs;
@@ -621,10 +459,4 @@
 	Mrf = MIN (radius, Mrf);
     }
-#ifdef USE_SE_KR
-    if (source->tmpFlags & SE_KR_USED) {
-        // we are using the sextratcor KR for this source set it back
-        Mrf = source->moments->Mrf;
-    }
-#endif
 
     // Calculate the Kron magnitude (make this block optional?)
