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 Andor camera service #122

Closed
wants to merge 20 commits into from
Closed

Add Andor camera service #122

wants to merge 20 commits into from

Conversation

ivalaginja
Copy link
Collaborator

@ivalaginja ivalaginja commented Oct 12, 2023

Add a service for an Andor camera, here specifically with tests on a Neo so other Andor cameras that use the same SDK might or might not work with this.

Very much WIP, for now just a mostly bare bones structure.

Fixes #135

@ivalaginja ivalaginja added the hardware Integrate new hardware label Oct 12, 2023
@ivalaginja ivalaginja self-assigned this Oct 12, 2023
@ivalaginja
Copy link
Collaborator Author

ivalaginja commented Oct 19, 2023

Our new PC got delivered way, way faster than anticipated, so I will be working on this PR with a higher urgency now.

I realized that it might be easiest to just use a Python package that provides a wrapper around the Andor SDK instead of trying to write the relevant pieces myself.

Googling gave me a couple of different options:
https://github.com/hamidohadi/pyandor
https://github.com/ardiloot/PyAndor
https://gitlab.com/ptapping/andor3
https://github.com/PyMoDAQ/pymodaq_plugins_andor

The first one seems the simplest, but it was not released either to PyPI or any conda channel, so we'd be relying on a GitHub repository only, which is not ideal. If it proves being the simplest/best solution I might still go for it, since the Andor Neo sCMOS camera that THD2 uses has recently been discontinued (it's not being sold anymore), and THD2 will be changing its main camera early next year anyway. Not sure how good it would be to merge a PR relying on this though.

Both the first and second one turn out to only work with the older Andor cameras and SDK2, while the Neo uses SDK3, so these options are out the window.

Both of the last two options support SDK3, I checked before continuing. Both also support Windows and Linux, not MacOS, which is fine since it's not expected to run any hardware components from MacOS, and a simulated services does not have to connect to the SDK.

The fourth library is a plugin for PyMoDAQ, a Python library sponsored by the CNRS for laboratory equipment. While it is regularly maintained, it is unclear to me how much it depends on the PyMoDAQ package itself, while option 3 listed above is completely independent and released on PyPI - so I am leaning towards option 3.

The best way forward will be for me to install andor3 on our machine and try to control the camera with that directly. If this works fine, I can start thinking about how to build the hardware service around.

@ehpor, does that make sense?

@a-sevin
Copy link
Collaborator

a-sevin commented Oct 19, 2023

For my point of view, all the codes inside hardware is independent from PyMoDAQ

@ivalaginja
Copy link
Collaborator Author

@a-sevin does that mean that PyMoDAQ plugins can be installed independently of the main library as well? It would be overkill to have that full library as a dependency if we just need one of the plugins I think.
Also, do you see any substantial difference in the actual code of the two options? To me they seem like they're doing the same thing.

@a-sevin
Copy link
Collaborator

a-sevin commented Oct 19, 2023

My first Thought was to copying the code and keeping the IP, copyright and license but... It's under GPL... So, I don't know if we can grab a part of a program GPL under BSD...
not really in fact: https://opensource.stackexchange.com/a/39

@ivalaginja
Copy link
Collaborator Author

@ehpor I just saw that the camera object Andor3 from andor3 calls the "open" call in its init already. From what I see in the other cameras in catkit2, this is not how it's done there. Does this pose a problem?

@ehpor
Copy link
Collaborator

ehpor commented Oct 19, 2023

@ivalaginja

@ehpor I just saw that the camera object Andor3 from andor3 calls the "open" call in its init already. From what I see in the other cameras in catkit2, this is not how it's done there. Does this pose a problem?

In principle that's not a problem. But, since there is some communication done at the end of __init__() with the testbed server, I prefer to have any code that might crash in the open() method. That ensures that log messages are actually passed around correctly, making debugging easier. Why can't you create the Andor3 object inside Service.open()?

@ehpor
Copy link
Collaborator

ehpor commented Oct 19, 2023

@ivalaginja

The best way forward will be for me to install andor3 on our machine and try to control the camera with that directly. If this works fine, I can start thinking about how to build the hardware service around.

Yes, both the andor3 library and PyMoDAQ seem like standard ctypes code, so that's unlikely to cause many problems. I'd choose andor3 for the time being, since it's a more focussed package.

@ivalaginja
Copy link
Collaborator Author

ivalaginja commented Oct 19, 2023

Why can't you create the Andor3 object inside Service.open()?

@ehpor I can, I simply haven't thought of it! 😄 Thanks for the guidance!

@ivalaginja ivalaginja force-pushed the feature/andor_camera branch from 805cf88 to 0b5cf24 Compare October 23, 2023 15:10
@ivalaginja
Copy link
Collaborator Author

@ehpor I think this is at a point where I would love some feedback if you have some time. I have managed to make the API calls work on our machine although I still have some stuff to figure out with the buffers and the acquisition, but I am getting there.
What I am most unsure about are the properties, I forgot - there are the Python object properties created with their getters and setters, but there are also the (same) ones created with the service method make_property() - what does what again, what exposes what where?

@@ -36,4 +36,5 @@ dependencies:
- pytest
- flake8
- pip:
- zwoasi>=0.0.21 # Requires additional manual install of driver(s) from https://astronomy-imaging-camera.com/software-drivers
- zwoasi>=0.0.21 # Requires additional manual installation of driver(s) from https://astronomy-imaging-camera.com/software-drivers
- andor3 # Requires additional manual installation of driver(s) from https://www.andor.com/scientific-software/software-development-kit
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This package also needs numba, which it doesn't install automatically. I need to add it to the env file.

@ivalaginja
Copy link
Collaborator Author

I am having memory issues on the PC I am testing this on, likely to a faulty installation of the library. I will wait for the new PC to be in the clean room and then try it on there.

@ivalaginja ivalaginja added the collaborators Worked on by external collaborator. Might need some extra help on code integration. label Nov 4, 2023
@ivalaginja ivalaginja force-pushed the feature/andor_camera branch from ce1d4ff to 27f657c Compare April 2, 2024 19:18
@ivalaginja ivalaginja force-pushed the feature/andor_camera branch from 27f657c to 2ddab2b Compare April 2, 2024 19:45
@ivalaginja
Copy link
Collaborator Author

This PR is not needed from our side anymore.

@ivalaginja ivalaginja closed this May 7, 2024
@ivalaginja ivalaginja deleted the feature/andor_camera branch May 17, 2024 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
collaborators Worked on by external collaborator. Might need some extra help on code integration. hardware Integrate new hardware
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a Service for an Andor camera
3 participants