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/33 [00:00<?, ?it/s]
  3%|▎         | 1/33 [00:02<01:06,  2.09s/it]
 39%|███▉      | 13/33 [00:03<00:05,  3.87it/s]
 64%|██████▎   | 21/33 [00:04<00:01,  6.80it/s]
100%|██████████| 33/33 [00:04<00:00,  7.90it/s]

Plot the signal and its baseline:

(s + (s-s2) * 1j).plot()
# Choose the second figure as gallery thumbnail:
# sphinx_gallery_thumbnail_number = 2
  • Two Gaussians Navigator
  • Two Gaussians Signal

Total running time of the script: (0 minutes 5.158 seconds)

Gallery generated by Sphinx-Gallery