Orbit correction and Orbit Response Matrix measurement through pySC.#82
Orbit correction and Orbit Response Matrix measurement through pySC.#82JeanLucPons merged 45 commits intomainfrom
Conversation
|
@JeanLucPons First ORM measurement (on design) is working. You can also check the interface in I have created an Maybe it's best we keep it detached in this PR and we attach it in a new one after this one is reviewed and merged? |
|
Thanks @kparasch , I'm impressed ! |
|
I just tried your example. orm = OrbitResponseMatrix(ORM_ConfigModel(element_holder=element_holder, bpm_array_name='BPM',
hcorr_array_name='HCorr', vcorr_array_name='VCorr',
corrector_delta=1e-6))Your model should not have the element holder, neither the arrays. For instance you should be able to do: hmags = sr.design.get_magnets("HCorr")['SF2*']
vmags = sr.design.get_magnets("VCorr")['SF2*']
bpms = sr.design.get_bpms("BPM")
orm.measure(hmags,vmags,bpms)It would be nice also to be able to save data to npy format. I continue with test. |
|
Dear @kparasch and @JeanLucPons, very nice developments! Ideally, if pyaml config is complete we could need to run just orm.measure() (such that any lab can use the code our of the box) with default the mandatory arrays of pyAML Hcor, Vcor, BPM, or you can pass a subset as shown above by @JeanLucPons. ciao |
|
OK, i tested the orbit correction, it went perfectly fine. Concerning configuration: OK, so we could keep the configuration proposed by @kparasch but without the element holder. If we want to follow the specification: # The orm object should be attached as all other elements in both ControlSystem and Simulator.
sr.design.orm.measure()
sr.live.orm.measure()but this prevents from having the writing I proposed with free arrays. Otherwise we can pass the holder as input param. orm.measure(sr.design) # Measure ORM on design using arrays in config
orm.measure(sr.live) # Measure ORM on live using arrays in config
orm.measure(hCorrectors=hmags, vCorrectors=vmags, bpms=bpms) # Measure ORM using dynamic arrays previously attached by the users |
|
Be aware orbit correction is still in a very preliminary state, another object will follow soon. The element holder I only have it there until we attach it. Unless we decide we don't want to do that. I like the idea of the dynamic arrays but I also would like a default configuration which is specified in the config files. PS: Do you think we could add MagnetArrays? It would simplify even more some things. |
|
Dear @kparasch, in fact in the specifications it is requested to be able to do something like: sr.design.orm.measure() # reference ORM
sr.live.orm.measure() # real accelerator ORMfor the hcor, vcor and bpm defaults it is ok for me. We could have additional arrays to be defined in the config file to specify the default correctors for ORM so the code becomes sharable among labs transparently. |
|
OK so let's follow the specification and forget free arrays to be passed an input parameters unless a real need is identified. |
|
We will need to put this informations in the configuration file for example defining ORM_HCOR, ORM_VCOR arrays of correctors (with less than all correctors) and use them to specify a property "correctors" of the ORM device. |
Yes this is already done by the model proposed by Kostas. |
|
I suspect it is a sign problem, your EBS uses the sign of kickangle and I think we use the sign of PolynomB which are opposite. |
I will check this. |
|
I think we need arrays to be passed as arguments, at least at this stage. The specification also tells you that the user should be able to remove corrector or a bpm from the measurement. This is either a "free" array that is passed as an argument or some standard pyAML array (which does not exist yet in the code). I would not say that it will be convenient for the user to change the configuration file all the time. The config file we generate for SOLEIL II is enormous with 10 000+ lines. |
This should be handled at the |
I don't see a possible quick fix if this is this sign problem. Would it possible for you to add 2 separate gain for h and v ? |
|
@JeanLucPons I don't have the separation between h and v yet in pySC. A quicker fix to see if this is indeed the issue could be if you try: or if you pass an empty vcorr array to calculation of the ideal ORM, which you can then use with a gain=-1 |
It is worse. Now the 2 planes are failling.... |
On the difference between PolynomB[0] and KickAngle[0], I am tempted to think that we should only be concerned about the sign. When the approximation P.S. If we ever want to cover positron rings or rings that are defined in counter-clockwise frame, there will likely be another sign change that we will need to take care of. |
|
Yes yes, i agree. I will add a sign in |
class HCorrector(Magnet):
"""Horizontal Corrector class"""
polynom = PolynomInfo('PolynomB',0, -1.) # Sets the value
def set(self, value:float):
self.__poly[self.__polyIdx] = value * self.sign / self.__elements[0].LengthThis is not better, same issue :( |
|
Sign issue fixed in PR #84 On design: On live:
Now it would be nice to (if not already done):
Thanks again @kparasch for this very good job 👍 |
This reverts commit 5e25afc.
|
To summarize: I have created three We definitely should aim for something like: but I would like it the subject of a separate PR, since it can be an independent PR. For now I have included these examples and tests: and also a very small set of unit tests: and a big file used during the orbit correction test: pySC is included as a submodule at this moment. I initially wanted to keep it like this so that the pySC included in pyAML can be independent of any external pySC installation. Seeing how much trouble I have had to make the github workflow run, perhaps it is simpler to just have it as a dependency as Jean-Luc also suggested to me. You can try out the tests yourself but you need to initialize the submodule: The tests are succeeding locally after putting the I think this PR is in a good state to be merged before it becomes too big and we can improve the functionality in later PRs. |
gubaidulinvadim
left a comment
There was a problem hiding this comment.
@kparasch tests are failing, is this intended functionality :) ?
|
@gubaidulinvadim Tests should be ok now |
gubaidulinvadim
left a comment
There was a problem hiding this comment.
Looks good! I hope it is compatible with the latest Jean-Luc's latest refurbishment of control system access. I have a question, where are the wait times/sleeps handled for the measurements? Is it done on the level of pySC? In general, we should be using set_and_wait of pyAML but it is not implemented yet, I think.
|
The control access is very minimal actually in this PR, so if it is not compatible with Jean-Luc's refurbishment, it will not be difficult to adapt. pySC does not wait for anything :) The only place where the set is actually done is on the In the ESRF tests, we put some waiting times as attributes in the equivalent pySC_interface which we would tweak. |
|
So should we merge now and then we update tuning_tools classes to pyaml standard (attachment, PYAMLCLASS, ...) ? |
|
I would prefer to merge it and continue with a new PR. I think it will also be easier for you to review the changes. If you prefer to continue from here I can also do that. |
JeanLucPons
left a comment
There was a problem hiding this comment.
Nice work.
Thanks again Kostas !
|
@kparasch |
|
It is used in the tests where I do an actual orbit correction. I could also generate it on the spot but it will increase the time for tests quite a lot. |
|
I would also like to include in the configuration of the orbit correction actually. |
|
I'm currently working on that topic. I had to trick the fileloader using: # Expand condition
def hasToExpand(key,value):
return "file" not in str(key) and isinstance(value, str) and any(
value.endswith(suffix) for suffix in accepted_suffixes
) |
|
Ah! Not good! I would propose I make a ResponseMatrix pyaml class so that it actually parses it. Until then perhaps we can delete the file and disable the test. |
|
No worries. In any case we have to define a rule to not expand a field. |




No description provided.