.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/processing/baseline_removal.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_processing_baseline_removal.py: Baseline Removal ================ This example shows how to remove a baseline from a 1D signal using the `pybaselines `_ library. .. GENERATED FROM PYTHON SOURCE LINES 10-11 Create a signal .. GENERATED FROM PYTHON SOURCE LINES 11-15 .. code-block:: Python import hyperspy.api as hs s = hs.data.two_gaussians() .. GENERATED FROM PYTHON SOURCE LINES 16-17 Remove baseline using :meth:`~.api.signals.Signal1D.remove_baseline`: .. GENERATED FROM PYTHON SOURCE LINES 17-19 .. code-block:: Python s2 = s.remove_baseline(method="aspls", lam=1E7, inplace=False) .. GENERATED FROM PYTHON SOURCE LINES 20-21 Plot the signal and its baseline: .. GENERATED FROM PYTHON SOURCE LINES 21-24 .. code-block:: Python (s + (s-s2) * 1j).plot() # Choose the second figure as gallery thumbnail: # sphinx_gallery_thumbnail_number = 2 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/processing/images/sphx_glr_baseline_removal_001.png :alt: Two Gaussians Navigator :srcset: /auto_examples/processing/images/sphx_glr_baseline_removal_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/processing/images/sphx_glr_baseline_removal_002.png :alt: Two Gaussians Signal :srcset: /auto_examples/processing/images/sphx_glr_baseline_removal_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 6.490 seconds) .. _sphx_glr_download_auto_examples_processing_baseline_removal.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: baseline_removal.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: baseline_removal.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: baseline_removal.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_