{"id":32610994,"url":"https://github.com/asaboor-gh/pivotpy","last_synced_at":"2025-10-30T13:55:20.858Z","repository":{"id":39872145,"uuid":"254962890","full_name":"asaboor-gh/pivotpy","owner":"asaboor-gh","description":"Python Processing Tool for Vasp Ipnut/Output","archived":false,"fork":false,"pushed_at":"2023-07-06T21:36:36.000Z","size":356844,"stargazers_count":13,"open_issues_count":5,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-06T11:28:22.410Z","etag":null,"topics":["bandstructure","dft","dos","interpolate","matplotlib","plotly","powershell","python","spin-polarized","vasprun"],"latest_commit_sha":null,"homepage":"https://massgh.github.io/pivotpy/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asaboor-gh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-04-11T22:01:15.000Z","updated_at":"2025-01-18T02:13:13.000Z","dependencies_parsed_at":"2023-10-11T13:14:08.257Z","dependency_job_id":null,"html_url":"https://github.com/asaboor-gh/pivotpy","commit_stats":{"total_commits":425,"total_committers":1,"mean_commits":425.0,"dds":0.0,"last_synced_commit":"6e602b84812a4c52fbf73820ad67c480b38b3b1f"},"previous_names":["asaboor-gh/pivotpy","massgh/pivotpy"],"tags_count":0,"template":false,"template_full_name":"fastai/nbdev_template","purl":"pkg:github/asaboor-gh/pivotpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asaboor-gh%2Fpivotpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asaboor-gh%2Fpivotpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asaboor-gh%2Fpivotpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asaboor-gh%2Fpivotpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asaboor-gh","download_url":"https://codeload.github.com/asaboor-gh/pivotpy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asaboor-gh%2Fpivotpy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281818075,"owners_count":26566859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bandstructure","dft","dos","interpolate","matplotlib","plotly","powershell","python","spin-polarized","vasprun"],"created_at":"2025-10-30T13:54:32.691Z","updated_at":"2025-10-30T13:55:20.851Z","avatar_url":"https://github.com/asaboor-gh.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PivotPy\r\n\u003e A Python Processing Tool for Vasp Input/Output. A CLI is available in Powershell, see \u003ca href='https://github.com/massgh/Vasp2Visual'\u003eVasp2Visual\u003c/a\u003e.\r\n\r\n\r\n[![Run in Azure](https://notebooks.azure.com/launch.png)](https://testazurenotebooks-massaz.notebooks.azure.com/j/notebooks/test.ipynb)\r\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/massgh/pivotpy/blob/master/test.ipynb)\r\n\r\n\r\n\r\n\r\n\u003cstyle\u003ea{text-decoration: none !important;color:lightkblue;font-weight:bold;}\r\n                a:focus,a:active,a:hover{color:hotpink !important;}\u003c/style\u003e\r\n\u003e [\u0026nbsp;`▶` Index●\u0026nbsp;](https://massgh.github.io/pivotpy/)  \r\n\u003e [\u0026nbsp;`▶` Example\u0026nbsp;](https://massgh.github.io/pivotpy/Example)  \r\n\u003e [\u0026nbsp;`▶` StaticPlots\u0026nbsp;](https://massgh.github.io/pivotpy/StaticPlots)  \r\n\u003e [\u0026nbsp;`▶` InteractivePlots\u0026nbsp;](https://massgh.github.io/pivotpy/InteractivePlots)  \r\n\u003e [\u0026nbsp;`▶` SpinProjectedSurfaces\u0026nbsp;](https://massgh.github.io/pivotpy/SpinProjectedSurfaces)  \r\n\u003e [\u0026nbsp;`▶` StructureIO\u0026nbsp;](https://massgh.github.io/pivotpy/StructureIO)  \r\n\u003e [\u0026nbsp;`▶` Widgets\u0026nbsp;](https://massgh.github.io/pivotpy/Widgets)  \r\n\u003e [\u0026nbsp;`▶` MainAPI\u0026nbsp;](https://massgh.github.io/pivotpy/MainAPI)  \r\n\r\n\r\n\r\n\r\n## Install\r\n`pip install pivotpy`\r\n\r\nTo install as developer and make changes (Recommended), do the following:\r\n```shell\r\ngit clone https://github.com/massgh/pivotpy.git\r\ncd pivotpy\r\npip install -r requirements.txt\r\npip install -e .\r\n```\r\n\r\n## How to use\r\n- Use commnad `pivotpy` in regular terminal to quickly launch documentation any time. \r\n- See [Full Documentation](https://massgh.github.io/pivotpy/).\r\n- See a [Calculation Example](https://massgh.github.io/pivotpy/Example.html)\r\n- For CLI, use [Vasp2Visual](https://github.com/massgh/Vasp2Visual).\r\n- See [PDF Slides](https://github.com/massgh/InteractiveHTMLs/tree/master/docs/IPySlides.pdf) for detailed introduction.\r\n\r\n## CLI commnds\r\n- Use `pivotpy` in system terminal to launch DOCS. \r\n- Use `pivotpy_get_poscar` to download POSCAR.\r\n- Use `pivotpy_get_kpath` to create fine controlled KPATH. \r\n\r\n## Plot in Terminal without GUI\r\nUse `pp.plt2text(colorful=True/False)` after matplotlib's code and your figure will appear in terminal. You need to zoom out alot to get a good view like below.\r\n\r\nTip: Use file [matplotlib2terminal.py](https://gist.github.com/massgh/d5cc44ad32510d3ff58cfefd75c6884e) on github independent of this package to plot in terminal. \r\n![IMG](terminal.jpg)\r\n\r\n# Ipywidgets-based GUI\r\nSee GIF here:\r\n![GIF](widget.gif) \r\n\r\n# Live Slides in Jupyter Notebook\r\nNavigate to  [ipyslides](https://github.com/massgh/ipyslides) or do `pip install ipyslides` to create beautiful data driven presentation in Jupyter Notebook.\r\n\r\n```python\r\nimport os, pivotpy as pp\r\nwith pp.set_dir('E:/Research/graphene_example/ISPIN_1/bands'):\r\n    vr = pp.Vasprun(elim=[-5,5])\r\n\r\nprint('Try Follwing Methods:')\r\nfor v in dir(vr):\r\n    if not v.startswith('_'):\r\n        print('vr.'+v)\r\n```\r\n\r\n    Try Follwing Methods:\r\n    vr.Fermi\r\n    vr.data\r\n    vr.elim\r\n    vr.fermi\r\n    vr.get_band_info\r\n    vr.get_en_diff\r\n    vr.get_fermi\r\n    vr.iplot_dos_lines\r\n    vr.iplot_rgb_lines\r\n    vr.kticks\r\n    vr.poscar\r\n    vr.select\r\n    vr.splot_bands\r\n    vr.splot_color_lines\r\n    vr.splot_dos_lines\r\n    vr.splot_en_diff\r\n    vr.splot_rgb_lines\r\n    vr.to_json\r\n    vr.to_pickle\r\n    \r\n\r\n```python\r\nimport matplotlib.pyplot as plt \r\nax1,ax2 = pp.get_axes((6,3),ncols=2)\r\nax1.plot(vr.data.scsteps['e_fr_energy'],lw=3, label = 'e_fr_energy',color='k')\r\nax1.plot(vr.data.scsteps['e_0_energy'],lw=0.7,ls='dashed',label='e_0_energy',color='skyblue')\r\nax1.set_ylabel('Energy (eV)')\r\nax1.set_xlabel('Iteration Number')\r\nax1.legend()\r\n\r\nvr.poscar.splot_lat(ax=ax2,plane='xy')\r\nX, Y, Z = vr.data.poscar.coords.T\r\nq = ax2.quiver(X,Y,*vr.data.force[:,:2].T,scale=25,color='r')\r\nax2.quiverkey(q, 0.7, 1, 7, 'Force (arb. units)')\r\nax2.add_legend()\r\n```\r\n\r\n\r\n![svg](docs/images/output_8_0.svg)\r\n\r\n\r\n## Matplotlib's static plots\r\n- Add anything from legend,colorbar, colorwheel. In below figure, all three are shown.\r\n- Use aliases such as sbands, sdos,srgb,irgb,scolor,idos for plotting. \r\n\r\n```python\r\n#collapse_input\r\nimport pivotpy as pp, numpy as np\r\nimport matplotlib.pyplot as plt \r\nvr1=pp.Vasprun('E:/Research/graphene_example/ISPIN_2/bands/vasprun.xml')\r\nvr2=pp.Vasprun('E:/Research/graphene_example/ISPIN_2/dos/vasprun.xml')\r\naxs = pp.get_axes(ncols=3,widths=[2,1,2.2],sharey=True,wspace=0.05,figsize=(8,2.6))\r\nelements=[0,[0],[0,1]]\r\norbs=[[0],[2],[1,3]]\r\nlabels=['s','$p_z$','$(p_x+p_y)$']\r\nti_cks=dict(ktick_inds=[0,30,60,-1],ktick_vals=['Γ','M','K','Γ'])\r\nargs_dict=dict(elements=elements,orbs=orbs,labels=labels,elim=[-20,15],colormap='viridis',)\r\nvr1.splot_bands(ax=axs[0],**ti_cks,elim=[-20,15])\r\nvr1.splot_rgb_lines(ax=axs[2],**args_dict,**ti_cks,colorbar=False)\r\nvr2.splot_dos_lines(ax=axs[1],vertical=True,spin='both',include_dos='pdos',**args_dict,legend_kwargs={'ncol': 3})\r\naxs[2].color_cube(loc=(0.7,0.25),size=0.35)\r\npp._show() \r\n```\r\n\r\n    \u001b[0;92m Given 0 at position 1 of sequence =\u003e 'C': range(0, 2). To just pick one ion, write it as [0].\u001b[00m\r\n    \r\n\r\n\r\n![svg](docs/images/output_10_1.svg)\r\n\r\n\r\n## Interactive plots using plotly\r\n\r\n```python\r\nargs_dict['labels'] = ['s','p_z','p_x+p_y']\r\nargs_dict.pop('colormap')\r\nfig1 = vr1.iplot_rgb_lines(**args_dict)\r\n#pp.iplot2html(fig1) #Do inside Google Colab, fig1 inside Jupyter\r\nfrom IPython.display import Markdown\r\nMarkdown(\"[See Interactive Plot](https://massgh.github.io/InteractiveHTMLs/iGraphene.html)\")\r\n```\r\n\r\n\r\n\r\n\r\n[See Interactive Plot](https://massgh.github.io/InteractiveHTMLs/iGraphene.html)\r\n\r\n\r\n\r\n## Brillouin Zone (BZ) Processing\r\n- Look in `pivotpy.sio` module or `pivotpy.api.POSCAR` class for details on generating mesh and path of KPOINTS as well as using Materials Projects' API to get POSCAR right in the working folder. Below is a screenshot of interactive BZ plot. You can `double click` on blue points and hit `Ctrl + C` to copy the high symmetry points relative to reciprocal lattice basis vectors. \r\n- Same color points lie on a sphere, with radius decreasing as red to blue and  gamma point in gold color. These color help distinguishing points but the points not always be equivalent, for example in FCC, there are two points on mid of edges connecting square-hexagon and hexagon-hexagon at equal distance from center but not the same points. \r\n- Any colored point's hover text is in gold background.      \r\n#### Look the output of `pivotpy.sio.splot_bz`.\r\n![BZ](docs\\images\\3bz.jpg)\r\n![Energy](docs\\images\\energy.jpg)\r\n[See Interactive BZ Plot](https://massgh.github.io/InteractiveHTMLs/BZ.html)\r\n\r\n## Interpolation \r\nAmost every bandstructure and DOS plot function has an argument `interp_nk` which is a dictionary with keys `n` (Number of additional points between adjacent points) and `k` (order of interpolation 0-3). `n \u003e k` must hold.\r\n\r\n```python\r\n#collapse_input\r\nimport pivotpy as pp, matplotlib.pyplot as plt\r\nplt.style.use('ggplot')\r\nk = vr1.data.kpath\r\nef = vr1.data.bands.Fermi\r\nevals = vr1.data.bands.evals.SpinUp - ef\r\n#Let's interpolate our graph to see effect. It is useful for colored graphs.\r\nknew,enew=pp.interpolate_data(x=k,y=evals,n=10,k=3)\r\nplot = plt.plot(k,evals,'m',lw=5,label='real data')\r\nplot = plt.plot(k,evals,'w',lw=1,label='interpolated',ls='dashed')\r\npp.splots.add_text(ax=plt.gca(),txts='Graphene')\r\n```\r\n\r\n\r\n![svg](docs/images/output_15_0.svg)\r\n\r\n\r\n## LOCPOT,CHG Visualization\r\ncheck out the class `pivotpy.LOCPOT` to visulize local potential/charge and magnetization in a given direction.\r\n\r\n## Running powershell commands from python.\r\nSome tasks are very tideious in python while just a click way in powershell. See below, and try to list processes in python yourself to see the difference!\r\n\r\n```python\r\npp.utils.ps2std(ps_command='(Get-Process)[0..4]')\r\n```\r\n\r\n    \u001b[32;1m NPM(K)    PM(M)      WS(M)     CPU(s)      Id  SI ProcessName\u001b[0m\r\n    \u001b[32;1m ------    -----      -----     ------      --  -- -----------\u001b[0m\r\n    22     6.92       8.27       0.33   14100   1 AcrobatNot…\r\n    6     1.29       5.68       0.00    7724   0 Aggregator…\r\n    19     7.22      20.85       0.00    5608   0 AppHelperC…\r\n    26    39.25      57.59       0.48    2064   1 Applicatio…\r\n    9     1.67       6.88       0.00    5264   0 armsvc\r\n    \r\n\r\n## Advancaed: Poweshell Cell/Line Magic `%%ps/%ps`\r\n- You can create a IPython cell magic to run powershell commands directly in IPython Shell/Notebook (Powershell core installation required).\r\n- Cell magic can be assigned to a variable `foo` by `%%ps --out foo`\r\n- Line magic can be assigned to a variable by `foo = %ps powershell_command`\r\n\r\nPut below code in ipython profile's startup file (create one) \"~/.ipython/profile_default/startup/powershell_magic.py\"\r\n```python\r\nfrom IPython.core.magic import register_line_cell_magic\r\nfrom IPython import get_ipython\r\n@register_line_cell_magic\r\ndef ps(line, cell=None):\r\n    if cell:\r\n        return get_ipython().run_cell_magic('powershell',line,cell)\r\n    else:\r\n        get_ipython().run_cell_magic('powershell','--out posh_output',line)\r\n        return posh_output.splitlines()\r\n``` \r\nAdditionally you need to add following lines in \"~/.ipython/profile_default/ipython_config.py\" file to make above magic work.\r\n```python\r\nfrom traitlets.config.application import get_config\r\nc = get_config()\r\nc.ScriptMagics.script_magics = ['powershell']\r\nc.ScriptMagics.script_paths = {\r\n    'powershell' : 'powershell.exe -noprofile -command -',\r\n    'pwsh': 'pwsh.exe -noprofile -command -'\r\n}\r\n```\r\n\r\n```python\r\n%%ps \r\nGet-ChildItem 'E:\\Research\\graphene_example\\'\r\n```\r\n\r\n    \r\n\r\n    \r\n\r\n        Directory: E:\\Research\\graphene_example\r\n\r\n    \r\n\r\n    \r\n\r\n    Mode                 LastWriteTime         Length Name        \r\n\r\n    ----                 -------------         ------ ----        \r\n\r\n    da----          6/9/2022  10:33 AM                ISPIN_1     \r\n\r\n    da----          5/9/2020   1:05 PM                ISPIN_2     \r\n\r\n    -a----          5/9/2020   1:01 PM          75331 OUTCAR      \r\n\r\n    -a----          5/9/2020   1:01 PM         240755 vasprun.xml \r\n\r\n    \r\n\r\n    \r\n\r\n\r\n\r\n```python\r\nx = %ps (Get-ChildItem 'E:\\Research\\graphene_example\\').Name\r\nx\r\n```\r\n\r\n\r\n\r\n\r\n    ['ISPIN_1', 'ISPIN_2', 'OUTCAR', 'vasprun.xml']\r\n\r\n\r\n\r\n[Functions Reference](functions.md)\r\n\r\n\r\n\r\n\r\n\u003cstyle\u003ea{text-decoration: none !important;color:lightkblue;font-weight:bold;}\r\n                a:focus,a:active,a:hover{color:hotpink !important;}\u003c/style\u003e\r\n\u003e [\u0026nbsp;`▶` Index●\u0026nbsp;](https://massgh.github.io/pivotpy/)  \r\n\u003e [\u0026nbsp;`▶` Example\u0026nbsp;](https://massgh.github.io/pivotpy/Example)  \r\n\u003e [\u0026nbsp;`▶` StaticPlots\u0026nbsp;](https://massgh.github.io/pivotpy/StaticPlots)  \r\n\u003e [\u0026nbsp;`▶` InteractivePlots\u0026nbsp;](https://massgh.github.io/pivotpy/InteractivePlots)  \r\n\u003e [\u0026nbsp;`▶` SpinProjectedSurfaces\u0026nbsp;](https://massgh.github.io/pivotpy/SpinProjectedSurfaces)  \r\n\u003e [\u0026nbsp;`▶` StructureIO\u0026nbsp;](https://massgh.github.io/pivotpy/StructureIO)  \r\n\u003e [\u0026nbsp;`▶` Widgets\u0026nbsp;](https://massgh.github.io/pivotpy/Widgets)  \r\n\u003e [\u0026nbsp;`▶` MainAPI\u0026nbsp;](https://massgh.github.io/pivotpy/MainAPI)  \r\n\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasaboor-gh%2Fpivotpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasaboor-gh%2Fpivotpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasaboor-gh%2Fpivotpy/lists"}