IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36721


Ignore:
Timestamp:
May 1, 2014, 5:33:02 PM (12 years ago)
Author:
heather
Message:

first attempt to import IPP ST tables

File:
1 edited

Legend:

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

    r36720 r36721  
    440440
    441441      return True
     442    '''
     443    Imports IPP tables from FITS file
     444
     445    Accepts a regular expression filter so not all tables need to be imported
     446    '''
     447    def importIppSTTables(self, columns="*", filter=""):
     448
     449      self.logger.infoPair("Importing ST tables with filter", filter)
     450
     451      # print "trying to read ", self.fits.getPath()
     452
     453      # ST has 5 cmf files - all with the same table names. To counter this we do it like this.
     454
     455      filters = ["g","r","i","z","y"]
     456
     457      for f in filters:
     458          if (f == "g"):
     459              fileName = self.gfits.getPath()
     460          if (f == "r"):
     461              fileName = self.rfits.getPath()
     462          if (f == "i"):
     463              fileName = self.ifits.getPath()
     464          if (f == "z"):
     465              fileName = self.zfits.getPath()
     466          if (f == "y"):
     467              fileName = self.yfits.getPath()
     468
     469
     470          try:
     471              tables = stilts.treads(fileName)
     472          except:
     473              self.logger.errorPair("STILTS could not import from", fileName)
     474              return False
     475             
     476          count = 0
     477          for table in tables:
     478             
     479              # print "import smf table ", table
     480              match = re.match(filter, table.name)
     481             
     482              if not match: continue
     483              self.logger.debugPair("Reading IPP table", table.name)
     484              table = stilts.tpipe(table, cmd='addcol table_index $0')
     485                 
     486              table = stilts.tpipe(table, cmd='explodeall')
     487                 
     488              # print "read smf table ", table
     489                 
     490              # drop any previous tables before import
     491              self.scratchDb.dropTable(f + table.name)
     492                 
     493              # IPP FITS files are littered with infinities, so remove these
     494              self.logger.debug("Removing Infinity values from all columns")
     495              table = stilts.tpipe(table, cmd='keepcols "' + columns + '"')
     496              table = stilts.tpipe(table, cmd='replaceval -Infinity null *')
     497              table = stilts.tpipe(table, cmd='replaceval Infinity null *')
     498              # print "cleaned up values ", table
     499                 
     500              try:
     501                  table.write(self.scratchDb.url + '#' + f + table.name)
     502                  # XXX this one is not needed
     503                  # self.scratchDb.killLastConnectionID()
     504                  count = count + 1
     505              except:
     506                  self.logger.exception("Problem writing table '" + f + table.name + "' to the database")
     507                     
     508              self.logger.infoPair("Done. Imported", "%d tables" % count)
     509              self.indexIppTables()
     510                     
     511              return True
    442512
    443513    '''
     
    551621        # for P2/ST, this reads the detection tables from the CMF/SMF file(s)
    552622        # for OB, this imports object data from DVO
    553         if self.batchType != "ST":
    554             # if not ST we do it
     623        if self.batchType = "ST":
     624            if not self.importIppSTTables():
     625                self.logger.errorPair("skipping this batch", "could not import ST IPP tables")
     626                self.ippToPspsDb.updateProcessed(self.batchID, -1)
     627                raise
     628        else:   
     629            # if not ST we do this
    555630            if not self.importIppTables():
    556631                if self.batchType == "OB":
Note: See TracChangeset for help on using the changeset viewer.