Changeset 34615 for trunk/ippToPsps/jython/detectionbatch.py
- Timestamp:
- Oct 26, 2012, 5:15:52 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/detectionbatch.py (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/detectionbatch.py
r33830 r34615 388 388 # delete all detections with PSF_INST_MAG < 17.5, as decreed by Gene 389 389 BEFORE = self.scratchDb.getRowCount(ippTableName) 390 sql = "DELETE FROM " + ippTableName + " WHERE PSF_INST_MAG < -17.5" 391 self.scratchDb.execute(sql) 390 #don't do this anymore 391 #sql = "DELETE FROM " + ippTableName + " WHERE PSF_INST_MAG < -17.5" 392 #self.scratchDb.execute(sql) 392 393 #DELETED = BEFORE - self.scratchDb.getRowCount(ippTableName) 393 results['SATDET'] = BEFORE - self.scratchDb.getRowCount(ippTableName) 394 #results['SATDET'] = BEFORE - self.scratchDb.getRowCount(ippTableName) 395 #we aren't deletng these now 396 results['SATDET'] = 0 394 397 #self.logger.infoPair("Saturated detections", "%d deleted" % DELETED) 395 398 … … 404 407 ,xPosErr \ 405 408 ,yPosErr \ 406 , instFlux \407 , instFluxErr \409 ,psfFlux \ 410 ,psfFluxErr \ 408 411 ,peakADU \ 409 412 ,psfWidMajor \ … … 411 414 ,psfTheta \ 412 415 ,psfLikelihood \ 413 ,psf Cf \416 ,psfQf \ 414 417 ,momentXX \ 415 418 ,momentXY \ 416 419 ,momentYY \ 417 ,ap Mag\420 ,apFlux \ 418 421 ,kronFlux \ 419 422 ,kronFluxErr \ 423 ,psfQfPerfect \ 424 ,psfChiSq \ 420 425 ,infoFlag \ 421 426 ,sky \ … … 450 455 ,KRON_FLUX / " + self.header['EXPTIME'] + " \ 451 456 ,KRON_FLUX_ERR / " + self.header['EXPTIME'] + " \ 452 ,FLAGS\ 457 ,PSF_QF_PERFECT \ 458 ,PSF_CHISQ \ 459 ,FLAGS2 << 32 | FLAGS\ 453 460 ,SKY \ 454 461 ,SKY_SIGMA \ … … 459 466 , " + str(self.config.dataRelease) + "\ 460 467 FROM " + ippTableName 468 # SA10 todo 469 # need to correct formulas for psfFlux/psfFluxErr 470 # need to correct apMag apFlux 471 # need to correct unites kronFlux/Err to correct units 472 # need to change psfqfperfect -> psfqfperfect PSF_QF_PERFECT? 473 # need to change psfchisq PSF_CHI_SQ? 474 # need to change unites of sky/skyErr to adu/s/pixel 475 # need formula for sgsep/psflikelhood 476 # self.logger.info(sql) 461 477 self.scratchDb.execute(sql) 462 478 463 479 # now delete bad flux and bad chip positions 464 sql="DELETE FROM " + pspsTableName + " WHERE instFlux < 0.0000001" # TODO clearly a hack = 0 not allowed for instFlux 465 self.scratchDb.execute(sql) 466 480 #sql="DELETE FROM " + pspsTableName + " WHERE instFlux < 0.0000001" # TODO clearly a hack = 0 not allowed for instFlux 481 #self.scratchDb.execute(sql) 482 483 # add a instFlux = 0.0 -> 0.000001 484 sql="UPDATE " + pspsTableName + " SET psfFlux = 0.0000001 WHERE psfFlux = 0" 485 self.scratchDb.execute(sql) 486 467 487 # update cosmic ray and extended likelihoods 468 sql="UPDATE " + pspsTableName + " SET extendedLikelihood = 0, crLikelihood = 1.0 - psfLikelihood WHERE sgSep <= 0"469 self.scratchDb.execute(sql)470 sql="UPDATE " + pspsTableName + " SET crLikelihood = 0, extendedLikelihood = 1.0 - psfLikelihood WHERE sgSep > 0"471 self.scratchDb.execute(sql)488 #sql="UPDATE " + pspsTableName + " SET extendedLikelihood = 0, crLikelihood = 1.0 - psfLikelihood WHERE sgSep <= 0" 489 #self.scratchDb.execute(sql) 490 #sql="UPDATE " + pspsTableName + " SET crLikelihood = 0, extendedLikelihood = 1.0 - psfLikelihood WHERE sgSep > 0" 491 #self.scratchDb.execute(sql) 472 492 473 493 # remove detections will NULL inst flux or NULL peak ADU 474 results['NULLINSTFLUX'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "instFlux") 475 results['NULLPEAKADU'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "peakADU") 494 # leave them in at this stage- don't delete them. 495 #results['NULLINSTFLUX'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "instFlux") 496 #results['NULLPEAKADU'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "peakADU") 497 #we don't delete thos anymore 498 results['NULLINSTFLUX'] = 0; 499 results['NULLPEAKADU'] = 0; 476 500 477 501 ''' … … 504 528 505 529 ''' 530 Populates the DetectionCalib table for this OTA 531 ''' 532 def populateDetectionCalibTable(self, ota): 533 534 tableName = "DetectionCalib_" + ota 535 # drop then re-create table 536 self.scratchDb.dropTable(tableName) 537 sql = "CREATE TABLE " + tableName + " LIKE DetectionCalib" 538 try: self.scratchDb.execute(sql) 539 except: pass 540 541 # insert all detections into table 542 sql = "INSERT INTO " + tableName + " ( \ 543 objID \ 544 ,detectID \ 545 ,ippObjID \ 546 ,ippDetectID \ 547 ,filterID \ 548 ,surveyID \ 549 ) \ 550 SELECT \ 551 objID \ 552 ,detectID \ 553 ,ippObjID \ 554 ,ippDetectID \ 555 ,filterID \ 556 ,surveyID \ 557 FROM Detection_" + ota 558 self.scratchDb.execute(sql) 559 #SA10 TODO 560 # insert ra/dec/calstuff into Table 561 # heather discovered dec is called 'dec_' 562 sql = "UPDATE " + tableName + " SET ra = -999, dec_ =-999, raErr = -999, decErr = -999, zp = -999, zpErr = -999, expTime = -999, airMass = -999" 563 self.scratchDb.execute(sql) 564 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease)) 565 566 ''' 506 567 Populates the Detection table for this OTA 507 568 ''' … … 608 669 extension = "XY%d%d_psf" % (x, y) 609 670 self.scratchDb.createIndex(extension, "IPP_IDET") 610 671 self.logger.infoPair("created indexes on", "IPP tables") 611 672 ''' 612 673 Updates provided table with DVO IDs from DVO table … … 620 681 a.detectID = b.detectID, \ 621 682 a.objID = b.objID, \ 622 a.infoFlag = b.flags << 32| a.infoFlag \683 a.infoFlag = b.flags << 46 | a.infoFlag \ 623 684 WHERE a.ippDetectID = b.ippDetectID \ 624 685 AND b.imageID = " + str(imageID) … … 658 719 self.logger.info("| %5s | ------------- Bad astrometric solution : rejecting ------------ |" % ota) 659 720 continue 660 721 # self.logger.info("populate stuff "); 661 722 # populate remainder of tables 662 723 self.populateDetectionTable(ota, results) 663 724 # self.logger.info("successful populate "); 664 725 # now add DVO IDs 665 726 self.updateDvoIDs("Detection_" + ota, self.imageIDs[ota]) 727 # self.logger.info("updated dvoids") 666 728 results['NULLOBJID'] = self.scratchDb.reportAndDeleteRowsWithNULLS("Detection_" + ota, "objID") 667 self.updateImageID("Detection_" + ota, x, y) 729 #self.logger.info("deleted nulls") 730 self.updateImageID("Detection_" + ota, x, y) 731 # self.logger.info("updateImageId") 668 732 rowCount = self.scratchDb.getRowCount("Detection_" + ota) 733 # self.logger.info("got row count") 669 734 self.logger.info("| %5s | %13d | %13d | %13d | %13d | %13d | %13d |", 670 735 ota, … … 675 740 results['NULLOBJID'], 676 741 rowCount) 677 678 742 totalOriginal = totalOriginal + results['ORIGINALTOTAL'] 679 743 totalSatDet = totalSatDet + results['SATDET'] … … 682 746 totalNullObjID = totalNullObjID + results['NULLOBJID'] 683 747 totalDetections = totalDetections + rowCount 684 748 #self.logger.info("updated totals") 685 749 # check we have something in this Detection table TODO add this to table above 686 750 if rowCount < 1: … … 692 756 SET nDetect = %d, photoCalID = %d" % (self.scratchDb.getRowCount("Detection_" + ota), self.scratchDb.getPhotoCalID(self.imageIDs[ota])) 693 757 self.scratchDb.execute(sql) 694 758 759 #self.logger.info("updated imagedata") 695 760 self.populateSkinnyObjectTable(ota) 761 #self.logger.info("updated skinnyobject") 696 762 self.populateObjectCalColorTable(ota) 697 763 #self.logger.info("updated objectcalcolor") 764 self.populateDetectionCalibTable(ota) 765 #self.logger.info("updated detectioncalibtable") 766 698 767 # add these to list of tables to export later 699 768 self.tablesToExport.append("ImageMeta_" + ota) … … 701 770 self.tablesToExport.append("SkinnyObject_" + ota) 702 771 self.tablesToExport.append("ObjectCalColor_" + ota) 772 self.tablesToExport.append("DetectionCalib_" + ota) 703 773 tables.append("Detection_" + ota) 704 774 705 775 otaCount = otaCount + 1 706 776 #self.logger.info("end of ota") 707 777 # print totals 708 778 self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+---------------+") … … 757 827 else : regex = ".*.psf" 758 828 759 columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG PSF_INST_MAG PSF_INST_MAG_SIG PEAK_FLUX_AS_MAG PSF_MAJOR PSF_MINOR PSF_THETA EXT_NSIGMA PSF_QF MOMENTS_XX MOMENTS_XY MOMENTS_YY AP_MAG KRON_FLUX KRON_FLUX_ERR FLAGS SKY SKY_SIGMA EXT_NSIGMA"829 columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG PSF_INST_MAG PSF_INST_MAG_SIG PEAK_FLUX_AS_MAG PSF_MAJOR PSF_MINOR PSF_THETA EXT_NSIGMA PSF_QF MOMENTS_XX MOMENTS_XY MOMENTS_YY AP_MAG KRON_FLUX KRON_FLUX_ERR FLAGS FLAGS2 SKY SKY_SIGMA EXT_NSIGMA PSF_QF_PERFECT PSF_CHISQ" 760 830 761 831 return super(DetectionBatch, self).importIppTables(columns, regex)
Note:
See TracChangeset
for help on using the changeset viewer.
