IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 5, 2016, 3:34:49 PM (11 years ago)
Author:
eugene
Message:

need to handle possibly NULL / NaN values in the headers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/stackbatch.py

    r39250 r39305  
    274274        pltscale2 = pltscale * pltscale
    275275
    276         psfFwhmMajor = pltscale * self.getKeyFloat(header, "%.8f", 'FWHM_MAJ')
    277         psfFwhmMinor = pltscale * self.getKeyFloat(header, "%.8f", 'FWHM_MIN')
    278         psfFWHM = 0.5*(psfFwhmMajor + psfFwhmMinor)
     276        psfFwhmMajor = self.getKeyFloat(header, "%.8f", 'FWHM_MAJ')
     277        if (psfFwhmMajor != "NULL"): psfFwhmMajor *= pltscale
     278
     279        psfFwhmMinor = self.getKeyFloat(header, "%.8f", 'FWHM_MIN')
     280        if (psfFwhmMinor != "NULL"): psfFwhmMinor *= pltscale
     281
     282        psfFWHM = "NULL"
     283        if (psfFwhmMajor != "NULL") and (psfFwhmMinor != "NULL"):
     284            psfFWHM = 0.5*(psfFwhmMajor + psfFwhmMinor)
    279285
    280286        psfmodel_name    = self.getKeyValue(header, 'PSFMODEL')
     
    283289        ast_cdx = self.getKeyFloat(header, "%.8f",'AST_CDX')
    284290        ast_cdy = self.getKeyFloat(header, "%.8f",'AST_CDY')
    285         astroscat = math.sqrt(ast_cdx**2 + ast_cdy**2)
     291
     292        astroscat = "NULL"
     293        if (ast_cdx != "NULL") and (ast_cdy != "NULL"):
     294            astroscat = math.sqrt(ast_cdx**2 + ast_cdy**2)
    286295       
    287296        # Convert detectionThreshold to appropriate magnitudes
    288         magref  = self.magref[filter]
    289         expTime = self.expTime[filter]
    290         zp      = self.zpImage[filter]
    291         zpErr   = self.zpError[filter]
     297        magref  = "NULL" if (self.magref[filter]  == "NULL") else float(self.magref[filter])
     298        expTime = "NULL" if (self.expTime[filter] == "NULL") else float(self.expTime[filter])
     299        zp      = "NULL" if (self.zpImage[filter] == "NULL") else float(self.zpImage[filter])
     300        zpErr   = "NULL" if (self.zpError[filter] == "NULL") else float(self.zpError[filter])
    292301
    293302        # zp correction should comes from DVO (unless image is not in DVO)
    294303        zpImage = self.scratchDb.getImageZeroPoint(stackID)
    295         if zpImage < 0.0:
     304
     305        if (zpImage == "NULL"):
    296306            zpImage = zp
    297307
    298         detectionThreshold = magref + zpImage + 2.5 * math.log10(expTime)
     308        detectionThreshold = "NULL"
     309        if (magref != "NULL") and (zpImage != "NULL") and (expTime != "NULL"):
     310            detectionThreshold = magref + zpImage + 2.5 * math.log10(expTime)
    299311
    300312        # insert stack metadata into table
     
    10401052        exptimeString = str(self.getKeyFloat(header, "%.5f", "EXPTIME"))
    10411053
     1054        ## this is a serious problem: not sure we have to handle it.
     1055        if (exptimeString == "NULL"):
     1056            print "**** serious error: EXPTIME is NULL (missing or NAN)"
     1057            os._exit(4)
     1058
    10421059        # generate the sql to do the necessary ops on the columns   
    10431060        sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + cmfTable + " AS b SET ")
Note: See TracChangeset for help on using the changeset viewer.