IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39062 for trunk


Ignore:
Timestamp:
Nov 6, 2015, 1:14:41 PM (11 years ago)
Author:
eugene
Message:

use names like foo_num not foo_forcedWarpID in forcedwarp scratch db

Location:
trunk/ippToPsps/jython
Files:
2 edited

Legend:

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

    r39029 r39062  
    5757               "FW",
    5858               None)
    59 
    60        # gpc1Db.getForcedWarpStageSmf(forcedWarpID)
    61        # there is a funny problem with order here: we need to open the file first to read the header to get
    62        # to skycell ID
    63        # forcedWarpID = self.forcedWarpID   
    6459
    6560       # make a set of lists (needs to be outside of the loop
     
    9994           self.logger.infoPair("index",num)
    10095           self.logger.infoPair("forcedWarpID", forcedWarpID)
    101            self.logger.infoPair("getting the fits file for add_id",forcedWarpID)
     96           self.logger.infoPair("getting the fits file for add_id", forcedWarpID)
    10297           self.fits[num] = gpc1Db.getForcedWarpStageCmf(skychunk.dvoLabel, int(forcedWarpID))
    10398           
     
    169164           self.logger.infoPair("projection cell found ",self.projectionID[num])
    170165           self.logger.infoPair("skycell found", self.skycellID[num])
    171            self.dropTableVerbose("ForcedWarpMeasurement"+"_"+str(forcedWarpID))
    172            self.dropTableVerbose("ForcedWarpMasked"+"_"+str(forcedWarpID))
    173            self.dropTableVerbose("ForcedWarpExtended"+"_"+str(forcedWarpID))
    174            self.dropTableVerbose("ForcedWarpMeta"+"_"+str(forcedWarpID))
    175            self.dropTableVerbose("ForcedWarpToImage"+"_"+str(forcedWarpID))
    176            self.dropTableVerbose("ForcedWarpLensing"+"_"+str(forcedWarpID))
     166           self.dropTableVerbose("ForcedWarpMeasurement"+"_"+str(num))
     167           self.dropTableVerbose("ForcedWarpMasked"+"_"+str(num))
     168           self.dropTableVerbose("ForcedWarpExtended"+"_"+str(num))
     169           self.dropTableVerbose("ForcedWarpMeta"+"_"+str(num))
     170           self.dropTableVerbose("ForcedWarpToImage"+"_"+str(num))
     171           self.dropTableVerbose("ForcedWarpLensing"+"_"+str(num))
    177172           if not self.config.retry:
    178                self.scratchDb.dropTable("ForcedWarpMeasurement"+"_"+str(forcedWarpID))
    179                self.scratchDb.dropTable("ForcedWarpMasked"+"_"+str(forcedWarpID))
    180                self.scratchDb.dropTable("ForcedWarpExtended"+"_"+str(forcedWarpID))
    181                self.scratchDb.dropTable("ForcedWarpMeta"+"_"+str(forcedWarpID))
    182                self.scratchDb.dropTable("ForcedWarpToImage"+"_"+str(forcedWarpID))
    183                self.scratchDb.dropTable("ForcedWarpLensing"+"_"+str(forcedWarpID))
    184        # get a few primary header values. if in test mode, then use defaults
    185                # create the tables
    186 
    187            # XXX why are these deleted?
    188            sql = "CREATE TABLE  ForcedWarpMeasurement_" + str(forcedWarpID) + " like ForcedWarpMeasurement"
    189            print sql
    190            #try: self.scratchDb.execute(sql)
    191            #except: raise
    192            sql = "CREATE TABLE  ForcedWarpExtended_" + str(forcedWarpID) + " like ForcedWarpExtended"
    193            #try: self.scratchDb.execute(sql)
    194            #except: raise
    195            sql = "CREATE TABLE  ForcedWarpMeta_" + str(forcedWarpID) + " like ForcedWarpMeta"
    196            #try: self.scratchDb.execute(sql)
    197            #except: raise
    198            sql = "CREATE TABLE  ForcedWarpToImage_" + str(forcedWarpID) + " like ForcedWarpToImage"
    199            #try: self.scratchDb.execute(sql)
    200            #except: raise
    201            sql = "CREATE TABLE  ForcedWarpLensing_" + str(forcedWarpID) + " like ForcedWarpLensing"
    202            #try: self.scratchDb.execute(sql)
    203            #except: raise
     173               self.scratchDb.dropTable("ForcedWarpMeasurement"+"_"+str(num))
     174               self.scratchDb.dropTable("ForcedWarpMasked"+"_"+str(num))
     175               self.scratchDb.dropTable("ForcedWarpExtended"+"_"+str(num))
     176               self.scratchDb.dropTable("ForcedWarpMeta"+"_"+str(num))
     177               self.scratchDb.dropTable("ForcedWarpToImage"+"_"+str(num))
     178               self.scratchDb.dropTable("ForcedWarpLensing"+"_"+str(num))
     179
     180           # get a few primary header values. if in test mode, then use defaults
    204181
    205182           ## MEH md5sum test
    206183           self.md5sum[num] = self.fits[num].getMd5sum()
    207184
    208            self.logger.infoPair("calculating ObsTime","ok")
    209185           # MJD-OBS is the exposure start, EXTIME / 172800 = (EXPTIME sec / 84600 sec/day) / 2
    210 
    211186           self.obsTime[num] = float(self.header[num]['MJD-OBS']) + (float(self.expTime[num]) / 172800.0)
    212 
    213187           self.logger.infoPair("obstime",self.obsTime[num])
     188
    214189           self.filterID[num] = self.scratchDb.getFilterID(self.filterName[num][0])
    215190           self.logger.infoPair("filterID is ",self.filterID[num])
    216            self.logger.infoPair("inserting basics into ","ForcedWarpMeta"+"_"+forcedWarpID)
    217            
     191
     192           self.logger.infoPair("inserting basics into ", "ipptopsps.forcedwarp")
    218193           self.ippToPspsDb.insertForcedWarpMeta( int(self.batchID), int(self.expID[num]), self.filterName[num][0])       
    219194
    220195           num=num+1
     196
    221197       # create an output filename, which is {expID}.FITS
    222198       self.outputFitsFile = "%08d.FITS" % self.id
     
    231207    def populateForcedWarpMeta(self,num):
    232208        forcedWarpID = self.number[num]
    233         tableName = "ForcedWarpMeta_" + forcedWarpID
     209        tableName = "ForcedWarpMeta_" + str(num)
    234210
    235211        self.logger.infoPair("Processing table", tableName)
     
    330306        forcedwarpID = self.number[num]
    331307        self.logger.infoPair("Procesing table", "ForcedWarpToImage")
    332         sql = "CREATE TABLE ForcedWarpToImage_"+forcedwarpID+" LIKE ForcedWarpToImage"
    333         try: self.scratchDb.execute(sql)
    334         except: pass
    335 
    336         #forcedwarpID = self.forcedWarpID
     308
     309        tableName = "ForcedWarpToImage_" + str(num)
     310
     311        sql = "CREATE TABLE " + tableName + " LIKE ForcedWarpToImage"
     312        self.scratchDb.execute(sql)
     313
    337314        if forcedwarpID > 0:
    338    
     315
    339316                imageIDs = self.gpc1Db.getImageIDsForThisForcedWarpID(forcedwarpID)
    340317
    341318                for imageID in imageIDs:
    342319
    343                     sql = "INSERT INTO ForcedWarpToImage_"+str(forcedwarpID)+" (forcedwarpID, imageID) \
    344                    VALUES (\
    345                    " + str(forcedwarpID) + ", " + imageID + ")"
     320                    sql = "INSERT INTO " + tableName + " (forcedwarpID, imageID) VALUES ( " + str(forcedwarpID) + ", " + imageID + ")"
    346321                    try: self.scratchDb.execute(sql)
    347322                    except:
    348323                       self.logger.infoPair("can't execute sql",sql)
    349324                       raise
    350                     # now update StackMeta with correct number of inputs
    351 
    352         #self.tablesToExport.append("ForcedWarpToImage")
    353 
    354 
    355 
    356 
    357325
    358326    '''
     
    361329    def populateForcedWarpMeasurement(self,num):
    362330        forcedWarpID = self.number[num]
    363         pspsTableName = "ForcedWarpMeasurement_"+forcedWarpID
    364         ippTableName = "SkyChip_psf_"+forcedWarpID
    365 
    366         sql = "CREATE TABLE ForcedWarpMeasurement_"+forcedWarpID+" LIKE ForcedWarpMeasurement"
    367         try: self.scratchDb.execute(sql)
    368         except: pass
    369 
    370         self.logger.infoPair("Procesing table", "ForcedWarpMeasurement_"+forcedWarpID)
    371 
    372         BEFORE = self.scratchDb.getRowCount(ippTableName)
     331        pspsTableName = "ForcedWarpMeasurement_" + str(num)
     332        maskTableName = "ForcedWarpMasked_" + str(num)
     333        ippTableName = "SkyChip_psf_" + str(num)
     334
     335        sql = "CREATE TABLE " + pspsTableName + " LIKE ForcedWarpMeasurement"
     336        self.scratchDb.execute(sql)
     337
     338        self.logger.infoPair("Procesing table", pspsTableName)
     339
    373340        expTimeString = str(self.expTime[num])
    374341
    375 #missing are zp, telluricExt, airmass (not easy to get ?)
    376      
    377342        sqlLine = sqlUtility("INSERT INTO " + pspsTableName + " (")
    378343        sqlLine.group("ippDetectID",       "IPP_IDET")
     
    401366        sqlLine.group("FpsfQfPerfect",     "PSF_QF_PERFECT")
    402367        sqlLine.group("FpsfChiSq",         "PSF_CHISQ")
    403 #       sqlLine.group("FpsfLikelihood",    "psfLikelihood(EXT_NSIGMA)") -- deprecated in r38867 (not measured in FW cmfs)
    404368        sqlLine.group("FmomentXX",         "MOMENTS_XX * PLTSCALE * PLTSCALE")
    405369        sqlLine.group("FmomentXY",         "MOMENTS_XY * PLTSCALE * PLTSCALE")
     
    429393        # insert the per-object data (IDs, random stack ID, processingVersion, etc)
    430394        # self.selectDvoObjIDs()
    431         self.logger.infoPair("inserting dvo info: find imageID","from externID")
     395        self.logger.infoPair("inserting dvo info: find imageID", "from externID")
    432396        imageID = self.scratchDb.getImageIDFromExternID(self.warpSkyFileID[num])
    433         self.logger.infoPair("updating","forcedWarpMeasurement_"+forcedWarpID)
    434 
    435         sqlLine = sqlUtility("UPDATE ForcedWarpMeasurement_"+forcedWarpID+" as a, " + self.scratchDb.dvoDetectionTable + " as b SET ")
     397        self.logger.infoPair("updating", pspsTableName)
     398
     399        sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, " + self.scratchDb.dvoDetectionTable + " as b SET ")
    436400        sqlLine.group("a.objID",      "b.objID")
    437401        sqlLine.group("a.detectID",   "b.detectID")
     
    456420
    457421        self.logger.infoPair("need to cull"," nulls objid")
    458         rowCountBefore = self.scratchDb.getRowCount("ForcedWarpMeasurement_"+forcedWarpID)
    459         results= self.scratchDb.reportAndDeleteRowsWithNULLS("ForcedWarpMeasurement_"+forcedWarpID, "objID")
    460         rowCountAfter =  self.scratchDb.getRowCount("ForcedWarpMeasurement_"+forcedWarpID)
     422        rowCountBefore = self.scratchDb.getRowCount(pspsTableName)
     423        results= self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "objID")
     424        rowCountAfter =  self.scratchDb.getRowCount(pspsTableName)
    461425        self.logger.infoPair("row count of ForcedWarpMeasurement", rowCountBefore)
    462426        self.logger.infoPair("row count of ForcedWarpMeasurement after cull of null objID ", rowCountAfter)
     
    465429            self.logger.infoPair ("skip this batch", "it is bad")
    466430            return False
    467 #        self.generateRandomIDs()
    468 
    469         self.logger.infoPair("Adding 'row' columns to", "ForcedWarpMeasurement_"+forcedWarpID)
    470         self.scratchDb.addRowCountColumn("ForcedWarpMeasurement_"+forcedWarpID, "row")
    471         self.logger.infoPair("Adding unique ids to", "ForcedWarpMeasurement_"+forcedWarpID)
    472         self.generateUniquePspsIDs(num)
    473         self.logger.infoPair("Dropping row column from", "ForcedWarpMeasurement_"+forcedWarpID+" table")
    474         self.scratchDb.dropColumn("ForcedWarpMeasurement_"+forcedWarpID, "row")
     431
     432        self.logger.infoPair("Adding 'row' columns to", pspsTableName)
     433        self.scratchDb.addRowCountColumn(pspsTableName, "row")
     434
     435        self.logger.infoPair("Adding unique ids to", pspsTableName)
     436        self.generateUniquePspsIDs(tableName, num)
     437
     438        self.logger.infoPair("Dropping row column from", pspsTableName)
     439        self.scratchDb.dropColumn(pspsTableName, "row")
    475440
    476441        # now move the rows with no data to ForcedWarpMasked
    477         self.logger.infoPair("Procesing table", "ForcedWarpMasked_"+forcedWarpID)
    478         sql = "CREATE TABLE ForcedWarpMasked_"+forcedWarpID+" LIKE ForcedWarpMasked"
    479         try: self.scratchDb.execute(sql)
    480         except: pass
     442        self.logger.infoPair("Procesing table", maskTableName)
     443        sql = "CREATE TABLE " + maskTableName + " LIKE ForcedWarpMasked"
     444        self.scratchDb.execute(sql)
    481445
    482446        # This is the definition of a "masked measurement".
     
    484448        maskedCondition = "FpsfQfPerfect < .0001 OR FpsfQfPerfect is NULL"
    485449
    486         sql = "INSERT INTO ForcedWarpMasked_"+forcedWarpID+" \
    487                SELECT objID, uniquePspsFWid, ippObjID, ippDetectID, filterID, surveyID, \
    488                 forcedSummaryID, forcedWarpID, randomWarpID, tessID, projectionID, \
    489                 skyCellID, dvoRegionID, obsTime \
    490                FROM ForcedWarpMeasurement_"+forcedWarpID+" WHERE "+maskedCondition
    491         try: self.scratchDb.execute(sql)
    492         except: pass
    493 
    494         sql = "DELETE FROM ForcedWarpMeasurement_"+forcedWarpID+" WHERE "+maskedCondition
    495         try: self.scratchDb.execute(sql)
    496         except: pass
     450        sql  = "INSERT INTO " + maskTableName
     451        sql += " SELECT objID, uniquePspsFWid, ippObjID, ippDetectID, filterID, surveyID,"
     452        sql += " forcedSummaryID, forcedWarpID, randomWarpID, tessID, projectionID,"
     453        sql += " skyCellID, dvoRegionID, obsTime"
     454        sql += " FROM " + pspsTableName + " WHERE " + maskedCondition
     455        self.scratchDb.execute(sql)
     456
     457        sql = "DELETE FROM " pspsTableName + " WHERE " + maskedCondition
     458        self.scratchDb.execute(sql)
    497459           
    498460        # add indexes ForcedWarpMeasurement
    499         self.scratchDb.createIndex("ForcedWarpMeasurement_"+forcedWarpID, "objID")
    500         self.scratchDb.createIndex("ForcedWarpMeasurement_"+forcedWarpID, "ippDetectID")
     461        self.scratchDb.createIndex(pspsTableName, "objID")
     462        self.scratchDb.createIndex(pspsTableName, "ippDetectID")
    501463
    502464        # add indexes ForcedWarpMasked
    503         self.scratchDb.createIndex("ForcedWarpMasked_"+forcedWarpID, "objID")
    504         self.scratchDb.createIndex("ForcedWarpMasked_"+forcedWarpID, "ippDetectID")
     465        self.scratchDb.createIndex(maskTableName, "objID")
     466        self.scratchDb.createIndex(maskTableName, "ippDetectID")
    505467
    506468    '''
     
    509471    def populateForcedWarpExtended(self,num):
    510472        forcedWarpID = self.number[num]
    511         pspsTableName = "ForcedWarpExtended_"+forcedWarpID
    512         ippTableName = "SkyChip_xrad_"+forcedWarpID
    513         sql = "CREATE TABLE ForcedWarpExtended_"+forcedWarpID+" LIKE ForcedWarpExtended"
    514         try: self.scratchDb.execute(sql)
    515         except: pass
    516 
    517         #self.tablesToExport.append("ForcedWarpExtended")
    518 
    519         #isert stuff from SkyChip_psf
     473        pspsTableName = "ForcedWarpExtended_" + str(num)
     474        ippTableName = "SkyChip_xrad_" + str(num)
     475        fMeasTableName = "ForcedWarpMeasurement_" + str(num)
     476
     477        sql = "CREATE TABLE " + pspsTableName + " LIKE ForcedWarpExtended"
     478        self.scratchDb.execute(sql)
     479
     480        # insert stuff from SkyChip_xrad
     481        self.logger.infoPair("inserting data from", ippTableName)
    520482        sqlLine = sqlUtility("INSERT INTO " + pspsTableName + " (")
    521483        sqlLine.group("ippDetectID",     "IPP_IDET")
     
    534496
    535497        sql = sqlLine.makeRaw(") SELECT ", " FROM " + ippTableName)
    536 
    537         try: self.scratchDb.execute(sql)
    538         except:
    539             self.logger.errorPair("failed sql: ", sql)
    540             raise
    541 
    542         #insert the things from FOrcedWarpMeasurement
    543         self.logger.infoPair("inserting objID,etc from","ForcedWarpMeasurement_"+forcedWarpID)
    544         sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, ForcedWarpMeasurement_"+forcedWarpID+" as b SET ")
     498        self.scratchDb.execute(sql)
     499
     500        # insert the things from ForcedWarpMeasurement
     501        self.logger.infoPair("adding objID, etc from", fMeasTableName)
     502        sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, " + fMeasTableName + " as b SET ")
    545503        sqlLine.group("a.objID","b.objID")
    546504        sqlLine.group("a.uniquePspsFWid","b.uniquePspsFWid")
     
    555513        sqlLine.group("a.obsTime","b.obsTime")
    556514        sql = sqlLine.makeEquals("Where a.ippDetectID = b.ippDetectID")
    557         try: self.scratchDb.execute(sql)
    558         except:
    559             self.logger.errorPair("failed sql: ", sql)
    560             raise
     515        self.scratchDb.execute(sql)
    561516       
    562        # add in the psps unique ids from stuff
    563         self.logger.infoPair("adding information from Skychip_xrad_"+forcedWarpID+" into","ForcedWarpExtended_"+forcedWarpID)
    564        
    565         # cull bad d
     517        # cull bad entris
    566518        self.logger.infoPair("need to cull"," nulls objid")
    567         results= self.scratchDb.reportAndDeleteRowsWithNULLS("ForcedWarpExtended_"+forcedWarpID, "objID")
    568        
    569         self.scratchDb.createIndex("ForcedWarpExtended_"+forcedWarpID, "objID")
    570                
    571 
    572 
    573     '''                                                                                                                                                                 
    574     Populates the ForcedWarpExtended table                                                                                                                               
     519        results = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "objID")
     520        self.scratchDb.createIndex(pspsTableName, "objID")
     521
     522    '''
     523    Populates the ForcedWarpExtended table
    575524    '''
    576525    def populateForcedWarpLensing(self, num):
    577         forcedWarpID = self.number[num]
    578         pspsTableName = "ForcedWarpLensing_"+forcedWarpID
    579         ippTableName = "SkyChip_psf_"+forcedWarpID
    580         sql = "CREATE TABLE ForcedWarpLensing_"+forcedWarpID+" LIKE ForcedWarpLensing"
    581         try: self.scratchDb.execute(sql)
    582         except: pass
    583 
    584         #self.tablesToExport.append("ForcedWarpExtended")                                                                                                               
    585 
    586         #isert stuff from SkyChip_psf                                                                                                                                   
     526        forcedWarpID   = self.number[num]
     527        ippTableName   = "SkyChip_psf_" + str(num)
     528        pspsTableName  = "ForcedWarpLensing_" + str(num)
     529        fMeasTableName = "ForcedWarpMeasurement_" + str(num)
     530
     531        sql = "CREATE TABLE " + pspsTableName + " LIKE ForcedWarpLensing"
     532        self.scratchDb.execute(sql)
     533
     534        # insert stuff from SkyChip_psf
     535        self.logger.infoPair("adding information from " + ippTableName + " into", pspsTableName)
    587536        sqlLine = sqlUtility("INSERT INTO " + pspsTableName + " (")
    588537        sqlLine.group("ippDetectID",     "IPP_IDET")
     
    609558        sqlLine.group("psfE1", "LENS_E1_PSF")
    610559        sqlLine.group("psfE2", "LENS_E2_PSF")
     560
    611561        sql = sqlLine.makeRaw(") SELECT ", " FROM " + ippTableName)
    612 
    613         try: self.scratchDb.execute(sql)
    614         except:
    615             self.logger.errorPair("failed sql: ", sql)
    616             raise
    617 
    618         #insert the things from FOrcedWarpMeasurement                                                                                                                   
    619         self.logger.infoPair("inserting objID,etc from","ForcedWarpMeasurement_"+forcedWarpID)
    620         sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, ForcedWarpMeasurement_"+forcedWarpID+" as b SET ")
     562        self.scratchDb.execute(sql)
     563
     564        # insert the things from ForcedWarpMeasurement
     565        self.logger.infoPair("inserting objID,etc from", fMeasTableName)
     566        sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, " + fMeasTableName + " as b SET ")
    621567        sqlLine.group("a.objID","b.objID")
    622568        sqlLine.group("a.uniquePspsFWid","b.uniquePspsFWid")
     
    630576        sqlLine.group("a.dvoRegionID","b.dvoRegionID")
    631577        sqlLine.group("a.obsTime","b.obsTime")
     578
    632579        sql = sqlLine.makeEquals("Where a.ippDetectID = b.ippDetectID")
    633         try: self.scratchDb.execute(sql)
    634         except:
    635             self.logger.errorPair("failed sql: ", sql)
    636             raise
    637 
    638        # add in the psps unique ids from stuff                                                                                                                           
    639         self.logger.infoPair("adding information from Skychip_psf_"+forcedWarpID+" into","ForcedWarpLensing_"+forcedWarpID)
    640 
    641         # cull bad d                                                                                                                                                     
     580        self.scratchDb.execute(sql)
     581
     582        # cull bad entries
    642583        self.logger.infoPair("need to cull"," nulls objid")
    643         results= self.scratchDb.reportAndDeleteRowsWithNULLS("ForcedWarpLensing_"+forcedWarpID, "objID")
    644 
    645         self.scratchDb.createIndex("ForcedWarpLensing_"+forcedWarpID, "objID")
    646 
    647 
     584        results= self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "objID")
     585
     586        self.scratchDb.createIndex(pspsTableName, "objID")
    648587
    649588    '''
     
    656595        self.tablesToExport=[]
    657596   
    658         #this should be done
    659         #number  = 0
    660         #for forcedWarpID in self.forcedWarpIds:
    661597        for num in self.number:   
    662             print "hawaht?"
    663598            forcedWarpID = self.number[num]
    664             self.logger.infoPair("Populating","ForcedWarpMeta_"+forcedWarpID)
     599            myTable = "ForcedWarpMeta_" + str(num)
     600            self.logger.infoPair("Populating", myTable)
    665601            self.populateForcedWarpMeta(num)         
    666             self.tablesToExport.append("ForcedWarpMeta_"+forcedWarpID)
     602            self.tablesToExport.append(myTable)
    667603           
    668             self.logger.infoPair("Populating","ForcedWarpMeasurement_"+forcedWarpID)
     604            myTable = "ForcedWarpMeasurement_" + str(num)
     605            self.logger.infoPair("Populating", myTable)
    669606            self.populateForcedWarpMeasurement(num)         
    670             self.tablesToExport.append("ForcedWarpMeasurement_"+forcedWarpID)
    671             self.tablesToExport.append("ForcedWarpMasked_"+forcedWarpID)
     607            self.tablesToExport.append(myTable)
     608
     609            self.logger.infoPair("setting min/max objid from", myTable)
     610            self.setMinMaxObjID([myTable])
     611
     612            # populateForcedWarpMeasurement also populates ForcedWarpMasked (from ForcedWarpMeasurement)
     613            self.tablesToExport.append("ForcedWarpMasked_" + str(num))
    672614           
    673             self.logger.infoPair("Populating","ForcedWarpExtended_"+forcedWarpID)
     615            myTable = "ForcedWarpExtended_" + str(num)
     616            self.logger.infoPair("Populating", myTable)
    674617            self.populateForcedWarpExtended(num)
    675             self.tablesToExport.append("ForcedWarpExtended_"+forcedWarpID)
    676 
    677             self.logger.infoPair("Populating","ForcedWarpLensing_"+forcedWarpID)
     618            self.tablesToExport.append(myTable)
     619
     620            myTable = "ForcedWarpLensing_" + str(num)
     621            self.logger.infoPair("Populating", myTable)
    678622            self.populateForcedWarpLensing(num)
    679             self.tablesToExport.append("ForcedWarpLensing_"+forcedWarpID)
    680 
    681 
    682             self.logger.infoPair("Populating","ForcedWarpToImage_"+forcedWarpID)
     623            self.tablesToExport.append(myTable)
     624
     625            myTable = "ForcedWarpToImage_" + str(num)
     626            self.logger.infoPair("Populating", myTable)
    683627            self.populateForcedWarpToImage(num)
    684             self.tablesToExport.append("ForcedWarpToImage_"+forcedWarpID)             
    685 
    686 
    687             self.logger.infoPair("setting min/max objid from","ForcedWarpMeasurement_"+forcedWarpID)
    688             self.setMinMaxObjID(["ForcedWarpMeasurement_"+forcedWarpID])
     628            self.tablesToExport.append(myTable)
    689629           
    690630            self.logger.infoPair("finishing","populatePspsTables")
     
    730670       
    731671            ## output table names need to have "_num" appended. 
    732             fitsOptions  = "-tablesuffix _" + str(forcedWarpID)
     672            fitsOptions  = "-tablesuffix _" + str(num)
    733673
    734674            # this option is equivalent to the stilts "addcol table_index $0" call
     
    750690
    751691            for table in tables:
    752                 myTable = table.name + "_" + str(forcedWarpID)
     692                myTable = table.name + "_" + str(num)
    753693                count = count + 1
    754694                     
    755695                self.tablesLoaded.append(myTable)
    756696
    757             self.indexIppTables(forcedWarpID)
     697            # after all tables are read for this forcedWarpID, then index the set
     698            self.indexIppTables(num)
    758699                     
    759         # after all tables are read for this forcedWarpID, then index the set
    760700        self.logger.infoPair("Done. Imported", "%d tables" % count)
    761701        return True
     
    765705    '''
    766706    def importIppTablesStilts(self, columns="*", tableRE=""):
     707
     708        print "*** STILTS import is now deprecated ***"
     709        os._exit(4)
    767710
    768711        self.tablesLoaded = []
     
    819762
    820763
    821     def generateRandomIDs(self,forcedWarpID):
    822         sql = "UPDATE ForcedWarpMeasurement_"+forcedWarpID+" set randomWarpID = RAND("+str(self.batchID)+")"
    823         try:
    824             self.scratchDb.execute(sql)
    825         except:
    826             self.logger.errorPair('failed sql',sql)
    827             raise
    828 
    829 
    830764    '''
    831765    Updates table and generates pspsuniqueids
    832766    '''
    833 
    834     def generateUniquePspsIDs(self,num):
     767    def generateUniquePspsIDs(self, tableName, num):
    835768       
    836         sql = "UPDATE ForcedWarpMeasurement_"+str(self.number[num])+" set uniquePspsFWid = (("+str(self.batchID)+"*1000000000 ) + ("+str(num)+"*1000000 ) + row)"
    837         try: self.scratchDb.execute(sql)
    838         except:
    839            self.logger.errorPair('failed sql',sql)
    840            raise
     769        sql = "UPDATE " + tableName + " set uniquePspsFWid = (("+str(self.batchID)+"*1000000000 ) + ("+str(num)+"*1000000 ) + row)"
     770        self.scratchDb.execute(sql)
    841771
    842772    '''
     
    869799    Applies indexes to the IPP tables
    870800    '''
    871     def indexIppTables(self,forcedWarpID):
    872 
    873         self.logger.infoPair("Creating indexes on " + forcedWarpID, "IPP tables")
     801    def indexIppTables(self,num):
     802
     803        self.logger.infoPair("Creating indexes on " + str(num), "IPP tables")
    874804
    875805        # it probably should not be an error not to have one of these:
    876         cmfTable = "SkyChip_psf_" + forcedWarpID
     806        cmfTable = "SkyChip_psf_" + str(num)
    877807        if cmfTable in self.tablesLoaded: self.scratchDb.createIndex(cmfTable,  "IPP_IDET")
    878808
    879         cmfTable = "SkyChip_xfit_" + forcedWarpID
     809        cmfTable = "SkyChip_xfit_" + str(num)
    880810        if cmfTable in self.tablesLoaded: self.scratchDb.createIndex(cmfTable,  "IPP_IDET")
    881811
    882         cmfTable = "SkyChip_xrad_" + forcedWarpID
     812        cmfTable = "SkyChip_xrad_" + str(num)
    883813        if cmfTable in self.tablesLoaded: self.scratchDb.createIndex(cmfTable,  "IPP_IDET")
    884814
    885         cmfTable = "SkyChip_xsrc_" + forcedWarpID
     815        cmfTable = "SkyChip_xsrc_" + str(num)
    886816        if cmfTable in self.tablesLoaded: self.scratchDb.createIndex(cmfTable,  "IPP_IDET")
    887817
    888         cmfTable = "SkyChip_xgal_" + forcedWarpID
     818        cmfTable = "SkyChip_xgal_" + str(num)
    889819        if cmfTable in self.tablesLoaded: self.scratchDb.createIndex(cmfTable,  "IPP_IDET")
    890820
    891         ## self.scratchDb.createIndex("SkyChip_xfit_"+forcedWarpID, "IPP_IDET")
    892         ## self.scratchDb.createIndex("SkyChip_xrad_"+forcedWarpID, "IPP_IDET")
    893         ## self.scratchDb.createIndex("SkyChip_xsrc_"+forcedWarpID, "IPP_IDET")
    894         ## self.scratchDb.createIndex("SkyChip_xgal_"+forcedWarpID, "IPP_IDET")
    895 
    896821        return True
    897 
    898     '''
    899     Updates table and generates pspsuniqueids
    900     '''
    901 
    902     def updatePspsUniqueIDs(self,table):
    903         sql = "UPDATE ForcedWarpMeasurement_"+forcedWarpID+" set uniquePspsFWid = (("+str(self.batchID)+"*1000000000 ) + (str(number)*1000000 ) + row)"
    904         try: self.scratchDb.execute(sql)
    905         except:
    906            self.logger.errorPair('failed sql',sql)
    907            raise
  • trunk/ippToPsps/jython/stackbatch.py

    r39048 r39062  
    5555               None)
    5656
    57        self.stackType = "DEEP_STACK" # TODO
     57       self.stackType = "DEEP_STACK" # XXX NOTE:this is currently hard-wired for 3pi.  Before we run MD, this needs to be updated.
    5858       self.stackTypeID = self.getStackTypeID()
    5959       
Note: See TracChangeset for help on using the changeset viewer.