-
Notifications
You must be signed in to change notification settings - Fork 81
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
FailedStatus from ophyd while writing array to EpicsSignal #1206
Comments
While the documentation of Both fixes can be applied by inserting code just before this line: ophyd/ophyd/utils/epics_pvs.py Line 338 in 9c77d86
I propose inserting these lines: array_like = (list, np.ndarray, tuple)
if isinstance(a, array_like) and isinstance(b, array_like):
# 2024-07-30, prj:
# np.allclose(a, b) fails when both a & b are different shaped arrays
# If only one is a numpy array, then np.allclose does not fail.
# np.allclose() calls np.isclose() which has a comment that states
# the two arrays "must be the same shape."
a = np.array(a) # target
b = np.array(b) # reported by EPICS
if len(a.shape) == 1 and len(b.shape) == 1 and len(a) < len(b):
# Some EPICS arrays always return full size, even if only less is written.
# EPICS CA arrays are always 1-D.
b = b[:len(a)] # cut 1-D EPICS array down to requested size
if a.shape != b.shape:
return False |
A fix here is critical to our fly scans at the APS. |
If you
? When we "put" to an array should we be resetting the size as well or is the issue that the monitor is providing up to max size rather than the current size? |
Neither, actually. The current |
We want to write to some array PVs (such as positioner arrays in the sscan record, array fields in the array calcs). We know we can do this with the
EpicsSignal.put()
method. It works. What fails is the QA process associated with the.set()
method that assures the EPICS PV has reached the values we wrote.When writing an array (list, np.ndarray, tuple) to an EpicsSignal connected to such a PV, the ophyd code stops with an FailedStatus exception that points to this chain:
ophyd.utils._wait_for_value()
line 295ophyd.utils._compare_maybe_enum()
line 341np.core.numeric.allclose()
line 2241np.core.numeric.isclose()
line 2332, which fails due toabs(x-y)
One failure is that the two arrays passed must have the same shape (or this operation in numpy fails).
Another part of the failure is that EPICS Channel Access (used by EpicsSignal) always returns (since we have not told it to return less) the full array, not just the limited part we wanted to write.
Demonstrate the problem
Such an EPICS PV:
pjgp:userArrayCalc1.AA
(bluesky_2024_2) jemian@otz ~ $ cainfo pjgp:userArrayCalc1.AA pjgp:userArrayCalc1.AA State: connected Host: otz.xray.aps.anl.gov:5064 Access: read, write Native data type: DBF_DOUBLE Request type: DBR_DOUBLE Element count: 8000
ophyd 1.9.0, numpy 1.26.4
Show the problem using
EpicsSignal.set()
:numpy demo
The text was updated successfully, but these errors were encountered: