Index: trunk/ippToPsps/jython/detectionbatch.py
===================================================================
--- trunk/ippToPsps/jython/detectionbatch.py	(revision 31504)
+++ trunk/ippToPsps/jython/detectionbatch.py	(revision 31810)
@@ -7,4 +7,6 @@
 from java.sql import *
 
+from xml.etree.ElementTree import ElementTree, Element, tostring
+
 from batch import Batch
 from gpc1db import Gpc1Db
@@ -24,33 +26,22 @@
     def __init__(self, 
                  logger,
+                 configDoc,
                  gpc1Db,
                  ippToPspsDb,
-                 scratchDb,
                  camID, 
-                 inputFile, 
-                 test=False, 
-                 useFullTables=False):
+                 inputFile):
 
        super(DetectionBatch, self).__init__(
                logger,
+               configDoc,
                gpc1Db,
                ippToPspsDb,
-               scratchDb,
                camID,
                "detection", 
                inputFile, 
-               "MD04", # TODO
-               #"3PI") # TODO
-               useFullTables)
+               #"MD04") # TODO
+               "3PI")
 
        if not self.everythingOK: return
-
-       # meta data to the log
-       self.logger.info("New Detection Batch:")
-       self.logger.info("Cam ID:             %d" % self.id)
-       self.logger.info("file:               %s" % inputFile)
-       self.logger.info("Exp ID:             %d" % self.expID)
-       self.logger.info("Exp name:           %s" % self.expName)
-       self.logger.info("Distribution group: %s" % self.distGroup)
 
        # create an output filename, which is {expID}.FITS
@@ -59,5 +50,5 @@
 
        # if test mode
-       if test:
+       if self.testMode:
            self.startX = 3
            self.endX = 4
@@ -79,5 +70,4 @@
        # set up some defauts
        self.calibModNum = 0
-       self.dataRelease = 0
 
        self.totalNumPhotoRef = 0
@@ -88,4 +78,17 @@
        # insert what we know about this stack batch into the stack table
        self.ippToPspsDb.insertDetectionMeta(self.batchID, self.expID, self.filter)
+
+    '''
+    Prints metadata to the log
+    '''
+    def printMe(self):
+
+        super(DetectionBatch, self).printMe()
+
+        self.logger.info("Cam ID:                 %d" % self.id)
+        self.logger.info("Exp ID:                 %d" % self.expID)
+        self.logger.info("Exp name:               %s" % self.expName)
+        self.logger.info("Distribution group:     %s" % self.distGroup)
+
 
 
@@ -145,5 +148,5 @@
         ,1  \
         ,1  \
-        ,' ' \
+        ,'" + str(self.analysisVer) + "' \
         ,' ' \
         ,' ' \
@@ -207,4 +210,6 @@
                frameID \
                ,ccdID \
+               ,bias \
+               ,biasScat \
                ,sky \
                ,skyScat \
@@ -267,4 +272,6 @@
                " + str(self.expID) + " \
                ," + ota[2:4] + " \
+               ," + str(self.bias) + " \
+               ," + str(self.biasScat) + " \
                ," + self.safeDictionaryAccess(header, 'MSKY_MN') + " \
                ," + self.safeDictionaryAccess(header, 'MSKY_SIG') + " \
@@ -364,4 +371,6 @@
                ,momentYY \
                ,apMag \
+               ,kronFlux \
+               ,kronFluxErr \
                ,infoFlag \
                ,sky \
@@ -386,4 +395,6 @@
                ,MOMENTS_YY \
                ,AP_MAG \
+               ,KRON_FLUX \
+               ,KRON_FLUX_ERR \
                ,FLAGS\
                ,SKY \
@@ -645,6 +656,12 @@
         self.expName = meta[1];
         self.distGroup = meta[2];
-
-        return self.ippToPspsDb.alreadyProcessed("detection", "exp_id", self.expID)
+        self.analysisVer = meta[3];
+        self.bias = meta[4];
+        self.biasScat = meta[5];
+
+        if not self.analysisVer: self.analysisVer = -999
+
+        #return self.ippToPspsDb.alreadyProcessed("detection", "exp_id", self.expID)
+        return 0
 
 
@@ -664,5 +681,9 @@
     '''
     def importIppTables(self, filter=""):
-       return super(DetectionBatch, self).importIppTables(".*.psf")
+
+       if self.testMode: regex = "XY33.psf"
+       else : regex = ".*.psf"
+
+       return super(DetectionBatch, self).importIppTables(regex)
 
 
@@ -674,35 +695,29 @@
 
 
-# TODO put in config
-useFullTables=True
-testMode=False
-
 logging.config.fileConfig("logging.conf")
-logger = logging.getLogger("detectionbatch")
+logger = logging.getLogger("ippToPspsLog")
 logger.setLevel(logging.INFO)
 logger.info("Starting")
 
+configDoc = ElementTree(file="config.xml")
+dvoGpc1Label = configDoc.find("dvo/gpc1Label").text
+
 gpc1Db = Gpc1Db(logger)
 ippToPspsDb = IppToPspsDb(logger)
-scratchDb = ScratchDb(logger, useFullTables)
-
-camIDs = gpc1Db.getIDsInThisDVODbForThisStage("MD04.V2", "cam")
-logger.info("Found %d exposures" % len(camIDs))
-
-i = 0
-for camID in camIDs:
-
-    #if camID < 43764: continue # TODO 
-
-    file = gpc1Db.getCameraStageSmf(camID)
+
+ids = gpc1Db.getIDsInThisDVODbForThisStage(dvoGpc1Label, "cam")
+for id in ids:
+
+    if not int(configDoc.find("options/force").text) and ippToPspsDb.alreadyProcessed(id): continue
+
+    file = gpc1Db.getCameraStageSmf(id)
 
     detectionBatch = DetectionBatch(logger,
+                                    configDoc,
                                     gpc1Db,
                                     ippToPspsDb,
-                                    scratchDb,
-                                    camID, 
-                                    file, 
-                                    testMode, 
-                                    useFullTables)
+                                    id, 
+                                    file)
+    detectionBatch.printMe()
     detectionBatch.run()
 
