Skip to content
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

add XCS ladm.py file and add tab whitelist/alias to lens.py #1316

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

carogee
Copy link

@carogee carogee commented Jan 7, 2025

Description

Adding ladm.py file and tab whitelists/aliases names in lens.py

Motivation and Context

XCS ladm.py file has been copied manually into pcdsdevices upgrades, but it would be helpful to have it as part of the git directory.
Also tab whitelists/aliases used in XCS in the lens.py file are helpful.

How Has This Been Tested?

Has been running in XCS pcdsdevices.

Where Has This Been Documented?

Here

Pre-merge checklist

  • Code works interactively
  • Code contains descriptive docstrings, including context and API
  • New/changed functions and methods are covered in the test suite where possible
  • Test suite passes locally
  • Test suite passes on GitHub Actions
  • Ran docs/pre-release-notes.sh and created a pre-release documentation page
  • Pre-release docs include context, functional descriptions, and contributors as appropriate

@carogee carogee requested a review from ZLLentz January 7, 2025 01:47
Copy link
Member

@ZLLentz ZLLentz left a comment

Choose a reason for hiding this comment

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

Thank you for bringing this into the main pcdsdevices!

I made a lot of comments here. I marked each one to help note the relative importance of each.

Change requests are things that definitely need to be done before I can approve the PR.

Questions and confusions really need a response so we can figure out together if something needs to be done or not.

Suggestions are things that I highly recommend doing but I won't hold back the PR for.

You can ignore or defer follow-up ideas and nitpicks if you don't have time, even though I think they are at least somewhat useful.

pcdsdevices/ladm.py Outdated Show resolved Hide resolved
alpha_cos = np.cos(27 * np.pi/180)


def ThetaToMotors(theta, samz_offset=0):
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick:
This file commits a lot of pep8 sins, I'm not going to have the bandwidth to point them out one by one but not following pep8 makes the code more annoying for python devs.
https://peps.python.org/pep-0008/

pcdsdevices/ladm.py Show resolved Hide resolved
"""

# Motors
x1 = Cpt(IMS, ':MMS:01', name="x1", kind='normal',
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick:
It's pretty strange that this is generalized to such a degree. I think there's only one LADM and it has a fixed prefix. It doesn't need to be fixed but it's possible to e.g. set a default class prefix.

Comment on lines +146 to +150
self.theta = None # VirtualMotor
self.XT = None # VirtualMotor
self.gamma = None
self.__lowlimX = None
self.__hilimX = None
Copy link
Member

Choose a reason for hiding this comment

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

Confusion/suggestion/question:

Are any of these variables actually used in a meaningful way?
Elsewhere in the class some of these are essentially unused, others are referenced as if they aren't None but they also aren't set anywhere, so there's no way to make them values other than None without some runtime manipulation by the user.

If they aren't used, we should remove them.
If they are used, we should set them properly, either in here if we have all the info or as an __init__ argument to ensure they get included at init time.

Comment on lines +209 to +210
print(self.theta.position())
theta_now = self.theta.position()
Copy link
Member

Choose a reason for hiding this comment

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

Confusion:
Here, self.theta, which is nominally None, is assumed to have a position() callable, but on line 190 it is assumed to have a position attribute containing the raw position value. It can't have both.

pcdsdevices/ladm.py Outdated Show resolved Hide resolved
except KeyboardInterrupt:
self.stop()

def wmX(self):
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion:
It's worth taking a moment to check each of the methods here to make sure they have at least something useful in the docstring.

Copy link
Member

Choose a reason for hiding this comment

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

Change request:
This PR doesn't have any pre-release notes, and it needs them.

Copy link
Member

Choose a reason for hiding this comment

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

Stretch goal/follow-up idea:
It'd be nice to have some basic unit tests that create a fake device and run through the most used functions.

Copy link
Contributor

@tangkong tangkong left a comment

Choose a reason for hiding this comment

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

Some additional thoughts from me. I'm happy this is being upstreamed, and this is a good opportunity to clean some of this up


alpha_r = 63 * np.pi/180 # rail angle
r = 2960.0 # first rail distance from sample to rail rod at 27deg
R = 6735.0
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this? Surely there's a more descriptive name than captial R (to avoid confusion with lowercase r)

Copy link
Author

Choose a reason for hiding this comment

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

I'm guessing it is another rail distance, but I'm not sure who wrote this code...

return x1, x2, dz


def y1ToGamma(y1):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these defined outside the LADM class? They seem to be rather specific to the geometry of the LADM, with coordinate names that only someone familiar with the LADM would understand.

Generally I dislike such opaque naming. Without a diagram it's impossible to verify that this math is doing the right thing

except KeyboardInterrupt:
self.stop()

def mvrV(self, y):
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhancement / Improvement idea / Musing:

It looks like we're most interested in derived quantities (V, H, X, Theta), rather than the motors that have been defined in this class (x1, y1, z, etc)

Should we be wrapping these quantities in pseudo positioners so that we can use normal manipulate them with normal FltMvInterface methods?

self.y2.stop()
self.z.stop()

def __call__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: We probably want to use the standard format_status_info method that displays device information in ipython. That way you don't actually have to write the parentheses () when you want to see the status info.

More concisely, I think if we define LADM.format_status_info we should just be able to type LADM in the ipython terminal to see the status info

carogee and others added 4 commits January 10, 2025 13:52
Co-authored-by: Zachary Lentz <[email protected]>
Co-authored-by: Zachary Lentz <[email protected]>
Co-authored-by: Zachary Lentz <[email protected]>
Co-authored-by: Zachary Lentz <[email protected]>
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.

3 participants