Skip to content

Feature IDs interface - #527

Draft
gubaidulinvadim wants to merge 11 commits into
mainfrom
feature-ids-interface
Draft

gubaidulinvadim wants to merge 11 commits into
mainfrom
feature-ids-interface

Conversation

@gubaidulinvadim

@gubaidulinvadim gubaidulinvadim commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

This PR should allow an insertion device interface for pyAML that allows control of gap/phase or current (for electromagnetic IDs). It is flexible enough to cover several types of IDs. Each ID can have an attached feedforward (to be implemented as a MeasurementTool) for tuning or orbit. pyAT counterpart can have fixed settings of gap/phase corresponding to the model of the kickmap. A subholder is added for insertion devices.

This PR is to be merged after #526.

Resolves #509, #524, #525. This implementation is different to the interface proposed in the issue because I found that this solution is a bit more compact. In the end, the simplest solution is to have all cases covered together. Switching between different models/kickmaps of the ID could be easily done if atcollab/at#1124 is merged on the side of pyAT.

@eddrial You could have a look, but this is already a pyAML-specific implementation. However, the main class of pyaml/insertion_device/insertion_device.py should be easy to understand.

@gubaidulinvadim gubaidulinvadim added this to the ESRF Workshop milestone Nov 26, 2026
@gubaidulinvadim gubaidulinvadim self-assigned this Nov 26, 2026
@gubaidulinvadim gubaidulinvadim added the enhancement New feature or request label Nov 26, 2026
@gubaidulinvadim gubaidulinvadim changed the title Feature ids interface Feature IDs interface Nov 26, 2026
control_mode: APPLE01_MODE
model_operating_point: {gap: 4.0, phase: 0.0, mode: parallel}
disabled_operating_point: {gap: 30.0, phase: 0.0}
orbit_feedforward: ID01_ORBIT_FF

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nested dictionaries hide the way to configure the device (e.g. here in control variables). To properly have the SchemaValidator discover, describe and validate the configuration you would need to do something like this:

    - type: pyaml.insertion_device
      name: APPLE01
      device_id: APPLE01_SERIAL
      lattice_names: ID02
      description: Kickmap measured at 4 mm gap and zero phase.
      control_variables:
        - type: pyaml.insertion_devices.control_variable
           name: gap
           unit: mm
           backend: APPLE01_GAP
           movement_flag: APPLE01_GAP_MOVING
        - type: pyaml.insertion_devices.control_variable
           name: phase
           unit: mm, backend: APPLE01_PHASE
           movement_flag: APPLE01_MOVING
      control_mode: APPLE01_MODE
      model_operating_point: 
        - type: pyaml.insertion_devices.operating_point
           name: gap
           value: 4.0
        - type: pyaml.insertion_devices.operating_point
           name: phase
           value: 0.0
        - type: pyaml.insertion_devices.operating_point
           name: mode
           value: parallel
      disabled_operating_point:
        - type: pyaml.insertion_devices.operating_point
           name: gap
           value: 30.0
        - type: pyaml.insertion_devices.operating_point
           name: phase
           value: 0.0
      orbit_feedforward: ID01_ORBIT_FF

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is only a configuration file issue because both formats are valid yaml. But I agree that the docstring example should show the intended way of writing a config file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, you are right. I'm making the changes to allow a PyAMLish interface. But a dictionary gives simpler code and in this case maybe it's not worth it having the validation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can still build the same dictionary at init, I think there is no need to keep the pyaml.insertion_devices.operating_point type after initialization. Also since it is just a value with a name it could be a general pyaml "NamedValue" or something configuration class.

@gubaidulinvadim

Copy link
Copy Markdown
Member Author

atcollab/at#1124 is now merged. I will extend the implementation to support several model working points for a single ID (kickmaps corresponding to different gap/phase/polarisation values). This shouldn't change the code much. Working points will be a list of working points, and the simulator will allow changing between working point configurations.

@gubaidulinvadim

Copy link
Copy Markdown
Member Author

Updated to handle multiple kickmaps in a single element. Tests are failing because we are using older version of pyAT (0.9) where this functionality is not yet present.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ElectromagneticInsertionDevice GapPhaseInsertionDevice Feature: Insertion-device interface

2 participants