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


Python Oscilloscope.read_data方法代码示例

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


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

示例1: test_read_data

# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import read_data [as 别名]
 def test_read_data(self):
     print "Testing reading data from the oscilloscope."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     ch1_data, _ = scope.read_data(data_size=0x400)
     print ch1_data
     assert ch1_data
     assert scope.close_handle()
开发者ID:baruch,项目名称:Hantek6022API,代码行数:12,代码来源:LibUsbScopeTest.py

示例2: test_set_one_channel_and_read

# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import read_data [as 别名]
 def test_set_one_channel_and_read(self):
     print "Testing setting one channel and reading it."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware(mod_firmware_01)
     assert scope.set_ch1_voltage_range(0xA)
     assert scope.set_sample_rate(0x10)
     assert scope.set_num_channels(1)
     ch1_data, ch2_data = scope.read_data(0x4000)
     assert ch1_data
     assert not ch2_data
     assert scope.close_handle()
开发者ID:baruch,项目名称:Hantek6022API,代码行数:15,代码来源:LibUsbScopeTest.py

示例3: test_data_scaling

# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import read_data [as 别名]
 def test_data_scaling(self):
     print "Testing setting various scale facotrs and reading."
     scale_factor = 0x01
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     assert scope.set_ch1_voltage_range(scale_factor)
     assert scope.set_sample_rate(27)
     ch1_data, _ = scope.read_data(0x100000)
     ch1_data = scope.scale_read_data(ch1_data, scale_factor)
     print "Max:", max(ch1_data), "(V), Min:", min(ch1_data), "(V)"
     assert ch1_data
     assert scope.close_handle()
开发者ID:baruch,项目名称:Hantek6022API,代码行数:16,代码来源:LibUsbScopeTest.py

示例4: test_read_many_sizes

# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import read_data [as 别名]
 def test_read_many_sizes(self):
     print "Testing reading many different data sizes"
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     data_size = 0x400
     for _ in xrange(11):
         print "DATA SIZE", data_size
         ch1_data, ch2_data = scope.read_data(data_size=data_size, raw=True)
         print len(ch1_data)
         print len(ch2_data)
         assert ch1_data, ch2_data
         data_size <<= 1
     assert scope.close_handle()
开发者ID:baruch,项目名称:Hantek6022API,代码行数:17,代码来源:LibUsbScopeTest.py

示例5: enumerate

# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import read_data [as 别名]
    new_data = data[:window]
    for i, point in enumerate(data[window:-window]):
        new_data.append(sum(data[i-window:i+window+1])/(2*window+1))
    new_data.extend(data[-window:])
    return new_data

sample_rate_index = 0x04
voltage_range = 0x01
data_points = 0x2000

scope = Oscilloscope()
scope.setup()
scope.open_handle()
scope.set_sample_rate(sample_rate_index)
scope.set_ch1_voltage_range(voltage_range)
ch1_data, _ = scope.read_data(data_points)
voltage_data = scope.scale_read_data(ch1_data, voltage_range)
timing_data, _ = scope.convert_sampling_rate_to_measurement_times(data_points, sample_rate_index)
scope.close_handle()
pylab.title('Scope Visualization Example')
pylab.plot(timing_data, voltage_data, color='#009900', label='Raw Trace')
pylab.plot(timing_data, apply_data_smoothing(voltage_data, window=3), color='#0033CC', label='Smoothed Trace')
pylab.xlabel('Time (s)')
pylab.ylabel('Voltage (V)')
pylab.grid()
pylab.legend(loc='best')
pylab.xticks(rotation=30)
pylab.tight_layout()
pylab.show()

开发者ID:baruch,项目名称:Hantek6022API,代码行数:31,代码来源:example_linux_scopevis.py

示例6: enumerate

# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import read_data [as 别名]
    for i, point in enumerate(data[window:-window]):
        new_data.append(sum(data[i-window:i+window+1])/(2*window+1))
    new_data.extend(data[-window:])
    return new_data

sample_rate_index = 0x04
voltage_range = 0x01
data_points = 0x2000

scope = Oscilloscope()
scope.setup()
scope.open_handle()
scope.set_sample_rate(sample_rate_index)
scope.set_ch1_voltage_range(voltage_range)

ch1_data, _ = scope.read_data(data_points)#,raw=True)#timeout=1)

voltage_data = scope.scale_read_data(ch1_data, voltage_range)
timing_data, _ = scope.convert_sampling_rate_to_measurement_times(data_points, sample_rate_index)
scope.close_handle()

if len(timing_data) != len(voltage_data):
    w = sys.stderr.write
    w('data lengths differ!\n')
    w(str([(s,len(eval(s+'_data')))for s in 'timing voltage'.split()]))
    w('\n')
    exit(1)

# store the data
with open('/tmp/scopevis.dat', 'wt') as ouf:
    ouf.write('\n'.join('{:8f}'.format(v) for v in voltage_data))
开发者ID:fogns,项目名称:Hantek6022API,代码行数:33,代码来源:example_linux_scopevis.py


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