{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Graphene hv scan\n\nSimple workflow for analyzing a photon energy scan data of graphene as\nsimulated from a third nearest neighbor tight binding model.\nThe same workflow can be applied to any photon energy scan.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import the \"fundamental\" python libraries for a generic data analysis:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nimport matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Instead of loading the file as for example:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# from navarp.utils import navfile\n# file_name = r\"nxarpes_simulated_cone.nxs\"\n# entry = navfile.load(file_name)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we build the simulated graphene signal with a dedicated function defined\njust for this purpose:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from navarp.extras.simulation import get_tbgraphene_hv\n\nentry = get_tbgraphene_hv(\n scans=np.arange(90, 150, 2),\n angles=np.linspace(-7, 7, 300),\n ebins=np.linspace(-3.3, 0.4, 450),\n tht_an=-18,\n)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot a single analyzer image at scan = 90\nFirst I have to extract the isoscan from the entry, so I use the isoscan\nmethod of entry:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "iso0 = entry.isoscan(scan=90)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then to plot it using the 'show' method of the extracted iso0:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "iso0.show(yname='ekin')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or by string concatenation, directly as:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "entry.isoscan(scan=90).show(yname='ekin')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fermi level determination\nThe initial guess for the binding energy is: ebins = ekins - (hv - work_fun).\nHowever, the better way is to proper set the Fermi level first and then\nderives everything form it. In this case the Fermi level kinetic energy is\nchanging along the scan since it is a photon energy scan.\nSo to set the Fermi level I have to give an array of values corresponding to\neach photon energy. By definition I can give:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "efermis = entry.hv - entry.analyzer.work_fun\nentry.set_efermi(efermis)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or I can use a method for its detection, but in this case, it is important to\ngive a proper energy range for each photon energy. For example for each\nphoton a good range is within 0.4 eV around the photon energy minus the\nanalyzer work function:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "energy_range = (\n (entry.hv[:, None] - entry.analyzer.work_fun) +\n np.array([-0.4, 0.4])[None, :])\n\nentry.autoset_efermi(energy_range=energy_range)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In both cases the binding energy and the photon energy will be updated\nconsistently. Note that the work function depends on the beamline or\nlaboratory. If not specified is 4.5 eV.\n\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To check the Fermi level detection I can have a look on each photon energy.\nHere I show only the first 10 photon energies:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "for scan_i in range(10):\n print(\"hv = {} eV, E_F = {:.0f} eV, Res = {:.0f} meV\".format(\n entry.hv[scan_i],\n entry.efermi[scan_i],\n entry.efermi_fwhm[scan_i]*1000\n ))\n entry.plt_efermi_fit(scan_i=scan_i)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot a single analyzer image at scan = 110 with the Fermi level aligned\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "entry.isoscan(scan=110).show(yname='eef')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plotting iso-energetic cut at ekin = efermi\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "entry.isoenergy(0).show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plotting in the reciprocal space (k-space)\nI have to define first the reference point to be used for the transformation.\nMeaning a point in the angular space which I know it correspond to a\nparticular point in the k-space. In this case the graphene Dirac-point is for\nhv = 120 is at ekin = 114.3 eV and tht_p = -0.6 (see the figure below), which\nin the k-space has to correspond to kx = 1.7.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "hv_p = 120\n\nentry.isoscan(scan=hv_p, dscan=0).show(yname='ekin', cmap='cividis')\n\ntht_p = -0.6\ne_kin_p = 114.3\nplt.axvline(tht_p, color='w')\nplt.axhline(e_kin_p, color='w')\n\nentry.set_kspace(\n tht_p=tht_p,\n k_along_slit_p=1.7,\n scan_p=0,\n ks_p=0,\n e_kin_p=e_kin_p,\n inn_pot=14,\n p_hv=True,\n hv_p=hv_p,\n)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once it is set, all the isoscan or iscoenergy extracted from the entry will\nnow get their proper k-space scales:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "entry.isoscan(120).show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "sphinx_gallery_thumbnail_number = 17\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "entry.isoenergy(0).show(cmap='cividis')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "I can also place together in a single figure different images:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig, axs = plt.subplots(1, 2)\n\nentry.isoscan(120).show(ax=axs[0])\nentry.isoenergy(-0.9).show(ax=axs[1])\n\nplt.tight_layout()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Many other options:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig, axs = plt.subplots(2, 2)\n\nscan = 110\ndscan = 0\nebin = -0.9\ndebin = 0.01\n\nentry.isoscan(scan, dscan).show(ax=axs[0][0], xname='tht', yname='ekin')\nentry.isoscan(scan, dscan).show(ax=axs[0][1], cmap='binary')\n\naxs[0][1].axhline(ebin-debin)\naxs[0][1].axhline(ebin+debin)\n\nentry.isoenergy(ebin, debin).show(\n ax=axs[1][0], xname='tht', yname='phi', cmap='cividis')\nentry.isoenergy(ebin, debin).show(\n ax=axs[1][1], cmap='magma', cmapscale='log')\n\naxs[1][0].axhline(scan, color='w', ls='--')\naxs[0][1].axvline(1.7, color='r', ls='--')\naxs[1][1].axvline(1.7, color='r', ls='--')\n\nx_note = 0.05\ny_note = 0.98\n\nfor ax in axs[0][:]:\n ax.annotate(\n \"$scan \\: = \\: {} eV$\".format(scan, dscan),\n (x_note, y_note),\n xycoords='axes fraction',\n size=8, rotation=0, ha=\"left\", va=\"top\",\n bbox=dict(\n boxstyle=\"round\", fc='w', alpha=0.65, edgecolor='None', pad=0.05\n )\n )\n\nfor ax in axs[1][:]:\n ax.annotate(\n \"$E-E_F \\: = \\: {} \\pm {} \\; eV$\".format(ebin, debin),\n (x_note, y_note),\n xycoords='axes fraction',\n size=8, rotation=0, ha=\"left\", va=\"top\",\n bbox=dict(\n boxstyle=\"round\", fc='w', alpha=0.65, edgecolor='None', pad=0.05\n )\n )\n\nplt.tight_layout()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.13" } }, "nbformat": 4, "nbformat_minor": 0 }