
.. 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

        :ref:`Go to the end <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:: Python


    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:: Python


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

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

.. GENERATED FROM PYTHON SOURCE LINES 44-51

.. 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_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

 .. code-block:: none

    Fermi level at 115.4095 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.0095 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:: Python


    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

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x780947209590>



.. GENERATED FROM PYTHON SOURCE LINES 58-60

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

.. GENERATED FROM PYTHON SOURCE LINES 60-63

.. code-block:: Python


    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

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x7809471e3b10>



.. GENERATED FROM PYTHON SOURCE LINES 64-66

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

.. GENERATED FROM PYTHON SOURCE LINES 66-75

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

and check the isoenergy at the Fermi level:

.. GENERATED FROM PYTHON SOURCE LINES 77-80

.. code-block:: Python


    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

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x780947035bd0>



.. GENERATED FROM PYTHON SOURCE LINES 81-83

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

.. GENERATED FROM PYTHON SOURCE LINES 83-102

.. code-block:: Python


    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:: Python


    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

 .. code-block:: none


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



.. GENERATED FROM PYTHON SOURCE LINES 109-110

Run the interpolation defining an isok:

.. GENERATED FROM PYTHON SOURCE LINES 110-113

.. code-block:: Python


    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:: Python


    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

 .. code-block:: none


    <matplotlib.colorbar.Colorbar object at 0x7809468d4980>




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

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


.. _sphx_glr_download_auto_examples_plot_interpolation_gr_deflector_scan.py:

.. only:: html

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

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

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

    .. 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-zip

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


.. only:: html

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

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