本文整理汇总了Python中utils.Data.analyze方法的典型用法代码示例。如果您正苦于以下问题:Python Data.analyze方法的具体用法?Python Data.analyze怎么用?Python Data.analyze使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Data
的用法示例。
在下文中一共展示了Data.analyze方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import analyze [as 别名]
class pend:
NP = 400
tmax = 5.0 # We digitize oscillations for 10 seconds
looping = False
xlabel = 'Seconds'
ylabel = 'Volts'
size = [100,100]
scale = None
delay = 0.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.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 set_tmax(self,w):
d = self.scale.get()
self.tmax = float(d)
self.plot2d.setWorld(0, -5, self.tmax, 5)
self.plot2d.mark_axes(self.xlabel,self.ylabel)
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 calc_g(self,e):
if self.data.points == []:
return
x = self.lentext.get()
try:
L = float(x)
except:
self.msgwin.msg('Set the length of the rod', 'red')
return
import phmath, math
dat = []
for k in self.data.points:
dat.append([k[0], k[1]])
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)
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import analyze [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
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import analyze [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):
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import analyze [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):
#.........这里部分代码省略.........
示例5: __init__
# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import analyze [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]
#.........这里部分代码省略.........
示例6: __init__
# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import analyze [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 '+\
#.........这里部分代码省略.........
示例7: __init__
# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import analyze [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 '+\
#.........这里部分代码省略.........
示例8: __init__
# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import analyze [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
#.........这里部分代码省略.........