Skip to main content

Package for bandsplot widget

Project description

widget-bandsplot: Jupyter Widget to Plot Band Structure and Density of States

PyPI version Binder

A Jupyter widget to plot band structures and density of states. The widget is using the bands-widget Javascript package, which is developed by Materials Cloud group.

Installation

To install use pip:

$ pip install widget_bandsplot

Usage

1. Plot both the band structure and the density of states (DOS) side by side

w = BandsPlotWidget(bands=[banddata1, banddata2], dos=dosdata, plot_fermilevel = True, show_legend = True, energy_range = {"ymin": -10.0, "ymax": 10.0})
display(w)

In order to plot the band structure and density of states, one needs to provide bands data and DOS data as JSON-files. The examples of the input JSON-files are provided in the examples/data folder. The JSON-files for the band structure can be exported with the AiiDA command line interface (CLI) verdi as demonstrated in the code below:

verdi data band export <PK> --format=json

One can plot several band structure input files together with the widget. The format of the DOS input dict is validate by the PDOS Schema, the exampla valid input is:

dos_data = {
    "fermi_energy": -7.0,
    "dos": [
        {
            "label": "Total DOS",   # required
            "x": [0.0, 0.1, 0.2],   # required
            "y": [1.2, 3.2, 0.0],   # required
            "borderColor": "#41e2b3",   # optional
            "backgroundColor": "#51258b",   # optional
            "backgroundAlpha": "52%",  #optional: A string with integer between 0-100 and '%' in end.
            "lineStyle": "dash",    # optional
        },
        {
            "label": "Co (s↑)",
            "x": [0.0, 0.1, 0.2],
            "y": [1.2, 3.2, 0.0],
            "lineStyle": "solid",
            "borderColor": "#43ee8b",
            "backgroundColor": "#59595c",
        },
        {
            "label": "Co (s↓)",
            "x": [0.0, 0.1, 0.2],
            "y": [1.2, 3.2, 0.0],
            "lineStyle": "solid",
            "borderColor": "#403bae",
            "backgroundColor": "#a16c5e",
        },
    ],
}

2. Plot only the band structure

w = BandsPlotWidget(bands=[banddata1, banddata2], plot_fermilevel = True, show_legend = True, energy_range = {"ymin": -10.0, "ymax": 10.0})
display(w)

3. Plot only the density of states (DOS)

w = BandsPlotWidget(dos=dosdata, plot_fermilevel = True, show_legend = True, energy_range = {"ymin": -10.0, "ymax": 10.0})
display(w)

When only plotting the density of states, the plot will be shown in horizontal format.

For developers

For a development installation (requires Node.js and Yarn version 1),

$ git clone https://github.com/osscar/widget-bandsplot.git
$ cd widget-bandsplot
$ pip install -e .
$ jupyter nbextension install --py --symlink --overwrite --sys-prefix widget_bandsplot
$ jupyter nbextension enable --py --sys-prefix widget_bandsplot

When actively developing your extension for JupyterLab, run the command:

$ jupyter labextension develop --overwrite widget_bandsplot

Then you need to rebuild the JS when you make a code change:

$ cd js
$ yarn run build

You then need to refresh the JupyterLab page when your javascript changes.

For maintainers

To create a new release, clone the repository, install development dependencies with pip install -e '.[dev]', and then execute bumpver update [--major|--minor|--patch] [--tag [alpha|beta|rc]]. This will:

  1. Create a tagged release with bumped version and push it to the repository.
  2. Trigger a GitHub actions workflow that creates a GitHub release and publishes it on PyPI.

Additional notes:

  • Use the --dry option to preview the release change.
  • The release tag (e.g. a/b/rc) is determined from the last release. Use the --tag option to switch the release tag.
  • This packages follows semantic versioning.

Acknowledgements

We acknowledge support from the EPFL Open Science Fund via the OSSCAR project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

widget-bandsplot-0.5.0.tar.gz (799.4 kB view details)

Uploaded Source

Built Distribution

widget_bandsplot-0.5.0-py3-none-any.whl (881.0 kB view details)

Uploaded Python 3

File details

Details for the file widget-bandsplot-0.5.0.tar.gz.

File metadata

  • Download URL: widget-bandsplot-0.5.0.tar.gz
  • Upload date:
  • Size: 799.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for widget-bandsplot-0.5.0.tar.gz
Algorithm Hash digest
SHA256 2c0e8a3fed481ad2b375237373c5a278a2b072965ec3092a70b12c7391276af6
MD5 c5a3d0cbc8b0d844340f429224b85c51
BLAKE2b-256 1185c29545e845d2f6dbe5f1be4f34a31bc087228530553781b8db7933abc409

See more details on using hashes here.

File details

Details for the file widget_bandsplot-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for widget_bandsplot-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 659be1dd7d2c215e7fe4267754716a51666105a2efd43cea7bc5f2cf9e9bff20
MD5 32562ab92a02857ea1ad7575b0b01853
BLAKE2b-256 575229499689a14fe9cd37cb7ee474c06aab18d0952647aa1112e358ac6aff29

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page