IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 25, 2011, 1:51:58 PM (15 years ago)
Author:
rhenders
Message:

added check to see if SOURCEID and IMAGEID are present in image FITS header before processding with DVO access; using 'safe' dictionary access for all header fields; improved some logging

File:
1 edited

Legend:

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

    r31848 r31932  
    8080       #self.endY = 8
    8181
    82        self.obsTime = float(self.header['MJD-OBS']) + (float(self.header['EXPTIME']) / 172800.0)
     82       if self.safeDictionaryAccess(self.header, 'MJD-OBS') == "NULL" or self.safeDictionaryAccess(self.header, 'EXPTIME') == "NULL":
     83           self.obsTime = 1.0
     84           self.logger.errorPair("Fields missing from rimary header", "MJD-OBS or EXPTIME (or both)")
     85           if not self.testMode:
     86               self.everythingOK = False
     87               return
     88           self.logger.infoPair("Hardcoding obs time to", "%f" % self.obsTime)
     89       else:
     90           self.obsTime = float(self.header['MJD-OBS']) + (float(self.header['EXPTIME']) / 172800.0)
    8391     
    8492       # set up some defauts
     
    8896
    8997       # get filterID using init table
    90        self.filter = self.header['FILTERID'][0:1]
     98       if self.safeDictionaryAccess(self.header, 'FILTERID') == "NULL":
     99          self.filter = 'g'
     100          self.logger.errorPair("Field missing from rimary header", "FILTERID")
     101          if not self.testMode:
     102              self.everythingOK = False
     103              return
     104          self.logger.infoPair("Hardcoding filter to", "%s" % self.filter)
     105       else:
     106          self.filter = self.header['FILTERID'][0:1]
    91107
    92108       # insert what we know about this stack batch into the stack table
     
    164180        ,' ' \
    165181        ,' ' \
    166         ," + self.header['ZPT_ERR'] + " \
    167         ," + self.header['MJD-OBS'] + " \
    168         ," + self.header['EXPREQ'] + " \
    169         ," + self.header['AIRMASS'] + " \
    170         ," + self.header['RA'] + " \
    171         ," + self.header['DEC'] + " \
    172         ,'" + self.header['CTYPE1'] + "' \
    173         ,'" + self.header['CTYPE2'] + "' \
    174         ," + self.header['CRVAL1'] + " \
    175         ," + self.header['CRVAL2'] + " \
    176         ," + self.header['CRPIX1'] + " \
    177         ," + self.header['CRPIX2'] + " \
    178         ," + self.header['CDELT1'] + " \
    179         ," + self.header['CDELT2'] + " \
    180         ," + self.header['PC001001'] + " \
    181         ," + self.header['PC001002'] + " \
    182         ," + self.header['PC002001'] + " \
    183         ," + self.header['PC002002'] + " \
    184         ," + self.header['NPLYTERM'] + " \
    185         ," + self.header['PCA1X3Y0'] + " \
    186         ," + self.header['PCA1X2Y1'] + " \
    187         ," + self.header['PCA1X1Y2'] + " \
    188         ," + self.header['PCA1X0Y3'] + " \
    189         ," + self.header['PCA1X2Y0'] + " \
    190         ," + self.header['PCA1X1Y1'] + " \
    191         ," + self.header['PCA1X0Y2'] + " \
    192         ," + self.header['PCA2X3Y0'] + " \
    193         ," + self.header['PCA2X2Y1'] + " \
    194         ," + self.header['PCA2X1Y2'] + " \
    195         ," + self.header['PCA2X0Y3'] + " \
    196         ," + self.header['PCA2X2Y0'] + " \
    197         ," + self.header['PCA2X1Y1'] + " \
    198         ," + self.header['PCA2X0Y2'] + " \
     182        ," + self.safeDictionaryAccess(self.header, 'ZPT_ERR') + " \
     183        ," + self.safeDictionaryAccess(self.header, 'MJD-OBS') + " \
     184        ," + self.safeDictionaryAccess(self.header, 'EXPREQ') + " \
     185        ," + self.safeDictionaryAccess(self.header, 'AIRMASS') + " \
     186        ," + self.safeDictionaryAccess(self.header, 'RA') + " \
     187        ," + self.safeDictionaryAccess(self.header, 'DEC') + " \
     188        ,'" + self.safeDictionaryAccess(self.header, 'CTYPE1') + "' \
     189        ,'" + self.safeDictionaryAccess(self.header, 'CTYPE2') + "' \
     190        ," + self.safeDictionaryAccess(self.header, 'CRVAL1') + " \
     191        ," + self.safeDictionaryAccess(self.header, 'CRVAL2') + " \
     192        ," + self.safeDictionaryAccess(self.header, 'CRPIX1') + " \
     193        ," + self.safeDictionaryAccess(self.header, 'CRPIX2') + " \
     194        ," + self.safeDictionaryAccess(self.header, 'CDELT1') + " \
     195        ," + self.safeDictionaryAccess(self.header, 'CDELT2') + " \
     196        ," + self.safeDictionaryAccess(self.header, 'PC001001') + " \
     197        ," + self.safeDictionaryAccess(self.header, 'PC001002') + " \
     198        ," + self.safeDictionaryAccess(self.header, 'PC002001') + " \
     199        ," + self.safeDictionaryAccess(self.header, 'PC002002') + " \
     200        ," + self.safeDictionaryAccess(self.header, 'NPLYTERM') + " \
     201        ," + self.safeDictionaryAccess(self.header, 'PCA1X3Y0') + " \
     202        ," + self.safeDictionaryAccess(self.header, 'PCA1X2Y1') + " \
     203        ," + self.safeDictionaryAccess(self.header, 'PCA1X1Y2') + " \
     204        ," + self.safeDictionaryAccess(self.header, 'PCA1X0Y3') + " \
     205        ," + self.safeDictionaryAccess(self.header, 'PCA1X2Y0') + " \
     206        ," + self.safeDictionaryAccess(self.header, 'PCA1X1Y1') + " \
     207        ," + self.safeDictionaryAccess(self.header, 'PCA1X0Y2') + " \
     208        ," + self.safeDictionaryAccess(self.header, 'PCA2X3Y0') + " \
     209        ," + self.safeDictionaryAccess(self.header, 'PCA2X2Y1') + " \
     210        ," + self.safeDictionaryAccess(self.header, 'PCA2X1Y2') + " \
     211        ," + self.safeDictionaryAccess(self.header, 'PCA2X0Y3') + " \
     212        ," + self.safeDictionaryAccess(self.header, 'PCA2X2Y0') + " \
     213        ," + self.safeDictionaryAccess(self.header, 'PCA2X1Y1') + " \
     214        ," + self.safeDictionaryAccess(self.header, 'PCA2X0Y2') + " \
    199215        )"
    200216        self.scratchDb.execute(sql)
     
    595611                header = self.fits.findAndReadHeader(ota + ".hdr")
    596612                if not header:
    597                     self.logger.error("No header found for OTA " + ota)
     613                    self.logger.errorPair("No header found for OTA", ota)
     614                    continue
     615
     616                # check we have valid sourceID/imageID pair from the header
     617                if 'SOURCEID' not in header or 'IMAGEID' not in header:
     618                    self.logger.errorPair("Can't read SOURCEID/IMAGEID pair for", ota)
    598619                    continue
    599620
     
    601622                if not self.useFullTables:
    602623                    self.scratchDb.insertNewDvoImage(header['SOURCEID'], header['IMAGEID'])
    603 
    604                 # check we have valid sourceID/imageID pair from the header
    605                 if 'SOURCEID' not in header or 'IMAGEID' not in header:
    606                     self.logger.error("Can't read SOURCEID/IMAGEID pair from " + ota + " header")
    607                     continue
    608624
    609625                # store these for later
Note: See TracChangeset for help on using the changeset viewer.