Skip to content

Feature implement bpm device#45

Merged
JeanLucPons merged 17 commits intomainfrom
feature-implement-bpm-device
Oct 23, 2025
Merged

Feature implement bpm device#45
JeanLucPons merged 17 commits intomainfrom
feature-implement-bpm-device

Conversation

@gubaidulinvadim
Copy link
Contributor

First try at BPM implementation. Following Issue #6 and some discussions with Jean-Luc. I've only added the simplest tests for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

2 things:

  • You can remove the hardware part. For model without needed conversion or extra calculation we will do as for magnet using identity bpm model.
  • It would be nice to test attached field and initialize them to None in __init__() i.e.
    @property
    def tilt(self) -> RWBpmTiltScalar:
        if self.__tilt is None:
            raise PyAMLException(f"{str(self)} does not support tilt")
        return self.__tilt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I will correct. I understood that the hardware part can be skipped only yesterday by looking at your RF device implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

According to @gupichon modifications, an other field than FamName can be used for elements identification.
So you should pass it to the construct of your RBpmArray and use this field.

index = self.lattice.get_refpts(self.element.FamName)

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately I'm not sure that get_refpts() can be used to select on an arbitrary AT field.
You may need to extract the index at each call.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think a simple mods like below should be ok.

    def get(self) -> np.array:
        index = self.lattice.index(self.element)
        _, orbit = at.find_orbit(self.lattice, refpts=index)
        return orbit[0, [0, 2]]

Copy link
Contributor

Choose a reason for hiding this comment

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

May be remove the debug trace

print(self.__BPMS.keys())

Copy link
Contributor

@JeanLucPons JeanLucPons left a comment

Choose a reason for hiding this comment

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

Nice works. Thanks
Just few details above !

@gubaidulinvadim
Copy link
Contributor Author

gubaidulinvadim commented Oct 23, 2025

I've made the corrections and also added a test with a nonzero orbit by setting one of the corrector magnet strength to 1e-6 in the test. FYI, I've created an issue in tango-pyaml python-accelerator-middle-layer/tango-pyaml#21 but I'm not sure if it originates in tango-pyaml or in pyaml itself. If I use type: tango.pyaml.attribute_read_only the configuration part fails, with type: tango.pyaml.attribute everything works.

@JeanLucPons JeanLucPons merged commit 76ab77f into main Oct 23, 2025
2 checks passed
@JeanLucPons
Copy link
Contributor

I've made the corrections and also added a test with a nonzero orbit by setting one of the corrector magnet strength to 1e-6 in the test. FYI, I've created an issue in tango-pyaml python-accelerator-middle-layer/tango-pyaml#21 but I'm not sure if it originates in tango-pyaml or in pyaml itself. If I use type: tango.pyaml.attribute_read_only the configuration part fails, with type: tango.pyaml.attribute everything works.

Yes I think there is a bug in attribute_read_only that prevents to use get().
We will fix this ASAP
Thanks for the updates

@gubaidulinvadim gubaidulinvadim linked an issue Nov 19, 2025 that may be closed by this pull request
@gubaidulinvadim gubaidulinvadim deleted the feature-implement-bpm-device branch December 17, 2025 08:53
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.

Implement BPM device

2 participants