Index: /branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py
===================================================================
--- /branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py	(revision 37207)
+++ /branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py	(revision 37208)
@@ -437,4 +437,5 @@
 
           # print "read smf table ", table
+          self.logger.infoPair("read smf table", table)
 
           # drop any previous tables before import
Index: /branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py
===================================================================
--- /branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py	(revision 37207)
+++ /branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py	(revision 37208)
@@ -98,4 +98,5 @@
            raise
        
+       # MJD-OBS is the exposure start, EXTIME / 172800 = (EXPTIME sec / 84600 sec/day) / 2
        self.obsTime = float(self.header['MJD-OBS']) + (float(self.header['EXPTIME']) / 172800.0)
       
@@ -135,37 +136,37 @@
         sqlLine.group("telescopeID",           "1");
         sqlLine.group("analysisVer",           self.analysisVer);
-        sqlLine.group("photoScat",             self.getKeyValue(self.header, 'ZPT_ERR'));
-        sqlLine.group("expStart",              self.getKeyValue(self.header, 'MJD-OBS'));
-        sqlLine.group("expTime",               self.getKeyValue(self.header, 'EXPREQ'));
-        sqlLine.group("airmass",               self.getKeyValue(self.header, 'AIRMASS'));
-        sqlLine.group("raBore",                self.getKeyValue(self.header, 'RA'));
-        sqlLine.group("decBore",               self.getKeyValue(self.header, 'DEC'));
+        sqlLine.group("photoScat",             self.getKeyFloat(self.header, "%.8f", 'ZPT_ERR'));
+        sqlLine.group("expStart",              self.getKeyFloat(self.header, "%.10f", 'MJD-OBS'));
+        sqlLine.group("expTime",               self.getKeyFloat(self.header, "%.8f", 'EXPREQ'));
+        sqlLine.group("airmass",               self.getKeyFloat(self.header, "%.8f", 'AIRMASS'));
+        sqlLine.group("raBore",                self.getKeyFloat(self.header, "%.10f", 'RA'));
+        sqlLine.group("decBore",               self.getKeyFloat(self.header, "%.10f", 'DEC'));
         sqlLine.group("ctype1",                self.getKeyValue(self.header, 'CTYPE1'));
         sqlLine.group("ctype2",                self.getKeyValue(self.header, 'CTYPE2'));
-        sqlLine.group("crval1",                self.getKeyValue(self.header, 'CRVAL1'));
-        sqlLine.group("crval2",                self.getKeyValue(self.header, 'CRVAL2'));
-        sqlLine.group("crpix1",                self.getKeyValue(self.header, 'CRPIX1'));
-        sqlLine.group("crpix2",                self.getKeyValue(self.header, 'CRPIX2'));
-        sqlLine.group("cdelt1",                self.getKeyValue(self.header, 'CDELT1'));
-        sqlLine.group("cdelt2",                self.getKeyValue(self.header, 'CDELT2'));
-        sqlLine.group("pc001001",              self.getKeyValue(self.header, 'PC001001'));
-        sqlLine.group("pc001002",              self.getKeyValue(self.header, 'PC001002'));
-        sqlLine.group("pc002001",              self.getKeyValue(self.header, 'PC002001'));
-        sqlLine.group("pc002002",              self.getKeyValue(self.header, 'PC002002'));
+        sqlLine.group("crval1",                self.getKeyFloat(self.header, "%.8f", 'CRVAL1'));
+        sqlLine.group("crval2",                self.getKeyFloat(self.header, "%.8f", 'CRVAL2'));
+        sqlLine.group("crpix1",                self.getKeyFloat(self.header, "%.8f", 'CRPIX1'));
+        sqlLine.group("crpix2",                self.getKeyFloat(self.header, "%.8f", 'CRPIX2'));
+        sqlLine.group("cdelt1",                self.getKeyFloat(self.header, "%.8e", 'CDELT1'));
+        sqlLine.group("cdelt2",                self.getKeyFloat(self.header, "%.8e", 'CDELT2'));
+        sqlLine.group("pc001001",              self.getKeyFloat(self.header, "%.8e", 'PC001001'));
+        sqlLine.group("pc001002",              self.getKeyFloat(self.header, "%.8e", 'PC001002'));
+        sqlLine.group("pc002001",              self.getKeyFloat(self.header, "%.8e", 'PC002001'));
+        sqlLine.group("pc002002",              self.getKeyFloat(self.header, "%.8e", 'PC002002'));
         sqlLine.group("polyOrder",             self.getKeyValue(self.header, 'NPLYTERM'));
-        sqlLine.group("pca1x3y0",              self.getKeyValue(self.header, 'PCA1X3Y0'));
-        sqlLine.group("pca1x2y1",              self.getKeyValue(self.header, 'PCA1X2Y1'));
-        sqlLine.group("pca1x1y2",              self.getKeyValue(self.header, 'PCA1X1Y2'));
-        sqlLine.group("pca1x0y3",              self.getKeyValue(self.header, 'PCA1X0Y3'));
-        sqlLine.group("pca1x2y0",              self.getKeyValue(self.header, 'PCA1X2Y0'));
-        sqlLine.group("pca1x1y1",              self.getKeyValue(self.header, 'PCA1X1Y1'));
-        sqlLine.group("pca1x0y2",              self.getKeyValue(self.header, 'PCA1X0Y2'));
-        sqlLine.group("pca2x3y0",              self.getKeyValue(self.header, 'PCA2X3Y0'));
-        sqlLine.group("pca2x2y1",              self.getKeyValue(self.header, 'PCA2X2Y1'));
-        sqlLine.group("pca2x1y2",              self.getKeyValue(self.header, 'PCA2X1Y2'));
-        sqlLine.group("pca2x0y3",              self.getKeyValue(self.header, 'PCA2X0Y3'));
-        sqlLine.group("pca2x2y0",              self.getKeyValue(self.header, 'PCA2X2Y0'));
-        sqlLine.group("pca2x1y1",              self.getKeyValue(self.header, 'PCA2X1Y1'));
-        sqlLine.group("pca2x0y2",              self.getKeyValue(self.header, 'PCA2X0Y2'));
+        sqlLine.group("pca1x3y0",              self.getKeyFloat(self.header, "%.8e", 'PCA1X3Y0'));
+        sqlLine.group("pca1x2y1",              self.getKeyFloat(self.header, "%.8e", 'PCA1X2Y1'));
+        sqlLine.group("pca1x1y2",              self.getKeyFloat(self.header, "%.8e", 'PCA1X1Y2'));
+        sqlLine.group("pca1x0y3",              self.getKeyFloat(self.header, "%.8e", 'PCA1X0Y3'));
+        sqlLine.group("pca1x2y0",              self.getKeyFloat(self.header, "%.8e", 'PCA1X2Y0'));
+        sqlLine.group("pca1x1y1",              self.getKeyFloat(self.header, "%.8e", 'PCA1X1Y1'));
+        sqlLine.group("pca1x0y2",              self.getKeyFloat(self.header, "%.8e", 'PCA1X0Y2'));
+        sqlLine.group("pca2x3y0",              self.getKeyFloat(self.header, "%.8e", 'PCA2X3Y0'));
+        sqlLine.group("pca2x2y1",              self.getKeyFloat(self.header, "%.8e", 'PCA2X2Y1'));
+        sqlLine.group("pca2x1y2",              self.getKeyFloat(self.header, "%.8e", 'PCA2X1Y2'));
+        sqlLine.group("pca2x0y3",              self.getKeyFloat(self.header, "%.8e", 'PCA2X0Y3'));
+        sqlLine.group("pca2x2y0",              self.getKeyFloat(self.header, "%.8e", 'PCA2X2Y0'));
+        sqlLine.group("pca2x1y1",              self.getKeyFloat(self.header, "%.8e", 'PCA2X1Y1'));
+        sqlLine.group("pca2x0y2",              self.getKeyFloat(self.header, "%.8e", 'PCA2X0Y2'));
 
         sql = sqlLine.make(") VALUES ( ", ")")
@@ -199,5 +200,5 @@
             psfFwhm = "NULL"
         else:
-            psfFwhm = 0.5*(psfFwhmMajor + psfFwhmMinor)
+            psfFwhm = 0.5*(float(psfFwhmMajor) + float(psfFwhmMinor))
 
         # insert image metadata into table
@@ -208,10 +209,10 @@
         sqlLine.group("bias",             str(self.bias))
         sqlLine.group("biasScat",         str(self.biasScat))
-        sqlLine.group("sky",              self.getKeyValue(header, 'MSKY_MN'))
-        sqlLine.group("skyScat",          self.getKeyValue(header, 'MSKY_SIG'))
-        sqlLine.group("magSat",           self.getKeyValue(header, 'FSATUR'))
-        sqlLine.group("completMag",       self.getKeyValue(header, 'FLIMIT'))
-        sqlLine.group("astroScat",        self.getKeyValue(header, 'CERROR'))
-        sqlLine.group("photoScat",        self.getKeyValue(self.header, 'ZPT_OBS'))
+        sqlLine.group("sky",              self.getKeyFloat(header, "%.8f", 'MSKY_MN'))
+        sqlLine.group("skyScat",          self.getKeyFloat(header, "%.8f", 'MSKY_SIG'))
+        sqlLine.group("magSat",           self.getKeyFloat(header, "%.8f", 'FSATUR'))
+        sqlLine.group("completMag",       self.getKeyFloat(header, "%.8f", 'FLIMIT'))
+        sqlLine.group("astroScat",        self.getKeyFloat(header, "%.8f", 'CERROR'))
+        sqlLine.group("photoScat",        self.getKeyFloat(self.header, "%.8f", 'ZPT_OBS'))
         sqlLine.group("numAstroRef",      self.getKeyValue(header, 'NASTRO'))
         sqlLine.group("numPhotoRef",      self.getKeyValue(header, 'NASTRO'))
@@ -221,16 +222,13 @@
         sqlLine.group("psfWidMajor",      str(psfFwhmMajor))
         sqlLine.group("psfWidMinor",      str(psfFwhmMinor))
-        sqlLine.group("psfTheta",         self.getKeyValue(header, 'ANGLE'))
-        sqlLine.group("momentXX",         "-999")
-        sqlLine.group("momentXY",         "-999")
-        sqlLine.group("momentYY",         "-999")
-        sqlLine.group("momentM3C",        "-999")
-        sqlLine.group("momentM3S",        "-999")
-        sqlLine.group("momentM4C",        "-999")
-        sqlLine.group("momentM4S",        "-999")
-        sqlLine.group("momentR1",         "-999")
-        sqlLine.group("momentRH",         "-999")
-        sqlLine.group("apResid",          self.getKeyValue(header, 'APMIFIT'))
-        sqlLine.group("dapResid",         self.getKeyValue(header, 'DAPMIFIT'))
+        sqlLine.group("psfTheta",         self.getKeyFloat(header, "%.8f", 'ANGLE'))
+        sqlLine.group("momentsMajor",     self.getKeyFloat(header, "%.8f", 'IQ_FW1'))
+        sqlLine.group("momentsMinor",     self.getKeyFloat(header, "%.8f", 'IQ_FW2'))
+        sqlLine.group("momentM2C",        self.getKeyFloat(header, "%.8f", 'IQ_M2C'))
+        sqlLine.group("momentM2S",        self.getKeyFloat(header, "%.8f", 'IQ_M2S'))
+        sqlLine.group("momentM3",         self.getKeyFloat(header, "%.8f", 'IQ_M3'))
+        sqlLine.group("momentM4",         self.getKeyFloat(header, "%.8f", 'IQ_M4'))
+        sqlLine.group("apResid",          self.getKeyFloat(header, "%.8f", 'APMIFIT'))
+        sqlLine.group("dapResid",         self.getKeyFloat(header, "%.8f", 'DAPMIFIT'))
         sqlLine.group("detectorID",       self.getKeyValue(header, 'DETECTOR'))
         sqlLine.group("qaFlags",          str(self.scratchDb.getDvoImageFlags(header['IMAGEID'])))
@@ -243,27 +241,27 @@
         # sqlLine.group("detrend7",         " ")
         # sqlLine.group("detrend8",         " ")
-        sqlLine.group("photoZero",        self.getKeyValue(self.header, 'ZPT_OBS'))
+        sqlLine.group("photoZero",        self.getKeyFloat(self.header, "%.8f", 'ZPT_OBS'))
         sqlLine.group("ctype1",           self.getKeyValue(header, 'CTYPE1'))
         sqlLine.group("ctype2",           self.getKeyValue(header, 'CTYPE2'))
-        sqlLine.group("crval1",           self.getKeyValue(header, 'CRVAL1'))
-        sqlLine.group("crval2",           self.getKeyValue(header, 'CRVAL2'))
-        sqlLine.group("crpix1",           self.getKeyValue(header, 'CRPIX1'))
-        sqlLine.group("crpix2",           self.getKeyValue(header, 'CRPIX2'))
-        sqlLine.group("cdelt1",           self.getKeyValue(header, 'CDELT1'))
-        sqlLine.group("cdelt2",           self.getKeyValue(header, 'CDELT2'))
-        sqlLine.group("pc001001",         self.getKeyValue(header, 'PC001001'))
-        sqlLine.group("pc001002",         self.getKeyValue(header, 'PC001002'))
-        sqlLine.group("pc002001",         self.getKeyValue(header, 'PC002001'))
-        sqlLine.group("pc002002",         self.getKeyValue(header, 'PC002002'))
+        sqlLine.group("crval1",           self.getKeyFloat(header, "%.8f", 'CRVAL1'))
+        sqlLine.group("crval2",           self.getKeyFloat(header, "%.8f", 'CRVAL2'))
+        sqlLine.group("crpix1",           self.getKeyFloat(header, "%.8f", 'CRPIX1'))
+        sqlLine.group("crpix2",           self.getKeyFloat(header, "%.8f", 'CRPIX2'))
+        sqlLine.group("cdelt1",           self.getKeyFloat(header, "%.8e", 'CDELT1'))
+        sqlLine.group("cdelt2",           self.getKeyFloat(header, "%.8e", 'CDELT2'))
+        sqlLine.group("pc001001",         self.getKeyFloat(header, "%.8e", 'PC001001'))
+        sqlLine.group("pc001002",         self.getKeyFloat(header, "%.8e", 'PC001002'))
+        sqlLine.group("pc002001",         self.getKeyFloat(header, "%.8e", 'PC002001'))
+        sqlLine.group("pc002002",         self.getKeyFloat(header, "%.8e", 'PC002002'))
         sqlLine.group("polyOrder",        self.getKeyValue(header, 'NPLYTERM'))
 
         nPolyterm = int(self.getKeyValue(header, 'NPLYTERM'))
         if nPolyterm > 1:
-            sqlLine.group("pca1x2y0",         self.getKeyValue(header, 'PCA1X2Y0'))
-            sqlLine.group("pca1x1y1",         self.getKeyValue(header, 'PCA1X1Y1'))
-            sqlLine.group("pca1x0y2",         self.getKeyValue(header, 'PCA1X0Y2'))
-            sqlLine.group("pca2x2y0",         self.getKeyValue(header, 'PCA2X2Y0'))
-            sqlLine.group("pca2x1y1",         self.getKeyValue(header, 'PCA2X1Y1'))
-            sqlLine.group("pca2x0y2",         self.getKeyValue(header, 'PCA2X0Y2'))
+            sqlLine.group("pca1x2y0",         self.getKeyFloat(header, "%.8e", 'PCA1X2Y0'))
+            sqlLine.group("pca1x1y1",         self.getKeyFloat(header, "%.8e", 'PCA1X1Y1'))
+            sqlLine.group("pca1x0y2",         self.getKeyFloat(header, "%.8e", 'PCA1X0Y2'))
+            sqlLine.group("pca2x2y0",         self.getKeyFloat(header, "%.8e", 'PCA2X2Y0'))
+            sqlLine.group("pca2x1y1",         self.getKeyFloat(header, "%.8e", 'PCA2X1Y1'))
+            sqlLine.group("pca2x0y2",         self.getKeyFloat(header, "%.8e", 'PCA2X0Y2'))
         else:
             sqlLine.group("pca1x2y0",         "-999")
@@ -275,12 +273,12 @@
             
         if nPolyterm > 2:
-            sqlLine.group("pca1x3y0",         self.getKeyValue(header, 'PCA1X3Y0'))
-            sqlLine.group("pca1x2y1",         self.getKeyValue(header, 'PCA1X2Y1'))
-            sqlLine.group("pca1x1y2",         self.getKeyValue(header, 'PCA1X1Y2'))
-            sqlLine.group("pca1x0y3",         self.getKeyValue(header, 'PCA1X0Y3'))
-            sqlLine.group("pca2x3y0",         self.getKeyValue(header, 'PCA2X3Y0'))
-            sqlLine.group("pca2x2y1",         self.getKeyValue(header, 'PCA2X2Y1'))
-            sqlLine.group("pca2x1y2",         self.getKeyValue(header, 'PCA2X1Y2'))
-            sqlLine.group("pca2x0y3",         self.getKeyValue(header, 'PCA2X0Y3'))
+            sqlLine.group("pca1x3y0",         self.getKeyFloat(header, "%.8e", 'PCA1X3Y0'))
+            sqlLine.group("pca1x2y1",         self.getKeyFloat(header, "%.8e", 'PCA1X2Y1'))
+            sqlLine.group("pca1x1y2",         self.getKeyFloat(header, "%.8e", 'PCA1X1Y2'))
+            sqlLine.group("pca1x0y3",         self.getKeyFloat(header, "%.8e", 'PCA1X0Y3'))
+            sqlLine.group("pca2x3y0",         self.getKeyFloat(header, "%.8e", 'PCA2X3Y0'))
+            sqlLine.group("pca2x2y1",         self.getKeyFloat(header, "%.8e", 'PCA2X2Y1'))
+            sqlLine.group("pca2x1y2",         self.getKeyFloat(header, "%.8e", 'PCA2X1Y2'))
+            sqlLine.group("pca2x0y3",         self.getKeyFloat(header, "%.8e", 'PCA2X0Y3'))
         else:
             sqlLine.group("pca1x3y0",         "-999")
@@ -346,4 +344,6 @@
         sqlLine.group("pltScale",        "PLTSCALE")                                      
         sqlLine.group("posAngle",        "POSANGLE")                                      
+        sqlLine.group("raErr",           "X_PSF_SIG * abs(PLTSCALE)") 
+        sqlLine.group("decErr",          "Y_PSF_SIG * abs(PLTSCALE)") 
         sqlLine.group("psfFlux",         "PSF_INST_FLUX / " + extTimeString)
         sqlLine.group("psfFluxErr",      "PSF_INST_FLUX_SIG / " + extTimeString)
@@ -367,5 +367,5 @@
         sqlLine.group("apFlux",          "AP_FLUX / " + extTimeString)
         sqlLine.group("apFluxErr",       "AP_FLUX_SIG / " + extTimeString)
-        sqlLine.group("apFillF",         "AP_NPIX / (3.1416 * AP_MAG_RADIUS * AP_MAG_RADIUS)")
+        sqlLine.group("apFillF",         "AP_NPIX / (3.14159265359 * POW(AP_MAG_RADIUS - 0.5, 2))")
         sqlLine.group("apRadius",        "AP_MAG_RADIUS")
         sqlLine.group("kronFlux",        "KRON_FLUX / " + extTimeString)
@@ -525,4 +525,8 @@
                     ota = "XY%d%d" % (x, y)
                 
+                    if self.config.test and not ((x == 0) and (y == 1)):
+                        print "skipping ota: " + ota
+                        continue
+                        
                     self.alterPspsTablesChip(ota, ota + ".hdr", x, y)
 
@@ -576,8 +580,7 @@
                a.detectID     = b.detectID, \
                a.ippObjID     = b.ippObjID, \
+               a.dvoRegionID  = b.catID \
                a.ra           = b.ra, \
                a.dec          = b.dec_, \
-               a.raErr        = b.raErr, \
-               a.decErr       = b.decErr, \
                a.zp           = b.zp, \
                a.telluricExt  = b.telluricExt, \
@@ -587,6 +590,4 @@
                WHERE a.ippDetectID = b.ippDetectID \
                AND b.imageID = " + str(imageID)
-
-        # XXX need to add dvoRegion
 
         self.scratchDb.execute(sql)
@@ -704,4 +705,8 @@
                 if ota not in self.imageIDs: continue
 
+                if self.config.test and not ((x == 0) and (y == 1)):
+                    print "skipping ota " + ota
+                    continue
+
                 if self.populatePspsTablesChip(ota, x, y, results, tables): otaCount = otaCount + 1
                 if self.skipBatch: 
@@ -814,7 +819,8 @@
     def importIppTables(self, filter=""):
 
-       ## if self.config.test: regex = "XY33.psf"
-       ## else : regex = ".*.psf"
-       regex = ".*.psf"
+       if self.config.test:
+           regex = "XY01.psf"
+       else: 
+           regex = ".*.psf"
   
        # XXX EAM NOTE : this is fragile : requires PS1_V4
Index: /branches/eam_branches/ipp-20140717/ippToPsps/jython/gpc1db.py
===================================================================
--- /branches/eam_branches/ipp-20140717/ippToPsps/jython/gpc1db.py	(revision 37207)
+++ /branches/eam_branches/ipp-20140717/ippToPsps/jython/gpc1db.py	(revision 37208)
@@ -117,4 +117,6 @@
             stage = "forcedwarp"
             sql = "SELECT differentStuff from Stufftable"
+
+        self.logger.infoPair("sql for pending:", sql)
 
         try:
Index: /branches/eam_branches/ipp-20140717/ippToPsps/jython/testCode.py
===================================================================
--- /branches/eam_branches/ipp-20140717/ippToPsps/jython/testCode.py	(revision 37207)
+++ /branches/eam_branches/ipp-20140717/ippToPsps/jython/testCode.py	(revision 37208)
@@ -20,15 +20,15 @@
     def run(self):
 
-        myvalue = "10.0"
-        print "test line"
-        print "log of 5.0: " + str(math.log10(float(myvalue)))
+        for x in range(0, 8):
+            for y in range(0, 8):
 
-        names = {}
-
-        filters =['g','r','i']
-        for f in filters:
-
-            names[f] = f + ".00000"
-            print "filter: " + f + " = " + names[f]
+                if not ((x == 0) and (y == 1)):
+                    print "case 1"
+                    print "x : " + str(x)
+                    print "y : " + str(y)
+                else:
+                    print "case 2"
+                    print "x : " + str(x)
+                    print "y : " + str(y)
 
 '''
