Index: /trunk/psModules/configure.ac
===================================================================
--- /trunk/psModules/configure.ac	(revision 10609)
+++ /trunk/psModules/configure.ac	(revision 10610)
@@ -56,5 +56,5 @@
 
 SRCPATH='${top_srcdir}/src'
-SRCDIRS="config concepts camera astrom detrend imcombine objects"
+SRCDIRS="extras config concepts camera astrom detrend imcombine objects"
 # escape two escapes at this level so \\ gets passed to the shell and \ to perl
 SRCINC=`echo "${SRCDIRS=}" | ${PERL} -pe "s|(\w+)|-I\\\\${SRCPATH=}/\1|g"`
@@ -100,4 +100,172 @@
 AM_CONDITIONAL(DOXYGEN, test x$doxygen = xtrue)
 
+dnl ------------------ kapa,libkapa options -------------------------
+dnl -- libkapa implies the requirement for libpng, libjpeg as well --
+
+dnl save LIBS/CFLAGS/LDFLAGS
+TMP_LIBS=${LIBS}
+TMP_CFLAGS=${CFLAGS}
+TMP_LDFLAGS=${LDFLAGS}
+TMP_CPPFLAGS=${CPPFLAGS}
+
+dnl test for command-line options: use ohana-config if not supplied
+KAPA_CFLAGS_CONFIG="true"
+KAPA_LIBS_CONFIG="true"
+AC_ARG_WITH(kapa,
+[AS_HELP_STRING(--with-kapa=DIR,Specify location of libkapa)],
+[KAPA_CFLAGS="-I$withval/include" KAPA_LIBS="-L$withval/lib" 
+ KAPA_CFLAGS_CONFIG="false"       KAPA_LIBS_CONFIG="false"])
+AC_ARG_WITH(kapa-include,
+[AS_HELP_STRING(--with-kapa-include=DIR,Specify libkapa include directory.)],
+[KAPA_CFLAGS="-I$withval" KAPA_CFLAGS_CONFIG="false"])
+AC_ARG_WITH(kapa-lib,
+[AS_HELP_STRING(--with-kapa-lib=DIR,Specify libkapa library directory.)],
+[KAPA_LIBS="-L$withval" KAPA_LIBS_CONFIG="false"])
+
+echo "KAPA_CFLAGS_CONFIG: $KAPA_CFLAGS_CONFIG"
+echo "KAPA_LIBS_CONFIG: $KAPA_LIBS_CONFIG"
+echo "KAPA_CFLAGS: $KAPA_CFLAGS"
+echo "KAPA_LIBS: $KAPA_LIBS"
+
+dnl HAVE_KAPA is set to false if any of the tests fail
+HAVE_KAPA="true"
+AC_MSG_NOTICE([checking for libkapa])
+if test "$KAPA_CFLAGS_CONFIG" = "true" -o "$KAPA_LIBS_CONFIG" = "true"; then
+  AC_MSG_NOTICE([kapa info supplied by ohana-config])
+  KAPA_CONFIG=`which ohana-config`
+  AC_CHECK_FILE($KAPA_CONFIG,[],
+    [HAVE_KAPA="false"; AC_MSG_WARN([libkapa is not found: output plots disabled.  Obtain libkapa at http://kiawe.ifa.hawaii.edu/Elixir/Ohana or use --with-kapa to specify location])])
+  
+  echo "HAVE_KAPA: $HAVE_KAPA"
+  echo "KAPA_CFLAGS_CONFIG: $KAPA_CFLAGS_CONFIG"
+
+  if test "$HAVE_KAPA" = "true" -a "$KAPA_CFLAGS_CONFIG" = "true" ; then
+   AC_MSG_NOTICE([libkapa cflags info supplied by ohana-config])
+   AC_MSG_CHECKING([libkapa cflags])
+   KAPA_CFLAGS="`${KAPA_CONFIG} --cflags`"
+   AC_MSG_RESULT([${KAPA_CFLAGS}])
+  fi
+
+  if test "$HAVE_KAPA" = "true" -a "$KAPA_LIBS_CONFIG" = "true" ; then
+   AC_MSG_NOTICE([libkapa ldflags info supplied by ohana-config])
+   AC_MSG_CHECKING([libkapa ldflags])
+   KAPA_LIBS="`${KAPA_CONFIG} --libs` -lX11"
+   AC_MSG_RESULT([${KAPA_LIBS}])
+  fi
+fi
+
+if test "$HAVE_KAPA" = "true" ; then
+ AC_MSG_NOTICE([libkapa supplied])
+ PSMODULES_CFLAGS="${PSMODULES_CFLAGS} ${KAPA_CFLAGS}"
+ PSMODULES_LIBS="${PSMODULES_LIBS} ${KAPA_LIBS}"
+else
+ AC_MSG_NOTICE([libkapa ignored])
+fi
+
+dnl HAVE_KAPA is set to false if any of the tests fail
+dnl HAVE_KAPA=true
+dnl AC_CHECK_HEADERS([kapa.h],
+dnl  [PSMODULES_CFLAGS="$PSMODULES_CFLAGS $KAPA_CFLAGS" AC_SUBST(KAPA_CFLAGS)],
+dnl  [HAVE_KAPA=false; AC_MSG_WARN([libkapa headers not found: output plots disabled.  Obtain libkapa at http://kiawe.ifa.hawaii.edu/Elixir/Ohana or use --with-kapa to specify location.])]
+dnl )
+dnl AC_CHECK_LIB(kapa,KapaInitGraph,
+dnl  [PSMODULES_LIBS="$PSMODULES_LIBS $JPEG_LDFLAGS -ljpeg"],  
+dnl  [HAVE_KAPA=false; AC_MSG_WARN([libkapa headers not found: output plots disabled.  Obtain libkapa at http://kiawe.ifa.hawaii.edu/Elixir/Ohana or use --with-kapa to specify location.])],[-lm]
+dnl )
+
+dnl restore the CFLAGS/LDFLAGS
+LIBS=${TMP_LIBS}
+CFLAGS=${TMP_CFLAGS}
+LDFLAGS=${TMP_LDFLAGS}
+CPPFLAGS=${TMP_CPPFLAGS}
+
+dnl ------------------ libjpeg options ---------------------
+
+dnl save LIBS/CFLAGS/LDFLAGS
+TMP_LIBS=${LIBS}
+TMP_CFLAGS=${CFLAGS}
+TMP_LDFLAGS=${LDFLAGS}
+TMP_CPPFLAGS=${CPPFLAGS}
+
+AC_ARG_WITH(jpeg,
+[AS_HELP_STRING(--with-jpeg=DIR,Specify location of libjpeg.)],
+[JPEG_CFLAGS="-I$withval/include"
+ JPEG_LDFLAGS="-L$withval/lib"])
+AC_ARG_WITH(jpeg-include,
+[AS_HELP_STRING(--with-jpeg-include=DIR,Specify libjpeg include directory.)],
+[JPEG_CFLAGS="-I$withval"])
+AC_ARG_WITH(jpeg-lib,
+[AS_HELP_STRING(--with-jpeg-lib=DIR,Specify libjpeg library directory.)],
+[JPEG_LDFLAGS="-L$withval"])
+
+CFLAGS="${CFLAGS} ${JPEG_CFLAGS}"
+CPPFLAGS=${CFLAGS}
+LDFLAGS="${LDFLAGS} ${JPEG_LDFLAGS}"
+
+AC_CHECK_HEADERS([jpeglib.h],
+  [PSMODULES_CFLAGS="$PSMODULES_CFLAGS $JPEG_CFLAGS" AC_SUBST(JPEG_CFLAGS)],
+  [HAVE_KAPA=false; AC_MSG_WARN([libjpeg headers not found: output plots disabled.  Obtain libjpeg from http://www.ijg.org/ or use --with-jpeg to specify location.])]
+)
+
+AC_CHECK_LIB(jpeg,jpeg_CreateCompress,
+  [PSMODULES_LIBS="$PSMODULES_LIBS $JPEG_LDFLAGS -ljpeg"],
+  [HAVE_KAPA=false; AC_MSG_WARN([libjpeg library not found: output plots disabled.  Obtain libjpeg from http://www.ijg.org/ or use --with-jpeg to specify location.])]
+)
+
+dnl restore the CFLAGS/LDFLAGS
+LIBS=${TMP_LIBS}
+CFLAGS=${TMP_CFLAGS}
+LDFLAGS=${TMP_LDFLAGS}
+CPPFLAGS=${TMP_CPPFLAGS}
+
+dnl ------------------ libpng options ---------------------
+
+dnl save LIBS/CFLAGS/LDFLAGS
+TMP_LIBS=${LIBS}
+TMP_CFLAGS=${CFLAGS}
+TMP_LDFLAGS=${LDFLAGS}
+TMP_CPPFLAGS=${CPPFLAGS}
+
+AC_ARG_WITH(png,
+[AS_HELP_STRING(--with-png=DIR,Specify location of libpng.)],
+[PNG_CFLAGS="-I$withval/include"
+ PNG_LDFLAGS="-L$withval/lib"])
+AC_ARG_WITH(png-include,
+[AS_HELP_STRING(--with-png-include=DIR,Specify libpng include directory.)],
+[PNG_CFLAGS="-I$withval"])
+AC_ARG_WITH(png-lib,
+[AS_HELP_STRING(--with-png-lib=DIR,Specify libpng library directory.)],
+[PNG_LDFLAGS="-L$withval"])
+
+CFLAGS="${CFLAGS} ${PNG_CFLAGS}"
+CPPFLAGS=${CFLAGS}
+LDFLAGS="${LDFLAGS} ${PNG_LDFLAGS}"
+
+AC_CHECK_HEADERS([png.h],
+  [PSMODULES_CFLAGS="$PSMODULES_CFLAGS $PNG_CFLAGS" AC_SUBST(PNG_CFLAGS)],
+  [HAVE_KAPA=false; AC_MSG_WARN([libpng headers not found: output plots disabled.  Obtain libpng from http://www.ijg.org/ or use --with-png to specify location.])]
+)
+
+AC_CHECK_LIB(png,png_init_io,
+  [PSMODULES_LIBS="$PSMODULES_LIBS $PNG_LDFLAGS -lpng"],
+  [HAVE_KAPA=false; AC_MSG_WARN([libpng library not found: output plots disabled.  Obtain libpng from http://www.ijg.org/ or use --with-png to specify location.])]
+)
+
+dnl restore the CFLAGS/LDFLAGS
+LIBS=${TMP_LIBS}
+CFLAGS=${TMP_CFLAGS}
+LDFLAGS=${TMP_LDFLAGS}
+CPPFLAGS=${TMP_CPPFLAGS}
+
+dnl ------------------ use kapa or not? ---------------------
+
+if test "$HAVE_KAPA" == "true" ; then
+  AC_MSG_RESULT([including plotting functions])
+  AC_DEFINE([HAVE_KAPA],[1],[enable use of libkapa])
+else
+  AC_MSG_RESULT([skipping plotting functions])
+  AC_DEFINE([HAVE_KAPA],[0],[disable use of libkapa])
+fi
+
 dnl pslib ---------------------------------------------------------------------
 AC_ARG_WITH(pslib-config,
@@ -120,4 +288,8 @@
 PSMODULES_CFLAGS="${PSMODULES_CFLAGS=} ${PSLIB_CFLAGS}"
 PSMODULES_LIBS="${PSMODULES_LIBS=} ${PSLIB_LIBS}"
+
+echo "PSMODULES_CFLAGS: $PSMODULES_CFLAGS"
+echo "PSMODULE_LIBS: $PSMODULES_LIBS"
+
 dnl ---------------------------------------------------------------------------
 
@@ -135,4 +307,5 @@
   src/imcombine/Makefile
   src/objects/Makefile
+  src/extras/Makefile
   test/Makefile
   test/astrom/Makefile
@@ -141,4 +314,5 @@
   test/concepts/Makefile
   test/detrend/Makefile
+  test/extras/Makefile
   test/imcombine/Makefile
   test/objects/Makefile
Index: /trunk/psModules/src/detrend/Makefile.am
===================================================================
--- /trunk/psModules/src/detrend/Makefile.am	(revision 10609)
+++ /trunk/psModules/src/detrend/Makefile.am	(revision 10610)
@@ -11,7 +11,5 @@
 	pmBias.c \
 	pmDetrendDB.c \
-	pmShutterCorrection.c \
-	psPipe.c \
-	psIOBuffer.c
+	pmShutterCorrection.c
 
 #	pmSkySubtract.c
@@ -25,7 +23,5 @@
 	pmBias.h \
 	pmDetrendDB.h \
-	pmShutterCorrection.h \
-	psPipe.h \
-	psIOBuffer.h
+	pmShutterCorrection.h
 
 #	pmSkySubtract.h
Index: unk/psModules/src/detrend/psIOBuffer.c
===================================================================
--- /trunk/psModules/src/detrend/psIOBuffer.c	(revision 10609)
+++ 	(revision )
@@ -1,113 +1,0 @@
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <pslib.h>
-#include "psIOBuffer.h"
-
-static void psIOBufferFree (psIOBuffer *buffer)
-{
-    if (buffer == NULL)
-        return;
-
-    psFree (buffer->data);
-    return;
-}
-
-psIOBuffer *psIOBufferAlloc (int nBuffer)
-{
-
-    psIOBuffer *buffer = (psIOBuffer *)psAlloc(sizeof(psIOBuffer));
-    psMemSetDeallocator(buffer, (psFreeFunc) psIOBufferFree);
-
-    buffer->data = (char *) psAlloc (nBuffer);
-
-    buffer->nAlloc = nBuffer;
-    buffer->nReset = nBuffer;
-    buffer->nBlock = nBuffer / 2;
-    buffer->n = 0;
-    return (buffer);
-}
-
-bool psIOBufferFlush (psIOBuffer *buffer)
-{
-
-    if (buffer == NULL)
-        return false;
-    buffer->n = 0;
-    buffer->nAlloc = buffer->nReset;
-    psRealloc (buffer->data, buffer->nAlloc);
-    bzero (buffer->data, buffer->nAlloc);
-
-    return true;
-}
-
-int psIOBufferRead (psIOBuffer *buffer, int fd)
-{
-
-    int Nread, Nfree;
-
-    if (fd == 0) {
-        /* pipe is closed */
-        return (0);
-    }
-
-    Nfree = buffer->nAlloc - buffer->n;
-
-    // extend the data block if needed
-    if (Nfree < buffer->nBlock) {
-        buffer->nAlloc += 2*buffer->nBlock;
-        psRealloc (buffer->data, buffer->nAlloc);
-        Nfree = buffer->nAlloc - buffer->n;
-        bzero (buffer->data + buffer->n, Nfree);
-    }
-
-    // attempt to read from the fd into the buffer
-    Nread = read (fd, &buffer->data[buffer->n], buffer->nBlock);
-
-    if (Nread >= 0) {
-        buffer->n += Nread;
-        buffer->data[buffer->n] = 0;
-        return (Nread);
-    }
-
-    // check on exit status (try again if waiting for non-blocking fd)
-    if (Nread == -1) {
-        switch (errno) {
-        case EAGAIN:
-        case EIO:
-            /** no data available in pipe **/
-            return (-1);
-        default:
-            /** error reading from pipe **/
-            psError (PS_ERR_IO, true, "error on psIOBufferRead");
-            return (-2);
-        }
-    }
-    return (Nread);
-}
-
-/* read until buffer is empty (Nmax retries) */
-int psIOBufferReadEmpty (psIOBuffer *buffer, int Nmax, int fd)
-{
-
-    int i, status;
-
-    status = -1;
-    for (i = 0; (status != 0) && (i < Nmax); i++) {
-        status = psIOBufferRead (buffer, fd);
-        if (status == -2)
-            return false;
-        if (status == -1)
-            usleep (10000);
-        if (status > 0)
-            i = 0;
-    }
-    if (status == -1)
-        return false;
-    return true;
-}
Index: unk/psModules/src/detrend/psIOBuffer.h
===================================================================
--- /trunk/psModules/src/detrend/psIOBuffer.h	(revision 10609)
+++ 	(revision )
@@ -1,34 +1,0 @@
-/** @file  psPipe.h
-*
-*  @brief 3-stream pipe 
-*
-*  @ingroup misc
-*
-*  @author EAM, IfA
-*
-*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-10 01:01:09 $
-*
-*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
-*/
-
-#ifndef PS_IO_BUFFER_H
-#define PS_IO_BUFFER_H
-
-typedef struct
-{
-    char *data;
-    int nAlloc;    // current size of allocated buffer
-    int nReset;    // size to set buffer after flush
-    int nBlock;    // number of bytes to try to read at a time
-    int n;    // current size of filled data
-}
-psIOBuffer;
-
-// psIOBuffer functions
-psIOBuffer *psIOBufferAlloc (int nBuffer);
-bool psIOBufferFlush (psIOBuffer *buffer);
-int psIOBufferRead (psIOBuffer *buffer, int fd);
-int psIOBufferReadEmpty (psIOBuffer *buffer, int maxRetries, int fd);
-
-# endif
Index: unk/psModules/src/detrend/psPipe.c
===================================================================
--- /trunk/psModules/src/detrend/psPipe.c	(revision 10609)
+++ 	(revision )
@@ -1,210 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <pslib.h>
-#include <psPipe.h>
-
-void closePipes (int *stdin_fd, int *stdout_fd, int *stderr_fd)
-{
-
-    if (stdin_fd[0]  != 0)
-        close (stdin_fd[0]);
-    if (stdin_fd[1]  != 0)
-        close (stdin_fd[0]);
-    if (stdout_fd[0] != 0)
-        close (stdout_fd[0]);
-    if (stdout_fd[1] != 0)
-        close (stdout_fd[1]);
-    if (stderr_fd[0] != 0)
-        close (stderr_fd[0]);
-    if (stderr_fd[1] != 0)
-        close (stderr_fd[1]);
-}
-
-static void psPipeFree (psPipe *pipe)
-{
-    return;
-}
-
-psPipe *psPipeAlloc ()
-{
-    psPipe *pipe = (psPipe *)psAlloc(sizeof(psPipe));
-    psMemSetDeallocator(pipe, (psFreeFunc) psPipeFree);
-
-    pipe->fd_stdin  = 0;
-    pipe->fd_stdout = 0;
-    pipe->fd_stderr = 0;
-    return (pipe);
-}
-
-psPipe *psPipeOpen (char *command)
-{
-
-    int stdin_fd[2], stdout_fd[2], stderr_fd[2], status;
-    pid_t pid;
-
-    bzero (stdin_fd,  2*sizeof(int));
-    bzero (stdout_fd, 2*sizeof(int));
-    bzero (stderr_fd, 2*sizeof(int));
-
-    if (pipe (stdin_fd)  < 0) {
-        psError (PS_ERR_UNKNOWN, true, "cannot create pipe file descriptor");
-        closePipes (stdin_fd, stdout_fd, stderr_fd);
-        return NULL;
-    }
-    if (pipe (stdout_fd) < 0) {
-        psError (PS_ERR_UNKNOWN, true, "cannot create pipe file descriptor");
-        closePipes (stdin_fd, stdout_fd, stderr_fd);
-        return NULL;
-    }
-    if (pipe (stderr_fd) < 0) {
-        psError (PS_ERR_UNKNOWN, true, "cannot create pipe file descriptor");
-        closePipes (stdin_fd, stdout_fd, stderr_fd);
-        return NULL;
-    }
-
-    psArray *cmd = psStringSplitArray (command, " ", false);
-    if (cmd->n <= 0) {
-        psError (PS_ERR_UNKNOWN, true, "empty command for pipe");
-        psFree (cmd);
-        closePipes (stdin_fd, stdout_fd, stderr_fd);
-        return NULL;
-    }
-
-    // create the command line array needed by execvp
-    char **argv = (char **)psAlloc((cmd->n+1)*sizeof(char *));
-    for (int i = 0; i < cmd->n; i++) {
-        argv[i] = cmd->data[i];
-    }
-    argv[cmd->n] = NULL;
-
-    pid = fork ();
-    if (!pid) { /* must be child process */
-        /* close the other ends of the pipes */
-        close (stdin_fd[1]);
-        close (stdout_fd[0]);
-        close (stderr_fd[0]);
-
-        /* tie our ends of the pipes to stdin, stdout, stderr */
-        dup2 (stdin_fd[0],  STDIN_FILENO);
-        dup2 (stdout_fd[1], STDOUT_FILENO);
-        dup2 (stderr_fd[1], STDERR_FILENO);
-
-        /* set all three unblocking */
-        setvbuf (stdin,  (char *) NULL, _IONBF, BUFSIZ);
-        setvbuf (stdout, (char *) NULL, _IONBF, BUFSIZ);
-        setvbuf (stderr, (char *) NULL, _IONBF, BUFSIZ);
-
-        status = execvp (argv[0], argv);
-
-        // this statement exits the child, not the parent, process
-        exit (1);
-    }
-    psFree (cmd);
-    psFree (argv);
-
-    if (pid == -1) {
-        psError (PS_ERR_UNKNOWN, true, "unable to create child process");
-        closePipes (stdin_fd, stdout_fd, stderr_fd);
-        return NULL;
-    }
-
-    /* close the other ends of the pipes */
-    close (stdin_fd[0]);
-    stdin_fd[0]  = 0;
-    close (stdout_fd[1]);
-    stdout_fd[1] = 0;
-    close (stderr_fd[1]);
-    stderr_fd[1] = 0;
-
-    /* make the pipes non-blocking */
-    fcntl (stdin_fd[1],  F_SETFL, O_NONBLOCK);
-    fcntl (stdout_fd[0], F_SETFL, O_NONBLOCK);
-    fcntl (stderr_fd[0], F_SETFL, O_NONBLOCK);
-
-    psPipe *pipe = psPipeAlloc();
-
-    pipe->pid    = pid;
-    pipe->fd_stdin  = stdin_fd[1];
-    pipe->fd_stdout = stdout_fd[0];
-    pipe->fd_stderr = stderr_fd[0];
-
-    return (pipe);
-}
-
-// this function returns the exit status of the called function
-// or a value > 255 on an error
-int psPipeClose (psPipe *pipe)
-{
-    int close_status;
-    int exit_status;
-    int wait_status;
-    int result;
-
-    PS_ASSERT_PTR_NON_NULL(pipe, false);
-
-    close_status = true;
-    if (close (pipe->fd_stdin) != 0) {
-        psError(PS_ERR_IO, true, "error closing the pipe stdin (pid %d, error %s)\n", pipe->pid, strerror(errno));
-        close_status = false;
-    }
-    if (close (pipe->fd_stdout) != 0) {
-        psError(PS_ERR_IO, true, "error closing the pipe stdout (pid %d, error %s)\n", pipe->pid, strerror(errno));
-        close_status = false;
-    }
-    if (close (pipe->fd_stderr) != 0) {
-        psError(PS_ERR_IO, true, "error closing the pipe sterr (pid %d, error %s)\n", pipe->pid, strerror(errno));
-        close_status = false;
-    }
-
-    // we expect the child process to have exited.
-    // wait for the exit condition, but no longer than 100ms
-    for (int i = 0; i < 10; i++) {
-        result = waitpid (pipe->pid, &wait_status, WNOHANG);
-        switch (result) {
-        case -1:   // error on waitpid
-            switch (errno) {
-            case ECHILD:
-                psError(PS_ERR_IO, true, "unknown PID, not a child process: %d\n", pipe->pid);
-                return 0x100;
-            default:
-                psAbort ("psPipeClose", "unexpected response to waitpid: %d\n", result);
-            }
-            break;
-
-        case 0:   // child not yet exited
-            usleep (10000);
-            continue;
-
-        default:
-            if (result != pipe->pid) {
-                psAbort ("psPipeClose", "waitpid error: mis-matched PID (%d vs %d).  programming error\n", result, pipe->pid);
-            }
-            if (WIFEXITED(wait_status)) {
-                exit_status = WEXITSTATUS(wait_status);
-                if (close_status) {
-                    return exit_status;
-                } else {
-                    return (0x100);
-                }
-            }
-            if (WIFSIGNALED(wait_status)) {
-                psError(PS_ERR_IO, true, "job %d exited on signal %d\n", pipe->pid, WTERMSIG(wait_status));
-                return (0x100 + WTERMSIG(wait_status));
-            }
-            if (WIFSTOPPED(wait_status)) {
-                psAbort ("psPipeClose", "waitpid returns 'stopped' programming error\n");
-            }
-        }
-    }
-    psError(PS_ERR_IO, true, "child process pid %d did not exit\n", pipe->pid);
-    return 0x100;
-}
Index: unk/psModules/src/detrend/psPipe.h
===================================================================
--- /trunk/psModules/src/detrend/psPipe.h	(revision 10609)
+++ 	(revision )
@@ -1,33 +1,0 @@
-/** @file  psPipe.h
-*
-*  @brief 3-stream pipe 
-*
-*  @ingroup misc
-*
-*  @author EAM, IfA
-*
-*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-11-20 17:50:17 $
-*
-*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
-*/
-
-#ifndef PS_PIPE_H
-#define PS_PIPE_H
-
-// move these to pslib??
-typedef struct
-{
-    int pid;
-    int fd_stdin;
-    int fd_stdout;
-    int fd_stderr;
-}
-psPipe;
-
-// psPipe functions
-psPipe *psPipeAlloc ();
-psPipe *psPipeOpen (char *command);
-int     psPipeClose (psPipe *pipe);
-
-# endif
Index: /trunk/psModules/src/extras/Makefile.am
===================================================================
--- /trunk/psModules/src/extras/Makefile.am	(revision 10610)
+++ /trunk/psModules/src/extras/Makefile.am	(revision 10610)
@@ -0,0 +1,17 @@
+noinst_LTLIBRARIES = libpsmodulesextras.la
+
+libpsmodulesextras_la_CPPFLAGS = $(SRCINC) $(PSMODULES_CFLAGS) -I../pslib/
+libpsmodulesextras_la_LDFLAGS  = -release $(PACKAGE_VERSION)
+libpsmodulesextras_la_SOURCES  = \
+	psVectorBracket.c \
+	psPipe.c \
+	psIOBuffer.c \
+	pmKapaPlots.c
+
+pkginclude_HEADERS = \
+	psVectorBracket.h \
+	psPipe.h \
+	psIOBuffer.h \
+	pmKapaPlots.h
+
+CLEANFILES = *~
Index: /trunk/psModules/src/extras/pmKapaPlots.c
===================================================================
--- /trunk/psModules/src/extras/pmKapaPlots.c	(revision 10610)
+++ /trunk/psModules/src/extras/pmKapaPlots.c	(revision 10610)
@@ -0,0 +1,65 @@
+/** @file  pmAstrometryWCS.c
+ *
+ *  @brief functions to convert FITS WCS keywords to / from pmFPA structures
+ *
+ *  @ingroup Astrometry
+ *
+ *  @author EAM, IfA
+ *
+ *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-12-10 18:27:26 $
+ *
+ *  Copyright 2006 Institute for Astronomy, University of Hawaii
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <pslib.h>
+#include "pmKapaPlots.h"
+
+// the top portion of this file defines plotting functions which use kapa for plotting.
+// if kapa is not available, these functions are defined in the bottom portion as stubs
+// which perform NOP and return false (XXX should this be true??)
+
+# 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 pmKapaOpen ()
+{
+
+    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 pmKapaClose ()
+{
+
+    if (kapa_fd == -1)
+        return true;
+    KapaClose (kapa_fd);
+    kapa_fd = -1;
+    return true;
+}
+
+# else
+
+    int pmKapaOpen ()
+{
+    return -1;
+}
+
+bool KapaClose ()
+{
+    return true;
+}
+
+# endif
Index: /trunk/psModules/src/extras/pmKapaPlots.h
===================================================================
--- /trunk/psModules/src/extras/pmKapaPlots.h	(revision 10610)
+++ /trunk/psModules/src/extras/pmKapaPlots.h	(revision 10610)
@@ -0,0 +1,22 @@
+/** @file  pmAstrometryDistortion.h
+*
+*  @brief functions to convert FITS WCS keywords to / from pmFPA structures
+*
+*  @ingroup Astrometry
+*
+*  @author EAM, IfA
+*
+*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-12-10 18:27:26 $
+*
+*  Copyright 2006 Institute for Astronomy, University of Hawaii
+*/
+
+#ifndef PM_KAPA_PLOTS_H
+#define PM_KAPA_PLOTS_H
+
+// move to psLib or psModules
+int pmKapaOpen ();
+bool pmKapaClose ();
+
+#endif // PM_KAPA_PLOTS_H
Index: /trunk/psModules/src/extras/psIOBuffer.c
===================================================================
--- /trunk/psModules/src/extras/psIOBuffer.c	(revision 10610)
+++ /trunk/psModules/src/extras/psIOBuffer.c	(revision 10610)
@@ -0,0 +1,113 @@
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <pslib.h>
+#include "psIOBuffer.h"
+
+static void psIOBufferFree (psIOBuffer *buffer)
+{
+    if (buffer == NULL)
+        return;
+
+    psFree (buffer->data);
+    return;
+}
+
+psIOBuffer *psIOBufferAlloc (int nBuffer)
+{
+
+    psIOBuffer *buffer = (psIOBuffer *)psAlloc(sizeof(psIOBuffer));
+    psMemSetDeallocator(buffer, (psFreeFunc) psIOBufferFree);
+
+    buffer->data = (char *) psAlloc (nBuffer);
+
+    buffer->nAlloc = nBuffer;
+    buffer->nReset = nBuffer;
+    buffer->nBlock = nBuffer / 2;
+    buffer->n = 0;
+    return (buffer);
+}
+
+bool psIOBufferFlush (psIOBuffer *buffer)
+{
+
+    if (buffer == NULL)
+        return false;
+    buffer->n = 0;
+    buffer->nAlloc = buffer->nReset;
+    psRealloc (buffer->data, buffer->nAlloc);
+    bzero (buffer->data, buffer->nAlloc);
+
+    return true;
+}
+
+int psIOBufferRead (psIOBuffer *buffer, int fd)
+{
+
+    int Nread, Nfree;
+
+    if (fd == 0) {
+        /* pipe is closed */
+        return (0);
+    }
+
+    Nfree = buffer->nAlloc - buffer->n;
+
+    // extend the data block if needed
+    if (Nfree < buffer->nBlock) {
+        buffer->nAlloc += 2*buffer->nBlock;
+        psRealloc (buffer->data, buffer->nAlloc);
+        Nfree = buffer->nAlloc - buffer->n;
+        bzero (buffer->data + buffer->n, Nfree);
+    }
+
+    // attempt to read from the fd into the buffer
+    Nread = read (fd, &buffer->data[buffer->n], buffer->nBlock);
+
+    if (Nread >= 0) {
+        buffer->n += Nread;
+        buffer->data[buffer->n] = 0;
+        return (Nread);
+    }
+
+    // check on exit status (try again if waiting for non-blocking fd)
+    if (Nread == -1) {
+        switch (errno) {
+        case EAGAIN:
+        case EIO:
+            /** no data available in pipe **/
+            return (-1);
+        default:
+            /** error reading from pipe **/
+            psError (PS_ERR_IO, true, "error on psIOBufferRead");
+            return (-2);
+        }
+    }
+    return (Nread);
+}
+
+/* read until buffer is empty (Nmax retries) */
+int psIOBufferReadEmpty (psIOBuffer *buffer, int Nmax, int fd)
+{
+
+    int i, status;
+
+    status = -1;
+    for (i = 0; (status != 0) && (i < Nmax); i++) {
+        status = psIOBufferRead (buffer, fd);
+        if (status == -2)
+            return false;
+        if (status == -1)
+            usleep (10000);
+        if (status > 0)
+            i = 0;
+    }
+    if (status == -1)
+        return false;
+    return true;
+}
Index: /trunk/psModules/src/extras/psIOBuffer.h
===================================================================
--- /trunk/psModules/src/extras/psIOBuffer.h	(revision 10610)
+++ /trunk/psModules/src/extras/psIOBuffer.h	(revision 10610)
@@ -0,0 +1,34 @@
+/** @file  psPipe.h
+*
+*  @brief 3-stream pipe 
+*
+*  @ingroup misc
+*
+*  @author EAM, IfA
+*
+*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-12-10 18:27:26 $
+*
+*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
+*/
+
+#ifndef PS_IO_BUFFER_H
+#define PS_IO_BUFFER_H
+
+typedef struct
+{
+    char *data;
+    int nAlloc;    // current size of allocated buffer
+    int nReset;    // size to set buffer after flush
+    int nBlock;    // number of bytes to try to read at a time
+    int n;    // current size of filled data
+}
+psIOBuffer;
+
+// psIOBuffer functions
+psIOBuffer *psIOBufferAlloc (int nBuffer);
+bool psIOBufferFlush (psIOBuffer *buffer);
+int psIOBufferRead (psIOBuffer *buffer, int fd);
+int psIOBufferReadEmpty (psIOBuffer *buffer, int maxRetries, int fd);
+
+# endif
Index: /trunk/psModules/src/extras/psPipe.c
===================================================================
--- /trunk/psModules/src/extras/psPipe.c	(revision 10610)
+++ /trunk/psModules/src/extras/psPipe.c	(revision 10610)
@@ -0,0 +1,210 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <pslib.h>
+#include <psPipe.h>
+
+void closePipes (int *stdin_fd, int *stdout_fd, int *stderr_fd)
+{
+
+    if (stdin_fd[0]  != 0)
+        close (stdin_fd[0]);
+    if (stdin_fd[1]  != 0)
+        close (stdin_fd[0]);
+    if (stdout_fd[0] != 0)
+        close (stdout_fd[0]);
+    if (stdout_fd[1] != 0)
+        close (stdout_fd[1]);
+    if (stderr_fd[0] != 0)
+        close (stderr_fd[0]);
+    if (stderr_fd[1] != 0)
+        close (stderr_fd[1]);
+}
+
+static void psPipeFree (psPipe *pipe)
+{
+    return;
+}
+
+psPipe *psPipeAlloc ()
+{
+    psPipe *pipe = (psPipe *)psAlloc(sizeof(psPipe));
+    psMemSetDeallocator(pipe, (psFreeFunc) psPipeFree);
+
+    pipe->fd_stdin  = 0;
+    pipe->fd_stdout = 0;
+    pipe->fd_stderr = 0;
+    return (pipe);
+}
+
+psPipe *psPipeOpen (char *command)
+{
+
+    int stdin_fd[2], stdout_fd[2], stderr_fd[2], status;
+    pid_t pid;
+
+    bzero (stdin_fd,  2*sizeof(int));
+    bzero (stdout_fd, 2*sizeof(int));
+    bzero (stderr_fd, 2*sizeof(int));
+
+    if (pipe (stdin_fd)  < 0) {
+        psError (PS_ERR_UNKNOWN, true, "cannot create pipe file descriptor");
+        closePipes (stdin_fd, stdout_fd, stderr_fd);
+        return NULL;
+    }
+    if (pipe (stdout_fd) < 0) {
+        psError (PS_ERR_UNKNOWN, true, "cannot create pipe file descriptor");
+        closePipes (stdin_fd, stdout_fd, stderr_fd);
+        return NULL;
+    }
+    if (pipe (stderr_fd) < 0) {
+        psError (PS_ERR_UNKNOWN, true, "cannot create pipe file descriptor");
+        closePipes (stdin_fd, stdout_fd, stderr_fd);
+        return NULL;
+    }
+
+    psArray *cmd = psStringSplitArray (command, " ", false);
+    if (cmd->n <= 0) {
+        psError (PS_ERR_UNKNOWN, true, "empty command for pipe");
+        psFree (cmd);
+        closePipes (stdin_fd, stdout_fd, stderr_fd);
+        return NULL;
+    }
+
+    // create the command line array needed by execvp
+    char **argv = (char **)psAlloc((cmd->n+1)*sizeof(char *));
+    for (int i = 0; i < cmd->n; i++) {
+        argv[i] = cmd->data[i];
+    }
+    argv[cmd->n] = NULL;
+
+    pid = fork ();
+    if (!pid) { /* must be child process */
+        /* close the other ends of the pipes */
+        close (stdin_fd[1]);
+        close (stdout_fd[0]);
+        close (stderr_fd[0]);
+
+        /* tie our ends of the pipes to stdin, stdout, stderr */
+        dup2 (stdin_fd[0],  STDIN_FILENO);
+        dup2 (stdout_fd[1], STDOUT_FILENO);
+        dup2 (stderr_fd[1], STDERR_FILENO);
+
+        /* set all three unblocking */
+        setvbuf (stdin,  (char *) NULL, _IONBF, BUFSIZ);
+        setvbuf (stdout, (char *) NULL, _IONBF, BUFSIZ);
+        setvbuf (stderr, (char *) NULL, _IONBF, BUFSIZ);
+
+        status = execvp (argv[0], argv);
+
+        // this statement exits the child, not the parent, process
+        exit (1);
+    }
+    psFree (cmd);
+    psFree (argv);
+
+    if (pid == -1) {
+        psError (PS_ERR_UNKNOWN, true, "unable to create child process");
+        closePipes (stdin_fd, stdout_fd, stderr_fd);
+        return NULL;
+    }
+
+    /* close the other ends of the pipes */
+    close (stdin_fd[0]);
+    stdin_fd[0]  = 0;
+    close (stdout_fd[1]);
+    stdout_fd[1] = 0;
+    close (stderr_fd[1]);
+    stderr_fd[1] = 0;
+
+    /* make the pipes non-blocking */
+    fcntl (stdin_fd[1],  F_SETFL, O_NONBLOCK);
+    fcntl (stdout_fd[0], F_SETFL, O_NONBLOCK);
+    fcntl (stderr_fd[0], F_SETFL, O_NONBLOCK);
+
+    psPipe *pipe = psPipeAlloc();
+
+    pipe->pid    = pid;
+    pipe->fd_stdin  = stdin_fd[1];
+    pipe->fd_stdout = stdout_fd[0];
+    pipe->fd_stderr = stderr_fd[0];
+
+    return (pipe);
+}
+
+// this function returns the exit status of the called function
+// or a value > 255 on an error
+int psPipeClose (psPipe *pipe)
+{
+    int close_status;
+    int exit_status;
+    int wait_status;
+    int result;
+
+    PS_ASSERT_PTR_NON_NULL(pipe, false);
+
+    close_status = true;
+    if (close (pipe->fd_stdin) != 0) {
+        psError(PS_ERR_IO, true, "error closing the pipe stdin (pid %d, error %s)\n", pipe->pid, strerror(errno));
+        close_status = false;
+    }
+    if (close (pipe->fd_stdout) != 0) {
+        psError(PS_ERR_IO, true, "error closing the pipe stdout (pid %d, error %s)\n", pipe->pid, strerror(errno));
+        close_status = false;
+    }
+    if (close (pipe->fd_stderr) != 0) {
+        psError(PS_ERR_IO, true, "error closing the pipe sterr (pid %d, error %s)\n", pipe->pid, strerror(errno));
+        close_status = false;
+    }
+
+    // we expect the child process to have exited.
+    // wait for the exit condition, but no longer than 100ms
+    for (int i = 0; i < 10; i++) {
+        result = waitpid (pipe->pid, &wait_status, WNOHANG);
+        switch (result) {
+        case -1:   // error on waitpid
+            switch (errno) {
+            case ECHILD:
+                psError(PS_ERR_IO, true, "unknown PID, not a child process: %d\n", pipe->pid);
+                return 0x100;
+            default:
+                psAbort ("psPipeClose", "unexpected response to waitpid: %d\n", result);
+            }
+            break;
+
+        case 0:   // child not yet exited
+            usleep (10000);
+            continue;
+
+        default:
+            if (result != pipe->pid) {
+                psAbort ("psPipeClose", "waitpid error: mis-matched PID (%d vs %d).  programming error\n", result, pipe->pid);
+            }
+            if (WIFEXITED(wait_status)) {
+                exit_status = WEXITSTATUS(wait_status);
+                if (close_status) {
+                    return exit_status;
+                } else {
+                    return (0x100);
+                }
+            }
+            if (WIFSIGNALED(wait_status)) {
+                psError(PS_ERR_IO, true, "job %d exited on signal %d\n", pipe->pid, WTERMSIG(wait_status));
+                return (0x100 + WTERMSIG(wait_status));
+            }
+            if (WIFSTOPPED(wait_status)) {
+                psAbort ("psPipeClose", "waitpid returns 'stopped' programming error\n");
+            }
+        }
+    }
+    psError(PS_ERR_IO, true, "child process pid %d did not exit\n", pipe->pid);
+    return 0x100;
+}
Index: /trunk/psModules/src/extras/psPipe.h
===================================================================
--- /trunk/psModules/src/extras/psPipe.h	(revision 10610)
+++ /trunk/psModules/src/extras/psPipe.h	(revision 10610)
@@ -0,0 +1,33 @@
+/** @file  psPipe.h
+*
+*  @brief 3-stream pipe 
+*
+*  @ingroup misc
+*
+*  @author EAM, IfA
+*
+*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-12-10 18:27:26 $
+*
+*  Copyright 2004-2005 Institute for Astronomy, University of Hawaii
+*/
+
+#ifndef PS_PIPE_H
+#define PS_PIPE_H
+
+// move these to pslib??
+typedef struct
+{
+    int pid;
+    int fd_stdin;
+    int fd_stdout;
+    int fd_stderr;
+}
+psPipe;
+
+// psPipe functions
+psPipe *psPipeAlloc ();
+psPipe *psPipeOpen (char *command);
+int     psPipeClose (psPipe *pipe);
+
+# endif
Index: /trunk/psModules/src/extras/psVectorBracket.c
===================================================================
--- /trunk/psModules/src/extras/psVectorBracket.c	(revision 10610)
+++ /trunk/psModules/src/extras/psVectorBracket.c	(revision 10610)
@@ -0,0 +1,137 @@
+/** @file  psVectorBracket.c
+ *
+ *  Vector Bracketing tools
+ *
+ *  @author EAM, IfA
+ *
+ *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-12-10 18:27:26 $
+ *
+ *  Copyright 2006 Institute for Astronomy, University of Hawaii
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <pslib.h>
+#include "psVectorBracket.h"
+
+// return the last entry below or first entry above key value
+int psVectorBracket(const psVector *index, psF32 key, bool above)
+{
+
+    int N;
+    int Nlo = 0;
+    int Nhi = index->n;
+
+    if (above) {
+        while (Nhi - Nlo > 10) {
+            N = 0.5*(Nlo + Nhi);
+            if (index->data.F32[N] > key) {
+                Nhi = N;
+            } else {
+                Nlo = N - 1;
+            }
+        }
+        // at this point, index[Nhi] > key >= index[Nlo]
+        N = Nlo;
+        while ((index->data.F32[N] <= key) && (N < Nhi)) {
+            N++;
+        }
+        return (N);
+    }
+    while (Nhi - Nlo > 10) {
+        N = 0.5*(Nlo + Nhi);
+        if (index->data.F32[N] < key) {
+            Nlo = N;
+        } else {
+            Nhi = N + 1;
+        }
+    }
+    // at this point, index[Nhi] >= key > index[Nlo]
+    N = Nhi;
+    while ((index->data.F32[N] >= key) && (N > Nlo)) {
+        N--;
+    }
+    return (N);
+}
+
+// return the last entry below or first entry above key value (reverse sorted input)
+int psVectorBracketDescend(const psVector *index, psF32 key, bool above)
+{
+
+    int N;
+    int Nhi = 0;
+    int Nlo = index->n;
+
+    if (above) {
+        while (Nlo - Nhi > 10) {
+            N = 0.5*(Nhi + Nlo);
+            if (index->data.F32[N] < key) {
+                Nlo = N;
+            } else {
+                Nhi = N - 1;
+            }
+        }
+        // at this point, index[Nhi] >= key > index[Nlo]
+        N = Nhi;
+        while ((index->data.F32[N] >= key) && (N < Nlo)) {
+            N++;
+        }
+        return (N);
+    }
+    while (Nlo - Nhi > 10) {
+        N = 0.5*(Nhi + Nlo);
+        if (index->data.F32[N] > key) {
+            Nhi = N;
+        } else {
+            Nlo = N + 1;
+        }
+    }
+    // at this point, index[Nhi] > key >= index[Nlo]
+    N = Nlo;
+    while ((index->data.F32[N] <= key) && (N > Nhi)) {
+        N--;
+    }
+    return (N);
+}
+
+// search for the bins bounding key in index, interpolate the corresponding values
+psF32 psVectorInterpolate(const psVector *index, const psVector *value, psF32 key)
+{
+
+    int n0 = 0;
+    int n1 = 0;
+
+    // extrapolate at ends
+    if (key < index->data.F32[0]) {
+        n0 = 0;
+        n1 = 1;
+    }
+
+    // extrapolate at ends
+    if (key > index->data.F32[index->n-1]) {
+        n0 = index->n-2;
+        n1 = index->n-1;
+    }
+
+    if (n1 == 0) {
+        n0 = psVectorBracket (index, key, FALSE);
+        n1 = n0 + 1;
+    }
+
+    if (n0 == index->n-1) {
+        n1 = n0;
+        n0 = n1 - 1;
+    }
+
+    float dy = value->data.F32[n1] - value->data.F32[n0];
+    float dx = index->data.F32[n1] - index->data.F32[n0];
+    float dX = key - index->data.F32[n0];
+    float dY = dX * (dy/dx);
+    float result = value->data.F32[n0] + dY;
+    return result;
+}
+
Index: /trunk/psModules/src/extras/psVectorBracket.h
===================================================================
--- /trunk/psModules/src/extras/psVectorBracket.h	(revision 10610)
+++ /trunk/psModules/src/extras/psVectorBracket.h	(revision 10610)
@@ -0,0 +1,9 @@
+
+# ifndef PS_VECTOR_BRACKET_H
+# define PS_VECTOR_BRACKET_H
+
+int psVectorBracket(const psVector *index, psF32 key, bool above);
+int psVectorBracketDescend(const psVector *index, psF32 key, bool above);
+psF32 psVectorInterpolate(const psVector *index, const psVector *value, psF32 key);
+
+# endif /* PS_VECTOR_BRACKET_H */
Index: /trunk/psModules/src/objects/Makefile.am
===================================================================
--- /trunk/psModules/src/objects/Makefile.am	(revision 10609)
+++ /trunk/psModules/src/objects/Makefile.am	(revision 10610)
@@ -22,6 +22,5 @@
      pmPSF_IO.c \
      pmPSFtry.c \
-     pmGrowthCurve.c \
-     psVectorBracket.c
+     pmGrowthCurve.c
 
 EXTRA_DIST = \
@@ -45,6 +44,5 @@
      pmPSF_IO.h \
      pmPSFtry.h \
-     pmGrowthCurve.h \
-     psVectorBracket.h
+     pmGrowthCurve.h
 
 CLEANFILES = *~
Index: unk/psModules/src/objects/psVectorBracket.c
===================================================================
--- /trunk/psModules/src/objects/psVectorBracket.c	(revision 10609)
+++ 	(revision )
@@ -1,137 +1,0 @@
-/** @file  psVectorBracket.c
- *
- *  Vector Bracketing tools
- *
- *  @author EAM, IfA
- *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-05 20:47:47 $
- *
- *  Copyright 2006 Institute for Astronomy, University of Hawaii
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <pslib.h>
-# include "psVectorBracket.h"
-
-// return the last entry below or first entry above key value
-int psVectorBracket(const psVector *index, psF32 key, bool above)
-{
-
-    int N;
-    int Nlo = 0;
-    int Nhi = index->n;
-
-    if (above) {
-        while (Nhi - Nlo > 10) {
-            N = 0.5*(Nlo + Nhi);
-            if (index->data.F32[N] > key) {
-                Nhi = N;
-            } else {
-                Nlo = N - 1;
-            }
-        }
-        // at this point, index[Nhi] > key >= index[Nlo]
-        N = Nlo;
-        while ((index->data.F32[N] <= key) && (N < Nhi)) {
-            N++;
-        }
-        return (N);
-    }
-    while (Nhi - Nlo > 10) {
-        N = 0.5*(Nlo + Nhi);
-        if (index->data.F32[N] < key) {
-            Nlo = N;
-        } else {
-            Nhi = N + 1;
-        }
-    }
-    // at this point, index[Nhi] >= key > index[Nlo]
-    N = Nhi;
-    while ((index->data.F32[N] >= key) && (N > Nlo)) {
-        N--;
-    }
-    return (N);
-}
-
-// return the last entry below or first entry above key value (reverse sorted input)
-int psVectorBracketDescend(const psVector *index, psF32 key, bool above)
-{
-
-    int N;
-    int Nhi = 0;
-    int Nlo = index->n;
-
-    if (above) {
-        while (Nlo - Nhi > 10) {
-            N = 0.5*(Nhi + Nlo);
-            if (index->data.F32[N] < key) {
-                Nlo = N;
-            } else {
-                Nhi = N - 1;
-            }
-        }
-        // at this point, index[Nhi] >= key > index[Nlo]
-        N = Nhi;
-        while ((index->data.F32[N] >= key) && (N < Nlo)) {
-            N++;
-        }
-        return (N);
-    }
-    while (Nlo - Nhi > 10) {
-        N = 0.5*(Nhi + Nlo);
-        if (index->data.F32[N] > key) {
-            Nhi = N;
-        } else {
-            Nlo = N + 1;
-        }
-    }
-    // at this point, index[Nhi] > key >= index[Nlo]
-    N = Nlo;
-    while ((index->data.F32[N] <= key) && (N > Nhi)) {
-        N--;
-    }
-    return (N);
-}
-
-// search for the bins bounding key in index, interpolate the corresponding values
-psF32 psVectorInterpolate(const psVector *index, const psVector *value, psF32 key)
-{
-
-    int n0 = 0;
-    int n1 = 0;
-
-    // extrapolate at ends
-    if (key < index->data.F32[0]) {
-        n0 = 0;
-        n1 = 1;
-    }
-
-    // extrapolate at ends
-    if (key > index->data.F32[index->n-1]) {
-        n0 = index->n-2;
-        n1 = index->n-1;
-    }
-
-    if (n1 == 0) {
-        n0 = psVectorBracket (index, key, FALSE);
-        n1 = n0 + 1;
-    }
-
-    if (n0 == index->n-1) {
-        n1 = n0;
-        n0 = n1 - 1;
-    }
-
-    float dy = value->data.F32[n1] - value->data.F32[n0];
-    float dx = index->data.F32[n1] - index->data.F32[n0];
-    float dX = key - index->data.F32[n0];
-    float dY = dX * (dy/dx);
-    float result = value->data.F32[n0] + dY;
-    return result;
-}
-
Index: unk/psModules/src/objects/psVectorBracket.h
===================================================================
--- /trunk/psModules/src/objects/psVectorBracket.h	(revision 10609)
+++ 	(revision )
@@ -1,11 +1,0 @@
-
-# ifndef PS_VECTOR_BRACKET_H
-# define PS_VECTOR_BRACKET_H
-
-#include <pslib.h>
-
-int psVectorBracket(const psVector *index, psF32 key, bool above);
-int psVectorBracketDescend(const psVector *index, psF32 key, bool above);
-psF32 psVectorInterpolate(const psVector *index, const psVector *value, psF32 key);
-
-# endif /* PS_VECTOR_BRACKET_H */
Index: /trunk/psModules/src/psmodules.h
===================================================================
--- /trunk/psModules/src/psmodules.h	(revision 10609)
+++ /trunk/psModules/src/psmodules.h	(revision 10610)
@@ -3,4 +3,10 @@
 
 #include <pslib.h>
+
+// the following headers are from psModule:extras
+#include <psPipe.h>
+#include <psIOBuffer.h>
+#include <psVectorBracket.h>
+#include <pmKapaPlots.h>
 
 // the following headers are from psModule:config
@@ -47,6 +53,4 @@
 #include <pmDetrendDB.h>
 #include <pmShutterCorrection.h>
-#include <psPipe.h>
-#include <psIOBuffer.h>
 // #include <pmSkySubtract.h>
 
@@ -76,5 +80,4 @@
 #include <pmModelGroup.h>
 #include <pmSourcePhotometry.h>
-#include <psVectorBracket.h>
 
 #endif
Index: /trunk/psModules/test/extras/Makefile.am
===================================================================
--- /trunk/psModules/test/extras/Makefile.am	(revision 10610)
+++ /trunk/psModules/test/extras/Makefile.am	(revision 10610)
@@ -0,0 +1,19 @@
+
+AM_CPPFLAGS = \
+	$(SRCINC) \
+	-I$(top_srcdir)/test/tap/src \
+	-I$(top_srcdir)/test/pstap/src \
+	$(PSMODULES_CFLAGS)
+
+AM_LDFLAGS = \
+	$(top_builddir)/src/libpsmodules.la  \
+	$(top_builddir)/test/tap/src/libtap.la \
+	$(top_builddir)/test/pstap/src/libpstap.la \
+	$(PSMODULES_LIBS)
+
+# XXX is this desired?
+# AM_CFLAGS  = @AM_CFLAGS@ $(PSMODULES_CFLAGS) $(SRCINC)
+
+check_PROGRAMS =
+
+test: check
