IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34949


Ignore:
Timestamp:
Jan 17, 2013, 6:11:44 AM (14 years ago)
Author:
eugene
Message:

fix alter table sql (need "add column" before each new entry), fix update sql (mixed up ave and meas, renamed a & b to ave & meas for clarify), replace DEC with DEC_ in sql

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/dvodetections.py

    r34630 r34949  
    8383       # first try to add the new columns. catch failure and continue
    8484       try:
    85            sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT), (ZP REAL), (RA FLOAT), (DEC FLOAT)"
     85           sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT), ADD COLUMN (ZP REAL), ADD COLUMN (RA FLOAT), ADD COLUMN (DEC_ FLOAT)"
    8686           self.scratchDb.execute(sql)
    8787       except:
    88            self.logger.infoPair("Already added PSPS_OBJ_ID column to", cpmTableName)
     88           # failed, but may be due to mysql error
     89           self.logger.infoPair("mysql error or already added PSPS_OBJ_ID column to", cpmTableName)
     90           # self.logger.infoPair("sql command", sql)
    8991               
    9092       # shove PSPS objIDs from cpt table and the calibrated zero point and coordinates which are formed
    9193       # 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) \
    98               WHERE a.CAT_ID = b.CAT_ID \
    99               AND a.OBJ_ID = b.OBJ_ID   \
    100               AND b.PHOTCODE = c.CODE"
     94       sql = "UPDATE " \
     95              + cpmTableName + " AS meas, " \
     96              + cptTableName + " AS ave, " \
     97              + self.scratchDb.dvoPhotcodesTable + " AS phot \
     98              SET \
     99              meas.PSPS_OBJ_ID = ave.EXT_ID, \
     100              meas.ZP  = phot.C_LAM * 0.001 + phot.K * (meas.AIRMASS - 1) - meas.M_CAL, \
     101              meas.RA  = ave.RA  - (meas.D_RA  / 3600.0), \
     102              meas.DEC_ = ave.DEC_ - (meas.D_DEC / 3600.0) \
     103              WHERE meas.CAT_ID = ave.CAT_ID \
     104              AND meas.OBJ_ID = ave.OBJ_ID   \
     105              AND meas.PHOTCODE = phot.CODE"
    101106
     107       self.logger.infoPair("sql command", sql)
    102108       self.scratchDb.execute(sql)
    103109
     
    136142              ,POW(10.0, 0.4 * M_TIME)  \
    137143              ,RA   \
    138               ,DEC  \
     144              ,DEC_  \
    139145              ,X_CCD_ERR*PLTSCALE   \
    140146              ,Y_CCD_ERR*PLTSCALE   \
Note: See TracChangeset for help on using the changeset viewer.