Note
Go to the end to download the full example code.
Plot Residual#
Fit an affine function and plot the residual.
import numpy as np
import hyperspy.api as hs
Create a signal:
Add noise:
s.add_poissonian_noise(random_state=0)
Create model:
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/rsciio/utils/rgb_tools.py:62: VisibleDeprecationWarning: The module `rsciio.utils.rgb_tools` has been renamed to `rsciio.utils.rgb` and it will be removed in version 1.0. Use `RGB_DTYPES` instead
warnings.warn(
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/rsciio/utils/rgb_tools.py:62: VisibleDeprecationWarning: The module `rsciio.utils.rgb_tools` has been renamed to `rsciio.utils.rgb` and it will be removed in version 1.0.
warnings.warn(
Fit for all navigation positions:
Exception ignored in: <function tqdm.__del__ at 0x7f4baac4ca40>
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/tqdm/std.py", line 1148, in __del__
self.close()
File "/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/tqdm/notebook.py", line 279, in close
self.disp(bar_style='danger', check_delay=False)
^^^^^^^^^
AttributeError: 'tqdm_notebook' object has no attribute 'disp'
0%| | 0/10 [00:00<?, ?it/s]
100%|██████████| 10/10 [00:00<00:00, 1370.46it/s]
Plot the fitted model with residual:
m.plot(plot_residual=True)
sphinx_gallery_thumbnail_number = 2
Total running time of the script: (0 minutes 0.469 seconds)

