Ejemplo n.º 1
0
    def _main_tab_default(self):
        self.sal_plot = Plot(self.plot_data)
        self.sal_plot.plot(('time_ds', 'sal_ds'), type='line')
        #sal_plot.overlays.append(PlotAxis(sal_plot, orientation='left'))
        #bottom_axis = PlotAxis(sal_plot, orientation="bottom",# mapper=xmapper,
        #                   tick_generator=ScalesTickGenerator(scale=CalendarScaleSystem()))
        #sal_plot.overlays.append(bottom_axis)

        #hgrid, vgrid = add_default_grids(sal_plot)
        #vgrid.tick_generator = bottom_axis.tick_generator
        #sal_plot.tools.append(PanTool(sal_plot, constrain=True,
        #                              constrain_direction="x"))
        #sal_plot.overlays.append(ZoomTool(sal_plot, drag_button="right",
        #                                  always_on=True,
        #                                  tool_mode="range",
        #                                  axis="index",
        #                                  max_zoom_out_factor=10.0,
        #                                  ))

        container = VPlotContainer(bgcolor="lightblue",
                                   spacing=40,
                                   padding=50,
                                   fill_padding=False)
        container.add(sal_plot)
        #container.add(price_plot)
        #container.overlays.append(PlotLabel("Salinity Plot with Date Axis",
        #                                    component=container,
        #                                    #font="Times New Roman 24"))
        #                                    font="Arial 24"))
        return container
Ejemplo n.º 2
0
    def __init__(self):
        # 首先需要调用父类的初始化函数
        super(TriangleWave, self).__init__()

        # 创建绘图数据集,暂时没有数据因此都赋值为空,只是创建几个名字,以供Plot引用
        self.plot_data = ArrayPlotData(x=[], y=[], f=[], p=[], x2=[], y2=[])

        # 创建一个垂直排列的绘图容器,它将频谱图和波形图上下排列
        self.container = VPlotContainer()

        # 创建波形图,波形图绘制两条曲线: 原始波形(x,y)和合成波形(x2,y2)
        self.plot_wave = self._create_plot(("x", "y"), "Triangle Wave")
        self.plot_wave.plot(("x2", "y2"), color="red")

        # 创建频谱图,使用数据集中的f和p
        self.plot_fft = self._create_plot(("f", "p"), "FFT", type="scatter")

        # 将两个绘图容器添加到垂直容器中
        self.container.add(self.plot_wave)
        self.container.add(self.plot_fft)

        # 设置
        self.plot_wave.x_axis.title = "Samples"
        self.plot_fft.x_axis.title = "Frequency pins"
        self.plot_fft.y_axis.title = "(dB)"

        # 改变fftsize为1024,因为Enum的默认缺省值为枚举列表中的第一个值
        self.fftsize = 1024
Ejemplo n.º 3
0
    def _main_tab_default(self):
        self.sal_plot = Plot(self.plot_data)
        self.sal_plot.plot(('time_ds', 'sal_ds'), type='line')
        #sal_plot.overlays.append(PlotAxis(sal_plot, orientation='left'))
        #bottom_axis = PlotAxis(sal_plot, orientation="bottom",# mapper=xmapper,
        #                   tick_generator=ScalesTickGenerator(scale=CalendarScaleSystem()))
        #sal_plot.overlays.append(bottom_axis)

        #hgrid, vgrid = add_default_grids(sal_plot)
        #vgrid.tick_generator = bottom_axis.tick_generator
        #sal_plot.tools.append(PanTool(sal_plot, constrain=True,
        #                              constrain_direction="x"))
        #sal_plot.overlays.append(ZoomTool(sal_plot, drag_button="right",
        #                                  always_on=True,
        #                                  tool_mode="range",
        #                                  axis="index",
        #                                  max_zoom_out_factor=10.0,
        #                                  ))

        container = VPlotContainer(bgcolor="lightblue",
                                   spacing=40,
                                   padding=50,
                                   fill_padding=False)
        container.add(sal_plot)
        #container.add(price_plot)
        #container.overlays.append(PlotLabel("Salinity Plot with Date Axis",
        #                                    component=container,
        #                                    #font="Times New Roman 24"))
        #                                    font="Arial 24"))
        return container
Ejemplo n.º 4
0
def _create_plot_component():

    # Create some x-y data series to plot
    x = linspace(-2.0, 10.0, 100)
    pd = ArrayPlotData(index = x)
    for i in range(5):
        pd.set_data("y" + str(i), jn(i,x))

    # Create some line plots of some of the data
    plot1 = Plot(pd, padding=50)
    plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red")
    plot1.plot(("index", "y3"), name="j_3", color="blue")

    # Attach some tools to the plot
    plot1.tools.append(PanTool(plot1))
    zoom = ZoomTool(component=plot1, tool_mode="box", always_on=False)
    plot1.overlays.append(zoom)

    # Add the scrollbar
    hscrollbar = PlotScrollBar(component=plot1, axis="index", resizable="h",
                               height=15)
    plot1.padding_top = 0
    hscrollbar.force_data_update()

    # Create a container and add our plots
    container = VPlotContainer()
    container.add(plot1)
    container.add(hscrollbar)

    return container
Ejemplo n.º 5
0
def create_zoomed_plot():
    try:
        x,y = read_music_data()
    except:
        x = linspace(-10*pi, 10*pi, numpts)
        y = sin(x)

    main_plot = create_gridded_line_plot(x,y)
    zoom_plot = create_gridded_line_plot(x,y)

    outer_container = VPlotContainer(padding=30,
                                     fill_padding=True,
                                     spacing=50,
                                     stack_order='top_to_bottom',
                                     bgcolor='lightgray',
                                     use_backbuffer=True)

    outer_container.add(main_plot)
    outer_container.add(zoom_plot)

    main_plot.controller = RangeSelection(main_plot)

    zoom_overlay = ZoomOverlay(source=main_plot, destination=zoom_plot)
    outer_container.overlays.append(zoom_overlay)

    return outer_container
Ejemplo n.º 6
0
def _create_plot_component(obj):
    # Setup the spectrum plot
    frequencies = linspace(0.0, float(SAMPLING_RATE)/2, num=NUM_SAMPLES/2)
    obj.spectrum_data = ArrayPlotData(frequency=frequencies)
    empty_amplitude = zeros(NUM_SAMPLES/2)
    obj.spectrum_data.set_data('amplitude', empty_amplitude)

    obj.spectrum_plot = Plot(obj.spectrum_data)
    spec_renderer = obj.spectrum_plot.plot(("frequency", "amplitude"), name="Spectrum",
                           color="red")[0]
    obj.spectrum_plot.padding = 50
    obj.spectrum_plot.title = "Spectrum"
    spec_range = obj.spectrum_plot.plots.values()[0][0].value_mapper.range
    spec_range.low = 0.0
    spec_range.high = 5.0
    obj.spectrum_plot.index_axis.title = 'Frequency (hz)'
    obj.spectrum_plot.value_axis.title = 'Amplitude'

    # Time Series plot
    times = linspace(0.0, float(NUM_SAMPLES)/SAMPLING_RATE, num=NUM_SAMPLES)
    obj.time_data = ArrayPlotData(time=times)
    empty_amplitude = zeros(NUM_SAMPLES)
    obj.time_data.set_data('amplitude', empty_amplitude)

    obj.time_plot = Plot(obj.time_data)
    obj.time_plot.plot(("time", "amplitude"), name="Time", color="blue")
    obj.time_plot.padding = 50
    obj.time_plot.title = "Time"
    obj.time_plot.index_axis.title = 'Time (seconds)'
    obj.time_plot.value_axis.title = 'Amplitude'
    time_range = obj.time_plot.plots.values()[0][0].value_mapper.range
    time_range.low = -0.2
    time_range.high = 0.2

    # Spectrogram plot
    values = [zeros(NUM_SAMPLES/2) for i in xrange(SPECTROGRAM_LENGTH)]
    p = WaterfallRenderer(index = spec_renderer.index, values = values,
            index_mapper = LinearMapper(range = obj.spectrum_plot.index_mapper.range),
            value_mapper = LinearMapper(range = DataRange1D(low=0, high=SPECTROGRAM_LENGTH)),
            y2_mapper = LinearMapper(low_pos=0, high_pos=8,
                            range=DataRange1D(low=0, high=15)),
            )
    spectrogram_plot = p
    obj.spectrogram_plot = p
    dummy = Plot()
    dummy.padding = 50
    dummy.index_axis.mapper.range = p.index_mapper.range
    dummy.index_axis.title = "Frequency (hz)"
    dummy.add(p)

    container = HPlotContainer()
    container.add(obj.spectrum_plot)
    container.add(obj.time_plot)

    c2 = VPlotContainer()
    c2.add(dummy)
    c2.add(container)

    return c2
Ejemplo n.º 7
0
    def _createResultsPane(self):
        container = VPlotContainer(resizable = "hv", bgcolor="lightgray", fill_padding=True, padding = 10)
        #container = Container(resizable = "hv", bgcolor="lightgray", fill_padding=True, padding = 10)
        addTitleOverlay(container, 'Results Pane')

        container.add(self._createVoltageTraceComponent())

        return container
Ejemplo n.º 8
0
 def __init__(self):
     super(EqualizerDesigner, self).__init__()
     self.plot_data = ArrayPlotData(f=FREQS, gain=[], phase=[])
     self.plot_gain = self._create_plot(("f", "gain"), "Gain(dB)")
     self.plot_phase = self._create_plot(("f", "phase"), "Phase(degree)")
     self.container = VPlotContainer()
     self.container.add(self.plot_phase)
     self.container.add(self.plot_gain)
     self.plot_gain.padding_bottom = 20
     self.plot_phase.padding_top = 20
Ejemplo n.º 9
0
    def _createConfigurationPane(self):
        container = VPlotContainer(resizable = "hv", bgcolor="lightgray", fill_padding=True, padding = 10)
        #container = Container(resizable = "hv", bgcolor="lightgray", fill_padding=True, padding = 10)
        addTitleOverlay(container, 'Configuration Pane')

        container.add(self._create_cellConfigComponent())
        container.add_trait ('self.surface_area_um2', self.surface_area_um2)
        #traits_view = View(Item('self.surface_area_um2', editor=ComponentEditor(), show_label=False), width=500, height=500, resizable=True, title="Chaco Plot")

        #container.add(traits_view)
        return container
Ejemplo n.º 10
0
    def normal_left_dclick(self, event):
        plot = Plot(self.data)
        for data, kw in self.command_queue:
            plot.plot(data, **kw)
            plot.title = self.title

        plot.title = self.title
        container = VPlotContainer(bgcolor=WindowColor)
        container.add(plot)
        plot.tools.append(PanTool(plot))
        plot.overlays.append(ZoomTool(plot))
        window = PlotWindow(plot=container)
        window.edit_traits(kind="live", parent=event.window.control)
Ejemplo n.º 11
0
    def _create_plot_component(self):
        self.data = ArrayPlotData()
        self.data["frequency"] = np.linspace(0., SAMPLING_RATE/2.0, num=NUM_SAMPLES/2)
        for i in range(NUM_LINES):
            self.data['amplitude%d' % i] = np.zeros(NUM_SAMPLES/2)
        self.data["time"] = np.linspace(0., float(NUM_SAMPLES)/SAMPLING_RATE, num=NUM_SAMPLES)
        self.data['time_amplitude'] = np.zeros(NUM_SAMPLES)        
        self.data['imagedata'] = np.zeros(( NUM_SAMPLES/2, SPECTROGRAM_LENGTH))
        
        spectrum_plot = Plot(self.data)
        for i in range(NUM_LINES):
            if i==NUM_LINES-1:
                linewidth = 2
                color = (1,0,0)
            else:
                linewidth = 1
                c = (NUM_LINES-i-1)/float(NUM_LINES)
                color = (1, 0.5+c/2, c)
            spectrum_plot.plot(("frequency", "amplitude%d" % i), name="Spectrum%d" % i, 
                color=color, line_width=linewidth)
        spectrum_plot.padding_bottom = 20
        spectrum_plot.padding_top = 20
        spec_range = list(spectrum_plot.plots.values())[0][0].value_mapper.range
        spec_range.low = -90
        spec_range.high = 0.0
        spectrum_plot.index_axis.title = 'Frequency(Hz)'
        spectrum_plot.value_axis.title = 'Amplitude(dB)'

        time_plot = Plot(self.data)
        time_plot.plot(("time", "time_amplitude"), name="Time", color="blue")
        time_plot.padding_top = 20
        time_plot.padding_bottom = 20
        time_plot.index_axis.title = 'Time (seconds)'
        time_plot.value_axis.title = 'Amplitude'
        time_range = list(time_plot.plots.values())[0][0].value_mapper.range
        time_range.low = -1.5
        time_range.high = 1.5

        spectrogram_plot = Plot(self.data)
        spectrogram_time = (0.0, SPECTROGRAM_LENGTH*NUM_SAMPLES/float(SAMPLING_RATE))
        spectrogram_freq = (0.0, SAMPLING_RATE/2.0)
        spectrogram_plot.img_plot('imagedata',
            name='Spectrogram',
            xbounds=spectrogram_time,
            ybounds=spectrogram_freq,
            colormap=cm.reverse(cm.Blues),
        )
        range_obj = spectrogram_plot.plots['Spectrogram'][0].value_mapper.range
        range_obj.high = -20
        range_obj.low = -60
        spectrogram_plot.padding_bottom = 20
        spectrogram_plot.padding_top = 20

        container = VPlotContainer()
        container.add(time_plot)    
        container.add(spectrum_plot)
        container.add(spectrogram_plot)

        return container        
Ejemplo n.º 12
0
    def __init__(self, **traits):
        super(ContainerExample, self).__init__(**traits)
        x = np.linspace(-14, 14, 100)
        y = np.sin(x) * x**3 / 1000
        data = ArrayPlotData(x=x, y=y)

        p1 = Plot(data, padding=30)
        p1.plot(("x", "y"), type="scatter", color="blue")
        p1.plot(("x", "y"), type="line", color="blue")

        p2 = Plot(data, padding=30)
        p2.plot(("x", "y"), type="line", color="blue")
        p2.set(bounds=[200, 100],
               position=[70, 150],
               bgcolor=(0.9, 0.9, 0.9),
               unified_draw=True,
               resizable="")

        p3 = Plot(data, padding=30)
        p3.plot(("x", "y"), type="line", color="blue", line_width=2.0)

        p4 = Plot(data, padding=30)
        p4.plot(("x", "y"), type="scatter", color="red", marker="circle")

        c1 = OverlayPlotContainer(p1, p2)

        c1.fixed_preferred_size = p3.get_preferred_size()
        c2 = HPlotContainer(c1, p3)
        c3 = VPlotContainer(p4, c2)

        self.plot = c3
    def __init__(self):
        # 首先需要调用父类的初始化函数
        super(TriangleWave, self).__init__()

        # 创建绘图数据集,暂时没有数据因此都赋值为空,只是创建几个名字,以供Plot引用
        self.plot_data = ArrayPlotData(x=[], y=[], f=[], p=[], x2=[], y2=[])

        # 创建一个垂直排列的绘图容器,它将频谱图和波形图上下排列
        self.container = VPlotContainer()

        # 创建波形图,波形图绘制两条曲线: 原始波形(x,y)和合成波形(x2,y2)
        self.plot_wave = self._create_plot(("x", "y"), "Triangle Wave")
        self.plot_wave.plot(("x2", "y2"), color="red")

        # 创建频谱图,使用数据集中的f和p
        self.plot_fft = self._create_plot(("f", "p"), "FFT", type="scatter")

        # 将两个绘图容器添加到垂直容器中
        self.container.add(self.plot_wave)
        self.container.add(self.plot_fft)

        # 设置
        self.plot_wave.x_axis.title = "Samples"
        self.plot_fft.x_axis.title = "Frequency pins"
        self.plot_fft.y_axis.title = "(dB)"

        # 改变fftsize为1024,因为Enum的默认缺省值为枚举列表中的第一个值
        self.fftsize = 1024
    def _create_plot_component(self):
        spectrum_plot = Plot(self.data)
        spectrum_plot.plot(("frequency", "amplitude"), name="Spectrum", color=(1, 0, 0), line_width=2)
        spectrum_plot.padding_bottom = 20
        spectrum_plot.padding_top = 20
        spectrum_plot.index_range.low = MIN_FREQUENCY
        spectrum_plot.index_range.high = MAX_FREQUENCY
        spec_range = spectrum_plot.plots.values()[0][0].value_mapper.range
        spec_range.low = 0.0
        spec_range.high = 65536.0
        spectrum_plot.index_axis.title = 'Frequency(Hz)'
        spectrum_plot.value_axis.title = 'Amplitude(dB)'

        container = VPlotContainer()
        container.add(spectrum_plot)
        return container        
 def _field_data_plots_default(self):
     
     # Plot data and vertical container object
     data = ArrayPlotData(**self._get_field_plots_data())
     container = VPlotContainer()
     
     # Add individual distributions plots to container
     for key in ('area', 'diameter', 'average', 'peak'):
         p = Plot(data)
         p.plot((key+'_bins', key), name=key, type='polygon', edge_width=2, 
             edge_color='red', face_color='salmon')
         p.x_axis.title = key
         p.y_axis.title = 'count'
         p.padding = [50, 30, 20, 40]
         container.add(p)
     
     return container
Ejemplo n.º 16
0
 def test_halign(self):
     container = VPlotContainer(bounds=[200,300], halign="center")
     comp1 = StaticPlotComponent([100,200])
     container.add(comp1)
     container.do_layout()
     self.failUnlessEqual(comp1.position, [50,0])
     container.halign="right"
     container.do_layout(force=True)
     self.failUnlessEqual(comp1.position, [100,0])
     return
Ejemplo n.º 17
0
    def _create_window(self):

        # Create the data and datasource objects
        # In order for the date axis to work, the index data points need to
        # be in units of seconds since the epoch.  This is because we are using
        # the CalendarScaleSystem, whose formatters interpret the numerical values
        # as seconds since the epoch.
        numpoints = 500
        index = create_dates(numpoints)
        returns = random.lognormal(0.01, 0.1, size=numpoints)
        price = 100.0 * cumprod(returns)
        volume = abs(random.normal(1000.0, 1500.0, size=numpoints) + 2000.0)

        time_ds = ArrayDataSource(index)
        vol_ds = ArrayDataSource(volume, sort_order="none")
        price_ds = ArrayDataSource(price, sort_order="none")

        # Create the price plots
        price_plot, mini_plot = self._create_price_plots(time_ds, price_ds)
        price_plot.index_mapper.domain_limits = (index[0], index[-1])
        self.price_plot = price_plot
        self.mini_plot = mini_plot

        # Create the volume plot
        vol_plot = self._create_vol_plot(time_ds, vol_ds)
        vol_plot.index_mapper.domain_limits = (index[0], index[-1])

        # Set the plot's bottom axis to use the Scales ticking system
        ticker = ScalesTickGenerator(scale=CalendarScaleSystem())
        for plot in price_plot, mini_plot, vol_plot:
            bottom_axis = PlotAxis(plot, orientation="bottom",
                                   tick_generator = ticker)
            plot.overlays.append(bottom_axis)
            plot.overlays.append(PlotAxis(plot, orientation="left"))
            hgrid, vgrid = add_default_grids(plot)
            vgrid.tick_generator = bottom_axis.tick_generator

        container = VPlotContainer(bgcolor = "lightgray",
                                   spacing = 40,
                                   padding = 50,
                                   fill_padding=False)
        container.add(mini_plot, vol_plot, price_plot)

        return Window(self, -1, component=container)
    def _create_plot_component(self):
        self.data = ArrayPlotData()
        self.data["frequency"] = np.linspace(0., SAMPLING_RATE/2.0, num=NUM_SAMPLES/2)
        for i in xrange(NUM_LINES):
            self.data['amplitude%d' % i] = np.zeros(NUM_SAMPLES/2)
        self.data["time"] = np.linspace(0., float(NUM_SAMPLES)/SAMPLING_RATE, num=NUM_SAMPLES)
        self.data['time_amplitude'] = np.zeros(NUM_SAMPLES)        
        self.data['imagedata'] = np.zeros(( NUM_SAMPLES/2, SPECTROGRAM_LENGTH))
        
        spectrum_plot = Plot(self.data)
        for i in xrange(NUM_LINES):
            if i==NUM_LINES-1:
                linewidth = 2
                color = (1,0,0)
            else:
                linewidth = 1
                c = (NUM_LINES-i-1)/float(NUM_LINES)
                color = (1, 0.5+c/2, c)
            spectrum_plot.plot(("frequency", "amplitude%d" % i), name="Spectrum%d" % i, 
                color=color, line_width=linewidth)
        spectrum_plot.padding_bottom = 20
        spectrum_plot.padding_top = 20
        spec_range = spectrum_plot.plots.values()[0][0].value_mapper.range
        spec_range.low = -90
        spec_range.high = 0.0
        spectrum_plot.index_axis.title = 'Frequency(Hz)'
        spectrum_plot.value_axis.title = 'Amplitude(dB)'

        time_plot = Plot(self.data)
        time_plot.plot(("time", "time_amplitude"), name="Time", color="blue")
        time_plot.padding_top = 20
        time_plot.padding_bottom = 20
        time_plot.index_axis.title = 'Time (seconds)'
        time_plot.value_axis.title = 'Amplitude'
        time_range = time_plot.plots.values()[0][0].value_mapper.range
        time_range.low = -1.5
        time_range.high = 1.5

        spectrogram_plot = Plot(self.data)
        spectrogram_time = (0.0, SPECTROGRAM_LENGTH*NUM_SAMPLES/float(SAMPLING_RATE))
        spectrogram_freq = (0.0, SAMPLING_RATE/2.0)
        spectrogram_plot.img_plot('imagedata',
            name='Spectrogram',
            xbounds=spectrogram_time,
            ybounds=spectrogram_freq,
            colormap=cm.reverse(cm.Blues),
        )
        range_obj = spectrogram_plot.plots['Spectrogram'][0].value_mapper.range
        range_obj.high = -20
        range_obj.low = -60
        spectrogram_plot.padding_bottom = 20
        spectrogram_plot.padding_top = 20

        container = VPlotContainer()
        container.add(time_plot)    
        container.add(spectrum_plot)
        container.add(spectrogram_plot)

        return container        
 def _unit_data_plots_default(self):
     
     # Plot data and vertical container object
     data = ArrayPlotData(**self._get_unit_plots_data())
     container = VPlotContainer()
     
     # Add individual distribution plots to container
     for key in ('avg_diameter', 'avg_area', 'coverage', 'max_r', 'num_fields'):
         p = Plot(data)
         p.plot((key+'_bins', key), name=key, type='polygon', edge_width=2, 
             edge_color='mediumblue', face_color='lightsteelblue')
         p.x_axis.title = key
         p.y_axis.title = 'count'
         p.padding = [50, 30, 20, 40]
         if key == 'num_fields':
             p.x_axis.tick_interval = 1
         container.add(p)
     
     return container
 def __init__(self):
     super(EqualizerDesigner, self).__init__()
     self.plot_data = ArrayPlotData(f=FREQS, gain=[], phase=[])
     self.plot_gain = self._create_plot(("f", "gain"), "Gain(dB)")
     self.plot_phase = self._create_plot(("f", "phase"), "Phase(degree)")
     self.container = VPlotContainer()
     self.container.add( self.plot_phase )                
     self.container.add( self.plot_gain )
     self.plot_gain.padding_bottom = 20
     self.plot_phase.padding_top = 20
Ejemplo n.º 21
0
    def _create_complexspectrumplot(self, x, y1, y2):
        amplitudeplot = create_line_plot((x, y1), index_bounds=None, value_bounds=None,
                                         orientation='h', color='green', width=1.0, dash='solid',
                                         value_mapper_class=LinearMapper,
                                         bgcolor='white', border_visible=True,
                                         add_grid=False, add_axis=False, index_sort='ascending')
        add_default_axes(amplitudeplot, orientation='normal', htitle='Frequency [MHz]', vtitle='Amplitude')

        amplitudeplot.tools.append(PanTool(amplitudeplot, drag_button="right"))
        zoom = SimpleZoom(component=amplitudeplot, tool_mode="box", drag_button="left", always_on=True)
        amplitudeplot.overlays.append(zoom)

        phaseplot = create_line_plot((x, y2), index_bounds=None,
                                     value_bounds=None,
                                     orientation='h', color='red',
                                     width=1.0, dash='solid',
                                     value_mapper_class=LinearMapper,
                                     bgcolor='white', border_visible=True,
                                     add_grid=False, add_axis=False,
                                     index_sort='ascending')
        add_default_axes(phaseplot, orientation='normal',
                         htitle='Frequency [MHz]', vtitle='Unwrapped phase')

        #        phaseplot.tools.append(PanTool(phaseplot, drag_button="right"))
        zoom = SimpleZoom(component=phaseplot, tool_mode="box",
                          drag_button="left", always_on=True,
                          #                          enter_zoom_key=KeySpec('z')
        )
        phaseplot.overlays.append(zoom)
        self.rangeselect = RangeSelection(phaseplot, left_button_selects=False)
        self.rangeselect.on_trait_change(self.phase_center, "selection_completed")
        phaseplot.active_tool = self.rangeselect
        phaseplot.overlays.append(RangeSelectionOverlay(component=phaseplot))

        container = VPlotContainer(padding=40, padding_left=60, spacing=40)
        container.add(phaseplot)
        container.add(amplitudeplot)
        self.container = container
Ejemplo n.º 22
0
    def _createVoltageTraceComponent(self):

        x = arange(-5, 15, 100)
        tracedata = ArrayPlotData(x=x, y1=np.sin(x), y2=np.cos(x))

        plot = Plot(tracedata)
        plot.x_axis.title = "time"
        plot.y_axis.title = "Voltage"
        renderer = plot.plot(("x", "y1"), type="line", color="blue",
                                  width=2.0)[0]
        renderer.overlays.append(LineInspector(renderer, axis='value',
                                                write_metadata=True,
                                                is_listener=True))
        renderer.overlays.append(LineInspector(renderer, axis="index",
                                                write_metadata=True,
                                                is_listener=True))
        plot.overlays.append(ZoomTool(plot, tool_mode="range"))
        plot.tools.append(PanTool(plot))

        # Make the container:
        container = VPlotContainer(resizable = "hv", bgcolor="lightgray", fill_padding=True, padding = 10)
        container.add(plot)
        return container
Ejemplo n.º 23
0
    def __init__(self, model, ui, extension, parent):
        '''
        Constructor
        '''
        self.model = model
        self.ui = ui
        self.extension = extension
        self.parent = parent

        self.plots = {}
        self.renderers = {}

        self.hidden = False
        self.time_src = ArrayDataSource([])
        self.container = VPlotContainer(bgcolor="white",
                                        fill_padding=True,
                                        border_visible=False,
                                        stack_order='top_to_bottom')
        self.setup_plots()
        self.pc = self.edit_traits(view='container_view',
                                   parent=parent,
                                   kind='subpanel').control
        parent.layout.addWidget(self.pc)
        self.pc.setParent(parent)
Ejemplo n.º 24
0
 def test_stack_nonresize(self):
     container = VPlotContainer(bounds=[100,300])
     comp1 = StaticPlotComponent([70,100])
     comp2 = StaticPlotComponent([80,90])
     comp3 = StaticPlotComponent([90,80])
     container.add(comp1, comp2, comp3)
     container.do_layout()
     self.assert_tuple(container.get_preferred_size(), (90, 270))
     self.assert_tuple(container.bounds, (100,300))
     self.assert_tuple(comp1.position, (0,0))
     self.assert_tuple(comp2.position, (0,100))
     self.assert_tuple(comp3.position, (0,190))
     return
Ejemplo n.º 25
0
 def test_stack_one_resize(self):
     "Checks stacking with 1 resizable component thrown in"
     container = VPlotContainer(bounds=[100,300])
     comp1 = StaticPlotComponent([70,100])
     comp2 = StaticPlotComponent([80,90])
     comp3 = StaticPlotComponent([90,80], resizable='hv')
     comp4 = StaticPlotComponent([50,40])
     container.add(comp1, comp2, comp3, comp4)
     container.do_layout()
     self.assert_tuple(container.get_preferred_size(), (80,230))
     self.assert_tuple(container.bounds, (100,300))
     self.assert_tuple(comp1.position, (0,0))
     self.assert_tuple(comp2.position, (0,100))
     self.assert_tuple(comp3.position, (0,190))
     self.assert_tuple(comp4.position, (0,260))
     return
Ejemplo n.º 26
0
 def __init__(self, model, ui, extension, parent):
     '''
     Constructor
     '''
     self.model = model
     self.ui = ui
     self.extension = extension
     self.parent = parent
     
     self.plots = {}
     self.renderers = {}
     
     self.hidden = False
     self.time_src = ArrayDataSource([])
     self.container = VPlotContainer(bgcolor = "white",
         fill_padding=True,
         border_visible=False,
         stack_order = 'top_to_bottom')  
     self.setup_plots()
     self.pc = self.edit_traits(view='container_view', parent=parent, kind='subpanel').control
     parent.layout.addWidget(self.pc)
     self.pc.setParent(parent)
Ejemplo n.º 27
0
    def __init__(self, **traits):
        super(SelectionDemo, self).__init__(**traits)
        x = np.linspace(-140, 140, 1000)
        y = np.sin(x) * x**3
        y /= np.max(y)
        data = ArrayPlotData(x=x, y=y)

        self.plot1 = plot1 = Plot(data, padding=25)
        self.line1 = line1 = plot1.plot(("x", "y"), type="line")[0]

        self.select_tool = select_tool = RangeSelection(line1)
        line1.tools.append(select_tool)
        select_tool.on_trait_change(self._selection_changed, "selection")

        line1.overlays.append(RangeSelectionOverlay(component=line1))

        self.plot2 = plot2 = Plot(data, padding=25)
        plot2.plot(("x", "y"), type="line")[0]

        self.plot = VPlotContainer(plot2, plot1)

        self.data = data
Ejemplo n.º 28
0
 def _container_default(self):
     #image_container = OverlayPlotContainer(padding=20,
     #                                         use_backbuffer=True,
     #                                         unified_draw=True)
     #image_container.add(self.plot)
     container = HPlotContainer(padding=40,
                                fill_padding=True,
                                bgcolor="white",
                                use_backbuffer=False)
     inner_cont = VPlotContainer(padding=0, use_backbuffer=True)
     #        container = HPlotContainer(bgcolor = "white", use_backbuffer=False)
     #        inner_cont = VPlotContainer(use_backbuffer=True)
     inner_cont.add(self.h_plot)
     inner_cont.add(self.plot)
     container.add(inner_cont)
     container.add(self.v_plot)
     return container
Ejemplo n.º 29
0
class plotBox(HasTraits):
	pointsClicked = Int
	index = Array
	normal = Array
	shear = Array
	pointX = Array(dtype = int, value = ([0.0,100.0,200.0]), comparison_mode = 0)
	pointY = Array(dtype = float, value = ([0.0,0.0,0.0]), comparison_mode = 0)
	message = Str
	isAccepted = Bool
	accept = Action(name = "Accept", action = "accept")
	reject = Action(name = "Reject", action = "reject")
	cursorPosX = Int
	cursorPosY = Float
	vPlot = Instance(VPlotContainer)

	def __init__(self, fileName, fOut):
		super(plotBox, self).__init__()

		self.isAccepted = True
		self.fOut = fOut
		self.message = 'Analysis Acceptable?'
		self.vPlot = VPlotContainer(padding = 10)
		self.vPlot.stack_order = 'top_to_bottom'
		topPlot = OverlayPlotContainer(padding = 10)
		self.vPlot.add(topPlot)
		bottomPlot = OverlayPlotContainer(padding = 10)
		self.vPlot.add(bottomPlot)

		# def parseFileName():
		self.fileName = fileName
		# get complete path of data file
		fullFileName = os.path.abspath(fileName)
		self.fileName = os.path.split(fullFileName)[1]
		self.shortFileName = os.path.splitext(self.fileName)[1]
		self.plotTitle = self.shortFileName

		# def readData():
		fileIn = open(fileName,'r')
		hD = rx.readDataFileHeader(fileIn)
		dD = rx.readDataFileArray(fileIn)

		self.normal = numpy.array(map(float,dD['voltageForceNormal']))
		self.shear  = numpy.array(map(float,dD['voltageForceLateral']))
		self.index  = numpy.arange(len(self.normal))

		# index dictionary
		iD = rx.parseForceTrace(hD,dD)
		self.pointX[0] = iD['indexContact']
		self.pointY[0] = self.normal[iD['indexContact']]
		self.pointX[1] = iD['indexMaxPreload']
		self.pointY[1] = self.normal[iD['indexMaxPreload']]
		self.pointX[2] = iD['indexMaxAdhesion']
		self.pointY[2] = self.normal[iD['indexMaxAdhesion']]

		# def constructPlots():
		self.plotdata = ArrayPlotData(index = self.index,
		                              normal = self.normal,
		                              shear = self.shear,
		                              pointX = self.pointX,
		                              pointY = self.pointY)
		self.normalPlot = Plot(self.plotdata)
		self.normalPlot.plot(('index','normal'), type = 'line',
		                                         color = 'blue')
		self.normalPlot.plot(('pointX','pointY'), type = 'scatter',
		                                          marker = 'diamond',
		                                          marker_size = 5,
		                                          color = (0.0,0.0,1.0,0.5),
		                                          outline_color = 'none')
		self.normalPlot.value_range.set_bounds(-1,1)
		self.shearPlot = Plot(self.plotdata)
		self.shearPlot.plot(('index','shear'),type='line',color='green')

		self.normalPlot.overlays.append(customTool(plotBox = self,
		                                   component = self.normalPlot,
		                                   axis = 'index_x',
		                                   inspect_mode = 'indexed',
		                                   write_metadata = True,
		                                   color = 'black',
		                                   is_listener = False))

		self.normalPlot.tools.append(rx.SimpleZoom(self.normalPlot))
		self.normalPlot.tools.append(PanTool(self.normalPlot,drag_button = 'right'))

		self.normalPlot.title = 'Normal Force Trace'
		self.shearPlot.title  = 'Shear Force Trace'
		topPlot.add(self.shearPlot)
		bottomPlot.add(self.normalPlot)

		self.shearPlot.index_range = self.normalPlot.index_range

	traits_view = View(Item('vPlot',
										      editor = ComponentEditor(),
										      resizable = True,
										      show_label = False),
										 HGroup(Item('message',    width = 200),
										        Item('cursorPosX', width = 200),
										        Item('cursorPosY', width = 200),
										        Item('pointX', style='readonly', width = 200),
										        Item('pointY', style='readonly', width = 200)),
										        buttons = [accept, reject, OKButton],
                     title = 'Roxanne Parse Application',
                     handler = plotBoxHandler(),
                     key_bindings = key_bindings,
                     resizable = True,
                     width = 1400, height = 800,
                     x = 20, y = 40)
Ejemplo n.º 30
0
    def create_plot_component(self):
        color_range_max_value = 10

        # gripper right cos field
        x_axis = numpy.array(
            range(self.arch._gripper_right_cos_field.
                  get_output_dimension_sizes()[0]))
        self._gripper_right_cos_field_plotdata = ArrayPlotData(
            x=x_axis, y=self.arch._gripper_right_cos_field.get_activation())
        self._gripper_right_cos_field_plot = Plot(
            self._gripper_right_cos_field_plotdata)
        self._gripper_right_cos_field_plot.title = 'gripper right cos'
        self._gripper_right_cos_field_plot.plot(("x", "y"),
                                                name='gripper_right_cos',
                                                type="line",
                                                color="blue")
        range_self = self._gripper_right_cos_field_plot.plots[
            'gripper_right_cos'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # gripper left cos field
        x_axis = numpy.array(
            range(
                self.arch._gripper_left_cos_field.get_output_dimension_sizes()
                [0]))
        self._gripper_left_cos_field_plotdata = ArrayPlotData(
            x=x_axis, y=self.arch._gripper_left_cos_field.get_activation())
        self._gripper_left_cos_field_plot = Plot(
            self._gripper_left_cos_field_plotdata)
        self._gripper_left_cos_field_plot.title = 'gripper left cos'
        self._gripper_left_cos_field_plot.plot(("x", "y"),
                                               name='gripper_left_cos',
                                               type="line",
                                               color="blue")
        range_self = self._gripper_left_cos_field_plot.plots[
            'gripper_left_cos'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # find red color intention field
        x_axis = numpy.array(
            range(self.arch._find_color.get_intention_field().
                  get_output_dimension_sizes()[0]))
        self._find_color_intention_field_plotdata = ArrayPlotData(
            x=x_axis,
            y=self.arch._find_color.get_intention_field().get_activation())
        self._find_color_intention_field_plot = Plot(
            self._find_color_intention_field_plotdata)
        self._find_color_intention_field_plot.title = 'find color int'
        self._find_color_intention_field_plot.plot(("x", "y"),
                                                   name='find_color_int',
                                                   type="line",
                                                   color="blue")
        range_self = self._find_color_intention_field_plot.plots[
            'find_color_int'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # find green color intention field
        x_axis = numpy.array(
            range(self.arch._find_color_ee.get_intention_field().
                  get_output_dimension_sizes()[0]))
        self._find_color_ee_intention_field_plotdata = ArrayPlotData(
            x=x_axis,
            y=self.arch._find_color_ee.get_intention_field().get_activation())
        self._find_color_ee_intention_field_plot = Plot(
            self._find_color_ee_intention_field_plotdata)
        self._find_color_ee_intention_field_plot.title = 'find color ee int'
        self._find_color_ee_intention_field_plot.plot(("x", "y"),
                                                      name='find_color_ee_int',
                                                      type="line",
                                                      color="blue")
        range_self = self._find_color_ee_intention_field_plot.plots[
            'find_color_ee_int'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # camera
        self._camera_field_plotdata = ArrayPlotData()
        self._camera_field_plotdata.set_data(
            'imagedata',
            self.arch._camera_field.get_activation().max(2).transpose())
        self._camera_field_plot = Plot(self._camera_field_plotdata)
        self._camera_field_plot.title = 'camera'
        self._camera_field_plot.img_plot(
            'imagedata',
            name='camera_field',
            xbounds=(0, self.arch._camera_field_sizes[0] - 1),
            ybounds=(0, self.arch._camera_field_sizes[1] - 1),
            colormap=jet,
        )
        range_self = self._camera_field_plot.plots['camera_field'][
            0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # color space red
        self._color_space_field_plotdata = ArrayPlotData()
        self._color_space_field_plotdata.set_data(
            'imagedata',
            self.arch._color_space_field.get_activation().max(1).transpose())
        self._color_space_field_plot = Plot(self._color_space_field_plotdata)
        self._color_space_field_plot.title = 'color space'
        self._color_space_field_plot.img_plot(
            'imagedata',
            name='color_space_field',
            xbounds=(0, self.arch._color_space_field_sizes[0] - 1),
            ybounds=(0, self.arch._color_space_field_sizes[2] - 1),
            colormap=jet,
        )
        range_self = self._color_space_field_plot.plots['color_space_field'][
            0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # color space green
        self._color_space_ee_field_plotdata = ArrayPlotData()
        self._color_space_ee_field_plotdata.set_data(
            'imagedata',
            self.arch._color_space_ee_field.get_activation().max(
                2).transpose())
        self._color_space_ee_field_plot = Plot(
            self._color_space_ee_field_plotdata)
        self._color_space_ee_field_plot.title = 'color space ee'
        self._color_space_ee_field_plot.img_plot(
            'imagedata',
            name='color_space_ee_field',
            xbounds=(0, self.arch._color_space_ee_field_sizes[0] - 1),
            ybounds=(0, self.arch._color_space_ee_field_sizes[1] - 1),
            colormap=jet,
        )
        range_self = self._color_space_ee_field_plot.plots[
            'color_space_ee_field'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # spatial target
        self._spatial_target_field_plotdata = ArrayPlotData()
        self._spatial_target_field_plotdata.set_data(
            'imagedata',
            self.arch._spatial_target_field.get_activation().transpose())
        self._spatial_target_field_plot = Plot(
            self._spatial_target_field_plotdata)
        self._spatial_target_field_plot.title = 'spatial target'
        self._spatial_target_field_plot.img_plot(
            'imagedata',
            name='spatial_target_field',
            xbounds=(0, self.arch._spatial_target_field_sizes[0] - 1),
            ybounds=(0, self.arch._spatial_target_field_sizes[1] - 1),
            colormap=jet,
        )
        range_self = self._spatial_target_field_plot.plots[
            'spatial_target_field'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # move head intention
        self._move_head_intention_field_plotdata = ArrayPlotData()
        self._move_head_intention_field_plotdata.set_data(
            'imagedata',
            self.arch._move_head.get_intention_field().get_activation().
            transpose())
        self._move_head_intention_field_plot = Plot(
            self._move_head_intention_field_plotdata)
        self._move_head_intention_field_plot.title = 'move head int'
        self._move_head_intention_field_plot.img_plot(
            'imagedata',
            name='move_head_intention_field',
            xbounds=(0, self.arch._move_head_field_sizes[0] - 1),
            ybounds=(0, self.arch._move_head_field_sizes[1] - 1),
            colormap=jet,
        )
        range_self = self._move_head_intention_field_plot.plots[
            'move_head_intention_field'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # move head cos
        self._move_head_cos_field_plotdata = ArrayPlotData()
        self._move_head_cos_field_plotdata.set_data(
            'imagedata',
            self.arch._move_head.get_cos_field().get_activation().transpose())
        self._move_head_cos_field_plot = Plot(
            self._move_head_cos_field_plotdata)
        self._move_head_cos_field_plot.title = 'move head cos'
        self._move_head_cos_field_plot.img_plot(
            'imagedata',
            name='move_head_cos_field',
            xbounds=(0, self.arch._move_head_field_sizes[0] - 1),
            ybounds=(0, self.arch._move_head_field_sizes[1] - 1),
            colormap=jet,
        )
        range_self = self._move_head_cos_field_plot.plots[
            'move_head_cos_field'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # move right arm intention
        self._move_right_arm_intention_field_plotdata = ArrayPlotData()
        self._move_right_arm_intention_field_plotdata.set_data(
            'imagedata',
            self.arch._move_right_arm_intention_field.get_activation().
            transpose())
        self._move_right_arm_intention_field_plot = Plot(
            self._move_right_arm_intention_field_plotdata)
        self._move_right_arm_intention_field_plot.title = 'move right arm int'
        self._move_right_arm_intention_field_plot.img_plot(
            'imagedata',
            name='move_right_arm_intention_field',
            xbounds=(0, self.arch._move_arm_field_sizes[0] - 1),
            ybounds=(0, self.arch._move_arm_field_sizes[1] - 1),
            colormap=jet,
        )
        range_self = self._move_right_arm_intention_field_plot.plots[
            'move_right_arm_intention_field'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # move right arm cos
        self._move_right_arm_cos_field_plotdata = ArrayPlotData()
        self._move_right_arm_cos_field_plotdata.set_data(
            'imagedata',
            self.arch._move_arm_cos_field.get_activation().transpose())
        self._move_right_arm_cos_field_plot = Plot(
            self._move_right_arm_cos_field_plotdata)
        self._move_right_arm_cos_field_plot.title = 'move right arm cos'
        self._move_right_arm_cos_field_plot.img_plot(
            'imagedata',
            name='move_right_arm_cos_field',
            xbounds=(0, self.arch._move_arm_field_sizes[0] - 1),
            ybounds=(0, self.arch._move_arm_field_sizes[1] - 1),
            colormap=jet,
        )
        range_self = self._move_right_arm_cos_field_plot.plots[
            'move_right_arm_cos_field'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # visual servoing right intention
        self._visual_servoing_right_intention_field_plotdata = ArrayPlotData()
        self._visual_servoing_right_intention_field_plotdata.set_data(
            'imagedata',
            self.arch._visual_servoing_right.get_intention_field().
            get_activation().transpose())
        self._visual_servoing_right_intention_field_plot = Plot(
            self._visual_servoing_right_intention_field_plotdata)
        self._visual_servoing_right_intention_field_plot.title = 'visual servoing right int'
        self._visual_servoing_right_intention_field_plot.img_plot(
            'imagedata',
            name='visual_servoing_right_intention_field',
            xbounds=(0, self.arch._visual_servoing_field_sizes[0] - 1),
            ybounds=(0, self.arch._visual_servoing_field_sizes[1] - 1),
            colormap=jet,
        )
        range_self = self._visual_servoing_right_intention_field_plot.plots[
            'visual_servoing_right_intention_field'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        # visual servoing right cos
        self._visual_servoing_right_cos_field_plotdata = ArrayPlotData()
        self._visual_servoing_right_cos_field_plotdata.set_data(
            'imagedata',
            self.arch._visual_servoing_right.get_cos_field().get_activation().
            transpose())
        self._visual_servoing_right_cos_field_plot = Plot(
            self._visual_servoing_right_cos_field_plotdata)
        self._visual_servoing_right_cos_field_plot.title = 'visual servoing right cos'
        self._visual_servoing_right_cos_field_plot.img_plot(
            'imagedata',
            name='visual_servoing_right_cos_field',
            xbounds=(0, self.arch._visual_servoing_field_sizes[0] - 1),
            ybounds=(0, self.arch._visual_servoing_field_sizes[1] - 1),
            colormap=jet,
        )
        range_self = self._visual_servoing_right_cos_field_plot.plots[
            'visual_servoing_right_cos_field'][0].value_mapper.range
        range_self.high = color_range_max_value
        range_self.low = -color_range_max_value

        self._container = VPlotContainer()
        self._hcontainer_top = HPlotContainer()
        self._hcontainer_bottom = HPlotContainer()
        self._hcontainer_bottom.add(self._camera_field_plot)
        self._hcontainer_bottom.add(self._color_space_field_plot)
        self._hcontainer_bottom.add(self._spatial_target_field_plot)
        self._hcontainer_bottom.add(self._move_head_intention_field_plot)
        self._hcontainer_bottom.add(self._move_right_arm_intention_field_plot)
        #        self._hcontainer_bottom.add(self._find_color_intention_field_plot)
        #        self._hcontainer_bottom.add(self._gripper_right_intention_field_plot)

        self._hcontainer_top.add(self._color_space_ee_field_plot)
        self._hcontainer_top.add(
            self._visual_servoing_right_intention_field_plot)
        self._hcontainer_top.add(self._visual_servoing_right_cos_field_plot)
        self._hcontainer_top.add(self._move_head_cos_field_plot)
        self._hcontainer_top.add(self._move_right_arm_cos_field_plot)
        #        self._hcontainer_top.add(self._gripper_right_cos_field_plot)

        self._container.add(self._hcontainer_bottom)
        self._container.add(self._hcontainer_top)
Ejemplo n.º 31
0
	def __init__(self, fileName, fOut):
		super(plotBox, self).__init__()

		self.isAccepted = True
		self.fOut = fOut
		self.message = 'Analysis Acceptable?'
		self.vPlot = VPlotContainer(padding = 10)
		self.vPlot.stack_order = 'top_to_bottom'
		topPlot = OverlayPlotContainer(padding = 10)
		self.vPlot.add(topPlot)
		bottomPlot = OverlayPlotContainer(padding = 10)
		self.vPlot.add(bottomPlot)

		# def parseFileName():
		self.fileName = fileName
		# get complete path of data file
		fullFileName = os.path.abspath(fileName)
		self.fileName = os.path.split(fullFileName)[1]
		self.shortFileName = os.path.splitext(self.fileName)[1]
		self.plotTitle = self.shortFileName

		# def readData():
		fileIn = open(fileName,'r')
		hD = rx.readDataFileHeader(fileIn)
		dD = rx.readDataFileArray(fileIn)

		self.normal = numpy.array(map(float,dD['voltageForceNormal']))
		self.shear  = numpy.array(map(float,dD['voltageForceLateral']))
		self.index  = numpy.arange(len(self.normal))

		# index dictionary
		iD = rx.parseForceTrace(hD,dD)
		self.pointX[0] = iD['indexContact']
		self.pointY[0] = self.normal[iD['indexContact']]
		self.pointX[1] = iD['indexMaxPreload']
		self.pointY[1] = self.normal[iD['indexMaxPreload']]
		self.pointX[2] = iD['indexMaxAdhesion']
		self.pointY[2] = self.normal[iD['indexMaxAdhesion']]

		# def constructPlots():
		self.plotdata = ArrayPlotData(index = self.index,
		                              normal = self.normal,
		                              shear = self.shear,
		                              pointX = self.pointX,
		                              pointY = self.pointY)
		self.normalPlot = Plot(self.plotdata)
		self.normalPlot.plot(('index','normal'), type = 'line',
		                                         color = 'blue')
		self.normalPlot.plot(('pointX','pointY'), type = 'scatter',
		                                          marker = 'diamond',
		                                          marker_size = 5,
		                                          color = (0.0,0.0,1.0,0.5),
		                                          outline_color = 'none')
		self.normalPlot.value_range.set_bounds(-1,1)
		self.shearPlot = Plot(self.plotdata)
		self.shearPlot.plot(('index','shear'),type='line',color='green')

		self.normalPlot.overlays.append(customTool(plotBox = self,
		                                   component = self.normalPlot,
		                                   axis = 'index_x',
		                                   inspect_mode = 'indexed',
		                                   write_metadata = True,
		                                   color = 'black',
		                                   is_listener = False))

		self.normalPlot.tools.append(rx.SimpleZoom(self.normalPlot))
		self.normalPlot.tools.append(PanTool(self.normalPlot,drag_button = 'right'))

		self.normalPlot.title = 'Normal Force Trace'
		self.shearPlot.title  = 'Shear Force Trace'
		topPlot.add(self.shearPlot)
		bottomPlot.add(self.normalPlot)

		self.shearPlot.index_range = self.normalPlot.index_range
Ejemplo n.º 32
0
class Plots(HasTraits):
    '''
    
    Main work horse. Model of the data.
    '''  

    container = Instance(VPlotContainer)
    
    container_view = View(Item('container', editor=ComponentEditor(), show_label=False, width = 1000, height = 400), 
                   width = 1000, height = 400, resizable=True)
    
    #*************************************__init__()************************************* 
    def __init__(self, model, ui, extension, parent):
        '''
        Constructor
        '''
        self.model = model
        self.ui = ui
        self.extension = extension
        self.parent = parent
        
        self.plots = {}
        self.renderers = {}
        
        self.hidden = False
        self.time_src = ArrayDataSource([])
        self.container = VPlotContainer(bgcolor = "white",
            fill_padding=True,
            border_visible=False,
            stack_order = 'top_to_bottom')  
        self.setup_plots()
        self.pc = self.edit_traits(view='container_view', parent=parent, kind='subpanel').control
        parent.layout.addWidget(self.pc)
        self.pc.setParent(parent)
    
    #*************************************update_plots()************************************* 
    def update_plots(self, pc):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        ann = pc.data_dict["annotations"]
        t0 = ann.get_value("START")
        t1 = ann.get_value("STOP")
        tug = ann.get_value("TURN_AROUND")
        delta = t1 - t0
        total = delta.seconds + delta.microseconds * 10**(-6)
        self.time_src.set_data([0, total])

        t2 = tug-t0
        t2 = t2.seconds + t2.microseconds * 10**(-6)


        self.x_axis.labels = ["START", "TURN_AROUND", "5s", "STOP"]
        self.x_axis.positions = [0,
                                 t2,
                                 5,
                                 total]
        
        for name, plot in self.plots.items():
            plot_conactory = plot.plot_conactory
          
            res = pc.results[name[:-3]] # to remove the extension
            print res
            data_src = plot_conactory.datasources.get("index")
            data_src.set_data(res[0])
              
            data_src = plot_conactory.datasources.get(name)
            data_src.set_data(res[1])
            
    #*************************************create_plot()************************************* 
    def create_plot(self, name, ylabel="", color="blue"):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        p = PlotContainer(name, self, self.time_src)
        p.plot_conactory.y_axis.title = ylabel
        self.plots[name] = p
        
        p.plot_data.set_data(name, [])
        renderer, = p.plot_conactory.plot(("index", name), name=name, color=color, line_width=1.5)
        self.renderers[name] = renderer
        
        self.container.add(p.plot_conactory)

    #*************************************setup_plots()************************************* 
    def setup_plots(self):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        ext = self.extension
        
        if ext == "S2":
            color = "green"
        else:
            color = "blue"

        self.create_plot("AAE " + ext, ylabel="[ ]", color=color)
        self.create_plot("ARE " + ext, ylabel="[ ]", color=color)
        self.create_plot("Jerk " + ext, ylabel="[m/s2/s]", color=color)
        self.create_plot("SI " + ext, ylabel="[ ]", color=color)
        self.create_plot("VI " + ext, ylabel="[ ]", color=color)
        
        p = self.plots["VI " + ext]
        
        null_ds = ArrayDataSource([])
        self.time_plot = LinePlot(index = self.time_src, value = null_ds,
                        index_mapper = LinearMapper(range=DataRange1D(self.time_src)),
                        value_mapper = LinearMapper(range=DataRange1D(null_ds)),  
                        color = "black",
                        border_visible = True,
                        bgcolor = "white",
                        height = 10,
                        resizable = "h",
                        padding_top=50,
                        padding_bottom=40,
                        padding_left=50,
                        padding_right=20)
        self.ticker = ScalesTickGenerator()  
        self.x_axis = LabelAxis(self.time_plot, orientation="bottom", title="Time [sec]", label_rotation=0)
        #self.x_axis = PlotAxis(self.time_plot, orientation="bottom", tick_generator = self.ticker, title="Time [sec]")
        self.time_plot.underlays.append(self.x_axis)
        self.container.add(self.time_plot)
        
        # Add a range overlay to the miniplot that is hooked up to the range
        # of the main price_plot
        range_tool = RangeSelection(self.time_plot)
        self.time_plot.tools.append(range_tool)
        range_overlay = RangeSelectionOverlay(self.time_plot, metadata_name="selections")
        self.time_plot.overlays.append(range_overlay)
        range_tool.on_trait_change(self._range_selection_handler, "selection")
        self.range_tool = range_tool

        p.plot_conactory.index_range.on_trait_change(self._plot_range_handler, "updated")
        self.zoom_overlay = ZoomOverlay(source=self.time_plot, destination=p.plot_conactory)
        self.container.overlays.append(self.zoom_overlay)
          
    #*************************************set_inde_range()************************************* 
    def set_index_range(self, low, high):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        iterator = iter(self.renderers.values())
        while True:
            try:
                curr = iterator.next()
                curr.index_range.low = low
                curr.index_range.high = high
            except StopIteration:
                break 
            
    #*************************************set_bounds()************************************* 
    def set_bounds(self, low, high):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        iterator = iter(self.renderers.values())
        while True:
            try:
                curr = iterator.next()
                curr.index_range.set_bounds(low, high)
            except StopIteration:
                break 
       
    #*************************************_range_selection_handler()************************************* 
    def _range_selection_handler(self, event):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        # The event obj should be a tuple (low, high) in data space
        if event is not None:
            low, high = event
            self.set_index_range(low, high)
        else:
            self.set_bounds("auto", "auto")
        
    #*************************************_plot_range_handler()************************************* 
    def _plot_range_handler(self, event):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        if event is not None:
            low, high = event
            if "auto" not in (low, high):
                pass
                '''if low < self.df["Time"][0]:
                    low = self.df["Time"][0]
                if high > self.df["Time"][self.counter-1]:
                    high = self.df["Time"][self.counter-1]
                self.range_tool.selection = (low, high)'''
          
          
    #*************************************change_view()************************************* 
    def change_view(self, plots_to_show):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        temp = list(self.container.components) # to get a copy
        for plot in temp:
            #if type(plot).__name__ == 'Plot':
            self.container.remove(plot)
            
        plots_to_show.sort()
        for plot in plots_to_show:    
            self.container.add(self.plots[plot + " " + self.extension].plot_conactory)
        self.container.add(self.time_plot) # add the time_plot back last so it is on the bottom
        self.container.request_redraw()
                
    #*************************************hide()************************************* 
    def hide(self):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        self.hidden = True
        self.pc.hide()
        
    #*************************************unhide()************************************* 
    def unhide(self):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        self.hidden = False
        self.pc.show()
Ejemplo n.º 33
0
def _create_plot_component():

    # Create the data and datasource objects
    numpoints = 500
    index = arange(numpoints)
    returns = random.lognormal(0.01, 0.1, size=numpoints)
    price = 100.0 * cumprod(returns)
    volume = abs(random.normal(1000.0, 1500.0, size=numpoints) + 2000.0)

    time_ds = ArrayDataSource(index)
    vol_ds = ArrayDataSource(volume, sort_order="none")
    price_ds = ArrayDataSource(price, sort_order="none")

    xmapper = LinearMapper(range=DataRange1D(time_ds))
    vol_mapper = LinearMapper(range=DataRange1D(vol_ds))
    price_mapper = LinearMapper(range=DataRange1D(price_ds))

    price_plot = FilledLinePlot(index = time_ds, value = price_ds,
                                index_mapper = xmapper,
                                value_mapper = price_mapper,
                                edge_color = "blue",
                                face_color = "paleturquoise",
                                bgcolor = "white",
                                border_visible = True)
    add_default_grids(price_plot)
    price_plot.overlays.append(PlotAxis(price_plot, orientation='left'))
    price_plot.overlays.append(PlotAxis(price_plot, orientation='bottom'))
    price_plot.tools.append(PanTool(price_plot, constrain=True,
                                    constrain_direction="x"))
    price_plot.overlays.append(ZoomTool(price_plot, drag_button="right",
                                          always_on=True,
                                          tool_mode="range",
                                          axis="index"))

    vol_plot = BarPlot(index = time_ds, value = vol_ds,
                       index_mapper = xmapper,
                       value_mapper = vol_mapper,
                       line_color = "transparent",
                       fill_color = "black",
                       bar_width = 1.0,
                       bar_width_type = "screen",
                       antialias = False,
                       height = 100,
                       resizable = "h",
                       bgcolor = "white",
                       border_visible = True)

    add_default_grids(vol_plot)
    vol_plot.underlays.append(PlotAxis(vol_plot, orientation='left'))
    vol_plot.tools.append(PanTool(vol_plot, constrain=True,
                                  constrain_direction="x"))

    container = VPlotContainer(bgcolor = "lightblue",
                               spacing = 20,
                               padding = 50,
                               fill_padding=False)
    container.add(vol_plot)
    container.add(price_plot)
    container.overlays.append(PlotLabel("Financial Plot",
                                        component=container,
                                        #font="Times New Roman 24"))
                                        font="Arial 24"))
    return container
class TriangleWave(HasTraits):
    # 指定三角波的最窄和最宽范围,由于Range似乎不能将常数和traits名混用
    # 所以定义这两个不变的trait属性
    low = Float(0.02)
    hi = Float(1.0)

    # 三角波形的宽度
    wave_width = Range("low", "hi", 0.5)

    # 三角波的顶点C的x轴坐标
    length_c = Range("low", "wave_width", 0.5)

    # 三角波的定点的y轴坐标
    height_c = Float(1.0)

    # FFT计算所使用的取样点数,这里用一个Enum类型的属性以供用户从列表中选择
    fftsize = Enum([(2 ** x) for x in range(6, 12)])

    # FFT频谱图的x轴上限值
    fft_graph_up_limit = Range(0, 400, 20)

    # 用于显示FFT的结果
    peak_list = Str

    # 采用多少个频率合成三角波
    N = Range(1, 40, 4)

    # 保存绘图数据的对象
    plot_data = Instance(AbstractPlotData)

    # 绘制波形图的容器
    plot_wave = Instance(Component)

    # 绘制FFT频谱图的容器
    plot_fft = Instance(Component)

    # 包括两个绘图的容器
    container = Instance(Component)

    # 设置用户界面的视图, 注意一定要指定窗口的大小,这样绘图容器才能正常初始化
    view = View(
        HSplit(
            VSplit(
                VGroup(
                    Item("wave_width", editor=scrubber, label=u"波形宽度"),
                    Item("length_c", editor=scrubber, label=u"最高点x坐标"),
                    Item("height_c", editor=scrubber, label=u"最高点y坐标"),
                    Item("fft_graph_up_limit", editor=scrubber, label=u"频谱图范围"),
                    Item("fftsize", label=u"FFT点数"),
                    Item("N", label=u"合成波频率数"),
                ),
                Item("peak_list", style="custom", show_label=False, width=100, height=250),
            ),
            VGroup(
                Item("container", editor=ComponentEditor(size=(600, 300)), show_label=False), orientation="vertical"
            ),
        ),
        resizable=True,
        width=800,
        height=600,
        title=u"三角波FFT演示",
    )

    # 创建绘图的辅助函数,创建波形图和频谱图有很多类似的地方,因此单独用一个函数以
    # 减少重复代码
    def _create_plot(self, data, name, type="line"):
        p = Plot(self.plot_data)
        p.plot(data, name=name, title=name, type=type)
        p.tools.append(PanTool(p))
        zoom = ZoomTool(component=p, tool_mode="box", always_on=False)
        p.overlays.append(zoom)
        p.title = name
        return p

    def __init__(self):
        # 首先需要调用父类的初始化函数
        super(TriangleWave, self).__init__()

        # 创建绘图数据集,暂时没有数据因此都赋值为空,只是创建几个名字,以供Plot引用
        self.plot_data = ArrayPlotData(x=[], y=[], f=[], p=[], x2=[], y2=[])

        # 创建一个垂直排列的绘图容器,它将频谱图和波形图上下排列
        self.container = VPlotContainer()

        # 创建波形图,波形图绘制两条曲线: 原始波形(x,y)和合成波形(x2,y2)
        self.plot_wave = self._create_plot(("x", "y"), "Triangle Wave")
        self.plot_wave.plot(("x2", "y2"), color="red")

        # 创建频谱图,使用数据集中的f和p
        self.plot_fft = self._create_plot(("f", "p"), "FFT", type="scatter")

        # 将两个绘图容器添加到垂直容器中
        self.container.add(self.plot_wave)
        self.container.add(self.plot_fft)

        # 设置
        self.plot_wave.x_axis.title = "Samples"
        self.plot_fft.x_axis.title = "Frequency pins"
        self.plot_fft.y_axis.title = "(dB)"

        # 改变fftsize为1024,因为Enum的默认缺省值为枚举列表中的第一个值
        self.fftsize = 1024

    # FFT频谱图的x轴上限值的改变事件处理函数,将最新的值赋值给频谱图的响应属性
    def _fft_graph_up_limit_changed(self):
        self.plot_fft.x_axis.mapper.range.high = self.fft_graph_up_limit

    def _N_changed(self):
        self.plot_sin_combine()

    # 多个trait属性的改变事件处理函数相同时,可以用@on_trait_change指定
    @on_trait_change("wave_width, length_c, height_c, fftsize")
    def update_plot(self):
        # 计算三角波
        global y_data
        x_data = np.arange(0, 1.0, 1.0 / self.fftsize)
        func = self.triangle_func()
        # 将func函数的返回值强制转换成float64
        y_data = np.cast["float64"](func(x_data))

        # 计算频谱
        fft_parameters = np.fft.fft(y_data) / len(y_data)

        # 计算各个频率的振幅
        fft_data = np.clip(20 * np.log10(np.abs(fft_parameters))[: self.fftsize / 2 + 1], -120, 120)

        # 将计算的结果写进数据集
        self.plot_data.set_data("x", np.arange(0, self.fftsize))  # x坐标为取样点
        self.plot_data.set_data("y", y_data)
        self.plot_data.set_data("f", np.arange(0, len(fft_data)))  # x坐标为频率编号
        self.plot_data.set_data("p", fft_data)

        # 合成波的x坐标为取样点,显示2个周期
        self.plot_data.set_data("x2", np.arange(0, 2 * self.fftsize))

        # 更新频谱图x轴上限
        self._fft_graph_up_limit_changed()

        # 将振幅大于-80dB的频率输出
        peak_index = fft_data > -80
        peak_value = fft_data[peak_index][:20]
        result = []
        for f, v in zip(np.flatnonzero(peak_index), peak_value):
            result.append("%s : %s" % (f, v))
        self.peak_list = "\n".join(result)

        # 保存现在的fft计算结果,并计算正弦合成波
        self.fft_parameters = fft_parameters
        self.plot_sin_combine()

    # 计算正弦合成波,计算2个周期
    def plot_sin_combine(self):
        index, data = fft_combine(self.fft_parameters, self.N, 2)
        self.plot_data.set_data("y2", data)

    # 返回一个ufunc计算指定参数的三角波
    def triangle_func(self):
        c = self.wave_width
        c0 = self.length_c
        hc = self.height_c

        def trifunc(x):
            x = x - int(x)  # 三角波的周期为1,因此只取x坐标的小数部分进行计算
            if x >= c:
                r = 0.0
            elif x < c0:
                r = x / c0 * hc
            else:
                r = (c - x) / (c - c0) * hc
            return r

        # 用trifunc函数创建一个ufunc函数,可以直接对数组进行计算, 不过通过此函数
        # 计算得到的是一个Object数组,需要进行类型转换
        return np.frompyfunc(trifunc, 1, 1)
class EqualizerDesigner(HasTraits):
    '''均衡器设计器的主界面'''
    
    equalizers = Instance(Equalizers)
    
    # 保存绘图数据的对象
    plot_data = Instance(AbstractPlotData)    

    # 绘制波形图的容器
    container = Instance(Component)    
    
    plot_gain = Instance(Component)
    plot_phase = Instance(Component)   
    save_button = Button("Save")
    load_button = Button("Load")
    export_button = Button("Export")
       
    view = View(
        VGroup(
            HGroup(
                Item("load_button"),            
                Item("save_button"),
                Item("export_button"),
                show_labels = False
            ),
            HSplit(
                VGroup(
                    Item("equalizers", style="custom", show_label=False),
                    show_border=True,
                ),
                Item("container", editor=ComponentEditor(size=(800, 300)), show_label=False),
            )
        ),
        resizable = True,
        width = 800,
        height = 500,
        title = u"Equalizer Designer"
    )
    
    def _create_plot(self, data, name, type="line"):
        p = Plot(self.plot_data)
        p.plot(data, name=name, title=name, type=type)
        p.tools.append(PanTool(p))
        zoom = ZoomTool(component=p, tool_mode="box", always_on=False)
        p.overlays.append(zoom)        
        p.title = name
        p.index_scale = "log"
        return p    
    
    def __init__(self):
        super(EqualizerDesigner, self).__init__()
        self.plot_data = ArrayPlotData(f=FREQS, gain=[], phase=[])
        self.plot_gain = self._create_plot(("f", "gain"), "Gain(dB)")
        self.plot_phase = self._create_plot(("f", "phase"), "Phase(degree)")
        self.container = VPlotContainer()
        self.container.add( self.plot_phase )                
        self.container.add( self.plot_gain )
        self.plot_gain.padding_bottom = 20
        self.plot_phase.padding_top = 20
    
    def _equalizers_default(self):
        return Equalizers()
        
    @on_trait_change("equalizers.h")
    def redraw(self):
        gain = 20*np.log10(np.abs(self.equalizers.h)) 
        phase = np.angle(self.equalizers.h, deg=1)
        self.plot_data.set_data("gain", gain)
        self.plot_data.set_data("phase", phase)
        
    def _save_button_fired(self):
        dialog = FileDialog(action="save as", wildcard='EQ files (*.eq)|*.eq')
        result = dialog.open()
        if result == OK:
            f = file(dialog.path, "wb")
            pickle.dump( self.equalizers , f)
            f.close()
        
    def _load_button_fired(self):
        dialog = FileDialog(action="open", wildcard='EQ files (*.eq)|*.eq')
        result = dialog.open()
        if result == OK:
            f = file(dialog.path, "rb")
            self.equalizers = pickle.load(f)
            f.close()
            
    def _export_button_fired(self):
        dialog = FileDialog(action="save as", wildcard='c files (*.c)|*.c')
        result = dialog.open()
        if result == OK:
            self.equalizers.export(dialog.path)
Ejemplo n.º 36
0
    def init(self,data):
        self.raw = data
        self.data_selected = data
        index = range(self.raw.length)
        self.x1 = 0
        self.x2 = self.raw.length

        self.epsilon = self.data_selected.epsilon
        self.word_size = self.data_selected.word_size
        self.alphabet_size = self.data_selected.alphabet_size

        self.id1 = self.data_selected.id1
        self.id2 = self.data_selected.id2
        self.id3 = self.data_selected.id3

        self.window_min = self.data_selected.window_min
        self.window_max = self.data_selected.window_max
        self.window_step = self.data_selected.window_step

        self.dist_max = self.data_selected.dist_max

        overviewkwargs = {}
        for (dim,i) in zip(self.raw.data_transposed, range(len(self.plot_names))):
            overviewkwargs[self.plot_names[i]] = dim

        overviewdata = ArrayPlotData(index=index, **overviewkwargs)
        overview = Plot(overviewdata)

        axiscontainer = VPlotContainer()
        axiscontainer.spacing = 0
        aps = []
        paastep = self.selected_length / (len(self.data_selected.data_paaed[0]))
        paaindex = range(paastep/2,self.selected_length, paastep)

        for (dim,i) in zip(self.raw.data_transposed, range(len(self.plot_names))):
            overview.plot(("index",self.plot_names[i]),
                          type="line",
                          color=self.plot_colors[i])

            ap = Plot(ArrayPlotData(index = index,
                                    paaindex = paaindex,
                                    paa = self.data_selected.data_paaed[i],
                                    **{self.plot_names[i]:self.data_selected.data_transposed[i]}))

            ap.plot(("index",self.plot_names[i]), type="line", color=self.plot_colors[i])
            ap.plot(("paaindex","paa"), type="scatter", color=self.plot_colors[i])
            #ap.title = a["name"]
            ap.padding_top = 1
            ap.padding_bottom = 0
            ap.y_axis.orientation = "right"
            axiscontainer.add(ap)
            aps.append(ap)
            ap.components[1].visible = False

        self.aps = aps

        rs = RangeSelection(overview.components[0], left_button_selects= True)
        self.selector = rs
        overview.components[0].tools.append(rs)
        overview.components[0].overlays.append(RangeSelectionOverlay(component=overview.components[0]))

        lrcontainer = HPlotContainer(overview,axiscontainer)

        lrcontainer.spacing = 0
        self.plot = lrcontainer
Ejemplo n.º 37
0
class plotBox(HasTraits):
    pointsClicked = Int
    index = Array
    normal = Array
    shear = Array
    pointX = Array(dtype=int, value=([0.0, 100.0, 200.0]), comparison_mode=0)
    pointY = Array(dtype=float, value=([0.0, 0.0, 0.0]), comparison_mode=0)
    message = Str
    isAccepted = Bool
    accept = Action(name="Accept", action="accept")
    reject = Action(name="Reject", action="reject")
    cursorPosX = Int
    cursorPosY = Float
    vPlot = Instance(VPlotContainer)

    def __init__(self, fileName, fOut):
        super(plotBox, self).__init__()

        self.isAccepted = True
        self.fOut = fOut
        self.message = "Analysis Acceptable?"
        self.vPlot = VPlotContainer(padding=10)
        self.vPlot.stack_order = "top_to_bottom"
        topPlot = OverlayPlotContainer(padding=10)
        self.vPlot.add(topPlot)
        bottomPlot = OverlayPlotContainer(padding=10)
        self.vPlot.add(bottomPlot)

        # def parseFileName():
        self.fileName = fileName
        # get complete path of data file
        fullFileName = os.path.abspath(fileName)
        self.fileName = os.path.split(fullFileName)[1]
        self.shortFileName = os.path.splitext(self.fileName)[1]
        self.plotTitle = self.shortFileName

        # def readData():
        fileIn = open(fileName, "r")
        hD = rx.readDataFileHeader(fileIn)
        dD = rx.readDataFileArray(fileIn)

        self.normal = numpy.array(map(float, dD["voltageForceNormal"]))
        self.shear = numpy.array(map(float, dD["voltageForceLateral"]))
        self.index = numpy.arange(len(self.normal))

        # index dictionary
        iD = rx.parseForceTrace(hD, dD)
        self.pointX[0] = iD["indexContact"]
        self.pointY[0] = self.normal[iD["indexContact"]]
        self.pointX[1] = iD["indexMaxPreload"]
        self.pointY[1] = self.normal[iD["indexMaxPreload"]]
        self.pointX[2] = iD["indexMaxAdhesion"]
        self.pointY[2] = self.normal[iD["indexMaxAdhesion"]]

        # def constructPlots():
        self.plotdata = ArrayPlotData(
            index=self.index, normal=self.normal, shear=self.shear, pointX=self.pointX, pointY=self.pointY
        )
        self.normalPlot = Plot(self.plotdata)
        self.normalPlot.plot(("index", "normal"), type="line", color="blue")
        self.normalPlot.plot(
            ("pointX", "pointY"),
            type="scatter",
            marker="diamond",
            marker_size=5,
            color=(0.0, 0.0, 1.0, 0.5),
            outline_color="none",
        )
        # set range of plot
        self.normalPlot.value_range.set_bounds(-1.5, 1.5)
        self.shearPlot = Plot(self.plotdata)
        self.shearPlot.plot(("index", "shear"), type="line", color="green")

        self.normalPlot.overlays.append(
            customTool(
                plotBox=self,
                component=self.normalPlot,
                axis="index_x",
                inspect_mode="indexed",
                write_metadata=True,
                color="black",
                is_listener=False,
            )
        )

        self.normalPlot.tools.append(rx.SimpleZoom(self.normalPlot))
        self.normalPlot.tools.append(PanTool(self.normalPlot, drag_button="right"))

        self.normalPlot.title = "Normal Force Trace"
        self.shearPlot.title = "Shear Force Trace"
        topPlot.add(self.shearPlot)
        bottomPlot.add(self.normalPlot)

        self.shearPlot.index_range = self.normalPlot.index_range

    traits_view = View(
        Item("vPlot", editor=ComponentEditor(), resizable=True, show_label=False),
        HGroup(
            Item("message", width=200),
            Item("cursorPosX", width=200),
            Item("cursorPosY", width=200),
            Item("pointX", style="readonly", width=200),
            Item("pointY", style="readonly", width=200),
        ),
        buttons=[accept, reject, OKButton],
        title="Roxanne Parse Application",
        handler=plotBoxHandler(),
        resizable=True,
        width=1400,
        height=800,
        x=20,
        y=40,
    )
Ejemplo n.º 38
0
class TriangleWave(HasTraits):
    # 指定三角波的最窄和最宽范围,由于Range类型不能将常数和Traits属性名混用
    # 所以定义这两个值不变的Trait属性
    low = Float(0.02)
    hi = Float(1.0)

    # 三角波形的宽度
    wave_width = Range("low", "hi", 0.5)

    # 三角波的顶点C的x轴坐标
    length_c = Range("low", "wave_width", 0.5)

    # 三角波的定点的y轴坐标
    height_c = Float(1.0)

    # FFT计算所使用的取样点数,这里用一个Enum类型的属性以供用户从列表中选择
    fftsize = Enum([(2**x) for x in range(6, 12)])

    # FFT频谱图的x轴上限值
    fft_graph_up_limit = Range(0, 400, 20)

    # 用于显示FFT的结果
    peak_list = Str

    # 采用多少个频率合成三角波
    N = Range(1, 40, 4)

    # 保存绘图数据的对象
    plot_data = Instance(AbstractPlotData)

    # 绘制波形图的容器
    plot_wave = Instance(Component)

    # 绘制FFT频谱图的容器
    plot_fft = Instance(Component)

    # 包括两个绘图的容器
    container = Instance(Component)

    # 设置用户界面的视图, 注意一定要指定窗口的大小,这样绘图容器才能正常初始化
    view = View(HSplit(
        VSplit(
            VGroup(Item("wave_width", editor=scrubber, label="波形宽度"),
                   Item("length_c", editor=scrubber, label="最高点x坐标"),
                   Item("height_c", editor=scrubber, label="最高点y坐标"),
                   Item("fft_graph_up_limit", editor=scrubber, label="频谱图范围"),
                   Item("fftsize", label="FFT点数"), Item("N", label="合成波频率数")),
            Item("peak_list",
                 style="custom",
                 show_label=False,
                 width=100,
                 height=250)),
        VGroup(Item("container",
                    editor=ComponentEditor(size=(600, 300)),
                    show_label=False),
               orientation="vertical")),
                resizable=True,
                width=800,
                height=600,
                title="三角波FFT演示")

    # 创建绘图的辅助函数,创建波形图和频谱图有很多类似的地方,因此单独用一个函数以
    # 减少重复代码
    def _create_plot(self, data, name, type="line"):
        p = Plot(self.plot_data)
        p.plot(data, name=name, title=name, type=type)
        p.tools.append(PanTool(p))
        zoom = ZoomTool(component=p, tool_mode="box", always_on=False)
        p.overlays.append(zoom)
        p.title = name
        return p

    def __init__(self):
        # 首先需要调用父类的初始化函数
        super(TriangleWave, self).__init__()

        # 创建绘图数据集,暂时没有数据因此都赋值为空,只是创建几个名字,以供Plot引用
        self.plot_data = ArrayPlotData(x=[], y=[], f=[], p=[], x2=[], y2=[])

        # 创建一个垂直排列的绘图容器,它将频谱图和波形图上下排列
        self.container = VPlotContainer()

        # 创建波形图,波形图绘制两条曲线: 原始波形(x,y)和合成波形(x2,y2)
        self.plot_wave = self._create_plot(("x", "y"), "Triangle Wave")
        self.plot_wave.plot(("x2", "y2"), color="red")

        # 创建频谱图,使用数据集中的f和p
        self.plot_fft = self._create_plot(("f", "p"), "FFT", type="scatter")

        # 将两个绘图容器添加到垂直容器中
        self.container.add(self.plot_wave)
        self.container.add(self.plot_fft)

        # 设置
        self.plot_wave.x_axis.title = "Samples"
        self.plot_fft.x_axis.title = "Frequency pins"
        self.plot_fft.y_axis.title = "(dB)"

        # 改变fftsize为1024,因为Enum的默认缺省值为枚举列表中的第一个值
        self.fftsize = 1024

    # FFT频谱图的x轴上限值的改变事件处理函数,将最新的值赋值给频谱图的响应属性
    def _fft_graph_up_limit_changed(self):
        self.plot_fft.x_axis.mapper.range.high = self.fft_graph_up_limit

    def _N_changed(self):
        self.plot_sin_combine()

    # 多个trait属性的改变事件处理函数相同时,可以用@on_trait_change指定
    @on_trait_change("wave_width, length_c, height_c, fftsize")
    def update_plot(self):
        # 计算三角波
        global y_data
        x_data = np.arange(0, 1.0, 1.0 / self.fftsize)
        func = self.triangle_func()
        # 将func函数的返回值强制转换成float64
        y_data = np.cast["float64"](func(x_data))

        # 计算频谱
        fft_parameters = np.fft.fft(y_data) / len(y_data)

        # 计算各个频率的振幅
        fft_data = np.clip(
            20 * np.log10(np.abs(fft_parameters))[:self.fftsize / 2 + 1], -120,
            120)

        # 将计算的结果写进数据集
        self.plot_data.set_data("x", np.arange(0, self.fftsize))  # x坐标为取样点
        self.plot_data.set_data("y", y_data)
        self.plot_data.set_data("f", np.arange(0, len(fft_data)))  # x坐标为频率编号
        self.plot_data.set_data("p", fft_data)

        # 合成波的x坐标为取样点,显示2个周期
        self.plot_data.set_data("x2", np.arange(0, 2 * self.fftsize))

        # 更新频谱图x轴上限
        self._fft_graph_up_limit_changed()

        # 将振幅大于-80dB的频率输出
        peak_index = (fft_data > -80)
        peak_value = fft_data[peak_index][:20]
        result = []
        for f, v in zip(np.flatnonzero(peak_index), peak_value):
            result.append("%s : %s" % (f, v))
        self.peak_list = "\n".join(result)

        # 保存现在的fft计算结果,并计算正弦合成波
        self.fft_parameters = fft_parameters
        self.plot_sin_combine()

    # 计算正弦合成波,计算2个周期
    def plot_sin_combine(self):
        index, data = fft_combine(self.fft_parameters, self.N, 2)
        self.plot_data.set_data("y2", data)

    # 返回一个ufunc计算指定参数的三角波
    def triangle_func(self):
        c = self.wave_width
        c0 = self.length_c
        hc = self.height_c

        def trifunc(x):
            x = x - int(x)  # 三角波的周期为1,因此只取x坐标的小数部分进行计算
            if x >= c: r = 0.0
            elif x < c0: r = x / c0 * hc
            else: r = (c - x) / (c - c0) * hc
            return r

        # 用trifunc函数创建一个ufunc函数,可以直接对数组进行计算, 不过通过此函数
        # 计算得到的是一个Object数组,需要进行类型转换
        return np.frompyfunc(trifunc, 1, 1)
    def create_plot(self):

        # Create the mapper, etc
        self._image_index = GridDataSource(array([]),
                                          array([]),
                                          sort_order=("ascending","ascending"))
        image_index_range = DataRange2D(self._image_index)
        self._image_index.on_trait_change(self._metadata_changed,
                                          "metadata_changed")

        self._image_value = ImageData(data=array([]), value_depth=1)
        image_value_range = DataRange1D(self._image_value)



        # Create the contour plots
        self.polyplot = ContourPolyPlot(index=self._image_index,
                                        value=self._image_value,
                                        index_mapper=GridMapper(range=
                                            image_index_range),
                                        color_mapper=\
                                            self._cmap(image_value_range),
                                        levels=self.num_levels)

        self.lineplot = ContourLinePlot(index=self._image_index,
                                        value=self._image_value,
                                        index_mapper=GridMapper(range=
                                            self.polyplot.index_mapper.range),
                                        levels=self.num_levels)


        # Add a left axis to the plot
        left = PlotAxis(orientation='left',
                        title= "y",
                        mapper=self.polyplot.index_mapper._ymapper,
                        component=self.polyplot)
        self.polyplot.overlays.append(left)

        # Add a bottom axis to the plot
        bottom = PlotAxis(orientation='bottom',
                          title= "x",
                          mapper=self.polyplot.index_mapper._xmapper,
                          component=self.polyplot)
        self.polyplot.overlays.append(bottom)


        # Add some tools to the plot
        self.polyplot.tools.append(PanTool(self.polyplot,
                                           constrain_key="shift"))
        self.polyplot.overlays.append(ZoomTool(component=self.polyplot,
                                            tool_mode="box", always_on=False))
        self.polyplot.overlays.append(LineInspector(component=self.polyplot,
                                               axis='index_x',
                                               inspect_mode="indexed",
                                               write_metadata=True,
                                               is_listener=False,
                                               color="white"))
        self.polyplot.overlays.append(LineInspector(component=self.polyplot,
                                               axis='index_y',
                                               inspect_mode="indexed",
                                               write_metadata=True,
                                               color="white",
                                               is_listener=False))

        # Add these two plots to one container
        contour_container = OverlayPlotContainer(padding=20,
                                                 use_backbuffer=True,
                                                 unified_draw=True)
        contour_container.add(self.polyplot)
        contour_container.add(self.lineplot)


        # Create a colorbar
        cbar_index_mapper = LinearMapper(range=image_value_range)
        self.colorbar = ColorBar(index_mapper=cbar_index_mapper,
                                 plot=self.polyplot,
                                 padding_top=self.polyplot.padding_top,
                                 padding_bottom=self.polyplot.padding_bottom,
                                 padding_right=40,
                                 resizable='v',
                                 width=30)

        self.pd = ArrayPlotData(line_index = array([]),
                                line_value = array([]),
                                scatter_index = array([]),
                                scatter_value = array([]),
                                scatter_color = array([]))

        self.cross_plot = Plot(self.pd, resizable="h")
        self.cross_plot.height = 100
        self.cross_plot.padding = 20
        self.cross_plot.plot(("line_index", "line_value"),
                             line_style="dot")
        self.cross_plot.plot(("scatter_index","scatter_value","scatter_color"),
                             type="cmap_scatter",
                             name="dot",
                             color_mapper=self._cmap(image_value_range),
                             marker="circle",
                             marker_size=8)

        self.cross_plot.index_range = self.polyplot.index_range.x_range

        self.pd.set_data("line_index2", array([]))
        self.pd.set_data("line_value2", array([]))
        self.pd.set_data("scatter_index2", array([]))
        self.pd.set_data("scatter_value2", array([]))
        self.pd.set_data("scatter_color2", array([]))

        self.cross_plot2 = Plot(self.pd, width = 140, orientation="v", resizable="v", padding=20, padding_bottom=160)
        self.cross_plot2.plot(("line_index2", "line_value2"),
                             line_style="dot")
        self.cross_plot2.plot(("scatter_index2","scatter_value2","scatter_color2"),
                             type="cmap_scatter",
                             name="dot",
                             color_mapper=self._cmap(image_value_range),
                             marker="circle",
                             marker_size=8)

        self.cross_plot2.index_range = self.polyplot.index_range.y_range



        # Create a container and add components
        self.container = HPlotContainer(padding=40, fill_padding=True,
                                        bgcolor = "white", use_backbuffer=False)
        inner_cont = VPlotContainer(padding=0, use_backbuffer=True)
        inner_cont.add(self.cross_plot)
        inner_cont.add(contour_container)
        self.container.add(self.colorbar)
        self.container.add(inner_cont)
        self.container.add(self.cross_plot2)
Ejemplo n.º 40
0
class EqualizerDesigner(HasTraits):
    '''均衡器设计器的主界面'''

    equalizers = Instance(Equalizers)

    # 保存绘图数据的对象
    plot_data = Instance(AbstractPlotData)

    # 绘制波形图的容器
    container = Instance(Component)

    plot_gain = Instance(Component)
    plot_phase = Instance(Component)
    save_button = Button("Save")
    load_button = Button("Load")
    export_button = Button("Export")

    view = View(VGroup(
        HGroup(Item("load_button"),
               Item("save_button"),
               Item("export_button"),
               show_labels=False),
        HSplit(
            VGroup(
                Item("equalizers", style="custom", show_label=False),
                show_border=True,
            ),
            Item("container",
                 editor=ComponentEditor(size=(800, 300)),
                 show_label=False),
        )),
                resizable=True,
                width=800,
                height=500,
                title="Equalizer Designer")

    def _create_plot(self, data, name, type="line"):
        p = Plot(self.plot_data)
        p.plot(data, name=name, title=name, type=type)
        p.tools.append(PanTool(p))
        zoom = ZoomTool(component=p, tool_mode="box", always_on=False)
        p.overlays.append(zoom)
        p.title = name
        p.index_scale = "log"
        return p

    def __init__(self):
        super(EqualizerDesigner, self).__init__()
        self.plot_data = ArrayPlotData(f=FREQS, gain=[], phase=[])
        self.plot_gain = self._create_plot(("f", "gain"), "Gain(dB)")
        self.plot_phase = self._create_plot(("f", "phase"), "Phase(degree)")
        self.container = VPlotContainer()
        self.container.add(self.plot_phase)
        self.container.add(self.plot_gain)
        self.plot_gain.padding_bottom = 20
        self.plot_phase.padding_top = 20

    def _equalizers_default(self):
        return Equalizers()

    @on_trait_change("equalizers.h")
    def redraw(self):
        gain = 20 * np.log10(np.abs(self.equalizers.h))
        phase = np.angle(self.equalizers.h, deg=1)
        self.plot_data.set_data("gain", gain)
        self.plot_data.set_data("phase", phase)

    def _save_button_fired(self):
        dialog = FileDialog(action="save as", wildcard='EQ files (*.eq)|*.eq')
        result = dialog.open()
        if result == OK:
            f = file(dialog.path, "wb")
            pickle.dump(self.equalizers, f)
            f.close()

    def _load_button_fired(self):
        dialog = FileDialog(action="open", wildcard='EQ files (*.eq)|*.eq')
        result = dialog.open()
        if result == OK:
            f = file(dialog.path, "rb")
            self.equalizers = pickle.load(f)
            f.close()

    def _export_button_fired(self):
        dialog = FileDialog(action="save as", wildcard='c files (*.c)|*.c')
        result = dialog.open()
        if result == OK:
            self.equalizers.export(dialog.path)
Ejemplo n.º 41
0
    def __init__(self, fileName, fOut):
        super(plotBox, self).__init__()

        self.isAccepted = True
        self.fOut = fOut
        self.message = "Analysis Acceptable?"
        self.vPlot = VPlotContainer(padding=10)
        self.vPlot.stack_order = "top_to_bottom"
        topPlot = OverlayPlotContainer(padding=10)
        self.vPlot.add(topPlot)
        bottomPlot = OverlayPlotContainer(padding=10)
        self.vPlot.add(bottomPlot)

        # def parseFileName():
        self.fileName = fileName
        # get complete path of data file
        fullFileName = os.path.abspath(fileName)
        self.fileName = os.path.split(fullFileName)[1]
        self.shortFileName = os.path.splitext(self.fileName)[1]
        self.plotTitle = self.shortFileName

        # def readData():
        fileIn = open(fileName, "r")
        hD = rx.readDataFileHeader(fileIn)
        dD = rx.readDataFileArray(fileIn)

        self.normal = numpy.array(map(float, dD["voltageForceNormal"]))
        self.shear = numpy.array(map(float, dD["voltageForceLateral"]))
        self.index = numpy.arange(len(self.normal))

        # index dictionary
        iD = rx.parseForceTrace(hD, dD)
        self.pointX[0] = iD["indexContact"]
        self.pointY[0] = self.normal[iD["indexContact"]]
        self.pointX[1] = iD["indexMaxPreload"]
        self.pointY[1] = self.normal[iD["indexMaxPreload"]]
        self.pointX[2] = iD["indexMaxAdhesion"]
        self.pointY[2] = self.normal[iD["indexMaxAdhesion"]]

        # def constructPlots():
        self.plotdata = ArrayPlotData(
            index=self.index, normal=self.normal, shear=self.shear, pointX=self.pointX, pointY=self.pointY
        )
        self.normalPlot = Plot(self.plotdata)
        self.normalPlot.plot(("index", "normal"), type="line", color="blue")
        self.normalPlot.plot(
            ("pointX", "pointY"),
            type="scatter",
            marker="diamond",
            marker_size=5,
            color=(0.0, 0.0, 1.0, 0.5),
            outline_color="none",
        )
        # set range of plot
        self.normalPlot.value_range.set_bounds(-1.5, 1.5)
        self.shearPlot = Plot(self.plotdata)
        self.shearPlot.plot(("index", "shear"), type="line", color="green")

        self.normalPlot.overlays.append(
            customTool(
                plotBox=self,
                component=self.normalPlot,
                axis="index_x",
                inspect_mode="indexed",
                write_metadata=True,
                color="black",
                is_listener=False,
            )
        )

        self.normalPlot.tools.append(rx.SimpleZoom(self.normalPlot))
        self.normalPlot.tools.append(PanTool(self.normalPlot, drag_button="right"))

        self.normalPlot.title = "Normal Force Trace"
        self.shearPlot.title = "Shear Force Trace"
        topPlot.add(self.shearPlot)
        bottomPlot.add(self.normalPlot)

        self.shearPlot.index_range = self.normalPlot.index_range
Ejemplo n.º 42
0
class Plots(HasTraits):
    '''
    
    Main work horse. Model of the data.
    '''

    container = Instance(VPlotContainer)

    container_view = View(Item('container',
                               editor=ComponentEditor(),
                               show_label=False,
                               width=1000,
                               height=400),
                          width=1000,
                          height=400,
                          resizable=True)

    #*************************************__init__()*************************************
    def __init__(self, model, ui, extension, parent):
        '''
        Constructor
        '''
        self.model = model
        self.ui = ui
        self.extension = extension
        self.parent = parent

        self.plots = {}
        self.renderers = {}

        self.hidden = False
        self.time_src = ArrayDataSource([])
        self.container = VPlotContainer(bgcolor="white",
                                        fill_padding=True,
                                        border_visible=False,
                                        stack_order='top_to_bottom')
        self.setup_plots()
        self.pc = self.edit_traits(view='container_view',
                                   parent=parent,
                                   kind='subpanel').control
        parent.layout.addWidget(self.pc)
        self.pc.setParent(parent)

    #*************************************update_plots()*************************************
    def update_plots(self, pc):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        ann = pc.data_dict["annotations"]
        t0 = ann.get_value("START")
        t1 = ann.get_value("STOP")
        tug = ann.get_value("TURN_AROUND")
        delta = t1 - t0
        total = delta.seconds + delta.microseconds * 10**(-6)
        self.time_src.set_data([0, total])

        t2 = tug - t0
        t2 = t2.seconds + t2.microseconds * 10**(-6)

        self.x_axis.labels = ["START", "TURN_AROUND", "5s", "STOP"]
        self.x_axis.positions = [0, t2, 5, total]

        for name, plot in self.plots.items():
            plot_conactory = plot.plot_conactory

            res = pc.results[name[:-3]]  # to remove the extension
            print res
            data_src = plot_conactory.datasources.get("index")
            data_src.set_data(res[0])

            data_src = plot_conactory.datasources.get(name)
            data_src.set_data(res[1])

    #*************************************create_plot()*************************************
    def create_plot(self, name, ylabel="", color="blue"):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        p = PlotContainer(name, self, self.time_src)
        p.plot_conactory.y_axis.title = ylabel
        self.plots[name] = p

        p.plot_data.set_data(name, [])
        renderer, = p.plot_conactory.plot(("index", name),
                                          name=name,
                                          color=color,
                                          line_width=1.5)
        self.renderers[name] = renderer

        self.container.add(p.plot_conactory)

    #*************************************setup_plots()*************************************
    def setup_plots(self):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        ext = self.extension

        if ext == "S2":
            color = "green"
        else:
            color = "blue"

        self.create_plot("AAE " + ext, ylabel="[ ]", color=color)
        self.create_plot("ARE " + ext, ylabel="[ ]", color=color)
        self.create_plot("Jerk " + ext, ylabel="[m/s2/s]", color=color)
        self.create_plot("SI " + ext, ylabel="[ ]", color=color)
        self.create_plot("VI " + ext, ylabel="[ ]", color=color)

        p = self.plots["VI " + ext]

        null_ds = ArrayDataSource([])
        self.time_plot = LinePlot(
            index=self.time_src,
            value=null_ds,
            index_mapper=LinearMapper(range=DataRange1D(self.time_src)),
            value_mapper=LinearMapper(range=DataRange1D(null_ds)),
            color="black",
            border_visible=True,
            bgcolor="white",
            height=10,
            resizable="h",
            padding_top=50,
            padding_bottom=40,
            padding_left=50,
            padding_right=20)
        self.ticker = ScalesTickGenerator()
        self.x_axis = LabelAxis(self.time_plot,
                                orientation="bottom",
                                title="Time [sec]",
                                label_rotation=0)
        #self.x_axis = PlotAxis(self.time_plot, orientation="bottom", tick_generator = self.ticker, title="Time [sec]")
        self.time_plot.underlays.append(self.x_axis)
        self.container.add(self.time_plot)

        # Add a range overlay to the miniplot that is hooked up to the range
        # of the main price_plot
        range_tool = RangeSelection(self.time_plot)
        self.time_plot.tools.append(range_tool)
        range_overlay = RangeSelectionOverlay(self.time_plot,
                                              metadata_name="selections")
        self.time_plot.overlays.append(range_overlay)
        range_tool.on_trait_change(self._range_selection_handler, "selection")
        self.range_tool = range_tool

        p.plot_conactory.index_range.on_trait_change(self._plot_range_handler,
                                                     "updated")
        self.zoom_overlay = ZoomOverlay(source=self.time_plot,
                                        destination=p.plot_conactory)
        self.container.overlays.append(self.zoom_overlay)

    #*************************************set_inde_range()*************************************
    def set_index_range(self, low, high):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        iterator = iter(self.renderers.values())
        while True:
            try:
                curr = iterator.next()
                curr.index_range.low = low
                curr.index_range.high = high
            except StopIteration:
                break

    #*************************************set_bounds()*************************************
    def set_bounds(self, low, high):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        iterator = iter(self.renderers.values())
        while True:
            try:
                curr = iterator.next()
                curr.index_range.set_bounds(low, high)
            except StopIteration:
                break

    #*************************************_range_selection_handler()*************************************
    def _range_selection_handler(self, event):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        # The event obj should be a tuple (low, high) in data space
        if event is not None:
            low, high = event
            self.set_index_range(low, high)
        else:
            self.set_bounds("auto", "auto")

    #*************************************_plot_range_handler()*************************************
    def _plot_range_handler(self, event):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        if event is not None:
            low, high = event
            if "auto" not in (low, high):
                pass
                '''if low < self.df["Time"][0]:
                    low = self.df["Time"][0]
                if high > self.df["Time"][self.counter-1]:
                    high = self.df["Time"][self.counter-1]
                self.range_tool.selection = (low, high)'''

    #*************************************change_view()*************************************
    def change_view(self, plots_to_show):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        temp = list(self.container.components)  # to get a copy
        for plot in temp:
            #if type(plot).__name__ == 'Plot':
            self.container.remove(plot)

        plots_to_show.sort()
        for plot in plots_to_show:
            self.container.add(self.plots[plot + " " +
                                          self.extension].plot_conactory)
        self.container.add(
            self.time_plot
        )  # add the time_plot back last so it is on the bottom
        self.container.request_redraw()

    #*************************************hide()*************************************
    def hide(self):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        self.hidden = True
        self.pc.hide()

    #*************************************unhide()*************************************
    def unhide(self):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        self.hidden = False
        self.pc.show()