Skip to content

Added convenience function for meas tool - #421

Merged
JeanLucPons merged 2 commits into
mainfrom
add-convenience-function-for-meastool
Sep 15, 2026
Merged

JeanLucPons merged 2 commits into
mainfrom
add-convenience-function-for-meastool

Conversation

@JeanLucPons

@JeanLucPons JeanLucPons commented Sep 15, 2026

Copy link
Copy Markdown
Member

This PR add 2 convenience functions to retrieve handle to measurement tool from callback.
It allows to add metadata in a more convenient way.
It also add a new event (INIT) when the scan starts.

ex (Add tune measurement at each orm measurement step):

from pyaml.common.constants import Action
from pyaml.accelerator import Accelerator
from pyaml.tuning_tools.measurement_tool import MeasurementTool
import numpy as np
import matplotlib.pyplot as plt

# Load the accelerator
sr = Accelerator.load("/home/esrf/pons/pyaml/examples/use_cases/config/bessy2/bessy2.yaml")

# ORM callback
def orbit_callback(action: int, cdata):

    if action == Action.INIT:

        MeasurementTool.get_from_cb(cdata).latest_measurement["tune"] = []

    elif action == Action.MEASURE:

        # Add additionnal data to the scan
        tune = MeasurementTool.get_peer_from_cb(cdata).tune.readback()
        MeasurementTool.get_from_cb(cdata).latest_measurement["tune"].append(tune.tolist())

    return True


# Start scan
sr.design.orm.measure(callback=orbit_callback)
# Save measurement data including additionnal metadata
sr.design.orm.save("mat.json") 

@JeanLucPons
JeanLucPons merged commit a519166 into main Sep 15, 2026
4 checks passed
@JeanLucPons
JeanLucPons deleted the add-convenience-function-for-meastool branch September 15, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants