Changeset 37133
- Timestamp:
- Jul 29, 2014, 9:52:00 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140717/ippToPsps/jython
- Files:
-
- 12 edited
-
batch.py (modified) (1 diff)
-
detectionbatch.py (modified) (11 diffs)
-
dvo.py (modified) (1 diff)
-
gpc1db.py (modified) (1 diff)
-
initbatch.py (modified) (2 diffs)
-
ipptopsps.py (modified) (2 diffs)
-
ipptopspsdb.py (modified) (3 diffs)
-
loader.py (modified) (2 diffs)
-
queue.py (modified) (2 diffs)
-
scratchdb.py (modified) (3 diffs)
-
sqlUtility.py (modified) (2 diffs)
-
stackbatch.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140717/ippToPsps/jython/batch.py
r37129 r37133 230 230 ''' 231 231 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): 232 242 233 243 if key in header: return header[key] -
branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py
r37129 r37133 125 125 sqlLine = sqlUtility("INSERT INTO FrameMeta (") 126 126 127 # sqlLine.group("p1Recip", ' '); 128 # sqlLine.group("p2Recip", ' '); 129 # sqlLine.group("p3Recip", ' '); 130 127 131 sqlLine.group("frameID", str(self.expID)); 128 132 sqlLine.group("frameName", self.expName); … … 130 134 sqlLine.group("cameraConfigID", "1"); 131 135 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')); 169 170 170 171 sql = sqlLine.make(") VALUES ( ", ")") … … 193 194 else: ccdID = 0 194 195 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) 196 202 197 203 # insert image metadata into table … … 202 208 sqlLine.group("bias", str(self.bias)) 203 209 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')) 214 220 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')) 218 224 sqlLine.group("momentXX", "-999") 219 225 sqlLine.group("momentXY", "-999") … … 225 231 sqlLine.group("momentR1", "-999") 226 232 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')) 230 236 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')) 267 273 268 274 sql = sqlLine.make(") VALUES ( ", ")") … … 340 346 sqlLine.group("apFlux", "AP_FLUX / " + extTimeString) 341 347 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") 343 350 sqlLine.group("kronFlux", "KRON_FLUX / " + extTimeString) 344 351 sqlLine.group("kronFluxErr", "KRON_FLUX_ERR / " + extTimeString) … … 350 357 sqlLine.group("dataRelease", str(self.skychunk.dataRelease)) 351 358 352 sqlLine.make(") SELECT ", " FROM " + ippTableName) 353 359 sql = sqlLine.makeRaw(") SELECT ", " FROM " + ippTableName) 354 360 print "sql: " + sql 355 361 … … 450 456 451 457 # check we have valid sourceID/imageID pair from the header 452 if self. safeDictionaryAccess(header, 'SOURCEID') == "NULL": return False453 if self. safeDictionaryAccess(header, 'IMAGEID') == "NULL": return False458 if self.getKeyValue(header, 'SOURCEID') == "NULL": return False 459 if self.getKeyValue(header, 'IMAGEID') == "NULL": return False 454 460 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']) 457 463 458 464 # store these for later … … 501 507 self.alterPspsTablesChip("Chip", "Chip.hdr", 0, 0) 502 508 503 # now run DVO code to get all IDs 504 if not self.getIDsFromDVO(): return False509 # now run DVO code to get all IDs ( XXX deprecated, uses dvograbber) 510 # if not self.getIDsFromDVO(): return False 505 511 506 512 # dec is reserved in MySQL, so STILTS replaces if with dec_, which is not the name of … … 547 553 a.ippObjID = b.ippObjID, \ 548 554 a.ra = b.ra, \ 549 a.dec _= b.dec_, \555 a.dec = b.dec_, \ 550 556 a.raErr = b.raErr, \ 551 557 a.decErr = b.decErr, \ … … 791 797 # 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" 792 798 793 # XXX EAM NOTE : this is fragile : requires PS1_V 4794 columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG P SF_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" 795 801 796 802 return super(DetectionBatch, self).importIppTables(columns, regex) -
branches/eam_branches/ipp-20140717/ippToPsps/jython/dvo.py
r37129 r37133 684 684 685 685 if (useP2 ==1 and useST==0): 686 #grab d only P2s687 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" 689 689 690 690 self.logger.infoPair("Running dvopsps", cmd) -
branches/eam_branches/ipp-20140717/ippToPsps/jython/gpc1db.py
r36715 r37133 117 117 stage = "forcedwarp" 118 118 sql = "SELECT differentStuff from Stufftable" 119 120 print "SQL: " + sql 119 121 120 122 try: -
branches/eam_branches/ipp-20140717/ippToPsps/jython/initbatch.py
r35097 r37133 33 33 scratchDb, 34 34 batchID): 35 35 36 super(InitBatch, self).__init__(logger, 36 37 config, … … 42 43 batchID, 43 44 "IN", 44 None, 45 0) 45 None) 46 46 47 47 self.outputFitsFile = "00000000.FITS"; -
branches/eam_branches/ipp-20140717/ippToPsps/jython/ipptopsps.py
r37129 r37133 155 155 while not self.refreshSkychunk() or self.ippToPspsDb.isPaused(self.HOST, self.PID): 156 156 157 print "looping in ipptopsps" 158 157 159 self.ippToPspsDb.updateClient(self.config.programName, self.HOST, self.PID) 158 160 if self.ippToPspsDb.isKilled(self.HOST, self.PID): … … 162 164 time.sleep(self.PAUSEPERIOD) 163 165 166 print "DONE looping in ipptopsps" 164 167 165 168 ''' -
branches/eam_branches/ipp-20140717/ippToPsps/jython/ipptopspsdb.py
r37129 r37133 1136 1136 1137 1137 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(): 1222 1164 self.logger.errorPair("Could not read skychunk with name", self.skychunk.name) 1223 1165 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 1224 1246 1225 1247 return self.skychunk.isLoaded … … 1387 1409 # XXX print "sql: ", sql 1388 1410 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") 1412 1444 1413 1445 # tests against ra_center need to use a finite box … … 1458 1490 GROUP BY ra_center LIMIT 1" 1459 1491 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") 1482 1524 1483 1525 # tests against ra_center need to use a finite box -
branches/eam_branches/ipp-20140717/ippToPsps/jython/loader.py
r37129 r37133 82 82 83 83 self.skychunk.printAll() 84 print "done with loader.py init" 84 85 85 86 ''' … … 174 175 self.logger.infoPair("processed","ok") 175 176 177 self.logger.infoPair("done with processing boxes, numAttempts: ", str(numAttempts)) 176 178 if abort or not self.checkClientStatus(): abort = True 177 179 elif numAttempts > 1 and not self.waitForPollTime(): break 180 181 print "done with wait?" 178 182 179 183 if self.onePassOnly: self.exitProgram("one pass completed") -
branches/eam_branches/ipp-20140717/ippToPsps/jython/queue.py
r37129 r37133 63 63 ''' 64 64 def run(self): 65 print "here"65 self.logger.info("------------- starting queue.run -----------------") 66 66 # this outer while loop simply waits a few minutes then starts queuing again (as more stuff may appear in DVO over time) 67 67 while True: 68 68 69 69 self.ippToPspsDb.removeAllBoxes() 70 print "remove boxes" 70 71 71 # queue up batches that are processed but not loaded to datastore 72 72 for batchType in self.skychunk.batchTypes: … … 77 77 # get totals for whole area to check if there is anything to do 78 78 processedIDs = self.ippToPspsDb.getProcessedIDs(batchType) 79 print "got processed ids"80 79 consistantlyFailedIDs = self.ippToPspsDb.getConsistentlyFailedIDs(batchType) 81 print "got here" 80 82 81 # for object batches, get full list of stuff from Dvo 83 82 # 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 85 85 if (batchType == "OB" or batchType =="DO" or batchType =="FO"): 86 86 self.dvoObjects.setSkyArea( -
branches/eam_branches/ipp-20140717/ippToPsps/jython/scratchdb.py
r37129 r37133 229 229 def alreadyImportedThisDvoTable(self, path): 230 230 231 print "***** alreadyImportedThisDvoTable *****"232 print "path: " + path233 234 231 fileStat = os.stat(path) 235 print "path: " + path236 232 237 233 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) 243 237 rs.first() 244 238 if rs.getInt(1) > 0: 245 print "***** DID import previously *****"246 239 self.logger.debugPair("Already imported up-to-date version of", path) 247 240 return True 248 241 else: 249 print "***** did NOT import previously *****"242 self.logger.infoPair("Did NOT already import from", path) 250 243 return False 251 244 except: 252 245 print "***** exception in alreadyImportedThisDvoTable *****" 253 246 self.logger.exception("Unable to check whether this DVO table has been imported") 254 255 print "***** done with alreadyImportedThisDvoTable *****"256 257 247 258 248 ''' … … 342 332 rs.close() 343 333 if not haveDone: 344 print "dvoDone not yet build"334 self.logger.info("dvoDone not yet built") 345 335 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) 348 341 349 342 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: 354 354 head,tail = os.path.split(rs.getString(1)) 355 355 … … 358 358 return True 359 359 else: 360 self.logger. errorPair("DVO does not match. We have", head)360 self.logger.infoPair("DVO does not match. We have", head) 361 361 return False 362 362 363 363 except Exception, e: 364 364 print str(e) 365 self.logger.errorPair(" No DVO files ingested for this path", path)366 return False365 self.logger.errorPair("problem searching for DVO at", path) 366 sys.exit(1) 367 367 368 368 ''' -
branches/eam_branches/ipp-20140717/ippToPsps/jython/sqlUtility.py
r37129 r37133 16 16 17 17 def group(self,field,value): 18 print "group field: " + field + ", value: " + value 18 19 self.fields.append(field) 19 20 self.values.append(value) 20 21 return 21 22 22 def make (self,middleString,endString):23 def makeRaw(self,middleString,endString): 23 24 24 25 output = self.startString … … 40 41 return output 41 42 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 42 63 # when we do a sql insert, we have a command that looks like this: 43 64 # INSERT INTO Table (field1, field2,...) OPERATION (value1, value2,...) -
branches/eam_branches/ipp-20140717/ippToPsps/jython/stackbatch.py
r37129 r37133 1199 1199 self.skipBatch = False 1200 1200 1201 # get the IDs from the DVO tables 1202 if not self.getIDsFromDVO():1203 return False1201 # get the IDs from the DVO tables 1202 # XXX deprecated along with dvograbber 1203 # if not self.getIDsFromDVO(): return False 1204 1204 1205 1205 # do some basics first:
Note:
See TracChangeset
for help on using the changeset viewer.
