IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37133


Ignore:
Timestamp:
Jul 29, 2014, 9:52:00 AM (12 years ago)
Author:
eugene
Message:

scatter some debugging prints around; replace safeDictionaryAccess (terrible name) with getKeyValue; fix use of strings vs sql words in insert queries; fix detections for new schema; remove use of old dvograbber-based code; clean some avoidable errors

Location:
branches/eam_branches/ipp-20140717/ippToPsps/jython
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py

    r37129 r37133  
    230230    '''
    231231    def safeDictionaryAccess(self, header, key):
     232
     233         if key in header: return header[key]
     234         else:
     235             self.logger.errorPair("Missing header field", key)
     236             return "NULL"
     237
     238    '''
     239    Returns the string keyword value from this header or else "NULL"
     240    '''
     241    def getKeyValue(self, header, key):
    232242
    233243         if key in header: return header[key]
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py

    r37129 r37133  
    125125        sqlLine = sqlUtility("INSERT INTO FrameMeta (")
    126126
     127        # sqlLine.group("p1Recip",               ' ');
     128        # sqlLine.group("p2Recip",               ' ');
     129        # sqlLine.group("p3Recip",               ' ');
     130
    127131        sqlLine.group("frameID",               str(self.expID));
    128132        sqlLine.group("frameName",             self.expName);
     
    130134        sqlLine.group("cameraConfigID",        "1");
    131135        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')");
     136        sqlLine.group("analysisVer",           self.analysisVer);
     137        sqlLine.group("photoScat",             self.getKeyValue(self.header, 'ZPT_ERR'));
     138        sqlLine.group("expStart",              self.getKeyValue(self.header, 'MJD-OBS'));
     139        sqlLine.group("expTime",               self.getKeyValue(self.header, 'EXPREQ'));
     140        sqlLine.group("airmass",               self.getKeyValue(self.header, 'AIRMASS'));
     141        sqlLine.group("raBore",                self.getKeyValue(self.header, 'RA'));
     142        sqlLine.group("decBore",               self.getKeyValue(self.header, 'DEC'));
     143        sqlLine.group("ctype1",                self.getKeyValue(self.header, 'CTYPE1'));
     144        sqlLine.group("ctype2",                self.getKeyValue(self.header, 'CTYPE2'));
     145        sqlLine.group("crval1",                self.getKeyValue(self.header, 'CRVAL1'));
     146        sqlLine.group("crval2",                self.getKeyValue(self.header, 'CRVAL2'));
     147        sqlLine.group("crpix1",                self.getKeyValue(self.header, 'CRPIX1'));
     148        sqlLine.group("crpix2",                self.getKeyValue(self.header, 'CRPIX2'));
     149        sqlLine.group("cdelt1",                self.getKeyValue(self.header, 'CDELT1'));
     150        sqlLine.group("cdelt2",                self.getKeyValue(self.header, 'CDELT2'));
     151        sqlLine.group("pc001001",              self.getKeyValue(self.header, 'PC001001'));
     152        sqlLine.group("pc001002",              self.getKeyValue(self.header, 'PC001002'));
     153        sqlLine.group("pc002001",              self.getKeyValue(self.header, 'PC002001'));
     154        sqlLine.group("pc002002",              self.getKeyValue(self.header, 'PC002002'));
     155        sqlLine.group("polyOrder",             self.getKeyValue(self.header, 'NPLYTERM'));
     156        sqlLine.group("pca1x3y0",              self.getKeyValue(self.header, 'PCA1X3Y0'));
     157        sqlLine.group("pca1x2y1",              self.getKeyValue(self.header, 'PCA1X2Y1'));
     158        sqlLine.group("pca1x1y2",              self.getKeyValue(self.header, 'PCA1X1Y2'));
     159        sqlLine.group("pca1x0y3",              self.getKeyValue(self.header, 'PCA1X0Y3'));
     160        sqlLine.group("pca1x2y0",              self.getKeyValue(self.header, 'PCA1X2Y0'));
     161        sqlLine.group("pca1x1y1",              self.getKeyValue(self.header, 'PCA1X1Y1'));
     162        sqlLine.group("pca1x0y2",              self.getKeyValue(self.header, 'PCA1X0Y2'));
     163        sqlLine.group("pca2x3y0",              self.getKeyValue(self.header, 'PCA2X3Y0'));
     164        sqlLine.group("pca2x2y1",              self.getKeyValue(self.header, 'PCA2X2Y1'));
     165        sqlLine.group("pca2x1y2",              self.getKeyValue(self.header, 'PCA2X1Y2'));
     166        sqlLine.group("pca2x0y3",              self.getKeyValue(self.header, 'PCA2X0Y3'));
     167        sqlLine.group("pca2x2y0",              self.getKeyValue(self.header, 'PCA2X2Y0'));
     168        sqlLine.group("pca2x1y1",              self.getKeyValue(self.header, 'PCA2X1Y1'));
     169        sqlLine.group("pca2x0y2",              self.getKeyValue(self.header, 'PCA2X0Y2'));
    169170
    170171        sql = sqlLine.make(") VALUES ( ", ")")
     
    193194        else: ccdID = 0
    194195
    195         psfFwhm = 0.5*(self.safeDictionaryAccess(header, 'FWHM_MAJ') + self.safeDictionaryAccess(header, 'FWHM_MIN'))
     196        psfFwhmMajor = self.getKeyValue(header, 'FWHM_MAJ')
     197        psfFwhmMinor = self.getKeyValue(header, 'FWHM_MIN')
     198        if ((psfFwhmMajor == "NULL") or (psfFwhmMajor == "NULL")):
     199            psfFwhm = "NULL"
     200        else:
     201            psfFwhm = 0.5*(psfFwhmMajor + psfFwhmMinor)
    196202
    197203        # insert image metadata into table
     
    202208        sqlLine.group("bias",             str(self.bias))
    203209        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')")
     210        sqlLine.group("sky",              self.getKeyValue(header, 'MSKY_MN'))
     211        sqlLine.group("skyScat",          self.getKeyValue(header, 'MSKY_SIG'))
     212        sqlLine.group("magSat",           self.getKeyValue(header, 'FSATUR'))
     213        sqlLine.group("completMag",       self.getKeyValue(header, 'FLIMIT'))
     214        sqlLine.group("astroScat",        self.getKeyValue(header, 'CERROR'))
     215        sqlLine.group("photoScat",        self.getKeyValue(self.header, 'ZPT_OBS'))
     216        sqlLine.group("numAstroRef",      self.getKeyValue(header, 'NASTRO'))
     217        sqlLine.group("numPhotoRef",      self.getKeyValue(header, 'NASTRO'))
     218        sqlLine.group("nx",               self.getKeyValue(header, 'CNAXIS1'))
     219        sqlLine.group("ny",               self.getKeyValue(header, 'CNAXIS2'))
    214220        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')")
     221        sqlLine.group("psfWidMajor",      str(psfFwhmMajor))
     222        sqlLine.group("psfWidMinor",      str(psfFwhmMinor))
     223        sqlLine.group("psfTheta",         self.getKeyValue(header, 'ANGLE'))
    218224        sqlLine.group("momentXX",         "-999")
    219225        sqlLine.group("momentXY",         "-999")
     
    225231        sqlLine.group("momentR1",         "-999")
    226232        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'))
     233        sqlLine.group("apResid",          self.getKeyValue(header, 'APMIFIT'))
     234        sqlLine.group("dapResid",         self.getKeyValue(header, 'DAPMIFIT'))
     235        sqlLine.group("detectorID",       self.getKeyValue(header, 'DETECTOR'))
    230236        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')")
     237        sqlLine.group("detrend1",         self.getKeyValue(header, 'DETREND.MASK'))
     238        sqlLine.group("detrend2",         self.getKeyValue(header, 'DETREND.DARK'))
     239        sqlLine.group("detrend3",         self.getKeyValue(header, 'DETREND.FLAT'))
     240        # sqlLine.group("detrend4",         " ")
     241        # sqlLine.group("detrend5",         " ")
     242        # sqlLine.group("detrend6",         " ")
     243        # sqlLine.group("detrend7",         " ")
     244        # sqlLine.group("detrend8",         " ")
     245        sqlLine.group("photoZero",        self.getKeyValue(self.header, 'ZPT_OBS'))
     246        sqlLine.group("ctype1",           self.getKeyValue(header, 'CTYPE1'))
     247        sqlLine.group("ctype2",           self.getKeyValue(header, 'CTYPE2'))
     248        sqlLine.group("crval1",           self.getKeyValue(header, 'CRVAL1'))
     249        sqlLine.group("crval2",           self.getKeyValue(header, 'CRVAL2'))
     250        sqlLine.group("crpix1",           self.getKeyValue(header, 'CRPIX1'))
     251        sqlLine.group("crpix2",           self.getKeyValue(header, 'CRPIX2'))
     252        sqlLine.group("cdelt1",           self.getKeyValue(header, 'CDELT1'))
     253        sqlLine.group("cdelt2",           self.getKeyValue(header, 'CDELT2'))
     254        sqlLine.group("pc001001",         self.getKeyValue(header, 'PC001001'))
     255        sqlLine.group("pc001002",         self.getKeyValue(header, 'PC001002'))
     256        sqlLine.group("pc002001",         self.getKeyValue(header, 'PC002001'))
     257        sqlLine.group("pc002002",         self.getKeyValue(header, 'PC002002'))
     258        sqlLine.group("polyOrder",        self.getKeyValue(header, 'NPLYTERM'))
     259        sqlLine.group("pca1x3y0",         self.getKeyValue(header, 'PCA1X3Y0'))
     260        sqlLine.group("pca1x2y1",         self.getKeyValue(header, 'PCA1X2Y1'))
     261        sqlLine.group("pca1x1y2",         self.getKeyValue(header, 'PCA1X1Y2'))
     262        sqlLine.group("pca1x0y3",         self.getKeyValue(header, 'PCA1X0Y3'))
     263        sqlLine.group("pca1x2y0",         self.getKeyValue(header, 'PCA1X2Y0'))
     264        sqlLine.group("pca1x1y1",         self.getKeyValue(header, 'PCA1X1Y1'))
     265        sqlLine.group("pca1x0y2",         self.getKeyValue(header, 'PCA1X0Y2'))
     266        sqlLine.group("pca2x3y0",         self.getKeyValue(header, 'PCA2X3Y0'))
     267        sqlLine.group("pca2x2y1",         self.getKeyValue(header, 'PCA2X2Y1'))
     268        sqlLine.group("pca2x1y2",         self.getKeyValue(header, 'PCA2X1Y2'))
     269        sqlLine.group("pca2x0y3",         self.getKeyValue(header, 'PCA2X0Y3'))
     270        sqlLine.group("pca2x2y0",         self.getKeyValue(header, 'PCA2X2Y0'))
     271        sqlLine.group("pca2x1y1",         self.getKeyValue(header, 'PCA2X1Y1'))
     272        sqlLine.group("pca2x0y2",         self.getKeyValue(header, 'PCA2X0Y2'))
    267273
    268274        sql = sqlLine.make(") VALUES ( ", ")")
     
    340346        sqlLine.group("apFlux",          "AP_FLUX / " + extTimeString)
    341347        sqlLine.group("apFluxErr",       "AP_FLUX_SIG / " + extTimeString)
    342         sqlLine.group("apFluxNpix",      "AP_NPIX")
     348        sqlLine.group("apFillF",         "AP_NPIX / (3.1416 * AP_MAG_RADIUS * AP_MAG_RADIUS)")
     349        sqlLine.group("apRadius",        "AP_MAG_RADIUS")
    343350        sqlLine.group("kronFlux",        "KRON_FLUX / " + extTimeString)
    344351        sqlLine.group("kronFluxErr",     "KRON_FLUX_ERR / " + extTimeString)
     
    350357        sqlLine.group("dataRelease",     str(self.skychunk.dataRelease))                 
    351358
    352         sqlLine.make(") SELECT ", " FROM " + ippTableName)
    353 
     359        sql = sqlLine.makeRaw(") SELECT ", " FROM " + ippTableName)
    354360        print "sql: " + sql
    355361
     
    450456       
    451457        # check we have valid sourceID/imageID pair from the header
    452         if self.safeDictionaryAccess(header, 'SOURCEID') == "NULL": return False
    453         if self.safeDictionaryAccess(header, 'IMAGEID') == "NULL": return False
     458        if self.getKeyValue(header, 'SOURCEID') == "NULL": return False
     459        if self.getKeyValue(header, 'IMAGEID') == "NULL": return False
    454460       
    455         # store sourceID/imageID combo in Db so DVO can look up later
    456         self.scratchDb.insertNewDvoExternID(header['SOURCEID'], header['IMAGEID'])
     461        # store sourceID/imageID combo in Db so DVO can look up later (XXX deprecated?)
     462        # self.scratchDb.insertNewDvoExternID(header['SOURCEID'], header['IMAGEID'])
    457463           
    458464        # store these for later
     
    501507        self.alterPspsTablesChip("Chip", "Chip.hdr", 0, 0)
    502508
    503         # now run DVO code to get all IDs
    504         if not self.getIDsFromDVO(): return False
     509        # now run DVO code to get all IDs ( XXX deprecated, uses dvograbber)
     510        # if not self.getIDsFromDVO(): return False
    505511
    506512        # dec is reserved in MySQL, so STILTS replaces if with dec_, which is not the name of
     
    547553               a.ippObjID     = b.ippObjID, \
    548554               a.ra           = b.ra, \
    549                a.dec_         = b.dec_, \
     555               a.dec          = b.dec_, \
    550556               a.raErr        = b.raErr, \
    551557               a.decErr       = b.decErr, \
     
    791797       # columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG PSF_INST_MAG PSF_INST_MAG_SIG PSF_INST_FLUX PSF_INST_FLUX_SIG PEAK_FLUX_AS_MAG PSF_MAJOR PSF_MINOR PSF_THETA EXT_NSIGMA PSF_QF MOMENTS_XX MOMENTS_XY MOMENTS_YY AP_MAG AP_FLUX KRON_FLUX KRON_FLUX_ERR FLAGS FLAGS2 SKY SKY_SIGMA EXT_NSIGMA PSF_QF_PERFECT PSF_CHISQ"
    792798
    793        # XXX EAM NOTE : this is fragile : requires PS1_V4
    794        columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG PSF_INST_MAG PSF_INST_MAG_SIG PSF_INST_FLUX PSF_INST_FLUX_SIG PEAK_FLUX_AS_MAG PSF_MAJOR PSF_MINOR PSF_THETA EXT_NSIGMA PSF_QF MOMENTS_XX MOMENTS_XY MOMENTS_YY MOMENTS_R1 MOMENTS_RH MOMENTS_M3C MOMENTS_M3S MOMENTS_M4C MOMENTS_M4S AP_MAG KRON_FLUX KRON_FLUX_ERR FLAGS FLAGS2 SKY SKY_SIGMA EXT_NSIGMA PSF_QF_PERFECT PSF_CHISQ POSANGLE PLTSCALE"
     799       # XXX EAM NOTE : this is fragile : requires PS1_V5
     800       columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG POSANGLE PLTSCALE PSF_INST_FLUX PSF_INST_FLUX_SIG PSF_FWHM_MAJ PSF_FWHM_MIN PSF_THETA PSF_CORE PSF_QF PSF_QF_PERFECT PSF_CHISQ EXT_NSIGMA MOMENTS_XX MOMENTS_XY MOMENTS_YY MOMENTS_R1 MOMENTS_RH MOMENTS_M3C MOMENTS_M3S MOMENTS_M4C MOMENTS_M4S AP_FLUX AP_FLUX_SIG AP_NPIX AP_MAG_RADIUS KRON_FLUX KRON_FLUX_ERR SKY SKY_SIGMA FLAGS FLAGS2"
    795801
    796802       return super(DetectionBatch, self).importIppTables(columns, regex)
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/dvo.py

    r37129 r37133  
    684684
    685685        if (useP2 ==1 and useST==0):
    686             #grabd only P2s   
    687             cmd += " -photcode-start 10000 -photcode-end 10577"
    688 
     686            #grab only P2s (4000-4500 are test cameras, SIMTEST and SIMMOSAIC)
     687            # XXX EAM 20140729 : this is a terrible hack...
     688            cmd += " -photcode-start 4000 -photcode-end 10577"
    689689
    690690        self.logger.infoPair("Running dvopsps", cmd)
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/gpc1db.py

    r36715 r37133  
    117117            stage = "forcedwarp"
    118118            sql = "SELECT differentStuff from Stufftable"
     119
     120        print "SQL: " + sql
    119121
    120122        try:
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/initbatch.py

    r35097 r37133  
    3333            scratchDb,
    3434            batchID):
     35
    3536       super(InitBatch, self).__init__(logger,
    3637               config,
     
    4243               batchID,
    4344               "IN",
    44                None,
    45                0)
     45               None)
    4646
    4747       self.outputFitsFile = "00000000.FITS";
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/ipptopsps.py

    r37129 r37133  
    155155        while not self.refreshSkychunk() or self.ippToPspsDb.isPaused(self.HOST, self.PID):
    156156
     157            print "looping in ipptopsps"
     158
    157159            self.ippToPspsDb.updateClient(self.config.programName, self.HOST, self.PID)
    158160            if self.ippToPspsDb.isKilled(self.HOST, self.PID):
     
    162164            time.sleep(self.PAUSEPERIOD)
    163165
     166        print "DONE looping in ipptopsps"
    164167
    165168    '''
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/ipptopspsdb.py

    r37129 r37133  
    11361136
    11371137        self.skychunk.batchTypes = []
    1138         try:
    1139             # print "sql: " + sql
    1140             rs = self.executeQuery(sql)
    1141 
    1142             rs.first()
    1143             self.skychunk.datastoreProduct = rs.getString(1)
    1144             self.skychunk.datastoreType = rs.getString(2)
    1145             if rs.getInt(3) == 1: self.skychunk.datastorePublishing = True
    1146             else: self.skychunk.datastorePublishing = False
    1147             self.skychunk.dvoLabel = rs.getString(4)
    1148 
    1149             # if dvoLabel is null is can break queries, so set to something
    1150             if not self.skychunk.dvoLabel: self.skychunk.dvoLabel = "none"
    1151             self.skychunk.dvoLocation = rs.getString(5)
    1152             self.skychunk.minRa = rs.getDouble(6)
    1153             self.skychunk.maxRa = rs.getDouble(7)
    1154             self.skychunk.minDec = rs.getDouble(8)
    1155             self.skychunk.maxDec = rs.getDouble(9)
    1156 
    1157             self.skychunk.boxSize = rs.getDouble(10)
    1158             # self.skychunk.halfBox = self.skychunk.boxSize/2.0
    1159             # self.skychunk.boxSizeWithBorder = self.skychunk.boxSize + (self.skychunk.BORDER * 2)
    1160 
    1161             self.skychunk.basePath = rs.getString(11)
    1162             self.skychunk.dataRelease = rs.getInt(12)
    1163 
    1164             self.skychunk.deleteLocal = rs.getInt(13)
    1165             self.skychunk.deleteDatastore = rs.getInt(14)
    1166             self.skychunk.deleteDxLayer = rs.getInt(15)
    1167 
    1168             self.skychunk.epoch = rs.getString(16)
    1169 
    1170             self.skychunk.survey = rs.getString(17)
    1171             self.skychunk.pspsSurvey = rs.getString(18)
    1172 
    1173             if rs.getInt(19) == 1: self.skychunk.batchTypes.append("P2")
    1174             if rs.getInt(20) == 1: self.skychunk.batchTypes.append("ST")
    1175             if rs.getInt(21) == 1: self.skychunk.batchTypes.append("OB")
    1176             if rs.getInt(22) == 1: self.skychunk.batchTypes.append("DF")
    1177             if rs.getInt(23) == 1: self.skychunk.batchTypes.append("DO")
    1178             if rs.getInt(24) == 1: self.skychunk.batchTypes.append("FW")
    1179             if rs.getInt(25) == 1: self.skychunk.batchTypes.append("FO")
    1180 
    1181             self.skychunk.force = True # TODO
    1182             self.skychunk.parallel = False # TODO
    1183 
    1184             if rs.getInt(26) == 1: self.skychunk.parallel = True
    1185             self.skychunk.P2_smf_version = rs.getString(27)
    1186             # options: "use_new", "not_reproc", "use_original"
    1187 
    1188             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 
    1213             self.skychunk.trange_start = rs.getString(29)
    1214             # options: "YYYY-MM-DD,HH:MM:SS" or "0000-00-00 00:00:00"
    1215 
    1216             self.skychunk.trange_end = rs.getString(30)
    1217             # options: "YYYY-MM-DD,HH:MM:SS" or "0000-00-00 00:00:00"
    1218 
    1219             if self.skychunk.parallel: print "USING parallel"
    1220             self.skychunk.isLoaded = True
    1221         except:
     1138
     1139        try:
     1140            rs = self.executeQuery("show tables")
     1141        except:
     1142            self.logger.errorPair("cannot even show tables?", "Boo hoo")
     1143            sys.exit(1)
     1144
     1145        # while rs.next():
     1146        #     print "table row"
     1147        #     print rs.getString(1)
     1148        #
     1149        # rs = self.executeQuery("select * from skychunk")
     1150        # while rs.next():
     1151        #     print "skychunk row"
     1152        #     print rs.getString(1)
     1153        #
     1154        # print "SQL (2): " + sql
     1155
     1156        try:
     1157            rs = self.executeQuery(sql)
     1158
     1159        except:
     1160            self.logger.errorPair("problem with sql query for skychunk", sql)
     1161            sys.exit(1)
     1162
     1163        if not rs.next():
    12221164            self.logger.errorPair("Could not read skychunk with name", self.skychunk.name)
    12231165            self.skychunk.isLoaded = False
     1166            return False
     1167
     1168        self.skychunk.datastoreProduct = rs.getString(1)
     1169        self.skychunk.datastoreType = rs.getString(2)
     1170        if rs.getInt(3) == 1: self.skychunk.datastorePublishing = True
     1171        else: self.skychunk.datastorePublishing = False
     1172        self.skychunk.dvoLabel = rs.getString(4)
     1173
     1174        # if dvoLabel is null is can break queries, so set to something
     1175        if not self.skychunk.dvoLabel: self.skychunk.dvoLabel = "none"
     1176        self.skychunk.dvoLocation = rs.getString(5)
     1177        self.skychunk.minRa = rs.getDouble(6)
     1178        self.skychunk.maxRa = rs.getDouble(7)
     1179        self.skychunk.minDec = rs.getDouble(8)
     1180        self.skychunk.maxDec = rs.getDouble(9)
     1181
     1182        self.skychunk.boxSize = rs.getDouble(10)
     1183        # self.skychunk.halfBox = self.skychunk.boxSize/2.0
     1184        # self.skychunk.boxSizeWithBorder = self.skychunk.boxSize + (self.skychunk.BORDER * 2)
     1185
     1186        self.skychunk.basePath = rs.getString(11)
     1187        self.skychunk.dataRelease = rs.getInt(12)
     1188
     1189        self.skychunk.deleteLocal = rs.getInt(13)
     1190        self.skychunk.deleteDatastore = rs.getInt(14)
     1191        self.skychunk.deleteDxLayer = rs.getInt(15)
     1192
     1193        self.skychunk.epoch = rs.getString(16)
     1194
     1195        self.skychunk.survey = rs.getString(17)
     1196        self.skychunk.pspsSurvey = rs.getString(18)
     1197
     1198        if rs.getInt(19) == 1: self.skychunk.batchTypes.append("P2")
     1199        if rs.getInt(20) == 1: self.skychunk.batchTypes.append("ST")
     1200        if rs.getInt(21) == 1: self.skychunk.batchTypes.append("OB")
     1201        if rs.getInt(22) == 1: self.skychunk.batchTypes.append("DF")
     1202        if rs.getInt(23) == 1: self.skychunk.batchTypes.append("DO")
     1203        if rs.getInt(24) == 1: self.skychunk.batchTypes.append("FW")
     1204        if rs.getInt(25) == 1: self.skychunk.batchTypes.append("FO")
     1205
     1206        self.skychunk.force = True # TODO
     1207        self.skychunk.parallel = False # TODO
     1208
     1209        if rs.getInt(26) == 1: self.skychunk.parallel = True
     1210        self.skychunk.P2_smf_version = rs.getString(27)
     1211        # options: "use_new", "not_reproc", "use_original"
     1212
     1213        self.skychunk.ST_cmf_version = rs.getString(28)
     1214        # options: not used?
     1215
     1216        # NOTE : the rs (ResultSet) class is somewhat annoying and finicky esp about timestamp values
     1217        # for example, rs.getTimestamp(N) fails silently if the value is not a valid time.  this is
     1218        # also true to getString() on the same column.  Docs for the ResultSet class can be found here:
     1219        # http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/ResultSet.html?is-external=true
     1220
     1221        # rsmd = rs.getMetaData()
     1222        # print "got metadata"
     1223        # print "number of columns: " + str(rsmd.getColumnCount())
     1224        # print "label: " + rsmd.getColumnLabel(25)
     1225        # print "label: " + rsmd.getColumnLabel(29)
     1226        # print "name: " + rsmd.getColumnName(25)
     1227        # print "name: " + rsmd.getColumnName(29)
     1228        # print "typename: " + rsmd.getColumnTypeName(25)
     1229        # print "typename: " + rsmd.getColumnTypeName(29)
     1230
     1231        # epochStamp = rs.getTimestamp(16)
     1232        # print "epoch: " + epochStamp.toString()
     1233
     1234        # print "label: " + rsmd.getColumnLabel(16)
     1235        # print "name: " + rsmd.getColumnName(16)
     1236        # print "typename: " + rsmd.getColumnTypeName(16)
     1237
     1238        self.skychunk.trange_start = rs.getString(29)
     1239        # options: "YYYY-MM-DD,HH:MM:SS" or "0000-00-00 00:00:00"
     1240
     1241        self.skychunk.trange_end = rs.getString(30)
     1242        # options: "YYYY-MM-DD,HH:MM:SS" or "0000-00-00 00:00:00"
     1243
     1244        if self.skychunk.parallel: print "USING parallel"
     1245        self.skychunk.isLoaded = True
    12241246
    12251247        return self.skychunk.isLoaded
     
    13871409        # XXX print "sql: ", sql               
    13881410
    1389         try:
    1390             rs = self.executeQuery(sql)
    1391             rs.first()
    1392             raCenter = rs.getFloat(1)
    1393             rs.close()
    1394         except:
    1395             self.logger.errorPair("No free stripes", "trying to steal boxes from other client...")
    1396             sql = "SELECT ra_center, COUNT(*) AS numPending\
    1397                    FROM box \
    1398                    JOIN pending ON (id = box_id) \
    1399                    WHERE skychunk = '" + self.skychunk.name + "' \
    1400                    AND batch_type = '" + batchType + "' \
    1401                    GROUP BY ra_center \
    1402                    ORDER BY numPending \
    1403                    DESC LIMIT 1"
    1404 
    1405             try:
    1406                 rs = self.executeQuery(sql)
    1407                 rs.first()
    1408                 raCenter = rs.getFloat(1)
    1409                 rs.close()
    1410             except:
    1411                 self.logger.errorPair("No outstanding boxes to steal", "no stripe obtained")
     1411        try: rs = self.executeQuery(sql)
     1412        except:
     1413            self.logger.errorPair("Problem querying for outstanding boxes", "error in sql?")
     1414            print "SQL: " + sql
     1415
     1416        print "SQL: " + sql
     1417        if not rs.next():
     1418            self.logger.errorPair("No outstanding boxes", "nothing to do here")
     1419            rs.close()
     1420            self.unlockTables()
     1421            return ids
     1422
     1423        raCenter = rs.getFloat(1)
     1424        rs.close()
     1425
     1426        #except:
     1427        #    self.logger.errorPair("No free stripes", "trying to steal boxes from other client...")
     1428        #    sql = "SELECT ra_center, COUNT(*) AS numPending\
     1429        #           FROM box \
     1430        #           JOIN pending ON (id = box_id) \
     1431        #           WHERE skychunk = '" + self.skychunk.name + "' \
     1432        #           AND batch_type = '" + batchType + "' \
     1433        #           GROUP BY ra_center \
     1434        #           ORDER BY numPending \
     1435        #           DESC LIMIT 1"
     1436        #
     1437        #    try:
     1438        #        rs = self.executeQuery(sql)
     1439        #        rs.first()
     1440        #        raCenter = rs.getFloat(1)
     1441        #        rs.close()
     1442        #    except:
     1443        #        self.logger.errorPair("No outstanding boxes to steal", "no stripe obtained")
    14121444
    14131445        # tests against ra_center need to use a finite box
     
    14581490               GROUP BY ra_center LIMIT 1"
    14591491
    1460         try:
    1461             rs = self.executeQuery(sql)
    1462             rs.first()
    1463             raCenter = rs.getFloat(1)
    1464             rs.close()
    1465         except:
    1466             self.logger.errorPair("No free stripes", "trying to steal boxes from other client...")
    1467             sql = "SELECT ra_center, COUNT(*) AS numPending\
    1468                    FROM box \
    1469                    JOIN pending ON (id = box_id) \
    1470                    WHERE skychunk = '" + self.skychunk.name + "' \
    1471                    GROUP BY ra_center \
    1472                    ORDER BY numPending \
    1473                    DESC LIMIT 1"
    1474 
    1475             try:
    1476                 rs = self.executeQuery(sql)
    1477                 rs.first()
    1478                 raCenter = rs.getFloat(1)
    1479                 rs.close()
    1480             except:
    1481                 self.logger.errorPair("No outstanding boxes to steal", "no stripe obtained")
     1492        try: rs = self.executeQuery(sql)
     1493        except:
     1494            self.logger.errorPair("Problem querying for outstanding boxes", "error in sql?")
     1495            print "SQL: " + sql
     1496
     1497        print "SQL: " + sql
     1498        if not rs.next():
     1499            self.logger.infoPair("No outstanding boxes", "nothing to do here")
     1500            rs.close()
     1501            self.unlockTables()
     1502            return ids
     1503
     1504        raCenter = rs.getFloat(1)
     1505        rs.close()
     1506
     1507        # except:
     1508        #     self.logger.errorPair("No free stripes", "trying to steal boxes from other client...")
     1509        #     sql = "SELECT ra_center, COUNT(*) AS numPending\
     1510        #            FROM box \
     1511        #            JOIN pending ON (id = box_id) \
     1512        #            WHERE skychunk = '" + self.skychunk.name + "' \
     1513        #            GROUP BY ra_center \
     1514        #            ORDER BY numPending \
     1515        #            DESC LIMIT 1"
     1516        #
     1517        #     try:
     1518        #         rs = self.executeQuery(sql)
     1519        #         rs.first()
     1520        #         raCenter = rs.getFloat(1)
     1521        #         rs.close()
     1522        #     except:
     1523        #         self.logger.errorPair("No outstanding boxes to steal", "no stripe obtained")
    14821524
    14831525        # tests against ra_center need to use a finite box
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/loader.py

    r37129 r37133  
    8282
    8383        self.skychunk.printAll()
     84        print "done with loader.py init"
    8485
    8586    '''
     
    174175                    self.logger.infoPair("processed","ok")
    175176
     177            self.logger.infoPair("done with processing boxes, numAttempts: ", str(numAttempts))
    176178            if abort or not self.checkClientStatus(): abort = True
    177179            elif numAttempts > 1 and not self.waitForPollTime():  break
     180
     181            print "done with wait?"
    178182
    179183            if self.onePassOnly: self.exitProgram("one pass completed")
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/queue.py

    r37129 r37133  
    6363    '''
    6464    def run(self):
    65         print "here"
     65        self.logger.info("------------- starting queue.run -----------------")
    6666        # this outer while loop simply waits a few minutes then starts queuing again (as more stuff may appear in DVO over time)
    6767        while True:
    6868
    6969            self.ippToPspsDb.removeAllBoxes()
    70             print "remove boxes"
     70
    7171            # queue up batches that are processed but not loaded to datastore
    7272            for batchType in self.skychunk.batchTypes:
     
    7777                # get totals for whole area to check if there is anything to do
    7878                processedIDs = self.ippToPspsDb.getProcessedIDs(batchType)
    79                 print "got processed ids"
    8079                consistantlyFailedIDs = self.ippToPspsDb.getConsistentlyFailedIDs(batchType)
    81                 print "got here"
     80
    8281                # for object batches, get full list of stuff from Dvo
    8382                # XXX : need to fix 'dvo.setSkyArea' or this may not return the full list for a parallel dvo
    84             #for object-like batches, info comes from dvo
     83
     84                # for object-like batches, info comes from dvo
    8585                if (batchType == "OB" or batchType =="DO" or batchType =="FO"):
    8686                    self.dvoObjects.setSkyArea(
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/scratchdb.py

    r37129 r37133  
    229229    def alreadyImportedThisDvoTable(self, path):
    230230
    231         print "***** alreadyImportedThisDvoTable *****"
    232         print "path: " + path
    233 
    234231        fileStat = os.stat(path)
    235         print "path: " + path
    236232
    237233        sql = "SELECT COUNT(*) FROM " + self.dvoDoneTable + " WHERE path = '" + path + "' AND modifiedDate = " + str(fileStat.st_mtime)
    238         print "sql: " + sql
    239 
    240         try:
    241             rs = self.executeQuery(sql)
    242             print "ran sql: " + sql
     234
     235        try:
     236            rs = self.executeQuery(sql)
    243237            rs.first()
    244238            if rs.getInt(1) > 0:
    245                 print "***** DID import previously *****"
    246239                self.logger.debugPair("Already imported up-to-date version of",  path)
    247240                return True
    248241            else:
    249                 print "***** did NOT import previously *****"
     242                self.logger.infoPair("Did NOT already import from",  path)
    250243                return False
    251244        except:
    252245            print "***** exception in alreadyImportedThisDvoTable *****"
    253246            self.logger.exception("Unable to check whether this DVO table has been imported")
    254 
    255         print "***** done with alreadyImportedThisDvoTable *****"
    256 
    257247
    258248    '''
     
    342332            rs.close()
    343333            if not haveDone:
    344                 print "dvoDone not yet build"
     334                self.logger.info("dvoDone not yet built")
    345335                return False
    346         except:
    347             print "failed to run query: " + sql
     336
     337        except Exception, e:
     338            print str(e)
     339            self.logger.errorPair("problem examining table", sql)
     340            sys.exit(1)
    348341
    349342        sql = "SELECT path FROM " + self.dvoDoneTable + " WHERE path LIKE '%SkyTable.fits'"
    350         try:
    351             rs = self.executeQuery(sql) 
    352             rs.first()
    353 
     343        try: rs = self.executeQuery(sql) 
     344        except Exception, e:
     345            print str(e)
     346            self.logger.errorPair("problem querying for dvo path", path)
     347            sys.exit(1)
     348
     349        if not rs.next():
     350            self.logger.info("dvoDone exists, but is empty")
     351            return False
     352
     353        try:
    354354            head,tail = os.path.split(rs.getString(1))
    355355
     
    358358                return True
    359359            else:
    360                 self.logger.errorPair("DVO does not match. We have", head)
     360                self.logger.infoPair("DVO does not match. We have", head)
    361361                return False
    362362
    363363        except Exception, e:
    364364            print str(e)
    365             self.logger.errorPair("No DVO files ingested for this path", path)
    366             return False
     365            self.logger.errorPair("problem searching for DVO at", path)
     366            sys.exit(1)
    367367
    368368    '''
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/sqlUtility.py

    r37129 r37133  
    1616   
    1717    def group(self,field,value):
     18        print "group field: " + field + ", value: " + value
    1819        self.fields.append(field)
    1920        self.values.append(value)
    2021        return
    2122
    22     def make(self,middleString,endString):
     23    def makeRaw(self,middleString,endString):
    2324
    2425        output = self.startString
     
    4041        return output
    4142
     43    def make(self,middleString,endString):
     44
     45        output = self.startString
     46
     47        for i in range(len(self.fields)):
     48            output += self.fields[i]
     49            if (i < len(self.fields) - 1):
     50                output += ", "
     51
     52        output += middleString
     53
     54        for i in range(len(self.values)):
     55            output += "'" + self.values[i] + "'"
     56            if (i < len(self.values) - 1):
     57                output += ", "
     58       
     59        output += endString
     60
     61        return output
     62
    4263    # when we do a sql insert, we have a command that looks like this:
    4364    # INSERT INTO Table (field1, field2,...) OPERATION (value1, value2,...)
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/stackbatch.py

    r37129 r37133  
    11991199        self.skipBatch = False
    12001200
    1201         # get the IDs from the DVO tables
    1202         if not self.getIDsFromDVO():
    1203             return False
     1201        # get the IDs from the DVO tables 
     1202        # XXX deprecated along with dvograbber
     1203        # if not self.getIDsFromDVO(): return False
    12041204
    12051205        # do some basics first:
Note: See TracChangeset for help on using the changeset viewer.