IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 9, 2015, 5:55:53 PM (11 years ago)
Author:
eugene
Message:

2.5log(exptime) should be added, not subtracted, from deteff; fix the assignment of skycell/projection/tess ID in diff and forcedwarp; get zpImage from header for Diffs (dvo does NOT calculate); apply platescale to GalShape sizes; remove StackDetectRowID

File:
1 edited

Legend:

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

    r39084 r39094  
    55import glob
    66import time
     7import math
    78import stilts
    89import re
     
    154155           self.logger.infoPair("TessName ",tessName)
    155156
    156            # XXX EAM 20140812 : I am hardwiring the parsing logic for RINGS vs LOCAL
    157157           if self.tessName[num] == 'RINGS.V3':
    158            # skycell is, eg "skycell.1133.081"
    159            #                 0123456789012345
     158               # skycell is, eg "skycell.1133.081"
     159               #                 0123456789012345
    160160               self.projectionID[num] = self.skycellName[num][8:12]
    161                self.skycellID[num] = self.skycellName[num][13:]
    162                self.skycellID[num] = self.skycellName[num][8:]
     161               self.skycellID[num] = self.skycellName[num][13:]
    163162           else:
    164            # skycell is, eg "skycell.081"
    165            #                 01234567890
     163               # skycell is, eg "skycell.081"
     164               #                 01234567890
    166165               self.projectionID[num] = 0
    167                self.skycellID[num] = self.skycellName[num][8:11]
    168                self.skycellID[num]=self.skycellName[num][8:]
    169            if self.skycellID[num] == "":
     166               self.skycellID[num] = self.skycellName[num][8:]
     167               
     168           if self.projectionID[num] == "":
     169               self.projectionID[num] = -1
     170           if self.skycellID[num] == "":
    170171               self.skycellID[num] = -1
    171172
     
    183184           self.psfModelID[num]  = self.scratchDb.getFitModelID(self.psfModelName[num])
    184185
    185 
    186186           # drop the existing tables   
    187187
     
    191191           self.dropTableVerbose("DiffDetEffMeta_"+str(num))
    192192
    193            if not self.analysisVer[num]: self.analysisVer[num] = -999
     193           # if not self.analysisVer[num]: self.analysisVer[num] = -999
    194194
    195195           self.logger.infoPair("getPhotoCalID",diffSkyFileID)
     
    222222        self.logger.infoPair("Proccesing table", "DiffMeta_"+str(num))
    223223
     224        header = self.header[num]
     225
     226        # Convert detectionThreshold to appropriate magnitudes
     227        detectionThreshold = self.getKeyFloat(header, "%.8f", 'DETEFF.MAGREF')
     228        zpImage            = self.getKeyFloat(header, "%.8f", 'FPA.ZP')
     229           
     230        detectionThreshold = detectionThreshold + zpImage + 2.5 * math.log10(float(self.expTime[num]))
     231
    224232        sql = "CREATE TABLE DiffMeta_"+str(num)+" like DiffMeta"
    225233        try: self.scratchDb.execute(sql)
     
    234242        sqlLine.group("negImageID",            self.negImageID[num]);
    235243        sqlLine.group("ippDiffID",             self.ippDiffID[num]);
     244        sqlLine.group("tessID",                str(self.tessID[num]))
    236245        sqlLine.group("projectionID",          str(self.projectionID[num]))
    237246        sqlLine.group("skycellID",             str(self.skycellID[num]))
     
    239248        sqlLine.group("analysisVer",           str(self.analysisVer[num]));
    240249        sqlLine.group("md5sum",                str(self.md5sum[num]))
     250        sqlLine.group("detectionThreshold",    detectionThreshold)
    241251        sqlLine.group("expTime",               self.expTime[num]);
    242252        sqlLine.group("psfModelID",            self.psfModelID[num])
     
    244254        sqlLine.group("psfWidMajor",           self.psfFwhmMajor[num])
    245255        sqlLine.group("psfWidMinor",           self.psfFwhmMinor[num])
    246         sqlLine.group("kernel",                self.getKeyValue(self.header[num], 'SUBTRACTION.KERNEL'))
    247         sqlLine.group("mode",                  self.getKeyValue(self.header[num], 'SUBTRACTION.MODE'))
    248         sqlLine.group("psfTheta",              self.getKeyFloat(self.header[num], "%.8f", 'ANGLE'))
    249         sqlLine.group("numStamps",             self.getKeyValue(self.header[num], 'SUBTRACTION.STAMPS'))
    250         sqlLine.group("stampDevMean",          self.getKeyFloat(self.header[num], "%.8e", 'SUBTRACTION.DEV.MEAN'))
    251         sqlLine.group("stampDevRMS",           self.getKeyFloat(self.header[num], "%.8e", 'SUBTRACTION.DEV.RMS'))
    252         sqlLine.group("normalization",         self.getKeyFloat(self.header[num], "%.8e", 'SUBTRACTION.NORM'))
    253         sqlLine.group("convolveMax",           self.getKeyFloat(self.header[num], "%.8e", 'SUBTRACTION.CONV.MAX'))
    254         sqlLine.group("deconvolveMax",         self.getKeyFloat(self.header[num], "%.8e", 'SUBTRACTION.DECONV.MAX'))
    255         sqlLine.group("ctype1",                self.getKeyValue(self.header[num], 'CTYPE1'));
    256         sqlLine.group("ctype2",                self.getKeyValue(self.header[num], 'CTYPE2'));
    257         sqlLine.group("crval1",                self.getKeyFloat(self.header[num], "%.8f", 'CRVAL1'));
    258         sqlLine.group("crval2",                self.getKeyFloat(self.header[num], "%.8f", 'CRVAL2'));
    259         sqlLine.group("crpix1",                self.getKeyFloat(self.header[num], "%.8f", 'CRPIX1'));
    260         sqlLine.group("crpix2",                self.getKeyFloat(self.header[num], "%.8f", 'CRPIX2'));
    261         sqlLine.group("cdelt1",                self.getKeyFloat(self.header[num], "%.8e", 'CDELT1'));
    262         sqlLine.group("cdelt2",                self.getKeyFloat(self.header[num], "%.8e", 'CDELT2'));
    263         sqlLine.group("pc001001",              self.getKeyFloat(self.header[num], "%.8e", 'PC001001'));
    264         sqlLine.group("pc001002",              self.getKeyFloat(self.header[num], "%.8e", 'PC001002'));
    265         sqlLine.group("pc002001",              self.getKeyFloat(self.header[num], "%.8e", 'PC002001'));
    266         sqlLine.group("pc002002",              self.getKeyFloat(self.header[num], "%.8e", 'PC002002'));
     256
     257        sqlLine.group("kernel",                self.getKeyValue(header, 'SUBTRACTION.KERNEL'))
     258        sqlLine.group("mode",                  self.getKeyValue(header, 'SUBTRACTION.MODE'))
     259        sqlLine.group("psfTheta",              self.getKeyFloat(header, "%.8f", 'ANGLE'))
     260        sqlLine.group("numStamps",             self.getKeyValue(header, 'SUBTRACTION.STAMPS'))
     261        sqlLine.group("stampDevMean",          self.getKeyFloat(header, "%.8e", 'SUBTRACTION.DEV.MEAN'))
     262        sqlLine.group("stampDevRMS",           self.getKeyFloat(header, "%.8e", 'SUBTRACTION.DEV.RMS'))
     263        sqlLine.group("normalization",         self.getKeyFloat(header, "%.8e", 'SUBTRACTION.NORM'))
     264        sqlLine.group("convolveMax",           self.getKeyFloat(header, "%.8e", 'SUBTRACTION.CONV.MAX'))
     265        sqlLine.group("deconvolveMax",         self.getKeyFloat(header, "%.8e", 'SUBTRACTION.DECONV.MAX'))
     266        sqlLine.group("ctype1",                self.getKeyValue(header, 'CTYPE1'));
     267        sqlLine.group("ctype2",                self.getKeyValue(header, 'CTYPE2'));
     268        sqlLine.group("crval1",                self.getKeyFloat(header, "%.8f", 'CRVAL1'));
     269        sqlLine.group("crval2",                self.getKeyFloat(header, "%.8f", 'CRVAL2'));
     270        sqlLine.group("crpix1",                self.getKeyFloat(header, "%.8f", 'CRPIX1'));
     271        sqlLine.group("crpix2",                self.getKeyFloat(header, "%.8f", 'CRPIX2'));
     272        sqlLine.group("cdelt1",                self.getKeyFloat(header, "%.8e", 'CDELT1'));
     273        sqlLine.group("cdelt2",                self.getKeyFloat(header, "%.8e", 'CDELT2'));
     274        sqlLine.group("pc001001",              self.getKeyFloat(header, "%.8e", 'PC001001'));
     275        sqlLine.group("pc001002",              self.getKeyFloat(header, "%.8e", 'PC001002'));
     276        sqlLine.group("pc002001",              self.getKeyFloat(header, "%.8e", 'PC002001'));
     277        sqlLine.group("pc002002",              self.getKeyFloat(header, "%.8e", 'PC002002'));
    267278
    268279        sql = sqlLine.make(") VALUES ( ", ")")
     
    323334            sqlLine.group("filterID",        str(self.filterID[num]))
    324335            sqlLine.group("surveyID",        str(self.surveyID))
     336            sqlLine.group("tessID",          str(self.tessID[num]))
     337            sqlLine.group("projectionID",    str(self.projectionID[num]))
    325338            sqlLine.group("skycellID",       str(self.skycellID[num]))
    326339            sqlLine.group("expTime",         str(self.expTime[num]))
     
    336349                sqlLine.group("decErr",          "Y_PSF_SIG * abs(PLTSCALE)")
    337350            else:
    338                 sqlLine.group("pltScale",        "0.257")
    339                 sqlLine.group("posAngle",        "-999")
     351                sqlLine.group("pltScale",        "0.25")
     352                # sqlLine.group("posAngle",        "-999")
    340353                sqlLine.group("raErr",           "X_PSF_SIG * 0.25")
    341354                sqlLine.group("decErr",          "Y_PSF_SIG * 0.25")
     
    433446        self.logger.infoPair("Dropping row column from", "DiffDetection table")
    434447        self.scratchDb.dropColumn("DiffDetection_"+str(num), "row")
    435  
    436448
    437449    '''
     
    494506
    495507        header = self.header[num]
    496         # CZW: this is broken, and can't get the zeropoint
    497         #        zpImage = self.scratchDb.getImageZeroPoint(diffSkyFileID)
    498         zpImage = 0.0
    499 
    500         if zpImage < 0.0:
    501             zpImage = 0.0
     508        zpImage = self.getKeyFloat(header,"%.8f","FPA.ZP")
     509
    502510        if zpImage == 0.0:
    503511            self.logger.infoPair("CZW If this value for the zeropoint is zero, the getImageZeroPoint call is likely still broken", str(zpImage))
    504512
    505 
    506513        magref = self.getKeyFloat(header,"%.8f","DETEFF.MAGREF") + zpImage
    507514        self.logger.infoPair("Found zeropoint and set magref", str(magref))
    508         self.logger.infoPair("CZW If that magref is -5.804804, then it's reading from the PHU, not the Deteff extension.","In a test, I mean.")
     515
    509516        sqlLine = sqlUtility("INSERT INTO " + ippTableName + "(")
    510517        sqlLine.group("diffImageID", str(diffSkyFileID))
    511518        sqlLine.group("magref",       magref)
    512519        sql = sqlLine.make(") VALUES ( ", ")")
    513            
    514520
    515521        try: self.scratchDb.execute(sql)
Note: See TracChangeset for help on using the changeset viewer.