Changeset 38999
- Timestamp:
- Oct 29, 2015, 10:50:19 AM (11 years ago)
- Location:
- trunk/ippToPsps/jython
- Files:
-
- 4 edited
-
batch.py (modified) (2 diffs)
-
diffbatch.py (modified) (2 diffs)
-
forcedwarpbatch.py (modified) (2 diffs)
-
stackbatch.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/batch.py
r38995 r38999 466 466 ''' 467 467 Imports IPP tables from FITS file 468 469 Accepts a regular expression filter so not all tables need to be imported470 468 ''' 471 469 def importIppTablesOhana(self): … … 473 471 self.logger.infoPair("Importing IPP tables", "using fits_to_mysql") 474 472 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 475 485 ## use stilts to get a list of the tables from the header 476 486 try: 477 tables = stilts.treads( self.fits.getPath())487 tables = stilts.treads(fileName) 478 488 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 490 492 for table in tables: 491 492 493 # example of listing all columns in a table: 493 494 ## print "-----table: " + table.name -
trunk/ippToPsps/jython/diffbatch.py
r38960 r38999 564 564 ''' 565 565 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 566 638 Accepts a regular expression to match the tables so not all tables need to be imported 567 639 (This regex feature is not currently used...) 568 640 ''' 569 def importIppTables (self, columns="*", tableRE=""):641 def importIppTablesStilts(self, columns="*", tableRE=""): 570 642 571 643 if self.config.retry: return True … … 632 704 return True 633 705 634 635 636 637 638 639 706 ''' 640 707 Overriding this method. Use regex to trim off, eg _XY33 extension -
trunk/ippToPsps/jython/forcedwarpbatch.py
r38990 r38999 747 747 748 748 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 751 817 752 818 ''' 753 819 This function reads the cmf/smf file and loads it into the database as its own table 754 820 ''' 755 def importIppTables (self, columns="*", tableRE=""):821 def importIppTablesStilts(self, columns="*", tableRE=""): 756 822 757 823 self.tablesLoaded = [] … … 760 826 for num in self.number: 761 827 forcedWarpID = self.number[num] 762 if self.config.retry: return True 828 fileName = self.fits[num].getPath() 829 763 830 self.logger.infoPair("loading for add id", forcedWarpID) 764 831 self.logger.infoPair("Importing FW tables with table match expression: ", tableRE) 765 fileName = self.fits[num].getPath()766 832 767 833 self.logger.infoPair("using filename:",fileName) -
trunk/ippToPsps/jython/stackbatch.py
r38995 r38999 1423 1423 1424 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') 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) 1428 1433 1429 1434 # get the list of tables in this file:
Note:
See TracChangeset
for help on using the changeset viewer.
