Note
Go to the end to download the full example code.
Baseline Removal#
This example shows how to remove a baseline from a 1D signal using the pybaselines library.
Create a signal
import hyperspy.api as hs
s = hs.data.two_gaussians()
Remove baseline using remove_baseline()
:
s2 = s.remove_baseline(method="aspls", lam=1E7, inplace=False)
0%| | 0/50 [00:00<?, ?it/s]
2%|▏ | 1/50 [00:03<03:03, 3.75s/it]
26%|██▌ | 13/50 [00:04<00:09, 3.81it/s]
30%|███ | 15/50 [00:05<00:09, 3.51it/s]
78%|███████▊ | 39/50 [00:05<00:00, 13.71it/s]
100%|██████████| 50/50 [00:05<00:00, 9.31it/s]
Plot the signal and its baseline:
(s + (s-s2) * 1j).plot()
# Choose the second figure as gallery thumbnail:
# sphinx_gallery_thumbnail_number = 2
Total running time of the script: (0 minutes 6.658 seconds)