From f80eda762026379905c9143618cea5bff8156ff9 Mon Sep 17 00:00:00 2001 From: Maksim Rakitin Date: Wed, 12 Oct 2022 14:20:14 -0400 Subject: [PATCH 1/9] Add baseline configuration --- startup/10-devices.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/startup/10-devices.py b/startup/10-devices.py index e9f9e98..f77722f 100644 --- a/startup/10-devices.py +++ b/startup/10-devices.py @@ -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 @@ -212,3 +213,7 @@ class FrameGrabber(Device): GQ11 = channel_dict["GQ11"]["ophyd"] GQ12 = channel_dict["GQ12"]["ophyd"] HeNe1 = channel_dict["HeNe1"]["ophyd"] + +sd = SupplementalData() +RE.preprocessors.append(sd) +sd.baseline.extend([GQ10, GQ11, GQ12]) From 388a1378c4a38035c2dac5d9d3dd26915084f2b8 Mon Sep 17 00:00:00 2001 From: Maksim Rakitin Date: Wed, 12 Oct 2022 17:52:48 -0400 Subject: [PATCH 2/9] Add more ophyd objects for ATF hardware --- startup/10-devices.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/startup/10-devices.py b/startup/10-devices.py index f77722f..53b31cb 100644 --- a/startup/10-devices.py +++ b/startup/10-devices.py @@ -48,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", @@ -196,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 @@ -206,13 +216,15 @@ 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) From 3f8142c4c3428a9e4b30e232904d19bf6e001a18 Mon Sep 17 00:00:00 2001 From: Maksim Rakitin Date: Wed, 12 Oct 2022 17:53:28 -0400 Subject: [PATCH 3/9] Add `madx_plan` with the docstring on how to use it --- startup/20-madx.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/startup/20-madx.py b/startup/20-madx.py index a80ee01..9eb8600 100644 --- a/startup/20-madx.py +++ b/startup/20-madx.py @@ -32,18 +32,24 @@ 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(bp.fly([madx_flyer])) + + 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_var[parameter].value, value) + return (yield from bp.fly([madx_flyer])) From 29072a2c75654768e4f9c85d515fcfe47f3c6b4f Mon Sep 17 00:00:00 2001 From: Maksim Rakitin Date: Wed, 12 Oct 2022 18:35:55 -0400 Subject: [PATCH 4/9] Update docstring with correct plan to pass to RE --- startup/20-madx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startup/20-madx.py b/startup/20-madx.py index 9eb8600..0e880e0 100644 --- a/startup/20-madx.py +++ b/startup/20-madx.py @@ -38,7 +38,7 @@ def madx_plan(parameter="ihq1", value=2.0): Run: - uid, = RE(bp.fly([madx_flyer])) + uid, = RE(madx_plan()) Data access: From e3b44d3b3ca1c62b169ea312da3d2f7b846ad48d Mon Sep 17 00:00:00 2001 From: Maksim Rakitin Date: Tue, 6 Dec 2022 16:39:10 -0500 Subject: [PATCH 5/9] Add `commands` and `elements` to the list of model fields; use example 2 (BL2_TDC) --- startup/20-madx.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/startup/20-madx.py b/startup/20-madx.py index 0e880e0..b20a26d 100644 --- a/startup/20-madx.py +++ b/startup/20-madx.py @@ -21,9 +21,11 @@ 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.data, + connection=connection, + extra_model_fields=["rpnVariables", "commands", "elements"]) globals().update(**objects) madx_flyer = MADXFlyer( From b41f26f1a7121174a05fcbacc945a7affc82c51e Mon Sep 17 00:00:00 2001 From: Maksim Rakitin Date: Thu, 15 Dec 2022 19:40:44 -0500 Subject: [PATCH 6/9] We do not use `objects_var` variable anymore --- startup/20-madx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startup/20-madx.py b/startup/20-madx.py index b20a26d..55332ce 100644 --- a/startup/20-madx.py +++ b/startup/20-madx.py @@ -53,5 +53,5 @@ def madx_plan(parameter="ihq1", value=2.0): plt.plot(tbl['madx_flyer_S'], tbl['madx_flyer_BETY']) """ - yield from bps.mv(objects_var[parameter].value, value) + yield from bps.mv(objects[parameter].value, value) return (yield from bp.fly([madx_flyer])) From af1b7107649459cc5053ffb46a3ea9ab4cb72e08 Mon Sep 17 00:00:00 2001 From: Maksim Rakitin Date: Thu, 15 Jun 2023 11:15:08 -0400 Subject: [PATCH 7/9] STY: fix formatting with `black` --- startup/10-devices.py | 20 ++++++++++---------- startup/20-madx.py | 9 +++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/startup/10-devices.py b/startup/10-devices.py index 53b31cb..8fa7033 100644 --- a/startup/10-devices.py +++ b/startup/10-devices.py @@ -197,16 +197,16 @@ class FrameGrabber(Device): for el_id in [ - "GQ10", - "GQ11", - "GQ12", - "GT10V", - "GT9V", - "HQ1", - "HT2V", - "HeNe1", - "TK1H", - ]: + "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 diff --git a/startup/20-madx.py b/startup/20-madx.py index 55332ce..6f80715 100644 --- a/startup/20-madx.py +++ b/startup/20-madx.py @@ -23,9 +23,11 @@ connection = SirepoBluesky(ATF_SIREPO_URL) data, schema = connection.auth("madx", "00000002") # BL2_TDC example - classes, objects = create_classes(connection.data, - connection=connection, - extra_model_fields=["rpnVariables", "commands", "elements"]) + classes, objects = create_classes( + connection.data, + connection=connection, + extra_model_fields=["rpnVariables", "commands", "elements"], + ) globals().update(**objects) madx_flyer = MADXFlyer( @@ -34,7 +36,6 @@ report="elementAnimation250-20", ) - def madx_plan(parameter="ihq1", value=2.0): """A bluesky plan to use MAD-X simulation package within Sirepo (via sirepo-bluesky lib). From 0057515ab4841bbe730aa8a39217c48f95d10b59 Mon Sep 17 00:00:00 2001 From: Ambar Date: Tue, 15 Aug 2023 12:19:48 -0400 Subject: [PATCH 8/9] CI: add Python 3.10 to the test matrix --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index aba6941..cd4602f 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -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: From 5bbdc4029f92b824d284a93ad3ec2e9f4d47cb83 Mon Sep 17 00:00:00 2001 From: Ambar Date: Tue, 15 Aug 2023 13:33:40 -0400 Subject: [PATCH 9/9] MNT: sirepo-bluesky's `create_classes` API change --- startup/20-madx.py | 1 - 1 file changed, 1 deletion(-) diff --git a/startup/20-madx.py b/startup/20-madx.py index 6f80715..b72f50a 100644 --- a/startup/20-madx.py +++ b/startup/20-madx.py @@ -24,7 +24,6 @@ data, schema = connection.auth("madx", "00000002") # BL2_TDC example classes, objects = create_classes( - connection.data, connection=connection, extra_model_fields=["rpnVariables", "commands", "elements"], )