Пример #1
0
 def __init__(self):
     super(Study, self).__init__()
     HasTraits.__init__(self)
     # Find foms available
     foms = Application().fom_manager.find_foms()
     foms.insert(0, ' ')
     self.add_trait('input_directory', Directory)
     # self.add_trait('input_directory',Directory('/nfs/neurospin/cati/cati_shared'))
     self.add_trait('input_fom', Enum(foms))
     self.add_trait('output_directory', Directory)
     self.add_trait('output_fom', Enum(foms))
     self.add_trait('shared_directory', Directory)
     self.add_trait('spm_directory', Directory)
     self.add_trait('format_image', Str)
     self.add_trait('format_mesh', Str)
     self.add_trait(
         'process',
         Enum(
             '   ',
             'morphologist.process.morphologist_simplified.SimplifiedMorphologist',
             'morphologist.process.morphologist.Morphologist',
             'morpho.morphologist.morphologist',
             'morphologist.process.customized.morphologist.CustomMorphologist'
         ))
     # self.process_specific=None
     self.compteur_run_process = {}
     self.runs = collections.OrderedDict()
 def __init__(self):
     HasTraits.__init__(self)
     x, y, z = ogrid[-10:10:100j, -10:10:100j, -10:10:100j]
     scalars = sin(x*y*z)/(x*y*z)
     src = ArraySource(scalar_data=scalars)
     self.scene.mayavi_scene.add_child(src)
     src.add_module(IsoSurface())
Пример #3
0
    def __init__(self, parent):
        HasTraits.__init__(self)
        # Create some data, and plot it using the embedded scene's engine

        self.parent = parent
        pub.subscribe(self.on_patient_loaded, "patient.loaded")
        pub.subscribe(self.voi_changed, "voi.selection_changed")
 def __init__(self):
     HasTraits.__init__(self)
     x, y, z = ogrid[-10:10:100j, -10:10:100j, -10:10:100j]
     scalars = sin(x*y*z)/(x*y*z)
     src = ArraySource(scalar_data=scalars)
     self.scene.mayavi_scene.add_child(src)
     src.add_module(IsoSurface())
Пример #5
0
 def __init__(self, AO_channel='/Dev1/ao3', voltage_range=(0.,5.), **kwargs):
     self.AOTask = AOTask(Channels=AO_channel, range=voltage_range)
     self.AOTask.Write(np.array((float(voltage_range[0]),)))
     self.add_trait('voltage', Range(low=float(voltage_range[0]), high=float(voltage_range[1]), value=float(voltage_range[0]), desc='output voltage', label='Voltage [V]'))
     self.on_trait_change(self.write_voltage, 'voltage')
     HasTraits.__init__(self, **kwargs)
     self.voltage_range=voltage_range
Пример #6
0
 def __init__(self,
              device,
              channel=None,
              voltage_max=20.0,
              current_max=2.0,
              fuse_voltage_max=20.0,
              fuse_current_max=2.5,
              **kwargs):
     HMP2030.__init__(self, device, channel, voltage_max, current_max,
                      fuse_voltage_max, fuse_current_max)
     self.add_trait(
         'current',
         Range(low=0.0,
               high='current_max_value',
               value=self.get_current(),
               label='Current [A]',
               auto_set=False,
               enter_set=True))
     self.add_trait(
         'voltage',
         Range(low=0.0,
               high='voltage_max_value',
               value=self.get_voltage(),
               label='Voltage [V]',
               auto_set=False,
               enter_set=True))
     self.add_trait('channel', Enum())
     HasTraits.__init__(self, **kwargs)
Пример #7
0
    def __init__(self, parent_frame):
        #Initialize the parent class
        HasTraits.__init__(self)

        #Record the frame calling this
        self.parent_frame = parent_frame

        #And more initialization
        self.warning_text_visible = False
        self.form_is_closing = False
        self.init_view_objects()

        #Subscribe to messages
        model.messages.subscribe(self.update_stats_panel,
                                 model.messages.MSG_EXPERIMENT_QSPACE_CHANGED)
        model.messages.subscribe(self.update_data_volume,
                                 model.messages.MSG_EXPERIMENT_QSPACE_CHANGED)
        model.messages.subscribe(
            self.update_data_points,
            model.messages.MSG_EXPERIMENT_REFLECTIONS_CHANGED)
        model.messages.subscribe(
            self.update_stats_panel,
            model.messages.MSG_EXPERIMENT_REFLECTIONS_CHANGED)
        model.messages.subscribe(
            self.init_view_objects,
            model.messages.MSG_EXPERIMENT_QSPACE_SETTINGS_CHANGED)

        #Do an initial data update
        self.update_stats_panel()
        self.update_data_volume()
        self.update_data_points()
        self.view_mode_changed()

        #Don't open a child frame at first
        self.reflection_info_child_frame = None
Пример #8
0
    def __init__(self,
                 vlsvReader,
                 variable,
                 operator="pass",
                 threaded=False,
                 **traits):
        ''' Initializes the class and loads the mayavi grid

          :param vlsvReader:        Some vlsv reader with a file open
          :type vlsvReader:         :class:`vlsvfile.VlsvReader`
          :param variable:          Name of the variable
          :param operator:          Operator for the variable
          :param threaded:          Boolean value for using threads or not using threads to draw the grid (threads enable interactive mode)
      '''
        HasTraits.__init__(self, **traits)
        self.vlsvReader = vlsvReader
        self.engine_view = EngineView(engine=self.scene.engine)
        self.__engine = self.scene.engine
        self.__picker = []
        self.__mins = []
        self.__maxs = []
        self.__cells = []
        self.__last_pick = []
        self.__grid_figure = mayavi.mlab.gcf(engine=self.__engine)
        self.__structured_figures = []
        self.__unstructured_figures = []
        self.__thread = []
        self.__load_grid(variable=variable,
                         operator=operator,
                         threaded=threaded)
        self.values = []
        self.variable_plotted = variable
Пример #9
0
    def __init__(self, dsviewer):
        HasTraits.__init__(self)
        self.dsviewer = dsviewer
        self.view = dsviewer.view
        self.do = dsviewer.do
        self.image = dsviewer.image

        self.tracker = None

        #        self.features.on_trait_change(self.OnFeaturesChanged)
        #        self.pNew.on_trait_change(self.OnParamChange)
        #        self.r0.on_trait_change = self.OnParamChange
        #        self.pLinkCutoff.on_trait_change = self.OnParamChange

        #self.pipeline = dsviewer.pipeline
        self.penCols = [
            wx.Colour(*pylab.cm.hsv(v, bytes=True))
            for v in np.linspace(0, 1, 16)
        ]
        self.penColsA = [
            wx.Colour(*pylab.cm.hsv(v, alpha=0.5, bytes=True))
            for v in np.linspace(0, 1, 16)
        ]
        self.CreatePens()

        dsviewer.do.overlays.append(self.DrawOverlays)

        dsviewer.paneHooks.append(self.GenTrackingPanel)
Пример #10
0
   def __init__(self, vlsvReader, variable, operator="pass", threaded=False, **traits):
      ''' Initializes the class and loads the mayavi grid

          :param vlsvReader:        Some vlsv reader with a file open
          :type vlsvReader:         :class:`vlsvfile.VlsvReader`
          :param variable:          Name of the variable
          :param operator:          Operator for the variable
          :param threaded:          Boolean value for using threads or not using threads to draw the grid (threads enable interactive mode)
      '''
      HasTraits.__init__(self, **traits)
      self.vlsvReader = vlsvReader
      self.engine_view = EngineView(engine=self.scene.engine)
      self.__engine = self.scene.engine
      self.__picker = []
      self.__mins = []
      self.__maxs = []
      self.__cells = []
      self.__last_pick = []
      self.__grid_figure = mayavi.mlab.gcf(engine=self.__engine)
      self.__structured_figures = []
      self.__unstructured_figures = []
      self.__thread = []
      self.__load_grid( variable=variable, operator=operator, threaded=threaded )
      self.values = []
      self.variable_plotted = variable
Пример #11
0
 def __init__(self, controller, title=None, **traits):
     HasTraits.__init__(self, **traits)
     BaseVisualizerImpl.__init__(self, controller=controller, title=title)
     # Force the creation of the image_plane_widgets:
     self.ipw_3d_x
     self.ipw_3d_y
     self.ipw_3d_z
Пример #12
0
    def __init__(self, width, height, n_rows, n_columns):
        HasTraits.__init__(self)

        n_scenes = n_rows * n_columns
        if n_scenes < 1:
            raise ValueError("n_rows=%r, n_columns=%r" % (n_rows, n_columns))

        self.scenes = tuple(MlabSceneModel() for _ in xrange(n_scenes))
        for i, scene in enumerate(self.scenes):
            self.add_trait(SCENE_NAME % i, scene)

        if n_rows == n_columns == 1:
            self.view = View(Item(SCENE_NAME % 0,
                                  editor=SceneEditor(scene_class=Scene),
                                  resizable=True,
                                  show_label=False),
                             width=width,
                             height=height,
                             resizable=True)
        else:
            rows = []
            for row in xrange(n_rows):
                columns = []
                for column in xrange(n_columns):
                    i = row * n_columns + column
                    item = Item(SCENE_NAME % i,
                                editor=SceneEditor(scene_class=Scene),
                                resizable=True,
                                show_label=False)
                    columns.append(item)
                rows.append(HGroup(*columns))
            self.view = View(VGroup(*rows))

        self.figures = [scene.mayavi_scene for scene in self.scenes]
 def __init__(self):
     HasTraits.__init__(self)
     x, y, z = ogrid[-10:10, -10:10, -10:10]
     scalars = x ** 2 + y ** 2 + z ** 2
     src = ArraySource(scalar_data=scalars)
     self.scene.mayavi_scene.add_child(src)
     src.add_module(IsoSurface())
Пример #14
0
 def __init__(self, G_, **traits):
     
     HasTraits.__init__(self, **traits)
     
     # Visualization
     self.G_=G_
     self.G=None
     self.engine=None
     self.scn=None
     self.pipeline=None
     self.tube=None
     self.surface=None
     self.glyph=None
     self.glyph_points=None # points needed to render one glyph
     self.outline=None
     self.x, self.y, self.z= None, None, None
     self.node_id=None
     self.data=None
     self.nodes=None
     self.edges=None
     
     #parameters
     self.bound=3
     self.bending_factor=40
     self.connect_step=.1
     self.n_new_nodes=0
    def __init__(self, engine_name="", engine=None, mayavi_engine=None):
        '''
        Parameters
        ----------
        engine_name : str
            Name of the Simphony Modeling Engine wrapper

        engine : ABCModelingEngine
            Simphony Modeling Engine wrapper

        mayavi_engine : mayavi.api.engine
            Default to be mayavi.mlab.get_engine()

        '''
        # Traits initialisation
        HasTraits.__init__(self)

        if mayavi_engine is None:
            # Standalone Mayavi Engine
            mayavi_engine = mlab.get_engine()
        else:
            mayavi_engine = mayavi_engine

        # Add panels
        self.panels = TabbedPanelCollection.create(
            add_engine=AddEnginePanel(engine_manager=self),
            add_source=AddSourcePanel(engine_name=self.engine_name,
                                      engine=self.engine,
                                      mayavi_engine=mayavi_engine),
            run_and_animate=RunAndAnimatePanel(engine=self.engine,
                                               mayavi_engine=mayavi_engine))

        if engine and engine_name:
            self.add_engine(engine_name, engine)
Пример #16
0
    def __init__(self, width, height, n_rows, n_columns):
        HasTraits.__init__(self)

        n_scenes = n_rows * n_columns
        if n_scenes < 1:
            raise ValueError("n_rows=%r, n_columns=%r" % (n_rows, n_columns))

        self.scenes = tuple(MlabSceneModel() for _ in range(n_scenes))
        for i, scene in enumerate(self.scenes):
            self.add_trait(SCENE_NAME % i, scene)

        if n_rows == n_columns == 1:
            self.view = View(Item(SCENE_NAME % 0,
                                  editor=SceneEditor(scene_class=Scene),
                                  resizable=True, show_label=False),
                             width=width, height=height, resizable=True)
        else:
            rows = []
            for row in range(n_rows):
                columns = []
                for column in range(n_columns):
                    i = row * n_columns + column
                    item = Item(SCENE_NAME % i,
                                editor=SceneEditor(scene_class=Scene),
                                resizable=True, show_label=False)
                    columns.append(item)
                rows.append(HGroup(*columns))
            self.view = View(VGroup(*rows))

        self.figures = [scene.mayavi_scene for scene in self.scenes]
    def __init__(self, dsviewer, tracker = None, clumps=[]):
        HasTraits.__init__(self)
        if tracker is None:
            self.tracker = TrackFeatures()
        else:
            self.tracker = tracker
        
        self.clumps = []
        
        self.dsviewer = dsviewer
        self.view = dsviewer.view
        self.do = dsviewer.do
        self.image = dsviewer.image
        
        #self.tracker = None
        self.selectedTrack = None
        
        #self.clumps = []
        
        if 'tracks' in dir(self.image):
            self.SetTracks(self.image.tracks)
        
        self.penCols = [wx.Colour(*plt.cm.hsv(v, bytes=True)) for v in np.linspace(0, 1, 16)]
        self.penColsA = [wx.Colour(*plt.cm.hsv(v, alpha=0.5, bytes=True)) for v in np.linspace(0, 1, 16)]
        self.CreatePens()

        self.trackview = wx.html2.WebView.New(dsviewer)
        dsviewer.AddPage(self.trackview, True, 'Track Info')  
        
        dsviewer.do.overlays.append(self.DrawOverlays)

        dsviewer.paneHooks.append(self.GenTrackingPanel)
    def __init__(self):
        HasTraits.__init__(self)

        self.I = None

        self.images = {}
        self.imageCounter = 0
        self.sceneObjectImages = {}
        self.imageRenderArgs = {}

        self.data = {}
        self.dataScalar = {}
        self.dataCounter = 0
        self.sceneObjectData = {}
        self.dataRenderArgs = {}

        self.sceneObjectImageVolume = None
        self.modeVectorFlip = 1.0

        self.view = None
        self.roll = None

        self.onCloseCallback = None

        # image plane widget attributes
        self._ipw_picked_obj = None
        self._ipw_picked_points = []
Пример #19
0
    def __init__(self):
        HasTraits.__init__(self)

        X = np.array([[0., 0., 0.]])
        s = np.array([0])
        v = np.array([[0.15, 0.15, 0.15]])
        dist = 0.25
        self.cam_path_plot = self.scene.mlab.plot3d(X[:, 0],
                                                    X[:, 1],
                                                    X[:, 2],
                                                    s,
                                                    tube_radius=None,
                                                    colormap='jet')

        self.cam_pos_plot = self.scene.mlab.quiver3d(X[-1:, 0],
                                                     X[-1:, 1],
                                                     X[-1:, 2],
                                                     v[-1:, 0],
                                                     v[-1:, 1],
                                                     v[-1:, 2],
                                                     opacity=0.5,
                                                     scale_factor=dist / 2,
                                                     color=(1, 0, 0),
                                                     mode='2dthick_arrow')

        self.map_plot = self.scene.mlab.points3d(X[:, 0],
                                                 X[:, 1],
                                                 X[:, 2],
                                                 color=(0, 1, 0.25),
                                                 mode='point')
        self.scene.reset_zoom()
    def __init__(self,type,r,penal,move,e,nu,volfac,**traits):

        HasTraits.__init__(self, **traits)
        self.scene.mayavi_scene.name = 'Geometry'
        self.scene.foreground = (1,170/255,0)
        self.scene0.mayavi_scene.name = 'Displacement'
        self.scene1.mayavi_scene.name = 'Stress'
        self.scene2.mayavi_scene.name = 'Strain'
        self.scene3.mayavi_scene.name = 'Density'
        self.scene4.mayavi_scene.name = 'Animate'

        #初始化enine_view
        self.engine_view = EngineView(engine=self.scene.engine)

        #对current_selection 进行动态监听,如果current_selection的值发生变化就调用 self._selection_change

        self.scene.engine.on_trait_change(self._selection_change,name = 'current_selection')
        self.simp_solver = None
        self.type = type
        self.r = r
        self.penal = penal
        self.move = move
        self.e = e
        self.nu = nu
        self.volfac = volfac
        self.address = 'H:\GitHub\Topology-optimization-of-structure-via-simp-method'
        self.i = 1
Пример #21
0
 def __init__(self, controller, title=None, **traits):
     HasTraits.__init__(self, **traits)
     BaseVisualizerImpl.__init__(self, controller=controller, title=title)
     # Force the creation of the image_plane_widgets:
     self.ipw_3d_x
     self.ipw_3d_y
     self.ipw_3d_z
Пример #22
0
 def __init__(self):
     XYStage.__init__(self)
     HasTraits.__init__(self)
     self.x = self.actual_x = self.get_x()
     self.y = self.actual_y = self.get_y()
     self.on_trait_change(self.on_x_change, 'x')
     self.on_trait_change(self.on_y_change, 'y')
Пример #23
0
    def __init__(self, x, y, z, theta, phi, THETAnorm, PHInorm, mask):
        # Do not forget to call the parent's __init__
        HasTraits.__init__(self)

        self.theta = theta
        self.phi = phi
        self.THETAnorm = THETAnorm
        self.PHInorm = PHInorm
        self.z = z
        self.mask = mask

        #
        # Visualize the results.
        #
        self.Ximg, self.Yimg = np.mgrid[0:1001, 0:1001]

        Zimg = estimate(self.z, self.theta, self.phi, self.THETAnorm,
                        self.PHInorm, self.lmax)
        self.mesh = self.scene.mlab.mesh(self.Ximg,
                                         self.Yimg,
                                         Zimg,
                                         mask=~mask)

        x_undistort = (theta / (np.pi / 2) * np.sin(phi) + 1) * 1001 / 2
        y_undistort = (theta / (np.pi / 2) * np.cos(phi) + 1) * 1001 / 2
        self.scene.mlab.points3d(x_undistort,
                                 y_undistort,
                                 self.z,
                                 mode='sphere',
                                 scale_mode='none',
                                 scale_factor=5,
                                 color=(0, 0, 1))

        self.scene.mlab.outline(color=(0, 0, 0),
                                extent=(0, 1001, 0, 1001, 0, 255))
Пример #24
0
    def __init__(self , model ):
        HasTraits.__init__(self)

        ## Save model to object
        self.model = model

        ## Set value range
        ## self.frame = Range(0, self.model.numberOfFrames - 1 , 0)

        ## Set to initial frame
        self.model.setFrame( 0 )

        ## Get every joint coordinates in the frame
        x = np.array( [ self.model.model_position[ key ][ 0 , 0 ] for key in self.model.model_position ] ) 
        y = np.array( [ self.model.model_position[ key ][ 1 , 0 ] for key in self.model.model_position ] )
        z = np.array( [ self.model.model_position[ key ][ 2 , 0 ] for key in self.model.model_position ] )

        ## Plot Edges
        ##for edge in self.model.model_edges:
        ##    self.plotEdges.append( self.scene.mlab.plot3d( edge[ : , 0 ] , edge[ : , 2 ] , edge[ : , 1 ]  , color=(0 , 0 ,0) ) )

        ## Plot floor
        s = np.array( 100 * [ 100 * [0] ] )
        self.scene.mlab.surf( s , representation = 'wireframe' )        

        # Populating our plot
        self.plotJoints = self.scene.mlab.points3d(x, z, y, color=(0 , 0 ,0), scale_factor=.75 )
Пример #25
0
 def __init__(self, component=None, **kw):
     # Need to ensure component is initialized first so that
     # _set_screen_points can accurately map the points if needed
     if 'component' in kw:
         component = kw['component']
     self.component = component
     HasTraits.__init__(self, **kw)
Пример #26
0
    def __init__(self, tvtkGridSrcs=None, tvtkGridFunctionSrcs=None,
                 tvtkStructuredGridDataSrcs=None, dataRange=None):
        HasTraits.__init__(self)
        if tvtkGridSrcs is not None:
            try:
                self.tvtkGridSrcs = [VTKDataSource(data=tvtkSrc) for tvtkSrc in tvtkGridSrcs]
            except TypeError:
                self.tvtkGridSrcs = [VTKDataSource(data=tvtkGridSrcs)]
        else:
            self.tvtkGridSrcs = []
        if tvtkGridFunctionSrcs is not None:
            try:
                self.tvtkGridFunctionSrcs = [VTKDataSource(data=tvtkSrc)
                                             for tvtkSrc in tvtkGridFunctionSrcs]
            except TypeError:
                self.tvtkGridFunctionSrcs = [VTKDataSource(data=tvtkGridFunctionSrcs)]
        else:
            self.tvtkGridFunctionSrcs = []
        if tvtkStructuredGridDataSrcs is not None:
            try:
                self.tvtkStructuredGridDataSrcs = [VTKDataSource(data=tvtkSrc)
                                             for tvtkSrc in tvtkStructuredGridDataSrcs]
            except TypeError:
                self.tvtkStructuredGridDataSrcs = [VTKDataSource(data=tvtkStructuredGridDataSrcs)]
        else:
            self.tvtkStructuredGridDataSrcs = []

        # Retrieve and store the overall range of the real and imaginary parts and squared norm
        def extendRange(range, data_source):
            if data_source is None:
                return
            r = data_source.range
            range[0] = min(range[0], r[0])
            range[1] = max(range[1], r[1])

        if dataRange is not None:
            if len(dataRange) != 2:
                raise ValueError, "dataRange must be a two-element iterable"
            if dataRange[0] > dataRange[1]:
                raise ValueError, "lower bound of data range must not be larger than its upper bound"
            self.realDataRange = dataRange
            self.imagDataRange = dataRange
            self.abs2DataRange = dataRange
        else:
            self.realDataRange = [1e100, -1e100]
            self.imagDataRange = [1e100, -1e100]
            self.abs2DataRange = [1e100, -1e100]
            for src in (self.tvtkGridFunctionSrcs + self.tvtkStructuredGridDataSrcs):
                extendRange(self.realDataRange, src.data.point_data.get_array("real"))
                extendRange(self.imagDataRange, src.data.point_data.get_array("imag"))
                extendRange(self.abs2DataRange, src.data.point_data.get_array("abs^2"))
                extendRange(self.realDataRange, src.data.cell_data.get_array("real"))
                extendRange(self.imagDataRange, src.data.cell_data.get_array("imag"))
                extendRange(self.abs2DataRange, src.data.cell_data.get_array("abs^2"))
            if self.realDataRange[0] > self.realDataRange[1]:
                self.realDataRange = [0, 0]
            if self.imagDataRange[0] > self.imagDataRange[1]:
                self.imagDataRange = [0, 0]
            if self.abs2DataRange[0] > self.abs2DataRange[1]:
                self.abs2DataRange = [0, 0]
Пример #27
0
    def __init__(self, cpSchedule, logPath, id=0):
        HasTraits.__init__(self)
        self.id = id

        self.logPath = logPath
        self.CPSched = cpSchedule
        self.AveR = cpSchedule.AveR

        self.showLog = True
        self.showBoards = True
        self.showFL = False
        self.show3m = False
        self.showPerc = False
        self.showFront = False
        self.showOpenFace = False

        if self.CPSched.Cutplans.shape[0] > 0:
            c = self.CPSched.Cutplans.iloc[self.id]
            log = self.CPSched.AverageLog(self.id)
            self.scene.mlab.clf()
            self.coords = GetLogCoords(log, c)
            self.myOff = self.coords.Offset
            self.plotter = LogPlotter(self.scene, c, self.coords)
            # self.plotter.PlotLog()
        else:
            c = None
            self.plotter = None
 def __init__(self):
     HasTraits.__init__(self)
     x, y, z = ogrid[-10:10, -10:10, -10:10]
     scalars = x**2 + y**2 + z**2
     src = ArraySource(scalar_data=scalars)
     self.scene.mayavi_scene.add_child(src)
     src.add_module(IsoSurface())
Пример #29
0
    def __init__(self, send_trial_number = False, *args, **kwargs):
        HasTraits.__init__(self, *args, **kwargs)
        
        # events -- dispatched on UI thread
        self.on_trait_event(self._handle_push_event, 'push_event', dispatch='fast_ui')
        self.on_trait_event(self._handle_push_streaming, 'push_streaming', dispatch='fast_ui')
        self.on_trait_change(self._handle_eot, 'eot', dispatch='ui')

        # database
        self.persistor = Persistor()

        # config
        # self.configFile = os.environ.get("voyeur_config")
        self.configFile = os.path.join('/Users/Gottfried_Lab/PycharmProjects/PyOlfa/src/voyeur_rig_config.conf')

        # serial
        self.serial_queue1 = SerialCallThread(monitor=self, max_queue_size=1)        
        try:
            if self.serial1 is None:
                self.serial1 = SerialPort(self.configFile, board='board1', port='port1', send_trial_number = send_trial_number)
        except SerialException as e:
            print('Serial Port 1 Error')
            print('Serial exception. Message: ', e.msg, ' Path: ', e.path)

        self.protocol_name = self.serial1.request_protocol_name()
        ### Define monitor metadata. This metadata is consistent between all protocols.
        self.metadata = {'arduino_protocol_name': self.protocol_name,
                         'start_date': time.mktime(time.localtime()),
                         #todo: add VOYEUR core version hash or version number lookup.
                         }
Пример #30
0
    def __init__(self,  sim_config, mechanism_functor, chlname, **kwargs):
        HasTraits.__init__(self)

        self.sim_config = sim_config
        self.sim_config.add_simulation_chl_functor(self)

        self.mechanism_functor = mechanism_functor
        self.chlname = chlname
Пример #31
0
 def __init__(self, meas_in=None):
     HasTraits.__init__(self, trait_value=True)
     if meas_in:
         measurement_file_name = meas_in
     else:
         measurement_file_name = 'Path to measurement input text file.'
     self.H = Human(meas_in if meas_in else self.measPreload)
     self._init_draw_human()
Пример #32
0
 def __init__(self, meas_in=None):
     HasTraits.__init__(self, trait_value=True)
     if meas_in:
         measurement_file_name = meas_in
     else:
         measurement_file_name = 'Path to measurement input text file.'
     self.H = Human(meas_in if meas_in else self.measPreload)
     self._init_draw_human()
Пример #33
0
 def __init__(self):
     HasTraits.__init__(self)
     # Create some data, and plot it using the embedded scene's engine
     x, y, z = ogrid[-10:10:100j, -10:10:100j, -10:10:100j]
     scalars = sin(x*y*z)/(x*y*z)
     src = ArraySource(scalar_data=scalars)
     self.scene.engine.add_source(src)
     src.add_module(IsoSurface())
Пример #34
0
 def __init__(self):
     HasTraits.__init__(self)
     # Create some data, and plot it using the embedded scene's engine
     x, y, z = ogrid[-10:10:100j, -10:10:100j, -10:10:100j]
     scalars = sin(x * y * z) / (x * y * z)
     src = ArraySource(scalar_data=scalars)
     self.scene.engine.add_source(src)
     src.add_module(IsoSurface())
Пример #35
0
 def __init__(self, config, server):
     HasTraits.__init__(self)
     self.mayavi_view = PlotHead(self, config, server)
     self.tail_data = np.zeros((2,3))
     self.head_data = np.zeros((2,3))
     self.reset = False
     self.init_plot()
     self.timer = Timer(2000, self.update_plot)
     self.timer.Start()
Пример #36
0
    def __init__(self, *args, **kw):
        HasTraits.__init__(self, *args, **kw)
        self.styles = {
                "fast" : CellFormat(bold=True, fgcolor="darkGreen"),
                "slow" : CellFormat(italics=True, fgcolor="lightGray"),
                }

        self.fast_dates = [date(2010,7,4), date(2010,7,3), date(2010,7,2)]
        self.slow_dates = [date(2010,6,28), date(2010,6,27), date(2010,6,24)]
Пример #37
0
    def __init__(self, folder_to_watch=None):
        """ Initialises the Slow View GUI """
        HasTraits.__init__(self)

        self.slice_mode = None
        if folder_to_watch is None:
            self.folder_to_watch = ""
            self.science_image_wildmasks = ["(None)"]
        else: self.folder_to_watch = folder_to_watch
Пример #38
0
    def __init__(self, **traits):
        self._update_region = None
        self._gc = None
        self._pointer_owner = None
        HasTraits.__init__(self, **traits)

        # Create a default component (if necessary):
        if self.component is None:
            self.component = Container()
Пример #39
0
 def __init__(self, rds=None, **traits):
     HasTraits.__init__(self, **traits)
     if rds and len(rds) == 3:
         self.rds = rds
         self.ts, self.x, self.y, self.hd = get_tracking(*rds)
         self.t = stamp_to_time(self.ts,
             zero_stamp=get_session_metadata(*rds)['start'])
     else:
         raise ValueError, 'bad session specifier: %s'%str(rds)
Пример #40
0
 def __init__(self, *args, **kw):
     HasTraits.__init__(self, *args, **kw)
     numpoints = 200
     plotdata = ArrayPlotData(x=sort(random(numpoints)), y=random(numpoints))
     plot = Plot(plotdata)
     plot.plot(("x", "y"), type="scatter")
     plot.tools.append(PanTool(plot))
     plot.overlays.append(ZoomTool(plot))
     self.plot = plot
Пример #41
0
 def __init__(self, config_file, server, parent):
     HasTraits.__init__(self)
     self.count = 0
     self.parent = parent
     self.pointer_position = np.zeros((1, 3))
     self.head_data = np.zeros((1, 3))
     self.load_config(config_file)
     self.init_plot()
     self.setup_dragonfly(server)
Пример #42
0
 def __init__(self, cov, chan_map, **traits):
     self.cov = cov
     self._cv_mn = cov.min()
     self._cv_mx = cov.max()
     array_plot = ArrayMap(chan_map, vec=self.cov.mean(1))
     HasTraits.__init__(self,
                        array_plot=array_plot,
                        _c_lo=self._cv_mn,
                        _c_hi=self._cv_mx)
     self.sync_trait('selected_site', self.array_plot, mutual=True)
Пример #43
0
 def __init__(self, *args, **kw):
     HasTraits.__init__(self, *args, **kw)
     numpoints = 200
     plotdata = ArrayPlotData(x=sort(random(numpoints)),
                              y=random(numpoints))
     plot = Plot(plotdata)
     plot.plot(("x", "y"), type="scatter")
     plot.tools.append(PanTool(plot))
     plot.overlays.append(ZoomTool(plot))
     self.plot = plot
Пример #44
0
 def __init__(self):
     HasTraits.__init__(self)
     # Create some data, and plot it using the embedded scene's engine
     reader = tvtk.OBJReader()
     reader.file_name = "C:\\Users\\amcmorl\\Desktop\\Head\\Head.obj"
     mapper = tvtk.PolyDataMapper()
     mapper.input = reader.output
     actor = tvtk.Actor()
     actor.mapper = mapper
     self.scene.add_actor(actor)
Пример #45
0
    def __init__(self, **traits):
        Ice.Application.__init__(self)
        HasTraits.__init__(self,**traits)

        plots = {}
        self.container = OverlayPlotContainer(padding = 50, fill_padding = True,
                                         bgcolor = "lightgray", use_backbuffer=True)
        self.jtrig = 0
        self.trigTelType = 0
        self.CAMERAlayout = ArrayPlotData()
Пример #46
0
 def __init__(self, **traits):
     HasTraits.__init__(self, **traits)
     self.fs = FS
     if self._decimate_factor > 2:
         self.fs /= self._decimate_factor
         self._b = firwin(self._ntaps, self.fs, nyq=FS / 2, pass_zero=True)
     self.b = firwin(self.ntaps,
                     CfgBands[self.band],
                     nyq=self.fs / 2,
                     pass_zero=False)
Пример #47
0
    def __init__(self,  sim_config, general_pane=None, chlname=None):
        HasTraits.__init__(self)

        self.sim_config = sim_config
        self.sim_config.add_simulation_chl_functor(self)

        self.general=general_pane

        self.general.parentchlpane = self
        self.chlname=chlname
Пример #48
0
 def __init__(self):
     # Do not forget to call the parent's __init__
     HasTraits.__init__(self)
     
     # initialize scene?
     self.scene.disable_render = True
     self.pt_source = mlab.pipeline.scalar_scatter(1, 1, 1, 1, figure = self.scene.mayavi_scene)
     self.scene.disable_render = False
     
     # self.scene.mlab.cfg(figure = self.scene.mayavi_scene)
     return
Пример #49
0
    def __init__(self, **traits):
        self._scroll_origin = (0.0, 0.0)
        self._update_region = None
        self._gc = None
        self._pointer_owner = None
        HasTraits.__init__(self, **traits)

        # Create a default component (if necessary):
        if self.component is None:
            self.component = Container()
        return
Пример #50
0
 def __init__(self):
     # Do not forget to call the parent's __init__
     HasTraits.__init__(self)
     names, x, y, z = zip(*colors)
     
     self.plot = self.scene.mlab.triangular_mesh(x, y, z, tg.hull,
                                                 color=(1,1,1),
                                                 #opacity=0.3,
                                                 representation='wireframe')
     
     """
Пример #51
0
    def __init__(self, **traits):
        HasTraits.__init__(self, **traits)
        self.engine_view = EngineView(engine=self.scene.engine)

        # Hook up the current_selection to change when the one in the engine
        # changes.  This is probably unnecessary in Traits3 since you can show
        # the UI of a sub-object in T3.
        self.scene.engine.on_trait_change(self._selection_change,
                                          'current_selection')

        self.generate_data_mayavi()
Пример #52
0
 def __init__(self, xyz_src, xyz_targ,T=None):
     self.xyz_src = xyz_src
     self.xyz1_src = np.c_[xyz_src, np.ones(len(xyz_src))]
     self.xyz1_targ = np.c_[xyz_targ, np.ones(len(xyz_targ))]
     self.xyz_targ = xyz_targ
     if T is not None:
         Tflat = T.flatten()
         assert Tflat.size == 12 or Tflat.size == 16
         self.x00,self.x01,self.x02,self.x03,self.x10,self.x11,self.x12,self.x13,self.x20,self.x21,self.x22,self.x23 = Tflat[:12]
     
     HasTraits.__init__(self)
     self.redraw()
Пример #53
0
 def __init__(self, *args, **kw):
     HasTraits.__init__(self, *args, **kw)
     # Create the data and the PlotData object
     x = linspace(-14, 14, 100)
     y = sin(x) * x**3
     plotdata = ArrayPlotData(x = x, y = y)
     # Create the scatter plot
     plot = Plot(plotdata)
     plot.plot(("x", "y"), type=self.plot_type, color="blue")
     plot.tools.append(PanTool(plot))
     plot.tools.append(ZoomTool(plot))
     self.plot = plot
Пример #54
0
    def __init__(self, *args, **kw):
        HasTraits.__init__(self, *args, **kw)

        self.container = Plot(
            data=self.data,
            padding=50,
            fill_padding=True,
            bgcolor='white',
            border_visible=True,
            use_backbuffer=True,
            )

        #self.container.overlays.append(
        #        ConstrainedZoomTool(
        #            self.container,
        #            wheel_zoom_step=0.25,
        #            enter_zoom_key=KeySpec('z'),
        #            ),
        #        )
        self.container.tools.append(PanTool(self.container))

        self.plot = self.container.plot(('index', 'value'),
                'scatter',
                color='gray',
                line_width=0,
                marker='circle',
                marker_size=4,
                )[0]

        self.plot.tools.append(
                ScatterInspector(
                    self.plot,
                    selection_mode='single',
                    persistent_hover=False,
                    )
                )

        self.plot.overlays.append(
                ScatterInspectorOverlay(
                    self.plot,
                    hover_color='transparent',
                    hover_line_width=2,
                    hover_marker_size=6,
                    hover_outline_color='red',
                    selection_marker_size=6,
                    selection_marker='circle',
                    selection_color='black',
                    selection_line_width=0,
                    )
                )

        '''
Пример #55
0
 def __init__(self, eval=None, label='Value',
              trait=None, min=0.0, max=1.0,
              initial=None, **traits):
     HasTraits.__init__(self, **traits)
     if trait is None:
         if min > max:
             min, max = max, min
         if initial is None:
             initial = min
         elif not (min <= initial <= max):
             initial = [min, max][abs(initial - min) > abs(initial - max)]
         trait = Range(min, max, value=initial)
     self.add_trait(label, trait)
    def __init__(self, fault, horxyz, origxyz=None, ve=2, calc_fault=None, 
                **kwargs):
        self.ve = ve
        self.origxyz = origxyz

        self.fault = fault
        if calc_fault is None:
            self.faultxyz = data.to_world(data.to_xyz(fault))
        else:
            self.faultxyz = calc_fault
        self.horxyz = horxyz

        HasTraits.__init__(self, **kwargs)
Пример #57
0
    def __init__(self, input_data):
        HasTraits.__init__(self)
        # Create some data, and plot it using the embedded scene's engine
        
        if input_data['backend'] == 'CoolProp':
            input_data['backend'] = 'HEOS'
        HEOS = CoolProp.AbstractState(input_data['backend'],input_data['fluid1'] + '&' + input_data['fluid2'])
        n = 200
        data = []
        X0 = linspace(0.0001, 0.9999, input_data['N'])
        for x0 in X0:

            HEOS.set_mole_fractions([x0, 1 - x0])
            try:
                HEOS.build_phase_envelope("dummy")
            except ValueError as VE:
                print(VE)
            
            PE = HEOS.get_phase_envelope_data()
            # Find maximum pressure location
            ipmax = argmax(PE.p)
            # Interpolate to find densities corresponding to cutoff pressure (if possible)
            if min(PE.p[0:ipmax-1]) < input_data['p_cutoff'] < max(PE.p[0:ipmax-1]):
                rhoymin = Interpolate(PE.p[0:ipmax-1], PE.rhomolar_vap[0:ipmax-1])([input_data['p_cutoff']])[0]
            else:
                rhoymin = min(PE.rhomolar_vap)
            if min(PE.p[ipmax+1::]) < input_data['p_cutoff'] < max(PE.p[ipmax+1::]):
                rhoymax = Interpolate(PE.p[ipmax+1::], PE.rhomolar_vap[ipmax+1::])([input_data['p_cutoff']])[0]
            else:
                rhoymax = max(PE.rhomolar_vap)
            rhoy = logspace(math.log10(rhoymin), math.log10(rhoymax), n)
            T = Interpolate(PE.rhomolar_vap, PE.T)(rhoy)
            logp = Interpolate(PE.rhomolar_vap, log(PE.p))(rhoy)
            data.append((list(T), list(logp), rhoy))
        
        for j in range(len(data)-1):
            triangles = [(0+i, 1+i, 0+n+i) for i in range(0, n-1)] + [(0+n+i, 1+i, 1+n+i) for i in range(0, n-1)]
            x = data[j][0] + data[j+1][0]
            y = data[j][1] + data[j+1][1]
            z = [X0[j]]*len(data[j][0]) + [X0[j+1]]*len(data[j][0])
            t = data[j][2] + data[j+1][2]
            
            # Apply scale factors
            y = [_*50 for _ in y]
            z = [_*100 for _ in z]
            
            lens = (len(x), len(y), len(z), len(t))
            assert(len(set(lens)) == 1)
            
            self.plot = self.scene.mlab.points3d(x, y, z, scale_factor = 0.5, figure = self.scene.mayavi_scene)
            self.plot = self.scene.mlab.triangular_mesh(x, y, z, triangles, scalars = t, figure = self.scene.mayavi_scene)