Changeset 35097 for trunk/ippToPsps/jython/stackbatch.py
- Timestamp:
- Feb 6, 2013, 3:16:35 PM (13 years ago)
- Location:
- trunk/ippToPsps
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps
- Property svn:mergeinfo changed
-
trunk/ippToPsps/jython
- Property svn:ignore
-
old new 1 1 *.class 2 Makefile 3 Makefile.in
-
- Property svn:ignore
-
trunk/ippToPsps/jython/stackbatch.py
r34879 r35097 2 2 3 3 import os.path 4 import glob 4 5 import sys 5 6 … … 32 33 logger, 33 34 config, 35 skychunk, 34 36 gpc1Db, 35 37 ippToPspsDb, … … 42 44 logger, 43 45 config, 46 skychunk, 44 47 gpc1Db, 45 48 ippToPspsDb, … … 48 51 batchID, 49 52 "ST", 50 gpc1Db.getStackStageCmf( config.dvoLabel, stackID),53 gpc1Db.getStackStageCmf(skychunk.dvoLabel, stackID), 51 54 useFullTables) 55 56 # self.printline = 0 57 # # self.testprint() 52 58 53 59 self.stackType = "DEEP_STACK" # TODO … … 63 69 self.filterID = self.scratchDb.getFilterID(self.filter) 64 70 self.skycell = meta[1]; 71 72 # self.testprint() 65 73 66 74 # skycell is, eg "skycell.1133.081" … … 76 84 self.skycell = self.skycell[8:12] 77 85 self.projectioncell = self.skycell 86 87 # self.testprint() 78 88 79 89 # proposed new values. Need to coordinate with the SkyCell table … … 96 106 self.scratchDb.dropTable("StackDetectionCalib") 97 107 108 # self.testprint() 109 98 110 # delete IPP tables 99 111 self.scratchDb.dropTable("SkyChip_psf") … … 115 127 if not self.useFullTables: 116 128 self.scratchDb.insertNewDvoExternID(self.header['SOURCEID'], self.header['IMAGEID']) 129 130 # self.testprint() 117 131 118 132 # dump stuff to log … … 139 153 self.scratchDb.execute(sql) 140 154 155 156 def testprint(self): 157 print "here ", self.printline 158 self.printline += 1 141 159 142 160 ''' … … 348 366 self.logger.infoPair("Procesing table", "StackMeta") 349 367 368 self.fwhm_maj = self.safeDictionaryAccess(self.header, 'FWHM_MAJ') 369 self.fwhm_maj_uq = self.safeDictionaryAccess(self.header, 'FW_MJ_UQ') 370 self.psfmodel = self.safeDictionaryAccess(self.header, 'PSFMODEL') 371 if (self.fwhm_maj == "NULL"): self.fwhm_maj = -999 372 if (self.fwhm_maj_uq == "NULL"): self.fwhm_maj_uq = -999 373 374 # print "fwhm_maj = ", self.fwhm_maj 375 # print "fwhm_maj_uq = ", self.fwhm_maj_uq 376 # print "psfmodel = ", self.psfmodel 377 350 378 sql = "INSERT INTO StackMeta (\ 351 379 stackMetaID \ … … 375 403 ," + self.header['FPA.ZP'] + " \ 376 404 ," + self.expTime + " \ 377 ,'" + self. safeDictionaryAccess(self.header, 'PSFMODEL')+ "' \378 , '" + self.safeDictionaryAccess(self.header, 'FWHM_MAJ') + "'\379 , '" + self.safeDictionaryAccess(self.header, 'FW_MJ_UQ') + "'\405 ,'" + self.psfmodel + "' \ 406 ," + str(self.fwhm_maj) + " \ 407 ," + str(self.fwhm_maj_uq) + " \ 380 408 ,'" + self.header['CTYPE1'] + "' \ 381 409 ,'" + self.header['CTYPE2'] + "' \ … … 395 423 self.scratchDb.updateAllRows("StackMeta", "surveyID", str(self.surveyID)) 396 424 self.scratchDb.updateFilterID("StackMeta", self.filter) 397 self.scratchDb.updateAllRows("StackMeta", "dataRelease", str(self. config.dataRelease))425 self.scratchDb.updateAllRows("StackMeta", "dataRelease", str(self.skychunk.dataRelease)) 398 426 self.updateStackTypeID("StackMeta") 399 427 … … 486 514 ," + self.historyModNum + " \ 487 515 FROM SkyChip_psf" 488 self.scratchDb.execute(sql) 489 516 517 # print "sql: ", sql 518 # response = raw_input("ready to insert stack det ") 519 520 self.scratchDb.execute(sql) 521 490 522 #it is possible to drop some detections from dvo (that are present in the cmf). when that happens we get a 0 for objid 491 523 #we drop those... … … 498 530 self.scratchDb.updateFilterID("StackDetection", self.filter) 499 531 500 self.scratchDb.updateAllRows("StackDetection", "dataRelease", str(self. config.dataRelease))532 self.scratchDb.updateAllRows("StackDetection", "dataRelease", str(self.skychunk.dataRelease)) 501 533 502 534 self.scratchDb.updateAllRows("StackDetection", "primaryF", "0") … … 509 541 510 542 self.updateDvoIDsAndFlags("StackDetection") 543 # response = raw_input("updated dvo ") 511 544 512 545 sql = "ALTER IGNORE TABLE StackDetection ADD PRIMARY KEY (objID)" 513 546 514 547 self.scratchDb.execute(sql) 548 # response = raw_input("add primary key? ") 515 549 516 550 if self.stackType == "DEEP_STACK": … … 524 558 525 559 self.scratchDb.execute(sql) 560 # response = raw_input("add psf flux ") 526 561 527 562 #leave null instflux in … … 529 564 530 565 self.scratchDb.reportAndDeleteRowsWithNULLS("StackDetection", "objID") 566 # response = raw_input("delete nulls ") 531 567 532 568 sql="DELETE FROM StackDetection where objID = 0" 533 569 534 570 self.scratchDb.execute(sql) 535 self.logger.infoPair("Delleting", "entries with StackDetection.objID = 0") 571 self.logger.infoPair("Deleting", "entries with StackDetection.objID = 0") 572 # response = raw_input("deleted objID is 0 ") 536 573 537 574 … … 577 614 self.scratchDb.updateAllRows("StackApFlx", "surveyID", str(self.surveyID)) 578 615 self.scratchDb.updateFilterID("StackApFlx", self.filter) 579 self.scratchDb.updateAllRows("StackApFlx", "dataRelease", str(self. config.dataRelease))616 self.scratchDb.updateAllRows("StackApFlx", "dataRelease", str(self.skychunk.dataRelease)) 580 617 self.scratchDb.updateAllRows("StackApFlx", "primaryF", "0") 581 618 self.scratchDb.updateAllRows("StackApFlx", "activeFlag", "0") … … 611 648 self.scratchDb.updateAllRows("StackModelFit", "surveyID", str(self.surveyID)) 612 649 self.scratchDb.updateFilterID("StackModelFit", self.filter) 613 self.scratchDb.updateAllRows("StackModelFit", "dataRelease", str(self. config.dataRelease))650 self.scratchDb.updateAllRows("StackModelFit", "dataRelease", str(self.skychunk.dataRelease)) 614 651 self.scratchDb.updateAllRows("StackModelFit", "primaryF", "0") 615 652 self.scratchDb.updateAllRows("StackModelFit", "activeFlag", "0") … … 676 713 677 714 self.scratchDb.updateAllRows("SkinnyObject", "surveyID", str(self.surveyID)) 678 self.scratchDb.updateAllRows("SkinnyObject", "dataRelease", str(self. config.dataRelease))715 self.scratchDb.updateAllRows("SkinnyObject", "dataRelease", str(self.skychunk.dataRelease)) 679 716 680 717 ''' 681 718 Populates the StackDetectionCalib table 682 ''' 683 def populateStackDetectionCalib(self): 719 XXX this can probably get a big speed increase by using 'SELECT () INTO OUTFILE '/tmp/name' and then 720 calling the load data infile '/tmp/name' into table; 721 ''' 722 def populateStackDetectionCalibInsertUpdate(self): 684 723 self.logger.infoPair("Processing table", "StackDetectionCalib") 685 724 tableName = "StackDetectionCalib" … … 702 741 FROM StackDetection" 703 742 self.scratchDb.execute(sql) 743 744 imageID = self.scratchDb.getImageIDFromExternID(self.header['IMAGEID']) 745 self.logger.infoPair("obtained","imageID") 746 704 747 # insert calibration information from dvoDetections into the Table 705 748 sql = "UPDATE " + tableName + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b \ … … 712 755 a.expTime = b.expTime, \ 713 756 a.airMass = b.airMass \ 714 WHERE a.stackDetectID = b.detectID" 715 self.scratchDb.execute(sql) 716 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease)) 717 718 719 757 WHERE a.stackDetectID = b.detectID \ 758 AND b.imageID = " + str(imageID) 759 self.scratchDb.execute(sql) 760 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease)) 761 762 def populateStackDetectionCalib(self): 763 764 tableName = "StackDetectionCalib" 765 self.logger.infoPair("Processing table", tableName) 766 767 imageID = self.scratchDb.getImageIDFromExternID(self.header['IMAGEID']) 768 self.logger.infoPair("obtained","imageID") 769 770 # check for & create output directory first 771 datadumpDir = "/tmp/datadump" 772 try: 773 statinfo = os.stat(datadumpDir) 774 # check on the stat results? 775 except: 776 print "making the data dump directory ", datadumpDir 777 os.mkdir(datadumpDir) 778 os.chmod(datadumpDir, 0777) 779 statinfo = os.stat(datadumpDir) 780 781 dumpFile = datadumpDir + "/genetest.xx.dat" 782 files = glob.glob(dumpFile) 783 if len(files) > 0: 784 os.unlink(dumpFile) 785 786 # insert all detections into table 787 sql = "SELECT \ 788 a.objID, \ 789 a.stackDetectID, \ 790 a.ippObjID, \ 791 a.ippDetectID, \ 792 a.filterID, \ 793 a.surveyID, \ 794 b.ra, \ 795 b.dec_, \ 796 b.raErr, \ 797 b.decErr, \ 798 b.zp, \ 799 b.zpErr, \ 800 b.expTime, \ 801 b.airMass, \ 802 " + str(self.skychunk.dataRelease) + " \ 803 FROM \ 804 StackDetection as a \ 805 JOIN " + self.scratchDb.dvoDetectionTable + " as b \ 806 ON (a.stackDetectID = b.detectID) where b.imageID = " + str(imageID) + \ 807 " INTO OUTFILE '" + dumpFile + "'" 808 print "sql: ", sql 809 self.scratchDb.execute(sql) 810 811 sql = "LOAD DATA INFILE '" + dumpFile + "' INTO TABLE " + tableName 812 print "sql: ", sql 813 self.scratchDb.execute(sql) 814 815 ## XXX write this with the select/insert 816 # self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease)) 720 817 721 818 ''' … … 737 834 738 835 self.scratchDb.updateFilterID("ObjectCalColor", self.filter) 739 self.scratchDb.updateAllRows("ObjectCalColor", "dataRelease", str(self. config.dataRelease))836 self.scratchDb.updateAllRows("ObjectCalColor", "dataRelease", str(self.skychunk.dataRelease)) 740 837 741 838 … … 802 899 WHERE a.ippDetectID = b.ippDetectID \ 803 900 AND b.imageID = " + str(imageID) 901 902 # print "update dvo sql: ", sql 903 # response = raw_input("update dvo...") 804 904 self.scratchDb.execute(sql) 805 905
Note:
See TracChangeset
for help on using the changeset viewer.
