IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 29, 2015, 10:50:19 AM (11 years ago)
Author:
eugene
Message:

generate the table_index columns; update diff and forcedwarp to use fits_to_mysql

File:
1 edited

Legend:

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

    r38990 r38999  
    747747
    748748        return True
    749          
    750 
     749
     750    '''
     751    Imports IPP tables from FITS file
     752
     753    Accepts a regular expression filter so not all tables need to be imported
     754    '''
     755    def importIppTables(self, columns="*", filter=""):
     756        if self.config.useOhanaMYSQLtoFITS:
     757            if not self.importIppTablesOhana():
     758                self.logger.errorPair("problem running", "importIppTablesOhana")
     759                return False
     760        else:
     761            if not self.importIppTablesStilts(columns, filter):
     762                self.logger.errorPair("problem running", "importIppTablesStilts")
     763                return False
     764
     765        return True
     766
     767    '''
     768    Imports IPP tables from FITS file
     769    '''
     770    def importIppTablesOhana(self):
     771       
     772        self.logger.infoPair("Importing DF tables", "using fits_to_mysql")
     773
     774        count = 0
     775        self.tablesLoaded = []
     776        self.haveApNpix = {}
     777
     778        for num in self.number:
     779            forcedWarpID = self.number[num]
     780            fileName = self.fits[num].getPath()
     781           
     782            self.logger.infoPair("loading for FW id", forcedWarpID)
     783           
     784            self.logger.infoPair("using filename:",fileName)
     785       
     786            ## output table names need to have "_num" appended. 
     787            fitsOptions  = "-tablesuffix _" + str(forcedWarpID)
     788
     789            # this option is equivalent to the stilts "addcol table_index $0" call
     790            fitsOptions += " -sequence-column table_index"
     791            fitsOptions += " -sequence-column-start 1"
     792
     793            ## *** actually write the FITS data to mysql
     794            self.scratchDb.loadFITStoMYSQL(fileName, fitsOptions)
     795
     796            ## use stilts to get a list of the tables from the header
     797            try:
     798                tables = stilts.treads(fileName)
     799            except:
     800                self.logger.errorPair("STILTS could not import from", fileName)
     801                return False
     802       
     803            # this is an optional field, check for it in the table below
     804            self.haveApNpix[num] = 0
     805
     806            for table in tables:
     807                myTable = table.name + "_" + str(forcedWarpID)
     808                count = count + 1
     809                     
     810                self.tablesLoaded.append(myTable)
     811
     812            self.indexIppTables(forcedWarpID)
     813                     
     814        # after all tables are read for this forcedWarpID, then index the set
     815        self.logger.infoPair("Done. Imported", "%d tables" % count)
     816        return True
    751817
    752818    '''
    753819    This function reads the cmf/smf file and loads it into the database as its own table
    754820    '''
    755     def importIppTables(self, columns="*", tableRE=""):
     821    def importIppTablesStilts(self, columns="*", tableRE=""):
    756822
    757823        self.tablesLoaded = []
     
    760826        for num in self.number:
    761827            forcedWarpID = self.number[num]
    762             if self.config.retry: return True
     828            fileName = self.fits[num].getPath()
     829
    763830            self.logger.infoPair("loading for add id", forcedWarpID)
    764831            self.logger.infoPair("Importing FW tables with table match expression: ", tableRE)
    765             fileName = self.fits[num].getPath()
    766832           
    767833            self.logger.infoPair("using filename:",fileName)
Note: See TracChangeset for help on using the changeset viewer.