Created
March 16, 2023 21:14
-
-
Save gwbischof/afe58eee621b646cf1ed4b74c65b1b98 to your computer and use it in GitHub Desktop.
ophyd device plotter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_ophyd_device(device, dont_plot={'ramp_rate'}): | |
''' | |
Plot all of the signals of an ophyd device. | |
There is probably some inaccuracy of the timestamps. | |
Simple implementation. | |
''' | |
history = {signal: [getattr(device, signal).get()] | |
for signal in set(device.component_names) - dont_plot} | |
history['timestamp'] = [time.time()] | |
print(set(device.component_names) - dont_plot) | |
def update(i): | |
history['timestamp'].append(time.time()) | |
x = history['timestamp'] | |
plt.cla() | |
for signal in set(device.component_names) - dont_plot: | |
history[signal].append(getattr(device, signal).get()) | |
plt.plot(x, history[signal]) | |
plt.xlabel('time') | |
plt.ylabel('value') | |
plt.title(device.name) | |
plt.gcf().autofmt_xdate() | |
plt.tight_layout() | |
ani = FuncAnimation(plt.gcf(), update, 1000) | |
plt.tight_layout() | |
plt.show(block=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment