IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38995 for trunk


Ignore:
Timestamp:
Oct 28, 2015, 8:29:33 PM (11 years ago)
Author:
eugene
Message:

add -stilts option; fix stilts and regex for detectionbatch; add tableprefix option for stacks; alter photcode.type to type_as_int

Location:
trunk/ippToPsps/jython
Files:
6 edited

Legend:

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

    r38990 r38995  
    453453    '''
    454454    def importIppTables(self, columns="*", filter=""):
    455         if self.useOhanaMYSQLtoFITS:
     455        if self.config.useOhanaMYSQLtoFITS:
    456456            if not self.importIppTablesOhana():
    457457                self.logger.errorPair("problem running", "importIppTablesOhana")
     
    480480            return False
    481481
    482         self.scratchDb.loadFITStoMYSQL(self.fits.getPath(), "none")
     482        self.scratchDb.loadFITStoMYSQL(self.fits.getPath())
    483483
    484484        ## may need to do this with direct sql:
     
    515515    def importIppTablesStilts(self, columns="*", filter=""):
    516516       
    517         self.logger.infoPair("Importing tables with filter", filter)
     517        self.logger.infoPair("Importing tables (stilts) with filter", filter)
    518518       
    519         # print "trying to read ", self.fits.getPath()
     519        print "trying to read ", self.fits.getPath()
    520520
    521521        try:
     
    527527        self.tablesLoaded = []
    528528
     529        print "read tables from ", self.fits.getPath()
     530
    529531        count = 0
    530532        for table in tables:
    531533
    532534            # example of listing all columns in a table:
    533             ## print "-----table: " + table.name
    534             ## columns = table.columns()
    535             ## for column in columns:
    536             ##     print column
    537             ##
    538             ## print "-----"
    539 
    540             # print "import smf table ", table
     535            print "-----table: " + table.name
     536            myColumns = table.columns()
     537            for column in myColumns:
     538                print column
     539            print "-----"
     540
     541            print "import smf table ", table.name
     542
    541543            match = re.match(filter, table.name)
    542544            if not match: continue
     
    555557            self.logger.debug("Removing Infinity values from all columns")
    556558            table = stilts.tpipe(table, cmd='keepcols "' + columns + '"')
     559            print "-----"
    557560            table = stilts.tpipe(table, cmd='replaceval -Infinity null *')
     561            print "-----"
    558562            table = stilts.tpipe(table, cmd='replaceval Infinity null *')
    559             # print "cleaned up values ", table
     563            print "cleaned up values ", table.name
    560564
    561565            try:
  • trunk/ippToPsps/jython/config.py

    r38990 r38995  
    2121    def __init__(self):
    2222
    23         self.useOhanaMYSQLtoFITS = False
     23        self.useOhanaMYSQLtoFITS = True
    2424        self.test = False
    2525        self.resetDvo = False
     
    4141        # by default, we use gpc1test in a test, and do not if not a test
    4242        self.gpc1test = self.test
     43
     44        if sys.argv.count("-stilts"):
     45            self.useOhanaMYSQLtoFITS = False
     46            sys.argv.remove("-stilts")
    4347
    4448        if sys.argv.count("-realgpc"):
  • trunk/ippToPsps/jython/detectionbatch.py

    r38973 r38995  
    844844        self.updateDvoIDs("Detection_" + chipname, self.imageIDs[chipname])
    845845        self.logger.info("updated dvoids")
     846
    846847        results['NULLOBJID'] = self.scratchDb.reportAndDeleteRowsWithNULLS("Detection_" + chipname, "objID")
    847848        self.logger.info("deleted nulls")
     
    10601061    def importIppTables(self, filter=""):
    10611062       
    1062         ## XXX does the regex work?
    1063         regex = "XY*"
     1063        ## regex only works for -stilts import
     1064        regex = ".*"
    10641065   
    10651066        ## for a quick test, just do the first chip:
     
    10761077            columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG POSANGLE PLTSCALE PSF_INST_FLUX PSF_INST_FLUX_SIG PSF_FWHM_MAJ PSF_FWHM_MIN PSF_THETA PSF_CORE PSF_QF PSF_QF_PERFECT PSF_CHISQ EXT_NSIGMA MOMENTS_XX MOMENTS_XY MOMENTS_YY MOMENTS_R1 MOMENTS_RH MOMENTS_M3C MOMENTS_M3S MOMENTS_M4C MOMENTS_M4S AP_FLUX AP_FLUX_SIG AP_NPIX AP_MAG_RADIUS KRON_FLUX KRON_FLUX_ERR SKY SKY_SIGMA FLAGS FLAGS2"
    10771078
    1078             #### crap crap crap
    1079 
    1080         ## this is apparently over-riding the choices above
    1081         ## regex = ".*"
    1082 
    10831079        ## the list of columns above works fine for *.psf, but breaks the *.deteff tables
    10841080        ## just read all columns
  • trunk/ippToPsps/jython/dvo.py

    r38990 r38995  
    590590    '''
    591591    def importPhotcodes(self, path, tableName):
    592         if True:
     592        if self.config.useOhanaMYSQLtoFITS:
    593593            self.importPhotcodesOhana(path,tableName)
    594594        else:
     
    607607      # table = stilts.tpipe(table, cmd='addcol -after TYPE TYPE_AS_INT "TYPE + 0"')
    608608
    609       self.scratchDb.loadFITStoMYSQL (path, tableName)
     609      self.scratchDb.loadFITStoMYSQL (path, "-tablename " + tableName)
     610
     611      sql = "ALTER TABLE " + tableName + " ADD COLUMN TYPE_AS_INT INT AFTER TYPE"
     612      self.scratchDb.execute(sql)
     613
     614      sql = "UPDATE " + tableName + " SET TYPE_AS_INT = ascii(TYPE)"
     615      self.scratchDb.execute(sql)
    610616
    611617      self.logger.debugPair("Finished importing", tableName)
  • trunk/ippToPsps/jython/scratchdb.py

    r38990 r38995  
    809809    Use Ohana fits_to_mysql to load FITS tables into scratch db
    810810    '''
    811     def loadFITStoMYSQL(self, filename, tablename):
     811    def loadFITStoMYSQL(self, filename, tablename=""):
    812812
    813813        self.logger.infoPair("starting loadFITStoMYSQL: ", filename)
     
    819819        cmd += " -dbuser " + self.dbUser
    820820        cmd += " -dbpass " + self.dbPass
     821        cmd += " " + tablename
    821822
    822823        self.logger.debugPair("preparing command: ", cmd)
    823 
    824         if tablename != "none":
    825             cmd += " -tablename " + tablename
    826824
    827825        (stdoutFile, stdoutName) = tempfile.mkstemp(prefix="fits_to_mysql.stdout.", dir="/tmp")
  • trunk/ippToPsps/jython/stackbatch.py

    r38988 r38995  
    13871387    '''
    13881388    Imports IPP tables from FITS file
     1389
     1390    Accepts a regular expression filter so not all tables need to be imported
     1391    '''
     1392    def importIppTables(self, columns="*", filter=""):
     1393        if self.config.useOhanaMYSQLtoFITS:
     1394            if not self.importIppTablesOhana():
     1395                self.logger.errorPair("problem running", "importIppTablesOhana")
     1396                return False
     1397        else:
     1398            if not self.importIppTablesStilts(columns, filter):
     1399                self.logger.errorPair("problem running", "importIppTablesStilts")
     1400                return False
     1401
     1402        return True
     1403
     1404    '''
     1405    Imports IPP tables from FITS file
     1406    Accepts a regular expression to match the tables so not all tables need to be imported
     1407    '''
     1408    def importIppTablesOhana(self, columns="*", tableRE=""):
     1409       
     1410        self.logger.infoPair("Importing ST tables using ", "Ohana")
     1411
     1412        self.tablesLoaded = []
     1413
     1414        count = 0
     1415        for filter in self.filters:
     1416            if self.stackIDs[filter] <= 0: 
     1417                self.logger.infoPair("no files for filter" , filter)
     1418                continue
     1419
     1420            fileName = self.fits[filter].getPath()
     1421           
     1422            self.logger.infoPair("using filename:",fileName)
     1423           
     1424            ## 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')
     1428
     1429            # get the list of tables in this file:
     1430            try:
     1431                tables = stilts.treads(fileName)
     1432            except:
     1433                self.logger.errorPair("STILTS could not import from", fileName)
     1434                return False
     1435           
     1436            for table in tables:
     1437                self.logger.debugPair("Read IPP table", table.name)
     1438                myTable = filter + table.name.replace(".", "_")
     1439                self.tablesLoaded.append(myTable)
     1440                count += 1
     1441
     1442        self.logger.infoPair("Done. Imported", "%d tables" % count)
     1443        self.indexIppTables()
     1444
     1445        return True
     1446
     1447    '''
     1448    Imports IPP tables from FITS file
    13891449    Accepts a regular expression to match the tables so not all tables need to be imported
    13901450    (This regex feature is not currently used...)
    13911451    '''
    1392     def importIppTables(self, columns="*", tableRE=""):
     1452    def importIppTablesStilts(self, columns="*", tableRE=""):
    13931453       
    13941454        if self.config.retry: return True
Note: See TracChangeset for help on using the changeset viewer.