IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 25, 2015, 2:29:26 PM (11 years ago)
Author:
eugene
Message:

add inst flux -> Jy conversions, add pixels -> arcsec conversions

File:
1 edited

Legend:

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

    r38771 r38775  
    413413        # XXX apFluxF or apFluxNpix + apFluxRadius?
    414414
     415        # EAM 20150925: the code below populates the mysql temporary smf table with
     416        # instrumental fluxes in counts/sec and calibrated sizes (arcsec).
     417        # below, we convert instrumental fluxes to Jy
     418
    415419        sqlLine.group("ippDetectID",     "IPP_IDET")                                               
    416 #        sqlLine.group("randomDetID",     "FLOOR(RAND("+str(self.batchID)+")*9223372036854775807)")                       
     420#       sqlLine.group("randomDetID",     "FLOOR(RAND("+str(self.batchID)+")*9223372036854775807)")                       
    417421        sqlLine.group("randomDetID",     "RAND("+str(self.batchID)+")")                       
    418422        sqlLine.group("filterID",        str(self.filterID))                                       
     
    437441        sqlLine.group("psfFluxErr",      "PSF_INST_FLUX_SIG / " + extTimeString)
    438442        if (self.id >= 982483):
    439             sqlLine.group("psfMajorFWHM",    "PSF_FWHM_MAJ")                                               
    440             sqlLine.group("psfMinorFWHM",    "PSF_FWHM_MIN")                                               
     443            sqlLine.group("psfMajorFWHM",    "PSF_FWHM_MAJ * abs(PLTSCALE)")                                               
     444            sqlLine.group("psfMinorFWHM",    "PSF_FWHM_MIN * abs(PLTSCALE)")                                               
    441445            sqlLine.group("psfCore",         "PSF_CORE")                                                   
    442446        sqlLine.group("psfTheta",        "PSF_THETA")                                               
     
    445449        sqlLine.group("psfChiSq",        "PSF_CHISQ")                                     
    446450        sqlLine.group("psfLikelihood",   "psfLikelihood(EXT_NSIGMA)")                               
    447         sqlLine.group("momentXX",        "MOMENTS_XX")                                             
    448         sqlLine.group("momentXY",        "MOMENTS_XY")                                             
    449         sqlLine.group("momentYY",        "MOMENTS_YY")                                             
    450         sqlLine.group("momentR1",        "MOMENTS_R1")                                             
    451         sqlLine.group("momentRH",        "MOMENTS_RH")                                             
    452         sqlLine.group("momentM3C",       "MOMENTS_M3C")                                             
    453         sqlLine.group("momentM3S",       "MOMENTS_M3S")                                             
    454         sqlLine.group("momentM4C",       "MOMENTS_M4C")                                             
    455         sqlLine.group("momentM4S",       "MOMENTS_M4S")                                             
     451        sqlLine.group("momentXX",        "MOMENTS_XX * PLTSCALE * PLTSCALE")                                             
     452        sqlLine.group("momentXY",        "MOMENTS_XY * PLTSCALE * PLTSCALE")                                             
     453        sqlLine.group("momentYY",        "MOMENTS_YY * PLTSCALE * PLTSCALE")                                             
     454        sqlLine.group("momentR1",        "MOMENTS_R1 * abs(PLTSCALE)")                                             
     455        sqlLine.group("momentRH",        "MOMENTS_RH * abs(PLTSCALE)")                                             
     456        sqlLine.group("momentM3C",       "MOMENTS_M3C * PLTSCALE * PLTSCALE")                                             
     457        sqlLine.group("momentM3S",       "MOMENTS_M3S * PLTSCALE * PLTSCALE")                                             
     458        sqlLine.group("momentM4C",       "MOMENTS_M4C * PLTSCALE * PLTSCALE")                                             
     459        sqlLine.group("momentM4S",       "MOMENTS_M4S * PLTSCALE * PLTSCALE")                                             
    456460        if (self.id >= 982483):
    457461            sqlLine.group("apFlux",          "AP_FLUX / " + extTimeString)
     
    479483        # something like (f < 0.0) ? -999 : -2.5*log10(f)
    480484        # as a result, the negative fluxes here result in floating point errors
    481         # XXX EAM 2014072 : Is this still a problem?
     485
     486        # XXX EAM 20140724 : Is this still a problem?
     487        # XXX EAM 20150925 : do this after inst flux -> Jy conversion?
     488
    482489        sql = "UPDATE " + pspsTableName + " SET psfFlux = 1e20 WHERE psfFlux <= 0.0"
    483490        try: self.scratchDb.execute(sql)
     
    674681    '''
    675682    def updateDvoIDs(self, table, externID):
    676         self.logger.info("getting imge id")
     683        self.logger.info("getting imageID")
    677684        imageID = self.scratchDb.getImageIDFromExternID(externID)
    678685        self.logger.info("Updating table '" + table + "' with DVO IDs using imageID = %d" % imageID)
     
    689696               a.airmass      = b.airmass, \
    690697               a.infoFlag3    = b.flags, \
    691                a.expTime      = b.expTime \
     698               a.expTime      = b.expTime, \
     699               a.psfFlux      = a.psfFlux     * b.zpFactor, \
     700               a.psfFluxErr   = a.psfFluxErr  * b.zpFactor, \
     701               a.apFlux       = a.apFlux      * b.zpFactor, \
     702               a.apFluxErr    = a.apFluxErr   * b.zpFactor, \
     703               a.kronFlux     = a.kronFlux    * b.zpFactor, \
     704               a.kronFluxErr  = a.kronFluxErr * b.zpFactor  \
    692705               WHERE a.ippDetectID = b.ippDetectID \
    693706               AND b.imageID = " + str(imageID)
     707
     708               ## a.psfFlux      = a.psfFlux * 3630.78 * POW(10.0, -0.4*b.zp), \
     709               ## a.psfFluxErr   = a.psfFluxErr * 3630.78 * POW(10.0, -0.4*b.zp), \
     710               ## a.apFlux       = a.apFlux * 3630.78 * POW(10.0, -0.4*b.zp), \
     711               ## a.apFluxErr    = a.apFluxErr * 3630.78 * POW(10.0, -0.4*b.zp), \
     712               ## a.kronFlux     = a.kronFlux * 3630.78 * POW(10.0, -0.4*b.zp), \
     713               ## a.kronFluxErr  = a.kronFluxErr * 3630.78 * POW(10.0, -0.4*b.zp) \
     714
     715        # instrumental flux vs Janskies:
     716        # b.ZP is defined to include the airmass term and zero point offset from relative calibration or ubercal
     717        # (see dvopsps/src/insert_detections_dvopsps_catalog.c:311
     718        # mag_AB = -2.5*log(flux_DN/sec) + ZP
     719        # flux_Jy = flux_cgs * 10^23
     720        # flux_cgs = ten(-0.4*(mag_AB + 48.6)) (~by definition, ~Vega flux in V-band)
     721        # flux_cgs = ten(-0.4*mag_AB - 19.44)
     722        # flux_cgs = ten(-0.4*mag_AB) * 3.63078e-20
     723        # flux_Jy  = ten(-0.4*mag_AB) * 3630.78
     724        # flux_Jy  = ten(-0.4*(-2.5*log(flux_DN/sec) + ZP)) * 3630.78
     725        # flux_Jy  = flux_DN/sec * ten(-0.4*ZP) * 3630.78
     726        # NOTE: update dvopsps to populate zpFactor = 3630.78 * ten(-0.4*zp)
    694727
    695728        print sql
Note: See TracChangeset for help on using the changeset viewer.