IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34630


Ignore:
Timestamp:
Oct 31, 2012, 11:54:39 AM (14 years ago)
Author:
bills
Message:

Changes to PSPS table definitions for SA 10.
Detection tables contain all fluxes
Object table contains all magnitudes
Populate DetectionCalib and StackDetectinCalib

Location:
trunk/ippToPsps/jython
Files:
5 edited

Legend:

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

    r34615 r34630  
    452452               ,MOMENTS_XY \
    453453               ,MOMENTS_YY \
    454                ,AP_MAG \
     454               ,POW(10.0, -0.4 *AP_MAG) / " + self.header['EXPTIME'] + " \
    455455               ,KRON_FLUX / " + self.header['EXPTIME'] + " \
    456456               ,KRON_FLUX_ERR / " + self.header['EXPTIME'] + " \
     
    458458               ,PSF_CHISQ \
    459459               ,FLAGS2 << 32 | FLAGS\
    460                ,SKY \
    461                ,SKY_SIGMA \
     460               ,SKY  / " + self.header['EXPTIME'] + " \
     461               ,SKY_SIGMA  / " + self.header['EXPTIME'] + " \
    462462               ,EXT_NSIGMA \
    463463               , 0 \
     
    466466               , " + str(self.config.dataRelease) + "\
    467467               FROM " + ippTableName
    468         # SA10 todo
    469         # need to correct formulas for psfFlux/psfFluxErr
    470         # need to correct apMag apFlux
    471         # need to correct unites kronFlux/Err to correct units
    472         # need to change psfqfperfect -> psfqfperfect PSF_QF_PERFECT?
    473         # need to change psfchisq  PSF_CHI_SQ?
    474         # need to change unites of sky/skyErr to adu/s/pixel
    475         # need formula for sgsep/psflikelhood
    476468        # self.logger.info(sql)
    477469        self.scratchDb.execute(sql)
     
    557549               FROM Detection_" + ota
    558550        self.scratchDb.execute(sql)
    559         #SA10 TODO
    560         # insert ra/dec/calstuff into Table
    561         # heather discovered dec is called 'dec_'
    562         sql = "UPDATE " + tableName + " SET ra = -999, dec_ =-999, raErr = -999, decErr = -999, zp = -999, zpErr = -999, expTime = -999, airMass = -999"
     551
     552        # insert calibration information from dvoDetections into the Table
     553        sql = "UPDATE " + tableName + " AS a, "  + self.scratchDb.dvoDetectionTable + " AS b \
     554            SET a.ra = b.ra, \
     555            a.dec_ = b.dec_, \
     556            a.raErr = b.raErr, \
     557            a.decErr = b.decErr, \
     558            a.zp = b.zp, \
     559            a.zpErr = b.zpErr, \
     560            a.expTime = b.expTime, \
     561            a.airMass = b.airMass   \
     562            WHERE a.objID = b.objID AND a.detectID = b.detectID"
    563563        self.scratchDb.execute(sql)
    564564        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
  • trunk/ippToPsps/jython/dvodetections.py

    r33686 r34630  
    4444           self.importFits(
    4545                   cpmPath,
    46                    "IMAGE_ID DET_ID OBJ_ID CAT_ID EXT_ID DB_FLAGS",
     46                   "IMAGE_ID DET_ID OBJ_ID CAT_ID EXT_ID DB_FLAGS PHOTCODE AIRMASS M_TIME M_CAL MAG_CAL_ERR D_RA D_DEC PLTSCALE X_CCD_ERR Y_CCD_ERR",
    4747                   cpmTableName)
    4848
     
    5050           self.scratchDb.createIndex(cpmTableName, "CAT_ID")
    5151           self.scratchDb.createIndex(cpmTableName, "OBJ_ID")
     52
     53           # XXX: Should we create index on PHOTCODE?
    5254
    5355           # we can now report that we have imported this table
     
    6062       self.importFits(
    6163               cptPath,
    62                "OBJ_ID CAT_ID EXT_ID",
     64               "OBJ_ID CAT_ID EXT_ID RA DEC",
    6365               cptTableName)
    6466
     
    6769       self.scratchDb.createIndex(cptTableName, "OBJ_ID")
    6870
     71       # SA10
     72       # Columns needed for DetectionCalib and StackDetectionCalib
     73       # zp      = photcode.K * (AIRMASS - 1) + photcode.C_LAM * 0.001 - cpm.M_CAL
     74       # zpErr   = cpm.MAG_CAL_ERR
     75       # airMass = cpm.AIRMASS
     76       # expTime = POW(10.0, 0.4 * cpm.M_TIME)
     77       # ra      = cpt.RA  - (cpm.D_RA  / 3600.0)
     78       # dec     = cpt.DEC - (cpm.D_DEC / 3600.0)
     79       # raErr   = cpm.X_CCD_ERR * cpm.PLTSCALE
     80       # decErr  = cpm.Y_CCD_ERR * cpm.PLTSCALE
     81
    6982       self.logger.infoPair("Adding","PSPS objIDs")
    70        # first try to add a column for PSPS_OBJ_ID. catch failure and continue
     83       # first try to add the new columns. catch failure and continue
    7184       try:
    72            sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT)"
     85           sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT), (ZP REAL), (RA FLOAT), (DEC FLOAT)"
    7386           self.scratchDb.execute(sql)
    7487       except:
    7588           self.logger.infoPair("Already added PSPS_OBJ_ID column to", cpmTableName)
    7689               
    77        # shove PSPS objIDs from cpt table into measurement table
    78        sql = "UPDATE " + cpmTableName + " AS a, " + cptTableName + " AS b \
    79               SET a.PSPS_OBJ_ID = b.EXT_ID \
     90       # shove PSPS objIDs from cpt table and the calibrated zero point and coordinates which are formed
     91       # by combining values from multiple tables into cpt table
     92       sql = "UPDATE " + cpmTableName + " AS a, " + cptTableName + " AS b, " \
     93              + self.scratchDb.dvoPhotcodesTable + " AS c \
     94              SET a.PSPS_OBJ_ID = b.EXT_ID, \
     95              b.ZP  = c.C_LAM * 0.001 + c.K * (b.AIRMASS - 1) - b.M_CAL, \
     96              b.RA  = a.RA  - (b.D_RA  / 3600.0), \
     97              b.DEC = a.DEC - (b.D_DEC / 3600.0) \
    8098              WHERE a.CAT_ID = b.CAT_ID \
    81               AND a.OBJ_ID = b.OBJ_ID"
     99              AND a.OBJ_ID = b.OBJ_ID   \
     100              AND b.PHOTCODE = c.CODE"
     101
    82102       self.scratchDb.execute(sql)
    83103
     
    86106       # PSPS object IDs assigned in the corresponding cpt file. This is believed to be a chip-boundary
    87107       # issue within DVO. So, for now, we take the first IMAGE_ID/DET_ID detection we find, and ignore the rest
     108       # XXX: Bills 2012-10031 Does this problem still exist?
    88109       self.logger.infoPair("Merging into", self.scratchDb.dvoDetectionTable)
    89110       sql = "INSERT IGNORE INTO " + self.scratchDb.dvoDetectionTable + " (\
     
    94115              ,objID \
    95116              ,flags \
     117              ,zp   \
     118              ,zpErr    \
     119              ,airMass  \
     120              ,expTime  \
     121              ,ra   \
     122              ,dec_  \
     123              ,raErr    \
     124              ,decErr   \
    96125              ,fileID \
    97126              ) SELECT \
     
    102131              ,PSPS_OBJ_ID \
    103132              ,DB_FLAGS \
     133              ,ZP   \
     134              ,MAG_CAL_ERR  \
     135              ,AIRMASS  \
     136              ,POW(10.0, 0.4 * M_TIME)  \
     137              ,RA   \
     138              ,DEC  \
     139              ,X_CCD_ERR*PLTSCALE   \
     140              ,Y_CCD_ERR*PLTSCALE   \
    104141              , " + str(fileId) + " \
    105142              FROM " + cpmTableName
     143
    106144       try:
    107145           self.scratchDb.execute(sql)
  • trunk/ippToPsps/jython/objectbatch.py

    r34615 r34630  
    113113        self.logger.infoPair("Adding magnitudes from", "cps table")
    114114        for filter in filters:
     115
     116            filterID = self.scratchDb.getFilterID(filter[1])
    115117
    116118            sql = "UPDATE Object JOIN \
     
    129131                   ," + filter[1] + "80pct = MAG_80/1000 \
    130132                   ," + filter[1] + "Flags = FLAGS  \
    131                    ," + filter[1] + "StackDetectID = STACK_ID"
    132 
    133             #stackDetectID needs to be filled still for SA10 - currently at STACK_ID for test purposes
    134             # everthing should be correctly calculated as mags for SA10       
     133                   ," + filter[1] + "StackDetectID = (10 * STACK_DETECT_ID) + " + str(filterID)
     134
    135135            #self.logger.info(sql)
    136136            self.scratchDb.execute(sql)
  • trunk/ippToPsps/jython/scratchdb.py

    r34441 r34630  
    6868               DECLARE t REAL; \
    6969               DECLARE z REAL; \
     70               DECLARE s INT; \
     71               SET s= SIGN(x); \
    7072               SET x = ABS(x) / 1.4142135623731; \
    7173               SET z=ABS(x); \
     
    7577               SET ans = 2.0 - ans; \
    7678               END IF; \
     79               SET ans = ans * s; \
    7780               RETURN ans; \
    7881               END"
     
    385388               objID BIGINT, \
    386389               flags INT, \
     390               zp REAL,
     391               zpErr REAL,
     392               airMass REAL,
     393               expTime REAL,
     394               ra FLOAT,
     395               dec_ FLOAT,
     396               raErr REAL
     397               decErr REAL,
    387398               PRIMARY KEY (imageID, ippDetectID) \
    388399               )"
  • trunk/ippToPsps/jython/stackbatch.py

    r34615 r34630  
    197197        sql = "UPDATE StackModelFit AS a, SkyChip_xfit AS b SET \
    198198        "+model+"Radius=b.EXT_WIDTH_MAJ,  \
    199         "+model+"Flux=b.EXT_INST_MAG,  \
    200         "+model+"FluxErr=b.EXT_INST_MAG_SIG, \
     199        "+model+"Flux=POW(10, -0.4 * b.EXT_INST_MAG) " + str(self.expTime) " ,  \
     200        "+model+"FluxErr=ABS(b.EXT_INST_MAG_SIG) * POW(10, -0.4 * b.EXT_INST_MAG) " + str(self.expTime) " / 1.085736, \
    201201        "+model+"Ab=b.EXT_WIDTH_MAJ/b.EXT_WIDTH_MIN, \
    202202        "+model+"Phi=b.EXT_THETA,  \
     
    230230        "+modelLong+"Covar77=b.EXT_COVAR_06_06   \
    231231        WHERE a.ippDetectID=b.IPP_IDET AND b.MODEL_TYPE = '"+ippModelType+"'"
    232 
    233         #SA10 convert mag to flux in calculation above
    234232
    235233        self.scratchDb.execute(sql)
     
    369367               ,ABS((PSF_INST_MAG_SIG*(POW(10.0, (-0.4*PSF_INST_MAG)) / " + str(self.expTime) + ")) / 1.085736) \
    370368               ,POW(10.0, (-0.4*PEAK_FLUX_AS_MAG)) / " + str(self.expTime) + " \
    371                ,SKY \
    372                ,SKY_SIGMA \
     369               ,SKY / " + str(self.expTime) + " \
     370               ,SKY_SIGMA / " + str(self.expTime) + " \
    373371               ,EXT_NSIGMA \
    374372               ,PSF_MAJOR \
     
    388386               ,MOMENTS_R1 \
    389387               ,MOMENTS_RH \
    390                ,AP_MAG \
     388               ,POW(10.0, (-0.4*AP_MAG) / " + str(self.expTime) + " \
    391389               , NULL \
    392390               ,KRON_FLUX / " + str(self.expTime) + " \
     
    398396               ," + self.historyModNum + " \
    399397               FROM SkyChip_psf"
    400 
    401                #SA10 to do
    402                # put in correct formula for apFlux, psfFlux, psfLikelihood, sgsep
    403                # need correct units of anything in Flux
    404398        self.scratchDb.execute(sql)
    405399       
     
    481475        petRadius=b.PETRO_RADIUS \
    482476        ,petRadiusErr=b.PETRO_RADIUS_ERR \
    483         ,petFlux=b.PETRO_MAG \
    484         ,petFluxErr=b.PETRO_MAG_ERR \
     477        ,petFlux=POW(10.0, -0.4 * b.PETRO_MAG) /" + str(self.expTime) + " \
     478        ,petFluxErr=ABS((b.PETRO_MAG_ERR * POW(10.0, (-0.4*b.petroMag))) / " + str(self.expTime) + " / 1.085736 \
    485479        ,petR50=b.PETRO_RADIUS_50 \
    486480        ,petR50Err=b.PETRO_RADIUS_50_ERR \
     
    489483        ,petCf=b.PETRO_FILL \
    490484        WHERE a.ippDetectID=b.IPP_IDET"
    491         #SA10 Put correct calculation for PetFlux
    492485        self.scratchDb.execute(sql)
    493486
     
    620613        self.logger.info(sql)
    621614        self.scratchDb.execute(sql)
    622         #SA10 TODO
    623         # insert ra/dec/calstuff into Table
    624         # heather discovered dec is called 'dec_'
    625         sql = "UPDATE " + tableName + " SET ra = -999, dec_ =-999, raErr = -999, decErr = -999, zp = -999, zpErr = -999, expTime = -999, airMass = -999"
     615        # insert calibration information from dvoDetections into the Table
     616        sql = "UPDATE " + tableName + " AS a, "  + self.scratchDb.dvoDetectionTable + " AS b \
     617            SET a.ra = b.ra, \
     618            a.dec_ = b.dec_, \
     619            a.raErr = b.raErr, \
     620            a.decErr = b.decErr, \
     621            a.zp = b.zp, \
     622            a.zpErr = b.zpErr, \
     623            a.expTime = b.expTime, \
     624            a.airMass = b.airMass   \
     625            WHERE a.objID = b.objID AND a.detectID = b.detectID"
    626626        self.logger.info(sql)
    627627        self.scratchDb.execute(sql)
Note: See TracChangeset for help on using the changeset viewer.