- Timestamp:
- Oct 28, 2015, 8:29:33 PM (11 years ago)
- Location:
- trunk/ippToPsps/jython
- Files:
-
- 6 edited
-
batch.py (modified) (5 diffs)
-
config.py (modified) (2 diffs)
-
detectionbatch.py (modified) (3 diffs)
-
dvo.py (modified) (2 diffs)
-
scratchdb.py (modified) (2 diffs)
-
stackbatch.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/batch.py
r38990 r38995 453 453 ''' 454 454 def importIppTables(self, columns="*", filter=""): 455 if self. useOhanaMYSQLtoFITS:455 if self.config.useOhanaMYSQLtoFITS: 456 456 if not self.importIppTablesOhana(): 457 457 self.logger.errorPair("problem running", "importIppTablesOhana") … … 480 480 return False 481 481 482 self.scratchDb.loadFITStoMYSQL(self.fits.getPath() , "none")482 self.scratchDb.loadFITStoMYSQL(self.fits.getPath()) 483 483 484 484 ## may need to do this with direct sql: … … 515 515 def importIppTablesStilts(self, columns="*", filter=""): 516 516 517 self.logger.infoPair("Importing tables with filter", filter)517 self.logger.infoPair("Importing tables (stilts) with filter", filter) 518 518 519 #print "trying to read ", self.fits.getPath()519 print "trying to read ", self.fits.getPath() 520 520 521 521 try: … … 527 527 self.tablesLoaded = [] 528 528 529 print "read tables from ", self.fits.getPath() 530 529 531 count = 0 530 532 for table in tables: 531 533 532 534 # example of listing all columns in a table: 533 ##print "-----table: " + table.name534 ## columns = table.columns()535 ## for column in columns:536 ##print column537 ##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 541 543 match = re.match(filter, table.name) 542 544 if not match: continue … … 555 557 self.logger.debug("Removing Infinity values from all columns") 556 558 table = stilts.tpipe(table, cmd='keepcols "' + columns + '"') 559 print "-----" 557 560 table = stilts.tpipe(table, cmd='replaceval -Infinity null *') 561 print "-----" 558 562 table = stilts.tpipe(table, cmd='replaceval Infinity null *') 559 # print "cleaned up values ", table563 print "cleaned up values ", table.name 560 564 561 565 try: -
trunk/ippToPsps/jython/config.py
r38990 r38995 21 21 def __init__(self): 22 22 23 self.useOhanaMYSQLtoFITS = False23 self.useOhanaMYSQLtoFITS = True 24 24 self.test = False 25 25 self.resetDvo = False … … 41 41 # by default, we use gpc1test in a test, and do not if not a test 42 42 self.gpc1test = self.test 43 44 if sys.argv.count("-stilts"): 45 self.useOhanaMYSQLtoFITS = False 46 sys.argv.remove("-stilts") 43 47 44 48 if sys.argv.count("-realgpc"): -
trunk/ippToPsps/jython/detectionbatch.py
r38973 r38995 844 844 self.updateDvoIDs("Detection_" + chipname, self.imageIDs[chipname]) 845 845 self.logger.info("updated dvoids") 846 846 847 results['NULLOBJID'] = self.scratchDb.reportAndDeleteRowsWithNULLS("Detection_" + chipname, "objID") 847 848 self.logger.info("deleted nulls") … … 1060 1061 def importIppTables(self, filter=""): 1061 1062 1062 ## XXX does the regex work?1063 regex = " XY*"1063 ## regex only works for -stilts import 1064 regex = ".*" 1064 1065 1065 1066 ## for a quick test, just do the first chip: … … 1076 1077 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" 1077 1078 1078 #### crap crap crap1079 1080 ## this is apparently over-riding the choices above1081 ## regex = ".*"1082 1083 1079 ## the list of columns above works fine for *.psf, but breaks the *.deteff tables 1084 1080 ## just read all columns -
trunk/ippToPsps/jython/dvo.py
r38990 r38995 590 590 ''' 591 591 def importPhotcodes(self, path, tableName): 592 if True:592 if self.config.useOhanaMYSQLtoFITS: 593 593 self.importPhotcodesOhana(path,tableName) 594 594 else: … … 607 607 # table = stilts.tpipe(table, cmd='addcol -after TYPE TYPE_AS_INT "TYPE + 0"') 608 608 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) 610 616 611 617 self.logger.debugPair("Finished importing", tableName) -
trunk/ippToPsps/jython/scratchdb.py
r38990 r38995 809 809 Use Ohana fits_to_mysql to load FITS tables into scratch db 810 810 ''' 811 def loadFITStoMYSQL(self, filename, tablename ):811 def loadFITStoMYSQL(self, filename, tablename=""): 812 812 813 813 self.logger.infoPair("starting loadFITStoMYSQL: ", filename) … … 819 819 cmd += " -dbuser " + self.dbUser 820 820 cmd += " -dbpass " + self.dbPass 821 cmd += " " + tablename 821 822 822 823 self.logger.debugPair("preparing command: ", cmd) 823 824 if tablename != "none":825 cmd += " -tablename " + tablename826 824 827 825 (stdoutFile, stdoutName) = tempfile.mkstemp(prefix="fits_to_mysql.stdout.", dir="/tmp") -
trunk/ippToPsps/jython/stackbatch.py
r38988 r38995 1387 1387 ''' 1388 1388 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 1389 1449 Accepts a regular expression to match the tables so not all tables need to be imported 1390 1450 (This regex feature is not currently used...) 1391 1451 ''' 1392 def importIppTables (self, columns="*", tableRE=""):1452 def importIppTablesStilts(self, columns="*", tableRE=""): 1393 1453 1394 1454 if self.config.retry: return True
Note:
See TracChangeset
for help on using the changeset viewer.
