本文整理汇总了Python中device.Device.readRMS方法的典型用法代码示例。如果您正苦于以下问题:Python Device.readRMS方法的具体用法?Python Device.readRMS怎么用?Python Device.readRMS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类device.Device
的用法示例。
在下文中一共展示了Device.readRMS方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from device import Device [as 别名]
# 或者: from device.Device import readRMS [as 别名]
class Waveform:
def __init__(self, startFreq=0, endFreq=0, numSamples=0):
if numSamples == 0:
self.numSamples = numSamples
self.frequencies = []
self.voltRms = []
else:
self.frequencies = []
self.voltRms = []
self.device = Device()
self.device.enableInput(5)
self.device.enableOutput(1.41)
self.numSamples = numSamples
startl = math.log10(startFreq)
endl = math.log10(endFreq)
delta = (endl - startl) / (numSamples - 1)
for i in range(0, numSamples):
freq = 10 ** startl
rms = self.device.readRMS(freq, int(freq * 32))
if not math.isnan(rms):
self.frequencies.append(freq)
self.voltRms.append(rms)
startl += delta
def writeToFile(self, fileName):
fHandle = open(fileName, 'w+')
for freq, vrms in zip(self.frequencies, self.voltRms):
fHandle.write(str(freq) + ', ' + str(vrms) + '\n')
fHandle.close()
def loadFromFile(self, fileName):
with open(fileName) as f:
for line in f: # read rest of lines
freq, vrms = [float(x) for x in line.split(',')]
self.frequencies.append(freq)
self.voltRms.append(vrms)
self.numSamples += 1
def dumpData(self):
for freq, vrms in zip(self.frequencies, self.voltRms):
print 'Freq:', freq, '\tVrms:', vrms
def getDeviation(self, w):
result = Waveform()
for freq, vrms1, vrms2 in zip(self.frequencies, self.voltRms, w.voltRms):
result.frequencies.append(freq)
result.voltRms.append(vrms1-vrms2)
return result