moonshot-nagayama-pj / PnPQ

Python package for Controlling Optical Devices in Quantum Testbed
Other
0 stars 0 forks source link

Abstract interface for motorized polarization controllers and MPC320 driver #51

Open auspicacious opened 1 week ago

auspicacious commented 1 week ago

We want to support motorized polarization controllers such as the Thorlabs MPC320.

This is a good chance for us to see if we can successfully implement an abstract base class as described in https://github.com/moonshot-nagayama-pj/PnPQ/issues/29 before we attempt to refactor existing code.

Acceptance criteria

Good to have

References

auspicacious commented 1 week ago

Some notes on third-party libraries:

auspicacious commented 1 week ago

Wow, there are a lot of Python libraries related to scientific units.

No longer maintained or considered not ready for production

We should avoid using these.

Dependencies on bigger libraries

We should avoid using these.

Further investigation required

These might be useful.

auspicacious commented 1 week ago

Pint seems to have the most features and the most complete documentation. It's also actively maintained. It doesn't have type safety (all quantities are the same class) but the many features it offers, including optional NumPy and pandas integration, seem to make it the only viable choice at this point in time.

Newly discovered but not appropriate

Not appropriate

auspicacious commented 1 week ago

Discovered yet another library that supports Thorlabs APT devices and supports a connection abstraction so it's possible to use, for instance, serial over Ethernet: https://instrumentkit.readthedocs.io/en/latest/

I'm not sure if everything works 100% for the APT protocol, as the library was originally mostly built for SCPI, I think. However, it has a nice object model for building messages (each APT packet is an object). It also uses Pint to make sure that values have units wherever possible.

While I would like to consider using this library, it's AGPL licensed. Using it in PnPQ would effectively require us to license PnPQ as AGPL (or GPL, I think) as well, as well as any further dependent testbed repositories we publish. This warrants a much broader team discussion and I am unsure of the outcome.

auspicacious commented 1 week ago

I'm convinced that implementing a usable interface that can handle things like status updates will require either threading or asyncio, and I'm working through the details now.