Index: branches/eam_branches/ipp-20130904/ippToPsps/jython/dxlayer.py
===================================================================
--- branches/eam_branches/ipp-20130904/ippToPsps/jython/dxlayer.py	(revision 36095)
+++ branches/eam_branches/ipp-20130904/ippToPsps/jython/dxlayer.py	(revision 36192)
@@ -25,4 +25,5 @@
     '''
     def deleteBatch(self, batchID):
+        #HAF This is really lazy to do this way, but for the time, will check both dx layers and try the first, if no go try the second.
 
         batch = Batch.getNameFromID(batchID)
@@ -46,8 +47,36 @@
         p.stdout.close()
 
-        if ret: self.logger.infoPair("Deleted batch from DXLayer", batch) 
-        else: self.logger.errorPair("Unable to delete batch from DXLayer", batch)
+        if ret: self.logger.infoPair("Deleted batch from DXLayer 1", batch) 
+        else: self.logger.errorPair("Unable to delete batch from DXLayer 1" , batch)
+
+
+       
+
+        tempFile = tempfile.NamedTemporaryFile(mode='w+b')
+
+        p = Popen("deleteFromDXLayer2.pl -b " + batch + " -f " + tempFile.name, 
+                shell=True, 
+                stdout=PIPE)
+        p.wait()
+       
+        if p.returncode != 0:
+           self.logger.debugPair("DXLayer webservice", "failed")
+           return 0
+        else:
+           self.logger.debugPair("DXLayer webservice", "successful")
+
+        ret = self.decodeDXLayerResponse(tempFile.name)
+
+        tempFile.close()
+        p.stdout.close()
+
+        if ret: self.logger.infoPair("Deleted batch from DXLayer 2", batch) 
+        else: self.logger.errorPair("Unable to delete batch from DXLayer 2" , batch)
+
+
+
 
         return ret
+
 
     '''
Index: branches/eam_branches/ipp-20130904/ippToPsps/jython/ipptopspsdb.py
===================================================================
--- branches/eam_branches/ipp-20130904/ippToPsps/jython/ipptopspsdb.py	(revision 36095)
+++ branches/eam_branches/ipp-20130904/ippToPsps/jython/ipptopspsdb.py	(revision 36192)
@@ -39,4 +39,6 @@
                AND batch_type = '" + batchType + "' \
                AND dvo_db = '" + self.skychunk.dvoLabel + "' \
+               AND comment = '" + self.skychunk.name + "' \
+               AND datastore_product = '" + self.skychunk.datastoreProduct + "' \
                AND merged = 1 \
                AND deleted_local = 0 \
@@ -65,4 +67,6 @@
                AND batch_type = '" + batchType + "' \
                AND dvo_db = '" + self.skychunk.dvoLabel + "' \
+               AND comment = '" + self.skychunk.name + "' \
+               AND datastore_product = '" + self.skychunk.datastoreProduct + "' \
                AND purged = 1 \
                AND deleted_local = 0 \
@@ -92,4 +96,6 @@
                AND batch_type = '" + batchType + "' \
                AND dvo_db = '" + self.skychunk.dvoLabel + "' \
+               AND comment = '" + self.skychunk.name + "' \
+               AND datastore_product = '" + self.skychunk.datastoreProduct + "' \
                AND purged = 1 \
                AND deleted_datastore = 0 \
@@ -119,5 +125,7 @@
                AND batch_type = '" + batchType + "' \
                AND dvo_db = '" + self.skychunk.dvoLabel + "' \
-               AND (loaded_to_ODM = -1 OR merge_worthy = 1) \
+               AND comment = '" + self.skychunk.name + "' \
+               AND datastore_product = '" + self.skychunk.datastoreProduct + "' \
+               AND (merge_worthy = 1) \
                AND deleted_datastore = 0 AND block_delete_datastore = 0"
 
@@ -144,5 +152,5 @@
                AND batch_type = '" + batchType + "' \
                AND dvo_db = '" + self.skychunk.dvoLabel + "' \
-               AND (loaded_to_ODM = -1 OR merge_worthy = 1) \
+               AND (merge_worthy = 1) \
                AND deleted_dxlayer = 0 and block_delete_dxlayer = 0"
 
Index: branches/eam_branches/ipp-20130904/ippToPsps/jython/stackbatch.py
===================================================================
--- branches/eam_branches/ipp-20130904/ippToPsps/jython/stackbatch.py	(revision 36095)
+++ branches/eam_branches/ipp-20130904/ippToPsps/jython/stackbatch.py	(revision 36192)
@@ -645,5 +645,5 @@
         ,petRadiusErr=b.PETRO_RADIUS_ERR \
         ,petFlux=POW(10.0, -0.4 * b.PETRO_MAG) /" + str(self.expTime) + " \
-        ,petFluxErr=ABS(b.PETRO_MAG_ERR) * POW(10.0, (-0.4*b.PETRO_MAG)) / " + str(self.expTime) + " / 1.085736  \
+        ,petFluxErr=-999  \
         ,petR50=b.PETRO_RADIUS_50 \
         ,petR50Err=b.PETRO_RADIUS_50_ERR \
@@ -653,4 +653,15 @@
         WHERE a.ippDetectID=b.IPP_IDET"
         self.scratchDb.execute(sql)
+
+        self.logger.infoPair("Adding", "petFluxErr for non nulls")
+        sql = "UPDATE StackApFlx as a, SkyChip_xsrc AS b SET \
+        petFluxErr=ABS(b.PETRO_MAG_ERR) * POW(10.0, (-0.4*b.PETRO_MAG)) / " + str(self.expTime) + " / 1.085736  \
+        WHERE a.ippDetectID=b.IPP_IDET \
+        AND (b.PETRO_MAG_ERR is not NULL AND b.PETRO_MAG is not NULL AND PETRO_MAG_ERR < 1000.0)"
+        # added this because when the petromagerr is crazy large (10^29 it out of ranges the flux err calc)
+        self.logger.infoPair("sql", sql)
+        self.scratchDb.execute(sql)
+
+
 
         self.logger.infoPair("adding"," PrimaryF to stackApFlx")
