IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35124


Ignore:
Timestamp:
Feb 7, 2013, 2:12:41 PM (13 years ago)
Author:
eugene
Message:

explicitly track the valid chips; add (unused) function to remove duplicate objIDs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/detectionbatch.py

    r35097 r35124  
    389389        except: pass
    390390       
    391         # delete all detections with PSF_INST_MAG < -17.5, as decreed by Gene
     391        # XXX we no longer delete detections with funny mags (eg PSF_INST_MAG < -17.5)
     392        # for examples of code which do this, go to r35097 or earlier
     393
    392394        BEFORE = self.scratchDb.getRowCount(ippTableName)
    393         #don't do this anymore
    394         #sql = "DELETE FROM " + ippTableName + " WHERE PSF_INST_MAG < -17.5"
    395         #self.scratchDb.execute(sql)
    396         #DELETED = BEFORE - self.scratchDb.getRowCount(ippTableName)
    397         #results['SATDET'] = BEFORE - self.scratchDb.getRowCount(ippTableName)
    398         #we aren't deletng these now
    399395        results['SATDET'] = 0
    400         #self.logger.infoPair("Saturated detections", "%d deleted" % DELETED)
    401396
    402397        # insert all detections into table
     
    473468        self.scratchDb.execute(sql)
    474469
    475         # now delete bad flux and bad chip positions
    476         #sql="DELETE FROM " + pspsTableName + " WHERE instFlux < 0.0000001" # TODO clearly a hack = 0 not allowed for instFlux
    477         #self.scratchDb.execute(sql)
    478 
    479470        # add a instFlux = 0.0 -> 0.000001
     471        # XXX EAM : why is this done?
    480472        sql="UPDATE " + pspsTableName + " SET psfFlux = 0.0000001 WHERE psfFlux =  0"
    481473        self.scratchDb.execute(sql)
    482474     
    483         # update cosmic ray and extended likelihoods
    484         #sql="UPDATE " + pspsTableName + " SET extendedLikelihood = 0, crLikelihood = 1.0 - psfLikelihood WHERE sgSep <= 0"
    485         #self.scratchDb.execute(sql)
    486         #sql="UPDATE " + pspsTableName + " SET crLikelihood = 0, extendedLikelihood = 1.0 - psfLikelihood WHERE sgSep > 0"
    487         #self.scratchDb.execute(sql)
    488 
    489         # remove detections will NULL inst flux or NULL peak ADU
    490         # leave them in at this stage- don't delete them.
    491         #results['NULLINSTFLUX'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "instFlux")
    492         #results['NULLPEAKADU'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "peakADU")
    493         #we don't delete thos anymore
     475        # we don't delete these anymore
    494476        results['NULLINSTFLUX'] = 0;
    495477        results['NULLPEAKADU'] = 0;
     
    857839        self.logger.info("updated detectioncalibtable")
    858840
     841        self.validChips.append(chipname)
     842
    859843        return True
    860844
     
    865849
    866850        # loop through all OTAs again to update with DVO IDs
     851        self.validChips = []   
    867852        self.tablesToExport = []   
    868853        self.tablesToExport.append("FrameMeta")
     
    907892            return False
    908893
     894        # XXX EAM : turn this on (and fix up the code) if we need it
     895        # self.removeDuplicateObjects()
     896
    909897        self.setMinMaxObjID(tables)
    910898
     
    914902       
    915903        return True
     904
     905    def removeDuplicateObjects(self):
     906
     907        sql = "DROP TABLE SkinnyObject_All"
     908        try:
     909            self.scratchDb.execute(sql)
     910        except:
     911            print "SkinnyObject_All table not yet defined"
     912
     913        sql = "CREATE TABLE SkinnyObject_All (objID bigint, ippObjID bigint, chipID char(16))"
     914        try:
     915            self.scratchDb.execute(sql)
     916        except:
     917            print "failed to create table SkinnyObject_All"
     918            raise
     919
     920        for chipname in self.validChips:
     921           
     922            sql = "INSERT INTO SkinnyObject_All (objID, ippObjID, chipID) \
     923                   SELECT objID, ippObjID, '" + chipname + "' from SkinnyObject_" + chipname
     924            try:
     925                self.scratchDb.execute(sql)
     926            except:
     927                print "failed to insert entry SkinnyObject_All: ", chipname
     928                raise
     929           
     930
     931        Nduplicates = 0
     932        sql = "SELECT n, objID from (select count(objID) as n, objID from SkinnyObject_All group by objID) as tmp where n > 1"
     933        try:
     934            rs = self.scratchDb.executeQuery(sql)
     935            while (rs.next()):
     936                objID = rs.getInt(1)
     937                chipID = rs.getString(3)
     938                print "delete: ", str(objID), chipID
     939                Nduplicates += 1
     940
     941            rs.close()
     942        except:
     943            print "failed to get duplicates"
     944            raise
     945
     946        print "duplicates found: ", str(Nduplicates)
    916947
    917948    '''
     
    935966
    936967    '''
     968    This function reads the cmf/smf file and loads it into the database as its own table
    937969    Overriding this method. Filter to only import *.psf extensions
    938970    '''
Note: See TracChangeset for help on using the changeset viewer.