
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/plot_basic_commands.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_basic_commands.py>`
        to download the full example code.

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

.. _sphx_glr_auto_examples_plot_basic_commands.py:


Simulated cone basic analysis
=============================

Simple workflow for analyzing a deflector scan data.
The same workflow can be applied in the case of manipulator angular scans.

.. GENERATED FROM PYTHON SOURCE LINES 11-12

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

.. GENERATED FROM PYTHON SOURCE LINES 12-15

.. code-block:: Python


    import numpy as np








.. GENERATED FROM PYTHON SOURCE LINES 16-17

Import the navarp libraries:

.. GENERATED FROM PYTHON SOURCE LINES 17-20

.. code-block:: Python


    from navarp.utils import navfile





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

 .. code-block:: none

    WARNING: igor2 package not found. It is not necessary but, if not present, pxt and ibw files cannot be loaded.
    To install it in your python enviroment do: 
    pip install igor2




.. GENERATED FROM PYTHON SOURCE LINES 21-22

Load the data from a file:

.. GENERATED FROM PYTHON SOURCE LINES 22-26

.. code-block:: Python


    file_name = r"nxarpes_simulated_cone.nxs"
    entry = navfile.load(file_name)





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

 .. code-block:: none

    instrument_name = simulated




.. GENERATED FROM PYTHON SOURCE LINES 27-29

Plot a single slice
Ex: scan = 0.5

.. GENERATED FROM PYTHON SOURCE LINES 29-33

.. code-block:: Python


    scan = 0.5
    entry.isoscan(scan).show()




.. image-sg:: /auto_examples/images/sphx_glr_plot_basic_commands_001.png
   :alt: plot basic commands
   :srcset: /auto_examples/images/sphx_glr_plot_basic_commands_001.png
   :class: sphx-glr-single-img


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

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x7809480a52b0>



.. GENERATED FROM PYTHON SOURCE LINES 34-35

Fermi level determination

.. GENERATED FROM PYTHON SOURCE LINES 35-43

.. code-block:: Python


    entry.autoset_efermi(energy_range=[93.8, 94.3])
    entry.plt_efermi_fit()

    print("Fermi level = {:.3f} meV".format(entry.efermi))
    print("Energy resolution = {:.0f} meV".format(entry.efermi_fwhm*1000))
    print("hv = {:g} eV".format(np.squeeze(entry.hv)))




.. image-sg:: /auto_examples/images/sphx_glr_plot_basic_commands_002.png
   :alt: plot basic commands
   :srcset: /auto_examples/images/sphx_glr_plot_basic_commands_002.png
   :class: sphx-glr-single-img


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

 .. code-block:: none

    /build/navarp-1RRLiy/navarp-1.6.0/navarp/utils/fermilevel.py:67: RuntimeWarning: divide by zero encountered in divide
      ddata_s_denergies = ddata_s_denergies/np.abs(data_sum)
    /build/navarp-1RRLiy/navarp-1.6.0/navarp/utils/fermilevel.py:67: RuntimeWarning: invalid value encountered in divide
      ddata_s_denergies = ddata_s_denergies/np.abs(data_sum)
    Fermi level at 93.8881 eV
    Energy resolution = 67.2 meV (i.e. FWHM of the Gaussian shape which, convoluted with a step function, fits the Fermi edge)
    Photon energy is now set to 98.4881 eV (instead of 100.0000 eV)
    Fermi level = 93.888 meV
    Energy resolution = 67 meV
    hv = 98.4881 eV




.. GENERATED FROM PYTHON SOURCE LINES 44-46

Since now the Fermi level is known, the same plot is automatically aligned
Ex: scan = 0.5

.. GENERATED FROM PYTHON SOURCE LINES 46-50

.. code-block:: Python


    scan = 0.5
    entry.isoscan(scan).show()




.. image-sg:: /auto_examples/images/sphx_glr_plot_basic_commands_003.png
   :alt: plot basic commands
   :srcset: /auto_examples/images/sphx_glr_plot_basic_commands_003.png
   :class: sphx-glr-single-img


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

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x780947408a50>



.. GENERATED FROM PYTHON SOURCE LINES 51-53

Plotting iso-energetic cut
Ex: isoenergy cut at ekin = efermi

.. GENERATED FROM PYTHON SOURCE LINES 53-57

.. code-block:: Python


    ebin = 0
    debin = 0.005
    entry.isoenergy(ebin, debin).show()



.. image-sg:: /auto_examples/images/sphx_glr_plot_basic_commands_004.png
   :alt: plot basic commands
   :srcset: /auto_examples/images/sphx_glr_plot_basic_commands_004.png
   :class: sphx-glr-single-img


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

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x78094747ad50>




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

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


.. _sphx_glr_download_auto_examples_plot_basic_commands.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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