Index: trunk/ippToPsps/jython/dvodetections.py
===================================================================
--- trunk/ippToPsps/jython/dvodetections.py	(revision 34630)
+++ trunk/ippToPsps/jython/dvodetections.py	(revision 35097)
@@ -20,7 +20,7 @@
     Constructor
     '''
-    def __init__(self, logger, config, scratchDbName):
+    def __init__(self, logger, config, skychunk, ippToPspsDb, scratchDbName):
 
-        super(DvoDetections, self).__init__(logger, config, scratchDbName)
+        super(DvoDetections, self).__init__(logger, config, skychunk, ippToPspsDb, scratchDbName)
 
         # declare DVO file types of interest
@@ -32,6 +32,6 @@
     def ingestRegion(self, region):
 
-       cpmPath = self.config.dvoLocation + "/" + region + ".cpm"
-       cptPath = self.config.dvoLocation + "/" + region + ".cpt"
+       cpmPath = self.skychunk.dvoLocation + "/" + region + ".cpm"
+       cptPath = self.skychunk.dvoLocation + "/" + region + ".cpt"
 
        cpmTableName = self.scratchDb.getDbFriendlyTableName(region + ".cpm")
@@ -83,21 +83,28 @@
        # first try to add the new columns. catch failure and continue
        try:
-           sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT), (ZP REAL), (RA FLOAT), (DEC FLOAT)"
+           sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT), ADD COLUMN (ZP REAL), ADD COLUMN (RA FLOAT), ADD COLUMN (DEC_ FLOAT)"
            self.scratchDb.execute(sql)
        except:
-           self.logger.infoPair("Already added PSPS_OBJ_ID column to", cpmTableName)
+           # failed, but may be due to mysql error
+           self.logger.infoPair("mysql error or already added PSPS_OBJ_ID column to", cpmTableName)
+           # self.logger.infoPair("sql command", sql)
                
        # shove PSPS objIDs from cpt table and the calibrated zero point and coordinates which are formed 
        # by combining values from multiple tables into cpt table
-       sql = "UPDATE " + cpmTableName + " AS a, " + cptTableName + " AS b, " \
-              + self.scratchDb.dvoPhotcodesTable + " AS c \
-              SET a.PSPS_OBJ_ID = b.EXT_ID, \
-              b.ZP  = c.C_LAM * 0.001 + c.K * (b.AIRMASS - 1) - b.M_CAL, \
-              b.RA  = a.RA  - (b.D_RA  / 3600.0), \
-              b.DEC = a.DEC - (b.D_DEC / 3600.0) \
-              WHERE a.CAT_ID = b.CAT_ID \
-              AND a.OBJ_ID = b.OBJ_ID   \
-              AND b.PHOTCODE = c.CODE"
+       sql = "UPDATE " \
+              + cpmTableName + " AS meas, " \
+              + cptTableName + " AS ave, " \
+              + self.scratchDb.dvoPhotcodesTable + " AS phot \
+              SET \
+              meas.PSPS_OBJ_ID = ave.EXT_ID, \
+              meas.ZP  = phot.C_LAM * 0.001 + phot.K * (meas.AIRMASS - 1) - meas.M_CAL, \
+              meas.RA  = ave.RA  - (meas.D_RA  / 3600.0), \
+              meas.DEC_ = ave.DEC_ - (meas.D_DEC / 3600.0) \
+              WHERE meas.CAT_ID = ave.CAT_ID \
+              AND meas.OBJ_ID = ave.OBJ_ID   \
+              AND meas.PHOTCODE = phot.CODE"
 
+       # EAM : add some debug I/O
+       # self.logger.infoPair("sql command", sql)
        self.scratchDb.execute(sql)
 
@@ -136,9 +143,12 @@
               ,POW(10.0, 0.4 * M_TIME)  \
               ,RA   \
-              ,DEC  \
+              ,DEC_  \
               ,X_CCD_ERR*PLTSCALE   \
               ,Y_CCD_ERR*PLTSCALE   \
               , " + str(fileId) + " \
               FROM " + cpmTableName
+
+       # print "sql :", sql
+       # response = raw_input("prepare to insert dvoDetectionTable ")
 
        try:
@@ -148,4 +158,5 @@
            return False
        finally:
+           # response = raw_input("insert dvoDetectionTable ")
            self.logger.infoPair("Dropping tables", "%s and %s" % (cpmTableName, cptTableName))
            self.scratchDb.dropTable(cpmTableName)
@@ -155,4 +166,2 @@
 
        return True
-
-
