IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 6, 2013, 3:16:35 PM (13 years ago)
Author:
eugene
Message:

upgrade to ippToPsps (see doc/upgrade.txt): adds native dvo to mysql ingest operations, adds autogen configuration & installation, splits out global config information from new "skychunk" information (current region on the sky being processed), adds test suites

Location:
trunk/ippToPsps
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps

  • trunk/ippToPsps/jython

    • Property svn:ignore
      •  

        old new  
        11*.class
         2Makefile
         3Makefile.in
  • trunk/ippToPsps/jython/stackbatch.py

    r34879 r35097  
    22
    33import os.path
     4import glob
    45import sys
    56
     
    3233                 logger,
    3334                 config,
     35                 skychunk,
    3436                 gpc1Db,
    3537                 ippToPspsDb,
     
    4244               logger,
    4345               config,
     46               skychunk,
    4447               gpc1Db,
    4548               ippToPspsDb,
     
    4851               batchID,
    4952               "ST",
    50                gpc1Db.getStackStageCmf(config.dvoLabel, stackID),
     53               gpc1Db.getStackStageCmf(skychunk.dvoLabel, stackID),
    5154               useFullTables)
     55
     56       # self.printline = 0
     57       # # self.testprint()
    5258
    5359       self.stackType = "DEEP_STACK" # TODO
     
    6369       self.filterID = self.scratchDb.getFilterID(self.filter)
    6470       self.skycell = meta[1];
     71
     72       # self.testprint()
    6573
    6674       # skycell is, eg "skycell.1133.081"
     
    7684       self.skycell = self.skycell[8:12]
    7785       self.projectioncell = self.skycell
     86
     87       # self.testprint()
    7888
    7989       # proposed new values. Need to coordinate with the SkyCell table
     
    96106       self.scratchDb.dropTable("StackDetectionCalib")
    97107
     108       # self.testprint()
     109
    98110       # delete IPP tables
    99111       self.scratchDb.dropTable("SkyChip_psf")
     
    115127       if not self.useFullTables:
    116128           self.scratchDb.insertNewDvoExternID(self.header['SOURCEID'], self.header['IMAGEID'])
     129
     130       # self.testprint()
    117131
    118132       # dump stuff to log
     
    139153        self.scratchDb.execute(sql)
    140154
     155
     156    def testprint(self):
     157      print "here ", self.printline
     158      self.printline += 1
    141159
    142160    '''
     
    348366        self.logger.infoPair("Procesing table", "StackMeta")
    349367
     368        self.fwhm_maj    = self.safeDictionaryAccess(self.header, 'FWHM_MAJ')
     369        self.fwhm_maj_uq = self.safeDictionaryAccess(self.header, 'FW_MJ_UQ')
     370        self.psfmodel    = self.safeDictionaryAccess(self.header, 'PSFMODEL')
     371        if (self.fwhm_maj    == "NULL"): self.fwhm_maj    = -999
     372        if (self.fwhm_maj_uq == "NULL"): self.fwhm_maj_uq = -999
     373
     374        # print "fwhm_maj    = ", self.fwhm_maj
     375        # print "fwhm_maj_uq = ", self.fwhm_maj_uq
     376        # print "psfmodel    = ", self.psfmodel
     377
    350378        sql = "INSERT INTO StackMeta (\
    351379        stackMetaID \
     
    375403        ," + self.header['FPA.ZP'] + " \
    376404        ," + self.expTime + " \
    377         ,'" + self.safeDictionaryAccess(self.header, 'PSFMODEL') + "' \
    378         ,'" + self.safeDictionaryAccess(self.header, 'FWHM_MAJ') + "' \
    379         ,'" + self.safeDictionaryAccess(self.header, 'FW_MJ_UQ') + "' \
     405        ,'" + self.psfmodel  + "' \
     406        ," + str(self.fwhm_maj)    + " \
     407        ," + str(self.fwhm_maj_uq) + " \
    380408        ,'" + self.header['CTYPE1'] + "' \
    381409        ,'" + self.header['CTYPE2'] + "' \
     
    395423        self.scratchDb.updateAllRows("StackMeta", "surveyID", str(self.surveyID))
    396424        self.scratchDb.updateFilterID("StackMeta", self.filter)
    397         self.scratchDb.updateAllRows("StackMeta", "dataRelease", str(self.config.dataRelease))
     425        self.scratchDb.updateAllRows("StackMeta", "dataRelease", str(self.skychunk.dataRelease))
    398426        self.updateStackTypeID("StackMeta")
    399427
     
    486514               ," + self.historyModNum + " \
    487515               FROM SkyChip_psf"
    488         self.scratchDb.execute(sql)
    489        
     516
     517        # print "sql: ", sql
     518        # response = raw_input("ready to insert stack det ")
     519
     520        self.scratchDb.execute(sql)
     521
    490522        #it is possible to drop some detections from dvo (that are present in the cmf). when that happens we get a 0 for objid
    491523        #we drop those...
     
    498530        self.scratchDb.updateFilterID("StackDetection", self.filter)
    499531       
    500         self.scratchDb.updateAllRows("StackDetection", "dataRelease", str(self.config.dataRelease))
     532        self.scratchDb.updateAllRows("StackDetection", "dataRelease", str(self.skychunk.dataRelease))
    501533       
    502534        self.scratchDb.updateAllRows("StackDetection", "primaryF", "0")
     
    509541       
    510542        self.updateDvoIDsAndFlags("StackDetection")
     543        # response = raw_input("updated dvo ")
    511544       
    512545        sql = "ALTER IGNORE TABLE StackDetection ADD PRIMARY KEY (objID)"
    513546       
    514547        self.scratchDb.execute(sql)
     548        # response = raw_input("add primary key? ")
    515549 
    516550        if self.stackType == "DEEP_STACK":
     
    524558           
    525559            self.scratchDb.execute(sql)
     560            # response = raw_input("add psf flux ")
    526561           
    527562        #leave null instflux in
     
    529564       
    530565        self.scratchDb.reportAndDeleteRowsWithNULLS("StackDetection", "objID")
     566        # response = raw_input("delete nulls ")
    531567       
    532568        sql="DELETE FROM StackDetection where objID = 0"
    533569       
    534570        self.scratchDb.execute(sql)
    535         self.logger.infoPair("Delleting", "entries with StackDetection.objID = 0")
     571        self.logger.infoPair("Deleting", "entries with StackDetection.objID = 0")
     572        # response = raw_input("deleted objID is 0 ")
    536573       
    537574
     
    577614        self.scratchDb.updateAllRows("StackApFlx", "surveyID", str(self.surveyID))
    578615        self.scratchDb.updateFilterID("StackApFlx", self.filter)
    579         self.scratchDb.updateAllRows("StackApFlx", "dataRelease", str(self.config.dataRelease))
     616        self.scratchDb.updateAllRows("StackApFlx", "dataRelease", str(self.skychunk.dataRelease))
    580617        self.scratchDb.updateAllRows("StackApFlx", "primaryF", "0")
    581618        self.scratchDb.updateAllRows("StackApFlx", "activeFlag", "0")
     
    611648        self.scratchDb.updateAllRows("StackModelFit", "surveyID", str(self.surveyID))
    612649        self.scratchDb.updateFilterID("StackModelFit", self.filter)
    613         self.scratchDb.updateAllRows("StackModelFit", "dataRelease", str(self.config.dataRelease))
     650        self.scratchDb.updateAllRows("StackModelFit", "dataRelease", str(self.skychunk.dataRelease))
    614651        self.scratchDb.updateAllRows("StackModelFit", "primaryF", "0")
    615652        self.scratchDb.updateAllRows("StackModelFit", "activeFlag", "0")
     
    676713
    677714        self.scratchDb.updateAllRows("SkinnyObject", "surveyID", str(self.surveyID))
    678         self.scratchDb.updateAllRows("SkinnyObject", "dataRelease", str(self.config.dataRelease))
     715        self.scratchDb.updateAllRows("SkinnyObject", "dataRelease", str(self.skychunk.dataRelease))
    679716
    680717    '''   
    681718    Populates the StackDetectionCalib table
    682     '''
    683     def populateStackDetectionCalib(self):
     719    XXX this can probably get a big speed increase by using 'SELECT () INTO OUTFILE '/tmp/name' and then
     720    calling the load data infile '/tmp/name' into table;
     721    '''
     722    def populateStackDetectionCalibInsertUpdate(self):
    684723        self.logger.infoPair("Processing table", "StackDetectionCalib")
    685724        tableName = "StackDetectionCalib"
     
    702741               FROM StackDetection"
    703742        self.scratchDb.execute(sql)
     743
     744        imageID = self.scratchDb.getImageIDFromExternID(self.header['IMAGEID'])
     745        self.logger.infoPair("obtained","imageID")
     746
    704747        # insert calibration information from dvoDetections into the Table
    705748        sql = "UPDATE " + tableName + " AS a, "  + self.scratchDb.dvoDetectionTable + " AS b \
     
    712755            a.expTime = b.expTime, \
    713756            a.airMass = b.airMass   \
    714             WHERE a.stackDetectID = b.detectID"
    715         self.scratchDb.execute(sql)
    716         self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
    717        
    718    
    719 
     757            WHERE a.stackDetectID = b.detectID \
     758            AND b.imageID = " + str(imageID)
     759        self.scratchDb.execute(sql)
     760        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease))
     761       
     762    def populateStackDetectionCalib(self):
     763
     764        tableName = "StackDetectionCalib"
     765        self.logger.infoPair("Processing table", tableName)
     766
     767        imageID = self.scratchDb.getImageIDFromExternID(self.header['IMAGEID'])
     768        self.logger.infoPair("obtained","imageID")
     769
     770        # check for & create output directory first
     771        datadumpDir = "/tmp/datadump"
     772        try:
     773            statinfo = os.stat(datadumpDir)
     774            # check on the stat results?
     775        except:
     776            print "making the data dump directory ", datadumpDir
     777            os.mkdir(datadumpDir)
     778            os.chmod(datadumpDir, 0777)
     779            statinfo = os.stat(datadumpDir)
     780
     781        dumpFile = datadumpDir + "/genetest.xx.dat"
     782        files = glob.glob(dumpFile)
     783        if len(files) > 0:
     784            os.unlink(dumpFile)
     785
     786        # insert all detections into table
     787        sql = "SELECT \
     788          a.objID,    \
     789          a.stackDetectID, \
     790          a.ippObjID,      \
     791          a.ippDetectID,   \
     792          a.filterID,      \
     793          a.surveyID,      \
     794          b.ra,            \
     795          b.dec_,          \
     796          b.raErr,         \
     797          b.decErr,        \
     798          b.zp,            \
     799          b.zpErr,         \
     800          b.expTime,       \
     801          b.airMass,       \
     802          " + str(self.skychunk.dataRelease) + " \
     803         FROM              \
     804           StackDetection as a \
     805         JOIN " + self.scratchDb.dvoDetectionTable + " as b \
     806         ON (a.stackDetectID = b.detectID) where b.imageID = " + str(imageID) + \
     807         " INTO OUTFILE '" + dumpFile + "'"
     808        print "sql: ", sql
     809        self.scratchDb.execute(sql)
     810
     811        sql = "LOAD DATA INFILE '" + dumpFile + "' INTO TABLE " + tableName
     812        print "sql: ", sql
     813        self.scratchDb.execute(sql)
     814
     815        ## XXX write this with the select/insert
     816        # self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease))
    720817
    721818    '''
     
    737834
    738835        self.scratchDb.updateFilterID("ObjectCalColor", self.filter)
    739         self.scratchDb.updateAllRows("ObjectCalColor", "dataRelease", str(self.config.dataRelease))
     836        self.scratchDb.updateAllRows("ObjectCalColor", "dataRelease", str(self.skychunk.dataRelease))
    740837
    741838
     
    802899               WHERE a.ippDetectID = b.ippDetectID \
    803900               AND b.imageID = " + str(imageID)
     901
     902        # print "update dvo sql: ", sql
     903        # response = raw_input("update dvo...")
    804904        self.scratchDb.execute(sql)
    805905   
Note: See TracChangeset for help on using the changeset viewer.