IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40281 for trunk


Ignore:
Timestamp:
Dec 12, 2017, 1:17:02 PM (9 years ago)
Author:
eugene
Message:

split zpImage into zpImagePSF, zpImageAPER; apply appropriate selection of zpImagePSF or zpImageAPER

File:
1 edited

Legend:

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

    r40215 r40281  
    307307
    308308        # zp correction should comes from DVO (unless image is not in DVO)
    309         zpImage = self.scratchDb.getImageZeroPoint(stackID)
    310 
    311         if (zpImage == "NULL"):
    312             zpImage = zp
     309        (zpImagePSF, zpImageAPER) = self.scratchDb.getStackZeroPoint(stackID)
     310
     311        # zp is the value in the header, zpImage includes the McalPSF value from DVO
     312        if (zpImagePSF  == "NULL"): zpImagePSF  = zp
     313        if (zpImageAPER == "NULL"): zpImageAPER = zpImagePSF
    313314
    314315        detectionThreshold = "NULL"
    315         if (magref != "NULL") and (zpImage != "NULL") and (expTime != "NULL"):
    316             detectionThreshold = magref + zpImage + 2.5 * math.log10(expTime)
     316        if (magref != "NULL") and (zpImagePSF != "NULL") and (expTime != "NULL"):
     317            detectionThreshold = magref + zpImagePSF + 2.5 * math.log10(expTime)
    317318
    318319        # insert stack metadata into table
     
    340341#       sqlLine.group("psfFwhm_max",        fwhm_maj_uq)
    341342        sqlLine.group("astroScat",          astroscat)
    342         sqlLine.group("photoZero",          zpImage)
     343        sqlLine.group("photoZero",          zpImagePSF)
     344        sqlLine.group("photoZeroAperture",  zpImageAPER)
    343345        sqlLine.group("photoScat",          zpErr)
    344346        sqlLine.group("nAstroRef",          header['NASTRO'])
     
    429431            sqlLine.group("a."+filter+"Epoch",         str(stackEpoch))
    430432
    431             sqlLine.group("a."+filter+"PSFMag",        "b.Mpsf")
     433            # the Mag values below are set in dvopsps/insert_detections_dvopsps_catalog.c using either zpPSF (PSFMag) or zpAPER (KronMag, ApMag)
     434            sqlLine.group("a."+filter+"PSFMag",        "b.Mpsf")
    432435            sqlLine.group("a."+filter+"PSFMagErr",     "b.dMpsf")
    433436            sqlLine.group("a."+filter+"KronMag",       "b.Mkron")
     
    557560            sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET")
    558561            sqlLine.group("a."+filter+"expTime",       "b.expTime")
    559             sqlLine.group("a."+filter+"zp",            "b.zp")
    560             sqlLine.group("a."+filter+"PSFFlux",       "a."+filter+"PSFFlux     * b.zpFactor")
    561             sqlLine.group("a."+filter+"PSFFluxErr",    "a."+filter+"PSFFluxErr  * b.zpFactor")
    562             sqlLine.group("a."+filter+"ApFlux",        "a."+filter+"ApFlux      * b.zpFactor")
    563             sqlLine.group("a."+filter+"ApFluxErr",     "a."+filter+"ApFluxErr   * b.zpFactor")
    564             sqlLine.group("a."+filter+"KronFlux",      "a."+filter+"KronFlux    * b.zpFactor")
    565             sqlLine.group("a."+filter+"KronFluxErr",   "a."+filter+"KronFluxErr * b.zpFactor")
    566 
    567             sqlLine.group("a."+filter+"sky",           "a."+filter+"sky         * b.zpFactor")
    568             sqlLine.group("a."+filter+"skyErr",        "a."+filter+"skyErr      * b.zpFactor")
     562            sqlLine.group("a."+filter+"zp",            "b.zpPSF")
     563            sqlLine.group("a."+filter+"zpAPER",        "b.zpAPER")
     564            sqlLine.group("a."+filter+"PSFFlux",       "a."+filter+"PSFFlux     * b.zpFactorPSF")
     565            sqlLine.group("a."+filter+"PSFFluxErr",    "a."+filter+"PSFFluxErr  * b.zpFactorPSF")
     566            sqlLine.group("a."+filter+"ApFlux",        "a."+filter+"ApFlux      * b.zpFactorAPER")
     567            sqlLine.group("a."+filter+"ApFluxErr",     "a."+filter+"ApFluxErr   * b.zpFactorAPER")
     568            sqlLine.group("a."+filter+"KronFlux",      "a."+filter+"KronFlux    * b.zpFactorAPER")
     569            sqlLine.group("a."+filter+"KronFluxErr",   "a."+filter+"KronFluxErr * b.zpFactorAPER")
     570
     571            sqlLine.group("a."+filter+"sky",           "a."+filter+"sky         * b.zpFactorAPER")
     572            sqlLine.group("a."+filter+"skyErr",        "a."+filter+"skyErr      * b.zpFactorAPER")
    569573
    570574            # where should these go?
     
    700704        imageID = self.imageIDs[filter]
    701705        self.logger.infoPair("selecting imageID", imageID)
     706
     707        # NOTE: for model magnitudes, we use zpPSF not zpAPER since they are PSF-matched
     708        # (maybe that is the wrong solution?)
    702709
    703710        # model calibrated magnitude = instrumental magnitude + 2.5*log10(exptime) + ZP (added below from dvoDetectionTable)
     
    765772        sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET")
    766773
    767         sqlLine.group("a." + filter + model + "Mag",       "a." + filter + model + "Mag       + b.zp")
     774        sqlLine.group("a." + filter + model + "Mag",       "a." + filter + model + "Mag       + b.zpPSF")
    768775
    769776        sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID))
     
    884891        # PETRO_MAG is instrumental + 2.5log(exptime) + FPA.ZP
    885892        # we want to apply the DVO zero point, so remove FPA.ZP:
    886         ## XXX is this statement true: is FPA.ZP + 2.5log(exptime) applied to PETRO_MAG?
    887893
    888894        hdrZP   = str(self.zpImage[filter])
     
    897903        sqlLine.group("a."+filter+"haveData",         "'1'")
    898904
    899         sqlLine.group("a." + filter + "petMag",       "b.PETRO_MAG - " + hdrZP)  
     905        sqlLine.group("a." + filter + "petMag",       "b.PETRO_MAG - " + hdrZP) # note that this is **subtracting** the hdrZP (zpAPER is added in below)
    900906        sqlLine.group("a." + filter + "petMagErr",    "1.0 / b.PETRO_MAG_ERR")  # still inverted? (yes)
    901907
     
    913919        # modify petMag to apply the zero point
    914920        sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET")
    915         sqlLine.group("a." + filter + "petMag",       "a." + filter + "petMag    + b.zp")
     921        sqlLine.group("a." + filter + "petMag",       "a." + filter + "petMag    + b.zpAPER")
    916922        sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID))
    917923
     
    10191025        # care of this, but does not?
    10201026
    1021 #chopping this out to see if it still works
     1027        # chopping this out to see if it still works
    10221028
    10231029        #sqlLine = sqlUtility("UPDATE " + tablename + " SET")
     
    10321038
    10331039        #sql = sqlLine.makeEquals("")
    1034        
    1035 #        try: self.scratchDb.execute(sql)
    1036 #        except:
    1037 #            self.logger.errorPair('failed sql',sql)
    1038 #            raise
     1040         
     1041        #        try: self.scratchDb.execute(sql)
     1042        #        except:
     1043        #            self.logger.errorPair('failed sql',sql)
     1044        #            raise
    10391045
    10401046        # set the flux values from the cmf file
     
    11121118            pspsNum  = str(int(number) + 2)
    11131119            field = filter + prefix + "flxR" + pspsNum
    1114             sqlLine.group(field,               field         + " * b.zpFactor")
    1115             sqlLine.group(field + "Err",       field + "err" + " * b.zpFactor")
    1116             sqlLine.group(field + "Std",       field + "Std" + " * b.zpFactor")
     1120            sqlLine.group(field,               field         + " * b.zpFactorAPER")
     1121            sqlLine.group(field + "Err",       field + "err" + " * b.zpFactorAPER")
     1122            sqlLine.group(field + "Std",       field + "Std" + " * b.zpFactorAPER")
    11171123
    11181124        sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID))
     
    11221128            self.logger.infoPair("failed sql",sql)
    11231129            raise
     1130
    11241131    '''
    11251132    Populates the StackToImage table
Note: See TracChangeset for help on using the changeset viewer.