Changeset 33259 for trunk/ippToPsps/jython/metrics.py
- Timestamp:
- Feb 14, 2012, 12:02:48 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/metrics.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/metrics.py
r33191 r33259 9 9 from xml.etree.ElementTree import ElementTree, Element, tostring 10 10 11 from config import Config 11 12 from pslogger import PSLogger 12 13 from ipptopspsdb import IppToPspsDb … … 19 20 def plotMe(batchType, file): 20 21 21 OUTPUTFILE = "plots/" + DVOLABEL+ "_" + batchType + ".png"22 OUTPUTFILE = "plots/" + config.dvoLabel + "_" + batchType + ".png" 22 23 f=os.popen('gnuplot', 'w') 23 24 … … 29 30 print >> f, "set term " + TERM + "; \ 30 31 set output \"" + OUTPUTFILE + "\"; \ 31 set title \"ippToPsps : " + batchType + " loading for " + DVOLABEL+ "\"; \32 set title \"ippToPsps : " + batchType + " loading for " + config.dvoLabel + "\"; \ 32 33 set boxwidth; \ 33 34 set xtic rotate by -90 scale 0; \ … … 54 55 55 56 # get a master list of IDs in DVO for this batch type 56 if MINRA and MAXRA and MINDEC and MAXDEC: 57 allIDs = gpc1Db.getIDsInThisDVODbForThisStage(DVOLABEL, batchType, MINRA, MAXRA, MINDEC, MAXDEC) 58 else: 59 allIDs = gpc1Db.getIDsInThisDVODbForThisStage(DVOLABEL, batchType) 57 allIDs = gpc1Db.getIDsInThisDVODbForThisStage(config.dvoLabel, batchType, config.minRa, config.maxRa, config.minDec, config.maxDec) 60 58 prevList = allIDs 61 59 numEverything = len(allIDs) … … 69 67 70 68 # get lists. Use unions with prev list to make sure the right stuff is included 71 success = list(set(ippToPspsDb.getStageIDs(batchType, EPOCH, DVOLABEL, stage, 1)) & set(prevList))72 fail = list(set(ippToPspsDb.getStageIDs(batchType, EPOCH, DVOLABEL, stage, -1)) & set(prevList) - set(success))69 success = list(set(ippToPspsDb.getStageIDs(batchType, config.epoch, config.dvoLabel, stage, 1)) & set(prevList)) 70 fail = list(set(ippToPspsDb.getStageIDs(batchType, config.epoch, config.dvoLabel, stage, -1)) & set(prevList) - set(success)) 73 71 pending = list(set(prevList) - set(success) - set(fail)) 74 72 … … 87 85 print >> DATFILE, stage, numSuccess, numFail, numPending 88 86 89 czarDb.insertStats(stage, DVOLABEL, batchType, numPending, numSuccess, numFail)87 czarDb.insertStats(stage, config.dvoLabel, batchType, numPending, numSuccess, numFail) 90 88 91 89 if stage == 'processed': numPendingProcessed = numPending 92 90 93 91 sys.stdout.write("|\n") 94 plotMe(batchType, tempFilename)92 #plotMe(batchType, tempFilename) 95 93 DATFILE.close() 96 94 … … 111 109 def printStats(batchType): 112 110 113 rate = ippToPspsDb.countBatchesInLastPeriod(batchType, EPOCH, DVOLABEL, "1 HOUR") / 1.0111 rate = ippToPspsDb.countBatchesInLastPeriod(batchType, config.epoch, config.dvoLabel, "1 HOUR") / 1.0 114 112 115 113 logger.info("| %2s | %16.1f | %13d | %17.1f | %16d | %14s |" % 116 114 (batchType, 117 115 rate, 118 ippToPspsDb.countBatchesInLastPeriod(batchType, EPOCH, DVOLABEL, "24 HOUR"),119 ippToPspsDb.countBatchesInLastPeriod(batchType, EPOCH, DVOLABEL, "1 WEEK") / 7.0,120 ippToPspsDb.getTotalDetectionsPublished(batchType, EPOCH, DVOLABEL),121 ippToPspsDb.getTimeOfLastBatchPublished(batchType, EPOCH, DVOLABEL)))116 ippToPspsDb.countBatchesInLastPeriod(batchType, config.epoch, config.dvoLabel, "24 HOUR"), 117 ippToPspsDb.countBatchesInLastPeriod(batchType, config.epoch, config.dvoLabel, "1 WEEK") / 7.0, 118 ippToPspsDb.getTotalDetectionsPublished(batchType, config.epoch, config.dvoLabel), 119 ippToPspsDb.getTimeOfLastBatchPublished(batchType, config.epoch, config.dvoLabel))) 122 120 123 121 return rate … … 126 124 Start of program. 127 125 ''' 128 if len(sys.argv) > 1: CONFIG = sys.argv[1]126 if len(sys.argv) > 1: CONFIGPATH = sys.argv[1] 129 127 else: 130 128 print "** Usage: " + sys.argv[0] + " <configPath> [hours]" … … 137 135 SECONDS = None 138 136 139 140 141 # open config file 142 configDoc = ElementTree(file=CONFIG) 143 144 logging.setLoggerClass(PSLogger) 145 logger = logging.getLogger("metrics") 146 logger.setup(configDoc, "metrics") 147 148 # create database objects 149 ippToPspsDb = IppToPspsDb(logger, configDoc) 150 czarDb = CzarDb(logger, configDoc) 151 gpc1Db = Gpc1Db(logger, configDoc) 152 153 DVOLABEL = configDoc.find("dvo/gpc1Label").text 154 EPOCH = configDoc.find("options/epoch").text 137 # create objects 138 config = Config(CONFIGPATH) 139 logger = config.getLogger("metrics") 140 ippToPspsDb = IppToPspsDb(logger, config) 141 czarDb = CzarDb(logger, config) 142 gpc1Db = Gpc1Db(logger, config) 155 143 156 144 while True: … … 159 147 now = datetime.datetime.now() 160 148 logger.infoPair("Time now", now.strftime("%Y-%m-%d %H:%M:%S")) 161 logger.infoPair("Loading epoch", EPOCH) 162 logger.infoPair("DVO label", DVOLABEL) 163 164 # get equatorial coord constraints, if any 165 try: 166 MINRA = float(configDoc.find("dvo/minRA").text) 167 MAXRA = float(configDoc.find("dvo/maxRA").text) 168 MINDEC = float(configDoc.find("dvo/minDec").text) 169 MAXDEC = float(configDoc.find("dvo/maxDec").text) 170 except: 171 MINRA = 0.0 172 MAXRA = 360.0 173 MINDEC = -30.0 174 MAXDEC = 90.0 175 176 logger.infoPair("RA limits", "%.1f to %.1f" % (MINRA, MAXRA)) 177 logger.infoPair("Dec limits", "%.1f to %.1f" % (MINDEC, MAXDEC)) 149 logger.infoPair("Loading epoch", config.epoch) 150 logger.infoPair("DVO label", config.dvoLabel) 151 config.printBoxCoords() 178 152 179 153 logger.info("+----+------------------+---------------+-------------------+------------------+----------------+")
Note:
See TracChangeset
for help on using the changeset viewer.
