.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/model_fitting/EELS_curve_fitting.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_model_fitting_EELS_curve_fitting.py: EELS curve fitting ================== Performs curve fitting to an EELS spectrum, plots the result and saves it as png file. .. GENERATED FROM PYTHON SOURCE LINES 10-21 .. code-block:: Python import hyperspy.api as hs s = hs.load("../coreloss_spectrum.msa", signal_type="EELS") low_loss = hs.load("../lowloss_spectrum.msa", signal_type="EELS") s.add_elements(("Mn", "O")) s.set_microscope_parameters( beam_energy=300, convergence_angle=24.6, collection_angle=13.6 ) .. GENERATED FROM PYTHON SOURCE LINES 22-28 Create a model and fit it to the data. .. note:: By default, :ref:`generalized oscillator strength (GOS) ` calculated using density functional theory (DFT) are used. Use the ``GOS`` parameter to change to use other GOS, for example ``GOS="dirac"``. .. GENERATED FROM PYTHON SOURCE LINES 28-33 .. code-block:: Python m = s.create_model(low_loss=low_loss) m.enable_fine_structure() m.multifit(kind="smart") .. GENERATED FROM PYTHON SOURCE LINES 34-37 Print the fitted intensities and convert them to areal density (atoms/nm²). This assumes the low-loss spectrum was passed *raw* (counts) and that both spectra share the same dwell time. .. GENERATED FROM PYTHON SOURCE LINES 37-43 .. code-block:: Python m.quantify() for edge in m.edges: N = edge.intensity.value * 1e10 print(f"{edge.name}: {N:.3e} atoms/nm²") .. rst-class:: sphx-glr-script-out .. code-block:: none Absolute quantification: Elem. Intensity O 0.001607 Mn 0.000463 O_K: 1.607e+07 atoms/nm² Mn_L3: 4.626e+06 atoms/nm² Mn_L2: 4.626e+06 atoms/nm² Mn_L1: 4.626e+06 atoms/nm² .. GENERATED FROM PYTHON SOURCE LINES 44-45 Plot the model fit result .. GENERATED FROM PYTHON SOURCE LINES 45-46 .. code-block:: Python m.plot() .. image-sg:: /auto_examples/model_fitting/images/sphx_glr_EELS_curve_fitting_001.png :alt: coreloss_spectrum Signal :srcset: /auto_examples/model_fitting/images/sphx_glr_EELS_curve_fitting_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.496 seconds) .. _sphx_glr_download_auto_examples_model_fitting_EELS_curve_fitting.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: EELS_curve_fitting.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: EELS_curve_fitting.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: EELS_curve_fitting.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_