Skip to content

Commit

Permalink
Merge pull request #1 from BNL-ATF/add-baseline
Browse files Browse the repository at this point in the history
Add baseline configuration & Sirepo/MAD-X updates
  • Loading branch information
mrakitin authored Aug 16, 2023
2 parents cc8e3ab + 5bbdc40 commit 915d664
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.9", "3.10"]
pylon-version: ["5.2.0.13457-deb0_amd64"]
fail-fast: false
env:
Expand Down
27 changes: 22 additions & 5 deletions startup/10-devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from atfdb import atfdb
from atfdb.ophyd import ATFSignalNoConn, ReadOnlyException, open_close_conn
from bluesky import SupplementalData
from ophyd import Component as Cpt
from ophyd import Device, Signal
from ophyd.sim import NullStatus
Expand Down Expand Up @@ -47,7 +48,7 @@ def check_conn_once(envvar="ATF_OPEN_CONN_ONCE"):
"HT1V": "DARL2",
"HT2H": "DARL3",
"HT2V": "DARL4",
"HQ1": "DARL149",
"HQ1": "DARL149", # 'ihq1' in Sirepo
"HQ2": "DARL150",
"HQ3": "DARL151",
"HT3H": "DARL9",
Expand Down Expand Up @@ -195,7 +196,17 @@ class FrameGrabber(Device):
fg3 = FrameGrabber(name="fg3")


for el_id in ["TK1H", "GT9V", "GT10V", "GQ10", "GQ11", "GQ12", "HeNe1"]:
for el_id in [
"GQ10",
"GQ11",
"GQ12",
"GT10V",
"GT9V",
"HQ1",
"HT2V",
"HeNe1",
"TK1H",
]:
el = channel_dict[el_id]
channel_dict[el_id]["ophyd"] = ATFSignal(
name=f"{el_id}_{el['name']}", # ophyd API
Expand All @@ -205,10 +216,16 @@ class FrameGrabber(Device):
timeout=3.0 if el_id == "TK1H" else 2.0,
)

TK1H = channel_dict["TK1H"]["ophyd"]
GT9V = channel_dict["GT9V"]["ophyd"]
GT10V = channel_dict["GT10V"]["ophyd"]
GQ10 = channel_dict["GQ10"]["ophyd"]
GQ11 = channel_dict["GQ11"]["ophyd"]
GQ12 = channel_dict["GQ12"]["ophyd"]
GT10V = channel_dict["GT10V"]["ophyd"]
GT9V = channel_dict["GT9V"]["ophyd"]
HQ1 = channel_dict["HQ1"]["ophyd"]
HT2V = channel_dict["HT2V"]["ophyd"]
HeNe1 = channel_dict["HeNe1"]["ophyd"]
TK1H = channel_dict["TK1H"]["ophyd"]

sd = SupplementalData()
RE.preprocessors.append(sd)
sd.baseline.extend([GQ10, GQ11, GQ12])
42 changes: 25 additions & 17 deletions startup/20-madx.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@

print(f"Using Sirepo at {ATF_SIREPO_URL}")
connection = SirepoBluesky(ATF_SIREPO_URL)
data, schema = connection.auth("madx", "00000002")
data, schema = connection.auth("madx", "00000002") # BL2_TDC example

classes, objects = create_classes(connection.data, connection=connection)
classes, objects = create_classes(
connection=connection,
extra_model_fields=["rpnVariables", "commands", "elements"],
)
globals().update(**objects)

madx_flyer = MADXFlyer(
Expand All @@ -32,18 +35,23 @@
report="elementAnimation250-20",
)

# RE(bp.fly([madx_flyer]))
#
# hdr = db["2c8504e4-8ac9-4e56-ab42-da5e3cb9b4e0"]
# hdr.table(stream_name="madx_flyer", fill=True)
#
# def madx_plan():
# yield from bps.mv(fq1.k1, "ifq1/5.4444e-3/hr")
# yield from bp.fly([madx_flyer])
#
# RE(madx_plan())
#
# hdr2 = db["a3ed4aea-068e-4b15-85f7-3abdcf5cccc2"]
#
# hdr.table(stream_name="madx_flyer", fill=True).loc[21]
# hdr2.table(stream_name="madx_flyer", fill=True).loc[21]
def madx_plan(parameter="ihq1", value=2.0):
"""A bluesky plan to use MAD-X simulation package within Sirepo (via sirepo-bluesky lib).
Run:
uid, = RE(madx_plan())
Data access:
hdr = db[uid]
tbl = hdr.table(stream_name="madx_flyer", fill=True)
Plotting:
plt.plot(tbl['madx_flyer_S'], tbl['madx_flyer_BETX'])
plt.plot(tbl['madx_flyer_S'], tbl['madx_flyer_BETY'])
"""
yield from bps.mv(objects[parameter].value, value)
return (yield from bp.fly([madx_flyer]))

0 comments on commit 915d664

Please sign in to comment.