Closed ZeusMarti closed 1 month ago
Hello @ZeusMarti , this looks nice should we add this to the python too?
Hi @swhite2401, sure, I can take care of it but I'm not python fluent and we are quite busy with alba-II, it can take some time. Don't take me wrong, I would be happy, for me it would be good a way to force myself to get more familiar with pyat. If you don't feel like waiting for me to go through the exercise please feel free to add the changes yourself. Let me know!
No rush! If you want to train yourself it is very good! Let me know in case you would need any help!
I tested the two implementations in Matlab and Python. Please take a look at it, it should be ready to be reviewed.
Python avllinopt:
Matlab atavedata:
Results look nice. Concerning the code, please look at the review above !
Results look nice. Concerning the code, please look at the review above !
Sorry Laurent, I do not see the review!
Dear @lfarv , neither I see your reviews or requests. You might need to finish the review to make it public (something similar happened to me while reviewing a few weeks ago)
Hi @ZeusMarti and @oscarxblanco. Is it better now? I was confused because for me it appears in the conversation… Sorry.
Dear @lfarv , yes. Now the review is visible to me.
@ZeusMarti : I get more that 100 warnings about code not respecting PEP8. Most of them are:
PEP 8: E225 missing whitespace around operator
PEP 8: E303 too many blank lines (3)
PEP 8: E231 missing whitespace after ','
PEP 8: E128 continuation line under-indented for visual indent
PEP 8: E501 line too long (106 > 88 characters)
You should use an IDE which warns about that (ex. PyCharm or VSCode)
@lfarv , I implemented your last comments.
I realized that I have not properly tested it adding magnet movements, rolls and closed orbit errors, I'll do it after holidays.
Also, the code logic is a bit cumbersome, there are different behaviors for thin or long, focusing or not, drifts. Any suggestions on how to make it more clear? Maybe it just needs more comments?
Also, the code logic is a bit cumbersome...
Agreed, but since you are at the moment the most familiar with this code, go on… My only concern is about the "epsilon" trick for the focusing strength. Is not it possible to correctly treat the 0-strength quadrupoles?
I realized that I have not properly tested it adding magnet movements, rolls and closed orbit errors, I'll do it after holidays.
Excellent !
Hi @lfarv,
I'm sorry I have not been able to advance much, however I noticed a peculiar behaviour of the function, both in Matlab and python in the master branch and this branch. Since the input parameter refpts is used only to create a bolean array, if refpts is not sorted that information is lost in the calculation and the results are given always assuming a sorted order.
It was the cause of some trouble for me so I'm wondering if this behavior should be kept. We could simply unsort the arrays at the end or alternatively generate a warning in case of non sorted refpts and output the sorted refpts. Which is your opinion on this?
Hi @ZeusMarti : the refpts
argument, if integer, should always be ordered, and the behaviour you get should be similar in many functions. This is specified in the documentation:
**Selecting elements in a lattice:**
The *refpts* argument allows functions to select locations in the lattice. The
location is defined as the entrance of the selected element. *refpts* may be:
#. an integer in the range *[-len(lattice), len(lattice)-1]*
selecting an element according to the python indexing rules.
As a special case, *len(lattice)* is allowed and refers to the end
of the last element,
#. an ordered list of such integers without duplicates,
#. a numpy array of booleans of maximum length *len(lattice)+1*,
where selected elements are :py:obj:`True`,
...
The problem is that it would be difficult (and time consuming) to check the validity of refpts
everywhere…
Now, for this PR, it's up to you !
Ah, sorry! My bad. Then I see no point in implementing a different behavior for atavedata.m. hopefully I can address the final details of this PR shortly.
Sorry it is taking me so long, we have been very busy lately, I tested the scrips again with errors (up to 100um in x-y and 100urad rotation) and the averages hold very well both in Matlab and Python. I think it is ready fore some more review from your side.
Matlab:
Python:
Everyone looked happy with this, so I merge
The file has been changed to:
This tries to solve issue #399