IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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)
Note: See TracChangeset for help on using the changeset viewer.