IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38999


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

Location:
trunk/ippToPsps/jython
Files:
4 edited

Legend:

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

    r38995 r38999  
    466466    '''
    467467    Imports IPP tables from FITS file
    468 
    469     Accepts a regular expression filter so not all tables need to be imported
    470468    '''
    471469    def importIppTablesOhana(self):
     
    473471        self.logger.infoPair("Importing IPP tables", "using fits_to_mysql")
    474472
     473        count = 0
     474        self.tablesLoaded = []
     475
     476        fileName = self.fits.getPath()
     477
     478        # this option is equivalent to the stilts "addcol table_index $0" call
     479        fitsOptions  = " -sequence-column table_index"
     480        fitsOptions += " -sequence-column-start 1"
     481
     482        ## *** actually write the FITS data to mysql
     483        self.scratchDb.loadFITStoMYSQL(fileName, fitsOptions)
     484
    475485        ## use stilts to get a list of the tables from the header
    476486        try:
    477             tables = stilts.treads(self.fits.getPath())
     487            tables = stilts.treads(fileName)
    478488        except:
    479             self.logger.errorPair("STILTS could not import from", self.fits.getPath())
    480             return False
    481 
    482         self.scratchDb.loadFITStoMYSQL(self.fits.getPath())
    483 
    484         ## may need to do this with direct sql:
    485         # table = stilts.tpipe(table, cmd='addcol table_index $0')
    486 
    487         self.tablesLoaded = []
    488 
    489         count = 0
     489            self.logger.errorPair("STILTS could not import from", fileName)
     490            return False
     491
    490492        for table in tables:
    491 
    492493            # example of listing all columns in a table:
    493494            ## print "-----table: " + table.name
  • trunk/ippToPsps/jython/diffbatch.py

    r38960 r38999  
    564564    '''
    565565    Imports IPP tables from FITS file
     566
     567    Accepts a regular expression filter so not all tables need to be imported
     568    '''
     569    def importIppTables(self, columns="*", filter=""):
     570        if self.config.useOhanaMYSQLtoFITS:
     571            if not self.importIppTablesOhana():
     572                self.logger.errorPair("problem running", "importIppTablesOhana")
     573                return False
     574        else:
     575            if not self.importIppTablesStilts(columns, filter):
     576                self.logger.errorPair("problem running", "importIppTablesStilts")
     577                return False
     578
     579        return True
     580
     581    '''
     582    Imports IPP tables from FITS file
     583    '''
     584    def importIppTablesOhana(self):
     585       
     586        self.logger.infoPair("Importing DF tables", "using fits_to_mysql")
     587
     588        count = 0
     589        self.tablesLoaded = []
     590        self.haveApNpix = {}
     591
     592        for num in self.number:
     593            diffSkyFileID = self.number[num]
     594            fileName = self.fits[num].getPath()
     595           
     596            self.logger.infoPair("using filename:",fileName)
     597       
     598            ## output table names need to have "_num" appended. 
     599            fitsOptions  = "-tablesuffix _" + str(num)
     600
     601            # this option is equivalent to the stilts "addcol table_index $0" call
     602            fitsOptions += " -sequence-column table_index"
     603            fitsOptions += " -sequence-column-start 1"
     604
     605            ## *** actually write the FITS data to mysql
     606            self.scratchDb.loadFITStoMYSQL(fileName, fitsOptions)
     607
     608            ## use stilts to get a list of the tables from the header
     609            try:
     610                tables = stilts.treads(fileName)
     611            except:
     612                self.logger.errorPair("STILTS could not import from", fileName)
     613                return False
     614       
     615            # this is an optional field, check for it in the table below
     616            self.haveApNpix[num] = 0
     617
     618            for table in tables:
     619                # check for AP_NPIX columns: missing for SAS39
     620                if table.name == "SkyChip_psf":
     621                    columns = table.columns()
     622                    if 'AP_NPIX' in columns:
     623                        self.haveApNpix[num] = 1
     624
     625                myTable = table.name + "_" + str(num)
     626                count = count + 1
     627                     
     628                self.tablesLoaded.append(myTable)
     629
     630            # after all tables are read for this 'num', then index the set
     631            self.indexIppTables(num)
     632
     633        self.logger.infoPair("Done. Imported", "%d tables" % count)
     634        return True
     635
     636    '''
     637    Imports IPP tables from FITS file
    566638    Accepts a regular expression to match the tables so not all tables need to be imported
    567639    (This regex feature is not currently used...)
    568640    '''
    569     def importIppTables(self, columns="*", tableRE=""):
     641    def importIppTablesStilts(self, columns="*", tableRE=""):
    570642       
    571643        if self.config.retry: return True
     
    632704        return True
    633705
    634 
    635 
    636 
    637 
    638 
    639706    '''
    640707    Overriding this method. Use regex to trim off, eg _XY33 extension
  • 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)
  • trunk/ippToPsps/jython/stackbatch.py

    r38995 r38999  
    14231423           
    14241424            ## output table names need to have "filter" prepended. 
    1425             ## add this as an option
    1426             self.scratchDb.loadFITStoMYSQL(fileName, "-tableprefix " + filter)
    1427             ## XXX table = stilts.tpipe(table, cmd='addcol table_index $0')
     1425            fitsOptions  = "-tableprefix " + filter
     1426
     1427            # this pair of options is equivalent to the stilts "addcol table_index $0" call
     1428            fitsOptions += " -sequence-column table_index"
     1429            fitsOptions += " -sequence-column-start 1"
     1430
     1431            ## *** actually write the FITS data to mysql
     1432            self.scratchDb.loadFITStoMYSQL(fileName, fitsOptions)
    14281433
    14291434            # get the list of tables in this file:
Note: See TracChangeset for help on using the changeset viewer.