File: scope_mode_generator.py

package info (click to toggle)
wxmplot 0.9.58-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,052 kB
  • sloc: python: 10,085; makefile: 88; sh: 2
file content (25 lines) | stat: -rw-r--r-- 680 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import numpy as np
from wxmplot.interactive import plot, set_data_generator

# generator of datasets
npts = 501
x = np.linspace(0, 50, npts)
datasets = ((np.cos(1.3*x) + np.sin(0.8*(x+nx/7)),
             np.cos(1.1*x) - np.sin(0.6*(x+nx/43)))
            for nx in range(npts))

def more_data():
    """yield next pair of datasets from data generator"""
    while True:
        try:
            ds = next(datasets)
            yield [(x, ds[0]), (x, ds[1])]
        except StopIteration:
            break

# set up an initial plot
plot(x, np.zeros(len(x)))

# now set data generator and wait
set_data_generator(more_data,  polltime=30)
print("consuming data from generator...")