Skip to content

"NoneType object is not subscriptable" error when trying to plot a band structure #230

@RemiLacroix-IDRIS

Description

@RemiLacroix-IDRIS

Hello,

One of our users is trying to plot a band structure using Abipy:

from abipy.abilab import abiopen
import abipy.data as abidata

filename="big_GSR.nc"

with abiopen(filename) as ncfile:
    ebands = ncfile.ebands

ebands.plot(with_gaps=True, title="Band structure", show=False, savefig="bands.png")

ebands.kpoints.plot(show=False, savefig="kpoints.png")

This works for most inputs but he is getting an error with the big_GSR.nc file attached:

~/.conda/envs/abipy/lib/python3.7/site-packages/pymatgen/symmetry/kpath.py:180: UserWarning: The input structure does not match the expected standard primitive! The path can be incorrect. Use at your own risk.
  "The input structure does not match the expected standard primitive! "
Traceback (most recent call last):
  File "plot_ebands_user.py", line 9, in <module>
    ebands.plot(with_gaps=True, title="Silicon band structure", show=False, savefig="bands.png")
  File "~/.conda/envs/abipy/lib/python3.7/site-packages/pymatgen/util/plotting.py", line 573, in wrapper
    fig = func(*args, **kwargs)
  File "~/.conda/envs/abipy/lib/python3.7/site-packages/abipy/electrons/ebands.py", line 1967, in plot
    self.decorate_ax(ax, klabels=klabels)
  File "~/.conda/envs/abipy/lib/python3.7/site-packages/abipy/electrons/ebands.py", line 2256, in decorate_ax
    ticks, labels = self._make_ticks_and_labels(klabels)
  File "~/.conda/envs/abipy/lib/python3.7/site-packages/abipy/electrons/ebands.py", line 2410, in _make_ticks_and_labels
    d = self._auto_klabels
  File "~/.conda/envs/abipy/lib/python3.7/site-packages/monty/functools.py", line 238, in __get__
    value = self.__func(inst)
  File "~/.conda/envs/abipy/lib/python3.7/site-packages/abipy/electrons/ebands.py", line 560, in _auto_klabels
    name = kpoint.name if kpoint.name is not None else self.structure.findname_in_hsym_stars(kpoint)
  File "~/.conda/envs/abipy/lib/python3.7/site-packages/abipy/core/structure.py", line 1185, in findname_in_hsym_stars
    for star in self.hsym_stars:
  File "~/.conda/envs/abipy/lib/python3.7/site-packages/monty/functools.py", line 238, in __get__
    value = self.__func(inst)
  File "~/.conda/envs/abipy/lib/python3.7/site-packages/abipy/core/structure.py", line 1152, in hsym_stars
    return [kpoint.compute_star(self.abi_spacegroup.fm_symmops) for kpoint in self.hsym_kpoints]
  File "~/.conda/envs/abipy/lib/python3.7/site-packages/monty/functools.py", line 238, in __get__
    value = self.__func(inst)
  File "~/.conda/envs/abipy/lib/python3.7/site-packages/abipy/core/structure.py", line 1105, in hsym_kpoints
    name2frac_coords = self.hsym_kpath.kpath["kpoints"]
TypeError: 'NoneType' object is not subscriptable

The warning at the beginning might be relevant but it also appears for other input files for which the plots are successfully generated.

Best regards,
Rémi Lacroix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions