measurement_tool#
- class MeasurementToolConfigModel(*, name, description=None, lattice_names=None, n_step=1, sleep_between_step=0, n_avg_meas=1, sleep_between_meas=0)[source]#
Bases:
ElementConfigModelMeasurement tool configuration model
- Parameters:
n_step (int, optional) – Number of measurement step [-delta/n_step..delta/n_step] Default 1
sleep_between_step (float, optional) – Default sleep time after an actuator excitation Default: 0
n_avg_meas (int, optional) – Default number of measurement per step used for averaging Default 1
sleep_between_meas (float, optional) – Default sleep time between two measurments Default: 0
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.
- class MeasurementTool(name)[source]#
Bases:
ElementBase class for measurement tool such as reponse matrix measurement or other scans.
- attach(peer)[source]#
Create a new reference to attach this measurement tool object to a simulator or a control system.
- get()[source]#
Return last measurement data, a dictionary containing last measurement data. See sub class of MeasurementTool to get description.
- Returns:
dict – Return latest measurement or None
- abstractmethod measure()[source]#
Launch measurement :Returns: bool – True if the process has been aborted
- save(save_path, with_type='json')[source]#
Save measurement data
- Parameters:
save_path (Path) – Matrix filename
with_type (str) – File type (json,yaml,npz)
- send_callback(action, cb_data, raiseException=True)[source]#
Send callback from this Measurement tool to the caller. If the callback returns False, the scan is aborted and actuators are restored to their orignal values. Callback example:
def callback(action: Action, data: dict): print(f"{action}, data:{data}") return True # Measure a tune response matrix using the above callback sr.design.trm.measure(callback=callback)
- Parameters:
action (Action) – See
pyaml.common.constants.Actioncb_data (dict) – Callback data