Beispiel #1
0
    def update_react_graph(self, autoscale=None):
        """Updates the graph with reaction rates
        
        Attributes
        ----------
        
        autoscale
            will keep timescale from last ax unless it's the first plot. Default None.
        """
        if not self.reactList.selectedItems():
            return

        # Get current range
        former_xrange = None
        if self.firstAx is not None:
            former_xrange = self.firstAx.get_xlim()

        # clear the Axes
        if not self.reactWidget.axes:
            self.reactWidget.init_axes()
        else:
            self.reactWidget.clear()

        QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(Qt.WaitCursor))

        citer = cycle(COLOR_SERIES)
        lines = []
        for item in iter_2_selected(self.reactList):
            name = item[1]
            rate = array(self.data.rate(item[0]))

            flt = rate > RATE_THRESHOLD
            label = "[%d] %s" % (item[0], name)

            lines.append(self.reactWidget.axes[0].plot(self.data.t[flt],
                                                       rate[flt],
                                                       c=next(citer),
                                                       lw=LINE_WIDTH,
                                                       label=label,
                                                       zorder=10)[0])
            self.reactWidget.add_data(self.data.t, rate, label)

        self.reactWidget.rateAx.cursorlines = lines
        self.datacursor(self.reactWidget, unit='cm-3/s', labname='Reaction')

        self.reactWidget.set_scales(yscale='log', xscale=self.xscale)

        self.reactWidget.axes[0].set_xlabel("t [s]")
        self.reactWidget.axes[0].set_ylabel(
            "Rate [cm$^\mathdefault{-3}$s$^\mathdefault{-1}$]")
        self.reactWidget.axes[0].legend(loc=(1.025, 0.0), prop=dict(size=8))

        # Reset former xrange
        if former_xrange is not None:
            self.reactWidget.axes[0].set_xlim(former_xrange)

        self.reactWidget.axes[0].xaxis.set_major_formatter(TimeFormatter())

        # force an image redraw
        self.reactWidget.draw()

        QtWidgets.QApplication.restoreOverrideCursor()
Beispiel #2
0
    def update_spec_graph(self, autoscale=None):
        """Updates the graph with densities
        
        Attributes
        ----------
        
        autoscale
            will keep timescale from last ax unless it's the first plot. Default None.
        """

        # Get current range
        former_xrange = None
        if self.firstAx is not None:
            former_xrange = self.firstAx.get_xlim()

        # clear the Axes
        if not self.speciesList.selectedItems():
            return

        if not self.densWidget.axes:
            self.densWidget.init_axes()
        else:
            self.densWidget.clear()

        QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(Qt.WaitCursor))
        self.data.flush()

        citer = cycle(COLOR_SERIES)
        lines = []
        # Loop over all selected species
        for item in iter_2_selected(self.speciesList):
            name = item[1]
            dens = self.data.density(item[0])
            flt = dens > DENS_THRESHOLD
            lines.append(self.densWidget.axes[0].plot(self.data.t[flt],
                                                      dens[flt],
                                                      lw=LINE_WIDTH,
                                                      scalex=False,
                                                      c=next(citer),
                                                      label=name,
                                                      zorder=10)[0])
            self.densWidget.add_data(self.data.t, dens, name)

        self.densWidget.densAx.cursorlines = lines
        self.datacursor(self.densWidget, unit='cm-3', labname='Spec.')

        self.densWidget.set_scales(yscale='log', xscale=self.xscale)
        self.densWidget.axes[0].set_xlabel("t [s]")
        self.densWidget.axes[0].set_ylabel("Density [cm$^\mathdefault{-3}$]")
        self.densWidget.axes[0].legend(loc=(1.05, 0.0), prop=dict(size=11))

        # Reset former xrange
        if former_xrange is not None:
            self.densWidget.axes[0].set_xlim(former_xrange)
        else:  # autoscale to full range
            self.densWidget.axes[0].autoscale(True, axis='x')

        self.densWidget.axes[0].xaxis.set_major_formatter(TimeFormatter())

        # force an image redraw
        self.densWidget.draw()

        QtWidgets.QApplication.restoreOverrideCursor()
Beispiel #3
0
    def update_source_graph(self, autoscale=None):
        """Updates the graph with sources rates
        
        Attributes
        ----------
        
        autoscale
            will keep timescale from last ax unless it's the first plot. Default None.
        """
        try:
            species = list(iter_2_selected(self.speciesSourceList))[0]
        except AttributeError:
            return

        # Get current range
        former_xrange = None
        if self.firstAx is not None:
            former_xrange = self.firstAx.get_xlim()

        # clear the Axes
        if not self.sourceWidget.axes:
            self.sourceWidget.init_axes()
        else:
            self.sourceWidget.clear()

        QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(Qt.WaitCursor))

        filters = {
            0: (0.1, -1),
            1: (0.01, -1),
            2: (0.001, -1),
            3: (1e-4, -1),
            4: (0.0, -1)
        }

        delta, max_rates = filters[self.Combo_filter.currentIndex()]

        icreation, idestruct = select_rates(self.data,
                                            species[0],
                                            delta,
                                            max_rates=max_rates)

        citer = cycle(COLOR_SERIES)
        lines = []
        for i in icreation:
            name = self.data.reactions[i - 1]
            rate = array(self.data.rate(i))
            flt = rate > RATE_THRESHOLD
            label = "[%d] %s" % (i, name)

            lines.append(
                self.sourceWidget.creationAx.plot(self.data.t[flt],
                                                  rate[flt],
                                                  c=next(citer),
                                                  lw=LINE_WIDTH,
                                                  label=label,
                                                  scalex=False,
                                                  zorder=10)[0])

            self.sourceWidget.add_data(self.data.t, rate, label)
        self.sourceWidget.creationAx.cursorlines = lines

        citer = cycle(COLOR_SERIES)
        lines = []
        for i in idestruct:
            name = self.data.reactions[i - 1]
            rate = array(self.data.rate(i))
            flt = rate > RATE_THRESHOLD
            label = "[%d] %s" % (i, name)

            lines.append(
                self.sourceWidget.removalAx.plot(self.data.t[flt],
                                                 rate[flt],
                                                 c=next(citer),
                                                 lw=LINE_WIDTH,
                                                 label=label,
                                                 scalex=False,
                                                 zorder=10)[0])

            self.sourceWidget.add_data(self.data.t, rate, "- " + label)
        self.sourceWidget.removalAx.cursorlines = lines

        self.datacursor(self.sourceWidget, unit='cm-3/s', labname='Reac.')

        self.sourceWidget.creationAx.set_ylabel(
            "Production [cm$^\mathdefault{-3}$s$^\mathdefault{-1}$]")
        self.sourceWidget.creationAx.legend(loc=(1.05, 0.0), prop=dict(size=9))

        self.sourceWidget.removalAx.set_ylabel(
            "Losses [cm$^\mathdefault{-3}$s$^\mathdefault{-1}$]")
        self.sourceWidget.removalAx.set_xlabel("t [s]")

        self.sourceWidget.removalAx.legend(loc=(1.05, 0.0), prop=dict(size=9))

        self.sourceWidget.set_scales(yscale='log', xscale=self.xscale)

        # Reset former xrange
        if former_xrange is not None:
            self.sourceWidget.creationAx.set_xlim(former_xrange)


#            self.sourceWidget.removalAx.set_xlim(former_xrange)  # synchronized already
        else:  # autoscale to full range
            self.sourceWidget.creationAx.autoscale(True, axis='x')

        self.sourceWidget.creationAx.xaxis.set_major_formatter(TimeFormatter())
        self.sourceWidget.removalAx.xaxis.set_major_formatter(TimeFormatter())

        # force an image redraw
        self.sourceWidget.draw()

        QtWidgets.QApplication.restoreOverrideCursor()
Beispiel #4
0
    def update_cond_graph(self):
        """Updates the graph with conditions
        
        Attributes
        ----------
        
        autoscale
            will keep timescale from last ax unless it's the first plot. Default None.
            
        """
        #
        #        try:
        #            condition = list(iter_2_selected(self.condList))[0][0]
        #        except AttributeError:
        #            return

        # Get current range
        former_xrange = None
        if self.firstAx is not None:
            former_xrange = self.firstAx.get_xlim()

        # clear the Axes
        if not self.condWidget.axes:
            self.condWidget.init_axes()
        else:
            self.condWidget.clear()

        QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(Qt.WaitCursor))

        citer = cycle(COLOR_SERIES)
        lines = []
        label = ''
        # Loop over all selected conditions
        for item in iter_2_selected(self.condList):
            name = item[1]
            y = array(self.data.condition(item[0]))
            condition_name = self.data.conditions[item[0] - 1]

            flt = logical_and(isreal(y), isfinite(y))
            label = CONDITIONS_PRETTY_NAMES.get(condition_name, condition_name)
            lines.append(self.condWidget.axes[0].plot(
                self.data.t[flt],
                y[flt],
                lw=LINE_WIDTH,
                label=name,  #scalex=False,
                zorder=10,
                c=next(citer))[0])

        self.condWidget.condAx.cursorlines = lines
        self.datacursor(self.condWidget)

        self.condWidget.set_scales(yscale='linear', xscale=self.xscale)
        self.condWidget.axes[0].set_xlabel("t [s]")
        self.condWidget.axes[0].set_ylabel(label)

        # Reset former xrange
        if former_xrange is not None:
            self.condWidget.axes[0].set_xlim(former_xrange)
        else:  # autoscale to full range
            self.condWidget.axes[0].autoscale(True, axis='x')

        self.condWidget.axes[0].xaxis.set_major_formatter(TimeFormatter())

        # force an image redraw
        self.condWidget.draw()

        self.condWidget.add_data(self.data.t, y, label)
        QtWidgets.QApplication.restoreOverrideCursor()