
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/plot_export_isoenergy_as_nxs_or_itx.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_plot_export_isoenergy_as_nxs_or_itx.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_plot_export_isoenergy_as_nxs_or_itx.py:


Export isoenergy at the Fermi level
====================================

Simple workflow for exporting the isoenergy at the Fermi level.
The data are a deflector scan on graphene as simulated from a third nearest
neighbor tight binding model. The same workflow can be applied to any
tilt-, polar-, deflector- or hv-scan.

.. GENERATED FROM PYTHON SOURCE LINES 13-14

Import the "fundamental" python libraries for a generic data analysis:

.. GENERATED FROM PYTHON SOURCE LINES 14-17

.. code-block:: Python


    import numpy as np








.. GENERATED FROM PYTHON SOURCE LINES 18-19

Instead of loading the file as for example:

.. GENERATED FROM PYTHON SOURCE LINES 19-24

.. code-block:: Python


    # from navarp.utils import navfile
    # file_name = r"nxarpes_simulated_cone.nxs"
    # entry = navfile.load(file_name)








.. GENERATED FROM PYTHON SOURCE LINES 25-27

Here we build the simulated graphene signal with a dedicated function defined
just for this purpose:

.. GENERATED FROM PYTHON SOURCE LINES 27-39

.. code-block:: Python

    from navarp.extras.simulation import get_tbgraphene_deflector

    entry = get_tbgraphene_deflector(
        scans=np.linspace(-5., 20., 91),
        angles=np.linspace(-25, 6, 400),
        ebins=np.linspace(-13, 0.4, 700),
        tht_an=-18,
        phi_an=0,
        hv=120,
        gamma=0.05
    )








.. GENERATED FROM PYTHON SOURCE LINES 40-42

Fermi level autoset
^^^^^^^^^^^^^^^^^^^^^^^^^

.. GENERATED FROM PYTHON SOURCE LINES 42-49

.. code-block:: Python


    entry.autoset_efermi(scan_range=[-5, 5], energy_range=[115.2, 115.8])
    print("Energy of the Fermi level = {:.0f} eV".format(entry.efermi))
    print("Energy resolution = {:.0f} meV".format(entry.efermi_fwhm*1000))

    entry.plt_efermi_fit()




.. image-sg:: /auto_examples/images/sphx_glr_plot_export_isoenergy_as_nxs_or_itx_001.png
   :alt: plot export isoenergy as nxs or itx
   :srcset: /auto_examples/images/sphx_glr_plot_export_isoenergy_as_nxs_or_itx_001.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Fermi level at 115.4092 eV
    Energy resolution = 137.8 meV (i.e. FWHM of the Gaussian shape which, convoluted with a step function, fits the Fermi edge)
    Photon energy is now set to 120.0092 eV (instead of 120.0000 eV)
    Energy of the Fermi level = 115 eV
    Energy resolution = 138 meV




.. GENERATED FROM PYTHON SOURCE LINES 50-52

Set the k-space for the transformation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. GENERATED FROM PYTHON SOURCE LINES 52-61

.. code-block:: Python


    entry.set_kspace(
        tht_p=0.1,
        k_along_slit_p=1.7,
        scan_p=0,
        ks_p=0,
        e_kin_p=114.3,
    )





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    tht_an = -17.979
    scan_type =  deflector
    inn_pot = 14.000
    scans_0 = 0.000
    phi_an = 0.000
    kspace transformation ready




.. GENERATED FROM PYTHON SOURCE LINES 62-65

Export the Fermi surface:
^^^^^^^^^^^^^^^^^^^^^^^^^
First of all let's show it:

.. GENERATED FROM PYTHON SOURCE LINES 65-68

.. code-block:: Python


    entry.isoenergy(0, 0.02).show()




.. image-sg:: /auto_examples/images/sphx_glr_plot_export_isoenergy_as_nxs_or_itx_002.png
   :alt: plot export isoenergy as nxs or itx
   :srcset: /auto_examples/images/sphx_glr_plot_export_isoenergy_as_nxs_or_itx_002.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x780947046210>



.. GENERATED FROM PYTHON SOURCE LINES 69-75

Then to be exported it mush be interpolated in a uniform grid.
This can be done by defining kbins in the isoenergy definition, which is the
number of points the momentum along the analyzer slit and the scan.
In this case the number will be [1000, 800] and we will call such isoenergy
object as isoatfermi.
sphinx_gallery_thumbnail_number = 3

.. GENERATED FROM PYTHON SOURCE LINES 75-78

.. code-block:: Python


    isoatfermi = entry.isoenergy(0, 0.02, kbins=[1000, 800])








.. GENERATED FROM PYTHON SOURCE LINES 79-80

To show what we are going to save, the method is always the same:

.. GENERATED FROM PYTHON SOURCE LINES 80-83

.. code-block:: Python


    isoatfermi.show()




.. image-sg:: /auto_examples/images/sphx_glr_plot_export_isoenergy_as_nxs_or_itx_003.png
   :alt: plot export isoenergy as nxs or itx
   :srcset: /auto_examples/images/sphx_glr_plot_export_isoenergy_as_nxs_or_itx_003.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x7809470e7b10>



.. GENERATED FROM PYTHON SOURCE LINES 84-85

To export it as NXdata class of the nexus format uncomment this line:

.. GENERATED FROM PYTHON SOURCE LINES 85-88

.. code-block:: Python


    # isoatfermi.export_as_nxs('fermimap.nxs')








.. GENERATED FROM PYTHON SOURCE LINES 89-90

To export it as igor-pro text file (itx) uncomment this line:

.. GENERATED FROM PYTHON SOURCE LINES 90-92

.. code-block:: Python


    # isoatfermi.export_as_itx('fermimap.itx')








.. rst-class:: sphx-glr-timing

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


.. _sphx_glr_download_auto_examples_plot_export_isoenergy_as_nxs_or_itx.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_export_isoenergy_as_nxs_or_itx.ipynb <plot_export_isoenergy_as_nxs_or_itx.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_export_isoenergy_as_nxs_or_itx.py <plot_export_isoenergy_as_nxs_or_itx.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_export_isoenergy_as_nxs_or_itx.zip <plot_export_isoenergy_as_nxs_or_itx.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
