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

        Click :ref:`here <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:: default


    import numpy as np








.. GENERATED FROM PYTHON SOURCE LINES 16-17

Import the navarp libraries:

.. GENERATED FROM PYTHON SOURCE LINES 17-20

.. code-block:: default


    from navarp.utils import navfile








.. GENERATED FROM PYTHON SOURCE LINES 21-22

Load the data from a file:

.. GENERATED FROM PYTHON SOURCE LINES 22-26

.. code-block:: default


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





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

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


    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

 Out:

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x7f750d5a3dc0>



.. GENERATED FROM PYTHON SOURCE LINES 34-35

Fermi level determination

.. GENERATED FROM PYTHON SOURCE LINES 35-43

.. code-block:: default


    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

 Out:

 .. code-block:: none

    /build/navarp-sipDon/navarp-1.3.0/navarp/utils/fermilevel.py:67: RuntimeWarning: divide by zero encountered in true_divide
      ddata_s_denergies = ddata_s_denergies/np.abs(data_sum)
    /build/navarp-sipDon/navarp-1.3.0/navarp/utils/fermilevel.py:67: RuntimeWarning: invalid value encountered in true_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:: default


    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

 Out:

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x7f750ca9ad00>



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


    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

 Out:

 .. code-block:: none


    <matplotlib.collections.QuadMesh object at 0x7f750c15e820>




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

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


.. _sphx_glr_download_auto_examples_plot_basic_commands.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_basic_commands.py <plot_basic_commands.py>`



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

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


.. only:: html

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

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