IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40275 for trunk


Ignore:
Timestamp:
Dec 12, 2017, 1:11:39 PM (9 years ago)
Author:
eugene
Message:

add more failure tests and messages; check for PS1_V6 format for the Images.dat (use readFitsHeader method); change MCAL to MCAL_PSF, MCAL_APER

File:
1 edited

Legend:

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

    r40011 r40275  
    101101
    102102        if not self.loadImages():
     103            self.logger.debugPair("FAILED to load images", "exiting")
    103104            os._exit(1)
    104105
     106        print "DONE load images (resetAllTables)"
    105107
    106108    '''
     
    145147        self.logger.infoPair("DVO Images.dat file", "NOT up-to-date")
    146148
     149        # check on the format:
     150        try:
     151            imagesHeaderPHU = self.readFitsHeader("PHU", path)
     152        except Exception,e:
     153            # print the error, wait a few secs then try again
     154            print str(e)
     155            self.logger.infoPair("Failed to find PHU for Images.dat", path)
     156            raise
     157
     158        if "FORMAT" in imagesHeaderPHU:
     159            fileFormat = imagesHeaderPHU["FORMAT"]
     160        else:
     161            self.logger.infoPair("Missing FORMAT for Images.dat", path)
     162            raise
     163
     164        self.logger.infoPair("got FORMAT for Images.dat", fileFormat)
     165
     166        if not (fileFormat == "PS1_V6"):
     167            self.logger.infoPair("Invalid FORMAT for Images.dat (PS1_V6)", fileFormat)
     168            return False
     169
    147170        self.importFits(
    148171                path,
    149                 "SOURCE_ID IMAGE_ID EXTERN_ID FLAGS MCAL SECZ PHOTCODE XPIX_SYS_ERR YPIX_SYS_ERR N_FIT_ASTROM MAG_SYS_ERR N_FIT_PHOTOM",
     172                "SOURCE_ID IMAGE_ID EXTERN_ID FLAGS MCAL_PSF MCAL_APER SECZ PHOTCODE XPIX_SYS_ERR YPIX_SYS_ERR N_FIT_ASTROM MAG_SYS_ERR N_FIT_PHOTOM",
    150173                self.scratchDb.dvoImagesTable)
    151174        self.logger.infoPair("Adding primary key to", self.scratchDb.dvoImagesTable)
     
    559582          self.logger.debugPair("Reading IPP table", table.name)
    560583          table = stilts.tpipe(table, cmd='explodeall')
    561           #adds an index to all the tables
    562        #   table = stilts.tpipe(table, cmd='addcol table_index $0')
     584
     585          # adds an index to all the tables
     586          # table = stilts.tpipe(table, cmd='addcol table_index $0')
    563587
    564588          # IPP FITS files are littered with infinity values. Remove them
     
    566590          table = stilts.tpipe(table, cmd='replaceval -Infinity null *')
    567591          table = stilts.tpipe(table, cmd='replaceval Infinity null *')
     592
     593          # verify that all columns in 'columns' exist in the tabl
     594          ## myColumns = table.columns()
     595          ## for wcol in columns:
     596          ##     foundCol = False
     597          ##     for tcol in myColumns:
     598          ##         if (wcol == tcol.name):
     599          ##             print "found wcol " + wcol
     600          ##             foundCol = True;
     601          ##             break
     602          ##     if not foundCol:
    568603
    569604          attempts = 0
     
    575610                  table.cmd_keepcols(columns).write(self.scratchDb.url + '#' + tableName)
    576611                  break
    577               except:
    578                   # wait a few secs then try again
     612              except Exception,e:
     613                  # print the error, wait a few secs then try again
     614                  print str(e)
    579615                  time.sleep(2)
    580616                  attempts = attempts + 1
     
    663699
    664700    '''
     701    Find and read a header extension.
     702    '''
     703    def readFitsHeader(self, extname, filename):
     704
     705        cmd = "fhead -n %s %s" % (extname, filename)
     706        p = Popen(cmd, shell=True, stdout=PIPE)
     707        output = p.communicate()[0]       
     708
     709        header = {}
     710
     711        # split the output header bytes into key/value pairs for each 80-byte line
     712        for i in range(0, len(output), 80):
     713            # print "line %d : %s" % (i, output[i:i+80])
     714            record = output[i:i+80]
     715
     716            match = re.match('^(HIERARCH )*([a-zA-Z0-9-_\.]+)\s*=\s+\'*([a-zA-Z0-9-+_\.:\s@#\(\)\,]+)\'*\\/*', record)
     717
     718            if match:
     719                param = match.group(2)
     720                value = match.group(3).strip()
     721                if value == "NaN": value = "NULL"
     722                header[param] = value
     723
     724        return header
     725
     726    '''
    665727    ingest skyregion into MySQL database using the native DVO program dvopsps
    666728    Populates dvoDetections and dvoDone with FITS tables from DVO for the defined sky area, this
     
    688750
    689751        # make sure we have an up-to-date Images table
    690         self.loadImages() # this is in nativeIngestDetections (remove?)
     752        if not self.loadImages(): # this is in nativeIngestDetections (remove?)
     753            self.logger.debugPair("FAILED to load images", "exiting")
     754            os._exit(1)
     755
     756        print "DONE load images (nativeIngestDetections)"
    691757
    692758        # the box dimensions are the area used to select the items of
Note: See TracChangeset for help on using the changeset viewer.