Index: trunk/ippToPsps/config/test/map.xml
===================================================================
--- trunk/ippToPsps/config/test/map.xml	(revision 28758)
+++ trunk/ippToPsps/config/test/map.xml	(revision 28759)
@@ -3,96 +3,7 @@
 <tabledata>
 
- <table name="FrameMeta">
-  <map ippName="ZPT_ERR" ippType="TFLOAT" pspsName="photoScat" />
-  <map ippName="MJD-OBS" ippType="TFLOAT" pspsName="expStart" />
-  <map ippName="EXPREQ" ippType="TFLOAT" pspsName="expTime" />
-  <map ippName="AIRMASS" ippType="TFLOAT" pspsName="airmass" />
-  <map ippName="RA" ippType="TDOUBLE" pspsName="raBore" />
-  <map ippName="DEC" ippType="TDOUBLE" pspsName="decBore" />
-  <map ippName="CTYPE1" ippType="TSTRING" pspsName="ctype1" />
-  <map ippName="CTYPE2" ippType="TSTRING" pspsName="ctype2" />
-  <map ippName="CRVAL1" ippType="TDOUBLE" pspsName="crval1" />
-  <map ippName="CRVAL2" ippType="TDOUBLE" pspsName="crval2" />
-  <map ippName="CRPIX1" ippType="TDOUBLE" pspsName="crpix1" />
-  <map ippName="CRPIX2" ippType="TDOUBLE" pspsName="crpix2" />
-  <map ippName="CDELT1" ippType="TDOUBLE" pspsName="cdelt1" />
-  <map ippName="CDELT2" ippType="TDOUBLE" pspsName="cdelt2" />
-  <map ippName="PC001001" ippType="TDOUBLE" pspsName="pc001001" />
-  <map ippName="PC001002" ippType="TDOUBLE" pspsName="pc001002" />
-  <map ippName="PC002001" ippType="TDOUBLE" pspsName="pc002001" />
-  <map ippName="PC002002" ippType="TDOUBLE" pspsName="pc002002" />
-  <map ippName="NPLYTERM" ippType="TBYTE" pspsName="polyOrder" />
-  <map ippName="PCA1X3Y0" ippType="TDOUBLE" pspsName="pca1x3y0" />
-  <map ippName="PCA1X2Y1" ippType="TDOUBLE" pspsName="pca1x2y1" />
-  <map ippName="PCA1X1Y2" ippType="TDOUBLE" pspsName="pca1x1y2" />
-  <map ippName="PCA1X0Y3" ippType="TDOUBLE" pspsName="pca1x0y3" />
-  <map ippName="PCA1X2Y0" ippType="TDOUBLE" pspsName="pca1x2y0" />
-  <map ippName="PCA1X1Y1" ippType="TDOUBLE" pspsName="pca1x1y1" />
-  <map ippName="PCA1X0Y2" ippType="TDOUBLE" pspsName="pca1x0y2" />
-  <map ippName="PCA2X3Y0" ippType="TDOUBLE" pspsName="pca2x3y0" />
-  <map ippName="PCA2X2Y1" ippType="TDOUBLE" pspsName="pca2x2y1" />
-  <map ippName="PCA2X1Y2" ippType="TDOUBLE" pspsName="pca2x1y2" />
-  <map ippName="PCA2X0Y3" ippType="TDOUBLE" pspsName="pca2x0y3" />
-  <map ippName="PCA2X2Y0" ippType="TDOUBLE" pspsName="pca2x2y0" />
-  <map ippName="PCA2X1Y1" ippType="TDOUBLE" pspsName="pca2x1y1" />
-  <map ippName="PCA2X0Y2" ippType="TDOUBLE" pspsName="pca2x0y2" />
- </table>
-
- <table name="ImageMeta">
-  <map ippName="MSKY_MN" ippType="TFLOAT" pspsName="sky" />
-  <map ippName="MSKY_SIG" ippType="TFLOAT" pspsName="skyScat" />
-  <map ippName="FSATUR" ippType="TFLOAT" pspsName="magSat" />
-  <map ippName="FLIMIT" ippType="TFLOAT" pspsName="completMag" />
-  <map ippName="CERROR" ippType="TFLOAT" pspsName="astroScat" />
-  <map ippName="NASTRO" ippType="TLONG" pspsName="numAstroRef" />
-  <map ippName="CNAXIS1" ippType="TSHORT" pspsName="nx" />
-  <map ippName="CNAXIS2" ippType="TSHORT" pspsName="ny" />
-  <map ippName="FWHM_MAJ" ippType="TFLOAT" pspsName="psfWidMajor" />
-  <map ippName="FWHM_MIN" ippType="TFLOAT" pspsName="psfWidMinor" />
-  <map ippName="ANGLE" ippType="TFLOAT" pspsName="psfTheta" />
-  <map ippName="APMIFIT" ippType="TFLOAT" pspsName="apResid" />
-  <map ippName="DAPMIFIT" ippType="TFLOAT" pspsName="dapResid" />
-  <map ippName="CTYPE1" ippType="TSTRING" pspsName="ctype1" />
-  <map ippName="CTYPE2" ippType="TSTRING" pspsName="ctype2" />
-  <map ippName="CRVAL1" ippType="TDOUBLE" pspsName="crval1" />
-  <map ippName="CRVAL2" ippType="TDOUBLE" pspsName="crval2" />
-  <map ippName="CRPIX1" ippType="TDOUBLE" pspsName="crpix1" />
-  <map ippName="CRPIX2" ippType="TDOUBLE" pspsName="crpix2" />
-  <map ippName="CDELT1" ippType="TDOUBLE" pspsName="cdelt1" />
-  <map ippName="CDELT2" ippType="TDOUBLE" pspsName="cdelt2" />
-  <map ippName="PC001001" ippType="TDOUBLE" pspsName="pc001001" />
-  <map ippName="PC001002" ippType="TDOUBLE" pspsName="pc001002" />
-  <map ippName="PC002001" ippType="TDOUBLE" pspsName="pc002001" />
-  <map ippName="PC002002" ippType="TDOUBLE" pspsName="pc002002" />
-  <map ippName="NPLYTERM" ippType="TBYTE" pspsName="polyOrder" />
-  <map ippName="PCA1X3Y0" ippType="TDOUBLE" pspsName="pca1x3y0" />
-  <map ippName="PCA1X2Y1" ippType="TDOUBLE" pspsName="pca1x2y1" />
-  <map ippName="PCA1X1Y2" ippType="TDOUBLE" pspsName="pca1x1y2" />
-  <map ippName="PCA1X0Y3" ippType="TDOUBLE" pspsName="pca1x0y3" />
-  <map ippName="PCA1X2Y0" ippType="TDOUBLE" pspsName="pca1x2y0" />
-  <map ippName="PCA1X1Y1" ippType="TDOUBLE" pspsName="pca1x1y1" />
-  <map ippName="PCA1X0Y2" ippType="TDOUBLE" pspsName="pca1x0y2" />
-  <map ippName="PCA2X3Y0" ippType="TDOUBLE" pspsName="pca2x3y0" />
-  <map ippName="PCA2X2Y1" ippType="TDOUBLE" pspsName="pca2x2y1" />
-  <map ippName="PCA2X1Y2" ippType="TDOUBLE" pspsName="pca2x1y2" />
-  <map ippName="PCA2X0Y3" ippType="TDOUBLE" pspsName="pca2x0y3" />
-  <map ippName="PCA2X2Y0" ippType="TDOUBLE" pspsName="pca2x2y0" />
-  <map ippName="PCA2X1Y1" ippType="TDOUBLE" pspsName="pca2x1y1" />
-  <map ippName="PCA2X0Y2" ippType="TDOUBLE" pspsName="pca2x0y2" />
- </table>
-
  <table name="Detection">
-  <map ippName="X_PSF" ippType="TFLOAT" pspsName="xPos" />
-  <map ippName="Y_PSF" ippType="TFLOAT" pspsName="yPos" />
-  <map ippName="X_PSF_SIG" ippType="TFLOAT" pspsName="xPosErr" />
-  <map ippName="Y_PSF_SIG" ippType="TFLOAT" pspsName="yPosErr" />
-  <map ippName="RA_PSF" ippType="TFLOAT" pspsName="ippRa" />
-  <map ippName="DEC_PSF" ippType="TFLOAT" pspsName="ippDec" />
-  <map ippName="PSF_MAJOR" ippType="TFLOAT" pspsName="psfWidMajor" />
-  <map ippName="PSF_MINOR" ippType="TFLOAT" pspsName="psfWidMinor" />
-  <map ippName="PSF_THETA" ippType="TFLOAT" pspsName="psfTheta" />
-  <map ippName="PSF_QF" ippType="TFLOAT" pspsName="psfCf" />
-  <map ippName="SKY" ippType="TFLOAT" pspsName="sky" />
-  <map ippName="SKY_SIGMA" ippType="TFLOAT" pspsName="skyErr" />
+  <map ippName="RA_PSF" ippType="TFLOAT" pspsName="ra" />
+  <map ippName="DEC_PSF" ippType="TFLOAT" pspsName="dec" />
  </table>
 
Index: trunk/ippToPsps/config/test/tables.xml
===================================================================
--- trunk/ippToPsps/config/test/tables.xml	(revision 28758)
+++ trunk/ippToPsps/config/test/tables.xml	(revision 28759)
@@ -2,92 +2,4 @@
 
 <tableDescriptions type="det">
-  <table name="FrameMeta">
-    <column name="frameID" type="TLONG" default="0" comment="unique exposure/frame identifier."></column>
-    <column name="filterID" type="TBYTE" default="0" comment="filter identifier"></column>
-    <column name="nOTA" type="TSHORT" default="-999" comment="number of valid OTA/CCD images in this exposure"></column>
-    <column name="photoScat" type="TFLOAT" default="-999" comment=" global photometric scatter (unit = mag)"></column>
-    <column name="expStart" type="TDOUBLE" default="-999" comment=" exposure start time in MJD (unit = day)"></column>
-    <column name="expTime" type="TFLOAT" default="-999" comment=" exposure time (unit = s)"></column>
-    <column name="airmass" type="TFLOAT" default="-999" comment="airmass at mid-exposure"></column>
-    <column name="raBore" type="TDOUBLE" default="-999" comment=" RA of telescope boresight (unit = deg)"></column>
-    <column name="decBore" type="TDOUBLE" default="-999" comment=" DEC of telescope boresight (unit = deg)"></column>
-    <column name="ctype1" type="TSTRING" default=" " comment="name of astrometric projection in RA"></column>
-    <column name="ctype2" type="TSTRING" default=" " comment="name of astrometric projection in DEC"></column>
-    <column name="crval1" type="TDOUBLE" default="-999" comment=" RA corresponding to reference pixel (unit = deg)"></column>
-    <column name="crval2" type="TDOUBLE" default="-999" comment=" DEC corresponding to reference pixel (unit = deg)"></column>
-    <column name="crpix1" type="TDOUBLE" default="-999" comment="reference pixel value for RA"></column>
-    <column name="crpix2" type="TDOUBLE" default="-999" comment="reference pixel value for DEC"></column>
-    <column name="cdelt1" type="TDOUBLE" default="-999" comment=""></column>
-    <column name="cdelt2" type="TDOUBLE" default="-999" comment=""></column>
-    <column name="pc001001" type="TDOUBLE" default="-999" comment="elements of rotation/Dcale matrix"></column>
-    <column name="pc001002" type="TDOUBLE" default="-999" comment="elements of rotation/Dcale matrix"></column>
-    <column name="pc002001" type="TDOUBLE" default="-999" comment="elements of rotation/Dcale matrix"></column>
-    <column name="pc002002" type="TDOUBLE" default="-999" comment="elements of rotation/Dcale matrix"></column>
-    <column name="polyOrder" type="TBYTE" default="255" comment="polynomial order of astrometry fit"></column>
-    <column name="pca1x3y0" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x2y1" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x1y2" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x0y3" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x2y0" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x1y1" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x0y2" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x3y0" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x2y1" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x1y2" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x0y3" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x2y0" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x1y1" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x0y2" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-  </table>
-  <table name="ImageMeta">
-    <column name="photoCalID" type="TLONG" default="0" comment="photometry reduction code identifier"></column>
-    <column name="filterID" type="TBYTE" default="0" comment="filter ID"></column>
-    <column name="sky" type="TFLOAT" default="-999" comment=" mean sky level (unit = ADU)"></column>
-    <column name="skyScat" type="TFLOAT" default="-999" comment=" scatter in mean sky level (unit = ADU)"></column>
-    <column name="nDetect" type="TLONG" default="-999" comment="number of detections on CCD"></column>
-    <column name="magSat" type="TFLOAT" default="-999" comment=" saturation magnitude level (unit = mag)"></column>
-    <column name="completMag" type="TFLOAT" default="-999" comment=" 95% completion level in mag (unit = mag)"></column>
-    <column name="astroScat" type="TFLOAT" default="-999" comment=" astrometric scatter for chip (unit = mag)"></column>
-    <column name="photoScat" type="TFLOAT" default="-999" comment="photometric scatter for chip"></column>
-    <column name="numAstroRef" type="TLONG" default="-999" comment="number of astrometric reference sources"></column>
-    <column name="nx" type="TSHORT" default="-999" comment="chip dimension in x"></column>
-    <column name="ny" type="TSHORT" default="-999" comment="chip dimension in y"></column>
-    <column name="psfModelID" type="TLONG" default="-999" comment="PSF model identifier"></column>
-    <column name="psfFwhm" type="TFLOAT" default="-999" comment=" model psf full width at half maximum at chip center (unit = arcsec)"></column>
-    <column name="psfWidMajor" type="TFLOAT" default="-999" comment=" model PSF parameters at chip center (unit = arcsec)"></column>
-    <column name="psfWidMinor" type="TFLOAT" default="-999" comment=" model PSF parameters at chip center (unit = arcsec)"></column>
-    <column name="psfTheta" type="TFLOAT" default="-999" comment=" model PSF parameters at chip center (unit = deg)"></column>
-    <column name="apResid" type="TFLOAT" default="-999" comment="corrected aperture residual"></column>
-    <column name="dapResid" type="TFLOAT" default="-999" comment="scatter of aperture corrections"></column>
-    <column name="photoZero" type="TFLOAT" default="-999" comment=" local derived photometric zero point (unit = mag)"></column>
-    <column name="qaFlags" type="TLONGLONG" default="-999" comment="Q/A flags for this OTA"></column>
-    <column name="ctype1" type="TSTRING" default=" " comment="name of astrometric projection in RA"></column>
-    <column name="ctype2" type="TSTRING" default=" " comment="name of astrometric projection in DEC"></column>
-    <column name="crval1" type="TDOUBLE" default="-999" comment=" RA corresponding to reference pixel (unit = deg)"></column>
-    <column name="crval2" type="TDOUBLE" default="-999" comment=" DEC corresponding to reference pixel (unit = deg)"></column>
-    <column name="crpix1" type="TDOUBLE" default="-999" comment=" reference pixel value for RA (unit = pix)"></column>
-    <column name="crpix2" type="TDOUBLE" default="-999" comment=" reference pixel value for DEC (unit = pix)"></column>
-    <column name="cdelt1" type="TDOUBLE" default="-999" comment=""></column>
-    <column name="cdelt2" type="TDOUBLE" default="-999" comment=""></column>
-    <column name="pc001001" type="TDOUBLE" default="-999" comment="elements of rotation/Dcale matrix"></column>
-    <column name="pc001002" type="TDOUBLE" default="-999" comment="elements of rotation/Dcale matrix"></column>
-    <column name="pc002001" type="TDOUBLE" default="-999" comment="elements of rotation/Dcale matrix"></column>
-    <column name="pc002002" type="TDOUBLE" default="-999" comment="elements of rotation/Dcale matrix"></column>
-    <column name="polyOrder" type="TBYTE" default="255" comment="polynomial order of astrometry fit"></column>
-    <column name="pca1x3y0" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x2y1" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x1y2" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x0y3" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x2y0" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x1y1" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca1x0y2" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x3y0" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x2y1" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x1y2" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x0y3" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x2y0" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x1y1" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-    <column name="pca2x0y2" type="TDOUBLE" default="-999" comment="polynomial coefficients for the astrometric fit"></column>
-  </table>
   <table name="Detection">
     <column name="objID" type="TLONGLONG" default="0" comment="ODM object identifier"></column>
@@ -96,20 +8,9 @@
     <column name="ippDetectID" type="TLONGLONG" default="0" comment="detection id generated by IPP"></column>
     <column name="filterID" type="TBYTE" default="0" comment="filter ID: g=1, r=2, i=3, z=4, y=5, w=6, ..."></column>
-    <column name="xPos" type="TFLOAT" default="-999" comment=" measured x on CCD from PSF fit (unit = pix)"></column>
-    <column name="yPos" type="TFLOAT" default="-999" comment=" measured y on CCD from PSF fit (unit = pix)"></column>
-    <column name="xPosErr" type="TFLOAT" default="-999" comment=" estimated error in x (unit = pix)"></column>
-    <column name="yPosErr" type="TFLOAT" default="-999" comment=" estimated error in y (unit = pix)"></column>
-    <column name="ippRa" type="TFLOAT" default="-999" comment="RA"></column>
-    <column name="ippDec" type="TFLOAT" default="-999" comment="dec"></column>
+    <column name="imageID" type="TLONGLONG" default="0" comment="unique ID for each image, hashed from frameID and ccdID (ALEX)"></column>
+    <column name="ra" type="TFLOAT" default="-999" comment="RA"></column>
+    <column name="dec" type="TFLOAT" default="-999" comment="dec"></column>
+    <column name="infoFlag" type="TLONGLONG" default="-999" comment="flag indicating provenance information"></column>
     <column name="instFlux" type="TFLOAT" default="-999" comment=" PSF instrumental flux (unit = adu/s)"></column>
-    <column name="instFluxErr" type="TFLOAT" default="-999" comment=" estimated error in flux (unit = adu/s)"></column>
-    <column name="peakADU" type="TFLOAT" default="-999" comment=" peak count in source pixel (unit = adu)"></column>
-    <column name="psfWidMajor" type="TFLOAT" default="-999" comment=" model PSF width in major axis (unit = arcsec)"></column>
-    <column name="psfWidMinor" type="TFLOAT" default="-999" comment=" model PSF width in minor axis (unit = arcsec)"></column>
-    <column name="psfTheta" type="TFLOAT" default="-999" comment=" model PSF orientation angle (unit = deg)"></column>
-    <column name="psfCf" type="TFLOAT" default="-999" comment="PSF coverage factor"></column>
-    <column name="infoFlag" type="TLONGLONG" default="-999" comment="flag indicating provenance information"></column>
-    <column name="sky" type="TFLOAT" default="-999" comment=" PSF sky level at source (unit = adu)"></column>
-    <column name="skyErr" type="TFLOAT" default="-999" comment=" estimated error in sky (unit = adu)"></column>
   </table>
 </tableDescriptions>
Index: trunk/ippToPsps/src/ippToPspsBatchTest.c
===================================================================
--- trunk/ippToPsps/src/ippToPspsBatchTest.c	(revision 28758)
+++ trunk/ippToPsps/src/ippToPspsBatchTest.c	(revision 28759)
@@ -13,15 +13,13 @@
 #include "fitsio.h"
 
-// Gets flux from magnitude
-static __inline bool ippToPsps_getFlux(const float zeroPoint, const float exposureTime, const float magnitude, float* flux) {
-
-    // use uncalibrated instrumental flux
+// Gets uncalibrated instrumental flux from magnitude
+static __inline bool ippToPsps_getFlux(const float exposureTime, const float magnitude, float* flux, const float magnitudeErr, float* fluxErr) {
+
     *flux = powf(10.0, -0.4*magnitude) / exposureTime;
-
-    // use calibrated flux in Janskys, where 3631 Jy is the zero point flux for the filter: constant over all filters because we're using AB magnitudes
-    //float flux = 3631 * powf(10.0, -0.4*(magnitude + zeroPoint)) / exposureTime;
-
-    //    printf("mag=%f\texpTime=%f\tzeroPoint=%f\tflux=%f\n", magnitude, exposureTime, zeroPoint, flux);
-    return (!isfinite(*flux) || *flux < 0.000001) ? false : true;
+    if (!isfinite(*flux) || *flux < 0.000001) return false;
+    if (fluxErr) *fluxErr = fabsf((magnitudeErr * *flux)/1.085736);
+    //  if (fluxErr)    printf("Mag = %03.03f, Flux = %03.03f, Mag err = %03.03f, Flux Err = %03.03f\n", magnitude, *flux, magnitudeErr, *fluxErr);
+
+    return true;
 }
 
@@ -29,5 +27,5 @@
   \brief test data for checking PSPS values correspond with IPP 
 
-  */
+*/
 int ippToPsps_batchTest(IppToPsps *this) {
 
@@ -53,13 +51,13 @@
     status=0; fits_read_key(fitsIn, TFLOAT, "EXPREQ", &exposureTime, NULL, &status);
     status=0; fits_read_key(fitsIn, TSTRING, "FILTERID", filterType, NULL, &status);
-    
-    ippToPspsConfig_writeTable(this->config, fitsIn, this->fitsOut, 1, "FrameMeta", true);
+
+//    ippToPspsConfig_writeTable(this->config, fitsIn, this->fitsOut, 1, "FrameMeta", true);
 
     // FrameMeta values
-    fits_write_col(this->fitsOut, TLONG, FRAMEMETA_FRAMEID, 1, 1, 1, &this->expId, &status);
+//    fits_write_col(this->fitsOut, TLONG, FRAMEMETA_FRAMEID, 1, 1, 1, &this->expId, &status);
 
     int8_t filterID = -1;
     ippToPspsConfig_getFilterId(this->config, filterType, &filterID);
-    fits_write_col(this->fitsOut, TBYTE, FRAMEMETA_FILTERID, 1, 1, 1, &filterID, &status);
+//    fits_write_col(this->fitsOut, TBYTE, FRAMEMETA_FILTERID, 1, 1, 1, &filterID, &status);
 
     // stuff to keep from psf.hdr header
@@ -140,5 +138,5 @@
     long removeList[MAXDETECT];
     long thisObjId;
-    bool firstTimeIn = true;
+    bool firstTimeIn = true, peakFluxOk, instFluxOk;
     int ippIDetNum, instMagNum, instMagErrNum, peakMagNum;
 
@@ -198,14 +196,14 @@
 
             // create ImageMeta
-            ippToPspsConfig_writeTable(this->config, fitsIn, this->fitsOut, 1, "ImageMeta", true);
+    //        ippToPspsConfig_writeTable(this->config, fitsIn, this->fitsOut, 1, "ImageMeta", true);
             psfFwhm = (fwhmMaj+fwhmMin)/2;
             momentFwhm = (momentMaj+momentMin)/2;
             imageFlags = (uint64_t)pImage->flags;
-            fits_write_col(this->fitsOut, TLONG, IMAGEMETA_PHOTOCALID, 1, 1, 1, &pImage->photcode, &status); 
-            fits_write_col(this->fitsOut, TBYTE, IMAGEMETA_FILTERID, 1, 1, 1, &filterID, &status);
-            fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PHOTOSCAT, 1, 1, 1, &zptObs, &status);
-            fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PSFFWHM, 1, 1, 1, &psfFwhm, &status);
-            fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PHOTOZERO, 1, 1, 1, &zptObs, &status);
-            fits_write_col(this->fitsOut, TLONGLONG, IMAGEMETA_QAFLAGS, 1, 1, 1, &imageFlags, &status);
+      //      fits_write_col(this->fitsOut, TLONG, IMAGEMETA_PHOTOCALID, 1, 1, 1, &pImage->photcode, &status); 
+        //    fits_write_col(this->fitsOut, TBYTE, IMAGEMETA_FILTERID, 1, 1, 1, &filterID, &status);
+        //    fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PHOTOSCAT, 1, 1, 1, &zptObs, &status);
+        //    fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PSFFWHM, 1, 1, 1, &psfFwhm, &status);
+        //    fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PHOTOZERO, 1, 1, 1, &zptObs, &status);
+        //    fits_write_col(this->fitsOut, TLONGLONG, IMAGEMETA_QAFLAGS, 1, 1, 1, &imageFlags, &status);
 
             // now move BACK to detections table in smf
@@ -287,9 +285,9 @@
                     obsTimes[s] = obsTime;
 
-                    ippToPsps_getFlux(zeroPoint, exposureTime, instMagErr[s], &instFluxErr[s]);
+                    peakFluxOk = ippToPsps_getFlux(exposureTime, peakMag[s], &peakFlux[s], 0.0, NULL);
+                    instFluxOk = ippToPsps_getFlux(exposureTime, instMag[s], &instFlux[s], instMagErr[s], &instFluxErr[s]);
 
                     // check for invalid flux values (if not already labelled as a duplicate)
-                    if ((!ippToPsps_getFlux(zeroPoint, exposureTime, peakMag[s], &peakFlux[s]) ||
-                                !ippToPsps_getFlux(zeroPoint, exposureTime, instMag[s], &instFlux[s])) && !isDuplicate) {
+                    if ( (!peakFluxOk || !instFluxOk) && !isDuplicate) {
                         removeList[numOfDuplicates+numInvalidFlux] = s+1;
                         numInvalidFlux++;
@@ -314,5 +312,5 @@
             // write number of rows (detections) to ImageMeta
             numDetectionsOut = totalDetections - numOfDuplicates - numInvalidFlux;
-            fits_write_col(this->fitsOut, TLONG, IMAGEMETA_NDETECT, 1, 1, 1, &numDetectionsOut, &status);
+          //  fits_write_col(this->fitsOut, TLONG, IMAGEMETA_NDETECT, 1, 1, 1, &numDetectionsOut, &status);
 
             // detections
@@ -323,7 +321,8 @@
             fits_write_col(this->fitsOut, TLONGLONG, DETECTION_IPPDETECTID, 1, 1, nDet, ippDetectID, &status);
             fits_write_col(this->fitsOut, TBYTE, DETECTION_FILTERID, 1, 1, nDet, filterIDs, &status);
+            fits_write_col(this->fitsOut, TLONGLONG, DETECTION_IMAGEID, 1, 1, nDet, imageID, &status);
             fits_write_col(this->fitsOut, TFLOAT, DETECTION_INSTFLUX, 1, 1, nDet, instFlux, &status);
-            fits_write_col(this->fitsOut, TFLOAT, DETECTION_INSTFLUXERR, 1, 1, nDet, instFluxErr, &status);
-            fits_write_col(this->fitsOut, TFLOAT, DETECTION_PEAKADU, 1, 1, nDet, peakFlux, &status);
+            //fits_write_col(this->fitsOut, TFLOAT, DETECTION_INSTFLUXERR, 1, 1, nDet, instFluxErr, &status);
+            //fits_write_col(this->fitsOut, TFLOAT, DETECTION_PEAKADU, 1, 1, nDet, peakFlux, &status);
             fits_write_col(this->fitsOut, TLONGLONG, DETECTION_INFOFLAG, 1, 1, nDet, flags, &status);
             if (numOfDuplicates||numInvalidFlux) fits_delete_rowlist(this->fitsOut, removeList, numOfDuplicates+numInvalidFlux, &status);
@@ -346,8 +345,8 @@
     // write number of images we have found into FrameMeta table
     status=0; 
-    if (fits_movnam_hdu(this->fitsOut, BINARY_TBL, "FrameMeta", 0, &status))
-        psError(PS_ERR_IO, false, "Can't move back to FrameMeta extension to write number of OTAs\n");
-    else 
-        fits_write_col(this->fitsOut, TSHORT, FRAMEMETA_NOTA, 1, 1, 1, &nOta, &status);
+    //if (fits_movnam_hdu(this->fitsOut, BINARY_TBL, "FrameMeta", 0, &status))
+      //  psError(PS_ERR_IO, false, "Can't move back to FrameMeta extension to write number of OTAs\n");
+    //else 
+    //    fits_write_col(this->fitsOut, TSHORT, FRAMEMETA_NOTA, 1, 1, 1, &nOta, &status);
 
     status=0;
Index: trunk/ippToPsps/src/ippToPspsTestEnums.h
===================================================================
--- trunk/ippToPsps/src/ippToPspsTestEnums.h	(revision 28758)
+++ trunk/ippToPsps/src/ippToPspsTestEnums.h	(revision 28759)
@@ -3,89 +3,4 @@
 
 
-typedef enum {
-  FRAMEMETA_FRAMEID = 1,
-  FRAMEMETA_FILTERID,
-  FRAMEMETA_NOTA,
-  FRAMEMETA_PHOTOSCAT,
-  FRAMEMETA_EXPSTART,
-  FRAMEMETA_EXPTIME,
-  FRAMEMETA_AIRMASS,
-  FRAMEMETA_RABORE,
-  FRAMEMETA_DECBORE,
-  FRAMEMETA_CTYPE1,
-  FRAMEMETA_CTYPE2,
-  FRAMEMETA_CRVAL1,
-  FRAMEMETA_CRVAL2,
-  FRAMEMETA_CRPIX1,
-  FRAMEMETA_CRPIX2,
-  FRAMEMETA_PC001001,
-  FRAMEMETA_PC001002,
-  FRAMEMETA_PC002001,
-  FRAMEMETA_PC002002,
-  FRAMEMETA_POLYORDER,
-  FRAMEMETA_PCA1X3Y0,
-  FRAMEMETA_PCA1X2Y1,
-  FRAMEMETA_PCA1X1Y2,
-  FRAMEMETA_PCA1X0Y3,
-  FRAMEMETA_PCA1X2Y0,
-  FRAMEMETA_PCA1X1Y1,
-  FRAMEMETA_PCA1X0Y2,
-  FRAMEMETA_PCA2X3Y0,
-  FRAMEMETA_PCA2X2Y1,
-  FRAMEMETA_PCA2X1Y2,
-  FRAMEMETA_PCA2X0Y3,
-  FRAMEMETA_PCA2X2Y0,
-  FRAMEMETA_PCA2X1Y1,
-  FRAMEMETA_PCA2X0Y2,
-} FrameMeta;
-
-typedef enum {
-  IMAGEMETA_PHOTOCALID = 1,
-  IMAGEMETA_FILTERID,
-  IMAGEMETA_SKY,
-  IMAGEMETA_SKYSCAT,
-  IMAGEMETA_NDETECT,
-  IMAGEMETA_MAGSAT,
-  IMAGEMETA_COMPLETMAG,
-  IMAGEMETA_ASTROSCAT,
-  IMAGEMETA_PHOTOSCAT,
-  IMAGEMETA_NUMASTROREF,
-  IMAGEMETA_NX,
-  IMAGEMETA_NY,
-  IMAGEMETA_PSFMODELID,
-  IMAGEMETA_PSFFWHM,
-  IMAGEMETA_PSFWIDMAJOR,
-  IMAGEMETA_PSFWIDMINOR,
-  IMAGEMETA_PSFTHETA,
-  IMAGEMETA_APRESID,
-  IMAGEMETA_DAPRESID,
-  IMAGEMETA_PHOTOZERO,
-  IMAGEMETA_QAFLAGS,
-  IMAGEMETA_CTYPE1,
-  IMAGEMETA_CTYPE2,
-  IMAGEMETA_CRVAL1,
-  IMAGEMETA_CRVAL2,
-  IMAGEMETA_CRPIX1,
-  IMAGEMETA_CRPIX2,
-  IMAGEMETA_PC001001,
-  IMAGEMETA_PC001002,
-  IMAGEMETA_PC002001,
-  IMAGEMETA_PC002002,
-  IMAGEMETA_POLYORDER,
-  IMAGEMETA_PCA1X3Y0,
-  IMAGEMETA_PCA1X2Y1,
-  IMAGEMETA_PCA1X1Y2,
-  IMAGEMETA_PCA1X0Y3,
-  IMAGEMETA_PCA1X2Y0,
-  IMAGEMETA_PCA1X1Y1,
-  IMAGEMETA_PCA1X0Y2,
-  IMAGEMETA_PCA2X3Y0,
-  IMAGEMETA_PCA2X2Y1,
-  IMAGEMETA_PCA2X1Y2,
-  IMAGEMETA_PCA2X0Y3,
-  IMAGEMETA_PCA2X2Y0,
-  IMAGEMETA_PCA2X1Y1,
-  IMAGEMETA_PCA2X0Y2,
-} ImageMeta;
 
 typedef enum {
@@ -95,20 +10,9 @@
   DETECTION_IPPDETECTID,
   DETECTION_FILTERID,
-  DETECTION_XPOS,
-  DETECTION_YPOS,
-  DETECTION_XPOSERR,
-  DETECTION_YPOSERR,
-  DETECTION_IPPRA ,
-  DETECTION_IPPDEC ,
+  DETECTION_IMAGEID,
+  DETECTION_RA ,
+  DETECTION_DEC ,
+  DETECTION_INFOFLAG,
   DETECTION_INSTFLUX,
-  DETECTION_INSTFLUXERR,
-  DETECTION_PEAKADU,
-  DETECTION_PSFWIDMAJOR,
-  DETECTION_PSFWIDMINOR,
-  DETECTION_PSFTHETA,
-  DETECTION_PSFCF,
-  DETECTION_INFOFLAG,
-  DETECTION_SKY,
-  DETECTION_SKYERR,
 } Detection;
 
