66 lines
1.4 KiB
Python
Executable File
66 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import sys
|
|
from pathlib import Path
|
|
# Add import path for inplace usage
|
|
sys.path.insert(0, str(Path(__file__).absolute().parents[1]))
|
|
|
|
from frappy.client.interactive import Client
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
from frappy_psi.iqplot import Pause
|
|
|
|
|
|
if len(sys.argv) < 2:
|
|
print("""
|
|
Usage:
|
|
|
|
us-plot <end> [<start> [<npoints>]]
|
|
|
|
end: end of window [ns]
|
|
start: start of window [n2], default: 0
|
|
npoints: number fo points (default 1000)
|
|
""")
|
|
sys.exit(0)
|
|
|
|
Client('pc13252:5000')
|
|
|
|
|
|
def plot(array, ax, style, xs):
|
|
xaxis = np.arange(len(array)) * xs
|
|
return ax.plot(xaxis, array, style)[0]
|
|
|
|
|
|
def update(array, line, xs):
|
|
xaxis = np.arange(len(array)) * xs
|
|
line.set_data(np.array([xaxis, array]))
|
|
|
|
def on_close(event):
|
|
sys.exit(0)
|
|
|
|
start = 0
|
|
end = float(sys.argv[1])
|
|
npoints = 1000
|
|
if len(sys.argv) > 2:
|
|
start = float(sys.argv[2])
|
|
if len(sys.argv) > 3:
|
|
npoints = float(sys.argv[3])
|
|
|
|
fig, ax = plt.subplots(figsize=(15,3))
|
|
pause = Pause(fig)
|
|
try:
|
|
get_signal = iq.get_signal
|
|
print('plotting RUS signal')
|
|
except NameError:
|
|
get_signal = u.get_signal
|
|
print('plotting PE signal')
|
|
|
|
xs, signal = get_signal(start, end, npoints)
|
|
|
|
lines = [plot(s, ax, '-', xs) for s in signal]
|
|
|
|
while pause(0.5):
|
|
plt.draw()
|
|
xs, signal = get_signal(start, end, npoints)
|
|
for line, sig in zip(lines, signal):
|
|
update(sig, line, xs)
|