IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 27, 2018, 3:31:55 PM (8 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/czw_branch/20170908
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20170908

  • branches/czw_branch/20170908/ippToPsps/jython/stackbatch.py

    r39764 r40483  
    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")
     
    440443         
    441444            sqlLine.group("a."+filter+"infoFlag3",     "b.flags")
     445            sqlLine.group("a."+filter+"infoFlag4",     "b.filtflags")
    442446            sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID))
    443447
     
    557561            sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET")
    558562            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")
     563            sqlLine.group("a."+filter+"zp",            "b.zpPSF")
     564            sqlLine.group("a."+filter+"zpAPER",        "b.zpAPER")
     565            sqlLine.group("a."+filter+"PSFFlux",       "a."+filter+"PSFFlux     * b.zpFactorPSF")
     566            sqlLine.group("a."+filter+"PSFFluxErr",    "a."+filter+"PSFFluxErr  * b.zpFactorPSF")
     567            sqlLine.group("a."+filter+"ApFlux",        "a."+filter+"ApFlux      * b.zpFactorAPER")
     568            sqlLine.group("a."+filter+"ApFluxErr",     "a."+filter+"ApFluxErr   * b.zpFactorAPER")
     569            sqlLine.group("a."+filter+"KronFlux",      "a."+filter+"KronFlux    * b.zpFactorAPER")
     570            sqlLine.group("a."+filter+"KronFluxErr",   "a."+filter+"KronFluxErr * b.zpFactorAPER")
     571
     572            sqlLine.group("a."+filter+"sky",           "a."+filter+"sky         * b.zpFactorAPER")
     573            sqlLine.group("a."+filter+"skyErr",        "a."+filter+"skyErr      * b.zpFactorAPER")
    569574
    570575            # where should these go?
     
    700705        imageID = self.imageIDs[filter]
    701706        self.logger.infoPair("selecting imageID", imageID)
     707
     708        # NOTE: for model magnitudes, we use zpPSF not zpAPER since they are PSF-matched
     709        # (maybe that is the wrong solution?)
    702710
    703711        # model calibrated magnitude = instrumental magnitude + 2.5*log10(exptime) + ZP (added below from dvoDetectionTable)
     
    765773        sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET")
    766774
    767         sqlLine.group("a." + filter + model + "Mag",       "a." + filter + model + "Mag       + b.zp")
     775        sqlLine.group("a." + filter + model + "Mag",       "a." + filter + model + "Mag       + b.zpPSF")
    768776
    769777        sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID))
     
    884892        # PETRO_MAG is instrumental + 2.5log(exptime) + FPA.ZP
    885893        # 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?
    887894
    888895        hdrZP   = str(self.zpImage[filter])
     
    897904        sqlLine.group("a."+filter+"haveData",         "'1'")
    898905
    899         sqlLine.group("a." + filter + "petMag",       "b.PETRO_MAG - " + hdrZP)  
     906        sqlLine.group("a." + filter + "petMag",       "b.PETRO_MAG - " + hdrZP) # note that this is **subtracting** the hdrZP (zpAPER is added in below)
    900907        sqlLine.group("a." + filter + "petMagErr",    "1.0 / b.PETRO_MAG_ERR")  # still inverted? (yes)
    901908
     
    913920        # modify petMag to apply the zero point
    914921        sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET")
    915         sqlLine.group("a." + filter + "petMag",       "a." + filter + "petMag    + b.zp")
     922        sqlLine.group("a." + filter + "petMag",       "a." + filter + "petMag    + b.zpAPER")
    916923        sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID))
    917924
     
    10191026        # care of this, but does not?
    10201027
    1021         sqlLine = sqlUtility("UPDATE " + tablename + " SET")
    1022         for radius in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
    1023             if radius < minRadius: continue
    1024             if radius > maxRadius: continue
    1025             pspsRadius = radius + 2
    1026             sqlLine.group(filter + prefix + "flxR" + str(pspsRadius),          "-999")
    1027             sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Err",  "-999")
    1028             sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Std",  "-999")
    1029             sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Fill", "-999")
    1030 
    1031         sql = sqlLine.makeEquals("")
    1032        
    1033         try: self.scratchDb.execute(sql)
    1034         except:
    1035             self.logger.errorPair('failed sql',sql)
    1036             raise
     1028        # chopping this out to see if it still works
     1029
     1030        #sqlLine = sqlUtility("UPDATE " + tablename + " SET")
     1031        #for radius in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
     1032        #    if radius < minRadius: continue
     1033        #    if radius > maxRadius: continue
     1034        #    pspsRadius = radius + 2
     1035        #    sqlLine.group(filter + prefix + "flxR" + str(pspsRadius),          "-999")
     1036        #    sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Err",  "-999")
     1037        #    sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Std",  "-999")
     1038        #    sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Fill", "-999")#
     1039
     1040        #sql = sqlLine.makeEquals("")
     1041         
     1042        #        try: self.scratchDb.execute(sql)
     1043        #        except:
     1044        #            self.logger.errorPair('failed sql',sql)
     1045        #            raise
    10371046
    10381047        # set the flux values from the cmf file
     
    11101119            pspsNum  = str(int(number) + 2)
    11111120            field = filter + prefix + "flxR" + pspsNum
    1112             sqlLine.group(field,               field         + " * b.zpFactor")
    1113             sqlLine.group(field + "Err",       field + "err" + " * b.zpFactor")
    1114             sqlLine.group(field + "Std",       field + "Std" + " * b.zpFactor")
     1121            sqlLine.group(field,               field         + " * b.zpFactorAPER")
     1122            sqlLine.group(field + "Err",       field + "err" + " * b.zpFactorAPER")
     1123            sqlLine.group(field + "Std",       field + "Std" + " * b.zpFactorAPER")
    11151124
    11161125        sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID))
     
    11201129            self.logger.infoPair("failed sql",sql)
    11211130            raise
     1131
    11221132    '''
    11231133    Populates the StackToImage table
Note: See TracChangeset for help on using the changeset viewer.