Closed prjemian closed 2 weeks ago
RuntimeError: Invalid array size (0, 0, 0)
- Is that an unprimed area detector?
Perhaps the best way past this is to wrap https://github.com/BCDA-APS/apstools/blob/4a152d0894c9395045eaea6ad00b7721163dfc15/apstools/utils/device_info.py#L231
with try..except
and return a value. But what value to return? The error message (Invalid array size (0, 0, 0)
)? Something more terse?
If this is an unprimed area detector situation, it is harder to re-create the initial conditions. Need to take an existing AD and change its image parameters so that the ophyd object will raise the exception.
Adding a unit test here could be contrived and possibly not realistic. Need to create a Device
with a Signal
that triggers the exception.
Ran again with this code change and an unprimed area detector. Error is now:
In [5]: listdevice(adsimdet)
Subscription value callback exception (EpicsSignal(read_pv='ad:image1:ArrayData', name='adsimdet_image_array_data', parent='adsimdet_image', value=array([], dtype=uint8), timestamp=631152000.0, auto_monitor=True, string=False, write_pv='ad:image1:ArrayData', limits=False, put_complete=False))
Traceback (most recent call last):
File "/home/prjemian/.conda/envs/bluesky_2024_2/lib/python3.11/site-packages/ophyd/ophydobj.py", line 492, in inner
cb(*args, **kwargs)
File "/home/prjemian/.conda/envs/bluesky_2024_2/lib/python3.11/site-packages/ophyd/signal.py", line 696, in _derived_value_callback
value = self.inverse(value)
^^^^^^^^^^^^^^^^^^^
File "/home/prjemian/.conda/envs/bluesky_2024_2/lib/python3.11/site-packages/ophyd/areadetector/base.py", line 123, in inverse
raise RuntimeError(f"Invalid array size {self.derived_shape}")
RuntimeError: Invalid array size (0, 0, 0)
Still an exception from ophyd.areadetector.base
from the subscription, but this time listdevice()
completed.
We can suppress that exception from causing listdevice()
to fail but the same code raises an exception in the DETECTOR.image.shaped_image
callback. The exception is raised in areadetector.base
when the image shape tuple is all zeroes. That is an indicator of an area detector IOC that has just started and no image has been passed from the cam
to the image
plugin.