IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35060


Ignore:
Timestamp:
Jan 26, 2013, 5:47:08 AM (13 years ago)
Author:
eugene
Message:

replace detection calib insert/update with select into / load

Location:
branches/eam_branches/ipp-20121219/ippToPsps/jython
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/detectionbatch.py

    r35044 r35060  
    33import os.path
    44import sys
     5import glob
    56import time
    67import stilts
     8
    79from java.lang import *
    810from java.sql import *
     
    529531    Populates the DetectionCalib table for this OTA
    530532    '''
    531     def populateDetectionCalibTable(self, ota):
     533    def populateDetectionCalibTableUpdateInsert(self, ota):
    532534
    533535        tableName = "DetectionCalib_" + ota
     
    570572        self.scratchDb.execute(sql)
    571573        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
     574       
     575    '''
     576    Populates the DetectionCalib table for this OTA
     577    '''
     578    def populateDetectionCalibTable(self, ota):
     579
     580        # target table name:
     581        tableName = "DetectionCalib_" + ota
     582        # drop then re-create table
     583        self.scratchDb.dropTable(tableName)
     584        sql = "CREATE TABLE " + tableName + " LIKE DetectionCalib"
     585        try: self.scratchDb.execute(sql)
     586        except: pass
     587
     588        dumpFile = "/tmp/datadump/genetest.xx.dat"
     589        files = glob.glob(dumpFile)
     590        if len(files) > 0:
     591            os.unlink(dumpFile)
     592
     593        # insert all detections into table
     594        sql = "SELECT \
     595          a.objID,    \
     596          a.detectID, \
     597          a.ippObjID,      \
     598          a.ippDetectID,   \
     599          a.filterID,      \
     600          a.surveyID,      \
     601          b.ra,            \
     602          b.dec_,          \
     603          b.raErr,         \
     604          b.decErr,        \
     605          b.zp,            \
     606          b.zpErr,         \
     607          b.expTime,       \
     608          b.airMass,       \
     609          " + str(self.config.dataRelease) + " \
     610         FROM              \
     611           Detection_" + ota + " as a \
     612         JOIN " + self.scratchDb.dvoDetectionTable + " as b \
     613         ON (a.objID = b.objID AND a.detectID = b.detectID) \
     614         INTO OUTFILE '" + dumpFile + "'"
     615        print "sql: ", sql
     616        self.scratchDb.execute(sql)
     617
     618        sql = "LOAD DATA INFILE '" + dumpFile + "' INTO TABLE " + tableName
     619        print "sql: ", sql
     620        self.scratchDb.execute(sql)
    572621       
    573622    '''
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/stackbatch.py

    r35057 r35060  
    787787          b.expTime,       \
    788788          b.airMass,       \
    789           a.dataRelease    \
     789          " + str(self.config.dataRelease) + " \
    790790         FROM              \
    791791           StackDetection as a \
     
    799799        print "sql: ", sql
    800800        self.scratchDb.execute(sql)
    801         self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
     801
     802        ## XXX write this with the select/insert
     803        # self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
    802804
    803805    '''
Note: See TracChangeset for help on using the changeset viewer.