当前位置: 首页>>代码示例>>Python>>正文


Python EmPlotter.isClosed方法代码示例

本文整理汇总了Python中pyworkflow.em.plotter.EmPlotter.isClosed方法的典型用法代码示例。如果您正苦于以下问题:Python EmPlotter.isClosed方法的具体用法?Python EmPlotter.isClosed怎么用?Python EmPlotter.isClosed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyworkflow.em.plotter.EmPlotter的用法示例。


在下文中一共展示了EmPlotter.isClosed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ExperimentWindow

# 需要导入模块: from pyworkflow.em.plotter import EmPlotter [as 别名]
# 或者: from pyworkflow.em.plotter.EmPlotter import isClosed [as 别名]

#.........这里部分代码省略.........
        xValues=xValues[0] # From [array(...)] to array(...)
        yValues=yValues[0]

        useMeasureLog = self.useMeasureLog()
        useTimeLog = self.useTimeLog()

        if not (useMeasureLog or useTimeLog):
            return xValues, yValues

        # If log will be used either for time or measure var
        # we need to filter elements larger than 0
        newXValues = []
        newYValues = []

        def _value(v, useLog):
            if useLog:
                return math.log10(v) if v > 0 else None
            return v

        for x, y in izip(xValues, yValues):
            x = _value(x, useTimeLog)
            y = _value(y, useMeasureLog)

            if x is not None and y is not None:
                newXValues.append(x)
                newYValues.append(y)

        return newXValues, newYValues

    def _onPlotClick(self, e=None):
        sampleKeys = self.samplesTree.selection()

        if sampleKeys:
            if self.plotter is None or self.plotter.isClosed():
                self.plotter = EmPlotter()
                doShow = True
                ax = self.plotter.createSubPlot("Plot", self.getTimeLabel(),
                                                self.getMeasureLabel())
                self.plotDict = {}
            else:
                doShow = False
                ax = self.plotter.getLastSubPlot()

            samples = [self.experiment.samples[k] for k in sampleKeys]
            for s in samples:
                if not s.sampleName in self.plotDict:
                    x, y = self.getPlotValues(s)
                    ax.plot(x, y, label=s.sampleName)
                    self.plotDict[s.sampleName] = True
            leg = ax.legend()
            if leg:
                leg.draggable()

            if doShow:
                self.plotter.show()
            else:
                self.plotter.draw()
        else:
            self.showInfo("Please select some sample(s) to plot.")

    def _onPlotSummaryClick(self, e=None):
        sampleKeys = self.samplesTree.selection()
        n = len(sampleKeys)

        if n == 1:
            self.showInfo("Please select several samples to plot.")
开发者ID:cossorzano,项目名称:scipion,代码行数:70,代码来源:tk_experiment.py

示例2: PKPDResponsiveDialog

# 需要导入模块: from pyworkflow.em.plotter import EmPlotter [as 别名]
# 或者: from pyworkflow.em.plotter.EmPlotter import isClosed [as 别名]

#.........这里部分代码省略.........

    def useMeasureLog(self):
        return self.measureWidget[2].get()

    def getUnits(self, varName):
        return self.experiment.variables[varName].getUnitsString()

    def getLabel(self, varName, useLog):
        varLabel = '%s [%s]' % (varName, self.getUnits(varName))
        if useLog:
            varLabel = "log10(%s)" % varLabel
        return varLabel

    def getTimeLabel(self):
        return self.getLabel(self.varNameX, self.useTimeLog())

    def getMeasureLabel(self):
        return self.getLabel(self.varNameY, self.useMeasureLog())

    def computePlotValues(self, xValues, yValues):
        useMeasureLog = self.useMeasureLog()
        useTimeLog = self.useTimeLog()

        if not (useMeasureLog or useTimeLog):
            newXValues = xValues
            newYValues = yValues
        else:
            # If log will be used either for time or measure var
            # we need to filter elements larger than 0
            newXValues = []
            newYValues = []

            def _value(v, useLog):
                if useLog:
                    return math.log10(v) if v > 0 else None
                return v

            for x, y in izip(xValues, yValues):
                x = _value(x, useTimeLog)
                y = _value(y, useMeasureLog)

                if x is not None and y is not None:
                    newXValues.append(x)
                    newYValues.append(y)

        return newXValues, newYValues

    def _updateModel(self):
        """ This function should be called whenever the sample changes """
        pass

    def _onLogChanged(self, *args):
        # We will treat a log change as a sample change to plot
        self._onSampleChanged()

    def _onSampleChanged(self, e=None):
        sampleKeys = self.samplesTree.selection()

        if sampleKeys:
            # When the sample is changed we need to re-compute (with log or not)
            # the x, y values
            self.sample = self.experiment.samples[sampleKeys[0]]
            self.xValues, self.yValues = self.sample.getXYValues(self.varNameX,
                                                                 self.varNameY)
            self.newXValues, self.newYValues = self.computePlotValues(self.xValues[0],
                                                                      self.yValues[0])
            self._updateModel()
            self.computeFit()
            self.plotResults()
        else:
            dialog.showInfo("Warning","Please select some sample(s) to plot.",self)

    def plotResults(self):
        if self.plotter is None or self.plotter.isClosed():
            self.plotter = EmPlotter()
            doShow = True
        else:
            doShow = False
            ax = self.plotter.getLastSubPlot()
            self.plotter.clear()

        ax = self.plotter.createSubPlot("Sample: %s" % self.sample.sampleName,
                                        self.getTimeLabel(),
                                        self.getMeasureLabel())
        self.newXPValues, self.newYPValues = self.computePlotValues(self.xpValues[0],
                                                                    self.ypValues[0])
        ax.plot(self.newXValues, self.newYValues, 'x', label="Observations")
        ax.plot(self.newXPValues, self.newYPValues, label="Fit")
        ax.legend()

        if doShow:
            self.plotter.show()
        else:
            self.plotter.draw()

    def destroy(self):
        """Destroy the window"""
        if not (self.plotter is None or self.plotter.isClosed()):
            self.plotter.close()
        dialog.Dialog.destroy(self)
开发者ID:cossorzano,项目名称:scipion,代码行数:104,代码来源:tk_ode.py


注:本文中的pyworkflow.em.plotter.EmPlotter.isClosed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。