IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 28, 2014, 6:20:27 AM (12 years ago)
Author:
eugene
Message:

dropping options for stilts dvo import methods; fixing a number of previously ignored errors (eg, dropping non-existent tables); allowing queue questions to strip leading and trailing spaces (so we can read from an input file); echo back the response so input from a file is clearer; re-write big sql blocks with new sql utility code; updating names in MeanObject, ObjectThin to be more consistent; add a new test code program; update detection fields to match new schema; drop the code for the old now-unused tables (detecitonCalib, SkinnyObject, etc)

Location:
branches/eam_branches/ipp-20140717/ippToPsps
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140717/ippToPsps

  • branches/eam_branches/ipp-20140717/ippToPsps/jython/Makefile.am

    r36815 r37129  
    2222  gpc1db.py \
    2323  initbatch.py \
    24   insert.dvodb.info.py \       
     24  insert.dvodb.info.py \
    2525  ipptopspsdb.py \
    2626  ipptopsps.py \
     
    3535  pslogger.py \
    3636  queue.py \
    37   removepending.py \ 
     37  removepending.py \
    3838  scratchdb.py \
    3939  setupScratchDb.py \
    4040  skychunk.py \
     41  sqlUtility.py \
    4142  stackbatch.py
    4243
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py

    r36726 r37129  
    3737                 batchID,
    3838                 batchType,
    39                  fits,
    40                  useFullTables):
     39                 fits):
    4140
    4241        # print "starting the batch"
     
    4948        self.skychunk = skychunk
    5049        self.fits = fits
    51         self.useFullTables = useFullTables
    5250
    5351        # set up logging
     
    7977                raise
    8078
    81         self.scratchDb.setUseFullTables(self.useFullTables)
     79        # define the dvo table names
     80        self.scratchDb.setDvoTableNames()
    8281
    8382        # TODO
     
    113112        self.dateStr = now.strftime("%Y-%m-%d")
    114113
    115         # create DVO tables if accessing DVO directly
    116         if not self.useFullTables: self.scratchDb.createDvoTables()
     114        # create DVO tables (scratch database)
     115        self.scratchDb.createDvoTables()
    117116
    118117        # dump stuff to the log
     
    120119        self.logger.infoPair("Batch name", self.batchName)
    121120        self.logger.infoPair("Survey ID", "%d" % self.surveyID)
    122         self.logger.infoBool("Use full DVO tables?", self.useFullTables)
    123121
    124122        if self.fits:
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py

    r36744 r37129  
    1919from ipptopspsdb import IppToPspsDb
    2020from scratchdb import ScratchDb
     21from sqlUtility import sqlUtility
    2122
    2223import logging.config
     
    4142                 scratchDb,
    4243                 camID,
    43                  batchID,
    44                  useFullTables):
     44                 batchID):
    4545
    4646       super(DetectionBatch, self).__init__(
     
    5454               batchID,
    5555               "P2",
    56                gpc1Db.getCameraStageSmf(camID,skychunk.P2_smf_version),
    57                useFullTables)
     56               gpc1Db.getCameraStageSmf(camID,skychunk.P2_smf_version))
    5857
    5958       # get camera meta data
     
    124123        self.logger.infoPair("Proccesing table", "FrameMeta")
    125124
    126         sql = "INSERT INTO FrameMeta (\
    127           frameID \
    128          ,frameName \
    129          ,cameraID \
    130          ,cameraConfigID \
    131          ,telescopeID \
    132          ,analysisVer \
    133          ,p1Recip \
    134          ,p2Recip \
    135          ,p3Recip \
    136          ,photoScat \
    137          ,expStart \
    138          ,expTime \
    139          ,airmass \
    140          ,raBore \
    141          ,decBore \
    142          ,ctype1 \
    143          ,ctype2 \
    144          ,crval1 \
    145          ,crval2 \
    146          ,crpix1 \
    147          ,crpix2 \
    148          ,cdelt1 \
    149          ,cdelt2 \
    150          ,pc001001 \
    151          ,pc001002 \
    152          ,pc002001 \
    153          ,pc002002 \
    154          ,polyOrder \
    155          ,pca1x3y0 \
    156          ,pca1x2y1 \
    157          ,pca1x1y2 \
    158          ,pca1x0y3 \
    159          ,pca1x2y0 \
    160          ,pca1x1y1 \
    161          ,pca1x0y2 \
    162          ,pca2x3y0 \
    163          ,pca2x2y1 \
    164          ,pca2x1y2 \
    165          ,pca2x0y3 \
    166          ,pca2x2y0 \
    167          ,pca2x1y1 \
    168          ,pca2x0y2 \
    169          ) VALUES ( \
    170         " + str(self.expID) + " \
    171         ,'" + self.expName + "' \
    172         ,1  \
    173         ,1  \
    174         ,1  \
    175         ,'" + str(self.analysisVer) + "' \
    176         ,' ' \
    177         ,' ' \
    178         ,' ' \
    179         ," + self.safeDictionaryAccess(self.header, 'ZPT_ERR') + " \
    180         ," + self.safeDictionaryAccess(self.header, 'MJD-OBS') + " \
    181         ," + self.safeDictionaryAccess(self.header, 'EXPREQ') + " \
    182         ," + self.safeDictionaryAccess(self.header, 'AIRMASS') + " \
    183         ," + self.safeDictionaryAccess(self.header, 'RA') + " \
    184         ," + self.safeDictionaryAccess(self.header, 'DEC') + " \
    185         ,'" + self.safeDictionaryAccess(self.header, 'CTYPE1') + "' \
    186         ,'" + self.safeDictionaryAccess(self.header, 'CTYPE2') + "' \
    187         ," + self.safeDictionaryAccess(self.header, 'CRVAL1') + " \
    188         ," + self.safeDictionaryAccess(self.header, 'CRVAL2') + " \
    189         ," + self.safeDictionaryAccess(self.header, 'CRPIX1') + " \
    190         ," + self.safeDictionaryAccess(self.header, 'CRPIX2') + " \
    191         ," + self.safeDictionaryAccess(self.header, 'CDELT1') + " \
    192         ," + self.safeDictionaryAccess(self.header, 'CDELT2') + " \
    193         ," + self.safeDictionaryAccess(self.header, 'PC001001') + " \
    194         ," + self.safeDictionaryAccess(self.header, 'PC001002') + " \
    195         ," + self.safeDictionaryAccess(self.header, 'PC002001') + " \
    196         ," + self.safeDictionaryAccess(self.header, 'PC002002') + " \
    197         ," + self.safeDictionaryAccess(self.header, 'NPLYTERM') + " \
    198         ," + self.safeDictionaryAccess(self.header, 'PCA1X3Y0') + " \
    199         ," + self.safeDictionaryAccess(self.header, 'PCA1X2Y1') + " \
    200         ," + self.safeDictionaryAccess(self.header, 'PCA1X1Y2') + " \
    201         ," + self.safeDictionaryAccess(self.header, 'PCA1X0Y3') + " \
    202         ," + self.safeDictionaryAccess(self.header, 'PCA1X2Y0') + " \
    203         ," + self.safeDictionaryAccess(self.header, 'PCA1X1Y1') + " \
    204         ," + self.safeDictionaryAccess(self.header, 'PCA1X0Y2') + " \
    205         ," + self.safeDictionaryAccess(self.header, 'PCA2X3Y0') + " \
    206         ," + self.safeDictionaryAccess(self.header, 'PCA2X2Y1') + " \
    207         ," + self.safeDictionaryAccess(self.header, 'PCA2X1Y2') + " \
    208         ," + self.safeDictionaryAccess(self.header, 'PCA2X0Y3') + " \
    209         ," + self.safeDictionaryAccess(self.header, 'PCA2X2Y0') + " \
    210         ," + self.safeDictionaryAccess(self.header, 'PCA2X1Y1') + " \
    211         ," + self.safeDictionaryAccess(self.header, 'PCA2X0Y2') + " \
    212         )"
    213 
    214         # print "frame meta sql: ", sql
     125        sqlLine = sqlUtility("INSERT INTO FrameMeta (")
     126
     127        sqlLine.group("frameID",               str(self.expID));
     128        sqlLine.group("frameName",             self.expName);
     129        sqlLine.group("cameraID",              "1");
     130        sqlLine.group("cameraConfigID",        "1");
     131        sqlLine.group("telescopeID",           "1");
     132        sqlLine.group("analysisVer",           str(self.analysisVer));
     133        sqlLine.group("p1Recip",               " ");
     134        sqlLine.group("p2Recip",               " ");
     135        sqlLine.group("p3Recip",               " ");
     136        sqlLine.group("photoScat",             "self.safeDictionaryAccess(self.header, 'ZPT_ERR')");
     137        sqlLine.group("expStart",              "self.safeDictionaryAccess(self.header, 'MJD-OBS')");
     138        sqlLine.group("expTime",               "self.safeDictionaryAccess(self.header, 'EXPREQ')");
     139        sqlLine.group("airmass",               "self.safeDictionaryAccess(self.header, 'AIRMASS')");
     140        sqlLine.group("raBore",                "self.safeDictionaryAccess(self.header, 'RA')");
     141        sqlLine.group("decBore",               "self.safeDictionaryAccess(self.header, 'DEC')");
     142        sqlLine.group("ctype1",                self.safeDictionaryAccess(self.header, 'CTYPE1'));
     143        sqlLine.group("ctype2",                self.safeDictionaryAccess(self.header, 'CTYPE2'));
     144        sqlLine.group("crval1",                "self.safeDictionaryAccess(self.header, 'CRVAL1')");
     145        sqlLine.group("crval2",                "self.safeDictionaryAccess(self.header, 'CRVAL2')");
     146        sqlLine.group("crpix1",                "self.safeDictionaryAccess(self.header, 'CRPIX1')");
     147        sqlLine.group("crpix2",                "self.safeDictionaryAccess(self.header, 'CRPIX2')");
     148        sqlLine.group("cdelt1",                "self.safeDictionaryAccess(self.header, 'CDELT1')");
     149        sqlLine.group("cdelt2",                "self.safeDictionaryAccess(self.header, 'CDELT2')");
     150        sqlLine.group("pc001001",              "self.safeDictionaryAccess(self.header, 'PC001001')");
     151        sqlLine.group("pc001002",              "self.safeDictionaryAccess(self.header, 'PC001002')");
     152        sqlLine.group("pc002001",              "self.safeDictionaryAccess(self.header, 'PC002001')");
     153        sqlLine.group("pc002002",              "self.safeDictionaryAccess(self.header, 'PC002002')");
     154        sqlLine.group("polyOrder",             "self.safeDictionaryAccess(self.header, 'NPLYTERM')");
     155        sqlLine.group("pca1x3y0",              "self.safeDictionaryAccess(self.header, 'PCA1X3Y0')");
     156        sqlLine.group("pca1x2y1",              "self.safeDictionaryAccess(self.header, 'PCA1X2Y1')");
     157        sqlLine.group("pca1x1y2",              "self.safeDictionaryAccess(self.header, 'PCA1X1Y2')");
     158        sqlLine.group("pca1x0y3",              "self.safeDictionaryAccess(self.header, 'PCA1X0Y3')");
     159        sqlLine.group("pca1x2y0",              "self.safeDictionaryAccess(self.header, 'PCA1X2Y0')");
     160        sqlLine.group("pca1x1y1",              "self.safeDictionaryAccess(self.header, 'PCA1X1Y1')");
     161        sqlLine.group("pca1x0y2",              "self.safeDictionaryAccess(self.header, 'PCA1X0Y2')");
     162        sqlLine.group("pca2x3y0",              "self.safeDictionaryAccess(self.header, 'PCA2X3Y0')");
     163        sqlLine.group("pca2x2y1",              "self.safeDictionaryAccess(self.header, 'PCA2X2Y1')");
     164        sqlLine.group("pca2x1y2",              "self.safeDictionaryAccess(self.header, 'PCA2X1Y2')");
     165        sqlLine.group("pca2x0y3",              "self.safeDictionaryAccess(self.header, 'PCA2X0Y3')");
     166        sqlLine.group("pca2x2y0",              "self.safeDictionaryAccess(self.header, 'PCA2X2Y0')");
     167        sqlLine.group("pca2x1y1",              "self.safeDictionaryAccess(self.header, 'PCA2X1Y1')");
     168        sqlLine.group("pca2x0y2",              "self.safeDictionaryAccess(self.header, 'PCA2X0Y2')");
     169
     170        sql = sqlLine.make(") VALUES ( ", ")")
     171        print "frame meta sql: ", sql
    215172
    216173        self.scratchDb.execute(sql)
     
    228185        tableName = "ImageMeta_" + ota
    229186       
    230         # XXX we drop the table above so it is not left behind on failure
    231         # drop then re-create table
    232         # self.scratchDb.dropTable(tableName)
     187        # we drop the table before calling this functoin so it is not left behind on failure
    233188        sql = "CREATE TABLE " + tableName + " LIKE ImageMeta"
    234189        try: self.scratchDb.execute(sql)
    235190        except: pass
     191
    236192        if (ota[0:2] == "XY"): ccdID = ota[2:4]
    237193        else: ccdID = 0
    238194
     195        psfFwhm = 0.5*(self.safeDictionaryAccess(header, 'FWHM_MAJ') + self.safeDictionaryAccess(header, 'FWHM_MIN'))
     196
    239197        # insert image metadata into table
    240         sql = "INSERT INTO " + tableName + " ( \
    241                frameID \
    242                ,ccdID \
    243                ,bias \
    244                ,biasScat \
    245                ,sky \
    246                ,skyScat \
    247                ,magSat \
    248                ,completMag \
    249                ,astroScat \
    250                ,photoScat \
    251                ,numAstroRef \
    252                ,numPhotoRef \
    253                ,nx \
    254                ,ny \
    255                ,psfFwhm \
    256                ,psfWidMajor \
    257                ,psfWidMinor \
    258                ,psfTheta \
    259                ,momentXX \
    260                ,momentXY \
    261                ,momentYY \
    262                ,momentM3C \
    263                ,momentM3S \
    264                ,momentM4C \
    265                ,momentM4S \
    266                ,momentR1 \
    267                ,momentRH \
    268                ,apResid \
    269                ,dapResid \
    270                ,detectorID \
    271                ,qaFlags \
    272                ,detrend1 \
    273                ,detrend2 \
    274                ,detrend3 \
    275                ,detrend4 \
    276                ,detrend5 \
    277                ,detrend6 \
    278                ,detrend7 \
    279                ,detrend8 \
    280                ,photoZero \
    281                ,ctype1 \
    282                ,ctype2 \
    283                ,crval1 \
    284                ,crval2 \
    285                ,crpix1 \
    286                ,crpix2 \
    287                ,cdelt1 \
    288                ,cdelt2 \
    289                ,pc001001 \
    290                ,pc001002 \
    291                ,pc002001 \
    292                ,pc002002 \
    293                ,polyOrder \
    294                ,pca1x3y0 \
    295                ,pca1x2y1 \
    296                ,pca1x1y2 \
    297                ,pca1x0y3 \
    298                ,pca1x2y0 \
    299                ,pca1x1y1 \
    300                ,pca1x0y2 \
    301                ,pca2x3y0 \
    302                ,pca2x2y1 \
    303                ,pca2x1y2 \
    304                ,pca2x0y3 \
    305                ,pca2x2y0 \
    306                ,pca2x1y1 \
    307                ,pca2x0y2 \
    308                ) VALUES ( \
    309                " + str(self.expID) + " \
    310                ," + str(ccdID) + " \
    311                ," + str(self.bias) + " \
    312                ," + str(self.biasScat) + " \
    313                ," + self.safeDictionaryAccess(header, 'MSKY_MN') + " \
    314                ," + self.safeDictionaryAccess(header, 'MSKY_SIG') + " \
    315                ," + self.safeDictionaryAccess(header, 'FSATUR') + " \
    316                ," + self.safeDictionaryAccess(header, 'FLIMIT') + " \
    317                ," + self.safeDictionaryAccess(header, 'CERROR') + " \
    318                ," + self.safeDictionaryAccess(self.header, 'ZPT_OBS') + " \
    319                ," + self.safeDictionaryAccess(header, 'NASTRO') + " \
    320                ," + self.safeDictionaryAccess(header, 'NASTRO') + " \
    321                ," + self.safeDictionaryAccess(header, 'CNAXIS1') + " \
    322                ," + self.safeDictionaryAccess(header, 'CNAXIS2') + " \
    323                , ( " + self.safeDictionaryAccess(header, 'FWHM_MAJ') + " + " + self.safeDictionaryAccess(header, 'FWHM_MIN') + " ) / 2.0 \
    324                ," + self.safeDictionaryAccess(header, 'FWHM_MAJ') + " \
    325                ," + self.safeDictionaryAccess(header, 'FWHM_MIN') + " \
    326                ," + self.safeDictionaryAccess(header, 'ANGLE') + " \
    327                ,-999 \
    328                ,-999 \
    329                ,-999 \
    330                ,-999 \
    331                ,-999 \
    332                ,-999 \
    333                ,-999 \
    334                ,-999 \
    335                ,-999 \
    336                ," + self.safeDictionaryAccess(header, 'APMIFIT') + " \
    337                ," + self.safeDictionaryAccess(header, 'DAPMIFIT') + " \
    338                ,'" + self.safeDictionaryAccess(header, 'DETECTOR') + "' \
    339                ," + str(self.scratchDb.getDvoImageFlags(header['IMAGEID'])) + " \
    340                ,'" + self.safeDictionaryAccess(header, 'DETREND.MASK') + "' \
    341                ,'" + self.safeDictionaryAccess(header, 'DETREND.DARK') + "' \
    342                ,'" + self.safeDictionaryAccess(header, 'DETREND.FLAT') + "' \
    343                ,' ' \
    344                ,' ' \
    345                ,' ' \
    346                ,' ' \
    347                ,' ' \
    348                ," + self.safeDictionaryAccess(self.header, 'ZPT_OBS') + " \
    349                ,'" + self.safeDictionaryAccess(header, 'CTYPE1') + "' \
    350                ,'" + self.safeDictionaryAccess(header, 'CTYPE2') + "' \
    351                ," + self.safeDictionaryAccess(header, 'CRVAL1') + " \
    352                ," + self.safeDictionaryAccess(header, 'CRVAL2') + " \
    353                ," + self.safeDictionaryAccess(header, 'CRPIX1') + " \
    354                ," + self.safeDictionaryAccess(header, 'CRPIX2') + " \
    355                ," + self.safeDictionaryAccess(header, 'CDELT1') + " \
    356                ," + self.safeDictionaryAccess(header, 'CDELT2') + " \
    357                ," + self.safeDictionaryAccess(header, 'PC001001') + " \
    358                ," + self.safeDictionaryAccess(header, 'PC001002') + " \
    359                ," + self.safeDictionaryAccess(header, 'PC002001') + " \
    360                ," + self.safeDictionaryAccess(header, 'PC002002') + " \
    361                ," + self.safeDictionaryAccess(header, 'NPLYTERM') + " \
    362                ," + self.safeDictionaryAccess(header, 'PCA1X3Y0') + " \
    363                ," + self.safeDictionaryAccess(header, 'PCA1X2Y1') + " \
    364                ," + self.safeDictionaryAccess(header, 'PCA1X1Y2') + " \
    365                ," + self.safeDictionaryAccess(header, 'PCA1X0Y3') + " \
    366                ," + self.safeDictionaryAccess(header, 'PCA1X2Y0') + " \
    367                ," + self.safeDictionaryAccess(header, 'PCA1X1Y1') + " \
    368                ," + self.safeDictionaryAccess(header, 'PCA1X0Y2') + " \
    369                ," + self.safeDictionaryAccess(header, 'PCA2X3Y0') + " \
    370                ," + self.safeDictionaryAccess(header, 'PCA2X2Y1') + " \
    371                ," + self.safeDictionaryAccess(header, 'PCA2X1Y2') + " \
    372                ," + self.safeDictionaryAccess(header, 'PCA2X0Y3') + " \
    373                ," + self.safeDictionaryAccess(header, 'PCA2X2Y0') + " \
    374                ," + self.safeDictionaryAccess(header, 'PCA2X1Y1') + " \
    375                ," + self.safeDictionaryAccess(header, 'PCA2X0Y2') + " \
    376                )"
     198        sqlLine = sqlUtility("INSERT INTO " + tableName + "(")
     199
     200        sqlLine.group("frameID",          str(self.expID))
     201        sqlLine.group("ccdID",            str(ccdID))
     202        sqlLine.group("bias",             str(self.bias))
     203        sqlLine.group("biasScat",         str(self.biasScat))
     204        sqlLine.group("sky",              "self.safeDictionaryAccess(header, 'MSKY_MN')")
     205        sqlLine.group("skyScat",          "self.safeDictionaryAccess(header, 'MSKY_SIG')")
     206        sqlLine.group("magSat",           "self.safeDictionaryAccess(header, 'FSATUR')")
     207        sqlLine.group("completMag",       "self.safeDictionaryAccess(header, 'FLIMIT')")
     208        sqlLine.group("astroScat",        "self.safeDictionaryAccess(header, 'CERROR')")
     209        sqlLine.group("photoScat",        "self.safeDictionaryAccess(self.header, 'ZPT_OBS')")
     210        sqlLine.group("numAstroRef",      "self.safeDictionaryAccess(header, 'NASTRO')")
     211        sqlLine.group("numPhotoRef",      "self.safeDictionaryAccess(header, 'NASTRO')")
     212        sqlLine.group("nx",               "self.safeDictionaryAccess(header, 'CNAXIS1')")
     213        sqlLine.group("ny",               "self.safeDictionaryAccess(header, 'CNAXIS2')")
     214        sqlLine.group("psfFwhm",          str(psfFwhm))
     215        sqlLine.group("psfWidMajor",      "self.safeDictionaryAccess(header, 'FWHM_MAJ')")
     216        sqlLine.group("psfWidMinor",      "self.safeDictionaryAccess(header, 'FWHM_MIN')")
     217        sqlLine.group("psfTheta",         "self.safeDictionaryAccess(header, 'ANGLE')")
     218        sqlLine.group("momentXX",         "-999")
     219        sqlLine.group("momentXY",         "-999")
     220        sqlLine.group("momentYY",         "-999")
     221        sqlLine.group("momentM3C",        "-999")
     222        sqlLine.group("momentM3S",        "-999")
     223        sqlLine.group("momentM4C",        "-999")
     224        sqlLine.group("momentM4S",        "-999")
     225        sqlLine.group("momentR1",         "-999")
     226        sqlLine.group("momentRH",         "-999")
     227        sqlLine.group("apResid",          "self.safeDictionaryAccess(header, 'APMIFIT')")
     228        sqlLine.group("dapResid",         "self.safeDictionaryAccess(header, 'DAPMIFIT')")
     229        sqlLine.group("detectorID",       self.safeDictionaryAccess(header, 'DETECTOR'))
     230        sqlLine.group("qaFlags",          str(self.scratchDb.getDvoImageFlags(header['IMAGEID'])))
     231        sqlLine.group("detrend1",         self.safeDictionaryAccess(header, 'DETREND.MASK'))
     232        sqlLine.group("detrend2",         self.safeDictionaryAccess(header, 'DETREND.DARK'))
     233        sqlLine.group("detrend3",         self.safeDictionaryAccess(header, 'DETREND.FLAT'))
     234        sqlLine.group("detrend4",         " ")
     235        sqlLine.group("detrend5",         " ")
     236        sqlLine.group("detrend6",         " ")
     237        sqlLine.group("detrend7",         " ")
     238        sqlLine.group("detrend8",         " ")
     239        sqlLine.group("photoZero",        "self.safeDictionaryAccess(self.header, 'ZPT_OBS')")
     240        sqlLine.group("ctype1",           "self.safeDictionaryAccess(header, 'CTYPE1')")
     241        sqlLine.group("ctype2",           "self.safeDictionaryAccess(header, 'CTYPE2')")
     242        sqlLine.group("crval1",           "self.safeDictionaryAccess(header, 'CRVAL1')")
     243        sqlLine.group("crval2",           "self.safeDictionaryAccess(header, 'CRVAL2')")
     244        sqlLine.group("crpix1",           "self.safeDictionaryAccess(header, 'CRPIX1')")
     245        sqlLine.group("crpix2",           "self.safeDictionaryAccess(header, 'CRPIX2')")
     246        sqlLine.group("cdelt1",           "self.safeDictionaryAccess(header, 'CDELT1')")
     247        sqlLine.group("cdelt2",           "self.safeDictionaryAccess(header, 'CDELT2')")
     248        sqlLine.group("pc001001",         "self.safeDictionaryAccess(header, 'PC001001')")
     249        sqlLine.group("pc001002",         "self.safeDictionaryAccess(header, 'PC001002')")
     250        sqlLine.group("pc002001",         "self.safeDictionaryAccess(header, 'PC002001')")
     251        sqlLine.group("pc002002",         "self.safeDictionaryAccess(header, 'PC002002')")
     252        sqlLine.group("polyOrder",        "self.safeDictionaryAccess(header, 'NPLYTERM')")
     253        sqlLine.group("pca1x3y0",         "self.safeDictionaryAccess(header, 'PCA1X3Y0')")
     254        sqlLine.group("pca1x2y1",         "self.safeDictionaryAccess(header, 'PCA1X2Y1')")
     255        sqlLine.group("pca1x1y2",         "self.safeDictionaryAccess(header, 'PCA1X1Y2')")
     256        sqlLine.group("pca1x0y3",         "self.safeDictionaryAccess(header, 'PCA1X0Y3')")
     257        sqlLine.group("pca1x2y0",         "self.safeDictionaryAccess(header, 'PCA1X2Y0')")
     258        sqlLine.group("pca1x1y1",         "self.safeDictionaryAccess(header, 'PCA1X1Y1')")
     259        sqlLine.group("pca1x0y2",         "self.safeDictionaryAccess(header, 'PCA1X0Y2')")
     260        sqlLine.group("pca2x3y0",         "self.safeDictionaryAccess(header, 'PCA2X3Y0')")
     261        sqlLine.group("pca2x2y1",         "self.safeDictionaryAccess(header, 'PCA2X2Y1')")
     262        sqlLine.group("pca2x1y2",         "self.safeDictionaryAccess(header, 'PCA2X1Y2')")
     263        sqlLine.group("pca2x0y3",         "self.safeDictionaryAccess(header, 'PCA2X0Y3')")
     264        sqlLine.group("pca2x2y0",         "self.safeDictionaryAccess(header, 'PCA2X2Y0')")
     265        sqlLine.group("pca2x1y1",         "self.safeDictionaryAccess(header, 'PCA2X1Y1')")
     266        sqlLine.group("pca2x0y2",         "self.safeDictionaryAccess(header, 'PCA2X0Y2')")
     267
     268        sql = sqlLine.make(") VALUES ( ", ")")
    377269
    378270        try: self.scratchDb.execute(sql)
     
    407299        results['SATDET'] = 0
    408300
    409         # insert all detections into table
    410         sql = "INSERT IGNORE INTO " + pspsTableName + " ( \
    411                ippDetectID \
    412                ,randomDetID \
    413                ,filterID \
    414                ,surveyID \
    415                ,obsTime \
    416                ,xPos \
    417                ,yPos \
    418                ,xPosErr \
    419                ,yPosErr \
    420                ,psfFlux \
    421                ,psfFluxErr \
    422                ,psfMajorFWHM \
    423                ,psfMinorFWHM \
    424                ,psfTheta \
    425                ,psfCore \
    426                ,psfLikelihood \
    427                ,psfQf \
    428                ,momentXX \
    429                ,momentXY \
    430                ,momentYY \
    431                ,momentR1 \
    432                ,momentRH \
    433                ,momentM3C \
    434                ,momentM3S \
    435                ,momentM4C \
    436                ,momentM4S \
    437                ,apFlux \
    438                ,kronFlux \
    439                ,kronFluxErr \
    440                ,psfQfPerfect \
    441                ,psfChiSq \
    442                ,infoFlag \
    443                ,sky \
    444                ,skyErr \
    445                ,pltScale \
    446                ,posAngle \
    447                ,dataRelease \
    448                ) \
    449                SELECT \
    450                IPP_IDET \
    451                , FLOOR(RAND()*9223372036854775807) \
    452                , " + str(self.filterID) + "\
    453                , " + str(self.surveyID) + " \
    454                ," + str(self.obsTime) + " \
    455                ,X_PSF \
    456                ,Y_PSF \
    457                ,X_PSF_SIG \
    458                ,Y_PSF_SIG \
    459                ,PSF_INST_FLUX / " + self.header['EXPTIME'] + " \
    460                ,PSF_INST_FLUX_SIG / " + self.header['EXPTIME'] + " \
    461                ,PSF_MAJOR \
    462                ,PSF_MINOR \
    463                ,PSF_THETA \
    464                ,-999 \
    465                ,psfLikelihood(EXT_NSIGMA) \
    466                ,PSF_QF \
    467                ,MOMENTS_XX \
    468                ,MOMENTS_XY \
    469                ,MOMENTS_YY \
    470                ,MOMENTS_R1 \
    471                ,MOMENTS_RH \
    472                ,MOMENTS_M3C \
    473                ,MOMENTS_M3S \
    474                ,MOMENTS_M4C \
    475                ,MOMENTS_M4S \
    476                ,POW(10.0, -0.4 *AP_MAG) / " + self.header['EXPTIME'] + " \
    477                ,KRON_FLUX / " + self.header['EXPTIME'] + " \
    478                ,KRON_FLUX_ERR / " + self.header['EXPTIME'] + " \
    479                ,PSF_QF_PERFECT \
    480                ,PSF_CHISQ \
    481                ,FLAGS2 << 32 | FLAGS \
    482                ,SKY  / " + self.header['EXPTIME'] + " \
    483                ,SKY_SIGMA  / " + self.header['EXPTIME'] + " \
    484                ,PLTSCALE \
    485                ,POSANGLE \
    486                , " + str(self.skychunk.dataRelease) + "\
    487                FROM " + ippTableName
    488         # self.logger.info(sql)
    489 
    490 # these were used above (left over from before PSF_INST_FLUX, PSF_INST_FLUX_SIG were available?
    491 #               ,POW(10.0, (-0.4*PSF_INST_MAG)) / " + self.header['EXPTIME'] + "
    492 #               ,ABS((PSF_INST_MAG_SIG*(POW(10.0, (-0.4*PSF_INST_MAG)) / " + self.header['EXPTIME'] + ")) / 1.085736)
    493 
    494 # I need a way to choose the sql above based on the cmf version: V3 (LAP.PV1) does not have AP_FLUX
    495 # AP_FLUX is no              ,AP_FLUX / " + self.header['EXPTIME'] + "
    496 
    497         self.scratchDb.execute(sql)
    498 
    499         # XXX EAM : I removed this old fix for invalid fluxes
    500         # add a instFlux = 0.0 -> 0.000001
    501         # XXX EAM : why is this done?
    502         # sql="UPDATE " + pspsTableName + " SET psfFlux = 0.0000001 WHERE psfFlux =  0"
    503         # self.scratchDb.execute(sql)
    504      
     301        extTimeString = str(self.header['EXPTIME'])
     302
     303        # insert all detections into table : do NOT include the IGNORE unless we have to
     304        # sqlLine = sqlUtility("INSERT IGNORE INTO " + pspsTableName + " (")
     305        sqlLine = sqlUtility("INSERT INTO " + pspsTableName + " (")
     306
     307        # XXX WARNING: need to apply platescale to convert sizes to arcsec
     308        # XXX apFluxF or apFluxNpix + apFluxRadius?
     309
     310        sqlLine.group("ippDetectID",     "IPP_IDET")                                               
     311        sqlLine.group("randomDetID",     "FLOOR(RAND()*9223372036854775807)")                       
     312        sqlLine.group("filterID",        str(self.filterID))                                       
     313        sqlLine.group("surveyID",        str(self.surveyID))                                       
     314        sqlLine.group("obsTime",         str(self.obsTime))                                         
     315        sqlLine.group("xPos",            "X_PSF")                                                   
     316        sqlLine.group("yPos",            "Y_PSF")                                                   
     317        sqlLine.group("xPosErr",         "X_PSF_SIG")                                               
     318        sqlLine.group("yPosErr",         "Y_PSF_SIG")                                               
     319        sqlLine.group("pltScale",        "PLTSCALE")                                     
     320        sqlLine.group("posAngle",        "POSANGLE")                                     
     321        sqlLine.group("psfFlux",         "PSF_INST_FLUX / " + extTimeString)
     322        sqlLine.group("psfFluxErr",      "PSF_INST_FLUX_SIG / " + extTimeString)
     323        sqlLine.group("psfMajorFWHM",    "PSF_FWHM_MAJ")                                               
     324        sqlLine.group("psfMinorFWHM",    "PSF_FWHM_MIN")                                               
     325        sqlLine.group("psfTheta",        "PSF_THETA")                                               
     326        sqlLine.group("psfCore",         "PSF_CORE")                                                   
     327        sqlLine.group("psfQf",           "PSF_QF")                                                 
     328        sqlLine.group("psfQfPerfect",    "PSF_QF_PERFECT")                               
     329        sqlLine.group("psfChiSq",        "PSF_CHISQ")                                     
     330        sqlLine.group("psfLikelihood",   "psfLikelihood(EXT_NSIGMA)")                               
     331        sqlLine.group("momentXX",        "MOMENTS_XX")                                             
     332        sqlLine.group("momentXY",        "MOMENTS_XY")                                             
     333        sqlLine.group("momentYY",        "MOMENTS_YY")                                             
     334        sqlLine.group("momentR1",        "MOMENTS_R1")                                             
     335        sqlLine.group("momentRH",        "MOMENTS_RH")                                             
     336        sqlLine.group("momentM3C",       "MOMENTS_M3C")                                             
     337        sqlLine.group("momentM3S",       "MOMENTS_M3S")                                             
     338        sqlLine.group("momentM4C",       "MOMENTS_M4C")                                             
     339        sqlLine.group("momentM4S",       "MOMENTS_M4S")                                             
     340        sqlLine.group("apFlux",          "AP_FLUX / " + extTimeString)
     341        sqlLine.group("apFluxErr",       "AP_FLUX_SIG / " + extTimeString)
     342        sqlLine.group("apFluxNpix",      "AP_NPIX")
     343        sqlLine.group("kronFlux",        "KRON_FLUX / " + extTimeString)
     344        sqlLine.group("kronFluxErr",     "KRON_FLUX_ERR / " + extTimeString)
     345        sqlLine.group("kronRad",         "MOMENTS_R1 * 2.5")
     346        sqlLine.group("sky",             "SKY  / " + extTimeString)
     347        sqlLine.group("skyErr",          "SKY_SIGMA  / " + extTimeString)
     348        sqlLine.group("infoFlag",        "FLAGS")                         
     349        sqlLine.group("infoFlag2",       "FLAGS2")                         
     350        sqlLine.group("dataRelease",     str(self.skychunk.dataRelease))                 
     351
     352        sqlLine.make(") SELECT ", " FROM " + ippTableName)
     353
     354        print "sql: " + sql
     355
     356        self.scratchDb.execute(sql)
     357
    505358        # NOTE : Flux limits : in the current PSPS schema, negative fluxes
    506359        # cause problems for sql queries which work in mags as SQL cannot do
    507360        # something like (f < 0.0) ? -999 : -2.5*log10(f)
    508361        # as a result, the negative fluxes here result in floating point errors
     362        # XXX EAM 2014072 : Is this still a problem?
    509363        sql = "UPDATE " + pspsTableName + " SET psfFlux = 1e20 WHERE psfFlux <= 0.0"
    510364        self.scratchDb.execute(sql)
     
    518372        # we don't delete these anymore
    519373        results['NULLINSTFLUX'] = 0;
    520        
    521374
    522375    '''
     
    547400
    548401        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease))
    549 
    550     '''
    551     Populates the DetectionCalib table for this OTA
    552     '''
    553     def populateDetectionCalibTableUpdateInsert(self, ota):
    554 
    555         tableName = "Detection_" + ota
     402    '''
     403    Populates the SkinnyObject table for this OTA
     404    '''
     405    def populateSkinnyObjectTable(self, ota):
     406
     407        tableName = "SkinnyObject_" + ota
     408       
    556409        # drop then re-create table
    557         #self.scratchDb.dropTable(tableName)
    558         #sql = "CREATE TABLE " + tableName + " LIKE DetectionCalib"
    559         #try: self.scratchDb.execute(sql)
    560         #except: pass
     410        self.scratchDb.dropTable(tableName)
     411        sql = "CREATE TABLE " + tableName + " LIKE SkinnyObject"
     412        try: self.scratchDb.execute(sql)
     413        except: pass
    561414
    562415        # insert all detections into table
    563416        sql = "INSERT INTO " + tableName + " ( \
    564417               objID \
    565                ,detectID \
    566418               ,ippObjID \
    567                ,ippDetectID \
    568                ,filterID \
    569419               ,surveyID \
    570420               ) \
    571421               SELECT \
    572422               objID \
    573                ,detectID \
    574423               ,ippObjID \
    575                ,ippDetectID \
    576                ,filterID \
    577424               ,surveyID \
    578425               FROM Detection_" + ota
    579 #        self.scratchDb.execute(sql)
    580 
    581         # insert calibration information from dvoDetections into the Table
    582         sql = "UPDATE " + tableName + " AS a, "  + self.scratchDb.dvoDetectionTable + " AS b \
    583             SET a.ra = b.ra, \
    584             a.dec = b.dec_, \
    585             a.raErr = b.raErr, \
    586             a.decErr = b.decErr, \
    587             a.zp = b.zp, \
    588             a.expTime = b.expTime, \
    589             a.airMass = b.airMass   \
    590             WHERE a.objID = b.objID AND a.detectID = b.detectID"
    591         self.scratchDb.execute(sql)
    592         self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease))
    593        
    594     '''
    595     Populates the DetectionCalib table for this OTA
    596     '''
    597     def populateDetectionCalibTable(self, ota):
    598 
    599         # target table name:
    600         tableName = "Detection_" + ota
    601         # drop then re-create table
    602         #self.scratchDb.dropTable(tableName)
    603         #sql = "CREATE TABLE " + tableName + " LIKE Detection"
    604         #try: self.scratchDb.execute(sql)
    605         #except: pass
    606 
    607         externID = self.imageIDs[ota]
    608 
    609         imageID = self.scratchDb.getImageIDFromExternID(externID)
    610         self.logger.infoPair("obtained imageID",imageID)
    611         self.logger.infoPair("obtained externID",externID)
    612 
    613         # insert all detections into table
    614         sql = "Update Detection_" + ota + " AS a, "+ self.scratchDb.dvoDetectionTable + " as b \
    615           set a.ra=b.ra,            \
    616           a.dec = b.dec_,          \
    617           a.raErr = b.raErr,         \
    618           a.decErr = b.decErr,        \
    619           a.zp = b.zp,            \
    620           a.expTime = b.expTime,       \
    621           a.airMass = b.airMass       \
    622           WHERE (a.objID = b.objID AND a.detectID = b.detectID) \
    623           AND b.imageID = " + str(imageID)  \
    624  
    625 
    626         try: self.scratchDb.execute(sql)
    627         except:
    628             self.logger.info("failed to update data for detectionCalib")
    629             self.logger.infoPair("sql: ", sql)
    630             raise
    631        
    632     '''
    633     Populates the Detection table for this OTA
    634     '''
    635     def populateObjectCalColorTable(self, ota):
    636 
    637         tableName = "ObjectCalColor_" + ota
    638        
    639         # drop then re-create table
    640         self.scratchDb.dropTable(tableName)
    641         sql = "CREATE TABLE " + tableName + " LIKE ObjectCalColor"
    642         try: self.scratchDb.execute(sql)
    643         except: pass
    644 
    645         # insert all detections into table
    646         sql = "INSERT INTO " + tableName + " ( \
    647                objID \
    648                ,ippObjID \
    649                ,filterID \
    650                ) \
    651                SELECT \
    652                objID \
    653                ,ippObjID \
    654                ,filterID \
    655                FROM Detection_" + ota
    656         self.scratchDb.execute(sql)
    657 
    658         self.scratchDb.updateAllRows(tableName, "calibModNum", str(self.calibModNum))
     426        self.scratchDb.execute(sql)
     427
    659428        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease))
    660429
     
    685454       
    686455        # store sourceID/imageID combo in Db so DVO can look up later
    687         if not self.useFullTables:
    688             self.scratchDb.insertNewDvoExternID(header['SOURCEID'], header['IMAGEID'])
     456        self.scratchDb.insertNewDvoExternID(header['SOURCEID'], header['IMAGEID'])
    689457           
    690458        # store these for later
     
    734502
    735503        # now run DVO code to get all IDs
    736         if not self.useFullTables:
    737             if not self.getIDsFromDVO(): return False
     504        if not self.getIDsFromDVO(): return False
    738505
    739506        # dec is reserved in MySQL, so STILTS replaces if with dec_, which is not the name of
     
    774541        imageID = self.scratchDb.getImageIDFromExternID(externID)
    775542        self.logger.debug("Updating table '" + table + "' with DVO IDs using imageID = %d" % imageID)
     543
    776544        sql = "UPDATE IGNORE " + table + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b SET \
    777                a.ippObjID = b.ippObjID, \
    778                a.detectID = b.detectID, \
    779                a.objID = b.objID, \
    780                a.infoFlag = b.flags << 45 | a.infoFlag \
     545               a.objID        = b.objID, \
     546               a.detectID     = b.detectID, \
     547               a.ippObjID     = b.ippObjID, \
     548               a.ra           = b.ra, \
     549               a.dec_         = b.dec_, \
     550               a.raErr        = b.raErr, \
     551               a.decErr       = b.decErr, \
     552               a.zp           = b.zp, \
     553               a.telluricExt  = b.telluricExt, \
     554               a.airmass      = b.airmass, \
     555               a.expTime      = b.expTime, \
     556               a.infoFlag2    = (b.flags << 13) | a.infoFlag2 \
    781557               WHERE a.ippDetectID = b.ippDetectID \
    782558               AND b.imageID = " + str(imageID)
    783559
     560        # XXX need to add dvoRegion
     561
    784562        self.scratchDb.execute(sql)
    785563
     
    788566    '''
    789567    def populatePspsTablesChip(self, chipname, x, y, results, tables):
    790         # XXX EAM NOTE: drop tables (Detection_, SkinnyObject_, DetectionCalib_, Detection_) here so
     568        # XXX EAM NOTE: drop tables Detection_* here so
    791569        # they do not polute the db?
    792570        # XXX or put an explicit drop at the end of the loop?
    793571
    794         #self.logger.infoTitle("Processing " + chipname)
     572        # self.logger.infoTitle("Processing " + chipname)
    795573        # this is a bit crude: if the chip is not present, this test will fail and the chip
    796574        # will be (correctly) skipped.  would be better to carry that information explicitly ("chip is missing")
     
    853631        self.scratchDb.execute(sql)
    854632       
    855         #self.logger.info("updated imagedata")
    856        
    857         self.populateDetectionCalibTable(chipname)
    858         #self.logger.info("updated detectioncalibtable")
    859        
    860633        # add these to list of tables to export later
    861634        self.tablesToExport.append("ImageMeta_" + chipname)
     
    865638        self.logger.info("export Detection")
    866639
    867        
    868640        tables.append("Detection_" + chipname)
    869         self.logger.info("updated detectioncalibtable")
     641        self.logger.info("updated detection")
    870642
    871643        self.validChips.append(chipname)
     
    1024796       return super(DetectionBatch, self).importIppTables(columns, regex)
    1025797
    1026 
    1027798    '''
    1028799    Overriding this method. Use regex to trim off, eg _XY33 extension
     
    1030801    def exportPspsTablesToFits(self, regex="(.*)"):
    1031802       return super(DetectionBatch, self).exportPspsTablesToFits("([a-zA-Z]+)")
    1032 
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/dvo.py

    r36447 r37129  
    5050        self.regionsIngestedButOutOfDate = []
    5151       
    52         # we have (still) 3 modes of ingest from dvo cpt/cps/cpm files
    53         # 1) dvograbber (useFullTables == FALSE),
     52        # we USED TO have 3 modes of ingest from dvo cpt/cps/cpm files
     53        # 1) dvograbber (useStilts == TRUE, useFullTables == FALSE),
    5454        # 2) jython/stilts (useStilts == TRUE, useFullTables == TRUE)
    55         # 3) dvopsps (useStilts == FALSE, useFullTables == TRUE)
     55        # 3) dvopsps (useStilts == FALSE, useFullTables == FALSE)
    5656        # my goal (EAM, 2013/01/31) is to migrate to only dvopsps
    5757
    58         self.useStilts = 0
    59         self.scratchDb.setUseFullTables(True)
     58        self.scratchDb.setDvoTableNames()
    6059
    6160        # decide if we are using the right DVO for this scratchDb
     
    105104        if not self.correctDvo: return
    106105
     106        if (self.skychunk.dvoLocation == 'none'):
     107            print "do not load Photcodes for place-holder DVO " + self.skychunk.dvoLocation
     108            return False
     109
    107110        # check if we have up-to-date version
    108111        path = self.skychunk.dvoLocation + "/Photcodes.dat"
     
    156159        if not self.correctDvo: return False
    157160
     161        if (self.skychunk.dvoLocation == 'none'):
     162            print "do not load SkyTable for place-holder DVO " + self.skychunk.dvoLocation
     163            return False
     164
    158165        path =  self.skychunk.dvoLocation + "/SkyTable.fits"
    159166        if self.scratchDb.alreadyImportedThisDvoTable(path):
     
    164171        self.logger.infoPair("DVO SkyTable.fits file", "NOT up-to-date")       
    165172
    166         if self.useStilts:
    167             self.importFits(
    168                 path,
    169                 "R_MIN R_MAX D_MIN D_MAX INDEX NAME",
    170                 self.scratchDb.dvoSkyTable)
    171         else:
    172            
    173             # create dvoSkyTable
    174             sql = "drop TABLE dvoSkyTable"
    175             try:
    176                 self.scratchDb.execute(sql)
    177             except: pass
    178 
    179             # create dvoSkyTable
    180             sql = "CREATE TABLE dvoSkyTable (R_MIN REAL, R_MAX REAL, D_MIN REAL, D_MAX REAL, INDEX_ INT, NAME CHAR(18))"
    181             self.scratchDb.execute(sql)
    182 
    183             # TODO path to DVO prog hardcoded temporarily
    184             cmd = "dvopsps skytable"
    185             cmd += " -dbhost " + self.scratchDb.dbHost
    186             cmd += " -dbname " + self.scratchDb.dbName
    187             cmd += " -dbuser " + self.scratchDb.dbUser
    188             cmd += " -dbpass " + self.scratchDb.dbPass
    189             cmd += " -D CATDIR " + self.skychunk.dvoLocation
    190 
    191             self.logger.infoPair("Running dvopsps", cmd)
    192             p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
    193             p.wait()
    194             if p.returncode != 0:
    195                 self.logger.errorPair("dvopsps failed on SkyTable.fits for ", self.skychunk.dvoLocation)
    196                 raise
     173        # drop dvoSkyTable (if it exists)
     174        sql = "drop TABLE dvoSkyTable"
     175        try: self.scratchDb.execute(sql)
     176        except: pass
     177
     178        # create dvoSkyTable
     179        sql = "CREATE TABLE dvoSkyTable (R_MIN REAL, R_MAX REAL, D_MIN REAL, D_MAX REAL, INDEX_ INT, NAME CHAR(18))"
     180        self.scratchDb.execute(sql)
     181
     182        # TODO path to DVO prog hardcoded temporarily
     183        cmd = "dvopsps skytable"
     184        cmd += " -dbhost " + self.scratchDb.dbHost
     185        cmd += " -dbname " + self.scratchDb.dbName
     186        cmd += " -dbuser " + self.scratchDb.dbUser
     187        cmd += " -dbpass " + self.scratchDb.dbPass
     188        cmd += " -D CATDIR " + self.skychunk.dvoLocation
     189
     190        self.logger.infoPair("Running dvopsps", cmd)
     191        p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
     192        p.wait()
     193        if p.returncode != 0:
     194            self.logger.errorPair("dvopsps failed on SkyTable.fits for ", self.skychunk.dvoLocation)
     195            raise
    197196
    198197        self.logger.infoPair("Adding index to", self.scratchDb.dvoSkyTable)
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/dvoobjects.py

    r35417 r37129  
    2727        self.ingestFileTypes = ['cpt', 'cps']
    2828        self.loadPhotcodes()
    29 
    30     '''
    31     Ingests object files for this region
    32     '''
    33     def ingestRegion(self, region):
    34 
    35        self.logger.infoPair("Ingesting objects for", region)
    36 
    37        for fileType in self.ingestFileTypes:
    38 
    39            path = self.skychunk.dvoLocation + "/" + region + "." + fileType
    40            tableName = self.scratchDb.getDbFriendlyTableName(region + "." + fileType)
    41 
    42            self.importFits(path, "*", tableName)
    43 
    44            self.scratchDb.setImportedThisDvoTable(path, region)
    45 
    46        return True
    47 
    4829
    4930    '''
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/ippjython

    r35605 r37129  
    1313
    1414set JARDIR = $datadir/jar
     15
     16# XXX if you want to run a local test, use . for JYDIR
     17# set JYDIR = .
    1518set JYDIR = $datadir/jython
     19
    1620setenv IPPTOPSPS_DATA $datadir/ipptopsps
    1721
     
    4549shift
    4650
    47 # XXX if you want to run a test on a local file, use this line:
    48 # $JAVA -Xbootclasspath/a:$CLASSPATH -jar $JYTHON $classfile $*
    49 
    5051$JAVA -Xbootclasspath/a:$CLASSPATH -jar $JYTHON $JYDIR/$classfile $*
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/ipptopsps.py

    r35417 r37129  
    143143    def checkClientStatus(self):
    144144
    145         print "update client"
     145        print "updateClient (add this process to client table)"
    146146        self.ippToPspsDb.updateClient(self.config.programName, self.HOST, self.PID)
    147147
    148         print "check killed"
     148        print "check if isKilled (has someone killed me?)"
    149149        if self.ippToPspsDb.isKilled(self.HOST, self.PID):
    150150            self.exitProgram("killed via Db")
     
    152152        # this loop pauses the process if we have no skychunk or we have set it to pause
    153153        firstTimeIn = True
    154         print "refresh skychunk"
     154        print "refreshSkychunk"
    155155        while not self.refreshSkychunk() or self.ippToPspsDb.isPaused(self.HOST, self.PID):
    156156
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/ipptopspsdb.py

    r36815 r37129  
    786786            and not self.consistentlyFailed(batchType, stageID)):
    787787           
    788             self.logger.infoPair("heather:","passed logic")
     788            # self.logger.infoPair("heather:","passed logic")
    789789
    790790            sql = "INSERT INTO batch ( \
     
    803803                       '" + self.skychunk.name + "' \
    804804                       )"
    805             self.logger.infoPair("heather:","sql")
     805 
     806            # self.logger.infoPair("heather:",sql)
    806807
    807808            self.execute(sql)
     
    816817            except:
    817818                self.logger.exception("Unable to get batch ID")
     819                self.logger.infoPair("sql:",sql)
     820
    818821                batchID = -1
    819822
     
    10171020       response = raw_input(" * Name for new skychunk, or existing skychunk to edit? ")
    10181021       if response == "": return
     1022       response = response.strip()
    10191023       self.skychunk.name = response
    10201024
     
    10561060           question = question +  "? "
    10571061           response = raw_input(question)
     1062           response = response.strip()
     1063           print "response: '" + response + "'"
    10581064           if response != "":
    10591065               if type.find("varchar") != -1 or type.find("timestamp") != -1: quotes = "'"
    10601066               else: quotes = ""
     1067               # print "UPDATE skychunk SET " + field + " = " + quotes + response + quotes + " WHERE name = '" + self.skychunk.name + "'"
    10611068               self.execute("UPDATE skychunk SET " + field + " = " + quotes + response + quotes + " WHERE name = '" + self.skychunk.name + "'")
    10621069       
     
    11301137        self.skychunk.batchTypes = []
    11311138        try:
     1139            # print "sql: " + sql
    11321140            rs = self.executeQuery(sql)
    11331141
     
    11761184            if rs.getInt(26) == 1: self.skychunk.parallel = True
    11771185            self.skychunk.P2_smf_version = rs.getString(27)
     1186            # options: "use_new", "not_reproc", "use_original"
     1187
    11781188            self.skychunk.ST_cmf_version = rs.getString(28)
     1189            # options: not used?
     1190
     1191            # NOTE : the rs (ResultSet) class is somewhat annoying and finicky esp about timestamp values
     1192            # for example, rs.getTimestamp(N) fails silently if the value is not a valid time.  this is
     1193            # also true to getString() on the same column.  Docs for the ResultSet class can be found here:
     1194            # http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/ResultSet.html?is-external=true
     1195
     1196            # rsmd = rs.getMetaData()
     1197            # print "got metadata"
     1198            # print "number of columns: " + str(rsmd.getColumnCount())
     1199            # print "label: " + rsmd.getColumnLabel(25)
     1200            # print "label: " + rsmd.getColumnLabel(29)
     1201            # print "name: " + rsmd.getColumnName(25)
     1202            # print "name: " + rsmd.getColumnName(29)
     1203            # print "typename: " + rsmd.getColumnTypeName(25)
     1204            # print "typename: " + rsmd.getColumnTypeName(29)
     1205
     1206            # epochStamp = rs.getTimestamp(16)
     1207            # print "epoch: " + epochStamp.toString()
     1208
     1209            # print "label: " + rsmd.getColumnLabel(16)
     1210            # print "name: " + rsmd.getColumnName(16)
     1211            # print "typename: " + rsmd.getColumnTypeName(16)
     1212
    11791213            self.skychunk.trange_start = rs.getString(29)
     1214            # options: "YYYY-MM-DD,HH:MM:SS" or "0000-00-00 00:00:00"
     1215
    11801216            self.skychunk.trange_end = rs.getString(30)
     1217            # options: "YYYY-MM-DD,HH:MM:SS" or "0000-00-00 00:00:00"
    11811218
    11821219            if self.skychunk.parallel: print "USING parallel"
     
    16211658            pass
    16221659
    1623         self.execute("CREATE TEMPORARY TABLE all_pending (stage_id bigint(20), ra_bore float, dec_bore float)")
     1660        # XXX EAM : 20140727: for now this is not temporary (for debugging)
     1661        # self.execute("CREATE TEMPORARY TABLE all_pending (stage_id bigint(20), ra_bore float, dec_bore float)")
     1662        self.execute("CREATE TABLE all_pending (stage_id bigint(20), ra_bore float, dec_bore float)")
    16241663        for row in rows:
    16251664
     
    17021741        try:
    17031742            rs = self.executeQuery(sql)
    1704             while (rs.next()): ids.append(rs.getInt(1))
     1743            while (rs.next()):
     1744                ids.append(rs.getInt(1))
     1745                print "stage_id: " + str(rs.getInt(1))
    17051746        except:
    17061747            self.logger.errorPair("Can't get items in this box", sql)
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/loader.py

    r36709 r37129  
    160160                    self.logger.infoPair(batchType + " items found in this box", "%d" % len(ids))
    161161
    162                     useFullTables = 0
    163162                    if batchType != "OB":
    164 
    165                         if (self.dvoDetections.useStilts):
    166                             # look in DVO for this box (with extra border)
    167                             self.logger.infoPair("Querying DVO for this sky area", "")
    168 
    169                             # XXXX EAM : This code should not be used anymore
    170                             boxSize = 0.0
    171                             self.dvoDetections.setSkyAreaAsBox(boxDim['RA'], boxDim['DEC'], boxSize)
    172                             #self.dvoDetections.setSkyArea()
    173                             sizeToBeIngested = self.dvoDetections.getDiskSizeOfRegionsToBeIngested()
    174                             if sizeToBeIngested == 0.0: smfsPerGB = 999999999
    175                             else: smfsPerGB = len(ids)/sizeToBeIngested
    176                             self.logger.infoPair("DVO to be ingested", "%7.1e GB" % sizeToBeIngested)
    177                             self.logger.infoPair("smfs-per-GB", "%.1f" % smfsPerGB)
    178 
    179                             # should do we pre-ingest stuff from DVO?
    180                             # NOTE EAM : this skychunk loads the dvo detections into the mysql db
    181                             # XXXX EAM : this should happen for both P2 and Stack detection
    182                             # XXXX EAM : in parallel model, this should happen for all P2 & Stack batches
    183                             #
    184                             if (batchType == 'P2' or batchType == 'ST' or batchType == 'DF' or batchType == 'FW') and smfsPerGB > 30:
    185                                 if not self.dvoDetections.sync():
    186                                     self.logger.errorPair("Could not sync DVO with MySQL", "skipping")
    187                                     continue
    188                                
    189                                 useFullTables = 1
    190                         else:
    191                             # XXX EAM : this is not currently optional
    192                             # (it is the only path). either remove the
    193                             # non-native ingest code or make it an
    194                             # option if we are using the native
    195                             # loader, always use it need to work out a
    196                             # good boundary / region strategy in
    197                             # coordination with impact of mysql
    198                             # insertion
    199                             if not self.ippToPspsDb.isBoxIngested(boxId, self.scratchDb.dbHost):
    200                                 if not self.dvoDetections.nativeIngestDetections(boxId, boxDim):
    201                                     self.logger.error("Unable to ingest detections with nativeIngest")
    202                                     return False
    203 
    204                             useFullTables = 1
    205                
    206                     ## else:
    207                     ##     # if we are using the native loader, always use it
    208                     ##     # need to work out a good boundary / region strategy in coordination with
    209                     ##     # impact of mysql insertion
    210                     ##     self.dvoObjects.nativeIngestObjects(boxDim['RA'], boxDim['DEC'], boxSizeSansBorder)
    211                     ##     useFullTables = 1
     163                        if not self.ippToPspsDb.isBoxIngested(boxId, self.scratchDb.dbHost):
     164                            if not self.dvoDetections.nativeIngestDetections(boxId, boxDim):
     165                                self.logger.error("Unable to ingest detections with nativeIngest")
     166                                return False
    212167
    213168                    '''
    214169                    NOTE EAM : "TheseItems" refers to each of the stack CMFs, camera SMFs, or object batches
    215170                    '''
    216                     self.logger.infoBool("Using pre-ingested DVO data?", useFullTables)
    217                     if not self.processTheseItems(batchType, ids, useFullTables):
     171                    if not self.processTheseItems(batchType, ids):
    218172                        abort = True
    219173                        break
     
    228182    Actually loops through items and processes them
    229183    '''
    230     def processTheseItems(self, batchType, ids, useFullTables):
     184    def processTheseItems(self, batchType, ids):
    231185   
    232186        self.logger.infoPair("%s items queued" % batchType, "%d" % len(ids))
     
    262216                            self.scratchDb,
    263217                            id,
    264                             batchID,
    265                             useFullTables)
     218                            batchID)
    266219                elif batchType == "ST":
    267220                    self.logger.infoPair("defining ST batch for sky_id:",id)
     
    273226                            self.scratchDb,
    274227                            id,
    275                             batchID,
    276                             useFullTables)
     228                            batchID)
    277229   
    278230                elif batchType == "OB":
     
    284236                            self.scratchDb,
    285237                            id,
    286                             batchID,
    287                             useFullTables)
     238                            batchID)
    288239   
    289240                elif batchType == "DF":
     
    295246                            self.scratchDb,
    296247                            id,
    297                             batchID,
    298                             useFullTables)
     248                            batchID)
    299249   
    300250                elif batchType == "DO":
     
    306256                            self.scratchDb,
    307257                            id,
    308                             batchID,
    309                             useFullTables)
     258                            batchID)
    310259   
    311260                elif batchType == "FW":
     
    317266                            self.scratchDb,
    318267                            id,
    319                             batchID,
    320                             useFullTables)
     268                            batchID)
    321269   
    322270                elif batchType == "FO":
     
    328276                            self.scratchDb,
    329277                            id,
    330                             batchID,
    331                             useFullTables)
     278                            batchID)
    332279                   
    333280                batch.run()
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/mysql.py

    r35417 r37129  
    108108        except:
    109109            print "failed to kill connection: ", connectionID
     110
     111    def listTables(self):
     112
     113        sql = "show tables"
     114        rs = self.executeQuery(sql) 
     115        while (rs.next()):
     116            tableName = rs.getString(1)
     117            print "table: " + tableName
     118        rs.close()
    110119
    111120    '''
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/objectbatch.py

    r36744 r37129  
    1515from scratchdb import ScratchDb
    1616from dvoobjects import DvoObjects
     17from sqlUtility import sqlUtility
    1718
    1819import logging.config
     
    3738                 scratchDb,
    3839                 dvoID,
    39                  batchID,
    40                  useFullTables):
     40                 batchID):
    4141
    4242       super(ObjectBatch, self).__init__(
     
    5050               batchID,
    5151               "OB",
    52                None,
    53                1)
     52               None)
    5453
    5554       try:
    56            ## XX pass in the existing connection to scratchDb
    5755           self.dvoObjects = DvoObjects(self.logger, self.config, self.skychunk, self.ippToPspsDb, self.scratchDb)
    5856       except:
     
    7472        self.region = self.scratchDb.getRegionNameFromThisDvoIndex(self.id)
    7573        self.ippToPspsDb.insertObjectMeta(self.batchID, self.region)
    76         if True:
    77             self.dvoObjects.nativeIngestRegion(self.region)
    78         else:
    79             self.dvoObjects.ingestRegion(self.region)
     74        self.dvoObjects.nativeIngestRegion(self.region)
    8075
    8176        cptTableName = self.scratchDb.getDbFriendlyTableName(self.region + ".cpt")
     
    9085    def alterPspsTables(self):
    9186
     87        # XXX EAM 2014.07.24 : why is this no longer needed?
    9288        # dec is reserved in MySQL, so STILTS replaces if with dec_, which PSPS doesn't like. so, force it back again using ``
    93       # self.scratchDb.execute("ALTER TABLE MeanObject CHANGE dec_ `dec` double")
    94       # self.scratchDb.execute("ALTER TABLE ObjectThin CHANGE dec_ `dec` double")
     89        # self.scratchDb.execute("ALTER TABLE MeanObject CHANGE dec_ `dec` double")
     90        # self.scratchDb.execute("ALTER TABLE ObjectThin CHANGE dec_ `dec` double")
    9591
    9692        return True
     
    10197    def indexIppTables(self):
    10298
    103         self.logger.infoPair("Creating indexes on", "IPP tables")
     99        # since dvopsps is now used, no action is needed here
     100        # self.logger.infoPair("Creating indexes on", "IPP tables")
    104101
    105102        return True
     
    109106    '''
    110107    def updateMeanObjectFromCps(self, cpsTable):
     108
     109        # list of all filters PSPS is interested in
     110        # XXX EAM : 2014.07.24 : this list should probably be in a config file somewhere
     111        interestedFilters = ['g', 'r', 'i', 'z', 'y']
     112       
     113        filters = self.scratchDb.getOrderedListOfFiltersFromPhotcodesTable(interestedFilters)
     114   
     115        # get a count of the available filters
     116        filterCount = self.scratchDb.getCountOfFiltersFromPhotcodesTable()
     117
     118        self.logger.infoPair("Available filters in Photcodes", filters)
     119
     120        # the 'code' now defines the order in the cps file that the mags are listed for a given filter
     121        self.logger.infoPair("Adding magnitudes from", "cps table")
     122        for filter in filters:
     123
     124            filterID = self.scratchDb.getFilterID(filter[1])
     125
     126            # NOTE: Manipulation of FLAGS from cpsTable is to move ID_SECF_OBJ_EXT flag (0x01000000)
     127            # from bit 24 to bit 13 so that it fits into the SMALLINT Object.Flags
     128            # XXX EAM : 20140724 this manipulation is no longer needed : [grizy]Flags is now 4 byte (was 8 byte!)
     129
     130            # set the MeanObject fields based largely on dvopsps cps fields:
     131
     132            # XXX EAM 20140724 : filterCount is meant to match
     133            # Nsecfilt, but is potentially not determined correctly.
     134            # use a call to a dvo-native command which knows how to
     135            # find Nsecfilt (or save in the db with dvopsps)
     136
     137            # the math below depends on filterCount = Nsecfilt and MeanObject.row being 1 counting but cps being 0 counting?
     138            # cps.row has a count of MeanObject.row * Nsecfilt + Nfilter
     139            #  " + cpsTable + " AS cps ON (cps.row = (MeanObject.row* " + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \
     140
     141            sql = "UPDATE MeanObject JOIN \
     142                   " + cpsTable + " AS cps ON (cps.row = (MeanObject.row* " + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \
     143                   SET \
     144                    MeanObject." + filter[1] + "QfPerfect = -999 \
     145                   ,MeanObject." + filter[1] + "MeanPSFMag     = MAG \
     146                   ,MeanObject." + filter[1] + "MeanPSFMagErr  = MAG_ERR \
     147                   ,MeanObject." + filter[1] + "MeanPSFMagStd  = MAG_STDEV \
     148                   ,MeanObject." + filter[1] + "MeanPSFMagMin  = MAG_MIN \
     149                   ,MeanObject." + filter[1] + "MeanPSFMagMax  = MAG_MAX \
     150                   ,MeanObject." + filter[1] + "MeanPSFMagNpt  = NUSED \
     151                   ,MeanObject." + filter[1] + "MeanKronMag    = MAG_KRON \
     152                   ,MeanObject." + filter[1] + "MeanKronMagErr = MAG_KRON_ERR \
     153                   ,MeanObject." + filter[1] + "MeanKronMagStd = MAG_KRON_STDEV \
     154                   ,MeanObject." + filter[1] + "MeanKronMagNpt = NUSED_KRON \
     155                   ,MeanObject." + filter[1] + "MeanApMag      = MAG_AP \
     156                   ,MeanObject." + filter[1] + "MeanApMagErr   = MAG_AP_ERR \
     157                   ,MeanObject." + filter[1] + "MeanApMagStd   = MAG_AP_STDEV \
     158                   ,MeanObject." + filter[1] + "MeanApMagNpt   = NUSED_AP \
     159                   ,MeanObject." + filter[1] + "Flags = (0x7fff & FLAGS) | ((FLAGS >> 11) & 0x2000) "
     160
     161
     162            self.logger.info(sql)
     163            self.scratchDb.execute(sql)
     164
     165        # now set to null all MeanMagErr values > 0.5 (cut set by Gene, 2012-04-12)
     166        # XXX EAM 20140724 : keep this cut?
     167        cut = 0.5
     168        self.logger.infoPair("Setting to NULL all MeanMagErr value >", "%f" % cut)
     169        for filter in filters:
     170
     171            sql = "UPDATE MeanObject \
     172                   SET " + filter[1] + "MeanPSFMagErr = null \
     173                   WHERE " + filter[1] + "MeanPSFMagErr > " + str(cut)
     174            self.scratchDb.execute(sql)
     175
     176    '''
     177    Inserts stuff for all mags
     178    '''
     179    def updateObjectThinFromCps(self, cpsTable):
    111180
    112181        # list of all filters PSPS is interested in
     
    127196            filterID = self.scratchDb.getFilterID(filter[1])
    128197
    129             # NOTE: Manipulation of FLAGS from cpsTable is to move ID_SECF_OBJ_EXT flag (0x01000000)
    130             # from bit 24 to bit 13 so that it fits into the SMALLINT Object.Flags
    131 
    132             sql = "UPDATE MeanObject JOIN \
    133                    " + cpsTable + " AS cps ON (cps.row = (MeanObject.row* " + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \
    134                    SET \
    135                    MeanObject." + filter[1] + "QfPerfect = -999 \
    136                    ,MeanObject." + filter[1] + "MeanPSFMag = MAG \
    137                    ,MeanObject." + filter[1] + "MeanPSFMagErr = MAG_ERR \
    138                    ,MeanObject." + filter[1] + "MeanKronMag = MAG_KRON \
    139                    ,MeanObject." + filter[1] + "MeanKronMagErr = MAG_KRON_ERR \
    140                    ,MeanObject." + filter[1] + "nIncPSFMag = -999 \
    141                    ,MeanObject." + filter[1] + "MeanPSFMagStd = -999 \
    142                    ,MeanObject." + filter[1] + "MinPSFMag = -999 \
    143                    ,MeanObject." + filter[1] + "MaxPSFMag = -999 \
    144                    ,MeanObject." + filter[1] + "nIncKronMag = -999 \
    145                    ,MeanObject." + filter[1] + "MeanKronMag = -999 \
    146                    ,MeanObject." + filter[1] + "MeanKronMagStd = -999 \
    147                    ,MeanObject." + filter[1] + "MeanApMag = MAG_AP \
    148                    ,MeanObject." + filter[1] + "MeanApMagErr = MAG_ERR \
    149                    ,MeanObject." + filter[1] + "MeanApMagStd = MAG_STDEV \
    150                    ,MeanObject." + filter[1] + "nIncApMag = -999 \
    151                    ,MeanObject." + filter[1] + "Flags = (0x7fff & FLAGS) | ((FLAGS >> 11) & 0x2000) "
    152 
    153 
    154             self.logger.info(sql)
    155             self.scratchDb.execute(sql)
    156 
    157         # now set to null all MeanMagErr values > 0.5 (cut set by Gene, 2012-04-12)
    158         cut = 0.5
    159         self.logger.infoPair("Setting to NULL all MeanMagErr value >", "%f" % cut)
    160         for filter in filters:
    161 
    162             sql = "UPDATE MeanObject \
    163                    SET " + filter[1] + "MeanPSFMagErr = null \
    164                    WHERE " + filter[1] + "MeanPSFMagErr > " + str(cut)
    165             self.scratchDb.execute(sql)
    166     '''
    167     Inserts stuff for all mags
    168     '''
    169     def updateObjectThinFromCps(self, cpsTable):
    170 
    171         # list of all filters PSPS is interested in
    172         interestedFilters = ['g', 'r', 'i', 'z', 'y']
    173        
    174         filters = self.scratchDb.getOrderedListOfFiltersFromPhotcodesTable(interestedFilters)
    175    
    176         # get a count of the available filters
    177         filterCount = self.scratchDb.getCountOfFiltersFromPhotcodesTable()
    178         # filterCount = len(filters)
    179 
    180         self.logger.infoPair("Available filters in Photcodes", filters)
    181 
    182         # the 'code' now defines the order in the cps file that the mags are listed for a given filter
    183         self.logger.infoPair("Adding magnitudes from", "cps table")
    184         for filter in filters:
    185 
    186             filterID = self.scratchDb.getFilterID(filter[1])
    187 
    188             # NOTE: Manipulation of FLAGS from cpsTable is to move ID_SECF_OBJ_EXT flag (0x01000000)
    189             # from bit 24 to bit 13 so that it fits into the SMALLINT Object.Flags
    190 
     198            # XXX EAM 20140724 : this is quite awkward, add a objRow and ncode value to mysql db table?
    191199            sql = "UPDATE ObjectThin JOIN \
    192200                   " + cpsTable + " AS cps ON (cps.row = (ObjectThin.row* " + str(filterCount) + ")-(" + str(filterCount) + " - " + str(filter[0]) + ")) \
     
    196204            self.scratchDb.execute(sql)
    197205
     206        # XXX this does not seem like a good thing to leave in SQL
    198207        self.logger.infoPair("Calculating nDetections from", "n[filters]")
    199208        for filter in filters:
     
    203212                   WHERE n" + filter[1] + " != -999"
    204213            self.scratchDb.execute(sql)
    205            
    206 
    207214
    208215    '''
    209216    give objectName to objectThin
     217    XXX EAM 20140714 : This seems quite inefficient in SQL, move to dvopsps?
    210218    '''
    211219    def updateObjName(self):
     
    281289            return False
    282290
    283 
    284 
    285 
    286 
    287 
    288 
    289291    '''
    290292    Populates the Object table
     
    296298
    297299        if False:
     300            # XXX EAM 20140724 : this is probably wrong : flux measurements can be 0.0 or negative: please review
    298301            self.logger.infoPair("setting to null  > 1e-38 and < 1e-38 in", "cps FLUX_KRON_ERR")
    299302            sql = "UPDATE " + cpsTableName + " set FLUX_KRON_ERR = NULL where FLUX_KRON_ERR < 1e-37 AND FLUX_KRON_ERR > -1e-37 "
     303            self.exitProgram("review this code" + sql)
    300304     
    301305            try:
     
    315319
    316320       
    317         self.logger.infoPair("Populating", "ThinObject")
    318         self.logger.infoPair("Inserting objects from", "cpt file")
    319 
    320         # note `` around dec here, as this is a reserved word in MySQL
    321         sql = "INSERT IGNORE INTO ObjectThin (\
    322                objID \
    323                ,gcobjID \
    324                ,ippObjID \
    325                ,surveyID \
    326                ,skyCellID \
    327                ,randomID \
    328                ,batchID \
    329                ,dvoRegionID \
    330                ,dataRelease \
    331                ,objInfoFlag \
    332                ,qualityFlag \
    333                ,consistencyFlag \
    334                ,raStack \
    335                ,decStack \
    336                ,raStackErr \
    337                ,decStackErr \
    338                ,raMean \
    339                ,decMean \
    340                ,raMeanErr \
    341                ,decMeanErr \
    342                ,raMeanStd \
    343                ,decMeanStd \
    344                ,nStackObjectRows \
    345                ,nStackDetections \
    346                ,nDetections \
    347                 ) \
    348                SELECT \
    349                EXT_ID \
    350                , -999 \
    351                ,CAT_ID*1000000000 + OBJ_ID \
    352                ," + str(self.surveyID) + " \
    353                , -999 \
    354                , FLOOR(RAND()*9223372036854775807) \
    355                , " + str(self.batchID) + "\
    356                , -999 \
    357                , " + str(self.skychunk.dataRelease) + "\
    358                ,FLAGS \
    359                ,FLAGS >> 24 & 0xFF \
    360                , 0 \
    361                , -999 \
    362                , -999 \
    363                , -999 \
    364                , -999 \
    365                ,RA \
    366                ,DEC_ \
    367                ,RA_ERR \
    368                ,DEC_ERR \
    369                , -999 \
    370                , -999 \
    371                ,0 \
    372                ,0 \
    373                ,0 \
    374                 FROM " + cptTableName
     321        self.logger.info("Populating ThinObject")
     322        self.logger.info("Inserting objects from cpt file")
     323
     324        # note "dec" is a reserved word in MySQL
     325        # XXX EAM 20140724 : do not use INGORE unless we discover unavoidable problems...
     326        # INSERT IGNORE INTO ObjectThin
     327
     328        sqlLine = sqlUtility("INSERT INTO ObjectThin (")
     329
     330        sqlLine.group("objID",           "EXT_ID")
     331        # sqlLine.group("gcobjID",       "EXT_ID_GC")  # drop this one?
     332        sqlLine.group("ippObjID",        "OBJ_ID + (CAT_ID << 32)") # NOTE: shift by 32 bits exactly
     333        sqlLine.group("surveyID",        str(self.surveyID))
     334        sqlLine.group("skyCellID",       "-999") # XXX This does not make sense
     335        sqlLine.group("randomID",        "FLOOR(RAND()*9223372036854775807)") # XXX where does this number come from??
     336        sqlLine.group("batchID",         str(self.batchID))
     337        sqlLine.group("dvoRegionID",     "DVO_REGION") # XXX add to dvopsps output for cpt
     338        sqlLine.group("dataRelease",     str(self.skychunk.dataRelease))
     339        sqlLine.group("objInfoFlag",     "FLAGS")
     340        sqlLine.group("qualityFlag",     "FLAGS >> 24 & 0xFF")
     341        sqlLine.group("consistencyFlag", "0")
     342        sqlLine.group("raStack",         "RA_STK")
     343        sqlLine.group("decStack",        "DEC_STK")
     344        sqlLine.group("raStackErr",      "RA_STK_ERR")
     345        sqlLine.group("decStackErr",     "DEC_STK_ERR")
     346        sqlLine.group("raMean",          "RA_MEAN")
     347        sqlLine.group("decMean",         "DEC_MEAN")
     348        sqlLine.group("raMeanErr",       "RA_ERR")
     349        sqlLine.group("decMeanErr",      "DEC_ERR")
     350        sqlLine.group("raMeanStd",       "-999") # XXX I do not calculate this, use chisq?
     351        sqlLine.group("decMeanStd",      "-999")
     352        sqlLine.group("nStackObjectRows", "0") # XXX I need to add / define this in dvopsps
     353        sqlLine.group("nStackDetections", "0")
     354        sqlLine.group("nDetections",      "0")
     355        sql = sqlLine.make(") SELECT ", " FROM " + cptTableName)
    375356
    376357        try:
     
    390371        self.updateObjName()
    391372
    392 
    393373        self.logger.infoPair("update ObjectThin from ","cps table")
    394374
    395375        self.updateObjectThinFromCps(cpsTableName)
    396376
     377        # XXX EAM 20140724 : is this necessary??
    397378        #objects can have out of range ra dec in dvo - need to find and kill them at the end
    398379
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/queue.py

    r36697 r37129  
    4545
    4646        try:
    47             print "why doesn't this work"
     47            print "does this work?"
    4848            self.dvoObjects = DvoObjects(self.logger, self.config, self.skychunk, self.ippToPspsDb, self.scratchDb)
    4949        except:
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/scratchdb.py

    r35417 r37129  
    5151    Sets whether we are using normal or pre-ingested DVO tables
    5252    '''
    53     def setUseFullTables(self, useFull):
    54 
    55         if useFull:
    56             self.dvoImagesTable = "dvoImagesFull"
    57             self.dvoDetectionTable = "dvoDetectionFull"
    58         else:
    59             self.dvoImagesTable = "dvoImages"
    60             self.dvoDetectionTable = "dvoDetection"
     53    def setDvoTableNames(self):
     54
     55        self.dvoImagesTable = "dvoImagesFull"
     56        self.dvoDetectionTable = "dvoDetectionFull"
    6157
    6258        self.logger.debugPair("Using DVO images table", self.dvoImagesTable)
     
    233229    def alreadyImportedThisDvoTable(self, path):
    234230
     231        print "***** alreadyImportedThisDvoTable *****"
     232        print "path: " + path
     233
    235234        fileStat = os.stat(path)
     235        print "path: " + path
    236236
    237237        sql = "SELECT COUNT(*) FROM " + self.dvoDoneTable + " WHERE path = '" + path + "' AND modifiedDate = " + str(fileStat.st_mtime)
    238 
    239         try:
    240             rs = self.executeQuery(sql)
     238        print "sql: " + sql
     239
     240        try:
     241            rs = self.executeQuery(sql)
     242            print "ran sql: " + sql
    241243            rs.first()
    242244            if rs.getInt(1) > 0:
     245                print "***** DID import previously *****"
    243246                self.logger.debugPair("Already imported up-to-date version of",  path)
    244247                return True
    245248            else:
     249                print "***** did NOT import previously *****"
    246250                return False
    247251        except:
     252            print "***** exception in alreadyImportedThisDvoTable *****"
    248253            self.logger.exception("Unable to check whether this DVO table has been imported")
     254
     255        print "***** done with alreadyImportedThisDvoTable *****"
    249256
    250257
     
    322329    '''
    323330    def isCorrectDvo(self, path):
     331
     332        sql = "show tables"
     333        try:
     334            rs = self.executeQuery(sql) 
     335            haveDone = False
     336            while (rs.next()):
     337                tableName = rs.getString(1)
     338                # print "table: " + tableName
     339                if tableName == self.dvoDoneTable:
     340                    haveDone = True
     341                   
     342            rs.close()
     343            if not haveDone:
     344                print "dvoDone not yet build"
     345                return False
     346        except:
     347            print "failed to run query: " + sql
    324348
    325349        sql = "SELECT path FROM " + self.dvoDoneTable + " WHERE path LIKE '%SkyTable.fits'"
     
    415439   
    416440        dvoImagesTable = "dvoImages"
    417         dvoDetectionTable = "dvoDetections"
     441        dvoDetectionTable = "dvoDetection"
    418442
    419443        # drop and create Images table
    420         self.logger.debugPair("Creating DVO table", dvoImagesTable)
     444        self.logger.infoPair("Creating DVO table", dvoImagesTable)
    421445        sql = "DROP TABLE " + dvoImagesTable
    422446
     
    438462
    439463        # now detection table
    440         self.logger.debugPair("Creating DVO table", dvoDetectionTable)
     464        self.logger.infoPair("Dropping DVO table", dvoDetectionTable)
    441465        sql = "DROP TABLE " + dvoDetectionTable
    442466        try: self.execute(sql)
    443         except: pass
    444 
    445         self.logger.debugPair("Creating DVO table", "dvoDetection")
     467        except:
     468            print "problem dropping DVO " + dvoDetectionTable
     469            pass
     470
     471        self.logger.infoPair("Creating DVO table", "dvoDetection")
    446472        sql = "CREATE TABLE dvoDetection ( \
    447                imageID INT, \
    448                ippDetectID BIGINT, \
     473               objID BIGINT, \
    449474               detectID BIGINT, \
    450475               ippObjID BIGINT, \
    451                objID BIGINT, \
    452                flags INT, \
    453                zp FLOAT, \
    454                zpErr FLOAT, \
    455                airMass FLOAT, \
    456                expTime FLOAT, \
     476               ippDetectID BIGINT, \
     477               imageID INT, \
    457478               ra DOUBLE, \
    458479               dec_ DOUBLE, \
    459480               raErr FLOAT, \
    460481               decErr FLOAT, \
     482               zp FLOAT, \
     483               telluricExt FLOAT, \
     484               airmass FLOAT, \
     485               expTime FLOAT, \
     486               flags INT, \
    461487               PRIMARY KEY (imageID, ippDetectID), \
    462488               KEY (objID, detectID) \
     
    466492        except:
    467493            self.logger.error("Unable to create DVO detection database table")
     494            self.sys.exit(1)
    468495
    469496        # XXX EAM : for the parallel mode, dvoDetection requires duplicate objID values!
     
    550577       self.logger.infoPair("Dropping table", self.dvoSkyTable)
    551578       self.dropTable(self.dvoSkyTable)
    552        self.logger.infoPair("Dropping table", self.dvoDetectionTable)
    553        self.dropTable(self.dvoDetectionTable)
    554579       self.logger.infoPair("Dropping table", self.dvoDoneTable)
    555580       self.dropTable(self.dvoDoneTable)
     581
     582       # blow away existing dvoDetection table & re-crate
     583       if not self.resetDvoDetectionTable():
     584           self.logger.errorPair("Unable to reset scratch table", "DvoDetectionFull")
     585           return False
    556586
    557587       # create dvoDone table
     
    564594
    565595       self.changeEngineToInnoDB(self.dvoDoneTable)
    566 
    567        # blow away existing dvoDetection table & re-crate
    568        if not self.resetDvoDetectionTable():
    569            self.logger.errorPair("Unable to reset scratch table", "DvoDetectionFull")
    570            return False
    571596
    572597       return True
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/stackbatch.py

    r36744 r37129  
    3939                 scratchDb,
    4040                 skyID,
    41                  batchID,
    42                  useFullTables):
     41                 batchID):
    4342
    4443       super(StackBatch, self).__init__(
     
    5251               batchID,
    5352               "ST",
    54                "",
    55                #gpc1Db.getStackStageCmf(skychunk.dvoLabel, stackID),
    56                useFullTables)
    57 
    58        # self.printline = 0
    59        # # self.testprint()
    60 #       self.logger.infoPair("did I get", "here");
     53               None)
     54
    6155       self.stackType = "DEEP_STACK" # TODO
    6256       ## = stuff I commented out for pv2 stacks
     
    215209       self.scratchDb.dropTable("StackObject")
    216210       self.logger.infoPair("dropping table:","StackModelFit")
    217               
     211       self.scratchDb.dropTable("SkinnyObject")
    218212       self.scratchDb.dropTable("StackModelFit")
    219213       self.logger.infoPair("dropping table:","StackApFlx")
     
    262256       # insert what we know about this stack batch into the stack table
    263257       self.ippToPspsDb.insertStackMeta(self.batchID, "x" , self.stackType)
    264 
    265        # insert sourceID/imageID combo so DVO can look it up
    266        ##if not self.useFullTables:
    267        ##    self.scratchDb.insertNewDvoExternID(self.header['SOURCEID'], self.header['IMAGEID'])
    268 
    269        # self.testprint()
    270258
    271259       # dump stuff to log
     
    785773        self.logger.infoPair("Deleting", "entries with StackObject.objID = 0")
    786774        # response = raw_input("deleted objID is 0 ")
    787        
     775    '''
     776    Populates the SkinnyObject table
     777    '''
     778    def populateSkinnyObject(self):
     779
     780        self.logger.infoPair("Procesing table", "SkinnyObject")
     781
     782        sql = "INSERT INTO SkinnyObject (\
     783               objID \
     784               ,ippObjID \
     785               ,projectionCellID \
     786               ) \
     787               SELECT \
     788               DISTINCT objID \
     789               ,ippObjID \
     790               ,projectionCellID \
     791               FROM StackDetection"
     792        self.scratchDb.execute(sql)
     793
     794        self.scratchDb.updateAllRows("SkinnyObject", "surveyID", str(self.surveyID))
     795        self.scratchDb.updateAllRows("SkinnyObject", "dataRelease", str(self.skychunk.dataRelease))
     796         
    788797
    789798    '''
     
    11891198        self.logger.infoPair("starting","populatePspsTables");
    11901199        self.skipBatch = False
    1191         if not self.useFullTables:
    1192              if not self.getIDsFromDVO():
    1193                 return False
    1194         #do some basics first
     1200
     1201        # get the IDs from the DVO tables
     1202        if not self.getIDsFromDVO():
     1203            return False
     1204
     1205        # do some basics first:
    11951206        # populate stack meta per filter
    11961207        # insert objid/stackdetectid per filter to each table           
     
    13071318
    13081319        ##if self.totalDetections < 1:
     1320        #self.logger.infoPair("populating","SkinnyObject")
     1321        self.populateSkinnyObject()
    13091322
    13101323            ##self.logger.error("No detections to publish")
     
    13141327        self.tablesToExport.append("StackModelFit")
    13151328        self.tablesToExport.append("StackApFlx")
    1316 
     1329        self.tablesToExport.append("SkinnyObject")
    13171330        self.logger.infoPair("finishing","populatePspsTables");
    13181331        return True
  • branches/eam_branches/ipp-20140717/ippToPsps/test/fulltest.sh

    r35456 r37129  
    171171endif
    172172
    173 #  `name`
    174 #  `datastore_product`
    175 #  `datastore_type`
    176 #  `datastore_publish`
    177 #  `dvo_label`
    178 #  `dvo_location`
    179 #  `min_ra`
    180 #  `max_ra`
    181 #  `min_dec`
    182 #  `max_dec`
    183 #  `box_size`
    184 #  `base_path`
    185 #  `data_release`
    186 #  `delete_local`
    187 #  `delete_datastore`
    188 #  `delete_dxlayer`
    189 #  `epoch`
    190 #  `survey`
    191 #  `psps_survey`
    192 #  `queue_P2`
    193 #  `queue_ST`
    194 #  `queue_OB`
    195 #  `active`
    196 #  `parallel`
    197 
    198173# this is poor : we need to queue something in order to generate an init batch
    199174# this is because a skychunk carries the info about the datastore used to publish
     
    203178  echo " ---- make skychunk for IN batches ----"
    204179
    205   ippjython queue.py -test edit <<EOF
    206 initbatch
    207 test_ds
    208 IPP_PSPS
    209 0
    210 none
    211 none
    212 0
    213 0
    214 0
    215 0
    216 2
    217 none
    218 0
    219 0
    220 1
    221 1
    222 2012-12-10 00:00:00.0
    223 3PI
    224 3PI
    225 0
    226 0
    227 0
    228 1
    229 0
    230 y
    231 y
    232 EOF
     180  echo "initbatch              " >  initbatch.dat # skychunk name
     181  echo "test_ds                " >> initbatch.dat # datastore_product
     182  echo "IPP_PSPS               " >> initbatch.dat # datastore_type
     183  echo "0                      " >> initbatch.dat # datastore_publish
     184  echo "none                   " >> initbatch.dat # dvo_label
     185  echo "none                   " >> initbatch.dat # dvo_location
     186  echo "0                      " >> initbatch.dat # min_ra
     187  echo "0                      " >> initbatch.dat # max_ra
     188  echo "0                      " >> initbatch.dat # min_dec
     189  echo "0                      " >> initbatch.dat # max_dec
     190  echo "2                      " >> initbatch.dat # box_size
     191  echo "none                   " >> initbatch.dat # base_path
     192  echo "0                      " >> initbatch.dat # data_release
     193  echo "0                      " >> initbatch.dat # delete_local
     194  echo "1                      " >> initbatch.dat # delete_datastore
     195  echo "1                      " >> initbatch.dat # delete_dxlayer
     196  echo "2012-12-10 00:00:00.0  " >> initbatch.dat # epoch
     197  echo "3PI                    " >> initbatch.dat # survey
     198  echo "3PI                    " >> initbatch.dat # psps_survey
     199  echo "0                      " >> initbatch.dat # queue_P2
     200  echo "0                      " >> initbatch.dat # queue_ST
     201  echo "0                      " >> initbatch.dat # queue_OB
     202  echo "0                      " >> initbatch.dat # queue_DF
     203  echo "0                      " >> initbatch.dat # queue_DO
     204  echo "0                      " >> initbatch.dat # queue_FW
     205  echo "0                      " >> initbatch.dat # queue_FO
     206  echo "1                      " >> initbatch.dat # active
     207  echo "0                      " >> initbatch.dat # parallel
     208  echo "use_new                " >> initbatch.dat # P2_smf_version
     209  echo "any                    " >> initbatch.dat # ST_cmf_version
     210  echo "2000-01-01 00:00:00.0  " >> initbatch.dat # trange_start
     211  echo "2020-01-01 00:00:00.0  " >> initbatch.dat # trange_end
     212  cat initbatch.dat | ippjython queue.py -test edit
    233213
    234214  echo ""
     
    244224  echo " ---- queue P2 batches ----"
    245225
    246   ippjython queue.py -test edit <<EOF
    247 $queuename
    248 test_ds
    249 IPP_PSPS
    250 0
    251 catdir.cam
    252 $OUTDIR/catdir.cam
    253 9
    254 11
    255 19
    256 21
    257 2
    258 $OUTDIR
    259 0
    260 0
    261 1
    262 1
    263 2012-12-10 00:00:00.0
    264 3PI
    265 3PI
    266 1
    267 0
    268 0
    269 1
    270 0
    271 y
    272 y
    273 EOF
     226  echo "$queuename            " >  cambatch.dat # skychunk name
     227  echo "test_ds               " >> cambatch.dat # datastore_product
     228  echo "IPP_PSPS              " >> cambatch.dat # datastore_type
     229  echo "0                     " >> cambatch.dat # datastore_publish
     230  echo "catdir.cam            " >> cambatch.dat # dvo_label
     231  echo "$OUTDIR/catdir.cam    " >> cambatch.dat # dvo_location
     232  echo "9                     " >> cambatch.dat # min_ra
     233  echo "11                    " >> cambatch.dat # max_ra
     234  echo "19                    " >> cambatch.dat # min_dec
     235  echo "21                    " >> cambatch.dat # max_dec
     236  echo "2                     " >> cambatch.dat # box_size
     237  echo "$OUTDIR               " >> cambatch.dat # base_path
     238  echo "0                     " >> cambatch.dat # data_release
     239  echo "0                     " >> cambatch.dat # delete_local
     240  echo "1                     " >> cambatch.dat # delete_datastore
     241  echo "1                     " >> cambatch.dat # delete_dxlayer
     242  echo "2012-12-10 00:00:00.0 " >> cambatch.dat # epoch
     243  echo "3PI                   " >> cambatch.dat # survey
     244  echo "3PI                   " >> cambatch.dat # psps_survey
     245  echo "1                     " >> cambatch.dat # queue_P2
     246  echo "0                     " >> cambatch.dat # queue_ST
     247  echo "0                     " >> cambatch.dat # queue_OB
     248  echo "0                     " >> cambatch.dat # queue_DF
     249  echo "0                     " >> cambatch.dat # queue_DO
     250  echo "0                     " >> cambatch.dat # queue_FW
     251  echo "0                     " >> cambatch.dat # queue_FO
     252  echo "1                     " >> cambatch.dat # active
     253  echo "0                     " >> cambatch.dat # parallel
     254  echo "use_new               " >> cambatch.dat # P2_smf_version
     255  echo "any                   " >> cambatch.dat # ST_cmf_version
     256  echo "2000-01-01 00:00:00.0 " >> cambatch.dat # trange_start
     257  echo "2020-01-01 00:00:00.0 " >> cambatch.dat # trange_end
     258  cat cambatch.dat | ippjython queue.py -test edit
    274259endif
    275260
     
    290275    set stackqueuename = $queuename\_stk
    291276  endif
    292   ippjython queue.py -test edit <<EOF
    293 $stackqueuename
    294 test_ds
    295 IPP_PSPS
    296 0
    297 catdir.stk
    298 $OUTDIR/catdir.stk
    299 9
    300 11
    301 19
    302 21
    303 2
    304 $OUTDIR
    305 0
    306 0
    307 1
    308 1
    309 2012-12-10 00:00:00.0
    310 3PI
    311 3PI
    312 0
    313 1
    314 0
    315 1
    316 0
    317 y
    318 y
    319 EOF
     277  echo "$stackqueuename       " >  stackbatch.dat # skychunk name
     278  echo "test_ds               " >> stackbatch.dat # datastore_product
     279  echo "IPP_PSPS              " >> stackbatch.dat # datastore_type
     280  echo "0                     " >> stackbatch.dat # datastore_publish
     281  echo "catdir.stk            " >> stackbatch.dat # dvo_label
     282  echo "$OUTDIR/catdir.stk    " >> stackbatch.dat # dvo_location
     283  echo "9                     " >> stackbatch.dat # min_ra
     284  echo "11                    " >> stackbatch.dat # max_ra
     285  echo "19                    " >> stackbatch.dat # min_dec
     286  echo "21                    " >> stackbatch.dat # max_dec
     287  echo "2                     " >> stackbatch.dat # box_size
     288  echo "$OUTDIR               " >> stackbatch.dat # base_path
     289  echo "0                     " >> stackbatch.dat # data_release
     290  echo "0                     " >> stackbatch.dat # delete_local
     291  echo "1                     " >> stackbatch.dat # delete_datastore
     292  echo "1                     " >> stackbatch.dat # delete_dxlayer
     293  echo "2012-12-10 00:00:00.0 " >> stackbatch.dat # epoch
     294  echo "3PI                   " >> stackbatch.dat # survey
     295  echo "3PI                   " >> stackbatch.dat # psps_survey
     296  echo "0                     " >> stackbatch.dat # queue_P2
     297  echo "1                     " >> stackbatch.dat # queue_ST
     298  echo "0                     " >> stackbatch.dat # queue_OB
     299  echo "0                     " >> stackbatch.dat # queue_DF
     300  echo "0                     " >> stackbatch.dat # queue_DO
     301  echo "0                     " >> stackbatch.dat # queue_FW
     302  echo "0                     " >> stackbatch.dat # queue_FO
     303  echo "1                     " >> stackbatch.dat # active
     304  echo "0                     " >> stackbatch.dat # parallel
     305  echo "use_new               " >> stackbatch.dat # P2_smf_version
     306  echo "any                   " >> stackbatch.dat # ST_cmf_version
     307  echo "2000-01-01 00:00:00.0 " >> stackbatch.dat # trange_start
     308  echo "2020-01-01 00:00:00.0 " >> stackbatch.dat # trange_end
     309  cat stackbatch.dat | ippjython queue.py -test edit
    320310endif
    321311
     
    339329    set objectqueuename = $queuename\_obj
    340330  endif
    341   ippjython queue.py -test edit <<EOF
    342 $objectqueuename
    343 test_ds
    344 IPP_PSPS
    345 0
    346 catdir.stk
    347 $OUTDIR/catdir.stk
    348 9
    349 11
    350 19
    351 21
    352 2
    353 $OUTDIR
    354 0
    355 0
    356 1
    357 1
    358 2012-12-10 00:00:00.0
    359 3PI
    360 3PI
    361 0
    362 0
    363 1
    364 1
    365 0
    366 y
    367 y
    368 EOF
     331  echo "$objectqueuename      " >  objectbatch.dat # skychunk name
     332  echo "test_ds               " >> objectbatch.dat # datastore_product
     333  echo "IPP_PSPS              " >> objectbatch.dat # datastore_type
     334  echo "0                     " >> objectbatch.dat # datastore_publish
     335  echo "catdir.cam            " >> objectbatch.dat # dvo_label
     336  echo "$OUTDIR/catdir.cam    " >> objectbatch.dat # dvo_location
     337  echo "9                     " >> objectbatch.dat # min_ra
     338  echo "11                    " >> objectbatch.dat # max_ra
     339  echo "19                    " >> objectbatch.dat # min_dec
     340  echo "21                    " >> objectbatch.dat # max_dec
     341  echo "2                     " >> objectbatch.dat # box_size
     342  echo "$OUTDIR               " >> objectbatch.dat # base_path
     343  echo "0                     " >> objectbatch.dat # data_release
     344  echo "0                     " >> objectbatch.dat # delete_local
     345  echo "1                     " >> objectbatch.dat # delete_datastore
     346  echo "1                     " >> objectbatch.dat # delete_dxlayer
     347  echo "2012-12-10 00:00:00.0 " >> objectbatch.dat # epoch
     348  echo "3PI                   " >> objectbatch.dat # survey
     349  echo "3PI                   " >> objectbatch.dat # psps_survey
     350  echo "0                     " >> objectbatch.dat # queue_P2
     351  echo "0                     " >> objectbatch.dat # queue_ST
     352  echo "1                     " >> objectbatch.dat # queue_OB
     353  echo "0                     " >> objectbatch.dat # queue_DF
     354  echo "0                     " >> objectbatch.dat # queue_DO
     355  echo "0                     " >> objectbatch.dat # queue_FW
     356  echo "0                     " >> objectbatch.dat # queue_FO
     357  echo "1                     " >> objectbatch.dat # active
     358  echo "0                     " >> objectbatch.dat # parallel
     359  echo "use_new               " >> objectbatch.dat # P2_smf_version
     360  echo "any                   " >> objectbatch.dat # ST_cmf_version
     361  echo "2000-01-01 00:00:00.0 " >> objectbatch.dat # trange_start
     362  echo "2020-01-01 00:00:00.0 " >> objectbatch.dat # trange_end
     363  cat objectbatch.dat | ippjython queue.py -test edit once
    369364endif
    370365
  • branches/eam_branches/ipp-20140717/ippToPsps/test/mkgpc1data.dvo

    r35753 r37129  
    3939  # mkcatdir.cam PS1_V3 PS1_V4
    4040  # mkcatdir.stk PS1_V3 PS1_V4
    41   mkcatdir.cam PS1_V4 PS1_V4
    42   mkcatdir.stk PS1_V4 PS1_V4
     41  # mkcatdir.cam PS1_V4 PS1_V4
     42  # mkcatdir.stk PS1_V4 PS1_V4
     43  mkcatdir.cam PS1_V5 PS1_V5
     44  mkcatdir.stk PS1_V5 PS1_V5
    4345  insert.stack.set
    4446end
     
    203205    end
    204206
    205     if ($i == 5)
     207    if (0 && ($i == 5))
    206208      echo "NOTE: adding image $i 2x to DVO, but without detections : this simulates a failure in LAP dvo"
    207209
    208       echo addstar -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass -image -dup-images
    209       exec addstar -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass -image -dup-images
     210      echo addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass -image -dup-images
     211      exec addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass -image -dup-images
    210212    end
    211213
    212     if ($i == 7)
     214    if (0 && ($i == 7))
    213215      echo "NOTE: adding detections from image $i 2x to DVO, but with wrong photcode and duplicate image ID : this simulates a failure in LAP dvo"
    214       echo addstar -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass -dup-images -image-id-override 7 -photcode 2MASS_J
    215       exec addstar -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass -dup-images -image-id-override 7 -photcode 2MASS_J
     216      echo addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass -dup-images -image-id-override 7 -photcode 2MASS_J
     217      exec addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass -dup-images -image-id-override 7 -photcode 2MASS_J
    216218    end
    217219
    218     echo addstar -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass
    219     exec addstar -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass
    220   end
     220    echo addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass
     221    exec addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass
     222  end
     223
     224  echo relphot -D CATDIR $catdir -region 8 12 18 22 -images g,r,i,z,y -update
     225  exec relphot -D CATDIR $catdir -region 8 12 18 22 -images g,r,i,z,y -update
    221226
    222227  if ($PARALLEL)
     
    264269    $offset = $word:2
    265270
     271    ## this is not generating photcodes recognized as stack by relphot
     272
    266273    mkinput $offset $rawfile
    267274    exec mkcmf $rawfile $cmffile -extname SkyChip -date 2008/1/1 -time $i\:00:00 -radec $RA $DEC -type $1 -imageID $ID -sourceID 1
     
    271278    exec fits_insert $cmffile tmp.hdr
    272279
    273     exec addstar -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass
    274   end
     280    echo addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass
     281    exec addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass
     282  end
     283
     284  echo relphot -D CATDIR $catdir.stk -region 8 12 18 22 -images g,r,i,z,y -update
     285  exec relphot -D CATDIR $catdir.stk -region 8 12 18 22 -images g,r,i,z,y -update
    275286
    276287  if ($PARALLEL)
Note: See TracChangeset for help on using the changeset viewer.