Changeset 36706 for trunk/ippToPsps/jython/detectionbatch.py
- Timestamp:
- Apr 30, 2014, 11:43:09 AM (12 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/detectionbatch.py (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/detectionbatch.py
r35994 r36706 257 257 ,psfWidMinor \ 258 258 ,psfTheta \ 259 ,momentFwhm \ 260 ,momentWidMajor \ 261 ,momentWidMinor \ 259 ,momentXX \ 260 ,momentXY \ 261 ,momentYY \ 262 ,momentM3C \ 263 ,momentM3S \ 264 ,momentM4C \ 265 ,momentM4S \ 266 ,momentR1 \ 267 ,momentRH \ 262 268 ,apResid \ 263 269 ,dapResid \ … … 319 325 ," + self.safeDictionaryAccess(header, 'FWHM_MIN') + " \ 320 326 ," + self.safeDictionaryAccess(header, 'ANGLE') + " \ 321 , ( " + self.safeDictionaryAccess(header, 'IQ_FW1') + " + " + self.safeDictionaryAccess(header, 'IQ_FW2') + " ) / 2.0 \ 322 ," + self.safeDictionaryAccess(header, 'IQ_FW1') + " \ 323 ," + self.safeDictionaryAccess(header, 'IQ_FW2') + " \ 327 ,-999 \ 328 ,-999 \ 329 ,-999 \ 330 ,-999 \ 331 ,-999 \ 332 ,-999 \ 333 ,-999 \ 334 ,-999 \ 335 ,-999 \ 324 336 ," + self.safeDictionaryAccess(header, 'APMIFIT') + " \ 325 337 ," + self.safeDictionaryAccess(header, 'DAPMIFIT') + " \ … … 407 419 ,psfFlux \ 408 420 ,psfFluxErr \ 409 ,peakADU \ 410 ,psfWidMajor \ 411 ,psfWidMinor \ 421 ,psfMajorFWHM \ 422 ,psfMinorFWHM \ 412 423 ,psfTheta \ 424 ,psfCore \ 413 425 ,psfLikelihood \ 414 426 ,psfQf \ … … 416 428 ,momentXY \ 417 429 ,momentYY \ 430 ,momentR1 \ 431 ,momentRH \ 432 ,momentM3C \ 433 ,momentM3S \ 434 ,momentM4C \ 435 ,momentM4S \ 418 436 ,apFlux \ 419 437 ,kronFlux \ … … 424 442 ,sky \ 425 443 ,skyErr \ 426 ,sgSep \427 ,activeFlag \428 ,assocDate \429 ,historyModNum \430 444 ,dataRelease \ 431 445 ) \ … … 441 455 ,PSF_INST_FLUX / " + self.header['EXPTIME'] + " \ 442 456 ,PSF_INST_FLUX_SIG / " + self.header['EXPTIME'] + " \ 443 ,POW(10.0, (-0.4*PEAK_FLUX_AS_MAG)) / " + self.header['EXPTIME'] + " \444 457 ,PSF_MAJOR \ 445 458 ,PSF_MINOR \ 446 459 ,PSF_THETA \ 460 ,-999 \ 447 461 ,psfLikelihood(EXT_NSIGMA) \ 448 462 ,PSF_QF \ … … 450 464 ,MOMENTS_XY \ 451 465 ,MOMENTS_YY \ 466 ,-999 \ 467 ,-999 \ 468 ,-999 \ 469 ,-999 \ 470 ,-999 \ 471 ,-999 \ 452 472 ,POW(10.0, -0.4 *AP_MAG) / " + self.header['EXPTIME'] + " \ 453 473 ,KRON_FLUX / " + self.header['EXPTIME'] + " \ … … 458 478 ,SKY / " + self.header['EXPTIME'] + " \ 459 479 ,SKY_SIGMA / " + self.header['EXPTIME'] + " \ 460 ,EXT_NSIGMA \461 , 0 \462 , '" + self.dateStr + "' \463 , 0 \464 480 , " + str(self.skychunk.dataRelease) + "\ 465 481 FROM " + ippTableName … … 496 512 # we don't delete these anymore 497 513 results['NULLINSTFLUX'] = 0; 498 results['NULLPEAKADU'] = 0;514 499 515 500 516 ''' … … 531 547 def populateDetectionCalibTableUpdateInsert(self, ota): 532 548 533 tableName = "Detection Calib_" + ota549 tableName = "Detection_" + ota 534 550 # drop then re-create table 535 self.scratchDb.dropTable(tableName)536 sql = "CREATE TABLE " + tableName + " LIKE DetectionCalib"537 try: self.scratchDb.execute(sql)538 except: pass551 #self.scratchDb.dropTable(tableName) 552 #sql = "CREATE TABLE " + tableName + " LIKE DetectionCalib" 553 #try: self.scratchDb.execute(sql) 554 #except: pass 539 555 540 556 # insert all detections into table … … 555 571 ,surveyID \ 556 572 FROM Detection_" + ota 557 self.scratchDb.execute(sql)573 # self.scratchDb.execute(sql) 558 574 559 575 # insert calibration information from dvoDetections into the Table … … 564 580 a.decErr = b.decErr, \ 565 581 a.zp = b.zp, \ 566 a.zpErr = b.zpErr, \567 582 a.expTime = b.expTime, \ 568 583 a.airMass = b.airMass \ … … 577 592 578 593 # target table name: 579 tableName = "Detection Calib_" + ota594 tableName = "Detection_" + ota 580 595 # drop then re-create table 581 self.scratchDb.dropTable(tableName)582 sql = "CREATE TABLE " + tableName + " LIKE DetectionCalib"583 try: self.scratchDb.execute(sql)584 except: pass596 #self.scratchDb.dropTable(tableName) 597 #sql = "CREATE TABLE " + tableName + " LIKE Detection" 598 #try: self.scratchDb.execute(sql) 599 #except: pass 585 600 586 601 externID = self.imageIDs[ota] 587 602 588 603 imageID = self.scratchDb.getImageIDFromExternID(externID) 589 self.logger.infoPair("obtained","imageID") 590 591 # check for & create output directory first 592 datadumpDir = "/tmp/datadump" 593 try: 594 statinfo = os.stat(datadumpDir) 595 # check on the stat results? 596 except: 597 print "making the data dump directory ", datadumpDir 598 os.mkdir(datadumpDir) 599 os.chmod(datadumpDir, 0777) 600 statinfo = os.stat(datadumpDir) 601 602 dumpFile = datadumpDir + "/genetest.xx.dat" 603 files = glob.glob(dumpFile) 604 if len(files) > 0: 605 os.unlink(dumpFile) 604 self.logger.infoPair("obtained imageID",imageID) 605 self.logger.infoPair("obtained externID",externID) 606 606 607 607 # insert all detections into table 608 sql = "SELECT \ 609 a.objID, \ 610 a.detectID, \ 611 a.ippObjID, \ 612 a.ippDetectID, \ 613 a.filterID, \ 614 a.surveyID, \ 615 b.ra, \ 616 b.dec_, \ 617 b.raErr, \ 618 b.decErr, \ 619 b.zp, \ 620 b.zpErr, \ 621 b.expTime, \ 622 b.airMass, \ 623 " + str(self.skychunk.dataRelease) + " \ 624 FROM \ 625 Detection_" + ota + " as a \ 626 JOIN " + self.scratchDb.dvoDetectionTable + " as b \ 627 ON (a.objID = b.objID AND a.detectID = b.detectID) \ 628 WHERE b.imageID = " + str(imageID) + \ 629 " INTO OUTFILE '" + dumpFile + "'" 608 sql = "Update Detection_" + ota + " AS a, "+ self.scratchDb.dvoDetectionTable + " as b \ 609 set a.ra=b.ra, \ 610 a.dec = b.dec_, \ 611 a.raErr = b.raErr, \ 612 a.decErr = b.decErr, \ 613 a.zp = b.zp, \ 614 a.expTime = b.expTime, \ 615 a.airMass = b.airMass \ 616 WHERE (a.objID = b.objID AND a.detectID = b.detectID) \ 617 AND b.imageID = " + str(imageID) \ 618 630 619 631 620 try: self.scratchDb.execute(sql) 632 621 except: 633 self.logger.info("failed to select data for detectionCalib") 634 self.logger.infoPair("sql: ", sql) 635 raise 636 637 sql = "LOAD DATA INFILE '" + dumpFile + "' INTO TABLE " + tableName 638 try: self.scratchDb.execute(sql) 639 except: 640 self.logger.info("failed to load data from infile for detectionCalib") 622 self.logger.info("failed to update data for detectionCalib") 641 623 self.logger.infoPair("sql: ", sql) 642 624 raise … … 751 733 # dec is reserved in MySQL, so STILTS replaces if with dec_, which is not the name of 752 734 # the column in PSPS 753 self.scratchDb.execute("ALTER TABLE Detection CalibCHANGE dec_ `dec` double")735 self.scratchDb.execute("ALTER TABLE Detection CHANGE dec_ `dec` double") 754 736 755 737 return True … … 818 800 return False 819 801 820 self.logger.info("populate stuff ");802 #self.logger.info("populate stuff "); 821 803 # populate remainder of tables 822 804 self.populateDetectionTable(chipname, results) 823 self.logger.info("successful populate ");805 #self.logger.info("successful populate "); 824 806 # now add DVO IDs 825 807 self.updateDvoIDs("Detection_" + chipname, self.imageIDs[chipname]) 826 self.logger.info("updated dvoids")808 #self.logger.info("updated dvoids") 827 809 results['NULLOBJID'] = self.scratchDb.reportAndDeleteRowsWithNULLS("Detection_" + chipname, "objID") 828 810 #self.logger.info("deleted nulls") 829 811 self.updateImageID("Detection_" + chipname, x, y) 830 self.logger.info("updateImageId")812 #self.logger.info("updateImageId") 831 813 rowCount = self.scratchDb.getRowCount("Detection_" + chipname) 832 self.logger.info("got row count")833 self.logger.info("| %5s | %13d | %13d | %13d | %13d | %13d | %13d |",814 #self.logger.info("got row count") 815 self.logger.info("| %5s | %13d | %13d | %13d | %13d | %13d |", 834 816 chipname, 835 817 results['ORIGINALTOTAL'], 836 818 results['SATDET'], 837 819 results['NULLINSTFLUX'], 838 results['NULLPEAKADU'],839 820 results['NULLOBJID'], 840 821 rowCount) … … 842 823 self.totalSatDet = self.totalSatDet + results['SATDET'] 843 824 self.totalNulIInstFlux = self.totalNulIInstFlux + results['NULLINSTFLUX'] 844 self.totalNullPeakFlux = self.totalNullPeakFlux + results['NULLPEAKADU']845 825 self.totalNullObjID = self.totalNullObjID + results['NULLOBJID'] 846 826 self.totalDetections = self.totalDetections + rowCount … … 867 847 self.scratchDb.execute(sql) 868 848 869 self.logger.info("updated imagedata") 870 self.populateSkinnyObjectTable(chipname) 871 self.logger.info("updated skinnyobject") 872 #self.populateObjectCalColorTable(chipname) 873 #self.logger.info("updated objectcalcolor") 849 #self.logger.info("updated imagedata") 850 874 851 self.populateDetectionCalibTable(chipname) 875 self.logger.info("updated detectioncalibtable")852 #self.logger.info("updated detectioncalibtable") 876 853 877 854 # add these to list of tables to export later … … 882 859 self.logger.info("export Detection") 883 860 884 self.tablesToExport.append("SkinnyObject_" + chipname) 885 self.logger.info("export Skinny") 886 887 #self.tablesToExport.append("ObjectCalColor_" + chipname) 888 self.tablesToExport.append("DetectionCalib_" + chipname) 889 self.logger.info("export DetectionCalib") 890 861 891 862 tables.append("Detection_" + chipname) 892 863 self.logger.info("updated detectioncalibtable") … … 910 881 results = {} 911 882 self.totalOriginal = self.totalSatDet = self.totalNulIInstFlux = self.totalNullPeakFlux = self.totalNullObjID = self.totalDetections = 0 912 self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+ ---------------+")913 self.logger.info("| OTA | Initial total | Sat Det | NULL instFlux | NULL peak ADU | NULLobj ID | Remainder |")914 self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+ ---------------+")883 self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+") 884 self.logger.info("| OTA | Initial total | Sat Det | NULL instFlux | NULL obj ID | Remainder |") 885 self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+") 915 886 for x in range(self.startX, self.endX): 916 887 for y in range(self.startY, self.endY): … … 937 908 938 909 # print totals 939 self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+ ---------------+")910 self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+") 940 911 self.logger.info("| Total | %13d | %13d | %13d | %13d | %13d | %13d |", 941 912 self.totalOriginal, … … 945 916 self.totalNullObjID, 946 917 self.totalDetections) 947 self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+ ---------------+")918 self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+") 948 919 949 920 # if we only have one table export, i.e. FrameMeta, then get out of here (skip batch, but do not abort)
Note:
See TracChangeset
for help on using the changeset viewer.
