当前位置: 首页>>代码示例>>Python>>正文


Python Data.save_all方法代码示例

本文整理汇总了Python中utils.Data.save_all方法的典型用法代码示例。如果您正苦于以下问题:Python Data.save_all方法的具体用法?Python Data.save_all怎么用?Python Data.save_all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.Data的用法示例。


在下文中一共展示了Data.save_all方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]

#.........这里部分代码省略.........
        res = phmath.fit_dsine(dat)
        fit = []
        exp = []
        for k in res[0]: 
            fit.append([k[0],k[2]])
            exp.append([k[0],k[3]])
        self.data.traces.append(fit)
       	self.col = self.data.get_col()
        self.plot2d.line(fit, self.col)
       	self.col = self.data.get_col()
        self.plot2d.line(exp, self.col)

        D = res[1][4]
        T = 1.0 / res[1][1]
        r = 0.14		# radius of the rod
        R = 1.27		# radius of the ball
        density = 7.8		# density of iron
        m_rod = math.pi * r**2 * L * density
        m_ball = math.pi * 4 / 3 * R**3 * density
#        print m_rod,'',m_ball
        Lprime = ( (m_rod * L**2)/3 + (m_ball * 2/5 * R**2) + m_ball * \
          (L+R)**2 ) / ( (m_rod * L)/2 + m_ball*(L+R) )

        g = 4.0 * math.pi**2 * Lprime / (T * T)
#        print T, Lprime, g, D 
        ss = 'T = %4.3f seconds. Length = %4.2f | g = %4.0f \
cm/sec2 | Damping factor = %4.3f\n'%(T,L,g,D)
        self.msgwin.showtext(ss)
#        g2 = 4.0 * math.pi**2 * L / (T * T)
        
    def analyze(self,e):
        self.data.analyze(self.xlabel, self.ylabel)

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def show_all(self,e):
        self.plot2d.delete_lines()  
        self.data.index = 0
        for tr in self.data.traces:
          self.plot2d.line(tr,self.data.get_col())
#------------------------------------------------------------------        
        
    def start(self,e):
        if self.ph == None:
            self.msgwin.msg('Connection not made yet', 'red')
            return
        if self.looping == False:    		# Same color if restarted
        	self.col = self.data.get_col()
        self.msgwin.msg('Starting Pendulum Waveform digitization')
	self.looping = True

	v = self.ph.get_voltage_bip()		# First reading is taken
	self.start_time = v[0]			# Remember starting time
        self.data.points = [(0.0, v[1]/1000.0)]	# initialize the list
        
    def accept_trace(self):
        self.data.traces.append(self.data.points)

    def update(self):
        if self.looping == False:
            return
开发者ID:minrk,项目名称:phoenix,代码行数:70,代码来源:pendulum.py

示例2: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class osc:
    NP = 200
    adc_delay = 20
    delay_vals = [10,20,50,100,200,500,1000]
    looping = False
    xlabel = 'milli seconds'
    ylabel = 'Volts'
    adc_scale = None
    size = [100,100]
    
    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)
        self.size[0] = float(size[0])
        self.size[1] = float(size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = size[0], height = size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()
      
    def enter(self, fd):	#Phoenix handler set by the caller
        self.ph = fd
        self.ph.select_adc(0)
        self.ph.set_adc_size(1)
        self.plot2d.setWorld(0, 0, self.NP * self.adc_delay/1000.0, 5)
        self.plot2d.mark_axes(self.xlabel, self.ylabel)
        self.msg_intro()
      
    def exit(self):		# Do cleanup here
        self.ph.disable_set()

    def update(self):
        pass
      
    def clear(self,e):
        self.data.clear()
        self.plot2d.delete_lines()  
              
    def save(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)
        
    def show_waveform(self,w):
        data = self.ph.read_block(self.NP, self.adc_delay, 0)
        self.data.points = []
        for k in data:
          self.data.points.append( (k[0]/1000.0, k[1]/1000.0) )
        self.plot2d.line(self.data.points, self.data.get_col())
        self.data.traces.append(self.data.points)
        
    def set_adc_delay(self,w):
        d = self.adc_scale.get()    
        self.adc_delay = self.delay_vals[d]
        if self.ph == None:
            return
        self.ph.set_adc_delay(self.adc_delay)
        self.plot2d.setWorld(0, -5, self.NP * self.adc_delay/1000.0, 5)
        self.plot2d.mark_axes(self.xlabel, self.ylabel)

    def duty_cycle(self,e):
        sum = 0.0
        for k in range(100):
          t = self.ph.r2ftime(4,4)
          if t < 0:
            self.msgwin.showtext('\nTime out on CMP','red')
            return
          else:
            sum = sum + t    
        hi = sum / 100
        self.msgwin.showtext('\nHIGH = ' + '%4.1f'%(hi) + ' usec.  ')
        sum = 0.0
        for k in range(100):
          t = self.ph.f2rtime(4,4)
          if t < 0:
            self.msgwin.showtext('\nTime out on CMP','red')
            return
          else:
            sum = sum + t    
        low = sum / 100
        self.msgwin.showtext('LOW = ' + '%4.1f'%(low) + ' usec.  ')
        ds = hi * 100 / (low + hi)
        self.msgwin.showtext('Duty Cycle = ' + '%4.1f'%(ds)+ ' %. ')

    def frequency(self,e):
        fr = self.ph.measure_frequency()
        self.msgwin.showtext('\nFrequency = ' + '%4.0f'%(fr) + ' Hz')

#.........这里部分代码省略.........
开发者ID:phoenix-project,项目名称:phoenix,代码行数:103,代码来源:osc555.py

示例3: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class sound:
    NP = 200
    adc_delay = 10
    delay_vals = [10,20,50,100,200,500,1000]
    looping = False
    xlabel = 'milli seconds'
    ylabel = 'Volts'
    adc_scale = None
    size = [100,100]
    
    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)
        self.size[0] = float(size[0])
        self.size[1] = float(size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = size[0], height = size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()
      
    def enter(self, fd):	#Phoenix handler set by the caller
        self.ph = fd
        self.ph.select_adc(0)
        self.ph.set_adc_size(1)
        self.ph.write_outputs(0)
        self.ph.set_pulse_width(13)
        self.plot2d.setWorld(0, -5, self.NP * self.adc_delay/1000.0, 5)
        self.plot2d.mark_axes(self.xlabel, self.ylabel)
        self.msg_intro()
      
    def exit(self):		# Do cleanup here
        self.ph.disable_set()

    def update(self):
        pass
      
    def clear(self,e):
        self.data.clear()
        self.plot2d.delete_lines()  
              
    def save(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)
        
    def show_waveform(self,w):
        self.ph.enable_pulse_high(3)
        data = self.ph.read_block(self.NP, self.adc_delay, 1)
        self.data.points = []
        for k in data:
          self.data.points.append( (k[0]/1000.0, k[1]/1000.0) )
        self.plot2d.line(self.data.points, self.data.get_col())
        self.data.traces.append(self.data.points)
        self.ph.write_outputs(0);
        
    def set_adc_delay(self,w):
        d = self.adc_scale.get()    
        self.adc_delay = self.delay_vals[d]
        if self.ph == None:
            return
        self.ph.set_adc_delay(self.adc_delay)
        self.plot2d.setWorld(0, -5, self.NP * self.adc_delay/1000.0, 5)
        self.plot2d.mark_axes(self.xlabel, self.ylabel)

    def ms_delay(self,e):
        self.ph.write_outputs(0)
        self.ph.set_pulse_width(13)
        self.ph.set_pulse_polarity(0)
        t = self.ph.pulse2rtime(3,3)
        if t < 0:
            self.msgwin.showtext('\nTime out on Input D3','red')
            return
        self.msgwin.showtext('%4.0f'%t)
    
    def refresh(self,e):
        self.msg_intro()

    def msg_intro(self):
        self.clear(None)
        self.msgwin.clear()
        self.msgwin.showtext('Connect the Transmitter Piezo between Digital '+\
        'output D3 and Ground. Connect the Receiver Piezo between Ground '+\
        'and the Inverting Amplifier Input. Set a gain resistor of 100. '+\
        'Connect the Output of the amplifier to the level shifter and '+\
        'level shifter output to Ch0. If the Amplitude is less, use one '+\
        'more Inverting amplifier in series.')

        self.msgwin.showlink('View Waveform', self.show_waveform)
#.........这里部分代码省略.........
开发者ID:phoenix-project,项目名称:phoenix,代码行数:103,代码来源:usound.py

示例4: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class rodpend:
    NP = 400
    tmax = 10.0		# We digitize oscillations for 10 seconds
    maxcount = 10
    looping = False
    xlabel = 'Number'
    ylabel = 'g'
    size = [100,100]
    scale = None    
    
    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)
        self.size[0] = float(size[0])
        self.size[1] = float(size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = size[0], height = size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()

    def enter(self, p):	
      self.ph = p 
      self.ph.select_adc(0)
      self.ph.set_adc_size(2)
      self.intro_msg()
      self.plot2d.setWorld(0, -5, self.tmax, 5)	
      self.plot2d.mark_axes(self.xlabel,self.ylabel)

    def exit(self):
      self.looping = False
      
    def clear(self,e):
        self.plot2d.delete_lines()  
        self.data.clear()

    def save(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def analyze(self,e):
        self.data.analyze(self.xlabel, self.ylabel)

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def show_all(self,e):
        self.plot2d.delete_lines()  
        self.data.index = 0
        for tr in self.data.traces:
          self.plot2d.line(tr,self.data.get_col())
#------------------------------------------------------------------        
        
    def start(self,e):
        x = self.lentext.get()
        try:
            self.length = float(x)
        except:
            self.msgwin.msg('Set the length of the Pendulum', 'red')
            return

        x = self.numtext.get()
        try:
            self.maxcount = int(x)
        except:
            self.maxcount = 10
        self.tmax = self.maxcount

        if self.ph == None:
            self.msgwin.msg('Connection not made yet', 'red')
            return
        if self.looping == False:    		# Same color if restarted
        	self.col = self.data.get_col()
        self.msgwin.msg('Starting Measurement of gravity using Rod Pendulum')
	self.count = 0
        t = self.ph.pendulum_period(3)	# Every alternate rising edge
#	t = self.ph.multi_r2rtime(3,1)
	if t < 0:
          self.msgwin.msg('Pendulum Period Timeout Error', 'red')
          return
        t = t/1000000.0
        self.pisqr = math.pi ** 2
        g = 4.0 * self.pisqr * 2.0 * self.length / (3.0 *  t * t)
        self.msgwin.showtext('\nPeriod    Gravity')
        self.msgwin.showtext('\n%6.5f\t%4.1f'%(t,g))
#        print self.pisqr, self.length, t, g
        self.data.points = [(self.count, g)]
        self.plot2d.setWorld(0, 0, self.tmax, g*1.2)	
        self.plot2d.mark_axes(self.xlabel,self.ylabel)
	self.looping = True

#.........这里部分代码省略.........
开发者ID:phoenix-project,项目名称:phoenix,代码行数:103,代码来源:rodpend.py

示例5: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class pt100:
    NP = 400
    delay = 0.03	# minimum delay between voltage reads
    tmax = 12.0		# Number of seconds for NP reads
    looping = False
    xlabel = 'Seconds'
    ylabel = 'Kelvin'
    gain = 11.0		# Assume PT100 output is amplified by 11
    ccval = 1.0		# CCS nominal value is 1 mA
    maxtemp = 800.0
    size = [100,100]
    del_scale = None    
    np_scale = None    
    
    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)
        self.size[0] = float(size[0])
        self.size[1] = float(size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = size[0], height = size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()

    def enter(self, p):	
      self.ph = p 
      self.ph.select_adc(0)
      self.ph.set_adc_size(2)
      self.intro_msg()
      self.tmax = self.delay * self.NP
      self.plot2d.setWorld(0, 0, self.tmax, self.maxtemp)	
      self.plot2d.mark_axes(self.xlabel,self.ylabel)

    def exit(self):
      self.looping = False
      
    def set_delay(self,w):
        if self.looping:
          return
        d = self.del_scale.get()    
        self.delay = float(d)/1000.0
        self.plot2d.setWorld(0, 0, self.NP * self.delay, self.maxtemp)	
        self.plot2d.mark_axes(self.xlabel,self.ylabel)
        if len(self.data.points) < 2:
          return
        self.plot2d.delete_lines()
        self.plot2d.line(self.data.points, self.col)
        
    def set_NP(self,w):
        d = self.np_scale.get()    
        self.NP = d
        self.plot2d.setWorld(0, 0, self.NP * self.delay, self.maxtemp)	
        self.plot2d.mark_axes(self.xlabel,self.ylabel)
        if len(self.data.points) < 2:
          return
        self.plot2d.delete_lines()
        self.plot2d.line(self.data.points, self.col)
        
    def clear(self,e):
        self.plot2d.delete_lines()  
        self.data.clear()

    def save(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def analyze(self,e):
        self.data.analyze(self.xlabel, self.ylabel)

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def show_all(self,e):
        self.plot2d.delete_lines()  
        self.data.index = 0
        for tr in self.data.traces:
          self.plot2d.line(tr,self.data.get_col())
#------------------------------------------------------------------        
        
    def start(self,e):
        if self.ph == None:
            self.msgwin.msg('Connection not made yet', 'red')
            return
        if self.looping == False:    		# Same color if restarted
        	self.col = self.data.get_col()
        self.msgwin.msg('Started Temperature Recording')
	self.looping = True
	self.data.points = []
	
    def stop(self,e):
#.........这里部分代码省略.........
开发者ID:minrk,项目名称:phoenix,代码行数:103,代码来源:pt100.py

示例6: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class cap:
    NP = 200
    adc_delay = 20
    delay_vals = [10,20,50,100,200,500,1000]
    xlabel = 'milli seconds'
    ylabel = 'Volts'
    size = [100,100]
    
    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)
        self.size[0] = float(size[0])
        self.size[1] = float(size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = size[0], height = size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()
      
    def enter(self, fd):	#Phoenix handler 'ph' is set by the caller
        self.intro_msg()
        self.ph = fd
        try:
            self.ph.select_adc(0)
            self.ph.set_adc_size(2)
        except:
            self.msgwin.msg('Connection NOT Established','red')
                
    def exit(self):		# Do cleanup here
        try:
            self.ph.disable_set()
        except:
            pass
            
    def update(self):
        pass
      
    def clear(self,e):
        self.data.clear()
        self.plot2d.delete_lines()  
              
    def save(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def analyze(self,e):
        self.data.analyze(self.xlabel, self.ylabel)

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)
        
    def capture_trace(self): # Collect data and store in object 'data'
        # All conversion to be done here. setWorld according to 'trace'
        # xscale and yscale are specified
        # if axes are shown in different units    
        phdata = self.ph.read_block(self.NP, self.adc_delay, 0)
        self.data.points = []
        for k in phdata:
          self.data.points.append( (k[0]/1000.0, k[1]/1000.0) )
            #microsec -> millisec ; millivolts -> volts
        self.data.traces.append(self.data.points)
        last = self.data.points[-1][0]
        second = self.data.points[-2][0]
        xmax = last + (last-second)

        self.plot2d.setWorld(0, 0, xmax, 5)	# Set scale factors
        self.plot2d.mark_axes(self.xlabel, self.ylabel)	 # axes & labels
        self.plot2d.line(self.data.points, self.data.get_col())
        
    def discharge(self,w):
        self.ph.write_outputs(8)
        time.sleep(1)
        self.ph.enable_set_low(3)
        self.capture_trace()

    def charge(self,w):
        self.ph.write_outputs(0)
        time.sleep(1)
        self.ph.enable_set_high(3)
        self.capture_trace()
        
    def set_adc_delay(self,w):
        d = self.adc_scale.get()    
        self.adc_delay = self.delay_vals[d]
        if self.ph == None:
            return
        self.ph.set_adc_delay(self.adc_delay)
        self.plot2d.setWorld(0, 0, self.NP * self.adc_delay/1000.0, 5)
        self.plot2d.mark_axes(self.xlabel, self.ylabel)

    def calc_cap(self,e):
#.........这里部分代码省略.........
开发者ID:minrk,项目名称:phoenix,代码行数:103,代码来源:capacitor.py

示例7: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class tran:
    NP = 200
    adc_delay = 250
    numchans = 2
    xlabel = 'milli seconds'
    ylabel = 'Volts'
    size = [350.0, 272.0]

    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)        

        self.size[0] = float(im.size[0])
        self.size[1] = float(im.size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = im.size[0], height = im.size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()

    def enter(self, fd):
        self.ph = fd
        self.ph.set_adc_delay(self.adc_delay)
        self.plot2d.setWorld(0, -5, self.NP * self.adc_delay/1000.0, 5)
        self.plot2d.mark_axes(self.xlabel, self.ylabel, self.numchans)
        
        self.ph.add_channel(0)
        self.ph.add_channel(1)
        self.ph.del_channel(2)
        self.ph.del_channel(3)

        self.msg_intro()
	v = []
        for i in range(100):
	    x = 127.5 + 127.5 * math.sin(2.0*math.pi*i/100)
	    x = int(x+0.5)
	    v.append(x)
	self.ph.load_wavetable(v)	
	res = self.ph.start_wave(20)
	s = 'DAC is set to generate %3.1f Hz Sine Wave'%(res)
	self.msgwin.msg(s)
        self.updating = True

    def exit(self):
       self.updating = False
       self.ph.stop_wave()
       for k in range(4):
           self.ph.del_channel(k)

#--------------------------------------------------------------------

    def update(self):
        if self.ph == None:
            return
        phdata = self.ph.multi_read_block(self.NP, self.adc_delay, 0)
        if phdata == None:
            return

        self.data.points = []
        self.data.points2 = []
        for pt in phdata:
            self.data.points.append( (pt[0]/1000.0, 5.0 - 2.0 * pt[1]/1000.0) )
            self.data.points2.append((pt[0]/1000.0, 5.0 - 2.0 * pt[2]/1000.0) )
        self.plot2d.delete_lines()
        self.plot2d.line(self.data.points, 'black')
        self.plot2d.line(self.data.points2, 'red')

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.traces = []
        self.data.traces.append(self.data.points)
        self.data.traces.append(self.data.points2)
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)
          
#-------------------------- Message routines -------------
    def msg_intro(self):
        self.msgwin.clear()
        self.msgwin.showtext('In this experiment, the DAC socket (producing '+\
        'a 50 Hz signal) is connected one end of a coil (Other end to GND) '+\
        'through a series capacitor. The same is also connected to CH1 via '+\
        'a level shifter for monitoring the primary waveform. '+\
        'Another coil (Secondary) is connected between Ground '+\
        'and the input of another level shifter, and its output '+\
        'is connected to CH0. Now you should see the primary waveform '+\
        'as a sinewave and the secondary as a horizontal line. Keep the '+\
        'coils close and note changes in secondary waveform. Pack them '+\
        'with ferrite core to see the effect of increased magnetic coupling\n')
        self.msgwin.showlink('Save Traces', self.save_all)
        self.msgwin.showtext('  Saves both the voltage waveforms to text file named ') 
        self.fntext =  Entry(None, width =20, fg = 'red')
        self.msgwin.showwindow(self.fntext)
        self.fntext.insert(END,'trans.dat')
        self.msgwin.showtext('\n\nTry changing the orientation of the coils, removing the ferrite '+\
        'etc. to study the effect of them')
开发者ID:phoenix-project,项目名称:phoenix,代码行数:101,代码来源:transformer.py

示例8: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class gravity:
    NP = 400
    tmax = 10.0		# We digitize oscillations for 10 seconds
    maxcount = 10
    looping = False
    xlabel = 'Number'
    ylabel = 'g'
    size = [100,100]
    scale = None    
    
    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)
        self.size[0] = float(size[0])
        self.size[1] = float(size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = size[0], height = size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()

    def enter(self, p):	
      self.ph = p 
      self.intro_msg()
      self.plot2d.setWorld(0, -5, self.tmax, 5)	
      self.plot2d.mark_axes(self.xlabel,self.ylabel)

    def exit(self):
      self.looping = False
      
    def update(self):
        pass

    def clear(self,e):
        self.plot2d.delete_lines()  
        self.data.clear()

    def save(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def analyze(self,e):
        self.data.analyze(self.xlabel, self.ylabel)

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def show_all(self,e):
        self.plot2d.delete_lines()  
        self.data.index = 0
        for tr in self.data.traces:
          self.plot2d.line(tr,self.data.get_col())
#------------------------------------------------------------------        
        
    def attach(self,e):
        x = self.lentext.get()
        try:
            self.length = float(x)
        except:
            self.msgwin.msg('Set the Height', 'red')
            return

        if self.ph == None:
            self.msgwin.msg('Connection not made yet', 'red')
            return
        self.ph.write_outputs(1)
        self.msgwin.msg('Powered the Electromagnet')
        
    def measure(self,e):
        t = self.ph.clr2rtime(0,0)
        if t < 0:
             self.msgwin.msg('Timeout Error', 'red')
             return
        elif t < 20:
             self.msgwin.msg('Connection Error', 'red')
             return
        t = t + 4000.0   # 4 ms correction for magnetic retention
        t = t * 1.0e-6   # usec to sec
        print t, self.length
        g = 2.0 * self.length / t ** 2
        self.msgwin.showtext('\n%7.6f\t%4.1f'%(t,g))
        self.msgwin.msg('Done')

    def refresh(self,e):
        self.intro_msg()

    def intro_msg(self):
        self.msgwin.clear()
        self.msgwin.showtext('Connect the Electromagnet between Digital '+\
        'Output D0 and GND. '+\
        'Connect the loudspeaker between GND and the input of the inverting '+\
#.........这里部分代码省略.........
开发者ID:minrk,项目名称:phoenix,代码行数:103,代码来源:gravity.py

示例9: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class induction:
    NP = 200
    adc_delay = 500
    delay_vals = [200,500,1000]
    looping = False
    xlabel = 'milli seconds'
    ylabel = 'Volts'
    size = [100,100]
    
    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)
        self.size[0] = float(size[0])
        self.size[1] = float(size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = size[0], height = size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()

    def enter(self,fd):
        self.plot2d.setWorld(0, -5, self.NP * self.adc_delay/1000.0, 5)
        self.plot2d.mark_axes(self.xlabel, self.ylabel)
        self.intro_msg()
        self.ph = fd
        try:
            self.ph.select_adc(0)
            self.ph.set_adc_size(2)
        except:
            self.msgwin.msg('Connection NOT Established','red')
        
    def exit(self):
        self.looping = False
      
    def clear(self,e):
        self.data.clear()
        self.plot2d.delete_lines()  
              
    def save(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def analyze(self,e):
        self.data.analyze(self.xlabel, self.ylabel)

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)
        
    def show_all(self,e):
        self.plot2d.delete_lines()  
        self.data.index = 0
        for tr in self.data.traces:
          self.plot2d.line(tr,self.data.get_col())

    def set_adc_delay(self,w):
        d = self.adc_scale.get()    
        self.adc_delay = self.delay_vals[d]
        if self.ph == None:
            return
        self.ph.set_adc_delay(self.adc_delay)
        self.plot2d.setWorld(0, -5, self.NP * self.adc_delay/1000, 5)
        self.plot2d.mark_axes(self.xlabel, self.ylabel)
#------------------------------------------------------------------        
        
    def start(self,e):
        if self.ph == None:
          self.msgwin.msg('Connection not made yet', 'red')
          return
        phdata = self.ph.read_block(self.NP, self.adc_delay, 1)
        if phdata == None: 
            return

        self.data.points = []
        for k in phdata:
          self.data.points.append( (k[0]/1000.0, k[1]/1000.0) ) # scale & copy
        
	self.limit = 0.0		# Find the present signal level
	for p in self.data.points:
          if abs(p[1]) > self.limit:
	    self.limit = abs(p[1]) + 0.1
	self.looping = True
        self.msgwin.msg('Scanning for Waveform (amplitude > %4.3f V)'%self.limit)
#	print self.limit
	
    def get_peaks(self):
        vmin = 5.0
        vmax = -5.0
        t1 = t2 = 0
        for p in self.data.points:
          if p[1] < vmin:
            vmin = p[1]
#.........这里部分代码省略.........
开发者ID:minrk,项目名称:phoenix,代码行数:103,代码来源:induction.py

示例10: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class diode:
    NP = 500
    looping = False
    xlabel = 'Volts'
    ylabel = 'mA'
    size = [100,100]
    dac_voltage = 0.0
    adc_voltage = 0.0
    step = 39.0
    
    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)
        self.size[0] = float(size[0])
        self.size[1] = float(size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = size[0], height = size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()

    def enter(self, p):	
      self.ph = p 
      self.ph.select_adc(0)
      self.ph.set_adc_size(2)
      self.plot2d.setWorld(0, 0, 5, 5)
      self.plot2d.mark_axes(self.xlabel, self.ylabel)
      self.intro_msg()

    def exit(self):
      self.looping = False

    def clear(self,e):
        self.data.clear()
        self.plot2d.delete_lines()  
              
    def save(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def analyze(self,e):
        self.data.analyze(self.xlabel, self.ylabel)

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def show_all(self,e):
        self.plot2d.delete_lines()  
        self.data.index = 0
        for tr in self.data.traces:
          self.plot2d.line(tr,self.data.get_col())
#------------------------------------------------------------------        
    def start(self,e):
        if self.ph == None:
            self.msgwin.msg('Connection not made yet', 'red')
            return
        if self.looping == False:    # Same color if restarted in between
        	self.col = self.data.get_col()
        self.msgwin.msg('Starting Diode IV measurement')
        self.data.points = []
	self.looping = True
	self.dac_voltage = 0.0
	
    def accept_trace(self):
        self.data.traces.append(self.data.points)

    def update(self):
        if self.ph == None:
          return
        if self.looping != True:
          return
	self.ph.set_voltage(self.dac_voltage)
	time.sleep(0.05)
	self.adc_voltage = self.ph.get_voltage()[1]
	      # voltage and current converted into volts
	current = (self.dac_voltage - self.adc_voltage)/1000.0
        self.data.points.append( (self.adc_voltage/1000.0, current))
        if len(self.data.points) < 2:
          return
        self.plot2d.delete_lines()
        self.plot2d.line(self.data.points, self.col)
        self.dac_voltage = self.dac_voltage + self.step
        if self.dac_voltage > 5000:
          self.msgwin.msg('IV Plot Done')
          self.accept_trace()
          self.looping = False

    def intro_msg(self):
        self.clear(None)
        self.msgwin.clear()
        self.msgwin.showtext('Make the connections as shown above. The '+\
#.........这里部分代码省略.........
开发者ID:phoenix-project,项目名称:phoenix,代码行数:103,代码来源:diode.py

示例11: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class gm:
    NP = 400
    countrate = 100.0		# Assume a 100 Hz count rate
    numtrials = 5		# 5 trials default
    duration = 1		# count for one second
    tube_voltage = 0.0
    VMIN = 300.0
    VOPT = 500.0
    VMAX = 902.0
    looping = False
    xlabel = 'Trial'
    ylabel = 'Count'
    size = [100,100]
    scale = None    
    
    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)
        self.size[0] = float(size[0])
        self.size[1] = float(size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = size[0], height = size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()

    def enter(self, p):	
      self.ph = p 
      self.ph.select_adc(0)
      self.ph.set_adc_size(2)
      self.plot2d.setWorld(0, 0, self.countrate, self.numtrials)	
      self.plot2d.mark_axes(self.xlabel,self.ylabel)
      self.tube_voltage = self.ph.gm_set_voltage(self.VOPT)
      self.intro_msg()
      
    def exit(self):
      self.looping = False
      
    def clear(self,e):
        if self.looping == True: return
        self.plot2d.delete_lines()  
        self.data.clear()

    def save(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def analyze(self,e):
        self.data.analyze(self.xlabel, self.ylabel)

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def show_all(self,e):
        self.plot2d.delete_lines()  
        self.data.index = 0
        for tr in self.data.traces:
          self.plot2d.line(tr,self.data.get_col())
#------------------------------------------------------------------        
        
    def start(self,e):
        x = self.durationtext.get()
        try:
            self.duration = int(x)
        except:
            self.msgwin.msg('Set the Duration of Counting', 'red')
            return

        x = self.trialstext.get()
        try:
            self.numtrials = int(x)
        except:
            self.numtrials = 5

        if self.ph == None:
            self.msgwin.msg('Connection not made yet', 'red')
            return
        if self.looping == False:    		# Same color if restarted
        	self.col = self.data.get_col()
        
        self.tube_voltage = self.ph.gm_set_voltage(self.tube_voltage)
        self.msgwin.msg('GM tube Counting Radiation.')
        self.msgwin.label.update()
	self.count = 0
        gmc = self.ph.gm_get_count(self.duration)
        self.msgwin.showtext('\nCounts : %d '%(gmc))
        self.data.points = [(self.count, gmc)]
        self.plot2d.setWorld(0, 0, self.numtrials, gmc * 1.5 + 5)
        self.xlabel = 'Trial'
        self.plot2d.mark_axes(self.xlabel,self.ylabel)
        self.count = self.count + 1
#.........这里部分代码省略.........
开发者ID:phoenix-project,项目名称:phoenix,代码行数:103,代码来源:gm.py

示例12: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class mono:
    NP = 200
    adc_delay = 20
    delay_vals = [10,20,50,100,200,500,1000]
    looping = False
    xlabel = 'milli seconds'
    ylabel = 'Volts'
    adc_scale = None
    size = [100,100]
    
    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)
        self.size[0] = float(size[0])
        self.size[1] = float(size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = size[0], height = size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()
      
    def enter(self, fd):	#Phoenix handler set by the caller
        self.ph = fd
        self.ph.select_adc(0)
        self.ph.set_adc_size(1)
        self.ph.set_pulse_width(1)
        self.plot2d.setWorld(0, 0, self.NP * self.adc_delay/1000.0, 5)
        self.plot2d.mark_axes(self.xlabel, self.ylabel)
        self.msg_intro()
      
    def exit(self):		# Do cleanup here
        self.ph.disable_set()

    def update(self):
        pass
      
    def clear(self,e):
        self.data.clear()
        self.plot2d.delete_lines()  
              
    def save(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save(fname)
        self.msgwin.msg('Data saved to '+ fname)

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)
        
    def show_waveform(self,w):
        self.ph.enable_pulse_low(3)
        data = self.ph.read_block(self.NP, self.adc_delay, 0)
        self.data.points = []
        for k in data:
          self.data.points.append( (k[0]/1000.0, k[1]/1000.0) )
        self.plot2d.line(self.data.points, self.data.get_col())
        self.data.traces.append(self.data.points)
        self.ph.write_outputs(8);
        
    def set_adc_delay(self,w):
        d = self.adc_scale.get()    
        self.adc_delay = self.delay_vals[d]
        if self.ph == None:
            return
        self.ph.set_adc_delay(self.adc_delay)
        self.plot2d.setWorld(0, -5, self.NP * self.adc_delay/1000.0, 5)
        self.plot2d.mark_axes(self.xlabel, self.ylabel)

    def ms_delay(self,e):
        self.ph.write_outputs(8)
        self.ph.set_pulse_width(1)
        self.ph.set_pulse_polarity(1)
        t = self.ph.pulse2ftime(3,3)
        if t < 0:
            self.msgwin.showtext('\nTime out on Input D3','red')
            return
        self.msgwin.showtext('\nMonoshot Delay = ' + '%4.0f'%(t) + ' usec.')
    
    def refresh(self,e):
        self.msg_intro()

    def msg_intro(self):
        self.clear(None)
        self.msgwin.clear()
        self.msgwin.showtext('Power the Monostable Multivibrator circuit '+\
        'made using IC555 from the 5V Output socket. Connect the Trigger '+\
        'Input of 555 (pin number 2) to Digital Output D3.\n')

        self.msgwin.showlink('View Waveform', self.show_waveform)
        self.msgwin.showtext(' View the output of the circuit.\n')
        self.adc_scale =  Scale(None, command = self.set_adc_delay, \
          from_ = 0, to=6, orient=HORIZONTAL, length=100, showvalue=0)
        self.adc_scale.set(1)
#.........这里部分代码省略.........
开发者ID:phoenix-project,项目名称:phoenix,代码行数:103,代码来源:mono555.py

示例13: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]
class tran:
    NP = 200
    adc_delay = 250
    numchans = 2
    xlabel = 'milli seconds'
    ylabel = 'Volts'
    size = [350.0, 272.0]

    def __init__(self, parent, size, plot, msg):
        self.parent = parent
        self.plot2d = plot
        self.msgwin = msg
        x = Image.open(abs_path(photograph))
        im = x.resize(size)        

        self.size[0] = float(im.size[0])
        self.size[1] = float(im.size[1])
        self.image = ImageTk.PhotoImage(im)
        self.canvas = Canvas(parent, width = im.size[0], height = im.size[1])
        self.canvas.create_image(0,0,image = self.image, anchor = NW)
        self.data = Data()

    def enter(self, fd):
        self.ph = fd
        self.ph.set_adc_delay(self.adc_delay)
        self.plot2d.setWorld(0, -5, self.NP * self.adc_delay/1000.0, 5)
        self.plot2d.mark_axes(self.xlabel, self.ylabel, self.numchans)
        
        self.ph.add_channel(0)
        self.ph.add_channel(1)
        self.ph.del_channel(2)
        self.ph.del_channel(3)

        self.msg_intro()
	v = []
        for i in range(100):
	    x = 127.5 + 127.5 * math.sin(2.0*math.pi*i/100)
	    x = int(x+0.5)
	    v.append(x)
	self.ph.load_wavetable(v)	
	res = self.ph.start_wave(20)
	s = 'DAC is set to generate %3.1f Hz Sine Wave'%(res)
	self.msgwin.msg(s)
        self.updating = True

    def exit(self):
       self.updating = False
       self.ph.stop_wave()
       for k in range(4):
           self.ph.del_channel(k)

#--------------------------------------------------------------------

    def update(self):
        if self.ph == None:
            return
        phdata = self.ph.multi_read_block(self.NP, self.adc_delay, 0)
        if phdata == None:
            return

        self.data.points = []
        self.data.points2 = []
        for pt in phdata:
            self.data.points.append( (pt[0]/1000.0, 5.0 - 2.0 * pt[1]/1000.0) )
            self.data.points2.append((pt[0]/1000.0, 5.0 - 2.0 * pt[2]/1000.0) )
        self.plot2d.delete_lines()
        self.plot2d.line(self.data.points, 'black')
        self.plot2d.line(self.data.points2, 'red')

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.traces = []
        self.data.traces.append(self.data.points)
        self.data.traces.append(self.data.points2)
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)
          
#-------------------------- Message routines -------------
    def msg_intro(self):
        self.msgwin.clear()
        self.msgwin.showtext('Primary Coil is connected to DAC (producing '+\
        'a 50 Hz signal) through a series capacitor. Primary is monitored by CH1. '+\
        'and secondary coil is monitored by CH0. The primary waveform will be seen as a'+\
        'sinewave. Watch the changes in the secondary waveform by changing the distance between '+\
        'coils and adding the ferrite core.\n')
        self.msgwin.showlink('Save Traces', self.save_all)
        self.msgwin.showtext('  Saves both the voltage waveforms to text file named ') 
        self.fntext =  Entry(None, width =20, fg = 'red')
        self.msgwin.showwindow(self.fntext)
        self.fntext.insert(END,'trans.dat')
开发者ID:minrk,项目名称:phoenix,代码行数:94,代码来源:transformer.py

示例14: __init__

# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import save_all [as 别名]

#.........这里部分代码省略.........
        except:
          return
 
        ch = 0;
        for k in range(4):			# Copy data to traces
            adc = self.adcs[k]
            if self.adcs[k][3] == 1:		# Active channel
                if k < 2:			# CH0 or CH1
                    for xy in range(self.NP):
	                if self.ls_ins[k][3] == 0:	# No Level Shifter
    		            self.adcs[k][5][xy] = (self.phdata[xy][0]/1000.0,\
                               self.phdata[xy][ch+1]/1000.0 )
                        else:
    		            self.adcs[k][5][xy] = (self.phdata[xy][0]/1000.0, \
    		              5.0 - 2.0 * self.phdata[xy][ch+1]/1000.0 )
                else:
	            for xy in range(self.NP):
    		            self.adcs[k][5][xy] = (self.phdata[xy][0]/1000.0,\
                               self.phdata[xy][ch+1]/1000.0)
                ch = ch + 1
        
        self.plot2d.delete_lines()
        for adc in self.adcs:
            if adc[3] == 1:			# Active channel
                self.plot2d.line(adc[5], adc[4])
  
#-----------------------------------------------------------------------
    def start(self,e):
        self.updating = True

    def stop(self,e):
        self.updating = False

    def save_all(self,e):
        fname = self.fntext.get()
        if fname == None:
          return
        self.data.traces = []
        for adc in self.adcs:
            if adc[3] == 1:			# Active channel
              self.data.traces.append(adc[5])
        self.data.save_all(fname)
        self.msgwin.msg('Data saved to '+ fname)

#-------------------------- Message routines -------------
    def msg_intro(self):
        self.msgwin.clear()
        self.msgwin.showtext('This section helps you to explore ' +\
          'the different building blocks of PHOENIX. ')
        self.msgwin.showtext('Click on the different Sockets ', 'blue')
        self.msgwin.showtext('shown in  the Photograph to explore the system. '+\
        'Select "Connect" from the main before proceeding.\n'+\
        'From here you can use Phoenix as a test equipment also. The ADC '+\
        'inputs acts like CRO inputs. Digital Inputs can measure frequency '+\
        'of the 0-5V range signals etc.')
    def msg_ccs(self):
        self.msgwin.clear()
        self.msgwin.showtext('This socket gives a constant current of 1 mA ' +\
          'to load resistors upto 1KOhm. This feature is mainly used for ' +\
          'temperature measurements using RTD sensor elements.')

    def msg_cmp(self):
        self.msgwin.clear()
        self.msgwin.showtext('This is one of the Inputs of an Analog ' +\
          'Comparator. The other input is internally connected to around ' +\
          '1.2 V. Connect the DAC output to CMP input and change the DAC ' +\
开发者ID:phoenix-project,项目名称:phoenix,代码行数:70,代码来源:primer.py


注:本文中的utils.Data.save_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。