Index: trunk/ippToPsps/src/Batch.c
===================================================================
--- trunk/ippToPsps/src/Batch.c	(revision 32007)
+++ 	(revision )
@@ -1,344 +1,0 @@
-/** @file ippToPsps.c
- *
- *  @ingroup ippToPsps
- *
- *  Source for all methods in the Batch class
- *
- *  @author IfA
- *  Copyright 2009 Institute for Astronomy, University of Hawaii
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <sys/stat.h>
-
-#include <pslib.h>
-#include <psmodules.h>
-
-#include "Batch.h"
-
-// private class members
-static bool haveResultsPath = false;
-static bool haveFitsInPath = false;
-static bool haveFitsOutPath = false;
-static bool haveConfig = false;
-static bool haveSurveyType = false;
-
-// some getter methods
-static bool gotResultsPath() {return haveResultsPath;}
-static bool gotFitsInPath() {return haveFitsInPath;}
-static bool gotFitsOutPath() {return haveFitsOutPath;}
-static bool gotConfig() {return haveConfig;}
-static bool gotSurveyType() {return haveSurveyType;}
-
-/**
-  Gets uncalibrated instrumental flux from magnitude
-  */
-__inline bool getFlux(
-        const float exposureTime, 
-        const float magnitude, 
-        float* flux,
-        const float magnitudeErr,
-        float* fluxErr) {
-
-    *flux = powf(10.0, -0.4*magnitude) / exposureTime;
-    if (!isfinite(*flux) || *flux < 0.000001) return false;
-    if (fluxErr) *fluxErr = fabsf((magnitudeErr * *flux)/1.085736);
-
-    return true;
-}
-
-/**
-  Destructor
-  */
-static void destroy(Batch* this) {
-
-    // if we created an output file...
-    if (this->fitsOut) {
-
-        // if unsuccessful, then delete FITS file
-        if (this->exitCode != PS_EXIT_SUCCESS) {
-
-            this->logger->print(this->logger, MSG_ERROR, "Batch", "Failed, so deleting fits file\n");
-            this->fitsOut->delete(this->fitsOut);
-        }
-
-        this->fitsOut->destroy(this->fitsOut);
-    }
-
-    // save XML document for results
-    if (this->resultsXmlDoc) {
-
-        xmlSaveFormatFileEnc(this->resultsPath, this->resultsXmlDoc, "UTF-8", 1);
-
-        xmlFreeDoc(this->resultsXmlDoc);
-        xmlCleanupParser();
-        xmlMemoryDump();
-    }
-
-    psFree(this->pmconfig);
-
-    for(uint32_t i=0; i<this->numOfInputFiles; i++) free(this->inputFiles[i]);
-    free(this->inputFiles);
-
-    if (this->dvoConfig != NULL) dvoConfigFree(this->dvoConfig);
-
-    // destroy objects
-    this->fitsGenerator->destroy(this->fitsGenerator);
-    this->initData->destroy(this->initData);
-
-    pmConfigDone();
-
-    return;
-}
-
-/**
-  Reads file-input file and populate array of paths
-  */
-static bool readInputFilePaths(Batch* this) {
-
-    FILE* file = fopen (this->fitsInPath, "r");
-
-    if (file == NULL) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Batch", "Unable to open file at %s\n", this->fitsInPath);
-        return false;
-    }
-
-    this->numOfInputFiles = 0;
-    char line[1000];
-    while (fgets(line, 1000, file) != NULL) this->numOfInputFiles++;
-
-    this->logger->print(this->logger, MSG_INFO, "Batch", 
-            "%d input file%s found\n", this->numOfInputFiles, (this->numOfInputFiles > 1) ? "s" : "");
-
-    if (this->numOfInputFiles < 1) return false;
-
-    this->inputFiles = (char**)calloc(this->numOfInputFiles, sizeof(char*));
-    for(uint32_t i=0; i<this->numOfInputFiles; i++)
-        this->inputFiles[i] = (char*)calloc(1000, 1);
-
-    rewind(file);
-    uint16_t i = 0;
-    while (fgets(line, 1000, file) != NULL) {
-
-        sprintf(this->inputFiles[i], "%s", line);
-
-        // remove newline
-        for(uint16_t j=0;j<strlen(this->inputFiles[i]);j++)
-            if (this->inputFiles[i][j] == '\n') this->inputFiles[i][j] = '\0';
-        i++;
-    }
-
-    fclose(file);
-
-    return true;
-}
-
-/**
-  Sets-up and reads command-line arguments
-*/
-static bool parseArguments(Batch* this, int argc, char **argv, char* configsDir, char* fitsOutFile) {
-
-    // first deal with DVO database
-    bool haveDvo = false;
-    for (int i=0;i<argc; i++) {
-
-        if (strcmp(argv[i], "CATDIR") == 0) {haveDvo = true; break;}
-    }
-    if (haveDvo) this->dvoConfig = dvoConfigRead(&argc, argv);
-    else this->dvoConfig = NULL;
-
-    // setup pmconfig
-    this->pmconfig = pmConfigRead(&argc, argv, NULL);
-    if (!this->pmconfig) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Batch", "Unable to read configuration\n");
-        this->exitCode = PS_EXIT_CONFIG_ERROR;
-        return false;
-    }
-    assert(this->pmconfig);
-
-    haveResultsPath = false;
-    haveFitsInPath = false;
-    haveFitsOutPath = false;
-    haveConfig = false;
-    haveSurveyType = false;
-
-    char fitsOutPath[1000];
-    char configsBaseDir[1000];
-
-    // decode arguments
-    int32_t optind = 1;
-    while( ( optind < argc ) ) {
-
-        char * sw = argv[optind];
-
-        if( argv[optind][0] == '-' ) {
-
-            if(strcmp(sw, "-input") == 0 ) {
-                optind++; if( optind > ( argc-1 ) ) break;
-                strcpy(this->fitsInPath, argv[optind]);
-                haveFitsInPath = true;
-            }
-            else if(strcmp(sw, "-output") == 0 ) {
-                optind++; if( optind > ( argc-1 ) ) break;
-                strcpy(fitsOutPath, argv[optind]);
-                haveFitsOutPath = true;
-            }
-            else if(strcmp(sw, "-results") == 0 ) {
-                optind++; if( optind > ( argc-1 ) ) break;
-                strcpy(this->resultsPath, argv[optind]);
-                haveResultsPath = true;
-            }
-            else if(strcmp(sw, "-config") == 0 ) {
-                optind++; if( optind > ( argc-1 ) ) break;
-                strcpy(configsBaseDir, argv[optind]);
-                haveConfig = true;
-            }
-            else if(strcmp(sw, "-survey") == 0 ) {
-                optind++; if( optind > ( argc-1 ) ) break;
-                strcpy(this->surveyType, argv[optind]);
-                haveSurveyType = true;
-            }
-            else if(strcmp(sw, "-test") == 0 ) {
-                this->testMode = true;
-            }
-        }
-
-        optind++;
-    }
-
-    // check we have some input paths
-    if (haveFitsInPath && !readInputFilePaths(this)) {
-
-        this->exitCode = PS_EXIT_DATA_ERROR;
-        return false;
-    }
-
-    // create an InitData object and get survey ID
-    this->initData = new_InitData(configsBaseDir, this->logger);
-    if (strlen(this->surveyType) > 0 && 
-            !this->initData->getSurveyId(this->initData, this->surveyType, &this->surveyID)) {
-
-        this->exitCode = PS_EXIT_CONFIG_ERROR;
-        return false;
-    }
-
-    // create a FitsGenerator object
-    strcat(configsBaseDir, configsDir);
-    this->fitsGenerator = new_FitsGenerator(this->logger, configsBaseDir);
-
-    // create full FITS out path
-    sprintf(fitsOutPath, "%s/%s", fitsOutPath, fitsOutFile);
-
-    // create an output FITS file
-    this->fitsOut = new_Fits(fitsOutPath, this->logger);
-    if (this->fitsOut->getFilePtr(this->fitsOut) == NULL) return false;
-
-    // create XML document for results 
-    if (this->resultsPath) {
-
-        this->resultsXmlDoc = xmlNewDoc(BAD_CAST "1.0");
-        xmlNodePtr rootNode = xmlNewNode(NULL, BAD_CAST "ippToPsps_Results");
-        xmlDocSetRootElement(this->resultsXmlDoc, rootNode);
-        xmlNewChild(rootNode, NULL, BAD_CAST "filename", BAD_CAST fitsOutFile);
-    }
-
-    return true;
-}
-
-/**
-  Print-out of this class
-  */
-static void print(Batch* this) {
-
-    this->logger->print(this->logger, MSG_INFO, "Batch", "\n");
-    this->logger->print(this->logger, MSG_INFO, "Batch", "     Class fields:\n");
-    this->logger->print(this->logger, MSG_INFO, "Batch", "surveyType      : %s\n", this->surveyType);
-    this->logger->print(this->logger, MSG_INFO, "Batch", "surveyID        : %d\n", this->surveyID);
-    this->logger->print(this->logger, MSG_INFO, "Batch", "resultsPath     : %s\n", this->resultsPath);
-    this->logger->print(this->logger, MSG_INFO, "Batch", "numOfInputFiles : %d\n", this->numOfInputFiles);
-    this->logger->print(this->logger, MSG_INFO, "Batch", "fitsInPath      : %s\n", this->fitsInPath);
-    this->logger->print(this->logger, MSG_INFO, "Batch", "testMode        : %s\n", this->testMode ? "yes" : "no");
-}
-
-
-
-#if 0
-psDB *dbh = psMemIncrRefCounter(pmConfigDB(this->pmconfig));
-if (!dbh) {
-    psError(PS_ERR_UNKNOWN, false, "Can't configure database");
-    ret = false;;
-}
-
-
-
-psString query = psStringCopy("SELECT * FROM camMask");
-
-if (!p_psDBRunQuery(dbh, query)) {
-    psError(PS_ERR_UNKNOWN, false, "database error");
-    psFree(query);
-    return false;
-}
-psFree(query);
-
-psArray *output = p_psDBFetchResult(dbh);
-if (!output) {
-    psError(PS_ERR_UNKNOWN, false, "database error");
-    return false;
-}
-if (!psArrayLength(output)) {
-    psTrace("camtool", PS_LOG_INFO, "no rows found");
-    psFree(output);
-    return true;
-}
-
-psError(PS_ERR_UNKNOWN, false, "FOUND %ld rows\n", psArrayLength(output));
-
-
-psFree(output);
-
-#endif
-
-
-/**
-  Constructor. Takes a Batch object and initialises it.
-  */
-bool new_Batch(Logger* logger, Batch *this) {
-
-    this->logger = logger;
-    this->surveyID = -1;
-    this->resultsXmlDoc = NULL;
-    this->numOfInputFiles = 0;
-    this->inputFiles = NULL;
-    this->fitsOut = NULL;
-    this->fitsGenerator = NULL;
-    this->pmconfig = NULL;
-    this->exitCode = PS_EXIT_SUCCESS;
-    this->testMode = false;
-
-    // set up function pointers
-    this->parseArguments = parseArguments;
-    this->print = print;
-    this->gotResultsPath = gotResultsPath;
-    this->gotFitsInPath = gotFitsInPath;
-    this->gotFitsOutPath = gotFitsOutPath;
-    this->gotConfig = gotConfig;
-    this->gotSurveyType = gotSurveyType;
-    this->destroy = destroy;
-
-    assert(this);
-
-    // sort out current time
-    time_t now = time(NULL);;
-    struct tm *ts = gmtime(&now); // TODO should be UTC
-    strftime(this->todaysDate, sizeof(this->todaysDate), "%Y-%m-%d", ts);
-
-    return true;
-}
-
-
Index: trunk/ippToPsps/src/Batch.h
===================================================================
--- trunk/ippToPsps/src/Batch.h	(revision 32007)
+++ 	(revision )
@@ -1,81 +1,0 @@
-/** @file Batch.h
- *
- *  @brief Batch
- *
- *  @ingroup ippToPsps
- *
- *  @author IfA
- *  Copyright 2011 Institute for Astronomy, University of Hawaii
- */
-
-#ifndef IPPTOPSPS_BATCH_H
-#define IPPTOPSPS_BATCH_H
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include <psmodules.h>
-#include <dvo_util.h>
-
-#include "FitsGenerator.h"
-#include "Fits.h"
-#include "InitData.h"
-#include "Logger.h"
-
-/**
-  Abstract base class for all batches. Known subclasses are:
-
-  - InitBatch
-  - DetectionBatch
-  - StackBatch
-
-  All subclasses need to implement the run() method and may need to implement print()
-  */
-typedef struct Batch {
-
-    // fields
-    char surveyType[10];           // the survey type, eg 3PI, MD01, STS, SSS
-    int8_t surveyID;               // survey ID
-    char fitsInPath[1000];         // path to FITS input
-    char resultsPath[1000];        // path to results file
-    xmlDocPtr resultsXmlDoc;       // pointer to XML document for results
-    uint16_t numOfInputFiles;      // number of input files
-    char** inputFiles;             // array of input file names
-    Fits *fitsOut;                 // output FITS file
-    pmConfig* pmconfig;            // pmConfig
-    dvoConfig* dvoConfig;          // dvo database
-    FitsGenerator* fitsGenerator;  // FitsGenerator object
-    InitData* initData;            // InitData object
-    char todaysDate[20];           // today's date
-    int exitCode;                  // ps exit code
-    bool testMode;                 // test mode boolean
-    Logger* logger;                // Logger object 
-
-    // methods
-    bool (*parseArguments)();
-    int (*run)();
-    void (*print)();
-    bool (*gotResultsPath)(); 
-    bool (*gotFitsInPath)();
-    bool (*gotFitsOutPath)();
-    bool (*gotConfig)();
-    bool (*gotSurveyType)(); 
-
-    // destructor
-    void (*destroy)();
-
-} Batch;
-
-// public functions
-bool new_Batch(Logger* logger, Batch *this);
-
-void ippToPsps_VersionPrint(void);
-
-bool getFlux(
-        const float exposureTime, 
-        const float magnitude, 
-        float* flux, 
-        const float magnitudeErr, 
-        float* fluxErr);
-
-# endif // IPPTOPSPS_BATCH_H 
Index: trunk/ippToPsps/src/DetectionBatch.c
===================================================================
--- trunk/ippToPsps/src/DetectionBatch.c	(revision 32007)
+++ 	(revision )
@@ -1,549 +1,0 @@
-#include "DetectionBatch.h"
-#include "DetectionBatchEnums.h"
-
-#include "Fits.h"
-
-
-/**
-  Source for all methods in the DetectionBatch class
-  */
-
-/**
-  Destructor
-  */
-static void destroy(DetectionBatch* this) {
-
-    // call superclass destructor
-    this->base.destroy(&this->base);
-    free (this->expName);
-    free (this);
-}
-
-/**
-  Writes results to XML file
-  */
-static bool writeResults(DetectionBatch* this, long minObjID, long maxObjID, long totalDetectionsOut) {
-
-    if (!this->base.resultsXmlDoc) return false;
-
-    xmlNodePtr rootNode = xmlDocGetRootElement(this->base.resultsXmlDoc);
-    char tmp[100];
-    sprintf(tmp, "%ld", minObjID);
-    xmlNewChild(rootNode, NULL, BAD_CAST "minObjID", BAD_CAST tmp);
-    sprintf(tmp, "%ld", maxObjID);
-    xmlNewChild(rootNode, NULL, BAD_CAST "maxObjID", BAD_CAST tmp);
-    sprintf(tmp, "%ld", totalDetectionsOut);
-    xmlNewChild(rootNode, NULL, BAD_CAST "totalDetections", BAD_CAST tmp);
-
-    return true;
-}
-
-/**
-  Does the work. Loops through the provided smf files, tallies the contents with the DVO database already connected to and generates a new FITS file of the fomat required by PSPS (i.e. a binary table per PSPS database table)
-  */
-static int run(DetectionBatch* this) {
-
-    if (this->base.exitCode != PS_EXIT_SUCCESS) return this->base.exitCode;
-
-    // open input FITS file
-    Fits* fitsIn = existing_Fits(this->base.inputFiles[0], this->base.logger);
-    if (fitsIn->getFilePtr(fitsIn) == NULL)  return PS_EXIT_SYS_ERROR;
-
-    // read some header values 
-    float zptObs; fitsIn->getHeaderKeyValue(fitsIn, TFLOAT, "ZPT_OBS", &zptObs);
-    float exposureTime; fitsIn->getHeaderKeyValue(fitsIn, TFLOAT, "EXPREQ", &exposureTime);
-    char filterType[20]; fitsIn->getHeaderKeyValue(fitsIn, TSTRING, "FILTERID", filterType);
-    double expStart; fitsIn->getHeaderKeyValue(fitsIn, TDOUBLE, "MJD-OBS", &expStart); 
-    double expTime; fitsIn->getHeaderKeyValue(fitsIn, TDOUBLE, "EXPTIME", &expTime);
-    double obsTime = expStart + (expTime/172800.0); // exp start plus half exp time (converted from secs to days)
-
-
-    this->base.fitsGenerator->createAndPopulateTable(this->base.fitsGenerator, fitsIn, this->base.fitsOut, 1, "FrameMeta", true);
-
-    // FrameMeta values
-    int8_t filterID = -1;
-    if (!this->base.initData->getFilterId(this->base.initData, filterType, &filterID)) {
-    
-        this->base.exitCode = PS_EXIT_DATA_ERROR;
-        return this->base.exitCode;
-    }
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, FRAMEMETA_FILTERID, 1, 1, 1, &filterID);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TLONG, FRAMEMETA_FRAMEID, 1, 1, 1, &this->expId);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TSTRING, FRAMEMETA_FRAMENAME, 1, 1, 1, &(this->expName));
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, FRAMEMETA_SURVEYID, 1, 1, 1, &this->base.surveyID);
-
-
-    int16_t cameraID = 1; // TODO
-    int16_t cameraConfigID = 1; // TODO
-    int16_t telescopeID = 1; // TODO
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TSHORT, FRAMEMETA_CAMERAID, 1, 1, 1, &cameraID);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TSHORT, FRAMEMETA_CAMERACONFIGID, 1, 1, 1, &cameraConfigID);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TSHORT, FRAMEMETA_TELESCOPEID, 1, 1, 1, &telescopeID);
-
-    // stuff to keep from psf.hdr header
-    int sourceId = -1, imageId = -1;
-    float fwhmMaj, fwhmMin, momentMaj, momentMin, psfFwhm, momentFwhm;
-    long pspsImageId = -1;
-
-    // DVO variables
-    SkyList *skylist = NULL;
-    dvoDetection *dvoDetections = NULL;
-    int maxDvoDetId = -1, numDvoDetections = -1;
-    Image *image = NULL;
-
-    // stuff for detections table
-    uint32_t s,d, invalidDvoRows, nChipDetectionsOut = 0;
-
-    char ccdNumber[3], extensionName[15];
-    // for storing FITS column data - do this once, to avoid expension free/calloc for each chip
-    long* ippIDet = (long*)calloc(this->MAXDETECT, sizeof(long));
-    float* instMag = (float*)calloc(this->MAXDETECT, sizeof(float));
-    float* instMagErr = (float*)calloc(this->MAXDETECT, sizeof(float));
-    float* peakMag = (float*)calloc(this->MAXDETECT, sizeof(float));
-    uint64_t* flags = (uint64_t*)calloc(this->MAXDETECT, sizeof(uint64_t));
-    long* objID = (long*)calloc(this->MAXDETECT, sizeof(long));
-    long* detectID = (long*)calloc(this->MAXDETECT, sizeof(long));
-    long* ippObjID = (long*)calloc(this->MAXDETECT, sizeof(long));
-    long* ippDetectID = (long*)calloc(this->MAXDETECT, sizeof(long));
-    long* imageID = (long*)calloc(this->MAXDETECT, sizeof(long));
-    double* obsTimes = (double*)calloc(this->MAXDETECT, sizeof(double));
-    float* instFlux = (float*)calloc(this->MAXDETECT, sizeof(float));
-    float* instFluxErr = (float*)calloc(this->MAXDETECT, sizeof(float));
-    float* peakFlux = (float*)calloc(this->MAXDETECT, sizeof(float));
-    int8_t* filterIDs = (int8_t*)calloc(this->MAXDETECT, sizeof(int8_t));
-    int8_t* surveyIDs = (int8_t*)calloc(this->MAXDETECT, sizeof(int8_t));
-    char** assocDate = (char**)calloc(this->MAXDETECT, sizeof(char*));
-    for (uint32_t i=0; i<this->MAXDETECT;i++) assocDate[i] = (char*)malloc(20*sizeof(char));
-
-    // some stuff is the same for all detections so we can populate here
-    for (long s = 0; s<this->MAXDETECT; s++) {
-
-        filterIDs[s] = filterID;
-        surveyIDs[s] = this->base.surveyID;
-
-        // if running in test mode, don't use today's date
-        if (this->base.testMode) strcpy(assocDate[s], "2010-01-01");
-        else strcpy(assocDate[s], this->base.todaysDate);
-    }
-
-    long maxObjID = LONG_MIN, minObjID = LONG_MAX;
-    uint64_t imageFlags;
-    short nOta = 0;
-    long i;
-    uint32_t numOfDuplicates, numInvalidFlux, numOfInvalidIppIDet;
-    long totalDetectionsOut = 0, numPhotoRef, totalNumPhotoRef = 0;
-    long* removeList = (long*)calloc(this->MAXDETECT, sizeof(long));
-    long thisObjId;
-    bool firstTimeIn = true, peakFluxOk, instFluxOk;
-    int ippIDetNum, instMagNum, instMagErrNum, peakMagNum;
-    bool error = false;
-    int startX, stopX, startY, stopY;
-
-    // in test mode, only run for chip 33
-    if (this->base.testMode) {
-
-        startX = 3;
-        stopX = 4;
-        startY = 3;
-        stopY = 4;
-    }
-    // in 'normal' mode, run for all chips
-    else {
-    
-        startX = 0;
-        stopX = 8;
-        startY = 0;
-        stopY = 8;
-    }
-
-    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch",  
-            "+-----------+---------+----------+----------------+--------------+--------------+\n");
-    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch",  
-            "| Extension | Rows in | Rows out |  Duplicate IDs | Invalid Flux | Bogus det ID |\n");
-
-    // loop round chips
-    for (int x=startX; x<stopX; x++) {
-        for (int y=startY; y<stopY; y++) {
-
-            // dodge the corners
-            if (x==0 && y==0) continue;
-            if (x==0 && y==7) continue;
-            if (x==7 && y==0) continue;
-            if (x==7 && y==7) continue;
-
-            sprintf(ccdNumber, "%d%d", x, y);
-
-            // check we CAN move to detections table in smf
-            sprintf(extensionName, "XY%s.psf", ccdNumber);
-            if (!fitsIn->moveToBinaryTable(fitsIn, extensionName)) continue;
-
-            // move to header extension
-            sprintf(extensionName, "XY%s.hdr", ccdNumber);
-            if (!fitsIn->moveToHeader(fitsIn, extensionName)) continue;
-
-            // stuff to save from psf.hdr
-            fitsIn->getHeaderKeyValue(fitsIn, TFLOAT, "FWHM_MAJ", &fwhmMaj);
-            fitsIn->getHeaderKeyValue(fitsIn, TFLOAT, "FWHM_MIN", &fwhmMin);
-            fitsIn->getHeaderKeyValue(fitsIn, TFLOAT, "IQ_FW1", &momentMaj);
-            fitsIn->getHeaderKeyValue(fitsIn, TFLOAT, "IQ_FW2", &momentMin);
-            fitsIn->getHeaderKeyValue(fitsIn, TLONG, "IMAGEID", &imageId);
-            fitsIn->getHeaderKeyValue(fitsIn, TLONG, "SOURCEID", &sourceId);
-            fitsIn->getHeaderKeyValue(fitsIn, TLONG, "NASTRO", &numPhotoRef);
-            totalNumPhotoRef += numPhotoRef; // total up for storing in FrameMeta
-
-            // access DVO database
-            skylist = dvoSkyListByExternID(this->base.dvoConfig, sourceId, imageId, &image);
-            if (skylist == NULL) {
-                this->base.logger->print(this->base.logger, MSG_ERROR, "DetectionBatch",  
-                        "DVO: can't find SkyList for sourceId='%d' imageId='%d' (CCD = XY%s): skipping this chip\n",
-                        sourceId, imageId, ccdNumber);
-                continue;
-            }
-
-            // create unique int from 'frameID' (aka exposure ID) and ccd number
-            pspsImageId = (this->expId*100) + image->ccdnum;
-
-            // now get DVO detections
-            dvoDetections = NULL;
-            numDvoDetections = dvoGetDetections(skylist, image->imageID, &dvoDetections, &maxDvoDetId);
-
-            if (numDvoDetections > this->MAXDETECT ) {
-
-                this->base.logger->print(this->base.logger, MSG_ERROR, "DetectionBatch", "Number of detections (%d) exceeds max limit (%ld)\n",
-                        numDvoDetections, this->MAXDETECT);
-                error = true;
-                break;
-            }
-
-            // create ImageMeta
-            this->base.fitsGenerator->createAndPopulateTable(this->base.fitsGenerator, fitsIn, this->base.fitsOut, 1, "ImageMeta", true);
-            psfFwhm = (fwhmMaj+fwhmMin)/2;
-            momentFwhm = (momentMaj+momentMin)/2;
-            imageFlags = (uint64_t)image->flags;
-            this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, IMAGEMETA_IMAGEID, 1, 1, 1, &pspsImageId);
-            this->base.fitsOut->writeColumn(this->base.fitsOut, TLONG, IMAGEMETA_FRAMEID, 1, 1, 1, &this->expId);
-            this->base.fitsOut->writeColumn(this->base.fitsOut, TSHORT, IMAGEMETA_CCDID, 1, 1, 1, &image->ccdnum);
-            this->base.fitsOut->writeColumn(this->base.fitsOut, TLONG, IMAGEMETA_PHOTOCALID, 1, 1, 1, &image->photcode);
-            this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, IMAGEMETA_FILTERID, 1, 1, 1, &filterID);
-            this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, IMAGEMETA_PHOTOSCAT, 1, 1, 1, &zptObs);
-            this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, IMAGEMETA_PSFFWHM, 1, 1, 1, &psfFwhm);
-            this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, IMAGEMETA_MOMENTFWHM, 1, 1, 1, &momentFwhm);
-            this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, IMAGEMETA_PHOTOZERO, 1, 1, 1, &zptObs);
-            this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, IMAGEMETA_QAFLAGS, 1, 1, 1, &imageFlags);
-
-            // now move BACK to detections table in smf
-            sprintf(extensionName, "XY%s.psf", ccdNumber);
-            long nChipDetectionsIn = 0;
-            if (!fitsIn->moveToBinaryTableAndCountRows(fitsIn, extensionName, &nChipDetectionsIn)) continue;
-
-            // keep a running count of 'images' we find in order to write total into FrameMeta at the end
-            nOta++;
-
-            // loop round detections to populate some extra stuff
-            s = d = nChipDetectionsOut = invalidDvoRows = 0;
-
-            // determine column numbers for certain IPP detection columns - do this only once to save time
-            if (firstTimeIn) {
-
-                fitsIn->getColumnNumber(fitsIn, "IPP_IDET", &ippIDetNum);
-                fitsIn->getColumnNumber(fitsIn, "PSF_INST_MAG", &instMagNum);
-                fitsIn->getColumnNumber(fitsIn, "PSF_INST_MAG_SIG", &instMagErrNum);
-                fitsIn->getColumnNumber(fitsIn, "PEAK_FLUX_AS_MAG", &peakMagNum);
-
-                firstTimeIn=false;
-            }
-
-            //anynull = 0;
-            fitsIn->readColumn(fitsIn, TLONG, ippIDetNum, 1, 1, nChipDetectionsIn, ippIDet);
-            fitsIn->readColumn(fitsIn, TFLOAT, instMagNum, 1, 1, nChipDetectionsIn, instMag);
-            fitsIn->readColumn(fitsIn, TFLOAT, instMagErrNum, 1, 1, nChipDetectionsIn, instMagErr);
-            fitsIn->readColumn(fitsIn, TFLOAT, peakMagNum, 1, 1, nChipDetectionsIn, peakMag);
-
-            // DVO detections are ordered by IPP_IDET, which increments from 0 in SMF table
-            // both DVO detections and smf detections should increment. however, there may be gaps in smf and 'invalid' rows in dvo
-            numOfDuplicates = 0;
-            numInvalidFlux = 0;
-            numOfInvalidIppIDet = 0;
-            
-            // loop through all detections in smf file extension for this chip.
-            // there are three ways for a detection to be ommitted from the final FITS output:
-            //
-            // 1. it has a duplicate obj ID to a previous detection
-            // 2. it has an invalid detection ID (< 0 or > max DVO det ID)
-            // 3. it has an invalid flux value
-            for (long s = 0; s<nChipDetectionsIn; s++) {
-
-                // catch crazy large or negative IPP_IDET, and skip them
-                if (ippIDet[s] < 0 || ippIDet[s] > maxDvoDetId) {
-
-                    removeList[numOfDuplicates+numInvalidFlux+numOfInvalidIppIDet] = s+1;
-                    numOfInvalidIppIDet++;
-                    continue;
-                }
-
-                // loop forward through DVO detections until we find corresponding detection ID
-                while (ippIDet[s] > dvoDetections[d].meas.detID && dvoDetections[d].meas.detID <= maxDvoDetId) {
-
-                    d++;
-                    if (!dvoDetections[d].valid) invalidDvoRows++;
-                }
-
-                // if we have found matching detection IDs then continue to populate other columns
-                if (ippIDet[s] == dvoDetections[d].meas.detID ) {
-
-                    // check if we have already seen this obj ID, and if we have, skip this detection
-                    thisObjId = dvoDetections[d].ave.extID;
-                    bool isDuplicate = false;
-                    for (i=0; i<s; i++) {
-                        if (thisObjId == objID[i]) {
-                            removeList[numOfDuplicates+numInvalidFlux+numOfInvalidIppIDet] = s+1;
-                            numOfDuplicates++;
-                            isDuplicate=true;
-                            break;
-                        }
-                    }
-                    if (isDuplicate) continue; 
-
-                    // populate some arrays to be shoved in table in bulk later
-                    objID[s] = thisObjId;
-                    detectID[s] = dvoDetections[d].meas.extID;
-                    ippObjID[s] = (uint64_t)dvoDetections[d].ave.catID*1000000000 + (uint64_t)dvoDetections[d].ave.objID;
-                    ippDetectID[s] = dvoDetections[d].meas.detID;
-
-                    // the 'photFlags' are the same as those in the 'FLAGS' column of the smf
-                    flags[s] = ((uint64_t)dvoDetections[d].meas.dbFlags << 32) | (uint64_t)dvoDetections[d].meas.photFlags;
-                    imageID[s] = pspsImageId;
-                    obsTimes[s] = obsTime;
-
-                    // calculate flux and flux errors from magnitudes
-                    peakFluxOk = getFlux(exposureTime, peakMag[s], &peakFlux[s], 0.0, NULL);
-                    instFluxOk = getFlux(exposureTime, instMag[s], &instFlux[s], instMagErr[s], &instFluxErr[s]);
-
-                    // check for invalid flux values, and skip them
-                    if (!peakFluxOk || !instFluxOk) {
-                        removeList[numOfDuplicates+numInvalidFlux+numOfInvalidIppIDet] = s+1;
-                        numInvalidFlux++;
-                        continue;
-                    }
-
-                    // store max/min objID
-                    if (objID[s] > maxObjID) maxObjID = objID[s];
-                    if (objID[s] < minObjID) minObjID = objID[s];
-
-                    nChipDetectionsOut++;
-                }
-            } // end of loop round detections
-
-            // write number of rows (detections) to ImageMeta
-            this->base.fitsOut->writeColumn(this->base.fitsOut, TLONG, IMAGEMETA_NDETECT, 1, 1, 1, &nChipDetectionsOut);
-
-            int totalRemove = numOfDuplicates+numInvalidFlux+numOfInvalidIppIDet;
-
-            // avoid writing out an empty table of detections
-            if (nChipDetectionsOut > 0) {
-
-                // detections
-                this->base.fitsGenerator->createAndPopulateTable(this->base.fitsGenerator, fitsIn, this->base.fitsOut, nChipDetectionsIn, "Detection", false);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, DETECTION_OBJID, 1, 1, nChipDetectionsIn, objID);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, DETECTION_DETECTID, 1, 1, nChipDetectionsIn, detectID);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, DETECTION_IPPOBJID, 1, 1, nChipDetectionsIn, ippObjID);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, DETECTION_IPPDETECTID, 1, 1, nChipDetectionsIn, ippDetectID);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, DETECTION_FILTERID, 1, 1, nChipDetectionsIn, filterIDs);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, DETECTION_SURVEYID, 1, 1, nChipDetectionsIn, surveyIDs);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, DETECTION_IMAGEID, 1, 1, nChipDetectionsIn, imageID);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TDOUBLE, DETECTION_OBSTIME, 1, 1, nChipDetectionsIn, obsTimes);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, DETECTION_INSTFLUX, 1, 1, nChipDetectionsIn, instFlux);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, DETECTION_INSTFLUXERR, 1, 1, nChipDetectionsIn, instFluxErr);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, DETECTION_PEAKADU, 1, 1, nChipDetectionsIn, peakFlux);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TSTRING, DETECTION_ASSOCDATE, 1, 1, nChipDetectionsIn, assocDate);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, DETECTION_INFOFLAG, 1, 1, nChipDetectionsIn, flags);
-                if (numOfDuplicates||numInvalidFlux||numOfInvalidIppIDet) this->base.fitsOut->deleteRows(this->base.fitsOut, removeList, totalRemove); 
-
-                // skinny object
-                this->base.fitsGenerator->createAndPopulateTable(this->base.fitsGenerator, fitsIn, this->base.fitsOut, nChipDetectionsIn, "SkinnyObject", false);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, SKINNYOBJECT_OBJID, 1, 1, nChipDetectionsIn, objID);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, SKINNYOBJECT_IPPOBJID, 1, 1, nChipDetectionsIn, ippObjID);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, SKINNYOBJECT_SURVEYID, 1, 1, nChipDetectionsIn, surveyIDs);
-                if (numOfDuplicates||numInvalidFlux||numOfInvalidIppIDet) this->base.fitsOut->deleteRows(this->base.fitsOut, removeList, totalRemove);
-
-                // object calibration color
-                this->base.fitsGenerator->createAndPopulateTable(this->base.fitsGenerator, fitsIn, this->base.fitsOut, nChipDetectionsIn, "ObjectCalColor", false);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, OBJECTCALCOLOR_OBJID, 1, 1, nChipDetectionsIn, objID);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, OBJECTCALCOLOR_IPPOBJID, 1, 1, nChipDetectionsIn, ippObjID);
-                this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, OBJECTCALCOLOR_FILTERID, 1, 1, nChipDetectionsIn, filterIDs);
-                if (numOfDuplicates||numInvalidFlux||numOfInvalidIppIDet) this->base.fitsOut->deleteRows(this->base.fitsOut, removeList, totalRemove);
-            }
-
-            this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch",
-                    "|  %s |  %5ld  |   %5d  |     %5d      |    %5d     |    %5d     |\n",
-                    extensionName, nChipDetectionsIn, nChipDetectionsOut, numOfDuplicates, numInvalidFlux, numOfInvalidIppIDet);
-
-            totalDetectionsOut += nChipDetectionsOut;
-
-            if (dvoDetections!= NULL) dvoFree(dvoDetections);
-            SkyListFree(skylist);
-        }
-
-        if (error) break;
-    }
-
-    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch",  
-            "+-----------+---------+----------+----------------+--------------+--------------+\n");
-
-    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", "Total detections for this exposure = %ld\n", totalDetectionsOut);
-
-    // free-up memory
-    free(ippIDet);
-    free(instMag);
-    free(instMagErr);
-    free(peakMag);
-    free(flags);
-    free(objID);
-    free(detectID);
-    free(ippObjID);
-    free(ippDetectID);
-    free(imageID);
-    free(obsTimes);
-    free(instFlux);
-    free(instFluxErr);
-    free(peakFlux);
-    free(filterIDs);
-    free(surveyIDs);
-    free(removeList);
-    for (uint32_t i=0; i<this->MAXDETECT;i++) free(assocDate[i]);
-    free(assocDate);
-
-    // write number of images we have found into FrameMeta table
-    if (this->base.fitsOut->moveToBinaryTable(this->base.fitsOut, "FrameMeta")) {
-
-        this->base.fitsOut->writeColumn(this->base.fitsOut, TSHORT, FRAMEMETA_NOTA, 1, 1, 1, &nOta);
-        this->base.fitsOut->writeColumn(this->base.fitsOut, TSHORT, FRAMEMETA_NUMPHOTOREF, 1, 1, 1, &totalNumPhotoRef);
-    }
-
-    fitsIn->destroy(fitsIn);
-
-    writeResults(this, minObjID, maxObjID, totalDetectionsOut);
-
-    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", "Data written for a total of %d chips/OTAs\n", nOta);
-
-    if (error || nOta < 1) this->base.exitCode = PS_EXIT_DATA_ERROR;
-    else this->base.exitCode = PS_EXIT_SUCCESS;
-
-    return this->base.exitCode;
-}
-
-/**
-  Print-out this class. Calls base-calls print method first.
-  */
-static void print(DetectionBatch* this) {
-
-    this->base.print(&this->base);
-
-    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", "exp ID          : %d\n", this->expId);
-    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", "exp name        : %s\n",  this->expName ? this->expName : "undef");
-    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", "\n");
-}
-
-/**
-  Reads command-line arguments.  Calls base-calls print method first.
-  */
-static bool parseArguments(DetectionBatch* this, int argc, char **argv) {
-
-    bool haveExpId = false;
-    bool haveExpName = false;
-
-    int32_t optind = 1;
-    while( ( optind < argc ) ) {
-
-        char * sw = argv[optind];
-
-        if( argv[optind][0] == '-' ) { 
-
-            if(strcmp(sw, "-expid") == 0 ) {
-                optind++; if( optind > ( argc-1 ) ) break;
-                this->expId = atoi(argv[optind]);
-                haveExpId = true;
-            }
-            else if(strcmp(sw, "-expname") == 0 ) {
-                optind++; if( optind > ( argc-1 ) ) break;
-                strcpy(this->expName, argv[optind]);
-                haveExpName = true;
-            }
-        }
-        optind++;
-    }
-
-    char fitsOutFile[40];
-    sprintf(fitsOutFile, "%08d.FITS", this->expId);
-    this->base.parseArguments(&this->base, argc, argv, "/detection", fitsOutFile);
-
-    if (
-            !this->base.gotResultsPath() ||
-            !this->base.gotFitsInPath() ||
-            !this->base.gotFitsOutPath() ||
-            !this->base.gotConfig() ||
-            !this->base.gotSurveyType() ||
-            !haveExpId || 
-            !haveExpName) {
-
-        this->base.logger->print(this->base.logger, MSG_ERROR, "DetectionBatch", "Problem with supplied arguments\n");
-        this->print(this);
-        this->base.exitCode = PS_EXIT_CONFIG_ERROR;
-        return false;
-    }
-
-    return true;
-}
-
-/**
-  Constructor. Returns a new DetectionBatch object.
-  */
-DetectionBatch* new_DetectionBatch(Logger* logger, int *argc, char **argv) {
-
-    logger->print(logger, MSG_DEBUG, "DetectionBatch", "Constructor\n");
-    DetectionBatch *this = (DetectionBatch*)calloc(1, sizeof(DetectionBatch));
-
-    // call base-class constructor
-    new_Batch(logger, &this->base);
-
-    this->MAXDETECT = 200000;
-
-    // method pointers
-    this->print = print;
-    this->destroy = destroy;
-    this->base.run = run;
-
-    this->expName = (char*)calloc(100, sizeof(char));
-
-    parseArguments(this, *argc, argv);
-
-    this->print(this);
-
-    return this;
-}
-
-/**
-  Main
-  */
-int main(int argc, char **argv) {
-
-//    ippToPsps_VersionPrint();
-
-    Logger* logger = new_Logger(NULL, false);
-//    Logger* logger = new_Logger("./detBatchLog.txt", false);
-    logger->print(logger, MSG_INFO, "main", "Creating new detection batch\n");
-
-    DetectionBatch* detectionBatch = new_DetectionBatch(logger, &argc, argv);
-    detectionBatch->base.run(detectionBatch);
-    int exitCode = detectionBatch->base.exitCode;
-
-    detectionBatch->destroy(detectionBatch);
-
-    // tidy up
-    psLibFinalize();
-    logger->destroy(logger);
-
-    return exitCode;
-}
-
-
Index: trunk/ippToPsps/src/DetectionBatch.h
===================================================================
--- trunk/ippToPsps/src/DetectionBatch.h	(revision 32007)
+++ 	(revision )
@@ -1,35 +1,0 @@
-/** @file DetectionBatch.h
- *
- *  @brief DetectionBatch
- *
- *  @ingroup ippToPsps
- *
- *  @author IfA
- *  Copyright 2009 Institute for Astronomy, University of Hawaii
- */
-
-#ifndef IPPTOPSPS_DETECTIONBATCH_H
-#define IPPTOPSPS_DETECTIONBATCH_H
-
-#include "Batch.h"
-
-/**
-  Sub-class of Batch for detections
-  */
-typedef struct DetectionBatch {
-
-    // fields
-    Batch base;          // base class
-    size_t MAXDETECT;    // max number of detections per chip
-    uint32_t expId;      // exposure ID
-    char* expName;       // the exposure name
-
-    // methods
-    void (*print)();
-    void (*destroy)();
-
-} DetectionBatch;
-
-DetectionBatch *new_DetectionBatch(Logger* logger, int *argc, char **argv);
-
-# endif // IPPTOPSPS_DETECTIONBATCH_H 
Index: trunk/ippToPsps/src/DetectionBatchEnums.h
===================================================================
--- trunk/ippToPsps/src/DetectionBatchEnums.h	(revision 32007)
+++ 	(revision )
@@ -1,187 +1,0 @@
-#ifndef DETECTIONBATCHENUMS_H
-#define DETECTIONBATCHENUMS_H
-
-
-typedef enum {
-  FRAMEMETA_FRAMEID = 1,
-  FRAMEMETA_FRAMENAME = 2,
-  FRAMEMETA_SURVEYID = 3,
-  FRAMEMETA_FILTERID = 4,
-  FRAMEMETA_CAMERAID = 5,
-  FRAMEMETA_CAMERACONFIGID = 6,
-  FRAMEMETA_TELESCOPEID = 7,
-  FRAMEMETA_ANALYSISVER = 8,
-  FRAMEMETA_P1RECIP = 9,
-  FRAMEMETA_P2RECIP = 10,
-  FRAMEMETA_P3RECIP = 11,
-  FRAMEMETA_NOTA = 12,
-  FRAMEMETA_PHOTOSCAT = 13,
-  FRAMEMETA_NUMPHOTOREF = 14,
-  FRAMEMETA_EXPSTART = 15,
-  FRAMEMETA_EXPTIME = 16,
-  FRAMEMETA_AIRMASS = 17,
-  FRAMEMETA_RABORE = 18,
-  FRAMEMETA_DECBORE = 19,
-  FRAMEMETA_CTYPE1 = 20,
-  FRAMEMETA_CTYPE2 = 21,
-  FRAMEMETA_CRVAL1 = 22,
-  FRAMEMETA_CRVAL2 = 23,
-  FRAMEMETA_CRPIX1 = 24,
-  FRAMEMETA_CRPIX2 = 25,
-  FRAMEMETA_CDELT1 = 26,
-  FRAMEMETA_CDELT2 = 27,
-  FRAMEMETA_PC001001 = 28,
-  FRAMEMETA_PC001002 = 29,
-  FRAMEMETA_PC002001 = 30,
-  FRAMEMETA_PC002002 = 31,
-  FRAMEMETA_POLYORDER = 32,
-  FRAMEMETA_PCA1X3Y0 = 33,
-  FRAMEMETA_PCA1X2Y1 = 34,
-  FRAMEMETA_PCA1X1Y2 = 35,
-  FRAMEMETA_PCA1X0Y3 = 36,
-  FRAMEMETA_PCA1X2Y0 = 37,
-  FRAMEMETA_PCA1X1Y1 = 38,
-  FRAMEMETA_PCA1X0Y2 = 39,
-  FRAMEMETA_PCA2X3Y0 = 40,
-  FRAMEMETA_PCA2X2Y1 = 41,
-  FRAMEMETA_PCA2X1Y2 = 42,
-  FRAMEMETA_PCA2X0Y3 = 43,
-  FRAMEMETA_PCA2X2Y0 = 44,
-  FRAMEMETA_PCA2X1Y1 = 45,
-  FRAMEMETA_PCA2X0Y2 = 46,
-  FRAMEMETA_CALIBMODNUM = 47,
-  FRAMEMETA_DATARELEASE = 48,
-} FrameMeta;
-
-typedef enum {
-  IMAGEMETA_IMAGEID = 1,
-  IMAGEMETA_FRAMEID = 2,
-  IMAGEMETA_CCDID = 3,
-  IMAGEMETA_PHOTOCALID = 4,
-  IMAGEMETA_FILTERID = 5,
-  IMAGEMETA_BIAS = 6,
-  IMAGEMETA_BIASSCAT = 7,
-  IMAGEMETA_SKY = 8,
-  IMAGEMETA_SKYSCAT = 9,
-  IMAGEMETA_NDETECT = 10,
-  IMAGEMETA_MAGSAT = 11,
-  IMAGEMETA_COMPLETMAG = 12,
-  IMAGEMETA_ASTROSCAT = 13,
-  IMAGEMETA_PHOTOSCAT = 14,
-  IMAGEMETA_NUMASTROREF = 15,
-  IMAGEMETA_NUMPHOTOREF = 16,
-  IMAGEMETA_NX = 17,
-  IMAGEMETA_NY = 18,
-  IMAGEMETA_PSFMODELID = 19,
-  IMAGEMETA_PSFFWHM = 20,
-  IMAGEMETA_PSFWIDMAJOR = 21,
-  IMAGEMETA_PSFWIDMINOR = 22,
-  IMAGEMETA_PSFTHETA = 23,
-  IMAGEMETA_MOMENTFWHM = 24,
-  IMAGEMETA_MOMENTWIDMAJOR = 25,
-  IMAGEMETA_MOMENTWIDMINOR = 26,
-  IMAGEMETA_APRESID = 27,
-  IMAGEMETA_DAPRESID = 28,
-  IMAGEMETA_DETECTORID = 29,
-  IMAGEMETA_QAFLAGS = 30,
-  IMAGEMETA_DETREND1 = 31,
-  IMAGEMETA_DETREND2 = 32,
-  IMAGEMETA_DETREND3 = 33,
-  IMAGEMETA_DETREND4 = 34,
-  IMAGEMETA_DETREND5 = 35,
-  IMAGEMETA_DETREND6 = 36,
-  IMAGEMETA_DETREND7 = 37,
-  IMAGEMETA_DETREND8 = 38,
-  IMAGEMETA_PHOTOZERO = 39,
-  IMAGEMETA_CTYPE1 = 40,
-  IMAGEMETA_CTYPE2 = 41,
-  IMAGEMETA_CRVAL1 = 42,
-  IMAGEMETA_CRVAL2 = 43,
-  IMAGEMETA_CRPIX1 = 44,
-  IMAGEMETA_CRPIX2 = 45,
-  IMAGEMETA_CDELT1 = 46,
-  IMAGEMETA_CDELT2 = 47,
-  IMAGEMETA_PC001001 = 48,
-  IMAGEMETA_PC001002 = 49,
-  IMAGEMETA_PC002001 = 50,
-  IMAGEMETA_PC002002 = 51,
-  IMAGEMETA_POLYORDER = 52,
-  IMAGEMETA_PCA1X3Y0 = 53,
-  IMAGEMETA_PCA1X2Y1 = 54,
-  IMAGEMETA_PCA1X1Y2 = 55,
-  IMAGEMETA_PCA1X0Y3 = 56,
-  IMAGEMETA_PCA1X2Y0 = 57,
-  IMAGEMETA_PCA1X1Y1 = 58,
-  IMAGEMETA_PCA1X0Y2 = 59,
-  IMAGEMETA_PCA2X3Y0 = 60,
-  IMAGEMETA_PCA2X2Y1 = 61,
-  IMAGEMETA_PCA2X1Y2 = 62,
-  IMAGEMETA_PCA2X0Y3 = 63,
-  IMAGEMETA_PCA2X2Y0 = 64,
-  IMAGEMETA_PCA2X1Y1 = 65,
-  IMAGEMETA_PCA2X0Y2 = 66,
-  IMAGEMETA_CALIBMODNUM = 67,
-  IMAGEMETA_DATARELEASE = 68,
-} ImageMeta;
-
-typedef enum {
-  DETECTION_OBJID = 1,
-  DETECTION_DETECTID = 2,
-  DETECTION_IPPOBJID = 3,
-  DETECTION_IPPDETECTID = 4,
-  DETECTION_FILTERID = 5,
-  DETECTION_SURVEYID = 6,
-  DETECTION_IMAGEID = 7,
-  DETECTION_OBSTIME = 8,
-  DETECTION_XPOS = 9,
-  DETECTION_YPOS = 10,
-  DETECTION_XPOSERR = 11,
-  DETECTION_YPOSERR = 12,
-  DETECTION_INSTFLUX = 13,
-  DETECTION_INSTFLUXERR = 14,
-  DETECTION_PEAKADU = 15,
-  DETECTION_PSFWIDMAJOR = 16,
-  DETECTION_PSFWIDMINOR = 17,
-  DETECTION_PSFTHETA = 18,
-  DETECTION_PSFLIKELIHOOD = 19,
-  DETECTION_PSFCF = 20,
-  DETECTION_MOMENTXX = 21,
-  DETECTION_MOMENTXY = 22,
-  DETECTION_MOMENTYY = 23,
-  DETECTION_APMAG = 24,
-  DETECTION_APMAGERR = 25,
-  DETECTION_KRONFLUX = 26,
-  DETECTION_KRONFLUXERR = 27,
-  DETECTION_KRONRAD = 28,
-  DETECTION_KRONRADERR = 29,
-  DETECTION_CRLIKELIHOOD = 30,
-  DETECTION_EXTENDEDLIKELIHOOD = 31,
-  DETECTION_INFOFLAG = 32,
-  DETECTION_SKY = 33,
-  DETECTION_SKYERR = 34,
-  DETECTION_SGSEP = 35,
-  DETECTION_ACTIVEFLAG = 36,
-  DETECTION_ASSOCDATE = 37,
-  DETECTION_HISTORYMODNUM = 38,
-  DETECTION_DATARELEASE = 39,
-} Detection;
-
-typedef enum {
-  SKINNYOBJECT_OBJID = 1,
-  SKINNYOBJECT_IPPOBJID = 2,
-  SKINNYOBJECT_PROJECTIONCELLID = 3,
-  SKINNYOBJECT_DATARELEASE = 4,
-  SKINNYOBJECT_SURVEYID = 5,
-} SkinnyObject;
-
-typedef enum {
-  OBJECTCALCOLOR_OBJID = 1,
-  OBJECTCALCOLOR_IPPOBJID = 2,
-  OBJECTCALCOLOR_FILTERID = 3,
-  OBJECTCALCOLOR_CALCOLOR = 4,
-  OBJECTCALCOLOR_CALCOLORERR = 5,
-  OBJECTCALCOLOR_CALIBMODNUM = 6,
-  OBJECTCALCOLOR_DATARELEASE = 7,
-} ObjectCalColor;
-
-#endif
Index: trunk/ippToPsps/src/DiffBatchEnums.h
===================================================================
--- trunk/ippToPsps/src/DiffBatchEnums.h	(revision 32007)
+++ 	(revision )
@@ -1,99 +1,0 @@
-#ifndef DIFFBATCHENUMS_H
-#define DIFFBATCHENUMS_H
-
-
-typedef enum {
-  STACKMETA_STACKMETAID = 1,
-  STACKMETA_SKYCELLID = 2,
-  STACKMETA_SURVEYID = 3,
-  STACKMETA_PHOTOCALID = 4,
-  STACKMETA_FILTERID = 5,
-  STACKMETA_STACKTYPEID = 6,
-  STACKMETA_STACKGROUPID = 7,
-  STACKMETA_MAGSAT = 8,
-  STACKMETA_ANALVER = 9,
-  STACKMETA_NP2IMAGES = 10,
-  STACKMETA_COMPLETMAG = 11,
-  STACKMETA_ASTROSCAT = 12,
-  STACKMETA_PHOTOSCAT = 13,
-  STACKMETA_NASTROREF = 14,
-  STACKMETA_NPHOREF = 15,
-  STACKMETA_MEAN = 16,
-  STACKMETA_MAX = 17,
-  STACKMETA_PHOTOZERO = 18,
-  STACKMETA_PHOTOCOLOR = 19,
-  STACKMETA_CTYPE1 = 20,
-  STACKMETA_CTYPE2 = 21,
-  STACKMETA_CRVAL1 = 22,
-  STACKMETA_CRVAL2 = 23,
-  STACKMETA_CRPIX1 = 24,
-  STACKMETA_CRPIX2 = 25,
-  STACKMETA_CDELT1 = 26,
-  STACKMETA_CDELT2 = 27,
-  STACKMETA_PC001001 = 28,
-  STACKMETA_PC001002 = 29,
-  STACKMETA_PC002001 = 30,
-  STACKMETA_PC002002 = 31,
-  STACKMETA_CALIBMODNUM = 32,
-  STACKMETA_DATARELEASE = 33,
-} StackMeta;
-
-typedef enum {
-  STACKTOIMAGE_STACKMETAID = 1,
-  STACKTOIMAGE_IMAGEID = 2,
-} StackToImage;
-
-typedef enum {
-  STACKLOWSIGDELTA_STACKMETAID = 1,
-  STACKLOWSIGDELTA_DATATABLE = 2,
-  STACKLOWSIGDELTA_DATARELEASE = 3,
-} StackLowSigDelta;
-
-typedef enum {
-  STACKHIGHSIGDELTA_PARTITIONKEY = 1,
-  STACKHIGHSIGDELTA_STACKDIFFID = 2,
-  STACKHIGHSIGDELTA_IPPDETECTID = 3,
-  STACKHIGHSIGDELTA_FILTERID = 4,
-  STACKHIGHSIGDELTA_OBSTIME = 5,
-  STACKHIGHSIGDELTA_XPOS = 6,
-  STACKHIGHSIGDELTA_YPOS = 7,
-  STACKHIGHSIGDELTA_XPOSERR = 8,
-  STACKHIGHSIGDELTA_YPOSERR = 9,
-  STACKHIGHSIGDELTA_INSTMAG = 10,
-  STACKHIGHSIGDELTA_INSTMAGERR = 11,
-  STACKHIGHSIGDELTA_PEAKFLUXMAG = 12,
-  STACKHIGHSIGDELTA_PSFWIDMAJOR = 13,
-  STACKHIGHSIGDELTA_PSFWIDMINOR = 14,
-  STACKHIGHSIGDELTA_PSFTHETA = 15,
-  STACKHIGHSIGDELTA_PSFLIKELIHOOD = 16,
-  STACKHIGHSIGDELTA_PSFCF = 17,
-  STACKHIGHSIGDELTA_INFOFLAG = 18,
-  STACKHIGHSIGDELTA_NFRAMES = 19,
-  STACKHIGHSIGDELTA_HTMID = 20,
-  STACKHIGHSIGDELTA_ZONEID = 21,
-  STACKHIGHSIGDELTA_RA = 22,
-  STACKHIGHSIGDELTA_DEC = 23,
-  STACKHIGHSIGDELTA_RAERR = 24,
-  STACKHIGHSIGDELTA_DECERR = 25,
-  STACKHIGHSIGDELTA_CX = 26,
-  STACKHIGHSIGDELTA_CY = 27,
-  STACKHIGHSIGDELTA_CZ = 28,
-  STACKHIGHSIGDELTA_CALMAG = 29,
-  STACKHIGHSIGDELTA_CALMAGERR = 30,
-  STACKHIGHSIGDELTA_SKY = 31,
-  STACKHIGHSIGDELTA_SKYERR = 32,
-  STACKHIGHSIGDELTA_SGSEP = 33,
-  STACKHIGHSIGDELTA_DATARELEASE = 34,
-} StackHighSigDelta;
-
-typedef enum {
-  OBJECTCALCOLOR_OBJID = 1,
-  OBJECTCALCOLOR_IPPOBJID = 2,
-  OBJECTCALCOLOR_FILTERID = 3,
-  OBJECTCALCOLOR_CALCOLOR = 4,
-  OBJECTCALCOLOR_CALCOLORERR = 5,
-  OBJECTCALCOLOR_CALIBMODNUM = 6,
-  OBJECTCALCOLOR_DATARELEASE = 7,
-} ObjectCalColor;
-
-#endif
Index: trunk/ippToPsps/src/DifferenceBatch.c
===================================================================
--- trunk/ippToPsps/src/DifferenceBatch.c	(revision 32007)
+++ 	(revision )
@@ -1,119 +1,0 @@
-/** @file ippToPspsBatchDifference.c
- *
- *  @ingroup ippToPsps
- *
- *  @author IfA
- *  Copyright 2009 Institute for Astronomy, University of Hawaii
- */
-
-#include "ippToPsps.h"
-#include "Config.h"
-#include "ippToPspsDiffEnums.h"
-
-/**
-  \brief Loops round all the diff cmf files (one per skycell) and generates one FITS  
-  */
-int ippToPsps_batchDifference(IppToPsps *this) {
-
-    if (this->numOfInputFiles < 1) return PS_EXIT_DATA_ERROR;
-
-    uint32_t skycell = 0; // TODO
-    long tableSize;
-    float SIG_CONST = 5.0; // TODO
-    double obsTime;
-    float obsTimes[MAXDETECT];
-
-    char skycellStr[10];
-    char extensionName[20];
-    sprintf(extensionName, "SkyChip.psf");
-
-    int status;
-    fitsfile *fitsIn;         
-    int nKeys;
-    status=0;
-
-    float psfSigma[MAXDETECT];
-    long numLowSig = 0;
-    long numHighSig = 0;
-    long highSig[MAXDETECT];
-    long lowSig[MAXDETECT];
-    int anynull = 0;
-    float floatnull = -999.0;
-
-    for (uint16_t i = 0; i<this->numOfInputFiles; i++) {
-
-        if (fits_open_file(&fitsIn, this->inputFiles[i], READONLY, &status)) {
-
-            psError(PS_ERR_IO, false, "Unable to open file: '%s'", this->inputFiles[i]);
-            break; 
-        }
-
-        //psLogMsg("ippToPsps", PS_LOG_INFO,"Opened %s", this->inputFiles[i]);
-
-        skycell = i; // TODO
-        sprintf(skycellStr, "SC%03d", skycell);
-
-        // build StackMeta from primary header
-        fits_get_hdrspace(fitsIn, &nKeys, NULL, &status);
-        ippToPspsConfig_writeTable(this->config, fitsIn,  this->fitsOut, 1, "StackMeta", true);
-        fits_write_col(this->fitsOut, TLONG, STACKMETA_SKYCELLID, 1, 1, 1, &skycell, &status);
-
-        // build StackToImage
-        ippToPspsConfig_writeTable(this->config, fitsIn,  this->fitsOut, 1, "StackToImage", true);
-        //  psMetadataAdd(headerOut, PS_LIST_TAIL, "SKYCELL_ID", PS_DATA_S32, "Skycell ID", skycell);
-
-        // save some stuff for later
-        status=0; fits_read_key(fitsIn, TDOUBLE, "MJD-OBS", &obsTime, NULL, &status);
-
-        if (fits_movnam_hdu(fitsIn, BINARY_TBL, extensionName, 0, &status)) {
-            psError(PS_ERR_IO, false, "Can't move to extension: %s skipping\n", extensionName);
-            continue;
-        }
-        if (fits_get_num_rows(fitsIn, &tableSize, &status)) {
-            psError(PS_ERR_IO, false, "Can't count rows in extension: %s skipping\n", extensionName);
-            continue;
-        }
-
-        numLowSig = numHighSig = 0;
-
-        //  get magnitude error (PSF_INST_MAG_SIG)
-        fits_read_col(fitsIn, TFLOAT, 9, 1, 1, tableSize, &floatnull, psfSigma, &anynull, &status);
-
-        for (long j = 0; j<tableSize; j++) {
-
-            obsTimes[j] = obsTime;
-
-            // split between low and high 'significance difference detections'
-            if (psfSigma[j] > (1.0/SIG_CONST)) {
-
-                //     psMetadataAdd(rowOut, 0, "stackMetaID", PS_DATA_S64, "reference to stack", 0); // TODO
-                lowSig[numLowSig] = j+1;
-                numLowSig++;
-            }
-            else {
-
-                highSig[numHighSig] = j+1;
-                numHighSig++;
-            }
-        }
-
-        psLogMsg("ippToPsps", PS_LOG_INFO, 
-                "Reading skycell '%d'. High significant detections = %ld low significant detections = %ld", 
-                skycell, numHighSig, numLowSig);
-
-        //  psMetadataAdd(headerOut, PS_LIST_TAIL, "SKYCELL_ID", PS_DATA_S32, "Skycell ID", skycell);
-
-        // write out low and high significant tables
-        ippToPspsConfig_writeTable(this->config, fitsIn, this->fitsOut, 1, "StackLowSigDelta", false);
-        ippToPspsConfig_writeTable(this->config, fitsIn, this->fitsOut, tableSize, "StackHighSigDelta", false);
-        fits_write_col(this->fitsOut, TFLOAT, STACKHIGHSIGDELTA_OBSTIME, 1, 1, tableSize, obsTimes, &status);
-        if (numLowSig) fits_delete_rowlist(this->fitsOut, lowSig, numLowSig, &status);
-
-
-        //   psMetadataAdd(headerOut, PS_LIST_TAIL, "SKYCELL_ID", PS_DATA_S32, "Skycell ID", skycell);
-
-        if (fits_close_file(fitsIn, &status)) fits_report_error(stderr, status);
-    }
-
-    return PS_EXIT_SUCCESS;
-}
Index: trunk/ippToPsps/src/Fits.c
===================================================================
--- trunk/ippToPsps/src/Fits.c	(revision 32007)
+++ 	(revision )
@@ -1,455 +1,0 @@
-/** @file Fits.c
- *
- *  @ingroup ippToPsps
- *
- *  Source for all methods in the Fits class
- *
- *  @author IfA
- *  Copyright 2011 Institute for Astronomy, University of Hawaii
- */
-
-#include "Fits.h"
-
-/**
-  Non-class method
-
-  Gets cfitsio type from string
-  */
-int Fits_getDataType(char *typename) {
-
-    if (!strncmp(typename, "TBYTE", 5))  return TBYTE;
-    if (!strncmp(typename, "TSHORT", 6)) return TSHORT;
-    if (!strncmp(typename, "TLONGLONG", 9)) return TLONGLONG;
-    if (!strncmp(typename, "TLONG", 5)) return TLONG;
-    if (!strncmp(typename, "TFLOAT", 6)) return TFLOAT;
-    if (!strncmp(typename, "TDOUBLE", 7)) return TDOUBLE;
-    if (!strncmp(typename, "TSTRING", 7)) return TSTRING;
-
-//    this->logger->print(this->logger, MSG_ERROR, "Fits", "Don't understand data type '%s'", typename);
-
-    return 0;
-}
-
-/**
-  Destructor
-  */
-static void destroy(Fits* this) {
-
-    this->logger->print(this->logger, MSG_DEBUG, "Fits", "Destructor\n");
-
-    // if there is a file to close, then close it
-    if (this->file != NULL) {
-
-        int status = 0;
-
-        if (fits_close_file(this->file, &status)) {
-
-            this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to close FITS file '%s'\n", this->path);
-            fits_report_error(stderr, status);
-        }
-        else 
-            this->logger->print(this->logger, MSG_INFO, "Fits", "Closed FITS file '%s'\n", this->path);
-    }
-
-    free(this);
-}
-
-/**
-  Gets a header key value
-  */
-static bool getHeaderKeyValue(Fits* this, int type, char* name, void* value) {
-
-    int status = 0;
-    fits_read_key(this->file, type, name, value, NULL, &status);
-
-    if (status) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Could not get value for header key '%s' from file at '%s'\n", name, this->path);
-        return false;
-    }
-
-    return true;
-}
-
-/*
-   Gets the contents of a column vector
-   */
-static bool getColumnVector(
-        Fits* this,
-        int col,
-        long row,
-        int type,
-        int repeat,
-        float* vector) {
-
-    int status = 0;
-    int anynull = 0;
-
-    // remember to add 1 to row number since cfitsio is the stupidest libary ever written
-    fits_read_col(this->file, type, col, row+1, 1, repeat, NULL, vector, &anynull, &status);
-
-    if (status) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Failed to read vector column %d row %ld\n", col, row);
-        return false;
-    }
-
-    return true;
-}
-
-/**
-  Gets the column number for the provided column name
-  */
-static bool getColumnNumber(Fits* this, char* name, int* number) {
-
-    int status = 0;
-    fits_get_colnum(this->file, CASESEN, name, number, &status);
-    if (status) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Could not get column number for '%s'\n", name);
-        return false;
-    }
-
-    return true;
-}
-
-/*
-   Gets metadata about a column 
-   */
-bool getColumnMeta(
-        Fits* this,
-        char* name,
-        int* colNum,
-        int* type,
-        long* repeat) {
-
-    int status = 0;
-    fits_get_colnum(this->file, CASESEN, name, colNum, &status);
-    if (status) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to read col '%s'\n", name);
-        return false;
-    }
-
-    status = 0;
-    fits_get_eqcoltype(this->file, *colNum, type, repeat, NULL, &status);
-    if (status) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to read type info for '%s'\n", name);
-        return false;
-    }
-
-    return true;
-}
-
-
-/**
-  Moves to a certain extension of provided name and type
-  */
-bool moveToExtension(Fits* this, char* name, int type) {
-
-    int status = 0;
-    if (fits_movnam_hdu(this->file, type, name, 0, &status)) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Can't move to table extension named '%s'\n", name);
-        return false;
-    }
-
-    return true;
-}
-
-/**
-  Moves to a certain header extension
-  */
-static bool moveToHeader(Fits* this, char* name) {
-
-    return moveToExtension(this, name, IMAGE_HDU);
-}
-
-/**
-  Moves to a certain binary table extension
-  */
-static bool moveToBinaryTable(Fits* this, char* name) {
-
-    return moveToExtension(this, name, BINARY_TBL);
-}
-
-/**
-  Counts the rows in the current table extension
-  */
-static bool countRows(Fits* this, long* count) {
-
-    int status = 0;
-    if (fits_get_num_rows(this->file, count, &status)) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Count not count rows in this table\n");
-        return false;
-    }
-
-    return true;
-}
-
-/**
-  Moves to a certain binary table extension and counts rows within
-  */
-static bool moveToBinaryTableAndCountRows(Fits* this, char* name, long* count) {
-
-    if (!moveToExtension(this, name, BINARY_TBL)) return false;
-    return countRows(this, count);
-}
-
-/**
-  Deletes this file.
-  */
-static bool delete(Fits* this) {
-
-    if (remove(this->path) == -1) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to delete '%s'\n", this->path);
-        return false;
-    }
-
-    this->logger->print(this->logger, MSG_INFO, "Fits", "Deleted FITS file at '%s'\n", this->path);
-
-    return true;
-}
-
-/**
-  Returns the file path.
-  */
-static char* getPath(Fits* this) {
-
-    return this->path;
-}
-
-/**
-  Returns the file pointer.
-  */
-static fitsfile* getFilePtr(Fits* this) {
-
-    return this->file;
-}
-
-/**
-  Deletes a bunch of rows from the current binary table
-  */
-static bool deleteRows(Fits* this, long *rowlist, long nrows) {
-
-    int status = 0;
-    fits_delete_rowlist(this->file, rowlist, nrows, &status);
-    if (status) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to delete rows using rowlist\n");
-        return false;
-    }
-
-    return true;
-}
-
-/**
-  Reads a column from the current binary table
-  */
-static bool readColumn(
-        Fits* this, 
-        int datatype, 
-        int colnum, 
-        LONGLONG firstrow, 
-        LONGLONG firstelem,
-        LONGLONG nelements, 
-        void* coldata)  {
-
-    int anynull = 0;
-    int status = 0;
-
-    if (datatype == TBYTE) {
-
-        int8_t nullval = -99;
-        fits_read_col(this->file, datatype, colnum, firstrow, firstelem, nelements, &nullval, coldata, &anynull, &status);
-    }
-    else if (datatype == TSHORT) {
-
-        int16_t nullval = -999;
-        fits_read_col(this->file, datatype, colnum, firstrow, firstelem, nelements, &nullval, coldata, &anynull, &status);
-    }
-    else if (datatype == TLONG || datatype == TLONGLONG) {
-
-        long nullval = -999;
-        fits_read_col(this->file, datatype, colnum, firstrow, firstelem, nelements, &nullval, coldata, &anynull, &status);
-    }
-    else if (datatype == TFLOAT) {
-
-        float nullval = -999.0;
-        fits_read_col(this->file, datatype, colnum, firstrow, firstelem, nelements, &nullval, coldata, &anynull, &status);
-    }
-    else if (datatype == TDOUBLE) {
-
-        double nullval = -999.0;
-        fits_read_col(this->file, datatype, colnum, firstrow, firstelem, nelements, &nullval, coldata, &anynull, &status);
-    }
-    else if (datatype == TSTRING) {
-
-        char nullval[20];
-        strcpy(nullval, "null");
-        fits_read_col(this->file, datatype, colnum, firstrow, firstelem, nelements, &nullval, coldata, &anynull, &status);
-    }
-    else {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Don't understand datatype '%d'\n", datatype);
-        return false;
-    }
-
-    if (status) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to read column data from column %d\n", colnum);
-        return false;
-
-    }
-
-    return true;
-}
-
-/**
-  Reads a column from the current binary table providing column name
-  */
-static bool readColumnUsingName(
-        Fits* this,
-        int datatype, 
-        char* colname,
-        LONGLONG firstrow, 
-        LONGLONG firstelem,
-        LONGLONG nelements, 
-        void* coldata)  {
-
-    int colnum;
-    if (!getColumnNumber(this, colname, &colnum)) return false;
-
-    return  readColumn(this, datatype, colnum, firstrow, firstelem, nelements, coldata);
-}
-
-/**
-  Writes a column to the current binary table
-  */
-static bool writeColumn(
-        Fits* this, 
-        int datatype, 
-        int colnum, 
-        LONGLONG firstrow,
-        LONGLONG firstelem, 
-        LONGLONG nelements, 
-        void* coldata) { 
-
-    int status = 0;
-    fits_write_col(this->file, datatype, colnum, firstrow, firstelem, nelements, coldata, &status);
-    if (status) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to write column data for column %d\n", colnum);
-        return false;
-
-    }
-
-    return true;
-}
-
-/**
-  Creates a new binary table
-  */
-static bool createBinaryTable(
-        Fits* this, 
-        LONGLONG nRows, 
-        int nCols, 
-        char *names[],
-        char *types[], 
-        char *name) {
-
-    int status = 0;
-    fits_create_tbl(this->file, BINARY_TBL, nRows, nCols, names, types, NULL, name, &status);
-
-    if (status) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to create table: '%s'\n", name);
-        return false;
-    }
-
-
-    return true;
-}
-
-/**
-  Initilization common to all constructors
-  */
-static Fits* init(const char* path, Logger* logger) {
-
-    Fits* this = (Fits*)calloc(1, sizeof(Fits));
-
-    // fields
-    strcpy(this->path, path);
-    this->logger = logger;
-
-    // method pointers
-    this->getFilePtr = getFilePtr;
-    this->getPath = getPath;
-    this->countRows = countRows;
-    this->getColumnMeta = getColumnMeta;
-    this->getColumnNumber = getColumnNumber;
-    this->getColumnVector = getColumnVector;
-    this->readColumn = readColumn;
-    this->readColumnUsingName = readColumnUsingName;
-    this->getHeaderKeyValue = getHeaderKeyValue;
-    this->moveToExtension = moveToExtension;
-    this->moveToHeader = moveToHeader;
-    this->moveToBinaryTable = moveToBinaryTable;
-    this->moveToBinaryTableAndCountRows = moveToBinaryTableAndCountRows;
-    this->deleteRows = deleteRows;
-    this->createBinaryTable = createBinaryTable;
-    this->writeColumn = writeColumn;
-    this->delete = delete;
-    this->destroy = destroy;
-
-    assert(this);
-
-    return this;
-}
-
-/**
-  Constructor.
-
-  Returns a new Fits object representing an existing FITS file.
-
-*/
-Fits* existing_Fits(const char* path, Logger* logger) {
-
-    Fits* this = init(path, logger);
-    this->logger->print(this->logger, MSG_DEBUG, "Fits", "Constructor for existing file at '%s'\n", path);
-
-    int status = 0;
-    if (fits_open_file(&this->file, path, READONLY, &status)) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to open FITS file here %s\n", path);
-        this->file = NULL;
-    }
-
-
-    return this;
-}
-
-/**
-  Constructor. 
-
-  Returns a new Fits object representing a new FITS file.
-  */
-Fits* new_Fits(const char* path, Logger* logger) {
-
-    Fits* this = init(path, logger);
-    this->logger->print(this->logger, MSG_DEBUG, "Fits", "Constructor for new file at '%s'\n", path);
-
-    int status = 0;
-    if (fits_create_file(&this->file, path, &status)) {
-
-        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to create FITS file here '%s'\n", path);
-        this->file = NULL;
-    }
-
-    return this;
-}
-
-
Index: trunk/ippToPsps/src/Fits.h
===================================================================
--- trunk/ippToPsps/src/Fits.h	(revision 32007)
+++ 	(revision )
@@ -1,64 +1,0 @@
-/** @file Fits.h
- *
- *  @brief An encapsulation of necessary cfitsio functions
- *
- *  @ingroup ippToPsps
- *
- *  @author IfA
- *  Copyright 2011 Institute for Astronomy, University of Hawaii
- */
-
-#ifndef IPPTOPSPS_FITS_H
-#define IPPTOPSPS_FITS_H
-
-#include <psmodules.h>
-
-#include "Logger.h"
-
-/**
-
-  Class that encapsulates a FITS file, making an OO interface to the dreaded cfitsio
-
-  */
-typedef struct Fits {
-
-    // fields
-    fitsfile* file;             // cfitsio file pointer
-    char path[1000];            // FITS path
-    Logger* logger;             // logger object
-
-    // accessor methods
-    fitsfile* (*getFilePtr)();
-    int (*getDataType)();
-    char* (*getPath)();
-    bool (*countRows)();
-    bool (*getColumnMeta)();
-    bool (*getColumnNumber)();
-    bool (*getColumnVector)();
-    bool (*readColumn)();
-    bool (*readColumnUsingName)();
-    bool (*getHeaderKeyValue)();
-
-    // mutators
-    bool (*moveToExtension)();
-    bool (*moveToHeader)();
-    bool (*moveToBinaryTable)();
-    bool (*moveToBinaryTableAndCountRows)();
-    bool (*createBinaryTable)();
-    bool (*writeColumn)();
-    bool (*deleteRows)();
-    bool (*delete)();
-
-    // destructor
-    void (*destroy)();
-
-} Fits;
-
-// constructors
-Fits* existing_Fits(const char* path, Logger* logger);
-Fits* new_Fits(const char* path, Logger* logger);
-
-// non-class methods
-int Fits_getDataType(char *typename);
-
-# endif // IPPTOPSPS_FITS_H 
Index: trunk/ippToPsps/src/FitsGenerator.c
===================================================================
--- trunk/ippToPsps/src/FitsGenerator.c	(revision 32007)
+++ 	(revision )
@@ -1,781 +1,0 @@
-/** @file FitsGenerator.c
- *
- *  @ingroup ippToPsps
- *
- *  @author IfA
- *  Copyright 2011 Institute for Astronomy, University of Hawaii
- */
-
-#include "FitsGenerator.h"
-#include <ctype.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include "Fits.h"
-
-/**
-  Finds a column within this table
-  */
-static Column* findColumn(FitsGenerator* this, Table* table, const char* name) {
-
-    Column* column = NULL;
-
-    for (uint32_t i=0; i<table->numOfColumns; i++) {
-
-        if (strcmp(table->columns[i].pspsName, name) == 0) {
-            column = table->columns+i;
-            break;
-        }
-    }
-
-    if (!column) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
-            "Could not find column '%s' in table '%s'\n", name, table->name);
-
-    return column;
-}
-
-/**
-  Finds a table from the array of tables
-  */
-static Table* findTable(FitsGenerator* this, const char* name) {
-
-    Table* table = NULL;
-
-    for (uint32_t i=0; i<this->numOfTables; i++) {
-
-        if (strcmp(this->tables[i].name, name) == 0) {
-            table = this->tables+i;
-            break;
-        }
-    }
-
-    if (!table) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
-            "Could not find table '%s'\n", name);
-
-    return table;
-}
-
-/**
-  Gets an attribute value from XML node
-  */
-static bool getAttribute(xmlNode* node, const char* attName, char* _value) {
-
-    xmlChar* value = xmlGetProp(node, (const xmlChar*)attName);
-    if (!value) return false;
-    sprintf(_value, "%s", value);
-    xmlFree(value);
-
-    return true;
-}
-
-/**
-  Creates a FITS binary table and populates it with defaults based on definition in schema XML
-  */
-static bool createTable(Table* table, Fits* fitsOut, const long nRows) {
-
-    if (!table) return false;
-    if (nRows < 1) return false;
-
-    long nCols = table->numOfColumns;
-
-    char** colNames = (char**)calloc(nCols, sizeof(char*));
-    char** colTypes = (char**)calloc(nCols, sizeof(char*));
-
-    uint32_t i = 0;
-    for (i=0;i<nCols;i++) colTypes[i] = (char*)calloc(5,sizeof(char));
-
-    i = 0;
-    for (uint32_t m=0; m<table->numOfColumns; m++) {
-
-        colNames[i] = table->columns[i].pspsName;
-
-        //        sprintf(colNames[i], table->columns[i].pspsName);
-
-        switch (table->columns[i].pspsType) {
-
-            case TBYTE: sprintf(colTypes[i],"1B");
-                        break;
-            case TSHORT: sprintf(colTypes[i],"1I");
-                         break;
-            case TLONG: sprintf(colTypes[i],"1J"); // TODO
-                        break;
-            case TLONGLONG: sprintf(colTypes[i],"1K");
-                            break;
-            case TFLOAT: sprintf(colTypes[i],"1E");
-                         break;
-            case TDOUBLE: sprintf(colTypes[i],"1D");
-                          break;
-            case TSTRING: sprintf(colTypes[i],"32A"); // TODO width?
-                          break;
-
-            default:
-                          break;
-        }
-
-        i++;
-    }
-
-    fitsOut->createBinaryTable(fitsOut, nRows, nCols, colNames, colTypes, table->name);
-
-    for (i=0;i<nCols;i++) free(colTypes[i]);
-    free(colTypes);
-    free(colNames);
-
-    // now insert defaults
-    int8_t* int8col = (int8_t*)calloc(nRows, sizeof(int8_t));
-    int16_t* int16col = (int16_t*)calloc(nRows, sizeof(int16_t));
-    long* longcol = (long*)calloc(nRows, sizeof(long));
-    float* floatcol = (float*)calloc(nRows, sizeof(float));
-    double* doublecol = (double*)calloc(nRows, sizeof(double));
-    char** strcol = (char**)calloc(nRows, sizeof(char**));
-    for (uint32_t i=0; i<nRows;i++)
-        strcol[i] = (char*)calloc(20,sizeof(char)); // TODO 20? size issue
-
-    uint32_t j;
-    int64_t tempLong;
-    double tempDouble;
-    char tempStr[20];
-
-    int col;
-    for (uint32_t i=0; i<table->numOfColumns; i++) {
-
-        col = i+1;
-
-        strcpy(tempStr,table->columns[i].defaultValue);
-        tempLong = atol(tempStr);
-        tempDouble = atof(tempStr);
-
-        switch (table->columns[i].pspsType) {
-
-            case TBYTE:
-                for(j=0;j<nRows;j++) int8col[j] = (int8_t)tempLong;
-                fitsOut->writeColumn(fitsOut, TBYTE, col, 1, 1, nRows, int8col);
-                break;
-            case TSHORT:
-                for(j=0;j<nRows;j++) int16col[j] = (int16_t)tempLong;
-                fitsOut->writeColumn(fitsOut, TSHORT, col, 1, 1, nRows, int16col);
-                break;
-            case TLONG:
-                for(j=0;j<nRows;j++) longcol[j] = (long)tempLong;
-                fitsOut->writeColumn(fitsOut, TLONG, col, 1, 1, nRows, longcol);
-                break;
-
-            case TLONGLONG:
-                for(j=0;j<nRows;j++) longcol[j] = tempLong;
-                fitsOut->writeColumn(fitsOut, TLONGLONG, col, 1, 1, nRows, longcol);
-                break;
-
-            case TFLOAT:
-                for(j=0;j<nRows;j++) floatcol[j] = (float)tempDouble;
-                fitsOut->writeColumn(fitsOut, TFLOAT, col, 1, 1, nRows, floatcol);
-                break;
-
-            case TDOUBLE:
-                for(j=0;j<nRows;j++) doublecol[j] = tempDouble;
-                fitsOut->writeColumn(fitsOut, TDOUBLE, col, 1, 1, nRows, doublecol);
-                break;
-
-            case TSTRING:
-                for(j=0;j<nRows;j++) strcpy(strcol[j], tempStr);
-                fitsOut->writeColumn(fitsOut, TSTRING, col, 1, 1, nRows, strcol);
-                break;
-
-            default:
-                break;
-        }
-    }
-
-    free(int8col);
-    free(int16col);
-    free(longcol);
-    free(floatcol);
-    free(doublecol);
-    for (uint32_t i=0; i<nRows;i++) free(strcol[i]);
-    free(strcol);
-
-    return true;
-}
-
-/*
-   Counts number of children with the provided name
-   */
-static int countChildren(xmlNode* rootNode, const char* name) {
-
-    int count = 0;
-    xmlNode* node = NULL;
-
-    for (node = rootNode->children; node; node = node->next) {
-
-        if (strcmp((const char*)node->name, name)==0) count++;
-    } 
-
-    return count;
-}
-
-/*
-   opens an XML file and returns the document
-   */
-static xmlDoc* openXmlFile(FitsGenerator* this, const char* path) {
-
-    xmlDoc* doc = xmlReadFile(path, NULL, 0);
-    if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
-            "Unable to open XML file at %s\n", path);
-    return doc;
-}
-
-/*
-   closes an XML file 
-   */
-static bool closeXmlFile(xmlDoc* doc) {
-
-    xmlFreeDoc(doc);
-    xmlCleanupParser();
-
-    return true;
-}
-
-/**
-  Populates the provided table with data from XML
-  */
-static bool populateTable(FitsGenerator* this, Table* table, xmlNode* rootElement, Fits *fitsOut) {
-
-    char tempStr[100];
-    xmlNode* node = NULL;
-    xmlNode* tableNode = NULL;
-
-    // first check we have data for this table in XML file
-    for (node = rootElement->children; node; node = node->next) {
-        if (node->type == XML_ELEMENT_NODE) {
-
-            if (strcmp((const char*)node->name, "table")!=0) continue;
-            if (!getAttribute(node, "name", tempStr)) continue;
-            if (strcmp(tempStr, table->name)==0) {tableNode = node; break;}
-        }
-    }
-
-    if(!tableNode) {
-
-        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
-                "Could not find table: %s\n", table->name);
-        return false;
-    }
-
-    // now count the number of rows
-    int nRows = countChildren(tableNode, "row");
-    if (nRows < 1) return false;
-    if (!createTable(table, fitsOut, nRows)) return false;
-
-    int rows=0;
-    int status;
-    char** strcol = (char**)calloc(1, sizeof(char**));
-    strcol[0] = (char*)calloc(32,sizeof(char)); // TODO 20? size issue
-
-    int8_t* bytecol = calloc(1, sizeof(uint8_t));
-    int16_t* shortcol = calloc(1, sizeof(uint16_t));
-    long* longcol = calloc(1, sizeof(long));
-    double* doublecol = calloc(1, sizeof(double));
-    float* floatcol = calloc(1, sizeof(float));
-
-    int col;
-
-    // now get rows
-    for (node = tableNode->children; node; node = node->next) {
-
-        if (strcmp((const char*)node->name, "row")!=0) continue;
-
-        rows++;
-
-        // get column data for this row
-        for (int i=0;i<table->numOfColumns;i++) {
-
-            col = i+1;
-
-            if (!getAttribute(node, table->columns[i].pspsName, tempStr)) continue;
-
-            strncpy(strcol[0], tempStr, 32);
-            status=0;
-            //psLogMsg("ippToPsps", PS_LOG_INFO, "Values %s - %ld - %f - %d", strcol[0], longcol[0], doublecol[0], bytecol[0]);
-            switch (table->columns[i].pspsType) {
-
-                case TBYTE:
-                    bytecol[0] = atoi(tempStr);
-                    fitsOut->writeColumn(fitsOut, table->columns[i].pspsType, col, rows, 1, 1, bytecol); 
-                    break;
-                case TSHORT:
-                    shortcol[0] = atoi(tempStr);
-                    fitsOut->writeColumn(fitsOut, table->columns[i].pspsType, col, rows, 1, 1, shortcol); 
-                    break;
-                case TLONG:
-                case TLONGLONG:
-                    longcol[0] = atol(tempStr);
-                    fitsOut->writeColumn(fitsOut, table->columns[i].pspsType, col, rows, 1, 1, longcol); 
-                    break;
-                case TFLOAT:
-                    floatcol[0] = atof(tempStr);
-                    fitsOut->writeColumn(fitsOut, table->columns[i].pspsType, col, rows, 1, 1, floatcol);
-                    break;
-                case TDOUBLE:
-                    doublecol[0] = atof(tempStr);
-                    fitsOut->writeColumn(fitsOut, table->columns[i].pspsType, col, rows, 1, 1, doublecol);
-                    break;
-                case TSTRING:
-                    fitsOut->writeColumn(fitsOut, table->columns[i].pspsType, col, rows, 1, 1, strcol); 
-                    break;
-
-            }
-            if (status) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
-                    "Unable to write value of %s to column %s in table %s\n", 
-                    tempStr, table->columns[i].pspsName, table->name);
-        }
-    }
-
-    free(bytecol);
-    free(shortcol);
-    free(longcol);
-    free(floatcol);
-    free(doublecol);
-    free(strcol[0]);
-    free(strcol);
-
-    return true;
-}
-
-/**
-  Loads a table description from XML
-  */
-static bool loadTableDescription(FitsGenerator* this, Table* table, xmlNode* tableNode) {
-
-    bool ret = true;
-    char tableName[100];
-    getAttribute(tableNode, "name", tableName);
-    strcpy(table->name, tableName);
-
-    // count how many columns we have coming in and allocate memory for them
-    table->numOfColumns = countChildren(tableNode, "column");
-    table->columns = calloc(table->numOfColumns, sizeof(Column));
-    //    psLogMsg("ippToPsps", PS_LOG_INFO, " Found '%d' columns", table->numOfColumns);
-
-    char buffer[200];
-    xmlNode* node;
-    int columnNum = 0;
-
-    for (node = tableNode->children; node; node = node->next) {
-
-        if (strcmp((const char*)node->name, "column") != 0) continue;
-
-        table->columns[columnNum].usingDefault = true;
-
-        // column name
-        getAttribute(node, "name", buffer);
-        sprintf(table->columns[columnNum].pspsName, buffer);
-
-        // column type
-        getAttribute(node, "type", buffer);
-        table->columns[columnNum].pspsType = Fits_getDataType(buffer);
-
-        // default value
-        getAttribute(node, "default", buffer);
-        sprintf(table->columns[columnNum].defaultValue, buffer);
-
-        // comment
-        getAttribute(node, "comment", buffer);
-        sprintf(table->columns[columnNum].comment, buffer);
-
-        # if 0
-        psLogMsg("ippToPsps", PS_LOG_INFO, "'%s'  name='%s' type='%d'  default='%s' comment='%s'", 
-                table->name,
-                table->columns[columnNum].pspsName, 
-                table->columns[columnNum].pspsType, 
-                table->columns[columnNum].defaultValue, 
-                table->columns[columnNum].comment);
-# endif
-        columnNum++;
-    }   
-
-
-    if (columnNum < 1) {
-
-        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
-                "Found no columns for table '%s'\n", tableName);
-        ret = false;
-    }
-
-    if (columnNum != table->numOfColumns)
-        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
-                "Mismatch between number of columns expected (%d) and those found (%d)\n", 
-                table->numOfColumns, columnNum);
-
-    return ret;
-}
-
-/**
-  Reads table shapes from XML file
-  */
-static bool loadTableDescriptions(FitsGenerator* this) {
-
-    bool ret = true;
-
-    psString path = NULL;
-    psStringAppend(&path, "%s/tables.xml", this->configsPath);
-
-    xmlDoc* doc = openXmlFile(this, path);
-
-    if (doc == NULL) {
-
-        psFree(path);
-        return false;
-    }
-    psFree(path);
-
-    xmlNode* rootElement = xmlDocGetRootElement(doc);
-
-    if (strcmp((const char*)rootElement->name, "tableDescriptions")!=0) {
-
-        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
-                "Root node of XML is not 'tableDescriptions', as it should be\n");
-        return false;
-    }
-
-    // count how many tables we have coming in and allocate memory for them
-    this->numOfTables = countChildren(rootElement, "table");
-    this->tables = calloc(this->numOfTables, sizeof(Table));
-    //    psLogMsg("ippToPsps", PS_LOG_INFO, " Found '%d' tables", this->numOfTables);
-
-    xmlNode* node = NULL;
-    Table* table = NULL;
-
-    int tableNum = 0;
-    // loop round all available table descriptions
-    for (node = rootElement->children; node; node = node->next) {
-        if (node->type == XML_ELEMENT_NODE) {
-
-            if (strcmp((const char*)node->name, "table")==0) {
-
-                table = this->tables+tableNum;
-
-                if (!loadTableDescription(this, table, node)) ret = false;
-                else tableNum++;
-            }
-        }
-    }
-
-    if (tableNum != this->numOfTables)
-        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
-                "Mismatch between number of tables expected (%d) and those found (%d)\n", 
-                this->numOfTables, tableNum);
-
-    closeXmlFile(doc);
-
-    return ret;
-}
-
-/**
-  Loads mappings from XML for a particular table
-  */
-static bool loadTableMappings(FitsGenerator* this, xmlNode* tableNode) {
-
-    bool ret = false;
-
-    xmlNode* node = NULL;
-
-    char tableName[100];
-    getAttribute(tableNode, "name", tableName);
-
-    Table* table = findTable(this, tableName);
-    Column* column = NULL;
-    if (!table) return false;
-
-    char buffer[100];
-    //psLogMsg("ippToPsps", PS_LOG_INFO, "Table '%s'", tableName);
-
-    // loop round all available mappings for this table
-    for (node = tableNode->children; node; node = node->next) {
-        if (node->type == XML_ELEMENT_NODE) {
-
-            if (strcmp((const char*)node->name, "map")==0) {
-
-                // column type
-                getAttribute(node, "pspsName", buffer);
-                column = findColumn(this, table, buffer);
-
-                if (!column) continue;
-
-                // IPP name
-                getAttribute(node, "ippName", buffer);
-                strcpy(column->ippName, buffer);
-
-                // IPP type
-                getAttribute(node, "ippType", buffer);
-                column->ippType = Fits_getDataType(buffer); 
-
-                column->usingDefault = false;
-
-                //psLogMsg("ippToPsps", PS_LOG_INFO, "...mapping PSPS:'%s' to '%s' '%d'", column->pspsName, column->ippName, column->ippColNum );
-            }
-        }
-    }
-
-    return ret;
-}
-
-/**
-  Reads table mappings from XML file
-  */
-static bool loadMappings(FitsGenerator* this) {
-
-    bool ret = true;
-
-    char path[1000];
-    sprintf(path, "%s/map.xml", this->configsPath);
-
-    struct stat sts;
-    if ((stat(path, &sts)) == -1) {
-        this->logger->print(this->logger, MSG_INFO, "FitsGenerator", 
-                "No map file found at '%s'\n", path);
-        return false;
-    }
-
-    xmlDoc* doc = openXmlFile(this, path);
-
-    if (doc == NULL) {
-        
-        this->logger->print(this->logger, MSG_ERROR,"FitsGenerator",  
-                "Could not create XML document from '%s'\n", path);
-        return false;
-    }
-
-    this->logger->print(this->logger, MSG_INFO, "FitsGenerator", 
-            "Using map file at '%s'\n", path);
-    xmlNode* rootElement = xmlDocGetRootElement(doc);
-
-    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
-        this->logger->print(this->logger, MSG_ERROR,"FitsGenerator",  
-                "Root node of XML is not 'tabledata', as it should be\n");
-        return false;
-    }
-
-    xmlNode* node = NULL;
-
-    // loop round all available tables
-    for (node = rootElement->children; node; node = node->next) {
-        if (node->type == XML_ELEMENT_NODE) {
-
-            if (strcmp((const char*)node->name, "table")==0) {
-
-                if (!loadTableMappings(this, node)) ret = false;
-            }
-        }
-    }
-
-    closeXmlFile(doc);
-
-    return ret;
-}
-
-/**
-  Populate the provided table with data from XML
-  */
-static bool populateFromFile(FitsGenerator* this, Fits *fitsOut) {
-
-    bool ret = true;
-    psString path = NULL;
-    psStringAppend(&path, "%s/data.xml", this->configsPath);
-
-    xmlDoc* doc = openXmlFile(this, path);
-
-    if (doc == NULL) {
-        psFree(path);
-        return false;
-    }
-    psFree(path);
-
-    xmlNode* rootElement = xmlDocGetRootElement(doc);
-
-    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
-        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", 
-                "Root node of XML is not 'tabledata', as it should be\n");
-        return false;
-    }
-
-    for (uint32_t i=0; i<this->numOfTables; i++) {
-        if (!populateTable(this, this->tables+i, rootElement, fitsOut)) {
-            ret = false;
-        }
-    }
-
-    closeXmlFile(doc);
-
-    return ret;
-}
-
-/**
-  Populate with data from another FITS table into this one
-  */
-static bool populateTableFromFits(
-        FitsGenerator* this,
-        Table* table,
-        Fits *fitsIn, 
-        Fits *fitsOut,
-        const long nRows, 
-        const bool fromHeader) {
-
-    if (!table) return false;
-    if (!fitsIn) return false;
-
-    int8_t* int8col = (int8_t*)calloc(nRows, sizeof(int8_t));
-    int16_t* int16col = (int16_t*)calloc(nRows, sizeof(int16_t));
-    long* longcol = (long*)calloc(nRows, sizeof(long));
-    float* floatcol = (float*)calloc(nRows, sizeof(float));
-    double* doublecol = (double*)calloc(nRows, sizeof(double));
-    char** strcol = (char**)calloc(nRows, sizeof(char**));
-    for (uint32_t i=0; i<nRows;i++)
-        strcol[i] = (char*)calloc(50,sizeof(char)); // TODO 20? size issue
-
-    // first loop round all columns and get IPP col numbers for provided column names TODO only do once, first time in
-    if(!fromHeader) {
-
-        for (uint32_t i=0; i<table->numOfColumns; i++) {
-
-            if (strlen(table->columns[i].ippName) < 1) continue;
-
-            int dummy; // TODO getting wrong type for some reason
-            if (!fitsIn->getColumnMeta(fitsIn, table->columns[i].ippName, &table->columns[i].ippColNum, &dummy, &table->columns[i].ippRepeat)) return false;
-        }
-    }
-
-    int col;
-    for (uint32_t i=0; i<table->numOfColumns; i++) {
-
-        if (!table->columns[i].usingDefault) {
-
-            col = i+1;
-
-            switch (table->columns[i].ippType) {
-
-                case TBYTE:
-                    if (fromHeader) {
-                        fitsIn->getHeaderKeyValue(fitsIn, TBYTE, table->columns[i].ippName, &int8col[0]); 
-                    }
-                    else fitsIn->readColumn(fitsIn, TBYTE, table->columns[i].ippColNum, 1, 1, nRows, int8col);
-                    fitsOut->writeColumn(fitsOut, TBYTE, col, 1, 1, nRows, int8col);
-                    break;
-                case TSHORT:
-                    if (fromHeader) {
-                        fitsIn->getHeaderKeyValue(fitsIn, TSHORT, table->columns[i].ippName, &int16col[0]);
-                    }
-                    else fitsIn->readColumn(fitsIn, TSHORT, table->columns[i].ippColNum, 1, 1, nRows, int16col);
-                    fitsOut->writeColumn(fitsOut, TSHORT, col, 1, 1, nRows, int16col);
-                    break;
-                case TLONG:
-                    if (fromHeader) {
-                        fitsIn->getHeaderKeyValue(fitsIn, TLONG, table->columns[i].ippName, &longcol[0]);
-                    }
-                    else fitsIn->readColumn(fitsIn, TLONG, table->columns[i].ippColNum, 1, 1, nRows, longcol);
-                    fitsOut->writeColumn(fitsOut, TLONG, col, 1, 1, nRows, longcol);
-                    break;
-                case TLONGLONG:
-                    if (fromHeader) {
-                        fitsIn->getHeaderKeyValue(fitsIn, TLONGLONG, table->columns[i].ippName, &longcol[0]);
-                    }
-                    else fitsIn->readColumn(fitsIn, TLONGLONG, table->columns[i].ippColNum, 1, 1, nRows, longcol);
-                    fitsOut->writeColumn(fitsOut, TLONGLONG, col, 1, 1, nRows, longcol);
-                    break;
-                case TFLOAT:
-                    if (fromHeader) {
-                        fitsIn->getHeaderKeyValue(fitsIn, TFLOAT, table->columns[i].ippName,&floatcol[0]); 
-                    }
-                    else fitsIn->readColumn(fitsIn, TFLOAT, table->columns[i].ippColNum, 1, 1, nRows, floatcol);
-                    fitsOut->writeColumn(fitsOut, TFLOAT, col, 1, 1, nRows, floatcol);
-                    break;
-                case TDOUBLE:
-                    if (fromHeader) {
-                        fitsIn->getHeaderKeyValue(fitsIn, TDOUBLE, table->columns[i].ippName, &doublecol[0]);
-                    }
-                    else fitsIn->readColumn(fitsIn, TDOUBLE, table->columns[i].ippColNum, 1, 1, nRows, doublecol);
-                    fitsOut->writeColumn(fitsOut, TDOUBLE, col, 1, 1, nRows, doublecol);
-                    break;
-                case TSTRING:
-                    if (fromHeader) fitsIn->getHeaderKeyValue(fitsIn, TSTRING, table->columns[i].ippName, strcol[0]);
-                    else fitsIn->readColumn(fitsIn, TSTRING, table->columns[i].ippColNum, 1, 1, nRows, strcol);
-                    fitsOut->writeColumn(fitsOut, TSTRING, col, 1, 1, nRows, strcol);
-                    break;
-
-                default:
-                    this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", "Don't know IPP type (%d) for mapping from  '%d'  '%s' to '%s'\n", table->columns[i].ippType,
-                            table->columns[i].ippColNum, table->columns[i].ippName, table->columns[i].pspsName);
-                    break;
-            }
-        }
-    }
-
-    free(int8col);
-    free(int16col);
-    free(longcol);
-    free(floatcol);
-    free(doublecol);
-    for (uint32_t i=0; i<nRows;i++) free(strcol[i]);
-    free(strcol);
-
-    return true;
-}
-
-/**
-  Creates and populates a table
-  */
-static bool createAndPopulateTable(
-        FitsGenerator* this, 
-        Fits* fitsIn,
-        Fits* fitsOut,
-        const long nRows,
-        const char* tableName,
-        const int fromHeader) {
-
-    Table* table = findTable(this, tableName);
-    if (!table) return false;
-
-    if(!createTable(table, fitsOut, nRows)) return false;
-    return populateTableFromFits(this, table, fitsIn, fitsOut, nRows, fromHeader);
-}
-
-/**
-  Destructor.
-  */
-static void destroy(FitsGenerator* this) {
-
-    if (this == NULL) return;
-
-    // TODO check logic here
-    for (int i=0;i<this->numOfTables;i++)
-        free(this->tables[i].columns);
-
-    free(this->tables);
-    psFree(this->configsPath);
-    free(this);
-}
-
-/**
-  Constructor.
-  */
-FitsGenerator* new_FitsGenerator(Logger* logger, const char* path) {
-
-    FitsGenerator* this = (FitsGenerator*)calloc(1, sizeof(FitsGenerator));
-
-    this->configsPath = NULL;
-    psStringAppend(&this->configsPath, path);
-    this->logger = logger;
-
-    // method pointers
-    this->createAndPopulateTable = createAndPopulateTable;
-    this->populateFromFile = populateFromFile;
-    this->destroy = destroy;
-
-    // load tables descriptions from XML
-    if (loadTableDescriptions(this)) {
-
-        // load any mappings we may have from XML        
-        loadMappings(this);
-    }
-
-    return this;
-}
-
Index: trunk/ippToPsps/src/FitsGenerator.h
===================================================================
--- trunk/ippToPsps/src/FitsGenerator.h	(revision 32007)
+++ 	(revision )
@@ -1,72 +1,0 @@
-/** @file FitsGenerator.h
- *
- *  @brief ippToPsps
- *
- *  @ingroup ippToPsps
- *
- *  @author IfA
- *  Copyright 2011 Institute for Astronomy, University of Hawaii
- */
-
-#ifndef IPPTOPSPS_FITSGENERATOR_H
-#define IPPTOPSPS_FITSGENERATOR_H
-
-#include <psmodules.h>
-
-#include "Logger.h"
-
-// column class
-typedef struct Column {
-
-    int ippColNum;
-    char ippName[100];
-    int ippType;
-    long ippRepeat;
-    char pspsName[100]; // TODO change to 'name'
-    int pspsType;
-    bool usingDefault;
-    char defaultValue[100];
-    char comment[300];
-
-} Column;
-
-// table class
-typedef struct Table {
-
-    char name[32];
-    Column* columns;
-    int numOfColumns;
-
-} Table;
-
-/**
-
-  Class used for generating FITS files.
-
-  - Uses XML table definitions to create table shapes
-  - Uses XML map files to populate tables from another FITS files
-  - Uses XML data files to populate tables with set values
-
-*/
-typedef struct FitsGenerator {
-
-    // fields
-    psString configsPath;
-    Table* tables;
-    int numOfTables;
-    Logger* logger;
-
-    // methods
-    bool (*createAndPopulateTable)();
-    bool (*populateFromFile)();
-
-    // destructor
-    void (*destroy)();
-
-} FitsGenerator; 
-
-// constructor
-FitsGenerator* new_FitsGenerator(Logger* logger, const char* path);
-
-#endif // IPPTOPSPS_FITSGENERATOR_H
-
Index: trunk/ippToPsps/src/InitBatch.c
===================================================================
--- trunk/ippToPsps/src/InitBatch.c	(revision 32007)
+++ 	(revision )
@@ -1,100 +1,0 @@
-#include "InitBatch.h"
-
-/**
-  Destructor
-  */
-static void destroy(InitBatch* this) {
-
-    // call superclass destructor
-    this->base.destroy(&this->base);
-    free (this);
-}
-
-/**
-  Does the work.
-  */
-static int run(InitBatch* this) {
-
-    if (this->base.exitCode != PS_EXIT_SUCCESS) return this->base.exitCode;
-
-    if (!this->base.fitsGenerator->populateFromFile(this->base.fitsGenerator, this->base.fitsOut)) 
-        this->base.exitCode = PS_EXIT_CONFIG_ERROR;
-    else this->base.exitCode = PS_EXIT_SUCCESS;
-
-    return this->base.exitCode;
-}
-
-/**
-  Print-out this class. Calls base-calls print method first.
-  */
-static void print(InitBatch* this) {
-
-    this->base.print(&this->base);
-}
-
-/**
-  Reads command-line arguments.
-  */
-static bool parseArguments(InitBatch* this, int argc, char **argv) {
-
-    this->base.parseArguments(&this->base, argc, argv, "/init", "00000000.FITS");
-
-    if (
-            !this->base.gotFitsOutPath() ||
-            !this->base.gotConfig() ) {
-
-        this->base.logger->print(this->base.logger, MSG_ERROR, "InitBatch", "Problem with supplied arguments\n");
-        this->base.exitCode = PS_EXIT_CONFIG_ERROR;
-        return false;
-    }
-
-    return true;
-}
-
-/**
-  Constructor
-  */
-InitBatch* new_InitBatch(Logger* logger, int *argc, char **argv) {
-
-    logger->print(logger, MSG_DEBUG, "InitBatch", "Constructor\n");
-    InitBatch *this = (InitBatch*)calloc(1, sizeof(InitBatch));
-
-    // call base-class constructor
-    new_Batch(logger, &this->base);
-
-    // method pointers
-    this->print = print;
-    this->destroy = destroy;
-    this->base.run = run;
-
-    parseArguments(this, *argc, argv);
-
-    this->print(this);
-
-    return this;
-}
-
-/**
-  Main
-  */
-int main(int argc, char **argv) {
-
-//    ippToPsps_VersionPrint();
-
-    Logger* logger = new_Logger(NULL, false);
-    logger->print(logger, MSG_INFO, "main", "Creating new initialization batch\n");
-
-    InitBatch* initBatch = new_InitBatch(logger, &argc, argv);
-    initBatch->base.run(initBatch);
-    int exitCode = initBatch->base.exitCode;
-
-    initBatch->destroy(initBatch);
-
-    // tidy up
-    psLibFinalize();
-    logger->destroy(logger);
-
-    return exitCode;
-}
-
-
Index: trunk/ippToPsps/src/InitBatch.h
===================================================================
--- trunk/ippToPsps/src/InitBatch.h	(revision 32007)
+++ 	(revision )
@@ -1,36 +1,0 @@
-/** @file InitBatch.h
- *
- *  @brief InitBatch
- *
- *  @ingroup ippToPsps
- *
- *  @author IfA
- *  Copyright 2009 Institute for Astronomy, University of Hawaii
- */
-
-#ifndef IPPTOPSPS_INITBATCH_H
-#define IPPTOPSPS_INITBATCH_H
-
-#include "Batch.h"
-
-/**
-  Sub-class of Batch for detections
-  */
-typedef struct InitBatch {
-
-    // fields
-    Batch base;             // base class
-
-    // methods
-    void (*print)();
-
-    // destructor
-    void (*destroy)();
-
-} InitBatch;
-
-// constructor
-InitBatch *new_InitBatch(Logger *logger, int *argc, char **argv);
-
-# endif // IPPTOPSPS_INITBATCH_H 
-
Index: trunk/ippToPsps/src/InitData.c
===================================================================
--- trunk/ippToPsps/src/InitData.c	(revision 32007)
+++ 	(revision )
@@ -1,225 +1,0 @@
-/** @file InitData.c
- *
- *  @ingroup ippToPsps
- *
- *  @author IfA
- *  Copyright 2011 Institute for Astronomy, University of Hawaii
- */
-
-#include "InitData.h"
-#include "Fits.h"
-
-
-/**
-  Gets an attribute value from XML node
-  */
-static bool getAttribute(xmlNode* node, const char* attName, char* _value) {
-
-    xmlChar* value = xmlGetProp(node, (const xmlChar*)attName);
-    if (!value) return false;
-    sprintf(_value, "%s", value);
-    xmlFree(value);
-
-    return true;
-}
-
-/**
-  Searches through this table and finds attribute value for a provided key
-  */
-static bool getRowAttribute(
-        InitData* this, 
-        xmlNode* tableNode,
-        const char* keyName, 
-        const char* keyValue,
-        const char* attName, 
-        char* attValue) {
-
-    xmlNode* node = NULL;
-
-    char buffer[100];
-
-    // loop round all available rows for this table
-    for (node = tableNode->children; node; node = node->next) {
-        if (node->type == XML_ELEMENT_NODE) {
-            //psLogMsg("ippToPsps", PS_LOG_INFO, "Node name '%s'",  (const char*)node->name );
-
-            if (strcmp((const char*)node->name, "row")==0) {
-                //psLogMsg("ippToPsps", PS_LOG_INFO, " Looking for key '%s'",  keyName );
-
-                if (!getAttribute(node, keyName, buffer)) continue;
-                //psLogMsg("ippToPsps", PS_LOG_INFO, "Found key '%s' value '%s'",  keyName, buffer );
-
-                if (strcmp(buffer, keyValue) != 0) continue;
-                getAttribute(node, attName, attValue);
-                //printf("FOUND %s %s %s %s \n", keyName, buffer, attName, attValue );
-                return true;
-
-            }
-        }
-    }
-
-    this->logger->print(this->logger, MSG_ERROR, 
-            "InitData", "Could not find value for '%s' for '%s' with value '%s'\n", 
-            attName, keyName, keyValue);
-
-    return false;
-}
-
-/**
-  Gets a value from the 'init' data 
-  */
-static bool getInitValue(
-        InitData* this, 
-        const char* tableName,
-        const char* keyName, 
-        const char* keyValue,
-        const char* attName, 
-        char* attValue) {
-
-    bool ret = true;
-
-    xmlNode* rootElement = xmlDocGetRootElement(this->doc);
-
-    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
-        this->logger->print(this->logger, MSG_ERROR, 
-                "InitData", "Root node of XML is not 'tabledata', as it should be\n");
-        return false;
-    }
-
-    xmlNode* node = NULL;
-    char tempStr[100];
-
-    // loop round all available tables
-    for (node = rootElement->children; node; node = node->next) {
-        if (node->type == XML_ELEMENT_NODE) {
-
-            if (strcmp((const char*)node->name, "table")!=0) continue;
-            if (!getAttribute(node, "name", tempStr)) continue;
-            if (strcmp(tempStr, tableName)!=0) continue;
-
-            ret = getRowAttribute(this, node, keyName, keyValue, attName, attValue);
-            break;
-        }
-
-    }
-
-    return ret;
-}
-
-/**
-   Gets model fit ID from name
-   */
-static bool getModelFitId(InitData* this, const char* name, int8_t* id) {
-
-    char buffer[10];
-    if (!getInitValue(this, "FitModel", "name", name, "fitModelID", buffer)) {
-
-        *id = -1;
-        return false;
-    }
-
-    *id = atoi(buffer);
-    return true;
-}
-
-/**
-   Gets survey ID from survey name
-   */
-static bool getSurveyId(InitData* this, const char* name, int8_t* id) {
-
-    char buffer[10];
-    if (!getInitValue(this, "Survey", "name", name, "surveyID", buffer)) {
-
-        *id = -1;
-        return false;
-    }
-
-    *id = atoi(buffer);
-    return true;
-}
-
-/**
-   Gets stack type ID from stack type string
-   */
-static bool getStackTypeId(InitData* this, const char* type, int8_t* id) {
-
-    char buffer[20];
-    if (!getInitValue(this, "StackType", "stackType", type, "stackTypeID", buffer)) {
-
-        *id = -1;
-        return false;
-    }
-
-    *id = atoi(buffer);
-    return true;
-}
-
-/**
-   Gets filter ID from filter type string
-   */
-static bool getFilterId(InitData* this, const char* type, int8_t* id) {
-
-    char tmp[2];
-    strncpy(tmp, type,1);
-    tmp[1] = '\0';
-    char buffer[10];
-    if (!getInitValue(this, "Filter", "filterType", tmp, "filterID", buffer)) {
-
-        *id = -1;
-        return false;
-    }
-
-    *id = atoi(buffer);
-    return true;
-}
-
-/**
-  Destructor.
-  */
-static void destroy(InitData* this) {
-
-    if (this == NULL) return;
-
-    if (this->doc != NULL) {
-
-        xmlFreeDoc(this->doc);
-        xmlCleanupParser();
-    }
-
-    this->logger->print(this->logger, MSG_DEBUG, "InitData", "Destructor\n");
-
-    free(this);
-}
-
-/**
-  Constructor.
-  */
-InitData* new_InitData(const char* path, Logger* logger) {
-
-    InitData* this = (InitData*)calloc(1, sizeof(InitData));
-    this->logger = logger;
-
-    this->logger->print(this->logger, MSG_DEBUG, "InitData", "Constructor\n");
-
-    sprintf(this->path, "%s/init/data.xml", path);
-
-    this->doc = xmlReadFile(this->path, NULL, 0);
-
-    if (this->doc == NULL)
-        this->logger->print(this->logger, MSG_ERROR, 
-                "InitData", "Unable to open init data file at '%s'\n", this->path);
-    else
-        this->logger->print(this->logger, MSG_INFO, 
-                "InitData", "Using init data file at '%s'\n", this->path);
-
-
-    // method pointers
-    this->getFilterId = getFilterId;
-    this->getSurveyId = getSurveyId;
-    this->getStackTypeId = getStackTypeId;
-    this->getModelFitId = getModelFitId;
-    this->destroy = destroy;
-
-    return this;
-}
-
Index: trunk/ippToPsps/src/InitData.h
===================================================================
--- trunk/ippToPsps/src/InitData.h	(revision 32007)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/** @file InitData.h
- *
- *  @brief ippToPsps
- *
- *  @ingroup ippToPsps
- *
- *  @author IfA
- *  Copyright 2011 Institute for Astronomy, University of Hawaii
- */
-
-#ifndef IPPTOPSPS_INITDATA_H
-#define IPPTOPSPS_INITDATA_H
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include <psmodules.h>
-
-#include "Logger.h"
-
-/**
-
-  Class encapsulating the initialization data
-
-*/
-typedef struct InitData {
-
-    // fields
-    char path[1000];
-    xmlDoc* doc;
-    Logger* logger;
-
-    // methods
-    bool (*getFilterId)();
-    bool (*getSurveyId)();
-    bool (*getStackTypeId)();
-    bool (*getModelFitId)();
-
-    // destructor
-    void (*destroy)();
-
-} InitData; 
-
-// constructor
-InitData* new_InitData(const char* path, Logger* logger);
-
-#endif // IPPTOPSPS_INITDATA_H
-
Index: trunk/ippToPsps/src/StackBatch.c
===================================================================
--- trunk/ippToPsps/src/StackBatch.c	(revision 32007)
+++ 	(revision )
@@ -1,483 +1,0 @@
-#include "StackBatch.h"
-#include "StackBatchEnums.h"
-
-#include "Fits.h"
-
-/**
-  Destructor
-  */
-static void destroy(StackBatch* this) {
-
-    // call superclass destructor
-    this->base.destroy(&this->base);
-    free (this);
-}
-
-/**
-  Creates the StackDetection table
-  */
-static bool createStackDetectionTable(
-        StackBatch* this,
-        Fits* fitsIn,
-        int8_t* filterIDs,
-        int8_t* surveyIDs,
-        long* skycellIDs,
-        float exposureTime
-        ) {
-
-    char extensionName[25];
-    sprintf(extensionName, "SkyChip.psf");
-    long nDet = 0;
-    if (!fitsIn->moveToBinaryTableAndCountRows(fitsIn, extensionName, &nDet)) return false;
-
-
-    // allocate stuff
-    char** assocDate = (char**)calloc(this->MAXDETECT, sizeof(char**));
-    for (uint32_t i=0; i<this->MAXDETECT;i++) assocDate[i] = (char*)calloc(20,sizeof(char));
-    long* removeList = (long*)calloc(this->MAXDETECT, sizeof(long));
-    float* instMag = (float*)calloc(this->MAXDETECT, sizeof(float));
-    float* peakMag = (float*)calloc(this->MAXDETECT, sizeof(float));
-    float* peakFlux = (float*)calloc(this->MAXDETECT, sizeof(float));
-    int* flags1 = (int*)calloc(this->MAXDETECT, sizeof(int));
-    int* flags2 = (int*)calloc(this->MAXDETECT, sizeof(int));
-    uint64_t* infoFlags = (uint64_t*)calloc(this->MAXDETECT, sizeof(uint64_t));
-
-    bool peakFluxOk;
-
-    // some stuff is the same for all detections so we can populate here
-    for (long s = 0; s<this->MAXDETECT; s++) {
-
-        // if running in test mode, don't use today's date
-        if (this->base.testMode) strcpy(assocDate[s], "2010-01-01");
-        else strcpy(assocDate[s], this->base.todaysDate);
-    }
-
-    fitsIn->readColumnUsingName(fitsIn, TFLOAT, "PSF_INST_MAG", 1, 1, nDet, instMag);
-    fitsIn->readColumnUsingName(fitsIn, TFLOAT, "PEAK_FLUX_AS_MAG", 1, 1, nDet, peakMag);
-    fitsIn->readColumnUsingName(fitsIn, TLONG, "FLAGS", 1, 1, nDet, flags1);
-    fitsIn->readColumnUsingName(fitsIn, TLONG, "FLAGS2", 1, 1, nDet, flags2);
-
-    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch", 
-            "Looping through %ld psf detection rows from '%s'\n", nDet, extensionName);
-    float mag;
-    long unmatched = 0, totalDetections = 0, numOfDuplicates = 0, numInvalidFlux = 0, numDetectionsOut = 0;
-
-    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch",  
-            "+---------------+---------+----------+------------------+---------------+--------------+\n");
-    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch",  
-            "|   Extension   | Rows in | Rows out | Missing from DVO | Duplicate IDs | Invalid Flux |\n");
-
-    for (long s=0; s<nDet; s++) {
-
-        // TODO implement this match in DVO
-        if (1) {
-
-            //infoFlags[s] = ((uint64_t)flags1[s] << 32) | (uint64_t)flags2[s]; TODO implement after schema change to make infoFlag 64-bit
-            infoFlags[s] = (uint64_t)flags1[s];
-
-            peakFluxOk = getFlux(exposureTime, peakMag[s], &peakFlux[s], 0.0, NULL);
-
-            mag = instMag[s];
-            if (!peakFluxOk || !isfinite(mag) || mag < -998.0) {
-
-                removeList[numOfDuplicates+numInvalidFlux] = s+1;
-                numInvalidFlux++;
-            }
-
-            totalDetections++;
-        }
-        else {
-
-            unmatched++;
-            continue;
-        }
-    }
-
-    numDetectionsOut = totalDetections - numInvalidFlux;
-    if (numDetectionsOut > 0) {
-
-        this->base.fitsGenerator->createAndPopulateTable(this->base.fitsGenerator, fitsIn, this->base.fitsOut, nDet, "StackDetection", false);
-        this->base.fitsOut->writeColumn(this->base.fitsOut, TLONG, STACKDETECTION_SKYCELLID, 1, 1, nDet, skycellIDs);
-        this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, STACKDETECTION_FILTERID, 1, 1, nDet, filterIDs);
-        this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKDETECTION_PEAKFLUX, 1, 1, nDet, peakFlux);
-        this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, STACKDETECTION_SURVEYID, 1, 1, nDet, surveyIDs);
-        this->base.fitsOut->writeColumn(this->base.fitsOut, TSTRING, STACKDETECTION_ASSOCDATE, 1, 1, nDet, assocDate);
-        this->base.fitsOut->writeColumn(this->base.fitsOut, TLONGLONG, STACKDETECTION_INFOFLAG, 1, 1, nDet, flags1);
-
-        if (numInvalidFlux) this->base.fitsOut->deleteRows(this->base.fitsOut, removeList, numInvalidFlux);
-
-    }
-
-    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch",
-            "|  %12s |  %5ld  |   %5ld  |      %5ld       |    %5ld      |    %5ld     |\n",
-            extensionName, nDet, numDetectionsOut, unmatched, numOfDuplicates, numInvalidFlux);
-    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch",
-            "+---------------+---------+----------+------------------+---------------+--------------+\n");
-
-
-    // free stuff up
-    free(removeList);
-    free(instMag);
-    free(flags1);
-    free(flags2);
-    free(infoFlags);
-    for (uint32_t i=0; i<this->MAXDETECT;i++) free(assocDate[i]);
-    free(assocDate);
-
-    return true;
-}
-/**
-  Structure to encapsulate block of flux values for StackApFlx table
-  */
-typedef struct {
-
-    float* flx;
-    float* flxErr;
-    float* flxStd;
-    float* flxFill;
-
-} StackApFlxFluxes;
-
-/**
-  Creates the StackApFlx table for extended source attributes
-  */
-static bool createStackApFlxTable(
-        StackBatch* this,
-        Fits* fitsIn,
-        int8_t* filterIDs,
-        int8_t* surveyIDs
-        ) {
-
-    long nDet = 0;
-    char extensionName[15];
-    sprintf(extensionName, "SkyChip.xrad");
-    if (!fitsIn->moveToBinaryTableAndCountRows(fitsIn, extensionName, &nDet)) return false;
-
-
-    int aperFluxColNum, aperFluxErrColNum, aperFluxStDevColNum, aperFluxFillColNum;
-    int type; // all the same type
-    long repeat;
-
-    fitsIn->getColumnMeta(fitsIn, "APER_FLUX", &aperFluxColNum, &type, &repeat);
-    fitsIn->getColumnMeta(fitsIn, "APER_FLUX_ERR", &aperFluxErrColNum, &type, &repeat);
-    fitsIn->getColumnMeta(fitsIn, "APER_FLUX_STDEV", &aperFluxStDevColNum, &type, &repeat);
-    fitsIn->getColumnMeta(fitsIn, "APER_FILL", &aperFluxFillColNum, &type, &repeat);
-    float* vector = calloc(repeat, sizeof(float));
-
-    // we store 10 different flux values
-    StackApFlxFluxes* stackApFlxFluxes = (StackApFlxFluxes*)calloc(11, sizeof(StackApFlxFluxes));
-    for (long i=0; i<11; i++) {
-
-        stackApFlxFluxes[i].flx = (float*)calloc(nDet, sizeof(float));
-        stackApFlxFluxes[i].flxErr = (float*)calloc(nDet, sizeof(float));
-        stackApFlxFluxes[i].flxStd = (float*)calloc(nDet, sizeof(float));
-        stackApFlxFluxes[i].flxFill = (float*)calloc(nDet, sizeof(float));
-    }
-
-    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch", 
-            "Looping through %ld extended source detections from extension '%s'\n", nDet, extensionName);
-    for (long s=0; s<nDet; s++) {
-
-        fitsIn->getColumnVector(fitsIn, aperFluxColNum,s, type, repeat, vector);
-        for (int i=0; i<repeat; i++) stackApFlxFluxes[i].flx[s] = vector[i];
-
-        fitsIn->getColumnVector(fitsIn, aperFluxErrColNum,s, type, repeat, vector);
-        for (int i=0; i<repeat; i++) stackApFlxFluxes[i].flxErr[s] = vector[i];
-
-        fitsIn->getColumnVector(fitsIn, aperFluxStDevColNum,s, type, repeat, vector);
-        for (int i=0; i<repeat; i++) stackApFlxFluxes[i].flxStd[s] = vector[i];
-
-        fitsIn->getColumnVector(fitsIn, aperFluxFillColNum,s, type, repeat, vector);
-        for (int i=0; i<repeat; i++) stackApFlxFluxes[i].flxFill[s] = vector[i];
-
-    }
-
-    free(vector);
-
-    //int status = 0;
-    this->base.fitsGenerator->createAndPopulateTable(this->base.fitsGenerator, fitsIn, this->base.fitsOut, nDet, "StackApFlx", false);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, STACKAPFLX_FILTERID, 1, 1, nDet, filterIDs);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, STACKAPFLX_SURVEYID, 1, 1, nDet, surveyIDs);
-
-    // R1->r10 flux values
-    // 1
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR1, 1, 1, nDet, stackApFlxFluxes[0].flx);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR1ERR, 1, 1, nDet, stackApFlxFluxes[0].flxErr);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR1STD, 1, 1, nDet, stackApFlxFluxes[0].flxStd);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR1FILL, 1, 1, nDet, stackApFlxFluxes[0].flxFill);
-    // 2
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR2, 1, 1, nDet, stackApFlxFluxes[1].flx);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR2ERR, 1, 1, nDet, stackApFlxFluxes[1].flxErr);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR2STD, 1, 1, nDet, stackApFlxFluxes[1].flxStd);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR2FILL, 1, 1, nDet, stackApFlxFluxes[1].flxFill);
-    // 3
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR3, 1, 1, nDet, stackApFlxFluxes[2].flx);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR3ERR, 1, 1, nDet, stackApFlxFluxes[2].flxErr);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR3STD, 1, 1, nDet, stackApFlxFluxes[2].flxStd);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR3FILL, 1, 1, nDet, stackApFlxFluxes[2].flxFill);
-    // 4
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR4, 1, 1, nDet, stackApFlxFluxes[3].flx);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR4ERR, 1, 1, nDet, stackApFlxFluxes[3].flxErr);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR4STD, 1, 1, nDet, stackApFlxFluxes[3].flxStd);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR4FILL, 1, 1, nDet, stackApFlxFluxes[3].flxFill);
-    // 5
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR5, 1, 1, nDet, stackApFlxFluxes[4].flx);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR5ERR, 1, 1, nDet, stackApFlxFluxes[4].flxErr);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR5STD, 1, 1, nDet, stackApFlxFluxes[4].flxStd);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR5FILL, 1, 1, nDet, stackApFlxFluxes[4].flxFill);
-    // 6
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR6, 1, 1, nDet, stackApFlxFluxes[5].flx);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR6ERR, 1, 1, nDet, stackApFlxFluxes[5].flxErr);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR6STD, 1, 1, nDet, stackApFlxFluxes[5].flxStd);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR6FILL, 1, 1, nDet, stackApFlxFluxes[5].flxFill);
-    // 7
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR7, 1, 1, nDet, stackApFlxFluxes[6].flx);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR7ERR, 1, 1, nDet, stackApFlxFluxes[6].flxErr);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR7STD, 1, 1, nDet, stackApFlxFluxes[6].flxStd);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR7FILL, 1, 1, nDet, stackApFlxFluxes[6].flxFill);
-    // 8
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR8, 1, 1, nDet, stackApFlxFluxes[7].flx);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR8ERR, 1, 1, nDet, stackApFlxFluxes[7].flxErr);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR8STD, 1, 1, nDet, stackApFlxFluxes[7].flxStd);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR8FILL, 1, 1, nDet, stackApFlxFluxes[7].flxFill);
-    // 9
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR9, 1, 1, nDet, stackApFlxFluxes[8].flx);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR9ERR, 1, 1, nDet, stackApFlxFluxes[8].flxErr);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR9STD, 1, 1, nDet, stackApFlxFluxes[8].flxStd);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR9FILL, 1, 1, nDet, stackApFlxFluxes[8].flxFill);
-    // 10
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR10, 1, 1, nDet, stackApFlxFluxes[9].flx);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR10ERR, 1, 1, nDet, stackApFlxFluxes[9].flxErr);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR10STD, 1, 1, nDet, stackApFlxFluxes[9].flxStd);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TFLOAT, STACKAPFLX_FLXR10FILL, 1, 1, nDet, stackApFlxFluxes[9].flxFill);
-
-    for (long i=0; i<11; i++) {
-
-        free(stackApFlxFluxes[i].flx);
-        free(stackApFlxFluxes[i].flxErr);
-        free(stackApFlxFluxes[i].flxStd);
-        free(stackApFlxFluxes[i].flxFill);
-    }
-
-    free(stackApFlxFluxes);
-
-    return true;
-}
-
-/**
-  Creates the StackModelFit table
-  */
-static bool createStackModelFitTable(
-        StackBatch* this,
-        Fits *fitsIn,
-        int8_t* filterIDs,
-        int8_t* surveyIDs) {
-
-    long nDet = 0;
-    char extensionName[40];
-    sprintf(extensionName, "SkyChip.xfit");
-    if (!fitsIn->moveToBinaryTableAndCountRows(fitsIn, extensionName, &nDet)) return false;
-
-    long* ippIdets = (long*)calloc(this->MAXDETECT, sizeof(long));
-    char** modelTypes = (char**)calloc(this->MAXDETECT, sizeof(char**));
-    for (uint32_t i=0; i<this->MAXDETECT;i++) modelTypes[i] = (char*)calloc(20,sizeof(char));
-
-    // read whole columns
-    fitsIn->readColumnUsingName(fitsIn, TLONG, "IPP_IDET", 1, 1, nDet, ippIdets);
-    fitsIn->readColumnUsingName(fitsIn, TSTRING, "MODEL_TYPE", 1, 1, nDet, modelTypes);
-
-    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch", 
-            "Looping through %ld model fit rows from '%s'\n", nDet, extensionName);
-    for (long i = 0; i<nDet; i++) {
-
-        printf("IPP_IDET %ld model %s\n", ippIdets[i], modelTypes[i]);
-
-    }
-
-    this->base.fitsGenerator->createAndPopulateTable(this->base.fitsGenerator, fitsIn, this->base.fitsOut, nDet, "StackModelFit", false);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, STACKMODELFIT_FILTERID, 1, 1, nDet, filterIDs);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, STACKMODELFIT_SURVEYID, 1, 1, nDet, surveyIDs);
-
-    // free up
-    free(ippIdets);
-    for (uint32_t i=0; i<this->MAXDETECT;i++) free(modelTypes[i]);
-    free(modelTypes);
-
-    return true;
-}
-
-/**
-  Creates the StackToImage table
-  */
-static bool createStackToImageTable(
-        StackBatch* this,
-        Fits* fitsIn
-        ) {
-
-    this->base.fitsGenerator->createAndPopulateTable(this->base.fitsGenerator, fitsIn, this->base.fitsOut, 3/*TODO*/, "StackToImage", false);
-
-    return true;
-}
-
-/**
-  Does the work. Writes all extensions to new FITS file.
-  */
-static int run(StackBatch* this) {
-
-    if (this->base.exitCode != PS_EXIT_SUCCESS) return this->base.exitCode; 
-
-    // open input FITS file
-    Fits* fitsIn = existing_Fits(this->base.inputFiles[0], this->base.logger);
-    if (fitsIn->getFilePtr(fitsIn) == NULL)  return PS_EXIT_SYS_ERROR;
-
-    // get primary header and pull stuff out for later
-    float exposureTime; fitsIn->getHeaderKeyValue(fitsIn, TFLOAT, "EXPTIME", &exposureTime);
-    char filterType[20]; fitsIn->getHeaderKeyValue(fitsIn, TSTRING, "FILTER", filterType);
-
-    int8_t filterID = -1;
-    if (!this->base.initData->getFilterId(this->base.initData, filterType, &filterID)) {
-
-        //        this->base.exitCode = PS_EXIT_DATA_ERROR;
-        //    return this->base.exitCode; TODO
-    }
-
-    exposureTime = 60.0;// TODO
-    filterID = 3; // TODO
-
-    // write StackMeta
-    this->base.fitsGenerator->createAndPopulateTable(this->base.fitsGenerator, fitsIn, this->base.fitsOut, 1, "StackMeta", true);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TLONG, STACKMETA_SKYCELLID, 1, 1, 1, &this->skycellId);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, STACKMETA_FILTERID, 1, 1, 1, &filterID);
-    this->base.fitsOut->writeColumn(this->base.fitsOut, TBYTE, STACKMETA_SURVEYID, 1, 1, 1, &this->base.surveyID);
-
-    // allocate stuff for other extensions
-    int8_t* filterIDs = (int8_t*)calloc(this->MAXDETECT, sizeof(int8_t));
-    int8_t* surveyIDs = (int8_t*)calloc(this->MAXDETECT, sizeof(int8_t));
-    long* skycellIDs = (long*)calloc(this->MAXDETECT, sizeof(long));
-
-    // some stuff is the same for all detections so we can populate here
-    for (long s = 0; s<this->MAXDETECT; s++) {
-
-        skycellIDs[s] = this->skycellId;
-        filterIDs[s] = filterID;
-        surveyIDs[s] = this->base.surveyID;
-    }
-
-    // create all extensions
-    createStackDetectionTable(this, fitsIn, filterIDs, surveyIDs, skycellIDs, exposureTime);
-    createStackApFlxTable(this, fitsIn, filterIDs, surveyIDs);
-    createStackModelFitTable(this, fitsIn, filterIDs, surveyIDs);
-    createStackToImageTable(this, fitsIn);
-
-    // free stuff up
-    free(filterIDs);
-    free(surveyIDs);
-    free(skycellIDs);
-    fitsIn->destroy(fitsIn);
-
-    return this->base.exitCode;
-}
-
-/**
-  Print-out this class. Calls base-calls print method first.
-  */
-static void print(StackBatch* this) {
-
-    this->base.print(&this->base);
-
-    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch", "skycell ID      : %d\n", this->skycellId);
-    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch", "\n");
-}
-
-/**
-  Reads command-line arguments.  Calls base-calls print method first.
-  */
-static bool parseArguments(StackBatch* this, int argc, char **argv) {
-
-    bool haveSkycellId = false;
-
-    int32_t optind = 1;
-    while( ( optind < argc ) ) {
-
-        char * sw = argv[optind];
-
-        if( argv[optind][0] == '-' ) { 
-
-            if(strcmp(sw, "-skycellid") == 0 ) {
-                optind++; if( optind > ( argc-1 ) ) break;
-                this->skycellId = atoi(argv[optind]);
-                haveSkycellId = true;
-            }
-        }
-        optind++;
-    }
-
-    char fitsOutFile[40];
-    sprintf(fitsOutFile, "%08d.FITS", this->skycellId);
-    this->base.parseArguments(&this->base, argc, argv, "/stack", fitsOutFile);
-
-    if (
-            !this->base.gotResultsPath() ||
-            !this->base.gotFitsInPath() ||
-            !this->base.gotFitsOutPath() ||
-            !this->base.gotConfig() ||
-            !this->base.gotSurveyType() ||
-            !haveSkycellId) {
-
-        printf("\n* ERROR with supplied arguments:");
-        this->print(this);
-        this->base.exitCode = PS_EXIT_CONFIG_ERROR;
-        return false;
-    }
-
-    return true;
-}
-
-/**
-  Constructor
-  */
-StackBatch* new_StackBatch(Logger* logger, int *argc, char **argv) {
-
-    logger->print(logger, MSG_DEBUG, "StackBatch", "Constructor\n");
-    StackBatch *this = (StackBatch*)calloc(1, sizeof(StackBatch));
-
-    // call base-class constructor
-    new_Batch(logger, &this->base);
-
-    this->MAXDETECT = 150000;
-
-    // method pointers
-    this->print = print;
-    this->destroy = destroy;
-    this->base.run = run;
-
-    parseArguments(this, *argc, argv);
-
-    this->print(this);
-
-    return this;
-}
-
-/**
-  Main
-  */
-int main(int argc, char **argv) {
-
-//    ippToPsps_VersionPrint();
-
-    Logger* logger = new_Logger(NULL, false);
-    logger->print(logger, MSG_INFO, "main", "Creating new stack batch\n");
-
-    StackBatch* stackBatch = new_StackBatch(logger, &argc, argv);
-    stackBatch->base.run(stackBatch);
-    int exitCode = stackBatch->base.exitCode;
-
-    stackBatch->destroy(stackBatch);
-
-    // tidy up
-    logger->destroy(logger);
-    psLibFinalize();
-
-    return exitCode;
-}
-
Index: trunk/ippToPsps/src/StackBatch.h
===================================================================
--- trunk/ippToPsps/src/StackBatch.h	(revision 32007)
+++ 	(revision )
@@ -1,34 +1,0 @@
-/** @file StackBatch.h
- *
- *  @brief StackBatch
- *
- *  @ingroup ippToPsps
- *
- *  @author IfA
- *  Copyright 2009 Institute for Astronomy, University of Hawaii
- */
-
-#ifndef IPPTOPSPS_STACKBATCH_H
-#define IPPTOPSPS_STACKBATCH_H
-
-#include "Batch.h"
-
-/**
-  Sub-class of Batch for detections
-  */
-typedef struct StackBatch {
-
-    // fields
-    Batch base;             // base class
-    size_t MAXDETECT;       // max number of detections
-    uint32_t skycellId;     // skycell ID
-
-    // methods
-    void (*print)();
-    void (*destroy)();
-
-} StackBatch;
-
-StackBatch *new_StackBatch(Logger* logger, int *argc, char **argv);
-
-# endif // IPPTOPSPS_STACKBATCH_H 
Index: trunk/ippToPsps/src/StackBatchEnums.h
===================================================================
--- trunk/ippToPsps/src/StackBatchEnums.h	(revision 32007)
+++ 	(revision )
@@ -1,392 +1,0 @@
-#ifndef STACKBATCHENUMS_H
-#define STACKBATCHENUMS_H
-
-
-typedef enum {
-  STACKMETA_STACKMETAID = 1,
-  STACKMETA_SKYCELLID = 2,
-  STACKMETA_SURVEYID = 3,
-  STACKMETA_PHOTOCALID = 4,
-  STACKMETA_FILTERID = 5,
-  STACKMETA_STACKTYPEID = 6,
-  STACKMETA_STACKGROUPID = 7,
-  STACKMETA_MAGSAT = 8,
-  STACKMETA_ANALVER = 9,
-  STACKMETA_NP2IMAGES = 10,
-  STACKMETA_COMPLETMAG = 11,
-  STACKMETA_ASTROSCAT = 12,
-  STACKMETA_PHOTOSCAT = 13,
-  STACKMETA_NASTROREF = 14,
-  STACKMETA_NPHOREF = 15,
-  STACKMETA_MEAN = 16,
-  STACKMETA_MAX = 17,
-  STACKMETA_PHOTOZERO = 18,
-  STACKMETA_PHOTOCOLOR = 19,
-  STACKMETA_CTYPE1 = 20,
-  STACKMETA_CTYPE2 = 21,
-  STACKMETA_CRVAL1 = 22,
-  STACKMETA_CRVAL2 = 23,
-  STACKMETA_CRPIX1 = 24,
-  STACKMETA_CRPIX2 = 25,
-  STACKMETA_CDELT1 = 26,
-  STACKMETA_CDELT2 = 27,
-  STACKMETA_PC001001 = 28,
-  STACKMETA_PC001002 = 29,
-  STACKMETA_PC002001 = 30,
-  STACKMETA_PC002002 = 31,
-  STACKMETA_CALIBMODNUM = 32,
-  STACKMETA_DATARELEASE = 33,
-} StackMeta;
-
-typedef enum {
-  STACKDETECTION_OBJID = 1,
-  STACKDETECTION_STACKDETECTID = 2,
-  STACKDETECTION_IPPOBJID = 3,
-  STACKDETECTION_IPPDETECTID = 4,
-  STACKDETECTION_FILTERID = 5,
-  STACKDETECTION_STACKTYPEID = 6,
-  STACKDETECTION_STACKGROUPID = 7,
-  STACKDETECTION_SURVEYID = 8,
-  STACKDETECTION_PRIMARYF = 9,
-  STACKDETECTION_STACKMETAID = 10,
-  STACKDETECTION_SKYCELLID = 11,
-  STACKDETECTION_PROJECTIONCELLID = 12,
-  STACKDETECTION_STACKVER = 13,
-  STACKDETECTION_OBSTIME = 14,
-  STACKDETECTION_XPOS = 15,
-  STACKDETECTION_YPOS = 16,
-  STACKDETECTION_XPOSERR = 17,
-  STACKDETECTION_YPOSERR = 18,
-  STACKDETECTION_INSTFLUX = 19,
-  STACKDETECTION_INSTFLUXERR = 20,
-  STACKDETECTION_PEAKFLUX = 21,
-  STACKDETECTION_SKY = 22,
-  STACKDETECTION_SKYERR = 23,
-  STACKDETECTION_SGSEP = 24,
-  STACKDETECTION_PSFWIDMAJOR = 25,
-  STACKDETECTION_PSFWIDMINOR = 26,
-  STACKDETECTION_PSFTHETA = 27,
-  STACKDETECTION_PSFLIKELIHOOD = 28,
-  STACKDETECTION_PSFCF = 29,
-  STACKDETECTION_INFOFLAG = 30,
-  STACKDETECTION_NFRAMES = 31,
-  STACKDETECTION_ACTIVEFLAG = 32,
-  STACKDETECTION_ASSOCDATE = 33,
-  STACKDETECTION_HISTORYMODNUM = 34,
-  STACKDETECTION_DATARELEASE = 35,
-} StackDetection;
-
-typedef enum {
-  STACKAPFLX_OBJID = 1,
-  STACKAPFLX_STACKDETECTID = 2,
-  STACKAPFLX_IPPOBJID = 3,
-  STACKAPFLX_IPPDETECTID = 4,
-  STACKAPFLX_FILTERID = 5,
-  STACKAPFLX_STACKTYPEID = 6,
-  STACKAPFLX_STACKGROUPID = 7,
-  STACKAPFLX_SURVEYID = 8,
-  STACKAPFLX_PRIMARYF = 9,
-  STACKAPFLX_STACKMETAID = 10,
-  STACKAPFLX_ISOPHOTMAG = 11,
-  STACKAPFLX_ISOPHOTMAGERR = 12,
-  STACKAPFLX_ISOPHOTMAJAXIS = 13,
-  STACKAPFLX_ISOPHOTMAJAXISERR = 14,
-  STACKAPFLX_ISOPHOTMINAXIS = 15,
-  STACKAPFLX_ISOPHOTMINAXISERR = 16,
-  STACKAPFLX_ISOPHOTMAJAXISGRAD = 17,
-  STACKAPFLX_ISOPHOTMINAXISGRAD = 18,
-  STACKAPFLX_ISOPHOTPA = 19,
-  STACKAPFLX_ISOPHOTPAERR = 20,
-  STACKAPFLX_ISOPHOTPAGRAD = 21,
-  STACKAPFLX_PETRADIUS = 22,
-  STACKAPFLX_PETRADIUSERR = 23,
-  STACKAPFLX_PETMAG = 24,
-  STACKAPFLX_PETMAGERR = 25,
-  STACKAPFLX_PETR50 = 26,
-  STACKAPFLX_PETR50ERR = 27,
-  STACKAPFLX_PETR90 = 28,
-  STACKAPFLX_PETR90ERR = 29,
-  STACKAPFLX_PETCF = 30,
-  STACKAPFLX_FLXR1 = 31,
-  STACKAPFLX_FLXR1ERR = 32,
-  STACKAPFLX_FLXR1STD = 33,
-  STACKAPFLX_FLXR1FILL = 34,
-  STACKAPFLX_FLXR2 = 35,
-  STACKAPFLX_FLXR2ERR = 36,
-  STACKAPFLX_FLXR2STD = 37,
-  STACKAPFLX_FLXR2FILL = 38,
-  STACKAPFLX_FLXR3 = 39,
-  STACKAPFLX_FLXR3ERR = 40,
-  STACKAPFLX_FLXR3STD = 41,
-  STACKAPFLX_FLXR3FILL = 42,
-  STACKAPFLX_FLXR4 = 43,
-  STACKAPFLX_FLXR4ERR = 44,
-  STACKAPFLX_FLXR4STD = 45,
-  STACKAPFLX_FLXR4FILL = 46,
-  STACKAPFLX_FLXR5 = 47,
-  STACKAPFLX_FLXR5ERR = 48,
-  STACKAPFLX_FLXR5STD = 49,
-  STACKAPFLX_FLXR5FILL = 50,
-  STACKAPFLX_FLXR6 = 51,
-  STACKAPFLX_FLXR6ERR = 52,
-  STACKAPFLX_FLXR6STD = 53,
-  STACKAPFLX_FLXR6FILL = 54,
-  STACKAPFLX_FLXR7 = 55,
-  STACKAPFLX_FLXR7ERR = 56,
-  STACKAPFLX_FLXR7STD = 57,
-  STACKAPFLX_FLXR7FILL = 58,
-  STACKAPFLX_FLXR8 = 59,
-  STACKAPFLX_FLXR8ERR = 60,
-  STACKAPFLX_FLXR8STD = 61,
-  STACKAPFLX_FLXR8FILL = 62,
-  STACKAPFLX_FLXR9 = 63,
-  STACKAPFLX_FLXR9ERR = 64,
-  STACKAPFLX_FLXR9STD = 65,
-  STACKAPFLX_FLXR9FILL = 66,
-  STACKAPFLX_FLXR10 = 67,
-  STACKAPFLX_FLXR10ERR = 68,
-  STACKAPFLX_FLXR10STD = 69,
-  STACKAPFLX_FLXR10FILL = 70,
-  STACKAPFLX_C1FLXR1 = 71,
-  STACKAPFLX_C1FLXR1ERR = 72,
-  STACKAPFLX_C1FLXR1STD = 73,
-  STACKAPFLX_C1FLXR1FILL = 74,
-  STACKAPFLX_C1FLXR2 = 75,
-  STACKAPFLX_C1FLXR2ERR = 76,
-  STACKAPFLX_C1FLXR2STD = 77,
-  STACKAPFLX_C1FLXR2FILL = 78,
-  STACKAPFLX_C1FLXR3 = 79,
-  STACKAPFLX_C1FLXR3ERR = 80,
-  STACKAPFLX_C1FLXR3STD = 81,
-  STACKAPFLX_C1FLXR3FILL = 82,
-  STACKAPFLX_C1FLXR4 = 83,
-  STACKAPFLX_C1FLXR4ERR = 84,
-  STACKAPFLX_C1FLXR4STD = 85,
-  STACKAPFLX_C1FLXR4FILL = 86,
-  STACKAPFLX_C1FLXR5 = 87,
-  STACKAPFLX_C1FLXR5ERR = 88,
-  STACKAPFLX_C1FLXR5STD = 89,
-  STACKAPFLX_C1FLXR5FILL = 90,
-  STACKAPFLX_C1FLXR6 = 91,
-  STACKAPFLX_C1FLXR6ERR = 92,
-  STACKAPFLX_C1FLXR6STD = 93,
-  STACKAPFLX_C1FLXR6FILL = 94,
-  STACKAPFLX_C1FLXR7 = 95,
-  STACKAPFLX_C1FLXR7ERR = 96,
-  STACKAPFLX_C1FLXR7STD = 97,
-  STACKAPFLX_C1FLXR7FILL = 98,
-  STACKAPFLX_C1FLXR8 = 99,
-  STACKAPFLX_C1FLXR8ERR = 100,
-  STACKAPFLX_C1FLXR8STD = 101,
-  STACKAPFLX_C1FLXR8FILL = 102,
-  STACKAPFLX_C1FLXR9 = 103,
-  STACKAPFLX_C1FLXR9ERR = 104,
-  STACKAPFLX_C1FLXR9STD = 105,
-  STACKAPFLX_C1FLXR9FILL = 106,
-  STACKAPFLX_C1FLXR10 = 107,
-  STACKAPFLX_C1FLXR10ERR = 108,
-  STACKAPFLX_C1FLXR10STD = 109,
-  STACKAPFLX_C1FLXR10FILL = 110,
-  STACKAPFLX_C2FLXR1 = 111,
-  STACKAPFLX_C2FLXR1ERR = 112,
-  STACKAPFLX_C2FLXR1STD = 113,
-  STACKAPFLX_C2FLXR1FILL = 114,
-  STACKAPFLX_C2FLXR2 = 115,
-  STACKAPFLX_C2FLXR2ERR = 116,
-  STACKAPFLX_C2FLXR2STD = 117,
-  STACKAPFLX_C2FLXR2FILL = 118,
-  STACKAPFLX_C2FLXR3 = 119,
-  STACKAPFLX_C2FLXR3ERR = 120,
-  STACKAPFLX_C2FLXR3STD = 121,
-  STACKAPFLX_C2FLXR3FILL = 122,
-  STACKAPFLX_C2FLXR4 = 123,
-  STACKAPFLX_C2FLXR4ERR = 124,
-  STACKAPFLX_C2FLXR4STD = 125,
-  STACKAPFLX_C2FLXR4FILL = 126,
-  STACKAPFLX_C2FLXR5 = 127,
-  STACKAPFLX_C2FLXR5ERR = 128,
-  STACKAPFLX_C2FLXR5STD = 129,
-  STACKAPFLX_C2FLXR5FILL = 130,
-  STACKAPFLX_C2FLXR6 = 131,
-  STACKAPFLX_C2FLXR6ERR = 132,
-  STACKAPFLX_C2FLXR6STD = 133,
-  STACKAPFLX_C2FLXR6FILL = 134,
-  STACKAPFLX_C2FLXR7 = 135,
-  STACKAPFLX_C2FLXR7ERR = 136,
-  STACKAPFLX_C2FLXR7STD = 137,
-  STACKAPFLX_C2FLXR7FILL = 138,
-  STACKAPFLX_C2FLXR8 = 139,
-  STACKAPFLX_C2FLXR8ERR = 140,
-  STACKAPFLX_C2FLXR8STD = 141,
-  STACKAPFLX_C2FLXR8FILL = 142,
-  STACKAPFLX_C2FLXR9 = 143,
-  STACKAPFLX_C2FLXR9ERR = 144,
-  STACKAPFLX_C2FLXR9STD = 145,
-  STACKAPFLX_C2FLXR9FILL = 146,
-  STACKAPFLX_C2FLXR10 = 147,
-  STACKAPFLX_C2FLXR10ERR = 148,
-  STACKAPFLX_C2FLXR10STD = 149,
-  STACKAPFLX_C2FLXR10FILL = 150,
-  STACKAPFLX_LOGC = 151,
-  STACKAPFLX_LOGA = 152,
-  STACKAPFLX_ACTIVEFLAG = 153,
-  STACKAPFLX_DATARELEASE = 154,
-} StackApFlx;
-
-typedef enum {
-  STACKMODELFIT_OBJID = 1,
-  STACKMODELFIT_STACKDETECTID = 2,
-  STACKMODELFIT_IPPOBJID = 3,
-  STACKMODELFIT_IPPDETECTID = 4,
-  STACKMODELFIT_FILTERID = 5,
-  STACKMODELFIT_STACKTYPEID = 6,
-  STACKMODELFIT_STACKGROUPID = 7,
-  STACKMODELFIT_SURVEYID = 8,
-  STACKMODELFIT_PRIMARYF = 9,
-  STACKMODELFIT_STACKMETAID = 10,
-  STACKMODELFIT_DEVRADIUS = 11,
-  STACKMODELFIT_DEVRADIUSERR = 12,
-  STACKMODELFIT_DEVMAG = 13,
-  STACKMODELFIT_DEVMAGERR = 14,
-  STACKMODELFIT_DEVAB = 15,
-  STACKMODELFIT_DEVABERR = 16,
-  STACKMODELFIT_DEVPHI = 17,
-  STACKMODELFIT_DEVPHIERR = 18,
-  STACKMODELFIT_RADEVOFF = 19,
-  STACKMODELFIT_DECDEVOFF = 20,
-  STACKMODELFIT_RADEVOFFERR = 21,
-  STACKMODELFIT_DECDEVOFFERR = 22,
-  STACKMODELFIT_DEVCF = 23,
-  STACKMODELFIT_DEVLIKELIHOOD = 24,
-  STACKMODELFIT_DEVCOVAR11 = 25,
-  STACKMODELFIT_DEVCOVAR12 = 26,
-  STACKMODELFIT_DEVCOVAR13 = 27,
-  STACKMODELFIT_DEVCOVAR14 = 28,
-  STACKMODELFIT_DEVCOVAR15 = 29,
-  STACKMODELFIT_DEVCOVAR16 = 30,
-  STACKMODELFIT_DEVCOVAR17 = 31,
-  STACKMODELFIT_DEVCOVAR22 = 32,
-  STACKMODELFIT_DEVCOVAR23 = 33,
-  STACKMODELFIT_DEVCOVAR24 = 34,
-  STACKMODELFIT_DEVCOVAR25 = 35,
-  STACKMODELFIT_DEVCOVAR26 = 36,
-  STACKMODELFIT_DEVCOVAR27 = 37,
-  STACKMODELFIT_DEVCOVAR33 = 38,
-  STACKMODELFIT_DEVCOVAR34 = 39,
-  STACKMODELFIT_DEVCOVAR35 = 40,
-  STACKMODELFIT_DEVCOVAR36 = 41,
-  STACKMODELFIT_DEVCOVAR37 = 42,
-  STACKMODELFIT_DEVCOVAR44 = 43,
-  STACKMODELFIT_DEVCOVAR45 = 44,
-  STACKMODELFIT_DEVCOVAR46 = 45,
-  STACKMODELFIT_DEVCOVAR47 = 46,
-  STACKMODELFIT_DEVCOVAR55 = 47,
-  STACKMODELFIT_DEVCOVAR56 = 48,
-  STACKMODELFIT_DEVCOVAR57 = 49,
-  STACKMODELFIT_DEVCOVAR66 = 50,
-  STACKMODELFIT_DEVCOVAR67 = 51,
-  STACKMODELFIT_DEVCOVAR77 = 52,
-  STACKMODELFIT_EXPRADIUS = 53,
-  STACKMODELFIT_EXPRADIUSERR = 54,
-  STACKMODELFIT_EXPMAG = 55,
-  STACKMODELFIT_EXPMAGERR = 56,
-  STACKMODELFIT_EXPAB = 57,
-  STACKMODELFIT_EXPABERR = 58,
-  STACKMODELFIT_EXPPHI = 59,
-  STACKMODELFIT_EXPPHIERR = 60,
-  STACKMODELFIT_RAEXPOFF = 61,
-  STACKMODELFIT_DECEXPOFF = 62,
-  STACKMODELFIT_RAEXPOFFERR = 63,
-  STACKMODELFIT_DECEXPOFFERR = 64,
-  STACKMODELFIT_EXPCF = 65,
-  STACKMODELFIT_EXPLIKELIHOOD = 66,
-  STACKMODELFIT_EXPCOVAR11 = 67,
-  STACKMODELFIT_EXPCOVAR12 = 68,
-  STACKMODELFIT_EXPCOVAR13 = 69,
-  STACKMODELFIT_EXPCOVAR14 = 70,
-  STACKMODELFIT_EXPCOVAR15 = 71,
-  STACKMODELFIT_EXPCOVAR16 = 72,
-  STACKMODELFIT_EXPCOVAR17 = 73,
-  STACKMODELFIT_EXPCOVAR22 = 74,
-  STACKMODELFIT_EXPCOVAR23 = 75,
-  STACKMODELFIT_EXPCOVAR24 = 76,
-  STACKMODELFIT_EXPCOVAR25 = 77,
-  STACKMODELFIT_EXPCOVAR26 = 78,
-  STACKMODELFIT_EXPCOVAR27 = 79,
-  STACKMODELFIT_EXPCOVAR33 = 80,
-  STACKMODELFIT_EXPCOVAR34 = 81,
-  STACKMODELFIT_EXPCOVAR35 = 82,
-  STACKMODELFIT_EXPCOVAR36 = 83,
-  STACKMODELFIT_EXPCOVAR37 = 84,
-  STACKMODELFIT_EXPCOVAR44 = 85,
-  STACKMODELFIT_EXPCOVAR45 = 86,
-  STACKMODELFIT_EXPCOVAR46 = 87,
-  STACKMODELFIT_EXPCOVAR47 = 88,
-  STACKMODELFIT_EXPCOVAR55 = 89,
-  STACKMODELFIT_EXPCOVAR56 = 90,
-  STACKMODELFIT_EXPCOVAR57 = 91,
-  STACKMODELFIT_EXPCOVAR66 = 92,
-  STACKMODELFIT_EXPCOVAR67 = 93,
-  STACKMODELFIT_EXPCOVAR77 = 94,
-  STACKMODELFIT_SERRADIUS = 95,
-  STACKMODELFIT_SERRADIUSERR = 96,
-  STACKMODELFIT_SERMAG = 97,
-  STACKMODELFIT_SERMAGERR = 98,
-  STACKMODELFIT_SERAB = 99,
-  STACKMODELFIT_SERABERR = 100,
-  STACKMODELFIT_SERNU = 101,
-  STACKMODELFIT_SERNUERR = 102,
-  STACKMODELFIT_SERPHI = 103,
-  STACKMODELFIT_SERPHIERR = 104,
-  STACKMODELFIT_RASEROFF = 105,
-  STACKMODELFIT_DECSEROFF = 106,
-  STACKMODELFIT_RASEROFFERR = 107,
-  STACKMODELFIT_DECSEROFFERR = 108,
-  STACKMODELFIT_SERCF = 109,
-  STACKMODELFIT_SERLIKELIHOOD = 110,
-  STACKMODELFIT_SERSICCOVAR11 = 111,
-  STACKMODELFIT_SERSICCOVAR12 = 112,
-  STACKMODELFIT_SERSICCOVAR13 = 113,
-  STACKMODELFIT_SERSICCOVAR14 = 114,
-  STACKMODELFIT_SERSICCOVAR15 = 115,
-  STACKMODELFIT_SERSICCOVAR16 = 116,
-  STACKMODELFIT_SERSICCOVAR17 = 117,
-  STACKMODELFIT_SERSICCOVAR18 = 118,
-  STACKMODELFIT_SERSICCOVAR22 = 119,
-  STACKMODELFIT_SERSICCOVAR23 = 120,
-  STACKMODELFIT_SERSICCOVAR24 = 121,
-  STACKMODELFIT_SERSICCOVAR25 = 122,
-  STACKMODELFIT_SERSICCOVAR26 = 123,
-  STACKMODELFIT_SERSICCOVAR27 = 124,
-  STACKMODELFIT_SERSICCOVAR28 = 125,
-  STACKMODELFIT_SERSICCOVAR33 = 126,
-  STACKMODELFIT_SERSICCOVAR34 = 127,
-  STACKMODELFIT_SERSICCOVAR35 = 128,
-  STACKMODELFIT_SERSICCOVAR36 = 129,
-  STACKMODELFIT_SERSICCOVAR37 = 130,
-  STACKMODELFIT_SERSICCOVAR38 = 131,
-  STACKMODELFIT_SERSICCOVAR44 = 132,
-  STACKMODELFIT_SERSICCOVAR45 = 133,
-  STACKMODELFIT_SERSICCOVAR46 = 134,
-  STACKMODELFIT_SERSICCOVAR47 = 135,
-  STACKMODELFIT_SERSICCOVAR48 = 136,
-  STACKMODELFIT_SERSICCOVAR55 = 137,
-  STACKMODELFIT_SERSICCOVAR56 = 138,
-  STACKMODELFIT_SERSICCOVAR57 = 139,
-  STACKMODELFIT_SERSICCOVAR58 = 140,
-  STACKMODELFIT_SERSICCOVAR66 = 141,
-  STACKMODELFIT_SERSICCOVAR67 = 142,
-  STACKMODELFIT_SERSICCOVAR68 = 143,
-  STACKMODELFIT_SERSICCOVAR77 = 144,
-  STACKMODELFIT_SERSICCOVAR78 = 145,
-  STACKMODELFIT_SERSICCOVAR88 = 146,
-  STACKMODELFIT_ACTIVEFLAG = 147,
-  STACKMODELFIT_DATARELEASE = 148,
-} StackModelFit;
-
-typedef enum {
-  STACKTOIMAGE_STACKMETAID = 1,
-  STACKTOIMAGE_IMAGEID = 2,
-} StackToImage;
-
-#endif
