Index: trunk/ippToPsps/jython/detectionbatch.py
===================================================================
--- trunk/ippToPsps/jython/detectionbatch.py	(revision 38878)
+++ trunk/ippToPsps/jython/detectionbatch.py	(revision 38899)
@@ -62,4 +62,13 @@
            self.logger.errorPair("Could not get", "camera metadata")
            raise
+
+       # set a flag indicating that we have the new columns added in version 5 of the
+       # cmf/smf format. It began around cam_id 982483 apparently.
+       # if cam_id is small assume that it cam from the test suite. 
+       # XXX: Should be looking for EXTNAME >= "PS1_V5"
+       if (self.id >= 982483 or self.id < 100):
+           self.v5cols = 1;
+       else:
+           self.v5cols = 0;
 
        self.expID = meta[0];
@@ -449,5 +458,5 @@
         sqlLine.group("xPosErr",          "X_PSF_SIG")                                               
         sqlLine.group("yPosErr",          "Y_PSF_SIG")                                               
-        if (self.id >= 982483):
+        if (self.v5cols):
             sqlLine.group("pltScale",     "PLTSCALE")                                      
             sqlLine.group("posAngle",     "POSANGLE")                                      
@@ -462,5 +471,5 @@
         sqlLine.group("psfFlux",          "PSF_INST_FLUX / " + expTimeString)
         sqlLine.group("psfFluxErr",       "PSF_INST_FLUX_SIG / " + expTimeString)
-        if (self.id >= 982483):
+        if (self.v5cols):
             sqlLine.group("psfMajorFWHM", "PSF_FWHM_MAJ * abs(PLTSCALE)")                                               
             sqlLine.group("psfMinorFWHM", "PSF_FWHM_MIN * abs(PLTSCALE)")                                               
@@ -480,5 +489,5 @@
         sqlLine.group("momentM4C",        "MOMENTS_M4C * PLTSCALE * PLTSCALE")                                             
         sqlLine.group("momentM4S",        "MOMENTS_M4S * PLTSCALE * PLTSCALE") 
-        if (self.id >= 982483):
+        if (self.v5cols):
             sqlLine.group("apFlux",       "AP_FLUX / " + expTimeString)
             sqlLine.group("apFluxErr",    "AP_FLUX_SIG / " + expTimeString)
@@ -999,5 +1008,5 @@
         print "my ID: " + str(self.id)
 
-        if (self.id < 982483):
+        if (not self.v5cols):
             # XXX EAM NOTE : this is fragile : requires PS1_V4
             columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG                   PSF_INST_FLUX PSF_INST_FLUX_SIG       PSF_MAJOR PSF_MINOR PSF_THETA          PSF_QF PSF_QF_PERFECT PSF_CHISQ EXT_NSIGMA MOMENTS_XX MOMENTS_XY MOMENTS_YY MOMENTS_R1 MOMENTS_RH MOMENTS_M3C MOMENTS_M3S MOMENTS_M4C MOMENTS_M4S                             AP_MAG_RADIUS KRON_FLUX KRON_FLUX_ERR SKY SKY_SIGMA FLAGS FLAGS2"
