Index: /trunk/ippToPsps/jython/gpc1db.py
===================================================================
--- /trunk/ippToPsps/jython/gpc1db.py	(revision 36710)
+++ /trunk/ippToPsps/jython/gpc1db.py	(revision 36711)
@@ -504,5 +504,5 @@
     joined to the dvodb 
     '''
-    def getStackIDsFromSkyID(self,dvoDb,skyID,filter):
+    def getStackIDFromSkyIDAndFilter(self,dvoDb,skyID,filter):
 
         self.logger.infoPair("finding stack_ids from gpc1 for sky_id ", skyID)
@@ -533,5 +533,5 @@
             self.logger.exception("can't query for stackid in DVO")
             self.logger.infoPair("failed sql:", sql)
-            return rows
+            return -999
 
         self.logger.infoPair("number of stackIDs found ", len(rows))
Index: /trunk/ippToPsps/jython/stackbatch.py
===================================================================
--- /trunk/ippToPsps/jython/stackbatch.py	(revision 36710)
+++ /trunk/ippToPsps/jython/stackbatch.py	(revision 36711)
@@ -59,14 +59,76 @@
        self.logger.infoPair("did I get", "here");
        self.stackType = "DEEP_STACK" # TODO
+       ## = stuff I commented out for pv2 stacks
+       
+       #heather tasks
+
+       # get a list of stackIDs
+       self.logger.infoPair ("getting stackID for: ","g.00000")
+       self.gstackID = getStackIDFromSkyIDAndFilter( skychunk.dvoLabel, skyID, "g.00000")
+       self.logger.infoPair ("getting stackID for: ","r.00000")
+       self.rstackID = getStackIDFromSkyIDAndFilter( skychunk.dvoLabel, skyID, "r.00000")
+       self.logger.infoPair ("getting stackID for: ","i.00000")
+       self.istackID = getStackIDFromSkyIDAndFilter( skychunk.dvoLabel, skyID, "i.00000")
+       self.logger.infoPair ("getting stackID for: ","z.00000")
+       self.zstackID = getStackIDFromSkyIDAndFilter( skychunk.dvoLabel, skyID, "z.00000")
+       self.logger.infoPair ("getting stackID for: ","y.00000")
+       self.ystackID = getStackIDFromSkyIDAndFilter( skychunk.dvoLabel, skyID, "y.00000")
+ 
+       # from each stackget fits name from getStackStageCmf
+       self.logger.infoPair ("finding fits file for: ","g.00000")
+       self.gfits = getStackStageCmf(skychunk.dvoLabel, gstackID)
+       self.logger.infoPair ("finding fits file for: ","r.00000")
+       self.rfits = getStackStageCmf(skychunk.dvoLabel, rstackID)
+       self.logger.infoPair ("finding fits file for: ","i.00000")
+       self.ifits = getStackStageCmf(skychunk.dvoLabel, istackID)
+       self.logger.infoPair ("finding fits file for: ","z.00000")
+       self.zfits = getStackStageCmf(skychunk.dvoLabel, zstackID)
+       self.logger.infoPair ("finding fits file for: ","y.00000")
+       self.yfits = getStackStageCmf(skychunk.dvoLabel, ystackID)
+
+       #from each of those get self.gheader, self.rheader, etc.
+
+       if self.gfits:
+           self.gheader = self.gfits.getPrimaryHeader()
+       if not self.gheader:
+           self.logger.errorPair("could not read FITS PHU for ",gstackID)
+           raise
+
+       if self.rfits:
+           self.rheader = self.rfits.getPrimaryHeader()
+       if not self.rheader:
+           self.logger.errorPair("could not read FITS PHU for ",rstackID)
+           raise
+
+       if self.ifits:
+           self.iheader = self.ifits.getPrimaryHeader()
+       if not self.iheader:
+           self.logger.errorPair("could not read FITS PHU for ",istackID)
+           raise
+
+       if self.zfits:
+           self.zheader = self.zfits.getPrimaryHeader()
+       if not self.zheader:
+           self.logger.errorPair("could not read FITS PHU for ",zstackID)
+           raise
+
+       if self.yfits:
+           self.yheader = self.yfits.getPrimaryHeader()
+       if not self.yheader:
+           self.logger.errorPair("could not read FITS PHU for ",ystackID)
+           raise
 
        # get stack meta data
-       meta = self.gpc1Db.getStackStageMeta(self.id)
+       meta = self.gpc1Db.getStackStageMeta(self.gstackID)  
+       ## this should be ok - it takes a stack_id and returns filter/skycell etc.
+
+
        if not meta:
            self.logger.errorPair("Could not get stack", "metadata")
            raise
 
-       self.filter = meta[0];
-       self.filter = self.filter[0:1]
-       self.filterID = self.scratchDb.getFilterID(self.filter)
+       ##self.filter = meta[0];
+       ##self.filter = self.filter[0:1]
+       ##self.filterID = self.scratchDb.getFilterID(self.filter)
        self.skycell = meta[1];
 
@@ -92,11 +154,16 @@
        # self.skycell = str( (tessID * (10000 * 1000)) + (int(self.projectioncell) * 1000) + cellID )
 
-       self.analysisVer = meta[2];
+       ##self.analysisVer = meta[2];
 
        #self.expTime = gpc1Db.getStackExpTime(self.id)
-       self.expTime = self.header['EXPTIME']
+       ##self.expTime = self.header['EXPTIME']
 
        # delete PSPS tables
-       self.scratchDb.dropTable("StackMeta")
+       self.scratchDb.dropTable("gStackMeta")
+       self.scratchDb.dropTable("rStackMeta")
+       self.scratchDb.dropTable("iStackMeta")
+       self.scratchDb.dropTable("zStackMeta")
+       self.scratchDb.dropTable("yStackMeta")
+
        self.scratchDb.dropTable("StackObject")
        self.scratchDb.dropTable("StackModelFit")
@@ -105,9 +172,28 @@
              # self.testprint()
 
+       # for PV2 we will have (grizy) of stack meta and skychip      
+
+
        # delete IPP tables
-       self.scratchDb.dropTable("SkyChip_psf")
-       self.scratchDb.dropTable("SkyChip_xrad")
-       self.scratchDb.dropTable("SkyChip_xfit")
-       self.scratchDb.dropTable("SkyChip_xsrc")
+       self.scratchDb.dropTable("gSkyChip_psf")
+       self.scratchDb.dropTable("gSkyChip_xrad")
+       self.scratchDb.dropTable("gSkyChip_xfit")
+       self.scratchDb.dropTable("gSkyChip_xsrc")
+       self.scratchDb.dropTable("rSkyChip_psf")
+       self.scratchDb.dropTable("rSkyChip_xrad")
+       self.scratchDb.dropTable("rSkyChip_xfit")
+       self.scratchDb.dropTable("rSkyChip_xsrc")
+       self.scratchDb.dropTable("iSkyChip_psf")
+       self.scratchDb.dropTable("iSkyChip_xrad")
+       self.scratchDb.dropTable("iSkyChip_xfit")
+       self.scratchDb.dropTable("iSkyChip_xsrc")
+       self.scratchDb.dropTable("zSkyChip_psf")
+       self.scratchDb.dropTable("zSkyChip_xrad")
+       self.scratchDb.dropTable("zSkyChip_xfit")
+       self.scratchDb.dropTable("zSkyChip_xsrc")
+       self.scratchDb.dropTable("ySkyChip_psf")
+       self.scratchDb.dropTable("ySkyChip_xrad")
+       self.scratchDb.dropTable("ySkyChip_xfit")
+       self.scratchDb.dropTable("ySkyChip_xsrc")
 
        # create an output filename, which is {stackID}.FITS
@@ -119,9 +205,9 @@
 
        # insert what we know about this stack batch into the stack table
-       self.ippToPspsDb.insertStackMeta(self.batchID, self.filter, self.stackType)
+       self.ippToPspsDb.insertStackMeta(self.batchID, "grizy" , self.stackType)
 
        # insert sourceID/imageID combo so DVO can look it up
-       if not self.useFullTables:
-           self.scratchDb.insertNewDvoExternID(self.header['SOURCEID'], self.header['IMAGEID'])
+       ##if not self.useFullTables:
+       ##    self.scratchDb.insertNewDvoExternID(self.header['SOURCEID'], self.header['IMAGEID'])
 
        # self.testprint()
@@ -132,5 +218,5 @@
        self.logger.infoPair("Skycell", "%s" % self.skycell)
        self.logger.infoPair("Projectioncell", "%s" % self.projectioncell)
-       self.logger.infoPair("Filter", "%s" % self.filter)
+       ##self.logger.infoPair("Filter", "%s" % self.filter)
 
     '''
@@ -922,9 +1008,18 @@
      
         # HAF everything is commented out for now with ##
-        ##if not self.useFullTables:
-        ##     if not self.getIDsFromDVO():
-        ##        return False
-        ##self.logger.infoPair("populating","StackMeta")    
-        ##self.populateStackMeta()
+        if not self.useFullTables:
+             if not self.getIDsFromDVO():
+                return False
+        self.logger.infoPair("populating","gStackMeta")    
+        self.populateStackMeta("g.00000")
+        self.logger.infoPair("populating","rStackMeta")    
+        self.populateStackMeta("r.00000")
+        self.logger.infoPair("populating","iStackMeta")    
+        self.populateStackMeta("i.00000")
+        self.logger.infoPair("populating","zStackMeta")    
+        self.populateStackMeta("z.00000")
+        self.logger.infoPair("populating","yStackMeta")    
+        self.populateStackMeta("y.00000")
+
         ##self.logger.infoPair("populating","StackObject") 
         ##self.populateStackObject()
