Feat: Waveform scan logic - Add async, timestamp, rolling update
Description
Overhaul of the BECWaveform
subplot before making it a standalone widget. More details on what was changed are in the Changes
section. To view a gallery of some plotting options, launch examples/jupyter_console_widget
and select the BECFigure
tab. Each plotting window is accessible in Jupyter with w1-8
, and the entire BECFigure
is accessible with fig
.
Related Issues
Relates to #196, #243 (closed), #201 (closed)
Closes #263 (closed)
Changes
-
BECWaveform
x-axis regimes:- "best_effort" (also chosen if no
x_name
is specified; it takes the first motor fromScanItem.status_message.info["scan_report_devices"]
) - "index" (an integer index for each point)
- "timestamp"
- "custom" (same as before if the user specifies
x_name
as some device, e.g.,x_name='samx'
)
- "best_effort" (also chosen if no
-
Simplified API for
BECWaveform
(also reflected at theBECFigure
level): The.plot()
method takes the first argument as x, y,np.ndarray(x, y)
, ory_name
, allowing the user to add a new plot with one argument. Examples:-
plt.plot('bpm4i')
→ Adds a plot with "best_effort" for x and one curve with "bpm4i" -
plt.plot([5, 6, 7])
→ Custom curve withx=[1, 2, 3]
andy=[5, 6, 7]
-
plt.plot(np.random.rand(10, 2))
→ 2D curve where the first column is x and the second is y
-
-
Switching x-axis source:
BECWaveform
can switch between x-axis sources for all curves from one mode to another usingplt.set_x(mode: str)
-
Single x-axis source type:
BECWaveform
allows only one type of x-axis source (except for custom curves, where the user can provide any two arrays) -
Async data readback: Implemented for
BECWaveform
, compatible only with x-axis modes "index" and "timestamp" - Validation: Validators to prevent combinations of async with sync positioners
Potential Side Effects
I did extensive manual testing with RPC and examples/jupyter_console_window
. However, there are many possible combinations that a user can prompt, so there might still be some unknown bugs.
Additional Comments
There is a lot of nested if/else logic to cover all possible scenarios, making some methods quite long and complex. I do not have much time for refactoring these methods now, so if anyone has ideas, please do not hesitate to add a comment. Otherwise, I will revisit this after the BSEG meeting.
Definition of Done
-
Documentation is up-to-date (will be adjusted after making the standalone version with the toolbar #243 (closed))