From ae212f84fa1c4f7fe9c7966a17b943bc05c75732 Mon Sep 17 00:00:00 2001 From: kparasch Date: Mon, 2 Nov 2026 14:12:25 +0100 Subject: [PATCH 1/2] fix diagnostic and tool paths --- .../use_cases/chromaticity-measurement.py | 2 +- docs/tutorials/use_cases/orbit_correction.py | 20 ++++++++-------- docs/tutorials/use_cases/tune-correction.py | 24 +++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/tutorials/use_cases/chromaticity-measurement.py b/docs/tutorials/use_cases/chromaticity-measurement.py index 23ee0da..d353276 100644 --- a/docs/tutorials/use_cases/chromaticity-measurement.py +++ b/docs/tutorials/use_cases/chromaticity-measurement.py @@ -99,7 +99,7 @@ def chroma_callback(action: int, cb_data: dict): return True # %% -chroma_monitor = SR.get_chromaticity_monitor("CHROMATICITY_MONITOR") +chroma_monitor = SR.tool.get("CHROMATICITY_MONITOR") # Measure the chromaticity chroma_monitor.measure( diff --git a/docs/tutorials/use_cases/orbit_correction.py b/docs/tutorials/use_cases/orbit_correction.py index f8e0898..0f18ef9 100644 --- a/docs/tutorials/use_cases/orbit_correction.py +++ b/docs/tutorials/use_cases/orbit_correction.py @@ -75,7 +75,7 @@ # -------------------------------- # Get BPMs -bpms = SR.bpms.get("BPM") +bpms = SR.diagnostic.bpms.get("BPM") # Get correctors hcorr = SR.magnets.get("HCorr") @@ -90,24 +90,24 @@ # The ORM can be saved in multiple formats. Load it into ``SR.orbit`` before correcting. # Print string representation of the orbit response matrix -print(SR.orm) +print(SR.tool.orm) # %% # Measure the ORM # ~~~~~~~~~~~~~~~~~~~~ -SR.orm.measure(sleep_between_step=wait_time) -SR.orm.save("orm.json") -SR.orm.save("orm.yaml", with_type="yaml") +SR.tool.orm.measure(sleep_between_step=wait_time) +SR.tool.orm.save("orm.json") +SR.tool.orm.save("orm.yaml", with_type="yaml") -SR.orbit.load("orm.json") +SR.tool.orbit.load("orm.json") print("ORM measured, saved and loaded.") # %% # Visualise the ORM # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -orm_data = SR.orm.get() +orm_data = SR.tool.orm.get() plt.imshow(np.array(orm_data["matrix"])) plt.colorbar() plt.title("Orbit response matrix") @@ -136,8 +136,8 @@ def disp_callback(action: int, cb_data) -> bool: return True # Measure the dispersion -SR.dispersion.measure(callback=disp_callback) -disp_data = SR.dispersion.get() +SR.tool.dispersion.measure(callback=disp_callback) +disp_data = SR.tool.dispersion.get() # Plot the results plt.plot(disp_data["frequency_response_x"], label="H dispersion") @@ -195,7 +195,7 @@ def disp_callback(action: int, cb_data) -> bool: # - **RF correction:** also adjusts the RF frequency to minimise dispersion-driven orbit. # Standard correction -SR.orbit.correct(reference=reference) +SR.tool.orbit.correct(reference=reference) # With virtual corrector weight (ESRF style): # SR.orbit.set_virtual_weight(1000) diff --git a/docs/tutorials/use_cases/tune-correction.py b/docs/tutorials/use_cases/tune-correction.py index 983b8e0..c28c449 100644 --- a/docs/tutorials/use_cases/tune-correction.py +++ b/docs/tutorials/use_cases/tune-correction.py @@ -74,7 +74,7 @@ # The tune monitor is defined in the configuration file under the name `BETATRON_TUNE`. # %% -tune_monitor = SR.get_betatron_tune_monitor("BETATRON_TUNE") +tune_monitor = SR.diagnostic.get("BETATRON_TUNE") # Print the string representation of the tune monitor print(tune_monitor) @@ -120,7 +120,7 @@ # Before correcting the tune you need a response matrix. It can be measured as shown below or loaded from a previously saved file. # Print the string representation of the tune correction tool -SR.tune +SR.tool.tune # %% # Measure the Tune Response Matrix @@ -139,15 +139,15 @@ def tune_callback(action: int, cb_data: dict): return True # Measure the response matrix -SR.trm.measure(sleep_between_step=wait_time, callback=tune_callback) -SR.trm.save("trm.json") +SR.tool.trm.measure(sleep_between_step=wait_time, callback=tune_callback) +SR.tool.trm.save("trm.json") # Load the measured response matrix -SR.tune.load("trm.json") +SR.tool.tune.load("trm.json") print("Response matrix loaded.") # Print string representation of the tune response matrix -print(SR.trm) +print(SR.tool.trm) # %% # Correcting the tune @@ -157,17 +157,17 @@ def tune_callback(action: int, cb_data: dict): # The ``iter`` parameter controls the number of iterations and ``wait_time`` the settling time between each iteration. # %% -print(f"Tune before correction: {SR.tune.readback()}") +print(f"Tune before correction: {SR.tool.tune.readback()}") qx, qy = 0.19, 0.28 print(f"\nSetting tune to [{qx}, {qy}]") -SR.tune.set([qx, qy], iter=10, wait_time=wait_time) -print(f"Tune after correction: {SR.tune.readback()}") +SR.tool.tune.set([qx, qy], iter=10, wait_time=wait_time) +print(f"Tune after correction: {SR.tool.tune.readback()}") qx, qy = 0.21, 0.30 print(f"\nSetting tune to [{qx}, {qy}]") -SR.tune.set([qx, qy], iter=10, wait_time=wait_time) -print(f"Tune after correction: {SR.tune.readback()}") +SR.tool.tune.set([qx, qy], iter=10, wait_time=wait_time) +print(f"Tune after correction: {SR.tool.tune.readback()}") # Print the string representation of the tune correction -SR.tune +SR.tool.tune From 8c4dc3a0177d51e7b4af9d205490a0cfc6c6c30e Mon Sep 17 00:00:00 2001 From: Alexis Gamelin Date: Mon, 2 Nov 2026 15:41:23 +0100 Subject: [PATCH 2/2] Made a pass to fix the same issue at other locations --- docs/source/explanation/architecture.md | 2 +- docs/source/explanation/control-modes.md | 6 +++--- .../how-to/configuration/create-configuration.md | 6 +++--- docs/tutorials/use_cases/orbit_correction.py | 10 +++++----- docs/tutorials/use_cases/tune-correction.py | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/source/explanation/architecture.md b/docs/source/explanation/architecture.md index 73b053f..3605ba4 100644 --- a/docs/source/explanation/architecture.md +++ b/docs/source/explanation/architecture.md @@ -84,7 +84,7 @@ quads = accelerator.design.magnets.get("QForTune") k = quads.strengths.get() # numpy array, one value per magnet quads.strengths.set(k * 1.001) -orbit = accelerator.design.bpms.get("BPM").positions.get() +orbit = accelerator.design.diagnostic.bpms.get("BPM").positions.get() ``` Arrays are also how high-level tools know which elements to use: a tune correction tool, for example, is configured with the *name* of the quadrupole array it should act on. diff --git a/docs/source/explanation/control-modes.md b/docs/source/explanation/control-modes.md index 942be2a..a03b0d8 100644 --- a/docs/source/explanation/control-modes.md +++ b/docs/source/explanation/control-modes.md @@ -57,7 +57,7 @@ Since every mode exposes the same elements, arrays and tools, a script can be wr ```python def correct_tune(sr): - accelerator.tune.set([0.2, 0.3]) + sr.tool.tune.set([0.2, 0.3]) correct_tune(accelerator.design) # Try it on the simulator first correct_tune(accelerator.live) # Then run it on the machine @@ -73,8 +73,8 @@ Different modes can also be used side by side, for example to compare the measur ```python delta = ( - accelerator.live.bpms.get("BPM").positions.get() - - accelerator.design.bpms.get("BPM").positions.get() + accelerator.live.diagnostic.bpms.get("BPM").positions.get() + - accelerator.design.diagnostic.bpms.get("BPM").positions.get() ) ``` diff --git a/docs/source/how-to/configuration/create-configuration.md b/docs/source/how-to/configuration/create-configuration.md index a287b0c..40f1314 100644 --- a/docs/source/how-to/configuration/create-configuration.md +++ b/docs/source/how-to/configuration/create-configuration.md @@ -31,7 +31,7 @@ Before writing an item, look up the constructor parameters of the class you want For example: ```python - from pyaml.bpm.bpm import BPM + from pyaml.diagnostics.bpm.bpm import BPM help(BPM) # class BPM(...) @@ -115,7 +115,7 @@ devices: class: pyaml.magnet.identity_model.IdentityMagnetModel unit: 1/m physics: AN01-AR/EM-QP/QD.01/magnetic_strength - - class: pyaml.bpm.bpm.BPM + - class: pyaml.diagnostics.bpm.bpm.BPM name: BPM_001 x_pos: AN01-AR/DG-EPOS/BPM.01/x y_pos: AN01-AR/DG-EPOS/BPM.01/y @@ -170,7 +170,7 @@ devices: class: pyaml.magnet.identity_model.IdentityMagnetModel unit: 1/m physics: AN01-AR/EM-QP/QD.01/magnetic_strength - - class: pyaml.bpm.bpm.BPM + - class: pyaml.diagnostics.bpm.bpm.BPM name: BPM_001 x_pos: AN01-AR/DG-EPOS/BPM.01/x y_pos: AN01-AR/DG-EPOS/BPM.01/y diff --git a/docs/tutorials/use_cases/orbit_correction.py b/docs/tutorials/use_cases/orbit_correction.py index 0f18ef9..16482bf 100644 --- a/docs/tutorials/use_cases/orbit_correction.py +++ b/docs/tutorials/use_cases/orbit_correction.py @@ -87,7 +87,7 @@ # Orbit Response Matrix # --------------------- # -# The ORM can be saved in multiple formats. Load it into ``SR.orbit`` before correcting. +# The ORM can be saved in multiple formats. Load it into ``SR.tool.orbit`` before correcting. # Print string representation of the orbit response matrix print(SR.tool.orm) @@ -187,7 +187,7 @@ def disp_callback(action: int, cb_data) -> bool: # Correct the Orbit # ------------------ # -# Standard correction: ``SR.orbit.correct(reference=reference)``. +# Standard correction: ``SR.tool.orbit.correct(reference=reference)``. # # Optional variants (uncomment to use): # @@ -198,11 +198,11 @@ def disp_callback(action: int, cb_data) -> bool: SR.tool.orbit.correct(reference=reference) # With virtual corrector weight (ESRF style): -# SR.orbit.set_virtual_weight(1000) -# SR.orbit.correct(reference=reference) +# SR.tool.orbit.set_virtual_weight(1000) +# SR.tool.orbit.correct(reference=reference) # With RF orbit correction (ESRF style, requires dispersion in ORM): -# SR.orbit.correct(reference=reference, rf=True) +# SR.tool.orbit.correct(reference=reference, rf=True) sleep(wait_time) diff --git a/docs/tutorials/use_cases/tune-correction.py b/docs/tutorials/use_cases/tune-correction.py index c28c449..4fcbff9 100644 --- a/docs/tutorials/use_cases/tune-correction.py +++ b/docs/tutorials/use_cases/tune-correction.py @@ -115,7 +115,7 @@ # Tune Correction # ----------------------------- # -# ``SR.tune`` is the `DEFAULT_TUNE_CORRECTION` tool. ``SR.trm`` is the `DEFAULT_TUNE_RESPONSE_MATRIX` tool. +# ``SR.tool.tune`` is the `DEFAULT_TUNE_CORRECTION` tool. ``SR.tool.trm`` is the `DEFAULT_TUNE_RESPONSE_MATRIX` tool. # # Before correcting the tune you need a response matrix. It can be measured as shown below or loaded from a previously saved file. @@ -153,7 +153,7 @@ def tune_callback(action: int, cb_data: dict): # Correcting the tune # ----------------------------- # -# ``SR.tune.set([qx, qy])`` runs the correction iteratively. +# ``SR.tool.tune.set([qx, qy])`` runs the correction iteratively. # The ``iter`` parameter controls the number of iterations and ``wait_time`` the settling time between each iteration. # %%