-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update 00-base.py with the approach used in bluesky/tutorials (no nsl…
…sii.configure_base())
- Loading branch information
Showing
1 changed file
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,67 @@ | ||
import os | ||
import matplotlib | ||
from IPython import get_ipython | ||
get_ipython().run_line_magic('matplotlib', 'notebook') # i.e. %matplotlib notebook | ||
|
||
import nslsii | ||
nslsii.configure_base(get_ipython().user_ns, 'amx', bec=True, mpl=True, pbar=False) | ||
# nslsii.configure_olog(get_ipython().user_ns, subscribe=False) | ||
get_ipython().run_line_magic('matplotlib', 'widget') # i.e. %matplotlib widget | ||
import matplotlib.pyplot | ||
|
||
from ophyd import Device, Component, EpicsSignal | ||
from ophyd.signal import EpicsSignalBase | ||
from ophyd.areadetector.filestore_mixins import resource_factory | ||
import uuid | ||
import os | ||
from pathlib import Path | ||
import numpy as np | ||
|
||
# Set up a RunEngine and use metadata backed by a sqlite file. | ||
from bluesky import RunEngine | ||
from bluesky.utils import get_history | ||
RE = RunEngine(get_history()) | ||
|
||
# Set up SupplementalData. | ||
from bluesky import SupplementalData | ||
sd = SupplementalData() | ||
RE.preprocessors.append(sd) | ||
|
||
# Set up a Broker. | ||
from databroker import Broker | ||
db = Broker.named('amx') | ||
|
||
# and subscribe it to the RunEngine | ||
RE.subscribe(db.insert) | ||
|
||
# Add a progress bar. | ||
# from bluesky.utils import ProgressBarManager | ||
# pbar_manager = ProgressBarManager() | ||
# RE.waiting_hook = pbar_manager | ||
|
||
# Register bluesky IPython magics. | ||
from bluesky.magics import BlueskyMagics | ||
get_ipython().register_magics(BlueskyMagics) | ||
|
||
# Set up the BestEffortCallback. | ||
from bluesky.callbacks.best_effort import BestEffortCallback | ||
bec = BestEffortCallback() | ||
RE.subscribe(bec) | ||
peaks = bec.peaks | ||
|
||
# Import matplotlib and put it in interactive mode. | ||
import matplotlib.pyplot as plt | ||
plt.ion() | ||
|
||
# Make plots update live while scans run. | ||
from bluesky.utils import install_nb_kicker | ||
install_nb_kicker() | ||
|
||
# convenience imports | ||
# some of the * imports are for 'back-compatibility' of a sort -- we have | ||
# taught BL staff to expect LiveTable and LivePlot etc. to be in their | ||
# namespace | ||
import numpy as np | ||
|
||
import bluesky.plans as bp | ||
import bluesky.plan_stubs as bps | ||
import bluesky.preprocessors as bpp | ||
|
||
#Optional: set any metadata that rarely changes. | ||
RE.md['beamline_id'] = 'AMX' |