def main(): ############################## # Adding a mapped FPA figure # - The mapped fpa will appear on the right 'nav' panel # - when you click on a ccd, you'll select data to display for that ccd # let's add this to a different TestSet tsMapFpa = pipeQA.TestSet(group="tutorial", label="mapped-FPA-figure-demo") camInfo = pipeQA.LsstSimCameraInfo() fpaFig = qaFig.FpaQaFigure(camInfo) # Fill the fpaFig.data attribute with the values to display. # This will color-code ccds in the focal plane according to these values # - this time, assume we only have 1 raft (the remaining sensors will be greyed-out) raftName = "2,2" data = fpaFig.data map = fpaFig.map for raft in sorted(data.keys()): if not re.search(raftName, raft): continue ccdDict = data[raft] for ccd, value in ccdDict.items(): data[raft][ccd] = numpy.random.normal(0.0, 1.0) # this time, add a mouse-over string (no spaces) for the map map[raft][ccd] = "data-from-" + ccd # make a plot for this ccd qafig = qaFig.QaFigure() fig = qafig.fig ax = fig.add_subplot(111) x = 2.0*numpy.pi*numpy.arange(100)/100 ax.plot(x, numpy.sin(x)+numpy.random.normal(0.0, 0.1, len(x)), 'r-') ax.set_ylim([-1.0, 1.0]) areaLabel = fpaFig.getAreaLabel(raft, ccd) # areaLabels are handled by FpaQaFigure tsMapFpa.addFigure(qafig, "sine-wave.png", "Sine wave from "+ ccd, areaLabel=areaLabel) # now tell fpaFig to make the matplotlib figure, and add the fpaFigure to the TestSet fpaFig.makeFigure(vlimits=[-1.0, 1.0], cmap="gray", cmapUnder="#0000ff", cmapOver="#ff0000") tsMapFpa.addFigure(fpaFig, camInfo.name+".png", "FPA for camera: "+camInfo.name, navMap=True)
def main(): ############################## # Adding a plain FPA figure # To demo multiple TestSets, let's add this figure to a different TestSet tsFpa = pipeQA.TestSet(group="tutorial", label="plain-FPA-figure-demo") # get a cameraInfo object for the camera you're interested in # - available: LsstSimCameraInfo, CfhtCameraInfo, HscCameraInfo, SuprimecamCamerainfo camInfo = pipeQA.LsstSimCameraInfo() # pass it to the FPA figure constructor fpaFig = qaFig.FpaQaFigure(camInfo) # Fill the fpaFig.data attribute with the values to display. # This will color-code ccds in the focal plane according to these values data = fpaFig.data for raft in sorted(data.keys()): ccdDict = data[raft] for ccd, value in ccdDict.items(): data[raft][ccd] = numpy.random.normal(0.0, 1.0) # now tell fpaFig to make the matplotlib figure, and add the fpaFigure to the TestSet vlimits = [-1.0, 1.0] # the colormap limits cmap = "copper" # the name of a matplotlib.cm colormap ('jet' by default) # color to use if below/above the cmap range, defaults are min/max of cmap cmapUnder, cmapOver = "#0000ff", "#ff0000" fpaFig.makeFigure(vlimits=vlimits, cmap="copper", cmapUnder=cmapUnder, cmapOver=cmapOver) tsFpa.addFigure(fpaFig, camInfo.name + ".png", "FPA for camera: " + camInfo.name)
def plot(self, data, dataId, showUndefined=False): testSet = self.getTestSet(data, dataId) testSet.setUseCache(self.useCache) isFinalDataId = False if len(data.brokenDataIdList ) == 0 or data.brokenDataIdList[-1] == dataId: isFinalDataId = True # override self.limits to use the faintest mag as an upper limit, if upper limit is 99.0 # put the new limits in a different variable so we do this on a visit-by-visit basis # ie. ... don't set it permanently in self.limits or every visit will use that. limitsToUse = [self.limits[0], self.limits[1]] if abs(self.limits[1] - 99.0) < 1.0e-3: limitsToUse[1] = self.faintest if self.showFpa: # fpa figure filebase = "completenessDepth" depthData, depthMap = testSet.unpickle(filebase, default=[None, None]) depths = [] depthFig = qaFig.FpaQaFigure(data.cameraInfo, data=depthData, map=depthMap) for raft, ccdDict in depthFig.data.items(): for ccd, value in ccdDict.items(): if self.depth.get(raft, ccd) is not None: depth = self.depth.get(raft, ccd) depths.append(depth) depthFig.data[raft][ccd] = depth if num.isfinite(depth): depthFig.map[raft][ccd] = 'mag=%.2f' % (depth) else: depthFig.map[raft][ccd] = 'mag=nan' testSet.pickle(filebase, [depthFig.data, depthFig.map]) blue = '#0000ff' red = '#ff0000' if False: if len(depths) >= 2: vmin = max(num.min(depths), self.limits[0]) vmax = min(num.max(depths), self.limits[1]) else: vmin = self.limits[0] vmax = self.limits[1] if vmax <= vmin: vmin = self.limits[0] vmax = self.limits[1] else: vmin, vmax = 1.0 * limitsToUse[0], 1.0 * limitsToUse[1] if vmin > vmax: vmax = vmin + (self.limits[1] - self.limits[0]) if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting FPAs") depthFig.makeFigure(showUndefined=showUndefined, cmap="RdBu_r", vlimits=[vmin, vmax], title="Photometric Depth", cmapOver=red, cmapUnder=blue, failLimits=limitsToUse) testSet.addFigure(depthFig, filebase + ".png", "Estimate of photometric depth", navMap=True) del depthFig cacheLabel = "completeness" shelfData = {} # Each CCD for raft, ccd in self.depth.raftCcdKeys(): orphan = self.orphan.get(raft, ccd) matchedStar = self.matchedStar.get(raft, ccd) blendedStar = self.blendedStar.get(raft, ccd) undetectedStar = self.undetectedStar.get(raft, ccd) matchedGalaxy = self.matchedGalaxy.get(raft, ccd) blendedGalaxy = self.blendedGalaxy.get(raft, ccd) undetectedGalaxy = self.undetectedGalaxy.get(raft, ccd) depth = self.depth.get(raft, ccd) self.log.log(self.log.INFO, "Plotting %s" % (ccd)) label = data.cameraInfo.getDetectorName(raft, ccd) dataDict = { 'title': label, 'orphan': orphan, 'depth': depth, 'matchedStar': matchedStar, 'blendedStar': blendedStar, 'undetectedStar': undetectedStar, 'matchedGalaxy': matchedGalaxy, 'blendedGalaxy': blendedGalaxy, 'undetectedGalaxy': undetectedGalaxy, 'bins': self.bins.tolist(), } import CompletenessQaPlot as plotModule caption = "Photometric detections " + label pngFile = cacheLabel + ".png" if self.lazyPlot.lower() in ['sensor', 'all']: testSet.addLazyFigure(dataDict, pngFile, caption, plotModule, areaLabel=label, plotargs="") else: testSet.cacheLazyData(dataDict, pngFile, areaLabel=label) fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting Summary figure") label = 'all' import CompletenessQaPlot as plotModule caption = "Photometric detections " + label pngFile = "completeness.png" if self.lazyPlot in ['all']: testSet.addLazyFigure(dataDict, cacheLabel + ".png", caption, plotModule, areaLabel=label, plotargs="") else: dataDict, isSummary = qaPlotUtil.unshelveGlob(cacheLabel + "-all.png", testSet=testSet) dataDict['title'] = 'All Sensors' fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig
def plot(self, data, dataId, showUndefined=False): testSet = self.getTestSet(data, dataId) testSet.setUseCache(self.useCache) isFinalDataId = False if len(data.brokenDataIdList ) == 0 or data.brokenDataIdList[-1] == dataId: isFinalDataId = True if self.showFpa: # make fpa figures - for all detections, and for matched detections emptyBase = "emptySectors" emptyMatBase = "aa_emptySectorsMat" emptyData, emptyMap = testSet.unpickle(emptyBase, [None, None]) emptyMatData, emptyMatMap = testSet.unpickle( emptyMatBase, [None, None]) emptyFig = qaFig.FpaQaFigure(data.cameraInfo, data=emptyData, map=emptyMap) emptyFigMat = qaFig.FpaQaFigure(data.cameraInfo, data=emptyMatData, map=emptyMatMap) for raft, ccdDict in emptyFig.data.items(): for ccd, value in ccdDict.items(): # set values for data[raft][ccd] (color coding) # set values for map[raft][ccd] (tooltip text) if self.emptySectors.get(raft, ccd) is not None: nEmpty = self.emptySectors.get(raft, ccd) emptyFig.data[raft][ccd] = nEmpty emptyFig.map[raft][ccd] = "%dx%d,empty=%d" % ( self.nx, self.ny, nEmpty) nEmptyMat = self.emptySectorsMat.get(raft, ccd) emptyFigMat.data[raft][ccd] = nEmptyMat emptyFigMat.map[raft][ccd] = "%dx%d,empty=%d" % ( self.nx, self.ny, nEmptyMat) testSet.pickle(emptyBase, [emptyFig.data, emptyFig.map]) testSet.pickle(emptyMatBase, [emptyFigMat.data, emptyFigMat.map]) # make the figures and add them to the testSet # sample colormaps at: http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting FPAs") emptyFig.makeFigure(showUndefined=showUndefined, cmap="gist_heat_r", vlimits=[0, self.nx * self.ny], title="Empty sectors (%dx%d grid)" % (self.nx, self.ny), failLimits=self.limits) testSet.addFigure(emptyFig, emptyBase + ".png", "Empty Sectors in %dx%d grid." % (self.nx, self.ny), navMap=True) del emptyFig emptyFigMat.makeFigure( showUndefined=showUndefined, cmap="gist_heat_r", vlimits=[0, self.nx * self.ny], title="Empty sectors (matched, %dx%d grid)" % (self.nx, self.ny), failLimits=self.limits) testSet.addFigure(emptyFigMat, emptyMatBase + ".png", "Empty Sectors in %dx%d grid." % (self.nx, self.ny), navMap=True) del emptyFigMat else: del emptyFig, emptyFigMat cacheLabel = "pointPositions" shelfData = {} xlo, xhi, ylo, yhi = 1.e10, -1.e10, 1.e10, -1.e10 for raft, ccd in data.cameraInfo.raftCcdKeys: if data.cameraInfo.name == 'coadd': xtmp, ytmp = self.x.get(raft, ccd), self.y.get(raft, ccd) if (xtmp is not None) and (ytmp is not None): xxlo, yylo, xxhi, yyhi = xtmp.min(), ytmp.min(), xtmp.max( ), ytmp.max() else: xxlo, yylo, xxhi, yyhi = xlo, ylo, xhi, yhi else: xxlo, yylo, xxhi, yyhi = data.cameraInfo.getBbox(raft, ccd) if xxlo < xlo: xlo = xxlo if xxhi > xhi: xhi = xxhi if yylo < ylo: ylo = yylo if yyhi > yhi: yhi = yyhi # make any individual (ie. per sensor) plots for raft, ccd in self.emptySectors.raftCcdKeys(): # get the data we want for this sensor (we stored it here in test() method above) x, y = self.x.get(raft, ccd), self.y.get(raft, ccd) xmat, ymat = self.xmat.get(raft, ccd), self.ymat.get(raft, ccd) xwid, ywid = self.size.get(raft, ccd) if data.cameraInfo.name == 'coadd': xmin, ymin, xmax, ymax = x.min(), y.min(), x.max(), y.max() x -= xmin y -= ymin xmat -= xmin ymat -= ymin xxlo, yylo, xxhi, yyhi = xmin, ymin, xmax, ymax else: xxlo, yylo, xxhi, yyhi = data.cameraInfo.getBbox(raft, ccd) dataDict = { 'x': x + xxlo, 'y': y + yylo, 'xmat': xmat + xxlo, 'ymat': ymat + yylo, 'limits': [0, xwid, 0, ywid], 'summary': False, 'alllimits': [xlo, xhi, ylo, yhi], 'bbox': [xxlo, xxhi, yylo, yyhi], 'nxn': [self.nx, self.ny] } self.log.log(self.log.INFO, "plotting %s" % (ccd)) import EmptySectorQaAnalysisPlot as plotModule label = data.cameraInfo.getDetectorName(raft, ccd) caption = "Pixel coordinates of all (black) and matched (red) detections." + label pngFile = cacheLabel + ".png" if self.lazyPlot.lower() in ['sensor', 'all']: testSet.addLazyFigure(dataDict, pngFile, caption, plotModule, areaLabel=label, plotargs="") else: testSet.cacheLazyData(dataDict, pngFile, areaLabel=label) fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting Summary figure") import EmptySectorQaAnalysisPlot as plotModule label = 'all' caption = "Pixel coordinates of all (black) and matched (red) detections." + label pngFile = "pointPositions.png" if self.lazyPlot in ['all']: testSet.addLazyFigure({}, cacheLabel + ".png", caption, plotModule, areaLabel=label, plotargs="") else: dataDict, isSummary = qaPlotUtil.unshelveGlob(cacheLabel + "-all.png", testSet=testSet) dataDict['summary'] = True dataDict['limits'] = dataDict['alllimits'] fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig
def plot(self, data, dataId, showUndefined=False): testSet = self.getTestSet(data, dataId, label=self.magType1 + "-" + self.magType2) testSet.setUseCache(self.useCache) isFinalDataId = False if len(data.brokenDataIdList ) == 0 or data.brokenDataIdList[-1] == dataId: isFinalDataId = True xlim = [14.0, 25.0] ylimStep = 0.4 ylim = [-ylimStep, ylimStep] aspRatio = (xlim[1] - xlim[0]) / (ylim[1] - ylim[0]) tag1 = "m$_{\mathrm{" + self.magType1.upper() + "}}$" tag = "m$_{\mathrm{" + self.magType1.upper( ) + "}}$ - m$_{\mathrm{" + self.magType2.upper() + "}}$" dtag = self.magType1 + "-" + self.magType2 wtag = self.magType1 + "minus" + self.magType2 if self.showFpa: # fpa figure meanFilebase = "mean" + wtag stdFilebase = "std" + wtag derrFilebase = "derr" + wtag slopeFilebase = "slope" + wtag meanData, meanMap = testSet.unpickle(meanFilebase, default=[None, None]) stdData, stdMap = testSet.unpickle(stdFilebase, default=[None, None]) derrData, derrMap = testSet.unpickle(derrFilebase, default=[None, None]) slopeData, slopeMap = testSet.unpickle(slopeFilebase, default=[None, None]) meanFig = qaFig.FpaQaFigure(data.cameraInfo, data=meanData, map=meanMap) stdFig = qaFig.FpaQaFigure(data.cameraInfo, data=stdData, map=stdMap) derrFig = qaFig.FpaQaFigure(data.cameraInfo, data=derrData, map=derrMap) slopeFig = qaFig.VectorFpaQaFigure(data.cameraInfo, data=slopeData, map=slopeMap) for raft, ccd in self.means.raftCcdKeys(): meanFig.data[raft][ccd] = self.means.get(raft, ccd) stdFig.data[raft][ccd] = self.stds.get(raft, ccd) derrFig.data[raft][ccd] = self.derrs.get(raft, ccd) slope = self.trend.get(raft, ccd)[0] if slope is not None and not slope[1] == 0: # aspRatio will make the vector have the same angle as the line in the figure slopeSigma = slope[0] / slope[1] slopeFig.data[raft][ccd] = [ numpy.arctan2(aspRatio * slope[0], 1.0), None, slopeSigma ] else: slopeSigma = None slopeFig.data[raft][ccd] = [None, None, None] if self.means.get(raft, ccd) is not None: meanFig.map[raft][ccd] = "mean=%.4f" % (self.means.get( raft, ccd)) stdFig.map[raft][ccd] = "std=%.4f" % (self.stds.get( raft, ccd)) derrFig.map[raft][ccd] = "derr=%.4f" % (self.derrs.get( raft, ccd)) fmt0, fmt1, fmtS = "%.4f", "%.4f", "%.1f" if slope[0] is None: fmt0 = "%s" if slope[1] is None: fmt1 = "%s" if slopeSigma is None: fmtS = "%s" fmt = "slope=" + fmt0 + "+/-" + fmt1 + "(" + fmtS + "sig)" slopeFig.map[raft][ccd] = fmt % (slope[0], slope[1], slopeSigma) blue, red = '#0000ff', '#ff0000' testSet.pickle(meanFilebase, [meanFig.data, meanFig.map]) testSet.pickle(stdFilebase, [stdFig.data, stdFig.map]) testSet.pickle(derrFilebase, [derrFig.data, derrFig.map]) testSet.pickle(slopeFilebase, [slopeFig.data, slopeFig.map]) if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting FPAs") meanFig.makeFigure(showUndefined=showUndefined, cmap="RdBu_r", vlimits=[-0.03, 0.03], title="Mean " + tag, cmapOver=red, cmapUnder=blue, failLimits=self.deltaLimits) testSet.addFigure(meanFig, "f01" + meanFilebase + ".png", "mean " + dtag + " mag (brighter than %.1f)" % (self.magCut), navMap=True) del meanFig stdFig.makeFigure(showUndefined=showUndefined, cmap="Reds", vlimits=[0.0, 0.03], title="Stdev " + tag, cmapOver=red, failLimits=self.rmsLimits) testSet.addFigure(stdFig, "f02" + stdFilebase + ".png", "stdev " + dtag + " mag (brighter than %.1f)" % (self.magCut), navMap=True) del stdFig derrFig.makeFigure(showUndefined=showUndefined, cmap="Reds", vlimits=[0.0, 0.01], title="Derr " + tag, cmapOver=red, failLimits=self.derrLimits) testSet.addFigure(derrFig, "f03" + derrFilebase + ".png", "derr " + dtag + " mag (brighter than %.1f)" % (self.magCut), navMap=True) del derrFig cScale = 2.0 slopeFig.makeFigure(cmap="RdBu_r", vlimits=[ cScale * self.slopeLimits[0], cScale * self.slopeLimits[1] ], title="Slope " + tag, failLimits=self.slopeLimits) testSet.addFigure(slopeFig, "f04" + slopeFilebase + ".png", "slope " + dtag + " mag (brighter than %.1f)" % (self.magCut), navMap=True) del slopeFig else: del meanFig del stdFig del derrFig del slopeFig ############################################# # #xmin, xmax = self.mag.summarize('min', default=0.0), self.mag.summarize('max', default=25.0) #ymin, ymax = self.diff.summarize('min', default=-1.0), self.diff.summarize('max', default=1.0) #xrang = xmax-xmin #xmin, xmax = int(xmin-0.05*xrang), int(xmax+0.05*xrang)+1 #yrang = ymax-ymin #ymin, ymax = ymin-0.05*yrang, ymax+0.05*yrang xlim2 = xlim #[xmin, xmax] ylim2 = [-2.0, 2.0] #[ymin, ymax] figsize = (6.5, 3.75) figbase = "diff_" + dtag shelfData = {} for raft, ccd in self.mag.raftCcdKeys(): mag0 = self.mag.get(raft, ccd) diff0 = self.diff.get(raft, ccd) star0 = self.star.get(raft, ccd) derr0 = self.derr.get(raft, ccd) self.log.log(self.log.INFO, "plotting %s" % (ccd)) areaLabel = data.cameraInfo.getDetectorName(raft, ccd) statBlurb = "Points used for statistics/trendline shown in red." dataDict = { 'mag0': mag0, 'diff0': diff0, 'star0': star0, 'derr0': derr0, 'areaLabel': areaLabel, 'raft': raft, 'ccd': ccd, 'figsize': figsize, 'xlim': xlim, 'ylim': ylim, 'xlim2': xlim2, 'ylim2': ylim2, 'ylimStep': ylimStep, 'tag1': tag1, 'tag': tag, 'x': self.y.get(raft, ccd), 'y': self.x.get(raft, ccd), 'trend': self.trend.get(raft, ccd), 'magCut': self.magCut, 'summary': False, } masterToggle = None if self.starGalaxyToggle: masterToggle = '0_stars' import PhotCompareQaAnalysisPlot as plotModule label = areaLabel pngFile = figbase + ".png" ############################################## caption = dtag + " vs. " + self.magType1 + "(stars). " + statBlurb toggle = '0_stars' if self.lazyPlot.lower() in ['sensor', 'all']: testSet.addLazyFigure(dataDict, pngFile, caption, plotModule, areaLabel=label, plotargs="stars standard", toggle=toggle, masterToggle=masterToggle) else: testSet.cacheLazyData(dataDict, pngFile, areaLabel=label, toggle=toggle, masterToggle=masterToggle) dataDict['mode'] = 'stars' dataDict['figType'] = 'standard' fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label, toggle=toggle) del fig ############################################## caption = dtag + " vs. " + self.magType1 + "(galaxies). " + statBlurb toggle = '1_galaxies' if self.lazyPlot.lower() in ['sensor', 'all']: testSet.addLazyFigure(dataDict, pngFile, caption, plotModule, areaLabel=label, plotargs="galaxies standard", toggle=toggle, masterToggle=masterToggle) else: testSet.cacheLazyData(dataDict, pngFile, areaLabel=label, toggle=toggle, masterToggle=masterToggle) dataDict['mode'] = 'galaxies' dataDict['figType'] = 'standard' fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label, toggle=toggle) del fig ############################################## caption = dtag + " vs. " + self.magType1 + "(everything). " + statBlurb toggle = '2_everything' if self.lazyPlot.lower() in ['sensor', 'all']: testSet.addLazyFigure(dataDict, pngFile, caption, plotModule, areaLabel=label, plotargs="all standard", toggle=toggle, masterToggle=masterToggle) else: testSet.cacheLazyData(dataDict, pngFile, areaLabel=label, toggle=toggle, masterToggle=masterToggle) dataDict['mode'] = 'all' dataDict['figType'] = 'standard' fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label, toggle=toggle) del fig ############################################## caption = dtag + " vs. " + self.magType1 + "(star derr). " + statBlurb toggle = '3_derr' if self.lazyPlot.lower() in ['sensor', 'all']: testSet.addLazyFigure(dataDict, pngFile, caption, plotModule, areaLabel=label, plotargs="stars derr", toggle=toggle, masterToggle=masterToggle) else: testSet.cacheLazyData(dataDict, pngFile, areaLabel=label, toggle=toggle, masterToggle=masterToggle) dataDict['mode'] = 'stars' dataDict['figType'] = 'derr' fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label, toggle=toggle) del fig else: import PhotCompareQaAnalysisPlot as plotModule label = areaLabel caption = dtag + " vs. " + self.magType1 + ". " + statBlurb pngFile = figbase + ".png" if self.lazyPlot.lower() in ['sensor', 'all']: testSet.addLazyFigure(dataDict, pngFile, caption, plotModule, areaLabel=label, plotargs="all standard") else: testSet.cacheLazyData(dataDict, pngFile, areaLabel=label) dataDict['mode'] = 'all' dataDict['figType'] = 'standard' fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting Summary figure") import PhotCompareQaAnalysisPlot as plotModule label = 'all' caption = dtag + " vs. " + self.magType1 pngFile = figbase + ".png" if self.lazyPlot in ['all']: testSet.addLazyFigure({}, pngFile, caption, plotModule, areaLabel=label, plotargs="all summary", masterToggle=masterToggle) else: dataDict, isSummary = qaPlotUtil.unshelveGlob(figbase + "-all.png", testSet=testSet) dataDict['mode'] = 'all' dataDict['figType'] = 'summary' fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig
def plotdM(self, data, dataId, visit, sgal, showUndefined=False): if sgal == 0: sglab = "star" else: sglab = "gal" testSet = self.getTestSet(data, dataId) testSet.setUseCache(self.useCache) isFinalDataId = False if len(data.brokenDataIdList ) > 0 and data.brokenDataIdList[-1] == dataId: isFinalDataId = True # fpa figure title = "$\Delta m_{\mathrm{" + self.magType.upper() + "}}$" cachetag = "%s_%s_%s" % (self.database, visit, self.magType) nametag = "d" + self.magType meanFilebase = "mean" + cachetag stdFilebase = "std" + cachetag meanData, meanMap = testSet.unpickle(meanFilebase, default=[None, None]) stdData, stdMap = testSet.unpickle(stdFilebase, default=[None, None]) meanFig = qaFig.FpaQaFigure(data.cameraInfo, data=meanData, map=meanMap) stdFig = qaFig.FpaQaFigure(data.cameraInfo, data=stdData, map=stdMap) for raft, ccd in self.mag[visit].raftCcdKeys(): meanFig.data[raft][ccd] = self.meanDmags[visit].get(raft, ccd) stdFig.data[raft][ccd] = self.stdDmags[visit].get(raft, ccd) meanFig.map[raft][ccd] = "mean=%.4f" % (self.meanDmags[visit].get( raft, ccd)) stdFig.map[raft][ccd] = "std=%.4f" % (self.stdDmags[visit].get( raft, ccd)) testSet.pickle(meanFilebase, [meanFig.data, meanFig.map]) testSet.pickle(stdFilebase, [stdFig.data, stdFig.map]) blue, red = '#0000ff', '#ff0000' if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting FPAs") meanFig.makeFigure(showUndefined=showUndefined, cmap="RdBu_r", vlimits=[-0.03, 0.03], title="Mean " + title, cmapOver=red, cmapUnder=blue, failLimits=self.deltaLimits) testSet.addFigure(meanFig, "f01" + meanFilebase + ".png", "mean " + nametag + " mag (brighter than %.1f)" % (self.magCut), navMap=True) del meanFig stdFig.makeFigure(showUndefined=showUndefined, cmap="Reds", vlimits=[0.0, 0.03], title="Stdev " + title, cmapOver=red, failLimits=self.rmsLimits) testSet.addFigure(stdFig, "f02" + stdFilebase + ".png", "stdev " + nametag + " mag (brighter than %.1f)" % (self.magCut), navMap=True) del stdFig else: del meanFig del stdFig # Per CCD figures rect1 = [0.125, 0.35, 0.775, 0.9 - 0.35] #left, bottom, width, height rect2 = [0.125, 0.1, 0.775, 0.2] figbase = "vvdiff%d_" % (sgal) + nametag toggle = "%d_%sdiff_" % (sgal, sglab) + visit shelfData = {} for raft, ccd in self.mag[visit].raftCcdKeys(): m1 = self.mag[visit].get(raft, ccd) m2 = self.visitMag[visit].get(raft, ccd) dm1 = self.magErr[visit].get(raft, ccd) dm2 = self.visitMagErr[visit].get(raft, ccd) M1 = self.refMag[visit].get(raft, ccd) M2 = self.visitRefMag[visit].get(raft, ccd) star = self.star[visit].get(raft, ccd) dmAll = m1 - m2 - (M1 - M2) ddmAll = num.sqrt(dm1**2 + dm2**2) if sgal == 0: idx = num.where(star > 0)[0] idxB = num.where((M1 > 10) & (M1 < self.magCut) & (star > 0))[0] idxF = num.where((M1 > 10) & (M1 >= self.magCut) & (star > 0))[0] else: idx = num.where(star == 0)[0] idxB = num.where((M1 > 10) & (M1 < self.magCut) & (star == 0))[0] idxF = num.where((M1 > 10) & (M1 >= self.magCut) & (star == 0))[0] dmB = dmAll[idxB] ddmB = ddmAll[idxB] dmF = dmAll[idxF] ddmF = ddmAll[idxF] fig = qaFig.QaFigure() ax1 = fig.fig.add_axes(rect1) ax2 = fig.fig.add_axes(rect2, sharex=ax1) if len(dmB): ax1.errorbar(M1[idxB], dmB, yerr=ddmB, fmt='ro', ms=3) if len(dmF): ax1.errorbar(M1[idxF], dmF, yerr=ddmF, fmt='o', ecolor='0.75', color='k', ms=3) ax1.axhline(y=0, c='k', linestyle=':') bins = num.arange(self.maglim[0], self.maglim[1], 0.5) self.plotErrvSig(ax2, M1[idx], dmAll[idx], ddmAll[idx], bins) # stars/gals only ax1.set_ylabel("dM", fontsize=12) ax2.set_xlabel("${\mathrm{M_{%s; cat}}}$" % self.ownFilt.getName(), fontsize=12) if self.ownFilt.getName() == self.visitFilters[visit].getName(): lab = "${\mathrm{(%s_{%s} - %s_{%s})_{%s}}}$" % ( self.ownFilt.getName(), dataId['visit'], self.visitFilters[visit].getName(), visit, self.magType) else: lab = "${\mathrm{(%s_{%s} - %s_{%s})_{%s} - (%s - %s)_{cat}}}$" % ( self.ownFilt.getName(), dataId['visit'], self.visitFilters[visit].getName(), visit, self.magType, self.ownFilt.getName(), self.visitFilters[visit].getName()) ax1.set_title(lab, fontsize=12) qaFigUtils.qaSetp(ax1.get_xticklabels() + ax1.get_yticklabels(), fontsize=8) qaFigUtils.qaSetp(ax2.get_xticklabels() + ax2.get_yticklabels(), fontsize=8) ax1.set_ylim(-0.5, 0.5) ax1.set_xlim(self.maglim[0], self.maglim[1]) ax2.semilogy() ax2.set_ylim(0.001, 0.99) areaLabel = data.cameraInfo.getDetectorName(raft, ccd) if sgal == 0: statBlurb = "Points used for statistics shown in red." else: statBlurb = "Stats currently not calculated for galaxies." testSet.addFigure(fig, figbase + ".png", nametag + " vs. " + self.magType + "(%s). " % (sglab) + statBlurb, areaLabel=areaLabel, toggle=toggle)
def plot(self, data, dataId, showUndefined=False): testSet = self.getTestSet(data, dataId) testSet.setUseCache(self.useCache) isFinalDataId = False if len(data.brokenDataIdList ) == 0 or data.brokenDataIdList[-1] == dataId: isFinalDataId = True ################################# # memory ################################ if self.showFpa: # make fpa figures - for all detections, and for matched detections memBase = "mem" memData, memMap = testSet.unpickle(memBase, [None, None]) memFig = qaFig.FpaQaFigure(data.cameraInfo, data=memData, map=memMap) for raft, ccdDict in memFig.data.items(): for ccd, value in ccdDict.items(): # set values for data[raft][ccd] (color coding) # set values for map[raft][ccd] (tooltip text) if self.mem.get(raft, ccd) is not None: mem = self.mem.get(raft, ccd) memFig.data[raft][ccd] = mem memFig.map[raft][ccd] = "%.1fMB" % (mem) testSet.pickle(memBase, [memFig.data, memFig.map]) # make the figures and add them to the testSet # sample colormaps at: http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting FPAs") memFig.makeFigure(showUndefined=showUndefined, cmap="gist_heat_r", vlimits=self.limits, title="Memory Usage [MB]", failLimits=self.limits) testSet.addFigure(memFig, memBase + ".png", "memory usage in MB", navMap=True) del memFig else: del memFig ################################# # runtime ################################ if self.showFpa: # make fpa figures - for all detections, and for matched detections runtimeBase = "runtime" runtimeData, runtimeMap = testSet.unpickle(runtimeBase, [None, None]) runtimeFig = qaFig.FpaQaFigure(data.cameraInfo, data=runtimeData, map=runtimeMap) #print "min/max", mintime, maxtime for raft, ccdDict in runtimeFig.data.items(): for ccd, value in ccdDict.items(): # set values for data[raft][ccd] (color coding) # set values for map[raft][ccd] (tooltip text) if self.testRuntime.get(raft, ccd) is not None: testRuntime = self.testRuntime.get(raft, ccd) plotRuntime = self.plotRuntime.get(raft, ccd) runtimeFig.data[raft][ccd] = testRuntime + plotRuntime runtimeFig.map[raft][ccd] = "t=%.1fsec+p=%.1fsec" % ( testRuntime, plotRuntime) testSet.pickle(runtimeBase, [runtimeFig.data, runtimeFig.map]) runArray = runtimeFig.getArray() if len(runArray) == 0: runArray = numpy.zeros(1) mintime, maxtime = runArray.min() - 1.0, runArray.max() + 1.0 # make the figures and add them to the testSet # sample colormaps at: http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps if not self.delaySummary or isFinalDataId: runtimeFig.makeFigure(showUndefined=showUndefined, cmap="gist_heat_r", vlimits=[mintime, maxtime], title="Runtime [Sec]", failLimits=[mintime, maxtime]) testSet.addFigure(runtimeFig, runtimeBase + ".png", "Runtime", navMap=True) del runtimeFig else: del runtimeFig
def plot(self, data, dataId, showUndefined=False): testSet = self.getTestSet(data, dataId) testSet.setUseCache(self.useCache) isFinalDataId = False if len(data.brokenDataIdList ) == 0 or data.brokenDataIdList[-1] == dataId: isFinalDataId = True if self.showFpa: # fpa figure zpts = [] zptBase = "zeropoint" zptData, zptMap = testSet.unpickle(zptBase, default=[None, None]) zptFig = qaFig.FpaQaFigure(data.cameraInfo, data=zptData, map=zptMap) offsetBase = "medZeropointOffset" offsetData, offsetMap = testSet.unpickle(offsetBase, default=[None, None]) offsetFig = qaFig.FpaQaFigure(data.cameraInfo, data=offsetData, map=offsetMap) for raft, ccdDict in zptFig.data.items(): for ccd, value in ccdDict.items(): if self.zeroPoint.get(raft, ccd) is not None: zpt = self.zeroPoint.get(raft, ccd) zpts.append(zpt) zptFig.data[raft][ccd] = zpt zptFig.map[raft][ccd] = 'zpt=%.2f' % (zpt) offset = self.medOffset.get(raft, ccd) offsetFig.data[raft][ccd] = offset offsetFig.map[raft][ccd] = 'offset=%.2f' % (offset) else: if zptFig.data[raft][ccd] is not None: zpts.append(zptFig.data[raft][ccd]) testSet.pickle(zptBase, [zptFig.data, zptFig.map]) testSet.pickle(offsetBase, [offsetFig.data, offsetFig.map]) if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting FPAs") blue = '#0000ff' red = '#ff0000' zptFig.makeFigure( showUndefined=showUndefined, cmap="jet", vlimits=[num.min(zpts) - 0.05, num.max(zpts) + 0.05], title="Zeropoint", cmapOver=red, cmapUnder=blue) testSet.addFigure(zptFig, zptBase + ".png", "Photometric zeropoint", navMap=True) del zptFig offsetFig.makeFigure(showUndefined=showUndefined, cmap="jet", vlimits=self.limits, title="Med offset from Zpt Fit", cmapOver=red, failLimits=self.limits, cmapUnder=blue) testSet.addFigure(offsetFig, offsetBase + ".png", "Median offset from photometric zeropoint", navMap=True) del offsetFig else: del zptFig, offsetFig cacheLabel = "zeropointFit" shelfData = {} # Each CCD for raft, ccd in self.zeroPoint.raftCcdKeys(): zeropt = self.zeroPoint.get(raft, ccd) if zeropt == 0.0: continue self.log.log(self.log.INFO, "Plotting %s" % (ccd)) # Plot all matched galaxies mrefGmag = self.matchedGalaxy.get(raft, ccd)["Refmag"] mimgGmag = self.matchedGalaxy.get(raft, ccd)["Imgmag"] mimgGmerr = self.matchedGalaxy.get(raft, ccd)["Imgerr"] # Plot all matched stars mrefSmag = self.matchedStar.get(raft, ccd)["Refmag"] mimgSmag = self.matchedStar.get(raft, ccd)["Imgmag"] mimgSmerr = self.matchedStar.get(raft, ccd)["Imgerr"] urefmag = num.concatenate((self.undetectedStar.get(raft, ccd), self.undetectedGalaxy.get(raft, ccd))) uimgmag = self.orphan.get(raft, ccd) label = data.cameraInfo.getDetectorName(raft, ccd) dataDict = { 'mrefGmag': mrefGmag, 'mimgGmag': mimgGmag, 'mimgGmerr': mimgGmerr, 'mrefSmag': mrefSmag, 'mimgSmag': mimgSmag, 'mimgSmerr': mimgSmerr, 'urefmag': urefmag, 'uimgmag': uimgmag, 'zeropt': zeropt, 'title': label, 'figsize': self.figsize, 'fluxType': self.fluxType, } import ZeropointFitQaPlot as plotModule caption = "Zeropoint fit " + label pngFile = cacheLabel + ".png" if self.lazyPlot.lower() in ['sensor', 'all']: testSet.addLazyFigure(dataDict, pngFile, caption, plotModule, areaLabel=label, plotargs="") else: testSet.cacheLazyData(dataDict, pngFile, areaLabel=label) fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting Summary figure") label = 'all' import ZeropointFitQaPlot as plotModule caption = "Zeropoint fit " + label pngFile = cacheLabel + ".png" if self.lazyPlot.lower() in ['all']: testSet.addLazyFigure(dataDict, pngFile, caption, plotModule, areaLabel=label, plotargs="") else: dataDict, isSummary = qaPlotUtil.unshelveGlob(cacheLabel + "-all.png", testSet=testSet) dataDict['summary'] = True fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig
def plot(self, data, dataId, showUndefined=False): testSet = self.getTestSet(data, dataId) testSet.setUseCache(self.useCache) isFinalDataId = False if len(data.brokenDataIdList ) == 0 or data.brokenDataIdList[-1] == dataId: isFinalDataId = True vLen = 3000.0 # for e=1.0 if self.showFpa: # fpa figures ellipBase = "medPsfEllip" ellipData, ellipMap = testSet.unpickle(ellipBase, default=[None, None]) ellipFig = qaFig.VectorFpaQaFigure(data.cameraInfo, data=ellipData, map=ellipMap) fwhmBase = "psfFwhm" fwhmData, fwhmMap = testSet.unpickle(fwhmBase, default=[None, None]) fwhmFig = qaFig.FpaQaFigure(data.cameraInfo, data=fwhmData, map=fwhmMap) fwhmMin = 1e10 fwhmMax = -1e10 fwhm = None for raft, ccdDict in ellipFig.data.items(): for ccd, value in ccdDict.items(): if self.ellipMedians.get(raft, ccd) is not None: ellipFig.data[raft][ccd] = [ self.thetaMedians.get(raft, ccd), 10 * vLen * self.ellipMedians.get(raft, ccd), self.ellipMedians.get(raft, ccd) ] ellipFig.map[raft][ccd] = "ell/theta=%.3f/%.0f" % ( self.ellipMedians.get(raft, ccd), numpy.degrees(self.thetaMedians.get(raft, ccd))) if self.fwhm.get(raft, ccd) is not None: fwhm = self.fwhm.get(raft, ccd) fwhmFig.data[raft][ccd] = fwhm fwhmFig.map[raft][ccd] = "fwhm=%.2f asec" % (fwhm) else: if fwhmFig.data[raft][ccd] is not None: fwhm = fwhmFig.data[raft][ccd] if fwhm is not None: if fwhm > fwhmMax: fwhmMax = fwhm if fwhm < fwhmMin: fwhmMin = fwhm testSet.pickle(ellipBase, [ellipFig.data, ellipFig.map]) testSet.pickle(fwhmBase, [fwhmFig.data, fwhmFig.map]) if fwhmMin < 1e10: vlimMin = numpy.max([self.limitsFwhm[0], fwhmMin]) else: vlimMin = self.limitsFwhm[0] if fwhmMax > -1e10: vlimMax = numpy.min([self.limitsFwhm[1], fwhmMax]) else: vlimMax = self.limitsFwhm[1] if vlimMax < vlimMin: vlimMax = vlimMin + (self.limitsFwhm[1] - self.limitsFwhm[0]) if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting FPAs") ellipFig.makeFigure(showUndefined=showUndefined, cmap="Reds", vlimits=self.limitsEllip, title="Median PSF Ellipticity", failLimits=self.limitsEllip) testSet.addFigure(ellipFig, ellipBase + ".png", "Median PSF Ellipticity", navMap=True) del ellipFig blue = '#0000ff' red = '#ff0000' fwhmFig.makeFigure(showUndefined=showUndefined, cmap="jet", vlimits=[vlimMin, vlimMax], title="PSF FWHM (arcsec)", cmapOver=red, failLimits=self.limitsFwhm, cmapUnder=blue) testSet.addFigure(fwhmFig, fwhmBase + ".png", "FWHM of Psf (arcsec)", navMap=True) del fwhmFig else: del ellipFig, fwhmFig # #xlim = [0, 25.0] #ylim = [0, 0.4] #Need to repeat vlim calculation here in case FPA not shown if not self.showFpa: fwhmMin = 1e10 fwhmMax = -1e10 fwhm = None if fwhmMin < 1e10: vlimMin = numpy.max([self.limitsFwhm[0], fwhmMin]) else: vlimMin = self.limitsFwhm[0] if fwhmMax > -1e10: vlimMax = numpy.min([self.limitsFwhm[1], fwhmMax]) else: vlimMax = self.limitsFwhm[1] if vlimMax < vlimMin: vlimMax = vlimMin + (self.limitsFwhm[1] - self.limitsFwhm[0]) norm = colors.Normalize(vmin=vlimMin, vmax=vlimMax) sm = cm.ScalarMappable(norm, cmap=cm.jet) cacheLabel = "psfEllip" shelfData = {} xlo, xhi, ylo, yhi = 1.e10, -1.e10, 1.e10, -1.e10 for raft, ccd in data.cameraInfo.raftCcdKeys: xxlo, yylo, xxhi, yyhi = data.cameraInfo.getBbox(raft, ccd) if xxlo < xlo: xlo = xxlo if xxhi > xhi: xhi = xxhi if yylo < ylo: ylo = yylo if yyhi > yhi: yhi = yyhi i = 0 xmin, xmax = 1.0e99, -1.0e99 for raft, ccd in self.ellip.raftCcdKeys(): eLen = self.ellip.get(raft, ccd) t = self.theta.get(raft, ccd) dx = eLen * numpy.cos(t) dy = eLen * numpy.sin(t) x = self.x.get(raft, ccd) y = self.y.get(raft, ccd) #x = self.ra.get(raft, ccd) #y = self.dec.get(raft, ccd) fwhm = self.fwhm.get(raft, ccd) self.log.log(self.log.INFO, "plotting %s" % (ccd)) if data.cameraInfo.name == 'coadd': xmin, ymin, xmax, ymax = x.min(), y.min(), x.max(), y.max() x -= xmin y -= ymin xxlo, yylo, xxhi, yyhi = xmin, ymin, xmax, ymax xlo, ylo, xhi, yhi = xmin, ymin, xmax, ymax else: xxlo, yylo, xxhi, yyhi = data.cameraInfo.getBbox(raft, ccd) limits = [xxlo, xxhi, yylo, yyhi] dataDict = { 't': t, 'x': x + xxlo, 'y': y + yylo, 'dx': dx, 'dy': dy, 'color': 'k', 'limits': [0, xxhi - xxlo, 0, yyhi - yylo], 'alllimits': [xlo, xhi, ylo, yhi], 'bbox': [xxlo, xxhi, yylo, yyhi], 'vLen': vLen, 'fwhm': numpy.array([fwhm] * len(t)), 'vlim': [vlimMin, vlimMax], 'summary': False, } label = data.cameraInfo.getDetectorName(raft, ccd) import PsfShapeQaAnalysisPlot as plotModule caption = "PSF ellipticity (e=1 shown with length %.0f pix))" % ( vLen) pngFile = cacheLabel + ".png" if self.lazyPlot.lower() in ['sensor', 'all']: testSet.addLazyFigure(dataDict, pngFile, caption, plotModule, areaLabel=label, plotargs="") else: testSet.cacheLazyData(dataDict, pngFile, areaLabel=label) fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting Summary figure") label = 'all' import PsfShapeQaAnalysisPlot as plotModule caption = "PSF ellipticity " + label pngFile = cacheLabel + ".png" if self.lazyPlot in ['all']: testSet.addLazyFigure({}, cacheLabel + ".png", caption, plotModule, areaLabel=label, plotargs="") else: dataDict, isSummary = qaPlotUtil.unshelveGlob(cacheLabel + "-all.png", testSet=testSet) dataDict['summary'] = True dataDict['vLen'] = 5.0 * vLen dataDict['limits'] = [xlo, xhi, ylo, yhi] fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig
def plot(self, data, dataId, showUndefined=False): testSet = self.getTestSet(data, dataId) testSet.setUseCache(self.useCache) #cache isFinalDataId = False if len(data.brokenDataIdList ) == 0 or data.brokenDataIdList[-1] == dataId: isFinalDataId = True if self.showFpa: # fpa figures medFigbase = "vignettingMedianPhotOffset" #cache medFigData, medFigMap = testSet.unpickle(medFigbase, [None, None]) #cache medFig = qaFig.FpaQaFigure(data.cameraInfo, data=medFigData, map=medFigMap) #cache for raft, ccdDict in medFig.data.items(): for ccd, value in ccdDict.items(): if self.medianOffset.get(raft, ccd) is not None: med = self.medianOffset.get(raft, ccd) medFig.data[raft][ccd] = med if num.isfinite(med): medFig.map[raft][ccd] = 'med=%.2f' % (med) else: medFig.map[raft][ccd] = 'med=nan' stdFigbase = "vignettingRmsPhotOffset" #cache stdFigData, stdFigMap = testSet.unpickle(stdFigbase, [None, None]) #cache stdFig = qaFig.FpaQaFigure(data.cameraInfo, data=stdFigData, map=stdFigMap) #cache for raft, ccdDict in stdFig.data.items(): for ccd, value in ccdDict.items(): if self.rmsOffset.get(raft, ccd) is not None: std = self.rmsOffset.get(raft, ccd) stdFig.data[raft][ccd] = std if num.isfinite(std): stdFig.map[raft][ccd] = 'stddev=%.2f' % (std) else: stdFig.map[raft][ccd] = 'stddev=nan' testSet.pickle(medFigbase, [medFig.data, medFig.map]) #cache testSet.pickle(stdFigbase, [stdFig.data, stdFig.map]) #cache blue = '#0000ff' red = '#ff0000' if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting FPAs") medFig.makeFigure(showUndefined=showUndefined, cmap="RdBu_r", vlimits=self.medLimits, title="Median offset", cmapOver=red, cmapUnder=blue, failLimits=self.medLimits) testSet.addFigure( medFig, medFigbase + ".png", "Median offset of bright (m<%d) stars versus radius" % (self.maxMag), navMap=True) del medFig stdFig.makeFigure(showUndefined=showUndefined, cmap="RdBu_r", vlimits=self.rmsLimits, title="Stddev offset", cmapOver=red, cmapUnder=blue, failLimits=self.rmsLimits) testSet.addFigure( stdFig, stdFigbase + ".png", "Stddev of bright (m < %d) stars as a function of radius" % (self.maxMag), navMap=True) del stdFig else: del medFig del stdFig cacheLabel = "vignetting_dmag" #cache shelfData = {} # make any individual (ie. per sensor) plots for raft, ccd in self.dmag.raftCcdKeys(): dmags = self.dmag.get(raft, ccd) radii = self.radius.get(raft, ccd) ids = self.ids.get(raft, ccd) med = self.medianOffset.get(raft, ccd) std = self.rmsOffset.get(raft, ccd) dataDict = { 'dmags': dmags, 'radii': radii, 'ids': ids, 'offsetStats': [med, std], 'magTypes': [self.magType1, self.magType2], 'summary': False, } self.log.log(self.log.INFO, "plotting %s" % (ccd)) import VignettingQaPlot as plotModule label = data.cameraInfo.getDetectorName(raft, ccd) caption = "Delta magnitude vs. radius " + label pngFile = cacheLabel + ".png" if self.lazyPlot.lower() in ['sensor', 'all']: testSet.addLazyFigure(dataDict, pngFile, caption, plotModule, areaLabel=label, plotargs="") else: testSet.cacheLazyData(dataDict, pngFile, areaLabel=label) fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig if not self.delaySummary or isFinalDataId: self.log.log(self.log.INFO, "plotting Summary figure") import VignettingQaPlot as plotModule label = 'all' caption = "Delta magnitude vs. radius " + label pngFile = cacheLabel + ".png" if self.lazyPlot in ['all']: testSet.addLazyFigure({}, pngFile, caption, plotModule, areaLabel=label, plotargs="") else: dataDict, isSummary = qaPlotUtil.unshelveGlob(cacheLabel + "-all.png", testSet=testSet) dataDict['summary'] = True fig = plotModule.plot(dataDict) testSet.addFigure(fig, pngFile, caption, areaLabel=label) del fig