Install bluesky-widgets, an experimental new package.
pip install bluesky-widgets
Download the example and enter the directory.
git clone https://gist.github.com/AbbyGi/38b44e89ccd55f392be0dc9921820894 aps_polar_example
cd aps_polar_example
Start IPython with a Qt GUI
ipython --gui=qt
from aps_polar_example import AutoXanesPlot
from bluesky_widgets.qt.figures import QtFigures
import databroker
# Use the new, experimental "v2" interface to databroker.
catalog = databroker.Broker.named('mongodb_config').v2
# Create our "auto plot builder" and a view for it.
model = AutoXanesPlot()
view = QtFigures(model.figures)
view.show() # An empty GUI window should appear.
# View some scans. (These are the ones you shared as example data back on 4 Dec.)
model.add_run(catalog[75])
model.add_run(catalog[91])
model.add_run(catalog[153])
Try adding any other scans you like. Let us know what happens!
Start IPython with a Qt GUI
ipython --gui=qt
This assumes that you have already defined a RunEngine instance, RE
.
from aps_polar_example import AutoXanesPlot
from bluesky_widgets.qt.figures import QtFigures
from bluesky_widgets.utils.streaming import stream_documents_into_runs
model = AutoXanesPlot()
view = QtFigures(model.figures)
view.show() # An empty GUI window should appear.
RE.subscribe(stream_documents_into_runs(model.add_run))
# Now take data with RE.
RE(...)
For applicable scans, plots should appear in the GUI window, and they should update in real time during data acquisition.
A key feature of bluesky-widgets in that this all works in Jupyter (and soon, in other GUI and visualization frameworks) with very minor changes.
First, you'll need to make your have ipympl installed to support interactive matplotlib plotting in Jupyter.
Then, referring to the examples above, replace:
from bluesky_widgets.qt.figures import QtFigures
...
view = QtFigures(model.figures)
view.show() # An empty GUI window should appear.
with
from bluesky_widgets.jupyter.figures import JupyterFigures
...
view = JupyterFigures(model.figures)
view # Place this at the bottom of a cell in the notebook.
An interactive plot should appear in the output.
For the record, this is how we tested it with example data.
pip install databroker-unpack
databroker-unpack inplace exported_scans POLAR-example
ipython --gui=qt
from aps_polar_example import view_example_data
catalog, model = view_example_data("POLAR-example")