def createCtfPlot(ctfSet, ctfId): from pyworkflow.utils.path import removeExt ctfModel = ctfSet[ctfId] psdFn = ctfModel.getPsdFile() fn = removeExt(psdFn) + "_avrot.txt" gridsize = [1, 1] xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='CTF Fitting') plot_title = "CTF Fitting" a = xplotter.createSubPlot(plot_title, 'pixels^-1', 'CTF', yformat=False) legendName = [] for i in range(1, 5): _plotCurve(a, i, fn) if i == 1: legendName.append('rotational avg. No Astg') elif i == 2: legendName.append('rotational avg.') elif i == 3: legendName.append('CTF Fit') elif i == 4: legendName.append('Cross Correlation') elif i == 5: legendName.append('2sigma cross correlation of noise') xplotter.showLegend(legendName) a.grid(True) xplotter.show()
def _showGuinier(self, volume): nrefs = len(self._refsList) gridsize = self._getGridSize(nrefs) guinierFn = volume + ".guinier" d2 = self._getGuinierValue(guinierFn, 0) legends = ["lnFweighted ln(F)", "corrected ln(F)", "model"] xplotter = EmPlotter(*gridsize, windowTitle='Guinier Plots') subPlot = xplotter.createSubPlot(basename(volume), 'd^-2(A^-2)', 'ln(F)', yformat=False) for i, legend in enumerate(legends): y = self._getGuinierValue(guinierFn, i+2) subPlot.plot(d2, y) xplotter.showLegend(legends) subPlot.grid(True) return xplotter
def _showFSC(self, paramName=None): threshold = self.resolutionThresholdFSC.get() nrefs = len(self._refsList) gridsize = self._getGridSize(nrefs) xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='Resolution FSC') if self.protocol.IS_REFINE: plot_title = 'FSC' a = xplotter.createSubPlot(plot_title, 'Angstroms^-1', 'FSC', yformat=False) legends = [] show = False for it in self._iterations: parFn = self.protocol._getFileName('output_vol_par', iter=it) if exists(parFn): show = True self._plotFSC(a, parFn) legends.append('iter %d' % it) xplotter.showLegend(legends) if show: if threshold < self.maxFrc: a.plot([self.minInv, self.maxInv],[threshold, threshold], color='black', linestyle='--') a.grid(True) else: raise Exception("Set a valid iteration to show its FSC") else: for ref3d in self._refsList: plot_title = 'class %s' % ref3d a = xplotter.createSubPlot(plot_title, 'Angstroms^-1', 'FSC', yformat=False) legends = [] for it in self._iterations: parFn = self.protocol._getFileName('output_vol_par_class', iter=it, ref=ref3d) if exists(parFn): show = True self._plotFSC(a, parFn) legends.append('iter %d' % it) xplotter.showLegend(legends) if show: if threshold < self.maxFrc: a.plot([self.minInv, self.maxInv],[threshold, threshold], color='black', linestyle='--') a.grid(True) else: raise Exception("Set a valid iteration to show its FSC") return [xplotter]
def _showFSC(self, paramName=None): threshold = self.resolutionThresholdFSC.get() gridsize = self._getGridSize(1) xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='Resolution FSC') plot_title = 'FSC' a = xplotter.createSubPlot(plot_title, 'Angstroms^-1', 'FSC', yformat=False) legends = [] show = False for it in self._iterations: if self.resolutionPlotsFSC.get() == FSC_UNMASK: fscUnmask = self.protocol._getFileName('fscUnmasked',run=self.protocol._getRun(), iter=it) if os.path.exists(fscUnmask): show = True self._plotFSC(a, fscUnmask) legends.append('unmasked map iter %d' % it) xplotter.showLegend(legends) elif self.resolutionPlotsFSC.get() == FSC_MASK: fscMask = self.protocol._getFileName('fscMasked',run=self.protocol._getRun(), iter=it) if os.path.exists(fscMask): show = True self._plotFSC(a, fscMask) legends.append('masked map iter %d' % it) xplotter.showLegend(legends) elif self.resolutionPlotsFSC.get() == FSC_MASKTIGHT: fscMaskTight = self.protocol._getFileName('fscMaskedTight',run=self.protocol._getRun(), iter=it) if os.path.exists(fscMaskTight): show = True self._plotFSC(a, fscMaskTight) legends.append('masked tight map iter %d' % it) xplotter.showLegend(legends) elif self.resolutionPlotsFSC.get() == FSC_ALL: fscUnmask = self.protocol._getFileName('fscUnmasked',run=self.protocol._getRun(), iter=it) fscMask = self.protocol._getFileName('fscMasked',run=self.protocol._getRun(), iter=it) fscMaskTight = self.protocol._getFileName('fscMaskedTight',run=self.protocol._getRun(), iter=it) if os.path.exists(fscUnmask): show = True self._plotFSC(a, fscUnmask) legends.append('unmasked map iter %d' % it) self._plotFSC(a, fscMask) legends.append('masked map iter %d' % it) self._plotFSC(a, fscMaskTight) legends.append('masked tight map iter %d' % it) xplotter.showLegend(legends) if show: if threshold < self.maxFrc: a.plot([self.minInv, self.maxInv],[threshold, threshold], color='black', linestyle='--') a.grid(True) else: raise Exception("Set a valid iteration to show its FSC") return [xplotter]
def createCtfPlot(ctfSet, ctfId): ctfModel = ctfSet[ctfId] psdFn = ctfModel.getPsdFile() fn = removeExt(psdFn) + "_avrot.txt" gridsize = [1, 1] xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='CTF Fitting') plot_title = "CTF Fitting" a = xplotter.createSubPlot(plot_title, 'pixels^-1', 'CTF', yformat=False) legendName = ['rotational avg. No Astg', 'rotational avg.', 'CTF Fit', 'Cross Correlation', '2sigma cross correlation of noise'] for i in range(1, 6): _plotCurve(a, i, fn) xplotter.showLegend(legendName) a.grid(True) xplotter.show()
def createCtfPlot(ctfSet, ctfId): ctfModel = ctfSet[ctfId] psdFn = ctfModel.getPsdFile() fn = pwutils.removeExt(psdFn) + "_EPA.txt" gridsize = [1, 1] xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='CTF Fitting') plot_title = "CTF Fitting" a = xplotter.createSubPlot(plot_title, 'Resolution (Angstroms)', 'CTF', yformat=False) a.invert_xaxis() for i in range(1, 5): _plotCurve(a, i, fn) xplotter.showLegend(['simulated CTF', 'equiphase avg.', 'equiphase avg. - bg', 'cross correlation']) a.grid(True) xplotter.show()
def createCtfPlot(ctfSet, ctfId): ctfModel = ctfSet[ctfId] psdFn = ctfModel.getPsdFile() fn = removeExt(psdFn) + "_avrot.txt" gridsize = [1, 1] xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='CTF Fitting') plot_title = "CTF Fitting" a = xplotter.createSubPlot(plot_title, 'pixels^-1', 'CTF', yformat=False) legendName = [ 'rotational avg. No Astg', 'rotational avg.', 'CTF Fit', 'Cross Correlation', '2sigma cross correlation of noise' ] for i in range(1, 6): _plotCurve(a, i, fn) xplotter.showLegend(legendName) a.grid(True) xplotter.show()
def _showSSNR(self, paramName=None): nrefs = len(self._refsList) gridsize = self._getGridSize(nrefs) xplotter = EmPlotter(x=gridsize[0], y=gridsize[1]) for ref3d in self._refsList: plot_title = 'Resolution SSNR, for Class %s' % ref3d a = xplotter.createSubPlot(plot_title, 'Angstroms^-1', 'sqrt(SSNR)', yformat=False) legendName = [] for it in self._iterations: if self.protocol.IS_REFINE: fn = self.protocol._getFileName('output_vol_par', iter=it) else: fn = self.protocol._getFileName('output_vol_par_class', iter=it, ref=ref3d) if exists(fn): self._plotSSNR(a, fn) legendName.append('iter %d' % it) xplotter.showLegend(legendName) a.grid(True) return [xplotter]
def _showFSC(self, paramName=None): threshold = self.resolutionThresholdFSC.get() iterations = self._getIterations() groups = self._getGroups() if self.groupFSC == 0: # group by iterations files = [(it, self._getFinalPath('fscdoc_%02d.stk' % it)) for it in iterations] legendPrefix = 'iter' else: it = iterations[-1] legendPrefix = 'group' def group(f): # retrieve the group number return int(f.split('_')[-1].split('.')[0]) groupFiles = glob(self._getFinalPath('fscdoc_%02d_???.stk' % it)) groupFiles.sort() files = [(group(f), f) for f in groupFiles if group(f) in groups] if not files: #empty files return [self.errorMessage("Please select valid groups to display", title="Wrong groups selection")] plotter = EmPlotter(x=1, y=1, windowTitle='Resolution FSC') a = plotter.createSubPlot("FSC", 'Angstroms^-1', 'FSC', yformat=False) #fscFile = self._getFinalPath('fscdoc_%02d.stk' % iterations[0]) legends = [] for it, fscFile in files: if os.path.exists(fscFile): self._plotFSC(a, fscFile) legends.append('%s %d' % (legendPrefix, it)) else: print "Missing file: ", fscFile if threshold < self.maxfsc: a.plot([self.minInv, self.maxInv],[threshold, threshold], color='black', linestyle='--') plotter.showLegend(legends) a.grid(True) return [plotter]
def createCtfPlot(ctfSet, ctfId): ctfModel = ctfSet[ctfId] psdFn = ctfModel.getPsdFile() fn = pwutils.removeExt(psdFn) + "_EPA.txt" gridsize = [1, 1] xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='CTF Fitting') plot_title = "CTF Fitting" a = xplotter.createSubPlot(plot_title, 'Resolution (Angstroms)', 'CTF', yformat=False) a.invert_xaxis() for i in range(1, 5): _plotCurve(a, i, fn) xplotter.showLegend([ 'simulated CTF', 'equiphase avg.', 'equiphase avg. - bg', 'cross correlation' ]) a.grid(True) xplotter.show()
def _showFSC(self, paramName=None): threshold = self.resolutionThresholdFSC.get() gridsize = self._getGridSize(1) xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='Resolution FSC') plot_title = 'FSC' a = xplotter.createSubPlot(plot_title, 'Angstroms^-1', 'FSC', yformat=False) legends = [] show = False for it in self._iterations: if self.resolutionPlotsFSC.get() == FSC_UNMASK: fscUnmask = self.protocol._getFileName( 'fscUnmasked', run=self.protocol._getRun(), iter=it) if os.path.exists(fscUnmask): show = True self._plotFSC(a, fscUnmask) legends.append('unmasked map iter %d' % it) xplotter.showLegend(legends) elif self.resolutionPlotsFSC.get() == FSC_MASK: fscMask = self.protocol._getFileName( 'fscMasked', run=self.protocol._getRun(), iter=it) if os.path.exists(fscMask): show = True self._plotFSC(a, fscMask) legends.append('masked map iter %d' % it) xplotter.showLegend(legends) elif self.resolutionPlotsFSC.get() == FSC_MASKTIGHT: fscMaskTight = self.protocol._getFileName( 'fscMaskedTight', run=self.protocol._getRun(), iter=it) if os.path.exists(fscMaskTight): show = True self._plotFSC(a, fscMaskTight) legends.append('masked tight map iter %d' % it) xplotter.showLegend(legends) elif self.resolutionPlotsFSC.get() == FSC_ALL: fscUnmask = self.protocol._getFileName( 'fscUnmasked', run=self.protocol._getRun(), iter=it) fscMask = self.protocol._getFileName( 'fscMasked', run=self.protocol._getRun(), iter=it) fscMaskTight = self.protocol._getFileName( 'fscMaskedTight', run=self.protocol._getRun(), iter=it) if os.path.exists(fscUnmask): show = True self._plotFSC(a, fscUnmask) legends.append('unmasked map iter %d' % it) self._plotFSC(a, fscMask) legends.append('masked map iter %d' % it) self._plotFSC(a, fscMaskTight) legends.append('masked tight map iter %d' % it) xplotter.showLegend(legends) if show: if threshold < self.maxFrc: a.plot([self.minInv, self.maxInv], [threshold, threshold], color='black', linestyle='--') a.grid(True) else: raise Exception("Set a valid iteration to show its FSC") return [xplotter]
def _showFSC(self, paramName=None): threshold = self.resolutionThresholdFSC.get() nrefs = len(self._refsList) gridsize = self._getGridSize(nrefs) xplotter = EmPlotter(x=gridsize[0], y=gridsize[1], windowTitle='Resolution FSC') if self.protocol.IS_REFINE: plot_title = 'FSC' a = xplotter.createSubPlot(plot_title, 'Angstroms^-1', 'FSC', yformat=False) legends = [] show = False for it in self._iterations: parFn = self.protocol._getFileName('output_vol_par', iter=it) if exists(parFn): show = True self._plotFSC(a, parFn) legends.append('iter %d' % it) xplotter.showLegend(legends) if show: if threshold < self.maxFrc: a.plot([self.minInv, self.maxInv], [threshold, threshold], color='black', linestyle='--') a.grid(True) else: raise Exception("Set a valid iteration to show its FSC") else: for ref3d in self._refsList: plot_title = 'class %s' % ref3d a = xplotter.createSubPlot(plot_title, 'Angstroms^-1', 'FSC', yformat=False) legends = [] for it in self._iterations: parFn = self.protocol._getFileName('output_vol_par_class', iter=it, ref=ref3d) if exists(parFn): show = True self._plotFSC(a, parFn) legends.append('iter %d' % it) xplotter.showLegend(legends) if show: if threshold < self.maxFrc: a.plot([self.minInv, self.maxInv], [threshold, threshold], color='black', linestyle='--') a.grid(True) else: raise Exception("Set a valid iteration to show its FSC") return [xplotter]