AlexShkarin / pyLabLib

Python package for device control and experiment automation
http://pylablib.readthedocs.io
GNU General Public License v3.0
125 stars 28 forks source link

Some data retrieving functions of AndorSDK2Lib return error #50

Open VictorUOL opened 11 months ago

VictorUOL commented 11 months ago

Hello,

I am trying to retrieve acquired data from an Andor camera with the wrapped GetMostRecentImage, GetImage or GetAcquired data from Andor library and facing the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1, in <lambda>
    func_args=self._prepare_arguments(argnames,prep_argtypes,kwargs,argprep)
  File "...\lib\site-packages\pylablib\core\utils\ctypes_wrap.py", line 163, in _prepare_arguments
    v=functions.call_cut_args(p,**kwargs) if hasattr(p,"__call__") else p
  File "...\lib\site-packages\pylablib\core\utils\functions.py", line 309, in call_cut_args
    return func(*args,**cut_kwargs)
  File "...\lib\site-packages\pylablib\core\utils\ctypes_wrap.py", line 324, in prep
    n=args[size_arg_pos]
IndexError: tuple index out of range

For these functions a size argument is required, which is the dimensions of the camera chip. I am getting these readings as pylablib.devices.Andor.AndorSDK2.lib.GetDetector() and the output is a turple of length 2 representing size in pixels. For example, size = (1024, 1024). Then I feed it to the pylablib.devices.Andor.AndorSDK2.lib.GetMostRecentImage(size). Here is a little snippet I wrote to reproduce:

Reproduce:

from pylablib.devices import Andor
lib = Andor.AndorSDK2.lib
cam = Andor.AndorSDK2Camera(0)
cam.open()

cam.set_temperature(-85, enable_cooler=False)
cam.set_fan_mode("full")
cam.set_cooler(True)
cam.set_acquisition_mode("single")
cam.set_read_mode("fvb")
cam.set_exposure(1)
gridsize = lib.GetDetector()

if cam.get_read_mode() == "fvb":
            size = gridsize[0]
elif cam.get_read_mode() == "image":
            size =  gridsize[0] *  gridsize[1]

cam.start_acquisition()
lib.WaitForAcquisition()
lib.GetMostRecentImage(size)
cam.stop_acquisition()
cam.close()