示例#1
0
文件: graph.py 项目: sgallet/pychron
 def add_point_inspector(self, scatter, convert_index=None):
     point_inspector = PointInspector(scatter, convert_index=convert_index)
     pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                tool=point_inspector)
     #
     scatter.overlays.append(pinspector_overlay)
     scatter.tools.append(point_inspector)
示例#2
0
    def add_tools(self,
                  plot,
                  scatter,
                  line=None,
                  convert_index=None,
                  add_inspector=True):

        # add a regression inspector tool to the line
        if line:
            tool = RegressionInspectorTool(component=line)
            overlay = RegressionInspectorOverlay(component=line, tool=tool)
            line.tools.append(tool)
            line.overlays.append(overlay)

        broadcaster = BroadcasterTool()
        scatter.tools.append(broadcaster)

        if add_inspector:
            point_inspector = PointInspector(scatter,
                                             convert_index=convert_index
                                             or self.convert_index_func)
            pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                       tool=point_inspector)

            scatter.overlays.append(pinspector_overlay)
            broadcaster.tools.append(point_inspector)

        rect_tool = RectSelectionTool(scatter)
        rect_overlay = RectSelectionOverlay(tool=rect_tool)

        scatter.overlays.append(rect_overlay)
        broadcaster.tools.append(rect_tool)
示例#3
0
def add_inspector(scatter, func, **kw):
    from pychron.graph.tools.point_inspector import PointInspector
    from pychron.graph.tools.point_inspector import PointInspectorOverlay

    point_inspector = PointInspector(scatter, additional_info=func, **kw)
    pinspector_overlay = PointInspectorOverlay(component=scatter,
                                               tool=point_inspector)

    scatter.overlays.append(pinspector_overlay)
    scatter.tools.append(point_inspector)
示例#4
0
    def _add_inspector(self, scatter):
        from pychron.graph.tools.point_inspector import PointInspector
        from pychron.graph.tools.point_inspector import PointInspectorOverlay

        point_inspector = PointInspector(scatter)
        pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                   tool=point_inspector)
        #
        scatter.overlays.append(pinspector_overlay)
        scatter.tools.append(point_inspector)
示例#5
0
    def _plot_baseline(self, i, iso, p, xma, xmi, yma, ymi):
        xs = iso.baseline.xs
        ys = iso.baseline.ys
        scatter, _ = self.graph.new_series(
            xs,
            ys,
            marker=p.marker,
            marker_size=p.marker_size,
            type='scatter',
            plotid=i,
            fit=iso.baseline.fit,
            filter_outliers_dict=iso.baseline.filter_outliers_dict,
            add_tools=False,
            color='black')

        pinspector = PointInspector(scatter, use_pane=True)

        xmi, xma = min_max(xmi, xma, xs)
        ymi, yma = min_max(ymi, yma, ys)
        return xma, xmi, yma, ymi, pinspector
示例#6
0
    def _plot_baseline(self, i, iso, p, xma, xmi, yma, ymi):
        xs = iso.baseline.xs
        ys = iso.baseline.ys
        plot, scatter, line = self.graph.new_series(
            xs,
            ys,
            marker=p.marker,
            marker_size=p.marker_size,
            type='scatter',
            plotid=i,
            fit=iso.baseline.fit,
            filter_outliers_dict=iso.baseline.filter_outliers_dict,
            add_tools=False,
            color='black')

        pinspector = PointInspector(scatter, use_pane=False)
        pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                   tool=pinspector)
        scatter.overlays.append(pinspector_overlay)
        xmi, xma = min_max(xmi, xma, xs)
        ymi, yma = min_max(ymi, yma, ys)
        return xma, xmi, yma, ymi, scatter, pinspector
示例#7
0
class IsoEvo(BaseArArFigure):
    ytitle = ''
    xtitle = 'Time (s)'
    show_sniff = True
    show_baseline = False

    def plot(self, plots, legend):
        for i, p in enumerate(plots):
            self._plot(i, p)

    def _plot(self, i, p):
        ai = self.analyses[0]

        # name is either an isotope "Ar40" or a detector "H1"
        # if its a detector only plot the baseline
        name = p.name

        is_baseline = False
        try:
            iso = ai.isotopes[name]
        except KeyError, e:
            is_baseline = True
            iso = next(
                (iso
                 for iso in ai.isotopes.itervalues() if iso.detector == name),
                None)
            if iso is None:
                print 'iso_evo _plot', ai.record_id, ai.isotopes_keys, name
                return

        ymi, yma = Inf, -Inf
        xmi, xma = 0, -Inf
        if is_baseline:
            xma, xmi, yma, ymi = self._plot_baseline(i, iso, p, xma, xmi, yma,
                                                     ymi)
            # print xma, xmi, yma, ymi
        else:
            if self.show_sniff:
                xs, ys = iso.sniff.xs, iso.sniff.ys
                scatter, _ = self.graph.new_series(xs,
                                                   ys,
                                                   marker=p.marker,
                                                   marker_size=p.marker_size,
                                                   type='scatter',
                                                   plotid=i,
                                                   fit=None,
                                                   add_inspector=False,
                                                   color='red')
                psinspector = PointInspector(scatter, use_pane=True)
                ymi, yma = min_max(ymi, yma, iso.sniff.ys)
                xmi, xma = min_max(xmi, xma, iso.sniff.xs)

            xs = iso.xs
            ys = iso.ys

            plot, scatter, line = self.graph.new_series(
                xs,
                ys,
                marker=p.marker,
                marker_size=p.marker_size,
                type='scatter',
                plotid=i,
                fit=iso.fit,
                filter_outliers_dict=iso.filter_outliers_dict,
                color='black',
                add_inspector=False)

            pinspector = PointInspector(scatter, use_pane=True)
            linspector = RegressionInspectorTool(component=line, use_pane=True)
            if psinspector:
                inspectors = [linspector, pinspector, psinspector]
            else:
                inspectors = [linspector, pinspector]

            ymi, yma = min_max(ymi, yma, iso.ys)
            xmi, xma = min_max(xmi, xma, iso.xs)

            if self.show_baseline:
                xma, xmi, yma, ymi, ins = self._plot_baseline(
                    i, iso, p, xma, xmi, yma, ymi)
                inspectors.append(ins)

            self._add_scatter_inspector(scatter, inspectors)
        self.graph.set_x_limits(min_=xmi, max_=xma * 1.05, plotid=i)
        self.graph.set_y_limits(min_=ymi, max_=yma, pad='0.05', plotid=i)
        self.graph.refresh()
示例#8
0
    def _plot(self, i, p):
        ai = self.analyses[0]

        # name is either an isotope "Ar40" or a detector "H1"
        # if its a detector only plot the baseline
        name = p.name

        is_baseline = False
        try:
            iso = ai.isotopes[name]
        except KeyError as e:
            is_baseline = True
            iso = ai.get_isotope(detector=name)
            # iso = next((iso for iso in six.itervalues(ai.isotopes) if iso.detector == name), None)
            if iso is None:
                print('iso_evo _plot', ai.record_id, ai.isotopes_keys, name)
                return

        ymi, yma = Inf, -Inf
        xmi, xma = 0, -Inf
        inspectors = []
        if is_baseline:
            xma, xmi, yma, ymi, scatter, ins = self._plot_baseline(
                i, iso, p, xma, xmi, yma, ymi)
            self._add_scatter_inspector(scatter, inspector=inspectors)
            # print xma, xmi, yma, ymi
        else:
            if self.options.show_sniff:
                # if self.show_sniff:
                xs, ys = iso.sniff.xs, iso.sniff.ys
                scatter, _ = self.graph.new_series(xs,
                                                   ys,
                                                   marker=p.marker,
                                                   marker_size=p.marker_size,
                                                   type='scatter',
                                                   plotid=i,
                                                   fit=None,
                                                   add_inspector=False,
                                                   color='red')
                psinspector = PointInspector(scatter)
                pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                           tool=psinspector)
                scatter.overlays.append(pinspector_overlay)
                inspectors.append(psinspector)

                ymi, yma = min_max(ymi, yma, iso.sniff.ys)
                xmi, xma = min_max(xmi, xma, iso.sniff.xs)

            xs = iso.xs
            ys = iso.ys

            plot, scatter, line = self.graph.new_series(
                xs,
                ys,
                marker=p.marker,
                marker_size=p.marker_size,
                type='scatter',
                plotid=i,
                fit=iso.fit,
                filter_outliers_dict=iso.filter_outliers_dict,
                color='black',
                add_inspector=False)

            pinspector = PointInspector(scatter, use_pane=False)
            pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                       tool=pinspector)
            scatter.overlays.append(pinspector_overlay)
            inspectors.append(pinspector)

            linspector = RegressionInspectorTool(component=line,
                                                 use_pane=False)
            scatter.overlays.append(
                RegressionInspectorOverlay(component=line, tool=linspector))
            inspectors.append(linspector)

            # if psinspector:
            #     inspectors = [linspector, pinspector, psinspector]
            # else:
            #     inspectors = [linspector, pinspector]

            ymi, yma = min_max(ymi, yma, iso.ys)
            xmi, xma = min_max(xmi, xma, iso.xs)

            if self.show_baseline:
                xma, xmi, yma, ymi, scatter, ins = self._plot_baseline(
                    i, iso, p, xma, xmi, yma, ymi)
                inspectors.append(ins)

            self._add_scatter_inspector(scatter, inspector=inspectors)

        self.graph.set_x_limits(min_=xmi, max_=xma * 1.05, plotid=i)
        self.graph.set_y_limits(min_=ymi, max_=yma, pad='0.05', plotid=i)
        self.graph.refresh()