tune_response_matrix#

class ConfigModel(*, name, description=None, lattice_names=None, n_step=1, sleep_between_step=0, n_avg_meas=1, sleep_between_meas=0, quad_array_name, betatron_tune_name, quad_delta)[source]#

Bases: MeasurementToolConfigModel

Configuration model for Tune response matrix

Parameters:
  • quad_array_name (str) – Array name of quad used to adjust the tune

  • betatron_tune_name (str) – Name of the diagnostic pyaml device for measuring the tune

  • quad_delta (float) – Delta strength used to get the response matrix

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

betatron_tune_name: str#
quad_array_name: str#
quad_delta: float#
class TuneResponseMatrix(cfg)[source]#

Bases: MeasurementTool

measure(quad_delta=None, n_step=None, sleep_between_step=None, n_avg_meas=None, sleep_between_meas=None, callback=None)[source]#

Measure tune response matrix. latest_measurement contains:

matrix:list[list[float] # The response matrix
variable_names:list[str] # Variable names
observable_names:list[str] # Observables names

Example

from pyaml.accelerator import Accelerator
from pyaml.common.constants import Action

def callback(action: Action, data:dict):
    print(f"{action}, data:{data}")
    return True

sr = Accelerator.load("tests/config/EBSTune.yaml")
acc = sr.design

if acc.trm.measure(n_avg_meas=3,sleep_between_meas=5,callback=callback):
    acc.trm.save("ideal_trm.json")
    acc.trm.save("ideal_trm.yaml", with_type="yaml")
    acc.trm.save("ideal_trm.npz", with_type="npz")
Parameters:
  • quad_delta (float) – Delta strength used to get the response matrix

  • n_step (int, optional) – Number of step for fitting the tune slope [-quad_delta/n_step..quad_delta/n_step] Default from config

  • sleep_between_step (float) – Default time sleep after quad exitation Default: from config

  • n_avg_meas (int, optional) – Default number of tune measurement per step used for averaging Default from config

  • sleep_between_meas (float) – Default time sleep between two tune measurment Default: from config

  • callback (Callable, optional) –

    Callback executed after each strength setting or measurement. See send_callback(). If the callback return false, then the scan is aborted and strength restored. callback_data dict contains:

    source:MeasurementTool # Tool that triggered the callback
    idx:int # The index in the element array being processed
    step:int # The current step
    avg_step:int # The current avg step
    magnet:str # The magnet being excited
    strength:float # Magnet strength
    tune:np.array # The measured tune (on Action.MEASURE)
    dtune:np.array # The tune variation (on Action.RESTORE)