IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 28, 2014, 6:20:27 AM (12 years ago)
Author:
eugene
Message:

dropping options for stilts dvo import methods; fixing a number of previously ignored errors (eg, dropping non-existent tables); allowing queue questions to strip leading and trailing spaces (so we can read from an input file); echo back the response so input from a file is clearer; re-write big sql blocks with new sql utility code; updating names in MeanObject, ObjectThin to be more consistent; add a new test code program; update detection fields to match new schema; drop the code for the old now-unused tables (detecitonCalib, SkinnyObject, etc)

Location:
branches/eam_branches/ipp-20140717/ippToPsps
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140717/ippToPsps

  • branches/eam_branches/ipp-20140717/ippToPsps/jython/scratchdb.py

    r35417 r37129  
    5151    Sets whether we are using normal or pre-ingested DVO tables
    5252    '''
    53     def setUseFullTables(self, useFull):
    54 
    55         if useFull:
    56             self.dvoImagesTable = "dvoImagesFull"
    57             self.dvoDetectionTable = "dvoDetectionFull"
    58         else:
    59             self.dvoImagesTable = "dvoImages"
    60             self.dvoDetectionTable = "dvoDetection"
     53    def setDvoTableNames(self):
     54
     55        self.dvoImagesTable = "dvoImagesFull"
     56        self.dvoDetectionTable = "dvoDetectionFull"
    6157
    6258        self.logger.debugPair("Using DVO images table", self.dvoImagesTable)
     
    233229    def alreadyImportedThisDvoTable(self, path):
    234230
     231        print "***** alreadyImportedThisDvoTable *****"
     232        print "path: " + path
     233
    235234        fileStat = os.stat(path)
     235        print "path: " + path
    236236
    237237        sql = "SELECT COUNT(*) FROM " + self.dvoDoneTable + " WHERE path = '" + path + "' AND modifiedDate = " + str(fileStat.st_mtime)
    238 
    239         try:
    240             rs = self.executeQuery(sql)
     238        print "sql: " + sql
     239
     240        try:
     241            rs = self.executeQuery(sql)
     242            print "ran sql: " + sql
    241243            rs.first()
    242244            if rs.getInt(1) > 0:
     245                print "***** DID import previously *****"
    243246                self.logger.debugPair("Already imported up-to-date version of",  path)
    244247                return True
    245248            else:
     249                print "***** did NOT import previously *****"
    246250                return False
    247251        except:
     252            print "***** exception in alreadyImportedThisDvoTable *****"
    248253            self.logger.exception("Unable to check whether this DVO table has been imported")
     254
     255        print "***** done with alreadyImportedThisDvoTable *****"
    249256
    250257
     
    322329    '''
    323330    def isCorrectDvo(self, path):
     331
     332        sql = "show tables"
     333        try:
     334            rs = self.executeQuery(sql) 
     335            haveDone = False
     336            while (rs.next()):
     337                tableName = rs.getString(1)
     338                # print "table: " + tableName
     339                if tableName == self.dvoDoneTable:
     340                    haveDone = True
     341                   
     342            rs.close()
     343            if not haveDone:
     344                print "dvoDone not yet build"
     345                return False
     346        except:
     347            print "failed to run query: " + sql
    324348
    325349        sql = "SELECT path FROM " + self.dvoDoneTable + " WHERE path LIKE '%SkyTable.fits'"
     
    415439   
    416440        dvoImagesTable = "dvoImages"
    417         dvoDetectionTable = "dvoDetections"
     441        dvoDetectionTable = "dvoDetection"
    418442
    419443        # drop and create Images table
    420         self.logger.debugPair("Creating DVO table", dvoImagesTable)
     444        self.logger.infoPair("Creating DVO table", dvoImagesTable)
    421445        sql = "DROP TABLE " + dvoImagesTable
    422446
     
    438462
    439463        # now detection table
    440         self.logger.debugPair("Creating DVO table", dvoDetectionTable)
     464        self.logger.infoPair("Dropping DVO table", dvoDetectionTable)
    441465        sql = "DROP TABLE " + dvoDetectionTable
    442466        try: self.execute(sql)
    443         except: pass
    444 
    445         self.logger.debugPair("Creating DVO table", "dvoDetection")
     467        except:
     468            print "problem dropping DVO " + dvoDetectionTable
     469            pass
     470
     471        self.logger.infoPair("Creating DVO table", "dvoDetection")
    446472        sql = "CREATE TABLE dvoDetection ( \
    447                imageID INT, \
    448                ippDetectID BIGINT, \
     473               objID BIGINT, \
    449474               detectID BIGINT, \
    450475               ippObjID BIGINT, \
    451                objID BIGINT, \
    452                flags INT, \
    453                zp FLOAT, \
    454                zpErr FLOAT, \
    455                airMass FLOAT, \
    456                expTime FLOAT, \
     476               ippDetectID BIGINT, \
     477               imageID INT, \
    457478               ra DOUBLE, \
    458479               dec_ DOUBLE, \
    459480               raErr FLOAT, \
    460481               decErr FLOAT, \
     482               zp FLOAT, \
     483               telluricExt FLOAT, \
     484               airmass FLOAT, \
     485               expTime FLOAT, \
     486               flags INT, \
    461487               PRIMARY KEY (imageID, ippDetectID), \
    462488               KEY (objID, detectID) \
     
    466492        except:
    467493            self.logger.error("Unable to create DVO detection database table")
     494            self.sys.exit(1)
    468495
    469496        # XXX EAM : for the parallel mode, dvoDetection requires duplicate objID values!
     
    550577       self.logger.infoPair("Dropping table", self.dvoSkyTable)
    551578       self.dropTable(self.dvoSkyTable)
    552        self.logger.infoPair("Dropping table", self.dvoDetectionTable)
    553        self.dropTable(self.dvoDetectionTable)
    554579       self.logger.infoPair("Dropping table", self.dvoDoneTable)
    555580       self.dropTable(self.dvoDoneTable)
     581
     582       # blow away existing dvoDetection table & re-crate
     583       if not self.resetDvoDetectionTable():
     584           self.logger.errorPair("Unable to reset scratch table", "DvoDetectionFull")
     585           return False
    556586
    557587       # create dvoDone table
     
    564594
    565595       self.changeEngineToInnoDB(self.dvoDoneTable)
    566 
    567        # blow away existing dvoDetection table & re-crate
    568        if not self.resetDvoDetectionTable():
    569            self.logger.errorPair("Unable to reset scratch table", "DvoDetectionFull")
    570            return False
    571596
    572597       return True
Note: See TracChangeset for help on using the changeset viewer.