You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{py:obj}`ChainedLiveFit <ibex_bluesky_core.callbacks.ChainedLiveFit>` is a specialised callback that manages multiple {py:obj}`LiveFit <ibex_bluesky_core.callbacks.LiveFit>` instances in a chain, where each fit's results inform the next fit's initial parameters. This is particularly useful when fitting datasets where the initial guess for each fit depends on the parameters obtained from a previous fit.
3
+
{py:obj}`~ibex_bluesky_core.callbacks.ChainedLiveFit` is a specialised callback that manages multiple {py:obj}`~ibex_bluesky_core.callbacks.LiveFit` instances in a chain, where each fit's results inform the next fit's initial parameters. This is particularly useful when fitting datasets where the initial guess for each fit depends on the parameters obtained from a previous fit.
4
4
5
5
This is useful for when you need to be careful with your curve fitting due to the presence of noisy data. It allows you to fit your widest (full) wavelength band first and then using its fit parameters as the initial guess of the parameters for the next fit
6
6
7
-
To show how we expect this to be used, we will use a {py:obj}`DualRunDae <ibex_bluesky_core.devices.polarisingdae.DualRunDae>` configured with multiple wavelength bands, to highlight the need to carry over fitting parameters. The example below shows two wavelength bands, first wider than the second. We will fit to the data in the widest wavelength band first, and carry over the results of that fit to the guess of the next fit, to improve the chances of that fit converging.
7
+
To show how we expect this to be used, we will use a {py:obj}`~ibex_bluesky_core.devices.polarisingdae.DualRunDae` configured with multiple wavelength bands, to highlight the need to carry over fitting parameters. The example below shows two wavelength bands, first wider than the second. We will fit to the data in the widest wavelength band first, and carry over the results of that fit to the guess of the next fit, to improve the chances of that fit converging.
The list of signal names for each independent variable should be passed in the same order that the fits are to be applied.
47
47
48
-
A list of matplotlib axes is accepted, which will mean that {external+bluesky:py:obj}`LiveFitPlots <bluesky.callbacks.mpl_plotting.LiveFitPlot>` are created per {py:obj}`LiveFit <ibex_bluesky_core.callbacks.LiveFit>`, and it will plot the each respective fit to an axis. {external+bluesky:py:obj}`LiveFitPlots <bluesky.callbacks.mpl_plotting.LiveFitPlot>` are not created if you do not pass `ax`.
48
+
A list of matplotlib axes is accepted, which will mean that {external+bluesky:py:obj}`LiveFitPlots <bluesky.callbacks.mpl_plotting.LiveFitPlot>` are created per {py:obj}`~ibex_bluesky_core.callbacks.LiveFit`, and it will plot the each respective fit to an axis. {external+bluesky:py:obj}`LiveFitPlots <bluesky.callbacks.mpl_plotting.LiveFitPlot>` are not created if you do not pass `ax`.
49
49
50
50
Similar to the `y` parameter, uncertainties for each dependent variable are accepted in `yerr`.
51
51
52
-
{py:obj}`ChainedLiveFit <ibex_bluesky_core.callbacks.ChainedLiveFit>` currently has the following limitations:
52
+
{py:obj}`~ibex_bluesky_core.callbacks.ChainedLiveFit` currently has the following limitations:
53
53
- The method for fitting must be the same across all dependent variables.
54
54
- Parameter uncertainties are not carried over between fits
55
-
- If a fit fails to converge, subsequent fits will use their default guess functions
55
+
- If a fit fails to converge, the next fits will use their default guess functions
Copy file name to clipboardExpand all lines: doc/callbacks/fitting/livefit_logger.md
+49-8Lines changed: 49 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,53 @@
1
1
{#livefit_logger}
2
-
# Saving fit results to file (`LiveFitLogger`)
2
+
# Saving fit results to file ({py:obj}`~ibex_bluesky_core.callbacks.LiveFitLogger`)
3
3
4
-
## Fitting Files
4
+
The {py:obj}`~ibex_bluesky_core.callbacks.LiveFitLogger` callback exists to write the results of a {py:obj}`~ibex_bluesky_core.callbacks.LiveFit` to file. These are designed to be human-readable files, rather than machine readable.
5
5
6
-
The callback ([`LiveFitLogger`](ibex_bluesky_core.callbacks.LiveFitLogger)) exists to write all fitting metrics from [`LiveFit`](ibex_bluesky_core.callbacks.LiveFit) to file. These are designed to be human readable files rather than machine readable.
6
+
The files written by this callback contain:
7
+
- The result of an {py:obj}`lmfit.model.ModelResult.fit_report`, which contains fit statistics such as r-squared, optimized values of fit parameters, and information about correlations if present.
8
+
- Two blank lines
9
+
- A csv table containing `x`, `y`, optionally `y` uncertainty, and modelled `y`
7
10
8
-
This callback provides you with useful metrics such as `R-squared` and `chi-square`, then providing you with a table of the raw collected data included modelled `y` data and `y` uncertainty.
11
+
---
9
12
10
-
### Example
11
-
An example of using this could be:
13
+
:::{collapse} Example output file from this callback (click to expand)
This will put the all fitting data collected over the run into a `.csv`file, named after the `uid` of the scan, in the `C:\\Instrument\\Var\\logs\\bluesky\\fitting`path provided to the callback. You should provide a `postfix` to append to the end of the filename to disambiguate different fits and to avoid overwriting fitting files- it is only one file per fit completed.
76
+
This will write data describing a fit to a file, into the path provided to the callback. If multiple fits are present simultaneously, use the `postfix`argument to append to the end of the filename to disambiguate different fits and to avoid overwriting fitting files.
36
77
37
-
If you provide a signal name for the `yerr` argument then an extra column for `y uncertainty` will be displayed in the fitting file. You have the option to not provide anything for this argument if you do not want to have uncertainty information in your fitting file. Keep in mind that even if you provide `yerr` in [`LiveFitLogger`](ibex_bluesky_core.callbacks.LiveFitLogger), you will still need to provide `yerr` in [`LiveFit`](ibex_bluesky_core.callbacks.LiveFit) if you want uncertainty/weight per point to influence the fit.
78
+
If you provide a signal name for the `yerr` argument, then an extra column for `y uncertainty` will be displayed in the fitting file. Keep in mind that even if you provide `yerr` in {py:obj}`~ibex_bluesky_core.callbacks.LiveFitLogger`, you will still *also*need to provide `yerr` in {py:obj}`~ibex_bluesky_core.callbacks.LiveFit` if you want uncertainty/weight per point to influence the fit.
Copy file name to clipboardExpand all lines: doc/callbacks/isiscallbacks.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
{#icc}
2
-
# ISIS Standard Callbacks ({py:obj}`ISISCallbacks <ibex_bluesky_core.callbacks.ISISCallbacks>`)
2
+
# ISIS Standard Callbacks ({py:obj}`~ibex_bluesky_core.callbacks.ISISCallbacks`)
3
3
4
-
{py:obj}`ISISCallbacks <ibex_bluesky_core.callbacks.ISISCallbacks>` is a helper to add common callbacks to 1-dimensional scans with a single dependent variable (with an optional uncertainty) and a single independent variable. This should avoid some repetition as you don't need to pass `x` and `y` to each callback.
4
+
{py:obj}`~ibex_bluesky_core.callbacks.ISISCallbacks` is a helper to add common callbacks to 1-dimensional scans with a single dependent variable (with an optional uncertainty) and a single independent variable. This should avoid some repetition as you don't need to pass `x` and `y` to each callback.
5
5
6
6
It is composed of the following callbacks:
7
7
- {py:obj}`ibex_bluesky_core.callbacks.LiveFit`
@@ -16,13 +16,13 @@ It is composed of the following callbacks:
16
16
17
17
## Live table
18
18
19
-
A {external+bluesky:py:obj}`LiveTable <bluesky.callbacks.LiveTable>` is enabled by default. This will show the values of X and Y according to their `seq_num` or event order.
19
+
A {external+bluesky:py:obj}`~bluesky.callbacks.LiveTable` is enabled by default. This will show the values of X and Y according to their `seq_num` or event order.
20
20
21
21
You can pass optional fields to be displayed in the LiveTable with the `fields_for_live_table` argument or the `measured_fields` argument if you want the fields to be put in the human-readable file (see {ref}`below. <hr_files_icc>`)
22
22
23
23
## Plotting
24
24
25
-
Plotting is enabled by default and running a plan with {py:obj}`ISISCallbacks <ibex_bluesky_core.callbacks.ISISCallbacks>` will close any current active plots.
25
+
Plotting is enabled by default and running a plan with {py:obj}`~ibex_bluesky_core.callbacks.ISISCallbacks` will close any current active plots.
26
26
27
27
## Fitting
28
28
@@ -32,7 +32,7 @@ After a scan has run you can get the fitting results by using the {py:obj}`live_
32
32
33
33
## Centre of mass and Peak Stats
34
34
35
-
These are both enabled by default. To access {py:obj}`Centre of Mass <ibex_bluesky_core.callbacks.CentreOfMass>` information after a plan, use the {py:obj}`com <ibex_bluesky_core.callbacks.ISISCallbacks.com>` property.
35
+
These are both enabled by default. To access {py:obj}`~ibex_bluesky_core.callbacks.CentreOfMass` information after a plan, use the {py:obj}`com <ibex_bluesky_core.callbacks.ISISCallbacks.com>` property.
36
36
37
37
To access {external+bluesky:py:obj}`Peak Stats <bluesky.callbacks.fitting.PeakStats>` after a plan use the {py:obj}`peak_stats <ibex_bluesky_core.callbacks.ISISCallbacks.peak_stats>` property.
0 commit comments