Index: trunk/ippToPsps/jython/gpc1db.py
===================================================================
--- trunk/ippToPsps/jython/gpc1db.py	(revision 32180)
+++ trunk/ippToPsps/jython/gpc1db.py	(revision 32493)
@@ -60,7 +60,7 @@
 
     '''
-    Gets a list of ids in this DVO database for this stage, could be cam or staticsky (so far)
-    '''
-    def getIDsInThisDVODbForThisStage(self, dvoDb, batchType):
+    Gets a list of ids in this DVO database for this stage, could be cam or staticsky, and a box can be defined with equatorial coordinates
+    '''
+    def getIDsInThisDVODbForThisStage(self, dvoDb, batchType, minRA=-999, maxRA=999, minDec=-999, maxDec=999):
 
         if batchType == "P2": # TODO define these someplace 
@@ -71,15 +71,19 @@
                    JOIN minidvodbRun USING(minidvodb_name) \
                    JOIN minidvodbProcessed USING(minidvodb_id) \
+                   JOIN camRun ON (stage_id = cam_id) \
+                   JOIN chipRun USING (chip_id) \
+                   JOIN rawExp USING (exp_id) \
                    WHERE minidvodbRun.minidvodb_group = '" + dvoDb + "' \
                    AND minidvodbRun.state = 'merged' \
                    AND minidvodbProcessed.fault = 0 \
                    AND addRun.stage = '" + stage + "' \
-                   AND addRun.state = 'full'"
+                   AND addRun.state = 'full' \
+                   AND decl BETWEEN RADIANS(" + str(minDec) + ") AND RADIANS(" + str(maxDec) + ") \
+                   AND ra BETWEEN RADIANS(" + str(minRA) + ") AND RADIANS(" + str(maxRA) + ")"
 
         elif batchType == "ST":       
 
             stage = "staticsky"
-            sql = "SELECT DISTINCT stack_id \
-                   FROM staticskyInput \
+            sql = "SELECT DISTINCT stack_id FROM staticskyInput \
                    JOIN addRun ON(staticskyInput.sky_id = addRun.stage_id) \
                    JOIN minidvodbRun USING(minidvodb_name) \
@@ -90,5 +94,5 @@
                    AND addRun.stage = '" + stage + "' \
                    AND addRun.state = 'full'"
-            
+
         try:
             rs = self.executeQuery(sql)
