コード例 #1
0
ファイル: status_overlay.py プロジェクト: brycehendrix/chaco
class MyPlot(HasTraits):
    """ Displays a plot with a few buttons to control which overlay
        to display
    """
    plot = Instance(Plot)
    status_overlay = Instance(StatusLayer)

    error_button = Button('Error')
    warn_button = Button('Warning')
    no_problem_button = Button('No problem')

    traits_view = View( HGroup(Item('error_button', show_label=False),
                               Item('warn_button', show_label=False),
                               Item('no_problem_button', show_label=False)),
                        Item('plot', editor=ComponentEditor(), show_label=False),
                        resizable=True)

    def __init__(self, index, data_series, **kw):
        super(MyPlot, self).__init__(**kw)

        plot_data = ArrayPlotData(index=index)
        plot_data.set_data('data_series', data_series)
        self.plot = Plot(plot_data)
        self.plot.plot(('index', 'data_series'))

    def _error_button_fired(self, event):
        """ removes the old overlay and replaces it with
            an error overlay
        """
        self.clear_status()

        self.status_overlay = ErrorLayer(component=self.plot,
                                            align='ul', scale_factor=0.25)
        self.plot.overlays.append(self.status_overlay)

        self.plot.request_redraw()

    def _warn_button_fired(self, event):
        """ removes the old overlay and replaces it with
            an warning overlay
        """
        self.clear_status()

        self.status_overlay = WarningLayer(component=self.plot,
                                            align='ur', scale_factor=0.25)
        self.plot.overlays.append(self.status_overlay)

        self.plot.request_redraw()

    def _no_problem_button_fired(self, event):
        """ removes the old overlay
        """
        self.clear_status()
        self.plot.request_redraw()

    def clear_status(self):
        if self.status_overlay in self.plot.overlays:
            # fade_out will remove the overlay when its done
            self.status_overlay.fade_out()
コード例 #2
0
ファイル: fiberkontrol.py プロジェクト: logang/Fiberkontrol
class FiberView( HasTraits ):

    timer         = Instance( Timer )
#    model         =  FiberModel(options)

    plot_data     = Instance( ArrayPlotData )
    plot          = Instance( Plot )
    start_stop    = Button()
    exit          = Button()

    # Default TraitsUI view
    traits_view = View(
        Item('plot', editor=ComponentEditor(), show_label=False),
        # Items
        HGroup( spring,
                Item( "start_stop", show_label = False ),
                Item( "exit", show_label = False ), spring),
        HGroup( spring ),

        # GUI window
        resizable = True,
        width     = 1000, 
        height    = 700,
        kind      = 'live' )

    def __init__(self, options, **kwtraits):
        super( FiberView, self).__init__(**kwtraits )
        self.model = FiberModel(options)

        # debugging
        self.debug = options.debug
        self.model.debug = options.debug

        # timing parameters
        self.max_packets = options.max_packets
        self.hertz = options.hertz

        # extend options to model
        self.model.max_packets = options.max_packets
        self.model.preallocate_arrays()
        self.model.num_analog_channels = options.num_analog_channels

        # generate traits plot
        self.plot_data = ArrayPlotData( x = self.model._tdata, y = self.model._ydata )
        self.plot = Plot( self.plot_data )
        renderer  = self.plot.plot(("x", "y"), type="line", name='old', color="green")[0]
#        self.plot.delplot('old')

        # recording flags
        self.model.recording = False
        self.model.trialEnded = True


        print 'Viewer initialized.'

        # should we wait for a ttl input to start?
        if options.ttl_start:
            self.model.ttl_start = True
            self.ttl_received = False

            # initialize FIO0 for TTL input
            self.FIO0_DIR_REGISTER = 6100 
            self.FIO0_STATE_REGISTER = 6000 
            self.model.labjack.writeRegister(self.FIO0_DIR_REGISTER, 0) # Set FIO0 low

        # initialize output array
        self.out_arr = None

        # keep track of number of runs
        self.run_number = 0

        self.timer = Timer(self.model.dt, self.time_update) # update every 1 ms


    def run( self ):
        self._plot_update()
        self.model._get_current_data()

    def time_update( self ):
        """ Callback that gets called on a timer to get the next data point over the labjack """

#        print "time_update"
#        print "self.model.ttl_start", self.model.ttl_start
#        print "self.ttl_received", self.ttl_received
#        print "self.model.recording", self.model.recording

        if self.model.ttl_start and not self.ttl_received:
            ttl = self.check_for_ttl()
            if ttl:
                self.ttl_received = True
#                self.model.recording = True
#                self.model.trialEnded = False
                self._start_stop_fired()
               
        if self.model.recording and not self.model.ttl_start:
            self.run()

        elif self.model.ttl_start:
            if self.model.recording and self.ttl_received:
                self.run()
#            elif self.model.recording:
#                self._start_stop_fired()
        else:
            if self.debug:
                pass #print "--timer tic--"
            pass

    def check_for_ttl(self):
        start_ttl = self.model.labjack.readRegister(self.FIO0_STATE_REGISTER)
#        print "start_ttl: ", start_ttl
        return start_ttl

    def clean_time_series(self, time_series, blip_thresh = 10.0):
        """ Removes blips, NAs, etc. """
        blip_idxs = time_series > blip_thresh
        time_series[blip_idxs] = np.median(time_series)
        return time_series

    def _plot_update( self ):
        num_display_points = 100*25 # For 1000 Hz
    
        if self.model.master_index > num_display_points:
            disp_begin = self.model.master_index - num_display_points
            disp_end = self.model.master_index
            print 'disp_begin', disp_begin
            print 'disp_end', disp_end
            ydata = self.clean_time_series( np.array(self.model._ydata[disp_begin:disp_end]) )
            xdata = np.array(self.model._tdata[disp_begin:disp_end])

            self.plot_data.set_data("y", ydata)
            self.plot_data.set_data("x", xdata)
            
        else:        
            self.plot_data.set_data( "y", self.clean_time_series( self.model._ydata[0:self.model.master_index] )) 
            self.plot_data.set_data( "x", self.model._tdata[0:self.model.master_index] )

        self.plot = Plot( self.plot_data )

#        self.plot.delplot('old')
        the_plot = self.plot.plot(("x", "y"), type="line", name = 'old', color="green")[0]
        self.plot.request_redraw()

    # Note: These should be moved to a proper handler (ModelViewController)

    def _start_stop_fired( self ):
        self.model.start_time = time.time()
        self.model.recording = not self.model.recording
        self.model.trialEnded = not self.model.trialEnded
        if self.model.trialEnded:
            self.save()

    def _exit_fired(self):
        print "Closing connection to LabJack..."
        self.ttl_start = False
        self.recording = False
        self.model.sdr.running = False
        self.model.recording = False

#        self.model.labjack.streamStop()
        self.model.labjack.close()
        print "connection closed. Safe to close..."
        #raise SystemExit
        #sys.exit()

    def save( self ):
            print "Saving!"        
            # Finally, construct and save full data array
            print "Saving acquired data..."
            for i in xrange( len( self.model.data ) ):
                new_array = 1
                block = self.model.data[i]
                for k in self.model.result.keys():
                    print k
                    if k != 0:
                        if new_array == 1:
                            array = np.array(block[k])
                            array.shape = (len(array),1)
                            new_array = 0
                        else:
                            new_data = np.array(block[k])
                            new_data.shape = (len(block[k]),1)
                            # if new_data is short by one, fill in with last entry
                            if new_data.shape[0] < array.shape[0]:
                                new_data = np.append( new_data, new_data[-1] )
                                new_data.shape = (new_data.shape[0], 1)
                                print "Appended point to new_data, shape now:",new_data.shape
                            if new_data.shape[0] > array.shape[0]:
                                new_data = new_data[:-1]
                                print "Removed point from new_data, shape now:",new_data.shape
                            print "array shape, new_data shape:", array.shape, new_data.shape
                            array = np.hstack((array, new_data ))
                if i == 0:
                    self.out_arr = array
                    print "Array shape:", self.out_arr.shape
                else:
                    self.out_arr = np.vstack( (self.out_arr, array) )
                    print "Array shape:", self.out_arr.shape
            date = time.localtime()
            outfile = self.model.savepath + self.model.filename
            outfile += str(date[0]) + '_' + str(date[1]) + '_' + str(date[2]) + '_'
            outfile += str(date[3]) + ':' + str(date[4]) + '_run_number_' + str(self.run_number) 
            np.savez(outfile, data=self.out_arr, time_stamps=self.model._tdata)

#             time_outfile = outfile + '_t'
#             np.savez(time_outfile, self.model._tdata)
            print "Saved ", outfile

            # Plot the data collected this last run
            self.plot_last_data()

            # clean up
            self.reset_variables()

    def reset_variables(self):
        self.out_arr = None
        self.ttl_received = False
        self.run_number += 1
        self.model.recording = False
        self.trialEnded = True
        self.plot.delplot('old')

    def plot_last_data(self):
        import pylab as pl
        if self.out_arr.shape[1] == 4:
            pl.figure()
            pl.subplot(411)
            pl.plot(self.out_arr[:,0])
            pl.subplot(412)
            pl.plot(self.out_arr[:,1])
            pl.subplot(413)
            pl.plot(self.out_arr[:,2])
            pl.subplot(414)
            pl.plot(self.out_arr[:,3])
            pl.show()
コード例 #3
0
ファイル: canvas.py プロジェクト: brycehendrix/chaco
def clone_plot(clonetool, drop_position):
    # A little sketchy...
    canvas = clonetool.component.container.component.component

    # Create a new Plot object
    oldplot = clonetool.component
    newplot = Plot(oldplot.data)
    basic_traits = ["orientation", "default_origin", "bgcolor", "border_color",
                    "border_width", "border_visible", "draw_layer", "unified_draw",
                    "fit_components", "fill_padding", "visible", "aspect_ratio",
                    "title"]

    for attr in basic_traits:
        setattr(newplot, attr, getattr(oldplot, attr))

    # copy the ranges
    dst = newplot.range2d
    src = oldplot.range2d
    #for attr in ('_low_setting', '_low_value', '_high_setting', '_high_value'):
    #    setattr(dst, attr, getattr(src, attr))
    dst._xrange.sources = copy(src._xrange.sources)
    dst._yrange.sources = copy(src._yrange.sources)

    newplot.padding = oldplot.padding
    newplot.bounds = oldplot.bounds[:]
    newplot.resizable = ""
    newplot.position = drop_position

    newplot.datasources = copy(oldplot.datasources)

    for name, renderers in oldplot.plots.items():
        newrenderers = []
        for renderer in renderers:
            new_r = clone_renderer(renderer)
            new_r.index_mapper = LinearMapper(range=newplot.index_range)
            new_r.value_mapper = LinearMapper(range=newplot.value_range)
            new_r._layout_needed = True
            new_r.invalidate_draw()
            new_r.resizable = "hv"
            newrenderers.append(new_r)
        newplot.plots[name] = newrenderers
    #newplot.plots = copy(oldplot.plots)

    for name, renderers in newplot.plots.items():
        newplot.add(*renderers)

    newplot.index_axis.title = oldplot.index_axis.title
    newplot.index_axis.unified_draw = True
    newplot.value_axis.title = oldplot.value_axis.title
    newplot.value_axis.unified_draw = True

    # Add new tools to the new plot
    newplot.tools.append(AxisTool(component=newplot,
        range_controller=canvas.range_controller))

    # Add tools to the new plot
    pan_traits = ["drag_button", "constrain", "constrain_key", "constrain_direction",
                  "speed"]
    zoom_traits = ["tool_mode", "always_on", "axis", "enable_wheel", "drag_button",
                   "wheel_zoom_step", "enter_zoom_key", "exit_zoom_key", "pointer",
                   "color", "alpha", "border_color", "border_size", "disable_on_complete",
                   "minimum_screen_delta", "max_zoom_in_factor", "max_zoom_out_factor"]
    move_traits = ["drag_button", "end_drag_on_leave", "cancel_keys", "capture_mouse",
                   "modifier_key"]

    if not MULTITOUCH:
        for tool in oldplot.tools:
            if isinstance(tool, PanTool):
                newtool = tool.clone_traits(pan_traits)
                newtool.component = newplot
                break
        else:
            newtool = PanTool(newplot)
        # Reconfigure the pan tool to always use the left mouse, because we will
        # put plot move on the right mouse button
        newtool.drag_button = "left"
        newplot.tools.append(newtool)

        for tool in oldplot.tools:
            if isinstance(tool, MoveTool):
                newtool = tool.clone_traits(move_traits)
                newtool.component = newplot
                break
        else:
            newtool = MoveTool(newplot, drag_button="right")
        newplot.tools.append(newtool)

        for tool in oldplot.tools:
            if isinstance(tool, ZoomTool):
                newtool = tool.clone_traits(zoom_traits)
                newtool.component = newplot
                break
        else:
            newtool = ZoomTool(newplot)
        newplot.tools.append(newtool)

    else:
        pz = MPPanZoom(newplot)
        #pz.pan.constrain = True
        #pz.pan.constrain_direction = "x"
        #pz.zoom.mode = "range"
        #pz.zoom.axis = "index"
        newplot.tools.append(MPPanZoom(newplot))
        #newplot.tools.append(MTMoveTool(

    newplot._layout_needed = True

    clonetool.dest.add(newplot)
    newplot.invalidate_draw()
    newplot.request_redraw()
    canvas.request_redraw()
    return
コード例 #4
0
class FiberView( HasTraits ):

    timer         = Instance( Timer )
#    model         =  FiberModel(options)

    plot_data     = Instance( ArrayPlotData )
    plot          = Instance( Plot )
    start_stop    = Button()
    exit          = Button()

    # Default TraitsUI view
    traits_view = View(
        Item('plot', editor=ComponentEditor(), show_label=False),
        # Items
        HGroup( spring,
                Item( "start_stop", show_label = False ),
                Item( "exit", show_label = False ), spring),
        HGroup( spring ),

        # GUI window
        resizable = True,
        width     = 1000, 
        height    = 700,
        kind      = 'live' )

    def __init__(self, options, **kwtraits):
        super( FiberView, self).__init__(**kwtraits )
        self.model = FiberModel(options)

        # debugging
        self.debug = options.debug
        self.model.debug = options.debug

        # timing parameters
        self.max_packets = options.max_packets
        self.hertz = options.hertz

        # extend options to model
        self.model.max_packets = options.max_packets
        self.model.preallocate_arrays()
        self.model.num_analog_channels = options.num_analog_channels

        # generate traits plot
        self.plot_data = ArrayPlotData( x = self.model._tdata, y = self.model._ydata )
        self.plot = Plot( self.plot_data )
        renderer  = self.plot.plot(("x", "y"), type="line", name='old', color="green")[0]
#        self.plot.delplot('old')

        # recording flags
        self.model.recording = False
        self.model.trialEnded = True


        print 'Viewer initialized.'

        # should we wait for a ttl input to start?
        if options.ttl_start:
            self.model.ttl_start = True
            self.ttl_received = False

            # initialize FIO0 for TTL input
            self.FIO0_DIR_REGISTER = 6100 
            self.FIO0_STATE_REGISTER = 6000 
            self.model.labjack.writeRegister(self.FIO0_DIR_REGISTER, 0) # Set FIO0 low

        # initialize output array
        self.out_arr = None

        # keep track of number of runs
        self.run_number = 0

        self.timer = Timer(self.model.dt, self.time_update) # update every 1 ms


    def run( self ):
        self._plot_update()
        self.model._get_current_data()


    def time_update( self ):
        """ Callback that gets called on a timer to get the next data point over the labjack """

#        print "time_update"
#        print "self.model.ttl_start", self.model.ttl_start
#        print "self.ttl_received", self.ttl_received
#        print "self.model.recording", self.model.recording

        if self.model.ttl_start and not self.ttl_received:
            ttl = self.check_for_ttl()
            if ttl:
                self.ttl_received = True
#                self.model.recording = True
#                self.model.trialEnded = False
                self._start_stop_fired()
               
        if self.model.recording and not self.model.ttl_start:
            self.run()

        elif self.model.ttl_start:
            if self.model.recording and self.ttl_received:
                self.run()
#            elif self.model.recording:
#                self._start_stop_fired()
        else:
            if self.debug:
                pass #print "--timer tic--"
            pass

    def check_for_ttl(self):
        start_ttl = self.model.labjack.readRegister(self.FIO0_STATE_REGISTER)
#        print "start_ttl: ", start_ttl
        return start_ttl

    def clean_time_series(self, time_series, blip_thresh = 10.0):
        """ Removes blips, NAs, etc. """
        blip_idxs = time_series > blip_thresh
        time_series[blip_idxs] = np.median(time_series)
        return time_series

    def _plot_update( self ):
        num_display_points = 100*25 # For 1000 Hz
    
        if self.model.master_index > num_display_points:
            disp_begin = self.model.master_index - num_display_points
            disp_end = self.model.master_index
#            print 'disp_begin', disp_begin
#            print 'disp_end', disp_end
            ydata = self.clean_time_series( np.array(self.model._ydata[disp_begin:disp_end]) )
            xdata = np.array(self.model._tdata[disp_begin:disp_end])

            self.plot_data.set_data("y", ydata)
            self.plot_data.set_data("x", xdata)
            
        else:        
            self.plot_data.set_data( "y", self.clean_time_series( self.model._ydata[0:self.model.master_index] )) 
            self.plot_data.set_data( "x", self.model._tdata[0:self.model.master_index] )

        self.plot = Plot( self.plot_data )

#        self.plot.delplot('old')
        the_plot = self.plot.plot(("x", "y"), type="line", name = 'old', color="green")[0]
        self.plot.request_redraw()

    # Note: These should be moved to a proper handler (ModelViewController)

    def _start_stop_fired( self ):
        self.model.start_time = time.time()
        self.model.recording = not self.model.recording
        self.model.trialEnded = not self.model.trialEnded
        if self.model.trialEnded:
            self.save()
        
        #Quickly turn LED off to signal button push
        self.model.start_LED()


    def _exit_fired(self):
        print "Closing connection to LabJack..."
        self.ttl_start = False
        self.recording = False
        self.model.sdr.running = False
        self.model.recording = False

#        self.model.labjack.streamStop()
        self.model.labjack.close()
        print "connection closed. Safe to close..."
        #raise SystemExit
        #sys.exit()

    def save( self ):
            print "Saving!"        
            # Finally, construct and save full data array
            print "Saving acquired data..."
            for i in xrange( len( self.model.data ) ):
                new_array = 1
                block = self.model.data[i]
                for k in self.model.result.keys():
                    print k
                    if k != 0:
                        if new_array == 1:
                            array = np.array(block[k])
                            array.shape = (len(array),1)
                            new_array = 0
                        else:
                            new_data = np.array(block[k])
                            new_data.shape = (len(block[k]),1)
                            # if new_data is short by one, fill in with last entry
                            if new_data.shape[0] < array.shape[0]:
                                new_data = np.append( new_data, new_data[-1] )
                                new_data.shape = (new_data.shape[0], 1)
                                print "Appended point to new_data, shape now:",new_data.shape
                            if new_data.shape[0] > array.shape[0]:
                                new_data = new_data[:-1]
                                print "Removed point from new_data, shape now:",new_data.shape
                            print "array shape, new_data shape:", array.shape, new_data.shape
                            array = np.hstack((array, new_data ))
                if i == 0:
                    self.out_arr = array
                    print "Array shape:", self.out_arr.shape
                else:
                    self.out_arr = np.vstack( (self.out_arr, array) )
                    print "Array shape:", self.out_arr.shape
            date = time.localtime()
            outfile = self.model.savepath + self.model.filename
            outfile += str(date[0]) + '_' + str(date[1]) + '_' + str(date[2]) + '_'
            outfile += str(date[3]) + '-' + str(date[4]) + '_run_number_' + str(self.run_number) 
            np.savez(outfile, data=self.out_arr, time_stamps=self.model._tdata)

#             time_outfile = outfile + '_t'
#             np.savez(time_outfile, self.model._tdata)
            print "Saved ", outfile

            # Plot the data collected this last run
            self.plot_last_data()

            # clean up
            self.reset_variables()

    def reset_variables(self):
        self.out_arr = None
        self.ttl_received = False
        self.run_number += 1
        self.model.recording = False
        self.trialEnded = True
        self.plot.delplot('old')

    def plot_last_data(self):
        import pylab as pl
        if self.out_arr.shape[1] == 4:
            pl.figure()
            pl.subplot(411)
            pl.plot(self.out_arr[:,0])
            pl.subplot(412)
            pl.plot(self.out_arr[:,1])
            pl.subplot(413)
            pl.plot(self.out_arr[:,2])
            pl.subplot(414)
            pl.plot(self.out_arr[:,3])
            pl.show()
コード例 #5
0
ファイル: visualization.py プロジェクト: mrbhjv/dft_python
class TimerController(HasTraits):
    def __init__(self):
        self.arch = BehOrg.GraspArchitecture()
        self._time_steps = 0
        self.create_plot_component()

    def get_container(self):
        return self._container

    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)

    def onTimer(self, *args):
        self.arch.step()

        self._camera_field_plotdata.set_data(
            'imagedata',
            self.arch._camera_field.get_activation().max(2).transpose())
        self._color_space_field_plotdata.set_data(
            'imagedata',
            self.arch._color_space_field.get_activation().max(1).transpose())
        self._color_space_ee_field_plotdata.set_data(
            'imagedata',
            self.arch._color_space_ee_field.get_activation().max(
                2).transpose())
        self._spatial_target_field_plotdata.set_data(
            'imagedata',
            self.arch._spatial_target_field.get_activation().transpose())
        self._move_head_intention_field_plotdata.set_data(
            'imagedata',
            self.arch._move_head.get_intention_field().get_activation().
            transpose())
        self._move_head_cos_field_plotdata.set_data(
            'imagedata',
            self.arch._move_head.get_cos_field().get_activation().transpose())
        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_cos_field_plotdata.set_data(
            'imagedata',
            self.arch._visual_servoing_right.get_cos_field().get_activation().
            transpose())
        self._move_right_arm_intention_field_plotdata.set_data(
            'imagedata',
            self.arch._move_right_arm_intention_field.get_activation().
            transpose())
        self._move_right_arm_cos_field_plotdata.set_data(
            'imagedata',
            self.arch._move_arm_cos_field.get_activation().transpose())
        #        self._gripper_right_intention_field_plotdata.set_data('imagedata', self.arch._gripper_right_intention_field.get_activation().transpose())
        #        self._gripper_right_cos_field_plotdata.set_data('imagedata', self.arch._gripper_right_cos_field.get_activation().transpose())
        #        self._find_color_intention_field_plotdata.set_data('y', self.arch._find_color.get_intention_field().get_activation())
        #        self._find_color_ee_intention_field_plotdata.set_data('y', self.arch._find_color_ee.get_intention_field().get_activation())

        self._camera_field_plot.request_redraw()
        self._color_space_field_plot.request_redraw()
        self._color_space_ee_field_plot.request_redraw()
        self._spatial_target_field_plot.request_redraw()
        self._move_head_intention_field_plot.request_redraw()
        self._move_head_cos_field_plot.request_redraw()
        self._visual_servoing_right_intention_field_plot.request_redraw()
        self._visual_servoing_right_cos_field_plot.request_redraw()
        self._move_right_arm_intention_field_plot.request_redraw()
        self._move_right_arm_cos_field_plot.request_redraw()
        #        self._gripper_right_cos_field_plot.request_redraw()
        #        self._gripper_right_intention_field_plot.request_redraw()

        return