Index: /trunk/psphot/src/psphot.h
===================================================================
--- /trunk/psphot/src/psphot.h	(revision 10613)
+++ /trunk/psphot/src/psphot.h	(revision 10614)
@@ -94,6 +94,2 @@
 bool psphotPlotMoments (pmConfig *config, pmFPAview *view, psArray *sources);
 bool psphotPlotPSFModel (pmConfig *config, pmFPAview *view, psArray *sources);
-
-// move to psLib or psModules
-int psphotKapaOpen ();
-bool psphotKapaClose ();
Index: /trunk/psphot/src/psphotReadout.c
===================================================================
--- /trunk/psphot/src/psphotReadout.c	(revision 10613)
+++ /trunk/psphot/src/psphotReadout.c	(revision 10614)
@@ -175,5 +175,6 @@
     pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");
 
-    psphotKapaClose ();
+    // XXX move this to top of loop
+    pmKapaClose ();
 
     psFree (psf);
Index: /trunk/psphot/src/psphotSummaryPlots.c
===================================================================
--- /trunk/psphot/src/psphotSummaryPlots.c	(revision 10613)
+++ /trunk/psphot/src/psphotSummaryPlots.c	(revision 10614)
@@ -5,28 +5,8 @@
 // which perform NOP and return false (XXX should this be true??)
 
+// this variable is defined in psmodules.h if ohana-config is found
 # if (HAVE_KAPA)
 
 # include <kapa.h>
-
-// XXX not thread safe (perhaps not needed)
-// to make this thread safe, we could check the thread ID and tie to it
-static int kapa_fd = -1;
-int psphotKapaOpen () {
-
-    if (kapa_fd == -1) {
-	// XXX make -noX an option
-	// XXX -noX is crashing kapa on point plotting
-	kapa_fd = KapaOpen ("kapa", "psphot");
-    }
-    return kapa_fd;
-}
-
-bool psphotKapaClose () {
-    
-    if (kapa_fd == -1) return true;
-    KapaClose (kapa_fd);
-    kapa_fd = -1;
-    return true;
-}
 
 // plot the sx, sy moments plane (faint and bright sources)
@@ -47,5 +27,5 @@
     psLogMsg ("psphot", 3, "creating moments plot");
 
-    int kapa = psphotKapaOpen ();
+    int kapa = pmKapaOpen ();
     if (kapa == -1) {
 	psError(PSPHOT_ERR_UNKNOWN, true, "failure to open kapa");
@@ -143,5 +123,5 @@
     psLogMsg ("psphot", 3, "creating psf model plot");
 
-    int kapa = psphotKapaOpen ();
+    int kapa = pmKapaOpen ();
     if (kapa == -1) {
 	psError(PSPHOT_ERR_UNKNOWN, true, "failure to open kapa");
@@ -297,11 +277,3 @@
 }
 
-int psphotKapaOpen () {
-    return -1;
-}
-
-bool psphotKapaClose () {
-    return true;
-}
-
 # endif
