Index: trunk/ippToPsps/jython/stackbatch.py
===================================================================
--- trunk/ippToPsps/jython/stackbatch.py	(revision 39250)
+++ trunk/ippToPsps/jython/stackbatch.py	(revision 39305)
@@ -274,7 +274,13 @@
         pltscale2 = pltscale * pltscale
 
-        psfFwhmMajor = pltscale * self.getKeyFloat(header, "%.8f", 'FWHM_MAJ')
-        psfFwhmMinor = pltscale * self.getKeyFloat(header, "%.8f", 'FWHM_MIN')
-        psfFWHM = 0.5*(psfFwhmMajor + psfFwhmMinor)
+        psfFwhmMajor = self.getKeyFloat(header, "%.8f", 'FWHM_MAJ')
+        if (psfFwhmMajor != "NULL"): psfFwhmMajor *= pltscale
+
+        psfFwhmMinor = self.getKeyFloat(header, "%.8f", 'FWHM_MIN')
+        if (psfFwhmMinor != "NULL"): psfFwhmMinor *= pltscale
+
+        psfFWHM = "NULL"
+        if (psfFwhmMajor != "NULL") and (psfFwhmMinor != "NULL"):
+            psfFWHM = 0.5*(psfFwhmMajor + psfFwhmMinor)
 
         psfmodel_name    = self.getKeyValue(header, 'PSFMODEL')
@@ -283,18 +289,24 @@
         ast_cdx = self.getKeyFloat(header, "%.8f",'AST_CDX')
         ast_cdy = self.getKeyFloat(header, "%.8f",'AST_CDY')
-        astroscat = math.sqrt(ast_cdx**2 + ast_cdy**2)
+
+        astroscat = "NULL"
+        if (ast_cdx != "NULL") and (ast_cdy != "NULL"):
+            astroscat = math.sqrt(ast_cdx**2 + ast_cdy**2)
         
         # Convert detectionThreshold to appropriate magnitudes
-        magref  = self.magref[filter]
-        expTime = self.expTime[filter]
-        zp      = self.zpImage[filter]
-        zpErr   = self.zpError[filter]
+        magref  = "NULL" if (self.magref[filter]  == "NULL") else float(self.magref[filter])
+        expTime = "NULL" if (self.expTime[filter] == "NULL") else float(self.expTime[filter])
+        zp      = "NULL" if (self.zpImage[filter] == "NULL") else float(self.zpImage[filter])
+        zpErr   = "NULL" if (self.zpError[filter] == "NULL") else float(self.zpError[filter])
 
         # zp correction should comes from DVO (unless image is not in DVO)
         zpImage = self.scratchDb.getImageZeroPoint(stackID)
-        if zpImage < 0.0:
+
+        if (zpImage == "NULL"):
             zpImage = zp
 
-        detectionThreshold = magref + zpImage + 2.5 * math.log10(expTime)
+        detectionThreshold = "NULL"
+        if (magref != "NULL") and (zpImage != "NULL") and (expTime != "NULL"):
+            detectionThreshold = magref + zpImage + 2.5 * math.log10(expTime)
 
         # insert stack metadata into table
@@ -1040,4 +1052,9 @@
         exptimeString = str(self.getKeyFloat(header, "%.5f", "EXPTIME"))
 
+        ## this is a serious problem: not sure we have to handle it.
+        if (exptimeString == "NULL"):
+            print "**** serious error: EXPTIME is NULL (missing or NAN)"
+            os._exit(4)
+
         # generate the sql to do the necessary ops on the columns    
         sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + cmfTable + " AS b SET ")
