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

.. only:: html

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

        Click :ref:`here <sphx_glr_download_auto_examples_plot_interpolation_gr_deflector_scan.py>`
        to download the full example code

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

.. _sphx_glr_auto_examples_plot_interpolation_gr_deflector_scan.py:


Interpolation on Graphene deflector scan
=========================================

Simple workflow for the interpolation of data along a generic path in the
k-space from its isoenergy cuts.
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 14-15

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

.. GENERATED FROM PYTHON SOURCE LINES 15-19

.. code-block:: default


    import numpy as np
    import matplotlib.pyplot as plt








.. GENERATED FROM PYTHON SOURCE LINES 20-21

Instead of loading the file as for example:

.. GENERATED FROM PYTHON SOURCE LINES 21-26

.. code-block:: default


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








.. GENERATED FROM PYTHON SOURCE LINES 27-29

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

.. GENERATED FROM PYTHON SOURCE LINES 29-41

.. code-block:: default

    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 42-44

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

.. GENERATED FROM PYTHON SOURCE LINES 44-51

.. code-block:: default


    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_interpolation_gr_deflector_scan_001.png
   :alt: plot interpolation gr deflector scan
   :srcset: /auto_examples/images/sphx_glr_plot_interpolation_gr_deflector_scan_001.png
   :class: sphx-glr-single-img


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

 Out:

 .. code-block:: none

    Fermi level at 115.4094 eV
    Energy resolution = 137.5 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.0094 eV (instead of 120.0000 eV)
    Energy of the Fermi level = 115 eV
    Energy resolution = 137 meV




.. GENERATED FROM PYTHON SOURCE LINES 52-54

Check for the Fermi level alignment
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. GENERATED FROM PYTHON SOURCE LINES 54-57

.. code-block:: default


    entry.isoscan(scan=0, dscan=0).show(yname='eef')




.. image-sg:: /auto_examples/images/sphx_glr_plot_interpolation_gr_deflector_scan_002.png
   :alt: plot interpolation gr deflector scan
   :srcset: /auto_examples/images/sphx_glr_plot_interpolation_gr_deflector_scan_002.png
   :class: sphx-glr-single-img


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

 Out:

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x7f26fba34390>



.. GENERATED FROM PYTHON SOURCE LINES 58-60

Plotting iso-energetic cut at ekin = efermi
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. GENERATED FROM PYTHON SOURCE LINES 60-63

.. code-block:: default


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




.. image-sg:: /auto_examples/images/sphx_glr_plot_interpolation_gr_deflector_scan_003.png
   :alt: plot interpolation gr deflector scan
   :srcset: /auto_examples/images/sphx_glr_plot_interpolation_gr_deflector_scan_003.png
   :class: sphx-glr-single-img


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

 Out:

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x7f26fb742e50>



.. GENERATED FROM PYTHON SOURCE LINES 64-66

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

.. GENERATED FROM PYTHON SOURCE LINES 66-75

.. code-block:: default


    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

 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 76-77

and check the isoenergy at the Fermi level:

.. GENERATED FROM PYTHON SOURCE LINES 77-80

.. code-block:: default


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




.. image-sg:: /auto_examples/images/sphx_glr_plot_interpolation_gr_deflector_scan_004.png
   :alt: plot interpolation gr deflector scan
   :srcset: /auto_examples/images/sphx_glr_plot_interpolation_gr_deflector_scan_004.png
   :class: sphx-glr-single-img


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

 Out:

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x7f26fba2a290>



.. GENERATED FROM PYTHON SOURCE LINES 81-83

Define the interpolation path points
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. GENERATED FROM PYTHON SOURCE LINES 83-102

.. code-block:: default


    kbins = 900
    k_GK = 1.702
    k_pts_xy = np.array([
        [0, 0],
        [k_GK, 0],
        [k_GK*np.cos(np.pi/3), k_GK*np.sin(np.pi/3)+0.05],
        [0, 0]
    ])
    kx_pts = k_pts_xy[:, 0]
    ky_pts = k_pts_xy[:, 1]

    klabels = [
        r'$\Gamma$',
        r'$\mathrm{K}$',
        r'$\mathrm{K}^{\prime}$',
        r'$\Gamma$'
    ]








.. GENERATED FROM PYTHON SOURCE LINES 103-104

and show them on the isoenergy at the Dirac point energy:

.. GENERATED FROM PYTHON SOURCE LINES 104-108

.. code-block:: default


    entry.isoenergy(-1.1, 0.02).show()
    plt.plot(kx_pts, ky_pts, '-+')




.. image-sg:: /auto_examples/images/sphx_glr_plot_interpolation_gr_deflector_scan_005.png
   :alt: plot interpolation gr deflector scan
   :srcset: /auto_examples/images/sphx_glr_plot_interpolation_gr_deflector_scan_005.png
   :class: sphx-glr-single-img


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

 Out:

 .. code-block:: none


    [<matplotlib.lines.Line2D object at 0x7f26fb843150>]



.. GENERATED FROM PYTHON SOURCE LINES 109-110

Run the interpolation defining an isok:

.. GENERATED FROM PYTHON SOURCE LINES 110-113

.. code-block:: default


    isok = entry.isok(kx_pts, ky_pts, klabels)








.. GENERATED FROM PYTHON SOURCE LINES 114-116

Show the final results with the executed path on the isoenergy:
sphinx_gallery_thumbnail_number = 6

.. GENERATED FROM PYTHON SOURCE LINES 116-127

.. code-block:: default


    fig, axs = plt.subplots(1, 2)

    entry.isoenergy(0, 0.02).show(ax=axs[0])

    isok.path_show(axs[0], 'k', 'k', xytext=(8, 8))

    qmesh = isok.show(ax=axs[1])

    fig.tight_layout()
    fig.colorbar(qmesh)



.. image-sg:: /auto_examples/images/sphx_glr_plot_interpolation_gr_deflector_scan_006.png
   :alt: plot interpolation gr deflector scan
   :srcset: /auto_examples/images/sphx_glr_plot_interpolation_gr_deflector_scan_006.png
   :class: sphx-glr-single-img


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

 Out:

 .. code-block:: none


    <matplotlib.colorbar.Colorbar object at 0x7f26fb755650>




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

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


.. _sphx_glr_download_auto_examples_plot_interpolation_gr_deflector_scan.py:


.. only :: html

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



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

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



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

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


.. only:: html

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

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