def key_press_U(self,obj,event):
     '''
     Key event u: last solution data - show last soultion data set
     '''
     key = obj.GetKeyCode()
     if key=='u' or key=='U':
         self.solutionPosition = self.solutionPosition - 1
         if self.solutionPosition < 0:
             self.solutionPosition = len(self.solutionName) - 1
         # recalculate the range of the lookuptable ## 
         self.scalarPosition = 0
         minL = []
         maxL = []
         for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
             minL.append(array.min())
             maxL.append(array.max())
         self.SourceMin = min(minL)
         self.SourceMax = max(maxL)
 
         #set time
         self.endTime = len(self.areaSolution[self.solutionPosition][0])
         
         #set name of the solution
         if self.pauseBool == False: self.engine.scenes[0].name = str(self.vascularNetwork.name +' - '+'paused'+' - '+self.solutionName[self.solutionPosition])
         else: self.engine.scenes[0].name = str(self.vascularNetwork.name +' - '+'running'+' - '+'t = 0.000' +' - '+self.solutionName[self.solutionPosition])
 
         #restart simulation
         self.currentTime = 0
    def visualize(self):
        '''
        Start the visualisation of the simulation result.
        Set up Upgrade method and starts the main loop.
        Use only if the simulation result was set!
        '''
        # update the lookuptables and set them
        minL = []
        maxL = []
       
        for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
            minL.append(array.min())
            maxL.append(array.max())
        self.SourceMin = min(minL)
        self.SourceMax = max(maxL)

        for actor in self.vizActors.itervalues():
            actor.module_manager.scalar_lut_manager.data_range = [self.SourceMin, self.SourceMax]
        #self.vizActors[0].module_manager.scalar_lut_manager.data_name = self.scalarNames[self.solutionPosition][self.scalarPosition]
        #self.vizActors[0].module_manager.scalar_lut_manager.show_scalar_bar = True

        timer = Timer(0.03, self.update)
        gui = GUI()
        gui.busy = True
        gui.start_event_loop()
Esempio n. 3
0
 def to_uint32(self, array, colname):
     if colname in {"open", "high", "low", "close"}:
         # Data is stored as 1000 * raw value.
         assert array.max() < (UINT_32_MAX / 1000), "Test data overflow!"
         return array * 1000
     else:
         assert colname in ("volume", "day"), "Unknown column: %s" % colname
         return array
Esempio n. 4
0
 def to_uint32(self, array, colname):
     if colname in {'open', 'high', 'low', 'close'}:
         # Data is stored as 1000 * raw value.
         assert array.max() < (UINT_32_MAX / 1000), "Test data overflow!"
         return array * 1000
     else:
         assert colname in ('volume', 'day'), "Unknown column: %s" % colname
         return array
Esempio n. 5
0
 def to_uint32(self, array, colname):
     arrmax = array.max()
     if colname in OHLC:
         self.check_uint_safe(arrmax * 1000, colname)
         return (array * 1000).astype(uint32)
     elif colname == 'volume':
         self.check_uint_safe(arrmax, colname)
         return array.astype(uint32)
     elif colname == 'day':
         nanos_per_second = (1000 * 1000 * 1000)
         self.check_uint_safe(arrmax.view(int) / nanos_per_second, colname)
         return (array.view(int) / nanos_per_second).astype(uint32)
 def key_press_V(self,obj,event):
     '''
     Key event V: open vessels and show vectorfields
     '''
     key = obj.GetKeyCode()
     if key=='v' or key=='V':
         if self.vecBool == False: 
             self.vecBool = True
             for glyph in self.glyph.itervalues(): glyph.actor.actor.visibility = self.vecBool
             self.scalarPosition = 3
             
             minL = []
             maxL = []
             for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
                 minL.append(array.min())
                 maxL.append(array.max())
                 
             self.SourceMin = min(minL)
             self.SourceMax = max(maxL)
             
             self.vizActors[0].module_manager.scalar_lut_manager.show_scalar_bar = False
             self.glyph[0].module_manager.scalar_lut_manager.data_range = [0, self.SourceMax]
             self.glyph[0].module_manager.scalar_lut_manager.show_scalar_bar = True
             self.glyph[0].module_manager.scalar_lut_manager.data_name = self.scalarNames[self.solutionPosition][self.scalarPosition]
             
             print " .. velocity profile enabled"
         else: 
             self.vecBool = False
             for glyph in self.glyph.itervalues(): glyph.actor.actor.visibility = self.vecBool
             print " .. velocity profile disabled"
             self.scalarPosition = 3
             minL = []
             maxL = []
             for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
                 minL.append(array.min())
                 maxL.append(array.max())
             self.SourceMin = min(minL)
             self.SourceMax = max(maxL)
             self.vizActors[0].module_manager.scalar_lut_manager.data_name = self.scalarNames[self.solutionPosition][3]
             self.vizActors[0].module_manager.scalar_lut_manager.show_scalar_bar = True
 def key_press_N(self,obj,event):
     '''
     Key event n: next lookup table - change the lookup and scalar mapping
     '''
     key = obj.GetKeyCode()
     if key=='n' or key=='N':
         self.scalarPosition = self.scalarPosition + 1
         if self.scalarPosition == len(self.scalarNames[self.solutionPosition]):
             self.scalarPosition = 0
         minL = []
         maxL = []
         for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
             minL.append(array.min())
             maxL.append(array.max())
         self.SourceMin = min(minL)
         self.SourceMax = max(maxL)
 def key_press_J(self,obj,event):
     '''
     Key event j: last lookup table - change the lookup and scalar mapping
     '''
     key = obj.GetKeyCode()
     if key=='j' or key=='J':
         self.scalarPosition = self.scalarPosition - 1
         if self.scalarPosition < 0:
             self.scalarPosition = len(self.scalarNames[self.solutionPosition]) - 1
         # recalculate the range of the lookuptable ## Note: change this in further version to save memory -> (list)
         minL = []
         maxL = []
         for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
             minL.append(array.min())
             maxL.append(array.max())
         self.SourceMin = min(minL)
         self.SourceMax = max(maxL)