diff --git a/docs/user/widgets/bec_figure.md b/docs/user/widgets/bec_figure.md index 3bf9a5c6..84e1873e 100644 --- a/docs/user/widgets/bec_figure.md +++ b/docs/user/widgets/bec_figure.md @@ -7,7 +7,6 @@ In the following, we describe 4 different type of widgets thaat are available in ![BECFigure.png](BECFigure.png) -(user.widgets.waveform_1d)= ## [1D Waveform Widget](/api_reference/_autosummary/bec_widgets.cli.client.BECWaveform) **Purpose:** This widget provides a straightforward visualization of 1D data. It is particularly useful for plotting positioner movements against detector readings, enabling users to observe correlations and patterns in a simple, linear format. @@ -20,11 +19,12 @@ In the following, we describe 4 different type of widgets thaat are available in **Example of Use:** ![Waveform 1D](./w1D.gif) -**Code example** +**Code example 1 - adding curves** + The following code snipped demonstrates how to create a 1D waveform plot using BEC Widgets within BEC. More details about BEC Widgets in BEC can be found in the getting started section within the [introduction to the command line.](user.command_line_introduction) ```python # adds a new dock, a new BECFigure and a BECWaveForm to the dock -plt = gui.add_dock().add_widget('BECFigure').plot('samx', 'bpm4i') +plt = gui.add_dock().add_widget('BECFigure').plot(x_name='samx', y_name='bpm4i') # add a second curve to the same plot plt.plot(x_name='samx', y_name='bpm3i') plt.set_title("Gauss plots vs. samx") @@ -39,6 +39,48 @@ dev.bpm4i.sim.select_sim_model("GaussianModel") dev.bpm3i.sim.select_sim_model("StepModel") ``` +**Code example 2 - Adding Data Processing Pipeline Curve with LMFit Models** + +Together with the scan curve, one can also add a second curve that fits the signal using a specified model +from [LMFit](https://lmfit.github.io/lmfit-py/builtin_models.html). The following code snippet demonstrates how to +create a 1D waveform curve with an attached DAP process, or how to add a DAP process to an existing curve using the BEC +CLI. Please note that for this example, both devices were set as Gaussian signals. + +```python +# Add a new dock, a new BECFigure, and a BECWaveForm to the dock with a GaussianModel DAP +plt = gui.add_dock().add_widget('BECFigure').plot(x_name='samx', y_name='bpm4i', dap="GaussianModel") + +# Add a second curve to the same plot without DAP +plt.plot(x_name='samx', y_name='bpm3a') + +# Add DAP to the second curve +plt.add_dap(x_name='samx', y_name='bpm3a', dap="GaussianModel") + +``` + +To get the parameters of the fit, one has to retrieve the curve objects and call the dap_params property. + +```python +# Get the curve object by name from the legend +dap_bpm4i = plt.get_curve("bpm4i-bpm4i-GaussianModel") +dap_bpm3a = plt.get_curve("bpm3a-bpm3a-GaussianModel") + +# Get the parameters of the fit +print(dap_bpm4i.dap_params) +# Output +{'amplitude': 197.399639720862, + 'center': 5.013486095404885, + 'sigma': 0.9820868875739888} + +print(dap_bpm3a.dap_params) +# Output +{'amplitude': 698.3072786185278, + 'center': 0.9702840866173836, + 'sigma': 1.97139754785518} +``` + +![Waveform 1D_DAP](./bec_figure_dap.gif) + (user.widgets.scatter_2d)= ## [2D Scatter Plot](/api_reference/_autosummary/bec_widgets.cli.client.BECWaveform) diff --git a/docs/user/widgets/bec_figure_dap.gif b/docs/user/widgets/bec_figure_dap.gif new file mode 100644 index 00000000..3905b0a1 Binary files /dev/null and b/docs/user/widgets/bec_figure_dap.gif differ