Index: trunk/ppstamp/Makefile.am
===================================================================
--- trunk/ppstamp/Makefile.am	(revision 15672)
+++ 	(revision )
@@ -1,3 +1,0 @@
-SUBDIRS = src
-
-CLEANFILES = *~ core core.*
Index: trunk/ppstamp/autogen.sh
===================================================================
--- trunk/ppstamp/autogen.sh	(revision 15672)
+++ 	(revision )
@@ -1,103 +1,0 @@
-#!/bin/sh
-# Run this to generate all the initial makefiles, etc.
-
-srcdir=`dirname $0`
-test -z "$srcdir" && srcdir=.
-
-ORIGDIR=`pwd`
-cd $srcdir
-
-PROJECT=ppstamp
-TEST_TYPE=-f
-# change this to be a unique filename in the top level dir
-FILE=autogen.sh
-
-DIE=0
-
-LIBTOOLIZE=libtoolize
-ACLOCAL="aclocal $ACLOCAL_FLAGS"
-AUTOHEADER=autoheader
-AUTOMAKE=automake
-AUTOCONF=autoconf
-
-($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
-        echo
-        echo "You must have $LIBTOOlIZE installed to compile $PROJECT."
-        echo "Download the appropriate package for your distribution,"
-        echo "or get the source tarball at http://ftp.gnu.org/gnu/libtool/"
-        DIE=1
-}
-
-($ACLOCAL --version) < /dev/null > /dev/null 2>&1 || {
-        echo
-        echo "You must have $ACLOCAL installed to compile $PROJECT."
-        echo "Download the appropriate package for your distribution,"
-        echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
-        DIE=1
-}
-
-($AUTOHEADER --version) < /dev/null > /dev/null 2>&1 || {
-        echo
-        echo "You must have $AUTOHEADER installed to compile $PROJECT."
-        echo "Download the appropriate package for your distribution,"
-        echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
-        DIE=1
-}
-
-($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
-        echo
-        echo "You must have $AUTOMAKE installed to compile $PROJECT."
-        echo "Download the appropriate package for your distribution,"
-        echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
-        DIE=1
-}
-
-($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || {
-        echo
-        echo "You must have $AUTOCONF installed to compile $PROJECT."
-        echo "Download the appropriate package for your distribution,"
-        echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
-        DIE=1
-}
-
-if test "$DIE" -eq 1; then
-        exit 1
-fi
-
-test $TEST_TYPE $FILE || {
-        echo "You must run this script in the top-level $PROJECT directory"
-        exit 1
-}
-
-if test -z "$*"; then
-        echo "I am going to run ./configure with no arguments - if you wish "
-        echo "to pass any to it, please specify them on the $0 command line."
-fi
-
-$LIBTOOLIZE --copy --force || echo "$LIBTOOlIZE failed"
-$ACLOCAL || echo "$ACLOCAL failed"
-$AUTOHEADER || echo "$AUTOHEADER failed"
-$AUTOMAKE --add-missing --force-missing --copy || echo "$AUTOMAKE failed"
-$AUTOCONF || echo "$AUTOCONF failed"
-
-cd $ORIGDIR
-
-run_configure=true
-for arg in $*; do
-    case $arg in
-        --no-configure)
-            run_configure=false
-            ;;
-        *)
-            ;;
-    esac
-done
-
-if $run_configure; then
-    $srcdir/configure --enable-maintainer-mode "$@"
-    echo
-    echo "Now type 'make' to compile $PROJECT."
-else
-    echo
-    echo "Now run 'configure' and 'make' to compile $PROJECT."
-fi
Index: trunk/ppstamp/configure.ac
===================================================================
--- trunk/ppstamp/configure.ac	(revision 15672)
+++ 	(revision )
@@ -1,47 +1,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_PREREQ(2.61)
-
-AC_INIT([ppstamp], [0.1.1], [ipp-support@ifa.hawaii.edu])
-AC_CONFIG_SRCDIR([src])
-
-AM_INIT_AUTOMAKE([1.6 foreign dist-bzip2])
-AM_CONFIG_HEADER([src/config.h])
-AM_MAINTAINER_MODE
-
-IPP_STDCFLAGS
-
-AC_LANG(C)
-AC_GNU_SOURCE
-AC_PROG_CC_C99
-AC_PROG_INSTALL
-AC_PROG_LIBTOOL
-AC_SYS_LARGEFILE
-
-dnl ------------------------------------------------------------
-
-AC_PATH_PROG([ERRORCODES], [psParseErrorCodes], [missing])
-if test "$ERRORCODES" = "missing" ; then
-  AC_MSG_ERROR([psParseErrorCodes is required])
-fi
-
-
-PKG_CHECK_MODULES([PSLIB], [pslib >= 1.0.0])
-PKG_CHECK_MODULES([PSMODULE], [psmodules >= 1.0.0])
-PKG_CHECK_MODULES([PPSTATS], [ppStats >= 1.0.0]) 
-PKG_CHECK_MODULES([PSPHOT], [psphot >= 0.8.0]) 
-
-dnl Set CFLAGS for build
-IPP_STDOPTS
-CFLAGS="${CFLAGS} -Wall -Werror"
-echo "PPSTAMP_CFLAGS: $PPSTAMP_CFLAGS"
-echo "PPSTAMP_LIBS: $PPSTAMP_LIBS"
-
-AC_SUBST([PPSTAMP_CFLAGS])
-AC_SUBST([PPSTAMP_LIBS])
-
-AC_CONFIG_FILES([
-  Makefile
-  src/Makefile
-])
-
-AC_OUTPUT
Index: trunk/ppstamp/src/Makefile.am
===================================================================
--- trunk/ppstamp/src/Makefile.am	(revision 15672)
+++ 	(revision )
@@ -1,42 +1,0 @@
-bin_PROGRAMS = ppstamp
-
-noinst_HEADERS = \
-	ppstamp.h  \
-        ppstampErrorCodes.h
-
-ppstamp_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) 
-
-# $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(ppstamp_CFLAGS)
-
-ppstamp_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) 
-#$(PSPHOT_LIBS) $(PPSTATS_LIBS) $(PSASTRO_LIBS) 
-
-ppstamp_SOURCES = \
-	ppstamp.c \
-	ppstampArguments.c \
-	ppstampCleanup.c \
-        ppstampErrorCodes.c \
-	ppstampMakeStamp.c \
-	ppstampMosaic.c \
-	ppstampOptions.c \
-	ppstampParseCamera.c \
-        ppstampRegion.c \
-	ppstampVersion.c
-
-
-clean-local:
-	-rm -f TAGS
-
-# Tags for emacs
-tags:
-	etags `find . -name \*.[ch] -print`
-
-### Error codes.
-BUILT_SOURCES = ppstampErrorCodes.h ppstampErrorCodes.c
-CLEANFILES = ppstampErrorCodes.h ppstampErrorCodes.c
-
-ppstampErrorCodes.h : ppstampErrorCodes.dat ppstampErrorCodes.h.in
-	$(ERRORCODES) --data=ppstampErrorCodes.dat --outdir=. ppstampErrorCodes.h
-
-ppstampErrorCodes.c : ppstampErrorCodes.dat ppstampErrorCodes.c.in ppstampErrorCodes.h
-	$(ERRORCODES) --data=ppstampErrorCodes.dat --outdir=. ppstampErrorCodes.c
Index: trunk/ppstamp/src/ppstamp.c
===================================================================
--- trunk/ppstamp/src/ppstamp.c	(revision 15672)
+++ 	(revision )
@@ -1,43 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ppstamp.h"
-
-int main(int argc, char **argv)
-{
-    ppstampOptions *options = NULL;
-    int exitCode;
-
-    psTimerStart(TIMERNAME);
-    psLibInit(NULL);
-    ppstampErrorRegister();
-
-    pmConfig *config = ppstampArguments(argc, argv, &options);
-    if (config == NULL) {
-        psErrorStackPrint(stderr, "Unable to parse command-line arguments.");
-        ppstampCleanup(config, options);
-        exit(PS_EXIT_CONFIG_ERROR);
-    }
-
-    // define the active I/O files
-    if (!ppstampParseCamera(config)) {
-        psErrorStackPrint(stderr, "Unable to parse camera.");
-        ppstampCleanup(config, options);
-        exit(PS_EXIT_CONFIG_ERROR);
-    }
-
-    // find the pixels that we need to copy, setup the output image
-    if (ppstampMakeStamp(config, options)) {
-        exitCode = 0;
-    } else {
-        exitCode = PS_EXIT_DATA_ERROR;
-    }
-
-    psLogMsg ("ppstamp", 3, "Complete ppstamp run: %f sec\n", psTimerMark(TIMERNAME));
-
-    // Cleaning up
-    ppstampCleanup(config, options);
-
-    return exitCode;
-}
Index: trunk/ppstamp/src/ppstamp.h
===================================================================
--- trunk/ppstamp/src/ppstamp.h	(revision 15672)
+++ 	(revision )
@@ -1,80 +1,0 @@
-#ifndef PP_STAMP_H
-#define PP_STAMP_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>  // for strcasecmp
-#include <unistd.h>   // for unlink
-#include "pslib.h"
-#include "psmodules.h"
-#include "psphot.h"
-#include "psastro.h"
-#include "ppStats.h"
-#include "ppstampErrorCodes.h"
-
-#define TIMERNAME "ppstamp"             // Name of timer
-
-// We need double precision coordinates when transforming so we
-// define this struct to use instead of a psRegion
-typedef struct {
-    psPlane p0;
-    psPlane p1;
-} ppstampROI;
-
-// Options for ppstamp processing
-typedef struct {
-    // input arguments
-    int    centerX;
-    int    centerY;
-    int    dX;
-    int    dY;
-    double centerRA;
-    double centerDEC;
-    double dRA;
-    double dDEC;
-    bool   celestialCenter;       // true if center is in RA/dec
-    bool   celestialRange;        // true if range is in RA/dec
-    psString    chipName;
-    //
-    // Calculated Values
-    //
-    psRegion    roi;            // roi in chip coordinates
-
-} ppstampOptions;
-
-
-ppstampOptions *ppstampOptionsAlloc(void);
-
-// Determine the processing options
-bool *ppstampOptionsParse(pmConfig *config);
-
-// Get the configuration
-pmConfig *ppstampArguments(int argc, char **argv, ppstampOptions **);
-
-// Determine what type of camera, and initialise
-bool ppstampParseCamera(pmConfig *config);
-
-bool ppstampMakeStamp(pmConfig *config, ppstampOptions *);
-pmFPAfile * ppstampBuildMosaic(pmConfig *config, pmFPAfile *input, pmFPAview *view);
-
-// free memory, check for leaks
-void ppstampCleanup (pmConfig *config, ppstampOptions *options);
-
-/// Return short version information
-psString ppstampVersion(void);
-
-/// Return long version information
-psString ppstampVersionLong(void);
-
-/// Update the metadata with version information for all dependencies
-void ppstampVersionMetadata(psMetadata *metadata, ppstampOptions *options);
-
-psRegion *ppstampCellRegion(const pmCell *cell);
-psRegion *ppstampChipRegion(const pmChip *chip);
-
-extern bool ppstampMegacamWorkaround;
-#endif
Index: trunk/ppstamp/src/ppstampArguments.c
===================================================================
--- trunk/ppstamp/src/ppstampArguments.c	(revision 15672)
+++ 	(revision )
@@ -1,246 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ppstamp.h"
-#include "ohana.h"
-
-static bool get2Angles(int argnum, int *pArgc, char **argv, bool bothDegrees, bool makePositive, double *p1, double *p2);
-static bool get2Ints(int argnum, int *pArgc, char **argv, bool makePositive, int *p1, int *p2);
-
-static void usage (void)
-{
-    fprintf(stderr, "\n");
-
-    fprintf(stderr, "USAGE: ppstamp -skycenter RA DEC -pixrange dx dy    [-file INPUT.fits] [-list INPUT.txt] OUTPUT\n");
-    fprintf(stderr, "       ppstamp -skycenter RA DEC -arcrange dRA dDEC [-file INPUT.fits] [-list INPUT.txt] OUTPUT\n");
-    fprintf(stderr, "       ppstamp -pixcenter x y    -pixrange dx dy    [-chip chipname] [-file INPUT.fits] [-list INPUT.txt] OUTPUT\n");
-    fprintf(stderr, "       ppstamp -pixcenter x y    -arcrange dRA dDEC [-chip chipname] [-file INPUT.fits] [-list INPUT.txt] OUTPUT\n");
-    fprintf(stderr, "\n");
-
-    fprintf(stderr, "-skycenter is specified as HH:MM:SS DD:MM:SS or decimal degrees\n");
-    fprintf(stderr, "-arcrange values are seconds of arc\n");
-    fprintf(stderr, "\n");
-    fprintf(stderr, "Optional arguments:\n");
-    fprintf(stderr, "         -chip chipName    selects chip (only used with -pixcenter)\n");
-    fprintf(stderr, "\n");
-
-    exit (2);
-}
-
-pmConfig *ppstampArguments(int argc, char **argv, ppstampOptions **pOptions)
-{
-    int argnum;                         // Argument number of interest
-    bool gotCenter = false;
-    bool gotRange = false;
-    ppstampOptions *options;
-
-    if (argc == 1) {
-        usage();
-    }
-
-    if (psArgumentGet (argc, argv, "-version")) {
-        psString version;
-        version = ppstampVersionLong();   fprintf (stdout, "%s\n", version); psFree (version);
-        version = psModulesVersionLong(); fprintf (stdout, "%s\n", version); psFree (version);
-        version = psLibVersionLong();     fprintf (stdout, "%s\n", version); psFree (version);
-        exit (0);
-    }
-
-    // load the site-wide configuration information
-    pmConfig *config = pmConfigRead(&argc, argv, NULL);
-    if (config == NULL) {
-        psError(PPSTAMP_ERR_CONFIG, false, "Can't read site configuration!\n");
-        return(NULL);
-    }
-
-    options = ppstampOptionsAlloc();
-    *pOptions = options;
-
-    if ((argnum = psArgumentGet(argc, argv, "-pixcenter"))) {
-        gotCenter = true;
-        options->celestialCenter = false;
-        psArgumentRemove(argnum, &argc, argv);
-
-        if (!get2Ints(argnum, &argc, argv, false, &options->centerX, &options->centerY)) {
-            psError(PPSTAMP_ERR_ARGUMENTS, true, "invalid pixcenter specification: %s %s\n",
-                argv[argnum], argv[argnum+1]);
-            usage();
-        }
-        psArgumentRemove(argnum, &argc, argv);
-        psArgumentRemove(argnum, &argc, argv);
-    }
-
-    if ((argnum = psArgumentGet(argc, argv, "-skycenter"))) {
-        if (gotCenter) {
-            psError(PPSTAMP_ERR_ARGUMENTS, true, "can't specify both -pixcenter and -skycenter\n");;
-            usage();
-        }
-        psArgumentRemove(argnum, &argc, argv);
-
-        double raDeg, decDeg;
-        if (!get2Angles(argnum, &argc, argv, false, false, &raDeg, &decDeg)) {
-            psError(PPSTAMP_ERR_ARGUMENTS, true, "invalid skycenter specification: %s %s\n",
-                argv[argnum], argv[argnum+1]);
-            usage();
-        }
-        psArgumentRemove(argnum, &argc, argv);
-        psArgumentRemove(argnum, &argc, argv);
-        options->centerRA  = DEG_TO_RAD(raDeg);
-        options->centerDEC = DEG_TO_RAD(decDeg);
-        gotCenter = true;
-        options->celestialCenter = true;
-    }
-
-    if (!gotCenter) {
-        psError(PPSTAMP_ERR_ARGUMENTS, true, "must specify center of region of interest\n");
-        usage();
-    }
-
-    if ((argnum = psArgumentGet(argc, argv, "-pixrange"))) {
-        gotRange = true;
-        options->celestialRange = false;
-        psArgumentRemove(argnum, &argc, argv);
-        if (!get2Ints(argnum, &argc, argv, true, &options->dX, &options->dY)) {
-            psError(PPSTAMP_ERR_ARGUMENTS, true, "invalid pixrange specification: %s %s\n",
-                argv[argnum], argv[argnum+1]);
-            usage();
-        }
-        psArgumentRemove(argnum, &argc, argv);
-        psArgumentRemove(argnum, &argc, argv);
-    }
-
-    if ((argnum = psArgumentGet(argc, argv, "-arcrange"))) {
-        if (gotRange) {
-            psError(PPSTAMP_ERR_ARGUMENTS, true, "specify only one of -pixrange or -arcrange\n");;
-            usage();
-        }
-        psArgumentRemove(argnum, &argc, argv);
-        gotRange = true;
-        options->celestialRange = true;
-
-        // arcrange values are seconds of arc
-        options->dRA  = SEC_TO_RAD(fabs(atof(argv[argnum])));
-        options->dDEC = SEC_TO_RAD(fabs(atof(argv[argnum+1])));
-
-        psArgumentRemove(argnum, &argc, argv);
-        psArgumentRemove(argnum, &argc, argv);
-    }
-    // I'm leaving in the -celrange option (HH:MM:SS DD:MM:SS), but not publicizing it
-    if ((argnum = psArgumentGet(argc, argv, "-celrange"))) {
-        if (gotRange) {
-            psError(PPSTAMP_ERR_ARGUMENTS, true, "specify one of -pixrange, -arcrange, or -celrange\n");;
-            usage();
-        }
-        psArgumentRemove(argnum, &argc, argv);
-        gotRange = true;
-        options->celestialRange = true;
-
-        double deg1, deg2;
-        if (!get2Angles(argnum, &argc, argv, false, true, &deg1, &deg2)) {
-            psError(PPSTAMP_ERR_ARGUMENTS, true, "invalid celrange specification: %s %s\n",
-                argv[argnum], argv[argnum+1]);
-            usage();
-        }
-        psArgumentRemove(argnum, &argc, argv);
-        psArgumentRemove(argnum, &argc, argv);
-        options->dRA = DEG_TO_RAD(deg1);
-        options->dDEC = DEG_TO_RAD(deg2);
-    }
-
-    if (!gotRange) {
-        psError(PPSTAMP_ERR_ARGUMENTS, true, "must specify range\n");
-        usage();
-    }
-
-    if ((argnum = psArgumentGet(argc, argv, "-chip"))) {
-        psArgumentRemove(argnum, &argc, argv);
-        options->chipName = psStringCopy(argv[argnum]);
-        psArgumentRemove(argnum, &argc, argv);
-    }
-
-    // the input file is a required argument; if not found, we will exit
-    bool status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
-    if (!status) {
-        psError(PPSTAMP_ERR_ARGUMENTS, true, "must specify INPUT\n");
-        usage();
-    }
-
-    // finally the output file
-    if (argc < 2) {
-        psError(PPSTAMP_ERR_ARGUMENTS, true, "must specify OUTPUT\n");
-        usage();
-    } else if (argc > 2) {
-        psError(PPSTAMP_ERR_ARGUMENTS, true, "unknown argument(s)\n");
-        usage();
-    }
-
-    // Add the output image (which remains on the command-line) to the arguments list
-    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[1]);
-
-    // psMetadataPrint(stdout, config->arguments,0);
-
-    return config;
-}
-
-static bool validNumber(char *string)
-{
-    char *p = string;
-
-    if ((*p == '+') || (*p == '-')) {
-        p++;
-    }
-    return isdigit(*p);
-}
-
-static bool get2Ints(int argnum, int *pArgc, char **argv, bool makePositive, int *p1, int *p2)
-{
-    if (*pArgc < 2) {
-        usage();
-    }
-
-    if (!validNumber(argv[argnum])) {
-        return false;
-    }
-    *p1 = atoi(argv[argnum]);
-
-    if (!validNumber(argv[argnum+1])) {
-        return false;
-    }
-    *p2 = atoi(argv[argnum+1]);
-
-    if (makePositive) {
-        *p1 = abs(*p1);
-        *p2 = abs(*p2);
-    }
-
-    return true;
-}
-
-static bool get2Angles(int argnum, int *pArgc, char **argv, bool bothInDegrees, bool makePositive,
-    double *p1, double *p2)
-{
-    bool rval;
-
-    if (*pArgc < 2) {
-        usage();
-    }
-
-    if (bothInDegrees) {
-        // both values are angles of arc DD:MM:SS or decimal degrees
-        rval   = ohana_dms_to_ddd(p1, argv[argnum]);
-        if (rval) {
-            rval  = ohana_dms_to_ddd(p1, argv[argnum+1]);
-        }
-    } else {
-        // first value may be in HH:MM:SS
-        rval = ohana_str_to_radec(p1, p2, argv[argnum], argv[argnum+1]);
-    }
-
-    if (rval && makePositive) {
-        *p1 = abs(*p1);
-        *p2 = abs(*p2);
-    }
-
-    return rval;
-}
Index: trunk/ppstamp/src/ppstampCleanup.c
===================================================================
--- trunk/ppstamp/src/ppstampCleanup.c	(revision 15672)
+++ 	(revision )
@@ -1,25 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-# include "ppstamp.h"
-
-void ppstampCleanup (pmConfig *config, ppstampOptions *options)
-{
-    // Free memory used by ppstamp
-    psFree(config);
-    psFree(options);
-
-    // Free memory used by psModules
-    pmConceptsDone();
-    pmConfigDone();
-    pmModelClassCleanup();
-
-    // Free memory used by psLib
-    psLibFinalize();
-
-    // psMemCheckLeaks (0, NULL, stderr, false);
-    // fprintf (stderr, "Found %d leaks in %s\n", psMemCheckLeaks (0, NULL, NULL, false), "ppstamp");
-
-    return;
-}
Index: trunk/ppstamp/src/ppstampErrorCodes.c.in
===================================================================
--- trunk/ppstamp/src/ppstampErrorCodes.c.in	(revision 15672)
+++ 	(revision )
@@ -1,25 +1,0 @@
-/*
- * The line
-    { PSWARP_ERR_$X{ErrorCode}, "$X{ErrorDescription}"},
- * (without the Xs)
- * will be replaced by values from errorCodes.dat
- */
-#include "pslib.h"
-#include "ppstampErrorCodes.h"
-
-void ppstampErrorRegister(void)
-{
-    static psErrorDescription errors[] = {
-       { PPSTAMP_ERR_BASE, "First value we use; lower values belong to psLib" },
-       { PPSTAMP_ERR_${ErrorCode}, "${ErrorDescription}"},
-    };
-    static int nerror = PPSTAMP_ERR_NERROR - PPSTAMP_ERR_BASE; // number of values in enum
-
-    for (int i = 0; i < nerror; i++) {
-       psErrorDescription *tmp = psAlloc(sizeof(psErrorDescription));
-       *tmp = errors[i];
-       psErrorRegister(tmp, 1);
-       psFree(tmp);			/* it's on the internal list */
-    }
-    nerror = 0;			                // don't register more than once
-}
Index: trunk/ppstamp/src/ppstampErrorCodes.dat
===================================================================
--- trunk/ppstamp/src/ppstampErrorCodes.dat	(revision 15672)
+++ 	(revision )
@@ -1,10 +1,0 @@
-#
-# This file is used to generate ppstampErrorCodes.h
-#
-BASE = 800		First value we use; lower values belong to psLib
-UNKNOWN			Unknown PM error code
-NOT_IMPLEMENTED		Desired feature is not yet implemented
-ARGUMENTS		Incorrect arguments
-CONFIG			Problem in configure files
-IO			Problem in FITS I/O
-DATA                    Problem in data values
Index: trunk/ppstamp/src/ppstampErrorCodes.h.in
===================================================================
--- trunk/ppstamp/src/ppstampErrorCodes.h.in	(revision 15672)
+++ 	(revision )
@@ -1,18 +1,0 @@
-#if !defined(PPSTAMP_ERROR_CODES_H)
-#define PPSTAMP_ERROR_CODES_H
-/*
- * The line
- *  PPSTAMP_ERR_$X{ErrorCode},
- * (without the X)
- *
- * will be replaced by values from errorCodes.dat
- */
-typedef enum {
-    PPSTAMP_ERR_BASE = 650,
-    PPSTAMP_ERR_${ErrorCode},
-    PPSTAMP_ERR_NERROR
-} ppstampErrorCode;
-
-void ppstampErrorRegister(void);
-
-#endif
Index: trunk/ppstamp/src/ppstampMakeStamp.c
===================================================================
--- trunk/ppstamp/src/ppstampMakeStamp.c	(revision 15672)
+++ 	(revision )
@@ -1,584 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ppstamp.h"
-#include "pmAstrometryUtils.h"
-
-#define WCS_NONLIN_TOL 0.001            // Non-linear tolerance for header WCS
-
-typedef enum {
-    PPSTAMP_OFF,
-    PPSTAMP_PARTIALLY_ON,
-    PPSTAMP_ON,
-    PPSTAMP_ERROR
-} ppstampOverlap;
-
-static void skyToChip(pmAstromObj *pt, pmFPA *fpa, pmChip *chip);
-
-// convert the input chip's transforms to the output
-static bool convertWCS(pmHDU *outHDU, pmFPA *outFPA, pmChip *outChip, pmChip *inChip, psRegion *roi)
-{
-    pmHDU *hdu = pmHDUFromChip(inChip);
-    PS_ASSERT_PTR_NON_NULL(hdu, 1)
-    PS_ASSERT_PTR_NON_NULL(hdu->header, 1)
-
-    // Change the reference pixel to account for the change in origin between the stamp and
-    // the original image
-    outChip->toFPA   = psPlaneTransformSetCenter(NULL, inChip->toFPA, (int) roi->x0, (int) roi->y0);
-
-    outChip->fromFPA = psPlaneTransformInvert(NULL, outChip->toFPA, *roi, 50);
-
-    // remove these keys which may have been copied from the input header
-    // XXX pmAstromWriteWCS should do this since it's the one that's inserting
-    // the PC00* style keywords
-    if (psMetadataLookup(outHDU->header, "CD1_1")) {
-        psMetadataRemoveKey(outHDU->header, "CD1_1");
-        psMetadataRemoveKey(outHDU->header, "CD1_2");
-        psMetadataRemoveKey(outHDU->header, "CD2_1");
-        psMetadataRemoveKey(outHDU->header, "CD2_2");
-    }
-
-    if (!pmAstromWriteWCS(outHDU->header, outFPA, outChip, WCS_NONLIN_TOL)) {
-        psError(PS_ERR_UNKNOWN, false, "Failed to write WCS to output\n");
-        return false;
-    }
-
-    return true;
-}
-
-static bool copyMetadata(pmFPAfile *output, pmFPAfile *input, pmChip *inChip, ppstampOptions *options)
-{
-    pmChip    *outChip;
-    pmFPAview *view = pmFPAviewAlloc(0);
-
-    // our output file has a single chip
-    view->chip = 0;
-    outChip = pmFPAviewThisChip(view, output->fpa);
-    psFree(view);
-
-    // copy data from the input chip header to the output.
-    // since some of the keywords might be duplicated we may not want to copy both
-
-    // copy the fpa concepts
-    outChip->parent->concepts = psMetadataCopy(outChip->parent->concepts, inChip->parent->concepts);
-
-    pmHDU *inHDU  = pmHDUFromChip(inChip);
-    pmHDU *outHDU = pmHDUGetHighest(output->fpa, outChip, NULL);
-
-    if (inHDU->header) {
-        outHDU->header = psMetadataCopy(outHDU->header, inHDU->header);
-    } else if (!outHDU->header) {
-        outHDU->header = psMetadataAlloc();
-    }
-
-
-    // If input had WCS convert it for stamp
-    if (input->fpa->toSky) {
-        // steal the input fpa's transforms
-        output->fpa->toTPA   = input->fpa->toTPA;
-        output->fpa->fromTPA = input->fpa->fromTPA;
-        output->fpa->toSky   = input->fpa->toSky;
-
-        // drop the references
-        input->fpa->toTPA   = 0;
-        input->fpa->fromTPA = 0;
-        input->fpa->toSky   = 0;
-
-        if (!convertWCS(outHDU, output->fpa, outChip, inChip, &options->roi)) {
-            return false;
-        }
-    } else {
-        psWarning("No WCS present in input\n");
-    }
-
-    ppstampVersionMetadata(outHDU->header, options);
-
-    return true;
-}
-
-#ifdef notdef
-// update the ROI to account for any change in the coordinate system in the
-// mosaic process
-// THERE isn't any change. This is something I was trying to make the megacam
-// transforms come out correctly.
-static bool updateROI(ppstampOptions *options, pmFPAfile *mosaic, pmChip *mosaicChip)
-{
-    // set up the astrometry
-    pmHDU *hdu = pmHDUFromChip(mosaicChip);
-    PS_ASSERT_PTR_NON_NULL(hdu, 1)
-    PS_ASSERT_PTR_NON_NULL(hdu->header, 1)
-
-
-    if (!pmAstromReadWCS(mosaic->fpa, mosaicChip, hdu->header, 1.0)) {
-        psError(PS_ERR_UNKNOWN, false, "Failed to Read WCS from mosaic, cannot proceed\n");
-        return false;
-    }
-    pmAstromObj *center = pmAstromObjAlloc();
-
-    center->sky->r = options->centerRA;
-    center->sky->d = options->centerDEC;
-    center->sky->rErr = 0;
-    center->sky->dErr = 0;
-
-    skyToChip(center, mosaic->fpa, mosaicChip);
-
-    int width = options->dX;
-    int height = options->dY;
-
-    fprintf(stderr, "ROI before: %s\n", psRegionToString(options->roi));
-
-    options->roi.x0 = center->chip->x - width/2;
-    options->roi.x1 = options->roi.x0 + width;
-    options->roi.y0 = center->chip->y - height/2;
-    options->roi.y1 = options->roi.y0 + height;
-
-    fprintf(stderr, "ROI after:  %s\n", psRegionToString(options->roi));
-
-
-    return true;
-}
-#endif
-
-// Build the postage stamp output file
-
-static bool makeStamp(pmConfig *config, ppstampOptions *options, pmFPAfile *input, 
-                pmChip *inChip, pmFPAview *view)
-{
-    int status = false;
-
-    pmFPAfile *output = psMetadataLookupPtr(NULL, config->files, "PPSTAMP.OUTPUT");
-    if (!output) {
-        psError(PS_ERR_UNKNOWN, false, "Can't find output data\n");
-        return false;
-    }
-    char *fpaName = psMetadataLookupStr(NULL, input->fpa->concepts, "FPA.NAME"); // Name of FPA
-    pmFPAview *outview = pmFPAviewAlloc(0);
-    pmFPAAddSourceFromView(output->fpa, fpaName, outview, output->format);
-
-    outview->chip = 0;
-    outview->cell = 0;
-    pmCell *target =  pmFPAviewThisCell(outview, output->fpa); // Target cell
-    psFree(outview);
-    outview = NULL;
-
-    //   psMetadataPrint(stderr, inChip->concepts, 0);
-    
-    // These default to zero. would that be ok?
-    psMetadataAddS32(target->concepts, PS_LIST_TAIL, "CELL.XBIN", PS_META_REPLACE, "Binning in x", 1);
-    psMetadataAddS32(target->concepts, PS_LIST_TAIL, "CELL.YBIN", PS_META_REPLACE, "Binning in y", 1);
-
-
-    // we extract our postage stamp from a mosaic so that
-    // pmChipMosaic can handle the tricky bits of parity, binning, etc.
-    pmFPAfile *mosaic = ppstampBuildMosaic(config, input, view);
-    if (mosaic == NULL) {
-        return false;
-    }
-
-    // one cell one chip
-    pmFPAview *mosaicView = pmFPAviewAlloc(0);
-    mosaicView->chip = 0;
-    mosaicView->cell = 0;
-
-    pmReadout *readout;
-    while ((readout = pmFPAviewNextReadout (mosaicView, mosaic->fpa, 1)) != NULL) {
-        if (!readout->data_exists) {
-            psError(PS_ERR_UNKNOWN, false, "no data in mosaic readout!\n");
-            continue;
-        }
-        pmReadout *outReadout = pmReadoutAlloc(target);
-        if (!outReadout) {
-            psError(PS_ERR_UNKNOWN, false, "failed to allocate output readout\n");
-            status = false;
-            break;
-        }
-
-        psRegion extractRegion = options->roi;
-
-        // Close your eyes while I hack around bug 986
-        if (ppstampMegacamWorkaround) {
-            // the coordinates of the mosaic are shifted 32 pixels from the chip
-            extractRegion.x0 -= 32;
-            extractRegion.x1 -= 32;
-        }
-    
-        psImage *subsetImage = psImageSubset(readout->image, extractRegion);
-
-        if (subsetImage) {
-            // make a copy since we're going to change the image's internals
-            outReadout->image = psImageCopy(NULL, subsetImage, subsetImage->type.type);
-            psFree(subsetImage);
-            if (outReadout->image) {
-                // The image has inherited the subset's col0 and row0. We don't want this in
-                // our output so override the values.
-                // XXX put this into a function in psImage
-                // (What I really needed was a function that does
-                //     "create a copy of this portion of an image and return it as a new image with
-                //      origin 0,0 ")
-                P_PSIMAGE_SET_COL0(outReadout->image, 0);
-                P_PSIMAGE_SET_ROW0(outReadout->image, 0);
-
-                outReadout->data_exists = true;
-                outReadout->parent->data_exists = true;
-                outReadout->parent->parent->data_exists = true;
-                status = true;
-            } else {
-                psError(PS_ERR_UNKNOWN, false, "Copying of readout image failed.\n");
-                status = false;
-            }
-        } else {
-            psError(PS_ERR_UNKNOWN, false, "Image subset failed.\n");
-            status = false;
-        }
-        psFree(outReadout); // drop reference
-    }
-
-    // XXXX remove this or make writing the mosaic to a file a valid option
-    static bool writeMosaic = false;
-    if (writeMosaic) {
-        mosaic->save = true;
-        mosaicView->cell = -1;
-        pmFPAfileIOChecks(config, mosaicView, PM_FPA_AFTER);
-    }
-
-    psFree(mosaicView);
-
-    if (status) {
-        status = copyMetadata(output, input, inChip, options);
-    }
-    return status;
-}
-
-
-
-static bool regionContainsPoint(psRegion *r, psPlane *pt)
-{
-    if (pt->x < r->x0)
-        return false;
-    if (pt->x >= r->x1)
-        return false;
-    if (pt->y < r->y0)
-        return false;
-    if (pt->y >= r->y1)
-        return false;
-
-    return true;
-}
-
-// true if the inner region is equal to or completely contained in
-// the outer region
-static bool regionContainsRegion(psRegion *outer, psRegion *inner)
-{
-    if ((outer->x0 <= inner->x0) &&
-        (outer->y0 <= inner->y0) &&
-        (outer->x1 >= inner->x1) &&
-        (outer->y1 >= inner->y1)) {
-        return true;
-    } else {
-        return false;
-    }
-}
-
-
-static void skyToChip(pmAstromObj *pt, pmFPA *fpa, pmChip *chip)
-{
-    // convert from sky to TP to FP
-    psProject(pt->TP, pt->sky, fpa->toSky);
-    psPlaneTransformApply(pt->FP, fpa->fromTPA, pt->TP);
-    // convert from FP to chip
-    psPlaneTransformApply(pt->chip, chip->fromFPA, pt->FP);
-}
-
-static void chipToSky(pmAstromObj *pt, pmFPA *fpa, pmChip *chip)
-{
-    // chip to FP
-    psPlaneTransformApply(pt->FP, chip->toFPA, pt->chip);
-    // FP to TP to sky
-    psPlaneTransformApply(pt->TP, fpa->toTPA, pt->FP);
-    psDeproject(pt->sky, pt->TP, fpa->toSky);
-
-}
-
-static void compareToBox(psRegion *region, psPlane *pt)
-{
-    if (pt->x < region->x0)
-        region->x0 = pt->x;
-    if (pt->x > region->x1)
-        region->x1 = pt->x;
-    if (pt->y < region->y0)
-        region->y0 = pt->y;
-    if (pt->y > region->y1)
-        region->y1 = pt->y;
-}
-
-// For roi width and height given in sky coordinates find a bounding box in chip coordinates
-// that encloses the requested range
-static void findBoundingBox(ppstampOptions *options, pmFPA *fpa, pmChip *chip, pmAstromObj *center)
-{
-    pmAstromObj *pt = pmAstromObjAlloc();
-
-    if (!options->celestialCenter) {
-        // Center was specified in chip coordinates, transform to the sky
-        chipToSky(center, fpa, chip);
-    }
-
-    // calculate the four corners of the bounding box in sky coordinates, translate them to
-    // chip coordinates and build the ROI by comparison.
-
-    options->roi.x0 = INFINITY;
-    options->roi.x1 = -INFINITY;
-    options->roi.y0 = INFINITY;
-    options->roi.y1 = -INFINITY;
-    
-    pt->sky->rErr = 0;
-    pt->sky->dErr = 0;
-
-    pt->sky->r = center->sky->r - options->dRA/2;
-    pt->sky->d = center->sky->d - options->dDEC/2;
-    skyToChip(pt, fpa, chip);
-    compareToBox(&options->roi, pt->chip);
-
-    pt->sky->r = center->sky->r + options->dRA/2;
-    pt->sky->d = center->sky->d - options->dDEC/2;
-    skyToChip(pt, fpa, chip);
-    compareToBox(&options->roi, pt->chip);
-
-    pt->sky->r = center->sky->r + options->dRA/2;
-    pt->sky->d = center->sky->d + options->dDEC/2;
-    skyToChip(pt, fpa, chip);
-    compareToBox(&options->roi, pt->chip);
-
-    pt->sky->r = center->sky->r - options->dRA/2;
-    pt->sky->d = center->sky->d + options->dDEC/2;
-    skyToChip(pt, fpa, chip);
-    compareToBox(&options->roi, pt->chip);
-
-    psFree(pt);
-
-    // save the width and height in case we need them later
-    options->dX = options->roi.x1 - options->roi.x0;
-    options->dY = options->roi.y1 - options->roi.y0;
-}
-
-#ifdef notdef
-// I'm not using this any more. We mosaic the chip before extracting the pixels
-// so we don't need to deal with cells at this level.
-
-// findCell
-// find cell on given chip that contains the region of interest
-// return the status of the overlap and if the cell completely contains the ROI 
-// set a pointer to reference the cell
-
-static ppstampOverlap findCell(pmFPAview *view, ppstampOptions *options, pmFPAfile *input,
-                                pmAstromObj *center, pmCell **ppCell)
-{
-    pmCell *cell;
-
-    view->cell = -1;
-    while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
-        psRegion *cellExtent = pmCellExtent(cell);
-        if (regionContainsPoint(cellExtent, center->chip)) {
-            if (regionContainsRegion(cellExtent, &options->roi)) {
-                *ppCell = cell;
-                psFree(cellExtent);
-                return PPSTAMP_ON;
-            } else {
-                fprintf(stderr, "ROI must be confined to single cell. Partial overlap cell %d\n",
-                    view->cell);
-                fprintf(stderr, "Partial Overlap cell %d\n", view->cell);
-                fprintf(stderr, "  ROI:         %s\n", psRegionToString(options->roi));
-                fprintf(stderr, "  Cell Extent: %s\n", psRegionToString(*cellExtent));
-                psFree(cellExtent);
-                return PPSTAMP_PARTIALLY_ON;
-            }
-        }
-        psFree(cellExtent);
-    }
-
-    // This shouldn't ever happen since ROI is on the chip, it must at least partially overlap
-    // one of the cells
-    psError(PS_ERR_PROGRAMMING, false, "findCell couldn't find a cell containing the center\n");
-
-    return PPSTAMP_OFF;
-}
-#endif
-
-
-
-// findROI
-// calculate the region of interest in chip coordinates and determine whether that region
-// is completely contained on a single chip
-
-static ppstampOverlap findROI(ppstampOptions *options, pmFPAview *view, pmFPAfile *input, pmChip *chip,
-                       pmAstromObj *center)
-{
-    psString chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
-    psRegion    *chipBounds = ppstampChipRegion(chip);
-    bool        onChip = false;
-    ppstampOverlap   returnval = PPSTAMP_OFF;
-
-//    fprintf(stderr, "ppstampChipBounds: %s\n", psRegionToString(*chipBounds));
-
-    // set up the astrometry
-    pmHDU *hdu = pmHDUFromChip(chip);
-    PS_ASSERT_PTR_NON_NULL(hdu, 1)
-    PS_ASSERT_PTR_NON_NULL(hdu->header, 1)
-
-    if (!pmAstromReadWCS(input->fpa, chip, hdu->header, 1.0)) {
-        // we can live without WCS if the ROI is specified in pixels
-
-        if (options->celestialCenter || options->celestialRange) {
-            psError(PPSTAMP_ERR_DATA, false, "Failed to Read WCS, cannot proceed\n");
-            psFree(chipBounds);
-            return PPSTAMP_ERROR;
-        }
-    }
-
-    if (options->celestialCenter) {
-
-        center->sky->r = options->centerRA;
-        center->sky->d = options->centerDEC;
-        center->sky->rErr = 0;
-        center->sky->dErr = 0;
-
-        skyToChip(center, input->fpa, chip);
-
-        if (regionContainsPoint(chipBounds, center->chip)) {
-            psLogMsg("ppstampMakeStamp", 2, "Found center (%f %f) on chip: %s\n", 
-                center->chip->x, center->chip->y, chipName);
-            onChip = true;
-        }
-    } else {
-        // center specified in pixels. 
-        // If the user specified a name of a chip name wait until we get to that one.
-        // If no chip name was specified, select this one (the first one that had data)
-        if ((options->chipName == NULL) || !strcmp(chipName, options->chipName)) {
-            psLogMsg("ppstampMakeStamp", 2, "Center on chip: %s\n", chipName);
-            center->chip->x = options->centerX;
-            center->chip->y = options->centerY;
-            center->chip->xErr = 0;
-            center->chip->yErr = 0;
-            onChip = true;
-        }
-    }
-
-    if (onChip) {
-        if (options->celestialRange) {
-            findBoundingBox(options, input->fpa, chip, center);
-        } else {
-            int width  = options->dX;
-            int height = options->dY;
-
-            // calculate the ROI in chip coordinates
-            options->roi.x0 = center->chip->x - width / 2;
-            options->roi.x1 = options->roi.x0 + width;
-            options->roi.y0 = center->chip->y - height / 2;
-            options->roi.y1 = options->roi.y0 + height;
-        }
-
-
-        if (regionContainsRegion(chipBounds, &options->roi)) {
-            // returnval = findCell(view, options, input, center, ppCell);
-            psLogMsg("ppstampMakeStamp", 2, "ROI contained on: %s\n", chipName);
-            returnval = PPSTAMP_ON;
-        } else {
-            fprintf(stderr, "Partial Overlap chip %s\n", chipName);
-            fprintf(stderr, "ROI:         %s\n", psRegionToString(options->roi));
-            fprintf(stderr, "Chip Extent: %s\n", psRegionToString(*chipBounds));
-
-            returnval = PPSTAMP_PARTIALLY_ON;
-
-        }
-    }
-    psFree(chipBounds);
-
-    return returnval;
-}
-
-bool ppstampMakeStamp (pmConfig *config, ppstampOptions *options)
-{
-    bool        status = false;
-    bool        returnval = false;;
-    bool        foundOverlap = false;
-    pmAstromObj *center = pmAstromObjAlloc();
-
-    pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPSTAMP.INPUT");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, true, "Can't find input data!\n");
-        psFree(center);
-        return false;
-    }
-
-    pmFPAview *view = pmFPAviewAlloc(0);// View for level of interest
-
-    // files associated with the science image
-    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
-        psError(PS_ERR_UNKNOWN, false, "Failed to load input.");
-        psFree(center);
-        psFree (view);
-        return false;
-    }
-
-    // Loop over the chips and find the one that contains the center
-    pmChip *chip;
-    while ((chip = pmFPAviewNextChip(view, input->fpa, 1)) != NULL) {
-	bool allDone = false;
-
-        if (!chip->process || !chip->file_exists) {
-            continue;
-        }
-
-        if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to load chip");
-            status = false;
-            break;
-        }
-
-        ppstampOverlap overlap = findROI(options, view, input, chip, center);
-
-        switch (overlap) {
-        case PPSTAMP_OFF:
-            // keep looking
-            break;
-        case PPSTAMP_ON:
-            returnval = makeStamp(config, options, input, chip, view);
-            allDone = true;
-            foundOverlap = true;
-            break;
-	case PPSTAMP_PARTIALLY_ON:
-            psError(PS_ERR_UNKNOWN, false, "Region of interest must be confined to a single chip\n");
-            // XXX: perhaps print a helpful message about what coordinates would be valid
-            returnval = false;
-            allDone = true;
-            foundOverlap = true;
-            break;
-        case PPSTAMP_ERROR:
-            returnval = false;
-            allDone = true;
-            break;
-        default:
-            psError(PS_ERR_PROGRAMMING, false, "findROI returned unexpected value %d\n", overlap);
-            break;
-        }
-
-	pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
-
-        if (allDone) {
-            view->chip = -1;
-            break;
-        }
-    } 
-    pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
-
-    psFree(center);
-    psFree(view);
-
-    if (!foundOverlap) {
-        fprintf(stderr, "ROI not found in input\n");
-    }
-
-    return returnval;
-}
-
-
Index: trunk/ppstamp/src/ppstampMosaic.c
===================================================================
--- trunk/ppstamp/src/ppstampMosaic.c	(revision 15672)
+++ 	(revision )
@@ -1,41 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ppstamp.h"
-
-// Mosaic the cells of a given chip
-
-
-pmFPAfile *ppstampBuildMosaic(pmConfig *config, pmFPAfile *input, pmFPAview *view)
-{
-    bool    status;
-
-    pmFPAfile *mosaic =  psMetadataLookupPtr(&status, config->files, "PPSTAMP.CHIP");
-    if (!status)  {
-        psErrorStackPrint(stderr, "can't find mosaic i/o file\n");
-        exit(EXIT_FAILURE);
-    }
-
-    pmFPAview *mosaicView = pmFPAviewAlloc(0);
-
-    mosaicView->chip = 0;
-    pmChip  *mChip  = pmFPAviewThisChip(mosaicView, mosaic->fpa);
-    pmChip  *inChip = pmFPAviewThisChip(view, input->fpa);
-    if (!mChip->hdu && !mChip->parent->hdu) {
-        const char *name = psMetadataLookupStr(&status, input->fpa->concepts, "FPA.NAME"); // Name of FPA
-        pmFPAAddSourceFromView(mosaic->fpa, name, mosaicView, mosaic->format);
-    }
-    psFree(mosaicView);
-
-    psMaskType blankMask = pmConfigMask("BLANK", config);
-
-    status = pmChipMosaic(mChip, inChip, true, blankMask);
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "chip mosaic failed\n");
-        return NULL;
-    }
-
-    return mosaic;
-}
-
Index: trunk/ppstamp/src/ppstampOptions.c
===================================================================
--- trunk/ppstamp/src/ppstampOptions.c	(revision 15672)
+++ 	(revision )
@@ -1,31 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ppstamp.h"
-
-
-static void imageOptionsFree(ppstampOptions *options)
-{
-    psFree(options->chipName);
-}
-
-ppstampOptions *ppstampOptionsAlloc(void)
-{
-    ppstampOptions *options = psAlloc(sizeof(ppstampOptions));
-    psMemSetDeallocator(options, (psFreeFunc)imageOptionsFree);
-
-    options->celestialCenter = false;
-    options->centerX         = 0;
-    options->centerY         = 0;
-    options->centerRA        = 0;
-    options->centerDEC       = 0;
-    options->celestialRange  = false;
-    options->dX   = 0;
-    options->dY   = 0;
-    options->dRA  = 0;
-    options->dDEC = 0;
-    options->chipName = NULL;
-
-    return options;
-}
Index: trunk/ppstamp/src/ppstampParseCamera.c
===================================================================
--- trunk/ppstamp/src/ppstampParseCamera.c	(revision 15672)
+++ 	(revision )
@@ -1,64 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-# include "ppstamp.h"
-
-bool ppstampMegacamWorkaround = false;
-
-// Set up the ppstamp output Image file
-bool setupOutput(pmConfig *config, pmFPAfile *input)
-{
-    pmFPAfile *output = pmFPAfileDefineSkycell(config, NULL, "PPSTAMP.OUTPUT");
-    output->save = true;
-
-    return true;
-}
-
-// This function seems mis-named. What are we doing with regards to the Camera?
-// Well we are building the output image based on the camera. Is there
-// something else that I'm missing?
-
-bool ppstampParseCamera(pmConfig *config)
-{
-    bool status = false;
-
-    // the input image defines the camera, and all recipes and options the follow
-    pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PPSTAMP.INPUT", "INPUT");
-    if (!status || !input) {
-        psError(PS_ERR_IO, false, "Failed to build FPA from PPSTAMP.INPUT");
-        return false;
-    }
-    if (input->type != PM_FPA_FILE_IMAGE) {
-        psError(PS_ERR_IO, true, "PPSTAMP.INPUT is not of type IMAGE");
-        return false;
-    }
-
-#ifdef notyet
-    // add recipe options supplied on command line
-    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, RECIPE_NAME);
-#endif
-
-    // Set up the output target
-
-    if (!setupOutput(config, input)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to setup output.");
-        return false;
-    }
-    pmFPAfile *chipImage = pmFPAfileDefineChipMosaic(config, input->fpa, "PPSTAMP.CHIP");
-    if (!chipImage) {
-        psError(PS_ERR_IO, false, _("Unable to generate new file from PPSTAMP.CHIP"));
-        return NULL;
-    }
-    if (chipImage->type != PM_FPA_FILE_IMAGE) {
-        psError(PS_ERR_IO, true, "PPSTAMP.CHIP is not of type IMAGE");
-        return NULL;
-    }
-
-    if (!strcmp(config->cameraName, "MEGACAM")) {
-        // workaround bug 986 and related
-        ppstampMegacamWorkaround = true;
-    }
- 
-    return true;
-}
Index: trunk/ppstamp/src/ppstampRegion.c
===================================================================
--- trunk/ppstamp/src/ppstampRegion.c	(revision 15672)
+++ 	(revision )
@@ -1,121 +1,0 @@
-#include <pslib.h>
-
-#include "pmHDU.h"
-#include "pmFPA.h"
-
-#include "ppstamp.h"
-
-// Functions to calculate the image space boundaries of a given Chip or Cell
-// These are calculated in coordinates that match the wcs transformation
-// (adapted from pmFPAExtent.c)
-
-// return cell pixels bounding the readout
-static psRegion *ppstampReadoutRegion(const pmReadout *readout)
-{
-    PS_ASSERT_PTR_NON_NULL(readout, NULL);
-
-    psImage *image = readout->image;    // Image from which to get dimensions
-    if (!image) {
-        return NULL;
-    }
-
-    // This is the difference between this function and pmReadoutExtent. 
-    // pmReadoutExtent ignores the col0, row0 of the readout
-   
-    int col0 = 0;   // should be  image->col0 - readout->col0
-    int row0 = 0;   //            image->row0 - readout->row0
-   
-    return psRegionAlloc(col0, col0 + image->numCols,
-                         row0, row0 + image->numRows);
-}
-
-// return chip pixels bounding the cell (all readouts)
-psRegion *ppstampCellRegion(const pmCell *cell)
-{
-    PS_ASSERT_PTR_NON_NULL(cell, NULL);
-
-    psArray *readouts = cell->readouts; // Array of component readouts
-    psRegion *cellExtent = psRegionAlloc(INFINITY, 0, INFINITY, 0); // Extent of cell
-    for (long i = 0; i < readouts->n; i++) {
-        pmReadout *readout = readouts->data[i]; // Readout of interest
-        psRegion *roExtent = ppstampReadoutRegion(readout); // Extent of readout
-        cellExtent->x0 = PS_MIN(cellExtent->x0, roExtent->x0);
-        cellExtent->x1 = PS_MAX(cellExtent->x1, roExtent->x1);
-        cellExtent->y0 = PS_MIN(cellExtent->y0, roExtent->y0);
-        cellExtent->y1 = PS_MAX(cellExtent->y1, roExtent->y1);
-        psFree(roExtent);
-    }
-
-    bool mdok;                          // Status of MD lookup
-    int cellX0 = psMetadataLookupS32(&mdok, cell->concepts, "CELL.X0"); // Cell x offset
-    if (!mdok) {
-        psError(PS_ERR_UNKNOWN, true, "Unable to find CELL.X0.\n");
-        psFree(cellExtent);
-        return NULL;
-    }
-
-    int cellY0 = psMetadataLookupS32(&mdok, cell->concepts, "CELL.Y0"); // Cell y offset
-    if (!mdok) {
-        psError(PS_ERR_UNKNOWN, true, "Unable to find CELL.Y0.\n");
-        psFree(cellExtent);
-        return NULL;
-    }
-    int xParity = psMetadataLookupS32(NULL, cell->concepts, "CELL.XPARITY");
-    int yParity = psMetadataLookupS32(NULL, cell->concepts, "CELL.YPARITY");
-
-    if (xParity >= 0) {
-        cellExtent->x0 += cellX0;
-        cellExtent->x1 += cellX0;
-    } else {
-        float x0 = cellX0 - cellExtent->x1;
-        float x1 = cellX0 - cellExtent->x0;
-        cellExtent->x0 = x0;
-        cellExtent->x1 = x1;
-    }
-
-    if (yParity >= 0) {
-        cellExtent->y0 += cellY0;
-        cellExtent->y1 += cellY0;
-    } else {
-        float y0 = cellY0 - cellExtent->y1;
-        float y1 = cellY0 - cellExtent->y0;
-        cellExtent->y0 = y0;
-        cellExtent->y1 = y1;
-    }
-
-    return cellExtent;
-}
-
-// return chip pixels included in all cells
-psRegion *ppstampChipRegion(const pmChip *chip)
-{
-    PS_ASSERT_PTR_NON_NULL(chip, NULL);
-
-    if (ppstampMegacamWorkaround) {
-        // There is an inconsistency in the megacam parameters. 
-        // The offset to the cells is effectively contained in two
-        // places.
-        // The CELL.X0 for the 2 cells are 0 and 1024 while
-        // readout->image.col0 = 32 and 1056
-        // This fact makes it impossible to calculate the Chip bounds 
-        // in a way consistent with say gpc1
-        // we're deferring that problem for now.
-        // Since all chips on megacam have the same bounds, just hard code
-        // the answer. See bug 986
-        return psRegionAlloc(32, 2080, 0, 4612);
-    }
-
-    psArray *cells = chip->cells;       // Array of component cells
-    psRegion *chipExtent = psRegionAlloc(INFINITY, 0, INFINITY, 0); // Extent of chip
-    for (long i = 0; i < cells->n; i++) {
-        pmCell *cell = cells->data[i];  // Cell of interest
-        psRegion *cellExtent = ppstampCellRegion(cell); // Extent of cell
-        chipExtent->x0 = PS_MIN(chipExtent->x0, cellExtent->x0);
-        chipExtent->x1 = PS_MAX(chipExtent->x1, cellExtent->x1);
-        chipExtent->y0 = PS_MIN(chipExtent->y0, cellExtent->y0);
-        chipExtent->y1 = PS_MAX(chipExtent->y1, cellExtent->y1);
-        psFree(cellExtent);
-    }
-
-    return chipExtent;
-}
Index: trunk/ppstamp/src/ppstampVersion.c
===================================================================
--- trunk/ppstamp/src/ppstampVersion.c	(revision 15672)
+++ 	(revision )
@@ -1,56 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ppstamp.h"
-
-static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
-
-psString ppstampVersion(void)
-{
-    psString version = NULL;            // Version, to return
-    psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
-    return version;
-}
-
-psString ppstampVersionLong(void)
-{
-    psString version = ppstampVersion(); // Version, to return
-    psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
-    psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
-    psFree(tag);
-    return version;
-}
-
-
-void ppstampVersionMetadata(psMetadata *metadata, ppstampOptions *options)
-{
-    PS_ASSERT_METADATA_NON_NULL(metadata,);
-
-    psString pslib = psLibVersionLong();// psLib version
-    psString psmodules = psModulesVersionLong(); // psModules version
-    psString ppstamp = ppstampVersionLong(); // ppstamp version
-
-    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
-    psString timeString = psTimeToISO(time); // The time in an ISO string
-    psFree(time);
-    psString head = NULL;               // Head string
-    psStringAppend(&head, "ppstamp processing at %s. Component information:", timeString);
-    psFree(timeString);
-
-    psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");
-    psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");
-    psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");
-    psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppstamp, "");
-    psString roi = NULL;
-    psStringAppend(&roi, "ppstamp: region of interest: %s", psRegionToString(options->roi));
-    psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY",  PS_META_DUPLICATE_OK, roi, "");
-
-    psFree(roi);
-    psFree(head);
-    psFree(pslib);
-    psFree(psmodules);
-    psFree(ppstamp);
-
-    return;
-}
