diff --git a/.doctrees/environment.pickle b/.doctrees/environment.pickle index c29130ee..a0d27595 100644 Binary files a/.doctrees/environment.pickle and b/.doctrees/environment.pickle differ diff --git a/.doctrees/index.doctree b/.doctrees/index.doctree index 41458ae3..ce7a1cbf 100644 Binary files a/.doctrees/index.doctree and b/.doctrees/index.doctree differ diff --git a/.doctrees/sumo-bandplot.doctree b/.doctrees/sumo-bandplot.doctree index 0b276b59..570f833a 100644 Binary files a/.doctrees/sumo-bandplot.doctree and b/.doctrees/sumo-bandplot.doctree differ diff --git a/.doctrees/sumo-bandstats.doctree b/.doctrees/sumo-bandstats.doctree index 3c74f058..4b9aafe0 100644 Binary files a/.doctrees/sumo-bandstats.doctree and b/.doctrees/sumo-bandstats.doctree differ diff --git a/.doctrees/sumo-dosplot.doctree b/.doctrees/sumo-dosplot.doctree index 2bc7bdef..3db70342 100644 Binary files a/.doctrees/sumo-dosplot.doctree and b/.doctrees/sumo-dosplot.doctree differ diff --git a/.doctrees/sumo-kgen.doctree b/.doctrees/sumo-kgen.doctree index 40b8e02e..18eeaf2c 100644 Binary files a/.doctrees/sumo-kgen.doctree and b/.doctrees/sumo-kgen.doctree differ diff --git a/.doctrees/sumo-optplot.doctree b/.doctrees/sumo-optplot.doctree index d346e657..307d813b 100644 Binary files a/.doctrees/sumo-optplot.doctree and b/.doctrees/sumo-optplot.doctree differ diff --git a/.doctrees/sumo-phonon-bandplot.doctree b/.doctrees/sumo-phonon-bandplot.doctree index cc015fdb..d4b80841 100644 Binary files a/.doctrees/sumo-phonon-bandplot.doctree and b/.doctrees/sumo-phonon-bandplot.doctree differ diff --git a/.doctrees/sumo.plotting.doctree b/.doctrees/sumo.plotting.doctree index fbdca8b7..30186bc8 100644 Binary files a/.doctrees/sumo.plotting.doctree and b/.doctrees/sumo.plotting.doctree differ diff --git a/_modules/sumo/cli/bandplot.html b/_modules/sumo/cli/bandplot.html index ee279d95..b79e73f6 100644 --- a/_modules/sumo/cli/bandplot.html +++ b/_modules/sumo/cli/bandplot.html @@ -44,9 +44,14 @@
import sys
import warnings
+try:
+ from importlib.resources import files as ilr_files
+except ImportError: # Python < 3.9
+ from importlib_resources import files as ilr_files
import matplotlib as mpl
-from pkg_resources import Requirement, resource_filename
-from pymatgen.electronic_structure.bandstructure import get_reconstructed_band_structure
+from pymatgen.electronic_structure.bandstructure import (
+ get_reconstructed_band_structure,
+)
from pymatgen.electronic_structure.core import Spin
from pymatgen.io.vasp.outputs import BSVasprun
@@ -372,6 +377,7 @@ Source code for sumo.cli.bandplot
# currently not supported as it is a pain to make subplots within subplots,
# although need to check this is still the case
+ # FIXME: is this necessary if mode can only be "rgb" and "stacked"?
if "split" in mode and dos_file:
logging.error(
"ERROR: Plotting split projected band structure with DOS"
@@ -420,7 +426,9 @@ Source code for sumo.cli.bandplot
else:
logging.info(f"Found PDOS file {pdos_file}")
else:
- logging.info(f"Cell file {cell_file} does not exist, cannot plot PDOS.")
+ logging.info(
+ f"Cell file {cell_file} does not exist, cannot plot PDOS."
+ )
dos, pdos = read_castep_dos(
dos_file,
@@ -649,7 +657,8 @@ Source code for sumo.cli.bandplot
"-c",
"--code",
default="vasp",
- help="Electronic structure code (default: vasp)." '"questaal" also supported.',
+ help="Electronic structure code (default: vasp)."
+ '"questaal" also supported.',
)
parser.add_argument(
"-p", "--prefix", metavar="P", help="prefix for the files generated"
@@ -790,7 +799,10 @@ Source code for sumo.cli.bandplot
"--orbitals",
type=_el_orb,
metavar="O",
- help=("orbitals to split into lm-decomposed " 'contributions (e.g. "Ru.d")'),
+ help=(
+ "orbitals to split into lm-decomposed "
+ 'contributions (e.g. "Ru.d")'
+ ),
)
parser.add_argument(
"--atoms",
@@ -854,7 +866,9 @@ Source code for sumo.cli.bandplot
parser.add_argument(
"--height", type=float, default=None, help="height of the graph"
)
- parser.add_argument("--width", type=float, default=None, help="width of the graph")
+ parser.add_argument(
+ "--width", type=float, default=None, help="width of the graph"
+ )
parser.add_argument(
"--ymin", type=float, default=-6.0, help="minimum energy on the y-axis"
)
@@ -905,8 +919,8 @@ Source code for sumo.cli.bandplot
logging.getLogger("").addHandler(console)
if args.config is None:
- config_path = resource_filename(
- Requirement.parse("sumo"), "sumo/plotting/orbital_colours.conf"
+ config_path = os.path.join(
+ ilr_files("sumo.plotting"), "orbital_colours.conf"
)
else:
config_path = args.config
@@ -914,7 +928,9 @@ Source code for sumo.cli.bandplot
colours.read(os.path.abspath(config_path))
warnings.filterwarnings("ignore", category=UserWarning, module="matplotlib")
- warnings.filterwarnings("ignore", category=UnicodeWarning, module="matplotlib")
+ warnings.filterwarnings(
+ "ignore", category=UnicodeWarning, module="matplotlib"
+ )
warnings.filterwarnings("ignore", category=UserWarning, module="pymatgen")
bandplot(
diff --git a/_modules/sumo/cli/dosplot.html b/_modules/sumo/cli/dosplot.html
index 85a37a92..f5c37a6b 100644
--- a/_modules/sumo/cli/dosplot.html
+++ b/_modules/sumo/cli/dosplot.html
@@ -49,7 +49,10 @@ Source code for sumo.cli.dosplot
import matplotlib as mpl
import numpy as np
-from pkg_resources import Requirement, resource_filename
+try:
+ from importlib.resources import files as ilr_files
+except ImportError: # Python < 3.9
+ from importlib_resources import files as ilr_files
mpl.use("Agg")
@@ -238,7 +241,6 @@ Source code for sumo.cli.dosplot
)
elif code.lower() == "castep":
-
if filename:
bands_file = filename
else:
@@ -294,7 +296,13 @@ Source code for sumo.cli.dosplot
else:
pdos_candidates = glob("dos.*")
for candidate in pdos_candidates:
- if candidate.split(".")[-1] in ("pdf", "png", "svg", "jpg", "jpeg"):
+ if candidate.split(".")[-1] in (
+ "pdf",
+ "png",
+ "svg",
+ "jpg",
+ "jpeg",
+ ):
continue
elif candidate.split(".")[-1].lower() in ("gz", "z", "bz2"):
pdos_file = candidate
@@ -456,14 +464,20 @@ Source code for sumo.cli.dosplot
)
parser.add_argument(
- "-f", "--filename", help="vasprun.xml file to plot", default=None, metavar="F"
+ "-f",
+ "--filename",
+ help="vasprun.xml file to plot",
+ default=None,
+ metavar="F",
)
parser.add_argument(
"-c",
"--code",
default="vasp",
metavar="C",
- help=('Input file format: "vasp" (vasprun.xml) or ' '"questaal" (opt.ext)'),
+ help=(
+ 'Input file format: "vasp" (vasprun.xml) or ' '"questaal" (opt.ext)'
+ ),
)
parser.add_argument(
"-p", "--prefix", metavar="P", help="prefix for the files generated"
@@ -483,7 +497,10 @@ Source code for sumo.cli.dosplot
"--orbitals",
type=_el_orb,
metavar="O",
- help=("orbitals to split into lm-decomposed " 'contributions (e.g. "Ru.d")'),
+ help=(
+ "orbitals to split into lm-decomposed "
+ 'contributions (e.g. "Ru.d")'
+ ),
)
parser.add_argument(
"-a",
@@ -534,7 +551,10 @@ Source code for sumo.cli.dosplot
),
)
parser.add_argument(
- "--no-legend", action="store_false", dest="legend", help="hide the plot legend"
+ "--no-legend",
+ action="store_false",
+ dest="legend",
+ help="hide the plot legend",
)
parser.add_argument(
"--legend-frame",
@@ -574,7 +594,9 @@ Source code for sumo.cli.dosplot
parser.add_argument(
"--height", type=float, default=None, help="height of the graph"
)
- parser.add_argument("--width", type=float, default=None, help="width of the graph")
+ parser.add_argument(
+ "--width", type=float, default=None, help="width of the graph"
+ )
parser.add_argument(
"--xmin", type=float, default=-6.0, help="minimum energy on the x-axis"
)
@@ -604,7 +626,10 @@ Source code for sumo.cli.dosplot
help="x-axis (i.e. energy) label/units",
)
parser.add_argument(
- "--ylabel", type=str, default="DOS", help="y-axis (i.e. DOS) label/units"
+ "--ylabel",
+ type=str,
+ default="DOS",
+ help="y-axis (i.e. DOS) label/units",
)
parser.add_argument(
"--yscale", type=float, default=1, help="scaling factor for the y-axis"
@@ -643,8 +668,8 @@ Source code for sumo.cli.dosplot
logging.getLogger("").addHandler(console)
if args.config is None:
- config_path = resource_filename(
- Requirement.parse("sumo"), "sumo/plotting/orbital_colours.conf"
+ config_path = os.path.join(
+ ilr_files("sumo.plotting"), "orbital_colours.conf"
)
else:
config_path = args.config
@@ -652,7 +677,9 @@ Source code for sumo.cli.dosplot
colours.read(os.path.abspath(config_path))
warnings.filterwarnings("ignore", category=UserWarning, module="matplotlib")
- warnings.filterwarnings("ignore", category=UnicodeWarning, module="matplotlib")
+ warnings.filterwarnings(
+ "ignore", category=UnicodeWarning, module="matplotlib"
+ )
warnings.filterwarnings("ignore", category=UserWarning, module="pymatgen")
if args.zero_energy is not None:
diff --git a/_modules/sumo/plotting.html b/_modules/sumo/plotting.html
index 47b179d2..4867e623 100644
--- a/_modules/sumo/plotting.html
+++ b/_modules/sumo/plotting.html
@@ -36,20 +36,29 @@ Source code for sumo.plotting
Subpackage providing helper functions for generating publication ready plots.
"""
from functools import wraps
+import os
import matplotlib.pyplot
import numpy as np
from matplotlib import rcParams
from matplotlib.collections import LineCollection
-from pkg_resources import resource_filename
+
+try:
+ from importlib.resources import files as ilr_files
+except ImportError: # Python < 3.9
+ from importlib_resources import files as ilr_files
colour_cache = {}
-sumo_base_style = resource_filename("sumo.plotting", "sumo_base.mplstyle")
-sumo_dos_style = resource_filename("sumo.plotting", "sumo_dos.mplstyle")
-sumo_bs_style = resource_filename("sumo.plotting", "sumo_bs.mplstyle")
-sumo_phonon_style = resource_filename("sumo.plotting", "sumo_phonon.mplstyle")
-sumo_optics_style = resource_filename("sumo.plotting", "sumo_optics.mplstyle")
+sumo_base_style = os.path.join(ilr_files("sumo.plotting"), "sumo_base.mplstyle")
+sumo_dos_style = os.path.join(ilr_files("sumo.plotting"), "sumo_dos.mplstyle")
+sumo_bs_style = os.path.join(ilr_files("sumo.plotting"), "sumo_bs.mplstyle")
+sumo_phonon_style = os.path.join(
+ ilr_files("sumo.plotting"), "sumo_phonon.mplstyle"
+)
+sumo_optics_style = os.path.join(
+ ilr_files("sumo.plotting"), "sumo_optics.mplstyle"
+)
@@ -71,8 +80,9 @@ Source code for sumo.plotting
def decorator(get_plot):
@wraps(get_plot)
- def wrapper(*args, fonts=None, style=None, no_base_style=False, **kwargs):
-
+ def wrapper(
+ *args, fonts=None, style=None, no_base_style=False, **kwargs
+ ):
if no_base_style:
list_style = []
else:
@@ -85,7 +95,9 @@ Source code for sumo.plotting
list_style += [style]
if fonts is not None:
- list_style += [{"font.family": "sans-serif", "font.sans-serif": fonts}]
+ list_style += [
+ {"font.family": "sans-serif", "font.sans-serif": fonts}
+ ]
matplotlib.pyplot.style.use(list_style)
return get_plot(*args, **kwargs)
@@ -236,14 +248,14 @@ Source code for sumo.plotting
Args:
x (list): x-axis data.
y (list): y-axis data (can be multidimensional array).
- weights (list): The weights of the color1, color2, and color3 channels. Given
- as an array with the shape (n, 3), where n is the same length as the x and
- y data.
+ weights (list): The weights of the color1, color2, and color3 channels.
+ Given as an array with the shape (n, 3), where n is the same length
+ as the x and y data.
color1 (str): A color specified in any way supported by matplotlib.
color2 (str): A color specified in any way supported by matplotlib.
color3 (str): A color specified in any way supported by matplotlib.
- colorspace (str): The colorspace in which to perform the interpolation. The
- allowed values are rgb, hsv, lab, luvlc, lablch, and xyz.
+ colorspace (str): The colorspace in which to perform the interpolation.
+ The allowed values are rgb, hsv, lab, luvlc, lablch, and xyz.
linestyles (:obj:`str`, optional): Linestyle for plot. Options are
``"solid"`` or ``"dotted"``.
"""
@@ -267,7 +279,11 @@ Source code for sumo.plotting
colours.extend(c.tolist())
lc = LineCollection(
- seg, colors=colours, rasterized=True, linewidth=linewidth, linestyles=linestyles
+ seg,
+ colors=colours,
+ rasterized=True,
+ linewidth=linewidth,
+ linestyles=linestyles,
)
return lc
@@ -283,10 +299,11 @@ Source code for sumo.plotting
color1 (str): A color specified in any way supported by matplotlib.
color2 (str): A color specified in any way supported by matplotlib.
color3 (str): A color specified in any way supported by matplotlib.
- weights (list): A list of weights with the shape (n, 3). Where the 3 values of
- the last axis give the amount of color1, color2, and color3.
- colorspace (str): The colorspace in which to perform the interpolation. The
- allowed values are rgb, hsv, lab, luvlc, lablch, and xyz.
+ weights (list): A list of weights with the shape (n, 3).
+ Where the 3 values of the last axis give the amount of
+ color1, color2, and color3.
+ colorspace (str): The colorspace in which to perform the interpolation.
+ The allowed values are rgb, hsv, lab, luvlc, lablch, and xyz.
Returns:
A list of colors, specified in the rgb format as a (n, 3) array.
@@ -311,7 +328,9 @@ Source code for sumo.plotting
"xyz": XYZColor,
}
if colorspace not in list(colorspace_mapping.keys()):
- raise ValueError(f"colorspace must be one of {colorspace_mapping.keys()}")
+ raise ValueError(
+ f"colorspace must be one of {colorspace_mapping.keys()}"
+ )
colorspace = colorspace_mapping[colorspace]
@@ -322,13 +341,19 @@ Source code for sumo.plotting
# now convert to the colorspace basis for interpolation
basis1 = np.array(
- convert_color(color1_rgb, colorspace, target_illuminant="d50").get_value_tuple()
+ convert_color(
+ color1_rgb, colorspace, target_illuminant="d50"
+ ).get_value_tuple()
)
basis2 = np.array(
- convert_color(color2_rgb, colorspace, target_illuminant="d50").get_value_tuple()
+ convert_color(
+ color2_rgb, colorspace, target_illuminant="d50"
+ ).get_value_tuple()
)
basis3 = np.array(
- convert_color(color3_rgb, colorspace, target_illuminant="d50").get_value_tuple()
+ convert_color(
+ color3_rgb, colorspace, target_illuminant="d50"
+ ).get_value_tuple()
)
# ensure weights is a numpy array
@@ -343,11 +368,12 @@ Source code for sumo.plotting
# convert colors to RGB
rgb_colors = [
- convert_color(colorspace(*c), sRGBColor).get_value_tuple() for c in colors
+ convert_color(colorspace(*c), sRGBColor).get_value_tuple()
+ for c in colors
]
- # ensure all rgb values are less than 1 (sometimes issues in interpolation gives
- # values slightly over 1)
+ # ensure all rgb values are less than 1 (sometimes issues in interpolation
+ # gives values slightly over 1)
return np.minimum(rgb_colors, 1)
diff --git a/_modules/sumo/symmetry/brad_crack_kpath.html b/_modules/sumo/symmetry/brad_crack_kpath.html
index 26f21be3..d21574bc 100644
--- a/_modules/sumo/symmetry/brad_crack_kpath.html
+++ b/_modules/sumo/symmetry/brad_crack_kpath.html
@@ -37,9 +37,14 @@ Source code for sumo.symmetry.brad_crack_kpath
"""
from json import load as load_json
+import os
import numpy as np
-import pkg_resources
+
+try:
+ from importlib.resources import files as ilr_files
+except ImportError: # Python < 3.9
+ from importlib_resources import files as ilr_files
from sumo.symmetry import Kpath
@@ -94,7 +99,9 @@
Source code for sumo.symmetry.brad_crack_kpath
spg_symbol = self.spg_symbol
lattice_type = self.lattice_type
- bravais = self._get_bravais_lattice(spg_symbol, lattice_type, a, b, c, unique)
+ bravais = self._get_bravais_lattice(
+ spg_symbol, lattice_type, a, b, c, unique
+ )
self._kpath = self._get_bradcrack_data(bravais)
@staticmethod
@@ -111,7 +118,7 @@
Source code for sumo.symmetry.brad_crack_kpath
'path': [['\Gamma', 'X', ..., 'P'], ['H', 'N', ...]]}
"""
- json_file = pkg_resources.resource_filename(__name__, "bradcrack.json")
+ json_file = os.path.join(ilr_files("sumo.symmetry"), "bradcrack.json")
with open(json_file) as f:
bradcrack_data = load_json(f)
return bradcrack_data[bravais]
diff --git a/index.html b/index.html
index eddde797..a6228cbd 100644
--- a/index.html
+++ b/index.html
@@ -80,13 +80,13 @@
Sumo¶
Usage¶
Sumo is intended to be used via the command-line, however, a
fully-documented python API is also provided. A manual, including
-tutorials and API documentation, is available online. Additionally, the built-in
+tutorials and API documentation, is available online. Additionally, the built-in
help (-h
) option for each command provides a summary of the
available options.
A guide to using each command can be found on the
-Tutorial page.
+Tutorial page.
For a preview of the functionality of sumo, see the
-Gallery.
+Gallery.
Currently, the scripts provided are:
sumo-kgen
: For generating VASP KPOINTS files along high-symmetry
@@ -103,7 +103,7 @@
Usage¶
from a band structure.
Information on how to tweak the style of sumo plots is provided on the
-Customising Sumo Plots page.
+Customising Sumo Plots page.
Feature support for different codes¶