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


Python Oscilloscope.scale_read_data方法代码示例

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


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

示例1: test_data_scaling

# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import scale_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

示例2: print

# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import scale_read_data [as 别名]
start_time = time.time()
print("Clearing FIFO and starting data transfer...")
i = 0
scope.start_capture()
shutdown_event = scope.read_async(extend_callback, data_points, outstanding_transfers=10, raw=True)
while time.time() - start_time < 1:
    scope.poll()
scope.stop_capture()
print("Stopping new transfers.")
shutdown_event.set()
print("Snooze 1")
time.sleep(1)
print("Closing handle")
scope.close_handle()
print("Handle closed.")
print("Points in buffer:", len(data))
scaled_data = scope.scale_read_data(data, voltage_range)
with open('/tmp/continuous_read.out','wt') as ouf:
    ouf.write(str(scaled_data[:65536])[1:-1].replace(', ',chr(10)))
plt.figure(0)
plt.plot(scaled_data)
plt.figure(1)
plt.plot(np.fft.fft(scaled_data).real)
#plt.show()
stab = build_stability_array(scaled_data, threshold=np.average(scaled_data))
stab_avg, stab_std = np.average(stab), np.std(stab)
print("Stability", stab_avg, "+/-", stab_std, "({}% deviance)".format(100.0*stab_std/stab_avg))
bad_pulse_count = len([p for p in stab if abs(stab_avg - p) >= stab_std])
print("Pulses more than 1 std dev out: {}/{} ({} %)".format(bad_pulse_count, len(stab), 100.0*bad_pulse_count/len(stab)))
plt.show()
开发者ID:jhoenicke,项目名称:Hantek6022API,代码行数:32,代码来源:example_linux_continous_read.py

示例3: enumerate

# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import scale_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

示例4: extend_callback

# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import scale_read_data [as 别名]
def extend_callback(ch1_data, _):
    data_extend(ch1_data)

start_time = time.time()
shutdown_event = scope.read_async(extend_callback, data_points, outstanding_transfers=25)
print "Clearing FIFO and starting data transfer..."
i = 0
scope.start_capture()
while time.time() - start_time < 1:
    time.sleep(0.01)
scope.stop_capture()
print "Stopping new transfers."
shutdown_event.set()
print "Snooze 1"
time.sleep(1)
print "Closing handle"
scope.close_handle()
print "Handle closed."
print "Points in buffer:", len(data)
plt.figure(0)
plt.plot(scope.scale_read_data(data, voltage_range))
plt.figure(1)
plt.plot(np.fft.fft(scope.scale_read_data(data, voltage_range)))
stab = build_stability_array(scope.scale_read_data(data, voltage_range), threshold=1.2)
stab_avg, stab_std = np.average(stab), np.std(stab)
print "Stability", stab_avg, "+/-", stab_std, "({}% deviance)".format(100.0*stab_std/stab_avg)
bad_pulse_count = len([p for p in stab if abs(stab_avg - p) >= stab_std])
print "Pulses more than 1 std dev out: {}/{} ({} %)".format(bad_pulse_count, len(stab), 100.0*bad_pulse_count/len(stab))
print stab
plt.show()
开发者ID:baruch,项目名称:Hantek6022API,代码行数:32,代码来源:example_linux_continous_read.py


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