mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-03-08 01:37:52 +01:00
refactor: global refactoring to use device-signal pair names
This commit is contained in:
@@ -55,7 +55,7 @@ bec_figure = BECFigure(gui_id="my_gui_app_id")
|
||||
window.setCentralWidget(bec_figure)
|
||||
|
||||
# prepare to plot samx motor vs bpm4i value
|
||||
bec_figure.plot(x_name="samx", y_name="bpm4i")
|
||||
bec_figure.plot(device_x="samx", device_y="bpm4i")
|
||||
```
|
||||
|
||||
In the example just above, the resulting application will show a plot of samx
|
||||
@@ -96,7 +96,7 @@ window = QMainWindow()
|
||||
bec_figure = BECFigure(parent=window, gui_id="my_gui_app_id")
|
||||
window.setCentralWidget(bec_figure)
|
||||
|
||||
bec_figure.plot(x_name="samx", y_name="bpm4i")
|
||||
bec_figure.plot(device_x="samx", device_y="bpm4i")
|
||||
|
||||
# ensuring proper cleanup
|
||||
def final_cleanup():
|
||||
|
||||
@@ -45,7 +45,7 @@ For the introduction given here, we will focus on the plotting widgets of BECWid
|
||||
|
||||
```python
|
||||
plt = gui.new().new().new(gui.available_widgets.Waveform)
|
||||
plt.plot(x_name='samx', y_name='bpm4i')
|
||||
plt.plot(device_x='samx', device_y='bpm4i')
|
||||
```
|
||||
Here, we create a new plot with a subscription to the devices `samx` and `bpm4i` and assign the plot to the object `plt`. We can now use this object to further customize the plot, e.g. changing the title (`title`), axis labels (`x_label`)
|
||||
<!-- or limits (`x_lim`). -->
|
||||
@@ -112,7 +112,7 @@ Let's assume BEC was just started and the `gui` object is available in the clien
|
||||
```python
|
||||
dock_area = gui.new()
|
||||
plt = dock_area.new().new(gui.available_widgets.Waveform)
|
||||
plt.plot(x_name='samx', y_name='bpm4i')
|
||||
plt.plot(device_x='samx', device_y='bpm4i')
|
||||
plt.curves[0].set_color(color="white")
|
||||
plt.title = '1D Waveform'
|
||||
```
|
||||
|
||||
@@ -47,9 +47,9 @@ heatmap_widget = dock_area.new().new(gui.available_widgets.Heatmap)
|
||||
|
||||
# Plot a heatmap with x and y motor positions and z detector signal
|
||||
heatmap_widget.plot(
|
||||
x_name='samx', # X-axis motor
|
||||
y_name='samy', # Y-axis motor
|
||||
z_name='bpm4i', # Z-axis detector signal
|
||||
device_x='samx', # X-axis motor
|
||||
device_y='samy', # Y-axis motor
|
||||
device_z='bpm4i', # Z-axis detector signal
|
||||
color_map='plasma'
|
||||
)
|
||||
heatmap_widget.title = "Grid Scan - Sample Position vs BPM Intensity"
|
||||
@@ -66,12 +66,12 @@ heatmap_widget = dock_area.new().new(gui.available_widgets.Heatmap)
|
||||
|
||||
# Plot heatmap with specific data entries
|
||||
heatmap_widget.plot(
|
||||
x_name='motor1',
|
||||
y_name='motor2',
|
||||
z_name='detector1',
|
||||
x_entry='RBV', # Use readback value for x
|
||||
y_entry='RBV', # Use readback value for y
|
||||
z_entry='value', # Use main value for z
|
||||
device_x='motor1',
|
||||
device_y='motor2',
|
||||
device_z='detector1',
|
||||
signal_x='RBV', # Use readback value for x
|
||||
signal_y='RBV', # Use readback value for y
|
||||
signal_z='value', # Use main value for z
|
||||
color_map='viridis',
|
||||
reload=True # Force reload of data
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ dock_area = gui.new()
|
||||
img_widget = dock_area.new().new(gui.available_widgets.Image)
|
||||
|
||||
# Add an ImageWidget to the BECFigure for a 2D detector
|
||||
img_widget.image(device_name='eiger', device_entry='preview')
|
||||
img_widget.image(device='eiger', signal='preview')
|
||||
img_widget.title = "Camera Image - Eiger Detector"
|
||||
```
|
||||
|
||||
@@ -46,7 +46,7 @@ dock_area = gui.new()
|
||||
img_widget = dock_area.new().new(gui.available_widgets.Image)
|
||||
|
||||
# Add an ImageWidget to the BECFigure for a 2D detector
|
||||
img_widget.image(device_name='waveform', device_entry='data')
|
||||
img_widget.image(device='waveform', signal='data')
|
||||
img_widget.title = "Line Detector Data"
|
||||
|
||||
# Optional: Set the color map and value range
|
||||
@@ -84,7 +84,7 @@ The Image Widget can be configured for different detectors by specifying the cor
|
||||
|
||||
```python
|
||||
# For a 2D camera detector
|
||||
img_widget = fig.image(device_name='eiger', device_entry='preview')
|
||||
img_widget = fig.image(device='eiger', signal='preview')
|
||||
img_widget.set_title("Eiger Camera Image")
|
||||
```
|
||||
|
||||
@@ -92,7 +92,7 @@ img_widget.set_title("Eiger Camera Image")
|
||||
|
||||
```python
|
||||
# For a 1D line detector
|
||||
img_widget = fig.image(device_name='waveform', device_entry='data')
|
||||
img_widget = fig.image(device='waveform', signal='data')
|
||||
img_widget.set_title("Line Detector Data")
|
||||
```
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ mm1 = dock_area.new().new(gui.available_widgets.MotorMap)
|
||||
mm2 = dock_area.new().new(gui.available_widgets.MotorMap)
|
||||
|
||||
# Add signals to the MotorMaps
|
||||
mm1.map(x_name='samx', y_name='samy')
|
||||
mm2.map(x_name='aptrx', y_name='aptry')
|
||||
mm1.map(device_x='samx', device_y='samy')
|
||||
mm2.map(device_x='aptrx', device_y='aptry')
|
||||
```
|
||||
|
||||
## Example 2 - Customizing Motor Map Display
|
||||
@@ -57,7 +57,7 @@ You can dynamically change the motors being tracked and reset the history of the
|
||||
mm1.reset_history()
|
||||
|
||||
# Change the motors being tracked
|
||||
mm1.map(x_name='aptrx', y_name='aptry')
|
||||
mm1.map(device_x='aptrx', device_y='aptry')
|
||||
```
|
||||
````
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ The 2D scatter plot widget is designed for more complex data visualization. It e
|
||||
```python
|
||||
# Add a new dock_area, a new dock and a BECWaveForm to the dock
|
||||
plt = gui.new().new().new(gui.available_widgets.ScatterWaveform)
|
||||
plt.plot(x_name='samx', y_name='samy', z_name='bpm4i')
|
||||
plt.plot(device_x='samx', device_y='samy', device_z='bpm4i')
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ plt1 = dock_area.new().new('Waveform')
|
||||
plt2 = gui.my_new_dock_area.new().new(gui.available_widgets.Waveform) # as an alternative example via dynamic name space
|
||||
|
||||
# Add signals to the WaveformWidget
|
||||
plt1.plot(x_name='samx', y_name='bpm4i')
|
||||
plt2.plot(x_name='samx', y_name='bpm3i')
|
||||
plt1.plot(device_x='samx', device_y='bpm4i')
|
||||
plt2.plot(device_x='samx', device_y='bpm3i')
|
||||
|
||||
# set axis labels
|
||||
plt1.title = "Gauss plots vs. samx"
|
||||
@@ -60,10 +60,10 @@ In addition to the scan curve, you can also add a second curve that fits the sig
|
||||
```python
|
||||
# Add a new dock_area, dock and Waveform and plot bpm4i vs samx with a GaussianModel DAP
|
||||
plt = gui.new().new().new('Waveform')
|
||||
plt.plot(x_name='samx', y_name='bpm4i', dap="GaussianModel")
|
||||
plt.plot(device_x='samx', device_y='bpm4i', dap="GaussianModel")
|
||||
|
||||
# Add a second curve to the same plot without DAP
|
||||
plt.plot(x_name='samx', y_name='bpm3a')
|
||||
plt.plot(device_x='samx', device_y='bpm3a')
|
||||
|
||||
# Add DAP to the second curve
|
||||
plt.add_dap_curve(device_label='bpm3a-bpm3a', dap_name='GaussianModel')
|
||||
|
||||
Reference in New Issue
Block a user