-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select elements with wildcards in PyAt #100
Comments
Hello @abdomit, I thought of that, but I figured out that you can get the same thing either as an iterator with:
for a single usage, or as a list with:
if you want to use the list several times… And as elements are indeed references, modifying the element in
or in the other direction:
I have 2 comments on indexing directly the lattice:
However, if there is a need for it, why not! P.S. selecting focusing quads looking for 'QD*' might give surprising results! |
Hello Laurent,
Ok, but an iterator is not very user-friendy. You cannot address the nth element with
Moreover this list will not take much place in memory because it is basically just a list of references.
We could also have to possibility to give an Element class, for instance asking all the BPMs with
Then concerning the possibility to select elements using other criteria, that would be interesting, but I think it should more look like this:
In my opinion it is very very useful! I would be interested to know if other at-users feel the same.
Now you know why I am not in the beam dynamics group! |
If I may weigh in, I had a similar need, to get elements by class, and created a local utility function for the task when I first started using AT. As for implementation, supporting things like 'QD*' and element instances/types as valid arguments to |
Done in #103 |
Sorry to reopen this issue. I realized (a bit too late) that something was missing. Now we have a |
Ok, I take care of this in #99, almost ready! |
Hello,
First I'd like to thanks all the people working on PyAt. It is really great for Matlab-allergic people (like me). I am a PyAt user since a month, and it's working great.
But one thing I couldn't find in PyAt is a way to easily get elements from the lattice by their FamName, using a string supporting wildcards. This is something possible in Matlab-At, and it is really convenient (specially when the lattice you use is only made of Multipole elements).
For instance I would like to get all focusing quadrupole in my ring by just typing ring['QD*']. Maybe there is already a way to do it in PyAt, but I couldn't find it.
I did a quick implementation of this here. It is just 5 lines long, doesn't support Python2 and don't address the __setitem__ method. If there is no other way of doing this and you think it is worth it, I could do a pull request with it, trying to make it cleaner in the meantime.
Thanks,
Benoit
The text was updated successfully, but these errors were encountered: