Index: /branches/eam_branch_20080926/psphot/src/psphotArguments.c
===================================================================
--- /branches/eam_branch_20080926/psphot/src/psphotArguments.c	(revision 19761)
+++ /branches/eam_branch_20080926/psphot/src/psphotArguments.c	(revision 19762)
@@ -67,4 +67,10 @@
     }
 
+    // visual : interactive display mode
+    if ((N = psArgumentGet (argc, argv, "-visual"))) {
+        psArgumentRemove (N, &argc, argv);
+	psphotSetVisual (true);
+    }
+
     // break : used from recipe throughout psphotReadout
     if ((N = psArgumentGet (argc, argv, "-break"))) {
Index: /branches/eam_branch_20080926/psphot/src/psphotReadout.c
===================================================================
--- /branches/eam_branch_20080926/psphot/src/psphotReadout.c	(revision 19761)
+++ /branches/eam_branch_20080926/psphot/src/psphotReadout.c	(revision 19762)
@@ -35,4 +35,7 @@
         return psphotReadoutCleanup(config, readout, recipe, NULL, NULL, NULL);
     }
+
+    // set up the Visual display, display the image, weight, mask (ch 1,2,3)
+    psphotVisualShowImage (readout);
 
     // generate a background model (median, smoothed image)
Index: /branches/eam_branch_20080926/psphot/src/psphotVisual.c
===================================================================
--- /branches/eam_branch_20080926/psphot/src/psphotVisual.c	(revision 19762)
+++ /branches/eam_branch_20080926/psphot/src/psphotVisual.c	(revision 19762)
@@ -0,0 +1,77 @@
+# include "psphotInternal.h"
+
+# if (HAVE_KAPA)
+# include <kapa.h>
+
+// functions used to visualize the analysis as it goes
+// these are invoked by the -visual options
+
+static bool isVisual = false;
+static int kapa = -1;
+
+bool psphotSetVisual (bool mode) {
+
+  isVisual = mode;
+  return true;
+}
+
+bool psphotVisualShowImage (pmReadout *readout) {
+
+  KiiImage image;
+  KapaImageData data;
+  Coords coords;
+
+  if (!isVisual) return true;
+
+  if (kapa == -1) {
+    kapa = pmKapaOpen (true, "psphot");
+    if (kapa == -1) {
+      fprintf (stderr, "failure to open kapa; visual mode disabled\n");
+      isVisual = false;
+      return false;
+    }
+  }  
+
+  // XXX get image stats
+  image.data2d = readout->image->data.F32;
+  image.Nx = readout->image->numCols;
+  image.Ny = readout->image->numRows;
+
+  strcpy (data.name, "image");
+  strcpy (data.file, "image");
+  data.zero = 0.0;
+  data.range = 1000.0;
+  data.logflux = 0;
+  
+  KiiSetChannel (kapa, 0);
+  KiiNewPicture2D (kapa, &image, &data, &coords);
+  
+  // display the weight
+  image.data2d = readout->weight->data.F32;
+  image.Nx = readout->weight->numCols;
+  image.Ny = readout->weight->numRows;
+
+  strcpy (data.name, "weight");
+  strcpy (data.file, "weight");
+  data.zero = 0.0;
+  data.range = 1000.0;
+  data.logflux = 0;
+  
+  KiiSetChannel (kapa, 0);
+  KiiNewPicture2D (kapa, &image, &data, &coords);
+  
+  // display the weight
+  image.data2d = readout->weight->data.F32;
+  image.Nx = readout->weight->numCols;
+  image.Ny = readout->weight->numRows;
+
+  strcpy (data.name, "mask");
+  strcpy (data.file, "maak");
+  data.zero = 0.0;
+  data.range = 1000.0;
+  data.logflux = 0;
+  
+  KiiSetChannel (kapa, 0);
+  KiiNewPicture2D (kapa, &image, &data, &coords);
+}
+
