IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33769


Ignore:
Timestamp:
Apr 12, 2012, 11:11:29 AM (14 years ago)
Author:
rhenders
Message:

new, safer, method to get ordered list of filters from DVO Photcodes table; change to JOIN when pulling filter mags from cps table; applying UNIQUE key on Object table after mags and colors populated; reporting number of duplicates found to the log

File:
1 edited

Legend:

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

    r33763 r33769  
    7878    def alterPspsTables(self):
    7979
    80         # index objID column
    81         self.scratchDb.makeColumnUnique("Object", "objID")
    82 
    8380        # dec is reserved in MySQL, so STILTS replaces if with dec_, which PSPS doesn't like. so, force it back again using ``
    8481        self.scratchDb.execute("ALTER TABLE Object CHANGE dec_ `dec` double")
     
    10097    def insertMags(self, cpsTable):
    10198
    102         # list of all filters we are interested in
    103         allFilters = ['g', 'r', 'i', 'z', 'y', ]
     99        # list of all filters PSPS is interested in
     100        interestedFilters = ['g', 'r', 'i', 'z', 'y']
    104101       
    105         # this loop looks into the DVO Photcodes tables and gets the 'CODE' for each the filters above that are listed
    106         filters = []
    107         for filter in allFilters:
    108             code = self.scratchDb.getCodeForThisFilter(filter)
    109             if code < 0: continue
    110             filters.append([code, filter])
     102        filters = self.scratchDb.getOrderedListOfFiltersFromPhotcodesTable(interestedFilters)
    111103   
    112104        # get a count of the available filters
     
    119111
    120112            sql = "UPDATE Object \
    121                    JOIN " + cpsTable + " AS cps ON (cps.row = (Object.row*" + str(filterCount) + ")-" + str(filter[0]) + ") \
     113                   JOIN " + cpsTable + " AS cps ON (cps.row = (Object.row*" + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \
    122114                   SET \
    123115                   n" + filter[1] + " = NCODE \
     
    128120                   ," + filter[1] + "Max = MAG_80 \
    129121                   "
    130 
     122           
    131123            self.scratchDb.execute(sql)
    132124
     
    251243        #if not self.populateObjectCalColorTable(): return False
    252244
    253         return True
    254 
     245        # now remove the objID duplicates. We could not do this before as cpt/cps tables relate by row number
     246        self.logger.infoPair("Forcing uniqueness on", "objID in Object table")
     247        rowCountBefore = self.scratchDb.getRowCount("Object")
     248        self.scratchDb.execute("ALTER IGNORE TABLE Object ADD UNIQUE INDEX(objID)")
     249        rowCountAfter = self.scratchDb.getRowCount("Object")
     250        self.logger.infoPair("Number of duplicated objIDs removed", "%d" % (rowCountBefore - rowCountAfter))
     251
     252        return True
     253
Note: See TracChangeset for help on using the changeset viewer.