#!/usr/bin/env python
# -*- coding: utf-8 -*-

from koheron import connect
from oscillo import Oscillo

import os
import numpy as np
import math

import matplotlib
matplotlib.use('TKAgg')
from matplotlib import pyplot as plt

host = os.getenv('HOST','192.168.1.100')
client = connect(host, name='oscillo')

oscillo = Oscillo(client)
oscillo.reset()

wfm_size = 8192
mhz = 1e6
sampling_rate = 125e6

decimation_factor = 1
index_low = 0
index_high = 8191

decimated_data = oscillo.get_decimated_data(decimation_factor, index_low, index_high)

t_min = index_low * mhz / sampling_rate
t_max = index_high * mhz / sampling_rate

t_range = np.linspace(t_min, t_max, wfm_size)

channel0 = np.zeros((wfm_size, 2))
channel1 = np.zeros((wfm_size, 2))

coeff = mhz * decimation_factor / sampling_rate
size = int(math.floor((index_high - index_low) / decimation_factor))

for i in range(0, wfm_size - 1):
    channel0[i] = [t_min + coeff * i, decimated_data[i]]
    channel1[i] = [t_min + coeff * i, decimated_data[i + size]]

oscillo.set_num_average_min(2000)
oscillo.set_average(True)

plt.plot(t_range, channel0, 'b')
plt.plot(t_range, channel1, 'g')
plt.axis([50, 50.30, -1500, 1500])
plt.show()

@@ -451,94 +451,76 @@
 91%0A%0A
-decimated_data = oscillo.get_decimated_data(decimation_factor, index_low, index_high)%0A
+size = int(math.floor((index_high - index_low) / decimation_factor))
 %0At_m
@@ -601,16 +601,9 @@
 ate%0A
-%0At_range
+t
  = n
@@ -631,523 +631,305 @@
 ax, 
-wfm_
 size)%0A%0A
-channel0 = np.zeros((wfm_size, 2))%0Achannel1 = np.zeros((wfm_size, 2))%0A%0Acoeff = mhz * decimation_factor / sampling_rate%0Asize = int(math.floor((index_high - index_low) / decimation_factor))%0A%0Afor i in range(0, wfm_size - 1):%0A    channel0%5Bi%5D = %5Bt_min + coeff * i, decimated_data%5Bi%5D%5D%0A    channel1%5Bi%5D = %5Bt_min + coeff * i, decimated_data%5Bi + size%5D%5D%0A%0Aoscillo.set_num_average_min(2000)%0Aoscillo.set_average(True)%0A%0Aplt.plot(t_range, channel0, 'b')%0Aplt.plot(t_range, channel1, 'g')%0Aplt.axis(%5B50, 50.30, -1500, 1500%5D
+oscillo.set_num_average_min(2000)%0Aoscillo.set_average(True)%0A%0Adata = oscillo.get_decimated_data(decimation_factor, index_low, index_high)%0A%0Adata = np.reshape(data, (2, size))%0A%0Aplt.plot(t, data%5B0,:%5D, 'b')%0Aplt.plot(t, data%5B1,:%5D, 'g')%0Aplt.axis(%5Bt_min, t_max, -8192, 8192%5D)%0Aplt.xlabel('Time (us)'
 )%0Apl

fix oscillo test.py